diff --git a/.gitignore b/.gitignore index 52e7c505e..2be738494 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,15 @@ -# Nazara build -build/config.lua +# xmake-related files +.xmake +CMakeLists.txt +Makefile +vs/* +vsxmake*/* # Nazara binaries bin/* # Build files -build/gmake*/ -build/vs*/ +build/* # Nazara libraries lib/* diff --git a/include/Nazara/Audio/OpenAL.hpp b/include/Nazara/Audio/OpenAL.hpp index d3a88974a..d60a1261c 100644 --- a/include/Nazara/Audio/OpenAL.hpp +++ b/include/Nazara/Audio/OpenAL.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_OPENAL_HPP #define NAZARA_OPENAL_HPP -#ifdef NAZARA_AUDIO_OPENAL +#if defined(NAZARA_AUDIO_OPENAL) || defined(NAZARA_AUDIO_BUILD) #include #include diff --git a/src/Nazara/Utility/Formats/FreeTypeLoader.cpp b/src/Nazara/Utility/Formats/FreeTypeLoader.cpp index b98b3cdf4..a05d9c599 100644 --- a/src/Nazara/Utility/Formats/FreeTypeLoader.cpp +++ b/src/Nazara/Utility/Formats/FreeTypeLoader.cpp @@ -3,7 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include +#include #include FT_FREETYPE_H #include FT_BITMAP_H #include FT_STROKER_H diff --git a/thirdparty/build/chipmunk.lua b/thirdparty/build/chipmunk.lua deleted file mode 100644 index 7331be7ca..000000000 --- a/thirdparty/build/chipmunk.lua +++ /dev/null @@ -1,21 +0,0 @@ -LIBRARY.Name = "chipmunk" - -LIBRARY.Defines = { - "CP_USE_CGTYPES=0", - "DRAW_CLOSEST=0", - "DRAW_EPA=0", - "DRAW_GJK=0", - "TARGET_IPHONE_SIMULATOR=0", - "TARGET_OS_IPHONE=0", - "TARGET_OS_MAC=0", -} - -LIBRARY.Language = "C++" -LIBRARY.DisableWarnings = true -- chipmunk has many warnings we can't really fix - -LIBRARY.Files = { - "../thirdparty/include/chipmunk/*.h", - "../thirdparty/src/chipmunk/*.h", - "../thirdparty/src/chipmunk/*.c", -} - diff --git a/thirdparty/build/lua.lua b/thirdparty/build/lua.lua deleted file mode 100644 index df66e0127..000000000 --- a/thirdparty/build/lua.lua +++ /dev/null @@ -1,14 +0,0 @@ -LIBRARY.Name = "lua" - -LIBRARY.Language = "C++" -- Compile as C++ to make Lua use exceptions instead of SJLJ - -LIBRARY.Files = { - "../thirdparty/include/Lua/*.h", - "../thirdparty/include/Lua/*.hpp", - "../thirdparty/src/Lua/*.h", - "../thirdparty/src/Lua/*.cpp" -} - -LIBRARY.OsDefines.Posix = { - "LUA_USE_LINUX" -} diff --git a/thirdparty/build/lua.txt b/thirdparty/build/lua.txt deleted file mode 100644 index 972aa049f..000000000 --- a/thirdparty/build/lua.txt +++ /dev/null @@ -1,95 +0,0 @@ -Changement: -----------------------------Erreurs via exceptions----------------------------- -Remplacement de l'extension de tous les fichiers .c en .cpp - ----------------------------------Compatibilité--------------------------------- --Dans tous les fichiers: - Remplacement des lignes: - #include "lauxlib.h" - #include "lua.h" - #include "luaconf.h" - #include "lualib.h" - - Par les lignes: - #include - #include - #include - #include - ----------------------Support des commentaires longs du C++---------------------- --Fichier llex.cpp (Aux alentours de la ligne 468) -static int llex (LexState *ls, SemInfo *seminfo) { -+#if defined(LUA_CPPCOMT_LONG) -+ int last; -+#endif - luaZ_resetbuffer(ls->buff); - for (;;) { --Fichier llex.cpp (Aux alentours de la ligne 530): - case '/': { - next(ls); - if (check_next1(ls, '/')) return TK_IDIV; -+#if defined(LUA_CPPCOMT_LONG) -+ /* bn 01/2012: added C++-style comments */ -+ /* Lynix 02/2015: Fixed it for Lua 5.3.0 */ -+ else if (check_next1('*')) { -+ last = 0; -+ while (ls->current != EOZ) { -+ if (last == '*' && ls->current == '/') break; -+ last = ls->current; -+ next(ls); /* skip until closing marker (or end of file) */ -+ } -+ if (ls->current == EOZ) -+ lexerror(ls, "unfinished long comment", TK_EOS); -+ else next(ls); -+ } -+#endif /* LUA_CPPCOMT_LONG */ - else return '/'; - } - --Fichier llex.h (Aux alentours de la ligne 20): - -+/* bn 01/2012: added C++-style comments */ -+#define LUA_CPPCOMT_LONG -+/* end changes */ -+ - /* - * WARNING: if you change the order of this enumeration, - * grep "ORDER RESERVED" - ----------------------Support de la négation du C/C++ (!=)---------------------- --Fichier llex.h (Aux alentours de la ligne 15): -+#define LUA_CPPNEG - - /* - * WARNING: if you change the order of this enumeration, - * grep "ORDER RESERVED" --Fichier llex.h (Aux alentours de la ligne 37) - TK_SHL, TK_SHR, - TK_DBCOLON, TK_EOS, -+#ifdef LUA_CPPNEG -+ TK_CNE, -+#endif - TK_FLT, TK_INT, TK_NAME, TK_STRING - --Fichier llex.cpp (Aux alentours de la ligne 44) - "//", "..", "...", "==", ">=", "<=", "~=", - "<<", ">>", "::", "", -+#ifdef LUA_CPPNEG -+ "!=", -+#endif - "", "", "", "" --Fichier llex.cpp (Aux alentours de la ligne 556) - if (check_next1(ls, '/')) return TK_IDIV; - else return '/'; - } -+#ifdef LUA_CPPNEG -+ case '!': { -+ next(ls); -+ if (check_next1(ls, '=')) return TK_NE; -+ else return '!'; -+ } -+#endif - case '~': { - next(ls); - if (check_next1(ls, '=')) return TK_NE; - diff --git a/thirdparty/build/newton.lua b/thirdparty/build/newton.lua deleted file mode 100644 index 1c5bb8995..000000000 --- a/thirdparty/build/newton.lua +++ /dev/null @@ -1,42 +0,0 @@ -LIBRARY.Name = "newton" - -LIBRARY.Defines = { - "_CRT_SECURE_NO_WARNINGS", - "_NEWTON_STATIC_LIB", -} - -LIBRARY.OsDefines.Windows = { - "_WINDOWS" -} - -LIBRARY.Language = "C++" -LIBRARY.DisableWarnings = true -- Newton has many warnings we can't really fix - -LIBRARY.Files = { - "../thirdparty/include/newton/**.h", - "../thirdparty/src/newton/**.h", - "../thirdparty/src/newton/**.c", - "../thirdparty/src/newton/**.cpp", -} - -LIBRARY.Includes = { - "../thirdparty/src/newton/dgCore", - "../thirdparty/src/newton/dgMeshUtil", - "../thirdparty/src/newton/dgPhysics", - "../thirdparty/src/newton/dgNewton", - "../thirdparty/src/newton/dContainers", - "../thirdparty/src/newton/dMath" -} - -LIBRARY.Custom = function() - vectorextensions("SSE3") - - filter({"architecture:x86_64", "system:linux"}) - defines("_POSIX_VER_64") - - filter({"architecture:x86", "system:linux"}) - defines("_POSIX_VER") - - filter({"architecture:x86_64", "system:macosx"}) - defines("_MACOSX_VER") -end diff --git a/thirdparty/build/stb.lua b/thirdparty/build/stb.lua deleted file mode 100644 index c73cc6c41..000000000 --- a/thirdparty/build/stb.lua +++ /dev/null @@ -1,12 +0,0 @@ -LIBRARY.Name = "stb_image" - -LIBRARY.Defines = { - "STBI_NO_STDIO" -} - -LIBRARY.Language = "C++" -- Compile as C++ because C99 isn't widely supported - -LIBRARY.Files = { - "../thirdparty/include/stb/*.h", - "../thirdparty/src/stb/*.cpp" -} diff --git a/thirdparty/include/Newton/Newton.h b/thirdparty/include/Newton/Newton.h deleted file mode 100644 index 4e409b34b..000000000 --- a/thirdparty/include/Newton/Newton.h +++ /dev/null @@ -1,1322 +0,0 @@ -/* Copyright (c) <2003-2019> -* -* 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 __NEWTON_H__ -#define __NEWTON_H__ - - -#define NEWTON_MAJOR_VERSION 3 -#define NEWTON_MINOR_VERSION 14 - -#include - -#ifdef _NEWTON_STATIC_LIB - #define NEWTON_API DG_LIBRARY_STATIC -#elif defined(_NEWTON_BUILD_DLL) - #define NEWTON_API DG_LIBRARY_EXPORT -#else - #define NEWTON_API DG_LIBRARY_IMPORT -#endif - - -#ifndef dLong - #define dLong long long -#endif - -#ifndef dFloat - #ifdef _NEWTON_USE_DOUBLE - #define dFloat double - #else - #define dFloat float - #endif -#endif - -#ifndef dFloat32 - #define dFloat32 float -#endif - -#ifndef dFloat64 - #define dFloat64 double -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - #define NEWTON_BROADPHASE_DEFAULT 0 - #define NEWTON_BROADPHASE_PERSINTENT 1 - - #define NEWTON_DYNAMIC_BODY 0 - #define NEWTON_KINEMATIC_BODY 1 - #define NEWTON_DYNAMIC_ASYMETRIC_BODY 2 -// #define NEWTON_DEFORMABLE_BODY 2 - - #define SERIALIZE_ID_SPHERE 0 - #define SERIALIZE_ID_CAPSULE 1 - #define SERIALIZE_ID_CYLINDER 2 - #define SERIALIZE_ID_CHAMFERCYLINDER 3 - #define SERIALIZE_ID_BOX 4 - #define SERIALIZE_ID_CONE 5 - #define SERIALIZE_ID_CONVEXHULL 6 - #define SERIALIZE_ID_NULL 7 - #define SERIALIZE_ID_COMPOUND 8 - #define SERIALIZE_ID_TREE 9 - #define SERIALIZE_ID_HEIGHTFIELD 10 - #define SERIALIZE_ID_CLOTH_PATCH 11 - #define SERIALIZE_ID_DEFORMABLE_SOLID 12 - #define SERIALIZE_ID_USERMESH 13 - #define SERIALIZE_ID_SCENE 14 - #define SERIALIZE_ID_FRACTURED_COMPOUND 15 - -#ifdef __cplusplus - class NewtonMesh; - class NewtonBody; - class NewtonWorld; - class NewtonJoint; - class NewtonMaterial; - class NewtonCollision; - class NewtonDeformableMeshSegment; - class NewtonFracturedCompoundMeshPart; -#else - typedef struct NewtonMesh{} NewtonMesh; - typedef struct NewtonBody{} NewtonBody; - typedef struct NewtonWorld{} NewtonWorld; - typedef struct NewtonJoint{} NewtonJoint; - typedef struct NewtonMaterial{} NewtonMaterial; - typedef struct NewtonCollision{} NewtonCollision; - typedef struct NewtonDeformableMeshSegment{} NewtonDeformableMeshSegment; - typedef struct NewtonFracturedCompoundMeshPart{} NewtonFracturedCompoundMeshPart; -#endif - - typedef union - { - void* m_ptr; - dLong m_int; - dFloat m_float; - } NewtonMaterialData; - - typedef struct NewtonCollisionMaterial - { - dLong m_userId; - NewtonMaterialData m_userData; - NewtonMaterialData m_userParam[6]; - } NewtonCollisionMaterial; - - typedef struct NewtonBoxParam - { - dFloat m_x; - dFloat m_y; - dFloat m_z; - } NewtonBoxParam; - - typedef struct NewtonSphereParam - { - dFloat m_radio; - } NewtonSphereParam; - - - typedef struct NewtonCapsuleParam - { - dFloat m_radio0; - dFloat m_radio1; - dFloat m_height; - } NewtonCapsuleParam; - - typedef struct NewtonCylinderParam - { - dFloat m_radio0; - dFloat m_radio1; - dFloat m_height; - } NewtonCylinderParam; - - typedef struct NewtonConeParam - { - dFloat m_radio; - dFloat m_height; - } NewtonConeParam; - - typedef struct NewtonChamferCylinderParam - { - dFloat m_radio; - dFloat m_height; - } NewtonChamferCylinderParam; - - typedef struct NewtonConvexHullParam - { - int m_vertexCount; - int m_vertexStrideInBytes; - int m_faceCount; - dFloat* m_vertex; - } NewtonConvexHullParam; - - typedef struct NewtonCompoundCollisionParam - { - int m_chidrenCount; - } NewtonCompoundCollisionParam; - - typedef struct NewtonCollisionTreeParam - { - int m_vertexCount; - int m_indexCount; - } NewtonCollisionTreeParam; - - typedef struct NewtonDeformableMeshParam - { - int m_vertexCount; - int m_triangleCount; - int m_vrtexStrideInBytes; - unsigned short *m_indexList; - dFloat *m_vertexList; - } NewtonDeformableMeshParam; - - typedef struct NewtonHeightFieldCollisionParam - { - int m_width; - int m_height; - int m_gridsDiagonals; - int m_elevationDataType; // 0 = 32 bit floats, 1 = unsigned 16 bit integers - dFloat m_verticalScale; - dFloat m_horizonalScale_x; - dFloat m_horizonalScale_z; - void* m_vertialElevation; - char* m_atributes; - } NewtonHeightFieldCollisionParam; - - typedef struct NewtonSceneCollisionParam - { - int m_childrenProxyCount; - } NewtonSceneCollisionParam; - - typedef struct NewtonCollisionInfoRecord - { - dFloat m_offsetMatrix[4][4]; - NewtonCollisionMaterial m_collisionMaterial; - int m_collisionType; // tag id to identify the collision primitive - union { - NewtonBoxParam m_box; - NewtonConeParam m_cone; - NewtonSphereParam m_sphere; - NewtonCapsuleParam m_capsule; - NewtonCylinderParam m_cylinder; - NewtonChamferCylinderParam m_chamferCylinder; - NewtonConvexHullParam m_convexHull; - NewtonDeformableMeshParam m_deformableMesh; - NewtonCompoundCollisionParam m_compoundCollision; - NewtonCollisionTreeParam m_collisionTree; - NewtonHeightFieldCollisionParam m_heightField; - NewtonSceneCollisionParam m_sceneCollision; - dFloat m_paramArray[64]; // user define collision can use this to store information - }; - } NewtonCollisionInfoRecord; - - typedef struct NewtonJointRecord - { - dFloat m_attachmenMatrix_0[4][4]; - dFloat m_attachmenMatrix_1[4][4]; - dFloat m_minLinearDof[3]; - dFloat m_maxLinearDof[3]; - dFloat m_minAngularDof[3]; - dFloat m_maxAngularDof[3]; - const NewtonBody* m_attachBody_0; - const NewtonBody* m_attachBody_1; - dFloat m_extraParameters[64]; - int m_bodiesCollisionOn; - char m_descriptionType[128]; - } NewtonJointRecord; - - typedef struct NewtonUserMeshCollisionCollideDesc - { - dFloat m_boxP0[4]; // lower bounding box of intersection query in local space - dFloat m_boxP1[4]; // upper bounding box of intersection query in local space - dFloat m_boxDistanceTravel[4]; // max distance that box bpxP0 and boxP1 can travel on this timestep, used this for continue collision mode. - int m_threadNumber; // current thread executing this query - int m_faceCount; // the application should set here how many polygons intersect the query box - int m_vertexStrideInBytes; // the application should set here the size of each vertex - dFloat m_skinThickness; // this is the minimum skin separation specified by the material between these two colliding shapes - void* m_userData; // user data passed to the collision geometry at creation time - - NewtonBody* m_objBody; // pointer to the colliding body - NewtonBody* m_polySoupBody; // pointer to the rigid body owner of this collision tree - NewtonCollision* m_objCollision; // collision shape of the colliding body, (no necessarily the collision of m_objBody) - NewtonCollision* m_polySoupCollision; // collision shape of the collision tree, (no necessarily the collision of m_polySoupBody) - - dFloat* m_vertex; // the application should set here the pointer to the global vertex of the mesh. - int* m_faceIndexCount; // the application should set here the pointer to the vertex count of each face. - int* m_faceVertexIndex; // the application should set here the pointer index array for each vertex on a face. - // the format of a face is I0, I1, I2, I3, ..., M, N, E0, E1, E2, ..., A - // I0, I1, I2, .. are the indices to the vertex, relative to m_vertex pointer - // M is the index to the material sub shape id - // N in the index to the vertex normal relative to m_vertex pointer - // E0, E1, E2, ... are the indices of the the face normal that is shared to that face edge, when the edge does not share a face normal then the edge index is set to index N, which the index to the face normal - // A is and estimate of the largest diagonal of the face, this used internally as a hint to improve floating point accuracy and algorithm performance. - } NewtonUserMeshCollisionCollideDesc; - - typedef struct NewtonWorldConvexCastReturnInfo - { - dFloat m_point[4]; // collision point in global space - dFloat m_normal[4]; // surface normal at collision point in global space - //dFloat m_normalOnHitPoint[4]; // surface normal at the surface of the hit body, - // is the same as the normal calculated by a ray cast hitting the body at the hit point - dLong m_contactID; // collision ID at contact point - const NewtonBody* m_hitBody; // body hit at contact point - dFloat m_penetration; // contact penetration at collision point - } NewtonWorldConvexCastReturnInfo; - - typedef struct NewtonUserMeshCollisionRayHitDesc - { - dFloat m_p0[4]; // ray origin in collision local space - dFloat m_p1[4]; // ray destination in collision local space - dFloat m_normalOut[4]; // copy here the normal at the ray intersection - dLong m_userIdOut; // copy here a user defined id for further feedback - void* m_userData; // user data passed to the collision geometry at creation time - } NewtonUserMeshCollisionRayHitDesc; - - typedef struct NewtonHingeSliderUpdateDesc - { - dFloat m_accel; - dFloat m_minFriction; - dFloat m_maxFriction; - dFloat m_timestep; - } NewtonHingeSliderUpdateDesc; - - typedef struct NewtonUserContactPoint - { - dFloat m_point[4]; - dFloat m_normal[4]; - dLong m_shapeId0; - dLong m_shapeId1; - dFloat m_penetration; - int m_unused[3]; - } NewtonUserContactPoint; - - - typedef struct NewtonImmediateModeConstraint - { - dFloat m_jacobian01[8][6]; - dFloat m_jacobian10[8][6]; - dFloat m_minFriction[8]; - dFloat m_maxFriction[8]; - dFloat m_jointAccel[8]; - dFloat m_jointStiffness[8]; - } NewtonConstraintDescriptor; - - - // data structure for interfacing with NewtonMesh - typedef struct NewtonMeshDoubleData - { - dFloat64* m_data; - int* m_indexList; - int m_strideInBytes; - } NewtonMeshDoubleData; - - typedef struct NewtonMeshFloatData - { - dFloat* m_data; - int* m_indexList; - int m_strideInBytes; - } NewtonMeshFloatData; - - typedef struct NewtonMeshVertexFormat - { - int m_faceCount; - int* m_faceIndexCount; - int* m_faceMaterial; - NewtonMeshDoubleData m_vertex; - NewtonMeshFloatData m_normal; - NewtonMeshFloatData m_binormal; - NewtonMeshFloatData m_uv0; - NewtonMeshFloatData m_uv1; - NewtonMeshFloatData m_vertexColor; - } NewtonMeshVertexFormat; - - // Newton callback functions - typedef void* (*NewtonAllocMemory) (int sizeInBytes); - typedef void (*NewtonFreeMemory) (void* const ptr, int sizeInBytes); - - typedef void (*NewtonWorldDestructorCallback) (const NewtonWorld* const world); - typedef void (*NewtonPostUpdateCallback) (const NewtonWorld* const world, dFloat timestep); - - typedef void(*NewtonCreateContactCallback) (const NewtonWorld* const newtonWorld, NewtonJoint* const contact); - typedef void(*NewtonDestroyContactCallback) (const NewtonWorld* const newtonWorld, NewtonJoint* const contact); - - typedef void (*NewtonWorldListenerDebugCallback) (const NewtonWorld* const world, void* const listener, void* const debugContext); - typedef void (*NewtonWorldListenerBodyDestroyCallback) (const NewtonWorld* const world, void* const listenerUserData, NewtonBody* const body); - typedef void (*NewtonWorldUpdateListenerCallback) (const NewtonWorld* const world, void* const listenerUserData, dFloat timestep); - typedef void (*NewtonWorldDestroyListenerCallback) (const NewtonWorld* const world, void* const listenerUserData); - - typedef dLong (*NewtonGetTimeInMicrosencondsCallback) (); - - typedef void (*NewtonSerializeCallback) (void* const serializeHandle, const void* const buffer, int size); - typedef void (*NewtonDeserializeCallback) (void* const serializeHandle, void* const buffer, int size); - - typedef void (*NewtonOnBodySerializationCallback) (NewtonBody* const body, void* const userData, NewtonSerializeCallback function, void* const serializeHandle); - typedef void (*NewtonOnBodyDeserializationCallback) (NewtonBody* const body, void* const userData, NewtonDeserializeCallback function, void* const serializeHandle); - - typedef void (*NewtonOnJointSerializationCallback) (const NewtonJoint* const joint, NewtonSerializeCallback function, void* const serializeHandle); - typedef void (*NewtonOnJointDeserializationCallback) (NewtonBody* const body0, NewtonBody* const body1, NewtonDeserializeCallback function, void* const serializeHandle); - - typedef void (*NewtonOnUserCollisionSerializationCallback) (void* const userData, NewtonSerializeCallback function, void* const serializeHandle); - - // user collision callbacks - typedef void (*NewtonUserMeshCollisionDestroyCallback) (void* const userData); - typedef dFloat (*NewtonUserMeshCollisionRayHitCallback) (NewtonUserMeshCollisionRayHitDesc* const lineDescData); - typedef void (*NewtonUserMeshCollisionGetCollisionInfo) (void* const userData, NewtonCollisionInfoRecord* const infoRecord); - typedef int (*NewtonUserMeshCollisionAABBTest) (void* const userData, const dFloat* const boxP0, const dFloat* const boxP1); - typedef int (*NewtonUserMeshCollisionGetFacesInAABB) (void* const userData, const dFloat* const p0, const dFloat* const p1, - const dFloat** const vertexArray, int* const vertexCount, int* const vertexStrideInBytes, - const int* const indexList, int maxIndexCount, const int* const userDataList); - typedef void (*NewtonUserMeshCollisionCollideCallback) (NewtonUserMeshCollisionCollideDesc* const collideDescData, const void* const continueCollisionHandle); - - typedef int (*NewtonTreeCollisionFaceCallback) (void* const context, const dFloat* const polygon, int strideInBytes, const int* const indexArray, int indexCount); - - typedef dFloat (*NewtonCollisionTreeRayCastCallback) (const NewtonBody* const body, const NewtonCollision* const treeCollision, dFloat intersection, dFloat* const normal, int faceId, void* const usedData); - typedef dFloat (*NewtonHeightFieldRayCastCallback) (const NewtonBody* const body, const NewtonCollision* const heightFieldCollision, dFloat intersection, int row, int col, dFloat* const normal, int faceId, void* const usedData); - - typedef void (*NewtonCollisionCopyConstructionCallback) (const NewtonWorld* const newtonWorld, NewtonCollision* const collision, const NewtonCollision* const sourceCollision); - typedef void (*NewtonCollisionDestructorCallback) (const NewtonWorld* const newtonWorld, const NewtonCollision* const collision); - - // collision tree call back (obsoleted no recommended) - typedef void (*NewtonTreeCollisionCallback) (const NewtonBody* const bodyWithTreeCollision, const NewtonBody* const body, int faceID, - int vertexCount, const dFloat* const vertex, int vertexStrideInBytes); - - typedef void (*NewtonBodyDestructor) (const NewtonBody* const body); - typedef void (*NewtonApplyForceAndTorque) (const NewtonBody* const body, dFloat timestep, int threadIndex); - typedef void (*NewtonSetTransform) (const NewtonBody* const body, const dFloat* const matrix, int threadIndex); - - typedef int (*NewtonIslandUpdate) (const NewtonWorld* const newtonWorld, const void* islandHandle, int bodyCount); - - typedef void (*NewtonFractureCompoundCollisionOnEmitCompoundFractured) (NewtonBody* const fracturedBody); - typedef void (*NewtonFractureCompoundCollisionOnEmitChunk) (NewtonBody* const chunkBody, NewtonFracturedCompoundMeshPart* const fracturexChunkMesh, const NewtonCollision* const fracturedCompountCollision); - typedef void (*NewtonFractureCompoundCollisionReconstructMainMeshCallBack) (NewtonBody* const body, NewtonFracturedCompoundMeshPart* const mainMesh, const NewtonCollision* const fracturedCompountCollision); - - typedef unsigned (*NewtonWorldRayPrefilterCallback)(const NewtonBody* const body, const NewtonCollision* const collision, void* const userData); - typedef dFloat (*NewtonWorldRayFilterCallback)(const NewtonBody* const body, const NewtonCollision* const shapeHit, const dFloat* const hitContact, const dFloat* const hitNormal, dLong collisionID, void* const userData, dFloat intersectParam); - - typedef int (*NewtonOnAABBOverlap) (const NewtonJoint* const contact, dFloat timestep, int threadIndex); - typedef void (*NewtonContactsProcess) (const NewtonJoint* const contact, dFloat timestep, int threadIndex); - typedef int (*NewtonOnCompoundSubCollisionAABBOverlap) (const NewtonJoint* const contact, dFloat timestep, const NewtonBody* const body0, const void* const collisionNode0, const NewtonBody* const body1, const void* const collisionNode1, int threadIndex); - typedef int (*NewtonOnContactGeneration) (const NewtonMaterial* const material, const NewtonBody* const body0, const NewtonCollision* const collision0, const NewtonBody* const body1, const NewtonCollision* const collision1, NewtonUserContactPoint* const contactBuffer, int maxCount, int threadIndex); - - typedef int (*NewtonBodyIterator) (const NewtonBody* const body, void* const userData); - typedef void (*NewtonJointIterator) (const NewtonJoint* const joint, void* const userData); - typedef void (*NewtonCollisionIterator) (void* const userData, int vertexCount, const dFloat* const faceArray, int faceId); - - typedef void (*NewtonBallCallback) (const NewtonJoint* const ball, dFloat timestep); - typedef unsigned (*NewtonHingeCallback) (const NewtonJoint* const hinge, NewtonHingeSliderUpdateDesc* const desc); - typedef unsigned (*NewtonSliderCallback) (const NewtonJoint* const slider, NewtonHingeSliderUpdateDesc* const desc); - typedef unsigned (*NewtonUniversalCallback) (const NewtonJoint* const universal, NewtonHingeSliderUpdateDesc* const desc); - typedef unsigned (*NewtonCorkscrewCallback) (const NewtonJoint* const corkscrew, NewtonHingeSliderUpdateDesc* const desc); - - typedef void (*NewtonUserBilateralCallback) (const NewtonJoint* const userJoint, dFloat timestep, int threadIndex); - typedef void (*NewtonUserBilateralGetInfoCallback) (const NewtonJoint* const userJoint, NewtonJointRecord* const info); - - typedef void (*NewtonConstraintDestructor) (const NewtonJoint* const me); - - typedef void (*NewtonJobTask) (NewtonWorld* const world, void* const userData, int threadIndex); - typedef int (*NewtonReportProgress) (dFloat normalizedProgressPercent, void* const userData); - - // ********************************************************************************************** - // - // world control functions - // - // ********************************************************************************************** - NEWTON_API int NewtonWorldGetVersion (); - NEWTON_API int NewtonWorldFloatSize (); - - NEWTON_API int NewtonGetMemoryUsed (); - NEWTON_API void NewtonSetMemorySystem (NewtonAllocMemory malloc, NewtonFreeMemory free); - - NEWTON_API NewtonWorld* NewtonCreate (); - NEWTON_API void NewtonDestroy (const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonDestroyAllBodies (const NewtonWorld* const newtonWorld); - - NEWTON_API NewtonPostUpdateCallback NewtonGetPostUpdateCallback(const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonSetPostUpdateCallback (const NewtonWorld* const newtonWorld, NewtonPostUpdateCallback callback); - - NEWTON_API void* NewtonAlloc (int sizeInBytes); - NEWTON_API void NewtonFree (void* const ptr); - - NEWTON_API void NewtonLoadPlugins(const NewtonWorld* const newtonWorld, const char* const plugInPath); - NEWTON_API void NewtonUnloadPlugins(const NewtonWorld* const newtonWorld); - NEWTON_API void* NewtonCurrentPlugin(const NewtonWorld* const newtonWorld); - NEWTON_API void* NewtonGetFirstPlugin(const NewtonWorld* const newtonWorld); - NEWTON_API void* NewtonGetPreferedPlugin(const NewtonWorld* const newtonWorld); - NEWTON_API void* NewtonGetNextPlugin(const NewtonWorld* const newtonWorld, const void* const plugin); - NEWTON_API const char* NewtonGetPluginString(const NewtonWorld* const newtonWorld, const void* const plugin); - NEWTON_API void NewtonSelectPlugin(const NewtonWorld* const newtonWorld, const void* const plugin); - - NEWTON_API dFloat NewtonGetContactMergeTolerance (const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonSetContactMergeTolerance (const NewtonWorld* const newtonWorld, dFloat tolerance); - - NEWTON_API void NewtonInvalidateCache (const NewtonWorld* const newtonWorld); - - NEWTON_API void NewtonSetSolverIterations (const NewtonWorld* const newtonWorld, int model); - NEWTON_API int NewtonGetSolverIterations(const NewtonWorld* const newtonWorld); - - NEWTON_API void NewtonSetParallelSolverOnLargeIsland (const NewtonWorld* const newtonWorld, int mode); - NEWTON_API int NewtonGetParallelSolverOnLargeIsland (const NewtonWorld* const newtonWorld); - - NEWTON_API int NewtonGetBroadphaseAlgorithm (const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonSelectBroadphaseAlgorithm (const NewtonWorld* const newtonWorld, int algorithmType); - NEWTON_API void NewtonResetBroadphase(const NewtonWorld* const newtonWorld); - - NEWTON_API void NewtonUpdate (const NewtonWorld* const newtonWorld, dFloat timestep); - NEWTON_API void NewtonUpdateAsync (const NewtonWorld* const newtonWorld, dFloat timestep); - NEWTON_API void NewtonWaitForUpdateToFinish (const NewtonWorld* const newtonWorld); - - NEWTON_API int NewtonGetNumberOfSubsteps (const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonSetNumberOfSubsteps (const NewtonWorld* const newtonWorld, int subSteps); - NEWTON_API dFloat NewtonGetLastUpdateTime (const NewtonWorld* const newtonWorld); - - NEWTON_API void NewtonSerializeToFile (const NewtonWorld* const newtonWorld, const char* const filename, NewtonOnBodySerializationCallback bodyCallback, void* const bodyUserData); - NEWTON_API void NewtonDeserializeFromFile (const NewtonWorld* const newtonWorld, const char* const filename, NewtonOnBodyDeserializationCallback bodyCallback, void* const bodyUserData); - - NEWTON_API void NewtonSerializeScene(const NewtonWorld* const newtonWorld, NewtonOnBodySerializationCallback bodyCallback, void* const bodyUserData, - NewtonSerializeCallback serializeCallback, void* const serializeHandle); - NEWTON_API void NewtonDeserializeScene(const NewtonWorld* const newtonWorld, NewtonOnBodyDeserializationCallback bodyCallback, void* const bodyUserData, - NewtonDeserializeCallback serializeCallback, void* const serializeHandle); - - NEWTON_API NewtonBody* NewtonFindSerializedBody(const NewtonWorld* const newtonWorld, int bodySerializedID); - NEWTON_API void NewtonSetJointSerializationCallbacks (const NewtonWorld* const newtonWorld, NewtonOnJointSerializationCallback serializeJoint, NewtonOnJointDeserializationCallback deserializeJoint); - NEWTON_API void NewtonGetJointSerializationCallbacks (const NewtonWorld* const newtonWorld, NewtonOnJointSerializationCallback* const serializeJoint, NewtonOnJointDeserializationCallback* const deserializeJoint); - - // multi threading interface - NEWTON_API void NewtonWorldCriticalSectionLock (const NewtonWorld* const newtonWorld, int threadIndex); - NEWTON_API void NewtonWorldCriticalSectionUnlock (const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonSetThreadsCount (const NewtonWorld* const newtonWorld, int threads); - NEWTON_API int NewtonGetThreadsCount(const NewtonWorld* const newtonWorld); - NEWTON_API int NewtonGetMaxThreadsCount(const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonDispachThreadJob(const NewtonWorld* const newtonWorld, NewtonJobTask task, void* const usedData, const char* const functionName); - NEWTON_API void NewtonSyncThreadJobs(const NewtonWorld* const newtonWorld); - - // atomic operations - NEWTON_API int NewtonAtomicAdd (int* const ptr, int value); - NEWTON_API int NewtonAtomicSwap (int* const ptr, int value); - NEWTON_API void NewtonYield (); - - NEWTON_API void NewtonSetIslandUpdateEvent (const NewtonWorld* const newtonWorld, NewtonIslandUpdate islandUpdate); - NEWTON_API void NewtonWorldForEachJointDo (const NewtonWorld* const newtonWorld, NewtonJointIterator callback, void* const userData); - NEWTON_API void NewtonWorldForEachBodyInAABBDo (const NewtonWorld* const newtonWorld, const dFloat* const p0, const dFloat* const p1, NewtonBodyIterator callback, void* const userData); - - NEWTON_API void NewtonWorldSetUserData (const NewtonWorld* const newtonWorld, void* const userData); - NEWTON_API void* NewtonWorldGetUserData (const NewtonWorld* const newtonWorld); - - NEWTON_API void* NewtonWorldAddListener (const NewtonWorld* const newtonWorld, const char* const nameId, void* const listenerUserData); - NEWTON_API void* NewtonWorldGetListener (const NewtonWorld* const newtonWorld, const char* const nameId); - - NEWTON_API void NewtonWorldListenerSetDebugCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldListenerDebugCallback callback); - NEWTON_API void NewtonWorldListenerSetPostStepCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldUpdateListenerCallback callback); - NEWTON_API void NewtonWorldListenerSetPreUpdateCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldUpdateListenerCallback callback); - NEWTON_API void NewtonWorldListenerSetPostUpdateCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldUpdateListenerCallback callback); - NEWTON_API void NewtonWorldListenerSetDestructorCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldDestroyListenerCallback callback); - NEWTON_API void NewtonWorldListenerSetBodyDestroyCallback(const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldListenerBodyDestroyCallback callback); - NEWTON_API void NewtonWorldListenerDebug(const NewtonWorld* const newtonWorld, void* const context); - NEWTON_API void* NewtonWorldGetListenerUserData(const NewtonWorld* const newtonWorld, void* const listener); - NEWTON_API NewtonWorldListenerBodyDestroyCallback NewtonWorldListenerGetBodyDestroyCallback (const NewtonWorld* const newtonWorld, void* const listener); - - NEWTON_API void NewtonWorldSetDestructorCallback (const NewtonWorld* const newtonWorld, NewtonWorldDestructorCallback destructor); - NEWTON_API NewtonWorldDestructorCallback NewtonWorldGetDestructorCallback (const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonWorldSetCollisionConstructorDestructorCallback (const NewtonWorld* const newtonWorld, NewtonCollisionCopyConstructionCallback constructor, NewtonCollisionDestructorCallback destructor); - - NEWTON_API void NewtonWorldSetCreateDestroyContactCallback(const NewtonWorld* const newtonWorld, NewtonCreateContactCallback createContact, NewtonDestroyContactCallback destroyContact); - - NEWTON_API void NewtonWorldRayCast (const NewtonWorld* const newtonWorld, const dFloat* const p0, const dFloat* const p1, NewtonWorldRayFilterCallback filter, void* const userData, NewtonWorldRayPrefilterCallback prefilter, int threadIndex); - NEWTON_API int NewtonWorldConvexCast (const NewtonWorld* const newtonWorld, const dFloat* const matrix, const dFloat* const target, const NewtonCollision* const shape, dFloat* const param, void* const userData, NewtonWorldRayPrefilterCallback prefilter, NewtonWorldConvexCastReturnInfo* const info, int maxContactsCount, int threadIndex); - NEWTON_API int NewtonWorldCollide (const NewtonWorld* const newtonWorld, const dFloat* const matrix, const NewtonCollision* const shape, void* const userData, NewtonWorldRayPrefilterCallback prefilter, NewtonWorldConvexCastReturnInfo* const info, int maxContactsCount, int threadIndex); - - // world utility functions - NEWTON_API int NewtonWorldGetBodyCount(const NewtonWorld* const newtonWorld); - NEWTON_API int NewtonWorldGetConstraintCount(const NewtonWorld* const newtonWorld); - - NEWTON_API NewtonJoint* NewtonWorldFindJoint(const NewtonBody* const body0, const NewtonBody* const body1); - - // ********************************************************************************************** - // - // Simulation islands - // - // ********************************************************************************************** - NEWTON_API NewtonBody* NewtonIslandGetBody (const void* const island, int bodyIndex); - NEWTON_API void NewtonIslandGetBodyAABB (const void* const island, int bodyIndex, dFloat* const p0, dFloat* const p1); - - // ********************************************************************************************** - // - // Physics Material Section - // - // ********************************************************************************************** - NEWTON_API int NewtonMaterialCreateGroupID(const NewtonWorld* const newtonWorld); - NEWTON_API int NewtonMaterialGetDefaultGroupID(const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonMaterialDestroyAllGroupID(const NewtonWorld* const newtonWorld); - - // material definitions that can not be overwritten in function callback - NEWTON_API void* NewtonMaterialGetUserData (const NewtonWorld* const newtonWorld, int id0, int id1); - NEWTON_API void NewtonMaterialSetSurfaceThickness (const NewtonWorld* const newtonWorld, int id0, int id1, dFloat thickness); - -// deprecated, not longer continue collision is set on the material -// NEWTON_API void NewtonMaterialSetContinuousCollisionMode (const NewtonWorld* const newtonWorld, int id0, int id1, int state); - - NEWTON_API void NewtonMaterialSetCallbackUserData (const NewtonWorld* const newtonWorld, int id0, int id1, void* const userData); - NEWTON_API void NewtonMaterialSetContactGenerationCallback (const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnContactGeneration contactGeneration); - NEWTON_API void NewtonMaterialSetCompoundCollisionCallback(const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnCompoundSubCollisionAABBOverlap compoundAabbOverlap); - NEWTON_API void NewtonMaterialSetCollisionCallback (const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnAABBOverlap aabbOverlap, NewtonContactsProcess process); - - NEWTON_API void NewtonMaterialSetDefaultSoftness (const NewtonWorld* const newtonWorld, int id0, int id1, dFloat value); - NEWTON_API void NewtonMaterialSetDefaultElasticity (const NewtonWorld* const newtonWorld, int id0, int id1, dFloat elasticCoef); - NEWTON_API void NewtonMaterialSetDefaultCollidable (const NewtonWorld* const newtonWorld, int id0, int id1, int state); - NEWTON_API void NewtonMaterialSetDefaultFriction (const NewtonWorld* const newtonWorld, int id0, int id1, dFloat staticFriction, dFloat kineticFriction); - - NEWTON_API void NewtonMaterialJointResetIntraJointCollision (const NewtonWorld* const newtonWorld, int id0, int id1); - NEWTON_API void NewtonMaterialJointResetSelftJointCollision (const NewtonWorld* const newtonWorld, int id0, int id1); - - NEWTON_API NewtonMaterial* NewtonWorldGetFirstMaterial (const NewtonWorld* const newtonWorld); - NEWTON_API NewtonMaterial* NewtonWorldGetNextMaterial (const NewtonWorld* const newtonWorld, const NewtonMaterial* const material); - - NEWTON_API NewtonBody* NewtonWorldGetFirstBody (const NewtonWorld* const newtonWorld); - NEWTON_API NewtonBody* NewtonWorldGetNextBody (const NewtonWorld* const newtonWorld, const NewtonBody* const curBody); - - - // ********************************************************************************************** - // - // Physics Contact control functions - // - // ********************************************************************************************** - NEWTON_API void *NewtonMaterialGetMaterialPairUserData (const NewtonMaterial* const material); - NEWTON_API unsigned NewtonMaterialGetContactFaceAttribute (const NewtonMaterial* const material); - NEWTON_API NewtonCollision* NewtonMaterialGetBodyCollidingShape (const NewtonMaterial* const material, const NewtonBody* const body); - NEWTON_API dFloat NewtonMaterialGetContactNormalSpeed (const NewtonMaterial* const material); - NEWTON_API void NewtonMaterialGetContactForce (const NewtonMaterial* const material, const NewtonBody* const body, dFloat* const force); - NEWTON_API void NewtonMaterialGetContactPositionAndNormal (const NewtonMaterial* const material, const NewtonBody* const body, dFloat* const posit, dFloat* const normal); - NEWTON_API void NewtonMaterialGetContactTangentDirections (const NewtonMaterial* const material, const NewtonBody* const body, dFloat* const dir0, dFloat* const dir1); - NEWTON_API dFloat NewtonMaterialGetContactTangentSpeed (const NewtonMaterial* const material, int index); - NEWTON_API dFloat NewtonMaterialGetContactMaxNormalImpact (const NewtonMaterial* const material); - NEWTON_API dFloat NewtonMaterialGetContactMaxTangentImpact (const NewtonMaterial* const material, int index); - NEWTON_API dFloat NewtonMaterialGetContactPenetration (const NewtonMaterial* const material); - NEWTON_API void NewtonMaterialSetAsSoftContact (const NewtonMaterial* const material, dFloat relaxation); - - NEWTON_API void NewtonMaterialSetContactSoftness (const NewtonMaterial* const material, dFloat softness); - NEWTON_API void NewtonMaterialSetContactThickness (const NewtonMaterial* const material, dFloat thickness); - NEWTON_API void NewtonMaterialSetContactElasticity (const NewtonMaterial* const material, dFloat restitution); - NEWTON_API void NewtonMaterialSetContactFrictionState (const NewtonMaterial* const material, int state, int index); - NEWTON_API void NewtonMaterialSetContactFrictionCoef (const NewtonMaterial* const material, dFloat staticFrictionCoef, dFloat kineticFrictionCoef, int index); - - NEWTON_API void NewtonMaterialSetContactNormalAcceleration (const NewtonMaterial* const material, dFloat accel); - NEWTON_API void NewtonMaterialSetContactNormalDirection (const NewtonMaterial* const material, const dFloat* const directionVector); - NEWTON_API void NewtonMaterialSetContactPosition (const NewtonMaterial* const material, const dFloat* const position); - - NEWTON_API void NewtonMaterialSetContactTangentFriction (const NewtonMaterial* const material, dFloat friction, int index); - NEWTON_API void NewtonMaterialSetContactTangentAcceleration (const NewtonMaterial* const material, dFloat accel, int index); - NEWTON_API void NewtonMaterialContactRotateTangentDirections (const NewtonMaterial* const material, const dFloat* const directionVector); - - //NEWTON_API dFloat NewtonMaterialGetContactPruningTolerance (const NewtonBody* const body0, const NewtonBody* const body1); - //NEWTON_API void NewtonMaterialSetContactPruningTolerance (const NewtonBody* const body0, const NewtonBody* const body1, dFloat tolerance); - NEWTON_API dFloat NewtonMaterialGetContactPruningTolerance(const NewtonJoint* const contactJoint); - NEWTON_API void NewtonMaterialSetContactPruningTolerance(const NewtonJoint* const contactJoint, dFloat tolerance); - - // ********************************************************************************************** - // - // convex collision primitives creation functions - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateNull (const NewtonWorld* const newtonWorld); - NEWTON_API NewtonCollision* NewtonCreateSphere (const NewtonWorld* const newtonWorld, dFloat radius, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateBox (const NewtonWorld* const newtonWorld, dFloat dx, dFloat dy, dFloat dz, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateCone (const NewtonWorld* const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateCapsule (const NewtonWorld* const newtonWorld, dFloat radius0, dFloat radius1, dFloat height, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateCylinder (const NewtonWorld* const newtonWorld, dFloat radio0, dFloat radio1, dFloat height, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateChamferCylinder (const NewtonWorld* const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateConvexHull (const NewtonWorld* const newtonWorld, int count, const dFloat* const vertexCloud, int strideInBytes, dFloat tolerance, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateConvexHullFromMesh (const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, dFloat tolerance, int shapeID); - - NEWTON_API int NewtonCollisionGetMode(const NewtonCollision* const convexCollision); - NEWTON_API void NewtonCollisionSetMode (const NewtonCollision* const convexCollision, int mode); - - NEWTON_API int NewtonConvexHullGetFaceIndices (const NewtonCollision* const convexHullCollision, int face, int* const faceIndices); - NEWTON_API int NewtonConvexHullGetVertexData (const NewtonCollision* const convexHullCollision, dFloat** const vertexData, int* strideInBytes); - - NEWTON_API dFloat NewtonConvexCollisionCalculateVolume (const NewtonCollision* const convexCollision); - NEWTON_API void NewtonConvexCollisionCalculateInertialMatrix (const NewtonCollision* convexCollision, dFloat* const inertia, dFloat* const origin); - NEWTON_API dFloat NewtonConvexCollisionCalculateBuoyancyVolume (const NewtonCollision* const convexCollision, const dFloat* const matrix, const dFloat* const fluidPlane, dFloat* const centerOfBuoyancy); - - NEWTON_API const void* NewtonCollisionDataPointer (const NewtonCollision* const convexCollision); - - // ********************************************************************************************** - // - // compound collision primitives creation functions - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateCompoundCollision (const NewtonWorld* const newtonWorld, int shapeID); - NEWTON_API NewtonCollision* NewtonCreateCompoundCollisionFromMesh (const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, dFloat hullTolerance, int shapeID, int subShapeID); - - NEWTON_API void NewtonCompoundCollisionBeginAddRemove (NewtonCollision* const compoundCollision); - NEWTON_API void* NewtonCompoundCollisionAddSubCollision (NewtonCollision* const compoundCollision, const NewtonCollision* const convexCollision); - NEWTON_API void NewtonCompoundCollisionRemoveSubCollision (NewtonCollision* const compoundCollision, const void* const collisionNode); - NEWTON_API void NewtonCompoundCollisionRemoveSubCollisionByIndex (NewtonCollision* const compoundCollision, int nodeIndex); - NEWTON_API void NewtonCompoundCollisionSetSubCollisionMatrix (NewtonCollision* const compoundCollision, const void* const collisionNode, const dFloat* const matrix); - NEWTON_API void NewtonCompoundCollisionEndAddRemove (NewtonCollision* const compoundCollision); - - NEWTON_API void* NewtonCompoundCollisionGetFirstNode (NewtonCollision* const compoundCollision); - NEWTON_API void* NewtonCompoundCollisionGetNextNode (NewtonCollision* const compoundCollision, const void* const collisionNode); - - NEWTON_API void* NewtonCompoundCollisionGetNodeByIndex (NewtonCollision* const compoundCollision, int index); - NEWTON_API int NewtonCompoundCollisionGetNodeIndex (NewtonCollision* const compoundCollision, const void* const collisionNode); - NEWTON_API NewtonCollision* NewtonCompoundCollisionGetCollisionFromNode (NewtonCollision* const compoundCollision, const void* const collisionNode); - - - // ********************************************************************************************** - // - // Fractured compound collision primitives interface - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateFracturedCompoundCollision (const NewtonWorld* const newtonWorld, const NewtonMesh* const solidMesh, int shapeID, int fracturePhysicsMaterialID, int pointcloudCount, const dFloat* const vertexCloud, int strideInBytes, int materialID, const dFloat* const textureMatrix, - NewtonFractureCompoundCollisionReconstructMainMeshCallBack regenerateMainMeshCallback, - NewtonFractureCompoundCollisionOnEmitCompoundFractured emitFracturedCompound, NewtonFractureCompoundCollisionOnEmitChunk emitFracfuredChunk); - NEWTON_API NewtonCollision* NewtonFracturedCompoundPlaneClip (const NewtonCollision* const fracturedCompound, const dFloat* const plane); - - NEWTON_API void NewtonFracturedCompoundSetCallbacks (const NewtonCollision* const fracturedCompound, NewtonFractureCompoundCollisionReconstructMainMeshCallBack regenerateMainMeshCallback, - NewtonFractureCompoundCollisionOnEmitCompoundFractured emitFracturedCompound, NewtonFractureCompoundCollisionOnEmitChunk emitFracfuredChunk); - - - NEWTON_API int NewtonFracturedCompoundIsNodeFreeToDetach (const NewtonCollision* const fracturedCompound, void* const collisionNode); - NEWTON_API int NewtonFracturedCompoundNeighborNodeList (const NewtonCollision* const fracturedCompound, void* const collisionNode, void** const list, int maxCount); - - - NEWTON_API NewtonFracturedCompoundMeshPart* NewtonFracturedCompoundGetMainMesh (const NewtonCollision* const fracturedCompound); - NEWTON_API NewtonFracturedCompoundMeshPart* NewtonFracturedCompoundGetFirstSubMesh(const NewtonCollision* const fracturedCompound); - NEWTON_API NewtonFracturedCompoundMeshPart* NewtonFracturedCompoundGetNextSubMesh(const NewtonCollision* const fracturedCompound, NewtonFracturedCompoundMeshPart* const subMesh); - - NEWTON_API int NewtonFracturedCompoundCollisionGetVertexCount (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner); - NEWTON_API const dFloat* NewtonFracturedCompoundCollisionGetVertexPositions (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner); - NEWTON_API const dFloat* NewtonFracturedCompoundCollisionGetVertexNormals (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner); - NEWTON_API const dFloat* NewtonFracturedCompoundCollisionGetVertexUVs (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner); - NEWTON_API int NewtonFracturedCompoundMeshPartGetIndexStream (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner, const void* const segment, int* const index); - - NEWTON_API void* NewtonFracturedCompoundMeshPartGetFirstSegment (const NewtonFracturedCompoundMeshPart* const fractureCompoundMeshPart); - NEWTON_API void* NewtonFracturedCompoundMeshPartGetNextSegment (const void* const fractureCompoundMeshSegment); - NEWTON_API int NewtonFracturedCompoundMeshPartGetMaterial (const void* const fractureCompoundMeshSegment); - NEWTON_API int NewtonFracturedCompoundMeshPartGetIndexCount (const void* const fractureCompoundMeshSegment); - - - // ********************************************************************************************** - // - // scene collision are static compound collision that can take polygonal static collisions - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateSceneCollision (const NewtonWorld* const newtonWorld, int shapeID); - - NEWTON_API void NewtonSceneCollisionBeginAddRemove (NewtonCollision* const sceneCollision); - NEWTON_API void* NewtonSceneCollisionAddSubCollision (NewtonCollision* const sceneCollision, const NewtonCollision* const collision); - NEWTON_API void NewtonSceneCollisionRemoveSubCollision (NewtonCollision* const compoundCollision, const void* const collisionNode); - NEWTON_API void NewtonSceneCollisionRemoveSubCollisionByIndex (NewtonCollision* const sceneCollision, int nodeIndex); - NEWTON_API void NewtonSceneCollisionSetSubCollisionMatrix (NewtonCollision* const sceneCollision, const void* const collisionNode, const dFloat* const matrix); - NEWTON_API void NewtonSceneCollisionEndAddRemove (NewtonCollision* const sceneCollision); - - NEWTON_API void* NewtonSceneCollisionGetFirstNode (NewtonCollision* const sceneCollision); - NEWTON_API void* NewtonSceneCollisionGetNextNode (NewtonCollision* const sceneCollision, const void* const collisionNode); - - NEWTON_API void* NewtonSceneCollisionGetNodeByIndex (NewtonCollision* const sceneCollision, int index); - NEWTON_API int NewtonSceneCollisionGetNodeIndex (NewtonCollision* const sceneCollision, const void* const collisionNode); - NEWTON_API NewtonCollision* NewtonSceneCollisionGetCollisionFromNode (NewtonCollision* const sceneCollision, const void* const collisionNode); - - - // *********************************************************************************************************** - // - // User Static mesh collision interface - // - // *********************************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateUserMeshCollision (const NewtonWorld* const newtonWorld, const dFloat* const minBox, - const dFloat* const maxBox, void* const userData, NewtonUserMeshCollisionCollideCallback collideCallback, - NewtonUserMeshCollisionRayHitCallback rayHitCallback, NewtonUserMeshCollisionDestroyCallback destroyCallback, - NewtonUserMeshCollisionGetCollisionInfo getInfoCallback, NewtonUserMeshCollisionAABBTest getLocalAABBCallback, - NewtonUserMeshCollisionGetFacesInAABB facesInAABBCallback, NewtonOnUserCollisionSerializationCallback serializeCallback, int shapeID); - - NEWTON_API int NewtonUserMeshCollisionContinuousOverlapTest (const NewtonUserMeshCollisionCollideDesc* const collideDescData, const void* const continueCollisionHandle, const dFloat* const minAabb, const dFloat* const maxAabb); - - // *********************************************************************************************************** - // - // Collision serialization functions - // - // *********************************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateCollisionFromSerialization (const NewtonWorld* const newtonWorld, NewtonDeserializeCallback deserializeFunction, void* const serializeHandle); - NEWTON_API void NewtonCollisionSerialize (const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, NewtonSerializeCallback serializeFunction, void* const serializeHandle); - NEWTON_API void NewtonCollisionGetInfo (const NewtonCollision* const collision, NewtonCollisionInfoRecord* const collisionInfo); - - // ********************************************************************************************** - // - // Static collision shapes functions - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateHeightFieldCollision (const NewtonWorld* const newtonWorld, int width, int height, int gridsDiagonals, int elevationdatType, const void* const elevationMap, const char* const attributeMap, dFloat verticalScale, dFloat horizontalScale_x, dFloat horizontalScale_z, int shapeID); - NEWTON_API void NewtonHeightFieldSetUserRayCastCallback (const NewtonCollision* const heightfieldCollision, NewtonHeightFieldRayCastCallback rayHitCallback); - - NEWTON_API NewtonCollision* NewtonCreateTreeCollision (const NewtonWorld* const newtonWorld, int shapeID); - NEWTON_API NewtonCollision* NewtonCreateTreeCollisionFromMesh (const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, int shapeID); - NEWTON_API void NewtonTreeCollisionSetUserRayCastCallback (const NewtonCollision* const treeCollision, NewtonCollisionTreeRayCastCallback rayHitCallback); - - NEWTON_API void NewtonTreeCollisionBeginBuild (const NewtonCollision* const treeCollision); - NEWTON_API void NewtonTreeCollisionAddFace (const NewtonCollision* const treeCollision, int vertexCount, const dFloat* const vertexPtr, int strideInBytes, int faceAttribute); - NEWTON_API void NewtonTreeCollisionEndBuild (const NewtonCollision* const treeCollision, int optimize); - - NEWTON_API int NewtonTreeCollisionGetFaceAttribute (const NewtonCollision* const treeCollision, const int* const faceIndexArray, int indexCount); - NEWTON_API void NewtonTreeCollisionSetFaceAttribute (const NewtonCollision* const treeCollision, const int* const faceIndexArray, int indexCount, int attribute); - - NEWTON_API void NewtonTreeCollisionForEachFace (const NewtonCollision* const treeCollision, NewtonTreeCollisionFaceCallback forEachFaceCallback, void* const context); - - NEWTON_API int NewtonTreeCollisionGetVertexListTriangleListInAABB (const NewtonCollision* const treeCollision, const dFloat* const p0, const dFloat* const p1, const dFloat** const vertexArray, int* const vertexCount, int* const vertexStrideInBytes, const int* const indexList, int maxIndexCount, const int* const faceAttribute); - - NEWTON_API void NewtonStaticCollisionSetDebugCallback (const NewtonCollision* const staticCollision, NewtonTreeCollisionCallback userCallback); - - // ********************************************************************************************** - // - // General purpose collision library functions - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCollisionCreateInstance (const NewtonCollision* const collision); - NEWTON_API int NewtonCollisionGetType (const NewtonCollision* const collision); - NEWTON_API int NewtonCollisionIsConvexShape (const NewtonCollision* const collision); - NEWTON_API int NewtonCollisionIsStaticShape (const NewtonCollision* const collision); - - // for the end user - NEWTON_API void NewtonCollisionSetUserData (const NewtonCollision* const collision, void* const userData); - NEWTON_API void* NewtonCollisionGetUserData (const NewtonCollision* const collision); - - NEWTON_API void NewtonCollisionSetUserID (const NewtonCollision* const collision, dLong id); - NEWTON_API dLong NewtonCollisionGetUserID (const NewtonCollision* const collision); - - NEWTON_API void NewtonCollisionGetMaterial (const NewtonCollision* const collision, NewtonCollisionMaterial* const userData); - NEWTON_API void NewtonCollisionSetMaterial (const NewtonCollision* const collision, const NewtonCollisionMaterial* const userData); - - NEWTON_API void* NewtonCollisionGetSubCollisionHandle (const NewtonCollision* const collision); - NEWTON_API NewtonCollision* NewtonCollisionGetParentInstance (const NewtonCollision* const collision); - - NEWTON_API void NewtonCollisionSetMatrix (const NewtonCollision* const collision, const dFloat* const matrix); - NEWTON_API void NewtonCollisionGetMatrix (const NewtonCollision* const collision, dFloat* const matrix); - - NEWTON_API void NewtonCollisionSetScale (const NewtonCollision* const collision, dFloat scaleX, dFloat scaleY, dFloat scaleZ); - NEWTON_API void NewtonCollisionGetScale (const NewtonCollision* const collision, dFloat* const scaleX, dFloat* const scaleY, dFloat* const scaleZ); - NEWTON_API void NewtonDestroyCollision (const NewtonCollision* const collision); - - NEWTON_API dFloat NewtonCollisionGetSkinThickness (const NewtonCollision* const collision); - NEWTON_API void NewtonCollisionSetSkinThickness(const NewtonCollision* const collision, dFloat thickness); - - NEWTON_API int NewtonCollisionIntersectionTest (const NewtonWorld* const newtonWorld, - const NewtonCollision* const collisionA, const dFloat* const matrixA, - const NewtonCollision* const collisionB, const dFloat* const matrixB, int threadIndex); - - NEWTON_API int NewtonCollisionPointDistance (const NewtonWorld* const newtonWorld, const dFloat* const point, - const NewtonCollision* const collision, const dFloat* const matrix, dFloat* const contact, dFloat* const normal, int threadIndex); - - NEWTON_API int NewtonCollisionClosestPoint (const NewtonWorld* const newtonWorld, - const NewtonCollision* const collisionA, const dFloat* const matrixA, - const NewtonCollision* const collisionB, const dFloat* const matrixB, - dFloat* const contactA, dFloat* const contactB, dFloat* const normalAB, int threadIndex); - - NEWTON_API int NewtonCollisionCollide (const NewtonWorld* const newtonWorld, int maxSize, - const NewtonCollision* const collisionA, const dFloat* const matrixA, - const NewtonCollision* const collisionB, const dFloat* const matrixB, - dFloat* const contacts, dFloat* const normals, dFloat* const penetration, - dLong* const attributeA, dLong* const attributeB, int threadIndex); - - NEWTON_API int NewtonCollisionCollideContinue (const NewtonWorld* const newtonWorld, int maxSize, dFloat timestep, - const NewtonCollision* const collisionA, const dFloat* const matrixA, const dFloat* const velocA, const dFloat* omegaA, - const NewtonCollision* const collisionB, const dFloat* const matrixB, const dFloat* const velocB, const dFloat* const omegaB, - dFloat* const timeOfImpact, dFloat* const contacts, dFloat* const normals, dFloat* const penetration, - dLong* const attributeA, dLong* const attributeB, int threadIndex); - - NEWTON_API void NewtonCollisionSupportVertex (const NewtonCollision* const collision, const dFloat* const dir, dFloat* const vertex); - NEWTON_API dFloat NewtonCollisionRayCast (const NewtonCollision* const collision, const dFloat* const p0, const dFloat* const p1, dFloat* const normal, dLong* const attribute); - NEWTON_API void NewtonCollisionCalculateAABB (const NewtonCollision* const collision, const dFloat* const matrix, dFloat* const p0, dFloat* const p1); - NEWTON_API void NewtonCollisionForEachPolygonDo (const NewtonCollision* const collision, const dFloat* const matrix, NewtonCollisionIterator callback, void* const userData); - - // ********************************************************************************************** - // - // collision aggregates, are a collision node on eh broad phase the serve as the root nod for a collection of rigid bodies - // that shared the property of being in close proximity all the time, they are similar to compound collision by the group bodies instead of collision instances - // These are good for speeding calculation calculation of rag doll, Vehicles or contractions of rigid bodied lined by joints. - // also for example if you know that many the life time of a group of bodies like the object on a house of a building will be localize to the confide of the building - // then warping the bodies under an aggregate will reduce collision calculation of almost an order of magnitude. - // - // ********************************************************************************************** - NEWTON_API void* NewtonCollisionAggregateCreate (NewtonWorld* const world); - NEWTON_API void NewtonCollisionAggregateDestroy (void* const aggregate); - NEWTON_API void NewtonCollisionAggregateAddBody (void* const aggregate, const NewtonBody* const body); - NEWTON_API void NewtonCollisionAggregateRemoveBody (void* const aggregate, const NewtonBody* const body); - - NEWTON_API int NewtonCollisionAggregateGetSelfCollision (void* const aggregate); - NEWTON_API void NewtonCollisionAggregateSetSelfCollision (void* const aggregate, int state); - - // ********************************************************************************************** - // - // transforms utility functions - // - // ********************************************************************************************** - NEWTON_API void NewtonSetEulerAngle (const dFloat* const eulersAngles, dFloat* const matrix); - NEWTON_API void NewtonGetEulerAngle (const dFloat* const matrix, dFloat* const eulersAngles0, dFloat* const eulersAngles1); - NEWTON_API dFloat NewtonCalculateSpringDamperAcceleration (dFloat dt, dFloat ks, dFloat x, dFloat kd, dFloat s); - - // ********************************************************************************************** - // - // body manipulation functions - // - // ********************************************************************************************** - NEWTON_API NewtonBody* NewtonCreateDynamicBody (const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, const dFloat* const matrix); - NEWTON_API NewtonBody* NewtonCreateKinematicBody (const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, const dFloat* const matrix); - NEWTON_API NewtonBody* NewtonCreateAsymetricDynamicBody(const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, const dFloat* const matrix); - - NEWTON_API void NewtonDestroyBody(const NewtonBody* const body); - - NEWTON_API int NewtonBodyGetSimulationState(const NewtonBody* const body); - NEWTON_API void NewtonBodySetSimulationState(const NewtonBody* const bodyPtr, const int state); - - NEWTON_API int NewtonBodyGetType (const NewtonBody* const body); - NEWTON_API int NewtonBodyGetCollidable (const NewtonBody* const body); - NEWTON_API void NewtonBodySetCollidable (const NewtonBody* const body, int collidableState); - - NEWTON_API void NewtonBodyAddForce (const NewtonBody* const body, const dFloat* const force); - NEWTON_API void NewtonBodyAddTorque (const NewtonBody* const body, const dFloat* const torque); - - NEWTON_API void NewtonBodySetCentreOfMass (const NewtonBody* const body, const dFloat* const com); - NEWTON_API void NewtonBodySetMassMatrix (const NewtonBody* const body, dFloat mass, dFloat Ixx, dFloat Iyy, dFloat Izz); - NEWTON_API void NewtonBodySetFullMassMatrix (const NewtonBody* const body, dFloat mass, const dFloat* const inertiaMatrix); - - NEWTON_API void NewtonBodySetMassProperties (const NewtonBody* const body, dFloat mass, const NewtonCollision* const collision); - NEWTON_API void NewtonBodySetMatrix (const NewtonBody* const body, const dFloat* const matrix); - NEWTON_API void NewtonBodySetMatrixNoSleep (const NewtonBody* const body, const dFloat* const matrix); - NEWTON_API void NewtonBodySetMatrixRecursive (const NewtonBody* const body, const dFloat* const matrix); - - NEWTON_API void NewtonBodySetMaterialGroupID (const NewtonBody* const body, int id); - NEWTON_API void NewtonBodySetContinuousCollisionMode (const NewtonBody* const body, unsigned state); - NEWTON_API void NewtonBodySetJointRecursiveCollision (const NewtonBody* const body, unsigned state); - NEWTON_API void NewtonBodySetOmega (const NewtonBody* const body, const dFloat* const omega); - NEWTON_API void NewtonBodySetOmegaNoSleep (const NewtonBody* const body, const dFloat* const omega); - NEWTON_API void NewtonBodySetVelocity (const NewtonBody* const body, const dFloat* const velocity); - NEWTON_API void NewtonBodySetVelocityNoSleep (const NewtonBody* const body, const dFloat* const velocity); - NEWTON_API void NewtonBodySetForce (const NewtonBody* const body, const dFloat* const force); - NEWTON_API void NewtonBodySetTorque (const NewtonBody* const body, const dFloat* const torque); - - NEWTON_API void NewtonBodySetLinearDamping (const NewtonBody* const body, dFloat linearDamp); - NEWTON_API void NewtonBodySetAngularDamping (const NewtonBody* const body, const dFloat* const angularDamp); - NEWTON_API void NewtonBodySetCollision (const NewtonBody* const body, const NewtonCollision* const collision); - NEWTON_API void NewtonBodySetCollisionScale (const NewtonBody* const body, dFloat scaleX, dFloat scaleY, dFloat scaleZ); - - NEWTON_API int NewtonBodyGetSleepState (const NewtonBody* const body); - NEWTON_API void NewtonBodySetSleepState (const NewtonBody* const body, int state); - - NEWTON_API int NewtonBodyGetAutoSleep (const NewtonBody* const body); - NEWTON_API void NewtonBodySetAutoSleep (const NewtonBody* const body, int state); - - NEWTON_API int NewtonBodyGetFreezeState(const NewtonBody* const body); - NEWTON_API void NewtonBodySetFreezeState (const NewtonBody* const body, int state); - - NEWTON_API int NewtonBodyGetGyroscopicTorque(const NewtonBody* const body); - NEWTON_API void NewtonBodySetGyroscopicTorque(const NewtonBody* const body, int state); - - NEWTON_API void NewtonBodySetDestructorCallback (const NewtonBody* const body, NewtonBodyDestructor callback); - NEWTON_API NewtonBodyDestructor NewtonBodyGetDestructorCallback (const NewtonBody* const body); - - NEWTON_API void NewtonBodySetTransformCallback (const NewtonBody* const body, NewtonSetTransform callback); - NEWTON_API NewtonSetTransform NewtonBodyGetTransformCallback (const NewtonBody* const body); - - NEWTON_API void NewtonBodySetForceAndTorqueCallback (const NewtonBody* const body, NewtonApplyForceAndTorque callback); - NEWTON_API NewtonApplyForceAndTorque NewtonBodyGetForceAndTorqueCallback (const NewtonBody* const body); - - NEWTON_API int NewtonBodyGetID (const NewtonBody* const body); - - NEWTON_API void NewtonBodySetUserData (const NewtonBody* const body, void* const userData); - NEWTON_API void* NewtonBodyGetUserData (const NewtonBody* const body); - - NEWTON_API NewtonWorld* NewtonBodyGetWorld (const NewtonBody* const body); - NEWTON_API NewtonCollision* NewtonBodyGetCollision (const NewtonBody* const body); - NEWTON_API int NewtonBodyGetMaterialGroupID (const NewtonBody* const body); - - NEWTON_API int NewtonBodyGetSerializedID(const NewtonBody* const body); - NEWTON_API int NewtonBodyGetContinuousCollisionMode (const NewtonBody* const body); - NEWTON_API int NewtonBodyGetJointRecursiveCollision (const NewtonBody* const body); - - NEWTON_API void NewtonBodyGetPosition(const NewtonBody* const body, dFloat* const pos); - NEWTON_API void NewtonBodyGetMatrix(const NewtonBody* const body, dFloat* const matrix); - NEWTON_API void NewtonBodyGetRotation(const NewtonBody* const body, dFloat* const rotation); - NEWTON_API void NewtonBodyGetMass (const NewtonBody* const body, dFloat* mass, dFloat* const Ixx, dFloat* const Iyy, dFloat* const Izz); - NEWTON_API void NewtonBodyGetInvMass(const NewtonBody* const body, dFloat* const invMass, dFloat* const invIxx, dFloat* const invIyy, dFloat* const invIzz); - NEWTON_API void NewtonBodyGetInertiaMatrix(const NewtonBody* const body, dFloat* const inertiaMatrix); - NEWTON_API void NewtonBodyGetInvInertiaMatrix(const NewtonBody* const body, dFloat* const invInertiaMatrix); - NEWTON_API void NewtonBodyGetOmega(const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetVelocity(const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetAlpha(const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetAcceleration(const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetForce(const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetTorque(const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetCentreOfMass (const NewtonBody* const body, dFloat* const com); - NEWTON_API void NewtonBodyGetPointVelocity (const NewtonBody* const body, const dFloat* const point, dFloat* const velocOut); - - NEWTON_API void NewtonBodyApplyImpulsePair (const NewtonBody* const body, dFloat* const linearImpulse, dFloat* const angularImpulse, dFloat timestep); - NEWTON_API void NewtonBodyAddImpulse (const NewtonBody* const body, const dFloat* const pointDeltaVeloc, const dFloat* const pointPosit, dFloat timestep); - NEWTON_API void NewtonBodyApplyImpulseArray (const NewtonBody* const body, int impuleCount, int strideInByte, const dFloat* const impulseArray, const dFloat* const pointArray, dFloat timestep); - - NEWTON_API void NewtonBodyIntegrateVelocity (const NewtonBody* const body, dFloat timestep); - - NEWTON_API dFloat NewtonBodyGetLinearDamping (const NewtonBody* const body); - NEWTON_API void NewtonBodyGetAngularDamping (const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetAABB (const NewtonBody* const body, dFloat* const p0, dFloat* const p1); - - NEWTON_API NewtonJoint* NewtonBodyGetFirstJoint (const NewtonBody* const body); - NEWTON_API NewtonJoint* NewtonBodyGetNextJoint (const NewtonBody* const body, const NewtonJoint* const joint); - - NEWTON_API NewtonJoint* NewtonBodyGetFirstContactJoint (const NewtonBody* const body); - NEWTON_API NewtonJoint* NewtonBodyGetNextContactJoint (const NewtonBody* const body, const NewtonJoint* const contactJoint); - NEWTON_API NewtonJoint* NewtonBodyFindContact (const NewtonBody* const body0, const NewtonBody* const body1); - - // ********************************************************************************************** - // - // contact joints interface - // - // ********************************************************************************************** - NEWTON_API void* NewtonContactJointGetFirstContact (const NewtonJoint* const contactJoint); - NEWTON_API void* NewtonContactJointGetNextContact (const NewtonJoint* const contactJoint, void* const contact); - - NEWTON_API int NewtonContactJointGetContactCount(const NewtonJoint* const contactJoint); - NEWTON_API void NewtonContactJointRemoveContact(const NewtonJoint* const contactJoint, void* const contact); - - NEWTON_API dFloat NewtonContactJointGetClosestDistance(const NewtonJoint* const contactJoint); - NEWTON_API void NewtonContactJointResetSelftJointCollision(const NewtonJoint* const contactJoint); - NEWTON_API void NewtonContactJointResetIntraJointCollision(const NewtonJoint* const contactJoint); - - NEWTON_API NewtonMaterial* NewtonContactGetMaterial (const void* const contact); - - NEWTON_API NewtonCollision* NewtonContactGetCollision0 (const void* const contact); - NEWTON_API NewtonCollision* NewtonContactGetCollision1 (const void* const contact); - - NEWTON_API void* NewtonContactGetCollisionID0 (const void* const contact); - NEWTON_API void* NewtonContactGetCollisionID1 (const void* const contact); - - - // ********************************************************************************************** - // - // Common joint functions - // - // ********************************************************************************************** - NEWTON_API void* NewtonJointGetUserData (const NewtonJoint* const joint); - NEWTON_API void NewtonJointSetUserData (const NewtonJoint* const joint, void* const userData); - - NEWTON_API NewtonBody* NewtonJointGetBody0 (const NewtonJoint* const joint); - NEWTON_API NewtonBody* NewtonJointGetBody1 (const NewtonJoint* const joint); - - NEWTON_API void NewtonJointGetInfo (const NewtonJoint* const joint, NewtonJointRecord* const info); - NEWTON_API int NewtonJointGetCollisionState (const NewtonJoint* const joint); - NEWTON_API void NewtonJointSetCollisionState (const NewtonJoint* const joint, int state); - - NEWTON_API dFloat NewtonJointGetStiffness (const NewtonJoint* const joint); - NEWTON_API void NewtonJointSetStiffness (const NewtonJoint* const joint, dFloat state); - - NEWTON_API void NewtonDestroyJoint(const NewtonWorld* const newtonWorld, const NewtonJoint* const joint); - NEWTON_API void NewtonJointSetDestructor (const NewtonJoint* const joint, NewtonConstraintDestructor destructor); - - NEWTON_API int NewtonJointIsActive (const NewtonJoint* const joint); - - // ********************************************************************************************** - // - // particle system interface (soft bodies, individual, pressure bodies and cloth) - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateMassSpringDamperSystem (const NewtonWorld* const newtonWorld, int shapeID, - const dFloat* const points, int pointCount, int strideInBytes, const dFloat* const pointMass, - const int* const links, int linksCount, const dFloat* const linksSpring, const dFloat* const linksDamper); - - NEWTON_API NewtonCollision* NewtonCreateDeformableSolid(const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, int shapeID); - - NEWTON_API int NewtonDeformableMeshGetParticleCount (const NewtonCollision* const deformableMesh); - NEWTON_API int NewtonDeformableMeshGetParticleStrideInBytes (const NewtonCollision* const deformableMesh); - NEWTON_API const dFloat* NewtonDeformableMeshGetParticleArray (const NewtonCollision* const deformableMesh); - -/* - NEWTON_API NewtonCollision* NewtonCreateClothPatch (const NewtonWorld* const newtonWorld, NewtonMesh* const mesh, int shapeID, NewtonClothPatchMaterial* const structuralMaterial, NewtonClothPatchMaterial* const bendMaterial); - NEWTON_API void NewtonDeformableMeshCreateClusters (NewtonCollision* const deformableMesh, int clusterCount, dFloat overlapingWidth); - NEWTON_API void NewtonDeformableMeshSetDebugCallback (NewtonCollision* const deformableMesh, NewtonCollisionIterator callback); - - - NEWTON_API void NewtonDeformableMeshGetParticlePosition (NewtonCollision* const deformableMesh, int particleIndex, dFloat* const posit); - - NEWTON_API void NewtonDeformableMeshBeginConfiguration (const NewtonCollision* const deformableMesh); - NEWTON_API void NewtonDeformableMeshUnconstraintParticle (NewtonCollision* const deformableMesh, int particleIndex); - NEWTON_API void NewtonDeformableMeshConstraintParticle (NewtonCollision* const deformableMesh, int particleIndex, const dFloat* const posit, const NewtonBody* const body); - NEWTON_API void NewtonDeformableMeshEndConfiguration (const NewtonCollision* const deformableMesh); - -// NEWTON_API void NewtonDeformableMeshSetPlasticity (NewtonCollision* const deformableMesh, dFloat plasticity); -// NEWTON_API void NewtonDeformableMeshSetStiffness (NewtonCollision* const deformableMesh, dFloat stiffness); - NEWTON_API void NewtonDeformableMeshSetSkinThickness (NewtonCollision* const deformableMesh, dFloat skinThickness); - - NEWTON_API void NewtonDeformableMeshUpdateRenderNormals (const NewtonCollision* const deformableMesh); - NEWTON_API int NewtonDeformableMeshGetVertexCount (const NewtonCollision* const deformableMesh); - NEWTON_API void NewtonDeformableMeshGetVertexStreams (const NewtonCollision* const deformableMesh, int vertexStrideInByte, dFloat* const vertex, int normalStrideInByte, dFloat* const normal, int uvStrideInByte0, dFloat* const uv0); - NEWTON_API NewtonDeformableMeshSegment* NewtonDeformableMeshGetFirstSegment (const NewtonCollision* const deformableMesh); - NEWTON_API NewtonDeformableMeshSegment* NewtonDeformableMeshGetNextSegment (const NewtonCollision* const deformableMesh, const NewtonDeformableMeshSegment* const segment); - - NEWTON_API int NewtonDeformableMeshSegmentGetMaterialID (const NewtonCollision* const deformableMesh, const NewtonDeformableMeshSegment* const segment); - NEWTON_API int NewtonDeformableMeshSegmentGetIndexCount (const NewtonCollision* const deformableMesh, const NewtonDeformableMeshSegment* const segment); - NEWTON_API const int* NewtonDeformableMeshSegmentGetIndexList (const NewtonCollision* const deformableMesh, const NewtonDeformableMeshSegment* const segment); -*/ - // ********************************************************************************************** - // - // Ball and Socket joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateBall (const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, const NewtonBody* const childBody, const NewtonBody* const parentBody); - NEWTON_API void NewtonBallSetUserCallback (const NewtonJoint* const ball, NewtonBallCallback callback); - NEWTON_API void NewtonBallGetJointAngle (const NewtonJoint* const ball, dFloat* angle); - NEWTON_API void NewtonBallGetJointOmega (const NewtonJoint* const ball, dFloat* omega); - NEWTON_API void NewtonBallGetJointForce (const NewtonJoint* const ball, dFloat* const force); - NEWTON_API void NewtonBallSetConeLimits (const NewtonJoint* const ball, const dFloat* pin, dFloat maxConeAngle, dFloat maxTwistAngle); - - // ********************************************************************************************** - // - // Hinge joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateHinge (const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir, const NewtonBody* const childBody, const NewtonBody* const parentBody); - NEWTON_API void NewtonHingeSetUserCallback (const NewtonJoint* const hinge, NewtonHingeCallback callback); - NEWTON_API dFloat NewtonHingeGetJointAngle (const NewtonJoint* const hinge); - NEWTON_API dFloat NewtonHingeGetJointOmega (const NewtonJoint* const hinge); - NEWTON_API void NewtonHingeGetJointForce (const NewtonJoint* const hinge, dFloat* const force); - NEWTON_API dFloat NewtonHingeCalculateStopAlpha (const NewtonJoint* const hinge, const NewtonHingeSliderUpdateDesc* const desc, dFloat angle); - - // ********************************************************************************************** - // - // Slider joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateSlider (const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir, const NewtonBody* const childBody, const NewtonBody* const parentBody); - NEWTON_API void NewtonSliderSetUserCallback (const NewtonJoint* const slider, NewtonSliderCallback callback); - NEWTON_API dFloat NewtonSliderGetJointPosit (const NewtonJoint* slider); - NEWTON_API dFloat NewtonSliderGetJointVeloc (const NewtonJoint* slider); - NEWTON_API void NewtonSliderGetJointForce (const NewtonJoint* const slider, dFloat* const force); - NEWTON_API dFloat NewtonSliderCalculateStopAccel (const NewtonJoint* const slider, const NewtonHingeSliderUpdateDesc* const desc, dFloat position); - - - // ********************************************************************************************** - // - // Corkscrew joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateCorkscrew (const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir, const NewtonBody* const childBody, const NewtonBody* const parentBody); - NEWTON_API void NewtonCorkscrewSetUserCallback (const NewtonJoint* const corkscrew, NewtonCorkscrewCallback callback); - NEWTON_API dFloat NewtonCorkscrewGetJointPosit (const NewtonJoint* const corkscrew); - NEWTON_API dFloat NewtonCorkscrewGetJointAngle (const NewtonJoint* const corkscrew); - NEWTON_API dFloat NewtonCorkscrewGetJointVeloc (const NewtonJoint* const corkscrew); - NEWTON_API dFloat NewtonCorkscrewGetJointOmega (const NewtonJoint* const corkscrew); - NEWTON_API void NewtonCorkscrewGetJointForce (const NewtonJoint* const corkscrew, dFloat* const force); - NEWTON_API dFloat NewtonCorkscrewCalculateStopAlpha (const NewtonJoint* const corkscrew, const NewtonHingeSliderUpdateDesc* const desc, dFloat angle); - NEWTON_API dFloat NewtonCorkscrewCalculateStopAccel (const NewtonJoint* const corkscrew, const NewtonHingeSliderUpdateDesc* const desc, dFloat position); - - - // ********************************************************************************************** - // - // Universal joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateUniversal (const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir0, const dFloat* pinDir1, const NewtonBody* const childBody, const NewtonBody* const parentBody); - NEWTON_API void NewtonUniversalSetUserCallback (const NewtonJoint* const universal, NewtonUniversalCallback callback); - NEWTON_API dFloat NewtonUniversalGetJointAngle0 (const NewtonJoint* const universal); - NEWTON_API dFloat NewtonUniversalGetJointAngle1 (const NewtonJoint* const universal); - NEWTON_API dFloat NewtonUniversalGetJointOmega0 (const NewtonJoint* const universal); - NEWTON_API dFloat NewtonUniversalGetJointOmega1 (const NewtonJoint* const universal); - NEWTON_API void NewtonUniversalGetJointForce (const NewtonJoint* const universal, dFloat* const force); - NEWTON_API dFloat NewtonUniversalCalculateStopAlpha0 (const NewtonJoint* const universal, const NewtonHingeSliderUpdateDesc* const desc, dFloat angle); - NEWTON_API dFloat NewtonUniversalCalculateStopAlpha1 (const NewtonJoint* const universal, const NewtonHingeSliderUpdateDesc* const desc, dFloat angle); - - - // ********************************************************************************************** - // - // Up vector joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateUpVector (const NewtonWorld* const newtonWorld, const dFloat* pinDir, const NewtonBody* const body); - NEWTON_API void NewtonUpVectorGetPin (const NewtonJoint* const upVector, dFloat *pin); - NEWTON_API void NewtonUpVectorSetPin (const NewtonJoint* const upVector, const dFloat *pin); - - - // ********************************************************************************************** - // - // User defined bilateral Joint - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateUserJoint (const NewtonWorld* const newtonWorld, int maxDOF, NewtonUserBilateralCallback callback, const NewtonBody* const childBody, const NewtonBody* const parentBody) ; - NEWTON_API int NewtonUserJointGetSolverModel(const NewtonJoint* const joint); - NEWTON_API void NewtonUserJointSetSolverModel(const NewtonJoint* const joint, int model); - NEWTON_API void NewtonUserJointMassScale(const NewtonJoint* const joint, dFloat scaleBody0, dFloat scaleBody1); - - NEWTON_API void NewtonUserJointSetFeedbackCollectorCallback (const NewtonJoint* const joint, NewtonUserBilateralCallback getFeedback); - NEWTON_API void NewtonUserJointAddLinearRow (const NewtonJoint* const joint, const dFloat* const pivot0, const dFloat* const pivot1, const dFloat* const dir); - NEWTON_API void NewtonUserJointAddAngularRow (const NewtonJoint* const joint, dFloat relativeAngle, const dFloat* const dir); - NEWTON_API void NewtonUserJointAddGeneralRow (const NewtonJoint* const joint, const dFloat* const jacobian0, const dFloat* const jacobian1); - NEWTON_API void NewtonUserJointSetRowMinimumFriction (const NewtonJoint* const joint, dFloat friction); - NEWTON_API void NewtonUserJointSetRowMaximumFriction (const NewtonJoint* const joint, dFloat friction); - NEWTON_API dFloat NewtonUserJointCalculateRowZeroAcceleration (const NewtonJoint* const joint); - NEWTON_API dFloat NewtonUserJointGetRowAcceleration (const NewtonJoint* const joint); - NEWTON_API void NewtonUserJointGetRowJacobian(const NewtonJoint* const joint, dFloat* const linear0, dFloat* const angula0, dFloat* const linear1, dFloat* const angula1); - NEWTON_API void NewtonUserJointSetRowAcceleration (const NewtonJoint* const joint, dFloat acceleration); - NEWTON_API void NewtonUserJointSetRowSpringDamperAcceleration (const NewtonJoint* const joint, dFloat rowStiffness, dFloat spring, dFloat damper); - NEWTON_API void NewtonUserJointSetRowStiffness (const NewtonJoint* const joint, dFloat stiffness); - NEWTON_API int NewtonUserJoinRowsCount (const NewtonJoint* const joint); - NEWTON_API void NewtonUserJointGetGeneralRow (const NewtonJoint* const joint, int index, dFloat* const jacobian0, dFloat* const jacobian1); - NEWTON_API dFloat NewtonUserJointGetRowForce (const NewtonJoint* const joint, int row); - - // ********************************************************************************************** - // - // Mesh joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonMesh* NewtonMeshCreate(const NewtonWorld* const newtonWorld); - NEWTON_API NewtonMesh* NewtonMeshCreateFromMesh(const NewtonMesh* const mesh); - NEWTON_API NewtonMesh* NewtonMeshCreateFromCollision(const NewtonCollision* const collision); - NEWTON_API NewtonMesh* NewtonMeshCreateTetrahedraIsoSurface(const NewtonMesh* const mesh); - NEWTON_API NewtonMesh* NewtonMeshCreateConvexHull (const NewtonWorld* const newtonWorld, int pointCount, const dFloat* const vertexCloud, int strideInBytes, dFloat tolerance); - NEWTON_API NewtonMesh* NewtonMeshCreateVoronoiConvexDecomposition (const NewtonWorld* const newtonWorld, int pointCount, const dFloat* const vertexCloud, int strideInBytes, int materialID, const dFloat* const textureMatrix); - NEWTON_API NewtonMesh* NewtonMeshCreateFromSerialization (const NewtonWorld* const newtonWorld, NewtonDeserializeCallback deserializeFunction, void* const serializeHandle); - NEWTON_API void NewtonMeshDestroy(const NewtonMesh* const mesh); - - NEWTON_API void NewtonMeshSerialize (const NewtonMesh* const mesh, NewtonSerializeCallback serializeFunction, void* const serializeHandle); - NEWTON_API void NewtonMeshSaveOFF(const NewtonMesh* const mesh, const char* const filename); - NEWTON_API NewtonMesh* NewtonMeshLoadOFF(const NewtonWorld* const newtonWorld, const char* const filename); - NEWTON_API NewtonMesh* NewtonMeshLoadTetrahedraMesh(const NewtonWorld* const newtonWorld, const char* const filename); - - NEWTON_API void NewtonMeshFlipWinding(const NewtonMesh* const mesh); - - NEWTON_API void NewtonMeshApplyTransform (const NewtonMesh* const mesh, const dFloat* const matrix); - NEWTON_API void NewtonMeshCalculateOOBB(const NewtonMesh* const mesh, dFloat* const matrix, dFloat* const x, dFloat* const y, dFloat* const z); - - NEWTON_API void NewtonMeshCalculateVertexNormals(const NewtonMesh* const mesh, dFloat angleInRadians); - NEWTON_API void NewtonMeshApplySphericalMapping(const NewtonMesh* const mesh, int material, const dFloat* const aligmentMatrix); - NEWTON_API void NewtonMeshApplyCylindricalMapping(const NewtonMesh* const mesh, int cylinderMaterial, int capMaterial, const dFloat* const aligmentMatrix); - NEWTON_API void NewtonMeshApplyBoxMapping(const NewtonMesh* const mesh, int frontMaterial, int sideMaterial, int topMaterial, const dFloat* const aligmentMatrix); - NEWTON_API void NewtonMeshApplyAngleBasedMapping(const NewtonMesh* const mesh, int material, NewtonReportProgress reportPrograssCallback, void* const reportPrgressUserData, dFloat* const aligmentMatrix); - - NEWTON_API void NewtonCreateTetrahedraLinearBlendSkinWeightsChannel(const NewtonMesh* const tetrahedraMesh, NewtonMesh* const skinMesh); - - NEWTON_API void NewtonMeshOptimize (const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshOptimizePoints (const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshOptimizeVertex (const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshIsOpenMesh (const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshFixTJoints (const NewtonMesh* const mesh); - - NEWTON_API void NewtonMeshPolygonize (const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshTriangulate (const NewtonMesh* const mesh); - NEWTON_API NewtonMesh* NewtonMeshUnion (const NewtonMesh* const mesh, const NewtonMesh* const clipper, const dFloat* const clipperMatrix); - NEWTON_API NewtonMesh* NewtonMeshDifference (const NewtonMesh* const mesh, const NewtonMesh* const clipper, const dFloat* const clipperMatrix); - NEWTON_API NewtonMesh* NewtonMeshIntersection (const NewtonMesh* const mesh, const NewtonMesh* const clipper, const dFloat* const clipperMatrix); - NEWTON_API void NewtonMeshClip (const NewtonMesh* const mesh, const NewtonMesh* const clipper, const dFloat* const clipperMatrix, NewtonMesh** const topMesh, NewtonMesh** const bottomMesh); - - NEWTON_API NewtonMesh* NewtonMeshConvexMeshIntersection (const NewtonMesh* const mesh, const NewtonMesh* const convexMesh); - - NEWTON_API NewtonMesh* NewtonMeshSimplify (const NewtonMesh* const mesh, int maxVertexCount, NewtonReportProgress reportPrograssCallback, void* const reportPrgressUserData); - NEWTON_API NewtonMesh* NewtonMeshApproximateConvexDecomposition (const NewtonMesh* const mesh, dFloat maxConcavity, dFloat backFaceDistanceFactor, int maxCount, int maxVertexPerHull, NewtonReportProgress reportProgressCallback, void* const reportProgressUserData); - - NEWTON_API void NewtonRemoveUnusedVertices(const NewtonMesh* const mesh, int* const vertexRemapTable); - - NEWTON_API void NewtonMeshBeginBuild(const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshBeginFace(const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshAddPoint(const NewtonMesh* const mesh, dFloat64 x, dFloat64 y, dFloat64 z); - NEWTON_API void NewtonMeshAddLayer(const NewtonMesh* const mesh, int layerIndex); - NEWTON_API void NewtonMeshAddMaterial(const NewtonMesh* const mesh, int materialIndex); - NEWTON_API void NewtonMeshAddNormal(const NewtonMesh* const mesh, dFloat x, dFloat y, dFloat z); - NEWTON_API void NewtonMeshAddBinormal(const NewtonMesh* const mesh, dFloat x, dFloat y, dFloat z); - NEWTON_API void NewtonMeshAddUV0(const NewtonMesh* const mesh, dFloat u, dFloat v); - NEWTON_API void NewtonMeshAddUV1(const NewtonMesh* const mesh, dFloat u, dFloat v); - NEWTON_API void NewtonMeshAddVertexColor(const NewtonMesh* const mesh, dFloat32 r, dFloat32 g, dFloat32 b, dFloat32 a); - NEWTON_API void NewtonMeshEndFace(const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshEndBuild(const NewtonMesh* const mesh); - - NEWTON_API void NewtonMeshClearVertexFormat (NewtonMeshVertexFormat* const format); - NEWTON_API void NewtonMeshBuildFromVertexListIndexList (const NewtonMesh* const mesh, const NewtonMeshVertexFormat* const format); - - NEWTON_API int NewtonMeshGetPointCount (const NewtonMesh* const mesh); - NEWTON_API const int* NewtonMeshGetIndexToVertexMap(const NewtonMesh* const mesh); - - NEWTON_API void NewtonMeshGetVertexDoubleChannel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat64* const outBuffer); - NEWTON_API void NewtonMeshGetVertexChannel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer); - NEWTON_API void NewtonMeshGetNormalChannel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer); - NEWTON_API void NewtonMeshGetBinormalChannel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer); - NEWTON_API void NewtonMeshGetUV0Channel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer); - NEWTON_API void NewtonMeshGetUV1Channel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer); - NEWTON_API void NewtonMeshGetVertexColorChannel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer); - - NEWTON_API int NewtonMeshHasNormalChannel(const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshHasBinormalChannel(const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshHasUV0Channel(const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshHasUV1Channel(const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshHasVertexColorChannel(const NewtonMesh* const mesh); - - NEWTON_API void* NewtonMeshBeginHandle (const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshEndHandle (const NewtonMesh* const mesh, void* const handle); - NEWTON_API int NewtonMeshFirstMaterial (const NewtonMesh* const mesh, void* const handle); - NEWTON_API int NewtonMeshNextMaterial (const NewtonMesh* const mesh, void* const handle, int materialId); - NEWTON_API int NewtonMeshMaterialGetMaterial (const NewtonMesh* const mesh, void* const handle, int materialId); - NEWTON_API int NewtonMeshMaterialGetIndexCount (const NewtonMesh* const mesh, void* const handle, int materialId); - NEWTON_API void NewtonMeshMaterialGetIndexStream (const NewtonMesh* const mesh, void* const handle, int materialId, int* const index); - NEWTON_API void NewtonMeshMaterialGetIndexStreamShort (const NewtonMesh* const mesh, void* const handle, int materialId, short int* const index); - - NEWTON_API NewtonMesh* NewtonMeshCreateFirstSingleSegment (const NewtonMesh* const mesh); - NEWTON_API NewtonMesh* NewtonMeshCreateNextSingleSegment (const NewtonMesh* const mesh, const NewtonMesh* const segment); - - NEWTON_API NewtonMesh* NewtonMeshCreateFirstLayer (const NewtonMesh* const mesh); - NEWTON_API NewtonMesh* NewtonMeshCreateNextLayer (const NewtonMesh* const mesh, const NewtonMesh* const segment); - - NEWTON_API int NewtonMeshGetTotalFaceCount (const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshGetTotalIndexCount (const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshGetFaces (const NewtonMesh* const mesh, int* const faceIndexCount, int* const faceMaterial, void** const faceIndices); - - NEWTON_API int NewtonMeshGetVertexCount (const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshGetVertexStrideInByte (const NewtonMesh* const mesh); - NEWTON_API const dFloat64* NewtonMeshGetVertexArray (const NewtonMesh* const mesh); - - NEWTON_API int NewtonMeshGetVertexBaseCount(const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshSetVertexBaseCount(const NewtonMesh* const mesh, int baseCount); - - NEWTON_API void* NewtonMeshGetFirstVertex (const NewtonMesh* const mesh); - NEWTON_API void* NewtonMeshGetNextVertex (const NewtonMesh* const mesh, const void* const vertex); - NEWTON_API int NewtonMeshGetVertexIndex (const NewtonMesh* const mesh, const void* const vertex); - - NEWTON_API void* NewtonMeshGetFirstPoint (const NewtonMesh* const mesh); - NEWTON_API void* NewtonMeshGetNextPoint (const NewtonMesh* const mesh, const void* const point); - NEWTON_API int NewtonMeshGetPointIndex (const NewtonMesh* const mesh, const void* const point); - NEWTON_API int NewtonMeshGetVertexIndexFromPoint (const NewtonMesh* const mesh, const void* const point); - - NEWTON_API void* NewtonMeshGetFirstEdge (const NewtonMesh* const mesh); - NEWTON_API void* NewtonMeshGetNextEdge (const NewtonMesh* const mesh, const void* const edge); - NEWTON_API void NewtonMeshGetEdgeIndices (const NewtonMesh* const mesh, const void* const edge, int* const v0, int* const v1); - //NEWTON_API void NewtonMeshGetEdgePointIndices (const NewtonMesh* const mesh, const void* const edge, int* const v0, int* const v1); - - NEWTON_API void* NewtonMeshGetFirstFace (const NewtonMesh* const mesh); - NEWTON_API void* NewtonMeshGetNextFace (const NewtonMesh* const mesh, const void* const face); - NEWTON_API int NewtonMeshIsFaceOpen (const NewtonMesh* const mesh, const void* const face); - NEWTON_API int NewtonMeshGetFaceMaterial (const NewtonMesh* const mesh, const void* const face); - NEWTON_API int NewtonMeshGetFaceIndexCount (const NewtonMesh* const mesh, const void* const face); - NEWTON_API void NewtonMeshGetFaceIndices (const NewtonMesh* const mesh, const void* const face, int* const indices); - NEWTON_API void NewtonMeshGetFacePointIndices (const NewtonMesh* const mesh, const void* const face, int* const indices); - NEWTON_API void NewtonMeshCalculateFaceNormal (const NewtonMesh* const mesh, const void* const face, dFloat64* const normal); - - NEWTON_API void NewtonMeshSetFaceMaterial (const NewtonMesh* const mesh, const void* const face, int matId); - - -#ifdef __cplusplus -} -#endif -#endif - - - diff --git a/thirdparty/include/Newton/dgTypes.h b/thirdparty/include/Newton/dgTypes.h deleted file mode 100644 index 08c6ee94f..000000000 --- a/thirdparty/include/Newton/dgTypes.h +++ /dev/null @@ -1,696 +0,0 @@ -/* Copyright (c) <2003-2019> -* -* 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 __DGTYPES_H__ -#define __DGTYPES_H__ - -#ifdef _MSC_VER - #ifdef _M_ARM - #ifndef _ARM_VER - #define _ARM_VER - #endif - #elif defined (_M_X64) - #ifndef _WIN_64_VER - #define _WIN_64_VER - #endif - #elif defined (_M_IX86) - #ifndef _WIN_32_VER - #define _WIN_32_VER - #endif - #else - #error target platform not defined - #endif - - #if _MSC_VER >= 1400 - #define HAVE_STRUCT_TIMESPEC - #endif -#endif - -#if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || (defined (_MSC_VER ) && defined (_ARM_VER)) ) - #pragma warning (disable: 4100) //unreferenced formal parameter - #pragma warning (disable: 4201) //nonstandard extension used : nameless struct/union - #pragma warning (disable: 4324) //structure was padded due to __declspec(align()) - #pragma warning (disable: 4514) //unreferenced inline function has been removed - #pragma warning (disable: 4530) //C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc - #pragma warning (disable: 4625) //copy constructor could not be generated because a base class copy constructor is inaccessible or deleted - #pragma warning (disable: 4626) //assignment operator could not be generated because a base class assignment operator is inaccessible or deleted - #pragma warning (disable: 4640) //construction of local static object is not thread-safe - #pragma warning (disable: 4820) //bytes padding added after data member - #pragma warning (disable: 4005) //'__useHeader': macro redefinition - //#pragma warning (disable: 4577) // 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc - - #include - #include - #include - #include - #include - #include - - #ifdef _DEBUG - #pragma warning (disable: 4127) //conditional expression is constant - #endif - - #pragma warning (push, 3) - #include - #include - //#ifndef _DURANGO - // #include - //#endif - #pragma warning (pop) -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if (defined (__MINGW32__) || defined (__MINGW64__)) - #include - #include - #include - #include - #include - #include -#endif - -#if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - #include - #include - #include -#endif - -#if (defined (_POSIX_VER) || defined (_POSIX_VER_64) || defined (__MINGW32__) || defined (__MINGW64__)) - /* CMake defines NDEBUG for _not_ debug builds. Therefore, set - Newton's _DEBUG flag only when NDEBUG is not defined. - */ - #ifndef NDEBUG - #define _DEBUG 1 - #endif - - #include - #include - #if (!defined(__arm__) && !defined(__aarch64__)) // it was __ARMCC_VERSION before, it should be __ARM__ or aarch64, otherwise cross compiling in gcc fails. - extern "C" - { - // for SSE3 and up - #include - #include - #include - } - #endif -#endif - -#ifdef _MACOSX_VER - #include - #include - #include - #if (defined __i386__ || defined __x86_64__) - #include - #include - #include //sse3 - #include - #endif -#endif - -// uncomment out D_PROFILER to enable profiler frame capture profiler traces -// alternatively the end application can use a command line option to enable this define -//#define D_PROFILER - -// uncomment this for Scalar floating point -// alternatively the end application can use a command line option to enable this define -//#define DG_SCALAR_VECTOR_CLASS - -// uncomment this for Scalar floating point -// alternatively the end application can use a command line option to enable this define -//#define __ANDROID__ - -// by default newton run on a separate thread and -// optionally concurrent with the calling thread, -// it also uses a thread job pool for multi core systems. -// define DG_USE_THREAD_EMULATION on the command line for -// platform that do not support hardware multi threading or -// if the and application want to control threading at the application level -//#define DG_USE_THREAD_EMULATION - -#if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - #if _MSC_VER < 1700 - #ifndef DG_USE_THREAD_EMULATION - #define DG_USE_THREAD_EMULATION - #endif - #endif -#endif - -#ifndef DG_USE_THREAD_EMULATION - #include - #include - #include -#endif - - -//************************************************************ -#ifdef DG_DISABLE_ASSERT - #define dgAssert(x) -#else - #if defined (_WIN_32_VER) || defined (_WIN_64_VER) - #define dgAssert(x) _ASSERTE(x) - #elif defined (_MSC_VER ) && defined (_ARM_VER) - #define dgAssert(x) _ASSERTE(x) - #else - #ifdef _DEBUG - #define dgAssert(x) assert(x) - #else - #define dgAssert(x) - #endif - #endif -#endif - - -#define DG_MAX_THREADS_HIVE_COUNT 16 - -#ifdef _DEBUG -//#define __ENABLE_DG_CONTAINERS_SANITY_CHECK -#endif - - -#ifdef DLL_DECLSPEC -#undef DLL_DECLSPEC -#endif - -#ifdef _DEBUG - #define DG_INLINE inline -#else - #if defined(_MSC_VER) - #define DG_INLINE __forceinline - #else - #define DG_INLINE inline - //#define DG_INLINE __attribute__((always_inline)) - #endif -#endif - - -#define DG_VECTOR_SIMD_SIZE 16 -#define DG_VECTOR_AVX2_SIZE 32 - -#if defined(_MSC_VER) - #define DG_GCC_VECTOR_ALIGNMENT - #define DG_MSC_VECTOR_ALIGNMENT __declspec(align(DG_VECTOR_SIMD_SIZE)) -#else - #define DG_GCC_VECTOR_ALIGNMENT __attribute__ ((aligned (DG_VECTOR_SIMD_SIZE))) - #define DG_MSC_VECTOR_ALIGNMENT -#endif - -#if defined(_MSC_VER) - #define DG_GCC_AVX_ALIGNMENT - #define DG_MSC_AVX_ALIGNMENT __declspec(align(DG_VECTOR_AVX2_SIZE)) -#else - #define DG_GCC_AVX_ALIGNMENT __attribute__ ((aligned (DG_VECTOR_AVX2_SIZE))) - #define DG_MSC_AVX_ALIGNMENT -#endif - -#if defined(_MSC_VER) - #define DG_LIBRARY_EXPORT __declspec(dllexport) - #define DG_LIBRARY_IMPORT __declspec(dllimport) - #define DG_LIBRARY_STATIC -#else - #define DG_LIBRARY_EXPORT __attribute__((visibility("default"))) - #define DG_LIBRARY_IMPORT __attribute__((visibility("default"))) - #define DG_LIBRARY_STATIC -#endif - - -#if ((defined (_WIN_32_VER) || defined (_WIN_64_VER)) && (_MSC_VER >= 1600)) - #include - typedef int8_t dgInt8; - typedef uint8_t dgUnsigned8; - - typedef int16_t dgInt16; - typedef uint16_t dgUnsigned16; - - typedef int32_t dgInt32; - typedef uint32_t dgUnsigned32; - - typedef int64_t dgInt64; - typedef uint64_t dgUnsigned64; -#else - typedef char dgInt8; - typedef unsigned char dgUnsigned8; - - typedef short dgInt16; - typedef unsigned short dgUnsigned16; - - typedef int dgInt32; - typedef unsigned dgUnsigned32; - typedef unsigned int dgUnsigned32; - - typedef long long dgInt64; - typedef unsigned long long dgUnsigned64; - typedef double dgFloat64; -#endif - - -typedef double dgFloat64; - -#ifdef _NEWTON_USE_DOUBLE - typedef double dgFloat32; -#else - typedef float dgFloat32; -#endif - - -class dgTriplex -{ - public: - dgFloat32 m_x; - dgFloat32 m_y; - dgFloat32 m_z; -}; - -#define dgPi dgFloat32 (3.141592f) -#define dgPI2 dgFloat32 (dgPi * 2.0f) -#define dgEXP dgFloat32 (2.71828f) -#define dgEpsilon dgFloat32 (1.0e-5f) -#define dgDegreeToRad dgFloat32 (dgPi / 180.0f) -#define dgRadToDegree dgFloat32 (180.0f / dgPi) - -class dgBigVector; -#ifndef _NEWTON_USE_DOUBLE -class dgVector; -#endif - - -#if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - #define dgApi __cdecl - #define dgStdApi __stdcall -#else - #define dgApi - #define dgStdApi -#endif - - - -#if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - #define dgCheckFloat(x) (_finite(x) && !_isnan(x)) -// #define dgCheckFloat(x) 1 -#else - #define dgCheckFloat(x) (isfinite(x) && !isnan(x)) -// #define dgCheckFloat(x) 1 -#endif - -typedef void (dgApi *dgDeserialize) (void* const userData, void* buffer, dgInt32 size); -typedef void (dgApi *dgSerialize) (void* const userData, const void* const buffer, dgInt32 size); -typedef bool (dgApi *dgReportProgress) (dgFloat32 progressNormalzedPercent, void* const userData); - -// assume this function returns memory aligned to 16 bytes -#define dgAlloca(type, count) (type*) alloca (sizeof (type) * (count)) - -DG_INLINE dgInt32 dgExp2 (dgInt32 x) -{ - dgInt32 exp; - for (exp = -1; x; x >>= 1) { - exp ++; - } - return exp; -} - -DG_INLINE dgInt32 dgBitReversal(dgInt32 v, dgInt32 base) -{ - dgInt32 x = 0; - dgInt32 power = dgExp2 (base) - 1; - do { - x += (v & 1) << power; - v >>= 1; - power--; - } while (v); - dgAssert(x < base); - return x; -} - - -template -DG_INLINE T dgMin(T A, T B) -{ - return (A < B) ? A : B; -} - -template -DG_INLINE T dgMax(T A, T B) -{ - return (A > B) ? A : B; -} - -template -DG_INLINE T dgMin(T A, T B, T C) -{ - return dgMin(dgMin (A, B), C); -} - -template -DG_INLINE T dgMax(T A, T B, T C) -{ - return dgMax(dgMax (A, B), C); -} - -template -DG_INLINE T dgClamp(T val, T min, T max) -{ - return dgMax (min, dgMin (max, val)); -} - -template -DG_INLINE void dgSwap(T& A, T& B) -{ - T tmp (A); - A = B; - B = tmp; -} - -template -DG_INLINE T dgAbs(T A) -{ - // according to Intel this is better because is does not read after write - return (A >= T(0)) ? A : -A; -} - -template -DG_INLINE T dgSign(T A) -{ - return (A >= T(0)) ? T(1) : T(-1); -} - -template -DG_INLINE bool dgAreEqual(T A, T B, T tol) -{ - if ((dgAbs(A) < tol) && (dgAbs(B) < tol)) { - return true; - } -/* - dgInt32 exp0; - dgFloat64 mantissa0 = frexp(dgFloat64 (A), &exp0); - - dgInt32 exp1; - dgFloat64 mantissa1 = frexp(dgFloat64(B), &exp1); - - if ((exp0 < -12) && (exp1 < -12)) { - return true; - } - - if (exp0 != exp1) { - return false; - } - return dgAbs(mantissa0 - mantissa1) < tol; -*/ - T den = dgMax(dgAbs(A), dgAbs(B)) + tol; - A /= den; - B /= den; - return dgAbs(A - B) < tol; -} - -#ifdef _NEWTON_USE_DOUBLE - union dgFloatSign - { - struct { - dgInt32 m_dommy; - dgInt32 m_iVal; - } m_integer; - dgFloat64 m_fVal; - }; -#else - union dgFloatSign - { - struct { - dgInt32 m_iVal; - } m_integer; - dgFloat32 m_fVal; - }; -#endif - -union dgDoubleInt -{ - struct { - dgInt32 m_intL; - dgInt32 m_intH; - }; - void* m_ptr; - dgInt64 m_int; - dgFloat64 m_float; -}; - - -void dgGetMinMax (dgBigVector &Min, dgBigVector &Max, const dgFloat64* const vArray, dgInt32 vCount, dgInt32 strideInBytes); -dgInt32 dgVertexListToIndexList (dgFloat64* const vertexList, dgInt32 strideInBytes, dgInt32 compareCount, dgInt32 vertexCount, dgInt32* const indexListOut, dgFloat64 tolerance = dgEpsilon); -dgInt32 dgVertexListToIndexList (dgFloat32* const vertexList, dgInt32 strideInBytes, dgInt32 floatSizeInBytes, dgInt32 unsignedSizeInBytes, dgInt32 vertexCount, dgInt32* const indexListOut, dgFloat32 tolerance = dgEpsilon); - -#define PointerToInt(x) ((size_t)x) -#define IntToPointer(x) ((void*)(size_t(x))) - - -#ifndef _MSC_VER - #define _stricmp(x,y) strcasecmp(x,y) -#endif - -#define dgSqrt(x) dgFloat32 (sqrt(x)) -#define dgSin(x) dgFloat32 (sin(x)) -#define dgCos(x) dgFloat32 (cos(x)) -#define dgAsin(x) dgFloat32 (asin(x)) -#define dgAcos(x) dgFloat32 (acos(x)) -#define dgLog(x) dgFloat32 (log(x)) -#define dgCeil(x) dgFloat32 (ceil(x)) -#define dgFloor(x) dgFloat32 (floor(x)) -#define dgPow(x,y) dgFloat32 (pow(x,y)) -#define dgFmod(x,y) dgFloat32 (fmod(x,y)) -#define dgAtan2(x,y) dgFloat32 (atan2(x,y)) -#define dgRsqrt(x) (dgFloat32 (1.0f) / dgSqrt(x)) -#define dgClearFP() _clearfp() -#define dgControlFP(x,y) _controlfp(x,y) - -enum dgSerializeRevisionNumber -{ - m_firstRevision = 100, - // add new serialization revision number here - m_currentRevision -}; - -dgUnsigned64 dgGetTimeInMicrosenconds(); -dgFloat64 dgRoundToFloat(dgFloat64 val); -void dgSerializeMarker(dgSerialize serializeCallback, void* const userData); -dgInt32 dgDeserializeMarker(dgDeserialize serializeCallback, void* const userData); - -class dgFloatExceptions -{ - public: - #ifdef _MSC_VER - #define DG_FLOAT_EXECTIONS_MASK (EM_INVALID | EM_DENORMAL | EM_ZERODIVIDE) - #else - #define DG_FLOAT_EXECTIONS_MASK 0 - #endif - - dgFloatExceptions(dgUnsigned32 mask = DG_FLOAT_EXECTIONS_MASK); - ~dgFloatExceptions(); - - private: - #if (defined (_MSC_VER) && defined (_WIN_32_VER)) - dgUnsigned32 m_mask; -#endif -}; - -class dgSetPrecisionDouble -{ - public: - dgSetPrecisionDouble(); - ~dgSetPrecisionDouble(); - #if (defined (_MSC_VER) && defined (_WIN_32_VER)) - dgInt32 m_mask; - #endif -}; - -DG_INLINE dgInt32 dgAtomicExchangeAndAdd (dgInt32* const addend, dgInt32 amount) -{ - #if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - return _InterlockedExchangeAdd((long*)addend, long(amount)); - #elif defined (_MSC_VER ) && defined (_ARM_VER) - return _InterlockedExchangeAdd((long*)addend, long(amount)); - #elif (defined (__MINGW32__) || defined (__MINGW64__)) - return InterlockedExchangeAdd((long*)addend, long(amount)); - #elif (defined (_POSIX_VER) || defined (_POSIX_VER_64) ||defined (_MACOSX_VER)|| defined ANDROID) - return __sync_fetch_and_add((int32_t*)addend, amount); - #else - #error "dgAtomicExchangeAndAdd implementation required" - #endif -} - -DG_INLINE dgInt32 dgInterlockedExchange(dgInt32* const ptr, dgInt32 value) -{ - #if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - return _InterlockedExchange((long*) ptr, value); - #elif defined (_MSC_VER ) && defined (_ARM_VER) - return _InterlockedExchange((long*)ptr, value); - #elif (defined (__MINGW32__) || defined (__MINGW64__)) - return InterlockedExchange((long*) ptr, value); - #elif (defined (_POSIX_VER) || defined (_POSIX_VER_64) ||defined (_MACOSX_VER)) - return __sync_lock_test_and_set((int32_t*)ptr, value); - #else - #error "dgInterlockedExchange implementation required" - #endif -} - -/* -DG_INLINE void* dgInterlockedExchange(void** const ptr, void* value) -{ - #if defined(_WIN32) - #ifdef _M_X64 - return (void*)_InterlockedExchange64((dgInt64*)ptr, dgInt64 (value)); - #else - return (void*)_InterlockedExchange((long*) ptr, dgInt32(value)); - #endif - #elif defined(__linux__) || defined(_MACOSX_VER) - #if defined(__ANDROID__) - return __sync_lock_test_and_set(ptr, value); - #else - #ifdef __x86_64__ - return (void*)__sync_lock_test_and_set((dgInt64*) ptr, (dgInt64)value); - #else - return (void*)__sync_lock_test_and_set((dgInt32*) ptr, (dgInt32) value); - #endif - #endif - #else - #error "dgInterlockedExchange implementation required" - #endif -} -*/ - -DG_INLINE dgInt32 dgInterlockedTest(dgInt32* const ptr, dgInt32 value) -{ - #if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - return _InterlockedCompareExchange((long*)ptr, value, value); - #elif defined (_MSC_VER ) && defined (_ARM_VER) - return _InterlockedCompareExchange((long*)ptr, value, value); - #elif (defined (__MINGW32__) || defined (__MINGW64__)) - return InterlockedCompareExchange((long*)ptr, value, value); - #elif (defined (_POSIX_VER) || defined (_POSIX_VER_64) ||defined (_MACOSX_VER)) - return __sync_lock_test_and_set((int32_t*)ptr, value); - #else - #error "dgInterlockedTest implementation required" - #endif -} - -DG_INLINE void dgThreadYield() -{ -#ifndef DG_USE_THREAD_EMULATION - std::this_thread::yield(); -#endif -} - -DG_INLINE void dgThreadPause() -{ -#ifndef DG_USE_THREAD_EMULATION - //#if defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (WIN32) || defined (i386_) || defined (x86_64_) - #if defined (_WIN_32_VER) || defined (_WIN_64_VER) - _mm_pause(); - #else - std::this_thread::yield(); - #endif -#endif -} - -DG_INLINE void dgSpinLock(dgInt32* const ptr) -{ -#ifndef DG_USE_THREAD_EMULATION - while (dgInterlockedExchange(ptr, 1)) { - dgThreadYield(); - } -#endif -} - - -DG_INLINE void dgSpinUnlock (dgInt32* const ptr) -{ - #ifndef DG_USE_THREAD_EMULATION - dgInterlockedExchange(ptr, 0); - #else - *ptr = 0; - #endif -} - - -class dgScopeSpinLock -{ - public: - DG_INLINE dgScopeSpinLock(dgInt32* const lock) - :m_atomicLock(lock) - { - dgSpinLock(m_atomicLock); - } - - DG_INLINE ~dgScopeSpinLock() - { - dgSpinUnlock(m_atomicLock); - } - - dgInt32* m_atomicLock; -}; - -class dgScopeSpinPause -{ - public: - DG_INLINE dgScopeSpinPause(dgInt32* const lock) - :m_atomicLock(lock) - { - while (dgInterlockedExchange(m_atomicLock, 1)) { - dgThreadPause(); - } - } - - DG_INLINE ~dgScopeSpinPause() - { - dgSpinUnlock(m_atomicLock); - } - - dgInt32* m_atomicLock; -}; - - - -#ifdef _MACOSX_VER -#include -#ifndef CLOCK_REALTIME - #define CLOCK_REALTIME 0 -#endif -#ifndef CLOCK_MONOTONIC - #define CLOCK_MONOTONIC 0 -#endif -//clock_gettime is not implemented on OSX -DG_INLINE int clock_gettime(int /*clk_id*/, struct timespec* t) { - struct timeval now; - int rv = gettimeofday(&now, NULL); - if (rv) return rv; - t->tv_sec = now.tv_sec; - t->tv_nsec = now.tv_usec * 1000; - return 0; -} -#endif - -#endif - diff --git a/thirdparty/include/SDL2/SDL.h b/thirdparty/include/SDL2/SDL.h deleted file mode 100644 index 634bf4b6d..000000000 --- a/thirdparty/include/SDL2/SDL.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL.h - * - * Main include header for the SDL library - */ - - -#ifndef SDL_h_ -#define SDL_h_ - -#include "SDL_main.h" -#include "SDL_stdinc.h" -#include "SDL_assert.h" -#include "SDL_atomic.h" -#include "SDL_audio.h" -#include "SDL_clipboard.h" -#include "SDL_cpuinfo.h" -#include "SDL_endian.h" -#include "SDL_error.h" -#include "SDL_events.h" -#include "SDL_filesystem.h" -#include "SDL_gamecontroller.h" -#include "SDL_haptic.h" -#include "SDL_hints.h" -#include "SDL_joystick.h" -#include "SDL_loadso.h" -#include "SDL_log.h" -#include "SDL_messagebox.h" -#include "SDL_metal.h" -#include "SDL_mutex.h" -#include "SDL_power.h" -#include "SDL_render.h" -#include "SDL_rwops.h" -#include "SDL_sensor.h" -#include "SDL_shape.h" -#include "SDL_system.h" -#include "SDL_thread.h" -#include "SDL_timer.h" -#include "SDL_version.h" -#include "SDL_video.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* As of version 0.5, SDL is loaded dynamically into the application */ - -/** - * \name SDL_INIT_* - * - * These are the flags which may be passed to SDL_Init(). You should - * specify the subsystems which you will be using in your application. - */ -/* @{ */ -#define SDL_INIT_TIMER 0x00000001u -#define SDL_INIT_AUDIO 0x00000010u -#define SDL_INIT_VIDEO 0x00000020u /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ -#define SDL_INIT_JOYSTICK 0x00000200u /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */ -#define SDL_INIT_HAPTIC 0x00001000u -#define SDL_INIT_GAMECONTROLLER 0x00002000u /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */ -#define SDL_INIT_EVENTS 0x00004000u -#define SDL_INIT_SENSOR 0x00008000u -#define SDL_INIT_NOPARACHUTE 0x00100000u /**< compatibility; this flag is ignored. */ -#define SDL_INIT_EVERYTHING ( \ - SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ - SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR \ - ) -/* @} */ - -/** - * This function initializes the subsystems specified by \c flags - */ -extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); - -/** - * This function initializes specific SDL subsystems - * - * Subsystem initialization is ref-counted, you must call - * SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly - * shutdown a subsystem manually (or call SDL_Quit() to force shutdown). - * If a subsystem is already loaded then this call will - * increase the ref-count and return. - */ -extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); - -/** - * This function cleans up specific SDL subsystems - */ -extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); - -/** - * This function returns a mask of the specified subsystems which have - * previously been initialized. - * - * If \c flags is 0, it returns a mask of all initialized subsystems. - */ -extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); - -/** - * This function cleans up all initialized subsystems. You should - * call it upon all exit conditions. - */ -extern DECLSPEC void SDLCALL SDL_Quit(void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_assert.h b/thirdparty/include/SDL2/SDL_assert.h deleted file mode 100644 index 21bdad998..000000000 --- a/thirdparty/include/SDL2/SDL_assert.h +++ /dev/null @@ -1,291 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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 SDL_assert_h_ -#define SDL_assert_h_ - -#include "SDL_config.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef SDL_ASSERT_LEVEL -#ifdef SDL_DEFAULT_ASSERT_LEVEL -#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL -#elif defined(_DEBUG) || defined(DEBUG) || \ - (defined(__GNUC__) && !defined(__OPTIMIZE__)) -#define SDL_ASSERT_LEVEL 2 -#else -#define SDL_ASSERT_LEVEL 1 -#endif -#endif /* SDL_ASSERT_LEVEL */ - -/* -These are macros and not first class functions so that the debugger breaks -on the assertion line and not in some random guts of SDL, and so each -assert can have unique static variables associated with it. -*/ - -#if defined(_MSC_VER) -/* Don't include intrin.h here because it contains C++ code */ - extern void __cdecl __debugbreak(void); - #define SDL_TriggerBreakpoint() __debugbreak() -#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) ) - #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) -#elif defined(__386__) && defined(__WATCOMC__) - #define SDL_TriggerBreakpoint() { _asm { int 0x03 } } -#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__) - #include - #define SDL_TriggerBreakpoint() raise(SIGTRAP) -#else - /* How do we trigger breakpoints on this platform? */ - #define SDL_TriggerBreakpoint() -#endif - -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ -# define SDL_FUNCTION __func__ -#elif ((__GNUC__ >= 2) || defined(_MSC_VER) || defined (__WATCOMC__)) -# define SDL_FUNCTION __FUNCTION__ -#else -# define SDL_FUNCTION "???" -#endif -#define SDL_FILE __FILE__ -#define SDL_LINE __LINE__ - -/* -sizeof (x) makes the compiler still parse the expression even without -assertions enabled, so the code is always checked at compile time, but -doesn't actually generate code for it, so there are no side effects or -expensive checks at run time, just the constant size of what x WOULD be, -which presumably gets optimized out as unused. -This also solves the problem of... - - int somevalue = blah(); - SDL_assert(somevalue == 1); - -...which would cause compiles to complain that somevalue is unused if we -disable assertions. -*/ - -/* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking - this condition isn't constant. And looks like an owl's face! */ -#ifdef _MSC_VER /* stupid /W4 warnings. */ -#define SDL_NULL_WHILE_LOOP_CONDITION (0,0) -#else -#define SDL_NULL_WHILE_LOOP_CONDITION (0) -#endif - -#define SDL_disabled_assert(condition) \ - do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION) - -typedef enum -{ - SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */ - SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */ - SDL_ASSERTION_ABORT, /**< Terminate the program. */ - SDL_ASSERTION_IGNORE, /**< Ignore the assert. */ - SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */ -} SDL_AssertState; - -typedef struct SDL_AssertData -{ - int always_ignore; - unsigned int trigger_count; - const char *condition; - const char *filename; - int linenum; - const char *function; - const struct SDL_AssertData *next; -} SDL_AssertData; - -#if (SDL_ASSERT_LEVEL > 0) - -/* Never call this directly. Use the SDL_assert* macros. */ -extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, - const char *, - const char *, int) -#if defined(__clang__) -#if __has_feature(attribute_analyzer_noreturn) -/* this tells Clang's static analysis that we're a custom assert function, - and that the analyzer should assume the condition was always true past this - SDL_assert test. */ - __attribute__((analyzer_noreturn)) -#endif -#endif -; - -/* the do {} while(0) avoids dangling else problems: - if (x) SDL_assert(y); else blah(); - ... without the do/while, the "else" could attach to this macro's "if". - We try to handle just the minimum we need here in a macro...the loop, - the static vars, and break points. The heavy lifting is handled in - SDL_ReportAssertion(), in SDL_assert.c. -*/ -#define SDL_enabled_assert(condition) \ - do { \ - while ( !(condition) ) { \ - static struct SDL_AssertData sdl_assert_data = { \ - 0, 0, #condition, 0, 0, 0, 0 \ - }; \ - const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \ - if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ - continue; /* go again. */ \ - } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \ - SDL_TriggerBreakpoint(); \ - } \ - break; /* not retrying. */ \ - } \ - } while (SDL_NULL_WHILE_LOOP_CONDITION) - -#endif /* enabled assertions support code */ - -/* Enable various levels of assertions. */ -#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */ -# define SDL_assert(condition) SDL_disabled_assert(condition) -# define SDL_assert_release(condition) SDL_disabled_assert(condition) -# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) -#elif SDL_ASSERT_LEVEL == 1 /* release settings. */ -# define SDL_assert(condition) SDL_disabled_assert(condition) -# define SDL_assert_release(condition) SDL_enabled_assert(condition) -# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) -#elif SDL_ASSERT_LEVEL == 2 /* normal settings. */ -# define SDL_assert(condition) SDL_enabled_assert(condition) -# define SDL_assert_release(condition) SDL_enabled_assert(condition) -# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) -#elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */ -# define SDL_assert(condition) SDL_enabled_assert(condition) -# define SDL_assert_release(condition) SDL_enabled_assert(condition) -# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition) -#else -# error Unknown assertion level. -#endif - -/* this assertion is never disabled at any level. */ -#define SDL_assert_always(condition) SDL_enabled_assert(condition) - - -typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)( - const SDL_AssertData* data, void* userdata); - -/** - * \brief Set an application-defined assertion handler. - * - * This allows an app to show its own assertion UI and/or force the - * response to an assertion failure. If the app doesn't provide this, SDL - * will try to do the right thing, popping up a system-specific GUI dialog, - * and probably minimizing any fullscreen windows. - * - * This callback may fire from any thread, but it runs wrapped in a mutex, so - * it will only fire from one thread at a time. - * - * Setting the callback to NULL restores SDL's original internal handler. - * - * This callback is NOT reset to SDL's internal handler upon SDL_Quit()! - * - * Return SDL_AssertState value of how to handle the assertion failure. - * - * \param handler Callback function, called when an assertion fails. - * \param userdata A pointer passed to the callback as-is. - */ -extern DECLSPEC void SDLCALL SDL_SetAssertionHandler( - SDL_AssertionHandler handler, - void *userdata); - -/** - * \brief Get the default assertion handler. - * - * This returns the function pointer that is called by default when an - * assertion is triggered. This is an internal function provided by SDL, - * that is used for assertions when SDL_SetAssertionHandler() hasn't been - * used to provide a different function. - * - * \return The default SDL_AssertionHandler that is called when an assert triggers. - */ -extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void); - -/** - * \brief Get the current assertion handler. - * - * This returns the function pointer that is called when an assertion is - * triggered. This is either the value last passed to - * SDL_SetAssertionHandler(), or if no application-specified function is - * set, is equivalent to calling SDL_GetDefaultAssertionHandler(). - * - * \param puserdata Pointer to a void*, which will store the "userdata" - * pointer that was passed to SDL_SetAssertionHandler(). - * This value will always be NULL for the default handler. - * If you don't care about this data, it is safe to pass - * a NULL pointer to this function to ignore it. - * \return The SDL_AssertionHandler that is called when an assert triggers. - */ -extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata); - -/** - * \brief Get a list of all assertion failures. - * - * Get all assertions triggered since last call to SDL_ResetAssertionReport(), - * or the start of the program. - * - * The proper way to examine this data looks something like this: - * - * - * const SDL_AssertData *item = SDL_GetAssertionReport(); - * while (item) { - * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n", - * item->condition, item->function, item->filename, - * item->linenum, item->trigger_count, - * item->always_ignore ? "yes" : "no"); - * item = item->next; - * } - * - * - * \return List of all assertions. - * \sa SDL_ResetAssertionReport - */ -extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void); - -/** - * \brief Reset the list of all assertion failures. - * - * Reset list of all assertions triggered. - * - * \sa SDL_GetAssertionReport - */ -extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void); - - -/* these had wrong naming conventions until 2.0.4. Please update your app! */ -#define SDL_assert_state SDL_AssertState -#define SDL_assert_data SDL_AssertData - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_assert_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_atomic.h b/thirdparty/include/SDL2/SDL_atomic.h deleted file mode 100644 index e99f1bcc6..000000000 --- a/thirdparty/include/SDL2/SDL_atomic.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_atomic.h - * - * Atomic operations. - * - * IMPORTANT: - * If you are not an expert in concurrent lockless programming, you should - * only be using the atomic lock and reference counting functions in this - * file. In all other cases you should be protecting your data structures - * with full mutexes. - * - * The list of "safe" functions to use are: - * SDL_AtomicLock() - * SDL_AtomicUnlock() - * SDL_AtomicIncRef() - * SDL_AtomicDecRef() - * - * Seriously, here be dragons! - * ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - * - * You can find out a little more about lockless programming and the - * subtle issues that can arise here: - * http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx - * - * There's also lots of good information here: - * http://www.1024cores.net/home/lock-free-algorithms - * http://preshing.com/ - * - * These operations may or may not actually be implemented using - * processor specific atomic operations. When possible they are - * implemented as true processor specific atomic operations. When that - * is not possible the are implemented using locks that *do* use the - * available atomic operations. - * - * All of the atomic operations that modify memory are full memory barriers. - */ - -#ifndef SDL_atomic_h_ -#define SDL_atomic_h_ - -#include "SDL_stdinc.h" -#include "SDL_platform.h" - -#include "begin_code.h" - -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \name SDL AtomicLock - * - * The atomic locks are efficient spinlocks using CPU instructions, - * but are vulnerable to starvation and can spin forever if a thread - * holding a lock has been terminated. For this reason you should - * minimize the code executed inside an atomic lock and never do - * expensive things like API or system calls while holding them. - * - * The atomic locks are not safe to lock recursively. - * - * Porting Note: - * The spin lock functions and type are required and can not be - * emulated because they are used in the atomic emulation code. - */ -/* @{ */ - -typedef int SDL_SpinLock; - -/** - * \brief Try to lock a spin lock by setting it to a non-zero value. - * - * \param lock Points to the lock. - * - * \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock); - -/** - * \brief Lock a spin lock by setting it to a non-zero value. - * - * \param lock Points to the lock. - */ -extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); - -/** - * \brief Unlock a spin lock by setting it to 0. Always returns immediately - * - * \param lock Points to the lock. - */ -extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); - -/* @} *//* SDL AtomicLock */ - - -/** - * The compiler barrier prevents the compiler from reordering - * reads and writes to globally visible variables across the call. - */ -#if defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__) -void _ReadWriteBarrier(void); -#pragma intrinsic(_ReadWriteBarrier) -#define SDL_CompilerBarrier() _ReadWriteBarrier() -#elif (defined(__GNUC__) && !defined(__EMSCRIPTEN__)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) -/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */ -#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory") -#elif defined(__WATCOMC__) -extern _inline void SDL_CompilerBarrier (void); -#pragma aux SDL_CompilerBarrier = "" parm [] modify exact []; -#else -#define SDL_CompilerBarrier() \ -{ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); } -#endif - -/** - * Memory barriers are designed to prevent reads and writes from being - * reordered by the compiler and being seen out of order on multi-core CPUs. - * - * A typical pattern would be for thread A to write some data and a flag, - * and for thread B to read the flag and get the data. In this case you - * would insert a release barrier between writing the data and the flag, - * guaranteeing that the data write completes no later than the flag is - * written, and you would insert an acquire barrier between reading the - * flag and reading the data, to ensure that all the reads associated - * with the flag have completed. - * - * In this pattern you should always see a release barrier paired with - * an acquire barrier and you should gate the data reads/writes with a - * single flag variable. - * - * For more information on these semantics, take a look at the blog post: - * http://preshing.com/20120913/acquire-and-release-semantics - */ -extern DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void); -extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); - -#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) -#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory") -#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory") -#elif defined(__GNUC__) && defined(__aarch64__) -#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") -#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") -#elif defined(__GNUC__) && defined(__arm__) -#if 0 /* defined(__LINUX__) || defined(__ANDROID__) */ -/* Information from: - https://chromium.googlesource.com/chromium/chromium/+/trunk/base/atomicops_internals_arm_gcc.h#19 - - The Linux kernel provides a helper function which provides the right code for a memory barrier, - hard-coded at address 0xffff0fa0 -*/ -typedef void (*SDL_KernelMemoryBarrierFunc)(); -#define SDL_MemoryBarrierRelease() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() -#define SDL_MemoryBarrierAcquire() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() -#elif 0 /* defined(__QNXNTO__) */ -#include - -#define SDL_MemoryBarrierRelease() __cpu_membarrier() -#define SDL_MemoryBarrierAcquire() __cpu_membarrier() -#else -#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__) -#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") -#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") -#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__) -#ifdef __thumb__ -/* The mcr instruction isn't available in thumb mode, use real functions */ -#define SDL_MEMORY_BARRIER_USES_FUNCTION -#define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction() -#define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction() -#else -#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") -#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") -#endif /* __thumb__ */ -#else -#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") -#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") -#endif /* __LINUX__ || __ANDROID__ */ -#endif /* __GNUC__ && __arm__ */ -#else -#if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) -/* This is correct for all CPUs on Solaris when using Solaris Studio 12.1+. */ -#include -#define SDL_MemoryBarrierRelease() __machine_rel_barrier() -#define SDL_MemoryBarrierAcquire() __machine_acq_barrier() -#else -/* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */ -#define SDL_MemoryBarrierRelease() SDL_CompilerBarrier() -#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier() -#endif -#endif - -/** - * \brief A type representing an atomic integer value. It is a struct - * so people don't accidentally use numeric operations on it. - */ -typedef struct { int value; } SDL_atomic_t; - -/** - * \brief Set an atomic variable to a new value if it is currently an old value. - * - * \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise. - * - * \note If you don't know what this function is for, you shouldn't use it! -*/ -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval); - -/** - * \brief Set an atomic variable to a value. - * - * \return The previous value of the atomic variable. - */ -extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v); - -/** - * \brief Get the value of an atomic variable - */ -extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a); - -/** - * \brief Add to an atomic variable. - * - * \return The previous value of the atomic variable. - * - * \note This same style can be used for any number operation - */ -extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v); - -/** - * \brief Increment an atomic variable used as a reference count. - */ -#ifndef SDL_AtomicIncRef -#define SDL_AtomicIncRef(a) SDL_AtomicAdd(a, 1) -#endif - -/** - * \brief Decrement an atomic variable used as a reference count. - * - * \return SDL_TRUE if the variable reached zero after decrementing, - * SDL_FALSE otherwise - */ -#ifndef SDL_AtomicDecRef -#define SDL_AtomicDecRef(a) (SDL_AtomicAdd(a, -1) == 1) -#endif - -/** - * \brief Set a pointer to a new value if it is currently an old value. - * - * \return SDL_TRUE if the pointer was set, SDL_FALSE otherwise. - * - * \note If you don't know what this function is for, you shouldn't use it! -*/ -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval); - -/** - * \brief Set a pointer to a value atomically. - * - * \return The previous value of the pointer. - */ -extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v); - -/** - * \brief Get the value of a pointer atomically. - */ -extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void **a); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif - -#include "close_code.h" - -#endif /* SDL_atomic_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_audio.h b/thirdparty/include/SDL2/SDL_audio.h deleted file mode 100644 index 4ba349147..000000000 --- a/thirdparty/include/SDL2/SDL_audio.h +++ /dev/null @@ -1,859 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_audio.h - * - * Access to the raw audio mixing buffer for the SDL library. - */ - -#ifndef SDL_audio_h_ -#define SDL_audio_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_endian.h" -#include "SDL_mutex.h" -#include "SDL_thread.h" -#include "SDL_rwops.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Audio format flags. - * - * These are what the 16 bits in SDL_AudioFormat currently mean... - * (Unspecified bits are always zero). - * - * \verbatim - ++-----------------------sample is signed if set - || - || ++-----------sample is bigendian if set - || || - || || ++---sample is float if set - || || || - || || || +---sample bit size---+ - || || || | | - 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 - \endverbatim - * - * There are macros in SDL 2.0 and later to query these bits. - */ -typedef Uint16 SDL_AudioFormat; - -/** - * \name Audio flags - */ -/* @{ */ - -#define SDL_AUDIO_MASK_BITSIZE (0xFF) -#define SDL_AUDIO_MASK_DATATYPE (1<<8) -#define SDL_AUDIO_MASK_ENDIAN (1<<12) -#define SDL_AUDIO_MASK_SIGNED (1<<15) -#define SDL_AUDIO_BITSIZE(x) (x & SDL_AUDIO_MASK_BITSIZE) -#define SDL_AUDIO_ISFLOAT(x) (x & SDL_AUDIO_MASK_DATATYPE) -#define SDL_AUDIO_ISBIGENDIAN(x) (x & SDL_AUDIO_MASK_ENDIAN) -#define SDL_AUDIO_ISSIGNED(x) (x & SDL_AUDIO_MASK_SIGNED) -#define SDL_AUDIO_ISINT(x) (!SDL_AUDIO_ISFLOAT(x)) -#define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x)) -#define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x)) - -/** - * \name Audio format flags - * - * Defaults to LSB byte order. - */ -/* @{ */ -#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ -#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ -#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ -#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */ -#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */ -#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ -#define AUDIO_U16 AUDIO_U16LSB -#define AUDIO_S16 AUDIO_S16LSB -/* @} */ - -/** - * \name int32 support - */ -/* @{ */ -#define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */ -#define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */ -#define AUDIO_S32 AUDIO_S32LSB -/* @} */ - -/** - * \name float32 support - */ -/* @{ */ -#define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */ -#define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */ -#define AUDIO_F32 AUDIO_F32LSB -/* @} */ - -/** - * \name Native audio byte ordering - */ -/* @{ */ -#if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define AUDIO_U16SYS AUDIO_U16LSB -#define AUDIO_S16SYS AUDIO_S16LSB -#define AUDIO_S32SYS AUDIO_S32LSB -#define AUDIO_F32SYS AUDIO_F32LSB -#else -#define AUDIO_U16SYS AUDIO_U16MSB -#define AUDIO_S16SYS AUDIO_S16MSB -#define AUDIO_S32SYS AUDIO_S32MSB -#define AUDIO_F32SYS AUDIO_F32MSB -#endif -/* @} */ - -/** - * \name Allow change flags - * - * Which audio format changes are allowed when opening a device. - */ -/* @{ */ -#define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001 -#define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002 -#define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004 -#define SDL_AUDIO_ALLOW_SAMPLES_CHANGE 0x00000008 -#define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE|SDL_AUDIO_ALLOW_SAMPLES_CHANGE) -/* @} */ - -/* @} *//* Audio flags */ - -/** - * This function is called when the audio device needs more data. - * - * \param userdata An application-specific parameter saved in - * the SDL_AudioSpec structure - * \param stream A pointer to the audio data buffer. - * \param len The length of that buffer in bytes. - * - * Once the callback returns, the buffer will no longer be valid. - * Stereo samples are stored in a LRLRLR ordering. - * - * You can choose to avoid callbacks and use SDL_QueueAudio() instead, if - * you like. Just open your audio device with a NULL callback. - */ -typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream, - int len); - -/** - * The calculated values in this structure are calculated by SDL_OpenAudio(). - * - * For multi-channel audio, the default SDL channel mapping is: - * 2: FL FR (stereo) - * 3: FL FR LFE (2.1 surround) - * 4: FL FR BL BR (quad) - * 5: FL FR FC BL BR (quad + center) - * 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR) - * 7: FL FR FC LFE BC SL SR (6.1 surround) - * 8: FL FR FC LFE BL BR SL SR (7.1 surround) - */ -typedef struct SDL_AudioSpec -{ - int freq; /**< DSP frequency -- samples per second */ - SDL_AudioFormat format; /**< Audio data format */ - Uint8 channels; /**< Number of channels: 1 mono, 2 stereo */ - Uint8 silence; /**< Audio buffer silence value (calculated) */ - Uint16 samples; /**< Audio buffer size in sample FRAMES (total samples divided by channel count) */ - Uint16 padding; /**< Necessary for some compile environments */ - Uint32 size; /**< Audio buffer size in bytes (calculated) */ - SDL_AudioCallback callback; /**< Callback that feeds the audio device (NULL to use SDL_QueueAudio()). */ - void *userdata; /**< Userdata passed to callback (ignored for NULL callbacks). */ -} SDL_AudioSpec; - - -struct SDL_AudioCVT; -typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt, - SDL_AudioFormat format); - -/** - * \brief Upper limit of filters in SDL_AudioCVT - * - * The maximum number of SDL_AudioFilter functions in SDL_AudioCVT is - * currently limited to 9. The SDL_AudioCVT.filters array has 10 pointers, - * one of which is the terminating NULL pointer. - */ -#define SDL_AUDIOCVT_MAX_FILTERS 9 - -/** - * \struct SDL_AudioCVT - * \brief A structure to hold a set of audio conversion filters and buffers. - * - * Note that various parts of the conversion pipeline can take advantage - * of SIMD operations (like SSE2, for example). SDL_AudioCVT doesn't require - * you to pass it aligned data, but can possibly run much faster if you - * set both its (buf) field to a pointer that is aligned to 16 bytes, and its - * (len) field to something that's a multiple of 16, if possible. - */ -#ifdef __GNUC__ -/* This structure is 84 bytes on 32-bit architectures, make sure GCC doesn't - pad it out to 88 bytes to guarantee ABI compatibility between compilers. - vvv - The next time we rev the ABI, make sure to size the ints and add padding. -*/ -#define SDL_AUDIOCVT_PACKED __attribute__((packed)) -#else -#define SDL_AUDIOCVT_PACKED -#endif -/* */ -typedef struct SDL_AudioCVT -{ - int needed; /**< Set to 1 if conversion possible */ - SDL_AudioFormat src_format; /**< Source audio format */ - SDL_AudioFormat dst_format; /**< Target audio format */ - double rate_incr; /**< Rate conversion increment */ - Uint8 *buf; /**< Buffer to hold entire audio data */ - int len; /**< Length of original audio buffer */ - int len_cvt; /**< Length of converted audio buffer */ - int len_mult; /**< buffer must be len*len_mult big */ - double len_ratio; /**< Given len, final size is len*len_ratio */ - SDL_AudioFilter filters[SDL_AUDIOCVT_MAX_FILTERS + 1]; /**< NULL-terminated list of filter functions */ - int filter_index; /**< Current audio conversion function */ -} SDL_AUDIOCVT_PACKED SDL_AudioCVT; - - -/* Function prototypes */ - -/** - * \name Driver discovery functions - * - * These functions return the list of built in audio drivers, in the - * order that they are normally initialized by default. - */ -/* @{ */ -extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); -extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); -/* @} */ - -/** - * \name Initialization and cleanup - * - * \internal These functions are used internally, and should not be used unless - * you have a specific need to specify the audio driver you want to - * use. You should normally use SDL_Init() or SDL_InitSubSystem(). - */ -/* @{ */ -extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); -extern DECLSPEC void SDLCALL SDL_AudioQuit(void); -/* @} */ - -/** - * This function returns the name of the current audio driver, or NULL - * if no driver has been initialized. - */ -extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void); - -/** - * This function opens the audio device with the desired parameters, and - * returns 0 if successful, placing the actual hardware parameters in the - * structure pointed to by \c obtained. If \c obtained is NULL, the audio - * data passed to the callback function will be guaranteed to be in the - * requested format, and will be automatically converted to the hardware - * audio format if necessary. This function returns -1 if it failed - * to open the audio device, or couldn't set up the audio thread. - * - * When filling in the desired audio spec structure, - * - \c desired->freq should be the desired audio frequency in samples-per- - * second. - * - \c desired->format should be the desired audio format. - * - \c desired->samples is the desired size of the audio buffer, in - * samples. This number should be a power of two, and may be adjusted by - * the audio driver to a value more suitable for the hardware. Good values - * seem to range between 512 and 8096 inclusive, depending on the - * application and CPU speed. Smaller values yield faster response time, - * but can lead to underflow if the application is doing heavy processing - * and cannot fill the audio buffer in time. A stereo sample consists of - * both right and left channels in LR ordering. - * Note that the number of samples is directly related to time by the - * following formula: \code ms = (samples*1000)/freq \endcode - * - \c desired->size is the size in bytes of the audio buffer, and is - * calculated by SDL_OpenAudio(). - * - \c desired->silence is the value used to set the buffer to silence, - * and is calculated by SDL_OpenAudio(). - * - \c desired->callback should be set to a function that will be called - * when the audio device is ready for more data. It is passed a pointer - * to the audio buffer, and the length in bytes of the audio buffer. - * This function usually runs in a separate thread, and so you should - * protect data structures that it accesses by calling SDL_LockAudio() - * and SDL_UnlockAudio() in your code. Alternately, you may pass a NULL - * pointer here, and call SDL_QueueAudio() with some frequency, to queue - * more audio samples to be played (or for capture devices, call - * SDL_DequeueAudio() with some frequency, to obtain audio samples). - * - \c desired->userdata is passed as the first parameter to your callback - * function. If you passed a NULL callback, this value is ignored. - * - * The audio device starts out playing silence when it's opened, and should - * be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready - * for your audio callback function to be called. Since the audio driver - * may modify the requested size of the audio buffer, you should allocate - * any local mixing buffers after you open the audio device. - */ -extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired, - SDL_AudioSpec * obtained); - -/** - * SDL Audio Device IDs. - * - * A successful call to SDL_OpenAudio() is always device id 1, and legacy - * SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls - * always returns devices >= 2 on success. The legacy calls are good both - * for backwards compatibility and when you don't care about multiple, - * specific, or capture devices. - */ -typedef Uint32 SDL_AudioDeviceID; - -/** - * Get the number of available devices exposed by the current driver. - * Only valid after a successfully initializing the audio subsystem. - * Returns -1 if an explicit list of devices can't be determined; this is - * not an error. For example, if SDL is set up to talk to a remote audio - * server, it can't list every one available on the Internet, but it will - * still allow a specific host to be specified to SDL_OpenAudioDevice(). - * - * In many common cases, when this function returns a value <= 0, it can still - * successfully open the default device (NULL for first argument of - * SDL_OpenAudioDevice()). - */ -extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture); - -/** - * Get the human-readable name of a specific audio device. - * Must be a value between 0 and (number of audio devices-1). - * Only valid after a successfully initializing the audio subsystem. - * The values returned by this function reflect the latest call to - * SDL_GetNumAudioDevices(); recall that function to redetect available - * hardware. - * - * The string returned by this function is UTF-8 encoded, read-only, and - * managed internally. You are not to free it. If you need to keep the - * string for any length of time, you should make your own copy of it, as it - * will be invalid next time any of several other SDL functions is called. - */ -extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index, - int iscapture); - - -/** - * Open a specific audio device. Passing in a device name of NULL requests - * the most reasonable default (and is equivalent to calling SDL_OpenAudio()). - * - * The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but - * some drivers allow arbitrary and driver-specific strings, such as a - * hostname/IP address for a remote audio server, or a filename in the - * diskaudio driver. - * - * \return 0 on error, a valid device ID that is >= 2 on success. - * - * SDL_OpenAudio(), unlike this function, always acts on device ID 1. - */ -extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char - *device, - int iscapture, - const - SDL_AudioSpec * - desired, - SDL_AudioSpec * - obtained, - int - allowed_changes); - - - -/** - * \name Audio state - * - * Get the current audio state. - */ -/* @{ */ -typedef enum -{ - SDL_AUDIO_STOPPED = 0, - SDL_AUDIO_PLAYING, - SDL_AUDIO_PAUSED -} SDL_AudioStatus; -extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void); - -extern DECLSPEC SDL_AudioStatus SDLCALL -SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); -/* @} *//* Audio State */ - -/** - * \name Pause audio functions - * - * These functions pause and unpause the audio callback processing. - * They should be called with a parameter of 0 after opening the audio - * device to start playing sound. This is so you can safely initialize - * data for your callback function after opening the audio device. - * Silence will be written to the audio device during the pause. - */ -/* @{ */ -extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); -extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, - int pause_on); -/* @} *//* Pause audio functions */ - -/** - * \brief Load the audio data of a WAVE file into memory - * - * Loading a WAVE file requires \c src, \c spec, \c audio_buf and \c audio_len - * to be valid pointers. The entire data portion of the file is then loaded - * into memory and decoded if necessary. - * - * If \c freesrc is non-zero, the data source gets automatically closed and - * freed before the function returns. - * - * Supported are RIFF WAVE files with the formats PCM (8, 16, 24, and 32 bits), - * IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and A-law and - * µ-law (8 bits). Other formats are currently unsupported and cause an error. - * - * If this function succeeds, the pointer returned by it is equal to \c spec - * and the pointer to the audio data allocated by the function is written to - * \c audio_buf and its length in bytes to \c audio_len. The \ref SDL_AudioSpec - * members \c freq, \c channels, and \c format are set to the values of the - * audio data in the buffer. The \c samples member is set to a sane default and - * all others are set to zero. - * - * It's necessary to use SDL_FreeWAV() to free the audio data returned in - * \c audio_buf when it is no longer used. - * - * Because of the underspecification of the Waveform format, there are many - * problematic files in the wild that cause issues with strict decoders. To - * provide compatibility with these files, this decoder is lenient in regards - * to the truncation of the file, the fact chunk, and the size of the RIFF - * chunk. The hints SDL_HINT_WAVE_RIFF_CHUNK_SIZE, SDL_HINT_WAVE_TRUNCATION, - * and SDL_HINT_WAVE_FACT_CHUNK can be used to tune the behavior of the - * loading process. - * - * Any file that is invalid (due to truncation, corruption, or wrong values in - * the headers), too big, or unsupported causes an error. Additionally, any - * critical I/O error from the data source will terminate the loading process - * with an error. The function returns NULL on error and in all cases (with the - * exception of \c src being NULL), an appropriate error message will be set. - * - * It is required that the data source supports seeking. - * - * Example: - * \code - * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); - * \endcode - * - * \param src The data source with the WAVE data - * \param freesrc A integer value that makes the function close the data source if non-zero - * \param spec A pointer filled with the audio format of the audio data - * \param audio_buf A pointer filled with the audio data allocated by the function - * \param audio_len A pointer filled with the length of the audio data buffer in bytes - * \return NULL on error, or non-NULL on success. - */ -extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, - int freesrc, - SDL_AudioSpec * spec, - Uint8 ** audio_buf, - Uint32 * audio_len); - -/** - * Loads a WAV from a file. - * Compatibility convenience function. - */ -#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ - SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) - -/** - * This function frees data previously allocated with SDL_LoadWAV_RW() - */ -extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf); - -/** - * This function takes a source format and rate and a destination format - * and rate, and initializes the \c cvt structure with information needed - * by SDL_ConvertAudio() to convert a buffer of audio data from one format - * to the other. An unsupported format causes an error and -1 will be returned. - * - * \return 0 if no conversion is needed, 1 if the audio filter is set up, - * or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, - SDL_AudioFormat src_format, - Uint8 src_channels, - int src_rate, - SDL_AudioFormat dst_format, - Uint8 dst_channels, - int dst_rate); - -/** - * Once you have initialized the \c cvt structure using SDL_BuildAudioCVT(), - * created an audio buffer \c cvt->buf, and filled it with \c cvt->len bytes of - * audio data in the source format, this function will convert it in-place - * to the desired format. - * - * The data conversion may expand the size of the audio data, so the buffer - * \c cvt->buf should be allocated after the \c cvt structure is initialized by - * SDL_BuildAudioCVT(), and should be \c cvt->len*cvt->len_mult bytes long. - * - * \return 0 on success or -1 if \c cvt->buf is NULL. - */ -extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt); - -/* SDL_AudioStream is a new audio conversion interface. - The benefits vs SDL_AudioCVT: - - it can handle resampling data in chunks without generating - artifacts, when it doesn't have the complete buffer available. - - it can handle incoming data in any variable size. - - You push data as you have it, and pull it when you need it - */ -/* this is opaque to the outside world. */ -struct _SDL_AudioStream; -typedef struct _SDL_AudioStream SDL_AudioStream; - -/** - * Create a new audio stream - * - * \param src_format The format of the source audio - * \param src_channels The number of channels of the source audio - * \param src_rate The sampling rate of the source audio - * \param dst_format The format of the desired audio output - * \param dst_channels The number of channels of the desired audio output - * \param dst_rate The sampling rate of the desired audio output - * \return 0 on success, or -1 on error. - * - * \sa SDL_AudioStreamPut - * \sa SDL_AudioStreamGet - * \sa SDL_AudioStreamAvailable - * \sa SDL_AudioStreamFlush - * \sa SDL_AudioStreamClear - * \sa SDL_FreeAudioStream - */ -extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioFormat src_format, - const Uint8 src_channels, - const int src_rate, - const SDL_AudioFormat dst_format, - const Uint8 dst_channels, - const int dst_rate); - -/** - * Add data to be converted/resampled to the stream - * - * \param stream The stream the audio data is being added to - * \param buf A pointer to the audio data to add - * \param len The number of bytes to write to the stream - * \return 0 on success, or -1 on error. - * - * \sa SDL_NewAudioStream - * \sa SDL_AudioStreamGet - * \sa SDL_AudioStreamAvailable - * \sa SDL_AudioStreamFlush - * \sa SDL_AudioStreamClear - * \sa SDL_FreeAudioStream - */ -extern DECLSPEC int SDLCALL SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len); - -/** - * Get converted/resampled data from the stream - * - * \param stream The stream the audio is being requested from - * \param buf A buffer to fill with audio data - * \param len The maximum number of bytes to fill - * \return The number of bytes read from the stream, or -1 on error - * - * \sa SDL_NewAudioStream - * \sa SDL_AudioStreamPut - * \sa SDL_AudioStreamAvailable - * \sa SDL_AudioStreamFlush - * \sa SDL_AudioStreamClear - * \sa SDL_FreeAudioStream - */ -extern DECLSPEC int SDLCALL SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len); - -/** - * Get the number of converted/resampled bytes available. The stream may be - * buffering data behind the scenes until it has enough to resample - * correctly, so this number might be lower than what you expect, or even - * be zero. Add more data or flush the stream if you need the data now. - * - * \sa SDL_NewAudioStream - * \sa SDL_AudioStreamPut - * \sa SDL_AudioStreamGet - * \sa SDL_AudioStreamFlush - * \sa SDL_AudioStreamClear - * \sa SDL_FreeAudioStream - */ -extern DECLSPEC int SDLCALL SDL_AudioStreamAvailable(SDL_AudioStream *stream); - -/** - * Tell the stream that you're done sending data, and anything being buffered - * should be converted/resampled and made available immediately. - * - * It is legal to add more data to a stream after flushing, but there will - * be audio gaps in the output. Generally this is intended to signal the - * end of input, so the complete output becomes available. - * - * \sa SDL_NewAudioStream - * \sa SDL_AudioStreamPut - * \sa SDL_AudioStreamGet - * \sa SDL_AudioStreamAvailable - * \sa SDL_AudioStreamClear - * \sa SDL_FreeAudioStream - */ -extern DECLSPEC int SDLCALL SDL_AudioStreamFlush(SDL_AudioStream *stream); - -/** - * Clear any pending data in the stream without converting it - * - * \sa SDL_NewAudioStream - * \sa SDL_AudioStreamPut - * \sa SDL_AudioStreamGet - * \sa SDL_AudioStreamAvailable - * \sa SDL_AudioStreamFlush - * \sa SDL_FreeAudioStream - */ -extern DECLSPEC void SDLCALL SDL_AudioStreamClear(SDL_AudioStream *stream); - -/** - * Free an audio stream - * - * \sa SDL_NewAudioStream - * \sa SDL_AudioStreamPut - * \sa SDL_AudioStreamGet - * \sa SDL_AudioStreamAvailable - * \sa SDL_AudioStreamFlush - * \sa SDL_AudioStreamClear - */ -extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream); - -#define SDL_MIX_MAXVOLUME 128 -/** - * This takes two audio buffers of the playing audio format and mixes - * them, performing addition, volume adjustment, and overflow clipping. - * The volume ranges from 0 - 128, and should be set to ::SDL_MIX_MAXVOLUME - * for full audio volume. Note this does not change hardware volume. - * This is provided for convenience -- you can mix your own audio data. - */ -extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src, - Uint32 len, int volume); - -/** - * This works like SDL_MixAudio(), but you specify the audio format instead of - * using the format of audio device 1. Thus it can be used when no audio - * device is open at all. - */ -extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, - const Uint8 * src, - SDL_AudioFormat format, - Uint32 len, int volume); - -/** - * Queue more audio on non-callback devices. - * - * (If you are looking to retrieve queued audio from a non-callback capture - * device, you want SDL_DequeueAudio() instead. This will return -1 to - * signify an error if you use it with capture devices.) - * - * SDL offers two ways to feed audio to the device: you can either supply a - * callback that SDL triggers with some frequency to obtain more audio - * (pull method), or you can supply no callback, and then SDL will expect - * you to supply data at regular intervals (push method) with this function. - * - * There are no limits on the amount of data you can queue, short of - * exhaustion of address space. Queued data will drain to the device as - * necessary without further intervention from you. If the device needs - * audio but there is not enough queued, it will play silence to make up - * the difference. This means you will have skips in your audio playback - * if you aren't routinely queueing sufficient data. - * - * This function copies the supplied data, so you are safe to free it when - * the function returns. This function is thread-safe, but queueing to the - * same device from two threads at once does not promise which buffer will - * be queued first. - * - * You may not queue audio on a device that is using an application-supplied - * callback; doing so returns an error. You have to use the audio callback - * or queue audio with this function, but not both. - * - * You should not call SDL_LockAudio() on the device before queueing; SDL - * handles locking internally for this function. - * - * \param dev The device ID to which we will queue audio. - * \param data The data to queue to the device for later playback. - * \param len The number of bytes (not samples!) to which (data) points. - * \return 0 on success, or -1 on error. - * - * \sa SDL_GetQueuedAudioSize - * \sa SDL_ClearQueuedAudio - */ -extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len); - -/** - * Dequeue more audio on non-callback devices. - * - * (If you are looking to queue audio for output on a non-callback playback - * device, you want SDL_QueueAudio() instead. This will always return 0 - * if you use it with playback devices.) - * - * SDL offers two ways to retrieve audio from a capture device: you can - * either supply a callback that SDL triggers with some frequency as the - * device records more audio data, (push method), or you can supply no - * callback, and then SDL will expect you to retrieve data at regular - * intervals (pull method) with this function. - * - * There are no limits on the amount of data you can queue, short of - * exhaustion of address space. Data from the device will keep queuing as - * necessary without further intervention from you. This means you will - * eventually run out of memory if you aren't routinely dequeueing data. - * - * Capture devices will not queue data when paused; if you are expecting - * to not need captured audio for some length of time, use - * SDL_PauseAudioDevice() to stop the capture device from queueing more - * data. This can be useful during, say, level loading times. When - * unpaused, capture devices will start queueing data from that point, - * having flushed any capturable data available while paused. - * - * This function is thread-safe, but dequeueing from the same device from - * two threads at once does not promise which thread will dequeued data - * first. - * - * You may not dequeue audio from a device that is using an - * application-supplied callback; doing so returns an error. You have to use - * the audio callback, or dequeue audio with this function, but not both. - * - * You should not call SDL_LockAudio() on the device before queueing; SDL - * handles locking internally for this function. - * - * \param dev The device ID from which we will dequeue audio. - * \param data A pointer into where audio data should be copied. - * \param len The number of bytes (not samples!) to which (data) points. - * \return number of bytes dequeued, which could be less than requested. - * - * \sa SDL_GetQueuedAudioSize - * \sa SDL_ClearQueuedAudio - */ -extern DECLSPEC Uint32 SDLCALL SDL_DequeueAudio(SDL_AudioDeviceID dev, void *data, Uint32 len); - -/** - * Get the number of bytes of still-queued audio. - * - * For playback device: - * - * This is the number of bytes that have been queued for playback with - * SDL_QueueAudio(), but have not yet been sent to the hardware. This - * number may shrink at any time, so this only informs of pending data. - * - * Once we've sent it to the hardware, this function can not decide the - * exact byte boundary of what has been played. It's possible that we just - * gave the hardware several kilobytes right before you called this - * function, but it hasn't played any of it yet, or maybe half of it, etc. - * - * For capture devices: - * - * This is the number of bytes that have been captured by the device and - * are waiting for you to dequeue. This number may grow at any time, so - * this only informs of the lower-bound of available data. - * - * You may not queue audio on a device that is using an application-supplied - * callback; calling this function on such a device always returns 0. - * You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use - * the audio callback, but not both. - * - * You should not call SDL_LockAudio() on the device before querying; SDL - * handles locking internally for this function. - * - * \param dev The device ID of which we will query queued audio size. - * \return Number of bytes (not samples!) of queued audio. - * - * \sa SDL_QueueAudio - * \sa SDL_ClearQueuedAudio - */ -extern DECLSPEC Uint32 SDLCALL SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev); - -/** - * Drop any queued audio data. For playback devices, this is any queued data - * still waiting to be submitted to the hardware. For capture devices, this - * is any data that was queued by the device that hasn't yet been dequeued by - * the application. - * - * Immediately after this call, SDL_GetQueuedAudioSize() will return 0. For - * playback devices, the hardware will start playing silence if more audio - * isn't queued. Unpaused capture devices will start filling the queue again - * as soon as they have more data available (which, depending on the state - * of the hardware and the thread, could be before this function call - * returns!). - * - * This will not prevent playback of queued audio that's already been sent - * to the hardware, as we can not undo that, so expect there to be some - * fraction of a second of audio that might still be heard. This can be - * useful if you want to, say, drop any pending music during a level change - * in your game. - * - * You may not queue audio on a device that is using an application-supplied - * callback; calling this function on such a device is always a no-op. - * You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use - * the audio callback, but not both. - * - * You should not call SDL_LockAudio() on the device before clearing the - * queue; SDL handles locking internally for this function. - * - * This function always succeeds and thus returns void. - * - * \param dev The device ID of which to clear the audio queue. - * - * \sa SDL_QueueAudio - * \sa SDL_GetQueuedAudioSize - */ -extern DECLSPEC void SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev); - - -/** - * \name Audio lock functions - * - * The lock manipulated by these functions protects the callback function. - * During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that - * the callback function is not running. Do not call these from the callback - * function or you will cause deadlock. - */ -/* @{ */ -extern DECLSPEC void SDLCALL SDL_LockAudio(void); -extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev); -extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); -extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev); -/* @} *//* Audio lock functions */ - -/** - * This function shuts down audio processing and closes the audio device. - */ -extern DECLSPEC void SDLCALL SDL_CloseAudio(void); -extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_audio_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_bits.h b/thirdparty/include/SDL2/SDL_bits.h deleted file mode 100644 index db150ed08..000000000 --- a/thirdparty/include/SDL2/SDL_bits.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_bits.h - * - * Functions for fiddling with bits and bitmasks. - */ - -#ifndef SDL_bits_h_ -#define SDL_bits_h_ - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \file SDL_bits.h - */ - -/** - * Get the index of the most significant bit. Result is undefined when called - * with 0. This operation can also be stated as "count leading zeroes" and - * "log base 2". - * - * \return Index of the most significant bit, or -1 if the value is 0. - */ -#if defined(__WATCOMC__) && defined(__386__) -extern _inline int _SDL_clz_watcom (Uint32); -#pragma aux _SDL_clz_watcom = \ - "bsr eax, eax" \ - "xor eax, 31" \ - parm [eax] nomemory \ - value [eax] \ - modify exact [eax] nomemory; -#endif - -SDL_FORCE_INLINE int -SDL_MostSignificantBitIndex32(Uint32 x) -{ -#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) - /* Count Leading Zeroes builtin in GCC. - * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html - */ - if (x == 0) { - return -1; - } - return 31 - __builtin_clz(x); -#elif defined(__WATCOMC__) && defined(__386__) - if (x == 0) { - return -1; - } - return 31 - _SDL_clz_watcom(x); -#else - /* Based off of Bit Twiddling Hacks by Sean Eron Anderson - * , released in the public domain. - * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog - */ - const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; - const int S[] = {1, 2, 4, 8, 16}; - - int msbIndex = 0; - int i; - - if (x == 0) { - return -1; - } - - for (i = 4; i >= 0; i--) - { - if (x & b[i]) - { - x >>= S[i]; - msbIndex |= S[i]; - } - } - - return msbIndex; -#endif -} - -SDL_FORCE_INLINE SDL_bool -SDL_HasExactlyOneBitSet32(Uint32 x) -{ - if (x && !(x & (x - 1))) { - return SDL_TRUE; - } - return SDL_FALSE; -} - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_bits_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_blendmode.h b/thirdparty/include/SDL2/SDL_blendmode.h deleted file mode 100644 index 5e21a79e6..000000000 --- a/thirdparty/include/SDL2/SDL_blendmode.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_blendmode.h - * - * Header file declaring the SDL_BlendMode enumeration - */ - -#ifndef SDL_blendmode_h_ -#define SDL_blendmode_h_ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief The blend mode used in SDL_RenderCopy() and drawing operations. - */ -typedef enum -{ - SDL_BLENDMODE_NONE = 0x00000000, /**< no blending - dstRGBA = srcRGBA */ - SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending - dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) - dstA = srcA + (dstA * (1-srcA)) */ - SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending - dstRGB = (srcRGB * srcA) + dstRGB - dstA = dstA */ - SDL_BLENDMODE_MOD = 0x00000004, /**< color modulate - dstRGB = srcRGB * dstRGB - dstA = dstA */ - SDL_BLENDMODE_MUL = 0x00000008, /**< color multiply - dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)) - dstA = (srcA * dstA) + (dstA * (1-srcA)) */ - SDL_BLENDMODE_INVALID = 0x7FFFFFFF - - /* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */ - -} SDL_BlendMode; - -/** - * \brief The blend operation used when combining source and destination pixel components - */ -typedef enum -{ - SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */ - SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */ - SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */ - SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D11 */ - SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D11 */ - -} SDL_BlendOperation; - -/** - * \brief The normalized factor used to multiply pixel components - */ -typedef enum -{ - SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */ - SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */ - SDL_BLENDFACTOR_SRC_COLOR = 0x3, /**< srcR, srcG, srcB, srcA */ - SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4, /**< 1-srcR, 1-srcG, 1-srcB, 1-srcA */ - SDL_BLENDFACTOR_SRC_ALPHA = 0x5, /**< srcA, srcA, srcA, srcA */ - SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6, /**< 1-srcA, 1-srcA, 1-srcA, 1-srcA */ - SDL_BLENDFACTOR_DST_COLOR = 0x7, /**< dstR, dstG, dstB, dstA */ - SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */ - SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */ - SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */ - -} SDL_BlendFactor; - -/** - * \brief Create a custom blend mode, which may or may not be supported by a given renderer - * - * \param srcColorFactor source color factor - * \param dstColorFactor destination color factor - * \param colorOperation color operation - * \param srcAlphaFactor source alpha factor - * \param dstAlphaFactor destination alpha factor - * \param alphaOperation alpha operation - * - * The result of the blend mode operation will be: - * dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor - * and - * dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor - */ -extern DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, - SDL_BlendFactor dstColorFactor, - SDL_BlendOperation colorOperation, - SDL_BlendFactor srcAlphaFactor, - SDL_BlendFactor dstAlphaFactor, - SDL_BlendOperation alphaOperation); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_blendmode_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_clipboard.h b/thirdparty/include/SDL2/SDL_clipboard.h deleted file mode 100644 index dbf69fcea..000000000 --- a/thirdparty/include/SDL2/SDL_clipboard.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_clipboard.h - * - * Include file for SDL clipboard handling - */ - -#ifndef SDL_clipboard_h_ -#define SDL_clipboard_h_ - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Function prototypes */ - -/** - * \brief Put UTF-8 text into the clipboard - * - * \sa SDL_GetClipboardText() - */ -extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); - -/** - * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() - * - * \sa SDL_SetClipboardText() - */ -extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); - -/** - * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty - * - * \sa SDL_GetClipboardText() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_clipboard_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_config.h b/thirdparty/include/SDL2/SDL_config.h deleted file mode 100644 index efebe9f02..000000000 --- a/thirdparty/include/SDL2/SDL_config.h +++ /dev/null @@ -1,259 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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 SDL_config_windows_h_ -#define SDL_config_windows_h_ -#define SDL_config_h_ - -#include "SDL_platform.h" - -/* This is a set of defines to configure the SDL features */ - -#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) -#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) -#define HAVE_STDINT_H 1 -#elif defined(_MSC_VER) -typedef signed __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef signed __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef signed __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; -#ifndef _UINTPTR_T_DEFINED -#ifdef _WIN64 -typedef unsigned __int64 uintptr_t; -#else -typedef unsigned int uintptr_t; -#endif -#define _UINTPTR_T_DEFINED -#endif -/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ -#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) -#define DWORD_PTR DWORD -#endif -#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) -#define LONG_PTR LONG -#endif -#else /* !__GNUC__ && !_MSC_VER */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -#ifndef _SIZE_T_DEFINED_ -#define _SIZE_T_DEFINED_ -typedef unsigned int size_t; -#endif -typedef unsigned int uintptr_t; -#endif /* __GNUC__ || _MSC_VER */ -#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ - -#ifdef _WIN64 -# define SIZEOF_VOIDP 8 -#else -# define SIZEOF_VOIDP 4 -#endif - -#define HAVE_DDRAW_H 1 -#define HAVE_DINPUT_H 1 -#define HAVE_DSOUND_H 1 -#define HAVE_DXGI_H 1 -#define HAVE_XINPUT_H 1 -#define HAVE_MMDEVICEAPI_H 1 -#define HAVE_AUDIOCLIENT_H 1 - -/* This is disabled by default to avoid C runtime dependencies and manifest requirements */ -#ifdef HAVE_LIBC -/* Useful headers */ -#define STDC_HEADERS 1 -#define HAVE_CTYPE_H 1 -#define HAVE_FLOAT_H 1 -#define HAVE_LIMITS_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 -#define HAVE_STDIO_H 1 -#define HAVE_STRING_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE__STRREV 1 -/* These functions have security warnings, so we won't use them */ -/* #undef HAVE__STRUPR */ -/* #undef HAVE__STRLWR */ -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -/* #undef HAVE_STRTOK_R */ -#if defined(_MSC_VER) -#define HAVE_STRTOK_S 1 -#endif -/* These functions have security warnings, so we won't use them */ -/* #undef HAVE__LTOA */ -/* #undef HAVE__ULTOA */ -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE__STRICMP 1 -#define HAVE__STRNICMP 1 -#define HAVE_ACOS 1 -#define HAVE_ACOSF 1 -#define HAVE_ASIN 1 -#define HAVE_ASINF 1 -#define HAVE_ATAN 1 -#define HAVE_ATANF 1 -#define HAVE_ATAN2 1 -#define HAVE_ATAN2F 1 -#define HAVE_CEILF 1 -#define HAVE__COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_EXP 1 -#define HAVE_EXPF 1 -#define HAVE_FABS 1 -#define HAVE_FABSF 1 -#define HAVE_FLOOR 1 -#define HAVE_FLOORF 1 -#define HAVE_FMOD 1 -#define HAVE_FMODF 1 -#define HAVE_LOG 1 -#define HAVE_LOGF 1 -#define HAVE_LOG10 1 -#define HAVE_LOG10F 1 -#define HAVE_POW 1 -#define HAVE_POWF 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#if defined(_MSC_VER) -/* These functions were added with the VC++ 2013 C runtime library */ -#if _MSC_VER >= 1800 -#define HAVE_STRTOLL 1 -#define HAVE_VSSCANF 1 -#define HAVE_SCALBN 1 -#define HAVE_SCALBNF 1 -#endif -/* This function is available with at least the VC++ 2008 C runtime library */ -#if _MSC_VER >= 1400 -#define HAVE__FSEEKI64 1 -#endif -#endif -#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) -#define HAVE_M_PI 1 -#endif -#else -#define HAVE_STDARG_H 1 -#define HAVE_STDDEF_H 1 -#endif - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_WASAPI 1 -#define SDL_AUDIO_DRIVER_DSOUND 1 -#define SDL_AUDIO_DRIVER_WINMM 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various input drivers */ -#define SDL_JOYSTICK_DINPUT 1 -#define SDL_JOYSTICK_XINPUT 1 -#define SDL_JOYSTICK_HIDAPI 1 -#define SDL_HAPTIC_DINPUT 1 -#define SDL_HAPTIC_XINPUT 1 - -/* Enable the dummy sensor driver */ -#define SDL_SENSOR_DUMMY 1 - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_WINDOWS 1 - -/* Enable various threading systems */ -#define SDL_THREAD_WINDOWS 1 - -/* Enable various timer systems */ -#define SDL_TIMER_WINDOWS 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_DUMMY 1 - -#ifndef SDL_VIDEO_RENDER_D3D -#define SDL_VIDEO_RENDER_D3D 1 -#endif -#ifndef SDL_VIDEO_RENDER_D3D11 -#define SDL_VIDEO_RENDER_D3D11 0 -#endif - -/* Enable OpenGL support */ -#ifndef SDL_VIDEO_OPENGL -#define SDL_VIDEO_OPENGL 1 -#endif -#ifndef SDL_VIDEO_OPENGL_WGL -#define SDL_VIDEO_OPENGL_WGL 1 -#endif -#ifndef SDL_VIDEO_RENDER_OGL -#define SDL_VIDEO_RENDER_OGL 1 -#endif -#ifndef SDL_VIDEO_RENDER_OGL_ES2 -#define SDL_VIDEO_RENDER_OGL_ES2 1 -#endif -#ifndef SDL_VIDEO_OPENGL_ES2 -#define SDL_VIDEO_OPENGL_ES2 1 -#endif -#ifndef SDL_VIDEO_OPENGL_EGL -#define SDL_VIDEO_OPENGL_EGL 1 -#endif - -/* Enable Vulkan support */ -#define SDL_VIDEO_VULKAN 1 - -/* Enable system power support */ -#define SDL_POWER_WINDOWS 1 - -/* Enable filesystem support */ -#define SDL_FILESYSTEM_WINDOWS 1 - -/* Enable assembly routines (Win64 doesn't have inline asm) */ -#ifndef _WIN64 -#define SDL_ASSEMBLY_ROUTINES 1 -#endif - -#endif /* SDL_config_windows_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config.h.cmake b/thirdparty/include/SDL2/SDL_config.h.cmake deleted file mode 100644 index c57266c41..000000000 --- a/thirdparty/include/SDL2/SDL_config.h.cmake +++ /dev/null @@ -1,445 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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 SDL_config_h_ -#define SDL_config_h_ - -/** - * \file SDL_config.h.in - * - * This is a set of defines to configure the SDL features - */ - -/* General platform specific identifiers */ -#include "SDL_platform.h" - -/* C language features */ -#cmakedefine const @HAVE_CONST@ -#cmakedefine inline @HAVE_INLINE@ -#cmakedefine volatile @HAVE_VOLATILE@ - -/* C datatypes */ -/* Define SIZEOF_VOIDP for 64/32 architectures */ -#ifdef __LP64__ -#define SIZEOF_VOIDP 8 -#else -#define SIZEOF_VOIDP 4 -#endif - -#cmakedefine HAVE_GCC_ATOMICS @HAVE_GCC_ATOMICS@ -#cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET @HAVE_GCC_SYNC_LOCK_TEST_AND_SET@ - -#cmakedefine HAVE_D3D_H @HAVE_D3D_H@ -#cmakedefine HAVE_D3D11_H @HAVE_D3D11_H@ -#cmakedefine HAVE_DDRAW_H @HAVE_DDRAW_H@ -#cmakedefine HAVE_DSOUND_H @HAVE_DSOUND_H@ -#cmakedefine HAVE_DINPUT_H @HAVE_DINPUT_H@ -#cmakedefine HAVE_XAUDIO2_H @HAVE_XAUDIO2_H@ -#cmakedefine HAVE_XINPUT_H @HAVE_XINPUT_H@ -#cmakedefine HAVE_DXGI_H @HAVE_DXGI_H@ -#cmakedefine HAVE_XINPUT_GAMEPAD_EX @HAVE_XINPUT_GAMEPAD_EX@ -#cmakedefine HAVE_XINPUT_STATE_EX @HAVE_XINPUT_STATE_EX@ - -/* Comment this if you want to build without any C library requirements */ -#cmakedefine HAVE_LIBC 1 -#if HAVE_LIBC - -/* Useful headers */ -#cmakedefine HAVE_ALLOCA_H 1 -#cmakedefine HAVE_SYS_TYPES_H 1 -#cmakedefine HAVE_STDIO_H 1 -#cmakedefine STDC_HEADERS 1 -#cmakedefine HAVE_STDLIB_H 1 -#cmakedefine HAVE_STDARG_H 1 -#cmakedefine HAVE_MALLOC_H 1 -#cmakedefine HAVE_MEMORY_H 1 -#cmakedefine HAVE_STRING_H 1 -#cmakedefine HAVE_STRINGS_H 1 -#cmakedefine HAVE_WCHAR_H 1 -#cmakedefine HAVE_INTTYPES_H 1 -#cmakedefine HAVE_STDINT_H 1 -#cmakedefine HAVE_CTYPE_H 1 -#cmakedefine HAVE_MATH_H 1 -#cmakedefine HAVE_ICONV_H 1 -#cmakedefine HAVE_SIGNAL_H 1 -#cmakedefine HAVE_ALTIVEC_H 1 -#cmakedefine HAVE_PTHREAD_NP_H 1 -#cmakedefine HAVE_LIBUDEV_H 1 -#cmakedefine HAVE_DBUS_DBUS_H 1 -#cmakedefine HAVE_IBUS_IBUS_H 1 -#cmakedefine HAVE_FCITX_FRONTEND_H 1 -#cmakedefine HAVE_LIBSAMPLERATE_H 1 - -/* C library functions */ -#cmakedefine HAVE_MALLOC 1 -#cmakedefine HAVE_CALLOC 1 -#cmakedefine HAVE_REALLOC 1 -#cmakedefine HAVE_FREE 1 -#cmakedefine HAVE_ALLOCA 1 -#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ -#cmakedefine HAVE_GETENV 1 -#cmakedefine HAVE_SETENV 1 -#cmakedefine HAVE_PUTENV 1 -#cmakedefine HAVE_UNSETENV 1 -#endif -#cmakedefine HAVE_QSORT 1 -#cmakedefine HAVE_ABS 1 -#cmakedefine HAVE_BCOPY 1 -#cmakedefine HAVE_MEMSET 1 -#cmakedefine HAVE_MEMCPY 1 -#cmakedefine HAVE_MEMMOVE 1 -#cmakedefine HAVE_MEMCMP 1 -#cmakedefine HAVE_WCSLEN 1 -#cmakedefine HAVE_WCSLCPY 1 -#cmakedefine HAVE_WCSLCAT 1 -#cmakedefine HAVE_WCSCMP 1 -#cmakedefine HAVE_STRLEN 1 -#cmakedefine HAVE_STRLCPY 1 -#cmakedefine HAVE_STRLCAT 1 -#cmakedefine HAVE_STRDUP 1 -#cmakedefine HAVE__STRREV 1 -#cmakedefine HAVE__STRUPR 1 -#cmakedefine HAVE__STRLWR 1 -#cmakedefine HAVE_INDEX 1 -#cmakedefine HAVE_RINDEX 1 -#cmakedefine HAVE_STRCHR 1 -#cmakedefine HAVE_STRRCHR 1 -#cmakedefine HAVE_STRSTR 1 -#cmakedefine HAVE_ITOA 1 -#cmakedefine HAVE__LTOA 1 -#cmakedefine HAVE__UITOA 1 -#cmakedefine HAVE__ULTOA 1 -#cmakedefine HAVE_STRTOL 1 -#cmakedefine HAVE_STRTOUL 1 -#cmakedefine HAVE__I64TOA 1 -#cmakedefine HAVE__UI64TOA 1 -#cmakedefine HAVE_STRTOLL 1 -#cmakedefine HAVE_STRTOULL 1 -#cmakedefine HAVE_STRTOD 1 -#cmakedefine HAVE_ATOI 1 -#cmakedefine HAVE_ATOF 1 -#cmakedefine HAVE_STRCMP 1 -#cmakedefine HAVE_STRNCMP 1 -#cmakedefine HAVE__STRICMP 1 -#cmakedefine HAVE_STRCASECMP 1 -#cmakedefine HAVE__STRNICMP 1 -#cmakedefine HAVE_STRNCASECMP 1 -#cmakedefine HAVE_VSSCANF 1 -#cmakedefine HAVE_VSNPRINTF 1 -#cmakedefine HAVE_M_PI 1 -#cmakedefine HAVE_ATAN 1 -#cmakedefine HAVE_ATAN2 1 -#cmakedefine HAVE_ACOS 1 -#cmakedefine HAVE_ASIN 1 -#cmakedefine HAVE_CEIL 1 -#cmakedefine HAVE_COPYSIGN 1 -#cmakedefine HAVE_COS 1 -#cmakedefine HAVE_COSF 1 -#cmakedefine HAVE_FABS 1 -#cmakedefine HAVE_FLOOR 1 -#cmakedefine HAVE_LOG 1 -#cmakedefine HAVE_POW 1 -#cmakedefine HAVE_SCALBN 1 -#cmakedefine HAVE_SIN 1 -#cmakedefine HAVE_SINF 1 -#cmakedefine HAVE_SQRT 1 -#cmakedefine HAVE_SQRTF 1 -#cmakedefine HAVE_TAN 1 -#cmakedefine HAVE_TANF 1 -#cmakedefine HAVE_FOPEN64 1 -#cmakedefine HAVE_FSEEKO 1 -#cmakedefine HAVE_FSEEKO64 1 -#cmakedefine HAVE_SIGACTION 1 -#cmakedefine HAVE_SA_SIGACTION 1 -#cmakedefine HAVE_SETJMP 1 -#cmakedefine HAVE_NANOSLEEP 1 -#cmakedefine HAVE_SYSCONF 1 -#cmakedefine HAVE_SYSCTLBYNAME 1 -#cmakedefine HAVE_CLOCK_GETTIME 1 -#cmakedefine HAVE_GETPAGESIZE 1 -#cmakedefine HAVE_MPROTECT 1 -#cmakedefine HAVE_ICONV 1 -#cmakedefine HAVE_PTHREAD_SETNAME_NP 1 -#cmakedefine HAVE_PTHREAD_SET_NAME_NP 1 -#cmakedefine HAVE_SEM_TIMEDWAIT 1 -#cmakedefine HAVE_GETAUXVAL 1 -#cmakedefine HAVE_POLL 1 - -#elif __WIN32__ -#cmakedefine HAVE_STDARG_H 1 -#cmakedefine HAVE_STDDEF_H 1 -#else -/* We may need some replacement for stdarg.h here */ -#include -#endif /* HAVE_LIBC */ - -/* SDL internal assertion support */ -#cmakedefine SDL_DEFAULT_ASSERT_LEVEL @SDL_DEFAULT_ASSERT_LEVEL@ - -/* Allow disabling of core subsystems */ -#cmakedefine SDL_ATOMIC_DISABLED @SDL_ATOMIC_DISABLED@ -#cmakedefine SDL_AUDIO_DISABLED @SDL_AUDIO_DISABLED@ -#cmakedefine SDL_CPUINFO_DISABLED @SDL_CPUINFO_DISABLED@ -#cmakedefine SDL_EVENTS_DISABLED @SDL_EVENTS_DISABLED@ -#cmakedefine SDL_FILE_DISABLED @SDL_FILE_DISABLED@ -#cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@ -#cmakedefine SDL_HAPTIC_DISABLED @SDL_HAPTIC_DISABLED@ -#cmakedefine SDL_LOADSO_DISABLED @SDL_LOADSO_DISABLED@ -#cmakedefine SDL_RENDER_DISABLED @SDL_RENDER_DISABLED@ -#cmakedefine SDL_THREADS_DISABLED @SDL_THREADS_DISABLED@ -#cmakedefine SDL_TIMERS_DISABLED @SDL_TIMERS_DISABLED@ -#cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@ -#cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@ -#cmakedefine SDL_FILESYSTEM_DISABLED @SDL_FILESYSTEM_DISABLED@ - -/* Enable various audio drivers */ -#cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@ -#cmakedefine SDL_AUDIO_DRIVER_ALSA_DYNAMIC @SDL_AUDIO_DRIVER_ALSA_DYNAMIC@ -#cmakedefine SDL_AUDIO_DRIVER_ANDROID @SDL_AUDIO_DRIVER_ANDROID@ -#cmakedefine SDL_AUDIO_DRIVER_ARTS @SDL_AUDIO_DRIVER_ARTS@ -#cmakedefine SDL_AUDIO_DRIVER_ARTS_DYNAMIC @SDL_AUDIO_DRIVER_ARTS_DYNAMIC@ -#cmakedefine SDL_AUDIO_DRIVER_COREAUDIO @SDL_AUDIO_DRIVER_COREAUDIO@ -#cmakedefine SDL_AUDIO_DRIVER_DISK @SDL_AUDIO_DRIVER_DISK@ -#cmakedefine SDL_AUDIO_DRIVER_DSOUND @SDL_AUDIO_DRIVER_DSOUND@ -#cmakedefine SDL_AUDIO_DRIVER_DUMMY @SDL_AUDIO_DRIVER_DUMMY@ -#cmakedefine SDL_AUDIO_DRIVER_EMSCRIPTEN @SDL_AUDIO_DRIVER_EMSCRIPTEN@ -#cmakedefine SDL_AUDIO_DRIVER_ESD @SDL_AUDIO_DRIVER_ESD@ -#cmakedefine SDL_AUDIO_DRIVER_ESD_DYNAMIC @SDL_AUDIO_DRIVER_ESD_DYNAMIC@ -#cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND @SDL_AUDIO_DRIVER_FUSIONSOUND@ -#cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC @SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC@ -#cmakedefine SDL_AUDIO_DRIVER_HAIKU @SDL_AUDIO_DRIVER_HAIKU@ -#cmakedefine SDL_AUDIO_DRIVER_JACK @SDL_AUDIO_DRIVER_JACK@ -#cmakedefine SDL_AUDIO_DRIVER_JACK_DYNAMIC @SDL_AUDIO_DRIVER_JACK_DYNAMIC@ -#cmakedefine SDL_AUDIO_DRIVER_NAS @SDL_AUDIO_DRIVER_NAS@ -#cmakedefine SDL_AUDIO_DRIVER_NAS_DYNAMIC @SDL_AUDIO_DRIVER_NAS_DYNAMIC@ -#cmakedefine SDL_AUDIO_DRIVER_NETBSD @SDL_AUDIO_DRIVER_NETBSD@ -#cmakedefine SDL_AUDIO_DRIVER_OSS @SDL_AUDIO_DRIVER_OSS@ -#cmakedefine SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H @SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H@ -#cmakedefine SDL_AUDIO_DRIVER_PAUDIO @SDL_AUDIO_DRIVER_PAUDIO@ -#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO @SDL_AUDIO_DRIVER_PULSEAUDIO@ -#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC @SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC@ -#cmakedefine SDL_AUDIO_DRIVER_QSA @SDL_AUDIO_DRIVER_QSA@ -#cmakedefine SDL_AUDIO_DRIVER_SNDIO @SDL_AUDIO_DRIVER_SNDIO@ -#cmakedefine SDL_AUDIO_DRIVER_SNDIO_DYNAMIC @SDL_AUDIO_DRIVER_SNDIO_DYNAMIC@ -#cmakedefine SDL_AUDIO_DRIVER_SUNAUDIO @SDL_AUDIO_DRIVER_SUNAUDIO@ -#cmakedefine SDL_AUDIO_DRIVER_WASAPI @SDL_AUDIO_DRIVER_WASAPI@ -#cmakedefine SDL_AUDIO_DRIVER_WINMM @SDL_AUDIO_DRIVER_WINMM@ -#cmakedefine SDL_AUDIO_DRIVER_XAUDIO2 @SDL_AUDIO_DRIVER_XAUDIO2@ - -/* Enable various input drivers */ -#cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@ -#cmakedefine SDL_INPUT_LINUXKD @SDL_INPUT_LINUXKD@ -#cmakedefine SDL_INPUT_TSLIB @SDL_INPUT_TSLIB@ -#cmakedefine SDL_JOYSTICK_ANDROID @SDL_JOYSTICK_ANDROID@ -#cmakedefine SDL_JOYSTICK_HAIKU @SDL_JOYSTICK_HAIKU@ -#cmakedefine SDL_JOYSTICK_DINPUT @SDL_JOYSTICK_DINPUT@ -#cmakedefine SDL_JOYSTICK_XINPUT @SDL_JOYSTICK_XINPUT@ -#cmakedefine SDL_JOYSTICK_DUMMY @SDL_JOYSTICK_DUMMY@ -#cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@ -#cmakedefine SDL_JOYSTICK_MFI @SDL_JOYSTICK_MFI@ -#cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@ -#cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@ -#cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@ -#cmakedefine SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H@ -#cmakedefine SDL_JOYSTICK_EMSCRIPTEN @SDL_JOYSTICK_EMSCRIPTEN@ -#cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@ -#cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@ -#cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@ -#cmakedefine SDL_HAPTIC_DINPUT @SDL_HAPTIC_DINPUT@ -#cmakedefine SDL_HAPTIC_XINPUT @SDL_HAPTIC_XINPUT@ -#cmakedefine SDL_HAPTIC_ANDROID @SDL_HAPTIC_ANDROID@ - -/* Enable various shared object loading systems */ -#cmakedefine SDL_LOADSO_DLOPEN @SDL_LOADSO_DLOPEN@ -#cmakedefine SDL_LOADSO_DUMMY @SDL_LOADSO_DUMMY@ -#cmakedefine SDL_LOADSO_LDG @SDL_LOADSO_LDG@ -#cmakedefine SDL_LOADSO_WINDOWS @SDL_LOADSO_WINDOWS@ - -/* Enable various threading systems */ -#cmakedefine SDL_THREAD_PTHREAD @SDL_THREAD_PTHREAD@ -#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX@ -#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP@ -#cmakedefine SDL_THREAD_WINDOWS @SDL_THREAD_WINDOWS@ - -/* Enable various timer systems */ -#cmakedefine SDL_TIMER_HAIKU @SDL_TIMER_HAIKU@ -#cmakedefine SDL_TIMER_DUMMY @SDL_TIMER_DUMMY@ -#cmakedefine SDL_TIMER_UNIX @SDL_TIMER_UNIX@ -#cmakedefine SDL_TIMER_WINDOWS @SDL_TIMER_WINDOWS@ -#cmakedefine SDL_TIMER_WINCE @SDL_TIMER_WINCE@ - -/* Enable various video drivers */ -#cmakedefine SDL_VIDEO_DRIVER_ANDROID @SDL_VIDEO_DRIVER_ANDROID@ -#cmakedefine SDL_VIDEO_DRIVER_HAIKU @SDL_VIDEO_DRIVER_HAIKU@ -#cmakedefine SDL_VIDEO_DRIVER_COCOA @SDL_VIDEO_DRIVER_COCOA@ -#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB @SDL_VIDEO_DRIVER_DIRECTFB@ -#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC @SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC@ -#cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@ -#cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@ -#cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@ -#cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@ -#cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@ -#cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@ - -#cmakedefine SDL_VIDEO_DRIVER_KMSDRM @SDL_VIDEO_DRIVER_KMSDRM@ -#cmakedefine SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC @SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC@ -#cmakedefine SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM @SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM@ - -#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH @SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH@ -#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC@ -#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL@ -#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR@ -#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON@ - -#cmakedefine SDL_VIDEO_DRIVER_MIR @SDL_VIDEO_DRIVER_MIR@ -#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC @SDL_VIDEO_DRIVER_MIR_DYNAMIC@ -#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON@ -#cmakedefine SDL_VIDEO_DRIVER_EMSCRIPTEN @SDL_VIDEO_DRIVER_EMSCRIPTEN@ -#cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@ -#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@ -#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT @SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT@ -#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR@ -#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA @SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA@ -#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 @SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2@ -#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR@ -#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS @SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS@ -#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE @SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE@ -#cmakedefine SDL_VIDEO_DRIVER_X11_XCURSOR @SDL_VIDEO_DRIVER_X11_XCURSOR@ -#cmakedefine SDL_VIDEO_DRIVER_X11_XDBE @SDL_VIDEO_DRIVER_X11_XDBE@ -#cmakedefine SDL_VIDEO_DRIVER_X11_XINERAMA @SDL_VIDEO_DRIVER_X11_XINERAMA@ -#cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2 @SDL_VIDEO_DRIVER_X11_XINPUT2@ -#cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH @SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH@ -#cmakedefine SDL_VIDEO_DRIVER_X11_XRANDR @SDL_VIDEO_DRIVER_X11_XRANDR@ -#cmakedefine SDL_VIDEO_DRIVER_X11_XSCRNSAVER @SDL_VIDEO_DRIVER_X11_XSCRNSAVER@ -#cmakedefine SDL_VIDEO_DRIVER_X11_XSHAPE @SDL_VIDEO_DRIVER_X11_XSHAPE@ -#cmakedefine SDL_VIDEO_DRIVER_X11_XVIDMODE @SDL_VIDEO_DRIVER_X11_XVIDMODE@ -#cmakedefine SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS @SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS@ -#cmakedefine SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY @SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY@ -#cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@ - -#cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@ -#cmakedefine SDL_VIDEO_RENDER_D3D11 @SDL_VIDEO_RENDER_D3D11@ -#cmakedefine SDL_VIDEO_RENDER_OGL @SDL_VIDEO_RENDER_OGL@ -#cmakedefine SDL_VIDEO_RENDER_OGL_ES @SDL_VIDEO_RENDER_OGL_ES@ -#cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@ -#cmakedefine SDL_VIDEO_RENDER_DIRECTFB @SDL_VIDEO_RENDER_DIRECTFB@ - -/* Enable OpenGL support */ -#cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@ -#cmakedefine SDL_VIDEO_OPENGL_ES @SDL_VIDEO_OPENGL_ES@ -#cmakedefine SDL_VIDEO_OPENGL_ES2 @SDL_VIDEO_OPENGL_ES2@ -#cmakedefine SDL_VIDEO_OPENGL_BGL @SDL_VIDEO_OPENGL_BGL@ -#cmakedefine SDL_VIDEO_OPENGL_CGL @SDL_VIDEO_OPENGL_CGL@ -#cmakedefine SDL_VIDEO_OPENGL_GLX @SDL_VIDEO_OPENGL_GLX@ -#cmakedefine SDL_VIDEO_OPENGL_WGL @SDL_VIDEO_OPENGL_WGL@ -#cmakedefine SDL_VIDEO_OPENGL_EGL @SDL_VIDEO_OPENGL_EGL@ -#cmakedefine SDL_VIDEO_OPENGL_OSMESA @SDL_VIDEO_OPENGL_OSMESA@ -#cmakedefine SDL_VIDEO_OPENGL_OSMESA_DYNAMIC @SDL_VIDEO_OPENGL_OSMESA_DYNAMIC@ - -/* Enable Vulkan support */ -#cmakedefine SDL_VIDEO_VULKAN @SDL_VIDEO_VULKAN@ - -/* Enable system power support */ -#cmakedefine SDL_POWER_ANDROID @SDL_POWER_ANDROID@ -#cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@ -#cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@ -#cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@ -#cmakedefine SDL_POWER_HAIKU @SDL_POWER_HAIKU@ -#cmakedefine SDL_POWER_EMSCRIPTEN @SDL_POWER_EMSCRIPTEN@ -#cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@ - -/* Enable system filesystem support */ -#cmakedefine SDL_FILESYSTEM_ANDROID @SDL_FILESYSTEM_ANDROID@ -#cmakedefine SDL_FILESYSTEM_HAIKU @SDL_FILESYSTEM_HAIKU@ -#cmakedefine SDL_FILESYSTEM_COCOA @SDL_FILESYSTEM_COCOA@ -#cmakedefine SDL_FILESYSTEM_DUMMY @SDL_FILESYSTEM_DUMMY@ -#cmakedefine SDL_FILESYSTEM_UNIX @SDL_FILESYSTEM_UNIX@ -#cmakedefine SDL_FILESYSTEM_WINDOWS @SDL_FILESYSTEM_WINDOWS@ -#cmakedefine SDL_FILESYSTEM_EMSCRIPTEN @SDL_FILESYSTEM_EMSCRIPTEN@ - -/* Enable assembly routines */ -#cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@ -#cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@ - -/* Enable dynamic libsamplerate support */ -#cmakedefine SDL_LIBSAMPLERATE_DYNAMIC @SDL_LIBSAMPLERATE_DYNAMIC@ - -/* Platform specific definitions */ -#if !defined(__WIN32__) -# if !defined(_STDINT_H_) && !defined(_STDINT_H) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H) -typedef unsigned int size_t; -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -typedef unsigned long uintptr_t; -# endif /* if (stdint.h isn't available) */ -#else /* __WIN32__ */ -# if !defined(_STDINT_H_) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H) -# if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) -#define HAVE_STDINT_H 1 -# elif defined(_MSC_VER) -typedef signed __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef signed __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef signed __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; -# ifndef _UINTPTR_T_DEFINED -# ifdef _WIN64 -typedef unsigned __int64 uintptr_t; -# else -typedef unsigned int uintptr_t; -# endif -#define _UINTPTR_T_DEFINED -# endif -/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ -# if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) -#define DWORD_PTR DWORD -# endif -# if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) -#define LONG_PTR LONG -# endif -# else /* !__GNUC__ && !_MSC_VER */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -# ifndef _SIZE_T_DEFINED_ -#define _SIZE_T_DEFINED_ -typedef unsigned int size_t; -# endif -typedef unsigned int uintptr_t; -# endif /* __GNUC__ || _MSC_VER */ -# endif /* !_STDINT_H_ && !HAVE_STDINT_H */ -#endif /* __WIN32__ */ - -#endif /* SDL_config_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config.h.in b/thirdparty/include/SDL2/SDL_config.h.in deleted file mode 100644 index 8b3d20880..000000000 --- a/thirdparty/include/SDL2/SDL_config.h.in +++ /dev/null @@ -1,389 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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 SDL_config_h_ -#define SDL_config_h_ - -/** - * \file SDL_config.h.in - * - * This is a set of defines to configure the SDL features - */ - -/* General platform specific identifiers */ -#include "SDL_platform.h" - -/* Make sure that this isn't included by Visual C++ */ -#ifdef _MSC_VER -#error You should run hg revert SDL_config.h -#endif - -/* C language features */ -#undef const -#undef inline -#undef volatile - -/* C datatypes */ -#ifdef __LP64__ -#define SIZEOF_VOIDP 8 -#else -#define SIZEOF_VOIDP 4 -#endif -#undef HAVE_GCC_ATOMICS -#undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET - -#undef HAVE_DDRAW_H -#undef HAVE_DINPUT_H -#undef HAVE_DSOUND_H -#undef HAVE_DXGI_H -#undef HAVE_XINPUT_H -#undef HAVE_XINPUT_GAMEPAD_EX -#undef HAVE_XINPUT_STATE_EX - -/* Comment this if you want to build without any C library requirements */ -#undef HAVE_LIBC -#if HAVE_LIBC - -/* Useful headers */ -#undef HAVE_ALLOCA_H -#undef HAVE_SYS_TYPES_H -#undef HAVE_STDIO_H -#undef STDC_HEADERS -#undef HAVE_STDLIB_H -#undef HAVE_STDARG_H -#undef HAVE_MALLOC_H -#undef HAVE_MEMORY_H -#undef HAVE_STRING_H -#undef HAVE_STRINGS_H -#undef HAVE_WCHAR_H -#undef HAVE_INTTYPES_H -#undef HAVE_STDINT_H -#undef HAVE_CTYPE_H -#undef HAVE_MATH_H -#undef HAVE_ICONV_H -#undef HAVE_SIGNAL_H -#undef HAVE_ALTIVEC_H -#undef HAVE_PTHREAD_NP_H -#undef HAVE_LIBUDEV_H -#undef HAVE_DBUS_DBUS_H -#undef HAVE_IBUS_IBUS_H -#undef HAVE_FCITX_FRONTEND_H -#undef HAVE_LIBSAMPLERATE_H - -/* C library functions */ -#undef HAVE_MALLOC -#undef HAVE_CALLOC -#undef HAVE_REALLOC -#undef HAVE_FREE -#undef HAVE_ALLOCA -#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ -#undef HAVE_GETENV -#undef HAVE_SETENV -#undef HAVE_PUTENV -#undef HAVE_UNSETENV -#endif -#undef HAVE_QSORT -#undef HAVE_ABS -#undef HAVE_BCOPY -#undef HAVE_MEMSET -#undef HAVE_MEMCPY -#undef HAVE_MEMMOVE -#undef HAVE_MEMCMP -#undef HAVE_WCSLEN -#undef HAVE_WCSLCPY -#undef HAVE_WCSLCAT -#undef HAVE_WCSCMP -#undef HAVE_STRLEN -#undef HAVE_STRLCPY -#undef HAVE_STRLCAT -#undef HAVE_STRDUP -#undef HAVE__STRREV -#undef HAVE__STRUPR -#undef HAVE__STRLWR -#undef HAVE_INDEX -#undef HAVE_RINDEX -#undef HAVE_STRCHR -#undef HAVE_STRRCHR -#undef HAVE_STRSTR -#undef HAVE_ITOA -#undef HAVE__LTOA -#undef HAVE__UITOA -#undef HAVE__ULTOA -#undef HAVE_STRTOL -#undef HAVE_STRTOUL -#undef HAVE__I64TOA -#undef HAVE__UI64TOA -#undef HAVE_STRTOLL -#undef HAVE_STRTOULL -#undef HAVE_STRTOD -#undef HAVE_ATOI -#undef HAVE_ATOF -#undef HAVE_STRCMP -#undef HAVE_STRNCMP -#undef HAVE__STRICMP -#undef HAVE_STRCASECMP -#undef HAVE__STRNICMP -#undef HAVE_STRNCASECMP -#undef HAVE_SSCANF -#undef HAVE_VSSCANF -#undef HAVE_SNPRINTF -#undef HAVE_VSNPRINTF -#undef HAVE_M_PI -#undef HAVE_ATAN -#undef HAVE_ATAN2 -#undef HAVE_ACOS -#undef HAVE_ASIN -#undef HAVE_CEIL -#undef HAVE_COPYSIGN -#undef HAVE_COS -#undef HAVE_COSF -#undef HAVE_FABS -#undef HAVE_FLOOR -#undef HAVE_LOG -#undef HAVE_POW -#undef HAVE_SCALBN -#undef HAVE_SIN -#undef HAVE_SINF -#undef HAVE_SQRT -#undef HAVE_SQRTF -#undef HAVE_TAN -#undef HAVE_TANF -#undef HAVE_FOPEN64 -#undef HAVE_FSEEKO -#undef HAVE_FSEEKO64 -#undef HAVE_SIGACTION -#undef HAVE_SA_SIGACTION -#undef HAVE_SETJMP -#undef HAVE_NANOSLEEP -#undef HAVE_SYSCONF -#undef HAVE_SYSCTLBYNAME -#undef HAVE_CLOCK_GETTIME -#undef HAVE_GETPAGESIZE -#undef HAVE_MPROTECT -#undef HAVE_ICONV -#undef HAVE_PTHREAD_SETNAME_NP -#undef HAVE_PTHREAD_SET_NAME_NP -#undef HAVE_SEM_TIMEDWAIT -#undef HAVE_GETAUXVAL -#undef HAVE_POLL - -#else -#define HAVE_STDARG_H 1 -#define HAVE_STDDEF_H 1 -#define HAVE_STDINT_H 1 -#endif /* HAVE_LIBC */ - -/* SDL internal assertion support */ -#undef SDL_DEFAULT_ASSERT_LEVEL - -/* Allow disabling of core subsystems */ -#undef SDL_ATOMIC_DISABLED -#undef SDL_AUDIO_DISABLED -#undef SDL_CPUINFO_DISABLED -#undef SDL_EVENTS_DISABLED -#undef SDL_FILE_DISABLED -#undef SDL_JOYSTICK_DISABLED -#undef SDL_HAPTIC_DISABLED -#undef SDL_LOADSO_DISABLED -#undef SDL_RENDER_DISABLED -#undef SDL_THREADS_DISABLED -#undef SDL_TIMERS_DISABLED -#undef SDL_VIDEO_DISABLED -#undef SDL_POWER_DISABLED -#undef SDL_FILESYSTEM_DISABLED - -/* Enable various audio drivers */ -#undef SDL_AUDIO_DRIVER_ALSA -#undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC -#undef SDL_AUDIO_DRIVER_ANDROID -#undef SDL_AUDIO_DRIVER_ARTS -#undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC -#undef SDL_AUDIO_DRIVER_COREAUDIO -#undef SDL_AUDIO_DRIVER_DISK -#undef SDL_AUDIO_DRIVER_DSOUND -#undef SDL_AUDIO_DRIVER_DUMMY -#undef SDL_AUDIO_DRIVER_EMSCRIPTEN -#undef SDL_AUDIO_DRIVER_ESD -#undef SDL_AUDIO_DRIVER_ESD_DYNAMIC -#undef SDL_AUDIO_DRIVER_FUSIONSOUND -#undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC -#undef SDL_AUDIO_DRIVER_HAIKU -#undef SDL_AUDIO_DRIVER_JACK -#undef SDL_AUDIO_DRIVER_JACK_DYNAMIC -#undef SDL_AUDIO_DRIVER_NACL -#undef SDL_AUDIO_DRIVER_NAS -#undef SDL_AUDIO_DRIVER_NAS_DYNAMIC -#undef SDL_AUDIO_DRIVER_NETBSD -#undef SDL_AUDIO_DRIVER_OSS -#undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H -#undef SDL_AUDIO_DRIVER_PAUDIO -#undef SDL_AUDIO_DRIVER_PULSEAUDIO -#undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC -#undef SDL_AUDIO_DRIVER_QSA -#undef SDL_AUDIO_DRIVER_SNDIO -#undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC -#undef SDL_AUDIO_DRIVER_SUNAUDIO -#undef SDL_AUDIO_DRIVER_WASAPI -#undef SDL_AUDIO_DRIVER_WINMM -#undef SDL_AUDIO_DRIVER_XAUDIO2 - -/* Enable various input drivers */ -#undef SDL_INPUT_LINUXEV -#undef SDL_INPUT_LINUXKD -#undef SDL_INPUT_TSLIB -#undef SDL_JOYSTICK_HAIKU -#undef SDL_JOYSTICK_DINPUT -#undef SDL_JOYSTICK_XINPUT -#undef SDL_JOYSTICK_DUMMY -#undef SDL_JOYSTICK_IOKIT -#undef SDL_JOYSTICK_LINUX -#undef SDL_JOYSTICK_ANDROID -#undef SDL_JOYSTICK_WINMM -#undef SDL_JOYSTICK_USBHID -#undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H -#undef SDL_JOYSTICK_EMSCRIPTEN -#undef SDL_HAPTIC_DUMMY -#undef SDL_HAPTIC_LINUX -#undef SDL_HAPTIC_IOKIT -#undef SDL_HAPTIC_DINPUT -#undef SDL_HAPTIC_XINPUT - -/* Enable various shared object loading systems */ -#undef SDL_LOADSO_DLOPEN -#undef SDL_LOADSO_DUMMY -#undef SDL_LOADSO_LDG -#undef SDL_LOADSO_WINDOWS - -/* Enable various threading systems */ -#undef SDL_THREAD_PTHREAD -#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX -#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP -#undef SDL_THREAD_WINDOWS - -/* Enable various timer systems */ -#undef SDL_TIMER_HAIKU -#undef SDL_TIMER_DUMMY -#undef SDL_TIMER_UNIX -#undef SDL_TIMER_WINDOWS - -/* Enable various video drivers */ -#undef SDL_VIDEO_DRIVER_HAIKU -#undef SDL_VIDEO_DRIVER_COCOA -#undef SDL_VIDEO_DRIVER_DIRECTFB -#undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC -#undef SDL_VIDEO_DRIVER_DUMMY -#undef SDL_VIDEO_DRIVER_WINDOWS -#undef SDL_VIDEO_DRIVER_WAYLAND -#undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH -#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC -#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL -#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR -#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON -#undef SDL_VIDEO_DRIVER_MIR -#undef SDL_VIDEO_DRIVER_MIR_DYNAMIC -#undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON -#undef SDL_VIDEO_DRIVER_X11 -#undef SDL_VIDEO_DRIVER_RPI -#undef SDL_VIDEO_DRIVER_KMSDRM -#undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC -#undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM -#undef SDL_VIDEO_DRIVER_ANDROID -#undef SDL_VIDEO_DRIVER_EMSCRIPTEN -#undef SDL_VIDEO_DRIVER_X11_DYNAMIC -#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT -#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR -#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA -#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 -#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR -#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS -#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE -#undef SDL_VIDEO_DRIVER_X11_XCURSOR -#undef SDL_VIDEO_DRIVER_X11_XDBE -#undef SDL_VIDEO_DRIVER_X11_XINERAMA -#undef SDL_VIDEO_DRIVER_X11_XINPUT2 -#undef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH -#undef SDL_VIDEO_DRIVER_X11_XRANDR -#undef SDL_VIDEO_DRIVER_X11_XSCRNSAVER -#undef SDL_VIDEO_DRIVER_X11_XSHAPE -#undef SDL_VIDEO_DRIVER_X11_XVIDMODE -#undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS -#undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY -#undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM -#undef SDL_VIDEO_DRIVER_NACL -#undef SDL_VIDEO_DRIVER_VIVANTE -#undef SDL_VIDEO_DRIVER_VIVANTE_VDK -#undef SDL_VIDEO_DRIVER_QNX - -#undef SDL_VIDEO_RENDER_D3D -#undef SDL_VIDEO_RENDER_D3D11 -#undef SDL_VIDEO_RENDER_OGL -#undef SDL_VIDEO_RENDER_OGL_ES -#undef SDL_VIDEO_RENDER_OGL_ES2 -#undef SDL_VIDEO_RENDER_DIRECTFB - -/* Enable OpenGL support */ -#undef SDL_VIDEO_OPENGL -#undef SDL_VIDEO_OPENGL_ES -#undef SDL_VIDEO_OPENGL_ES2 -#undef SDL_VIDEO_OPENGL_BGL -#undef SDL_VIDEO_OPENGL_CGL -#undef SDL_VIDEO_OPENGL_EGL -#undef SDL_VIDEO_OPENGL_GLX -#undef SDL_VIDEO_OPENGL_WGL -#undef SDL_VIDEO_OPENGL_OSMESA -#undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC - -/* Enable Vulkan support */ -#undef SDL_VIDEO_VULKAN - -/* Enable system power support */ -#undef SDL_POWER_LINUX -#undef SDL_POWER_WINDOWS -#undef SDL_POWER_MACOSX -#undef SDL_POWER_HAIKU -#undef SDL_POWER_ANDROID -#undef SDL_POWER_EMSCRIPTEN -#undef SDL_POWER_HARDWIRED - -/* Enable system filesystem support */ -#undef SDL_FILESYSTEM_HAIKU -#undef SDL_FILESYSTEM_COCOA -#undef SDL_FILESYSTEM_DUMMY -#undef SDL_FILESYSTEM_UNIX -#undef SDL_FILESYSTEM_WINDOWS -#undef SDL_FILESYSTEM_NACL -#undef SDL_FILESYSTEM_ANDROID -#undef SDL_FILESYSTEM_EMSCRIPTEN - -/* Enable assembly routines */ -#undef SDL_ASSEMBLY_ROUTINES -#undef SDL_ALTIVEC_BLITTERS - -/* Enable ime support */ -#undef SDL_USE_IME - -/* Enable dynamic udev support */ -#undef SDL_UDEV_DYNAMIC - -/* Enable dynamic libsamplerate support */ -#undef SDL_LIBSAMPLERATE_DYNAMIC - -#endif /* SDL_config_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_android.h b/thirdparty/include/SDL2/SDL_config_android.h deleted file mode 100644 index 361bad8b7..000000000 --- a/thirdparty/include/SDL2/SDL_config_android.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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 SDL_config_android_h_ -#define SDL_config_android_h_ -#define SDL_config_h_ - -#include "SDL_platform.h" - -/** - * \file SDL_config_android.h - * - * This is a configuration that can be used to build SDL for Android - */ - -#include - -#define HAVE_GCC_ATOMICS 1 - -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_SETENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 -#define HAVE_STRNCASECMP 1 -#define HAVE_VSSCANF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_M_PI 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_ACOS 1 -#define HAVE_ASIN 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#define HAVE_SIGACTION 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 -#define HAVE_SYSCONF 1 -#define HAVE_CLOCK_GETTIME 1 - -#define SIZEOF_VOIDP 4 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_ANDROID 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various input drivers */ -#define SDL_JOYSTICK_ANDROID 1 -#define SDL_HAPTIC_ANDROID 1 - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_DLOPEN 1 - -/* Enable various threading systems */ -#define SDL_THREAD_PTHREAD 1 -#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 - -/* Enable various timer systems */ -#define SDL_TIMER_UNIX 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_ANDROID 1 - -/* Enable OpenGL ES */ -#define SDL_VIDEO_OPENGL_ES 1 -#define SDL_VIDEO_OPENGL_ES2 1 -#define SDL_VIDEO_OPENGL_EGL 1 -#define SDL_VIDEO_RENDER_OGL_ES 1 -#define SDL_VIDEO_RENDER_OGL_ES2 1 - -/* Enable Vulkan support */ -/* Android does not support Vulkan in native code using the "armeabi" ABI. */ -#if defined(__ARM_ARCH) && __ARM_ARCH < 7 -#define SDL_VIDEO_VULKAN 0 -#else -#define SDL_VIDEO_VULKAN 1 -#endif - -/* Enable system power support */ -#define SDL_POWER_ANDROID 1 - -/* Enable the filesystem driver */ -#define SDL_FILESYSTEM_ANDROID 1 - -#endif /* SDL_config_android_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_iphoneos.h b/thirdparty/include/SDL2/SDL_config_iphoneos.h deleted file mode 100644 index deea03046..000000000 --- a/thirdparty/include/SDL2/SDL_config_iphoneos.h +++ /dev/null @@ -1,166 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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 SDL_config_iphoneos_h_ -#define SDL_config_iphoneos_h_ -#define SDL_config_h_ - -#include "SDL_platform.h" - -#ifdef __LP64__ -#define SIZEOF_VOIDP 8 -#else -#define SIZEOF_VOIDP 4 -#endif - -#define HAVE_GCC_ATOMICS 1 - -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_SETENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 -#define HAVE_STRNCASECMP 1 -#define HAVE_VSSCANF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_M_PI 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_ACOS 1 -#define HAVE_ASIN 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#define HAVE_SIGACTION 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 -#define HAVE_SYSCONF 1 -#define HAVE_SYSCTLBYNAME 1 - -/* enable iPhone version of Core Audio driver */ -#define SDL_AUDIO_DRIVER_COREAUDIO 1 -/* Enable the dummy audio driver (src/audio/dummy/\*.c) */ -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ -#define SDL_HAPTIC_DUMMY 1 - -/* Enable MFi joystick support */ -#define SDL_JOYSTICK_MFI 1 - -/* Enable Unix style SO loading */ -#define SDL_LOADSO_DLOPEN 1 - -/* Enable various threading systems */ -#define SDL_THREAD_PTHREAD 1 -#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 - -/* Enable various timer systems */ -#define SDL_TIMER_UNIX 1 - -/* Supported video drivers */ -#define SDL_VIDEO_DRIVER_UIKIT 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 - -/* enable OpenGL ES */ -#define SDL_VIDEO_OPENGL_ES2 1 -#define SDL_VIDEO_OPENGL_ES 1 -#define SDL_VIDEO_RENDER_OGL_ES 1 -#define SDL_VIDEO_RENDER_OGL_ES2 1 - -/* Enable Vulkan support */ -#if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM // Only 64-bit devices have Metal -#define SDL_VIDEO_VULKAN 1 -#else -#define SDL_VIDEO_VULKAN 0 -#endif - -/* Enable system power support */ -#define SDL_POWER_UIKIT 1 - -/* enable iPhone keyboard support */ -#define SDL_IPHONE_KEYBOARD 1 - -/* enable iOS extended launch screen */ -#define SDL_IPHONE_LAUNCHSCREEN 1 - -/* Set max recognized G-force from accelerometer - See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed - */ -#define SDL_IPHONE_MAX_GFORCE 5.0 - -/* enable filesystem support */ -#define SDL_FILESYSTEM_COCOA 1 - -#endif /* SDL_config_iphoneos_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_macosx.h b/thirdparty/include/SDL2/SDL_config_macosx.h deleted file mode 100644 index 9b0989952..000000000 --- a/thirdparty/include/SDL2/SDL_config_macosx.h +++ /dev/null @@ -1,197 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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 SDL_config_macosx_h_ -#define SDL_config_macosx_h_ -#define SDL_config_h_ - -#include "SDL_platform.h" - -/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ -#include - -/* This is a set of defines to configure the SDL features */ - -#ifdef __LP64__ - #define SIZEOF_VOIDP 8 -#else - #define SIZEOF_VOIDP 4 -#endif - -/* Useful headers */ -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 -#define HAVE_STRNCASECMP 1 -#define HAVE_VSSCANF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#define HAVE_SIGACTION 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 -#define HAVE_SYSCONF 1 -#define HAVE_SYSCTLBYNAME 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_ACOS 1 -#define HAVE_ASIN 1 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_COREAUDIO 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various input drivers */ -#define SDL_JOYSTICK_IOKIT 1 -#define SDL_HAPTIC_IOKIT 1 - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_DLOPEN 1 - -/* Enable various threading systems */ -#define SDL_THREAD_PTHREAD 1 -#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 - -/* Enable various timer systems */ -#define SDL_TIMER_UNIX 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_COCOA 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 -#undef SDL_VIDEO_DRIVER_X11 -#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/usr/X11R6/lib/libXi.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib" -#define SDL_VIDEO_DRIVER_X11_XDBE 1 -#define SDL_VIDEO_DRIVER_X11_XINERAMA 1 -#define SDL_VIDEO_DRIVER_X11_XRANDR 1 -#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1 -#define SDL_VIDEO_DRIVER_X11_XSHAPE 1 -#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 -#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1 - -#ifdef MAC_OS_X_VERSION_10_8 -/* - * No matter the versions targeted, this is the 10.8 or later SDK, so you have - * to use the external Xquartz, which is a more modern Xlib. Previous SDKs - * used an older Xlib. - */ -#define SDL_VIDEO_DRIVER_X11_XINPUT2 1 -#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1 -#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1 -#endif - -#ifndef SDL_VIDEO_RENDER_OGL -#define SDL_VIDEO_RENDER_OGL 1 -#endif - -/* Enable OpenGL support */ -#ifndef SDL_VIDEO_OPENGL -#define SDL_VIDEO_OPENGL 1 -#endif -#ifndef SDL_VIDEO_OPENGL_CGL -#define SDL_VIDEO_OPENGL_CGL 1 -#endif -#ifndef SDL_VIDEO_OPENGL_GLX -#define SDL_VIDEO_OPENGL_GLX 1 -#endif - -/* Enable Vulkan support */ -/* Metal/MoltenVK/Vulkan only supported on 64-bit architectures with 10.11+ */ -#if TARGET_CPU_X86_64 && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101100) -#define SDL_VIDEO_VULKAN 1 -#else -#define SDL_VIDEO_VULKAN 0 -#endif - -/* Enable system power support */ -#define SDL_POWER_MACOSX 1 - -/* enable filesystem support */ -#define SDL_FILESYSTEM_COCOA 1 - -/* Enable assembly routines */ -#define SDL_ASSEMBLY_ROUTINES 1 -#ifdef __ppc__ -#define SDL_ALTIVEC_BLITTERS 1 -#endif - -#endif /* SDL_config_macosx_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_macosx.h.orig b/thirdparty/include/SDL2/SDL_config_macosx.h.orig deleted file mode 100644 index f03f1ae3d..000000000 --- a/thirdparty/include/SDL2/SDL_config_macosx.h.orig +++ /dev/null @@ -1,197 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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 SDL_config_macosx_h_ -#define SDL_config_macosx_h_ -#define SDL_config_h_ - -#include "SDL_platform.h" - -/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ -#include - -/* This is a set of defines to configure the SDL features */ - -#ifdef __LP64__ - #define SIZEOF_VOIDP 8 -#else - #define SIZEOF_VOIDP 4 -#endif - -/* Useful headers */ -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 -#define HAVE_STRNCASECMP 1 -#define HAVE_VSSCANF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#define HAVE_SIGACTION 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 -#define HAVE_SYSCONF 1 -#define HAVE_SYSCTLBYNAME 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_ACOS 1 -#define HAVE_ASIN 1 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_COREAUDIO 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various input drivers */ -#define SDL_JOYSTICK_IOKIT 1 -#define SDL_HAPTIC_IOKIT 1 - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_DLOPEN 1 - -/* Enable various threading systems */ -#define SDL_THREAD_PTHREAD 1 -#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 - -/* Enable various timer systems */ -#define SDL_TIMER_UNIX 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_COCOA 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 -#undef SDL_VIDEO_DRIVER_X11 -#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/usr/X11R6/lib/libXi.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib" -#define SDL_VIDEO_DRIVER_X11_XDBE 1 -#define SDL_VIDEO_DRIVER_X11_XINERAMA 1 -#define SDL_VIDEO_DRIVER_X11_XRANDR 1 -#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1 -#define SDL_VIDEO_DRIVER_X11_XSHAPE 1 -#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 -#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1 - -#ifdef MAC_OS_X_VERSION_10_8 -/* - * No matter the versions targeted, this is the 10.8 or later SDK, so you have - * to use the external Xquartz, which is a more modern Xlib. Previous SDKs - * used an older Xlib. - */ -#define SDL_VIDEO_DRIVER_X11_XINPUT2 1 -#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1 -#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1 -#endif - -#ifndef SDL_VIDEO_RENDER_OGL -#define SDL_VIDEO_RENDER_OGL 1 -#endif - -/* Enable OpenGL support */ -#ifndef SDL_VIDEO_OPENGL -#define SDL_VIDEO_OPENGL 1 -#endif -#ifndef SDL_VIDEO_OPENGL_CGL -#define SDL_VIDEO_OPENGL_CGL 1 -#endif -#ifndef SDL_VIDEO_OPENGL_GLX -#define SDL_VIDEO_OPENGL_GLX 1 -#endif - -/* Enable Vulkan support */ -/* Metal/MoltenVK/Vulkan only supported on 64-bit architectures and 10.11+ */ -#if TARGET_CPU_X86_64 -#define SDL_VIDEO_VULKAN 1 -#else -#define SDL_VIDEO_VULKAN 0 -#endif - -/* Enable system power support */ -#define SDL_POWER_MACOSX 1 - -/* enable filesystem support */ -#define SDL_FILESYSTEM_COCOA 1 - -/* Enable assembly routines */ -#define SDL_ASSEMBLY_ROUTINES 1 -#ifdef __ppc__ -#define SDL_ALTIVEC_BLITTERS 1 -#endif - -#endif /* SDL_config_macosx_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_minimal.h b/thirdparty/include/SDL2/SDL_config_minimal.h deleted file mode 100644 index 31127006c..000000000 --- a/thirdparty/include/SDL2/SDL_config_minimal.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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 SDL_config_minimal_h_ -#define SDL_config_minimal_h_ -#define SDL_config_h_ - -#include "SDL_platform.h" - -/** - * \file SDL_config_minimal.h - * - * This is the minimal configuration that can be used to build SDL. - */ - -#define HAVE_STDARG_H 1 -#define HAVE_STDDEF_H 1 - -/* Most everything except Visual Studio 2008 and earlier has stdint.h now */ -#if defined(_MSC_VER) && (_MSC_VER < 1600) -/* Here are some reasonable defaults */ -typedef unsigned int size_t; -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -typedef unsigned long uintptr_t; -#else -#define HAVE_STDINT_H 1 -#endif /* Visual Studio 2008 */ - -#ifdef __GNUC__ -#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 -#endif - -/* Enable the dummy audio driver (src/audio/dummy/\*.c) */ -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ -#define SDL_JOYSTICK_DISABLED 1 - -/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ -#define SDL_HAPTIC_DISABLED 1 - -/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ -#define SDL_LOADSO_DISABLED 1 - -/* Enable the stub thread support (src/thread/generic/\*.c) */ -#define SDL_THREADS_DISABLED 1 - -/* Enable the stub timer support (src/timer/dummy/\*.c) */ -#define SDL_TIMERS_DISABLED 1 - -/* Enable the dummy video driver (src/video/dummy/\*.c) */ -#define SDL_VIDEO_DRIVER_DUMMY 1 - -/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */ -#define SDL_FILESYSTEM_DUMMY 1 - -#endif /* SDL_config_minimal_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_pandora.h b/thirdparty/include/SDL2/SDL_config_pandora.h deleted file mode 100644 index ea62fe59a..000000000 --- a/thirdparty/include/SDL2/SDL_config_pandora.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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 SDL_config_pandora_h_ -#define SDL_config_pandora_h_ -#define SDL_config_h_ - -/* This is a set of defines to configure the SDL features */ - -/* General platform specific identifiers */ -#include "SDL_platform.h" - -#ifdef __LP64__ -#define SIZEOF_VOIDP 8 -#else -#define SIZEOF_VOIDP 4 -#endif - -#define SDL_BYTEORDER 1234 - -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STDARG_H 1 -#define HAVE_MALLOC_H 1 -#define HAVE_MEMORY_H 1 -#define HAVE_STRING_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_ICONV_H 1 -#define HAVE_SIGNAL_H 1 -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_STRLEN 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 -#define HAVE_STRNCASECMP 1 -#define HAVE_VSSCANF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_M_PI 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#define HAVE_SIGACTION 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 - -#define SDL_AUDIO_DRIVER_DUMMY 1 -#define SDL_AUDIO_DRIVER_OSS 1 - -#define SDL_INPUT_LINUXEV 1 -#define SDL_INPUT_TSLIB 1 -#define SDL_JOYSTICK_LINUX 1 -#define SDL_HAPTIC_LINUX 1 - -#define SDL_LOADSO_DLOPEN 1 - -#define SDL_THREAD_PTHREAD 1 -#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 - -#define SDL_TIMER_UNIX 1 -#define SDL_FILESYSTEM_UNIX 1 - -#define SDL_VIDEO_DRIVER_DUMMY 1 -#define SDL_VIDEO_DRIVER_X11 1 -#define SDL_VIDEO_DRIVER_PANDORA 1 -#define SDL_VIDEO_RENDER_OGL_ES 1 -#define SDL_VIDEO_OPENGL_ES 1 - -#endif /* SDL_config_pandora_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_psp.h b/thirdparty/include/SDL2/SDL_config_psp.h deleted file mode 100644 index 28efb4c5c..000000000 --- a/thirdparty/include/SDL2/SDL_config_psp.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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 SDL_config_psp_h_ -#define SDL_config_psp_h_ -#define SDL_config_h_ - -#include "SDL_platform.h" - - - -#ifdef __GNUC__ -#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 -#endif - -#define HAVE_GCC_ATOMICS 1 - -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_SETENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 -#define HAVE_STRNCASECMP 1 -#define HAVE_VSSCANF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_M_PI 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_ACOS 1 -#define HAVE_ASIN 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 -/* #define HAVE_SYSCONF 1 */ -/* #define HAVE_SIGACTION 1 */ - - -/* PSP isn't that sophisticated */ -#define LACKS_SYS_MMAN_H 1 - -/* Enable the stub thread support (src/thread/psp/\*.c) */ -#define SDL_THREAD_PSP 1 - -/* Enable the stub timer support (src/timer/psp/\*.c) */ -#define SDL_TIMERS_PSP 1 - -/* Enable the stub joystick driver (src/joystick/psp/\*.c) */ -#define SDL_JOYSTICK_PSP 1 - -/* Enable the stub audio driver (src/audio/psp/\*.c) */ -#define SDL_AUDIO_DRIVER_PSP 1 - -/* PSP video dirver */ -#define SDL_VIDEO_DRIVER_PSP 1 - -/* PSP render dirver */ -#define SDL_VIDEO_RENDER_PSP 1 - -#define SDL_POWER_PSP 1 - -/* !!! FIXME: what does PSP do for filesystem stuff? */ -#define SDL_FILESYSTEM_DUMMY 1 - -/* PSP doesn't have haptic device (src/haptic/dummy/\*.c) */ -#define SDL_HAPTIC_DISABLED 1 - -/* PSP can't load shared object (src/loadso/dummy/\*.c) */ -#define SDL_LOADSO_DISABLED 1 - - -#endif /* SDL_config_psp_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_windows.h b/thirdparty/include/SDL2/SDL_config_windows.h deleted file mode 100644 index 2456c843f..000000000 --- a/thirdparty/include/SDL2/SDL_config_windows.h +++ /dev/null @@ -1,225 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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 SDL_config_windows_h_ -#define SDL_config_windows_h_ -#define SDL_config_h_ - -#include "SDL_platform.h" - -/* This is a set of defines to configure the SDL features */ - -#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) -#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) -#define HAVE_STDINT_H 1 -#elif defined(_MSC_VER) -typedef signed __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef signed __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef signed __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; -#ifndef _UINTPTR_T_DEFINED -#ifdef _WIN64 -typedef unsigned __int64 uintptr_t; -#else -typedef unsigned int uintptr_t; -#endif -#define _UINTPTR_T_DEFINED -#endif -/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ -#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) -#define DWORD_PTR DWORD -#endif -#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) -#define LONG_PTR LONG -#endif -#else /* !__GNUC__ && !_MSC_VER */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -#ifndef _SIZE_T_DEFINED_ -#define _SIZE_T_DEFINED_ -typedef unsigned int size_t; -#endif -typedef unsigned int uintptr_t; -#endif /* __GNUC__ || _MSC_VER */ -#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ - -#ifdef _WIN64 -# define SIZEOF_VOIDP 8 -#else -# define SIZEOF_VOIDP 4 -#endif - -#define HAVE_DDRAW_H 1 -#define HAVE_DINPUT_H 1 -#define HAVE_DSOUND_H 1 -#define HAVE_DXGI_H 1 -#define HAVE_XINPUT_H 1 - -/* This is disabled by default to avoid C runtime dependencies and manifest requirements */ -#ifdef HAVE_LIBC -/* Useful headers */ -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE__STRREV 1 -#define HAVE__STRUPR 1 -#define HAVE__STRLWR 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE__LTOA 1 -#define HAVE__ULTOA 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE__STRICMP 1 -#define HAVE__STRNICMP 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_ACOS 1 -#define HAVE_ASIN 1 -#define HAVE_CEIL 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#if _MSC_VER >= 1800 -#define HAVE_STRTOLL 1 -#define HAVE_VSSCANF 1 -#define HAVE_COPYSIGN 1 -#define HAVE_SCALBN 1 -#endif -#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) -#define HAVE_M_PI 1 -#endif -#else -#define HAVE_STDARG_H 1 -#define HAVE_STDDEF_H 1 -#endif - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_WASAPI 1 -#define SDL_AUDIO_DRIVER_DSOUND 1 -#define SDL_AUDIO_DRIVER_XAUDIO2 0 -#define SDL_AUDIO_DRIVER_WINMM 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various input drivers */ -#define SDL_JOYSTICK_DINPUT 1 -#define SDL_JOYSTICK_XINPUT 1 -#define SDL_HAPTIC_DINPUT 1 -#define SDL_HAPTIC_XINPUT 1 - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_WINDOWS 1 - -/* Enable various threading systems */ -#define SDL_THREAD_WINDOWS 1 - -/* Enable various timer systems */ -#define SDL_TIMER_WINDOWS 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_DUMMY 1 -#define SDL_VIDEO_DRIVER_WINDOWS 1 - -#ifndef SDL_VIDEO_RENDER_D3D -#define SDL_VIDEO_RENDER_D3D 1 -#endif -#ifndef SDL_VIDEO_RENDER_D3D11 -#define SDL_VIDEO_RENDER_D3D11 0 -#endif - -/* Enable OpenGL support */ -#ifndef SDL_VIDEO_OPENGL -#define SDL_VIDEO_OPENGL 1 -#endif -#ifndef SDL_VIDEO_OPENGL_WGL -#define SDL_VIDEO_OPENGL_WGL 1 -#endif -#ifndef SDL_VIDEO_RENDER_OGL -#define SDL_VIDEO_RENDER_OGL 1 -#endif -#ifndef SDL_VIDEO_RENDER_OGL_ES2 -#define SDL_VIDEO_RENDER_OGL_ES2 1 -#endif -#ifndef SDL_VIDEO_OPENGL_ES2 -#define SDL_VIDEO_OPENGL_ES2 1 -#endif -#ifndef SDL_VIDEO_OPENGL_EGL -#define SDL_VIDEO_OPENGL_EGL 1 -#endif - -/* Enable Vulkan support */ -#define SDL_VIDEO_VULKAN 1 - -/* Enable system power support */ -#define SDL_POWER_WINDOWS 1 - -/* Enable filesystem support */ -#define SDL_FILESYSTEM_WINDOWS 1 - -/* Enable assembly routines (Win64 doesn't have inline asm) */ -#ifndef _WIN64 -#define SDL_ASSEMBLY_ROUTINES 1 -#endif - -#endif /* SDL_config_windows_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_winrt.h b/thirdparty/include/SDL2/SDL_config_winrt.h deleted file mode 100644 index 24f9e17f2..000000000 --- a/thirdparty/include/SDL2/SDL_config_winrt.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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 SDL_config_winrt_h_ -#define SDL_config_winrt_h_ -#define SDL_config_h_ - -#include "SDL_platform.h" - -/* Make sure the Windows SDK's NTDDI_VERSION macro gets defined. This is used - by SDL to determine which version of the Windows SDK is being used. -*/ -#include - -/* Define possibly-undefined NTDDI values (used when compiling SDL against - older versions of the Windows SDK. -*/ -#ifndef NTDDI_WINBLUE -#define NTDDI_WINBLUE 0x06030000 -#endif -#ifndef NTDDI_WIN10 -#define NTDDI_WIN10 0x0A000000 -#endif - -/* This is a set of defines to configure the SDL features */ - -#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) -#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) -#define HAVE_STDINT_H 1 -#elif defined(_MSC_VER) -typedef signed __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef signed __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef signed __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; -#ifndef _UINTPTR_T_DEFINED -#ifdef _WIN64 -typedef unsigned __int64 uintptr_t; -#else -typedef unsigned int uintptr_t; -#endif -#define _UINTPTR_T_DEFINED -#endif -/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ -#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) -#define DWORD_PTR DWORD -#endif -#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) -#define LONG_PTR LONG -#endif -#else /* !__GNUC__ && !_MSC_VER */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -#ifndef _SIZE_T_DEFINED_ -#define _SIZE_T_DEFINED_ -typedef unsigned int size_t; -#endif -typedef unsigned int uintptr_t; -#endif /* __GNUC__ || _MSC_VER */ -#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ - -#ifdef _WIN64 -# define SIZEOF_VOIDP 8 -#else -# define SIZEOF_VOIDP 4 -#endif - -/* Useful headers */ -#define HAVE_DXGI_H 1 -#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP -#define HAVE_XINPUT_H 1 -#endif -#define HAVE_LIBC 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_FLOAT_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE__STRREV 1 -#define HAVE__STRUPR 1 -//#define HAVE__STRLWR 1 // TODO, WinRT: consider using _strlwr_s instead -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -//#define HAVE_ITOA 1 // TODO, WinRT: consider using _itoa_s instead -//#define HAVE__LTOA 1 // TODO, WinRT: consider using _ltoa_s instead -//#define HAVE__ULTOA 1 // TODO, WinRT: consider using _ultoa_s instead -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -//#define HAVE_STRTOLL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE__STRICMP 1 -#define HAVE__STRNICMP 1 -#define HAVE_VSNPRINTF 1 -//#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead -#define HAVE_M_PI 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_CEIL 1 -#define HAVE__COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -//#define HAVE_SCALBN 1 -#define HAVE__SCALB 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#define HAVE__FSEEKI64 1 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_XAUDIO2 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various input drivers */ -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP -#define SDL_JOYSTICK_DISABLED 1 -#define SDL_HAPTIC_DISABLED 1 -#else -#define SDL_JOYSTICK_XINPUT 1 -#define SDL_HAPTIC_XINPUT 1 -#endif - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_WINDOWS 1 - -/* Enable various threading systems */ -#if (NTDDI_VERSION >= NTDDI_WINBLUE) -#define SDL_THREAD_WINDOWS 1 -#else -/* WinRT on Windows 8.0 and Windows Phone 8.0 don't support CreateThread() */ -#define SDL_THREAD_STDCPP 1 -#endif - -/* Enable various timer systems */ -#define SDL_TIMER_WINDOWS 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_WINRT 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 - -/* Enable OpenGL ES 2.0 (via a modified ANGLE library) */ -#define SDL_VIDEO_OPENGL_ES2 1 -#define SDL_VIDEO_OPENGL_EGL 1 - -/* Enable appropriate renderer(s) */ -#define SDL_VIDEO_RENDER_D3D11 1 - -#if SDL_VIDEO_OPENGL_ES2 -#define SDL_VIDEO_RENDER_OGL_ES2 1 -#endif - -/* Enable system power support */ -#define SDL_POWER_WINRT 1 - -/* Enable assembly routines (Win64 doesn't have inline asm) */ -#ifndef _WIN64 -#define SDL_ASSEMBLY_ROUTINES 1 -#endif - -#endif /* SDL_config_winrt_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_wiz.h b/thirdparty/include/SDL2/SDL_config_wiz.h deleted file mode 100644 index 5bb845a0c..000000000 --- a/thirdparty/include/SDL2/SDL_config_wiz.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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 SDL_config_wiz_h_ -#define SDL_config_wiz_h_ -#define SDL_config_h_ - -/* This is a set of defines to configure the SDL features */ - -/* General platform specific identifiers */ -#include "SDL_platform.h" - -#define SDL_BYTEORDER 1234 - -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STDARG_H 1 -#define HAVE_MALLOC_H 1 -#define HAVE_MEMORY_H 1 -#define HAVE_STRING_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_ICONV_H 1 -#define HAVE_SIGNAL_H 1 -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_SETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_STRLEN 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 -#define HAVE_STRNCASECMP 1 -#define HAVE_VSSCANF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_M_PI 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#define HAVE_SIGACTION 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 -#define HAVE_POW 1 - -#define SDL_AUDIO_DRIVER_DUMMY 1 -#define SDL_AUDIO_DRIVER_OSS 1 - -#define SDL_INPUT_LINUXEV 1 -#define SDL_INPUT_TSLIB 1 -#define SDL_JOYSTICK_LINUX 1 -#define SDL_HAPTIC_LINUX 1 - -#define SDL_LOADSO_DLOPEN 1 - -#define SDL_THREAD_PTHREAD 1 -#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 - -#define SDL_TIMER_UNIX 1 - -#define SDL_VIDEO_DRIVER_DUMMY 1 -#define SDL_VIDEO_DRIVER_PANDORA 1 -#define SDL_VIDEO_RENDER_OGL_ES 1 -#define SDL_VIDEO_OPENGL_ES 1 - -#endif /* SDL_config_wiz_h_ */ diff --git a/thirdparty/include/SDL2/SDL_copying.h b/thirdparty/include/SDL2/SDL_copying.h deleted file mode 100644 index 8f60af6b4..000000000 --- a/thirdparty/include/SDL2/SDL_copying.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga - - 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. -*/ diff --git a/thirdparty/include/SDL2/SDL_cpuinfo.h b/thirdparty/include/SDL2/SDL_cpuinfo.h deleted file mode 100644 index 0d9b82131..000000000 --- a/thirdparty/include/SDL2/SDL_cpuinfo.h +++ /dev/null @@ -1,275 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_cpuinfo.h - * - * CPU feature detection for SDL. - */ - -#ifndef SDL_cpuinfo_h_ -#define SDL_cpuinfo_h_ - -#include "SDL_stdinc.h" - -/* Need to do this here because intrin.h has C++ code in it */ -/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ -#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) -#ifdef __clang__ -/* Many of the intrinsics SDL uses are not implemented by clang with Visual Studio */ -#undef __MMX__ -#undef __SSE__ -#undef __SSE2__ -#else -#include -#ifndef _WIN64 -#ifndef __MMX__ -#define __MMX__ -#endif -#ifndef __3dNOW__ -#define __3dNOW__ -#endif -#endif -#ifndef __SSE__ -#define __SSE__ -#endif -#ifndef __SSE2__ -#define __SSE2__ -#endif -#endif /* __clang__ */ -#elif defined(__MINGW64_VERSION_MAJOR) -#include -#else -/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */ -#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H) -#include -#endif -#if !defined(SDL_DISABLE_ARM_NEON_H) -# if defined(__ARM_NEON) -# include -# elif defined(__WINDOWS__) || defined(__WINRT__) -/* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */ -# if defined(_M_ARM) -# include -# include -# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ -# endif -# if defined (_M_ARM64) -# include -# include -# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ -# endif -# endif -#endif -#if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H) -#include -#endif -#if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H) -#include -#else -#if defined(__MMX__) && !defined(SDL_DISABLE_MMINTRIN_H) -#include -#endif -#if defined(__SSE__) && !defined(SDL_DISABLE_XMMINTRIN_H) -#include -#endif -#if defined(__SSE2__) && !defined(SDL_DISABLE_EMMINTRIN_H) -#include -#endif -#if defined(__SSE3__) && !defined(SDL_DISABLE_PMMINTRIN_H) -#include -#endif -#endif /* HAVE_IMMINTRIN_H */ -#endif /* compiler version */ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* This is a guess for the cacheline size used for padding. - * Most x86 processors have a 64 byte cache line. - * The 64-bit PowerPC processors have a 128 byte cache line. - * We'll use the larger value to be generally safe. - */ -#define SDL_CACHELINE_SIZE 128 - -/** - * This function returns the number of CPU cores available. - */ -extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); - -/** - * This function returns the L1 cache line size of the CPU - * - * This is useful for determining multi-threaded structure padding - * or SIMD prefetch sizes. - */ -extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); - -/** - * This function returns true if the CPU has the RDTSC instruction. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); - -/** - * This function returns true if the CPU has AltiVec features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); - -/** - * This function returns true if the CPU has MMX features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); - -/** - * This function returns true if the CPU has 3DNow! features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); - -/** - * This function returns true if the CPU has SSE features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); - -/** - * This function returns true if the CPU has SSE2 features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); - -/** - * This function returns true if the CPU has SSE3 features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); - -/** - * This function returns true if the CPU has SSE4.1 features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); - -/** - * This function returns true if the CPU has SSE4.2 features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); - -/** - * This function returns true if the CPU has AVX features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); - -/** - * This function returns true if the CPU has AVX2 features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void); - -/** - * This function returns true if the CPU has AVX-512F (foundation) features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void); - -/** - * This function returns true if the CPU has ARM SIMD (ARMv6) features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasARMSIMD(void); - -/** - * This function returns true if the CPU has NEON (ARM SIMD) features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void); - -/** - * This function returns the amount of RAM configured in the system, in MB. - */ -extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); - -/** - * \brief Report the alignment this system needs for SIMD allocations. - * - * This will return the minimum number of bytes to which a pointer must be - * aligned to be compatible with SIMD instructions on the current machine. - * For example, if the machine supports SSE only, it will return 16, but if - * it supports AVX-512F, it'll return 64 (etc). This only reports values for - * instruction sets SDL knows about, so if your SDL build doesn't have - * SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and - * not 64 for the AVX-512 instructions that exist but SDL doesn't know about. - * Plan accordingly. - */ -extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void); - -/** - * \brief Allocate memory in a SIMD-friendly way. - * - * This will allocate a block of memory that is suitable for use with SIMD - * instructions. Specifically, it will be properly aligned and padded for - * the system's supported vector instructions. - * - * The memory returned will be padded such that it is safe to read or write - * an incomplete vector at the end of the memory block. This can be useful - * so you don't have to drop back to a scalar fallback at the end of your - * SIMD processing loop to deal with the final elements without overflowing - * the allocated buffer. - * - * You must free this memory with SDL_FreeSIMD(), not free() or SDL_free() - * or delete[], etc. - * - * Note that SDL will only deal with SIMD instruction sets it is aware of; - * for example, SDL 2.0.8 knows that SSE wants 16-byte vectors - * (SDL_HasSSE()), and AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't - * know that AVX-512 wants 64. To be clear: if you can't decide to use an - * instruction set with an SDL_Has*() function, don't use that instruction - * set with memory allocated through here. - * - * SDL_AllocSIMD(0) will return a non-NULL pointer, assuming the system isn't - * out of memory. - * - * \param len The length, in bytes, of the block to allocated. The actual - * allocated block might be larger due to padding, etc. - * \return Pointer to newly-allocated block, NULL if out of memory. - * - * \sa SDL_SIMDAlignment - * \sa SDL_SIMDFree - */ -extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len); - -/** - * \brief Deallocate memory obtained from SDL_SIMDAlloc - * - * It is not valid to use this function on a pointer from anything but - * SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc, - * SDL_malloc, memalign, new[], etc. - * - * However, SDL_SIMDFree(NULL) is a legal no-op. - * - * \sa SDL_SIMDAlloc - */ -extern DECLSPEC void SDLCALL SDL_SIMDFree(void *ptr); - -/* vi: set ts=4 sw=4 expandtab: */ -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_cpuinfo_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_egl.h b/thirdparty/include/SDL2/SDL_egl.h deleted file mode 100644 index 531441e68..000000000 --- a/thirdparty/include/SDL2/SDL_egl.h +++ /dev/null @@ -1,1676 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_egl.h - * - * This is a simple file to encapsulate the EGL API headers. - */ -#if !defined(_MSC_VER) && !defined(__ANDROID__) - -#include -#include - -#else /* _MSC_VER */ - -/* EGL headers for Visual Studio */ - -#ifndef __khrplatform_h_ -#define __khrplatform_h_ - -/* -** Copyright (c) 2008-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Khronos platform-specific types and definitions. -* -* $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $ -* -* Adopters may modify this file to suit their platform. Adopters are -* encouraged to submit platform specific modifications to the Khronos -* group so that they can be included in future versions of this file. -* Please submit changes by sending them to the public Khronos Bugzilla -* (http://khronos.org/bugzilla) by filing a bug against product -* "Khronos (general)" component "Registry". -* -* A predefined template which fills in some of the bug fields can be -* reached using http://tinyurl.com/khrplatform-h-bugreport, but you -* must create a Bugzilla login first. -* -* -* See the Implementer's Guidelines for information about where this file -* should be located on your system and for more details of its use: -* http://www.khronos.org/registry/implementers_guide.pdf -* -* This file should be included as -* #include -* by Khronos client API header files that use its types and defines. -* -* The types in khrplatform.h should only be used to define API-specific types. -* -* Types defined in khrplatform.h: -* khronos_int8_t signed 8 bit -* khronos_uint8_t unsigned 8 bit -* khronos_int16_t signed 16 bit -* khronos_uint16_t unsigned 16 bit -* khronos_int32_t signed 32 bit -* khronos_uint32_t unsigned 32 bit -* khronos_int64_t signed 64 bit -* khronos_uint64_t unsigned 64 bit -* khronos_intptr_t signed same number of bits as a pointer -* khronos_uintptr_t unsigned same number of bits as a pointer -* khronos_ssize_t signed size -* khronos_usize_t unsigned size -* khronos_float_t signed 32 bit floating point -* khronos_time_ns_t unsigned 64 bit time in nanoseconds -* khronos_utime_nanoseconds_t unsigned time interval or absolute time in -* nanoseconds -* khronos_stime_nanoseconds_t signed time interval in nanoseconds -* khronos_boolean_enum_t enumerated boolean type. This should -* only be used as a base type when a client API's boolean type is -* an enum. Client APIs which use an integer or other type for -* booleans cannot use this as the base type for their boolean. -* -* Tokens defined in khrplatform.h: -* -* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. -* -* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. -* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. -* -* Calling convention macros defined in this file: -* KHRONOS_APICALL -* KHRONOS_APIENTRY -* KHRONOS_APIATTRIBUTES -* -* These may be used in function prototypes as: -* -* KHRONOS_APICALL void KHRONOS_APIENTRY funcname( -* int arg1, -* int arg2) KHRONOS_APIATTRIBUTES; -*/ - -/*------------------------------------------------------------------------- -* Definition of KHRONOS_APICALL -*------------------------------------------------------------------------- -* This precedes the return type of the function in the function prototype. -*/ -#if defined(_WIN32) && !defined(__SCITECH_SNAP__) && !defined(SDL_VIDEO_STATIC_ANGLE) -# define KHRONOS_APICALL __declspec(dllimport) -#elif defined (__SYMBIAN32__) -# define KHRONOS_APICALL IMPORT_C -#else -# define KHRONOS_APICALL -#endif - -/*------------------------------------------------------------------------- -* Definition of KHRONOS_APIENTRY -*------------------------------------------------------------------------- -* This follows the return type of the function and precedes the function -* name in the function prototype. -*/ -#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) -/* Win32 but not WinCE */ -# define KHRONOS_APIENTRY __stdcall -#else -# define KHRONOS_APIENTRY -#endif - -/*------------------------------------------------------------------------- -* Definition of KHRONOS_APIATTRIBUTES -*------------------------------------------------------------------------- -* This follows the closing parenthesis of the function prototype arguments. -*/ -#if defined (__ARMCC_2__) -#define KHRONOS_APIATTRIBUTES __softfp -#else -#define KHRONOS_APIATTRIBUTES -#endif - -/*------------------------------------------------------------------------- -* basic type definitions -*-----------------------------------------------------------------------*/ -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) - - -/* -* Using -*/ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__VMS ) || defined(__sgi) - -/* -* Using -*/ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) - -/* -* Win32 -*/ -typedef __int32 khronos_int32_t; -typedef unsigned __int32 khronos_uint32_t; -typedef __int64 khronos_int64_t; -typedef unsigned __int64 khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__sun__) || defined(__digital__) - -/* -* Sun or Digital -*/ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#if defined(__arch64__) || defined(_LP64) -typedef long int khronos_int64_t; -typedef unsigned long int khronos_uint64_t; -#else -typedef long long int khronos_int64_t; -typedef unsigned long long int khronos_uint64_t; -#endif /* __arch64__ */ -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif 0 - -/* -* Hypothetical platform with no float or int64 support -*/ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#define KHRONOS_SUPPORT_INT64 0 -#define KHRONOS_SUPPORT_FLOAT 0 - -#else - -/* -* Generic fallback -*/ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#endif - - -/* -* Types that are (so far) the same on all platforms -*/ -typedef signed char khronos_int8_t; -typedef unsigned char khronos_uint8_t; -typedef signed short int khronos_int16_t; -typedef unsigned short int khronos_uint16_t; - -/* -* Types that differ between LLP64 and LP64 architectures - in LLP64, -* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears -* to be the only LLP64 architecture in current use. -*/ -#ifdef _WIN64 -typedef signed long long int khronos_intptr_t; -typedef unsigned long long int khronos_uintptr_t; -typedef signed long long int khronos_ssize_t; -typedef unsigned long long int khronos_usize_t; -#else -typedef signed long int khronos_intptr_t; -typedef unsigned long int khronos_uintptr_t; -typedef signed long int khronos_ssize_t; -typedef unsigned long int khronos_usize_t; -#endif - -#if KHRONOS_SUPPORT_FLOAT -/* -* Float type -*/ -typedef float khronos_float_t; -#endif - -#if KHRONOS_SUPPORT_INT64 -/* Time types -* -* These types can be used to represent a time interval in nanoseconds or -* an absolute Unadjusted System Time. Unadjusted System Time is the number -* of nanoseconds since some arbitrary system event (e.g. since the last -* time the system booted). The Unadjusted System Time is an unsigned -* 64 bit value that wraps back to 0 every 584 years. Time intervals -* may be either signed or unsigned. -*/ -typedef khronos_uint64_t khronos_utime_nanoseconds_t; -typedef khronos_int64_t khronos_stime_nanoseconds_t; -#endif - -/* -* Dummy value used to pad enum types to 32 bits. -*/ -#ifndef KHRONOS_MAX_ENUM -#define KHRONOS_MAX_ENUM 0x7FFFFFFF -#endif - -/* -* Enumerated boolean type -* -* Values other than zero should be considered to be true. Therefore -* comparisons should not be made against KHRONOS_TRUE. -*/ -typedef enum { - KHRONOS_FALSE = 0, - KHRONOS_TRUE = 1, - KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM -} khronos_boolean_enum_t; - -#endif /* __khrplatform_h_ */ - - -#ifndef __eglplatform_h_ -#define __eglplatform_h_ - -/* -** Copyright (c) 2007-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Platform-specific types and definitions for egl.h -* $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $ -* -* Adopters may modify khrplatform.h and this file to suit their platform. -* You are encouraged to submit all modifications to the Khronos group so that -* they can be included in future versions of this file. Please submit changes -* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) -* by filing a bug against product "EGL" component "Registry". -*/ - -/*#include */ - -/* Macros used in EGL function prototype declarations. -* -* EGL functions should be prototyped as: -* -* EGLAPI return-type EGLAPIENTRY eglFunction(arguments); -* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); -* -* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h -*/ - -#ifndef EGLAPI -#define EGLAPI KHRONOS_APICALL -#endif - -#ifndef EGLAPIENTRY -#define EGLAPIENTRY KHRONOS_APIENTRY -#endif -#define EGLAPIENTRYP EGLAPIENTRY* - -/* The types NativeDisplayType, NativeWindowType, and NativePixmapType -* are aliases of window-system-dependent types, such as X Display * or -* Windows Device Context. They must be defined in platform-specific -* code below. The EGL-prefixed versions of Native*Type are the same -* types, renamed in EGL 1.3 so all types in the API start with "EGL". -* -* Khronos STRONGLY RECOMMENDS that you use the default definitions -* provided below, since these changes affect both binary and source -* portability of applications using EGL running on different EGL -* implementations. -*/ - -#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif -#ifndef NOMINMAX /* don't define min() and max(). */ -#define NOMINMAX -#endif -#include - -#if __WINRT__ -#include -typedef IUnknown * EGLNativeWindowType; -typedef IUnknown * EGLNativePixmapType; -typedef IUnknown * EGLNativeDisplayType; -#else -typedef HDC EGLNativeDisplayType; -typedef HBITMAP EGLNativePixmapType; -typedef HWND EGLNativeWindowType; -#endif - -#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ - -typedef int EGLNativeDisplayType; -typedef void *EGLNativeWindowType; -typedef void *EGLNativePixmapType; - -#elif defined(WL_EGL_PLATFORM) - -typedef struct wl_display *EGLNativeDisplayType; -typedef struct wl_egl_pixmap *EGLNativePixmapType; -typedef struct wl_egl_window *EGLNativeWindowType; - -#elif defined(__GBM__) - -typedef struct gbm_device *EGLNativeDisplayType; -typedef struct gbm_bo *EGLNativePixmapType; -typedef void *EGLNativeWindowType; - -#elif defined(__ANDROID__) /* Android */ - -struct ANativeWindow; -struct egl_native_pixmap_t; - -typedef struct ANativeWindow *EGLNativeWindowType; -typedef struct egl_native_pixmap_t *EGLNativePixmapType; -typedef void *EGLNativeDisplayType; - -#elif defined(MIR_EGL_PLATFORM) - -#include -typedef MirEGLNativeDisplayType EGLNativeDisplayType; -typedef void *EGLNativePixmapType; -typedef MirEGLNativeWindowType EGLNativeWindowType; - -#elif defined(__unix__) - -#ifdef MESA_EGL_NO_X11_HEADERS - -typedef void *EGLNativeDisplayType; -typedef khronos_uintptr_t EGLNativePixmapType; -typedef khronos_uintptr_t EGLNativeWindowType; - -#else - -/* X11 (tentative) */ -#include -#include - -typedef Display *EGLNativeDisplayType; -typedef Pixmap EGLNativePixmapType; -typedef Window EGLNativeWindowType; - -#endif /* MESA_EGL_NO_X11_HEADERS */ - -#else -#error "Platform not recognized" -#endif - -/* EGL 1.2 types, renamed for consistency in EGL 1.3 */ -typedef EGLNativeDisplayType NativeDisplayType; -typedef EGLNativePixmapType NativePixmapType; -typedef EGLNativeWindowType NativeWindowType; - - -/* Define EGLint. This must be a signed integral type large enough to contain -* all legal attribute names and values passed into and out of EGL, whether -* their type is boolean, bitmask, enumerant (symbolic constant), integer, -* handle, or other. While in general a 32-bit integer will suffice, if -* handles are 64 bit types, then EGLint should be defined as a signed 64-bit -* integer type. -*/ -typedef khronos_int32_t EGLint; - -#endif /* __eglplatform_h */ - -#ifndef __egl_h_ -#define __egl_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2013-2015 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ -/* -** This header is generated from the Khronos OpenGL / OpenGL ES XML -** API Registry. The current version of the Registry, generator scripts -** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 31566 $ on $Date: 2015-06-23 08:48:48 -0700 (Tue, 23 Jun 2015) $ -*/ - -/*#include */ - -/* Generated on date 20150623 */ - -/* Generated C header for: - * API: egl - * Versions considered: .* - * Versions emitted: .* - * Default extensions included: None - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef EGL_VERSION_1_0 -#define EGL_VERSION_1_0 1 -typedef unsigned int EGLBoolean; -typedef void *EGLDisplay; -typedef void *EGLConfig; -typedef void *EGLSurface; -typedef void *EGLContext; -typedef void (*__eglMustCastToProperFunctionPointerType)(void); -#define EGL_ALPHA_SIZE 0x3021 -#define EGL_BAD_ACCESS 0x3002 -#define EGL_BAD_ALLOC 0x3003 -#define EGL_BAD_ATTRIBUTE 0x3004 -#define EGL_BAD_CONFIG 0x3005 -#define EGL_BAD_CONTEXT 0x3006 -#define EGL_BAD_CURRENT_SURFACE 0x3007 -#define EGL_BAD_DISPLAY 0x3008 -#define EGL_BAD_MATCH 0x3009 -#define EGL_BAD_NATIVE_PIXMAP 0x300A -#define EGL_BAD_NATIVE_WINDOW 0x300B -#define EGL_BAD_PARAMETER 0x300C -#define EGL_BAD_SURFACE 0x300D -#define EGL_BLUE_SIZE 0x3022 -#define EGL_BUFFER_SIZE 0x3020 -#define EGL_CONFIG_CAVEAT 0x3027 -#define EGL_CONFIG_ID 0x3028 -#define EGL_CORE_NATIVE_ENGINE 0x305B -#define EGL_DEPTH_SIZE 0x3025 -#define EGL_DONT_CARE ((EGLint)-1) -#define EGL_DRAW 0x3059 -#define EGL_EXTENSIONS 0x3055 -#define EGL_FALSE 0 -#define EGL_GREEN_SIZE 0x3023 -#define EGL_HEIGHT 0x3056 -#define EGL_LARGEST_PBUFFER 0x3058 -#define EGL_LEVEL 0x3029 -#define EGL_MAX_PBUFFER_HEIGHT 0x302A -#define EGL_MAX_PBUFFER_PIXELS 0x302B -#define EGL_MAX_PBUFFER_WIDTH 0x302C -#define EGL_NATIVE_RENDERABLE 0x302D -#define EGL_NATIVE_VISUAL_ID 0x302E -#define EGL_NATIVE_VISUAL_TYPE 0x302F -#define EGL_NONE 0x3038 -#define EGL_NON_CONFORMANT_CONFIG 0x3051 -#define EGL_NOT_INITIALIZED 0x3001 -#define EGL_NO_CONTEXT ((EGLContext)0) -#define EGL_NO_DISPLAY ((EGLDisplay)0) -#define EGL_NO_SURFACE ((EGLSurface)0) -#define EGL_PBUFFER_BIT 0x0001 -#define EGL_PIXMAP_BIT 0x0002 -#define EGL_READ 0x305A -#define EGL_RED_SIZE 0x3024 -#define EGL_SAMPLES 0x3031 -#define EGL_SAMPLE_BUFFERS 0x3032 -#define EGL_SLOW_CONFIG 0x3050 -#define EGL_STENCIL_SIZE 0x3026 -#define EGL_SUCCESS 0x3000 -#define EGL_SURFACE_TYPE 0x3033 -#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 -#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 -#define EGL_TRANSPARENT_RED_VALUE 0x3037 -#define EGL_TRANSPARENT_RGB 0x3052 -#define EGL_TRANSPARENT_TYPE 0x3034 -#define EGL_TRUE 1 -#define EGL_VENDOR 0x3053 -#define EGL_VERSION 0x3054 -#define EGL_WIDTH 0x3057 -#define EGL_WINDOW_BIT 0x0004 -EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); -EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); -EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface); -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); -EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void); -EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw); -EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id); -EGLAPI EGLint EGLAPIENTRY eglGetError (void); -EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname); -EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor); -EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); -EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name); -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface); -EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine); -#endif /* EGL_VERSION_1_0 */ - -#ifndef EGL_VERSION_1_1 -#define EGL_VERSION_1_1 1 -#define EGL_BACK_BUFFER 0x3084 -#define EGL_BIND_TO_TEXTURE_RGB 0x3039 -#define EGL_BIND_TO_TEXTURE_RGBA 0x303A -#define EGL_CONTEXT_LOST 0x300E -#define EGL_MIN_SWAP_INTERVAL 0x303B -#define EGL_MAX_SWAP_INTERVAL 0x303C -#define EGL_MIPMAP_TEXTURE 0x3082 -#define EGL_MIPMAP_LEVEL 0x3083 -#define EGL_NO_TEXTURE 0x305C -#define EGL_TEXTURE_2D 0x305F -#define EGL_TEXTURE_FORMAT 0x3080 -#define EGL_TEXTURE_RGB 0x305D -#define EGL_TEXTURE_RGBA 0x305E -#define EGL_TEXTURE_TARGET 0x3081 -EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); -EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); -EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval); -#endif /* EGL_VERSION_1_1 */ - -#ifndef EGL_VERSION_1_2 -#define EGL_VERSION_1_2 1 -typedef unsigned int EGLenum; -typedef void *EGLClientBuffer; -#define EGL_ALPHA_FORMAT 0x3088 -#define EGL_ALPHA_FORMAT_NONPRE 0x308B -#define EGL_ALPHA_FORMAT_PRE 0x308C -#define EGL_ALPHA_MASK_SIZE 0x303E -#define EGL_BUFFER_PRESERVED 0x3094 -#define EGL_BUFFER_DESTROYED 0x3095 -#define EGL_CLIENT_APIS 0x308D -#define EGL_COLORSPACE 0x3087 -#define EGL_COLORSPACE_sRGB 0x3089 -#define EGL_COLORSPACE_LINEAR 0x308A -#define EGL_COLOR_BUFFER_TYPE 0x303F -#define EGL_CONTEXT_CLIENT_TYPE 0x3097 -#define EGL_DISPLAY_SCALING 10000 -#define EGL_HORIZONTAL_RESOLUTION 0x3090 -#define EGL_LUMINANCE_BUFFER 0x308F -#define EGL_LUMINANCE_SIZE 0x303D -#define EGL_OPENGL_ES_BIT 0x0001 -#define EGL_OPENVG_BIT 0x0002 -#define EGL_OPENGL_ES_API 0x30A0 -#define EGL_OPENVG_API 0x30A1 -#define EGL_OPENVG_IMAGE 0x3096 -#define EGL_PIXEL_ASPECT_RATIO 0x3092 -#define EGL_RENDERABLE_TYPE 0x3040 -#define EGL_RENDER_BUFFER 0x3086 -#define EGL_RGB_BUFFER 0x308E -#define EGL_SINGLE_BUFFER 0x3085 -#define EGL_SWAP_BEHAVIOR 0x3093 -#define EGL_UNKNOWN ((EGLint)-1) -#define EGL_VERTICAL_RESOLUTION 0x3091 -EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api); -EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void); -#endif /* EGL_VERSION_1_2 */ - -#ifndef EGL_VERSION_1_3 -#define EGL_VERSION_1_3 1 -#define EGL_CONFORMANT 0x3042 -#define EGL_CONTEXT_CLIENT_VERSION 0x3098 -#define EGL_MATCH_NATIVE_PIXMAP 0x3041 -#define EGL_OPENGL_ES2_BIT 0x0004 -#define EGL_VG_ALPHA_FORMAT 0x3088 -#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B -#define EGL_VG_ALPHA_FORMAT_PRE 0x308C -#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 -#define EGL_VG_COLORSPACE 0x3087 -#define EGL_VG_COLORSPACE_sRGB 0x3089 -#define EGL_VG_COLORSPACE_LINEAR 0x308A -#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 -#endif /* EGL_VERSION_1_3 */ - -#ifndef EGL_VERSION_1_4 -#define EGL_VERSION_1_4 1 -#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) -#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 -#define EGL_MULTISAMPLE_RESOLVE 0x3099 -#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A -#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B -#define EGL_OPENGL_API 0x30A2 -#define EGL_OPENGL_BIT 0x0008 -#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 -EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void); -#endif /* EGL_VERSION_1_4 */ - -#ifndef EGL_VERSION_1_5 -#define EGL_VERSION_1_5 1 -typedef void *EGLSync; -typedef intptr_t EGLAttrib; -typedef khronos_utime_nanoseconds_t EGLTime; -typedef void *EGLImage; -#define EGL_CONTEXT_MAJOR_VERSION 0x3098 -#define EGL_CONTEXT_MINOR_VERSION 0x30FB -#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD -#define EGL_NO_RESET_NOTIFICATION 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET 0x31BF -#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001 -#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define EGL_CONTEXT_OPENGL_DEBUG 0x31B0 -#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1 -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2 -#define EGL_OPENGL_ES3_BIT 0x00000040 -#define EGL_CL_EVENT_HANDLE 0x309C -#define EGL_SYNC_CL_EVENT 0x30FE -#define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF -#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0 -#define EGL_SYNC_TYPE 0x30F7 -#define EGL_SYNC_STATUS 0x30F1 -#define EGL_SYNC_CONDITION 0x30F8 -#define EGL_SIGNALED 0x30F2 -#define EGL_UNSIGNALED 0x30F3 -#define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001 -#define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull -#define EGL_TIMEOUT_EXPIRED 0x30F5 -#define EGL_CONDITION_SATISFIED 0x30F6 -#define EGL_NO_SYNC ((EGLSync)0) -#define EGL_SYNC_FENCE 0x30F9 -#define EGL_GL_COLORSPACE 0x309D -#define EGL_GL_COLORSPACE_SRGB 0x3089 -#define EGL_GL_COLORSPACE_LINEAR 0x308A -#define EGL_GL_RENDERBUFFER 0x30B9 -#define EGL_GL_TEXTURE_2D 0x30B1 -#define EGL_GL_TEXTURE_LEVEL 0x30BC -#define EGL_GL_TEXTURE_3D 0x30B2 -#define EGL_GL_TEXTURE_ZOFFSET 0x30BD -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 -#define EGL_IMAGE_PRESERVED 0x30D2 -#define EGL_NO_IMAGE ((EGLImage)0) -EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync); -EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); -EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); -EGLAPI EGLImage EGLAPIENTRY eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage (EGLDisplay dpy, EGLImage image); -EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags); -#endif /* EGL_VERSION_1_5 */ - -#ifdef __cplusplus -} -#endif - -#endif /* __egl_h_ */ - - - -#ifndef __eglext_h_ -#define __eglext_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2013-2015 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ -/* -** This header is generated from the Khronos OpenGL / OpenGL ES XML -** API Registry. The current version of the Registry, generator scripts -** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 31566 $ on $Date: 2015-06-23 08:48:48 -0700 (Tue, 23 Jun 2015) $ -*/ - -/*#include */ - -#define EGL_EGLEXT_VERSION 20150623 - -/* Generated C header for: - * API: egl - * Versions considered: .* - * Versions emitted: _nomatch_^ - * Default extensions included: egl - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef EGL_KHR_cl_event -#define EGL_KHR_cl_event 1 -#define EGL_CL_EVENT_HANDLE_KHR 0x309C -#define EGL_SYNC_CL_EVENT_KHR 0x30FE -#define EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF -#endif /* EGL_KHR_cl_event */ - -#ifndef EGL_KHR_cl_event2 -#define EGL_KHR_cl_event2 1 -typedef void *EGLSyncKHR; -typedef intptr_t EGLAttribKHR; -typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); -#endif -#endif /* EGL_KHR_cl_event2 */ - -#ifndef EGL_KHR_client_get_all_proc_addresses -#define EGL_KHR_client_get_all_proc_addresses 1 -#endif /* EGL_KHR_client_get_all_proc_addresses */ - -#ifndef EGL_KHR_config_attribs -#define EGL_KHR_config_attribs 1 -#define EGL_CONFORMANT_KHR 0x3042 -#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 -#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 -#endif /* EGL_KHR_config_attribs */ - -#ifndef EGL_KHR_create_context -#define EGL_KHR_create_context 1 -#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 -#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB -#define EGL_CONTEXT_FLAGS_KHR 0x30FC -#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD -#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF -#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 -#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 -#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 -#endif /* EGL_KHR_create_context */ - -#ifndef EGL_KHR_create_context_no_error -#define EGL_KHR_create_context_no_error 1 -#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31B3 -#endif /* EGL_KHR_create_context_no_error */ - -#ifndef EGL_KHR_fence_sync -#define EGL_KHR_fence_sync 1 -typedef khronos_utime_nanoseconds_t EGLTimeKHR; -#ifdef KHRONOS_SUPPORT_INT64 -#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 -#define EGL_SYNC_CONDITION_KHR 0x30F8 -#define EGL_SYNC_FENCE_KHR 0x30F9 -typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); -typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync); -EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); -EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); -#endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_KHR_fence_sync */ - -#ifndef EGL_KHR_get_all_proc_addresses -#define EGL_KHR_get_all_proc_addresses 1 -#endif /* EGL_KHR_get_all_proc_addresses */ - -#ifndef EGL_KHR_gl_colorspace -#define EGL_KHR_gl_colorspace 1 -#define EGL_GL_COLORSPACE_KHR 0x309D -#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 -#define EGL_GL_COLORSPACE_LINEAR_KHR 0x308A -#endif /* EGL_KHR_gl_colorspace */ - -#ifndef EGL_KHR_gl_renderbuffer_image -#define EGL_KHR_gl_renderbuffer_image 1 -#define EGL_GL_RENDERBUFFER_KHR 0x30B9 -#endif /* EGL_KHR_gl_renderbuffer_image */ - -#ifndef EGL_KHR_gl_texture_2D_image -#define EGL_KHR_gl_texture_2D_image 1 -#define EGL_GL_TEXTURE_2D_KHR 0x30B1 -#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC -#endif /* EGL_KHR_gl_texture_2D_image */ - -#ifndef EGL_KHR_gl_texture_3D_image -#define EGL_KHR_gl_texture_3D_image 1 -#define EGL_GL_TEXTURE_3D_KHR 0x30B2 -#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD -#endif /* EGL_KHR_gl_texture_3D_image */ - -#ifndef EGL_KHR_gl_texture_cubemap_image -#define EGL_KHR_gl_texture_cubemap_image 1 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 -#endif /* EGL_KHR_gl_texture_cubemap_image */ - -#ifndef EGL_KHR_image -#define EGL_KHR_image 1 -typedef void *EGLImageKHR; -#define EGL_NATIVE_PIXMAP_KHR 0x30B0 -#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) -typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); -#endif -#endif /* EGL_KHR_image */ - -#ifndef EGL_KHR_image_base -#define EGL_KHR_image_base 1 -#define EGL_IMAGE_PRESERVED_KHR 0x30D2 -#endif /* EGL_KHR_image_base */ - -#ifndef EGL_KHR_image_pixmap -#define EGL_KHR_image_pixmap 1 -#endif /* EGL_KHR_image_pixmap */ - -#ifndef EGL_KHR_lock_surface -#define EGL_KHR_lock_surface 1 -#define EGL_READ_SURFACE_BIT_KHR 0x0001 -#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 -#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 -#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 -#define EGL_MATCH_FORMAT_KHR 0x3043 -#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 -#define EGL_FORMAT_RGB_565_KHR 0x30C1 -#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 -#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 -#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 -#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 -#define EGL_BITMAP_POINTER_KHR 0x30C6 -#define EGL_BITMAP_PITCH_KHR 0x30C7 -#define EGL_BITMAP_ORIGIN_KHR 0x30C8 -#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 -#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA -#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB -#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC -#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD -#define EGL_LOWER_LEFT_KHR 0x30CE -#define EGL_UPPER_LEFT_KHR 0x30CF -typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface); -#endif -#endif /* EGL_KHR_lock_surface */ - -#ifndef EGL_KHR_lock_surface2 -#define EGL_KHR_lock_surface2 1 -#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 -#endif /* EGL_KHR_lock_surface2 */ - -#ifndef EGL_KHR_lock_surface3 -#define EGL_KHR_lock_surface3 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); -#endif -#endif /* EGL_KHR_lock_surface3 */ - -#ifndef EGL_KHR_partial_update -#define EGL_KHR_partial_update 1 -#define EGL_BUFFER_AGE_KHR 0x313D -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETDAMAGEREGIONKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSetDamageRegionKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); -#endif -#endif /* EGL_KHR_partial_update */ - -#ifndef EGL_KHR_platform_android -#define EGL_KHR_platform_android 1 -#define EGL_PLATFORM_ANDROID_KHR 0x3141 -#endif /* EGL_KHR_platform_android */ - -#ifndef EGL_KHR_platform_gbm -#define EGL_KHR_platform_gbm 1 -#define EGL_PLATFORM_GBM_KHR 0x31D7 -#endif /* EGL_KHR_platform_gbm */ - -#ifndef EGL_KHR_platform_wayland -#define EGL_KHR_platform_wayland 1 -#define EGL_PLATFORM_WAYLAND_KHR 0x31D8 -#endif /* EGL_KHR_platform_wayland */ - -#ifndef EGL_KHR_platform_x11 -#define EGL_KHR_platform_x11 1 -#define EGL_PLATFORM_X11_KHR 0x31D5 -#define EGL_PLATFORM_X11_SCREEN_KHR 0x31D6 -#endif /* EGL_KHR_platform_x11 */ - -#ifndef EGL_KHR_reusable_sync -#define EGL_KHR_reusable_sync 1 -#ifdef KHRONOS_SUPPORT_INT64 -#define EGL_SYNC_STATUS_KHR 0x30F1 -#define EGL_SIGNALED_KHR 0x30F2 -#define EGL_UNSIGNALED_KHR 0x30F3 -#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 -#define EGL_CONDITION_SATISFIED_KHR 0x30F6 -#define EGL_SYNC_TYPE_KHR 0x30F7 -#define EGL_SYNC_REUSABLE_KHR 0x30FA -#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 -#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull -#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); -#endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_KHR_reusable_sync */ - -#ifndef EGL_KHR_stream -#define EGL_KHR_stream 1 -typedef void *EGLStreamKHR; -typedef khronos_uint64_t EGLuint64KHR; -#ifdef KHRONOS_SUPPORT_INT64 -#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) -#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 -#define EGL_PRODUCER_FRAME_KHR 0x3212 -#define EGL_CONSUMER_FRAME_KHR 0x3213 -#define EGL_STREAM_STATE_KHR 0x3214 -#define EGL_STREAM_STATE_CREATED_KHR 0x3215 -#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 -#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 -#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 -#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 -#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A -#define EGL_BAD_STREAM_KHR 0x321B -#define EGL_BAD_STATE_KHR 0x321C -typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR (EGLDisplay dpy, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR (EGLDisplay dpy, EGLStreamKHR stream); -EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); -#endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_KHR_stream */ - -#ifndef EGL_KHR_stream_consumer_gltexture -#define EGL_KHR_stream_consumer_gltexture 1 -#ifdef EGL_KHR_stream -#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR (EGLDisplay dpy, EGLStreamKHR stream); -EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR (EGLDisplay dpy, EGLStreamKHR stream); -EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLStreamKHR stream); -#endif -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_consumer_gltexture */ - -#ifndef EGL_KHR_stream_cross_process_fd -#define EGL_KHR_stream_cross_process_fd 1 -typedef int EGLNativeFileDescriptorKHR; -#ifdef EGL_KHR_stream -#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) -typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); -typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR (EGLDisplay dpy, EGLStreamKHR stream); -EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); -#endif -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_cross_process_fd */ - -#ifndef EGL_KHR_stream_fifo -#define EGL_KHR_stream_fifo 1 -#ifdef EGL_KHR_stream -#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC -#define EGL_STREAM_TIME_NOW_KHR 0x31FD -#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE -#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); -#endif -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_fifo */ - -#ifndef EGL_KHR_stream_producer_aldatalocator -#define EGL_KHR_stream_producer_aldatalocator 1 -#ifdef EGL_KHR_stream -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_producer_aldatalocator */ - -#ifndef EGL_KHR_stream_producer_eglsurface -#define EGL_KHR_stream_producer_eglsurface 1 -#ifdef EGL_KHR_stream -#define EGL_STREAM_BIT_KHR 0x0800 -typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); -#endif -#endif /* EGL_KHR_stream */ -#endif /* EGL_KHR_stream_producer_eglsurface */ - -#ifndef EGL_KHR_surfaceless_context -#define EGL_KHR_surfaceless_context 1 -#endif /* EGL_KHR_surfaceless_context */ - -#ifndef EGL_KHR_swap_buffers_with_damage -#define EGL_KHR_swap_buffers_with_damage 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); -#endif -#endif /* EGL_KHR_swap_buffers_with_damage */ - -#ifndef EGL_KHR_vg_parent_image -#define EGL_KHR_vg_parent_image 1 -#define EGL_VG_PARENT_IMAGE_KHR 0x30BA -#endif /* EGL_KHR_vg_parent_image */ - -#ifndef EGL_KHR_wait_sync -#define EGL_KHR_wait_sync 1 -typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); -#endif -#endif /* EGL_KHR_wait_sync */ - -#ifndef EGL_ANDROID_blob_cache -#define EGL_ANDROID_blob_cache 1 -typedef khronos_ssize_t EGLsizeiANDROID; -typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); -typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); -typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC) (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); -#endif -#endif /* EGL_ANDROID_blob_cache */ - -#ifndef EGL_ANDROID_framebuffer_target -#define EGL_ANDROID_framebuffer_target 1 -#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 -#endif /* EGL_ANDROID_framebuffer_target */ - -#ifndef EGL_ANDROID_image_native_buffer -#define EGL_ANDROID_image_native_buffer 1 -#define EGL_NATIVE_BUFFER_ANDROID 0x3140 -#endif /* EGL_ANDROID_image_native_buffer */ - -#ifndef EGL_ANDROID_native_fence_sync -#define EGL_ANDROID_native_fence_sync 1 -#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 -#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 -#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 -#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 -typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR sync); -#endif -#endif /* EGL_ANDROID_native_fence_sync */ - -#ifndef EGL_ANDROID_recordable -#define EGL_ANDROID_recordable 1 -#define EGL_RECORDABLE_ANDROID 0x3142 -#endif /* EGL_ANDROID_recordable */ - -#ifndef EGL_ANGLE_d3d_share_handle_client_buffer -#define EGL_ANGLE_d3d_share_handle_client_buffer 1 -#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 -#endif /* EGL_ANGLE_d3d_share_handle_client_buffer */ - -#ifndef EGL_ANGLE_device_d3d -#define EGL_ANGLE_device_d3d 1 -#define EGL_D3D9_DEVICE_ANGLE 0x33A0 -#define EGL_D3D11_DEVICE_ANGLE 0x33A1 -#endif /* EGL_ANGLE_device_d3d */ - -#ifndef EGL_ANGLE_query_surface_pointer -#define EGL_ANGLE_query_surface_pointer 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); -#endif -#endif /* EGL_ANGLE_query_surface_pointer */ - -#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle -#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 -#endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */ - -#ifndef EGL_ANGLE_window_fixed_size -#define EGL_ANGLE_window_fixed_size 1 -#define EGL_FIXED_SIZE_ANGLE 0x3201 -#endif /* EGL_ANGLE_window_fixed_size */ - -#ifndef EGL_ARM_pixmap_multisample_discard -#define EGL_ARM_pixmap_multisample_discard 1 -#define EGL_DISCARD_SAMPLES_ARM 0x3286 -#endif /* EGL_ARM_pixmap_multisample_discard */ - -#ifndef EGL_EXT_buffer_age -#define EGL_EXT_buffer_age 1 -#define EGL_BUFFER_AGE_EXT 0x313D -#endif /* EGL_EXT_buffer_age */ - -#ifndef EGL_EXT_client_extensions -#define EGL_EXT_client_extensions 1 -#endif /* EGL_EXT_client_extensions */ - -#ifndef EGL_EXT_create_context_robustness -#define EGL_EXT_create_context_robustness 1 -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 -#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF -#endif /* EGL_EXT_create_context_robustness */ - -#ifndef EGL_EXT_device_base -#define EGL_EXT_device_base 1 -typedef void *EGLDeviceEXT; -#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)(0)) -#define EGL_BAD_DEVICE_EXT 0x322B -#define EGL_DEVICE_EXT 0x322C -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); -typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); -EGLAPI const char *EGLAPIENTRY eglQueryDeviceStringEXT (EGLDeviceEXT device, EGLint name); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryDevicesEXT (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); -#endif -#endif /* EGL_EXT_device_base */ - -#ifndef EGL_EXT_device_drm -#define EGL_EXT_device_drm 1 -#define EGL_DRM_DEVICE_FILE_EXT 0x3233 -#endif /* EGL_EXT_device_drm */ - -#ifndef EGL_EXT_device_enumeration -#define EGL_EXT_device_enumeration 1 -#endif /* EGL_EXT_device_enumeration */ - -#ifndef EGL_EXT_device_openwf -#define EGL_EXT_device_openwf 1 -#define EGL_OPENWF_DEVICE_ID_EXT 0x3237 -#endif /* EGL_EXT_device_openwf */ - -#ifndef EGL_EXT_device_query -#define EGL_EXT_device_query 1 -#endif /* EGL_EXT_device_query */ - -#ifndef EGL_EXT_image_dma_buf_import -#define EGL_EXT_image_dma_buf_import 1 -#define EGL_LINUX_DMA_BUF_EXT 0x3270 -#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 -#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 -#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 -#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 -#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 -#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 -#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 -#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 -#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 -#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A -#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B -#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C -#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D -#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E -#define EGL_ITU_REC601_EXT 0x327F -#define EGL_ITU_REC709_EXT 0x3280 -#define EGL_ITU_REC2020_EXT 0x3281 -#define EGL_YUV_FULL_RANGE_EXT 0x3282 -#define EGL_YUV_NARROW_RANGE_EXT 0x3283 -#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 -#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 -#endif /* EGL_EXT_image_dma_buf_import */ - -#ifndef EGL_EXT_multiview_window -#define EGL_EXT_multiview_window 1 -#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 -#endif /* EGL_EXT_multiview_window */ - -#ifndef EGL_EXT_output_base -#define EGL_EXT_output_base 1 -typedef void *EGLOutputLayerEXT; -typedef void *EGLOutputPortEXT; -#define EGL_NO_OUTPUT_LAYER_EXT ((EGLOutputLayerEXT)0) -#define EGL_NO_OUTPUT_PORT_EXT ((EGLOutputPortEXT)0) -#define EGL_BAD_OUTPUT_LAYER_EXT 0x322D -#define EGL_BAD_OUTPUT_PORT_EXT 0x322E -#define EGL_SWAP_INTERVAL_EXT 0x322F -typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTLAYERSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTPORTSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); -typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); -typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputLayersEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); -EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputPortsEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); -EGLAPI EGLBoolean EGLAPIENTRY eglOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); -EGLAPI const char *EGLAPIENTRY eglQueryOutputLayerStringEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); -EGLAPI EGLBoolean EGLAPIENTRY eglOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); -EGLAPI const char *EGLAPIENTRY eglQueryOutputPortStringEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); -#endif -#endif /* EGL_EXT_output_base */ - -#ifndef EGL_EXT_output_drm -#define EGL_EXT_output_drm 1 -#define EGL_DRM_CRTC_EXT 0x3234 -#define EGL_DRM_PLANE_EXT 0x3235 -#define EGL_DRM_CONNECTOR_EXT 0x3236 -#endif /* EGL_EXT_output_drm */ - -#ifndef EGL_EXT_output_openwf -#define EGL_EXT_output_openwf 1 -#define EGL_OPENWF_PIPELINE_ID_EXT 0x3238 -#define EGL_OPENWF_PORT_ID_EXT 0x3239 -#endif /* EGL_EXT_output_openwf */ - -#ifndef EGL_EXT_platform_base -#define EGL_EXT_platform_base 1 -typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); -typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); -typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT (EGLenum platform, void *native_display, const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); -#endif -#endif /* EGL_EXT_platform_base */ - -#ifndef EGL_EXT_platform_device -#define EGL_EXT_platform_device 1 -#define EGL_PLATFORM_DEVICE_EXT 0x313F -#endif /* EGL_EXT_platform_device */ - -#ifndef EGL_EXT_platform_wayland -#define EGL_EXT_platform_wayland 1 -#define EGL_PLATFORM_WAYLAND_EXT 0x31D8 -#endif /* EGL_EXT_platform_wayland */ - -#ifndef EGL_EXT_platform_x11 -#define EGL_EXT_platform_x11 1 -#define EGL_PLATFORM_X11_EXT 0x31D5 -#define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 -#endif /* EGL_EXT_platform_x11 */ - -#ifndef EGL_EXT_protected_surface -#define EGL_EXT_protected_surface 1 -#define EGL_PROTECTED_CONTENT_EXT 0x32C0 -#endif /* EGL_EXT_protected_surface */ - -#ifndef EGL_EXT_stream_consumer_egloutput -#define EGL_EXT_stream_consumer_egloutput 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerOutputEXT (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); -#endif -#endif /* EGL_EXT_stream_consumer_egloutput */ - -#ifndef EGL_EXT_swap_buffers_with_damage -#define EGL_EXT_swap_buffers_with_damage 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); -#endif -#endif /* EGL_EXT_swap_buffers_with_damage */ - -#ifndef EGL_EXT_yuv_surface -#define EGL_EXT_yuv_surface 1 -#define EGL_YUV_ORDER_EXT 0x3301 -#define EGL_YUV_NUMBER_OF_PLANES_EXT 0x3311 -#define EGL_YUV_SUBSAMPLE_EXT 0x3312 -#define EGL_YUV_DEPTH_RANGE_EXT 0x3317 -#define EGL_YUV_CSC_STANDARD_EXT 0x330A -#define EGL_YUV_PLANE_BPP_EXT 0x331A -#define EGL_YUV_BUFFER_EXT 0x3300 -#define EGL_YUV_ORDER_YUV_EXT 0x3302 -#define EGL_YUV_ORDER_YVU_EXT 0x3303 -#define EGL_YUV_ORDER_YUYV_EXT 0x3304 -#define EGL_YUV_ORDER_UYVY_EXT 0x3305 -#define EGL_YUV_ORDER_YVYU_EXT 0x3306 -#define EGL_YUV_ORDER_VYUY_EXT 0x3307 -#define EGL_YUV_ORDER_AYUV_EXT 0x3308 -#define EGL_YUV_SUBSAMPLE_4_2_0_EXT 0x3313 -#define EGL_YUV_SUBSAMPLE_4_2_2_EXT 0x3314 -#define EGL_YUV_SUBSAMPLE_4_4_4_EXT 0x3315 -#define EGL_YUV_DEPTH_RANGE_LIMITED_EXT 0x3318 -#define EGL_YUV_DEPTH_RANGE_FULL_EXT 0x3319 -#define EGL_YUV_CSC_STANDARD_601_EXT 0x330B -#define EGL_YUV_CSC_STANDARD_709_EXT 0x330C -#define EGL_YUV_CSC_STANDARD_2020_EXT 0x330D -#define EGL_YUV_PLANE_BPP_0_EXT 0x331B -#define EGL_YUV_PLANE_BPP_8_EXT 0x331C -#define EGL_YUV_PLANE_BPP_10_EXT 0x331D -#endif /* EGL_EXT_yuv_surface */ - -#ifndef EGL_HI_clientpixmap -#define EGL_HI_clientpixmap 1 -struct EGLClientPixmapHI { - void *pData; - EGLint iWidth; - EGLint iHeight; - EGLint iStride; -}; -#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 -typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); -#endif -#endif /* EGL_HI_clientpixmap */ - -#ifndef EGL_HI_colorformats -#define EGL_HI_colorformats 1 -#define EGL_COLOR_FORMAT_HI 0x8F70 -#define EGL_COLOR_RGB_HI 0x8F71 -#define EGL_COLOR_RGBA_HI 0x8F72 -#define EGL_COLOR_ARGB_HI 0x8F73 -#endif /* EGL_HI_colorformats */ - -#ifndef EGL_IMG_context_priority -#define EGL_IMG_context_priority 1 -#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 -#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 -#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 -#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 -#endif /* EGL_IMG_context_priority */ - -#ifndef EGL_MESA_drm_image -#define EGL_MESA_drm_image 1 -#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 -#define EGL_DRM_BUFFER_USE_MESA 0x31D1 -#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 -#define EGL_DRM_BUFFER_MESA 0x31D3 -#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 -#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 -#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 -typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); -#endif -#endif /* EGL_MESA_drm_image */ - -#ifndef EGL_MESA_image_dma_buf_export -#define EGL_MESA_image_dma_buf_export 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageQueryMESA (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); -EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); -#endif -#endif /* EGL_MESA_image_dma_buf_export */ - -#ifndef EGL_MESA_platform_gbm -#define EGL_MESA_platform_gbm 1 -#define EGL_PLATFORM_GBM_MESA 0x31D7 -#endif /* EGL_MESA_platform_gbm */ - -#ifndef EGL_NOK_swap_region -#define EGL_NOK_swap_region 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); -#endif -#endif /* EGL_NOK_swap_region */ - -#ifndef EGL_NOK_swap_region2 -#define EGL_NOK_swap_region2 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGION2NOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); -#endif -#endif /* EGL_NOK_swap_region2 */ - -#ifndef EGL_NOK_texture_from_pixmap -#define EGL_NOK_texture_from_pixmap 1 -#define EGL_Y_INVERTED_NOK 0x307F -#endif /* EGL_NOK_texture_from_pixmap */ - -#ifndef EGL_NV_3dvision_surface -#define EGL_NV_3dvision_surface 1 -#define EGL_AUTO_STEREO_NV 0x3136 -#endif /* EGL_NV_3dvision_surface */ - -#ifndef EGL_NV_coverage_sample -#define EGL_NV_coverage_sample 1 -#define EGL_COVERAGE_BUFFERS_NV 0x30E0 -#define EGL_COVERAGE_SAMPLES_NV 0x30E1 -#endif /* EGL_NV_coverage_sample */ - -#ifndef EGL_NV_coverage_sample_resolve -#define EGL_NV_coverage_sample_resolve 1 -#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 -#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 -#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 -#endif /* EGL_NV_coverage_sample_resolve */ - -#ifndef EGL_NV_cuda_event -#define EGL_NV_cuda_event 1 -#define EGL_CUDA_EVENT_HANDLE_NV 0x323B -#define EGL_SYNC_CUDA_EVENT_NV 0x323C -#define EGL_SYNC_CUDA_EVENT_COMPLETE_NV 0x323D -#endif /* EGL_NV_cuda_event */ - -#ifndef EGL_NV_depth_nonlinear -#define EGL_NV_depth_nonlinear 1 -#define EGL_DEPTH_ENCODING_NV 0x30E2 -#define EGL_DEPTH_ENCODING_NONE_NV 0 -#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 -#endif /* EGL_NV_depth_nonlinear */ - -#ifndef EGL_NV_device_cuda -#define EGL_NV_device_cuda 1 -#define EGL_CUDA_DEVICE_NV 0x323A -#endif /* EGL_NV_device_cuda */ - -#ifndef EGL_NV_native_query -#define EGL_NV_native_query 1 -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC) (EGLDisplay dpy, EGLNativeDisplayType *display_id); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV (EGLDisplay dpy, EGLNativeDisplayType *display_id); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); -#endif -#endif /* EGL_NV_native_query */ - -#ifndef EGL_NV_post_convert_rounding -#define EGL_NV_post_convert_rounding 1 -#endif /* EGL_NV_post_convert_rounding */ - -#ifndef EGL_NV_post_sub_buffer -#define EGL_NV_post_sub_buffer 1 -#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE -typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); -#endif -#endif /* EGL_NV_post_sub_buffer */ - -#ifndef EGL_NV_stream_sync -#define EGL_NV_stream_sync 1 -#define EGL_SYNC_NEW_FRAME_NV 0x321F -typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESTREAMSYNCNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateStreamSyncNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); -#endif -#endif /* EGL_NV_stream_sync */ - -#ifndef EGL_NV_sync -#define EGL_NV_sync 1 -typedef void *EGLSyncNV; -typedef khronos_utime_nanoseconds_t EGLTimeNV; -#ifdef KHRONOS_SUPPORT_INT64 -#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 -#define EGL_SYNC_STATUS_NV 0x30E7 -#define EGL_SIGNALED_NV 0x30E8 -#define EGL_UNSIGNALED_NV 0x30E9 -#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 -#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull -#define EGL_ALREADY_SIGNALED_NV 0x30EA -#define EGL_TIMEOUT_EXPIRED_NV 0x30EB -#define EGL_CONDITION_SATISFIED_NV 0x30EC -#define EGL_SYNC_TYPE_NV 0x30ED -#define EGL_SYNC_CONDITION_NV 0x30EE -#define EGL_SYNC_FENCE_NV 0x30EF -#define EGL_NO_SYNC_NV ((EGLSyncNV)0) -typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); -typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync); -EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync); -EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); -EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); -EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); -#endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_NV_sync */ - -#ifndef EGL_NV_system_time -#define EGL_NV_system_time 1 -typedef khronos_utime_nanoseconds_t EGLuint64NV; -#ifdef KHRONOS_SUPPORT_INT64 -typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void); -typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void); -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV (void); -EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); -#endif -#endif /* KHRONOS_SUPPORT_INT64 */ -#endif /* EGL_NV_system_time */ - -#ifndef EGL_TIZEN_image_native_buffer -#define EGL_TIZEN_image_native_buffer 1 -#define EGL_NATIVE_BUFFER_TIZEN 0x32A0 -#endif /* EGL_TIZEN_image_native_buffer */ - -#ifndef EGL_TIZEN_image_native_surface -#define EGL_TIZEN_image_native_surface 1 -#define EGL_NATIVE_SURFACE_TIZEN 0x32A1 -#endif /* EGL_TIZEN_image_native_surface */ - -#ifdef __cplusplus -} -#endif - -#endif /* __eglext_h_ */ - - -#endif /* _MSC_VER */ diff --git a/thirdparty/include/SDL2/SDL_endian.h b/thirdparty/include/SDL2/SDL_endian.h deleted file mode 100644 index 171c008a8..000000000 --- a/thirdparty/include/SDL2/SDL_endian.h +++ /dev/null @@ -1,263 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_endian.h - * - * Functions for reading and writing endian-specific values - */ - -#ifndef SDL_endian_h_ -#define SDL_endian_h_ - -#include "SDL_stdinc.h" - -/** - * \name The two types of endianness - */ -/* @{ */ -#define SDL_LIL_ENDIAN 1234 -#define SDL_BIG_ENDIAN 4321 -/* @} */ - -#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ -#ifdef __linux__ -#include -#define SDL_BYTEORDER __BYTE_ORDER -#elif defined(__OpenBSD__) -#include -#define SDL_BYTEORDER BYTE_ORDER -#else -#if defined(__hppa__) || \ - defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ - (defined(__MIPS__) && defined(__MIPSEB__)) || \ - defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ - defined(__sparc__) -#define SDL_BYTEORDER SDL_BIG_ENDIAN -#else -#define SDL_BYTEORDER SDL_LIL_ENDIAN -#endif -#endif /* __linux__ */ -#endif /* !SDL_BYTEORDER */ - - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \file SDL_endian.h - */ -#if defined(__GNUC__) && defined(__i386__) && \ - !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) -SDL_FORCE_INLINE Uint16 -SDL_Swap16(Uint16 x) -{ - __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); - return x; -} -#elif defined(__GNUC__) && defined(__x86_64__) -SDL_FORCE_INLINE Uint16 -SDL_Swap16(Uint16 x) -{ - __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); - return x; -} -#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) -SDL_FORCE_INLINE Uint16 -SDL_Swap16(Uint16 x) -{ - int result; - - __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); - return (Uint16)result; -} -#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) -SDL_FORCE_INLINE Uint16 -SDL_Swap16(Uint16 x) -{ - __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); - return x; -} -#elif defined(__WATCOMC__) && defined(__386__) -extern _inline Uint16 SDL_Swap16(Uint16); -#pragma aux SDL_Swap16 = \ - "xchg al, ah" \ - parm [ax] \ - modify [ax]; -#else -SDL_FORCE_INLINE Uint16 -SDL_Swap16(Uint16 x) -{ - return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); -} -#endif - -#if defined(__GNUC__) && defined(__i386__) -SDL_FORCE_INLINE Uint32 -SDL_Swap32(Uint32 x) -{ - __asm__("bswap %0": "=r"(x):"0"(x)); - return x; -} -#elif defined(__GNUC__) && defined(__x86_64__) -SDL_FORCE_INLINE Uint32 -SDL_Swap32(Uint32 x) -{ - __asm__("bswapl %0": "=r"(x):"0"(x)); - return x; -} -#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) -SDL_FORCE_INLINE Uint32 -SDL_Swap32(Uint32 x) -{ - Uint32 result; - - __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); - __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); - __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); - return result; -} -#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) -SDL_FORCE_INLINE Uint32 -SDL_Swap32(Uint32 x) -{ - __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); - return x; -} -#elif defined(__WATCOMC__) && defined(__386__) -extern _inline Uint32 SDL_Swap32(Uint32); -#ifndef __SW_3 /* 486+ */ -#pragma aux SDL_Swap32 = \ - "bswap eax" \ - parm [eax] \ - modify [eax]; -#else /* 386-only */ -#pragma aux SDL_Swap32 = \ - "xchg al, ah" \ - "ror eax, 16" \ - "xchg al, ah" \ - parm [eax] \ - modify [eax]; -#endif -#else -SDL_FORCE_INLINE Uint32 -SDL_Swap32(Uint32 x) -{ - return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | - ((x >> 8) & 0x0000FF00) | (x >> 24))); -} -#endif - -#if defined(__GNUC__) && defined(__i386__) -SDL_FORCE_INLINE Uint64 -SDL_Swap64(Uint64 x) -{ - union - { - struct - { - Uint32 a, b; - } s; - Uint64 u; - } v; - v.u = x; - __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), - "1"(v.s. - b)); - return v.u; -} -#elif defined(__GNUC__) && defined(__x86_64__) -SDL_FORCE_INLINE Uint64 -SDL_Swap64(Uint64 x) -{ - __asm__("bswapq %0": "=r"(x):"0"(x)); - return x; -} -#else -SDL_FORCE_INLINE Uint64 -SDL_Swap64(Uint64 x) -{ - Uint32 hi, lo; - - /* Separate into high and low 32-bit values and swap them */ - lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); - x >>= 32; - hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); - x = SDL_Swap32(lo); - x <<= 32; - x |= SDL_Swap32(hi); - return (x); -} -#endif - - -SDL_FORCE_INLINE float -SDL_SwapFloat(float x) -{ - union - { - float f; - Uint32 ui32; - } swapper; - swapper.f = x; - swapper.ui32 = SDL_Swap32(swapper.ui32); - return swapper.f; -} - - -/** - * \name Swap to native - * Byteswap item from the specified endianness to the native endianness. - */ -/* @{ */ -#if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define SDL_SwapLE16(X) (X) -#define SDL_SwapLE32(X) (X) -#define SDL_SwapLE64(X) (X) -#define SDL_SwapFloatLE(X) (X) -#define SDL_SwapBE16(X) SDL_Swap16(X) -#define SDL_SwapBE32(X) SDL_Swap32(X) -#define SDL_SwapBE64(X) SDL_Swap64(X) -#define SDL_SwapFloatBE(X) SDL_SwapFloat(X) -#else -#define SDL_SwapLE16(X) SDL_Swap16(X) -#define SDL_SwapLE32(X) SDL_Swap32(X) -#define SDL_SwapLE64(X) SDL_Swap64(X) -#define SDL_SwapFloatLE(X) SDL_SwapFloat(X) -#define SDL_SwapBE16(X) (X) -#define SDL_SwapBE32(X) (X) -#define SDL_SwapBE64(X) (X) -#define SDL_SwapFloatBE(X) (X) -#endif -/* @} *//* Swap to native */ - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_endian_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_error.h b/thirdparty/include/SDL2/SDL_error.h deleted file mode 100644 index aae37c0e4..000000000 --- a/thirdparty/include/SDL2/SDL_error.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_error.h - * - * Simple error message routines for SDL. - */ - -#ifndef SDL_error_h_ -#define SDL_error_h_ - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Public functions */ -/* SDL_SetError() unconditionally returns -1. */ -extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); -extern DECLSPEC const char *SDLCALL SDL_GetError(void); -extern DECLSPEC void SDLCALL SDL_ClearError(void); - -/** - * \name Internal error functions - * - * \internal - * Private error reporting function - used internally. - */ -/* @{ */ -#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) -#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) -#define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) -typedef enum -{ - SDL_ENOMEM, - SDL_EFREAD, - SDL_EFWRITE, - SDL_EFSEEK, - SDL_UNSUPPORTED, - SDL_LASTERROR -} SDL_errorcode; -/* SDL_Error() unconditionally returns -1. */ -extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); -/* @} *//* Internal error functions */ - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_error_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_events.h b/thirdparty/include/SDL2/SDL_events.h deleted file mode 100644 index 32cfbe327..000000000 --- a/thirdparty/include/SDL2/SDL_events.h +++ /dev/null @@ -1,792 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_events.h - * - * Include file for SDL event handling. - */ - -#ifndef SDL_events_h_ -#define SDL_events_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_video.h" -#include "SDL_keyboard.h" -#include "SDL_mouse.h" -#include "SDL_joystick.h" -#include "SDL_gamecontroller.h" -#include "SDL_quit.h" -#include "SDL_gesture.h" -#include "SDL_touch.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* General keyboard/mouse state definitions */ -#define SDL_RELEASED 0 -#define SDL_PRESSED 1 - -/** - * \brief The types of events that can be delivered. - */ -typedef enum -{ - SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */ - - /* Application events */ - SDL_QUIT = 0x100, /**< User-requested quit */ - - /* These application events have special meaning on iOS, see README-ios.md for details */ - SDL_APP_TERMINATING, /**< The application is being terminated by the OS - Called on iOS in applicationWillTerminate() - Called on Android in onDestroy() - */ - SDL_APP_LOWMEMORY, /**< The application is low on memory, free memory if possible. - Called on iOS in applicationDidReceiveMemoryWarning() - Called on Android in onLowMemory() - */ - SDL_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background - Called on iOS in applicationWillResignActive() - Called on Android in onPause() - */ - SDL_APP_DIDENTERBACKGROUND, /**< The application did enter the background and may not get CPU for some time - Called on iOS in applicationDidEnterBackground() - Called on Android in onPause() - */ - SDL_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground - Called on iOS in applicationWillEnterForeground() - Called on Android in onResume() - */ - SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive - Called on iOS in applicationDidBecomeActive() - Called on Android in onResume() - */ - - /* Display events */ - SDL_DISPLAYEVENT = 0x150, /**< Display state change */ - - /* Window events */ - SDL_WINDOWEVENT = 0x200, /**< Window state change */ - SDL_SYSWMEVENT, /**< System specific event */ - - /* Keyboard events */ - SDL_KEYDOWN = 0x300, /**< Key pressed */ - SDL_KEYUP, /**< Key released */ - SDL_TEXTEDITING, /**< Keyboard text editing (composition) */ - SDL_TEXTINPUT, /**< Keyboard text input */ - SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an - input language or keyboard layout change. - */ - - /* Mouse events */ - SDL_MOUSEMOTION = 0x400, /**< Mouse moved */ - SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ - SDL_MOUSEBUTTONUP, /**< Mouse button released */ - SDL_MOUSEWHEEL, /**< Mouse wheel motion */ - - /* Joystick events */ - SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */ - SDL_JOYBALLMOTION, /**< Joystick trackball motion */ - SDL_JOYHATMOTION, /**< Joystick hat position change */ - SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ - SDL_JOYBUTTONUP, /**< Joystick button released */ - SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */ - SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */ - - /* Game controller events */ - SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */ - SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */ - SDL_CONTROLLERBUTTONUP, /**< Game controller button released */ - SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */ - SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */ - SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */ - - /* Touch events */ - SDL_FINGERDOWN = 0x700, - SDL_FINGERUP, - SDL_FINGERMOTION, - - /* Gesture events */ - SDL_DOLLARGESTURE = 0x800, - SDL_DOLLARRECORD, - SDL_MULTIGESTURE, - - /* Clipboard events */ - SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */ - - /* Drag and drop events */ - SDL_DROPFILE = 0x1000, /**< The system requests a file open */ - SDL_DROPTEXT, /**< text/plain drag-and-drop event */ - SDL_DROPBEGIN, /**< A new set of drops is beginning (NULL filename) */ - SDL_DROPCOMPLETE, /**< Current set of drops is now complete (NULL filename) */ - - /* Audio hotplug events */ - SDL_AUDIODEVICEADDED = 0x1100, /**< A new audio device is available */ - SDL_AUDIODEVICEREMOVED, /**< An audio device has been removed. */ - - /* Sensor events */ - SDL_SENSORUPDATE = 0x1200, /**< A sensor was updated */ - - /* Render events */ - SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */ - SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */ - - /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, - * and should be allocated with SDL_RegisterEvents() - */ - SDL_USEREVENT = 0x8000, - - /** - * This last event is only for bounding internal arrays - */ - SDL_LASTEVENT = 0xFFFF -} SDL_EventType; - -/** - * \brief Fields shared by every event - */ -typedef struct SDL_CommonEvent -{ - Uint32 type; - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ -} SDL_CommonEvent; - -/** - * \brief Display state change event data (event.display.*) - */ -typedef struct SDL_DisplayEvent -{ - Uint32 type; /**< ::SDL_DISPLAYEVENT */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Uint32 display; /**< The associated display index */ - Uint8 event; /**< ::SDL_DisplayEventID */ - Uint8 padding1; - Uint8 padding2; - Uint8 padding3; - Sint32 data1; /**< event dependent data */ -} SDL_DisplayEvent; - -/** - * \brief Window state change event data (event.window.*) - */ -typedef struct SDL_WindowEvent -{ - Uint32 type; /**< ::SDL_WINDOWEVENT */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Uint32 windowID; /**< The associated window */ - Uint8 event; /**< ::SDL_WindowEventID */ - Uint8 padding1; - Uint8 padding2; - Uint8 padding3; - Sint32 data1; /**< event dependent data */ - Sint32 data2; /**< event dependent data */ -} SDL_WindowEvent; - -/** - * \brief Keyboard button event structure (event.key.*) - */ -typedef struct SDL_KeyboardEvent -{ - Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Uint32 windowID; /**< The window with keyboard focus, if any */ - Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ - Uint8 repeat; /**< Non-zero if this is a key repeat */ - Uint8 padding2; - Uint8 padding3; - SDL_Keysym keysym; /**< The key that was pressed or released */ -} SDL_KeyboardEvent; - -#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32) -/** - * \brief Keyboard text editing event structure (event.edit.*) - */ -typedef struct SDL_TextEditingEvent -{ - Uint32 type; /**< ::SDL_TEXTEDITING */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Uint32 windowID; /**< The window with keyboard focus, if any */ - char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ - Sint32 start; /**< The start cursor of selected editing text */ - Sint32 length; /**< The length of selected editing text */ -} SDL_TextEditingEvent; - - -#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32) -/** - * \brief Keyboard text input event structure (event.text.*) - */ -typedef struct SDL_TextInputEvent -{ - Uint32 type; /**< ::SDL_TEXTINPUT */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Uint32 windowID; /**< The window with keyboard focus, if any */ - char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ -} SDL_TextInputEvent; - -/** - * \brief Mouse motion event structure (event.motion.*) - */ -typedef struct SDL_MouseMotionEvent -{ - Uint32 type; /**< ::SDL_MOUSEMOTION */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Uint32 windowID; /**< The window with mouse focus, if any */ - Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ - Uint32 state; /**< The current button state */ - Sint32 x; /**< X coordinate, relative to window */ - Sint32 y; /**< Y coordinate, relative to window */ - Sint32 xrel; /**< The relative motion in the X direction */ - Sint32 yrel; /**< The relative motion in the Y direction */ -} SDL_MouseMotionEvent; - -/** - * \brief Mouse button event structure (event.button.*) - */ -typedef struct SDL_MouseButtonEvent -{ - Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Uint32 windowID; /**< The window with mouse focus, if any */ - Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ - Uint8 button; /**< The mouse button index */ - Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ - Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */ - Uint8 padding1; - Sint32 x; /**< X coordinate, relative to window */ - Sint32 y; /**< Y coordinate, relative to window */ -} SDL_MouseButtonEvent; - -/** - * \brief Mouse wheel event structure (event.wheel.*) - */ -typedef struct SDL_MouseWheelEvent -{ - Uint32 type; /**< ::SDL_MOUSEWHEEL */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Uint32 windowID; /**< The window with mouse focus, if any */ - Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ - Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */ - Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */ - Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */ -} SDL_MouseWheelEvent; - -/** - * \brief Joystick axis motion event structure (event.jaxis.*) - */ -typedef struct SDL_JoyAxisEvent -{ - Uint32 type; /**< ::SDL_JOYAXISMOTION */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - SDL_JoystickID which; /**< The joystick instance id */ - Uint8 axis; /**< The joystick axis index */ - Uint8 padding1; - Uint8 padding2; - Uint8 padding3; - Sint16 value; /**< The axis value (range: -32768 to 32767) */ - Uint16 padding4; -} SDL_JoyAxisEvent; - -/** - * \brief Joystick trackball motion event structure (event.jball.*) - */ -typedef struct SDL_JoyBallEvent -{ - Uint32 type; /**< ::SDL_JOYBALLMOTION */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - SDL_JoystickID which; /**< The joystick instance id */ - Uint8 ball; /**< The joystick trackball index */ - Uint8 padding1; - Uint8 padding2; - Uint8 padding3; - Sint16 xrel; /**< The relative motion in the X direction */ - Sint16 yrel; /**< The relative motion in the Y direction */ -} SDL_JoyBallEvent; - -/** - * \brief Joystick hat position change event structure (event.jhat.*) - */ -typedef struct SDL_JoyHatEvent -{ - Uint32 type; /**< ::SDL_JOYHATMOTION */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - SDL_JoystickID which; /**< The joystick instance id */ - Uint8 hat; /**< The joystick hat index */ - Uint8 value; /**< The hat position value. - * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP - * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT - * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN - * - * Note that zero means the POV is centered. - */ - Uint8 padding1; - Uint8 padding2; -} SDL_JoyHatEvent; - -/** - * \brief Joystick button event structure (event.jbutton.*) - */ -typedef struct SDL_JoyButtonEvent -{ - Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - SDL_JoystickID which; /**< The joystick instance id */ - Uint8 button; /**< The joystick button index */ - Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ - Uint8 padding1; - Uint8 padding2; -} SDL_JoyButtonEvent; - -/** - * \brief Joystick device event structure (event.jdevice.*) - */ -typedef struct SDL_JoyDeviceEvent -{ - Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */ -} SDL_JoyDeviceEvent; - - -/** - * \brief Game controller axis motion event structure (event.caxis.*) - */ -typedef struct SDL_ControllerAxisEvent -{ - Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - SDL_JoystickID which; /**< The joystick instance id */ - Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */ - Uint8 padding1; - Uint8 padding2; - Uint8 padding3; - Sint16 value; /**< The axis value (range: -32768 to 32767) */ - Uint16 padding4; -} SDL_ControllerAxisEvent; - - -/** - * \brief Game controller button event structure (event.cbutton.*) - */ -typedef struct SDL_ControllerButtonEvent -{ - Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - SDL_JoystickID which; /**< The joystick instance id */ - Uint8 button; /**< The controller button (SDL_GameControllerButton) */ - Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ - Uint8 padding1; - Uint8 padding2; -} SDL_ControllerButtonEvent; - - -/** - * \brief Controller device event structure (event.cdevice.*) - */ -typedef struct SDL_ControllerDeviceEvent -{ - Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */ -} SDL_ControllerDeviceEvent; - -/** - * \brief Audio device event structure (event.adevice.*) - */ -typedef struct SDL_AudioDeviceEvent -{ - Uint32 type; /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */ - Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */ - Uint8 padding1; - Uint8 padding2; - Uint8 padding3; -} SDL_AudioDeviceEvent; - - -/** - * \brief Touch finger event structure (event.tfinger.*) - */ -typedef struct SDL_TouchFingerEvent -{ - Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - SDL_TouchID touchId; /**< The touch device id */ - SDL_FingerID fingerId; - float x; /**< Normalized in the range 0...1 */ - float y; /**< Normalized in the range 0...1 */ - float dx; /**< Normalized in the range -1...1 */ - float dy; /**< Normalized in the range -1...1 */ - float pressure; /**< Normalized in the range 0...1 */ - Uint32 windowID; /**< The window underneath the finger, if any */ -} SDL_TouchFingerEvent; - - -/** - * \brief Multiple Finger Gesture Event (event.mgesture.*) - */ -typedef struct SDL_MultiGestureEvent -{ - Uint32 type; /**< ::SDL_MULTIGESTURE */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - SDL_TouchID touchId; /**< The touch device id */ - float dTheta; - float dDist; - float x; - float y; - Uint16 numFingers; - Uint16 padding; -} SDL_MultiGestureEvent; - - -/** - * \brief Dollar Gesture Event (event.dgesture.*) - */ -typedef struct SDL_DollarGestureEvent -{ - Uint32 type; /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - SDL_TouchID touchId; /**< The touch device id */ - SDL_GestureID gestureId; - Uint32 numFingers; - float error; - float x; /**< Normalized center of gesture */ - float y; /**< Normalized center of gesture */ -} SDL_DollarGestureEvent; - - -/** - * \brief An event used to request a file open by the system (event.drop.*) - * This event is enabled by default, you can disable it with SDL_EventState(). - * \note If this event is enabled, you must free the filename in the event. - */ -typedef struct SDL_DropEvent -{ - Uint32 type; /**< ::SDL_DROPBEGIN or ::SDL_DROPFILE or ::SDL_DROPTEXT or ::SDL_DROPCOMPLETE */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */ - Uint32 windowID; /**< The window that was dropped on, if any */ -} SDL_DropEvent; - - -/** - * \brief Sensor event structure (event.sensor.*) - */ -typedef struct SDL_SensorEvent -{ - Uint32 type; /**< ::SDL_SENSORUPDATE */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Sint32 which; /**< The instance ID of the sensor */ - float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */ -} SDL_SensorEvent; - -/** - * \brief The "quit requested" event - */ -typedef struct SDL_QuitEvent -{ - Uint32 type; /**< ::SDL_QUIT */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ -} SDL_QuitEvent; - -/** - * \brief OS Specific event - */ -typedef struct SDL_OSEvent -{ - Uint32 type; /**< ::SDL_QUIT */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ -} SDL_OSEvent; - -/** - * \brief A user-defined event type (event.user.*) - */ -typedef struct SDL_UserEvent -{ - Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - Uint32 windowID; /**< The associated window if any */ - Sint32 code; /**< User defined event code */ - void *data1; /**< User defined data pointer */ - void *data2; /**< User defined data pointer */ -} SDL_UserEvent; - - -struct SDL_SysWMmsg; -typedef struct SDL_SysWMmsg SDL_SysWMmsg; - -/** - * \brief A video driver dependent system event (event.syswm.*) - * This event is disabled by default, you can enable it with SDL_EventState() - * - * \note If you want to use this event, you should include SDL_syswm.h. - */ -typedef struct SDL_SysWMEvent -{ - Uint32 type; /**< ::SDL_SYSWMEVENT */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ - SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */ -} SDL_SysWMEvent; - -/** - * \brief General event structure - */ -typedef union SDL_Event -{ - Uint32 type; /**< Event type, shared with all events */ - SDL_CommonEvent common; /**< Common event data */ - SDL_DisplayEvent display; /**< Display event data */ - SDL_WindowEvent window; /**< Window event data */ - SDL_KeyboardEvent key; /**< Keyboard event data */ - SDL_TextEditingEvent edit; /**< Text editing event data */ - SDL_TextInputEvent text; /**< Text input event data */ - SDL_MouseMotionEvent motion; /**< Mouse motion event data */ - SDL_MouseButtonEvent button; /**< Mouse button event data */ - SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */ - SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */ - SDL_JoyBallEvent jball; /**< Joystick ball event data */ - SDL_JoyHatEvent jhat; /**< Joystick hat event data */ - SDL_JoyButtonEvent jbutton; /**< Joystick button event data */ - SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ - SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */ - SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */ - SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */ - SDL_AudioDeviceEvent adevice; /**< Audio device event data */ - SDL_SensorEvent sensor; /**< Sensor event data */ - SDL_QuitEvent quit; /**< Quit request event data */ - SDL_UserEvent user; /**< Custom event data */ - SDL_SysWMEvent syswm; /**< System dependent window event data */ - SDL_TouchFingerEvent tfinger; /**< Touch finger event data */ - SDL_MultiGestureEvent mgesture; /**< Gesture event data */ - SDL_DollarGestureEvent dgesture; /**< Gesture event data */ - SDL_DropEvent drop; /**< Drag and drop event data */ - - /* This is necessary for ABI compatibility between Visual C++ and GCC - Visual C++ will respect the push pack pragma and use 52 bytes for - this structure, and GCC will use the alignment of the largest datatype - within the union, which is 8 bytes. - - So... we'll add padding to force the size to be 56 bytes for both. - */ - Uint8 padding[56]; -} SDL_Event; - -/* Make sure we haven't broken binary compatibility */ -SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == 56); - - -/* Function prototypes */ - -/** - * Pumps the event loop, gathering events from the input devices. - * - * This function updates the event queue and internal input device state. - * - * This should only be run in the thread that sets the video mode. - */ -extern DECLSPEC void SDLCALL SDL_PumpEvents(void); - -/* @{ */ -typedef enum -{ - SDL_ADDEVENT, - SDL_PEEKEVENT, - SDL_GETEVENT -} SDL_eventaction; - -/** - * Checks the event queue for messages and optionally returns them. - * - * If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to - * the back of the event queue. - * - * If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front - * of the event queue, within the specified minimum and maximum type, - * will be returned and will not be removed from the queue. - * - * If \c action is ::SDL_GETEVENT, up to \c numevents events at the front - * of the event queue, within the specified minimum and maximum type, - * will be returned and will be removed from the queue. - * - * \return The number of events actually stored, or -1 if there was an error. - * - * This function is thread-safe. - */ -extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, - SDL_eventaction action, - Uint32 minType, Uint32 maxType); -/* @} */ - -/** - * Checks to see if certain event types are in the event queue. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type); -extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType); - -/** - * This function clears events from the event queue - * This function only affects currently queued events. If you want to make - * sure that all pending OS events are flushed, you can call SDL_PumpEvents() - * on the main thread immediately before the flush call. - */ -extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type); -extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType); - -/** - * \brief Polls for currently pending events. - * - * \return 1 if there are any pending events, or 0 if there are none available. - * - * \param event If not NULL, the next event is removed from the queue and - * stored in that area. - */ -extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event); - -/** - * \brief Waits indefinitely for the next available event. - * - * \return 1, or 0 if there was an error while waiting for events. - * - * \param event If not NULL, the next event is removed from the queue and - * stored in that area. - */ -extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event); - -/** - * \brief Waits until the specified timeout (in milliseconds) for the next - * available event. - * - * \return 1, or 0 if there was an error while waiting for events. - * - * \param event If not NULL, the next event is removed from the queue and - * stored in that area. - * \param timeout The timeout (in milliseconds) to wait for next event. - */ -extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event, - int timeout); - -/** - * \brief Add an event to the event queue. - * - * \return 1 on success, 0 if the event was filtered, or -1 if the event queue - * was full or there was some other error. - */ -extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event); - -typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event); - -/** - * Sets up a filter to process all events before they change internal state and - * are posted to the internal event queue. - * - * The filter is prototyped as: - * \code - * int SDL_EventFilter(void *userdata, SDL_Event * event); - * \endcode - * - * If the filter returns 1, then the event will be added to the internal queue. - * If it returns 0, then the event will be dropped from the queue, but the - * internal state will still be updated. This allows selective filtering of - * dynamically arriving events. - * - * \warning Be very careful of what you do in the event filter function, as - * it may run in a different thread! - * - * There is one caveat when dealing with the ::SDL_QuitEvent event type. The - * event filter is only called when the window manager desires to close the - * application window. If the event filter returns 1, then the window will - * be closed, otherwise the window will remain open if possible. - * - * If the quit event is generated by an interrupt signal, it will bypass the - * internal queue and be delivered to the application at the next event poll. - */ -extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, - void *userdata); - -/** - * Return the current event filter - can be used to "chain" filters. - * If there is no event filter set, this function returns SDL_FALSE. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter, - void **userdata); - -/** - * Add a function which is called when an event is added to the queue. - */ -extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, - void *userdata); - -/** - * Remove an event watch function added with SDL_AddEventWatch() - */ -extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, - void *userdata); - -/** - * Run the filter function on the current event queue, removing any - * events for which the filter returns 0. - */ -extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, - void *userdata); - -/* @{ */ -#define SDL_QUERY -1 -#define SDL_IGNORE 0 -#define SDL_DISABLE 0 -#define SDL_ENABLE 1 - -/** - * This function allows you to set the state of processing certain events. - * - If \c state is set to ::SDL_IGNORE, that event will be automatically - * dropped from the event queue and will not be filtered. - * - If \c state is set to ::SDL_ENABLE, that event will be processed - * normally. - * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the - * current processing state of the specified event. - */ -extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state); -/* @} */ -#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY) - -/** - * This function allocates a set of user-defined events, and returns - * the beginning event number for that set of events. - * - * If there aren't enough user-defined events left, this function - * returns (Uint32)-1 - */ -extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_events_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_filesystem.h b/thirdparty/include/SDL2/SDL_filesystem.h deleted file mode 100644 index 68042b60f..000000000 --- a/thirdparty/include/SDL2/SDL_filesystem.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_filesystem.h - * - * \brief Include file for filesystem SDL API functions - */ - -#ifndef SDL_filesystem_h_ -#define SDL_filesystem_h_ - -#include "SDL_stdinc.h" - -#include "begin_code.h" - -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Get the path where the application resides. - * - * Get the "base path". This is the directory where the application was run - * from, which is probably the installation directory, and may or may not - * be the process's current working directory. - * - * This returns an absolute path in UTF-8 encoding, and is guaranteed to - * end with a path separator ('\\' on Windows, '/' most other places). - * - * The pointer returned by this function is owned by you. Please call - * SDL_free() on the pointer when you are done with it, or it will be a - * memory leak. This is not necessarily a fast call, though, so you should - * call this once near startup and save the string if you need it. - * - * Some platforms can't determine the application's path, and on other - * platforms, this might be meaningless. In such cases, this function will - * return NULL. - * - * \return String of base dir in UTF-8 encoding, or NULL on error. - * - * \sa SDL_GetPrefPath - */ -extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); - -/** - * \brief Get the user-and-app-specific path where files can be written. - * - * Get the "pref dir". This is meant to be where users can write personal - * files (preferences and save games, etc) that are specific to your - * application. This directory is unique per user, per application. - * - * This function will decide the appropriate location in the native filesystem, - * create the directory if necessary, and return a string of the absolute - * path to the directory in UTF-8 encoding. - * - * On Windows, the string might look like: - * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\" - * - * On Linux, the string might look like: - * "/home/bob/.local/share/My Program Name/" - * - * On Mac OS X, the string might look like: - * "/Users/bob/Library/Application Support/My Program Name/" - * - * (etc.) - * - * You specify the name of your organization (if it's not a real organization, - * your name or an Internet domain you own might do) and the name of your - * application. These should be untranslated proper names. - * - * Both the org and app strings may become part of a directory name, so - * please follow these rules: - * - * - Try to use the same org string (including case-sensitivity) for - * all your applications that use this function. - * - Always use a unique app string for each one, and make sure it never - * changes for an app once you've decided on it. - * - Unicode characters are legal, as long as it's UTF-8 encoded, but... - * - ...only use letters, numbers, and spaces. Avoid punctuation like - * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. - * - * This returns an absolute path in UTF-8 encoding, and is guaranteed to - * end with a path separator ('\\' on Windows, '/' most other places). - * - * The pointer returned by this function is owned by you. Please call - * SDL_free() on the pointer when you are done with it, or it will be a - * memory leak. This is not necessarily a fast call, though, so you should - * call this once near startup and save the string if you need it. - * - * You should assume the path returned by this function is the only safe - * place to write files (and that SDL_GetBasePath(), while it might be - * writable, or even the parent of the returned path, aren't where you - * should be writing things). - * - * Some platforms can't determine the pref path, and on other - * platforms, this might be meaningless. In such cases, this function will - * return NULL. - * - * \param org The name of your organization. - * \param app The name of your application. - * \return UTF-8 string of user dir in platform-dependent notation. NULL - * if there's a problem (creating directory failed, etc). - * - * \sa SDL_GetBasePath - */ -extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_filesystem_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_gamecontroller.h b/thirdparty/include/SDL2/SDL_gamecontroller.h deleted file mode 100644 index 21cc1e437..000000000 --- a/thirdparty/include/SDL2/SDL_gamecontroller.h +++ /dev/null @@ -1,420 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_gamecontroller.h - * - * Include file for SDL game controller event handling - */ - -#ifndef SDL_gamecontroller_h_ -#define SDL_gamecontroller_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_rwops.h" -#include "SDL_joystick.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \file SDL_gamecontroller.h - * - * In order to use these functions, SDL_Init() must have been called - * with the ::SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system - * for game controllers, and load appropriate drivers. - * - * If you would like to receive controller updates while the application - * is in the background, you should set the following hint before calling - * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS - */ - -/** - * The gamecontroller structure used to identify an SDL game controller - */ -struct _SDL_GameController; -typedef struct _SDL_GameController SDL_GameController; - -typedef enum -{ - SDL_CONTROLLER_TYPE_UNKNOWN = 0, - SDL_CONTROLLER_TYPE_XBOX360, - SDL_CONTROLLER_TYPE_XBOXONE, - SDL_CONTROLLER_TYPE_PS3, - SDL_CONTROLLER_TYPE_PS4, - SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO -} SDL_GameControllerType; - -typedef enum -{ - SDL_CONTROLLER_BINDTYPE_NONE = 0, - SDL_CONTROLLER_BINDTYPE_BUTTON, - SDL_CONTROLLER_BINDTYPE_AXIS, - SDL_CONTROLLER_BINDTYPE_HAT -} SDL_GameControllerBindType; - -/** - * Get the SDL joystick layer binding for this controller button/axis mapping - */ -typedef struct SDL_GameControllerButtonBind -{ - SDL_GameControllerBindType bindType; - union - { - int button; - int axis; - struct { - int hat; - int hat_mask; - } hat; - } value; - -} SDL_GameControllerButtonBind; - - -/** - * To count the number of game controllers in the system for the following: - * int nJoysticks = SDL_NumJoysticks(); - * int nGameControllers = 0; - * for (int i = 0; i < nJoysticks; i++) { - * if (SDL_IsGameController(i)) { - * nGameControllers++; - * } - * } - * - * Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping() you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is: - * guid,name,mappings - * - * Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones. - * Under Windows there is a reserved GUID of "xinput" that covers any XInput devices. - * The mapping format for joystick is: - * bX - a joystick button, index X - * hX.Y - hat X with value Y - * aX - axis X of the joystick - * Buttons can be used as a controller axis and vice versa. - * - * This string shows an example of a valid mapping for a controller - * "03000000341a00003608000000000000,PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7", - * - */ - -/** - * Load a set of mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform() - * A community sourced database of controllers is available at https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt - * - * If \c freerw is non-zero, the stream will be closed after being read. - * - * \return number of mappings added, -1 on error - */ -extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw); - -/** - * Load a set of mappings from a file, filtered by the current SDL_GetPlatform() - * - * Convenience macro. - */ -#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1) - -/** - * Add or update an existing mapping configuration - * - * \return 1 if mapping is added, 0 if updated, -1 on error - */ -extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString); - -/** - * Get the number of mappings installed - * - * \return the number of mappings - */ -extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void); - -/** - * Get the mapping at a particular index. - * - * \return the mapping string. Must be freed with SDL_free(). Returns NULL if the index is out of range. - */ -extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_index); - -/** - * Get a mapping string for a GUID - * - * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available - */ -extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid); - -/** - * Get a mapping string for an open GameController - * - * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available - */ -extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController * gamecontroller); - -/** - * Is the joystick on this index supported by the game controller interface? - */ -extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index); - -/** - * Get the implementation dependent name of a game controller. - * This can be called before any controllers are opened. - * If no name can be found, this function returns NULL. - */ -extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index); - -/** - * Get the type of a game controller. - * This can be called before any controllers are opened. - */ -extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(int joystick_index); - -/** - * Get the mapping of a game controller. - * This can be called before any controllers are opened. - * - * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available - */ -extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index); - -/** - * Open a game controller for use. - * The index passed as an argument refers to the N'th game controller on the system. - * This index is not the value which will identify this controller in future - * controller events. The joystick's instance id (::SDL_JoystickID) will be - * used there instead. - * - * \return A controller identifier, or NULL if an error occurred. - */ -extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index); - -/** - * Return the SDL_GameController associated with an instance id. - */ -extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid); - -/** - * Return the SDL_GameController associated with a player index. - */ -extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(int player_index); - -/** - * Return the name for this currently opened controller - */ -extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller); - -/** - * Return the type of this currently opened controller - */ -extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_GameController *gamecontroller); - -/** - * Get the player index of an opened game controller, or -1 if it's not available - * - * For XInput controllers this returns the XInput user index. - */ -extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller); - -/** - * Set the player index of an opened game controller - */ -extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index); - -/** - * Get the USB vendor ID of an opened controller, if available. - * If the vendor ID isn't available this function returns 0. - */ -extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController * gamecontroller); - -/** - * Get the USB product ID of an opened controller, if available. - * If the product ID isn't available this function returns 0. - */ -extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController * gamecontroller); - -/** - * Get the product version of an opened controller, if available. - * If the product version isn't available this function returns 0. - */ -extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller); - -/** - * Returns SDL_TRUE if the controller has been opened and currently connected, - * or SDL_FALSE if it has not. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller); - -/** - * Get the underlying joystick object used by a controller - */ -extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller); - -/** - * Enable/disable controller event polling. - * - * If controller events are disabled, you must call SDL_GameControllerUpdate() - * yourself and check the state of the controller when you want controller - * information. - * - * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. - */ -extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state); - -/** - * Update the current state of the open game controllers. - * - * This is called automatically by the event loop if any game controller - * events are enabled. - */ -extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); - - -/** - * The list of axes available from a controller - * - * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX, - * and are centered within ~8000 of zero, though advanced UI will allow users to set - * or autodetect the dead zone, which varies between controllers. - * - * Trigger axis values range from 0 to SDL_JOYSTICK_AXIS_MAX. - */ -typedef enum -{ - SDL_CONTROLLER_AXIS_INVALID = -1, - SDL_CONTROLLER_AXIS_LEFTX, - SDL_CONTROLLER_AXIS_LEFTY, - SDL_CONTROLLER_AXIS_RIGHTX, - SDL_CONTROLLER_AXIS_RIGHTY, - SDL_CONTROLLER_AXIS_TRIGGERLEFT, - SDL_CONTROLLER_AXIS_TRIGGERRIGHT, - SDL_CONTROLLER_AXIS_MAX -} SDL_GameControllerAxis; - -/** - * turn this string into a axis mapping - */ -extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString); - -/** - * turn this axis enum into a string mapping - */ -extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis); - -/** - * Get the SDL joystick layer binding for this controller button mapping - */ -extern DECLSPEC SDL_GameControllerButtonBind SDLCALL -SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller, - SDL_GameControllerAxis axis); - -/** - * Get the current state of an axis control on a game controller. - * - * The state is a value ranging from -32768 to 32767 (except for the triggers, - * which range from 0 to 32767). - * - * The axis indices start at index 0. - */ -extern DECLSPEC Sint16 SDLCALL -SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, - SDL_GameControllerAxis axis); - -/** - * The list of buttons available from a controller - */ -typedef enum -{ - SDL_CONTROLLER_BUTTON_INVALID = -1, - SDL_CONTROLLER_BUTTON_A, - SDL_CONTROLLER_BUTTON_B, - SDL_CONTROLLER_BUTTON_X, - SDL_CONTROLLER_BUTTON_Y, - SDL_CONTROLLER_BUTTON_BACK, - SDL_CONTROLLER_BUTTON_GUIDE, - SDL_CONTROLLER_BUTTON_START, - SDL_CONTROLLER_BUTTON_LEFTSTICK, - SDL_CONTROLLER_BUTTON_RIGHTSTICK, - SDL_CONTROLLER_BUTTON_LEFTSHOULDER, - SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, - SDL_CONTROLLER_BUTTON_DPAD_UP, - SDL_CONTROLLER_BUTTON_DPAD_DOWN, - SDL_CONTROLLER_BUTTON_DPAD_LEFT, - SDL_CONTROLLER_BUTTON_DPAD_RIGHT, - SDL_CONTROLLER_BUTTON_MAX -} SDL_GameControllerButton; - -/** - * turn this string into a button mapping - */ -extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString); - -/** - * turn this button enum into a string mapping - */ -extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button); - -/** - * Get the SDL joystick layer binding for this controller button mapping - */ -extern DECLSPEC SDL_GameControllerButtonBind SDLCALL -SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller, - SDL_GameControllerButton button); - - -/** - * Get the current state of a button on a game controller. - * - * The button indices start at index 0. - */ -extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, - SDL_GameControllerButton button); - -/** - * Trigger a rumble effect - * Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling. - * - * \param gamecontroller The controller to vibrate - * \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF - * \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF - * \param duration_ms The duration of the rumble effect, in milliseconds - * - * \return 0, or -1 if rumble isn't supported on this joystick - */ -extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); - -/** - * Close a controller previously opened with SDL_GameControllerOpen(). - */ -extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_gamecontroller_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_gesture.h b/thirdparty/include/SDL2/SDL_gesture.h deleted file mode 100644 index 81ed43173..000000000 --- a/thirdparty/include/SDL2/SDL_gesture.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_gesture.h - * - * Include file for SDL gesture event handling. - */ - -#ifndef SDL_gesture_h_ -#define SDL_gesture_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_video.h" - -#include "SDL_touch.h" - - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -typedef Sint64 SDL_GestureID; - -/* Function prototypes */ - -/** - * \brief Begin Recording a gesture on the specified touch, or all touches (-1) - * - * - */ -extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); - - -/** - * \brief Save all currently loaded Dollar Gesture templates - * - * - */ -extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); - -/** - * \brief Save a currently loaded Dollar Gesture template - * - * - */ -extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); - - -/** - * \brief Load Dollar Gesture templates from a file - * - * - */ -extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_gesture_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_haptic.h b/thirdparty/include/SDL2/SDL_haptic.h deleted file mode 100644 index aa6f47fdd..000000000 --- a/thirdparty/include/SDL2/SDL_haptic.h +++ /dev/null @@ -1,1238 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_haptic.h - * - * \brief The SDL haptic subsystem allows you to control haptic (force feedback) - * devices. - * - * The basic usage is as follows: - * - Initialize the subsystem (::SDL_INIT_HAPTIC). - * - Open a haptic device. - * - SDL_HapticOpen() to open from index. - * - SDL_HapticOpenFromJoystick() to open from an existing joystick. - * - Create an effect (::SDL_HapticEffect). - * - Upload the effect with SDL_HapticNewEffect(). - * - Run the effect with SDL_HapticRunEffect(). - * - (optional) Free the effect with SDL_HapticDestroyEffect(). - * - Close the haptic device with SDL_HapticClose(). - * - * \par Simple rumble example: - * \code - * SDL_Haptic *haptic; - * - * // Open the device - * haptic = SDL_HapticOpen( 0 ); - * if (haptic == NULL) - * return -1; - * - * // Initialize simple rumble - * if (SDL_HapticRumbleInit( haptic ) != 0) - * return -1; - * - * // Play effect at 50% strength for 2 seconds - * if (SDL_HapticRumblePlay( haptic, 0.5, 2000 ) != 0) - * return -1; - * SDL_Delay( 2000 ); - * - * // Clean up - * SDL_HapticClose( haptic ); - * \endcode - * - * \par Complete example: - * \code - * int test_haptic( SDL_Joystick * joystick ) { - * SDL_Haptic *haptic; - * SDL_HapticEffect effect; - * int effect_id; - * - * // Open the device - * haptic = SDL_HapticOpenFromJoystick( joystick ); - * if (haptic == NULL) return -1; // Most likely joystick isn't haptic - * - * // See if it can do sine waves - * if ((SDL_HapticQuery(haptic) & SDL_HAPTIC_SINE)==0) { - * SDL_HapticClose(haptic); // No sine effect - * return -1; - * } - * - * // Create the effect - * memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default - * effect.type = SDL_HAPTIC_SINE; - * effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates - * effect.periodic.direction.dir[0] = 18000; // Force comes from south - * effect.periodic.period = 1000; // 1000 ms - * effect.periodic.magnitude = 20000; // 20000/32767 strength - * effect.periodic.length = 5000; // 5 seconds long - * effect.periodic.attack_length = 1000; // Takes 1 second to get max strength - * effect.periodic.fade_length = 1000; // Takes 1 second to fade away - * - * // Upload the effect - * effect_id = SDL_HapticNewEffect( haptic, &effect ); - * - * // Test the effect - * SDL_HapticRunEffect( haptic, effect_id, 1 ); - * SDL_Delay( 5000); // Wait for the effect to finish - * - * // We destroy the effect, although closing the device also does this - * SDL_HapticDestroyEffect( haptic, effect_id ); - * - * // Close the device - * SDL_HapticClose(haptic); - * - * return 0; // Success - * } - * \endcode - */ - -#ifndef SDL_haptic_h_ -#define SDL_haptic_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_joystick.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* FIXME: For SDL 2.1, adjust all the magnitude variables to be Uint16 (0xFFFF). - * - * At the moment the magnitude variables are mixed between signed/unsigned, and - * it is also not made clear that ALL of those variables expect a max of 0x7FFF. - * - * Some platforms may have higher precision than that (Linux FF, Windows XInput) - * so we should fix the inconsistency in favor of higher possible precision, - * adjusting for platforms that use different scales. - * -flibit - */ - -/** - * \typedef SDL_Haptic - * - * \brief The haptic structure used to identify an SDL haptic. - * - * \sa SDL_HapticOpen - * \sa SDL_HapticOpenFromJoystick - * \sa SDL_HapticClose - */ -struct _SDL_Haptic; -typedef struct _SDL_Haptic SDL_Haptic; - - -/** - * \name Haptic features - * - * Different haptic features a device can have. - */ -/* @{ */ - -/** - * \name Haptic effects - */ -/* @{ */ - -/** - * \brief Constant effect supported. - * - * Constant haptic effect. - * - * \sa SDL_HapticCondition - */ -#define SDL_HAPTIC_CONSTANT (1u<<0) - -/** - * \brief Sine wave effect supported. - * - * Periodic haptic effect that simulates sine waves. - * - * \sa SDL_HapticPeriodic - */ -#define SDL_HAPTIC_SINE (1u<<1) - -/** - * \brief Left/Right effect supported. - * - * Haptic effect for direct control over high/low frequency motors. - * - * \sa SDL_HapticLeftRight - * \warning this value was SDL_HAPTIC_SQUARE right before 2.0.0 shipped. Sorry, - * we ran out of bits, and this is important for XInput devices. - */ -#define SDL_HAPTIC_LEFTRIGHT (1u<<2) - -/* !!! FIXME: put this back when we have more bits in 2.1 */ -/* #define SDL_HAPTIC_SQUARE (1<<2) */ - -/** - * \brief Triangle wave effect supported. - * - * Periodic haptic effect that simulates triangular waves. - * - * \sa SDL_HapticPeriodic - */ -#define SDL_HAPTIC_TRIANGLE (1u<<3) - -/** - * \brief Sawtoothup wave effect supported. - * - * Periodic haptic effect that simulates saw tooth up waves. - * - * \sa SDL_HapticPeriodic - */ -#define SDL_HAPTIC_SAWTOOTHUP (1u<<4) - -/** - * \brief Sawtoothdown wave effect supported. - * - * Periodic haptic effect that simulates saw tooth down waves. - * - * \sa SDL_HapticPeriodic - */ -#define SDL_HAPTIC_SAWTOOTHDOWN (1u<<5) - -/** - * \brief Ramp effect supported. - * - * Ramp haptic effect. - * - * \sa SDL_HapticRamp - */ -#define SDL_HAPTIC_RAMP (1u<<6) - -/** - * \brief Spring effect supported - uses axes position. - * - * Condition haptic effect that simulates a spring. Effect is based on the - * axes position. - * - * \sa SDL_HapticCondition - */ -#define SDL_HAPTIC_SPRING (1u<<7) - -/** - * \brief Damper effect supported - uses axes velocity. - * - * Condition haptic effect that simulates dampening. Effect is based on the - * axes velocity. - * - * \sa SDL_HapticCondition - */ -#define SDL_HAPTIC_DAMPER (1u<<8) - -/** - * \brief Inertia effect supported - uses axes acceleration. - * - * Condition haptic effect that simulates inertia. Effect is based on the axes - * acceleration. - * - * \sa SDL_HapticCondition - */ -#define SDL_HAPTIC_INERTIA (1u<<9) - -/** - * \brief Friction effect supported - uses axes movement. - * - * Condition haptic effect that simulates friction. Effect is based on the - * axes movement. - * - * \sa SDL_HapticCondition - */ -#define SDL_HAPTIC_FRICTION (1u<<10) - -/** - * \brief Custom effect is supported. - * - * User defined custom haptic effect. - */ -#define SDL_HAPTIC_CUSTOM (1u<<11) - -/* @} *//* Haptic effects */ - -/* These last few are features the device has, not effects */ - -/** - * \brief Device can set global gain. - * - * Device supports setting the global gain. - * - * \sa SDL_HapticSetGain - */ -#define SDL_HAPTIC_GAIN (1u<<12) - -/** - * \brief Device can set autocenter. - * - * Device supports setting autocenter. - * - * \sa SDL_HapticSetAutocenter - */ -#define SDL_HAPTIC_AUTOCENTER (1u<<13) - -/** - * \brief Device can be queried for effect status. - * - * Device supports querying effect status. - * - * \sa SDL_HapticGetEffectStatus - */ -#define SDL_HAPTIC_STATUS (1u<<14) - -/** - * \brief Device can be paused. - * - * Devices supports being paused. - * - * \sa SDL_HapticPause - * \sa SDL_HapticUnpause - */ -#define SDL_HAPTIC_PAUSE (1u<<15) - - -/** - * \name Direction encodings - */ -/* @{ */ - -/** - * \brief Uses polar coordinates for the direction. - * - * \sa SDL_HapticDirection - */ -#define SDL_HAPTIC_POLAR 0 - -/** - * \brief Uses cartesian coordinates for the direction. - * - * \sa SDL_HapticDirection - */ -#define SDL_HAPTIC_CARTESIAN 1 - -/** - * \brief Uses spherical coordinates for the direction. - * - * \sa SDL_HapticDirection - */ -#define SDL_HAPTIC_SPHERICAL 2 - -/* @} *//* Direction encodings */ - -/* @} *//* Haptic features */ - -/* - * Misc defines. - */ - -/** - * \brief Used to play a device an infinite number of times. - * - * \sa SDL_HapticRunEffect - */ -#define SDL_HAPTIC_INFINITY 4294967295U - - -/** - * \brief Structure that represents a haptic direction. - * - * This is the direction where the force comes from, - * instead of the direction in which the force is exerted. - * - * Directions can be specified by: - * - ::SDL_HAPTIC_POLAR : Specified by polar coordinates. - * - ::SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates. - * - ::SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates. - * - * Cardinal directions of the haptic device are relative to the positioning - * of the device. North is considered to be away from the user. - * - * The following diagram represents the cardinal directions: - * \verbatim - .--. - |__| .-------. - |=.| |.-----.| - |--| || || - | | |'-----'| - |__|~')_____(' - [ COMPUTER ] - - - North (0,-1) - ^ - | - | - (-1,0) West <----[ HAPTIC ]----> East (1,0) - | - | - v - South (0,1) - - - [ USER ] - \|||/ - (o o) - ---ooO-(_)-Ooo--- - \endverbatim - * - * If type is ::SDL_HAPTIC_POLAR, direction is encoded by hundredths of a - * degree starting north and turning clockwise. ::SDL_HAPTIC_POLAR only uses - * the first \c dir parameter. The cardinal directions would be: - * - North: 0 (0 degrees) - * - East: 9000 (90 degrees) - * - South: 18000 (180 degrees) - * - West: 27000 (270 degrees) - * - * If type is ::SDL_HAPTIC_CARTESIAN, direction is encoded by three positions - * (X axis, Y axis and Z axis (with 3 axes)). ::SDL_HAPTIC_CARTESIAN uses - * the first three \c dir parameters. The cardinal directions would be: - * - North: 0,-1, 0 - * - East: 1, 0, 0 - * - South: 0, 1, 0 - * - West: -1, 0, 0 - * - * The Z axis represents the height of the effect if supported, otherwise - * it's unused. In cartesian encoding (1, 2) would be the same as (2, 4), you - * can use any multiple you want, only the direction matters. - * - * If type is ::SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations. - * The first two \c dir parameters are used. The \c dir parameters are as - * follows (all values are in hundredths of degrees): - * - Degrees from (1, 0) rotated towards (0, 1). - * - Degrees towards (0, 0, 1) (device needs at least 3 axes). - * - * - * Example of force coming from the south with all encodings (force coming - * from the south means the user will have to pull the stick to counteract): - * \code - * SDL_HapticDirection direction; - * - * // Cartesian directions - * direction.type = SDL_HAPTIC_CARTESIAN; // Using cartesian direction encoding. - * direction.dir[0] = 0; // X position - * direction.dir[1] = 1; // Y position - * // Assuming the device has 2 axes, we don't need to specify third parameter. - * - * // Polar directions - * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding. - * direction.dir[0] = 18000; // Polar only uses first parameter - * - * // Spherical coordinates - * direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding - * direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters. - * \endcode - * - * \sa SDL_HAPTIC_POLAR - * \sa SDL_HAPTIC_CARTESIAN - * \sa SDL_HAPTIC_SPHERICAL - * \sa SDL_HapticEffect - * \sa SDL_HapticNumAxes - */ -typedef struct SDL_HapticDirection -{ - Uint8 type; /**< The type of encoding. */ - Sint32 dir[3]; /**< The encoded direction. */ -} SDL_HapticDirection; - - -/** - * \brief A structure containing a template for a Constant effect. - * - * This struct is exclusively for the ::SDL_HAPTIC_CONSTANT effect. - * - * A constant effect applies a constant force in the specified direction - * to the joystick. - * - * \sa SDL_HAPTIC_CONSTANT - * \sa SDL_HapticEffect - */ -typedef struct SDL_HapticConstant -{ - /* Header */ - Uint16 type; /**< ::SDL_HAPTIC_CONSTANT */ - SDL_HapticDirection direction; /**< Direction of the effect. */ - - /* Replay */ - Uint32 length; /**< Duration of the effect. */ - Uint16 delay; /**< Delay before starting the effect. */ - - /* Trigger */ - Uint16 button; /**< Button that triggers the effect. */ - Uint16 interval; /**< How soon it can be triggered again after button. */ - - /* Constant */ - Sint16 level; /**< Strength of the constant effect. */ - - /* Envelope */ - Uint16 attack_length; /**< Duration of the attack. */ - Uint16 attack_level; /**< Level at the start of the attack. */ - Uint16 fade_length; /**< Duration of the fade. */ - Uint16 fade_level; /**< Level at the end of the fade. */ -} SDL_HapticConstant; - -/** - * \brief A structure containing a template for a Periodic effect. - * - * The struct handles the following effects: - * - ::SDL_HAPTIC_SINE - * - ::SDL_HAPTIC_LEFTRIGHT - * - ::SDL_HAPTIC_TRIANGLE - * - ::SDL_HAPTIC_SAWTOOTHUP - * - ::SDL_HAPTIC_SAWTOOTHDOWN - * - * A periodic effect consists in a wave-shaped effect that repeats itself - * over time. The type determines the shape of the wave and the parameters - * determine the dimensions of the wave. - * - * Phase is given by hundredth of a degree meaning that giving the phase a value - * of 9000 will displace it 25% of its period. Here are sample values: - * - 0: No phase displacement. - * - 9000: Displaced 25% of its period. - * - 18000: Displaced 50% of its period. - * - 27000: Displaced 75% of its period. - * - 36000: Displaced 100% of its period, same as 0, but 0 is preferred. - * - * Examples: - * \verbatim - SDL_HAPTIC_SINE - __ __ __ __ - / \ / \ / \ / - / \__/ \__/ \__/ - - SDL_HAPTIC_SQUARE - __ __ __ __ __ - | | | | | | | | | | - | |__| |__| |__| |__| | - - SDL_HAPTIC_TRIANGLE - /\ /\ /\ /\ /\ - / \ / \ / \ / \ / - / \/ \/ \/ \/ - - SDL_HAPTIC_SAWTOOTHUP - /| /| /| /| /| /| /| - / | / | / | / | / | / | / | - / |/ |/ |/ |/ |/ |/ | - - SDL_HAPTIC_SAWTOOTHDOWN - \ |\ |\ |\ |\ |\ |\ | - \ | \ | \ | \ | \ | \ | \ | - \| \| \| \| \| \| \| - \endverbatim - * - * \sa SDL_HAPTIC_SINE - * \sa SDL_HAPTIC_LEFTRIGHT - * \sa SDL_HAPTIC_TRIANGLE - * \sa SDL_HAPTIC_SAWTOOTHUP - * \sa SDL_HAPTIC_SAWTOOTHDOWN - * \sa SDL_HapticEffect - */ -typedef struct SDL_HapticPeriodic -{ - /* Header */ - Uint16 type; /**< ::SDL_HAPTIC_SINE, ::SDL_HAPTIC_LEFTRIGHT, - ::SDL_HAPTIC_TRIANGLE, ::SDL_HAPTIC_SAWTOOTHUP or - ::SDL_HAPTIC_SAWTOOTHDOWN */ - SDL_HapticDirection direction; /**< Direction of the effect. */ - - /* Replay */ - Uint32 length; /**< Duration of the effect. */ - Uint16 delay; /**< Delay before starting the effect. */ - - /* Trigger */ - Uint16 button; /**< Button that triggers the effect. */ - Uint16 interval; /**< How soon it can be triggered again after button. */ - - /* Periodic */ - Uint16 period; /**< Period of the wave. */ - Sint16 magnitude; /**< Peak value; if negative, equivalent to 180 degrees extra phase shift. */ - Sint16 offset; /**< Mean value of the wave. */ - Uint16 phase; /**< Positive phase shift given by hundredth of a degree. */ - - /* Envelope */ - Uint16 attack_length; /**< Duration of the attack. */ - Uint16 attack_level; /**< Level at the start of the attack. */ - Uint16 fade_length; /**< Duration of the fade. */ - Uint16 fade_level; /**< Level at the end of the fade. */ -} SDL_HapticPeriodic; - -/** - * \brief A structure containing a template for a Condition effect. - * - * The struct handles the following effects: - * - ::SDL_HAPTIC_SPRING: Effect based on axes position. - * - ::SDL_HAPTIC_DAMPER: Effect based on axes velocity. - * - ::SDL_HAPTIC_INERTIA: Effect based on axes acceleration. - * - ::SDL_HAPTIC_FRICTION: Effect based on axes movement. - * - * Direction is handled by condition internals instead of a direction member. - * The condition effect specific members have three parameters. The first - * refers to the X axis, the second refers to the Y axis and the third - * refers to the Z axis. The right terms refer to the positive side of the - * axis and the left terms refer to the negative side of the axis. Please - * refer to the ::SDL_HapticDirection diagram for which side is positive and - * which is negative. - * - * \sa SDL_HapticDirection - * \sa SDL_HAPTIC_SPRING - * \sa SDL_HAPTIC_DAMPER - * \sa SDL_HAPTIC_INERTIA - * \sa SDL_HAPTIC_FRICTION - * \sa SDL_HapticEffect - */ -typedef struct SDL_HapticCondition -{ - /* Header */ - Uint16 type; /**< ::SDL_HAPTIC_SPRING, ::SDL_HAPTIC_DAMPER, - ::SDL_HAPTIC_INERTIA or ::SDL_HAPTIC_FRICTION */ - SDL_HapticDirection direction; /**< Direction of the effect - Not used ATM. */ - - /* Replay */ - Uint32 length; /**< Duration of the effect. */ - Uint16 delay; /**< Delay before starting the effect. */ - - /* Trigger */ - Uint16 button; /**< Button that triggers the effect. */ - Uint16 interval; /**< How soon it can be triggered again after button. */ - - /* Condition */ - Uint16 right_sat[3]; /**< Level when joystick is to the positive side; max 0xFFFF. */ - Uint16 left_sat[3]; /**< Level when joystick is to the negative side; max 0xFFFF. */ - Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */ - Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */ - Uint16 deadband[3]; /**< Size of the dead zone; max 0xFFFF: whole axis-range when 0-centered. */ - Sint16 center[3]; /**< Position of the dead zone. */ -} SDL_HapticCondition; - -/** - * \brief A structure containing a template for a Ramp effect. - * - * This struct is exclusively for the ::SDL_HAPTIC_RAMP effect. - * - * The ramp effect starts at start strength and ends at end strength. - * It augments in linear fashion. If you use attack and fade with a ramp - * the effects get added to the ramp effect making the effect become - * quadratic instead of linear. - * - * \sa SDL_HAPTIC_RAMP - * \sa SDL_HapticEffect - */ -typedef struct SDL_HapticRamp -{ - /* Header */ - Uint16 type; /**< ::SDL_HAPTIC_RAMP */ - SDL_HapticDirection direction; /**< Direction of the effect. */ - - /* Replay */ - Uint32 length; /**< Duration of the effect. */ - Uint16 delay; /**< Delay before starting the effect. */ - - /* Trigger */ - Uint16 button; /**< Button that triggers the effect. */ - Uint16 interval; /**< How soon it can be triggered again after button. */ - - /* Ramp */ - Sint16 start; /**< Beginning strength level. */ - Sint16 end; /**< Ending strength level. */ - - /* Envelope */ - Uint16 attack_length; /**< Duration of the attack. */ - Uint16 attack_level; /**< Level at the start of the attack. */ - Uint16 fade_length; /**< Duration of the fade. */ - Uint16 fade_level; /**< Level at the end of the fade. */ -} SDL_HapticRamp; - -/** - * \brief A structure containing a template for a Left/Right effect. - * - * This struct is exclusively for the ::SDL_HAPTIC_LEFTRIGHT effect. - * - * The Left/Right effect is used to explicitly control the large and small - * motors, commonly found in modern game controllers. The small (right) motor - * is high frequency, and the large (left) motor is low frequency. - * - * \sa SDL_HAPTIC_LEFTRIGHT - * \sa SDL_HapticEffect - */ -typedef struct SDL_HapticLeftRight -{ - /* Header */ - Uint16 type; /**< ::SDL_HAPTIC_LEFTRIGHT */ - - /* Replay */ - Uint32 length; /**< Duration of the effect in milliseconds. */ - - /* Rumble */ - Uint16 large_magnitude; /**< Control of the large controller motor. */ - Uint16 small_magnitude; /**< Control of the small controller motor. */ -} SDL_HapticLeftRight; - -/** - * \brief A structure containing a template for the ::SDL_HAPTIC_CUSTOM effect. - * - * This struct is exclusively for the ::SDL_HAPTIC_CUSTOM effect. - * - * A custom force feedback effect is much like a periodic effect, where the - * application can define its exact shape. You will have to allocate the - * data yourself. Data should consist of channels * samples Uint16 samples. - * - * If channels is one, the effect is rotated using the defined direction. - * Otherwise it uses the samples in data for the different axes. - * - * \sa SDL_HAPTIC_CUSTOM - * \sa SDL_HapticEffect - */ -typedef struct SDL_HapticCustom -{ - /* Header */ - Uint16 type; /**< ::SDL_HAPTIC_CUSTOM */ - SDL_HapticDirection direction; /**< Direction of the effect. */ - - /* Replay */ - Uint32 length; /**< Duration of the effect. */ - Uint16 delay; /**< Delay before starting the effect. */ - - /* Trigger */ - Uint16 button; /**< Button that triggers the effect. */ - Uint16 interval; /**< How soon it can be triggered again after button. */ - - /* Custom */ - Uint8 channels; /**< Axes to use, minimum of one. */ - Uint16 period; /**< Sample periods. */ - Uint16 samples; /**< Amount of samples. */ - Uint16 *data; /**< Should contain channels*samples items. */ - - /* Envelope */ - Uint16 attack_length; /**< Duration of the attack. */ - Uint16 attack_level; /**< Level at the start of the attack. */ - Uint16 fade_length; /**< Duration of the fade. */ - Uint16 fade_level; /**< Level at the end of the fade. */ -} SDL_HapticCustom; - -/** - * \brief The generic template for any haptic effect. - * - * All values max at 32767 (0x7FFF). Signed values also can be negative. - * Time values unless specified otherwise are in milliseconds. - * - * You can also pass ::SDL_HAPTIC_INFINITY to length instead of a 0-32767 - * value. Neither delay, interval, attack_length nor fade_length support - * ::SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends. - * - * Additionally, the ::SDL_HAPTIC_RAMP effect does not support a duration of - * ::SDL_HAPTIC_INFINITY. - * - * Button triggers may not be supported on all devices, it is advised to not - * use them if possible. Buttons start at index 1 instead of index 0 like - * the joystick. - * - * If both attack_length and fade_level are 0, the envelope is not used, - * otherwise both values are used. - * - * Common parts: - * \code - * // Replay - All effects have this - * Uint32 length; // Duration of effect (ms). - * Uint16 delay; // Delay before starting effect. - * - * // Trigger - All effects have this - * Uint16 button; // Button that triggers effect. - * Uint16 interval; // How soon before effect can be triggered again. - * - * // Envelope - All effects except condition effects have this - * Uint16 attack_length; // Duration of the attack (ms). - * Uint16 attack_level; // Level at the start of the attack. - * Uint16 fade_length; // Duration of the fade out (ms). - * Uint16 fade_level; // Level at the end of the fade. - * \endcode - * - * - * Here we have an example of a constant effect evolution in time: - * \verbatim - Strength - ^ - | - | effect level --> _________________ - | / \ - | / \ - | / \ - | / \ - | attack_level --> | \ - | | | <--- fade_level - | - +--------------------------------------------------> Time - [--] [---] - attack_length fade_length - - [------------------][-----------------------] - delay length - \endverbatim - * - * Note either the attack_level or the fade_level may be above the actual - * effect level. - * - * \sa SDL_HapticConstant - * \sa SDL_HapticPeriodic - * \sa SDL_HapticCondition - * \sa SDL_HapticRamp - * \sa SDL_HapticLeftRight - * \sa SDL_HapticCustom - */ -typedef union SDL_HapticEffect -{ - /* Common for all force feedback effects */ - Uint16 type; /**< Effect type. */ - SDL_HapticConstant constant; /**< Constant effect. */ - SDL_HapticPeriodic periodic; /**< Periodic effect. */ - SDL_HapticCondition condition; /**< Condition effect. */ - SDL_HapticRamp ramp; /**< Ramp effect. */ - SDL_HapticLeftRight leftright; /**< Left/Right effect. */ - SDL_HapticCustom custom; /**< Custom effect. */ -} SDL_HapticEffect; - - -/* Function prototypes */ -/** - * \brief Count the number of haptic devices attached to the system. - * - * \return Number of haptic devices detected on the system. - */ -extern DECLSPEC int SDLCALL SDL_NumHaptics(void); - -/** - * \brief Get the implementation dependent name of a haptic device. - * - * This can be called before any joysticks are opened. - * If no name can be found, this function returns NULL. - * - * \param device_index Index of the device to get its name. - * \return Name of the device or NULL on error. - * - * \sa SDL_NumHaptics - */ -extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index); - -/** - * \brief Opens a haptic device for use. - * - * The index passed as an argument refers to the N'th haptic device on this - * system. - * - * When opening a haptic device, its gain will be set to maximum and - * autocenter will be disabled. To modify these values use - * SDL_HapticSetGain() and SDL_HapticSetAutocenter(). - * - * \param device_index Index of the device to open. - * \return Device identifier or NULL on error. - * - * \sa SDL_HapticIndex - * \sa SDL_HapticOpenFromMouse - * \sa SDL_HapticOpenFromJoystick - * \sa SDL_HapticClose - * \sa SDL_HapticSetGain - * \sa SDL_HapticSetAutocenter - * \sa SDL_HapticPause - * \sa SDL_HapticStopAll - */ -extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index); - -/** - * \brief Checks if the haptic device at index has been opened. - * - * \param device_index Index to check to see if it has been opened. - * \return 1 if it has been opened or 0 if it hasn't. - * - * \sa SDL_HapticOpen - * \sa SDL_HapticIndex - */ -extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index); - -/** - * \brief Gets the index of a haptic device. - * - * \param haptic Haptic device to get the index of. - * \return The index of the haptic device or -1 on error. - * - * \sa SDL_HapticOpen - * \sa SDL_HapticOpened - */ -extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic); - -/** - * \brief Gets whether or not the current mouse has haptic capabilities. - * - * \return SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't. - * - * \sa SDL_HapticOpenFromMouse - */ -extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void); - -/** - * \brief Tries to open a haptic device from the current mouse. - * - * \return The haptic device identifier or NULL on error. - * - * \sa SDL_MouseIsHaptic - * \sa SDL_HapticOpen - */ -extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void); - -/** - * \brief Checks to see if a joystick has haptic features. - * - * \param joystick Joystick to test for haptic capabilities. - * \return SDL_TRUE if the joystick is haptic, SDL_FALSE if it isn't - * or -1 if an error occurred. - * - * \sa SDL_HapticOpenFromJoystick - */ -extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick); - -/** - * \brief Opens a haptic device for use from a joystick device. - * - * You must still close the haptic device separately. It will not be closed - * with the joystick. - * - * When opening from a joystick you should first close the haptic device before - * closing the joystick device. If not, on some implementations the haptic - * device will also get unallocated and you'll be unable to use force feedback - * on that device. - * - * \param joystick Joystick to create a haptic device from. - * \return A valid haptic device identifier on success or NULL on error. - * - * \sa SDL_HapticOpen - * \sa SDL_HapticClose - */ -extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick * - joystick); - -/** - * \brief Closes a haptic device previously opened with SDL_HapticOpen(). - * - * \param haptic Haptic device to close. - */ -extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic); - -/** - * \brief Returns the number of effects a haptic device can store. - * - * On some platforms this isn't fully supported, and therefore is an - * approximation. Always check to see if your created effect was actually - * created and do not rely solely on SDL_HapticNumEffects(). - * - * \param haptic The haptic device to query effect max. - * \return The number of effects the haptic device can store or - * -1 on error. - * - * \sa SDL_HapticNumEffectsPlaying - * \sa SDL_HapticQuery - */ -extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic); - -/** - * \brief Returns the number of effects a haptic device can play at the same - * time. - * - * This is not supported on all platforms, but will always return a value. - * Added here for the sake of completeness. - * - * \param haptic The haptic device to query maximum playing effects. - * \return The number of effects the haptic device can play at the same time - * or -1 on error. - * - * \sa SDL_HapticNumEffects - * \sa SDL_HapticQuery - */ -extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic); - -/** - * \brief Gets the haptic device's supported features in bitwise manner. - * - * Example: - * \code - * if (SDL_HapticQuery(haptic) & SDL_HAPTIC_CONSTANT) { - * printf("We have constant haptic effect!\n"); - * } - * \endcode - * - * \param haptic The haptic device to query. - * \return Haptic features in bitwise manner (OR'd). - * - * \sa SDL_HapticNumEffects - * \sa SDL_HapticEffectSupported - */ -extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic); - - -/** - * \brief Gets the number of haptic axes the device has. - * - * \sa SDL_HapticDirection - */ -extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic); - -/** - * \brief Checks to see if effect is supported by haptic. - * - * \param haptic Haptic device to check on. - * \param effect Effect to check to see if it is supported. - * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. - * - * \sa SDL_HapticQuery - * \sa SDL_HapticNewEffect - */ -extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic, - SDL_HapticEffect * - effect); - -/** - * \brief Creates a new haptic effect on the device. - * - * \param haptic Haptic device to create the effect on. - * \param effect Properties of the effect to create. - * \return The identifier of the effect on success or -1 on error. - * - * \sa SDL_HapticUpdateEffect - * \sa SDL_HapticRunEffect - * \sa SDL_HapticDestroyEffect - */ -extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic, - SDL_HapticEffect * effect); - -/** - * \brief Updates the properties of an effect. - * - * Can be used dynamically, although behavior when dynamically changing - * direction may be strange. Specifically the effect may reupload itself - * and start playing from the start. You cannot change the type either when - * running SDL_HapticUpdateEffect(). - * - * \param haptic Haptic device that has the effect. - * \param effect Identifier of the effect to update. - * \param data New effect properties to use. - * \return 0 on success or -1 on error. - * - * \sa SDL_HapticNewEffect - * \sa SDL_HapticRunEffect - * \sa SDL_HapticDestroyEffect - */ -extern DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic * haptic, - int effect, - SDL_HapticEffect * data); - -/** - * \brief Runs the haptic effect on its associated haptic device. - * - * If iterations are ::SDL_HAPTIC_INFINITY, it'll run the effect over and over - * repeating the envelope (attack and fade) every time. If you only want the - * effect to last forever, set ::SDL_HAPTIC_INFINITY in the effect's length - * parameter. - * - * \param haptic Haptic device to run the effect on. - * \param effect Identifier of the haptic effect to run. - * \param iterations Number of iterations to run the effect. Use - * ::SDL_HAPTIC_INFINITY for infinity. - * \return 0 on success or -1 on error. - * - * \sa SDL_HapticStopEffect - * \sa SDL_HapticDestroyEffect - * \sa SDL_HapticGetEffectStatus - */ -extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic, - int effect, - Uint32 iterations); - -/** - * \brief Stops the haptic effect on its associated haptic device. - * - * \param haptic Haptic device to stop the effect on. - * \param effect Identifier of the effect to stop. - * \return 0 on success or -1 on error. - * - * \sa SDL_HapticRunEffect - * \sa SDL_HapticDestroyEffect - */ -extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic, - int effect); - -/** - * \brief Destroys a haptic effect on the device. - * - * This will stop the effect if it's running. Effects are automatically - * destroyed when the device is closed. - * - * \param haptic Device to destroy the effect on. - * \param effect Identifier of the effect to destroy. - * - * \sa SDL_HapticNewEffect - */ -extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic, - int effect); - -/** - * \brief Gets the status of the current effect on the haptic device. - * - * Device must support the ::SDL_HAPTIC_STATUS feature. - * - * \param haptic Haptic device to query the effect status on. - * \param effect Identifier of the effect to query its status. - * \return 0 if it isn't playing, 1 if it is playing or -1 on error. - * - * \sa SDL_HapticRunEffect - * \sa SDL_HapticStopEffect - */ -extern DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic * haptic, - int effect); - -/** - * \brief Sets the global gain of the device. - * - * Device must support the ::SDL_HAPTIC_GAIN feature. - * - * The user may specify the maximum gain by setting the environment variable - * SDL_HAPTIC_GAIN_MAX which should be between 0 and 100. All calls to - * SDL_HapticSetGain() will scale linearly using SDL_HAPTIC_GAIN_MAX as the - * maximum. - * - * \param haptic Haptic device to set the gain on. - * \param gain Value to set the gain to, should be between 0 and 100. - * \return 0 on success or -1 on error. - * - * \sa SDL_HapticQuery - */ -extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain); - -/** - * \brief Sets the global autocenter of the device. - * - * Autocenter should be between 0 and 100. Setting it to 0 will disable - * autocentering. - * - * Device must support the ::SDL_HAPTIC_AUTOCENTER feature. - * - * \param haptic Haptic device to set autocentering on. - * \param autocenter Value to set autocenter to, 0 disables autocentering. - * \return 0 on success or -1 on error. - * - * \sa SDL_HapticQuery - */ -extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic, - int autocenter); - -/** - * \brief Pauses a haptic device. - * - * Device must support the ::SDL_HAPTIC_PAUSE feature. Call - * SDL_HapticUnpause() to resume playback. - * - * Do not modify the effects nor add new ones while the device is paused. - * That can cause all sorts of weird errors. - * - * \param haptic Haptic device to pause. - * \return 0 on success or -1 on error. - * - * \sa SDL_HapticUnpause - */ -extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic); - -/** - * \brief Unpauses a haptic device. - * - * Call to unpause after SDL_HapticPause(). - * - * \param haptic Haptic device to unpause. - * \return 0 on success or -1 on error. - * - * \sa SDL_HapticPause - */ -extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic); - -/** - * \brief Stops all the currently playing effects on a haptic device. - * - * \param haptic Haptic device to stop. - * \return 0 on success or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic); - -/** - * \brief Checks to see if rumble is supported on a haptic device. - * - * \param haptic Haptic device to check to see if it supports rumble. - * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. - * - * \sa SDL_HapticRumbleInit - * \sa SDL_HapticRumblePlay - * \sa SDL_HapticRumbleStop - */ -extern DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic * haptic); - -/** - * \brief Initializes the haptic device for simple rumble playback. - * - * \param haptic Haptic device to initialize for simple rumble playback. - * \return 0 on success or -1 on error. - * - * \sa SDL_HapticOpen - * \sa SDL_HapticRumbleSupported - * \sa SDL_HapticRumblePlay - * \sa SDL_HapticRumbleStop - */ -extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic); - -/** - * \brief Runs simple rumble on a haptic device - * - * \param haptic Haptic device to play rumble effect on. - * \param strength Strength of the rumble to play as a 0-1 float value. - * \param length Length of the rumble to play in milliseconds. - * \return 0 on success or -1 on error. - * - * \sa SDL_HapticRumbleSupported - * \sa SDL_HapticRumbleInit - * \sa SDL_HapticRumbleStop - */ -extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length ); - -/** - * \brief Stops the simple rumble on a haptic device. - * - * \param haptic Haptic to stop the rumble on. - * \return 0 on success or -1 on error. - * - * \sa SDL_HapticRumbleSupported - * \sa SDL_HapticRumbleInit - * \sa SDL_HapticRumblePlay - */ -extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_haptic_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_hints.h b/thirdparty/include/SDL2/SDL_hints.h deleted file mode 100644 index a3a537383..000000000 --- a/thirdparty/include/SDL2/SDL_hints.h +++ /dev/null @@ -1,1364 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_hints.h - * - * Official documentation for SDL configuration variables - * - * This file contains functions to set and get configuration hints, - * as well as listing each of them alphabetically. - * - * The convention for naming hints is SDL_HINT_X, where "SDL_X" is - * the environment variable that can be used to override the default. - * - * In general these hints are just that - they may or may not be - * supported or applicable on any given platform, but they provide - * a way for an application or user to give the library a hint as - * to how they would like the library to work. - */ - -#ifndef SDL_hints_h_ -#define SDL_hints_h_ - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief A variable controlling how 3D acceleration is used to accelerate the SDL screen surface. - * - * SDL can try to accelerate the SDL screen surface by using streaming - * textures with a 3D rendering engine. This variable controls whether and - * how this is done. - * - * This variable can be set to the following values: - * "0" - Disable 3D acceleration - * "1" - Enable 3D acceleration, using the default renderer. - * "X" - Enable 3D acceleration, using X where X is one of the valid rendering drivers. (e.g. "direct3d", "opengl", etc.) - * - * By default SDL tries to make a best guess for each platform whether - * to use acceleration or not. - */ -#define SDL_HINT_FRAMEBUFFER_ACCELERATION "SDL_FRAMEBUFFER_ACCELERATION" - -/** - * \brief A variable specifying which render driver to use. - * - * If the application doesn't pick a specific renderer to use, this variable - * specifies the name of the preferred renderer. If the preferred renderer - * can't be initialized, the normal default renderer is used. - * - * This variable is case insensitive and can be set to the following values: - * "direct3d" - * "opengl" - * "opengles2" - * "opengles" - * "metal" - * "software" - * - * The default varies by platform, but it's the first one in the list that - * is available on the current platform. - */ -#define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER" - -/** - * \brief A variable controlling whether the OpenGL render driver uses shaders if they are available. - * - * This variable can be set to the following values: - * "0" - Disable shaders - * "1" - Enable shaders - * - * By default shaders are used if OpenGL supports them. - */ -#define SDL_HINT_RENDER_OPENGL_SHADERS "SDL_RENDER_OPENGL_SHADERS" - -/** - * \brief A variable controlling whether the Direct3D device is initialized for thread-safe operations. - * - * This variable can be set to the following values: - * "0" - Thread-safety is not enabled (faster) - * "1" - Thread-safety is enabled - * - * By default the Direct3D device is created with thread-safety disabled. - */ -#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE" - -/** - * \brief A variable controlling whether to enable Direct3D 11+'s Debug Layer. - * - * This variable does not have any effect on the Direct3D 9 based renderer. - * - * This variable can be set to the following values: - * "0" - Disable Debug Layer use - * "1" - Enable Debug Layer use - * - * By default, SDL does not use Direct3D Debug Layer. - */ -#define SDL_HINT_RENDER_DIRECT3D11_DEBUG "SDL_RENDER_DIRECT3D11_DEBUG" - -/** - * \brief A variable controlling the scaling policy for SDL_RenderSetLogicalSize. - * - * This variable can be set to the following values: - * "0" or "letterbox" - Uses letterbox/sidebars to fit the entire rendering on screen - * "1" or "overscan" - Will zoom the rendering so it fills the entire screen, allowing edges to be drawn offscreen - * - * By default letterbox is used - */ -#define SDL_HINT_RENDER_LOGICAL_SIZE_MODE "SDL_RENDER_LOGICAL_SIZE_MODE" - -/** - * \brief A variable controlling the scaling quality - * - * This variable can be set to the following values: - * "0" or "nearest" - Nearest pixel sampling - * "1" or "linear" - Linear filtering (supported by OpenGL and Direct3D) - * "2" or "best" - Currently this is the same as "linear" - * - * By default nearest pixel sampling is used - */ -#define SDL_HINT_RENDER_SCALE_QUALITY "SDL_RENDER_SCALE_QUALITY" - -/** - * \brief A variable controlling whether updates to the SDL screen surface should be synchronized with the vertical refresh, to avoid tearing. - * - * This variable can be set to the following values: - * "0" - Disable vsync - * "1" - Enable vsync - * - * By default SDL does not sync screen surface updates with vertical refresh. - */ -#define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" - -/** - * \brief A variable controlling whether the screensaver is enabled. - * - * This variable can be set to the following values: - * "0" - Disable screensaver - * "1" - Enable screensaver - * - * By default SDL will disable the screensaver. - */ -#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER "SDL_VIDEO_ALLOW_SCREENSAVER" - -/** - * \brief A variable controlling whether the graphics context is externally managed. - * - * This variable can be set to the following values: - * "0" - SDL will manage graphics contexts that are attached to windows. - * "1" - Disable graphics context management on windows. - * - * By default SDL will manage OpenGL contexts in certain situations. For example, on Android the - * context will be automatically saved and restored when pausing the application. Additionally, some - * platforms will assume usage of OpenGL if Vulkan isn't used. Setting this to "1" will prevent this - * behavior, which is desireable when the application manages the graphics context, such as - * an externally managed OpenGL context or attaching a Vulkan surface to the window. - */ -#define SDL_HINT_VIDEO_EXTERNAL_CONTEXT "SDL_VIDEO_EXTERNAL_CONTEXT" - -/** - * \brief A variable controlling whether the X11 VidMode extension should be used. - * - * This variable can be set to the following values: - * "0" - Disable XVidMode - * "1" - Enable XVidMode - * - * By default SDL will use XVidMode if it is available. - */ -#define SDL_HINT_VIDEO_X11_XVIDMODE "SDL_VIDEO_X11_XVIDMODE" - -/** - * \brief A variable controlling whether the X11 Xinerama extension should be used. - * - * This variable can be set to the following values: - * "0" - Disable Xinerama - * "1" - Enable Xinerama - * - * By default SDL will use Xinerama if it is available. - */ -#define SDL_HINT_VIDEO_X11_XINERAMA "SDL_VIDEO_X11_XINERAMA" - -/** - * \brief A variable controlling whether the X11 XRandR extension should be used. - * - * This variable can be set to the following values: - * "0" - Disable XRandR - * "1" - Enable XRandR - * - * By default SDL will not use XRandR because of window manager issues. - */ -#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR" - -/** - * \brief A variable forcing the visual ID chosen for new X11 windows - * - */ -#define SDL_HINT_VIDEO_X11_WINDOW_VISUALID "SDL_VIDEO_X11_WINDOW_VISUALID" - -/** - * \brief A variable controlling whether the X11 _NET_WM_PING protocol should be supported. - * - * This variable can be set to the following values: - * "0" - Disable _NET_WM_PING - * "1" - Enable _NET_WM_PING - * - * By default SDL will use _NET_WM_PING, but for applications that know they - * will not always be able to respond to ping requests in a timely manner they can - * turn it off to avoid the window manager thinking the app is hung. - * The hint is checked in CreateWindow. - */ -#define SDL_HINT_VIDEO_X11_NET_WM_PING "SDL_VIDEO_X11_NET_WM_PING" - -/** - * \brief A variable controlling whether the X11 _NET_WM_BYPASS_COMPOSITOR hint should be used. - * - * This variable can be set to the following values: - * "0" - Disable _NET_WM_BYPASS_COMPOSITOR - * "1" - Enable _NET_WM_BYPASS_COMPOSITOR - * - * By default SDL will use _NET_WM_BYPASS_COMPOSITOR - * - */ -#define SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR "SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR" - -/** - * \brief A variable controlling whether X11 should use GLX or EGL by default - * - * This variable can be set to the following values: - * "0" - Use GLX - * "1" - Use EGL - * - * By default SDL will use GLX when both are present. - */ -#define SDL_HINT_VIDEO_X11_FORCE_EGL "SDL_VIDEO_X11_FORCE_EGL" - -/** - * \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden - * - * This variable can be set to the following values: - * "0" - The window frame is not interactive when the cursor is hidden (no move, resize, etc) - * "1" - The window frame is interactive when the cursor is hidden - * - * By default SDL will allow interaction with the window frame when the cursor is hidden - */ -#define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN" - -/** - * \brief A variable to specify custom icon resource id from RC file on Windows platform - */ -#define SDL_HINT_WINDOWS_INTRESOURCE_ICON "SDL_WINDOWS_INTRESOURCE_ICON" -#define SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL "SDL_WINDOWS_INTRESOURCE_ICON_SMALL" - -/** - * \brief A variable controlling whether the windows message loop is processed by SDL - * - * This variable can be set to the following values: - * "0" - The window message loop is not run - * "1" - The window message loop is processed in SDL_PumpEvents() - * - * By default SDL will process the windows message loop - */ -#define SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP "SDL_WINDOWS_ENABLE_MESSAGELOOP" - -/** - * \brief A variable controlling whether grabbing input grabs the keyboard - * - * This variable can be set to the following values: - * "0" - Grab will affect only the mouse - * "1" - Grab will affect mouse and keyboard - * - * By default SDL will not grab the keyboard so system shortcuts still work. - */ -#define SDL_HINT_GRAB_KEYBOARD "SDL_GRAB_KEYBOARD" - -/** - * \brief A variable setting the double click time, in milliseconds. - */ -#define SDL_HINT_MOUSE_DOUBLE_CLICK_TIME "SDL_MOUSE_DOUBLE_CLICK_TIME" - -/** - * \brief A variable setting the double click radius, in pixels. - */ -#define SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS "SDL_MOUSE_DOUBLE_CLICK_RADIUS" - -/** - * \brief A variable setting the speed scale for mouse motion, in floating point, when the mouse is not in relative mode - */ -#define SDL_HINT_MOUSE_NORMAL_SPEED_SCALE "SDL_MOUSE_NORMAL_SPEED_SCALE" - -/** - * \brief A variable setting the scale for mouse motion, in floating point, when the mouse is in relative mode - */ -#define SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE "SDL_MOUSE_RELATIVE_SPEED_SCALE" - -/** - * \brief A variable controlling whether relative mouse mode is implemented using mouse warping - * - * This variable can be set to the following values: - * "0" - Relative mouse mode uses raw input - * "1" - Relative mouse mode uses mouse warping - * - * By default SDL will use raw input for relative mouse mode - */ -#define SDL_HINT_MOUSE_RELATIVE_MODE_WARP "SDL_MOUSE_RELATIVE_MODE_WARP" - -/** - * \brief Allow mouse click events when clicking to focus an SDL window - * - * This variable can be set to the following values: - * "0" - Ignore mouse clicks that activate a window - * "1" - Generate events for mouse clicks that activate a window - * - * By default SDL will ignore mouse clicks that activate a window - */ -#define SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH "SDL_MOUSE_FOCUS_CLICKTHROUGH" - -/** - * \brief A variable controlling whether touch events should generate synthetic mouse events - * - * This variable can be set to the following values: - * "0" - Touch events will not generate mouse events - * "1" - Touch events will generate mouse events - * - * By default SDL will generate mouse events for touch events - */ -#define SDL_HINT_TOUCH_MOUSE_EVENTS "SDL_TOUCH_MOUSE_EVENTS" - -/** - * \brief A variable controlling whether mouse events should generate synthetic touch events - * - * This variable can be set to the following values: - * "0" - Mouse events will not generate touch events (default for desktop platforms) - * "1" - Mouse events will generate touch events (default for mobile platforms, such as Android and iOS) - */ - -#define SDL_HINT_MOUSE_TOUCH_EVENTS "SDL_MOUSE_TOUCH_EVENTS" - -/** - * \brief Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to true. - * - */ -#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS" - -/** - * \brief A variable controlling whether the idle timer is disabled on iOS. - * - * When an iOS app does not receive touches for some time, the screen is - * dimmed automatically. For games where the accelerometer is the only input - * this is problematic. This functionality can be disabled by setting this - * hint. - * - * As of SDL 2.0.4, SDL_EnableScreenSaver() and SDL_DisableScreenSaver() - * accomplish the same thing on iOS. They should be preferred over this hint. - * - * This variable can be set to the following values: - * "0" - Enable idle timer - * "1" - Disable idle timer - */ -#define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED" - -/** - * \brief A variable controlling which orientations are allowed on iOS/Android. - * - * In some circumstances it is necessary to be able to explicitly control - * which UI orientations are allowed. - * - * This variable is a space delimited list of the following values: - * "LandscapeLeft", "LandscapeRight", "Portrait" "PortraitUpsideDown" - */ -#define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS" - -/** - * \brief A variable controlling whether controllers used with the Apple TV - * generate UI events. - * - * When UI events are generated by controller input, the app will be - * backgrounded when the Apple TV remote's menu button is pressed, and when the - * pause or B buttons on gamepads are pressed. - * - * More information about properly making use of controllers for the Apple TV - * can be found here: - * https://developer.apple.com/tvos/human-interface-guidelines/remote-and-controllers/ - * - * This variable can be set to the following values: - * "0" - Controller input does not generate UI events (the default). - * "1" - Controller input generates UI events. - */ -#define SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS "SDL_APPLE_TV_CONTROLLER_UI_EVENTS" - -/** - * \brief A variable controlling whether the Apple TV remote's joystick axes - * will automatically match the rotation of the remote. - * - * This variable can be set to the following values: - * "0" - Remote orientation does not affect joystick axes (the default). - * "1" - Joystick axes are based on the orientation of the remote. - */ -#define SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION" - -/** - * \brief A variable controlling whether the home indicator bar on iPhone X - * should be hidden. - * - * This variable can be set to the following values: - * "0" - The indicator bar is not hidden (default for windowed applications) - * "1" - The indicator bar is hidden and is shown when the screen is touched (useful for movie playback applications) - * "2" - The indicator bar is dim and the first swipe makes it visible and the second swipe performs the "home" action (default for fullscreen applications) - */ -#define SDL_HINT_IOS_HIDE_HOME_INDICATOR "SDL_IOS_HIDE_HOME_INDICATOR" - -/** - * \brief A variable controlling whether the Android / iOS built-in - * accelerometer should be listed as a joystick device. - * - * This variable can be set to the following values: - * "0" - The accelerometer is not listed as a joystick - * "1" - The accelerometer is available as a 3 axis joystick (the default). - */ -#define SDL_HINT_ACCELEROMETER_AS_JOYSTICK "SDL_ACCELEROMETER_AS_JOYSTICK" - -/** - * \brief A variable controlling whether the Android / tvOS remotes - * should be listed as joystick devices, instead of sending keyboard events. - * - * This variable can be set to the following values: - * "0" - Remotes send enter/escape/arrow key events - * "1" - Remotes are available as 2 axis, 2 button joysticks (the default). - */ -#define SDL_HINT_TV_REMOTE_AS_JOYSTICK "SDL_TV_REMOTE_AS_JOYSTICK" - -/** - * \brief A variable that lets you disable the detection and use of Xinput gamepad devices - * - * The variable can be set to the following values: - * "0" - Disable XInput detection (only uses direct input) - * "1" - Enable XInput detection (the default) - */ -#define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED" - -/** - * \brief A variable that causes SDL to use the old axis and button mapping for XInput devices. - * - * This hint is for backwards compatibility only and will be removed in SDL 2.1 - * - * The default value is "0". This hint must be set before SDL_Init() - */ -#define SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING "SDL_XINPUT_USE_OLD_JOYSTICK_MAPPING" - -/** - * \brief A variable that overrides the automatic controller type detection - * - * The variable should be comma separated entries, in the form: VID/PID=type - * - * The VID and PID should be hexadecimal with exactly 4 digits, e.g. 0x00fd - * - * The type should be one of: - * Xbox360 - * XboxOne - * PS3 - * PS4 - * SwitchPro - * - * This hint affects what driver is used, and must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) - */ -#define SDL_HINT_GAMECONTROLLERTYPE "SDL_GAMECONTROLLERTYPE" - -/** - * \brief A variable that lets you manually hint extra gamecontroller db entries. - * - * The variable should be newline delimited rows of gamecontroller config data, see SDL_gamecontroller.h - * - * This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) - * You can update mappings after the system is initialized with SDL_GameControllerMappingForGUID() and SDL_GameControllerAddMapping() - */ -#define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG" - -/** - * \brief A variable that lets you provide a file with extra gamecontroller db entries. - * - * The file should contain lines of gamecontroller config data, see SDL_gamecontroller.h - * - * This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) - * You can update mappings after the system is initialized with SDL_GameControllerMappingForGUID() and SDL_GameControllerAddMapping() - */ -#define SDL_HINT_GAMECONTROLLERCONFIG_FILE "SDL_GAMECONTROLLERCONFIG_FILE" - -/** - * \brief A variable containing a list of devices to skip when scanning for game controllers. - * - * The format of the string is a comma separated list of USB VID/PID pairs - * in hexadecimal form, e.g. - * - * 0xAAAA/0xBBBB,0xCCCC/0xDDDD - * - * The variable can also take the form of @file, in which case the named - * file will be loaded and interpreted as the value of the variable. - */ -#define SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES "SDL_GAMECONTROLLER_IGNORE_DEVICES" - -/** - * \brief If set, all devices will be skipped when scanning for game controllers except for the ones listed in this variable. - * - * The format of the string is a comma separated list of USB VID/PID pairs - * in hexadecimal form, e.g. - * - * 0xAAAA/0xBBBB,0xCCCC/0xDDDD - * - * The variable can also take the form of @file, in which case the named - * file will be loaded and interpreted as the value of the variable. - */ -#define SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT "SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT" - -/** - * \brief If set, game controller face buttons report their values according to their labels instead of their positional layout. - * - * For example, on Nintendo Switch controllers, normally you'd get: - * - * (Y) - * (X) (B) - * (A) - * - * but if this hint is set, you'll get: - * - * (X) - * (Y) (A) - * (B) - * - * The variable can be set to the following values: - * "0" - Report the face buttons by position, as though they were on an Xbox controller. - * "1" - Report the face buttons by label instead of position - * - * The default value is "1". This hint may be set at any time. - */ -#define SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS "SDL_GAMECONTROLLER_USE_BUTTON_LABELS" - -/** - * \brief A variable that lets you enable joystick (and gamecontroller) events even when your app is in the background. - * - * The variable can be set to the following values: - * "0" - Disable joystick & gamecontroller input events when the - * application is in the background. - * "1" - Enable joystick & gamecontroller input events when the - * application is in the background. - * - * The default value is "0". This hint may be set at any time. - */ -#define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS" - -/** - * \brief A variable controlling whether the HIDAPI joystick drivers should be used. - * - * This variable can be set to the following values: - * "0" - HIDAPI drivers are not used - * "1" - HIDAPI drivers are used (the default) - * - * This variable is the default for all drivers, but can be overridden by the hints for specific drivers below. - */ -#define SDL_HINT_JOYSTICK_HIDAPI "SDL_JOYSTICK_HIDAPI" - -/** - * \brief A variable controlling whether the HIDAPI driver for PS4 controllers should be used. - * - * This variable can be set to the following values: - * "0" - HIDAPI driver is not used - * "1" - HIDAPI driver is used - * - * The default is the value of SDL_HINT_JOYSTICK_HIDAPI - */ -#define SDL_HINT_JOYSTICK_HIDAPI_PS4 "SDL_JOYSTICK_HIDAPI_PS4" - -/** - * \brief A variable controlling whether extended input reports should be used for PS4 controllers when using the HIDAPI driver. - * - * This variable can be set to the following values: - * "0" - extended reports are not enabled (the default) - * "1" - extended reports - * - * Extended input reports allow rumble on Bluetooth PS4 controllers, but - * break DirectInput handling for applications that don't use SDL. - * - * Once extended reports are enabled, they can not be disabled without - * power cycling the controller. - */ -#define SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE "SDL_JOYSTICK_HIDAPI_PS4_RUMBLE" - -/** - * \brief A variable controlling whether the HIDAPI driver for Steam Controllers should be used. - * - * This variable can be set to the following values: - * "0" - HIDAPI driver is not used - * "1" - HIDAPI driver is used - * - * The default is the value of SDL_HINT_JOYSTICK_HIDAPI - */ -#define SDL_HINT_JOYSTICK_HIDAPI_STEAM "SDL_JOYSTICK_HIDAPI_STEAM" - -/** - * \brief A variable controlling whether the HIDAPI driver for Nintendo Switch controllers should be used. - * - * This variable can be set to the following values: - * "0" - HIDAPI driver is not used - * "1" - HIDAPI driver is used - * - * The default is the value of SDL_HINT_JOYSTICK_HIDAPI - */ -#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH "SDL_JOYSTICK_HIDAPI_SWITCH" - -/** - * \brief A variable controlling whether the HIDAPI driver for XBox controllers should be used. - * - * This variable can be set to the following values: - * "0" - HIDAPI driver is not used - * "1" - HIDAPI driver is used - * - * The default is the value of SDL_HINT_JOYSTICK_HIDAPI - */ -#define SDL_HINT_JOYSTICK_HIDAPI_XBOX "SDL_JOYSTICK_HIDAPI_XBOX" - -/** - * \brief A variable controlling whether the HIDAPI driver for Nintendo GameCube controllers should be used. - * - * This variable can be set to the following values: - * "0" - HIDAPI driver is not used - * "1" - HIDAPI driver is used - * - * The default is the value of SDL_HINT_JOYSTICK_HIDAPI - */ -#define SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE "SDL_JOYSTICK_HIDAPI_GAMECUBE" - -/** - * \brief A variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs - * - * The variable can be set to the following values: - * "0" - Do not scan for Steam Controllers - * "1" - Scan for Steam Controllers (the default) - * - * The default value is "1". This hint must be set before initializing the joystick subsystem. - */ -#define SDL_HINT_ENABLE_STEAM_CONTROLLERS "SDL_ENABLE_STEAM_CONTROLLERS" - - -/** - * \brief If set to "0" then never set the top most bit on a SDL Window, even if the video mode expects it. - * This is a debugging aid for developers and not expected to be used by end users. The default is "1" - * - * This variable can be set to the following values: - * "0" - don't allow topmost - * "1" - allow topmost - */ -#define SDL_HINT_ALLOW_TOPMOST "SDL_ALLOW_TOPMOST" - -/** - * \brief A variable that controls the timer resolution, in milliseconds. - * - * The higher resolution the timer, the more frequently the CPU services - * timer interrupts, and the more precise delays are, but this takes up - * power and CPU time. This hint is only used on Windows 7 and earlier. - * - * See this blog post for more information: - * http://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/ - * - * If this variable is set to "0", the system timer resolution is not set. - * - * The default value is "1". This hint may be set at any time. - */ -#define SDL_HINT_TIMER_RESOLUTION "SDL_TIMER_RESOLUTION" - - -/** - * \brief A variable describing the content orientation on QtWayland-based platforms. - * - * On QtWayland platforms, windows are rotated client-side to allow for custom - * transitions. In order to correctly position overlays (e.g. volume bar) and - * gestures (e.g. events view, close/minimize gestures), the system needs to - * know in which orientation the application is currently drawing its contents. - * - * This does not cause the window to be rotated or resized, the application - * needs to take care of drawing the content in the right orientation (the - * framebuffer is always in portrait mode). - * - * This variable can be one of the following values: - * "primary" (default), "portrait", "landscape", "inverted-portrait", "inverted-landscape" - */ -#define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION "SDL_QTWAYLAND_CONTENT_ORIENTATION" - -/** - * \brief Flags to set on QtWayland windows to integrate with the native window manager. - * - * On QtWayland platforms, this hint controls the flags to set on the windows. - * For example, on Sailfish OS "OverridesSystemGestures" disables swipe gestures. - * - * This variable is a space-separated list of the following values (empty = no flags): - * "OverridesSystemGestures", "StaysOnTop", "BypassWindowManager" - */ -#define SDL_HINT_QTWAYLAND_WINDOW_FLAGS "SDL_QTWAYLAND_WINDOW_FLAGS" - -/** -* \brief A string specifying SDL's threads stack size in bytes or "0" for the backend's default size -* -* Use this hint in case you need to set SDL's threads stack size to other than the default. -* This is specially useful if you build SDL against a non glibc libc library (such as musl) which -* provides a relatively small default thread stack size (a few kilobytes versus the default 8MB glibc uses). -* Support for this hint is currently available only in the pthread, Windows, and PSP backend. -* -* Instead of this hint, in 2.0.9 and later, you can use -* SDL_CreateThreadWithStackSize(). This hint only works with the classic -* SDL_CreateThread(). -*/ -#define SDL_HINT_THREAD_STACK_SIZE "SDL_THREAD_STACK_SIZE" - -/** - * \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac and iOS) - */ -#define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_VIDEO_HIGHDPI_DISABLED" - -/** - * \brief A variable that determines whether ctrl+click should generate a right-click event on Mac - * - * If present, holding ctrl while left clicking will generate a right click - * event when on Mac. - */ -#define SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK" - -/** -* \brief A variable specifying which shader compiler to preload when using the Chrome ANGLE binaries -* -* SDL has EGL and OpenGL ES2 support on Windows via the ANGLE project. It -* can use two different sets of binaries, those compiled by the user from source -* or those provided by the Chrome browser. In the later case, these binaries require -* that SDL loads a DLL providing the shader compiler. -* -* This variable can be set to the following values: -* "d3dcompiler_46.dll" - default, best for Vista or later. -* "d3dcompiler_43.dll" - for XP support. -* "none" - do not load any library, useful if you compiled ANGLE from source and included the compiler in your binaries. -* -*/ -#define SDL_HINT_VIDEO_WIN_D3DCOMPILER "SDL_VIDEO_WIN_D3DCOMPILER" - -/** -* \brief A variable that is the address of another SDL_Window* (as a hex string formatted with "%p"). -* -* If this hint is set before SDL_CreateWindowFrom() and the SDL_Window* it is set to has -* SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly -* created SDL_Window: -* -* 1. Its pixel format will be set to the same pixel format as this SDL_Window. This is -* needed for example when sharing an OpenGL context across multiple windows. -* -* 2. The flag SDL_WINDOW_OPENGL will be set on the new window so it can be used for -* OpenGL rendering. -* -* This variable can be set to the following values: -* The address (as a string "%p") of the SDL_Window* that new windows created with SDL_CreateWindowFrom() should -* share a pixel format with. -*/ -#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT" - -/** - * \brief A URL to a WinRT app's privacy policy - * - * All network-enabled WinRT apps must make a privacy policy available to its - * users. On Windows 8, 8.1, and RT, Microsoft mandates that this policy be - * be available in the Windows Settings charm, as accessed from within the app. - * SDL provides code to add a URL-based link there, which can point to the app's - * privacy policy. - * - * To setup a URL to an app's privacy policy, set SDL_HINT_WINRT_PRIVACY_POLICY_URL - * before calling any SDL_Init() functions. The contents of the hint should - * be a valid URL. For example, "http://www.example.com". - * - * The default value is "", which will prevent SDL from adding a privacy policy - * link to the Settings charm. This hint should only be set during app init. - * - * The label text of an app's "Privacy Policy" link may be customized via another - * hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL. - * - * Please note that on Windows Phone, Microsoft does not provide standard UI - * for displaying a privacy policy link, and as such, SDL_HINT_WINRT_PRIVACY_POLICY_URL - * will not get used on that platform. Network-enabled phone apps should display - * their privacy policy through some other, in-app means. - */ -#define SDL_HINT_WINRT_PRIVACY_POLICY_URL "SDL_WINRT_PRIVACY_POLICY_URL" - -/** \brief Label text for a WinRT app's privacy policy link - * - * Network-enabled WinRT apps must include a privacy policy. On Windows 8, 8.1, and RT, - * Microsoft mandates that this policy be available via the Windows Settings charm. - * SDL provides code to add a link there, with its label text being set via the - * optional hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL. - * - * Please note that a privacy policy's contents are not set via this hint. A separate - * hint, SDL_HINT_WINRT_PRIVACY_POLICY_URL, is used to link to the actual text of the - * policy. - * - * The contents of this hint should be encoded as a UTF8 string. - * - * The default value is "Privacy Policy". This hint should only be set during app - * initialization, preferably before any calls to SDL_Init(). - * - * For additional information on linking to a privacy policy, see the documentation for - * SDL_HINT_WINRT_PRIVACY_POLICY_URL. - */ -#define SDL_HINT_WINRT_PRIVACY_POLICY_LABEL "SDL_WINRT_PRIVACY_POLICY_LABEL" - -/** \brief Allows back-button-press events on Windows Phone to be marked as handled - * - * Windows Phone devices typically feature a Back button. When pressed, - * the OS will emit back-button-press events, which apps are expected to - * handle in an appropriate manner. If apps do not explicitly mark these - * events as 'Handled', then the OS will invoke its default behavior for - * unhandled back-button-press events, which on Windows Phone 8 and 8.1 is to - * terminate the app (and attempt to switch to the previous app, or to the - * device's home screen). - * - * Setting the SDL_HINT_WINRT_HANDLE_BACK_BUTTON hint to "1" will cause SDL - * to mark back-button-press events as Handled, if and when one is sent to - * the app. - * - * Internally, Windows Phone sends back button events as parameters to - * special back-button-press callback functions. Apps that need to respond - * to back-button-press events are expected to register one or more - * callback functions for such, shortly after being launched (during the - * app's initialization phase). After the back button is pressed, the OS - * will invoke these callbacks. If the app's callback(s) do not explicitly - * mark the event as handled by the time they return, or if the app never - * registers one of these callback, the OS will consider the event - * un-handled, and it will apply its default back button behavior (terminate - * the app). - * - * SDL registers its own back-button-press callback with the Windows Phone - * OS. This callback will emit a pair of SDL key-press events (SDL_KEYDOWN - * and SDL_KEYUP), each with a scancode of SDL_SCANCODE_AC_BACK, after which - * it will check the contents of the hint, SDL_HINT_WINRT_HANDLE_BACK_BUTTON. - * If the hint's value is set to "1", the back button event's Handled - * property will get set to 'true'. If the hint's value is set to something - * else, or if it is unset, SDL will leave the event's Handled property - * alone. (By default, the OS sets this property to 'false', to note.) - * - * SDL apps can either set SDL_HINT_WINRT_HANDLE_BACK_BUTTON well before a - * back button is pressed, or can set it in direct-response to a back button - * being pressed. - * - * In order to get notified when a back button is pressed, SDL apps should - * register a callback function with SDL_AddEventWatch(), and have it listen - * for SDL_KEYDOWN events that have a scancode of SDL_SCANCODE_AC_BACK. - * (Alternatively, SDL_KEYUP events can be listened-for. Listening for - * either event type is suitable.) Any value of SDL_HINT_WINRT_HANDLE_BACK_BUTTON - * set by such a callback, will be applied to the OS' current - * back-button-press event. - * - * More details on back button behavior in Windows Phone apps can be found - * at the following page, on Microsoft's developer site: - * http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj247550(v=vs.105).aspx - */ -#define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_WINRT_HANDLE_BACK_BUTTON" - -/** - * \brief A variable that dictates policy for fullscreen Spaces on Mac OS X. - * - * This hint only applies to Mac OS X. - * - * The variable can be set to the following values: - * "0" - Disable Spaces support (FULLSCREEN_DESKTOP won't use them and - * SDL_WINDOW_RESIZABLE windows won't offer the "fullscreen" - * button on their titlebars). - * "1" - Enable Spaces support (FULLSCREEN_DESKTOP will use them and - * SDL_WINDOW_RESIZABLE windows will offer the "fullscreen" - * button on their titlebars). - * - * The default value is "1". Spaces are disabled regardless of this hint if - * the OS isn't at least Mac OS X Lion (10.7). This hint must be set before - * any windows are created. - */ -#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES" - -/** -* \brief When set don't force the SDL app to become a foreground process -* -* This hint only applies to Mac OS X. -* -*/ -#define SDL_HINT_MAC_BACKGROUND_APP "SDL_MAC_BACKGROUND_APP" - -/** - * \brief Android APK expansion main file version. Should be a string number like "1", "2" etc. - * - * Must be set together with SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION. - * - * If both hints were set then SDL_RWFromFile() will look into expansion files - * after a given relative path was not found in the internal storage and assets. - * - * By default this hint is not set and the APK expansion files are not searched. - */ -#define SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION" - -/** - * \brief Android APK expansion patch file version. Should be a string number like "1", "2" etc. - * - * Must be set together with SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION. - * - * If both hints were set then SDL_RWFromFile() will look into expansion files - * after a given relative path was not found in the internal storage and assets. - * - * By default this hint is not set and the APK expansion files are not searched. - */ -#define SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION" - -/** - * \brief A variable to control whether certain IMEs should handle text editing internally instead of sending SDL_TEXTEDITING events. - * - * The variable can be set to the following values: - * "0" - SDL_TEXTEDITING events are sent, and it is the application's - * responsibility to render the text from these events and - * differentiate it somehow from committed text. (default) - * "1" - If supported by the IME then SDL_TEXTEDITING events are not sent, - * and text that is being composed will be rendered in its own UI. - */ -#define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING" - -/** - * \brief A variable to control whether we trap the Android back button to handle it manually. - * This is necessary for the right mouse button to work on some Android devices, or - * to be able to trap the back button for use in your code reliably. If set to true, - * the back button will show up as an SDL_KEYDOWN / SDL_KEYUP pair with a keycode of - * SDL_SCANCODE_AC_BACK. - * - * The variable can be set to the following values: - * "0" - Back button will be handled as usual for system. (default) - * "1" - Back button will be trapped, allowing you to handle the key press - * manually. (This will also let right mouse click work on systems - * where the right mouse button functions as back.) - * - * The value of this hint is used at runtime, so it can be changed at any time. - */ -#define SDL_HINT_ANDROID_TRAP_BACK_BUTTON "SDL_ANDROID_TRAP_BACK_BUTTON" - -/** - * \brief A variable to control whether the event loop will block itself when the app is paused. - * - * The variable can be set to the following values: - * "0" - Non blocking. - * "1" - Blocking. (default) - * - * The value should be set before SDL is initialized. - */ -#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE" - - /** - * \brief A variable to control whether the return key on the soft keyboard - * should hide the soft keyboard on Android and iOS. - * - * The variable can be set to the following values: - * "0" - The return key will be handled as a key event. This is the behaviour of SDL <= 2.0.3. (default) - * "1" - The return key will hide the keyboard. - * - * The value of this hint is used at runtime, so it can be changed at any time. - */ -#define SDL_HINT_RETURN_KEY_HIDES_IME "SDL_RETURN_KEY_HIDES_IME" - -/** - * \brief override the binding element for keyboard inputs for Emscripten builds - * - * This hint only applies to the emscripten platform - * - * The variable can be one of - * "#window" - The javascript window object (this is the default) - * "#document" - The javascript document object - * "#screen" - the javascript window.screen object - * "#canvas" - the WebGL canvas element - * any other string without a leading # sign applies to the element on the page with that ID. - */ -#define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT" - -/** - * \brief Tell SDL not to catch the SIGINT or SIGTERM signals. - * - * This hint only applies to Unix-like platforms. - * - * The variable can be set to the following values: - * "0" - SDL will install a SIGINT and SIGTERM handler, and when it - * catches a signal, convert it into an SDL_QUIT event. - * "1" - SDL will not install a signal handler at all. - */ -#define SDL_HINT_NO_SIGNAL_HANDLERS "SDL_NO_SIGNAL_HANDLERS" - -/** - * \brief Tell SDL not to generate window-close events for Alt+F4 on Windows. - * - * The variable can be set to the following values: - * "0" - SDL will generate a window-close event when it sees Alt+F4. - * "1" - SDL will only do normal key handling for Alt+F4. - */ -#define SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 "SDL_WINDOWS_NO_CLOSE_ON_ALT_F4" - -/** - * \brief Prevent SDL from using version 4 of the bitmap header when saving BMPs. - * - * The bitmap header version 4 is required for proper alpha channel support and - * SDL will use it when required. Should this not be desired, this hint can - * force the use of the 40 byte header version which is supported everywhere. - * - * The variable can be set to the following values: - * "0" - Surfaces with a colorkey or an alpha channel are saved to a - * 32-bit BMP file with an alpha mask. SDL will use the bitmap - * header version 4 and set the alpha mask accordingly. - * "1" - Surfaces with a colorkey or an alpha channel are saved to a - * 32-bit BMP file without an alpha mask. The alpha channel data - * will be in the file, but applications are going to ignore it. - * - * The default value is "0". - */ -#define SDL_HINT_BMP_SAVE_LEGACY_FORMAT "SDL_BMP_SAVE_LEGACY_FORMAT" - -/** - * \brief Tell SDL not to name threads on Windows with the 0x406D1388 Exception. - * The 0x406D1388 Exception is a trick used to inform Visual Studio of a - * thread's name, but it tends to cause problems with other debuggers, - * and the .NET runtime. Note that SDL 2.0.6 and later will still use - * the (safer) SetThreadDescription API, introduced in the Windows 10 - * Creators Update, if available. - * - * The variable can be set to the following values: - * "0" - SDL will raise the 0x406D1388 Exception to name threads. - * This is the default behavior of SDL <= 2.0.4. - * "1" - SDL will not raise this exception, and threads will be unnamed. (default) - * This is necessary with .NET languages or debuggers that aren't Visual Studio. - */ -#define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING "SDL_WINDOWS_DISABLE_THREAD_NAMING" - -/** - * \brief Tell SDL which Dispmanx layer to use on a Raspberry PI - * - * Also known as Z-order. The variable can take a negative or positive value. - * The default is 10000. - */ -#define SDL_HINT_RPI_VIDEO_LAYER "SDL_RPI_VIDEO_LAYER" - -/** - * \brief Tell the video driver that we only want a double buffer. - * - * By default, most lowlevel 2D APIs will use a triple buffer scheme that - * wastes no CPU time on waiting for vsync after issuing a flip, but - * introduces a frame of latency. On the other hand, using a double buffer - * scheme instead is recommended for cases where low latency is an important - * factor because we save a whole frame of latency. - * We do so by waiting for vsync immediately after issuing a flip, usually just - * after eglSwapBuffers call in the backend's *_SwapWindow function. - * - * Since it's driver-specific, it's only supported where possible and - * implemented. Currently supported the following drivers: - * - KMSDRM (kmsdrm) - * - Raspberry Pi (raspberrypi) - */ -#define SDL_HINT_VIDEO_DOUBLE_BUFFER "SDL_VIDEO_DOUBLE_BUFFER" - -/** - * \brief A variable controlling what driver to use for OpenGL ES contexts. - * - * On some platforms, currently Windows and X11, OpenGL drivers may support - * creating contexts with an OpenGL ES profile. By default SDL uses these - * profiles, when available, otherwise it attempts to load an OpenGL ES - * library, e.g. that provided by the ANGLE project. This variable controls - * whether SDL follows this default behaviour or will always load an - * OpenGL ES library. - * - * Circumstances where this is useful include - * - Testing an app with a particular OpenGL ES implementation, e.g ANGLE, - * or emulator, e.g. those from ARM, Imagination or Qualcomm. - * - Resolving OpenGL ES function addresses at link time by linking with - * the OpenGL ES library instead of querying them at run time with - * SDL_GL_GetProcAddress(). - * - * Caution: for an application to work with the default behaviour across - * different OpenGL drivers it must query the OpenGL ES function - * addresses at run time using SDL_GL_GetProcAddress(). - * - * This variable is ignored on most platforms because OpenGL ES is native - * or not supported. - * - * This variable can be set to the following values: - * "0" - Use ES profile of OpenGL, if available. (Default when not set.) - * "1" - Load OpenGL ES library using the default library names. - * - */ -#define SDL_HINT_OPENGL_ES_DRIVER "SDL_OPENGL_ES_DRIVER" - -/** - * \brief A variable controlling speed/quality tradeoff of audio resampling. - * - * If available, SDL can use libsamplerate ( http://www.mega-nerd.com/SRC/ ) - * to handle audio resampling. There are different resampling modes available - * that produce different levels of quality, using more CPU. - * - * If this hint isn't specified to a valid setting, or libsamplerate isn't - * available, SDL will use the default, internal resampling algorithm. - * - * Note that this is currently only applicable to resampling audio that is - * being written to a device for playback or audio being read from a device - * for capture. SDL_AudioCVT always uses the default resampler (although this - * might change for SDL 2.1). - * - * This hint is currently only checked at audio subsystem initialization. - * - * This variable can be set to the following values: - * - * "0" or "default" - Use SDL's internal resampling (Default when not set - low quality, fast) - * "1" or "fast" - Use fast, slightly higher quality resampling, if available - * "2" or "medium" - Use medium quality resampling, if available - * "3" or "best" - Use high quality resampling, if available - */ -#define SDL_HINT_AUDIO_RESAMPLING_MODE "SDL_AUDIO_RESAMPLING_MODE" - -/** - * \brief A variable controlling the audio category on iOS and Mac OS X - * - * This variable can be set to the following values: - * - * "ambient" - Use the AVAudioSessionCategoryAmbient audio category, will be muted by the phone mute switch (default) - * "playback" - Use the AVAudioSessionCategoryPlayback category - * - * For more information, see Apple's documentation: - * https://developer.apple.com/library/content/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionCategoriesandModes/AudioSessionCategoriesandModes.html - */ -#define SDL_HINT_AUDIO_CATEGORY "SDL_AUDIO_CATEGORY" - -/** - * \brief A variable controlling whether the 2D render API is compatible or efficient. - * - * This variable can be set to the following values: - * - * "0" - Don't use batching to make rendering more efficient. - * "1" - Use batching, but might cause problems if app makes its own direct OpenGL calls. - * - * Up to SDL 2.0.9, the render API would draw immediately when requested. Now - * it batches up draw requests and sends them all to the GPU only when forced - * to (during SDL_RenderPresent, when changing render targets, by updating a - * texture that the batch needs, etc). This is significantly more efficient, - * but it can cause problems for apps that expect to render on top of the - * render API's output. As such, SDL will disable batching if a specific - * render backend is requested (since this might indicate that the app is - * planning to use the underlying graphics API directly). This hint can - * be used to explicitly request batching in this instance. It is a contract - * that you will either never use the underlying graphics API directly, or - * if you do, you will call SDL_RenderFlush() before you do so any current - * batch goes to the GPU before your work begins. Not following this contract - * will result in undefined behavior. - */ -#define SDL_HINT_RENDER_BATCHING "SDL_RENDER_BATCHING" - - -/** - * \brief A variable controlling whether SDL logs all events pushed onto its internal queue. - * - * This variable can be set to the following values: - * - * "0" - Don't log any events (default) - * "1" - Log all events except mouse and finger motion, which are pretty spammy. - * "2" - Log all events. - * - * This is generally meant to be used to debug SDL itself, but can be useful - * for application developers that need better visibility into what is going - * on in the event queue. Logged events are sent through SDL_Log(), which - * means by default they appear on stdout on most platforms or maybe - * OutputDebugString() on Windows, and can be funneled by the app with - * SDL_LogSetOutputFunction(), etc. - * - * This hint can be toggled on and off at runtime, if you only need to log - * events for a small subset of program execution. - */ -#define SDL_HINT_EVENT_LOGGING "SDL_EVENT_LOGGING" - - - -/** - * \brief Controls how the size of the RIFF chunk affects the loading of a WAVE file. - * - * The size of the RIFF chunk (which includes all the sub-chunks of the WAVE - * file) is not always reliable. In case the size is wrong, it's possible to - * just ignore it and step through the chunks until a fixed limit is reached. - * - * Note that files that have trailing data unrelated to the WAVE file or - * corrupt files may slow down the loading process without a reliable boundary. - * By default, SDL stops after 10000 chunks to prevent wasting time. Use the - * environment variable SDL_WAVE_CHUNK_LIMIT to adjust this value. - * - * This variable can be set to the following values: - * - * "force" - Always use the RIFF chunk size as a boundary for the chunk search - * "ignorezero" - Like "force", but a zero size searches up to 4 GiB (default) - * "ignore" - Ignore the RIFF chunk size and always search up to 4 GiB - * "maximum" - Search for chunks until the end of file (not recommended) - */ -#define SDL_HINT_WAVE_RIFF_CHUNK_SIZE "SDL_WAVE_RIFF_CHUNK_SIZE" - -/** - * \brief Controls how a truncated WAVE file is handled. - * - * A WAVE file is considered truncated if any of the chunks are incomplete or - * the data chunk size is not a multiple of the block size. By default, SDL - * decodes until the first incomplete block, as most applications seem to do. - * - * This variable can be set to the following values: - * - * "verystrict" - Raise an error if the file is truncated - * "strict" - Like "verystrict", but the size of the RIFF chunk is ignored - * "dropframe" - Decode until the first incomplete sample frame - * "dropblock" - Decode until the first incomplete block (default) - */ -#define SDL_HINT_WAVE_TRUNCATION "SDL_WAVE_TRUNCATION" - -/** - * \brief Controls how the fact chunk affects the loading of a WAVE file. - * - * The fact chunk stores information about the number of samples of a WAVE - * file. The Standards Update from Microsoft notes that this value can be used - * to 'determine the length of the data in seconds'. This is especially useful - * for compressed formats (for which this is a mandatory chunk) if they produce - * multiple sample frames per block and truncating the block is not allowed. - * The fact chunk can exactly specify how many sample frames there should be - * in this case. - * - * Unfortunately, most application seem to ignore the fact chunk and so SDL - * ignores it by default as well. - * - * This variable can be set to the following values: - * - * "truncate" - Use the number of samples to truncate the wave data if - * the fact chunk is present and valid - * "strict" - Like "truncate", but raise an error if the fact chunk - * is invalid, not present for non-PCM formats, or if the - * data chunk doesn't have that many samples - * "ignorezero" - Like "truncate", but ignore fact chunk if the number of - * samples is zero - * "ignore" - Ignore fact chunk entirely (default) - */ -#define SDL_HINT_WAVE_FACT_CHUNK "SDL_WAVE_FACT_CHUNK" - -/* - * \brief Override for SDL_GetDisplayUsableBounds() - * - * If set, this hint will override the expected results for - * SDL_GetDisplayUsableBounds() for display index 0. Generally you don't want - * to do this, but this allows an embedded system to request that some of the - * screen be reserved for other uses when paired with a well-behaved - * application. - * - * The contents of this hint must be 4 comma-separated integers, the first - * is the bounds x, then y, width and height, in that order. - */ -#define SDL_HINT_DISPLAY_USABLE_BOUNDS "SDL_DISPLAY_USABLE_BOUNDS" - -/** - * \brief An enumeration of hint priorities - */ -typedef enum -{ - SDL_HINT_DEFAULT, - SDL_HINT_NORMAL, - SDL_HINT_OVERRIDE -} SDL_HintPriority; - - -/** - * \brief Set a hint with a specific priority - * - * The priority controls the behavior when setting a hint that already - * has a value. Hints will replace existing hints of their priority and - * lower. Environment variables are considered to have override priority. - * - * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise - */ -extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name, - const char *value, - SDL_HintPriority priority); - -/** - * \brief Set a hint with normal priority - * - * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise - */ -extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, - const char *value); - -/** - * \brief Get a hint - * - * \return The string value of a hint variable. - */ -extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); - -/** - * \brief Get a hint - * - * \return The boolean value of a hint variable. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_GetHintBoolean(const char *name, SDL_bool default_value); - -/** - * \brief type definition of the hint callback function. - */ -typedef void (SDLCALL *SDL_HintCallback)(void *userdata, const char *name, const char *oldValue, const char *newValue); - -/** - * \brief Add a function to watch a particular hint - * - * \param name The hint to watch - * \param callback The function to call when the hint value changes - * \param userdata A pointer to pass to the callback function - */ -extern DECLSPEC void SDLCALL SDL_AddHintCallback(const char *name, - SDL_HintCallback callback, - void *userdata); - -/** - * \brief Remove a function watching a particular hint - * - * \param name The hint being watched - * \param callback The function being called when the hint value changes - * \param userdata A pointer being passed to the callback function - */ -extern DECLSPEC void SDLCALL SDL_DelHintCallback(const char *name, - SDL_HintCallback callback, - void *userdata); - -/** - * \brief Clear all hints - * - * This function is called during SDL_Quit() to free stored hints. - */ -extern DECLSPEC void SDLCALL SDL_ClearHints(void); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_hints_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_joystick.h b/thirdparty/include/SDL2/SDL_joystick.h deleted file mode 100644 index a0dd7205d..000000000 --- a/thirdparty/include/SDL2/SDL_joystick.h +++ /dev/null @@ -1,418 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_joystick.h - * - * Include file for SDL joystick event handling - * - * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks(), with the exact joystick - * behind a device_index changing as joysticks are plugged and unplugged. - * - * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted - * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in. - * - * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of - * the device (a X360 wired controller for example). This identifier is platform dependent. - * - * - */ - -#ifndef SDL_joystick_h_ -#define SDL_joystick_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \file SDL_joystick.h - * - * In order to use these functions, SDL_Init() must have been called - * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system - * for joysticks, and load appropriate drivers. - * - * If you would like to receive joystick updates while the application - * is in the background, you should set the following hint before calling - * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS - */ - -/** - * The joystick structure used to identify an SDL joystick - */ -struct _SDL_Joystick; -typedef struct _SDL_Joystick SDL_Joystick; - -/* A structure that encodes the stable unique id for a joystick device */ -typedef struct { - Uint8 data[16]; -} SDL_JoystickGUID; - -/** - * This is a unique ID for a joystick for the time it is connected to the system, - * and is never reused for the lifetime of the application. If the joystick is - * disconnected and reconnected, it will get a new ID. - * - * The ID value starts at 0 and increments from there. The value -1 is an invalid ID. - */ -typedef Sint32 SDL_JoystickID; - -typedef enum -{ - SDL_JOYSTICK_TYPE_UNKNOWN, - SDL_JOYSTICK_TYPE_GAMECONTROLLER, - SDL_JOYSTICK_TYPE_WHEEL, - SDL_JOYSTICK_TYPE_ARCADE_STICK, - SDL_JOYSTICK_TYPE_FLIGHT_STICK, - SDL_JOYSTICK_TYPE_DANCE_PAD, - SDL_JOYSTICK_TYPE_GUITAR, - SDL_JOYSTICK_TYPE_DRUM_KIT, - SDL_JOYSTICK_TYPE_ARCADE_PAD, - SDL_JOYSTICK_TYPE_THROTTLE -} SDL_JoystickType; - -typedef enum -{ - SDL_JOYSTICK_POWER_UNKNOWN = -1, - SDL_JOYSTICK_POWER_EMPTY, /* <= 5% */ - SDL_JOYSTICK_POWER_LOW, /* <= 20% */ - SDL_JOYSTICK_POWER_MEDIUM, /* <= 70% */ - SDL_JOYSTICK_POWER_FULL, /* <= 100% */ - SDL_JOYSTICK_POWER_WIRED, - SDL_JOYSTICK_POWER_MAX -} SDL_JoystickPowerLevel; - -/* Function prototypes */ - -/** - * Locking for multi-threaded access to the joystick API - * - * If you are using the joystick API or handling events from multiple threads - * you should use these locking functions to protect access to the joysticks. - * - * In particular, you are guaranteed that the joystick list won't change, so - * the API functions that take a joystick index will be valid, and joystick - * and game controller events will not be delivered. - */ -extern DECLSPEC void SDLCALL SDL_LockJoysticks(void); -extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void); - -/** - * Count the number of joysticks attached to the system right now - */ -extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); - -/** - * Get the implementation dependent name of a joystick. - * This can be called before any joysticks are opened. - * If no name can be found, this function returns NULL. - */ -extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index); - -/** - * Get the player index of a joystick, or -1 if it's not available - * This can be called before any joysticks are opened. - */ -extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index); - -/** - * Return the GUID for the joystick at this index - * This can be called before any joysticks are opened. - */ -extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index); - -/** - * Get the USB vendor ID of a joystick, if available. - * This can be called before any joysticks are opened. - * If the vendor ID isn't available this function returns 0. - */ -extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index); - -/** - * Get the USB product ID of a joystick, if available. - * This can be called before any joysticks are opened. - * If the product ID isn't available this function returns 0. - */ -extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index); - -/** - * Get the product version of a joystick, if available. - * This can be called before any joysticks are opened. - * If the product version isn't available this function returns 0. - */ -extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_index); - -/** - * Get the type of a joystick, if available. - * This can be called before any joysticks are opened. - */ -extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_index); - -/** - * Get the instance ID of a joystick. - * This can be called before any joysticks are opened. - * If the index is out of range, this function will return -1. - */ -extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickGetDeviceInstanceID(int device_index); - -/** - * Open a joystick for use. - * The index passed as an argument refers to the N'th joystick on the system. - * This index is not the value which will identify this joystick in future - * joystick events. The joystick's instance id (::SDL_JoystickID) will be used - * there instead. - * - * \return A joystick identifier, or NULL if an error occurred. - */ -extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index); - -/** - * Return the SDL_Joystick associated with an instance id. - */ -extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID instance_id); - -/** - * Return the SDL_Joystick associated with a player index. - */ -extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromPlayerIndex(int player_index); - -/** - * Return the name for this currently opened joystick. - * If no name can be found, this function returns NULL. - */ -extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick); - -/** - * Get the player index of an opened joystick, or -1 if it's not available - * - * For XInput controllers this returns the XInput user index. - */ -extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick * joystick); - -/** - * Set the player index of an opened joystick - */ -extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick * joystick, int player_index); - -/** - * Return the GUID for this opened joystick - */ -extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick); - -/** - * Get the USB vendor ID of an opened joystick, if available. - * If the vendor ID isn't available this function returns 0. - */ -extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick * joystick); - -/** - * Get the USB product ID of an opened joystick, if available. - * If the product ID isn't available this function returns 0. - */ -extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick * joystick); - -/** - * Get the product version of an opened joystick, if available. - * If the product version isn't available this function returns 0. - */ -extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick * joystick); - -/** - * Get the type of an opened joystick. - */ -extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick * joystick); - -/** - * Return a string representation for this guid. pszGUID must point to at least 33 bytes - * (32 for the string plus a NULL terminator). - */ -extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID); - -/** - * Convert a string into a joystick guid - */ -extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID); - -/** - * Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick); - -/** - * Get the instance ID of an opened joystick or -1 if the joystick is invalid. - */ -extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick); - -/** - * Get the number of general axis controls on a joystick. - */ -extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick); - -/** - * Get the number of trackballs on a joystick. - * - * Joystick trackballs have only relative motion events associated - * with them and their state cannot be polled. - */ -extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick); - -/** - * Get the number of POV hats on a joystick. - */ -extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick); - -/** - * Get the number of buttons on a joystick. - */ -extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick); - -/** - * Update the current state of the open joysticks. - * - * This is called automatically by the event loop if any joystick - * events are enabled. - */ -extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); - -/** - * Enable/disable joystick event polling. - * - * If joystick events are disabled, you must call SDL_JoystickUpdate() - * yourself and check the state of the joystick when you want joystick - * information. - * - * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. - */ -extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); - -#define SDL_JOYSTICK_AXIS_MAX 32767 -#define SDL_JOYSTICK_AXIS_MIN -32768 -/** - * Get the current state of an axis control on a joystick. - * - * The state is a value ranging from -32768 to 32767. - * - * The axis indices start at index 0. - */ -extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, - int axis); - -/** - * Get the initial state of an axis control on a joystick. - * - * The state is a value ranging from -32768 to 32767. - * - * The axis indices start at index 0. - * - * \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick * joystick, - int axis, Sint16 *state); - -/** - * \name Hat positions - */ -/* @{ */ -#define SDL_HAT_CENTERED 0x00 -#define SDL_HAT_UP 0x01 -#define SDL_HAT_RIGHT 0x02 -#define SDL_HAT_DOWN 0x04 -#define SDL_HAT_LEFT 0x08 -#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) -#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) -#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) -#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) -/* @} */ - -/** - * Get the current state of a POV hat on a joystick. - * - * The hat indices start at index 0. - * - * \return The return value is one of the following positions: - * - ::SDL_HAT_CENTERED - * - ::SDL_HAT_UP - * - ::SDL_HAT_RIGHT - * - ::SDL_HAT_DOWN - * - ::SDL_HAT_LEFT - * - ::SDL_HAT_RIGHTUP - * - ::SDL_HAT_RIGHTDOWN - * - ::SDL_HAT_LEFTUP - * - ::SDL_HAT_LEFTDOWN - */ -extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick, - int hat); - -/** - * Get the ball axis change since the last poll. - * - * \return 0, or -1 if you passed it invalid parameters. - * - * The ball indices start at index 0. - */ -extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick, - int ball, int *dx, int *dy); - -/** - * Get the current state of a button on a joystick. - * - * The button indices start at index 0. - */ -extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick, - int button); - -/** - * Trigger a rumble effect - * Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling. - * - * \param joystick The joystick to vibrate - * \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF - * \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF - * \param duration_ms The duration of the rumble effect, in milliseconds - * - * \return 0, or -1 if rumble isn't supported on this joystick - */ -extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); - -/** - * Close a joystick previously opened with SDL_JoystickOpen(). - */ -extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick); - -/** - * Return the battery level of this joystick - */ -extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick * joystick); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_joystick_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_keyboard.h b/thirdparty/include/SDL2/SDL_keyboard.h deleted file mode 100644 index f6853c647..000000000 --- a/thirdparty/include/SDL2/SDL_keyboard.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_keyboard.h - * - * Include file for SDL keyboard event handling - */ - -#ifndef SDL_keyboard_h_ -#define SDL_keyboard_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_keycode.h" -#include "SDL_video.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief The SDL keysym structure, used in key events. - * - * \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event. - */ -typedef struct SDL_Keysym -{ - SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */ - SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */ - Uint16 mod; /**< current key modifiers */ - Uint32 unused; -} SDL_Keysym; - -/* Function prototypes */ - -/** - * \brief Get the window which currently has keyboard focus. - */ -extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); - -/** - * \brief Get a snapshot of the current state of the keyboard. - * - * \param numkeys if non-NULL, receives the length of the returned array. - * - * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values. - * - * \b Example: - * \code - * const Uint8 *state = SDL_GetKeyboardState(NULL); - * if ( state[SDL_SCANCODE_RETURN] ) { - * printf(" is pressed.\n"); - * } - * \endcode - */ -extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); - -/** - * \brief Get the current key modifier state for the keyboard. - */ -extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); - -/** - * \brief Set the current key modifier state for the keyboard. - * - * \note This does not change the keyboard state, only the key modifier flags. - */ -extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); - -/** - * \brief Get the key code corresponding to the given scancode according - * to the current keyboard layout. - * - * See ::SDL_Keycode for details. - * - * \sa SDL_GetKeyName() - */ -extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode); - -/** - * \brief Get the scancode corresponding to the given key code according to the - * current keyboard layout. - * - * See ::SDL_Scancode for details. - * - * \sa SDL_GetScancodeName() - */ -extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key); - -/** - * \brief Get a human-readable name for a scancode. - * - * \return A pointer to the name for the scancode. - * If the scancode doesn't have a name, this function returns - * an empty string (""). - * - * \sa SDL_Scancode - */ -extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); - -/** - * \brief Get a scancode from a human-readable name - * - * \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized - * - * \sa SDL_Scancode - */ -extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); - -/** - * \brief Get a human-readable name for a key. - * - * \return A pointer to a UTF-8 string that stays valid at least until the next - * call to this function. If you need it around any longer, you must - * copy it. If the key doesn't have a name, this function returns an - * empty string (""). - * - * \sa SDL_Keycode - */ -extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key); - -/** - * \brief Get a key code from a human-readable name - * - * \return key code, or SDLK_UNKNOWN if the name wasn't recognized - * - * \sa SDL_Keycode - */ -extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); - -/** - * \brief Start accepting Unicode text input events. - * This function will show the on-screen keyboard if supported. - * - * \sa SDL_StopTextInput() - * \sa SDL_SetTextInputRect() - * \sa SDL_HasScreenKeyboardSupport() - */ -extern DECLSPEC void SDLCALL SDL_StartTextInput(void); - -/** - * \brief Return whether or not Unicode text input events are enabled. - * - * \sa SDL_StartTextInput() - * \sa SDL_StopTextInput() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void); - -/** - * \brief Stop receiving any text input events. - * This function will hide the on-screen keyboard if supported. - * - * \sa SDL_StartTextInput() - * \sa SDL_HasScreenKeyboardSupport() - */ -extern DECLSPEC void SDLCALL SDL_StopTextInput(void); - -/** - * \brief Set the rectangle used to type Unicode text inputs. - * This is used as a hint for IME and on-screen keyboard placement. - * - * \sa SDL_StartTextInput() - */ -extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); - -/** - * \brief Returns whether the platform has some screen keyboard support. - * - * \return SDL_TRUE if some keyboard support is available else SDL_FALSE. - * - * \note Not all screen keyboard functions are supported on all platforms. - * - * \sa SDL_IsScreenKeyboardShown() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void); - -/** - * \brief Returns whether the screen keyboard is shown for given window. - * - * \param window The window for which screen keyboard should be queried. - * - * \return SDL_TRUE if screen keyboard is shown else SDL_FALSE. - * - * \sa SDL_HasScreenKeyboardSupport() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_keyboard_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_keycode.h b/thirdparty/include/SDL2/SDL_keycode.h deleted file mode 100644 index a1ce7a44d..000000000 --- a/thirdparty/include/SDL2/SDL_keycode.h +++ /dev/null @@ -1,349 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_keycode.h - * - * Defines constants which identify keyboard keys and modifiers. - */ - -#ifndef SDL_keycode_h_ -#define SDL_keycode_h_ - -#include "SDL_stdinc.h" -#include "SDL_scancode.h" - -/** - * \brief The SDL virtual key representation. - * - * Values of this type are used to represent keyboard keys using the current - * layout of the keyboard. These values include Unicode values representing - * the unmodified character that would be generated by pressing the key, or - * an SDLK_* constant for those keys that do not generate characters. - * - * A special exception is the number keys at the top of the keyboard which - * always map to SDLK_0...SDLK_9, regardless of layout. - */ -typedef Sint32 SDL_Keycode; - -#define SDLK_SCANCODE_MASK (1<<30) -#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK) - -typedef enum -{ - SDLK_UNKNOWN = 0, - - SDLK_RETURN = '\r', - SDLK_ESCAPE = '\033', - SDLK_BACKSPACE = '\b', - SDLK_TAB = '\t', - SDLK_SPACE = ' ', - SDLK_EXCLAIM = '!', - SDLK_QUOTEDBL = '"', - SDLK_HASH = '#', - SDLK_PERCENT = '%', - SDLK_DOLLAR = '$', - SDLK_AMPERSAND = '&', - SDLK_QUOTE = '\'', - SDLK_LEFTPAREN = '(', - SDLK_RIGHTPAREN = ')', - SDLK_ASTERISK = '*', - SDLK_PLUS = '+', - SDLK_COMMA = ',', - SDLK_MINUS = '-', - SDLK_PERIOD = '.', - SDLK_SLASH = '/', - SDLK_0 = '0', - SDLK_1 = '1', - SDLK_2 = '2', - SDLK_3 = '3', - SDLK_4 = '4', - SDLK_5 = '5', - SDLK_6 = '6', - SDLK_7 = '7', - SDLK_8 = '8', - SDLK_9 = '9', - SDLK_COLON = ':', - SDLK_SEMICOLON = ';', - SDLK_LESS = '<', - SDLK_EQUALS = '=', - SDLK_GREATER = '>', - SDLK_QUESTION = '?', - SDLK_AT = '@', - /* - Skip uppercase letters - */ - SDLK_LEFTBRACKET = '[', - SDLK_BACKSLASH = '\\', - SDLK_RIGHTBRACKET = ']', - SDLK_CARET = '^', - SDLK_UNDERSCORE = '_', - SDLK_BACKQUOTE = '`', - SDLK_a = 'a', - SDLK_b = 'b', - SDLK_c = 'c', - SDLK_d = 'd', - SDLK_e = 'e', - SDLK_f = 'f', - SDLK_g = 'g', - SDLK_h = 'h', - SDLK_i = 'i', - SDLK_j = 'j', - SDLK_k = 'k', - SDLK_l = 'l', - SDLK_m = 'm', - SDLK_n = 'n', - SDLK_o = 'o', - SDLK_p = 'p', - SDLK_q = 'q', - SDLK_r = 'r', - SDLK_s = 's', - SDLK_t = 't', - SDLK_u = 'u', - SDLK_v = 'v', - SDLK_w = 'w', - SDLK_x = 'x', - SDLK_y = 'y', - SDLK_z = 'z', - - SDLK_CAPSLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK), - - SDLK_F1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F1), - SDLK_F2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F2), - SDLK_F3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F3), - SDLK_F4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4), - SDLK_F5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F5), - SDLK_F6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F6), - SDLK_F7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F7), - SDLK_F8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F8), - SDLK_F9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F9), - SDLK_F10 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F10), - SDLK_F11 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F11), - SDLK_F12 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F12), - - SDLK_PRINTSCREEN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRINTSCREEN), - SDLK_SCROLLLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SCROLLLOCK), - SDLK_PAUSE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAUSE), - SDLK_INSERT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT), - SDLK_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME), - SDLK_PAGEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP), - SDLK_DELETE = '\177', - SDLK_END = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END), - SDLK_PAGEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN), - SDLK_RIGHT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT), - SDLK_LEFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LEFT), - SDLK_DOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DOWN), - SDLK_UP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UP), - - SDLK_NUMLOCKCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_NUMLOCKCLEAR), - SDLK_KP_DIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DIVIDE), - SDLK_KP_MULTIPLY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MULTIPLY), - SDLK_KP_MINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MINUS), - SDLK_KP_PLUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUS), - SDLK_KP_ENTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_ENTER), - SDLK_KP_1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_1), - SDLK_KP_2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_2), - SDLK_KP_3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_3), - SDLK_KP_4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_4), - SDLK_KP_5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_5), - SDLK_KP_6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_6), - SDLK_KP_7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_7), - SDLK_KP_8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_8), - SDLK_KP_9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_9), - SDLK_KP_0 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_0), - SDLK_KP_PERIOD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERIOD), - - SDLK_APPLICATION = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APPLICATION), - SDLK_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_POWER), - SDLK_KP_EQUALS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALS), - SDLK_F13 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F13), - SDLK_F14 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F14), - SDLK_F15 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F15), - SDLK_F16 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F16), - SDLK_F17 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F17), - SDLK_F18 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F18), - SDLK_F19 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F19), - SDLK_F20 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F20), - SDLK_F21 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F21), - SDLK_F22 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F22), - SDLK_F23 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F23), - SDLK_F24 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F24), - SDLK_EXECUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXECUTE), - SDLK_HELP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HELP), - SDLK_MENU = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MENU), - SDLK_SELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SELECT), - SDLK_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_STOP), - SDLK_AGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AGAIN), - SDLK_UNDO = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UNDO), - SDLK_CUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CUT), - SDLK_COPY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COPY), - SDLK_PASTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PASTE), - SDLK_FIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FIND), - SDLK_MUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MUTE), - SDLK_VOLUMEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEUP), - SDLK_VOLUMEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEDOWN), - SDLK_KP_COMMA = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COMMA), - SDLK_KP_EQUALSAS400 = - SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALSAS400), - - SDLK_ALTERASE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ALTERASE), - SDLK_SYSREQ = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SYSREQ), - SDLK_CANCEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CANCEL), - SDLK_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEAR), - SDLK_PRIOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRIOR), - SDLK_RETURN2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN2), - SDLK_SEPARATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SEPARATOR), - SDLK_OUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OUT), - SDLK_OPER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OPER), - SDLK_CLEARAGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN), - SDLK_CRSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL), - SDLK_EXSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL), - - SDLK_KP_00 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00), - SDLK_KP_000 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000), - SDLK_THOUSANDSSEPARATOR = - SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR), - SDLK_DECIMALSEPARATOR = - SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DECIMALSEPARATOR), - SDLK_CURRENCYUNIT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYUNIT), - SDLK_CURRENCYSUBUNIT = - SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYSUBUNIT), - SDLK_KP_LEFTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTPAREN), - SDLK_KP_RIGHTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTPAREN), - SDLK_KP_LEFTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTBRACE), - SDLK_KP_RIGHTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTBRACE), - SDLK_KP_TAB = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_TAB), - SDLK_KP_BACKSPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BACKSPACE), - SDLK_KP_A = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_A), - SDLK_KP_B = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_B), - SDLK_KP_C = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_C), - SDLK_KP_D = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_D), - SDLK_KP_E = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_E), - SDLK_KP_F = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_F), - SDLK_KP_XOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_XOR), - SDLK_KP_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_POWER), - SDLK_KP_PERCENT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERCENT), - SDLK_KP_LESS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LESS), - SDLK_KP_GREATER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_GREATER), - SDLK_KP_AMPERSAND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AMPERSAND), - SDLK_KP_DBLAMPERSAND = - SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLAMPERSAND), - SDLK_KP_VERTICALBAR = - SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_VERTICALBAR), - SDLK_KP_DBLVERTICALBAR = - SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLVERTICALBAR), - SDLK_KP_COLON = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COLON), - SDLK_KP_HASH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HASH), - SDLK_KP_SPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_SPACE), - SDLK_KP_AT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AT), - SDLK_KP_EXCLAM = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EXCLAM), - SDLK_KP_MEMSTORE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSTORE), - SDLK_KP_MEMRECALL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMRECALL), - SDLK_KP_MEMCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMCLEAR), - SDLK_KP_MEMADD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMADD), - SDLK_KP_MEMSUBTRACT = - SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSUBTRACT), - SDLK_KP_MEMMULTIPLY = - SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMMULTIPLY), - SDLK_KP_MEMDIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMDIVIDE), - SDLK_KP_PLUSMINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUSMINUS), - SDLK_KP_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEAR), - SDLK_KP_CLEARENTRY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEARENTRY), - SDLK_KP_BINARY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BINARY), - SDLK_KP_OCTAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_OCTAL), - SDLK_KP_DECIMAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DECIMAL), - SDLK_KP_HEXADECIMAL = - SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HEXADECIMAL), - - SDLK_LCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LCTRL), - SDLK_LSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LSHIFT), - SDLK_LALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LALT), - SDLK_LGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LGUI), - SDLK_RCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RCTRL), - SDLK_RSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RSHIFT), - SDLK_RALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RALT), - SDLK_RGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RGUI), - - SDLK_MODE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MODE), - - SDLK_AUDIONEXT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIONEXT), - SDLK_AUDIOPREV = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPREV), - SDLK_AUDIOSTOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOSTOP), - SDLK_AUDIOPLAY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPLAY), - SDLK_AUDIOMUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOMUTE), - SDLK_MEDIASELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIASELECT), - SDLK_WWW = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_WWW), - SDLK_MAIL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MAIL), - SDLK_CALCULATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALCULATOR), - SDLK_COMPUTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COMPUTER), - SDLK_AC_SEARCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SEARCH), - SDLK_AC_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_HOME), - SDLK_AC_BACK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BACK), - SDLK_AC_FORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_FORWARD), - SDLK_AC_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_STOP), - SDLK_AC_REFRESH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_REFRESH), - SDLK_AC_BOOKMARKS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BOOKMARKS), - - SDLK_BRIGHTNESSDOWN = - SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSDOWN), - SDLK_BRIGHTNESSUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSUP), - SDLK_DISPLAYSWITCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DISPLAYSWITCH), - SDLK_KBDILLUMTOGGLE = - SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMTOGGLE), - SDLK_KBDILLUMDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMDOWN), - SDLK_KBDILLUMUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMUP), - SDLK_EJECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EJECT), - SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP), - SDLK_APP1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APP1), - SDLK_APP2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APP2), - - SDLK_AUDIOREWIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOREWIND), - SDLK_AUDIOFASTFORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOFASTFORWARD) -} SDL_KeyCode; - -/** - * \brief Enumeration of valid key mods (possibly OR'd together). - */ -typedef enum -{ - KMOD_NONE = 0x0000, - KMOD_LSHIFT = 0x0001, - KMOD_RSHIFT = 0x0002, - KMOD_LCTRL = 0x0040, - KMOD_RCTRL = 0x0080, - KMOD_LALT = 0x0100, - KMOD_RALT = 0x0200, - KMOD_LGUI = 0x0400, - KMOD_RGUI = 0x0800, - KMOD_NUM = 0x1000, - KMOD_CAPS = 0x2000, - KMOD_MODE = 0x4000, - KMOD_RESERVED = 0x8000 -} SDL_Keymod; - -#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) -#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) -#define KMOD_ALT (KMOD_LALT|KMOD_RALT) -#define KMOD_GUI (KMOD_LGUI|KMOD_RGUI) - -#endif /* SDL_keycode_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_loadso.h b/thirdparty/include/SDL2/SDL_loadso.h deleted file mode 100644 index 89578a9f6..000000000 --- a/thirdparty/include/SDL2/SDL_loadso.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_loadso.h - * - * System dependent library loading routines - * - * Some things to keep in mind: - * \li These functions only work on C function names. Other languages may - * have name mangling and intrinsic language support that varies from - * compiler to compiler. - * \li Make sure you declare your function pointers with the same calling - * convention as the actual library function. Your code will crash - * mysteriously if you do not do this. - * \li Avoid namespace collisions. If you load a symbol from the library, - * it is not defined whether or not it goes into the global symbol - * namespace for the application. If it does and it conflicts with - * symbols in your code or other shared libraries, you will not get - * the results you expect. :) - */ - -#ifndef SDL_loadso_h_ -#define SDL_loadso_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * This function dynamically loads a shared object and returns a pointer - * to the object handle (or NULL if there was an error). - * The 'sofile' parameter is a system dependent name of the object file. - */ -extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); - -/** - * Given an object handle, this function looks up the address of the - * named function in the shared object and returns it. This address - * is no longer valid after calling SDL_UnloadObject(). - */ -extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, - const char *name); - -/** - * Unload a shared object from memory. - */ -extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_loadso_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_log.h b/thirdparty/include/SDL2/SDL_log.h deleted file mode 100644 index c1751fd77..000000000 --- a/thirdparty/include/SDL2/SDL_log.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_log.h - * - * Simple log messages with categories and priorities. - * - * By default logs are quiet, but if you're debugging SDL you might want: - * - * SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN); - * - * Here's where the messages go on different platforms: - * Windows: debug output stream - * Android: log output - * Others: standard error output (stderr) - */ - -#ifndef SDL_log_h_ -#define SDL_log_h_ - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * \brief The maximum size of a log message - * - * Messages longer than the maximum size will be truncated - */ -#define SDL_MAX_LOG_MESSAGE 4096 - -/** - * \brief The predefined log categories - * - * By default the application category is enabled at the INFO level, - * the assert category is enabled at the WARN level, test is enabled - * at the VERBOSE level and all other categories are enabled at the - * CRITICAL level. - */ -typedef enum -{ - SDL_LOG_CATEGORY_APPLICATION, - SDL_LOG_CATEGORY_ERROR, - SDL_LOG_CATEGORY_ASSERT, - SDL_LOG_CATEGORY_SYSTEM, - SDL_LOG_CATEGORY_AUDIO, - SDL_LOG_CATEGORY_VIDEO, - SDL_LOG_CATEGORY_RENDER, - SDL_LOG_CATEGORY_INPUT, - SDL_LOG_CATEGORY_TEST, - - /* Reserved for future SDL library use */ - SDL_LOG_CATEGORY_RESERVED1, - SDL_LOG_CATEGORY_RESERVED2, - SDL_LOG_CATEGORY_RESERVED3, - SDL_LOG_CATEGORY_RESERVED4, - SDL_LOG_CATEGORY_RESERVED5, - SDL_LOG_CATEGORY_RESERVED6, - SDL_LOG_CATEGORY_RESERVED7, - SDL_LOG_CATEGORY_RESERVED8, - SDL_LOG_CATEGORY_RESERVED9, - SDL_LOG_CATEGORY_RESERVED10, - - /* Beyond this point is reserved for application use, e.g. - enum { - MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, - MYAPP_CATEGORY_AWESOME2, - MYAPP_CATEGORY_AWESOME3, - ... - }; - */ - SDL_LOG_CATEGORY_CUSTOM -} SDL_LogCategory; - -/** - * \brief The predefined log priorities - */ -typedef enum -{ - SDL_LOG_PRIORITY_VERBOSE = 1, - SDL_LOG_PRIORITY_DEBUG, - SDL_LOG_PRIORITY_INFO, - SDL_LOG_PRIORITY_WARN, - SDL_LOG_PRIORITY_ERROR, - SDL_LOG_PRIORITY_CRITICAL, - SDL_NUM_LOG_PRIORITIES -} SDL_LogPriority; - - -/** - * \brief Set the priority of all log categories - */ -extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority); - -/** - * \brief Set the priority of a particular log category - */ -extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category, - SDL_LogPriority priority); - -/** - * \brief Get the priority of a particular log category - */ -extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category); - -/** - * \brief Reset all priorities to default. - * - * \note This is called in SDL_Quit(). - */ -extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void); - -/** - * \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO - */ -extern DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); - -/** - * \brief Log a message with SDL_LOG_PRIORITY_VERBOSE - */ -extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); - -/** - * \brief Log a message with SDL_LOG_PRIORITY_DEBUG - */ -extern DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); - -/** - * \brief Log a message with SDL_LOG_PRIORITY_INFO - */ -extern DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); - -/** - * \brief Log a message with SDL_LOG_PRIORITY_WARN - */ -extern DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); - -/** - * \brief Log a message with SDL_LOG_PRIORITY_ERROR - */ -extern DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); - -/** - * \brief Log a message with SDL_LOG_PRIORITY_CRITICAL - */ -extern DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); - -/** - * \brief Log a message with the specified category and priority. - */ -extern DECLSPEC void SDLCALL SDL_LogMessage(int category, - SDL_LogPriority priority, - SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3); - -/** - * \brief Log a message with the specified category and priority. - */ -extern DECLSPEC void SDLCALL SDL_LogMessageV(int category, - SDL_LogPriority priority, - const char *fmt, va_list ap); - -/** - * \brief The prototype for the log output function - */ -typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message); - -/** - * \brief Get the current log output function. - */ -extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata); - -/** - * \brief This function allows you to replace the default log output - * function with one of your own. - */ -extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_log_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_main.h b/thirdparty/include/SDL2/SDL_main.h deleted file mode 100644 index fcb5c17db..000000000 --- a/thirdparty/include/SDL2/SDL_main.h +++ /dev/null @@ -1,180 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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 SDL_main_h_ -#define SDL_main_h_ - -#include "SDL_stdinc.h" - -/** - * \file SDL_main.h - * - * Redefine main() on some platforms so that it is called by SDL. - */ - -#ifndef SDL_MAIN_HANDLED -#if defined(__WIN32__) -/* On Windows SDL provides WinMain(), which parses the command line and passes - the arguments to your main function. - - If you provide your own WinMain(), you may define SDL_MAIN_HANDLED - */ -#define SDL_MAIN_AVAILABLE - -#elif defined(__WINRT__) -/* On WinRT, SDL provides a main function that initializes CoreApplication, - creating an instance of IFrameworkView in the process. - - Please note that #include'ing SDL_main.h is not enough to get a main() - function working. In non-XAML apps, the file, - src/main/winrt/SDL_WinRT_main_NonXAML.cpp, or a copy of it, must be compiled - into the app itself. In XAML apps, the function, SDL_WinRTRunApp must be - called, with a pointer to the Direct3D-hosted XAML control passed in. -*/ -#define SDL_MAIN_NEEDED - -#elif defined(__IPHONEOS__) -/* On iOS SDL provides a main function that creates an application delegate - and starts the iOS application run loop. - - If you link with SDL dynamically on iOS, the main function can't be in a - shared library, so you need to link with libSDLmain.a, which includes a - stub main function that calls into the shared library to start execution. - - See src/video/uikit/SDL_uikitappdelegate.m for more details. - */ -#define SDL_MAIN_NEEDED - -#elif defined(__ANDROID__) -/* On Android SDL provides a Java class in SDLActivity.java that is the - main activity entry point. - - See docs/README-android.md for more details on extending that class. - */ -#define SDL_MAIN_NEEDED - -/* We need to export SDL_main so it can be launched from Java */ -#define SDLMAIN_DECLSPEC DECLSPEC - -#elif defined(__NACL__) -/* On NACL we use ppapi_simple to set up the application helper code, - then wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before - starting the user main function. - All user code is run in a separate thread by ppapi_simple, thus - allowing for blocking io to take place via nacl_io -*/ -#define SDL_MAIN_NEEDED - -#endif -#endif /* SDL_MAIN_HANDLED */ - -#ifndef SDLMAIN_DECLSPEC -#define SDLMAIN_DECLSPEC -#endif - -/** - * \file SDL_main.h - * - * The application's main() function must be called with C linkage, - * and should be declared like this: - * \code - * #ifdef __cplusplus - * extern "C" - * #endif - * int main(int argc, char *argv[]) - * { - * } - * \endcode - */ - -#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) -#define main SDL_main -#endif - -#include "begin_code.h" -#ifdef __cplusplus -extern "C" { -#endif - -/** - * The prototype for the application's main() function - */ -typedef int (*SDL_main_func)(int argc, char *argv[]); -extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); - - -/** - * This is called by the real SDL main function to let the rest of the - * library know that initialization was done properly. - * - * Calling this yourself without knowing what you're doing can cause - * crashes and hard to diagnose problems with your application. - */ -extern DECLSPEC void SDLCALL SDL_SetMainReady(void); - -#ifdef __WIN32__ - -/** - * This can be called to set the application class at startup - */ -extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); -extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); - -#endif /* __WIN32__ */ - - -#ifdef __WINRT__ - -/** - * \brief Initializes and launches an SDL/WinRT application. - * - * \param mainFunction The SDL app's C-style main(). - * \param reserved Reserved for future use; should be NULL - * \return 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more - * information on the failure. - */ -extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * reserved); - -#endif /* __WINRT__ */ - -#if defined(__IPHONEOS__) - -/** - * \brief Initializes and launches an SDL application. - * - * \param argc The argc parameter from the application's main() function - * \param argv The argv parameter from the application's main() function - * \param mainFunction The SDL app's C-style main(). - * \return the return value from mainFunction - */ -extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction); - -#endif /* __IPHONEOS__ */ - - -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_main_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_messagebox.h b/thirdparty/include/SDL2/SDL_messagebox.h deleted file mode 100644 index 03639ce4f..000000000 --- a/thirdparty/include/SDL2/SDL_messagebox.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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 SDL_messagebox_h_ -#define SDL_messagebox_h_ - -#include "SDL_stdinc.h" -#include "SDL_video.h" /* For SDL_Window */ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief SDL_MessageBox flags. If supported will display warning icon, etc. - */ -typedef enum -{ - SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */ - SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */ - SDL_MESSAGEBOX_INFORMATION = 0x00000040, /**< informational dialog */ - SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 0x00000080, /**< buttons placed left to right */ - SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 0x00000100 /**< buttons placed right to left */ -} SDL_MessageBoxFlags; - -/** - * \brief Flags for SDL_MessageBoxButtonData. - */ -typedef enum -{ - SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */ - SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */ -} SDL_MessageBoxButtonFlags; - -/** - * \brief Individual button data. - */ -typedef struct -{ - Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */ - int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */ - const char * text; /**< The UTF-8 button text */ -} SDL_MessageBoxButtonData; - -/** - * \brief RGB value used in a message box color scheme - */ -typedef struct -{ - Uint8 r, g, b; -} SDL_MessageBoxColor; - -typedef enum -{ - SDL_MESSAGEBOX_COLOR_BACKGROUND, - SDL_MESSAGEBOX_COLOR_TEXT, - SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, - SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, - SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, - SDL_MESSAGEBOX_COLOR_MAX -} SDL_MessageBoxColorType; - -/** - * \brief A set of colors to use for message box dialogs - */ -typedef struct -{ - SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX]; -} SDL_MessageBoxColorScheme; - -/** - * \brief MessageBox structure containing title, text, window, etc. - */ -typedef struct -{ - Uint32 flags; /**< ::SDL_MessageBoxFlags */ - SDL_Window *window; /**< Parent window, can be NULL */ - const char *title; /**< UTF-8 title */ - const char *message; /**< UTF-8 message text */ - - int numbuttons; - const SDL_MessageBoxButtonData *buttons; - - const SDL_MessageBoxColorScheme *colorScheme; /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */ -} SDL_MessageBoxData; - -/** - * \brief Create a modal message box. - * - * \param messageboxdata The SDL_MessageBoxData structure with title, text, etc. - * \param buttonid The pointer to which user id of hit button should be copied. - * - * \return -1 on error, otherwise 0 and buttonid contains user id of button - * hit or -1 if dialog was closed. - * - * \note This function should be called on the thread that created the parent - * window, or on the main thread if the messagebox has no parent. It will - * block execution of that thread until the user clicks a button or - * closes the messagebox. - */ -extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); - -/** - * \brief Create a simple modal message box - * - * \param flags ::SDL_MessageBoxFlags - * \param title UTF-8 title text - * \param message UTF-8 message text - * \param window The parent window, or NULL for no parent - * - * \return 0 on success, -1 on error - * - * \sa SDL_ShowMessageBox - */ -extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_messagebox_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_metal.h b/thirdparty/include/SDL2/SDL_metal.h deleted file mode 100644 index 3b7eb18aa..000000000 --- a/thirdparty/include/SDL2/SDL_metal.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_metal.h - * - * Header file for functions to creating Metal layers and views on SDL windows. - */ - -#ifndef SDL_metal_h_ -#define SDL_metal_h_ - -#include "SDL_video.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS). - * - * \note This can be cast directly to an NSView or UIView. - */ -typedef void *SDL_MetalView; - -/** - * \name Metal support functions - */ -/* @{ */ - -/** - * \brief Create a CAMetalLayer-backed NSView/UIView and attach it to the - * specified window. - * - * On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on its - * own. It is up to user code to do that. - * - * The returned handle can be casted directly to a NSView or UIView, and the - * CAMetalLayer can be accessed from the view's 'layer' property. - * - * \code - * SDL_MetalView metalview = SDL_Metal_CreateView(window); - * UIView *uiview = (__bridge UIView *)metalview; - * CAMetalLayer *metallayer = (CAMetalLayer *)uiview.layer; - * // [...] - * SDL_Metal_DestroyView(metalview); - * \endcode - * - * \sa SDL_Metal_DestroyView - */ -extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window); - -/** - * \brief Destroy an existing SDL_MetalView object. - * - * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was - * called after SDL_CreateWindow. - * - * \sa SDL_Metal_CreateView - */ -extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view); - -/* @} *//* Metal support functions */ - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_metal_h_ */ diff --git a/thirdparty/include/SDL2/SDL_mouse.h b/thirdparty/include/SDL2/SDL_mouse.h deleted file mode 100644 index 99b658e94..000000000 --- a/thirdparty/include/SDL2/SDL_mouse.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_mouse.h - * - * Include file for SDL mouse event handling. - */ - -#ifndef SDL_mouse_h_ -#define SDL_mouse_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_video.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct SDL_Cursor SDL_Cursor; /**< Implementation dependent */ - -/** - * \brief Cursor types for SDL_CreateSystemCursor(). - */ -typedef enum -{ - SDL_SYSTEM_CURSOR_ARROW, /**< Arrow */ - SDL_SYSTEM_CURSOR_IBEAM, /**< I-beam */ - SDL_SYSTEM_CURSOR_WAIT, /**< Wait */ - SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair */ - SDL_SYSTEM_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */ - SDL_SYSTEM_CURSOR_SIZENWSE, /**< Double arrow pointing northwest and southeast */ - SDL_SYSTEM_CURSOR_SIZENESW, /**< Double arrow pointing northeast and southwest */ - SDL_SYSTEM_CURSOR_SIZEWE, /**< Double arrow pointing west and east */ - SDL_SYSTEM_CURSOR_SIZENS, /**< Double arrow pointing north and south */ - SDL_SYSTEM_CURSOR_SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */ - SDL_SYSTEM_CURSOR_NO, /**< Slashed circle or crossbones */ - SDL_SYSTEM_CURSOR_HAND, /**< Hand */ - SDL_NUM_SYSTEM_CURSORS -} SDL_SystemCursor; - -/** - * \brief Scroll direction types for the Scroll event - */ -typedef enum -{ - SDL_MOUSEWHEEL_NORMAL, /**< The scroll direction is normal */ - SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */ -} SDL_MouseWheelDirection; - -/* Function prototypes */ - -/** - * \brief Get the window which currently has mouse focus. - */ -extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); - -/** - * \brief Retrieve the current state of the mouse. - * - * The current button state is returned as a button bitmask, which can - * be tested using the SDL_BUTTON(X) macros, and x and y are set to the - * mouse cursor position relative to the focus window for the currently - * selected mouse. You can pass NULL for either x or y. - */ -extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y); - -/** - * \brief Get the current state of the mouse, in relation to the desktop - * - * This works just like SDL_GetMouseState(), but the coordinates will be - * reported relative to the top-left of the desktop. This can be useful if - * you need to track the mouse outside of a specific window and - * SDL_CaptureMouse() doesn't fit your needs. For example, it could be - * useful if you need to track the mouse while dragging a window, where - * coordinates relative to a window might not be in sync at all times. - * - * \note SDL_GetMouseState() returns the mouse position as SDL understands - * it from the last pump of the event queue. This function, however, - * queries the OS for the current mouse position, and as such, might - * be a slightly less efficient function. Unless you know what you're - * doing and have a good reason to use this function, you probably want - * SDL_GetMouseState() instead. - * - * \param x Returns the current X coord, relative to the desktop. Can be NULL. - * \param y Returns the current Y coord, relative to the desktop. Can be NULL. - * \return The current button state as a bitmask, which can be tested using the SDL_BUTTON(X) macros. - * - * \sa SDL_GetMouseState - */ -extern DECLSPEC Uint32 SDLCALL SDL_GetGlobalMouseState(int *x, int *y); - -/** - * \brief Retrieve the relative state of the mouse. - * - * The current button state is returned as a button bitmask, which can - * be tested using the SDL_BUTTON(X) macros, and x and y are set to the - * mouse deltas since the last call to SDL_GetRelativeMouseState(). - */ -extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); - -/** - * \brief Moves the mouse to the given position within the window. - * - * \param window The window to move the mouse into, or NULL for the current mouse focus - * \param x The x coordinate within the window - * \param y The y coordinate within the window - * - * \note This function generates a mouse motion event - */ -extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, - int x, int y); - -/** - * \brief Moves the mouse to the given position in global screen space. - * - * \param x The x coordinate - * \param y The y coordinate - * \return 0 on success, -1 on error (usually: unsupported by a platform). - * - * \note This function generates a mouse motion event - */ -extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y); - -/** - * \brief Set relative mouse mode. - * - * \param enabled Whether or not to enable relative mode - * - * \return 0 on success, or -1 if relative mode is not supported. - * - * While the mouse is in relative mode, the cursor is hidden, and the - * driver will try to report continuous motion in the current window. - * Only relative motion events will be delivered, the mouse position - * will not change. - * - * \note This function will flush any pending mouse motion. - * - * \sa SDL_GetRelativeMouseMode() - */ -extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled); - -/** - * \brief Capture the mouse, to track input outside an SDL window. - * - * \param enabled Whether or not to enable capturing - * - * Capturing enables your app to obtain mouse events globally, instead of - * just within your window. Not all video targets support this function. - * When capturing is enabled, the current window will get all mouse events, - * but unlike relative mode, no change is made to the cursor and it is - * not restrained to your window. - * - * This function may also deny mouse input to other windows--both those in - * your application and others on the system--so you should use this - * function sparingly, and in small bursts. For example, you might want to - * track the mouse while the user is dragging something, until the user - * releases a mouse button. It is not recommended that you capture the mouse - * for long periods of time, such as the entire time your app is running. - * - * While captured, mouse events still report coordinates relative to the - * current (foreground) window, but those coordinates may be outside the - * bounds of the window (including negative values). Capturing is only - * allowed for the foreground window. If the window loses focus while - * capturing, the capture will be disabled automatically. - * - * While capturing is enabled, the current window will have the - * SDL_WINDOW_MOUSE_CAPTURE flag set. - * - * \return 0 on success, or -1 if not supported. - */ -extern DECLSPEC int SDLCALL SDL_CaptureMouse(SDL_bool enabled); - -/** - * \brief Query whether relative mouse mode is enabled. - * - * \sa SDL_SetRelativeMouseMode() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); - -/** - * \brief Create a cursor, using the specified bitmap data and - * mask (in MSB format). - * - * The cursor width must be a multiple of 8 bits. - * - * The cursor is created in black and white according to the following: - * - * - * - * - * - * - *
data mask resulting pixel on screen
0 1 White
1 1 Black
0 0 Transparent
1 0 Inverted color if possible, black - * if not.
- * - * \sa SDL_FreeCursor() - */ -extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, - const Uint8 * mask, - int w, int h, int hot_x, - int hot_y); - -/** - * \brief Create a color cursor. - * - * \sa SDL_FreeCursor() - */ -extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, - int hot_x, - int hot_y); - -/** - * \brief Create a system cursor. - * - * \sa SDL_FreeCursor() - */ -extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id); - -/** - * \brief Set the active cursor. - */ -extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor); - -/** - * \brief Return the active cursor. - */ -extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void); - -/** - * \brief Return the default cursor. - */ -extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void); - -/** - * \brief Frees a cursor created with SDL_CreateCursor() or similar functions. - * - * \sa SDL_CreateCursor() - * \sa SDL_CreateColorCursor() - * \sa SDL_CreateSystemCursor() - */ -extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor); - -/** - * \brief Toggle whether or not the cursor is shown. - * - * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current - * state. - * - * \return 1 if the cursor is shown, or 0 if the cursor is hidden. - */ -extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); - -/** - * Used as a mask when testing buttons in buttonstate. - * - Button 1: Left mouse button - * - Button 2: Middle mouse button - * - Button 3: Right mouse button - */ -#define SDL_BUTTON(X) (1 << ((X)-1)) -#define SDL_BUTTON_LEFT 1 -#define SDL_BUTTON_MIDDLE 2 -#define SDL_BUTTON_RIGHT 3 -#define SDL_BUTTON_X1 4 -#define SDL_BUTTON_X2 5 -#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) -#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) -#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) -#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) -#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_mouse_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_mutex.h b/thirdparty/include/SDL2/SDL_mutex.h deleted file mode 100644 index 3c5b95574..000000000 --- a/thirdparty/include/SDL2/SDL_mutex.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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 SDL_mutex_h_ -#define SDL_mutex_h_ - -/** - * \file SDL_mutex.h - * - * Functions to provide thread synchronization primitives. - */ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Synchronization functions which can time out return this value - * if they time out. - */ -#define SDL_MUTEX_TIMEDOUT 1 - -/** - * This is the timeout value which corresponds to never time out. - */ -#define SDL_MUTEX_MAXWAIT (~(Uint32)0) - - -/** - * \name Mutex functions - */ -/* @{ */ - -/* The SDL mutex structure, defined in SDL_sysmutex.c */ -struct SDL_mutex; -typedef struct SDL_mutex SDL_mutex; - -/** - * Create a mutex, initialized unlocked. - */ -extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void); - -/** - * Lock the mutex. - * - * \return 0, or -1 on error. - */ -#define SDL_mutexP(m) SDL_LockMutex(m) -extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex); - -/** - * Try to lock the mutex - * - * \return 0, SDL_MUTEX_TIMEDOUT, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex); - -/** - * Unlock the mutex. - * - * \return 0, or -1 on error. - * - * \warning It is an error to unlock a mutex that has not been locked by - * the current thread, and doing so results in undefined behavior. - */ -#define SDL_mutexV(m) SDL_UnlockMutex(m) -extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); - -/** - * Destroy a mutex. - */ -extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); - -/* @} *//* Mutex functions */ - - -/** - * \name Semaphore functions - */ -/* @{ */ - -/* The SDL semaphore structure, defined in SDL_syssem.c */ -struct SDL_semaphore; -typedef struct SDL_semaphore SDL_sem; - -/** - * Create a semaphore, initialized with value, returns NULL on failure. - */ -extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value); - -/** - * Destroy a semaphore. - */ -extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem); - -/** - * This function suspends the calling thread until the semaphore pointed - * to by \c sem has a positive count. It then atomically decreases the - * semaphore count. - */ -extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem); - -/** - * Non-blocking variant of SDL_SemWait(). - * - * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would - * block, and -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem); - -/** - * Variant of SDL_SemWait() with a timeout in milliseconds. - * - * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not - * succeed in the allotted time, and -1 on error. - * - * \warning On some platforms this function is implemented by looping with a - * delay of 1 ms, and so should be avoided if possible. - */ -extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms); - -/** - * Atomically increases the semaphore's count (not blocking). - * - * \return 0, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); - -/** - * Returns the current count of the semaphore. - */ -extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); - -/* @} *//* Semaphore functions */ - - -/** - * \name Condition variable functions - */ -/* @{ */ - -/* The SDL condition variable structure, defined in SDL_syscond.c */ -struct SDL_cond; -typedef struct SDL_cond SDL_cond; - -/** - * Create a condition variable. - * - * Typical use of condition variables: - * - * Thread A: - * SDL_LockMutex(lock); - * while ( ! condition ) { - * SDL_CondWait(cond, lock); - * } - * SDL_UnlockMutex(lock); - * - * Thread B: - * SDL_LockMutex(lock); - * ... - * condition = true; - * ... - * SDL_CondSignal(cond); - * SDL_UnlockMutex(lock); - * - * There is some discussion whether to signal the condition variable - * with the mutex locked or not. There is some potential performance - * benefit to unlocking first on some platforms, but there are some - * potential race conditions depending on how your code is structured. - * - * In general it's safer to signal the condition variable while the - * mutex is locked. - */ -extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void); - -/** - * Destroy a condition variable. - */ -extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond); - -/** - * Restart one of the threads that are waiting on the condition variable. - * - * \return 0 or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond); - -/** - * Restart all threads that are waiting on the condition variable. - * - * \return 0 or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond); - -/** - * Wait on the condition variable, unlocking the provided mutex. - * - * \warning The mutex must be locked before entering this function! - * - * The mutex is re-locked once the condition variable is signaled. - * - * \return 0 when it is signaled, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); - -/** - * Waits for at most \c ms milliseconds, and returns 0 if the condition - * variable is signaled, ::SDL_MUTEX_TIMEDOUT if the condition is not - * signaled in the allotted time, and -1 on error. - * - * \warning On some platforms this function is implemented by looping with a - * delay of 1 ms, and so should be avoided if possible. - */ -extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, - SDL_mutex * mutex, Uint32 ms); - -/* @} *//* Condition variable functions */ - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_mutex_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_name.h b/thirdparty/include/SDL2/SDL_name.h deleted file mode 100644 index a49c4887b..000000000 --- a/thirdparty/include/SDL2/SDL_name.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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 SDLname_h_ -#define SDLname_h_ - -#if defined(__STDC__) || defined(__cplusplus) -#define NeedFunctionPrototypes 1 -#endif - -#define SDL_NAME(X) SDL_##X - -#endif /* SDLname_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_opengl.h b/thirdparty/include/SDL2/SDL_opengl.h deleted file mode 100644 index 5cd302cde..000000000 --- a/thirdparty/include/SDL2/SDL_opengl.h +++ /dev/null @@ -1,2183 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_opengl.h - * - * This is a simple file to encapsulate the OpenGL API headers. - */ - -/** - * \def NO_SDL_GLEXT - * - * Define this if you have your own version of glext.h and want to disable the - * version included in SDL_opengl.h. - */ - -#ifndef SDL_opengl_h_ -#define SDL_opengl_h_ - -#include "SDL_config.h" - -#ifndef __IPHONEOS__ /* No OpenGL on iOS. */ - -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * Copyright (C) 2009 VMware, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef __gl_h_ -#define __gl_h_ - -#if defined(USE_MGL_NAMESPACE) -#include "gl_mangle.h" -#endif - - -/********************************************************************** - * Begin system-specific stuff. - */ - -#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) -#define __WIN32__ -#endif - -#if defined(__WIN32__) && !defined(__CYGWIN__) -# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ -# define GLAPI __declspec(dllexport) -# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ -# define GLAPI __declspec(dllimport) -# else /* for use with static link lib build of Win32 edition only */ -# define GLAPI extern -# endif /* _STATIC_MESA support */ -# if defined(__MINGW32__) && defined(GL_NO_STDCALL) || defined(UNDER_CE) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ -# define GLAPIENTRY -# else -# define GLAPIENTRY __stdcall -# endif -#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ -# define GLAPI extern -# define GLAPIENTRY __stdcall -#elif defined(__OS2__) || defined(__EMX__) /* native os/2 opengl */ -# define GLAPI extern -# define GLAPIENTRY _System -# define APIENTRY _System -# if defined(__GNUC__) && !defined(_System) -# define _System -# endif -#elif (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define GLAPI __attribute__((visibility("default"))) -# define GLAPIENTRY -#endif /* WIN32 && !CYGWIN */ - -/* - * WINDOWS: Include windows.h here to define APIENTRY. - * It is also useful when applications include this file by - * including only glut.h, since glut.h depends on windows.h. - * Applications needing to include windows.h with parms other - * than "WIN32_LEAN_AND_MEAN" may include windows.h before - * glut.h or gl.h. - */ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif -#ifndef NOMINMAX /* don't define min() and max(). */ -#define NOMINMAX -#endif -#include -#endif - -#ifndef GLAPI -#define GLAPI extern -#endif - -#ifndef GLAPIENTRY -#define GLAPIENTRY -#endif - -#ifndef APIENTRY -#define APIENTRY GLAPIENTRY -#endif - -/* "P" suffix to be used for a pointer to a function */ -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif - -#ifndef GLAPIENTRYP -#define GLAPIENTRYP GLAPIENTRY * -#endif - -#if defined(PRAGMA_EXPORT_SUPPORTED) -#pragma export on -#endif - -/* - * End system-specific stuff. - **********************************************************************/ - - - -#ifdef __cplusplus -extern "C" { -#endif - - - -#define GL_VERSION_1_1 1 -#define GL_VERSION_1_2 1 -#define GL_VERSION_1_3 1 -#define GL_ARB_imaging 1 - - -/* - * Datatypes - */ -typedef unsigned int GLenum; -typedef unsigned char GLboolean; -typedef unsigned int GLbitfield; -typedef void GLvoid; -typedef signed char GLbyte; /* 1-byte signed */ -typedef short GLshort; /* 2-byte signed */ -typedef int GLint; /* 4-byte signed */ -typedef unsigned char GLubyte; /* 1-byte unsigned */ -typedef unsigned short GLushort; /* 2-byte unsigned */ -typedef unsigned int GLuint; /* 4-byte unsigned */ -typedef int GLsizei; /* 4-byte signed */ -typedef float GLfloat; /* single precision float */ -typedef float GLclampf; /* single precision float in [0,1] */ -typedef double GLdouble; /* double precision float */ -typedef double GLclampd; /* double precision float in [0,1] */ - - - -/* - * Constants - */ - -/* Boolean values */ -#define GL_FALSE 0 -#define GL_TRUE 1 - -/* Data types */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_2_BYTES 0x1407 -#define GL_3_BYTES 0x1408 -#define GL_4_BYTES 0x1409 -#define GL_DOUBLE 0x140A - -/* Primitives */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -#define GL_QUADS 0x0007 -#define GL_QUAD_STRIP 0x0008 -#define GL_POLYGON 0x0009 - -/* Vertex Arrays */ -#define GL_VERTEX_ARRAY 0x8074 -#define GL_NORMAL_ARRAY 0x8075 -#define GL_COLOR_ARRAY 0x8076 -#define GL_INDEX_ARRAY 0x8077 -#define GL_TEXTURE_COORD_ARRAY 0x8078 -#define GL_EDGE_FLAG_ARRAY 0x8079 -#define GL_VERTEX_ARRAY_SIZE 0x807A -#define GL_VERTEX_ARRAY_TYPE 0x807B -#define GL_VERTEX_ARRAY_STRIDE 0x807C -#define GL_NORMAL_ARRAY_TYPE 0x807E -#define GL_NORMAL_ARRAY_STRIDE 0x807F -#define GL_COLOR_ARRAY_SIZE 0x8081 -#define GL_COLOR_ARRAY_TYPE 0x8082 -#define GL_COLOR_ARRAY_STRIDE 0x8083 -#define GL_INDEX_ARRAY_TYPE 0x8085 -#define GL_INDEX_ARRAY_STRIDE 0x8086 -#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A -#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C -#define GL_VERTEX_ARRAY_POINTER 0x808E -#define GL_NORMAL_ARRAY_POINTER 0x808F -#define GL_COLOR_ARRAY_POINTER 0x8090 -#define GL_INDEX_ARRAY_POINTER 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 -#define GL_V2F 0x2A20 -#define GL_V3F 0x2A21 -#define GL_C4UB_V2F 0x2A22 -#define GL_C4UB_V3F 0x2A23 -#define GL_C3F_V3F 0x2A24 -#define GL_N3F_V3F 0x2A25 -#define GL_C4F_N3F_V3F 0x2A26 -#define GL_T2F_V3F 0x2A27 -#define GL_T4F_V4F 0x2A28 -#define GL_T2F_C4UB_V3F 0x2A29 -#define GL_T2F_C3F_V3F 0x2A2A -#define GL_T2F_N3F_V3F 0x2A2B -#define GL_T2F_C4F_N3F_V3F 0x2A2C -#define GL_T4F_C4F_N3F_V4F 0x2A2D - -/* Matrix Mode */ -#define GL_MATRIX_MODE 0x0BA0 -#define GL_MODELVIEW 0x1700 -#define GL_PROJECTION 0x1701 -#define GL_TEXTURE 0x1702 - -/* Points */ -#define GL_POINT_SMOOTH 0x0B10 -#define GL_POINT_SIZE 0x0B11 -#define GL_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_POINT_SIZE_RANGE 0x0B12 - -/* Lines */ -#define GL_LINE_SMOOTH 0x0B20 -#define GL_LINE_STIPPLE 0x0B24 -#define GL_LINE_STIPPLE_PATTERN 0x0B25 -#define GL_LINE_STIPPLE_REPEAT 0x0B26 -#define GL_LINE_WIDTH 0x0B21 -#define GL_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_LINE_WIDTH_RANGE 0x0B22 - -/* Polygons */ -#define GL_POINT 0x1B00 -#define GL_LINE 0x1B01 -#define GL_FILL 0x1B02 -#define GL_CW 0x0900 -#define GL_CCW 0x0901 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_POLYGON_MODE 0x0B40 -#define GL_POLYGON_SMOOTH 0x0B41 -#define GL_POLYGON_STIPPLE 0x0B42 -#define GL_EDGE_FLAG 0x0B43 -#define GL_CULL_FACE 0x0B44 -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_POINT 0x2A01 -#define GL_POLYGON_OFFSET_LINE 0x2A02 -#define GL_POLYGON_OFFSET_FILL 0x8037 - -/* Display Lists */ -#define GL_COMPILE 0x1300 -#define GL_COMPILE_AND_EXECUTE 0x1301 -#define GL_LIST_BASE 0x0B32 -#define GL_LIST_INDEX 0x0B33 -#define GL_LIST_MODE 0x0B30 - -/* Depth buffer */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 -#define GL_DEPTH_TEST 0x0B71 -#define GL_DEPTH_BITS 0x0D56 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_COMPONENT 0x1902 - -/* Lighting */ -#define GL_LIGHTING 0x0B50 -#define GL_LIGHT0 0x4000 -#define GL_LIGHT1 0x4001 -#define GL_LIGHT2 0x4002 -#define GL_LIGHT3 0x4003 -#define GL_LIGHT4 0x4004 -#define GL_LIGHT5 0x4005 -#define GL_LIGHT6 0x4006 -#define GL_LIGHT7 0x4007 -#define GL_SPOT_EXPONENT 0x1205 -#define GL_SPOT_CUTOFF 0x1206 -#define GL_CONSTANT_ATTENUATION 0x1207 -#define GL_LINEAR_ATTENUATION 0x1208 -#define GL_QUADRATIC_ATTENUATION 0x1209 -#define GL_AMBIENT 0x1200 -#define GL_DIFFUSE 0x1201 -#define GL_SPECULAR 0x1202 -#define GL_SHININESS 0x1601 -#define GL_EMISSION 0x1600 -#define GL_POSITION 0x1203 -#define GL_SPOT_DIRECTION 0x1204 -#define GL_AMBIENT_AND_DIFFUSE 0x1602 -#define GL_COLOR_INDEXES 0x1603 -#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 -#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 -#define GL_LIGHT_MODEL_AMBIENT 0x0B53 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_SHADE_MODEL 0x0B54 -#define GL_FLAT 0x1D00 -#define GL_SMOOTH 0x1D01 -#define GL_COLOR_MATERIAL 0x0B57 -#define GL_COLOR_MATERIAL_FACE 0x0B55 -#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 -#define GL_NORMALIZE 0x0BA1 - -/* User clipping planes */ -#define GL_CLIP_PLANE0 0x3000 -#define GL_CLIP_PLANE1 0x3001 -#define GL_CLIP_PLANE2 0x3002 -#define GL_CLIP_PLANE3 0x3003 -#define GL_CLIP_PLANE4 0x3004 -#define GL_CLIP_PLANE5 0x3005 - -/* Accumulation buffer */ -#define GL_ACCUM_RED_BITS 0x0D58 -#define GL_ACCUM_GREEN_BITS 0x0D59 -#define GL_ACCUM_BLUE_BITS 0x0D5A -#define GL_ACCUM_ALPHA_BITS 0x0D5B -#define GL_ACCUM_CLEAR_VALUE 0x0B80 -#define GL_ACCUM 0x0100 -#define GL_ADD 0x0104 -#define GL_LOAD 0x0101 -#define GL_MULT 0x0103 -#define GL_RETURN 0x0102 - -/* Alpha testing */ -#define GL_ALPHA_TEST 0x0BC0 -#define GL_ALPHA_TEST_REF 0x0BC2 -#define GL_ALPHA_TEST_FUNC 0x0BC1 - -/* Blending */ -#define GL_BLEND 0x0BE2 -#define GL_BLEND_SRC 0x0BE1 -#define GL_BLEND_DST 0x0BE0 -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 - -/* Render Mode */ -#define GL_FEEDBACK 0x1C01 -#define GL_RENDER 0x1C00 -#define GL_SELECT 0x1C02 - -/* Feedback */ -#define GL_2D 0x0600 -#define GL_3D 0x0601 -#define GL_3D_COLOR 0x0602 -#define GL_3D_COLOR_TEXTURE 0x0603 -#define GL_4D_COLOR_TEXTURE 0x0604 -#define GL_POINT_TOKEN 0x0701 -#define GL_LINE_TOKEN 0x0702 -#define GL_LINE_RESET_TOKEN 0x0707 -#define GL_POLYGON_TOKEN 0x0703 -#define GL_BITMAP_TOKEN 0x0704 -#define GL_DRAW_PIXEL_TOKEN 0x0705 -#define GL_COPY_PIXEL_TOKEN 0x0706 -#define GL_PASS_THROUGH_TOKEN 0x0700 -#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 -#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 -#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 - -/* Selection */ -#define GL_SELECTION_BUFFER_POINTER 0x0DF3 -#define GL_SELECTION_BUFFER_SIZE 0x0DF4 - -/* Fog */ -#define GL_FOG 0x0B60 -#define GL_FOG_MODE 0x0B65 -#define GL_FOG_DENSITY 0x0B62 -#define GL_FOG_COLOR 0x0B66 -#define GL_FOG_INDEX 0x0B61 -#define GL_FOG_START 0x0B63 -#define GL_FOG_END 0x0B64 -#define GL_LINEAR 0x2601 -#define GL_EXP 0x0800 -#define GL_EXP2 0x0801 - -/* Logic Ops */ -#define GL_LOGIC_OP 0x0BF1 -#define GL_INDEX_LOGIC_OP 0x0BF1 -#define GL_COLOR_LOGIC_OP 0x0BF2 -#define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_CLEAR 0x1500 -#define GL_SET 0x150F -#define GL_COPY 0x1503 -#define GL_COPY_INVERTED 0x150C -#define GL_NOOP 0x1505 -#define GL_INVERT 0x150A -#define GL_AND 0x1501 -#define GL_NAND 0x150E -#define GL_OR 0x1507 -#define GL_NOR 0x1508 -#define GL_XOR 0x1506 -#define GL_EQUIV 0x1509 -#define GL_AND_REVERSE 0x1502 -#define GL_AND_INVERTED 0x1504 -#define GL_OR_REVERSE 0x150B -#define GL_OR_INVERTED 0x150D - -/* Stencil */ -#define GL_STENCIL_BITS 0x0D57 -#define GL_STENCIL_TEST 0x0B90 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_STENCIL_INDEX 0x1901 -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 - -/* Buffers, Pixel Drawing/Reading */ -#define GL_NONE 0 -#define GL_LEFT 0x0406 -#define GL_RIGHT 0x0407 -/*GL_FRONT 0x0404 */ -/*GL_BACK 0x0405 */ -/*GL_FRONT_AND_BACK 0x0408 */ -#define GL_FRONT_LEFT 0x0400 -#define GL_FRONT_RIGHT 0x0401 -#define GL_BACK_LEFT 0x0402 -#define GL_BACK_RIGHT 0x0403 -#define GL_AUX0 0x0409 -#define GL_AUX1 0x040A -#define GL_AUX2 0x040B -#define GL_AUX3 0x040C -#define GL_COLOR_INDEX 0x1900 -#define GL_RED 0x1903 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_ALPHA 0x1906 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A -#define GL_ALPHA_BITS 0x0D55 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_INDEX_BITS 0x0D51 -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_AUX_BUFFERS 0x0C00 -#define GL_READ_BUFFER 0x0C02 -#define GL_DRAW_BUFFER 0x0C01 -#define GL_DOUBLEBUFFER 0x0C32 -#define GL_STEREO 0x0C33 -#define GL_BITMAP 0x1A00 -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 -#define GL_DITHER 0x0BD0 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 - -/* Implementation limits */ -#define GL_MAX_LIST_NESTING 0x0B31 -#define GL_MAX_EVAL_ORDER 0x0D30 -#define GL_MAX_LIGHTS 0x0D31 -#define GL_MAX_CLIP_PLANES 0x0D32 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 -#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 -#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define GL_MAX_NAME_STACK_DEPTH 0x0D37 -#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B - -/* Gets */ -#define GL_ATTRIB_STACK_DEPTH 0x0BB0 -#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_CURRENT_INDEX 0x0B01 -#define GL_CURRENT_COLOR 0x0B00 -#define GL_CURRENT_NORMAL 0x0B02 -#define GL_CURRENT_RASTER_COLOR 0x0B04 -#define GL_CURRENT_RASTER_DISTANCE 0x0B09 -#define GL_CURRENT_RASTER_INDEX 0x0B05 -#define GL_CURRENT_RASTER_POSITION 0x0B07 -#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 -#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 -#define GL_CURRENT_TEXTURE_COORDS 0x0B03 -#define GL_INDEX_CLEAR_VALUE 0x0C20 -#define GL_INDEX_MODE 0x0C30 -#define GL_INDEX_WRITEMASK 0x0C21 -#define GL_MODELVIEW_MATRIX 0x0BA6 -#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 -#define GL_NAME_STACK_DEPTH 0x0D70 -#define GL_PROJECTION_MATRIX 0x0BA7 -#define GL_PROJECTION_STACK_DEPTH 0x0BA4 -#define GL_RENDER_MODE 0x0C40 -#define GL_RGBA_MODE 0x0C31 -#define GL_TEXTURE_MATRIX 0x0BA8 -#define GL_TEXTURE_STACK_DEPTH 0x0BA5 -#define GL_VIEWPORT 0x0BA2 - -/* Evaluators */ -#define GL_AUTO_NORMAL 0x0D80 -#define GL_MAP1_COLOR_4 0x0D90 -#define GL_MAP1_INDEX 0x0D91 -#define GL_MAP1_NORMAL 0x0D92 -#define GL_MAP1_TEXTURE_COORD_1 0x0D93 -#define GL_MAP1_TEXTURE_COORD_2 0x0D94 -#define GL_MAP1_TEXTURE_COORD_3 0x0D95 -#define GL_MAP1_TEXTURE_COORD_4 0x0D96 -#define GL_MAP1_VERTEX_3 0x0D97 -#define GL_MAP1_VERTEX_4 0x0D98 -#define GL_MAP2_COLOR_4 0x0DB0 -#define GL_MAP2_INDEX 0x0DB1 -#define GL_MAP2_NORMAL 0x0DB2 -#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 -#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 -#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 -#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 -#define GL_MAP2_VERTEX_3 0x0DB7 -#define GL_MAP2_VERTEX_4 0x0DB8 -#define GL_MAP1_GRID_DOMAIN 0x0DD0 -#define GL_MAP1_GRID_SEGMENTS 0x0DD1 -#define GL_MAP2_GRID_DOMAIN 0x0DD2 -#define GL_MAP2_GRID_SEGMENTS 0x0DD3 -#define GL_COEFF 0x0A00 -#define GL_ORDER 0x0A01 -#define GL_DOMAIN 0x0A02 - -/* Hints */ -#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 -#define GL_POINT_SMOOTH_HINT 0x0C51 -#define GL_LINE_SMOOTH_HINT 0x0C52 -#define GL_POLYGON_SMOOTH_HINT 0x0C53 -#define GL_FOG_HINT 0x0C54 -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* Scissor box */ -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 - -/* Pixel Mode / Transfer */ -#define GL_MAP_COLOR 0x0D10 -#define GL_MAP_STENCIL 0x0D11 -#define GL_INDEX_SHIFT 0x0D12 -#define GL_INDEX_OFFSET 0x0D13 -#define GL_RED_SCALE 0x0D14 -#define GL_RED_BIAS 0x0D15 -#define GL_GREEN_SCALE 0x0D18 -#define GL_GREEN_BIAS 0x0D19 -#define GL_BLUE_SCALE 0x0D1A -#define GL_BLUE_BIAS 0x0D1B -#define GL_ALPHA_SCALE 0x0D1C -#define GL_ALPHA_BIAS 0x0D1D -#define GL_DEPTH_SCALE 0x0D1E -#define GL_DEPTH_BIAS 0x0D1F -#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 -#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 -#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 -#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 -#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 -#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 -#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 -#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 -#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 -#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 -#define GL_PIXEL_MAP_S_TO_S 0x0C71 -#define GL_PIXEL_MAP_I_TO_I 0x0C70 -#define GL_PIXEL_MAP_I_TO_R 0x0C72 -#define GL_PIXEL_MAP_I_TO_G 0x0C73 -#define GL_PIXEL_MAP_I_TO_B 0x0C74 -#define GL_PIXEL_MAP_I_TO_A 0x0C75 -#define GL_PIXEL_MAP_R_TO_R 0x0C76 -#define GL_PIXEL_MAP_G_TO_G 0x0C77 -#define GL_PIXEL_MAP_B_TO_B 0x0C78 -#define GL_PIXEL_MAP_A_TO_A 0x0C79 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_PACK_LSB_FIRST 0x0D01 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SWAP_BYTES 0x0D00 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_UNPACK_LSB_FIRST 0x0CF1 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SWAP_BYTES 0x0CF0 -#define GL_ZOOM_X 0x0D16 -#define GL_ZOOM_Y 0x0D17 - -/* Texture mapping */ -#define GL_TEXTURE_ENV 0x2300 -#define GL_TEXTURE_ENV_MODE 0x2200 -#define GL_TEXTURE_1D 0x0DE0 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_ENV_COLOR 0x2201 -#define GL_TEXTURE_GEN_S 0x0C60 -#define GL_TEXTURE_GEN_T 0x0C61 -#define GL_TEXTURE_GEN_R 0x0C62 -#define GL_TEXTURE_GEN_Q 0x0C63 -#define GL_TEXTURE_GEN_MODE 0x2500 -#define GL_TEXTURE_BORDER_COLOR 0x1004 -#define GL_TEXTURE_WIDTH 0x1000 -#define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_BORDER 0x1005 -#define GL_TEXTURE_COMPONENTS 0x1003 -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE 0x8061 -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 -#define GL_OBJECT_LINEAR 0x2401 -#define GL_OBJECT_PLANE 0x2501 -#define GL_EYE_LINEAR 0x2400 -#define GL_EYE_PLANE 0x2502 -#define GL_SPHERE_MAP 0x2402 -#define GL_DECAL 0x2101 -#define GL_MODULATE 0x2100 -#define GL_NEAREST 0x2600 -#define GL_REPEAT 0x2901 -#define GL_CLAMP 0x2900 -#define GL_S 0x2000 -#define GL_T 0x2001 -#define GL_R 0x2002 -#define GL_Q 0x2003 - -/* Utility */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* Errors */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_OUT_OF_MEMORY 0x0505 - -/* glPush/PopAttrib bits */ -#define GL_CURRENT_BIT 0x00000001 -#define GL_POINT_BIT 0x00000002 -#define GL_LINE_BIT 0x00000004 -#define GL_POLYGON_BIT 0x00000008 -#define GL_POLYGON_STIPPLE_BIT 0x00000010 -#define GL_PIXEL_MODE_BIT 0x00000020 -#define GL_LIGHTING_BIT 0x00000040 -#define GL_FOG_BIT 0x00000080 -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_ACCUM_BUFFER_BIT 0x00000200 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_VIEWPORT_BIT 0x00000800 -#define GL_TRANSFORM_BIT 0x00001000 -#define GL_ENABLE_BIT 0x00002000 -#define GL_COLOR_BUFFER_BIT 0x00004000 -#define GL_HINT_BIT 0x00008000 -#define GL_EVAL_BIT 0x00010000 -#define GL_LIST_BIT 0x00020000 -#define GL_TEXTURE_BIT 0x00040000 -#define GL_SCISSOR_BIT 0x00080000 -#define GL_ALL_ATTRIB_BITS 0x000FFFFF - - -/* OpenGL 1.1 */ -#define GL_PROXY_TEXTURE_1D 0x8063 -#define GL_PROXY_TEXTURE_2D 0x8064 -#define GL_TEXTURE_PRIORITY 0x8066 -#define GL_TEXTURE_RESIDENT 0x8067 -#define GL_TEXTURE_BINDING_1D 0x8068 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#define GL_ALPHA4 0x803B -#define GL_ALPHA8 0x803C -#define GL_ALPHA12 0x803D -#define GL_ALPHA16 0x803E -#define GL_LUMINANCE4 0x803F -#define GL_LUMINANCE8 0x8040 -#define GL_LUMINANCE12 0x8041 -#define GL_LUMINANCE16 0x8042 -#define GL_LUMINANCE4_ALPHA4 0x8043 -#define GL_LUMINANCE6_ALPHA2 0x8044 -#define GL_LUMINANCE8_ALPHA8 0x8045 -#define GL_LUMINANCE12_ALPHA4 0x8046 -#define GL_LUMINANCE12_ALPHA12 0x8047 -#define GL_LUMINANCE16_ALPHA16 0x8048 -#define GL_INTENSITY 0x8049 -#define GL_INTENSITY4 0x804A -#define GL_INTENSITY8 0x804B -#define GL_INTENSITY12 0x804C -#define GL_INTENSITY16 0x804D -#define GL_R3_G3_B2 0x2A10 -#define GL_RGB4 0x804F -#define GL_RGB5 0x8050 -#define GL_RGB8 0x8051 -#define GL_RGB10 0x8052 -#define GL_RGB12 0x8053 -#define GL_RGB16 0x8054 -#define GL_RGBA2 0x8055 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_RGBA12 0x805A -#define GL_RGBA16 0x805B -#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 -#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 -#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF -#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF - - - -/* - * Miscellaneous - */ - -GLAPI void GLAPIENTRY glClearIndex( GLfloat c ); - -GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); - -GLAPI void GLAPIENTRY glClear( GLbitfield mask ); - -GLAPI void GLAPIENTRY glIndexMask( GLuint mask ); - -GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); - -GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref ); - -GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); - -GLAPI void GLAPIENTRY glLogicOp( GLenum opcode ); - -GLAPI void GLAPIENTRY glCullFace( GLenum mode ); - -GLAPI void GLAPIENTRY glFrontFace( GLenum mode ); - -GLAPI void GLAPIENTRY glPointSize( GLfloat size ); - -GLAPI void GLAPIENTRY glLineWidth( GLfloat width ); - -GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern ); - -GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode ); - -GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units ); - -GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask ); - -GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask ); - -GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag ); - -GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag ); - -GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height); - -GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation ); - -GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation ); - -GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode ); - -GLAPI void GLAPIENTRY glReadBuffer( GLenum mode ); - -GLAPI void GLAPIENTRY glEnable( GLenum cap ); - -GLAPI void GLAPIENTRY glDisable( GLenum cap ); - -GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap ); - - -GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); /* 1.1 */ - -GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); /* 1.1 */ - - -GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params ); - -GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params ); - -GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params ); - -GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params ); - - -GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask ); - -GLAPI void GLAPIENTRY glPopAttrib( void ); - - -GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); /* 1.1 */ - -GLAPI void GLAPIENTRY glPopClientAttrib( void ); /* 1.1 */ - - -GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode ); - -GLAPI GLenum GLAPIENTRY glGetError( void ); - -GLAPI const GLubyte * GLAPIENTRY glGetString( GLenum name ); - -GLAPI void GLAPIENTRY glFinish( void ); - -GLAPI void GLAPIENTRY glFlush( void ); - -GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode ); - - -/* - * Depth Buffer - */ - -GLAPI void GLAPIENTRY glClearDepth( GLclampd depth ); - -GLAPI void GLAPIENTRY glDepthFunc( GLenum func ); - -GLAPI void GLAPIENTRY glDepthMask( GLboolean flag ); - -GLAPI void GLAPIENTRY glDepthRange( GLclampd near_val, GLclampd far_val ); - - -/* - * Accumulation Buffer - */ - -GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); - -GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value ); - - -/* - * Transformation - */ - -GLAPI void GLAPIENTRY glMatrixMode( GLenum mode ); - -GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble near_val, GLdouble far_val ); - -GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right, - GLdouble bottom, GLdouble top, - GLdouble near_val, GLdouble far_val ); - -GLAPI void GLAPIENTRY glViewport( GLint x, GLint y, - GLsizei width, GLsizei height ); - -GLAPI void GLAPIENTRY glPushMatrix( void ); - -GLAPI void GLAPIENTRY glPopMatrix( void ); - -GLAPI void GLAPIENTRY glLoadIdentity( void ); - -GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m ); -GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m ); - -GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m ); -GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m ); - -GLAPI void GLAPIENTRY glRotated( GLdouble angle, - GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glRotatef( GLfloat angle, - GLfloat x, GLfloat y, GLfloat z ); - -GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z ); - -GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); - - -/* - * Display Lists - */ - -GLAPI GLboolean GLAPIENTRY glIsList( GLuint list ); - -GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range ); - -GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range ); - -GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode ); - -GLAPI void GLAPIENTRY glEndList( void ); - -GLAPI void GLAPIENTRY glCallList( GLuint list ); - -GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type, - const GLvoid *lists ); - -GLAPI void GLAPIENTRY glListBase( GLuint base ); - - -/* - * Drawing Functions - */ - -GLAPI void GLAPIENTRY glBegin( GLenum mode ); - -GLAPI void GLAPIENTRY glEnd( void ); - - -GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y ); -GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y ); -GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y ); -GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y ); - -GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z ); -GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z ); -GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z ); - -GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); -GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); -GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w ); -GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); - -GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glVertex2iv( const GLint *v ); -GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glVertex3iv( const GLint *v ); -GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glVertex4iv( const GLint *v ); -GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v ); - - -GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); -GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); -GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); -GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz ); -GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz ); - -GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v ); -GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glNormal3iv( const GLint *v ); -GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v ); - - -GLAPI void GLAPIENTRY glIndexd( GLdouble c ); -GLAPI void GLAPIENTRY glIndexf( GLfloat c ); -GLAPI void GLAPIENTRY glIndexi( GLint c ); -GLAPI void GLAPIENTRY glIndexs( GLshort c ); -GLAPI void GLAPIENTRY glIndexub( GLubyte c ); /* 1.1 */ - -GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c ); -GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c ); -GLAPI void GLAPIENTRY glIndexiv( const GLint *c ); -GLAPI void GLAPIENTRY glIndexsv( const GLshort *c ); -GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); /* 1.1 */ - -GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue ); -GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue ); -GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue ); -GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue ); -GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue ); -GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); -GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue ); -GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue ); - -GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green, - GLbyte blue, GLbyte alpha ); -GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green, - GLdouble blue, GLdouble alpha ); -GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green, - GLfloat blue, GLfloat alpha ); -GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green, - GLint blue, GLint alpha ); -GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green, - GLshort blue, GLshort alpha ); -GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green, - GLubyte blue, GLubyte alpha ); -GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green, - GLuint blue, GLuint alpha ); -GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green, - GLushort blue, GLushort alpha ); - - -GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v ); -GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glColor3iv( const GLint *v ); -GLAPI void GLAPIENTRY glColor3sv( const GLshort *v ); -GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v ); -GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v ); -GLAPI void GLAPIENTRY glColor3usv( const GLushort *v ); - -GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v ); -GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glColor4iv( const GLint *v ); -GLAPI void GLAPIENTRY glColor4sv( const GLshort *v ); -GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v ); -GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v ); -GLAPI void GLAPIENTRY glColor4usv( const GLushort *v ); - - -GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s ); -GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s ); -GLAPI void GLAPIENTRY glTexCoord1i( GLint s ); -GLAPI void GLAPIENTRY glTexCoord1s( GLshort s ); - -GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t ); -GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t ); -GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t ); -GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t ); - -GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); -GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); -GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r ); -GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r ); - -GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); -GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); -GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); -GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); - -GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v ); -GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v ); -GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v ); -GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v ); -GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v ); - - -GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y ); -GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y ); -GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y ); -GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y ); - -GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); -GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z ); -GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z ); - -GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); -GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); -GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); -GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); - -GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v ); -GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v ); -GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v ); -GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v ); - - -GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); -GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); -GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); -GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); - - -GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 ); -GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 ); -GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 ); -GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 ); - - -/* - * Vertex Arrays (1.1) - */ - -GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr ); - -GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride, - const GLvoid *ptr ); - -GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr ); - -GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride, - const GLvoid *ptr ); - -GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type, - GLsizei stride, const GLvoid *ptr ); - -GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); - -GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params ); - -GLAPI void GLAPIENTRY glArrayElement( GLint i ); - -GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); - -GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count, - GLenum type, const GLvoid *indices ); - -GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride, - const GLvoid *pointer ); - -/* - * Lighting - */ - -GLAPI void GLAPIENTRY glShadeModel( GLenum mode ); - -GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname, - const GLfloat *params ); -GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname, - const GLint *params ); - -GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname, - GLfloat *params ); -GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname, - GLint *params ); - -GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params ); - -GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params ); - -GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); - -GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode ); - - -/* - * Raster functions - */ - -GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor ); - -GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param ); - -GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param ); - -GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLsizei mapsize, - const GLfloat *values ); -GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLsizei mapsize, - const GLuint *values ); -GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLsizei mapsize, - const GLushort *values ); - -GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); -GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values ); -GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values ); - -GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height, - GLfloat xorig, GLfloat yorig, - GLfloat xmove, GLfloat ymove, - const GLubyte *bitmap ); - -GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLvoid *pixels ); - -GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels ); - -GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y, - GLsizei width, GLsizei height, - GLenum type ); - -/* - * Stenciling - */ - -GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask ); - -GLAPI void GLAPIENTRY glStencilMask( GLuint mask ); - -GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); - -GLAPI void GLAPIENTRY glClearStencil( GLint s ); - - - -/* - * Texture mapping - */ - -GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param ); -GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param ); - -GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); -GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); - -GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); -GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); - - -GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param ); - -GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params ); - -GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); - - -GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); - -GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname, - const GLfloat *params ); -GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname, - const GLint *params ); - -GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target, - GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target, - GLenum pname, GLint *params ); - -GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level, - GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level, - GLenum pname, GLint *params ); - - -GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level, - GLint internalFormat, - GLsizei width, GLint border, - GLenum format, GLenum type, - const GLvoid *pixels ); - -GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level, - GLint internalFormat, - GLsizei width, GLsizei height, - GLint border, GLenum format, GLenum type, - const GLvoid *pixels ); - -GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level, - GLenum format, GLenum type, - GLvoid *pixels ); - - -/* 1.1 functions */ - -GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures ); - -GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures); - -GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture ); - -GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n, - const GLuint *textures, - const GLclampf *priorities ); - -GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n, - const GLuint *textures, - GLboolean *residences ); - -GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture ); - - -GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level, - GLint xoffset, - GLsizei width, GLenum format, - GLenum type, const GLvoid *pixels ); - - -GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels ); - - -GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, - GLsizei width, GLint border ); - - -GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level, - GLenum internalformat, - GLint x, GLint y, - GLsizei width, GLsizei height, - GLint border ); - - -GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, - GLsizei width ); - - -GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, GLsizei height ); - - -/* - * Evaluators - */ - -GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2, - GLint stride, - GLint order, const GLdouble *points ); -GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2, - GLint stride, - GLint order, const GLfloat *points ); - -GLAPI void GLAPIENTRY glMap2d( GLenum target, - GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, - GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, - const GLdouble *points ); -GLAPI void GLAPIENTRY glMap2f( GLenum target, - GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, - GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, - const GLfloat *points ); - -GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v ); -GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v ); -GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v ); - -GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u ); -GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u ); - -GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u ); -GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u ); - -GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v ); -GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v ); - -GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u ); -GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u ); - -GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); -GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); - -GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, - GLint vn, GLdouble v1, GLdouble v2 ); -GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, - GLint vn, GLfloat v1, GLfloat v2 ); - -GLAPI void GLAPIENTRY glEvalPoint1( GLint i ); - -GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j ); - -GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); - -GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); - - -/* - * Fog - */ - -GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param ); - -GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param ); - -GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params ); - -GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params ); - - -/* - * Selection and Feedback - */ - -GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); - -GLAPI void GLAPIENTRY glPassThrough( GLfloat token ); - -GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer ); - -GLAPI void GLAPIENTRY glInitNames( void ); - -GLAPI void GLAPIENTRY glLoadName( GLuint name ); - -GLAPI void GLAPIENTRY glPushName( GLuint name ); - -GLAPI void GLAPIENTRY glPopName( void ); - - - -/* - * OpenGL 1.2 - */ - -#define GL_RESCALE_NORMAL 0x803A -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_TEXTURE_BINDING_3D 0x806A - -GLAPI void GLAPIENTRY glDrawRangeElements( GLenum mode, GLuint start, - GLuint end, GLsizei count, GLenum type, const GLvoid *indices ); - -GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level, - GLint internalFormat, - GLsizei width, GLsizei height, - GLsizei depth, GLint border, - GLenum format, GLenum type, - const GLvoid *pixels ); - -GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint zoffset, GLsizei width, - GLsizei height, GLsizei depth, - GLenum format, - GLenum type, const GLvoid *pixels); - -GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint zoffset, GLint x, - GLint y, GLsizei width, - GLsizei height ); - -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); - - -/* - * GL_ARB_imaging - */ - -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_BLEND_EQUATION 0x8009 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_FUNC_ADD 0x8006 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_BLEND_COLOR 0x8005 - - -GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat, - GLsizei width, GLenum format, - GLenum type, const GLvoid *table ); - -GLAPI void GLAPIENTRY glColorSubTable( GLenum target, - GLsizei start, GLsizei count, - GLenum format, GLenum type, - const GLvoid *data ); - -GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname, - const GLint *params); - -GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname, - const GLfloat *params); - -GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start, - GLint x, GLint y, GLsizei width ); - -GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat, - GLint x, GLint y, GLsizei width ); - -GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format, - GLenum type, GLvoid *table ); - -GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname, - GLfloat *params ); - -GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname, - GLint *params ); - -GLAPI void GLAPIENTRY glBlendEquation( GLenum mode ); - -GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green, - GLclampf blue, GLclampf alpha ); - -GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width, - GLenum internalformat, GLboolean sink ); - -GLAPI void GLAPIENTRY glResetHistogram( GLenum target ); - -GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset, - GLenum format, GLenum type, - GLvoid *values ); - -GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname, - GLfloat *params ); - -GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname, - GLint *params ); - -GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat, - GLboolean sink ); - -GLAPI void GLAPIENTRY glResetMinmax( GLenum target ); - -GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset, - GLenum format, GLenum types, - GLvoid *values ); - -GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname, - GLfloat *params ); - -GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname, - GLint *params ); - -GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target, - GLenum internalformat, GLsizei width, GLenum format, GLenum type, - const GLvoid *image ); - -GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target, - GLenum internalformat, GLsizei width, GLsizei height, GLenum format, - GLenum type, const GLvoid *image ); - -GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname, - GLfloat params ); - -GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname, - const GLfloat *params ); - -GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname, - GLint params ); - -GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname, - const GLint *params ); - -GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target, - GLenum internalformat, GLint x, GLint y, GLsizei width ); - -GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target, - GLenum internalformat, GLint x, GLint y, GLsizei width, - GLsizei height); - -GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format, - GLenum type, GLvoid *image ); - -GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname, - GLfloat *params ); - -GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname, - GLint *params ); - -GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target, - GLenum internalformat, GLsizei width, GLsizei height, GLenum format, - GLenum type, const GLvoid *row, const GLvoid *column ); - -GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, - GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); - - - - -/* - * OpenGL 1.3 - */ - -/* multitexture */ -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -/* texture_cube_map */ -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -/* texture_compression */ -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -/* multisample */ -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_MULTISAMPLE_BIT 0x20000000 -/* transpose_matrix */ -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -/* texture_env_combine */ -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_SUBTRACT 0x84E7 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -/* texture_env_dot3 */ -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -/* texture_border_clamp */ -#define GL_CLAMP_TO_BORDER 0x812D - -GLAPI void GLAPIENTRY glActiveTexture( GLenum texture ); - -GLAPI void GLAPIENTRY glClientActiveTexture( GLenum texture ); - -GLAPI void GLAPIENTRY glCompressedTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data ); - -GLAPI void GLAPIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); - -GLAPI void GLAPIENTRY glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data ); - -GLAPI void GLAPIENTRY glCompressedTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data ); - -GLAPI void GLAPIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); - -GLAPI void GLAPIENTRY glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ); - -GLAPI void GLAPIENTRY glGetCompressedTexImage( GLenum target, GLint lod, GLvoid *img ); - -GLAPI void GLAPIENTRY glMultiTexCoord1d( GLenum target, GLdouble s ); - -GLAPI void GLAPIENTRY glMultiTexCoord1dv( GLenum target, const GLdouble *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord1f( GLenum target, GLfloat s ); - -GLAPI void GLAPIENTRY glMultiTexCoord1fv( GLenum target, const GLfloat *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord1i( GLenum target, GLint s ); - -GLAPI void GLAPIENTRY glMultiTexCoord1iv( GLenum target, const GLint *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord1s( GLenum target, GLshort s ); - -GLAPI void GLAPIENTRY glMultiTexCoord1sv( GLenum target, const GLshort *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord2d( GLenum target, GLdouble s, GLdouble t ); - -GLAPI void GLAPIENTRY glMultiTexCoord2dv( GLenum target, const GLdouble *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t ); - -GLAPI void GLAPIENTRY glMultiTexCoord2fv( GLenum target, const GLfloat *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord2i( GLenum target, GLint s, GLint t ); - -GLAPI void GLAPIENTRY glMultiTexCoord2iv( GLenum target, const GLint *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord2s( GLenum target, GLshort s, GLshort t ); - -GLAPI void GLAPIENTRY glMultiTexCoord2sv( GLenum target, const GLshort *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord3d( GLenum target, GLdouble s, GLdouble t, GLdouble r ); - -GLAPI void GLAPIENTRY glMultiTexCoord3dv( GLenum target, const GLdouble *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r ); - -GLAPI void GLAPIENTRY glMultiTexCoord3fv( GLenum target, const GLfloat *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord3i( GLenum target, GLint s, GLint t, GLint r ); - -GLAPI void GLAPIENTRY glMultiTexCoord3iv( GLenum target, const GLint *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord3s( GLenum target, GLshort s, GLshort t, GLshort r ); - -GLAPI void GLAPIENTRY glMultiTexCoord3sv( GLenum target, const GLshort *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord4d( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q ); - -GLAPI void GLAPIENTRY glMultiTexCoord4dv( GLenum target, const GLdouble *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); - -GLAPI void GLAPIENTRY glMultiTexCoord4fv( GLenum target, const GLfloat *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord4i( GLenum target, GLint s, GLint t, GLint r, GLint q ); - -GLAPI void GLAPIENTRY glMultiTexCoord4iv( GLenum target, const GLint *v ); - -GLAPI void GLAPIENTRY glMultiTexCoord4s( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q ); - -GLAPI void GLAPIENTRY glMultiTexCoord4sv( GLenum target, const GLshort *v ); - - -GLAPI void GLAPIENTRY glLoadTransposeMatrixd( const GLdouble m[16] ); - -GLAPI void GLAPIENTRY glLoadTransposeMatrixf( const GLfloat m[16] ); - -GLAPI void GLAPIENTRY glMultTransposeMatrixd( const GLdouble m[16] ); - -GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] ); - -GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert ); - - -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); - - - -/* - * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1) - */ -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 - -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 - -GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture); -GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture); -GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s); -GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v); -GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s); -GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v); -GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s); -GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v); -GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s); -GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v); -GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t); -GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v); -GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); -GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v); -GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t); -GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v); -GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t); -GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v); -GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v); -GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v); -GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r); -GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v); -GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v); -GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v); -GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v); -GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v); -GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v); - -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); - -#endif /* GL_ARB_multitexture */ - - - -/* - * Define this token if you want "old-style" header file behaviour (extensions - * defined in gl.h). Otherwise, extensions will be included from glext.h. - */ -#if !defined(NO_SDL_GLEXT) && !defined(GL_GLEXT_LEGACY) -#include "SDL_opengl_glext.h" -#endif /* GL_GLEXT_LEGACY */ - - - -/* - * ???. GL_MESA_packed_depth_stencil - * XXX obsolete - */ -#ifndef GL_MESA_packed_depth_stencil -#define GL_MESA_packed_depth_stencil 1 - -#define GL_DEPTH_STENCIL_MESA 0x8750 -#define GL_UNSIGNED_INT_24_8_MESA 0x8751 -#define GL_UNSIGNED_INT_8_24_REV_MESA 0x8752 -#define GL_UNSIGNED_SHORT_15_1_MESA 0x8753 -#define GL_UNSIGNED_SHORT_1_15_REV_MESA 0x8754 - -#endif /* GL_MESA_packed_depth_stencil */ - - -#ifndef GL_ATI_blend_equation_separate -#define GL_ATI_blend_equation_separate 1 - -#define GL_ALPHA_BLEND_EQUATION_ATI 0x883D - -GLAPI void GLAPIENTRY glBlendEquationSeparateATI( GLenum modeRGB, GLenum modeA ); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEATIPROC) (GLenum modeRGB, GLenum modeA); - -#endif /* GL_ATI_blend_equation_separate */ - - -/* GL_OES_EGL_image */ -#ifndef GL_OES_EGL_image -typedef void* GLeglImageOES; -#endif - -#ifndef GL_OES_EGL_image -#define GL_OES_EGL_image 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); -GLAPI void APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); -#endif -typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); -typedef void (APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); -#endif - - -/** - ** NOTE!!!!! If you add new functions to this file, or update - ** glext.h be sure to regenerate the gl_mangle.h file. See comments - ** in that file for details. - **/ - - - -/********************************************************************** - * Begin system-specific stuff - */ -#if defined(PRAGMA_EXPORT_SUPPORTED) -#pragma export off -#endif - -/* - * End system-specific stuff - **********************************************************************/ - - -#ifdef __cplusplus -} -#endif - -#endif /* __gl_h_ */ - -#endif /* !__IPHONEOS__ */ - -#endif /* SDL_opengl_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_opengl_glext.h b/thirdparty/include/SDL2/SDL_opengl_glext.h deleted file mode 100644 index 6a402b15a..000000000 --- a/thirdparty/include/SDL2/SDL_opengl_glext.h +++ /dev/null @@ -1,11180 +0,0 @@ -#ifndef __glext_h_ -#define __glext_h_ 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2013-2014 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ -/* -** This header is generated from the Khronos OpenGL / OpenGL ES XML -** API Registry. The current version of the Registry, generator scripts -** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 26745 $ on $Date: 2014-05-21 03:12:26 -0700 (Wed, 21 May 2014) $ -*/ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif -#ifndef NOMINMAX /* don't define min() and max(). */ -#define NOMINMAX -#endif -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -#define GL_GLEXT_VERSION 20140521 - -/* Generated C header for: - * API: gl - * Profile: compatibility - * Versions considered: .* - * Versions emitted: 1\.[2-9]|[234]\.[0-9] - * Default extensions included: gl - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_RESCALE_NORMAL 0x803A -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif -#endif /* GL_VERSION_1_2 */ - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_SUBTRACT 0x84E7 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum texture); -GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); -GLAPI void APIENTRY glClientActiveTexture (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); -#endif -#endif /* GL_VERSION_1_3 */ - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#define GL_FUNC_ADD 0x8006 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); -GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); -GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); -GLAPI void APIENTRY glFogCoordf (GLfloat coord); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); -GLAPI void APIENTRY glFogCoordd (GLdouble coord); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2iv (const GLint *v); -GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); -GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3iv (const GLint *v); -GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); -GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void APIENTRY glBlendEquation (GLenum mode); -#endif -#endif /* GL_VERSION_1_4 */ - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#include -#ifdef __MACOSX__ -typedef long GLsizeiptr; -typedef long GLintptr; -#else -typedef ptrdiff_t GLsizeiptr; -typedef ptrdiff_t GLintptr; -#endif -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#define GL_SRC1_ALPHA 0x8589 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_FOG_COORD_SRC 0x8450 -#define GL_FOG_COORD 0x8451 -#define GL_CURRENT_FOG_COORD 0x8453 -#define GL_FOG_COORD_ARRAY_TYPE 0x8454 -#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORD_ARRAY_POINTER 0x8456 -#define GL_FOG_COORD_ARRAY 0x8457 -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D -#define GL_SRC0_RGB 0x8580 -#define GL_SRC1_RGB 0x8581 -#define GL_SRC2_RGB 0x8582 -#define GL_SRC0_ALPHA 0x8588 -#define GL_SRC2_ALPHA 0x858A -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); -typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQuery (GLuint id); -GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQuery (GLenum target); -GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); -GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); -GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); -GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); -GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); -GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); -#endif -#endif /* GL_VERSION_1_5 */ - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -typedef char GLchar; -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_TEXTURE_COORDS 0x8871 -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); -GLAPI void APIENTRY glCompileShader (GLuint shader); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum type); -GLAPI void APIENTRY glDeleteProgram (GLuint program); -GLAPI void APIENTRY glDeleteShader (GLuint shader); -GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); -GLAPI GLboolean APIENTRY glIsProgram (GLuint program); -GLAPI GLboolean APIENTRY glIsShader (GLuint shader); -GLAPI void APIENTRY glLinkProgram (GLuint program); -GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); -GLAPI void APIENTRY glUseProgram (GLuint program); -GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glValidateProgram (GLuint program); -GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -#endif -#endif /* GL_VERSION_2_0 */ - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#define GL_SLUMINANCE_ALPHA 0x8C44 -#define GL_SLUMINANCE8_ALPHA8 0x8C45 -#define GL_SLUMINANCE 0x8C46 -#define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SLUMINANCE 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif -#endif /* GL_VERSION_2_1 */ - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 -typedef unsigned short GLhalf; -#define GL_COMPARE_REF_TO_TEXTURE 0x884E -#define GL_CLIP_DISTANCE0 0x3000 -#define GL_CLIP_DISTANCE1 0x3001 -#define GL_CLIP_DISTANCE2 0x3002 -#define GL_CLIP_DISTANCE3 0x3003 -#define GL_CLIP_DISTANCE4 0x3004 -#define GL_CLIP_DISTANCE5 0x3005 -#define GL_CLIP_DISTANCE6 0x3006 -#define GL_CLIP_DISTANCE7 0x3007 -#define GL_MAX_CLIP_DISTANCES 0x0D32 -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_CONTEXT_FLAGS 0x821E -#define GL_COMPRESSED_RED 0x8225 -#define GL_COMPRESSED_RG 0x8226 -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 -#define GL_RGBA32F 0x8814 -#define GL_RGB32F 0x8815 -#define GL_RGBA16F 0x881A -#define GL_RGB16F 0x881B -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_CLAMP_READ_COLOR 0x891C -#define GL_FIXED_ONLY 0x891D -#define GL_MAX_VARYING_COMPONENTS 0x8B4B -#define GL_TEXTURE_1D_ARRAY 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define GL_R11F_G11F_B10F 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define GL_RGB9_E5 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define GL_PRIMITIVES_GENERATED 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define GL_RASTERIZER_DISCARD 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define GL_INTERLEAVED_ATTRIBS 0x8C8C -#define GL_SEPARATE_ATTRIBS 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define GL_RGBA32UI 0x8D70 -#define GL_RGB32UI 0x8D71 -#define GL_RGBA16UI 0x8D76 -#define GL_RGB16UI 0x8D77 -#define GL_RGBA8UI 0x8D7C -#define GL_RGB8UI 0x8D7D -#define GL_RGBA32I 0x8D82 -#define GL_RGB32I 0x8D83 -#define GL_RGBA16I 0x8D88 -#define GL_RGB16I 0x8D89 -#define GL_RGBA8I 0x8D8E -#define GL_RGB8I 0x8D8F -#define GL_RED_INTEGER 0x8D94 -#define GL_GREEN_INTEGER 0x8D95 -#define GL_BLUE_INTEGER 0x8D96 -#define GL_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_BGR_INTEGER 0x8D9A -#define GL_BGRA_INTEGER 0x8D9B -#define GL_SAMPLER_1D_ARRAY 0x8DC0 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define GL_UNSIGNED_INT_VEC2 0x8DC6 -#define GL_UNSIGNED_INT_VEC3 0x8DC7 -#define GL_UNSIGNED_INT_VEC4 0x8DC8 -#define GL_INT_SAMPLER_1D 0x8DC9 -#define GL_INT_SAMPLER_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define GL_QUERY_WAIT 0x8E13 -#define GL_QUERY_NO_WAIT 0x8E14 -#define GL_QUERY_BY_REGION_WAIT 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 -#define GL_BUFFER_ACCESS_FLAGS 0x911F -#define GL_BUFFER_MAP_LENGTH 0x9120 -#define GL_BUFFER_MAP_OFFSET 0x9121 -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#define GL_INDEX 0x8222 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#define GL_HALF_FLOAT 0x140B -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B -#define GL_ALPHA_INTEGER 0x8D97 -typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); -GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); -GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedback (void); -GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); -GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRender (void); -GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); -GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); -GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); -GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); -GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); -GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmap (GLenum target); -GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glBindVertexArray (GLuint array); -GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); -#endif -#endif /* GL_VERSION_3_0 */ - -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 -#define GL_SAMPLER_2D_RECT 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_2D_RECT 0x8DCD -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -#define GL_TEXTURE_BUFFER 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D -#define GL_TEXTURE_RECTANGLE 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART 0x8F9D -#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -#define GL_INVALID_INDEX 0xFFFFFFFFu -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); -typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); -typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); -GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); -GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); -GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); -GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); -GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif -#endif /* GL_VERSION_3_1 */ - -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 -typedef struct __GLsync *GLsync; -#ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glxext.h, so must be protected */ -#define GLEXT_64_TYPES_DEFINED -/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ -/* (as used in the GL_EXT_timer_query extension). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -#elif defined(__sun__) || defined(__digital__) -#include -#if defined(__STDC__) -#if defined(__arch64__) || defined(_LP64) -typedef long int int64_t; -typedef unsigned long int uint64_t; -#else -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#endif /* __arch64__ */ -#endif /* __STDC__ */ -#elif defined( __VMS ) || defined(__sgi) -#include -#elif defined(__SCO__) || defined(__USLC__) -#include -#elif defined(__UNIXOS2__) || defined(__SOL64__) -typedef long int int32_t; -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#elif defined(_WIN32) && defined(__GNUC__) -#include -#elif defined(_WIN32) -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -/* Fallback if nothing above works */ -#include -#endif -#endif -typedef uint64_t GLuint64; -typedef int64_t GLint64; -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_PROGRAM_POINT_SIZE 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_CONTEXT_PROFILE_MASK 0x9126 -#define GL_DEPTH_CLAMP 0x864F -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 -typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); -typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); -typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); -typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); -typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); -typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); -GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); -GLAPI void APIENTRY glProvokingVertex (GLenum mode); -GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); -GLAPI GLboolean APIENTRY glIsSync (GLsync sync); -GLAPI void APIENTRY glDeleteSync (GLsync sync); -GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); -GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); -GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); -#endif -#endif /* GL_VERSION_3_2 */ - -#ifndef GL_VERSION_3_3 -#define GL_VERSION_3_3 1 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -#define GL_SRC1_COLOR 0x88F9 -#define GL_ONE_MINUS_SRC1_COLOR 0x88FA -#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB -#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#define GL_SAMPLER_BINDING 0x8919 -#define GL_RGB10_A2UI 0x906F -#define GL_TEXTURE_SWIZZLE_R 0x8E42 -#define GL_TEXTURE_SWIZZLE_G 0x8E43 -#define GL_TEXTURE_SWIZZLE_B 0x8E44 -#define GL_TEXTURE_SWIZZLE_A 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 -#define GL_TIME_ELAPSED 0x88BF -#define GL_TIMESTAMP 0x8E28 -#define GL_INT_2_10_10_10_REV 0x8D9F -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); -typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); -typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); -typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); -GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); -GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); -GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); -GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); -GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); -GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); -GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); -GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); -GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); -GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); -GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); -#endif -#endif /* GL_VERSION_3_3 */ - -#ifndef GL_VERSION_4_0 -#define GL_VERSION_4_0 1 -#define GL_SAMPLE_SHADING 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F -#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F -#define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 -#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C -#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D -#define GL_MAX_VERTEX_STREAMS 0x8E71 -#define GL_DOUBLE_VEC2 0x8FFC -#define GL_DOUBLE_VEC3 0x8FFD -#define GL_DOUBLE_VEC4 0x8FFE -#define GL_DOUBLE_MAT2 0x8F46 -#define GL_DOUBLE_MAT3 0x8F47 -#define GL_DOUBLE_MAT4 0x8F48 -#define GL_DOUBLE_MAT2x3 0x8F49 -#define GL_DOUBLE_MAT2x4 0x8F4A -#define GL_DOUBLE_MAT3x2 0x8F4B -#define GL_DOUBLE_MAT3x4 0x8F4C -#define GL_DOUBLE_MAT4x2 0x8F4D -#define GL_DOUBLE_MAT4x3 0x8F4E -#define GL_ACTIVE_SUBROUTINES 0x8DE5 -#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 -#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 -#define GL_MAX_SUBROUTINES 0x8DE7 -#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 -#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A -#define GL_COMPATIBLE_SUBROUTINES 0x8E4B -#define GL_PATCHES 0x000E -#define GL_PATCH_VERTICES 0x8E72 -#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 -#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 -#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 -#define GL_TESS_GEN_MODE 0x8E76 -#define GL_TESS_GEN_SPACING 0x8E77 -#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 -#define GL_TESS_GEN_POINT_MODE 0x8E79 -#define GL_ISOLINES 0x8E7A -#define GL_FRACTIONAL_ODD 0x8E7B -#define GL_FRACTIONAL_EVEN 0x8E7C -#define GL_MAX_PATCH_VERTICES 0x8E7D -#define GL_MAX_TESS_GEN_LEVEL 0x8E7E -#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F -#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 -#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 -#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 -#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 -#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 -#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 -#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 -#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 -#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A -#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C -#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D -#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E -#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 -#define GL_TESS_EVALUATION_SHADER 0x8E87 -#define GL_TESS_CONTROL_SHADER 0x8E88 -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); -typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); -typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); -typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); -typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); -typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShading (GLfloat value); -GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); -GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); -GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); -GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); -GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); -GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); -GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); -GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); -GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedback (void); -GLAPI void APIENTRY glResumeTransformFeedback (void); -GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); -GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); -GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); -GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); -GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif -#endif /* GL_VERSION_4_0 */ - -#ifndef GL_VERSION_4_1 -#define GL_VERSION_4_1 1 -#define GL_FIXED 0x140C -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_RGB565 0x8D62 -#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -#define GL_PROGRAM_BINARY_LENGTH 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE -#define GL_PROGRAM_BINARY_FORMATS 0x87FF -#define GL_VERTEX_SHADER_BIT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#define GL_GEOMETRY_SHADER_BIT 0x00000004 -#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -#define GL_ALL_SHADER_BITS 0xFFFFFFFF -#define GL_PROGRAM_SEPARABLE 0x8258 -#define GL_ACTIVE_PROGRAM 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING 0x825A -#define GL_MAX_VIEWPORTS 0x825B -#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C -#define GL_VIEWPORT_BOUNDS_RANGE 0x825D -#define GL_LAYER_PROVOKING_VERTEX 0x825E -#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F -#define GL_UNDEFINED_VERTEX 0x8260 -typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); -typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); -typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); -typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); -typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); -typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); -typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); -typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); -typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); -typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReleaseShaderCompiler (void); -GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); -GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); -GLAPI void APIENTRY glClearDepthf (GLfloat d); -GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); -GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); -GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); -GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); -GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); -GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); -GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); -GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); -GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); -GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); -GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); -GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); -GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); -GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); -#endif -#endif /* GL_VERSION_4_1 */ - -#ifndef GL_VERSION_4_2 -#define GL_VERSION_4_2 1 -#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 -#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 -#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 -#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A -#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B -#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C -#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D -#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC -#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 -#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB -#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF -#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 -#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 -#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 -#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 -#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC -#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 -#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA -#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 -#define GL_COMMAND_BARRIER_BIT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 -#define GL_ALL_BARRIER_BITS 0xFFFFFFFF -#define GL_MAX_IMAGE_UNITS 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 -#define GL_IMAGE_BINDING_NAME 0x8F3A -#define GL_IMAGE_BINDING_LEVEL 0x8F3B -#define GL_IMAGE_BINDING_LAYERED 0x8F3C -#define GL_IMAGE_BINDING_LAYER 0x8F3D -#define GL_IMAGE_BINDING_ACCESS 0x8F3E -#define GL_IMAGE_1D 0x904C -#define GL_IMAGE_2D 0x904D -#define GL_IMAGE_3D 0x904E -#define GL_IMAGE_2D_RECT 0x904F -#define GL_IMAGE_CUBE 0x9050 -#define GL_IMAGE_BUFFER 0x9051 -#define GL_IMAGE_1D_ARRAY 0x9052 -#define GL_IMAGE_2D_ARRAY 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 -#define GL_INT_IMAGE_1D 0x9057 -#define GL_INT_IMAGE_2D 0x9058 -#define GL_INT_IMAGE_3D 0x9059 -#define GL_INT_IMAGE_2D_RECT 0x905A -#define GL_INT_IMAGE_CUBE 0x905B -#define GL_INT_IMAGE_BUFFER 0x905C -#define GL_INT_IMAGE_1D_ARRAY 0x905D -#define GL_INT_IMAGE_2D_ARRAY 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C -#define GL_MAX_IMAGE_SAMPLES 0x906D -#define GL_IMAGE_BINDING_FORMAT 0x906E -#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 -#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD -#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F -#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); -typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); -GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); -GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); -#endif -#endif /* GL_VERSION_4_2 */ - -#ifndef GL_VERSION_4_3 -#define GL_VERSION_4_3 1 -typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 -#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E -#define GL_COMPRESSED_RGB8_ETC2 0x9274 -#define GL_COMPRESSED_SRGB8_ETC2 0x9275 -#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 -#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 -#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 -#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 -#define GL_COMPRESSED_R11_EAC 0x9270 -#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 -#define GL_COMPRESSED_RG11_EAC 0x9272 -#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 -#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 -#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A -#define GL_MAX_ELEMENT_INDEX 0x8D6B -#define GL_COMPUTE_SHADER 0x91B9 -#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB -#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC -#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD -#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 -#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 -#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 -#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 -#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 -#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB -#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE -#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF -#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED -#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE -#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF -#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 -#define GL_DEBUG_SOURCE_API 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION 0x824A -#define GL_DEBUG_SOURCE_OTHER 0x824B -#define GL_DEBUG_TYPE_ERROR 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E -#define GL_DEBUG_TYPE_PORTABILITY 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 -#define GL_DEBUG_TYPE_OTHER 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES 0x9145 -#define GL_DEBUG_SEVERITY_HIGH 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 -#define GL_DEBUG_SEVERITY_LOW 0x9148 -#define GL_DEBUG_TYPE_MARKER 0x8268 -#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 -#define GL_DEBUG_TYPE_POP_GROUP 0x826A -#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B -#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C -#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D -#define GL_BUFFER 0x82E0 -#define GL_SHADER 0x82E1 -#define GL_PROGRAM 0x82E2 -#define GL_QUERY 0x82E3 -#define GL_PROGRAM_PIPELINE 0x82E4 -#define GL_SAMPLER 0x82E6 -#define GL_MAX_LABEL_LENGTH 0x82E8 -#define GL_DEBUG_OUTPUT 0x92E0 -#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 -#define GL_MAX_UNIFORM_LOCATIONS 0x826E -#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 -#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 -#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 -#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 -#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 -#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 -#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 -#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 -#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 -#define GL_INTERNALFORMAT_SUPPORTED 0x826F -#define GL_INTERNALFORMAT_PREFERRED 0x8270 -#define GL_INTERNALFORMAT_RED_SIZE 0x8271 -#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 -#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 -#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 -#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 -#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 -#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 -#define GL_INTERNALFORMAT_RED_TYPE 0x8278 -#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 -#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A -#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B -#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C -#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D -#define GL_MAX_WIDTH 0x827E -#define GL_MAX_HEIGHT 0x827F -#define GL_MAX_DEPTH 0x8280 -#define GL_MAX_LAYERS 0x8281 -#define GL_MAX_COMBINED_DIMENSIONS 0x8282 -#define GL_COLOR_COMPONENTS 0x8283 -#define GL_DEPTH_COMPONENTS 0x8284 -#define GL_STENCIL_COMPONENTS 0x8285 -#define GL_COLOR_RENDERABLE 0x8286 -#define GL_DEPTH_RENDERABLE 0x8287 -#define GL_STENCIL_RENDERABLE 0x8288 -#define GL_FRAMEBUFFER_RENDERABLE 0x8289 -#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A -#define GL_FRAMEBUFFER_BLEND 0x828B -#define GL_READ_PIXELS 0x828C -#define GL_READ_PIXELS_FORMAT 0x828D -#define GL_READ_PIXELS_TYPE 0x828E -#define GL_TEXTURE_IMAGE_FORMAT 0x828F -#define GL_TEXTURE_IMAGE_TYPE 0x8290 -#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 -#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 -#define GL_MIPMAP 0x8293 -#define GL_MANUAL_GENERATE_MIPMAP 0x8294 -#define GL_AUTO_GENERATE_MIPMAP 0x8295 -#define GL_COLOR_ENCODING 0x8296 -#define GL_SRGB_READ 0x8297 -#define GL_SRGB_WRITE 0x8298 -#define GL_FILTER 0x829A -#define GL_VERTEX_TEXTURE 0x829B -#define GL_TESS_CONTROL_TEXTURE 0x829C -#define GL_TESS_EVALUATION_TEXTURE 0x829D -#define GL_GEOMETRY_TEXTURE 0x829E -#define GL_FRAGMENT_TEXTURE 0x829F -#define GL_COMPUTE_TEXTURE 0x82A0 -#define GL_TEXTURE_SHADOW 0x82A1 -#define GL_TEXTURE_GATHER 0x82A2 -#define GL_TEXTURE_GATHER_SHADOW 0x82A3 -#define GL_SHADER_IMAGE_LOAD 0x82A4 -#define GL_SHADER_IMAGE_STORE 0x82A5 -#define GL_SHADER_IMAGE_ATOMIC 0x82A6 -#define GL_IMAGE_TEXEL_SIZE 0x82A7 -#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 -#define GL_IMAGE_PIXEL_FORMAT 0x82A9 -#define GL_IMAGE_PIXEL_TYPE 0x82AA -#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC -#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD -#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE -#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF -#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 -#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 -#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 -#define GL_CLEAR_BUFFER 0x82B4 -#define GL_TEXTURE_VIEW 0x82B5 -#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 -#define GL_FULL_SUPPORT 0x82B7 -#define GL_CAVEAT_SUPPORT 0x82B8 -#define GL_IMAGE_CLASS_4_X_32 0x82B9 -#define GL_IMAGE_CLASS_2_X_32 0x82BA -#define GL_IMAGE_CLASS_1_X_32 0x82BB -#define GL_IMAGE_CLASS_4_X_16 0x82BC -#define GL_IMAGE_CLASS_2_X_16 0x82BD -#define GL_IMAGE_CLASS_1_X_16 0x82BE -#define GL_IMAGE_CLASS_4_X_8 0x82BF -#define GL_IMAGE_CLASS_2_X_8 0x82C0 -#define GL_IMAGE_CLASS_1_X_8 0x82C1 -#define GL_IMAGE_CLASS_11_11_10 0x82C2 -#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 -#define GL_VIEW_CLASS_128_BITS 0x82C4 -#define GL_VIEW_CLASS_96_BITS 0x82C5 -#define GL_VIEW_CLASS_64_BITS 0x82C6 -#define GL_VIEW_CLASS_48_BITS 0x82C7 -#define GL_VIEW_CLASS_32_BITS 0x82C8 -#define GL_VIEW_CLASS_24_BITS 0x82C9 -#define GL_VIEW_CLASS_16_BITS 0x82CA -#define GL_VIEW_CLASS_8_BITS 0x82CB -#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC -#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD -#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE -#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF -#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 -#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 -#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 -#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 -#define GL_UNIFORM 0x92E1 -#define GL_UNIFORM_BLOCK 0x92E2 -#define GL_PROGRAM_INPUT 0x92E3 -#define GL_PROGRAM_OUTPUT 0x92E4 -#define GL_BUFFER_VARIABLE 0x92E5 -#define GL_SHADER_STORAGE_BLOCK 0x92E6 -#define GL_VERTEX_SUBROUTINE 0x92E8 -#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 -#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA -#define GL_GEOMETRY_SUBROUTINE 0x92EB -#define GL_FRAGMENT_SUBROUTINE 0x92EC -#define GL_COMPUTE_SUBROUTINE 0x92ED -#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE -#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF -#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 -#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 -#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 -#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 -#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 -#define GL_ACTIVE_RESOURCES 0x92F5 -#define GL_MAX_NAME_LENGTH 0x92F6 -#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 -#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 -#define GL_NAME_LENGTH 0x92F9 -#define GL_TYPE 0x92FA -#define GL_ARRAY_SIZE 0x92FB -#define GL_OFFSET 0x92FC -#define GL_BLOCK_INDEX 0x92FD -#define GL_ARRAY_STRIDE 0x92FE -#define GL_MATRIX_STRIDE 0x92FF -#define GL_IS_ROW_MAJOR 0x9300 -#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 -#define GL_BUFFER_BINDING 0x9302 -#define GL_BUFFER_DATA_SIZE 0x9303 -#define GL_NUM_ACTIVE_VARIABLES 0x9304 -#define GL_ACTIVE_VARIABLES 0x9305 -#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 -#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 -#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 -#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 -#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A -#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B -#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C -#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D -#define GL_LOCATION 0x930E -#define GL_LOCATION_INDEX 0x930F -#define GL_IS_PER_PATCH 0x92E7 -#define GL_SHADER_STORAGE_BUFFER 0x90D2 -#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 -#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 -#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 -#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 -#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 -#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 -#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 -#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA -#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB -#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC -#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD -#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE -#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF -#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 -#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 -#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA -#define GL_TEXTURE_BUFFER_OFFSET 0x919D -#define GL_TEXTURE_BUFFER_SIZE 0x919E -#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F -#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB -#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC -#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD -#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE -#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF -#define GL_VERTEX_ATTRIB_BINDING 0x82D4 -#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 -#define GL_VERTEX_BINDING_DIVISOR 0x82D6 -#define GL_VERTEX_BINDING_OFFSET 0x82D7 -#define GL_VERTEX_BINDING_STRIDE 0x82D8 -#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 -#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA -#define GL_VERTEX_BINDING_BUFFER 0x8F4F -#define GL_DISPLAY_LIST 0x82E7 -typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); -typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); -typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); -typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); -typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); -typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); -typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); -typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); -typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); -typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); -typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); -typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); -typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); -typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); -GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); -GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); -GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); -GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); -GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); -GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); -GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); -GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); -GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); -GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); -GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); -GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); -GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); -GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); -GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); -GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); -GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); -GLAPI void APIENTRY glPopDebugGroup (void); -GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); -GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); -GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); -GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); -#endif -#endif /* GL_VERSION_4_3 */ - -#ifndef GL_VERSION_4_4 -#define GL_VERSION_4_4 1 -#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 -#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 -#define GL_TEXTURE_BUFFER_BINDING 0x8C2A -#define GL_MAP_PERSISTENT_BIT 0x0040 -#define GL_MAP_COHERENT_BIT 0x0080 -#define GL_DYNAMIC_STORAGE_BIT 0x0100 -#define GL_CLIENT_STORAGE_BIT 0x0200 -#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 -#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F -#define GL_BUFFER_STORAGE_FLAGS 0x8220 -#define GL_CLEAR_TEXTURE 0x9365 -#define GL_LOCATION_COMPONENT 0x934A -#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B -#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C -#define GL_QUERY_BUFFER 0x9192 -#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 -#define GL_QUERY_BUFFER_BINDING 0x9193 -#define GL_QUERY_RESULT_NO_WAIT 0x9194 -#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 -typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); -typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); -typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); -typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); -typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); -typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); -typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); -GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); -GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); -GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); -GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); -GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); -GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); -#endif -#endif /* GL_VERSION_4_4 */ - -#ifndef GL_ARB_ES2_compatibility -#define GL_ARB_ES2_compatibility 1 -#endif /* GL_ARB_ES2_compatibility */ - -#ifndef GL_ARB_ES3_compatibility -#define GL_ARB_ES3_compatibility 1 -#endif /* GL_ARB_ES3_compatibility */ - -#ifndef GL_ARB_arrays_of_arrays -#define GL_ARB_arrays_of_arrays 1 -#endif /* GL_ARB_arrays_of_arrays */ - -#ifndef GL_ARB_base_instance -#define GL_ARB_base_instance 1 -#endif /* GL_ARB_base_instance */ - -#ifndef GL_ARB_bindless_texture -#define GL_ARB_bindless_texture 1 -typedef uint64_t GLuint64EXT; -#define GL_UNSIGNED_INT64_ARB 0x140F -typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); -typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); -typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); -typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); -GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); -GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); -GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); -GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); -GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); -GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); -GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); -GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); -GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); -GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); -GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); -#endif -#endif /* GL_ARB_bindless_texture */ - -#ifndef GL_ARB_blend_func_extended -#define GL_ARB_blend_func_extended 1 -#endif /* GL_ARB_blend_func_extended */ - -#ifndef GL_ARB_buffer_storage -#define GL_ARB_buffer_storage 1 -#endif /* GL_ARB_buffer_storage */ - -#ifndef GL_ARB_cl_event -#define GL_ARB_cl_event 1 -struct _cl_context; -struct _cl_event; -#define GL_SYNC_CL_EVENT_ARB 0x8240 -#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 -typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); -#endif -#endif /* GL_ARB_cl_event */ - -#ifndef GL_ARB_clear_buffer_object -#define GL_ARB_clear_buffer_object 1 -#endif /* GL_ARB_clear_buffer_object */ - -#ifndef GL_ARB_clear_texture -#define GL_ARB_clear_texture 1 -#endif /* GL_ARB_clear_texture */ - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); -#endif -#endif /* GL_ARB_color_buffer_float */ - -#ifndef GL_ARB_compatibility -#define GL_ARB_compatibility 1 -#endif /* GL_ARB_compatibility */ - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_ARB_compressed_texture_pixel_storage 1 -#endif /* GL_ARB_compressed_texture_pixel_storage */ - -#ifndef GL_ARB_compute_shader -#define GL_ARB_compute_shader 1 -#define GL_COMPUTE_SHADER_BIT 0x00000020 -#endif /* GL_ARB_compute_shader */ - -#ifndef GL_ARB_compute_variable_group_size -#define GL_ARB_compute_variable_group_size 1 -#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 -#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB -#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 -#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); -#endif -#endif /* GL_ARB_compute_variable_group_size */ - -#ifndef GL_ARB_conservative_depth -#define GL_ARB_conservative_depth 1 -#endif /* GL_ARB_conservative_depth */ - -#ifndef GL_ARB_copy_buffer -#define GL_ARB_copy_buffer 1 -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 -#endif /* GL_ARB_copy_buffer */ - -#ifndef GL_ARB_copy_image -#define GL_ARB_copy_image 1 -#endif /* GL_ARB_copy_image */ - -#ifndef GL_ARB_debug_output -#define GL_ARB_debug_output 1 -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 -#define GL_DEBUG_SOURCE_API_ARB 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A -#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B -#define GL_DEBUG_TYPE_ERROR_ARB 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E -#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 -#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 -#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif -#endif /* GL_ARB_debug_output */ - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 -#endif /* GL_ARB_depth_buffer_float */ - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp 1 -#endif /* GL_ARB_depth_clamp */ - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif /* GL_ARB_depth_texture */ - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); -#endif -#endif /* GL_ARB_draw_buffers */ - -#ifndef GL_ARB_draw_buffers_blend -#define GL_ARB_draw_buffers_blend 1 -typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif -#endif /* GL_ARB_draw_buffers_blend */ - -#ifndef GL_ARB_draw_elements_base_vertex -#define GL_ARB_draw_elements_base_vertex 1 -#endif /* GL_ARB_draw_elements_base_vertex */ - -#ifndef GL_ARB_draw_indirect -#define GL_ARB_draw_indirect 1 -#endif /* GL_ARB_draw_indirect */ - -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -#endif -#endif /* GL_ARB_draw_instanced */ - -#ifndef GL_ARB_enhanced_layouts -#define GL_ARB_enhanced_layouts 1 -#endif /* GL_ARB_enhanced_layouts */ - -#ifndef GL_ARB_explicit_attrib_location -#define GL_ARB_explicit_attrib_location 1 -#endif /* GL_ARB_explicit_attrib_location */ - -#ifndef GL_ARB_explicit_uniform_location -#define GL_ARB_explicit_uniform_location 1 -#endif /* GL_ARB_explicit_uniform_location */ - -#ifndef GL_ARB_fragment_coord_conventions -#define GL_ARB_fragment_coord_conventions 1 -#endif /* GL_ARB_fragment_coord_conventions */ - -#ifndef GL_ARB_fragment_layer_viewport -#define GL_ARB_fragment_layer_viewport 1 -#endif /* GL_ARB_fragment_layer_viewport */ - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); -GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); -#endif -#endif /* GL_ARB_fragment_program */ - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif /* GL_ARB_fragment_program_shadow */ - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif /* GL_ARB_fragment_shader */ - -#ifndef GL_ARB_framebuffer_no_attachments -#define GL_ARB_framebuffer_no_attachments 1 -#endif /* GL_ARB_framebuffer_no_attachments */ - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 -#endif /* GL_ARB_framebuffer_object */ - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 -#endif /* GL_ARB_framebuffer_sRGB */ - -#ifndef GL_KHR_context_flush_control -#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB -#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC -#endif /* GL_KHR_context_flush_control */ - -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 -#define GL_LINES_ADJACENCY_ARB 0x000A -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B -#define GL_TRIANGLES_ADJACENCY_ARB 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); -GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif -#endif /* GL_ARB_geometry_shader4 */ - -#ifndef GL_ARB_get_program_binary -#define GL_ARB_get_program_binary 1 -#endif /* GL_ARB_get_program_binary */ - -#ifndef GL_ARB_gpu_shader5 -#define GL_ARB_gpu_shader5 1 -#endif /* GL_ARB_gpu_shader5 */ - -#ifndef GL_ARB_gpu_shader_fp64 -#define GL_ARB_gpu_shader_fp64 1 -#endif /* GL_ARB_gpu_shader_fp64 */ - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -typedef unsigned short GLhalfARB; -#define GL_HALF_FLOAT_ARB 0x140B -#endif /* GL_ARB_half_float_pixel */ - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 -#endif /* GL_ARB_half_float_vertex */ - -#ifndef GL_ARB_imaging -#define GL_ARB_imaging 1 -#define GL_BLEND_COLOR 0x8005 -#define GL_BLEND_EQUATION 0x8009 -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); -GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogram (GLenum target); -GLAPI void APIENTRY glResetMinmax (GLenum target); -#endif -#endif /* GL_ARB_imaging */ - -#ifndef GL_ARB_indirect_parameters -#define GL_ARB_indirect_parameters 1 -#define GL_PARAMETER_BUFFER_ARB 0x80EE -#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -#endif -#endif /* GL_ARB_indirect_parameters */ - -#ifndef GL_ARB_instanced_arrays -#define GL_ARB_instanced_arrays 1 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); -#endif -#endif /* GL_ARB_instanced_arrays */ - -#ifndef GL_ARB_internalformat_query -#define GL_ARB_internalformat_query 1 -#endif /* GL_ARB_internalformat_query */ - -#ifndef GL_ARB_internalformat_query2 -#define GL_ARB_internalformat_query2 1 -#define GL_SRGB_DECODE_ARB 0x8299 -#endif /* GL_ARB_internalformat_query2 */ - -#ifndef GL_ARB_invalidate_subdata -#define GL_ARB_invalidate_subdata 1 -#endif /* GL_ARB_invalidate_subdata */ - -#ifndef GL_ARB_map_buffer_alignment -#define GL_ARB_map_buffer_alignment 1 -#endif /* GL_ARB_map_buffer_alignment */ - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 -#endif /* GL_ARB_map_buffer_range */ - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_ARB_matrix_palette */ - -#ifndef GL_ARB_multi_bind -#define GL_ARB_multi_bind 1 -#endif /* GL_ARB_multi_bind */ - -#ifndef GL_ARB_multi_draw_indirect -#define GL_ARB_multi_draw_indirect 1 -#endif /* GL_ARB_multi_draw_indirect */ - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); -#endif -#endif /* GL_ARB_multisample */ - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); -#endif -#endif /* GL_ARB_multitexture */ - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); -GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQueryARB (GLenum target); -GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); -#endif -#endif /* GL_ARB_occlusion_query */ - -#ifndef GL_ARB_occlusion_query2 -#define GL_ARB_occlusion_query2 1 -#endif /* GL_ARB_occlusion_query2 */ - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif /* GL_ARB_pixel_buffer_object */ - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); -#endif -#endif /* GL_ARB_point_parameters */ - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif /* GL_ARB_point_sprite */ - -#ifndef GL_ARB_program_interface_query -#define GL_ARB_program_interface_query 1 -#endif /* GL_ARB_program_interface_query */ - -#ifndef GL_ARB_provoking_vertex -#define GL_ARB_provoking_vertex 1 -#endif /* GL_ARB_provoking_vertex */ - -#ifndef GL_ARB_query_buffer_object -#define GL_ARB_query_buffer_object 1 -#endif /* GL_ARB_query_buffer_object */ - -#ifndef GL_ARB_robust_buffer_access_behavior -#define GL_ARB_robust_buffer_access_behavior 1 -#endif /* GL_ARB_robust_buffer_access_behavior */ - -#ifndef GL_ARB_robustness -#define GL_ARB_robustness 1 -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 -typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); -typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); -typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); -typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); -typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); -typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); -typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); -typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); -typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); -typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); -GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); -GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); -GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); -GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); -GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); -GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); -GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); -GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); -GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); -GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); -GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); -#endif -#endif /* GL_ARB_robustness */ - -#ifndef GL_ARB_robustness_isolation -#define GL_ARB_robustness_isolation 1 -#endif /* GL_ARB_robustness_isolation */ - -#ifndef GL_ARB_sample_shading -#define GL_ARB_sample_shading 1 -#define GL_SAMPLE_SHADING_ARB 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); -#endif -#endif /* GL_ARB_sample_shading */ - -#ifndef GL_ARB_sampler_objects -#define GL_ARB_sampler_objects 1 -#endif /* GL_ARB_sampler_objects */ - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map 1 -#endif /* GL_ARB_seamless_cube_map */ - -#ifndef GL_ARB_seamless_cubemap_per_texture -#define GL_ARB_seamless_cubemap_per_texture 1 -#endif /* GL_ARB_seamless_cubemap_per_texture */ - -#ifndef GL_ARB_separate_shader_objects -#define GL_ARB_separate_shader_objects 1 -#endif /* GL_ARB_separate_shader_objects */ - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ARB_shader_atomic_counters 1 -#endif /* GL_ARB_shader_atomic_counters */ - -#ifndef GL_ARB_shader_bit_encoding -#define GL_ARB_shader_bit_encoding 1 -#endif /* GL_ARB_shader_bit_encoding */ - -#ifndef GL_ARB_shader_draw_parameters -#define GL_ARB_shader_draw_parameters 1 -#endif /* GL_ARB_shader_draw_parameters */ - -#ifndef GL_ARB_shader_group_vote -#define GL_ARB_shader_group_vote 1 -#endif /* GL_ARB_shader_group_vote */ - -#ifndef GL_ARB_shader_image_load_store -#define GL_ARB_shader_image_load_store 1 -#endif /* GL_ARB_shader_image_load_store */ - -#ifndef GL_ARB_shader_image_size -#define GL_ARB_shader_image_size 1 -#endif /* GL_ARB_shader_image_size */ - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef __APPLE__ -typedef void *GLhandleARB; -#else -typedef unsigned int GLhandleARB; -#endif -typedef char GLcharARB; -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif -#endif /* GL_ARB_shader_objects */ - -#ifndef GL_ARB_shader_precision -#define GL_ARB_shader_precision 1 -#endif /* GL_ARB_shader_precision */ - -#ifndef GL_ARB_shader_stencil_export -#define GL_ARB_shader_stencil_export 1 -#endif /* GL_ARB_shader_stencil_export */ - -#ifndef GL_ARB_shader_storage_buffer_object -#define GL_ARB_shader_storage_buffer_object 1 -#endif /* GL_ARB_shader_storage_buffer_object */ - -#ifndef GL_ARB_shader_subroutine -#define GL_ARB_shader_subroutine 1 -#endif /* GL_ARB_shader_subroutine */ - -#ifndef GL_ARB_shader_texture_lod -#define GL_ARB_shader_texture_lod 1 -#endif /* GL_ARB_shader_texture_lod */ - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif /* GL_ARB_shading_language_100 */ - -#ifndef GL_ARB_shading_language_420pack -#define GL_ARB_shading_language_420pack 1 -#endif /* GL_ARB_shading_language_420pack */ - -#ifndef GL_ARB_shading_language_include -#define GL_ARB_shading_language_include 1 -#define GL_SHADER_INCLUDE_ARB 0x8DAE -#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 -#define GL_NAMED_STRING_TYPE_ARB 0x8DEA -typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); -typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); -GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif -#endif /* GL_ARB_shading_language_include */ - -#ifndef GL_ARB_shading_language_packing -#define GL_ARB_shading_language_packing 1 -#endif /* GL_ARB_shading_language_packing */ - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif /* GL_ARB_shadow */ - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif /* GL_ARB_shadow_ambient */ - -#ifndef GL_ARB_sparse_texture -#define GL_ARB_sparse_texture 1 -#define GL_TEXTURE_SPARSE_ARB 0x91A6 -#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 -#define GL_MIN_SPARSE_LEVEL_ARB 0x919B -#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 -#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 -#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 -#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 -#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 -#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 -#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A -#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 -typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); -#endif -#endif /* GL_ARB_sparse_texture */ - -#ifndef GL_ARB_stencil_texturing -#define GL_ARB_stencil_texturing 1 -#endif /* GL_ARB_stencil_texturing */ - -#ifndef GL_ARB_sync -#define GL_ARB_sync 1 -#endif /* GL_ARB_sync */ - -#ifndef GL_ARB_tessellation_shader -#define GL_ARB_tessellation_shader 1 -#endif /* GL_ARB_tessellation_shader */ - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif /* GL_ARB_texture_border_clamp */ - -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E -typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); -#endif -#endif /* GL_ARB_texture_buffer_object */ - -#ifndef GL_ARB_texture_buffer_object_rgb32 -#define GL_ARB_texture_buffer_object_rgb32 1 -#endif /* GL_ARB_texture_buffer_object_rgb32 */ - -#ifndef GL_ARB_texture_buffer_range -#define GL_ARB_texture_buffer_range 1 -#endif /* GL_ARB_texture_buffer_range */ - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); -#endif -#endif /* GL_ARB_texture_compression */ - -#ifndef GL_ARB_texture_compression_bptc -#define GL_ARB_texture_compression_bptc 1 -#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F -#endif /* GL_ARB_texture_compression_bptc */ - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 -#endif /* GL_ARB_texture_compression_rgtc */ - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif /* GL_ARB_texture_cube_map */ - -#ifndef GL_ARB_texture_cube_map_array -#define GL_ARB_texture_cube_map_array 1 -#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F -#endif /* GL_ARB_texture_cube_map_array */ - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif /* GL_ARB_texture_env_add */ - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif /* GL_ARB_texture_env_combine */ - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif /* GL_ARB_texture_env_crossbar */ - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif /* GL_ARB_texture_env_dot3 */ - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif /* GL_ARB_texture_float */ - -#ifndef GL_ARB_texture_gather -#define GL_ARB_texture_gather 1 -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F -#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F -#endif /* GL_ARB_texture_gather */ - -#ifndef GL_ARB_texture_mirror_clamp_to_edge -#define GL_ARB_texture_mirror_clamp_to_edge 1 -#endif /* GL_ARB_texture_mirror_clamp_to_edge */ - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif /* GL_ARB_texture_mirrored_repeat */ - -#ifndef GL_ARB_texture_multisample -#define GL_ARB_texture_multisample 1 -#endif /* GL_ARB_texture_multisample */ - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif /* GL_ARB_texture_non_power_of_two */ - -#ifndef GL_ARB_texture_query_levels -#define GL_ARB_texture_query_levels 1 -#endif /* GL_ARB_texture_query_levels */ - -#ifndef GL_ARB_texture_query_lod -#define GL_ARB_texture_query_lod 1 -#endif /* GL_ARB_texture_query_lod */ - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif /* GL_ARB_texture_rectangle */ - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 -#endif /* GL_ARB_texture_rg */ - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_ARB_texture_rgb10_a2ui 1 -#endif /* GL_ARB_texture_rgb10_a2ui */ - -#ifndef GL_ARB_texture_stencil8 -#define GL_ARB_texture_stencil8 1 -#endif /* GL_ARB_texture_stencil8 */ - -#ifndef GL_ARB_texture_storage -#define GL_ARB_texture_storage 1 -#endif /* GL_ARB_texture_storage */ - -#ifndef GL_ARB_texture_storage_multisample -#define GL_ARB_texture_storage_multisample 1 -#endif /* GL_ARB_texture_storage_multisample */ - -#ifndef GL_ARB_texture_swizzle -#define GL_ARB_texture_swizzle 1 -#endif /* GL_ARB_texture_swizzle */ - -#ifndef GL_ARB_texture_view -#define GL_ARB_texture_view 1 -#endif /* GL_ARB_texture_view */ - -#ifndef GL_ARB_timer_query -#define GL_ARB_timer_query 1 -#endif /* GL_ARB_timer_query */ - -#ifndef GL_ARB_transform_feedback2 -#define GL_ARB_transform_feedback2 1 -#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 -#endif /* GL_ARB_transform_feedback2 */ - -#ifndef GL_ARB_transform_feedback3 -#define GL_ARB_transform_feedback3 1 -#endif /* GL_ARB_transform_feedback3 */ - -#ifndef GL_ARB_transform_feedback_instanced -#define GL_ARB_transform_feedback_instanced 1 -#endif /* GL_ARB_transform_feedback_instanced */ - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); -#endif -#endif /* GL_ARB_transpose_matrix */ - -#ifndef GL_ARB_uniform_buffer_object -#define GL_ARB_uniform_buffer_object 1 -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#endif /* GL_ARB_uniform_buffer_object */ - -#ifndef GL_ARB_vertex_array_bgra -#define GL_ARB_vertex_array_bgra 1 -#endif /* GL_ARB_vertex_array_bgra */ - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 -#endif /* GL_ARB_vertex_array_object */ - -#ifndef GL_ARB_vertex_attrib_64bit -#define GL_ARB_vertex_attrib_64bit 1 -#endif /* GL_ARB_vertex_attrib_64bit */ - -#ifndef GL_ARB_vertex_attrib_binding -#define GL_ARB_vertex_attrib_binding 1 -#endif /* GL_ARB_vertex_attrib_binding */ - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); -GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); -GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); -GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); -GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); -GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); -GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); -GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); -GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glVertexBlendARB (GLint count); -#endif -#endif /* GL_ARB_vertex_blend */ - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#ifdef __MACOSX__ /* The OS X headers haven't caught up with Khronos yet */ -typedef long GLsizeiptrARB; -typedef long GLintptrARB; -#else -typedef ptrdiff_t GLsizeiptrARB; -typedef ptrdiff_t GLintptrARB; -#endif -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); -typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); -GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); -GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); -GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); -#endif -#endif /* GL_ARB_vertex_buffer_object */ - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); -#endif -#endif /* GL_ARB_vertex_program */ - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); -#endif -#endif /* GL_ARB_vertex_shader */ - -#ifndef GL_ARB_vertex_type_10f_11f_11f_rev -#define GL_ARB_vertex_type_10f_11f_11f_rev 1 -#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -#define GL_ARB_vertex_type_2_10_10_10_rev 1 -#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ - -#ifndef GL_ARB_viewport_array -#define GL_ARB_viewport_array 1 -#endif /* GL_ARB_viewport_array */ - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); -#endif -#endif /* GL_ARB_window_pos */ - -#ifndef GL_KHR_debug -#define GL_KHR_debug 1 -#endif /* GL_KHR_debug */ - -#ifndef GL_KHR_texture_compression_astc_hdr -#define GL_KHR_texture_compression_astc_hdr 1 -#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD -#endif /* GL_KHR_texture_compression_astc_hdr */ - -#ifndef GL_KHR_texture_compression_astc_ldr -#define GL_KHR_texture_compression_astc_ldr 1 -#endif /* GL_KHR_texture_compression_astc_ldr */ - -#ifndef GL_OES_byte_coordinates -#define GL_OES_byte_coordinates 1 -typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); -typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); -typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); -typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); -typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x); -typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y); -typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z); -typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); -GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); -GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); -GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); -GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); -GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); -GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); -GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); -GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); -GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); -GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); -GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); -GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); -GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); -GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); -GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex2bOES (GLbyte x); -GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y); -GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z); -GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); -#endif -#endif /* GL_OES_byte_coordinates */ - -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif /* GL_OES_compressed_paletted_texture */ - -#ifndef GL_OES_fixed_point -#define GL_OES_fixed_point 1 -typedef GLint GLfixed; -#define GL_FIXED_OES 0x140C -typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); -typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); -typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); -typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); -typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); -typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); -typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); -typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); -typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); -typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); -typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); -typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); -typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); -typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); -typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); -typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); -typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); -typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); -typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); -typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); -typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); -typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); -typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); -typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); -typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); -typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); -typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); -typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); -typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); -typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); -typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); -typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); -typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); -typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); -typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); -typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); -typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); -typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); -typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); -typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); -GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); -GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); -GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); -GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); -GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); -GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); -GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); -GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); -GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); -GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glLineWidthxOES (GLfixed width); -GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); -GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); -GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); -GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); -GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); -GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); -GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glPointSizexOES (GLfixed size); -GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); -GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert); -GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); -GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); -GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); -GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); -GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); -GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); -GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); -GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); -GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); -GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); -GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); -GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); -GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); -GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); -GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); -GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); -GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glIndexxOES (GLfixed component); -GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); -GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); -GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); -GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); -GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); -GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); -GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); -GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); -GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); -GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); -GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glPassThroughxOES (GLfixed token); -GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); -GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); -GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); -GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); -GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); -GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); -GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); -GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); -GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); -GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); -GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); -GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); -GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); -GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); -GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); -GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); -GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glVertex2xOES (GLfixed x); -GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); -GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); -GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); -#endif -#endif /* GL_OES_fixed_point */ - -#ifndef GL_OES_query_matrix -#define GL_OES_query_matrix 1 -typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); -#endif -#endif /* GL_OES_query_matrix */ - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif /* GL_OES_read_format */ - -#ifndef GL_OES_single_precision -#define GL_OES_single_precision 1 -typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); -typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); -typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); -typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); -typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); -GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); -GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); -GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); -GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -#endif -#endif /* GL_OES_single_precision */ - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif /* GL_3DFX_multisample */ - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); -#endif -#endif /* GL_3DFX_tbuffer */ - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif /* GL_3DFX_texture_compression_FXT1 */ - -#ifndef GL_AMD_blend_minmax_factor -#define GL_AMD_blend_minmax_factor 1 -#define GL_FACTOR_MIN_AMD 0x901C -#define GL_FACTOR_MAX_AMD 0x901D -#endif /* GL_AMD_blend_minmax_factor */ - -#ifndef GL_AMD_conservative_depth -#define GL_AMD_conservative_depth 1 -#endif /* GL_AMD_conservative_depth */ - -#ifndef GL_AMD_debug_output -#define GL_AMD_debug_output 1 -typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); -#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 -#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 -#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 -#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A -#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B -#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C -#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D -#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E -#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F -#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 -typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#endif -#endif /* GL_AMD_debug_output */ - -#ifndef GL_AMD_depth_clamp_separate -#define GL_AMD_depth_clamp_separate 1 -#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E -#define GL_DEPTH_CLAMP_FAR_AMD 0x901F -#endif /* GL_AMD_depth_clamp_separate */ - -#ifndef GL_AMD_draw_buffers_blend -#define GL_AMD_draw_buffers_blend 1 -typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#endif -#endif /* GL_AMD_draw_buffers_blend */ - -#ifndef GL_AMD_gcn_shader -#define GL_AMD_gcn_shader 1 -#endif /* GL_AMD_gcn_shader */ - -#ifndef GL_AMD_gpu_shader_int64 -#define GL_AMD_gpu_shader_int64 1 -typedef int64_t GLint64EXT; -#define GL_INT64_NV 0x140E -#define GL_UNSIGNED_INT64_NV 0x140F -#define GL_INT8_NV 0x8FE0 -#define GL_INT8_VEC2_NV 0x8FE1 -#define GL_INT8_VEC3_NV 0x8FE2 -#define GL_INT8_VEC4_NV 0x8FE3 -#define GL_INT16_NV 0x8FE4 -#define GL_INT16_VEC2_NV 0x8FE5 -#define GL_INT16_VEC3_NV 0x8FE6 -#define GL_INT16_VEC4_NV 0x8FE7 -#define GL_INT64_VEC2_NV 0x8FE9 -#define GL_INT64_VEC3_NV 0x8FEA -#define GL_INT64_VEC4_NV 0x8FEB -#define GL_UNSIGNED_INT8_NV 0x8FEC -#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED -#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE -#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF -#define GL_UNSIGNED_INT16_NV 0x8FF0 -#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 -#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 -#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 -#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 -#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 -#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 -#define GL_FLOAT16_NV 0x8FF8 -#define GL_FLOAT16_VEC2_NV 0x8FF9 -#define GL_FLOAT16_VEC3_NV 0x8FFA -#define GL_FLOAT16_VEC4_NV 0x8FFB -typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); -GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); -GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); -GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); -GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); -GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); -GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif -#endif /* GL_AMD_gpu_shader_int64 */ - -#ifndef GL_AMD_interleaved_elements -#define GL_AMD_interleaved_elements 1 -#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 -#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 -typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); -#endif -#endif /* GL_AMD_interleaved_elements */ - -#ifndef GL_AMD_multi_draw_indirect -#define GL_AMD_multi_draw_indirect 1 -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); -#endif -#endif /* GL_AMD_multi_draw_indirect */ - -#ifndef GL_AMD_name_gen_delete -#define GL_AMD_name_gen_delete 1 -#define GL_DATA_BUFFER_AMD 0x9151 -#define GL_PERFORMANCE_MONITOR_AMD 0x9152 -#define GL_QUERY_OBJECT_AMD 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 -#define GL_SAMPLER_OBJECT_AMD 0x9155 -typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); -typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); -typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); -GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); -GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); -#endif -#endif /* GL_AMD_name_gen_delete */ - -#ifndef GL_AMD_occlusion_query_event -#define GL_AMD_occlusion_query_event 1 -#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F -#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 -#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 -#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 -#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 -#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF -typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); -#endif -#endif /* GL_AMD_occlusion_query_event */ - -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); -typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); -GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif -#endif /* GL_AMD_performance_monitor */ - -#ifndef GL_AMD_pinned_memory -#define GL_AMD_pinned_memory 1 -#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 -#endif /* GL_AMD_pinned_memory */ - -#ifndef GL_AMD_query_buffer_object -#define GL_AMD_query_buffer_object 1 -#define GL_QUERY_BUFFER_AMD 0x9192 -#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 -#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 -#endif /* GL_AMD_query_buffer_object */ - -#ifndef GL_AMD_sample_positions -#define GL_AMD_sample_positions 1 -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F -typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); -#endif -#endif /* GL_AMD_sample_positions */ - -#ifndef GL_AMD_seamless_cubemap_per_texture -#define GL_AMD_seamless_cubemap_per_texture 1 -#endif /* GL_AMD_seamless_cubemap_per_texture */ - -#ifndef GL_AMD_shader_atomic_counter_ops -#define GL_AMD_shader_atomic_counter_ops 1 -#endif /* GL_AMD_shader_atomic_counter_ops */ - -#ifndef GL_AMD_shader_stencil_export -#define GL_AMD_shader_stencil_export 1 -#endif /* GL_AMD_shader_stencil_export */ - -#ifndef GL_AMD_shader_trinary_minmax -#define GL_AMD_shader_trinary_minmax 1 -#endif /* GL_AMD_shader_trinary_minmax */ - -#ifndef GL_AMD_sparse_texture -#define GL_AMD_sparse_texture 1 -#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 -#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 -#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 -#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 -#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 -#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A -#define GL_MIN_SPARSE_LEVEL_AMD 0x919B -#define GL_MIN_LOD_WARNING_AMD 0x919C -#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 -typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -#endif -#endif /* GL_AMD_sparse_texture */ - -#ifndef GL_AMD_stencil_operation_extended -#define GL_AMD_stencil_operation_extended 1 -#define GL_SET_AMD 0x874A -#define GL_REPLACE_VALUE_AMD 0x874B -#define GL_STENCIL_OP_VALUE_AMD 0x874C -#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D -typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); -#endif -#endif /* GL_AMD_stencil_operation_extended */ - -#ifndef GL_AMD_texture_texture4 -#define GL_AMD_texture_texture4 1 -#endif /* GL_AMD_texture_texture4 */ - -#ifndef GL_AMD_transform_feedback3_lines_triangles -#define GL_AMD_transform_feedback3_lines_triangles 1 -#endif /* GL_AMD_transform_feedback3_lines_triangles */ - -#ifndef GL_AMD_transform_feedback4 -#define GL_AMD_transform_feedback4 1 -#define GL_STREAM_RASTERIZATION_AMD 0x91A0 -#endif /* GL_AMD_transform_feedback4 */ - -#ifndef GL_AMD_vertex_shader_layer -#define GL_AMD_vertex_shader_layer 1 -#endif /* GL_AMD_vertex_shader_layer */ - -#ifndef GL_AMD_vertex_shader_tessellator -#define GL_AMD_vertex_shader_tessellator 1 -#define GL_SAMPLER_BUFFER_AMD 0x9001 -#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define GL_TESSELLATION_MODE_AMD 0x9004 -#define GL_TESSELLATION_FACTOR_AMD 0x9005 -#define GL_DISCRETE_AMD 0x9006 -#define GL_CONTINUOUS_AMD 0x9007 -typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); -GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); -#endif -#endif /* GL_AMD_vertex_shader_tessellator */ - -#ifndef GL_AMD_vertex_shader_viewport_index -#define GL_AMD_vertex_shader_viewport_index 1 -#endif /* GL_AMD_vertex_shader_viewport_index */ - -#ifndef GL_APPLE_aux_depth_stencil -#define GL_APPLE_aux_depth_stencil 1 -#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 -#endif /* GL_APPLE_aux_depth_stencil */ - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif /* GL_APPLE_client_storage */ - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 -#define GL_ELEMENT_ARRAY_APPLE 0x8A0C -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif -#endif /* GL_APPLE_element_array */ - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); -#endif -#endif /* GL_APPLE_fence */ - -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels 1 -#define GL_HALF_APPLE 0x140B -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#define GL_COLOR_FLOAT_APPLE 0x8A0F -#endif /* GL_APPLE_float_pixels */ - -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); -#endif -#endif /* GL_APPLE_flush_buffer_range */ - -#ifndef GL_APPLE_object_purgeable -#define GL_APPLE_object_purgeable 1 -#define GL_BUFFER_OBJECT_APPLE 0x85B3 -#define GL_RELEASED_APPLE 0x8A19 -#define GL_VOLATILE_APPLE 0x8A1A -#define GL_RETAINED_APPLE 0x8A1B -#define GL_UNDEFINED_APPLE 0x8A1C -#define GL_PURGEABLE_APPLE 0x8A1D -typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#endif -#endif /* GL_APPLE_object_purgeable */ - -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 -#define GL_RGB_422_APPLE 0x8A1F -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#define GL_RGB_RAW_422_APPLE 0x8A51 -#endif /* GL_APPLE_rgb_422 */ - -#ifndef GL_APPLE_row_bytes -#define GL_APPLE_row_bytes 1 -#define GL_PACK_ROW_BYTES_APPLE 0x8A15 -#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 -#endif /* GL_APPLE_row_bytes */ - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif /* GL_APPLE_specular_vector */ - -#ifndef GL_APPLE_texture_range -#define GL_APPLE_texture_range 1 -#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 -#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#define GL_STORAGE_PRIVATE_APPLE 0x85BD -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); -GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); -#endif -#endif /* GL_APPLE_texture_range */ - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif /* GL_APPLE_transform_hint */ - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); -#endif -#endif /* GL_APPLE_vertex_array_object */ - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CLIENT_APPLE 0x85B4 -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); -#endif -#endif /* GL_APPLE_vertex_array_range */ - -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_APPLE_vertex_program_evaluators 1 -#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 -#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 -#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 -#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 -#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 -#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 -#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 -#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 -#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 -#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#endif -#endif /* GL_APPLE_vertex_program_evaluators */ - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#define GL_YCBCR_422_APPLE 0x85B9 -#endif /* GL_APPLE_ycbcr_422 */ - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); -#endif -#endif /* GL_ATI_draw_buffers */ - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif -#endif /* GL_ATI_element_array */ - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); -#endif -#endif /* GL_ATI_envmap_bumpmap */ - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); -GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); -#endif -#endif /* GL_ATI_fragment_shader */ - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); -#endif -#endif /* GL_ATI_map_object_buffer */ - -#ifndef GL_ATI_meminfo -#define GL_ATI_meminfo 1 -#define GL_VBO_FREE_MEMORY_ATI 0x87FB -#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC -#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD -#endif /* GL_ATI_meminfo */ - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -#define GL_RGBA_FLOAT_MODE_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif /* GL_ATI_pixel_format_float */ - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); -#endif -#endif /* GL_ATI_pn_triangles */ - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif -#endif /* GL_ATI_separate_stencil */ - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif /* GL_ATI_text_fragment_shader */ - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif /* GL_ATI_texture_env_combine3 */ - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif /* GL_ATI_texture_float */ - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif /* GL_ATI_texture_mirror_once */ - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); -#endif -#endif /* GL_ATI_vertex_array_object */ - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); -#endif -#endif /* GL_ATI_vertex_attrib_array_object */ - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); -GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); -GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); -#endif -#endif /* GL_ATI_vertex_streams */ - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif /* GL_EXT_422_pixels */ - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#define GL_ABGR_EXT 0x8000 -#endif /* GL_EXT_abgr */ - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif /* GL_EXT_bgra */ - -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF -typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); -typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); -GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); -GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); -#endif -#endif /* GL_EXT_bindable_uniform */ - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -#endif -#endif /* GL_EXT_blend_color */ - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 -#define GL_BLEND_EQUATION_RGB_EXT 0x8009 -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); -#endif -#endif /* GL_EXT_blend_equation_separate */ - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif -#endif /* GL_EXT_blend_func_separate */ - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif /* GL_EXT_blend_logic_op */ - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_BLEND_EQUATION_EXT 0x8009 -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); -#endif -#endif /* GL_EXT_blend_minmax */ - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif /* GL_EXT_blend_subtract */ - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif /* GL_EXT_clip_volume_hint */ - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif /* GL_EXT_cmyka */ - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif -#endif /* GL_EXT_color_subtable */ - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif -#endif /* GL_EXT_compiled_vertex_array */ - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); -#endif -#endif /* GL_EXT_convolution */ - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); -GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); -GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); -GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_EXT_coordinate_frame */ - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif -#endif /* GL_EXT_copy_texture */ - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); -#endif -#endif /* GL_EXT_cull_vertex */ - -#ifndef GL_EXT_debug_label -#define GL_EXT_debug_label 1 -#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F -#define GL_PROGRAM_OBJECT_EXT 0x8B40 -#define GL_SHADER_OBJECT_EXT 0x8B48 -#define GL_BUFFER_OBJECT_EXT 0x9151 -#define GL_QUERY_OBJECT_EXT 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 -typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); -GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); -#endif -#endif /* GL_EXT_debug_label */ - -#ifndef GL_EXT_debug_marker -#define GL_EXT_debug_marker 1 -typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); -typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); -typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); -GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); -GLAPI void APIENTRY glPopGroupMarkerEXT (void); -#endif -#endif /* GL_EXT_debug_marker */ - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); -#endif -#endif /* GL_EXT_depth_bounds_test */ - -#ifndef GL_EXT_direct_state_access -#define GL_EXT_direct_state_access 1 -#define GL_PROGRAM_MATRIX_EXT 0x8E2D -#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F -typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); -typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); -typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); -typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); -typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); -typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); -typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); -typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); -typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); -GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); -GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); -GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); -GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); -GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); -GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); -GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); -GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); -GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); -GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); -GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); -GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); -GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); -GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); -GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); -GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); -GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); -GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); -GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); -GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); -GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); -GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); -GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); -GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); -GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); -GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); -GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); -GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); -GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); -GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); -GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); -GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); -GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); -GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); -GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); -GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); -GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); -#endif -#endif /* GL_EXT_direct_state_access */ - -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 -typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -#endif -#endif /* GL_EXT_draw_buffers2 */ - -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -#endif -#endif /* GL_EXT_draw_instanced */ - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); -#endif -#endif /* GL_EXT_draw_range_elements */ - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_EXT_fog_coord */ - -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif -#endif /* GL_EXT_framebuffer_blit */ - -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif -#endif /* GL_EXT_framebuffer_multisample */ - -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_EXT_framebuffer_multisample_blit_scaled 1 -#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB -#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); -#endif -#endif /* GL_EXT_framebuffer_object */ - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#endif /* GL_EXT_framebuffer_sRGB */ - -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 -#define GL_LINES_ADJACENCY_EXT 0x000A -#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B -#define GL_TRIANGLES_ADJACENCY_EXT 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); -#endif -#endif /* GL_EXT_geometry_shader4 */ - -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif -#endif /* GL_EXT_gpu_program_parameters */ - -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 -typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); -#endif -#endif /* GL_EXT_gpu_shader4 */ - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogramEXT (GLenum target); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); -#endif -#endif /* GL_EXT_histogram */ - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif /* GL_EXT_index_array_formats */ - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); -#endif -#endif /* GL_EXT_index_func */ - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); -#endif -#endif /* GL_EXT_index_material */ - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif /* GL_EXT_index_texture */ - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); -GLAPI void APIENTRY glTextureLightEXT (GLenum pname); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); -#endif -#endif /* GL_EXT_light_texture */ - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif /* GL_EXT_misc_attribute */ - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); -#endif -#endif /* GL_EXT_multi_draw_arrays */ - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); -#endif -#endif /* GL_EXT_multisample */ - -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#endif /* GL_EXT_packed_depth_stencil */ - -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C -#endif /* GL_EXT_packed_float */ - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif /* GL_EXT_packed_pixels */ - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); -GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -#endif -#endif /* GL_EXT_paletted_texture */ - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif /* GL_EXT_pixel_buffer_object */ - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -#endif -#endif /* GL_EXT_pixel_transform */ - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif /* GL_EXT_pixel_transform_color_table */ - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); -#endif -#endif /* GL_EXT_point_parameters */ - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); -#endif -#endif /* GL_EXT_polygon_offset */ - -#ifndef GL_EXT_provoking_vertex -#define GL_EXT_provoking_vertex 1 -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D -#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E -#define GL_PROVOKING_VERTEX_EXT 0x8E4F -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); -#endif -#endif /* GL_EXT_provoking_vertex */ - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif /* GL_EXT_rescale_normal */ - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_EXT_secondary_color */ - -#ifndef GL_EXT_separate_shader_objects -#define GL_EXT_separate_shader_objects 1 -#define GL_ACTIVE_PROGRAM_EXT 0x8B8D -typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); -typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); -GLAPI void APIENTRY glActiveProgramEXT (GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); -#endif -#endif /* GL_EXT_separate_shader_objects */ - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif /* GL_EXT_separate_specular_color */ - -#ifndef GL_EXT_shader_image_load_formatted -#define GL_EXT_shader_image_load_formatted 1 -#endif /* GL_EXT_shader_image_load_formatted */ - -#ifndef GL_EXT_shader_image_load_store -#define GL_EXT_shader_image_load_store 1 -#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 -#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A -#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B -#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C -#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D -#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E -#define GL_IMAGE_1D_EXT 0x904C -#define GL_IMAGE_2D_EXT 0x904D -#define GL_IMAGE_3D_EXT 0x904E -#define GL_IMAGE_2D_RECT_EXT 0x904F -#define GL_IMAGE_CUBE_EXT 0x9050 -#define GL_IMAGE_BUFFER_EXT 0x9051 -#define GL_IMAGE_1D_ARRAY_EXT 0x9052 -#define GL_IMAGE_2D_ARRAY_EXT 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 -#define GL_INT_IMAGE_1D_EXT 0x9057 -#define GL_INT_IMAGE_2D_EXT 0x9058 -#define GL_INT_IMAGE_3D_EXT 0x9059 -#define GL_INT_IMAGE_2D_RECT_EXT 0x905A -#define GL_INT_IMAGE_CUBE_EXT 0x905B -#define GL_INT_IMAGE_BUFFER_EXT 0x905C -#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D -#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C -#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D -#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 -#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 -#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); -#endif -#endif /* GL_EXT_shader_image_load_store */ - -#ifndef GL_EXT_shader_integer_mix -#define GL_EXT_shader_integer_mix 1 -#endif /* GL_EXT_shader_integer_mix */ - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 -#endif /* GL_EXT_shadow_funcs */ - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif /* GL_EXT_shared_texture_palette */ - -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 -typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); -#endif -#endif /* GL_EXT_stencil_clear_tag */ - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); -#endif -#endif /* GL_EXT_stencil_two_side */ - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif /* GL_EXT_stencil_wrap */ - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); -#endif -#endif /* GL_EXT_subtexture */ - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif /* GL_EXT_texture */ - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); -#endif -#endif /* GL_EXT_texture3D */ - -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -#endif /* GL_EXT_texture_array */ - -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E -typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); -#endif -#endif /* GL_EXT_texture_buffer_object */ - -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 -#endif /* GL_EXT_texture_compression_latc */ - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE -#endif /* GL_EXT_texture_compression_rgtc */ - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_EXT_texture_compression_s3tc 1 -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif /* GL_EXT_texture_compression_s3tc */ - -#ifndef GL_EXT_texture_cube_map -#define GL_EXT_texture_cube_map 1 -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif /* GL_EXT_texture_cube_map */ - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif /* GL_EXT_texture_env_add */ - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif /* GL_EXT_texture_env_combine */ - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif /* GL_EXT_texture_env_dot3 */ - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif /* GL_EXT_texture_filter_anisotropic */ - -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); -GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif -#endif /* GL_EXT_texture_integer */ - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif /* GL_EXT_texture_lod_bias */ - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif /* GL_EXT_texture_mirror_clamp */ - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); -GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif -#endif /* GL_EXT_texture_object */ - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); -#endif -#endif /* GL_EXT_texture_perturb_normal */ - -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif /* GL_EXT_texture_sRGB */ - -#ifndef GL_EXT_texture_sRGB_decode -#define GL_EXT_texture_sRGB_decode 1 -#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 -#define GL_DECODE_EXT 0x8A49 -#define GL_SKIP_DECODE_EXT 0x8A4A -#endif /* GL_EXT_texture_sRGB_decode */ - -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F -#endif /* GL_EXT_texture_shared_exponent */ - -#ifndef GL_EXT_texture_snorm -#define GL_EXT_texture_snorm 1 -#define GL_ALPHA_SNORM 0x9010 -#define GL_LUMINANCE_SNORM 0x9011 -#define GL_LUMINANCE_ALPHA_SNORM 0x9012 -#define GL_INTENSITY_SNORM 0x9013 -#define GL_ALPHA8_SNORM 0x9014 -#define GL_LUMINANCE8_SNORM 0x9015 -#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 -#define GL_INTENSITY8_SNORM 0x9017 -#define GL_ALPHA16_SNORM 0x9018 -#define GL_LUMINANCE16_SNORM 0x9019 -#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A -#define GL_INTENSITY16_SNORM 0x901B -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#endif /* GL_EXT_texture_snorm */ - -#ifndef GL_EXT_texture_swizzle -#define GL_EXT_texture_swizzle 1 -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 -#endif /* GL_EXT_texture_swizzle */ - -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 -#define GL_TIME_ELAPSED_EXT 0x88BF -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); -#endif -#endif /* GL_EXT_timer_query */ - -#ifndef GL_EXT_transform_feedback -#define GL_EXT_transform_feedback 1 -#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F -#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackEXT (void); -GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -#endif -#endif /* GL_EXT_transform_feedback */ - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint i); -GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); -GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); -GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); -#endif -#endif /* GL_EXT_vertex_array */ - -#ifndef GL_EXT_vertex_array_bgra -#define GL_EXT_vertex_array_bgra 1 -#endif /* GL_EXT_vertex_array_bgra */ - -#ifndef GL_EXT_vertex_attrib_64bit -#define GL_EXT_vertex_attrib_64bit 1 -#define GL_DOUBLE_VEC2_EXT 0x8FFC -#define GL_DOUBLE_VEC3_EXT 0x8FFD -#define GL_DOUBLE_VEC4_EXT 0x8FFE -#define GL_DOUBLE_MAT2_EXT 0x8F46 -#define GL_DOUBLE_MAT3_EXT 0x8F47 -#define GL_DOUBLE_MAT4_EXT 0x8F48 -#define GL_DOUBLE_MAT2x3_EXT 0x8F49 -#define GL_DOUBLE_MAT2x4_EXT 0x8F4A -#define GL_DOUBLE_MAT3x2_EXT 0x8F4B -#define GL_DOUBLE_MAT3x4_EXT 0x8F4C -#define GL_DOUBLE_MAT4x2_EXT 0x8F4D -#define GL_DOUBLE_MAT4x3_EXT 0x8F4E -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); -#endif -#endif /* GL_EXT_vertex_attrib_64bit */ - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); -GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); -GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); -GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); -GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); -GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); -GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); -GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); -GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); -GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); -GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); -GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -#endif -#endif /* GL_EXT_vertex_shader */ - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 -#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT 0x1700 -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); -#endif -#endif /* GL_EXT_vertex_weighting */ - -#ifndef GL_EXT_x11_sync_object -#define GL_EXT_x11_sync_object 1 -#define GL_SYNC_X11_FENCE_EXT 0x90E1 -typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#endif -#endif /* GL_EXT_x11_sync_object */ - -#ifndef GL_GREMEDY_frame_terminator -#define GL_GREMEDY_frame_terminator 1 -typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); -#endif -#endif /* GL_GREMEDY_frame_terminator */ - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); -#endif -#endif /* GL_GREMEDY_string_marker */ - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif /* GL_HP_convolution_border_modes */ - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); -#endif -#endif /* GL_HP_image_transform */ - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif /* GL_HP_occlusion_test */ - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif /* GL_HP_texture_lighting */ - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 -#define GL_CULL_VERTEX_IBM 103050 -#endif /* GL_IBM_cull_vertex */ - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); -#endif -#endif /* GL_IBM_multimode_draw_arrays */ - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif /* GL_IBM_rasterpos_clip */ - -#ifndef GL_IBM_static_data -#define GL_IBM_static_data 1 -#define GL_ALL_STATIC_DATA_IBM 103060 -#define GL_STATIC_VERTEX_ARRAY_IBM 103061 -typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); -#endif -#endif /* GL_IBM_static_data */ - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_IBM_texture_mirrored_repeat 1 -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif /* GL_IBM_texture_mirrored_repeat */ - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); -#endif -#endif /* GL_IBM_vertex_array_lists */ - -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif -#endif /* GL_INGR_blend_func_separate */ - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif /* GL_INGR_color_clamp */ - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#define GL_INTERLACE_READ_INGR 0x8568 -#endif /* GL_INGR_interlace_read */ - -#ifndef GL_INTEL_fragment_shader_ordering -#define GL_INTEL_fragment_shader_ordering 1 -#endif /* GL_INTEL_fragment_shader_ordering */ - -#ifndef GL_INTEL_map_texture -#define GL_INTEL_map_texture 1 -#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF -#define GL_LAYOUT_DEFAULT_INTEL 0 -#define GL_LAYOUT_LINEAR_INTEL 1 -#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 -typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); -typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); -GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); -GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); -#endif -#endif /* GL_INTEL_map_texture */ - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); -GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); -#endif -#endif /* GL_INTEL_parallel_arrays */ - -#ifndef GL_INTEL_performance_query -#define GL_INTEL_performance_query 1 -#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 -#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 -#define GL_PERFQUERY_WAIT_INTEL 0x83FB -#define GL_PERFQUERY_FLUSH_INTEL 0x83FA -#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 -#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 -#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 -#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 -#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 -#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 -#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 -#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 -#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 -#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA -#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB -#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC -#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD -#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE -#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF -#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 -typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); -typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); -typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); -typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); -typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); -typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); -typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); -typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); -typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); -GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); -GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); -GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); -GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); -GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); -GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); -GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); -GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); -#endif -#endif /* GL_INTEL_performance_query */ - -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E -#endif /* GL_MESAX_texture_stack */ - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 -#define GL_PACK_INVERT_MESA 0x8758 -#endif /* GL_MESA_pack_invert */ - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif -#endif /* GL_MESA_resize_buffers */ - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); -#endif -#endif /* GL_MESA_window_pos */ - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif /* GL_MESA_ycbcr_texture */ - -#ifndef GL_NVX_conditional_render -#define GL_NVX_conditional_render 1 -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); -GLAPI void APIENTRY glEndConditionalRenderNVX (void); -#endif -#endif /* GL_NVX_conditional_render */ - -#ifndef GL_NVX_gpu_memory_info -#define GL_NVX_gpu_memory_info 1 -#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 -#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 -#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 -#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A -#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B -#endif /* GL_NVX_gpu_memory_info */ - -#ifndef GL_NV_bindless_multi_draw_indirect -#define GL_NV_bindless_multi_draw_indirect 1 -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); -#endif -#endif /* GL_NV_bindless_multi_draw_indirect */ - -#ifndef GL_NV_bindless_texture -#define GL_NV_bindless_texture 1 -typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); -typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); -GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); -GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); -GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); -GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); -GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); -GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); -GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); -GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); -GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); -#endif -#endif /* GL_NV_bindless_texture */ - -#ifndef GL_NV_blend_equation_advanced -#define GL_NV_blend_equation_advanced 1 -#define GL_BLEND_OVERLAP_NV 0x9281 -#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 -#define GL_BLUE_NV 0x1905 -#define GL_COLORBURN_NV 0x929A -#define GL_COLORDODGE_NV 0x9299 -#define GL_CONJOINT_NV 0x9284 -#define GL_CONTRAST_NV 0x92A1 -#define GL_DARKEN_NV 0x9297 -#define GL_DIFFERENCE_NV 0x929E -#define GL_DISJOINT_NV 0x9283 -#define GL_DST_ATOP_NV 0x928F -#define GL_DST_IN_NV 0x928B -#define GL_DST_NV 0x9287 -#define GL_DST_OUT_NV 0x928D -#define GL_DST_OVER_NV 0x9289 -#define GL_EXCLUSION_NV 0x92A0 -#define GL_GREEN_NV 0x1904 -#define GL_HARDLIGHT_NV 0x929B -#define GL_HARDMIX_NV 0x92A9 -#define GL_HSL_COLOR_NV 0x92AF -#define GL_HSL_HUE_NV 0x92AD -#define GL_HSL_LUMINOSITY_NV 0x92B0 -#define GL_HSL_SATURATION_NV 0x92AE -#define GL_INVERT_OVG_NV 0x92B4 -#define GL_INVERT_RGB_NV 0x92A3 -#define GL_LIGHTEN_NV 0x9298 -#define GL_LINEARBURN_NV 0x92A5 -#define GL_LINEARDODGE_NV 0x92A4 -#define GL_LINEARLIGHT_NV 0x92A7 -#define GL_MINUS_CLAMPED_NV 0x92B3 -#define GL_MINUS_NV 0x929F -#define GL_MULTIPLY_NV 0x9294 -#define GL_OVERLAY_NV 0x9296 -#define GL_PINLIGHT_NV 0x92A8 -#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 -#define GL_PLUS_CLAMPED_NV 0x92B1 -#define GL_PLUS_DARKER_NV 0x9292 -#define GL_PLUS_NV 0x9291 -#define GL_RED_NV 0x1903 -#define GL_SCREEN_NV 0x9295 -#define GL_SOFTLIGHT_NV 0x929C -#define GL_SRC_ATOP_NV 0x928E -#define GL_SRC_IN_NV 0x928A -#define GL_SRC_NV 0x9286 -#define GL_SRC_OUT_NV 0x928C -#define GL_SRC_OVER_NV 0x9288 -#define GL_UNCORRELATED_NV 0x9282 -#define GL_VIVIDLIGHT_NV 0x92A6 -#define GL_XOR_NV 0x1506 -typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); -GLAPI void APIENTRY glBlendBarrierNV (void); -#endif -#endif /* GL_NV_blend_equation_advanced */ - -#ifndef GL_NV_blend_equation_advanced_coherent -#define GL_NV_blend_equation_advanced_coherent 1 -#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 -#endif /* GL_NV_blend_equation_advanced_coherent */ - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif /* GL_NV_blend_square */ - -#ifndef GL_NV_compute_program5 -#define GL_NV_compute_program5 1 -#define GL_COMPUTE_PROGRAM_NV 0x90FB -#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC -#endif /* GL_NV_compute_program5 */ - -#ifndef GL_NV_conditional_render -#define GL_NV_conditional_render 1 -#define GL_QUERY_WAIT_NV 0x8E13 -#define GL_QUERY_NO_WAIT_NV 0x8E14 -#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRenderNV (void); -#endif -#endif /* GL_NV_conditional_render */ - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif /* GL_NV_copy_depth_to_color */ - -#ifndef GL_NV_copy_image -#define GL_NV_copy_image 1 -typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif -#endif /* GL_NV_copy_image */ - -#ifndef GL_NV_deep_texture3D -#define GL_NV_deep_texture3D 1 -#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 -#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 -#endif /* GL_NV_deep_texture3D */ - -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF -typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); -GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); -#endif -#endif /* GL_NV_depth_buffer_float */ - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#define GL_DEPTH_CLAMP_NV 0x864F -#endif /* GL_NV_depth_clamp */ - -#ifndef GL_NV_draw_texture -#define GL_NV_draw_texture 1 -typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); -#endif -#endif /* GL_NV_draw_texture */ - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); -GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); -#endif -#endif /* GL_NV_evaluators */ - -#ifndef GL_NV_explicit_multisample -#define GL_NV_explicit_multisample 1 -#define GL_SAMPLE_POSITION_NV 0x8E50 -#define GL_SAMPLE_MASK_NV 0x8E51 -#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); -typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); -GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); -#endif -#endif /* GL_NV_explicit_multisample */ - -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); -GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); -GLAPI void APIENTRY glFinishFenceNV (GLuint fence); -GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); -#endif -#endif /* GL_NV_fence */ - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif /* GL_NV_float_buffer */ - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -#endif /* GL_NV_fog_distance */ - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif -#endif /* GL_NV_fragment_program */ - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif /* GL_NV_fragment_program2 */ - -#ifndef GL_NV_fragment_program4 -#define GL_NV_fragment_program4 1 -#endif /* GL_NV_fragment_program4 */ - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif /* GL_NV_fragment_program_option */ - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif -#endif /* GL_NV_framebuffer_multisample_coverage */ - -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 -typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); -GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif -#endif /* GL_NV_geometry_program4 */ - -#ifndef GL_NV_geometry_shader4 -#define GL_NV_geometry_shader4 1 -#endif /* GL_NV_geometry_shader4 */ - -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); -#endif -#endif /* GL_NV_gpu_program4 */ - -#ifndef GL_NV_gpu_program5 -#define GL_NV_gpu_program5 1 -#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C -#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F -#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 -#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 -typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); -#endif -#endif /* GL_NV_gpu_program5 */ - -#ifndef GL_NV_gpu_program5_mem_extended -#define GL_NV_gpu_program5_mem_extended 1 -#endif /* GL_NV_gpu_program5_mem_extended */ - -#ifndef GL_NV_gpu_shader5 -#define GL_NV_gpu_shader5 1 -#endif /* GL_NV_gpu_shader5 */ - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -typedef unsigned short GLhalfNV; -#define GL_HALF_FLOAT_NV 0x140B -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -#endif -#endif /* GL_NV_half_float */ - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif /* GL_NV_light_max_exponent */ - -#ifndef GL_NV_multisample_coverage -#define GL_NV_multisample_coverage 1 -#define GL_COLOR_SAMPLES_NV 0x8E20 -#endif /* GL_NV_multisample_coverage */ - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif /* GL_NV_multisample_filter_hint */ - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); -#endif -#endif /* GL_NV_occlusion_query */ - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif /* GL_NV_packed_depth_stencil */ - -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); -#endif -#endif /* GL_NV_parameter_buffer_object */ - -#ifndef GL_NV_parameter_buffer_object2 -#define GL_NV_parameter_buffer_object2 1 -#endif /* GL_NV_parameter_buffer_object2 */ - -#ifndef GL_NV_path_rendering -#define GL_NV_path_rendering 1 -#define GL_PATH_FORMAT_SVG_NV 0x9070 -#define GL_PATH_FORMAT_PS_NV 0x9071 -#define GL_STANDARD_FONT_NAME_NV 0x9072 -#define GL_SYSTEM_FONT_NAME_NV 0x9073 -#define GL_FILE_NAME_NV 0x9074 -#define GL_PATH_STROKE_WIDTH_NV 0x9075 -#define GL_PATH_END_CAPS_NV 0x9076 -#define GL_PATH_INITIAL_END_CAP_NV 0x9077 -#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 -#define GL_PATH_JOIN_STYLE_NV 0x9079 -#define GL_PATH_MITER_LIMIT_NV 0x907A -#define GL_PATH_DASH_CAPS_NV 0x907B -#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C -#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D -#define GL_PATH_DASH_OFFSET_NV 0x907E -#define GL_PATH_CLIENT_LENGTH_NV 0x907F -#define GL_PATH_FILL_MODE_NV 0x9080 -#define GL_PATH_FILL_MASK_NV 0x9081 -#define GL_PATH_FILL_COVER_MODE_NV 0x9082 -#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 -#define GL_PATH_STROKE_MASK_NV 0x9084 -#define GL_COUNT_UP_NV 0x9088 -#define GL_COUNT_DOWN_NV 0x9089 -#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A -#define GL_CONVEX_HULL_NV 0x908B -#define GL_BOUNDING_BOX_NV 0x908D -#define GL_TRANSLATE_X_NV 0x908E -#define GL_TRANSLATE_Y_NV 0x908F -#define GL_TRANSLATE_2D_NV 0x9090 -#define GL_TRANSLATE_3D_NV 0x9091 -#define GL_AFFINE_2D_NV 0x9092 -#define GL_AFFINE_3D_NV 0x9094 -#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 -#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 -#define GL_UTF8_NV 0x909A -#define GL_UTF16_NV 0x909B -#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C -#define GL_PATH_COMMAND_COUNT_NV 0x909D -#define GL_PATH_COORD_COUNT_NV 0x909E -#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F -#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 -#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 -#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 -#define GL_SQUARE_NV 0x90A3 -#define GL_ROUND_NV 0x90A4 -#define GL_TRIANGULAR_NV 0x90A5 -#define GL_BEVEL_NV 0x90A6 -#define GL_MITER_REVERT_NV 0x90A7 -#define GL_MITER_TRUNCATE_NV 0x90A8 -#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 -#define GL_USE_MISSING_GLYPH_NV 0x90AA -#define GL_PATH_ERROR_POSITION_NV 0x90AB -#define GL_PATH_FOG_GEN_MODE_NV 0x90AC -#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD -#define GL_ADJACENT_PAIRS_NV 0x90AE -#define GL_FIRST_TO_REST_NV 0x90AF -#define GL_PATH_GEN_MODE_NV 0x90B0 -#define GL_PATH_GEN_COEFF_NV 0x90B1 -#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 -#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 -#define GL_PATH_STENCIL_FUNC_NV 0x90B7 -#define GL_PATH_STENCIL_REF_NV 0x90B8 -#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 -#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD -#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE -#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF -#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 -#define GL_MOVE_TO_RESETS_NV 0x90B5 -#define GL_MOVE_TO_CONTINUES_NV 0x90B6 -#define GL_CLOSE_PATH_NV 0x00 -#define GL_MOVE_TO_NV 0x02 -#define GL_RELATIVE_MOVE_TO_NV 0x03 -#define GL_LINE_TO_NV 0x04 -#define GL_RELATIVE_LINE_TO_NV 0x05 -#define GL_HORIZONTAL_LINE_TO_NV 0x06 -#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 -#define GL_VERTICAL_LINE_TO_NV 0x08 -#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 -#define GL_QUADRATIC_CURVE_TO_NV 0x0A -#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B -#define GL_CUBIC_CURVE_TO_NV 0x0C -#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D -#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E -#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F -#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 -#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 -#define GL_SMALL_CCW_ARC_TO_NV 0x12 -#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 -#define GL_SMALL_CW_ARC_TO_NV 0x14 -#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 -#define GL_LARGE_CCW_ARC_TO_NV 0x16 -#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 -#define GL_LARGE_CW_ARC_TO_NV 0x18 -#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 -#define GL_RESTART_PATH_NV 0xF0 -#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 -#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 -#define GL_RECT_NV 0xF6 -#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 -#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA -#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC -#define GL_ARC_TO_NV 0xFE -#define GL_RELATIVE_ARC_TO_NV 0xFF -#define GL_BOLD_BIT_NV 0x01 -#define GL_ITALIC_BIT_NV 0x02 -#define GL_GLYPH_WIDTH_BIT_NV 0x01 -#define GL_GLYPH_HEIGHT_BIT_NV 0x02 -#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 -#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 -#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 -#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 -#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 -#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 -#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 -#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 -#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 -#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 -#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 -#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 -#define GL_FONT_ASCENDER_BIT_NV 0x00200000 -#define GL_FONT_DESCENDER_BIT_NV 0x00400000 -#define GL_FONT_HEIGHT_BIT_NV 0x00800000 -#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 -#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 -#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 -#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 -#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); -typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); -typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); -typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); -typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); -typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); -typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); -typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); -typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); -typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); -typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); -typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); -typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); -typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); -typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); -typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); -typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); -typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); -typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); -typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); -typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); -typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); -typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); -typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); -typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); -GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); -GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); -GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); -GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); -GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); -GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); -GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); -GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); -GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); -GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); -GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); -GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); -GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); -GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); -GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); -GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); -GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); -GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); -GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); -GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); -GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); -GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); -GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); -GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); -GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); -GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); -GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); -GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); -GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); -GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); -GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); -GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); -GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); -GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); -GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); -#endif -#endif /* GL_NV_path_rendering */ - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); -#endif -#endif /* GL_NV_pixel_data_range */ - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); -#endif -#endif /* GL_NV_point_sprite */ - -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B -typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); -GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#endif -#endif /* GL_NV_present_video */ - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); -#endif -#endif /* GL_NV_primitive_restart */ - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); -#endif -#endif /* GL_NV_register_combiners */ - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); -#endif -#endif /* GL_NV_register_combiners2 */ - -#ifndef GL_NV_shader_atomic_counters -#define GL_NV_shader_atomic_counters 1 -#endif /* GL_NV_shader_atomic_counters */ - -#ifndef GL_NV_shader_atomic_float -#define GL_NV_shader_atomic_float 1 -#endif /* GL_NV_shader_atomic_float */ - -#ifndef GL_NV_shader_buffer_load -#define GL_NV_shader_buffer_load 1 -#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D -#define GL_GPU_ADDRESS_NV 0x8F34 -#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 -typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); -typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); -typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); -typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); -typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); -GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); -GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); -GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); -GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); -GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); -GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); -GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); -GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); -GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif -#endif /* GL_NV_shader_buffer_load */ - -#ifndef GL_NV_shader_buffer_store -#define GL_NV_shader_buffer_store 1 -#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 -#endif /* GL_NV_shader_buffer_store */ - -#ifndef GL_NV_shader_storage_buffer_object -#define GL_NV_shader_storage_buffer_object 1 -#endif /* GL_NV_shader_storage_buffer_object */ - -#ifndef GL_NV_shader_thread_group -#define GL_NV_shader_thread_group 1 -#define GL_WARP_SIZE_NV 0x9339 -#define GL_WARPS_PER_SM_NV 0x933A -#define GL_SM_COUNT_NV 0x933B -#endif /* GL_NV_shader_thread_group */ - -#ifndef GL_NV_shader_thread_shuffle -#define GL_NV_shader_thread_shuffle 1 -#endif /* GL_NV_shader_thread_shuffle */ - -#ifndef GL_NV_tessellation_program5 -#define GL_NV_tessellation_program5 1 -#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 -#define GL_TESS_CONTROL_PROGRAM_NV 0x891E -#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F -#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 -#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 -#endif /* GL_NV_tessellation_program5 */ - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif /* GL_NV_texgen_emboss */ - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif /* GL_NV_texgen_reflection */ - -#ifndef GL_NV_texture_barrier -#define GL_NV_texture_barrier 1 -typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureBarrierNV (void); -#endif -#endif /* GL_NV_texture_barrier */ - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif /* GL_NV_texture_compression_vtc */ - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif /* GL_NV_texture_env_combine4 */ - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif /* GL_NV_texture_expand_normal */ - -#ifndef GL_NV_texture_multisample -#define GL_NV_texture_multisample 1 -#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 -#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#endif -#endif /* GL_NV_texture_multisample */ - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif /* GL_NV_texture_rectangle */ - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif /* GL_NV_texture_shader */ - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif /* GL_NV_texture_shader2 */ - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif /* GL_NV_texture_shader3 */ - -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F -#define GL_LAYER_NV 0x8DAA -#define GL_NEXT_BUFFER_NV -2 -#define GL_SKIP_COMPONENTS4_NV -3 -#define GL_SKIP_COMPONENTS3_NV -4 -#define GL_SKIP_COMPONENTS2_NV -5 -#define GL_SKIP_COMPONENTS1_NV -6 -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackNV (void); -GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); -GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); -GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); -GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); -#endif -#endif /* GL_NV_transform_feedback */ - -#ifndef GL_NV_transform_feedback2 -#define GL_NV_transform_feedback2 1 -#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedbackNV (void); -GLAPI void APIENTRY glResumeTransformFeedbackNV (void); -GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); -#endif -#endif /* GL_NV_transform_feedback2 */ - -#ifndef GL_NV_vdpau_interop -#define GL_NV_vdpau_interop 1 -typedef GLintptr GLvdpauSurfaceNV; -#define GL_SURFACE_STATE_NV 0x86EB -#define GL_SURFACE_REGISTERED_NV 0x86FD -#define GL_SURFACE_MAPPED_NV 0x8700 -#define GL_WRITE_DISCARD_NV 0x88BE -typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); -typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); -typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); -GLAPI void APIENTRY glVDPAUFiniNV (void); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); -GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); -#endif -#endif /* GL_NV_vdpau_interop */ - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); -#endif -#endif /* GL_NV_vertex_array_range */ - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif /* GL_NV_vertex_array_range2 */ - -#ifndef GL_NV_vertex_attrib_integer_64bit -#define GL_NV_vertex_attrib_integer_64bit 1 -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); -GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); -GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -#endif -#endif /* GL_NV_vertex_attrib_integer_64bit */ - -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_NV_vertex_buffer_unified_memory 1 -#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E -#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F -#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 -#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 -#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 -#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 -#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 -#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 -#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 -#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 -#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 -#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 -#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A -#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B -#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C -#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D -#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E -#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F -#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 -#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 -#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 -#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 -#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 -#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 -#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 -typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); -GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); -#endif -#endif /* GL_NV_vertex_buffer_unified_memory */ - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); -GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); -GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); -GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); -#endif -#endif /* GL_NV_vertex_program */ - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 -#endif /* GL_NV_vertex_program1_1 */ - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif /* GL_NV_vertex_program2 */ - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif /* GL_NV_vertex_program2_option */ - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif /* GL_NV_vertex_program3 */ - -#ifndef GL_NV_vertex_program4 -#define GL_NV_vertex_program4 1 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); -GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); -#endif -#endif /* GL_NV_vertex_program4 */ - -#ifndef GL_NV_video_capture -#define GL_NV_video_capture 1 -#define GL_VIDEO_BUFFER_NV 0x9020 -#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 -#define GL_FIELD_UPPER_NV 0x9022 -#define GL_FIELD_LOWER_NV 0x9023 -#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 -#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 -#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 -#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 -#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 -#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 -#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A -#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B -#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C -#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D -#define GL_PARTIAL_SUCCESS_NV 0x902E -#define GL_SUCCESS_NV 0x902F -#define GL_FAILURE_NV 0x9030 -#define GL_YCBYCR8_422_NV 0x9031 -#define GL_YCBAYCR8A_4224_NV 0x9032 -#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 -#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 -#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 -#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 -#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 -#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 -#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 -#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A -#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B -#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C -typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); -#endif -#endif /* GL_NV_video_capture */ - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif /* GL_OML_interlace */ - -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif /* GL_OML_resample */ - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif /* GL_OML_subsample */ - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); -#endif -#endif /* GL_PGI_misc_hints */ - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif /* GL_PGI_vertex_hints */ - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif /* GL_REND_screen_coordinates */ - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#define GL_RGBA_DXT5_S3TC 0x83A4 -#define GL_RGBA4_DXT5_S3TC 0x83A5 -#endif /* GL_S3_s3tc */ - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); -#endif -#endif /* GL_SGIS_detail_texture */ - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); -#endif -#endif /* GL_SGIS_fog_function */ - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif /* GL_SGIS_generate_mipmap */ - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); -#endif -#endif /* GL_SGIS_multisample */ - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); -#endif -#endif /* GL_SGIS_pixel_texture */ - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif /* GL_SGIS_point_line_texgen */ - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); -#endif -#endif /* GL_SGIS_point_parameters */ - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); -#endif -#endif /* GL_SGIS_sharpen_texture */ - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); -#endif -#endif /* GL_SGIS_texture4D */ - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif /* GL_SGIS_texture_border_clamp */ - -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif -#endif /* GL_SGIS_texture_color_mask */ - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif /* GL_SGIS_texture_edge_clamp */ - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif -#endif /* GL_SGIS_texture_filter4 */ - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif /* GL_SGIS_texture_lod */ - -#ifndef GL_SGIS_texture_select -#define GL_SGIS_texture_select 1 -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif /* GL_SGIS_texture_select */ - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 -#define GL_ASYNC_MARKER_SGIX 0x8329 -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); -#endif -#endif /* GL_SGIX_async */ - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif /* GL_SGIX_async_histogram */ - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif /* GL_SGIX_async_pixel */ - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif /* GL_SGIX_blend_alpha_minmax */ - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif /* GL_SGIX_calligraphic_fragment */ - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif /* GL_SGIX_clipmap */ - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif /* GL_SGIX_convolution_accuracy */ - -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif /* GL_SGIX_depth_pass_instrument */ - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif /* GL_SGIX_depth_texture */ - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif -#endif /* GL_SGIX_flush_raster */ - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif /* GL_SGIX_fog_offset */ - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); -GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); -#endif -#endif /* GL_SGIX_fragment_lighting */ - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); -#endif -#endif /* GL_SGIX_framezoom */ - -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); -#endif -#endif /* GL_SGIX_igloo_interface */ - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); -#endif -#endif /* GL_SGIX_instruments */ - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#define GL_INTERLACE_SGIX 0x8094 -#endif /* GL_SGIX_interlace */ - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif /* GL_SGIX_ir_instrument1 */ - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#define GL_LIST_PRIORITY_SGIX 0x8182 -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); -GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); -GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); -#endif -#endif /* GL_SGIX_list_priority */ - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); -#endif -#endif /* GL_SGIX_pixel_texture */ - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif /* GL_SGIX_pixel_tiles */ - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); -#endif -#endif /* GL_SGIX_polynomial_ffd */ - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); -#endif -#endif /* GL_SGIX_reference_plane */ - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif /* GL_SGIX_resample */ - -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif /* GL_SGIX_scalebias_hint */ - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif /* GL_SGIX_shadow */ - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif /* GL_SGIX_shadow_ambient */ - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); -#endif -#endif /* GL_SGIX_sprite */ - -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif /* GL_SGIX_subsample */ - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif -#endif /* GL_SGIX_tag_sample_buffer */ - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif /* GL_SGIX_texture_add_env */ - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif /* GL_SGIX_texture_coordinate_clamp */ - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif /* GL_SGIX_texture_lod_bias */ - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif /* GL_SGIX_texture_multi_buffer */ - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif /* GL_SGIX_texture_scale_bias */ - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif /* GL_SGIX_vertex_preclip */ - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif /* GL_SGIX_ycrcb */ - -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 -#endif /* GL_SGIX_ycrcb_subsample */ - -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif /* GL_SGIX_ycrcba */ - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif /* GL_SGI_color_matrix */ - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); -#endif -#endif /* GL_SGI_color_table */ - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif /* GL_SGI_texture_color_table */ - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif -#endif /* GL_SUNX_constant_data */ - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif /* GL_SUN_convolution_border_modes */ - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); -#endif -#endif /* GL_SUN_global_alpha */ - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif -#endif /* GL_SUN_mesh_array */ - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif /* GL_SUN_slice_accum */ - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); -#endif -#endif /* GL_SUN_triangle_list */ - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif -#endif /* GL_SUN_vertex */ - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif /* GL_WIN_phong_shading */ - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif /* GL_WIN_specular_fog */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/thirdparty/include/SDL2/SDL_opengles.h b/thirdparty/include/SDL2/SDL_opengles.h deleted file mode 100644 index 5c2a3e63c..000000000 --- a/thirdparty/include/SDL2/SDL_opengles.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_opengles.h - * - * This is a simple file to encapsulate the OpenGL ES 1.X API headers. - */ -#include "SDL_config.h" - -#ifdef __IPHONEOS__ -#include -#include -#else -#include -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif diff --git a/thirdparty/include/SDL2/SDL_opengles2.h b/thirdparty/include/SDL2/SDL_opengles2.h deleted file mode 100644 index 00bc180c2..000000000 --- a/thirdparty/include/SDL2/SDL_opengles2.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_opengles2.h - * - * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. - */ -#include "SDL_config.h" - -#ifndef _MSC_VER - -#ifdef __IPHONEOS__ -#include -#include -#else -#include -#include -#include -#endif - -#else /* _MSC_VER */ - -/* OpenGL ES2 headers for Visual Studio */ -#include "SDL_opengles2_khrplatform.h" -#include "SDL_opengles2_gl2platform.h" -#include "SDL_opengles2_gl2.h" -#include "SDL_opengles2_gl2ext.h" - -#endif /* _MSC_VER */ - -#ifndef APIENTRY -#define APIENTRY GL_APIENTRY -#endif diff --git a/thirdparty/include/SDL2/SDL_opengles2_gl2.h b/thirdparty/include/SDL2/SDL_opengles2_gl2.h deleted file mode 100644 index c62fb0a54..000000000 --- a/thirdparty/include/SDL2/SDL_opengles2_gl2.h +++ /dev/null @@ -1,621 +0,0 @@ -#ifndef __gl2_h_ -#define __gl2_h_ - -/* $Revision: 20555 $ on $Date:: 2013-02-12 14:32:47 -0800 #$ */ - -/*#include */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -/*------------------------------------------------------------------------- - * Data type definitions - *-----------------------------------------------------------------------*/ - -typedef void GLvoid; -typedef char GLchar; -typedef unsigned int GLenum; -typedef unsigned char GLboolean; -typedef unsigned int GLbitfield; -typedef khronos_int8_t GLbyte; -typedef short GLshort; -typedef int GLint; -typedef int GLsizei; -typedef khronos_uint8_t GLubyte; -typedef unsigned short GLushort; -typedef unsigned int GLuint; -typedef khronos_float_t GLfloat; -typedef khronos_float_t GLclampf; -typedef khronos_int32_t GLfixed; - -/* GL types for handling large vertex buffer objects */ -typedef khronos_intptr_t GLintptr; -typedef khronos_ssize_t GLsizeiptr; - -/* OpenGL ES core versions */ -#define GL_ES_VERSION_2_0 1 - -/* ClearBufferMask */ -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 - -/* Boolean */ -#define GL_FALSE 0 -#define GL_TRUE 1 - -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 - -/* AlphaFunction (not supported in ES20) */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 - -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ - -/* BlendEquationSeparate */ -#define GL_FUNC_ADD 0x8006 -#define GL_BLEND_EQUATION 0x8009 -#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ -#define GL_BLEND_EQUATION_ALPHA 0x883D - -/* BlendSubtract */ -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B - -/* Separate Blend Functions */ -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 - -/* Buffer Objects */ -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 - -#define GL_STREAM_DRAW 0x88E0 -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 - -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 - -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 - -/* CullFaceMode */ -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 - -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* EnableCap */ -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_BLEND 0x0BE2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_COVERAGE 0x80A0 - -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_OUT_OF_MEMORY 0x0505 - -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 - -/* GetPName */ -#define GL_LINE_WIDTH 0x0B21 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VIEWPORT 0x0BA2 -#define GL_SCISSOR_BOX 0x0C10 -/* GL_SCISSOR_TEST */ -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -/* GL_POLYGON_OFFSET_FILL */ -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB - -/* GetTextureParameter */ -/* GL_TEXTURE_MAG_FILTER */ -/* GL_TEXTURE_MIN_FILTER */ -/* GL_TEXTURE_WRAP_S */ -/* GL_TEXTURE_WRAP_T */ - -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 - -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* HintTarget */ -#define GL_GENERATE_MIPMAP_HINT 0x8192 - -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C - -/* PixelFormat */ -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A - -/* PixelType */ -/* GL_UNSIGNED_BYTE */ -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 - -/* Shaders */ -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_SHADER_TYPE 0x8B4F -#define GL_DELETE_STATUS 0x8B80 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D - -/* StencilFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 - -/* StencilOp */ -/* GL_ZERO */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_INVERT 0x150A -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 - -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 - -/* TextureMinFilter */ -/* GL_NEAREST */ -/* GL_LINEAR */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 - -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 - -/* TextureTarget */ -/* GL_TEXTURE_2D */ -#define GL_TEXTURE 0x1702 - -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C - -/* TextureUnit */ -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 - -/* TextureWrapMode */ -#define GL_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_MIRRORED_REPEAT 0x8370 - -/* Uniform Types */ -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_CUBE 0x8B60 - -/* Vertex Arrays */ -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F - -/* Read Format */ -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B - -/* Shader Source */ -#define GL_COMPILE_STATUS 0x8B81 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_SHADER_COMPILER 0x8DFA - -/* Shader Binary */ -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 - -/* Shader Precision-Specified Types */ -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 - -/* Framebuffer Object. */ -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 - -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGB565 0x8D62 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_STENCIL_INDEX8 0x8D48 - -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 - -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 - -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 - -#define GL_NONE 0 - -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD - -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 - -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 - -/*------------------------------------------------------------------------- - * GL core functions. - *-----------------------------------------------------------------------*/ - -GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); -GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); -GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); -GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode ); -GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); -GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); -GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); -GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); -GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); -GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); -GL_APICALL void GL_APIENTRY glClearStencil (GLint s); -GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); -GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); -GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); -GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); -GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); -GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); -GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); -GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); -GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); -GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); -GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); -GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glDisable (GLenum cap); -GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); -GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); -GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); -GL_APICALL void GL_APIENTRY glEnable (GLenum cap); -GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); -GL_APICALL void GL_APIENTRY glFinish (void); -GL_APICALL void GL_APIENTRY glFlush (void); -GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); -GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); -GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); -GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); -GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); -GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); -GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); -GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); -GL_APICALL GLenum GL_APIENTRY glGetError (void); -GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); -GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); -GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); -GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); -GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name); -GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); -GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); -GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); -GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); -GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); -GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); -GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); -GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); -GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); -GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); -GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); -GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); -GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); -GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); -GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); -GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); -GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); -GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); -GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); -GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); -GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); -GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params); -GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params); -GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x); -GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x); -GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y); -GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y); -GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z); -GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z); -GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); -GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); -GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); -GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); -GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); -GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z); -GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); -GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); - -#ifdef __cplusplus -} -#endif - -#endif /* __gl2_h_ */ - diff --git a/thirdparty/include/SDL2/SDL_opengles2_gl2ext.h b/thirdparty/include/SDL2/SDL_opengles2_gl2ext.h deleted file mode 100644 index e8ca8b13f..000000000 --- a/thirdparty/include/SDL2/SDL_opengles2_gl2ext.h +++ /dev/null @@ -1,2050 +0,0 @@ -#ifndef __gl2ext_h_ -#define __gl2ext_h_ - -/* $Revision: 22801 $ on $Date:: 2013-08-21 03:20:48 -0700 #$ */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -#ifndef GL_APIENTRYP -# define GL_APIENTRYP GL_APIENTRY* -#endif - -/* New types shared by several extensions */ - -#ifndef __gl3_h_ -/* These are defined with respect to in the - * Apple extension spec, but they are also used by non-APPLE - * extensions, and in the Khronos header we use the Khronos - * portable types in khrplatform.h, which must be defined. - */ -typedef khronos_int64_t GLint64; -typedef khronos_uint64_t GLuint64; -typedef struct __GLsync *GLsync; -#endif - - -/*------------------------------------------------------------------------* - * OES extension tokens - *------------------------------------------------------------------------*/ - -/* GL_OES_compressed_ETC1_RGB8_texture */ -#ifndef GL_OES_compressed_ETC1_RGB8_texture -#define GL_ETC1_RGB8_OES 0x8D64 -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif - -/* GL_OES_depth24 */ -#ifndef GL_OES_depth24 -#define GL_DEPTH_COMPONENT24_OES 0x81A6 -#endif - -/* GL_OES_depth32 */ -#ifndef GL_OES_depth32 -#define GL_DEPTH_COMPONENT32_OES 0x81A7 -#endif - -/* GL_OES_depth_texture */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_EGL_image */ -#ifndef GL_OES_EGL_image -typedef void* GLeglImageOES; -#endif - -/* GL_OES_EGL_image_external */ -#ifndef GL_OES_EGL_image_external -/* GLeglImageOES defined in GL_OES_EGL_image already. */ -#define GL_TEXTURE_EXTERNAL_OES 0x8D65 -#define GL_SAMPLER_EXTERNAL_OES 0x8D66 -#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 -#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 -#endif - -/* GL_OES_element_index_uint */ -#ifndef GL_OES_element_index_uint -#define GL_UNSIGNED_INT 0x1405 -#endif - -/* GL_OES_get_program_binary */ -#ifndef GL_OES_get_program_binary -#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE -#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF -#endif - -/* GL_OES_mapbuffer */ -#ifndef GL_OES_mapbuffer -#define GL_WRITE_ONLY_OES 0x88B9 -#define GL_BUFFER_ACCESS_OES 0x88BB -#define GL_BUFFER_MAPPED_OES 0x88BC -#define GL_BUFFER_MAP_POINTER_OES 0x88BD -#endif - -/* GL_OES_packed_depth_stencil */ -#ifndef GL_OES_packed_depth_stencil -#define GL_DEPTH_STENCIL_OES 0x84F9 -#define GL_UNSIGNED_INT_24_8_OES 0x84FA -#define GL_DEPTH24_STENCIL8_OES 0x88F0 -#endif - -/* GL_OES_required_internalformat */ -#ifndef GL_OES_required_internalformat -#define GL_ALPHA8_OES 0x803C -#define GL_DEPTH_COMPONENT16_OES 0x81A5 -/* reuse GL_DEPTH_COMPONENT24_OES */ -/* reuse GL_DEPTH24_STENCIL8_OES */ -/* reuse GL_DEPTH_COMPONENT32_OES */ -#define GL_LUMINANCE4_ALPHA4_OES 0x8043 -#define GL_LUMINANCE8_ALPHA8_OES 0x8045 -#define GL_LUMINANCE8_OES 0x8040 -#define GL_RGBA4_OES 0x8056 -#define GL_RGB5_A1_OES 0x8057 -#define GL_RGB565_OES 0x8D62 -/* reuse GL_RGB8_OES */ -/* reuse GL_RGBA8_OES */ -/* reuse GL_RGB10_EXT */ -/* reuse GL_RGB10_A2_EXT */ -#endif - -/* GL_OES_rgb8_rgba8 */ -#ifndef GL_OES_rgb8_rgba8 -#define GL_RGB8_OES 0x8051 -#define GL_RGBA8_OES 0x8058 -#endif - -/* GL_OES_standard_derivatives */ -#ifndef GL_OES_standard_derivatives -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B -#endif - -/* GL_OES_stencil1 */ -#ifndef GL_OES_stencil1 -#define GL_STENCIL_INDEX1_OES 0x8D46 -#endif - -/* GL_OES_stencil4 */ -#ifndef GL_OES_stencil4 -#define GL_STENCIL_INDEX4_OES 0x8D47 -#endif - -#ifndef GL_OES_surfaceless_context -#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 -#endif - -/* GL_OES_texture_3D */ -#ifndef GL_OES_texture_3D -#define GL_TEXTURE_WRAP_R_OES 0x8072 -#define GL_TEXTURE_3D_OES 0x806F -#define GL_TEXTURE_BINDING_3D_OES 0x806A -#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 -#define GL_SAMPLER_3D_OES 0x8B5F -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 -#endif - -/* GL_OES_texture_float */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_texture_float_linear */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_texture_half_float */ -#ifndef GL_OES_texture_half_float -#define GL_HALF_FLOAT_OES 0x8D61 -#endif - -/* GL_OES_texture_half_float_linear */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_texture_npot */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_vertex_array_object */ -#ifndef GL_OES_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 -#endif - -/* GL_OES_vertex_half_float */ -/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */ - -/* GL_OES_vertex_type_10_10_10_2 */ -#ifndef GL_OES_vertex_type_10_10_10_2 -#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 -#define GL_INT_10_10_10_2_OES 0x8DF7 -#endif - -/*------------------------------------------------------------------------* - * KHR extension tokens - *------------------------------------------------------------------------*/ - -#ifndef GL_KHR_debug -typedef void (GL_APIENTRYP GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245 -#define GL_DEBUG_SOURCE_API_KHR 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A -#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B -#define GL_DEBUG_TYPE_ERROR_KHR 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E -#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250 -#define GL_DEBUG_TYPE_OTHER_KHR 0x8251 -#define GL_DEBUG_TYPE_MARKER_KHR 0x8268 -#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269 -#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A -#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B -#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C -#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D -#define GL_BUFFER_KHR 0x82E0 -#define GL_SHADER_KHR 0x82E1 -#define GL_PROGRAM_KHR 0x82E2 -#define GL_QUERY_KHR 0x82E3 -/* PROGRAM_PIPELINE only in GL */ -#define GL_SAMPLER_KHR 0x82E6 -/* DISPLAY_LIST only in GL */ -#define GL_MAX_LABEL_LENGTH_KHR 0x82E8 -#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147 -#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148 -#define GL_DEBUG_OUTPUT_KHR 0x92E0 -#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002 -#define GL_STACK_OVERFLOW_KHR 0x0503 -#define GL_STACK_UNDERFLOW_KHR 0x0504 -#endif - -#ifndef GL_KHR_texture_compression_astc_ldr -#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD -#endif - -/*------------------------------------------------------------------------* - * AMD extension tokens - *------------------------------------------------------------------------*/ - -/* GL_AMD_compressed_3DC_texture */ -#ifndef GL_AMD_compressed_3DC_texture -#define GL_3DC_X_AMD 0x87F9 -#define GL_3DC_XY_AMD 0x87FA -#endif - -/* GL_AMD_compressed_ATC_texture */ -#ifndef GL_AMD_compressed_ATC_texture -#define GL_ATC_RGB_AMD 0x8C92 -#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 -#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE -#endif - -/* GL_AMD_performance_monitor */ -#ifndef GL_AMD_performance_monitor -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 -#endif - -/* GL_AMD_program_binary_Z400 */ -#ifndef GL_AMD_program_binary_Z400 -#define GL_Z400_BINARY_AMD 0x8740 -#endif - -/*------------------------------------------------------------------------* - * ANGLE extension tokens - *------------------------------------------------------------------------*/ - -/* GL_ANGLE_depth_texture */ -#ifndef GL_ANGLE_depth_texture -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_DEPTH_STENCIL_OES 0x84F9 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_UNSIGNED_INT 0x1405 -#define GL_UNSIGNED_INT_24_8_OES 0x84FA -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT32_OES 0x81A7 -#define GL_DEPTH24_STENCIL8_OES 0x88F0 -#endif - -/* GL_ANGLE_framebuffer_blit */ -#ifndef GL_ANGLE_framebuffer_blit -#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA -#endif - -/* GL_ANGLE_framebuffer_multisample */ -#ifndef GL_ANGLE_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 -#define GL_MAX_SAMPLES_ANGLE 0x8D57 -#endif - -/* GL_ANGLE_instanced_arrays */ -#ifndef GL_ANGLE_instanced_arrays -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE -#endif - -/* GL_ANGLE_pack_reverse_row_order */ -#ifndef GL_ANGLE_pack_reverse_row_order -#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 -#endif - -/* GL_ANGLE_program_binary */ -#ifndef GL_ANGLE_program_binary -#define GL_PROGRAM_BINARY_ANGLE 0x93A6 -#endif - -/* GL_ANGLE_texture_compression_dxt3 */ -#ifndef GL_ANGLE_texture_compression_dxt3 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 -#endif - -/* GL_ANGLE_texture_compression_dxt5 */ -#ifndef GL_ANGLE_texture_compression_dxt5 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 -#endif - -/* GL_ANGLE_texture_usage */ -#ifndef GL_ANGLE_texture_usage -#define GL_TEXTURE_USAGE_ANGLE 0x93A2 -#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 -#endif - -/* GL_ANGLE_translated_shader_source */ -#ifndef GL_ANGLE_translated_shader_source -#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 -#endif - -/*------------------------------------------------------------------------* - * APPLE extension tokens - *------------------------------------------------------------------------*/ - -/* GL_APPLE_copy_texture_levels */ -/* No new tokens introduced by this extension. */ - -/* GL_APPLE_framebuffer_multisample */ -#ifndef GL_APPLE_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 -#define GL_MAX_SAMPLES_APPLE 0x8D57 -#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA -#endif - -/* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_rgb_422 -#define GL_RGB_422_APPLE 0x8A1F -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -/* GL_APPLE_sync */ -#ifndef GL_APPLE_sync - -#define GL_SYNC_OBJECT_APPLE 0x8A53 -#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 -#define GL_OBJECT_TYPE_APPLE 0x9112 -#define GL_SYNC_CONDITION_APPLE 0x9113 -#define GL_SYNC_STATUS_APPLE 0x9114 -#define GL_SYNC_FLAGS_APPLE 0x9115 -#define GL_SYNC_FENCE_APPLE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 -#define GL_UNSIGNALED_APPLE 0x9118 -#define GL_SIGNALED_APPLE 0x9119 -#define GL_ALREADY_SIGNALED_APPLE 0x911A -#define GL_TIMEOUT_EXPIRED_APPLE 0x911B -#define GL_CONDITION_SATISFIED_APPLE 0x911C -#define GL_WAIT_FAILED_APPLE 0x911D -#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 -#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull -#endif - -/* GL_APPLE_texture_format_BGRA8888 */ -#ifndef GL_APPLE_texture_format_BGRA8888 -#define GL_BGRA_EXT 0x80E1 -#endif - -/* GL_APPLE_texture_max_level */ -#ifndef GL_APPLE_texture_max_level -#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D -#endif - -/*------------------------------------------------------------------------* - * ARM extension tokens - *------------------------------------------------------------------------*/ - -/* GL_ARM_mali_program_binary */ -#ifndef GL_ARM_mali_program_binary -#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61 -#endif - -/* GL_ARM_mali_shader_binary */ -#ifndef GL_ARM_mali_shader_binary -#define GL_MALI_SHADER_BINARY_ARM 0x8F60 -#endif - -/* GL_ARM_rgba8 */ -/* No new tokens introduced by this extension. */ - -/*------------------------------------------------------------------------* - * EXT extension tokens - *------------------------------------------------------------------------*/ - -/* GL_EXT_blend_minmax */ -#ifndef GL_EXT_blend_minmax -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#endif - -/* GL_EXT_color_buffer_half_float */ -#ifndef GL_EXT_color_buffer_half_float -#define GL_RGBA16F_EXT 0x881A -#define GL_RGB16F_EXT 0x881B -#define GL_RG16F_EXT 0x822F -#define GL_R16F_EXT 0x822D -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211 -#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17 -#endif - -/* GL_EXT_debug_label */ -#ifndef GL_EXT_debug_label -#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F -#define GL_PROGRAM_OBJECT_EXT 0x8B40 -#define GL_SHADER_OBJECT_EXT 0x8B48 -#define GL_BUFFER_OBJECT_EXT 0x9151 -#define GL_QUERY_OBJECT_EXT 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 -#endif - -/* GL_EXT_debug_marker */ -/* No new tokens introduced by this extension. */ - -/* GL_EXT_discard_framebuffer */ -#ifndef GL_EXT_discard_framebuffer -#define GL_COLOR_EXT 0x1800 -#define GL_DEPTH_EXT 0x1801 -#define GL_STENCIL_EXT 0x1802 -#endif - -#ifndef GL_EXT_disjoint_timer_query -#define GL_QUERY_COUNTER_BITS_EXT 0x8864 -#define GL_CURRENT_QUERY_EXT 0x8865 -#define GL_QUERY_RESULT_EXT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 -#define GL_TIME_ELAPSED_EXT 0x88BF -#define GL_TIMESTAMP_EXT 0x8E28 -#define GL_GPU_DISJOINT_EXT 0x8FBB -#endif - -#ifndef GL_EXT_draw_buffers -#define GL_EXT_draw_buffers 1 -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_MAX_DRAW_BUFFERS_EXT 0x8824 -#define GL_DRAW_BUFFER0_EXT 0x8825 -#define GL_DRAW_BUFFER1_EXT 0x8826 -#define GL_DRAW_BUFFER2_EXT 0x8827 -#define GL_DRAW_BUFFER3_EXT 0x8828 -#define GL_DRAW_BUFFER4_EXT 0x8829 -#define GL_DRAW_BUFFER5_EXT 0x882A -#define GL_DRAW_BUFFER6_EXT 0x882B -#define GL_DRAW_BUFFER7_EXT 0x882C -#define GL_DRAW_BUFFER8_EXT 0x882D -#define GL_DRAW_BUFFER9_EXT 0x882E -#define GL_DRAW_BUFFER10_EXT 0x882F -#define GL_DRAW_BUFFER11_EXT 0x8830 -#define GL_DRAW_BUFFER12_EXT 0x8831 -#define GL_DRAW_BUFFER13_EXT 0x8832 -#define GL_DRAW_BUFFER14_EXT 0x8833 -#define GL_DRAW_BUFFER15_EXT 0x8834 -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#endif - -/* GL_EXT_map_buffer_range */ -#ifndef GL_EXT_map_buffer_range -#define GL_MAP_READ_BIT_EXT 0x0001 -#define GL_MAP_WRITE_BIT_EXT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 -#endif - -/* GL_EXT_multisampled_render_to_texture */ -#ifndef GL_EXT_multisampled_render_to_texture -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C -/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */ -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -#endif - -/* GL_EXT_multiview_draw_buffers */ -#ifndef GL_EXT_multiview_draw_buffers -#define GL_COLOR_ATTACHMENT_EXT 0x90F0 -#define GL_MULTIVIEW_EXT 0x90F1 -#define GL_DRAW_BUFFER_EXT 0x0C01 -#define GL_READ_BUFFER_EXT 0x0C02 -#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 -#endif - -/* GL_EXT_multi_draw_arrays */ -/* No new tokens introduced by this extension. */ - -/* GL_EXT_occlusion_query_boolean */ -#ifndef GL_EXT_occlusion_query_boolean -#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F -#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A -#define GL_CURRENT_QUERY_EXT 0x8865 -#define GL_QUERY_RESULT_EXT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 -#endif - -/* GL_EXT_read_format_bgra */ -#ifndef GL_EXT_read_format_bgra -#define GL_BGRA_EXT 0x80E1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 -#endif - -/* GL_EXT_robustness */ -#ifndef GL_EXT_robustness -/* reuse GL_NO_ERROR */ -#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255 -#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3 -#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256 -#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252 -#define GL_NO_RESET_NOTIFICATION_EXT 0x8261 -#endif - -/* GL_EXT_separate_shader_objects */ -#ifndef GL_EXT_separate_shader_objects -#define GL_VERTEX_SHADER_BIT_EXT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002 -#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF -#define GL_PROGRAM_SEPARABLE_EXT 0x8258 -#define GL_ACTIVE_PROGRAM_EXT 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A -#endif - -/* GL_EXT_shader_framebuffer_fetch */ -#ifndef GL_EXT_shader_framebuffer_fetch -#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 -#endif - -/* GL_EXT_shader_texture_lod */ -/* No new tokens introduced by this extension. */ - -/* GL_EXT_shadow_samplers */ -#ifndef GL_EXT_shadow_samplers -#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C -#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D -#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E -#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62 -#endif - -/* GL_EXT_sRGB */ -#ifndef GL_EXT_sRGB -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210 -#endif - -/* GL_EXT_sRGB_write_control */ -#ifndef GL_EXT_sRGB_write_control -#define GL_EXT_sRGB_write_control 1 -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#endif - -/* GL_EXT_texture_compression_dxt1 */ -#ifndef GL_EXT_texture_compression_dxt1 -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#endif - -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -/* GL_EXT_texture_format_BGRA8888 */ -#ifndef GL_EXT_texture_format_BGRA8888 -#define GL_BGRA_EXT 0x80E1 -#endif - -/* GL_EXT_texture_rg */ -#ifndef GL_EXT_texture_rg -#define GL_RED_EXT 0x1903 -#define GL_RG_EXT 0x8227 -#define GL_R8_EXT 0x8229 -#define GL_RG8_EXT 0x822B -#endif - -/* GL_EXT_texture_sRGB_decode */ -#ifndef GL_EXT_texture_sRGB_decode -#define GL_EXT_texture_sRGB_decode 1 -#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 -#define GL_DECODE_EXT 0x8A49 -#define GL_SKIP_DECODE_EXT 0x8A4A -#endif - -/* GL_EXT_texture_storage */ -#ifndef GL_EXT_texture_storage -#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F -#define GL_ALPHA8_EXT 0x803C -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_RGBA32F_EXT 0x8814 -#define GL_RGB32F_EXT 0x8815 -#define GL_ALPHA32F_EXT 0x8816 -#define GL_LUMINANCE32F_EXT 0x8818 -#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 -/* reuse GL_RGBA16F_EXT */ -/* reuse GL_RGB16F_EXT */ -#define GL_ALPHA16F_EXT 0x881C -#define GL_LUMINANCE16F_EXT 0x881E -#define GL_LUMINANCE_ALPHA16F_EXT 0x881F -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGB10_EXT 0x8052 -#define GL_BGRA8_EXT 0x93A1 -#define GL_R8_EXT 0x8229 -#define GL_RG8_EXT 0x822B -#define GL_R32F_EXT 0x822E -#define GL_RG32F_EXT 0x8230 -#define GL_R16F_EXT 0x822D -#define GL_RG16F_EXT 0x822F -#endif - -/* GL_EXT_texture_type_2_10_10_10_REV */ -#ifndef GL_EXT_texture_type_2_10_10_10_REV -#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 -#endif - -/* GL_EXT_unpack_subimage */ -#ifndef GL_EXT_unpack_subimage -#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 -#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 -#endif - -/*------------------------------------------------------------------------* - * DMP extension tokens - *------------------------------------------------------------------------*/ - -/* GL_DMP_shader_binary */ -#ifndef GL_DMP_shader_binary -#define GL_SHADER_BINARY_DMP 0x9250 -#endif - -/*------------------------------------------------------------------------* - * FJ extension tokens - *------------------------------------------------------------------------*/ - -/* GL_FJ_shader_binary_GCCSO */ -#ifndef GL_FJ_shader_binary_GCCSO -#define GL_GCCSO_SHADER_BINARY_FJ 0x9260 -#endif - -/*------------------------------------------------------------------------* - * IMG extension tokens - *------------------------------------------------------------------------*/ - -/* GL_IMG_program_binary */ -#ifndef GL_IMG_program_binary -#define GL_SGX_PROGRAM_BINARY_IMG 0x9130 -#endif - -/* GL_IMG_read_format */ -#ifndef GL_IMG_read_format -#define GL_BGRA_IMG 0x80E1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 -#endif - -/* GL_IMG_shader_binary */ -#ifndef GL_IMG_shader_binary -#define GL_SGX_BINARY_IMG 0x8C0A -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -#endif - -/* GL_IMG_texture_compression_pvrtc2 */ -#ifndef GL_IMG_texture_compression_pvrtc2 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 -#endif - -/* GL_IMG_multisampled_render_to_texture */ -#ifndef GL_IMG_multisampled_render_to_texture -#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 -#define GL_MAX_SAMPLES_IMG 0x9135 -#define GL_TEXTURE_SAMPLES_IMG 0x9136 -#endif - -/*------------------------------------------------------------------------* - * NV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_NV_coverage_sample */ -#ifndef GL_NV_coverage_sample -#define GL_COVERAGE_COMPONENT_NV 0x8ED0 -#define GL_COVERAGE_COMPONENT4_NV 0x8ED1 -#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 -#define GL_COVERAGE_BUFFERS_NV 0x8ED3 -#define GL_COVERAGE_SAMPLES_NV 0x8ED4 -#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 -#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 -#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 -#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000 -#endif - -/* GL_NV_depth_nonlinear */ -#ifndef GL_NV_depth_nonlinear -#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C -#endif - -/* GL_NV_draw_buffers */ -#ifndef GL_NV_draw_buffers -#define GL_MAX_DRAW_BUFFERS_NV 0x8824 -#define GL_DRAW_BUFFER0_NV 0x8825 -#define GL_DRAW_BUFFER1_NV 0x8826 -#define GL_DRAW_BUFFER2_NV 0x8827 -#define GL_DRAW_BUFFER3_NV 0x8828 -#define GL_DRAW_BUFFER4_NV 0x8829 -#define GL_DRAW_BUFFER5_NV 0x882A -#define GL_DRAW_BUFFER6_NV 0x882B -#define GL_DRAW_BUFFER7_NV 0x882C -#define GL_DRAW_BUFFER8_NV 0x882D -#define GL_DRAW_BUFFER9_NV 0x882E -#define GL_DRAW_BUFFER10_NV 0x882F -#define GL_DRAW_BUFFER11_NV 0x8830 -#define GL_DRAW_BUFFER12_NV 0x8831 -#define GL_DRAW_BUFFER13_NV 0x8832 -#define GL_DRAW_BUFFER14_NV 0x8833 -#define GL_DRAW_BUFFER15_NV 0x8834 -#define GL_COLOR_ATTACHMENT0_NV 0x8CE0 -#define GL_COLOR_ATTACHMENT1_NV 0x8CE1 -#define GL_COLOR_ATTACHMENT2_NV 0x8CE2 -#define GL_COLOR_ATTACHMENT3_NV 0x8CE3 -#define GL_COLOR_ATTACHMENT4_NV 0x8CE4 -#define GL_COLOR_ATTACHMENT5_NV 0x8CE5 -#define GL_COLOR_ATTACHMENT6_NV 0x8CE6 -#define GL_COLOR_ATTACHMENT7_NV 0x8CE7 -#define GL_COLOR_ATTACHMENT8_NV 0x8CE8 -#define GL_COLOR_ATTACHMENT9_NV 0x8CE9 -#define GL_COLOR_ATTACHMENT10_NV 0x8CEA -#define GL_COLOR_ATTACHMENT11_NV 0x8CEB -#define GL_COLOR_ATTACHMENT12_NV 0x8CEC -#define GL_COLOR_ATTACHMENT13_NV 0x8CED -#define GL_COLOR_ATTACHMENT14_NV 0x8CEE -#define GL_COLOR_ATTACHMENT15_NV 0x8CEF -#endif - -/* GL_NV_draw_instanced */ -/* No new tokens introduced by this extension. */ - -/* GL_NV_fbo_color_attachments */ -#ifndef GL_NV_fbo_color_attachments -#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF -/* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */ -#endif - -/* GL_NV_fence */ -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -/* GL_NV_framebuffer_blit */ -#ifndef GL_NV_framebuffer_blit -#define GL_READ_FRAMEBUFFER_NV 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA -#endif - -/* GL_NV_framebuffer_multisample */ -#ifndef GL_NV_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56 -#define GL_MAX_SAMPLES_NV 0x8D57 -#endif - -/* GL_NV_generate_mipmap_sRGB */ -/* No new tokens introduced by this extension. */ - -/* GL_NV_instanced_arrays */ -#ifndef GL_NV_instanced_arrays -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE -#endif - -/* GL_NV_read_buffer */ -#ifndef GL_NV_read_buffer -#define GL_READ_BUFFER_NV 0x0C02 -#endif - -/* GL_NV_read_buffer_front */ -/* No new tokens introduced by this extension. */ - -/* GL_NV_read_depth */ -/* No new tokens introduced by this extension. */ - -/* GL_NV_read_depth_stencil */ -/* No new tokens introduced by this extension. */ - -/* GL_NV_read_stencil */ -/* No new tokens introduced by this extension. */ - -/* GL_NV_shadow_samplers_array */ -#ifndef GL_NV_shadow_samplers_array -#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4 -#endif - -/* GL_NV_shadow_samplers_cube */ -#ifndef GL_NV_shadow_samplers_cube -#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 -#endif - -/* GL_NV_sRGB_formats */ -#ifndef GL_NV_sRGB_formats -#define GL_SLUMINANCE_NV 0x8C46 -#define GL_SLUMINANCE_ALPHA_NV 0x8C44 -#define GL_SRGB8_NV 0x8C41 -#define GL_SLUMINANCE8_NV 0x8C47 -#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45 -#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F -#define GL_ETC1_SRGB8_NV 0x88EE -#endif - -/* GL_NV_texture_border_clamp */ -#ifndef GL_NV_texture_border_clamp -#define GL_TEXTURE_BORDER_COLOR_NV 0x1004 -#define GL_CLAMP_TO_BORDER_NV 0x812D -#endif - -/* GL_NV_texture_compression_s3tc_update */ -/* No new tokens introduced by this extension. */ - -/* GL_NV_texture_npot_2D_mipmap */ -/* No new tokens introduced by this extension. */ - -/*------------------------------------------------------------------------* - * QCOM extension tokens - *------------------------------------------------------------------------*/ - -/* GL_QCOM_alpha_test */ -#ifndef GL_QCOM_alpha_test -#define GL_ALPHA_TEST_QCOM 0x0BC0 -#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1 -#define GL_ALPHA_TEST_REF_QCOM 0x0BC2 -#endif - -/* GL_QCOM_binning_control */ -#ifndef GL_QCOM_binning_control -#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 -#define GL_CPU_OPTIMIZED_QCOM 0x8FB1 -#define GL_GPU_OPTIMIZED_QCOM 0x8FB2 -#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 -#endif - -/* GL_QCOM_driver_control */ -/* No new tokens introduced by this extension. */ - -/* GL_QCOM_extended_get */ -#ifndef GL_QCOM_extended_get -#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 -#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 -#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 -#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 -#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 -#define GL_TEXTURE_TYPE_QCOM 0x8BD7 -#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 -#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 -#define GL_TEXTURE_TARGET_QCOM 0x8BDA -#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB -#define GL_STATE_RESTORE 0x8BDC -#endif - -/* GL_QCOM_extended_get2 */ -/* No new tokens introduced by this extension. */ - -/* GL_QCOM_perfmon_global_mode */ -#ifndef GL_QCOM_perfmon_global_mode -#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 -#endif - -/* GL_QCOM_writeonly_rendering */ -#ifndef GL_QCOM_writeonly_rendering -#define GL_WRITEONLY_RENDERING_QCOM 0x8823 -#endif - -/* GL_QCOM_tiled_rendering */ -#ifndef GL_QCOM_tiled_rendering -#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 -#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 -#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 -#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 -#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 -#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 -#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 -#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 -#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 -#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 -#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 -#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 -#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 -#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 -#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 -#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 -#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 -#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 -#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 -#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 -#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 -#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 -#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 -#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 -#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 -#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 -#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 -#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 -#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 -#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 -#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 -#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 -#endif - -/*------------------------------------------------------------------------* - * VIV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_VIV_shader_binary */ -#ifndef GL_VIV_shader_binary -#define GL_SHADER_BINARY_VIV 0x8FC4 -#endif - -/*------------------------------------------------------------------------* - * End of extension tokens, start of corresponding extension functions - *------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------* - * OES extension functions - *------------------------------------------------------------------------*/ - -/* GL_OES_compressed_ETC1_RGB8_texture */ -#ifndef GL_OES_compressed_ETC1_RGB8_texture -#define GL_OES_compressed_ETC1_RGB8_texture 1 -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 -#endif - -/* GL_OES_depth24 */ -#ifndef GL_OES_depth24 -#define GL_OES_depth24 1 -#endif - -/* GL_OES_depth32 */ -#ifndef GL_OES_depth32 -#define GL_OES_depth32 1 -#endif - -/* GL_OES_depth_texture */ -#ifndef GL_OES_depth_texture -#define GL_OES_depth_texture 1 -#endif - -/* GL_OES_EGL_image */ -#ifndef GL_OES_EGL_image -#define GL_OES_EGL_image 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); -GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); -#endif -typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); -typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); -#endif - -/* GL_OES_EGL_image_external */ -#ifndef GL_OES_EGL_image_external -#define GL_OES_EGL_image_external 1 -/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */ -#endif - -/* GL_OES_element_index_uint */ -#ifndef GL_OES_element_index_uint -#define GL_OES_element_index_uint 1 -#endif - -/* GL_OES_fbo_render_mipmap */ -#ifndef GL_OES_fbo_render_mipmap -#define GL_OES_fbo_render_mipmap 1 -#endif - -/* GL_OES_fragment_precision_high */ -#ifndef GL_OES_fragment_precision_high -#define GL_OES_fragment_precision_high 1 -#endif - -/* GL_OES_get_program_binary */ -#ifndef GL_OES_get_program_binary -#define GL_OES_get_program_binary 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); -#endif -typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); -#endif - -/* GL_OES_mapbuffer */ -#ifndef GL_OES_mapbuffer -#define GL_OES_mapbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); -GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); -GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid **params); -#endif -typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); -typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); -typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid **params); -#endif - -/* GL_OES_packed_depth_stencil */ -#ifndef GL_OES_packed_depth_stencil -#define GL_OES_packed_depth_stencil 1 -#endif - -/* GL_OES_required_internalformat */ -#ifndef GL_OES_required_internalformat -#define GL_OES_required_internalformat 1 -#endif - -/* GL_OES_rgb8_rgba8 */ -#ifndef GL_OES_rgb8_rgba8 -#define GL_OES_rgb8_rgba8 1 -#endif - -/* GL_OES_standard_derivatives */ -#ifndef GL_OES_standard_derivatives -#define GL_OES_standard_derivatives 1 -#endif - -/* GL_OES_stencil1 */ -#ifndef GL_OES_stencil1 -#define GL_OES_stencil1 1 -#endif - -/* GL_OES_stencil4 */ -#ifndef GL_OES_stencil4 -#define GL_OES_stencil4 1 -#endif - -#ifndef GL_OES_surfaceless_context -#define GL_OES_surfaceless_context 1 -#endif - -/* GL_OES_texture_3D */ -#ifndef GL_OES_texture_3D -#define GL_OES_texture_3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -#endif -typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); -typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); -typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); -typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -#endif - -/* GL_OES_texture_float */ -#ifndef GL_OES_texture_float -#define GL_OES_texture_float 1 -#endif - -/* GL_OES_texture_float_linear */ -#ifndef GL_OES_texture_float_linear -#define GL_OES_texture_float_linear 1 -#endif - -/* GL_OES_texture_half_float */ -#ifndef GL_OES_texture_half_float -#define GL_OES_texture_half_float 1 -#endif - -/* GL_OES_texture_half_float_linear */ -#ifndef GL_OES_texture_half_float_linear -#define GL_OES_texture_half_float_linear 1 -#endif - -/* GL_OES_texture_npot */ -#ifndef GL_OES_texture_npot -#define GL_OES_texture_npot 1 -#endif - -/* GL_OES_vertex_array_object */ -#ifndef GL_OES_vertex_array_object -#define GL_OES_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array); -GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); -GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); -GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); -#endif -typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); -typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); -typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); -#endif - -/* GL_OES_vertex_half_float */ -#ifndef GL_OES_vertex_half_float -#define GL_OES_vertex_half_float 1 -#endif - -/* GL_OES_vertex_type_10_10_10_2 */ -#ifndef GL_OES_vertex_type_10_10_10_2 -#define GL_OES_vertex_type_10_10_10_2 1 -#endif - -/*------------------------------------------------------------------------* - * KHR extension functions - *------------------------------------------------------------------------*/ - -#ifndef GL_KHR_debug -#define GL_KHR_debug 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam); -GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message); -GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void); -GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); -GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); -GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label); -GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); -GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, GLvoid **params); -#endif -typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam); -typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); -typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void); -typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); -typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); -typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label); -typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); -typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, GLvoid **params); -#endif - -#ifndef GL_KHR_texture_compression_astc_ldr -#define GL_KHR_texture_compression_astc_ldr 1 -#endif - - -/*------------------------------------------------------------------------* - * AMD extension functions - *------------------------------------------------------------------------*/ - -/* GL_AMD_compressed_3DC_texture */ -#ifndef GL_AMD_compressed_3DC_texture -#define GL_AMD_compressed_3DC_texture 1 -#endif - -/* GL_AMD_compressed_ATC_texture */ -#ifndef GL_AMD_compressed_ATC_texture -#define GL_AMD_compressed_ATC_texture 1 -#endif - -/* AMD_performance_monitor */ -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); -GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); -GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); -GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor); -GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); -typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif - -/* GL_AMD_program_binary_Z400 */ -#ifndef GL_AMD_program_binary_Z400 -#define GL_AMD_program_binary_Z400 1 -#endif - -/*------------------------------------------------------------------------* - * ANGLE extension functions - *------------------------------------------------------------------------*/ - -/* GL_ANGLE_depth_texture */ -#ifndef GL_ANGLE_depth_texture -#define GL_ANGLE_depth_texture 1 -#endif - -/* GL_ANGLE_framebuffer_blit */ -#ifndef GL_ANGLE_framebuffer_blit -#define GL_ANGLE_framebuffer_blit 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif -typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -/* GL_ANGLE_framebuffer_multisample */ -#ifndef GL_ANGLE_framebuffer_multisample -#define GL_ANGLE_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_ANGLE_instanced_arrays -#define GL_ANGLE_instanced_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); -#endif -typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); -typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); -#endif - -/* GL_ANGLE_pack_reverse_row_order */ -#ifndef GL_ANGLE_pack_reverse_row_order -#define GL_ANGLE_pack_reverse_row_order 1 -#endif - -/* GL_ANGLE_program_binary */ -#ifndef GL_ANGLE_program_binary -#define GL_ANGLE_program_binary 1 -#endif - -/* GL_ANGLE_texture_compression_dxt3 */ -#ifndef GL_ANGLE_texture_compression_dxt3 -#define GL_ANGLE_texture_compression_dxt3 1 -#endif - -/* GL_ANGLE_texture_compression_dxt5 */ -#ifndef GL_ANGLE_texture_compression_dxt5 -#define GL_ANGLE_texture_compression_dxt5 1 -#endif - -/* GL_ANGLE_texture_usage */ -#ifndef GL_ANGLE_texture_usage -#define GL_ANGLE_texture_usage 1 -#endif - -#ifndef GL_ANGLE_translated_shader_source -#define GL_ANGLE_translated_shader_source 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); -#endif -typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); -#endif - -/*------------------------------------------------------------------------* - * APPLE extension functions - *------------------------------------------------------------------------*/ - -/* GL_APPLE_copy_texture_levels */ -#ifndef GL_APPLE_copy_texture_levels -#define GL_APPLE_copy_texture_levels 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); -#endif -typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); -#endif - -/* GL_APPLE_framebuffer_multisample */ -#ifndef GL_APPLE_framebuffer_multisample -#define GL_APPLE_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); -#endif - -/* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 -#endif - -/* GL_APPLE_sync */ -#ifndef GL_APPLE_sync -#define GL_APPLE_sync 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); -GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); -GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); -GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); -GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); -GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); -GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif -typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); -typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); -typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); -typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); -typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif - -/* GL_APPLE_texture_format_BGRA8888 */ -#ifndef GL_APPLE_texture_format_BGRA8888 -#define GL_APPLE_texture_format_BGRA8888 1 -#endif - -/* GL_APPLE_texture_max_level */ -#ifndef GL_APPLE_texture_max_level -#define GL_APPLE_texture_max_level 1 -#endif - -/*------------------------------------------------------------------------* - * ARM extension functions - *------------------------------------------------------------------------*/ - -/* GL_ARM_mali_program_binary */ -#ifndef GL_ARM_mali_program_binary -#define GL_ARM_mali_program_binary 1 -#endif - -/* GL_ARM_mali_shader_binary */ -#ifndef GL_ARM_mali_shader_binary -#define GL_ARM_mali_shader_binary 1 -#endif - -/* GL_ARM_rgba8 */ -#ifndef GL_ARM_rgba8 -#define GL_ARM_rgba8 1 -#endif - -/*------------------------------------------------------------------------* - * EXT extension functions - *------------------------------------------------------------------------*/ - -/* GL_EXT_blend_minmax */ -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#endif - -/* GL_EXT_color_buffer_half_float */ -#ifndef GL_EXT_color_buffer_half_float -#define GL_EXT_color_buffer_half_float 1 -#endif - -/* GL_EXT_debug_label */ -#ifndef GL_EXT_debug_label -#define GL_EXT_debug_label 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); -GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); -#endif -typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); -typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); -#endif - -/* GL_EXT_debug_marker */ -#ifndef GL_EXT_debug_marker -#define GL_EXT_debug_marker 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); -GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); -GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void); -#endif -typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); -typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); -typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); -#endif - -/* GL_EXT_discard_framebuffer */ -#ifndef GL_EXT_discard_framebuffer -#define GL_EXT_discard_framebuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); -#endif -typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); -#endif - -#ifndef GL_EXT_disjoint_timer_query -#define GL_EXT_disjoint_timer_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids); -GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids); -GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id); -GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id); -GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target); -GL_APICALL void GL_APIENTRY glQueryCounterEXT (GLuint id, GLenum target); -GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params); -GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params); -GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params); -GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); -GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); -#endif -typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids); -typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id); -typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id); -typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target); -typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target); -typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); -#endif /* GL_EXT_disjoint_timer_query */ - -#ifndef GL_EXT_draw_buffers -#define GL_EXT_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs); -#endif -typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs); -#endif /* GL_EXT_draw_buffers */ - -/* GL_EXT_map_buffer_range */ -#ifndef GL_EXT_map_buffer_range -#define GL_EXT_map_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); -#endif -typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -#endif - -/* GL_EXT_multisampled_render_to_texture */ -#ifndef GL_EXT_multisampled_render_to_texture -#define GL_EXT_multisampled_render_to_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); -#endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); -#endif - -/* GL_EXT_multiview_draw_buffers */ -#ifndef GL_EXT_multiview_draw_buffers -#define GL_EXT_multiview_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index); -GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices); -GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data); -#endif -typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index); -typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices); -typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data); -#endif - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); -#endif - -/* GL_EXT_occlusion_query_boolean */ -#ifndef GL_EXT_occlusion_query_boolean -#define GL_EXT_occlusion_query_boolean 1 -/* All entry points also exist in GL_EXT_disjoint_timer_query */ -#endif - -/* GL_EXT_read_format_bgra */ -#ifndef GL_EXT_read_format_bgra -#define GL_EXT_read_format_bgra 1 -#endif - -/* GL_EXT_robustness */ -#ifndef GL_EXT_robustness -#define GL_EXT_robustness 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void); -GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params); -#endif -typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void); -typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); -#endif - -/* GL_EXT_separate_shader_objects */ -#ifndef GL_EXT_separate_shader_objects -#define GL_EXT_separate_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program); -GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program); -GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings); -GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline); -GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines); -GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines); -GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline); -GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); -GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params); -GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint x); -GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint x, GLint y); -GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z); -GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); -GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat x); -GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat x, GLfloat y); -GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); -GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline); -GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif -typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program); -typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program); -typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings); -typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline); -typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines); -typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines); -typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline); -typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); -typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint x); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint x, GLint y); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat x); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline); -typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif - -/* GL_EXT_shader_framebuffer_fetch */ -#ifndef GL_EXT_shader_framebuffer_fetch -#define GL_EXT_shader_framebuffer_fetch 1 -#endif - -/* GL_EXT_shader_texture_lod */ -#ifndef GL_EXT_shader_texture_lod -#define GL_EXT_shader_texture_lod 1 -#endif - -/* GL_EXT_shadow_samplers */ -#ifndef GL_EXT_shadow_samplers -#define GL_EXT_shadow_samplers 1 -#endif - -/* GL_EXT_sRGB */ -#ifndef GL_EXT_sRGB -#define GL_EXT_sRGB 1 -#endif - -/* GL_EXT_texture_compression_dxt1 */ -#ifndef GL_EXT_texture_compression_dxt1 -#define GL_EXT_texture_compression_dxt1 1 -#endif - -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -/* GL_EXT_texture_format_BGRA8888 */ -#ifndef GL_EXT_texture_format_BGRA8888 -#define GL_EXT_texture_format_BGRA8888 1 -#endif - -/* GL_EXT_texture_rg */ -#ifndef GL_EXT_texture_rg -#define GL_EXT_texture_rg 1 -#endif - -/* GL_EXT_texture_storage */ -#ifndef GL_EXT_texture_storage -#define GL_EXT_texture_storage 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif -typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif - -/* GL_EXT_texture_type_2_10_10_10_REV */ -#ifndef GL_EXT_texture_type_2_10_10_10_REV -#define GL_EXT_texture_type_2_10_10_10_REV 1 -#endif - -/* GL_EXT_unpack_subimage */ -#ifndef GL_EXT_unpack_subimage -#define GL_EXT_unpack_subimage 1 -#endif - -/*------------------------------------------------------------------------* - * DMP extension functions - *------------------------------------------------------------------------*/ - -/* GL_DMP_shader_binary */ -#ifndef GL_DMP_shader_binary -#define GL_DMP_shader_binary 1 -#endif - -/*------------------------------------------------------------------------* - * FJ extension functions - *------------------------------------------------------------------------*/ - -/* GL_FJ_shader_binary_GCCSO */ -#ifndef GL_FJ_shader_binary_GCCSO -#define GL_FJ_shader_binary_GCCSO 1 -#endif - -/*------------------------------------------------------------------------* - * IMG extension functions - *------------------------------------------------------------------------*/ - -/* GL_IMG_program_binary */ -#ifndef GL_IMG_program_binary -#define GL_IMG_program_binary 1 -#endif - -/* GL_IMG_read_format */ -#ifndef GL_IMG_read_format -#define GL_IMG_read_format 1 -#endif - -/* GL_IMG_shader_binary */ -#ifndef GL_IMG_shader_binary -#define GL_IMG_shader_binary 1 -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_IMG_texture_compression_pvrtc 1 -#endif - -/* GL_IMG_texture_compression_pvrtc2 */ -#ifndef GL_IMG_texture_compression_pvrtc2 -#define GL_IMG_texture_compression_pvrtc2 1 -#endif - -/* GL_IMG_multisampled_render_to_texture */ -#ifndef GL_IMG_multisampled_render_to_texture -#define GL_IMG_multisampled_render_to_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); -#endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); -#endif - -/*------------------------------------------------------------------------* - * NV extension functions - *------------------------------------------------------------------------*/ - -/* GL_NV_coverage_sample */ -#ifndef GL_NV_coverage_sample -#define GL_NV_coverage_sample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); -GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); -#endif -typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); -typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); -#endif - -/* GL_NV_depth_nonlinear */ -#ifndef GL_NV_depth_nonlinear -#define GL_NV_depth_nonlinear 1 -#endif - -/* GL_NV_draw_buffers */ -#ifndef GL_NV_draw_buffers -#define GL_NV_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs); -#endif -typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs); -#endif - -/* GL_NV_draw_instanced */ -#ifndef GL_NV_draw_instanced -#define GL_NV_draw_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif -typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -/* GL_NV_fbo_color_attachments */ -#ifndef GL_NV_fbo_color_attachments -#define GL_NV_fbo_color_attachments 1 -#endif - -/* GL_NV_fence */ -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); -GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); -GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint fence); -GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint fence); -GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); -GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint fence); -GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint fence, GLenum condition); -#endif -typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -/* GL_NV_framebuffer_blit */ -#ifndef GL_NV_framebuffer_blit -#define GL_NV_framebuffer_blit 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBlitFramebufferNV (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif -typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -/* GL_NV_framebuffer_multisample */ -#ifndef GL_NV_framebuffer_multisample -#define GL_NV_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLENVPROC) ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -/* GL_NV_generate_mipmap_sRGB */ -#ifndef GL_NV_generate_mipmap_sRGB -#define GL_NV_generate_mipmap_sRGB 1 -#endif - -/* GL_NV_instanced_arrays */ -#ifndef GL_NV_instanced_arrays -#define GL_NV_instanced_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor); -#endif -typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor); -#endif - -/* GL_NV_read_buffer */ -#ifndef GL_NV_read_buffer -#define GL_NV_read_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode); -#endif -typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode); -#endif - -/* GL_NV_read_buffer_front */ -#ifndef GL_NV_read_buffer_front -#define GL_NV_read_buffer_front 1 -#endif - -/* GL_NV_read_depth */ -#ifndef GL_NV_read_depth -#define GL_NV_read_depth 1 -#endif - -/* GL_NV_read_depth_stencil */ -#ifndef GL_NV_read_depth_stencil -#define GL_NV_read_depth_stencil 1 -#endif - -/* GL_NV_read_stencil */ -#ifndef GL_NV_read_stencil -#define GL_NV_read_stencil 1 -#endif - -/* GL_NV_shadow_samplers_array */ -#ifndef GL_NV_shadow_samplers_array -#define GL_NV_shadow_samplers_array 1 -#endif - -/* GL_NV_shadow_samplers_cube */ -#ifndef GL_NV_shadow_samplers_cube -#define GL_NV_shadow_samplers_cube 1 -#endif - -/* GL_NV_sRGB_formats */ -#ifndef GL_NV_sRGB_formats -#define GL_NV_sRGB_formats 1 -#endif - -/* GL_NV_texture_border_clamp */ -#ifndef GL_NV_texture_border_clamp -#define GL_NV_texture_border_clamp 1 -#endif - -/* GL_NV_texture_compression_s3tc_update */ -#ifndef GL_NV_texture_compression_s3tc_update -#define GL_NV_texture_compression_s3tc_update 1 -#endif - -/* GL_NV_texture_npot_2D_mipmap */ -#ifndef GL_NV_texture_npot_2D_mipmap -#define GL_NV_texture_npot_2D_mipmap 1 -#endif - -/*------------------------------------------------------------------------* - * QCOM extension functions - *------------------------------------------------------------------------*/ - -/* GL_QCOM_alpha_test */ -#ifndef GL_QCOM_alpha_test -#define GL_QCOM_alpha_test 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref); -#endif -typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref); -#endif - -/* GL_QCOM_binning_control */ -#ifndef GL_QCOM_binning_control -#define GL_QCOM_binning_control 1 -#endif - -/* GL_QCOM_driver_control */ -#ifndef GL_QCOM_driver_control -#define GL_QCOM_driver_control 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); -GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); -GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); -GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); -#endif -typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); -typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); -typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); -typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); -#endif - -/* GL_QCOM_extended_get */ -#ifndef GL_QCOM_extended_get -#define GL_QCOM_extended_get 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); -GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); -GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); -GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); -GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); -GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); -GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params); -#endif -typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); -typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); -typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); -typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params); -#endif - -/* GL_QCOM_extended_get2 */ -#ifndef GL_QCOM_extended_get2 -#define GL_QCOM_extended_get2 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); -GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); -GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); -GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length); -#endif -typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); -typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); -typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); -typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length); -#endif - -/* GL_QCOM_perfmon_global_mode */ -#ifndef GL_QCOM_perfmon_global_mode -#define GL_QCOM_perfmon_global_mode 1 -#endif - -/* GL_QCOM_writeonly_rendering */ -#ifndef GL_QCOM_writeonly_rendering -#define GL_QCOM_writeonly_rendering 1 -#endif - -/* GL_QCOM_tiled_rendering */ -#ifndef GL_QCOM_tiled_rendering -#define GL_QCOM_tiled_rendering 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); -GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); -#endif -typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); -typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); -#endif - -/*------------------------------------------------------------------------* - * VIV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_VIV_shader_binary */ -#ifndef GL_VIV_shader_binary -#define GL_VIV_shader_binary 1 -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __gl2ext_h_ */ diff --git a/thirdparty/include/SDL2/SDL_opengles2_gl2platform.h b/thirdparty/include/SDL2/SDL_opengles2_gl2platform.h deleted file mode 100644 index c325686f0..000000000 --- a/thirdparty/include/SDL2/SDL_opengles2_gl2platform.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __gl2platform_h_ -#define __gl2platform_h_ - -/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h - * - * Adopters may modify khrplatform.h and this file to suit their platform. - * You are encouraged to submit all modifications to the Khronos group so that - * they can be included in future versions of this file. Please submit changes - * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) - * by filing a bug against product "OpenGL-ES" component "Registry". - */ - -/*#include */ - -#ifndef GL_APICALL -#define GL_APICALL KHRONOS_APICALL -#endif - -#ifndef GL_APIENTRY -#define GL_APIENTRY KHRONOS_APIENTRY -#endif - -#endif /* __gl2platform_h_ */ diff --git a/thirdparty/include/SDL2/SDL_opengles2_khrplatform.h b/thirdparty/include/SDL2/SDL_opengles2_khrplatform.h deleted file mode 100644 index c9e6f17d3..000000000 --- a/thirdparty/include/SDL2/SDL_opengles2_khrplatform.h +++ /dev/null @@ -1,282 +0,0 @@ -#ifndef __khrplatform_h_ -#define __khrplatform_h_ - -/* -** Copyright (c) 2008-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Khronos platform-specific types and definitions. - * - * $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $ - * - * Adopters may modify this file to suit their platform. Adopters are - * encouraged to submit platform specific modifications to the Khronos - * group so that they can be included in future versions of this file. - * Please submit changes by sending them to the public Khronos Bugzilla - * (http://khronos.org/bugzilla) by filing a bug against product - * "Khronos (general)" component "Registry". - * - * A predefined template which fills in some of the bug fields can be - * reached using http://tinyurl.com/khrplatform-h-bugreport, but you - * must create a Bugzilla login first. - * - * - * See the Implementer's Guidelines for information about where this file - * should be located on your system and for more details of its use: - * http://www.khronos.org/registry/implementers_guide.pdf - * - * This file should be included as - * #include - * by Khronos client API header files that use its types and defines. - * - * The types in khrplatform.h should only be used to define API-specific types. - * - * Types defined in khrplatform.h: - * khronos_int8_t signed 8 bit - * khronos_uint8_t unsigned 8 bit - * khronos_int16_t signed 16 bit - * khronos_uint16_t unsigned 16 bit - * khronos_int32_t signed 32 bit - * khronos_uint32_t unsigned 32 bit - * khronos_int64_t signed 64 bit - * khronos_uint64_t unsigned 64 bit - * khronos_intptr_t signed same number of bits as a pointer - * khronos_uintptr_t unsigned same number of bits as a pointer - * khronos_ssize_t signed size - * khronos_usize_t unsigned size - * khronos_float_t signed 32 bit floating point - * khronos_time_ns_t unsigned 64 bit time in nanoseconds - * khronos_utime_nanoseconds_t unsigned time interval or absolute time in - * nanoseconds - * khronos_stime_nanoseconds_t signed time interval in nanoseconds - * khronos_boolean_enum_t enumerated boolean type. This should - * only be used as a base type when a client API's boolean type is - * an enum. Client APIs which use an integer or other type for - * booleans cannot use this as the base type for their boolean. - * - * Tokens defined in khrplatform.h: - * - * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. - * - * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. - * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. - * - * Calling convention macros defined in this file: - * KHRONOS_APICALL - * KHRONOS_APIENTRY - * KHRONOS_APIATTRIBUTES - * - * These may be used in function prototypes as: - * - * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( - * int arg1, - * int arg2) KHRONOS_APIATTRIBUTES; - */ - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APICALL - *------------------------------------------------------------------------- - * This precedes the return type of the function in the function prototype. - */ -#if defined(_WIN32) && !defined(__SCITECH_SNAP__) -# define KHRONOS_APICALL __declspec(dllimport) -#elif defined (__SYMBIAN32__) -# define KHRONOS_APICALL IMPORT_C -#else -# define KHRONOS_APICALL -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APIENTRY - *------------------------------------------------------------------------- - * This follows the return type of the function and precedes the function - * name in the function prototype. - */ -#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) - /* Win32 but not WinCE */ -# define KHRONOS_APIENTRY __stdcall -#else -# define KHRONOS_APIENTRY -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APIATTRIBUTES - *------------------------------------------------------------------------- - * This follows the closing parenthesis of the function prototype arguments. - */ -#if defined (__ARMCC_2__) -#define KHRONOS_APIATTRIBUTES __softfp -#else -#define KHRONOS_APIATTRIBUTES -#endif - -/*------------------------------------------------------------------------- - * basic type definitions - *-----------------------------------------------------------------------*/ -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) - - -/* - * Using - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__VMS ) || defined(__sgi) - -/* - * Using - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) - -/* - * Win32 - */ -typedef __int32 khronos_int32_t; -typedef unsigned __int32 khronos_uint32_t; -typedef __int64 khronos_int64_t; -typedef unsigned __int64 khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__sun__) || defined(__digital__) - -/* - * Sun or Digital - */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#if defined(__arch64__) || defined(_LP64) -typedef long int khronos_int64_t; -typedef unsigned long int khronos_uint64_t; -#else -typedef long long int khronos_int64_t; -typedef unsigned long long int khronos_uint64_t; -#endif /* __arch64__ */ -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif 0 - -/* - * Hypothetical platform with no float or int64 support - */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#define KHRONOS_SUPPORT_INT64 0 -#define KHRONOS_SUPPORT_FLOAT 0 - -#else - -/* - * Generic fallback - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#endif - - -/* - * Types that are (so far) the same on all platforms - */ -typedef signed char khronos_int8_t; -typedef unsigned char khronos_uint8_t; -typedef signed short int khronos_int16_t; -typedef unsigned short int khronos_uint16_t; - -/* - * Types that differ between LLP64 and LP64 architectures - in LLP64, - * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears - * to be the only LLP64 architecture in current use. - */ -#ifdef _WIN64 -typedef signed long long int khronos_intptr_t; -typedef unsigned long long int khronos_uintptr_t; -typedef signed long long int khronos_ssize_t; -typedef unsigned long long int khronos_usize_t; -#else -typedef signed long int khronos_intptr_t; -typedef unsigned long int khronos_uintptr_t; -typedef signed long int khronos_ssize_t; -typedef unsigned long int khronos_usize_t; -#endif - -#if KHRONOS_SUPPORT_FLOAT -/* - * Float type - */ -typedef float khronos_float_t; -#endif - -#if KHRONOS_SUPPORT_INT64 -/* Time types - * - * These types can be used to represent a time interval in nanoseconds or - * an absolute Unadjusted System Time. Unadjusted System Time is the number - * of nanoseconds since some arbitrary system event (e.g. since the last - * time the system booted). The Unadjusted System Time is an unsigned - * 64 bit value that wraps back to 0 every 584 years. Time intervals - * may be either signed or unsigned. - */ -typedef khronos_uint64_t khronos_utime_nanoseconds_t; -typedef khronos_int64_t khronos_stime_nanoseconds_t; -#endif - -/* - * Dummy value used to pad enum types to 32 bits. - */ -#ifndef KHRONOS_MAX_ENUM -#define KHRONOS_MAX_ENUM 0x7FFFFFFF -#endif - -/* - * Enumerated boolean type - * - * Values other than zero should be considered to be true. Therefore - * comparisons should not be made against KHRONOS_TRUE. - */ -typedef enum { - KHRONOS_FALSE = 0, - KHRONOS_TRUE = 1, - KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM -} khronos_boolean_enum_t; - -#endif /* __khrplatform_h_ */ diff --git a/thirdparty/include/SDL2/SDL_pixels.h b/thirdparty/include/SDL2/SDL_pixels.h deleted file mode 100644 index 1b119e47b..000000000 --- a/thirdparty/include/SDL2/SDL_pixels.h +++ /dev/null @@ -1,473 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_pixels.h - * - * Header for the enumerated pixel format definitions. - */ - -#ifndef SDL_pixels_h_ -#define SDL_pixels_h_ - -#include "SDL_stdinc.h" -#include "SDL_endian.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \name Transparency definitions - * - * These define alpha as the opacity of a surface. - */ -/* @{ */ -#define SDL_ALPHA_OPAQUE 255 -#define SDL_ALPHA_TRANSPARENT 0 -/* @} */ - -/** Pixel type. */ -typedef enum -{ - SDL_PIXELTYPE_UNKNOWN, - SDL_PIXELTYPE_INDEX1, - SDL_PIXELTYPE_INDEX4, - SDL_PIXELTYPE_INDEX8, - SDL_PIXELTYPE_PACKED8, - SDL_PIXELTYPE_PACKED16, - SDL_PIXELTYPE_PACKED32, - SDL_PIXELTYPE_ARRAYU8, - SDL_PIXELTYPE_ARRAYU16, - SDL_PIXELTYPE_ARRAYU32, - SDL_PIXELTYPE_ARRAYF16, - SDL_PIXELTYPE_ARRAYF32 -} SDL_PixelType; - -/** Bitmap pixel order, high bit -> low bit. */ -typedef enum -{ - SDL_BITMAPORDER_NONE, - SDL_BITMAPORDER_4321, - SDL_BITMAPORDER_1234 -} SDL_BitmapOrder; - -/** Packed component order, high bit -> low bit. */ -typedef enum -{ - SDL_PACKEDORDER_NONE, - SDL_PACKEDORDER_XRGB, - SDL_PACKEDORDER_RGBX, - SDL_PACKEDORDER_ARGB, - SDL_PACKEDORDER_RGBA, - SDL_PACKEDORDER_XBGR, - SDL_PACKEDORDER_BGRX, - SDL_PACKEDORDER_ABGR, - SDL_PACKEDORDER_BGRA -} SDL_PackedOrder; - -/** Array component order, low byte -> high byte. */ -/* !!! FIXME: in 2.1, make these not overlap differently with - !!! FIXME: SDL_PACKEDORDER_*, so we can simplify SDL_ISPIXELFORMAT_ALPHA */ -typedef enum -{ - SDL_ARRAYORDER_NONE, - SDL_ARRAYORDER_RGB, - SDL_ARRAYORDER_RGBA, - SDL_ARRAYORDER_ARGB, - SDL_ARRAYORDER_BGR, - SDL_ARRAYORDER_BGRA, - SDL_ARRAYORDER_ABGR -} SDL_ArrayOrder; - -/** Packed component layout. */ -typedef enum -{ - SDL_PACKEDLAYOUT_NONE, - SDL_PACKEDLAYOUT_332, - SDL_PACKEDLAYOUT_4444, - SDL_PACKEDLAYOUT_1555, - SDL_PACKEDLAYOUT_5551, - SDL_PACKEDLAYOUT_565, - SDL_PACKEDLAYOUT_8888, - SDL_PACKEDLAYOUT_2101010, - SDL_PACKEDLAYOUT_1010102 -} SDL_PackedLayout; - -#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D) - -#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \ - ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \ - ((bits) << 8) | ((bytes) << 0)) - -#define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F) -#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F) -#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F) -#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F) -#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF) -#define SDL_BYTESPERPIXEL(X) \ - (SDL_ISPIXELFORMAT_FOURCC(X) ? \ - ((((X) == SDL_PIXELFORMAT_YUY2) || \ - ((X) == SDL_PIXELFORMAT_UYVY) || \ - ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF)) - -#define SDL_ISPIXELFORMAT_INDEXED(format) \ - (!SDL_ISPIXELFORMAT_FOURCC(format) && \ - ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ - (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ - (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))) - -#define SDL_ISPIXELFORMAT_PACKED(format) \ - (!SDL_ISPIXELFORMAT_FOURCC(format) && \ - ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \ - (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \ - (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32))) - -#define SDL_ISPIXELFORMAT_ARRAY(format) \ - (!SDL_ISPIXELFORMAT_FOURCC(format) && \ - ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \ - (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \ - (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \ - (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \ - (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32))) - -#define SDL_ISPIXELFORMAT_ALPHA(format) \ - ((SDL_ISPIXELFORMAT_PACKED(format) && \ - ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \ - (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \ - (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \ - (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) || \ - (SDL_ISPIXELFORMAT_ARRAY(format) && \ - ((SDL_PIXELORDER(format) == SDL_ARRAYORDER_ARGB) || \ - (SDL_PIXELORDER(format) == SDL_ARRAYORDER_RGBA) || \ - (SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \ - (SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA)))) - -/* The flag is set to 1 because 0x1? is not in the printable ASCII range */ -#define SDL_ISPIXELFORMAT_FOURCC(format) \ - ((format) && (SDL_PIXELFLAG(format) != 1)) - -/* Note: If you modify this list, update SDL_GetPixelFormatName() */ -typedef enum -{ - SDL_PIXELFORMAT_UNKNOWN, - SDL_PIXELFORMAT_INDEX1LSB = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, - 1, 0), - SDL_PIXELFORMAT_INDEX1MSB = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, - 1, 0), - SDL_PIXELFORMAT_INDEX4LSB = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, - 4, 0), - SDL_PIXELFORMAT_INDEX4MSB = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, - 4, 0), - SDL_PIXELFORMAT_INDEX8 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1), - SDL_PIXELFORMAT_RGB332 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB, - SDL_PACKEDLAYOUT_332, 8, 1), - SDL_PIXELFORMAT_RGB444 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, - SDL_PACKEDLAYOUT_4444, 12, 2), - SDL_PIXELFORMAT_BGR444 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, - SDL_PACKEDLAYOUT_4444, 12, 2), - SDL_PIXELFORMAT_RGB555 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, - SDL_PACKEDLAYOUT_1555, 15, 2), - SDL_PIXELFORMAT_BGR555 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, - SDL_PACKEDLAYOUT_1555, 15, 2), - SDL_PIXELFORMAT_ARGB4444 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, - SDL_PACKEDLAYOUT_4444, 16, 2), - SDL_PIXELFORMAT_RGBA4444 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, - SDL_PACKEDLAYOUT_4444, 16, 2), - SDL_PIXELFORMAT_ABGR4444 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, - SDL_PACKEDLAYOUT_4444, 16, 2), - SDL_PIXELFORMAT_BGRA4444 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, - SDL_PACKEDLAYOUT_4444, 16, 2), - SDL_PIXELFORMAT_ARGB1555 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, - SDL_PACKEDLAYOUT_1555, 16, 2), - SDL_PIXELFORMAT_RGBA5551 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, - SDL_PACKEDLAYOUT_5551, 16, 2), - SDL_PIXELFORMAT_ABGR1555 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, - SDL_PACKEDLAYOUT_1555, 16, 2), - SDL_PIXELFORMAT_BGRA5551 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, - SDL_PACKEDLAYOUT_5551, 16, 2), - SDL_PIXELFORMAT_RGB565 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, - SDL_PACKEDLAYOUT_565, 16, 2), - SDL_PIXELFORMAT_BGR565 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, - SDL_PACKEDLAYOUT_565, 16, 2), - SDL_PIXELFORMAT_RGB24 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0, - 24, 3), - SDL_PIXELFORMAT_BGR24 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0, - 24, 3), - SDL_PIXELFORMAT_RGB888 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, - SDL_PACKEDLAYOUT_8888, 24, 4), - SDL_PIXELFORMAT_RGBX8888 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, - SDL_PACKEDLAYOUT_8888, 24, 4), - SDL_PIXELFORMAT_BGR888 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, - SDL_PACKEDLAYOUT_8888, 24, 4), - SDL_PIXELFORMAT_BGRX8888 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, - SDL_PACKEDLAYOUT_8888, 24, 4), - SDL_PIXELFORMAT_ARGB8888 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, - SDL_PACKEDLAYOUT_8888, 32, 4), - SDL_PIXELFORMAT_RGBA8888 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, - SDL_PACKEDLAYOUT_8888, 32, 4), - SDL_PIXELFORMAT_ABGR8888 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, - SDL_PACKEDLAYOUT_8888, 32, 4), - SDL_PIXELFORMAT_BGRA8888 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA, - SDL_PACKEDLAYOUT_8888, 32, 4), - SDL_PIXELFORMAT_ARGB2101010 = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, - SDL_PACKEDLAYOUT_2101010, 32, 4), - - /* Aliases for RGBA byte arrays of color data, for the current platform */ -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA8888, - SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888, - SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888, -#else - SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888, - SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888, -#endif - - SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */ - SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'), - SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */ - SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'), - SDL_PIXELFORMAT_YUY2 = /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ - SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'), - SDL_PIXELFORMAT_UYVY = /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ - SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'), - SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ - SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'), - SDL_PIXELFORMAT_NV12 = /**< Planar mode: Y + U/V interleaved (2 planes) */ - SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'), - SDL_PIXELFORMAT_NV21 = /**< Planar mode: Y + V/U interleaved (2 planes) */ - SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'), - SDL_PIXELFORMAT_EXTERNAL_OES = /**< Android video texture format */ - SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ') -} SDL_PixelFormatEnum; - -typedef struct SDL_Color -{ - Uint8 r; - Uint8 g; - Uint8 b; - Uint8 a; -} SDL_Color; -#define SDL_Colour SDL_Color - -typedef struct SDL_Palette -{ - int ncolors; - SDL_Color *colors; - Uint32 version; - int refcount; -} SDL_Palette; - -/** - * \note Everything in the pixel format structure is read-only. - */ -typedef struct SDL_PixelFormat -{ - Uint32 format; - SDL_Palette *palette; - Uint8 BitsPerPixel; - Uint8 BytesPerPixel; - Uint8 padding[2]; - Uint32 Rmask; - Uint32 Gmask; - Uint32 Bmask; - Uint32 Amask; - Uint8 Rloss; - Uint8 Gloss; - Uint8 Bloss; - Uint8 Aloss; - Uint8 Rshift; - Uint8 Gshift; - Uint8 Bshift; - Uint8 Ashift; - int refcount; - struct SDL_PixelFormat *next; -} SDL_PixelFormat; - -/** - * \brief Get the human readable name of a pixel format - */ -extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format); - -/** - * \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks. - * - * \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible. - * - * \sa SDL_MasksToPixelFormatEnum() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, - int *bpp, - Uint32 * Rmask, - Uint32 * Gmask, - Uint32 * Bmask, - Uint32 * Amask); - -/** - * \brief Convert a bpp and RGBA masks to an enumerated pixel format. - * - * \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion - * wasn't possible. - * - * \sa SDL_PixelFormatEnumToMasks() - */ -extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, - Uint32 Rmask, - Uint32 Gmask, - Uint32 Bmask, - Uint32 Amask); - -/** - * \brief Create an SDL_PixelFormat structure from a pixel format enum. - */ -extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format); - -/** - * \brief Free an SDL_PixelFormat structure. - */ -extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format); - -/** - * \brief Create a palette structure with the specified number of color - * entries. - * - * \return A new palette, or NULL if there wasn't enough memory. - * - * \note The palette entries are initialized to white. - * - * \sa SDL_FreePalette() - */ -extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors); - -/** - * \brief Set the palette for a pixel format structure. - */ -extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format, - SDL_Palette *palette); - -/** - * \brief Set a range of colors in a palette. - * - * \param palette The palette to modify. - * \param colors An array of colors to copy into the palette. - * \param firstcolor The index of the first palette entry to modify. - * \param ncolors The number of entries to modify. - * - * \return 0 on success, or -1 if not all of the colors could be set. - */ -extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette, - const SDL_Color * colors, - int firstcolor, int ncolors); - -/** - * \brief Free a palette created with SDL_AllocPalette(). - * - * \sa SDL_AllocPalette() - */ -extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette); - -/** - * \brief Maps an RGB triple to an opaque pixel value for a given pixel format. - * - * \sa SDL_MapRGBA - */ -extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format, - Uint8 r, Uint8 g, Uint8 b); - -/** - * \brief Maps an RGBA quadruple to a pixel value for a given pixel format. - * - * \sa SDL_MapRGB - */ -extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format, - Uint8 r, Uint8 g, Uint8 b, - Uint8 a); - -/** - * \brief Get the RGB components from a pixel of the specified format. - * - * \sa SDL_GetRGBA - */ -extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, - const SDL_PixelFormat * format, - Uint8 * r, Uint8 * g, Uint8 * b); - -/** - * \brief Get the RGBA components from a pixel of the specified format. - * - * \sa SDL_GetRGB - */ -extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, - const SDL_PixelFormat * format, - Uint8 * r, Uint8 * g, Uint8 * b, - Uint8 * a); - -/** - * \brief Calculate a 256 entry gamma ramp for a gamma value. - */ -extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_pixels_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_platform.h b/thirdparty/include/SDL2/SDL_platform.h deleted file mode 100644 index 716655792..000000000 --- a/thirdparty/include/SDL2/SDL_platform.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_platform.h - * - * Try to get a standard set of platform defines. - */ - -#ifndef SDL_platform_h_ -#define SDL_platform_h_ - -#if defined(_AIX) -#undef __AIX__ -#define __AIX__ 1 -#endif -#if defined(__HAIKU__) -#undef __HAIKU__ -#define __HAIKU__ 1 -#endif -#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) -#undef __BSDI__ -#define __BSDI__ 1 -#endif -#if defined(_arch_dreamcast) -#undef __DREAMCAST__ -#define __DREAMCAST__ 1 -#endif -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) -#undef __FREEBSD__ -#define __FREEBSD__ 1 -#endif -#if defined(hpux) || defined(__hpux) || defined(__hpux__) -#undef __HPUX__ -#define __HPUX__ 1 -#endif -#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) -#undef __IRIX__ -#define __IRIX__ 1 -#endif -#if (defined(linux) || defined(__linux) || defined(__linux__)) -#undef __LINUX__ -#define __LINUX__ 1 -#endif -#if defined(ANDROID) || defined(__ANDROID__) -#undef __ANDROID__ -#undef __LINUX__ /* do we need to do this? */ -#define __ANDROID__ 1 -#endif - -#if defined(__APPLE__) -/* lets us know what version of Mac OS X we're compiling on */ -#include "AvailabilityMacros.h" -#include "TargetConditionals.h" -#if TARGET_OS_TV -#undef __TVOS__ -#define __TVOS__ 1 -#endif -#if TARGET_OS_IPHONE -/* if compiling for iOS */ -#undef __IPHONEOS__ -#define __IPHONEOS__ 1 -#undef __MACOSX__ -#else -/* if not compiling for iOS */ -#undef __MACOSX__ -#define __MACOSX__ 1 -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 -# error SDL for Mac OS X only supports deploying on 10.6 and above. -#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */ -#endif /* TARGET_OS_IPHONE */ -#endif /* defined(__APPLE__) */ - -#if defined(__NetBSD__) -#undef __NETBSD__ -#define __NETBSD__ 1 -#endif -#if defined(__OpenBSD__) -#undef __OPENBSD__ -#define __OPENBSD__ 1 -#endif -#if defined(__OS2__) || defined(__EMX__) -#undef __OS2__ -#define __OS2__ 1 -#endif -#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) -#undef __OSF__ -#define __OSF__ 1 -#endif -#if defined(__QNXNTO__) -#undef __QNXNTO__ -#define __QNXNTO__ 1 -#endif -#if defined(riscos) || defined(__riscos) || defined(__riscos__) -#undef __RISCOS__ -#define __RISCOS__ 1 -#endif -#if defined(__sun) && defined(__SVR4) -#undef __SOLARIS__ -#define __SOLARIS__ 1 -#endif - -#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) -/* Try to find out if we're compiling for WinRT or non-WinRT */ -#if defined(_MSC_VER) && defined(__has_include) -#if __has_include() -#define HAVE_WINAPIFAMILY_H 1 -#else -#define HAVE_WINAPIFAMILY_H 0 -#endif - -/* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */ -#elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */ -#define HAVE_WINAPIFAMILY_H 1 -#else -#define HAVE_WINAPIFAMILY_H 0 -#endif - -#if HAVE_WINAPIFAMILY_H -#include -#define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) -#else -#define WINAPI_FAMILY_WINRT 0 -#endif /* HAVE_WINAPIFAMILY_H */ - -#if WINAPI_FAMILY_WINRT -#undef __WINRT__ -#define __WINRT__ 1 -#else -#undef __WINDOWS__ -#define __WINDOWS__ 1 -#endif -#endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */ - -#if defined(__WINDOWS__) -#undef __WIN32__ -#define __WIN32__ 1 -#endif -#if defined(__PSP__) -#undef __PSP__ -#define __PSP__ 1 -#endif - -/* The NACL compiler defines __native_client__ and __pnacl__ - * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi - */ -#if defined(__native_client__) -#undef __LINUX__ -#undef __NACL__ -#define __NACL__ 1 -#endif -#if defined(__pnacl__) -#undef __LINUX__ -#undef __PNACL__ -#define __PNACL__ 1 -/* PNACL with newlib supports static linking only */ -#define __SDL_NOGETPROCADDR__ -#endif - - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Gets the name of the platform. - */ -extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_platform_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_power.h b/thirdparty/include/SDL2/SDL_power.h deleted file mode 100644 index 39884cc23..000000000 --- a/thirdparty/include/SDL2/SDL_power.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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 SDL_power_h_ -#define SDL_power_h_ - -/** - * \file SDL_power.h - * - * Header for the SDL power management routines. - */ - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief The basic state for the system's power supply. - */ -typedef enum -{ - SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ - SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ - SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ - SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ - SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ -} SDL_PowerState; - - -/** - * \brief Get the current power supply details. - * - * \param secs Seconds of battery life left. You can pass a NULL here if - * you don't care. Will return -1 if we can't determine a - * value, or we're not running on a battery. - * - * \param pct Percentage of battery life left, between 0 and 100. You can - * pass a NULL here if you don't care. Will return -1 if we - * can't determine a value, or we're not running on a battery. - * - * \return The state of the battery (if any). - */ -extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_power_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_quit.h b/thirdparty/include/SDL2/SDL_quit.h deleted file mode 100644 index b2bd5da50..000000000 --- a/thirdparty/include/SDL2/SDL_quit.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_quit.h - * - * Include file for SDL quit event handling. - */ - -#ifndef SDL_quit_h_ -#define SDL_quit_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -/** - * \file SDL_quit.h - * - * An ::SDL_QUIT event is generated when the user tries to close the application - * window. If it is ignored or filtered out, the window will remain open. - * If it is not ignored or filtered, it is queued normally and the window - * is allowed to close. When the window is closed, screen updates will - * complete, but have no effect. - * - * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) - * and SIGTERM (system termination request), if handlers do not already - * exist, that generate ::SDL_QUIT events as well. There is no way - * to determine the cause of an ::SDL_QUIT event, but setting a signal - * handler in your application will override the default generation of - * quit events for that signal. - * - * \sa SDL_Quit() - */ - -/* There are no functions directly affecting the quit event */ - -#define SDL_QuitRequested() \ - (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) - -#endif /* SDL_quit_h_ */ diff --git a/thirdparty/include/SDL2/SDL_rect.h b/thirdparty/include/SDL2/SDL_rect.h deleted file mode 100644 index 47f0d2078..000000000 --- a/thirdparty/include/SDL2/SDL_rect.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_rect.h - * - * Header file for SDL_rect definition and management functions. - */ - -#ifndef SDL_rect_h_ -#define SDL_rect_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_pixels.h" -#include "SDL_rwops.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief The structure that defines a point (integer) - * - * \sa SDL_EnclosePoints - * \sa SDL_PointInRect - */ -typedef struct SDL_Point -{ - int x; - int y; -} SDL_Point; - -/** - * \brief The structure that defines a point (floating point) - * - * \sa SDL_EnclosePoints - * \sa SDL_PointInRect - */ -typedef struct SDL_FPoint -{ - float x; - float y; -} SDL_FPoint; - - -/** - * \brief A rectangle, with the origin at the upper left (integer). - * - * \sa SDL_RectEmpty - * \sa SDL_RectEquals - * \sa SDL_HasIntersection - * \sa SDL_IntersectRect - * \sa SDL_UnionRect - * \sa SDL_EnclosePoints - */ -typedef struct SDL_Rect -{ - int x, y; - int w, h; -} SDL_Rect; - - -/** - * \brief A rectangle, with the origin at the upper left (floating point). - */ -typedef struct SDL_FRect -{ - float x; - float y; - float w; - float h; -} SDL_FRect; - - -/** - * \brief Returns true if point resides inside a rectangle. - */ -SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r) -{ - return ( (p->x >= r->x) && (p->x < (r->x + r->w)) && - (p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE; -} - -/** - * \brief Returns true if the rectangle has no area. - */ -SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r) -{ - return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE; -} - -/** - * \brief Returns true if the two rectangles are equal. - */ -SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b) -{ - return (a && b && (a->x == b->x) && (a->y == b->y) && - (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE; -} - -/** - * \brief Determine whether two rectangles intersect. - * - * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A, - const SDL_Rect * B); - -/** - * \brief Calculate the intersection of two rectangles. - * - * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A, - const SDL_Rect * B, - SDL_Rect * result); - -/** - * \brief Calculate the union of two rectangles. - */ -extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A, - const SDL_Rect * B, - SDL_Rect * result); - -/** - * \brief Calculate a minimal rectangle enclosing a set of points - * - * \return SDL_TRUE if any points were within the clipping rect - */ -extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, - int count, - const SDL_Rect * clip, - SDL_Rect * result); - -/** - * \brief Calculate the intersection of a rectangle and line segment. - * - * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect * - rect, int *X1, - int *Y1, int *X2, - int *Y2); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_rect_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_render.h b/thirdparty/include/SDL2/SDL_render.h deleted file mode 100644 index f26fb7e5f..000000000 --- a/thirdparty/include/SDL2/SDL_render.h +++ /dev/null @@ -1,1158 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_render.h - * - * Header file for SDL 2D rendering functions. - * - * This API supports the following features: - * * single pixel points - * * single pixel lines - * * filled rectangles - * * texture images - * - * The primitives may be drawn in opaque, blended, or additive modes. - * - * The texture images may be drawn in opaque, blended, or additive modes. - * They can have an additional color tint or alpha modulation applied to - * them, and may also be stretched with linear interpolation. - * - * This API is designed to accelerate simple 2D operations. You may - * want more functionality such as polygons and particle effects and - * in that case you should use SDL's OpenGL/Direct3D support or one - * of the many good 3D engines. - * - * These functions must be called from the main thread. - * See this bug for details: http://bugzilla.libsdl.org/show_bug.cgi?id=1995 - */ - -#ifndef SDL_render_h_ -#define SDL_render_h_ - -#include "SDL_stdinc.h" -#include "SDL_rect.h" -#include "SDL_video.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Flags used when creating a rendering context - */ -typedef enum -{ - SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */ - SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware - acceleration */ - SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized - with the refresh rate */ - SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports - rendering to texture */ -} SDL_RendererFlags; - -/** - * \brief Information on the capabilities of a render driver or context. - */ -typedef struct SDL_RendererInfo -{ - const char *name; /**< The name of the renderer */ - Uint32 flags; /**< Supported ::SDL_RendererFlags */ - Uint32 num_texture_formats; /**< The number of available texture formats */ - Uint32 texture_formats[16]; /**< The available texture formats */ - int max_texture_width; /**< The maximum texture width */ - int max_texture_height; /**< The maximum texture height */ -} SDL_RendererInfo; - -/** - * \brief The scaling mode for a texture. - */ -typedef enum -{ - SDL_ScaleModeNearest, /**< nearest pixel sampling */ - SDL_ScaleModeLinear, /**< linear filtering */ - SDL_ScaleModeBest /**< anisotropic filtering */ -} SDL_ScaleMode; - -/** - * \brief The access pattern allowed for a texture. - */ -typedef enum -{ - SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */ - SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */ - SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */ -} SDL_TextureAccess; - -/** - * \brief The texture channel modulation used in SDL_RenderCopy(). - */ -typedef enum -{ - SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */ - SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */ - SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */ -} SDL_TextureModulate; - -/** - * \brief Flip constants for SDL_RenderCopyEx - */ -typedef enum -{ - SDL_FLIP_NONE = 0x00000000, /**< Do not flip */ - SDL_FLIP_HORIZONTAL = 0x00000001, /**< flip horizontally */ - SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */ -} SDL_RendererFlip; - -/** - * \brief A structure representing rendering state - */ -struct SDL_Renderer; -typedef struct SDL_Renderer SDL_Renderer; - -/** - * \brief An efficient driver-specific representation of pixel data - */ -struct SDL_Texture; -typedef struct SDL_Texture SDL_Texture; - - -/* Function prototypes */ - -/** - * \brief Get the number of 2D rendering drivers available for the current - * display. - * - * A render driver is a set of code that handles rendering and texture - * management on a particular display. Normally there is only one, but - * some drivers may have several available with different capabilities. - * - * \sa SDL_GetRenderDriverInfo() - * \sa SDL_CreateRenderer() - */ -extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); - -/** - * \brief Get information about a specific 2D rendering driver for the current - * display. - * - * \param index The index of the driver to query information about. - * \param info A pointer to an SDL_RendererInfo struct to be filled with - * information on the rendering driver. - * - * \return 0 on success, -1 if the index was out of range. - * - * \sa SDL_CreateRenderer() - */ -extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, - SDL_RendererInfo * info); - -/** - * \brief Create a window and default renderer - * - * \param width The width of the window - * \param height The height of the window - * \param window_flags The flags used to create the window - * \param window A pointer filled with the window, or NULL on error - * \param renderer A pointer filled with the renderer, or NULL on error - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer( - int width, int height, Uint32 window_flags, - SDL_Window **window, SDL_Renderer **renderer); - - -/** - * \brief Create a 2D rendering context for a window. - * - * \param window The window where rendering is displayed. - * \param index The index of the rendering driver to initialize, or -1 to - * initialize the first one supporting the requested flags. - * \param flags ::SDL_RendererFlags. - * - * \return A valid rendering context or NULL if there was an error. - * - * \sa SDL_CreateSoftwareRenderer() - * \sa SDL_GetRendererInfo() - * \sa SDL_DestroyRenderer() - */ -extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window, - int index, Uint32 flags); - -/** - * \brief Create a 2D software rendering context for a surface. - * - * \param surface The surface where rendering is done. - * - * \return A valid rendering context or NULL if there was an error. - * - * \sa SDL_CreateRenderer() - * \sa SDL_DestroyRenderer() - */ -extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface); - -/** - * \brief Get the renderer associated with a window. - */ -extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window); - -/** - * \brief Get information about a rendering context. - */ -extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer, - SDL_RendererInfo * info); - -/** - * \brief Get the output size in pixels of a rendering context. - */ -extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer, - int *w, int *h); - -/** - * \brief Create a texture for a rendering context. - * - * \param renderer The renderer. - * \param format The format of the texture. - * \param access One of the enumerated values in ::SDL_TextureAccess. - * \param w The width of the texture in pixels. - * \param h The height of the texture in pixels. - * - * \return The created texture is returned, or NULL if no rendering context was - * active, the format was unsupported, or the width or height were out - * of range. - * - * \note The contents of the texture are not defined at creation. - * - * \sa SDL_QueryTexture() - * \sa SDL_UpdateTexture() - * \sa SDL_DestroyTexture() - */ -extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer, - Uint32 format, - int access, int w, - int h); - -/** - * \brief Create a texture from an existing surface. - * - * \param renderer The renderer. - * \param surface The surface containing pixel data used to fill the texture. - * - * \return The created texture is returned, or NULL on error. - * - * \note The surface is not modified or freed by this function. - * - * \sa SDL_QueryTexture() - * \sa SDL_DestroyTexture() - */ -extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface); - -/** - * \brief Query the attributes of a texture - * - * \param texture A texture to be queried. - * \param format A pointer filled in with the raw format of the texture. The - * actual format may differ, but pixel transfers will use this - * format. - * \param access A pointer filled in with the actual access to the texture. - * \param w A pointer filled in with the width of the texture in pixels. - * \param h A pointer filled in with the height of the texture in pixels. - * - * \return 0 on success, or -1 if the texture is not valid. - */ -extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, - Uint32 * format, int *access, - int *w, int *h); - -/** - * \brief Set an additional color value used in render copy operations. - * - * \param texture The texture to update. - * \param r The red color value multiplied into copy operations. - * \param g The green color value multiplied into copy operations. - * \param b The blue color value multiplied into copy operations. - * - * \return 0 on success, or -1 if the texture is not valid or color modulation - * is not supported. - * - * \sa SDL_GetTextureColorMod() - */ -extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, - Uint8 r, Uint8 g, Uint8 b); - - -/** - * \brief Get the additional color value used in render copy operations. - * - * \param texture The texture to query. - * \param r A pointer filled in with the current red color value. - * \param g A pointer filled in with the current green color value. - * \param b A pointer filled in with the current blue color value. - * - * \return 0 on success, or -1 if the texture is not valid. - * - * \sa SDL_SetTextureColorMod() - */ -extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, - Uint8 * r, Uint8 * g, - Uint8 * b); - -/** - * \brief Set an additional alpha value used in render copy operations. - * - * \param texture The texture to update. - * \param alpha The alpha value multiplied into copy operations. - * - * \return 0 on success, or -1 if the texture is not valid or alpha modulation - * is not supported. - * - * \sa SDL_GetTextureAlphaMod() - */ -extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, - Uint8 alpha); - -/** - * \brief Get the additional alpha value used in render copy operations. - * - * \param texture The texture to query. - * \param alpha A pointer filled in with the current alpha value. - * - * \return 0 on success, or -1 if the texture is not valid. - * - * \sa SDL_SetTextureAlphaMod() - */ -extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, - Uint8 * alpha); - -/** - * \brief Set the blend mode used for texture copy operations. - * - * \param texture The texture to update. - * \param blendMode ::SDL_BlendMode to use for texture blending. - * - * \return 0 on success, or -1 if the texture is not valid or the blend mode is - * not supported. - * - * \note If the blend mode is not supported, the closest supported mode is - * chosen. - * - * \sa SDL_GetTextureBlendMode() - */ -extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, - SDL_BlendMode blendMode); - -/** - * \brief Get the blend mode used for texture copy operations. - * - * \param texture The texture to query. - * \param blendMode A pointer filled in with the current blend mode. - * - * \return 0 on success, or -1 if the texture is not valid. - * - * \sa SDL_SetTextureBlendMode() - */ -extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, - SDL_BlendMode *blendMode); - -/** - * \brief Set the scale mode used for texture scale operations. - * - * \param texture The texture to update. - * \param scaleMode ::SDL_ScaleMode to use for texture scaling. - * - * \return 0 on success, or -1 if the texture is not valid. - * - * \note If the scale mode is not supported, the closest supported mode is - * chosen. - * - * \sa SDL_GetTextureScaleMode() - */ -extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture, - SDL_ScaleMode scaleMode); - -/** - * \brief Get the scale mode used for texture scale operations. - * - * \param texture The texture to query. - * \param scaleMode A pointer filled in with the current scale mode. - * - * \return 0 on success, or -1 if the texture is not valid. - * - * \sa SDL_SetTextureScaleMode() - */ -extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture, - SDL_ScaleMode *scaleMode); - -/** - * \brief Update the given texture rectangle with new pixel data. - * - * \param texture The texture to update - * \param rect A pointer to the rectangle of pixels to update, or NULL to - * update the entire texture. - * \param pixels The raw pixel data in the format of the texture. - * \param pitch The number of bytes in a row of pixel data, including padding between lines. - * - * The pixel data must be in the format of the texture. The pixel format can be - * queried with SDL_QueryTexture. - * - * \return 0 on success, or -1 if the texture is not valid. - * - * \note This is a fairly slow function. - */ -extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, - const SDL_Rect * rect, - const void *pixels, int pitch); - -/** - * \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data. - * - * \param texture The texture to update - * \param rect A pointer to the rectangle of pixels to update, or NULL to - * update the entire texture. - * \param Yplane The raw pixel data for the Y plane. - * \param Ypitch The number of bytes between rows of pixel data for the Y plane. - * \param Uplane The raw pixel data for the U plane. - * \param Upitch The number of bytes between rows of pixel data for the U plane. - * \param Vplane The raw pixel data for the V plane. - * \param Vpitch The number of bytes between rows of pixel data for the V plane. - * - * \return 0 on success, or -1 if the texture is not valid. - * - * \note You can use SDL_UpdateTexture() as long as your pixel data is - * a contiguous block of Y and U/V planes in the proper order, but - * this function is available if your pixel data is not contiguous. - */ -extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture, - const SDL_Rect * rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch); - -/** - * \brief Lock a portion of the texture for write-only pixel access. - * - * \param texture The texture to lock for access, which was created with - * ::SDL_TEXTUREACCESS_STREAMING. - * \param rect A pointer to the rectangle to lock for access. If the rect - * is NULL, the entire texture will be locked. - * \param pixels This is filled in with a pointer to the locked pixels, - * appropriately offset by the locked area. - * \param pitch This is filled in with the pitch of the locked pixels. - * - * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING. - * - * \sa SDL_UnlockTexture() - */ -extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, - const SDL_Rect * rect, - void **pixels, int *pitch); - -/** - * \brief Lock a portion of the texture for write-only pixel access. - * Expose it as a SDL surface. - * - * \param texture The texture to lock for access, which was created with - * ::SDL_TEXTUREACCESS_STREAMING. - * \param rect A pointer to the rectangle to lock for access. If the rect - * is NULL, the entire texture will be locked. - * \param surface This is filled in with a SDL surface representing the locked area - * Surface is freed internally after calling SDL_UnlockTexture or SDL_DestroyTexture. - * - * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING. - * - * \sa SDL_UnlockTexture() - */ -extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, - const SDL_Rect *rect, - SDL_Surface **surface); - -/** - * \brief Unlock a texture, uploading the changes to video memory, if needed. - * If SDL_LockTextureToSurface() was called for locking, the SDL surface is freed. - * - * \sa SDL_LockTexture() - * \sa SDL_LockTextureToSurface() - */ -extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); - -/** - * \brief Determines whether a window supports the use of render targets - * - * \param renderer The renderer that will be checked - * - * \return SDL_TRUE if supported, SDL_FALSE if not. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer); - -/** - * \brief Set a texture as the current rendering target. - * - * \param renderer The renderer. - * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target - * - * \return 0 on success, or -1 on error - * - * \sa SDL_GetRenderTarget() - */ -extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, - SDL_Texture *texture); - -/** - * \brief Get the current render target or NULL for the default render target. - * - * \return The current render target - * - * \sa SDL_SetRenderTarget() - */ -extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer); - -/** - * \brief Set device independent resolution for rendering - * - * \param renderer The renderer for which resolution should be set. - * \param w The width of the logical resolution - * \param h The height of the logical resolution - * - * This function uses the viewport and scaling functionality to allow a fixed logical - * resolution for rendering, regardless of the actual output resolution. If the actual - * output resolution doesn't have the same aspect ratio the output rendering will be - * centered within the output display. - * - * If the output display is a window, mouse events in the window will be filtered - * and scaled so they seem to arrive within the logical resolution. - * - * \note If this function results in scaling or subpixel drawing by the - * rendering backend, it will be handled using the appropriate - * quality hints. - * - * \sa SDL_RenderGetLogicalSize() - * \sa SDL_RenderSetScale() - * \sa SDL_RenderSetViewport() - */ -extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h); - -/** - * \brief Get device independent resolution for rendering - * - * \param renderer The renderer from which resolution should be queried. - * \param w A pointer filled with the width of the logical resolution - * \param h A pointer filled with the height of the logical resolution - * - * \sa SDL_RenderSetLogicalSize() - */ -extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h); - -/** - * \brief Set whether to force integer scales for resolution-independent rendering - * - * \param renderer The renderer for which integer scaling should be set. - * \param enable Enable or disable integer scaling - * - * This function restricts the logical viewport to integer values - that is, when - * a resolution is between two multiples of a logical size, the viewport size is - * rounded down to the lower multiple. - * - * \sa SDL_RenderSetLogicalSize() - */ -extern DECLSPEC int SDLCALL SDL_RenderSetIntegerScale(SDL_Renderer * renderer, - SDL_bool enable); - -/** - * \brief Get whether integer scales are forced for resolution-independent rendering - * - * \param renderer The renderer from which integer scaling should be queried. - * - * \sa SDL_RenderSetIntegerScale() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer); - -/** - * \brief Set the drawing area for rendering on the current target. - * - * \param renderer The renderer for which the drawing area should be set. - * \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target. - * - * The x,y of the viewport rect represents the origin for rendering. - * - * \return 0 on success, or -1 on error - * - * \note If the window associated with the renderer is resized, the viewport is automatically reset. - * - * \sa SDL_RenderGetViewport() - * \sa SDL_RenderSetLogicalSize() - */ -extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer, - const SDL_Rect * rect); - -/** - * \brief Get the drawing area for the current target. - * - * \sa SDL_RenderSetViewport() - */ -extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer, - SDL_Rect * rect); - -/** - * \brief Set the clip rectangle for the current target. - * - * \param renderer The renderer for which clip rectangle should be set. - * \param rect A pointer to the rectangle to set as the clip rectangle, - * relative to the viewport, or NULL to disable clipping. - * - * \return 0 on success, or -1 on error - * - * \sa SDL_RenderGetClipRect() - */ -extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer, - const SDL_Rect * rect); - -/** - * \brief Get the clip rectangle for the current target. - * - * \param renderer The renderer from which clip rectangle should be queried. - * \param rect A pointer filled in with the current clip rectangle, or - * an empty rectangle if clipping is disabled. - * - * \sa SDL_RenderSetClipRect() - */ -extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer, - SDL_Rect * rect); - -/** - * \brief Get whether clipping is enabled on the given renderer. - * - * \param renderer The renderer from which clip state should be queried. - * - * \sa SDL_RenderGetClipRect() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer); - - -/** - * \brief Set the drawing scale for rendering on the current target. - * - * \param renderer The renderer for which the drawing scale should be set. - * \param scaleX The horizontal scaling factor - * \param scaleY The vertical scaling factor - * - * The drawing coordinates are scaled by the x/y scaling factors - * before they are used by the renderer. This allows resolution - * independent drawing with a single coordinate system. - * - * \note If this results in scaling or subpixel drawing by the - * rendering backend, it will be handled using the appropriate - * quality hints. For best results use integer scaling factors. - * - * \sa SDL_RenderGetScale() - * \sa SDL_RenderSetLogicalSize() - */ -extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer, - float scaleX, float scaleY); - -/** - * \brief Get the drawing scale for the current target. - * - * \param renderer The renderer from which drawing scale should be queried. - * \param scaleX A pointer filled in with the horizontal scaling factor - * \param scaleY A pointer filled in with the vertical scaling factor - * - * \sa SDL_RenderSetScale() - */ -extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer, - float *scaleX, float *scaleY); - -/** - * \brief Set the color used for drawing operations (Rect, Line and Clear). - * - * \param renderer The renderer for which drawing color should be set. - * \param r The red value used to draw on the rendering target. - * \param g The green value used to draw on the rendering target. - * \param b The blue value used to draw on the rendering target. - * \param a The alpha value used to draw on the rendering target, usually - * ::SDL_ALPHA_OPAQUE (255). - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer, - Uint8 r, Uint8 g, Uint8 b, - Uint8 a); - -/** - * \brief Get the color used for drawing operations (Rect, Line and Clear). - * - * \param renderer The renderer from which drawing color should be queried. - * \param r A pointer to the red value used to draw on the rendering target. - * \param g A pointer to the green value used to draw on the rendering target. - * \param b A pointer to the blue value used to draw on the rendering target. - * \param a A pointer to the alpha value used to draw on the rendering target, - * usually ::SDL_ALPHA_OPAQUE (255). - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer, - Uint8 * r, Uint8 * g, Uint8 * b, - Uint8 * a); - -/** - * \brief Set the blend mode used for drawing operations (Fill and Line). - * - * \param renderer The renderer for which blend mode should be set. - * \param blendMode ::SDL_BlendMode to use for blending. - * - * \return 0 on success, or -1 on error - * - * \note If the blend mode is not supported, the closest supported mode is - * chosen. - * - * \sa SDL_GetRenderDrawBlendMode() - */ -extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, - SDL_BlendMode blendMode); - -/** - * \brief Get the blend mode used for drawing operations. - * - * \param renderer The renderer from which blend mode should be queried. - * \param blendMode A pointer filled in with the current blend mode. - * - * \return 0 on success, or -1 on error - * - * \sa SDL_SetRenderDrawBlendMode() - */ -extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, - SDL_BlendMode *blendMode); - -/** - * \brief Clear the current rendering target with the drawing color - * - * This function clears the entire rendering target, ignoring the viewport and - * the clip rectangle. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer); - -/** - * \brief Draw a point on the current rendering target. - * - * \param renderer The renderer which should draw a point. - * \param x The x coordinate of the point. - * \param y The y coordinate of the point. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer, - int x, int y); - -/** - * \brief Draw multiple points on the current rendering target. - * - * \param renderer The renderer which should draw multiple points. - * \param points The points to draw - * \param count The number of points to draw - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer, - const SDL_Point * points, - int count); - -/** - * \brief Draw a line on the current rendering target. - * - * \param renderer The renderer which should draw a line. - * \param x1 The x coordinate of the start point. - * \param y1 The y coordinate of the start point. - * \param x2 The x coordinate of the end point. - * \param y2 The y coordinate of the end point. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer, - int x1, int y1, int x2, int y2); - -/** - * \brief Draw a series of connected lines on the current rendering target. - * - * \param renderer The renderer which should draw multiple lines. - * \param points The points along the lines - * \param count The number of points, drawing count-1 lines - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer, - const SDL_Point * points, - int count); - -/** - * \brief Draw a rectangle on the current rendering target. - * - * \param renderer The renderer which should draw a rectangle. - * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer, - const SDL_Rect * rect); - -/** - * \brief Draw some number of rectangles on the current rendering target. - * - * \param renderer The renderer which should draw multiple rectangles. - * \param rects A pointer to an array of destination rectangles. - * \param count The number of rectangles. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer, - const SDL_Rect * rects, - int count); - -/** - * \brief Fill a rectangle on the current rendering target with the drawing color. - * - * \param renderer The renderer which should fill a rectangle. - * \param rect A pointer to the destination rectangle, or NULL for the entire - * rendering target. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer, - const SDL_Rect * rect); - -/** - * \brief Fill some number of rectangles on the current rendering target with the drawing color. - * - * \param renderer The renderer which should fill multiple rectangles. - * \param rects A pointer to an array of destination rectangles. - * \param count The number of rectangles. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer, - const SDL_Rect * rects, - int count); - -/** - * \brief Copy a portion of the texture to the current rendering target. - * - * \param renderer The renderer which should copy parts of a texture. - * \param texture The source texture. - * \param srcrect A pointer to the source rectangle, or NULL for the entire - * texture. - * \param dstrect A pointer to the destination rectangle, or NULL for the - * entire rendering target. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Rect * srcrect, - const SDL_Rect * dstrect); - -/** - * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center - * - * \param renderer The renderer which should copy parts of a texture. - * \param texture The source texture. - * \param srcrect A pointer to the source rectangle, or NULL for the entire - * texture. - * \param dstrect A pointer to the destination rectangle, or NULL for the - * entire rendering target. - * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction - * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2). - * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Rect * srcrect, - const SDL_Rect * dstrect, - const double angle, - const SDL_Point *center, - const SDL_RendererFlip flip); - - -/** - * \brief Draw a point on the current rendering target. - * - * \param renderer The renderer which should draw a point. - * \param x The x coordinate of the point. - * \param y The y coordinate of the point. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer, - float x, float y); - -/** - * \brief Draw multiple points on the current rendering target. - * - * \param renderer The renderer which should draw multiple points. - * \param points The points to draw - * \param count The number of points to draw - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer, - const SDL_FPoint * points, - int count); - -/** - * \brief Draw a line on the current rendering target. - * - * \param renderer The renderer which should draw a line. - * \param x1 The x coordinate of the start point. - * \param y1 The y coordinate of the start point. - * \param x2 The x coordinate of the end point. - * \param y2 The y coordinate of the end point. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer, - float x1, float y1, float x2, float y2); - -/** - * \brief Draw a series of connected lines on the current rendering target. - * - * \param renderer The renderer which should draw multiple lines. - * \param points The points along the lines - * \param count The number of points, drawing count-1 lines - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer, - const SDL_FPoint * points, - int count); - -/** - * \brief Draw a rectangle on the current rendering target. - * - * \param renderer The renderer which should draw a rectangle. - * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer, - const SDL_FRect * rect); - -/** - * \brief Draw some number of rectangles on the current rendering target. - * - * \param renderer The renderer which should draw multiple rectangles. - * \param rects A pointer to an array of destination rectangles. - * \param count The number of rectangles. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer, - const SDL_FRect * rects, - int count); - -/** - * \brief Fill a rectangle on the current rendering target with the drawing color. - * - * \param renderer The renderer which should fill a rectangle. - * \param rect A pointer to the destination rectangle, or NULL for the entire - * rendering target. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer, - const SDL_FRect * rect); - -/** - * \brief Fill some number of rectangles on the current rendering target with the drawing color. - * - * \param renderer The renderer which should fill multiple rectangles. - * \param rects A pointer to an array of destination rectangles. - * \param count The number of rectangles. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer, - const SDL_FRect * rects, - int count); - -/** - * \brief Copy a portion of the texture to the current rendering target. - * - * \param renderer The renderer which should copy parts of a texture. - * \param texture The source texture. - * \param srcrect A pointer to the source rectangle, or NULL for the entire - * texture. - * \param dstrect A pointer to the destination rectangle, or NULL for the - * entire rendering target. - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Rect * srcrect, - const SDL_FRect * dstrect); - -/** - * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center - * - * \param renderer The renderer which should copy parts of a texture. - * \param texture The source texture. - * \param srcrect A pointer to the source rectangle, or NULL for the entire - * texture. - * \param dstrect A pointer to the destination rectangle, or NULL for the - * entire rendering target. - * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction - * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2). - * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture - * - * \return 0 on success, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Rect * srcrect, - const SDL_FRect * dstrect, - const double angle, - const SDL_FPoint *center, - const SDL_RendererFlip flip); - -/** - * \brief Read pixels from the current rendering target. - * - * \param renderer The renderer from which pixels should be read. - * \param rect A pointer to the rectangle to read, or NULL for the entire - * render target. - * \param format The desired format of the pixel data, or 0 to use the format - * of the rendering target - * \param pixels A pointer to be filled in with the pixel data - * \param pitch The pitch of the pixels parameter. - * - * \return 0 on success, or -1 if pixel reading is not supported. - * - * \warning This is a very slow operation, and should not be used frequently. - */ -extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, - const SDL_Rect * rect, - Uint32 format, - void *pixels, int pitch); - -/** - * \brief Update the screen with rendering performed. - */ -extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer); - -/** - * \brief Destroy the specified texture. - * - * \sa SDL_CreateTexture() - * \sa SDL_CreateTextureFromSurface() - */ -extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); - -/** - * \brief Destroy the rendering context for a window and free associated - * textures. - * - * \sa SDL_CreateRenderer() - */ -extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); - -/** - * \brief Force the rendering context to flush any pending commands to the - * underlying rendering API. - * - * You do not need to (and in fact, shouldn't) call this function unless - * you are planning to call into OpenGL/Direct3D/Metal/whatever directly - * in addition to using an SDL_Renderer. - * - * This is for a very-specific case: if you are using SDL's render API, - * you asked for a specific renderer backend (OpenGL, Direct3D, etc), - * you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make - * OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of - * this applies, you should call SDL_RenderFlush() between calls to SDL's - * render API and the low-level API you're using in cooperation. - * - * In all other cases, you can ignore this function. This is only here to - * get maximum performance out of a specific situation. In all other cases, - * SDL will do the right thing, perhaps at a performance loss. - * - * This function is first available in SDL 2.0.10, and is not needed in - * 2.0.9 and earlier, as earlier versions did not queue rendering commands - * at all, instead flushing them to the OS immediately. - */ -extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer); - - -/** - * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with - * OpenGL instructions. - * - * \param texture The SDL texture to bind - * \param texw A pointer to a float that will be filled with the texture width - * \param texh A pointer to a float that will be filled with the texture height - * - * \return 0 on success, or -1 if the operation is not supported - */ -extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh); - -/** - * \brief Unbind a texture from the current OpenGL/ES/ES2 context. - * - * \param texture The SDL texture to unbind - * - * \return 0 on success, or -1 if the operation is not supported - */ -extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture); - -/** - * \brief Get the CAMetalLayer associated with the given Metal renderer - * - * \param renderer The renderer to query - * - * \return CAMetalLayer* on success, or NULL if the renderer isn't a Metal renderer - * - * \sa SDL_RenderGetMetalCommandEncoder() - */ -extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer); - -/** - * \brief Get the Metal command encoder for the current frame - * - * \param renderer The renderer to query - * - * \return id on success, or NULL if the renderer isn't a Metal renderer - * - * \sa SDL_RenderGetMetalLayer() - */ -extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_render_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_revision.h b/thirdparty/include/SDL2/SDL_revision.h deleted file mode 100644 index dfbc057fe..000000000 --- a/thirdparty/include/SDL2/SDL_revision.h +++ /dev/null @@ -1,2 +0,0 @@ -#define SDL_REVISION "hg-13609:34cc7d3b69d3" -#define SDL_REVISION_NUMBER 13609 diff --git a/thirdparty/include/SDL2/SDL_rwops.h b/thirdparty/include/SDL2/SDL_rwops.h deleted file mode 100644 index 6674f5060..000000000 --- a/thirdparty/include/SDL2/SDL_rwops.h +++ /dev/null @@ -1,291 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_rwops.h - * - * This file provides a general interface for SDL to read and write - * data streams. It can easily be extended to files, memory, etc. - */ - -#ifndef SDL_rwops_h_ -#define SDL_rwops_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* RWops Types */ -#define SDL_RWOPS_UNKNOWN 0U /**< Unknown stream type */ -#define SDL_RWOPS_WINFILE 1U /**< Win32 file */ -#define SDL_RWOPS_STDFILE 2U /**< Stdio file */ -#define SDL_RWOPS_JNIFILE 3U /**< Android asset */ -#define SDL_RWOPS_MEMORY 4U /**< Memory stream */ -#define SDL_RWOPS_MEMORY_RO 5U /**< Read-Only memory stream */ - -/** - * This is the read/write operation structure -- very basic. - */ -typedef struct SDL_RWops -{ - /** - * Return the size of the file in this rwops, or -1 if unknown - */ - Sint64 (SDLCALL * size) (struct SDL_RWops * context); - - /** - * Seek to \c offset relative to \c whence, one of stdio's whence values: - * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END - * - * \return the final offset in the data stream, or -1 on error. - */ - Sint64 (SDLCALL * seek) (struct SDL_RWops * context, Sint64 offset, - int whence); - - /** - * Read up to \c maxnum objects each of size \c size from the data - * stream to the area pointed at by \c ptr. - * - * \return the number of objects read, or 0 at error or end of file. - */ - size_t (SDLCALL * read) (struct SDL_RWops * context, void *ptr, - size_t size, size_t maxnum); - - /** - * Write exactly \c num objects each of size \c size from the area - * pointed at by \c ptr to data stream. - * - * \return the number of objects written, or 0 at error or end of file. - */ - size_t (SDLCALL * write) (struct SDL_RWops * context, const void *ptr, - size_t size, size_t num); - - /** - * Close and free an allocated SDL_RWops structure. - * - * \return 0 if successful or -1 on write error when flushing data. - */ - int (SDLCALL * close) (struct SDL_RWops * context); - - Uint32 type; - union - { -#if defined(__ANDROID__) - struct - { - void *fileNameRef; - void *inputStreamRef; - void *readableByteChannelRef; - void *readMethod; - void *assetFileDescriptorRef; - long position; - long size; - long offset; - int fd; - } androidio; -#elif defined(__WIN32__) - struct - { - SDL_bool append; - void *h; - struct - { - void *data; - size_t size; - size_t left; - } buffer; - } windowsio; -#endif - -#ifdef HAVE_STDIO_H - struct - { - SDL_bool autoclose; - FILE *fp; - } stdio; -#endif - struct - { - Uint8 *base; - Uint8 *here; - Uint8 *stop; - } mem; - struct - { - void *data1; - void *data2; - } unknown; - } hidden; - -} SDL_RWops; - - -/** - * \name RWFrom functions - * - * Functions to create SDL_RWops structures from various data streams. - */ -/* @{ */ - -extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, - const char *mode); - -#ifdef HAVE_STDIO_H -extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, - SDL_bool autoclose); -#else -extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp, - SDL_bool autoclose); -#endif - -extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size); -extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, - int size); - -/* @} *//* RWFrom functions */ - - -extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); -extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); - -#define RW_SEEK_SET 0 /**< Seek from the beginning of data */ -#define RW_SEEK_CUR 1 /**< Seek relative to current read point */ -#define RW_SEEK_END 2 /**< Seek relative to the end of data */ - -/** - * Return the size of the file in this rwops, or -1 if unknown - */ -extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context); - -/** - * Seek to \c offset relative to \c whence, one of stdio's whence values: - * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END - * - * \return the final offset in the data stream, or -1 on error. - */ -extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context, - Sint64 offset, int whence); - -/** - * Return the current offset in the data stream, or -1 on error. - */ -extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context); - -/** - * Read up to \c maxnum objects each of size \c size from the data - * stream to the area pointed at by \c ptr. - * - * \return the number of objects read, or 0 at error or end of file. - */ -extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context, - void *ptr, size_t size, size_t maxnum); - -/** - * Write exactly \c num objects each of size \c size from the area - * pointed at by \c ptr to data stream. - * - * \return the number of objects written, or 0 at error or end of file. - */ -extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context, - const void *ptr, size_t size, size_t num); - -/** - * Close and free an allocated SDL_RWops structure. - * - * \return 0 if successful or -1 on write error when flushing data. - */ -extern DECLSPEC int SDLCALL SDL_RWclose(SDL_RWops *context); - -/** - * Load all the data from an SDL data stream. - * - * The data is allocated with a zero byte at the end (null terminated) - * - * If \c datasize is not NULL, it is filled with the size of the data read. - * - * If \c freesrc is non-zero, the stream will be closed after being read. - * - * The data should be freed with SDL_free(). - * - * \return the data, or NULL if there was an error. - */ -extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, - int freesrc); - -/** - * Load an entire file. - * - * The data is allocated with a zero byte at the end (null terminated) - * - * If \c datasize is not NULL, it is filled with the size of the data read. - * - * If \c freesrc is non-zero, the stream will be closed after being read. - * - * The data should be freed with SDL_free(). - * - * \return the data, or NULL if there was an error. - */ -extern DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasize); - -/** - * \name Read endian functions - * - * Read an item of the specified endianness and return in native format. - */ -/* @{ */ -extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src); -extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src); -extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src); -extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src); -extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src); -extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); -extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); -/* @} *//* Read endian functions */ - -/** - * \name Write endian functions - * - * Write an item of native format to the specified endianness. - */ -/* @{ */ -extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value); -extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value); -extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value); -extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value); -extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value); -extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value); -extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); -/* @} *//* Write endian functions */ - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_rwops_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_scancode.h b/thirdparty/include/SDL2/SDL_scancode.h deleted file mode 100644 index b19197d2b..000000000 --- a/thirdparty/include/SDL2/SDL_scancode.h +++ /dev/null @@ -1,413 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_scancode.h - * - * Defines keyboard scancodes. - */ - -#ifndef SDL_scancode_h_ -#define SDL_scancode_h_ - -#include "SDL_stdinc.h" - -/** - * \brief The SDL keyboard scancode representation. - * - * Values of this type are used to represent keyboard keys, among other places - * in the \link SDL_Keysym::scancode key.keysym.scancode \endlink field of the - * SDL_Event structure. - * - * The values in this enumeration are based on the USB usage page standard: - * https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf - */ -typedef enum -{ - SDL_SCANCODE_UNKNOWN = 0, - - /** - * \name Usage page 0x07 - * - * These values are from usage page 0x07 (USB keyboard page). - */ - /* @{ */ - - SDL_SCANCODE_A = 4, - SDL_SCANCODE_B = 5, - SDL_SCANCODE_C = 6, - SDL_SCANCODE_D = 7, - SDL_SCANCODE_E = 8, - SDL_SCANCODE_F = 9, - SDL_SCANCODE_G = 10, - SDL_SCANCODE_H = 11, - SDL_SCANCODE_I = 12, - SDL_SCANCODE_J = 13, - SDL_SCANCODE_K = 14, - SDL_SCANCODE_L = 15, - SDL_SCANCODE_M = 16, - SDL_SCANCODE_N = 17, - SDL_SCANCODE_O = 18, - SDL_SCANCODE_P = 19, - SDL_SCANCODE_Q = 20, - SDL_SCANCODE_R = 21, - SDL_SCANCODE_S = 22, - SDL_SCANCODE_T = 23, - SDL_SCANCODE_U = 24, - SDL_SCANCODE_V = 25, - SDL_SCANCODE_W = 26, - SDL_SCANCODE_X = 27, - SDL_SCANCODE_Y = 28, - SDL_SCANCODE_Z = 29, - - SDL_SCANCODE_1 = 30, - SDL_SCANCODE_2 = 31, - SDL_SCANCODE_3 = 32, - SDL_SCANCODE_4 = 33, - SDL_SCANCODE_5 = 34, - SDL_SCANCODE_6 = 35, - SDL_SCANCODE_7 = 36, - SDL_SCANCODE_8 = 37, - SDL_SCANCODE_9 = 38, - SDL_SCANCODE_0 = 39, - - SDL_SCANCODE_RETURN = 40, - SDL_SCANCODE_ESCAPE = 41, - SDL_SCANCODE_BACKSPACE = 42, - SDL_SCANCODE_TAB = 43, - SDL_SCANCODE_SPACE = 44, - - SDL_SCANCODE_MINUS = 45, - SDL_SCANCODE_EQUALS = 46, - SDL_SCANCODE_LEFTBRACKET = 47, - SDL_SCANCODE_RIGHTBRACKET = 48, - SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return - * key on ISO keyboards and at the right end - * of the QWERTY row on ANSI keyboards. - * Produces REVERSE SOLIDUS (backslash) and - * VERTICAL LINE in a US layout, REVERSE - * SOLIDUS and VERTICAL LINE in a UK Mac - * layout, NUMBER SIGN and TILDE in a UK - * Windows layout, DOLLAR SIGN and POUND SIGN - * in a Swiss German layout, NUMBER SIGN and - * APOSTROPHE in a German layout, GRAVE - * ACCENT and POUND SIGN in a French Mac - * layout, and ASTERISK and MICRO SIGN in a - * French Windows layout. - */ - SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code - * instead of 49 for the same key, but all - * OSes I've seen treat the two codes - * identically. So, as an implementor, unless - * your keyboard generates both of those - * codes and your OS treats them differently, - * you should generate SDL_SCANCODE_BACKSLASH - * instead of this code. As a user, you - * should not rely on this code because SDL - * will never generate it with most (all?) - * keyboards. - */ - SDL_SCANCODE_SEMICOLON = 51, - SDL_SCANCODE_APOSTROPHE = 52, - SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI - * and ISO keyboards). Produces GRAVE ACCENT and - * TILDE in a US Windows layout and in US and UK - * Mac layouts on ANSI keyboards, GRAVE ACCENT - * and NOT SIGN in a UK Windows layout, SECTION - * SIGN and PLUS-MINUS SIGN in US and UK Mac - * layouts on ISO keyboards, SECTION SIGN and - * DEGREE SIGN in a Swiss German layout (Mac: - * only on ISO keyboards), CIRCUMFLEX ACCENT and - * DEGREE SIGN in a German layout (Mac: only on - * ISO keyboards), SUPERSCRIPT TWO and TILDE in a - * French Windows layout, COMMERCIAL AT and - * NUMBER SIGN in a French Mac layout on ISO - * keyboards, and LESS-THAN SIGN and GREATER-THAN - * SIGN in a Swiss German, German, or French Mac - * layout on ANSI keyboards. - */ - SDL_SCANCODE_COMMA = 54, - SDL_SCANCODE_PERIOD = 55, - SDL_SCANCODE_SLASH = 56, - - SDL_SCANCODE_CAPSLOCK = 57, - - SDL_SCANCODE_F1 = 58, - SDL_SCANCODE_F2 = 59, - SDL_SCANCODE_F3 = 60, - SDL_SCANCODE_F4 = 61, - SDL_SCANCODE_F5 = 62, - SDL_SCANCODE_F6 = 63, - SDL_SCANCODE_F7 = 64, - SDL_SCANCODE_F8 = 65, - SDL_SCANCODE_F9 = 66, - SDL_SCANCODE_F10 = 67, - SDL_SCANCODE_F11 = 68, - SDL_SCANCODE_F12 = 69, - - SDL_SCANCODE_PRINTSCREEN = 70, - SDL_SCANCODE_SCROLLLOCK = 71, - SDL_SCANCODE_PAUSE = 72, - SDL_SCANCODE_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but - does send code 73, not 117) */ - SDL_SCANCODE_HOME = 74, - SDL_SCANCODE_PAGEUP = 75, - SDL_SCANCODE_DELETE = 76, - SDL_SCANCODE_END = 77, - SDL_SCANCODE_PAGEDOWN = 78, - SDL_SCANCODE_RIGHT = 79, - SDL_SCANCODE_LEFT = 80, - SDL_SCANCODE_DOWN = 81, - SDL_SCANCODE_UP = 82, - - SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards - */ - SDL_SCANCODE_KP_DIVIDE = 84, - SDL_SCANCODE_KP_MULTIPLY = 85, - SDL_SCANCODE_KP_MINUS = 86, - SDL_SCANCODE_KP_PLUS = 87, - SDL_SCANCODE_KP_ENTER = 88, - SDL_SCANCODE_KP_1 = 89, - SDL_SCANCODE_KP_2 = 90, - SDL_SCANCODE_KP_3 = 91, - SDL_SCANCODE_KP_4 = 92, - SDL_SCANCODE_KP_5 = 93, - SDL_SCANCODE_KP_6 = 94, - SDL_SCANCODE_KP_7 = 95, - SDL_SCANCODE_KP_8 = 96, - SDL_SCANCODE_KP_9 = 97, - SDL_SCANCODE_KP_0 = 98, - SDL_SCANCODE_KP_PERIOD = 99, - - SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO - * keyboards have over ANSI ones, - * located between left shift and Y. - * Produces GRAVE ACCENT and TILDE in a - * US or UK Mac layout, REVERSE SOLIDUS - * (backslash) and VERTICAL LINE in a - * US or UK Windows layout, and - * LESS-THAN SIGN and GREATER-THAN SIGN - * in a Swiss German, German, or French - * layout. */ - SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */ - SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag, - * not a physical key - but some Mac keyboards - * do have a power key. */ - SDL_SCANCODE_KP_EQUALS = 103, - SDL_SCANCODE_F13 = 104, - SDL_SCANCODE_F14 = 105, - SDL_SCANCODE_F15 = 106, - SDL_SCANCODE_F16 = 107, - SDL_SCANCODE_F17 = 108, - SDL_SCANCODE_F18 = 109, - SDL_SCANCODE_F19 = 110, - SDL_SCANCODE_F20 = 111, - SDL_SCANCODE_F21 = 112, - SDL_SCANCODE_F22 = 113, - SDL_SCANCODE_F23 = 114, - SDL_SCANCODE_F24 = 115, - SDL_SCANCODE_EXECUTE = 116, - SDL_SCANCODE_HELP = 117, - SDL_SCANCODE_MENU = 118, - SDL_SCANCODE_SELECT = 119, - SDL_SCANCODE_STOP = 120, - SDL_SCANCODE_AGAIN = 121, /**< redo */ - SDL_SCANCODE_UNDO = 122, - SDL_SCANCODE_CUT = 123, - SDL_SCANCODE_COPY = 124, - SDL_SCANCODE_PASTE = 125, - SDL_SCANCODE_FIND = 126, - SDL_SCANCODE_MUTE = 127, - SDL_SCANCODE_VOLUMEUP = 128, - SDL_SCANCODE_VOLUMEDOWN = 129, -/* not sure whether there's a reason to enable these */ -/* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */ -/* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */ -/* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */ - SDL_SCANCODE_KP_COMMA = 133, - SDL_SCANCODE_KP_EQUALSAS400 = 134, - - SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see - footnotes in USB doc */ - SDL_SCANCODE_INTERNATIONAL2 = 136, - SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */ - SDL_SCANCODE_INTERNATIONAL4 = 138, - SDL_SCANCODE_INTERNATIONAL5 = 139, - SDL_SCANCODE_INTERNATIONAL6 = 140, - SDL_SCANCODE_INTERNATIONAL7 = 141, - SDL_SCANCODE_INTERNATIONAL8 = 142, - SDL_SCANCODE_INTERNATIONAL9 = 143, - SDL_SCANCODE_LANG1 = 144, /**< Hangul/English toggle */ - SDL_SCANCODE_LANG2 = 145, /**< Hanja conversion */ - SDL_SCANCODE_LANG3 = 146, /**< Katakana */ - SDL_SCANCODE_LANG4 = 147, /**< Hiragana */ - SDL_SCANCODE_LANG5 = 148, /**< Zenkaku/Hankaku */ - SDL_SCANCODE_LANG6 = 149, /**< reserved */ - SDL_SCANCODE_LANG7 = 150, /**< reserved */ - SDL_SCANCODE_LANG8 = 151, /**< reserved */ - SDL_SCANCODE_LANG9 = 152, /**< reserved */ - - SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */ - SDL_SCANCODE_SYSREQ = 154, - SDL_SCANCODE_CANCEL = 155, - SDL_SCANCODE_CLEAR = 156, - SDL_SCANCODE_PRIOR = 157, - SDL_SCANCODE_RETURN2 = 158, - SDL_SCANCODE_SEPARATOR = 159, - SDL_SCANCODE_OUT = 160, - SDL_SCANCODE_OPER = 161, - SDL_SCANCODE_CLEARAGAIN = 162, - SDL_SCANCODE_CRSEL = 163, - SDL_SCANCODE_EXSEL = 164, - - SDL_SCANCODE_KP_00 = 176, - SDL_SCANCODE_KP_000 = 177, - SDL_SCANCODE_THOUSANDSSEPARATOR = 178, - SDL_SCANCODE_DECIMALSEPARATOR = 179, - SDL_SCANCODE_CURRENCYUNIT = 180, - SDL_SCANCODE_CURRENCYSUBUNIT = 181, - SDL_SCANCODE_KP_LEFTPAREN = 182, - SDL_SCANCODE_KP_RIGHTPAREN = 183, - SDL_SCANCODE_KP_LEFTBRACE = 184, - SDL_SCANCODE_KP_RIGHTBRACE = 185, - SDL_SCANCODE_KP_TAB = 186, - SDL_SCANCODE_KP_BACKSPACE = 187, - SDL_SCANCODE_KP_A = 188, - SDL_SCANCODE_KP_B = 189, - SDL_SCANCODE_KP_C = 190, - SDL_SCANCODE_KP_D = 191, - SDL_SCANCODE_KP_E = 192, - SDL_SCANCODE_KP_F = 193, - SDL_SCANCODE_KP_XOR = 194, - SDL_SCANCODE_KP_POWER = 195, - SDL_SCANCODE_KP_PERCENT = 196, - SDL_SCANCODE_KP_LESS = 197, - SDL_SCANCODE_KP_GREATER = 198, - SDL_SCANCODE_KP_AMPERSAND = 199, - SDL_SCANCODE_KP_DBLAMPERSAND = 200, - SDL_SCANCODE_KP_VERTICALBAR = 201, - SDL_SCANCODE_KP_DBLVERTICALBAR = 202, - SDL_SCANCODE_KP_COLON = 203, - SDL_SCANCODE_KP_HASH = 204, - SDL_SCANCODE_KP_SPACE = 205, - SDL_SCANCODE_KP_AT = 206, - SDL_SCANCODE_KP_EXCLAM = 207, - SDL_SCANCODE_KP_MEMSTORE = 208, - SDL_SCANCODE_KP_MEMRECALL = 209, - SDL_SCANCODE_KP_MEMCLEAR = 210, - SDL_SCANCODE_KP_MEMADD = 211, - SDL_SCANCODE_KP_MEMSUBTRACT = 212, - SDL_SCANCODE_KP_MEMMULTIPLY = 213, - SDL_SCANCODE_KP_MEMDIVIDE = 214, - SDL_SCANCODE_KP_PLUSMINUS = 215, - SDL_SCANCODE_KP_CLEAR = 216, - SDL_SCANCODE_KP_CLEARENTRY = 217, - SDL_SCANCODE_KP_BINARY = 218, - SDL_SCANCODE_KP_OCTAL = 219, - SDL_SCANCODE_KP_DECIMAL = 220, - SDL_SCANCODE_KP_HEXADECIMAL = 221, - - SDL_SCANCODE_LCTRL = 224, - SDL_SCANCODE_LSHIFT = 225, - SDL_SCANCODE_LALT = 226, /**< alt, option */ - SDL_SCANCODE_LGUI = 227, /**< windows, command (apple), meta */ - SDL_SCANCODE_RCTRL = 228, - SDL_SCANCODE_RSHIFT = 229, - SDL_SCANCODE_RALT = 230, /**< alt gr, option */ - SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */ - - SDL_SCANCODE_MODE = 257, /**< I'm not sure if this is really not covered - * by any of the above, but since there's a - * special KMOD_MODE for it I'm adding it here - */ - - /* @} *//* Usage page 0x07 */ - - /** - * \name Usage page 0x0C - * - * These values are mapped from usage page 0x0C (USB consumer page). - */ - /* @{ */ - - SDL_SCANCODE_AUDIONEXT = 258, - SDL_SCANCODE_AUDIOPREV = 259, - SDL_SCANCODE_AUDIOSTOP = 260, - SDL_SCANCODE_AUDIOPLAY = 261, - SDL_SCANCODE_AUDIOMUTE = 262, - SDL_SCANCODE_MEDIASELECT = 263, - SDL_SCANCODE_WWW = 264, - SDL_SCANCODE_MAIL = 265, - SDL_SCANCODE_CALCULATOR = 266, - SDL_SCANCODE_COMPUTER = 267, - SDL_SCANCODE_AC_SEARCH = 268, - SDL_SCANCODE_AC_HOME = 269, - SDL_SCANCODE_AC_BACK = 270, - SDL_SCANCODE_AC_FORWARD = 271, - SDL_SCANCODE_AC_STOP = 272, - SDL_SCANCODE_AC_REFRESH = 273, - SDL_SCANCODE_AC_BOOKMARKS = 274, - - /* @} *//* Usage page 0x0C */ - - /** - * \name Walther keys - * - * These are values that Christian Walther added (for mac keyboard?). - */ - /* @{ */ - - SDL_SCANCODE_BRIGHTNESSDOWN = 275, - SDL_SCANCODE_BRIGHTNESSUP = 276, - SDL_SCANCODE_DISPLAYSWITCH = 277, /**< display mirroring/dual display - switch, video mode switch */ - SDL_SCANCODE_KBDILLUMTOGGLE = 278, - SDL_SCANCODE_KBDILLUMDOWN = 279, - SDL_SCANCODE_KBDILLUMUP = 280, - SDL_SCANCODE_EJECT = 281, - SDL_SCANCODE_SLEEP = 282, - - SDL_SCANCODE_APP1 = 283, - SDL_SCANCODE_APP2 = 284, - - /* @} *//* Walther keys */ - - /** - * \name Usage page 0x0C (additional media keys) - * - * These values are mapped from usage page 0x0C (USB consumer page). - */ - /* @{ */ - - SDL_SCANCODE_AUDIOREWIND = 285, - SDL_SCANCODE_AUDIOFASTFORWARD = 286, - - /* @} *//* Usage page 0x0C (additional media keys) */ - - /* Add any other keys here. */ - - SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes - for array bounds */ -} SDL_Scancode; - -#endif /* SDL_scancode_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_sensor.h b/thirdparty/include/SDL2/SDL_sensor.h deleted file mode 100644 index 5122ee153..000000000 --- a/thirdparty/include/SDL2/SDL_sensor.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_sensor.h - * - * Include file for SDL sensor event handling - * - */ - -#ifndef SDL_sensor_h_ -#define SDL_sensor_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -/* *INDENT-OFF* */ -extern "C" { -/* *INDENT-ON* */ -#endif - -/** - * \brief SDL_sensor.h - * - * In order to use these functions, SDL_Init() must have been called - * with the ::SDL_INIT_SENSOR flag. This causes SDL to scan the system - * for sensors, and load appropriate drivers. - */ - -struct _SDL_Sensor; -typedef struct _SDL_Sensor SDL_Sensor; - -/** - * This is a unique ID for a sensor for the time it is connected to the system, - * and is never reused for the lifetime of the application. - * - * The ID value starts at 0 and increments from there. The value -1 is an invalid ID. - */ -typedef Sint32 SDL_SensorID; - -/* The different sensors defined by SDL - * - * Additional sensors may be available, using platform dependent semantics. - * - * Hare are the additional Android sensors: - * https://developer.android.com/reference/android/hardware/SensorEvent.html#values - */ -typedef enum -{ - SDL_SENSOR_INVALID = -1, /**< Returned for an invalid sensor */ - SDL_SENSOR_UNKNOWN, /**< Unknown sensor type */ - SDL_SENSOR_ACCEL, /**< Accelerometer */ - SDL_SENSOR_GYRO /**< Gyroscope */ -} SDL_SensorType; - -/** - * Accelerometer sensor - * - * The accelerometer returns the current acceleration in SI meters per - * second squared. This includes gravity, so a device at rest will have - * an acceleration of SDL_STANDARD_GRAVITY straight down. - * - * values[0]: Acceleration on the x axis - * values[1]: Acceleration on the y axis - * values[2]: Acceleration on the z axis - * - * For phones held in portrait mode, the axes are defined as follows: - * -X ... +X : left ... right - * -Y ... +Y : bottom ... top - * -Z ... +Z : farther ... closer - * - * The axis data is not changed when the phone is rotated. - * - * \sa SDL_GetDisplayOrientation() - */ -#define SDL_STANDARD_GRAVITY 9.80665f - -/** - * Gyroscope sensor - * - * The gyroscope returns the current rate of rotation in radians per second. - * The rotation is positive in the counter-clockwise direction. That is, - * an observer looking from a positive location on one of the axes would - * see positive rotation on that axis when it appeared to be rotating - * counter-clockwise. - * - * values[0]: Angular speed around the x axis - * values[1]: Angular speed around the y axis - * values[2]: Angular speed around the z axis - * - * For phones held in portrait mode, the axes are defined as follows: - * -X ... +X : left ... right - * -Y ... +Y : bottom ... top - * -Z ... +Z : farther ... closer - * - * The axis data is not changed when the phone is rotated. - * - * \sa SDL_GetDisplayOrientation() - */ - -/* Function prototypes */ - -/** - * \brief Count the number of sensors attached to the system right now - */ -extern DECLSPEC int SDLCALL SDL_NumSensors(void); - -/** - * \brief Get the implementation dependent name of a sensor. - * - * This can be called before any sensors are opened. - * - * \return The sensor name, or NULL if device_index is out of range. - */ -extern DECLSPEC const char *SDLCALL SDL_SensorGetDeviceName(int device_index); - -/** - * \brief Get the type of a sensor. - * - * This can be called before any sensors are opened. - * - * \return The sensor type, or SDL_SENSOR_INVALID if device_index is out of range. - */ -extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetDeviceType(int device_index); - -/** - * \brief Get the platform dependent type of a sensor. - * - * This can be called before any sensors are opened. - * - * \return The sensor platform dependent type, or -1 if device_index is out of range. - */ -extern DECLSPEC int SDLCALL SDL_SensorGetDeviceNonPortableType(int device_index); - -/** - * \brief Get the instance ID of a sensor. - * - * This can be called before any sensors are opened. - * - * \return The sensor instance ID, or -1 if device_index is out of range. - */ -extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetDeviceInstanceID(int device_index); - -/** - * \brief Open a sensor for use. - * - * The index passed as an argument refers to the N'th sensor on the system. - * - * \return A sensor identifier, or NULL if an error occurred. - */ -extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorOpen(int device_index); - -/** - * Return the SDL_Sensor associated with an instance id. - */ -extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorFromInstanceID(SDL_SensorID instance_id); - -/** - * \brief Get the implementation dependent name of a sensor. - * - * \return The sensor name, or NULL if the sensor is NULL. - */ -extern DECLSPEC const char *SDLCALL SDL_SensorGetName(SDL_Sensor *sensor); - -/** - * \brief Get the type of a sensor. - * - * This can be called before any sensors are opened. - * - * \return The sensor type, or SDL_SENSOR_INVALID if the sensor is NULL. - */ -extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetType(SDL_Sensor *sensor); - -/** - * \brief Get the platform dependent type of a sensor. - * - * This can be called before any sensors are opened. - * - * \return The sensor platform dependent type, or -1 if the sensor is NULL. - */ -extern DECLSPEC int SDLCALL SDL_SensorGetNonPortableType(SDL_Sensor *sensor); - -/** - * \brief Get the instance ID of a sensor. - * - * This can be called before any sensors are opened. - * - * \return The sensor instance ID, or -1 if the sensor is NULL. - */ -extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor); - -/** - * Get the current state of an opened sensor. - * - * The number of values and interpretation of the data is sensor dependent. - * - * \param sensor The sensor to query - * \param data A pointer filled with the current sensor state - * \param num_values The number of values to write to data - * - * \return 0 or -1 if an error occurred. - */ -extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data, int num_values); - -/** - * Close a sensor previously opened with SDL_SensorOpen() - */ -extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor * sensor); - -/** - * Update the current state of the open sensors. - * - * This is called automatically by the event loop if sensor events are enabled. - * - * This needs to be called from the thread that initialized the sensor subsystem. - */ -extern DECLSPEC void SDLCALL SDL_SensorUpdate(void); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -/* *INDENT-OFF* */ -} -/* *INDENT-ON* */ -#endif -#include "close_code.h" - -#endif /* SDL_sensor_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_shape.h b/thirdparty/include/SDL2/SDL_shape.h deleted file mode 100644 index cbd9debd6..000000000 --- a/thirdparty/include/SDL2/SDL_shape.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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 SDL_shape_h_ -#define SDL_shape_h_ - -#include "SDL_stdinc.h" -#include "SDL_pixels.h" -#include "SDL_rect.h" -#include "SDL_surface.h" -#include "SDL_video.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** \file SDL_shape.h - * - * Header file for the shaped window API. - */ - -#define SDL_NONSHAPEABLE_WINDOW -1 -#define SDL_INVALID_SHAPE_ARGUMENT -2 -#define SDL_WINDOW_LACKS_SHAPE -3 - -/** - * \brief Create a window that can be shaped with the specified position, dimensions, and flags. - * - * \param title The title of the window, in UTF-8 encoding. - * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or - * ::SDL_WINDOWPOS_UNDEFINED. - * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or - * ::SDL_WINDOWPOS_UNDEFINED. - * \param w The width of the window. - * \param h The height of the window. - * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: - * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED, - * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_RESIZABLE, - * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED, - * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset. - * - * \return The window created, or NULL if window creation failed. - * - * \sa SDL_DestroyWindow() - */ -extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); - -/** - * \brief Return whether the given window is a shaped window. - * - * \param window The window to query for being shaped. - * - * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL. - * - * \sa SDL_CreateShapedWindow - */ -extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); - -/** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ -typedef enum { - /** \brief The default mode, a binarized alpha cutoff of 1. */ - ShapeModeDefault, - /** \brief A binarized alpha cutoff with a given integer value. */ - ShapeModeBinarizeAlpha, - /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ - ShapeModeReverseBinarizeAlpha, - /** \brief A color key is applied. */ - ShapeModeColorKey -} WindowShapeMode; - -#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) - -/** \brief A union containing parameters for shaped windows. */ -typedef union { - /** \brief A cutoff alpha value for binarization of the window shape's alpha channel. */ - Uint8 binarizationCutoff; - SDL_Color colorKey; -} SDL_WindowShapeParams; - -/** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ -typedef struct SDL_WindowShapeMode { - /** \brief The mode of these window-shape parameters. */ - WindowShapeMode mode; - /** \brief Window-shape parameters. */ - SDL_WindowShapeParams parameters; -} SDL_WindowShapeMode; - -/** - * \brief Set the shape and parameters of a shaped window. - * - * \param window The shaped window whose parameters should be set. - * \param shape A surface encoding the desired shape for the window. - * \param shape_mode The parameters to set for the shaped window. - * - * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW - * if the SDL_Window given does not reference a valid shaped window. - * - * \sa SDL_WindowShapeMode - * \sa SDL_GetShapedWindowMode. - */ -extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); - -/** - * \brief Get the shape parameters of a shaped window. - * - * \param window The shaped window whose parameters should be retrieved. - * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape. - * - * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode - * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if - * the SDL_Window given is a shapeable window currently lacking a shape. - * - * \sa SDL_WindowShapeMode - * \sa SDL_SetWindowShape - */ -extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_shape_h_ */ diff --git a/thirdparty/include/SDL2/SDL_stdinc.h b/thirdparty/include/SDL2/SDL_stdinc.h deleted file mode 100644 index d96e18bc2..000000000 --- a/thirdparty/include/SDL2/SDL_stdinc.h +++ /dev/null @@ -1,617 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_stdinc.h - * - * This is a general header that includes C language support. - */ - -#ifndef SDL_stdinc_h_ -#define SDL_stdinc_h_ - -#include "SDL_config.h" - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_STDIO_H -#include -#endif -#if defined(STDC_HEADERS) -# include -# include -# include -#else -# if defined(HAVE_STDLIB_H) -# include -# elif defined(HAVE_MALLOC_H) -# include -# endif -# if defined(HAVE_STDDEF_H) -# include -# endif -# if defined(HAVE_STDARG_H) -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_WCHAR_H -# include -#endif -#if defined(HAVE_INTTYPES_H) -# include -#elif defined(HAVE_STDINT_H) -# include -#endif -#ifdef HAVE_CTYPE_H -# include -#endif -#ifdef HAVE_MATH_H -# if defined(__WINRT__) -/* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on - WinRT. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx - for more information. -*/ -# define _USE_MATH_DEFINES -# endif -# include -#endif -#ifdef HAVE_FLOAT_H -# include -#endif -#if defined(HAVE_ALLOCA) && !defined(alloca) -# if defined(HAVE_ALLOCA_H) -# include -# elif defined(__GNUC__) -# define alloca __builtin_alloca -# elif defined(_MSC_VER) -# include -# define alloca _alloca -# elif defined(__WATCOMC__) -# include -# elif defined(__BORLANDC__) -# include -# elif defined(__DMC__) -# include -# elif defined(__AIX__) -#pragma alloca -# elif defined(__MRC__) -void *alloca(unsigned); -# else -char *alloca(); -# endif -#endif - -/** - * The number of elements in an array. - */ -#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) -#define SDL_TABLESIZE(table) SDL_arraysize(table) - -/** - * Macro useful for building other macros with strings in them - * - * e.g. #define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(__FUNCTION__) ": " X "\n") - */ -#define SDL_STRINGIFY_ARG(arg) #arg - -/** - * \name Cast operators - * - * Use proper C++ casts when compiled as C++ to be compatible with the option - * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). - */ -/* @{ */ -#ifdef __cplusplus -#define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) -#define SDL_static_cast(type, expression) static_cast(expression) -#define SDL_const_cast(type, expression) const_cast(expression) -#else -#define SDL_reinterpret_cast(type, expression) ((type)(expression)) -#define SDL_static_cast(type, expression) ((type)(expression)) -#define SDL_const_cast(type, expression) ((type)(expression)) -#endif -/* @} *//* Cast operators */ - -/* Define a four character code as a Uint32 */ -#define SDL_FOURCC(A, B, C, D) \ - ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \ - (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \ - (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \ - (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24)) - -/** - * \name Basic data types - */ -/* @{ */ - -#ifdef __CC_ARM -/* ARM's compiler throws warnings if we use an enum: like "SDL_bool x = a < b;" */ -#define SDL_FALSE 0 -#define SDL_TRUE 1 -typedef int SDL_bool; -#else -typedef enum -{ - SDL_FALSE = 0, - SDL_TRUE = 1 -} SDL_bool; -#endif - -/** - * \brief A signed 8-bit integer type. - */ -#define SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */ -#define SDL_MIN_SINT8 ((Sint8)(~0x7F)) /* -128 */ -typedef int8_t Sint8; -/** - * \brief An unsigned 8-bit integer type. - */ -#define SDL_MAX_UINT8 ((Uint8)0xFF) /* 255 */ -#define SDL_MIN_UINT8 ((Uint8)0x00) /* 0 */ -typedef uint8_t Uint8; -/** - * \brief A signed 16-bit integer type. - */ -#define SDL_MAX_SINT16 ((Sint16)0x7FFF) /* 32767 */ -#define SDL_MIN_SINT16 ((Sint16)(~0x7FFF)) /* -32768 */ -typedef int16_t Sint16; -/** - * \brief An unsigned 16-bit integer type. - */ -#define SDL_MAX_UINT16 ((Uint16)0xFFFF) /* 65535 */ -#define SDL_MIN_UINT16 ((Uint16)0x0000) /* 0 */ -typedef uint16_t Uint16; -/** - * \brief A signed 32-bit integer type. - */ -#define SDL_MAX_SINT32 ((Sint32)0x7FFFFFFF) /* 2147483647 */ -#define SDL_MIN_SINT32 ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */ -typedef int32_t Sint32; -/** - * \brief An unsigned 32-bit integer type. - */ -#define SDL_MAX_UINT32 ((Uint32)0xFFFFFFFFu) /* 4294967295 */ -#define SDL_MIN_UINT32 ((Uint32)0x00000000) /* 0 */ -typedef uint32_t Uint32; - -/** - * \brief A signed 64-bit integer type. - */ -#define SDL_MAX_SINT64 ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */ -#define SDL_MIN_SINT64 ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */ -typedef int64_t Sint64; -/** - * \brief An unsigned 64-bit integer type. - */ -#define SDL_MAX_UINT64 ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */ -#define SDL_MIN_UINT64 ((Uint64)(0x0000000000000000ull)) /* 0 */ -typedef uint64_t Uint64; - -/* @} *//* Basic data types */ - -/* Make sure we have macros for printing 64 bit values. - * should define these but this is not true all platforms. - * (for example win32) */ -#ifndef SDL_PRIs64 -#ifdef PRIs64 -#define SDL_PRIs64 PRIs64 -#elif defined(__WIN32__) -#define SDL_PRIs64 "I64d" -#elif defined(__LINUX__) && defined(__LP64__) -#define SDL_PRIs64 "ld" -#else -#define SDL_PRIs64 "lld" -#endif -#endif -#ifndef SDL_PRIu64 -#ifdef PRIu64 -#define SDL_PRIu64 PRIu64 -#elif defined(__WIN32__) -#define SDL_PRIu64 "I64u" -#elif defined(__LINUX__) && defined(__LP64__) -#define SDL_PRIu64 "lu" -#else -#define SDL_PRIu64 "llu" -#endif -#endif -#ifndef SDL_PRIx64 -#ifdef PRIx64 -#define SDL_PRIx64 PRIx64 -#elif defined(__WIN32__) -#define SDL_PRIx64 "I64x" -#elif defined(__LINUX__) && defined(__LP64__) -#define SDL_PRIx64 "lx" -#else -#define SDL_PRIx64 "llx" -#endif -#endif -#ifndef SDL_PRIX64 -#ifdef PRIX64 -#define SDL_PRIX64 PRIX64 -#elif defined(__WIN32__) -#define SDL_PRIX64 "I64X" -#elif defined(__LINUX__) && defined(__LP64__) -#define SDL_PRIX64 "lX" -#else -#define SDL_PRIX64 "llX" -#endif -#endif - -/* Annotations to help code analysis tools */ -#ifdef SDL_DISABLE_ANALYZE_MACROS -#define SDL_IN_BYTECAP(x) -#define SDL_INOUT_Z_CAP(x) -#define SDL_OUT_Z_CAP(x) -#define SDL_OUT_CAP(x) -#define SDL_OUT_BYTECAP(x) -#define SDL_OUT_Z_BYTECAP(x) -#define SDL_PRINTF_FORMAT_STRING -#define SDL_SCANF_FORMAT_STRING -#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) -#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) -#else -#if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */ -#include - -#define SDL_IN_BYTECAP(x) _In_bytecount_(x) -#define SDL_INOUT_Z_CAP(x) _Inout_z_cap_(x) -#define SDL_OUT_Z_CAP(x) _Out_z_cap_(x) -#define SDL_OUT_CAP(x) _Out_cap_(x) -#define SDL_OUT_BYTECAP(x) _Out_bytecap_(x) -#define SDL_OUT_Z_BYTECAP(x) _Out_z_bytecap_(x) - -#define SDL_PRINTF_FORMAT_STRING _Printf_format_string_ -#define SDL_SCANF_FORMAT_STRING _Scanf_format_string_impl_ -#else -#define SDL_IN_BYTECAP(x) -#define SDL_INOUT_Z_CAP(x) -#define SDL_OUT_Z_CAP(x) -#define SDL_OUT_CAP(x) -#define SDL_OUT_BYTECAP(x) -#define SDL_OUT_Z_BYTECAP(x) -#define SDL_PRINTF_FORMAT_STRING -#define SDL_SCANF_FORMAT_STRING -#endif -#if defined(__GNUC__) -#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 ))) -#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 ))) -#else -#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) -#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) -#endif -#endif /* SDL_DISABLE_ANALYZE_MACROS */ - -#define SDL_COMPILE_TIME_ASSERT(name, x) \ - typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1] -/** \cond */ -#ifndef DOXYGEN_SHOULD_IGNORE_THIS -SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); -SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); -SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); -SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); -SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); -SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); -SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); -SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); -#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ -/** \endcond */ - -/* Check to make sure enums are the size of ints, for structure packing. - For both Watcom C/C++ and Borland C/C++ the compiler option that makes - enums having the size of an int must be enabled. - This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). -*/ - -/** \cond */ -#ifndef DOXYGEN_SHOULD_IGNORE_THIS -#if !defined(__ANDROID__) - /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ -typedef enum -{ - DUMMY_ENUM_VALUE -} SDL_DUMMY_ENUM; - -SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); -#endif -#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ -/** \endcond */ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef HAVE_ALLOCA -#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) -#define SDL_stack_free(data) -#else -#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) -#define SDL_stack_free(data) SDL_free(data) -#endif - -extern DECLSPEC void *SDLCALL SDL_malloc(size_t size); -extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size); -extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size); -extern DECLSPEC void SDLCALL SDL_free(void *mem); - -typedef void *(SDLCALL *SDL_malloc_func)(size_t size); -typedef void *(SDLCALL *SDL_calloc_func)(size_t nmemb, size_t size); -typedef void *(SDLCALL *SDL_realloc_func)(void *mem, size_t size); -typedef void (SDLCALL *SDL_free_func)(void *mem); - -/** - * \brief Get the current set of SDL memory functions - */ -extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func, - SDL_calloc_func *calloc_func, - SDL_realloc_func *realloc_func, - SDL_free_func *free_func); - -/** - * \brief Replace SDL's memory allocation functions with a custom set - * - * \note If you are replacing SDL's memory functions, you should call - * SDL_GetNumAllocations() and be very careful if it returns non-zero. - * That means that your free function will be called with memory - * allocated by the previous memory allocation functions. - */ -extern DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func, - SDL_calloc_func calloc_func, - SDL_realloc_func realloc_func, - SDL_free_func free_func); - -/** - * \brief Get the number of outstanding (unfreed) allocations - */ -extern DECLSPEC int SDLCALL SDL_GetNumAllocations(void); - -extern DECLSPEC char *SDLCALL SDL_getenv(const char *name); -extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite); - -extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)); - -extern DECLSPEC int SDLCALL SDL_abs(int x); - -/* !!! FIXME: these have side effects. You probably shouldn't use them. */ -/* !!! FIXME: Maybe we do forceinline functions of SDL_mini, SDL_minf, etc? */ -#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) -#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) - -extern DECLSPEC int SDLCALL SDL_isdigit(int x); -extern DECLSPEC int SDLCALL SDL_isspace(int x); -extern DECLSPEC int SDLCALL SDL_isupper(int x); -extern DECLSPEC int SDLCALL SDL_islower(int x); -extern DECLSPEC int SDLCALL SDL_toupper(int x); -extern DECLSPEC int SDLCALL SDL_tolower(int x); - -extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len); - -#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) -#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) -#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x))) - -/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */ -SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords) -{ -#ifdef __APPLE__ - memset_pattern4(dst, &val, dwords * 4); -#elif defined(__GNUC__) && defined(i386) - int u0, u1, u2; - __asm__ __volatile__ ( - "cld \n\t" - "rep ; stosl \n\t" - : "=&D" (u0), "=&a" (u1), "=&c" (u2) - : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords)) - : "memory" - ); -#else - size_t _n = (dwords + 3) / 4; - Uint32 *_p = SDL_static_cast(Uint32 *, dst); - Uint32 _val = (val); - if (dwords == 0) - return; - switch (dwords % 4) - { - case 0: do { *_p++ = _val; /* fallthrough */ - case 3: *_p++ = _val; /* fallthrough */ - case 2: *_p++ = _val; /* fallthrough */ - case 1: *_p++ = _val; /* fallthrough */ - } while ( --_n ); - } -#endif -} - -extern DECLSPEC void *SDLCALL SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); - -extern DECLSPEC void *SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); -extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); - -extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr); -extern DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); -extern DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); -extern DECLSPEC wchar_t *SDLCALL SDL_wcsdup(const wchar_t *wstr); -extern DECLSPEC wchar_t *SDLCALL SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle); - -extern DECLSPEC int SDLCALL SDL_wcscmp(const wchar_t *str1, const wchar_t *str2); -extern DECLSPEC int SDLCALL SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen); - -extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str); -extern DECLSPEC size_t SDLCALL SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); -extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes); -extern DECLSPEC size_t SDLCALL SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); -extern DECLSPEC char *SDLCALL SDL_strdup(const char *str); -extern DECLSPEC char *SDLCALL SDL_strrev(char *str); -extern DECLSPEC char *SDLCALL SDL_strupr(char *str); -extern DECLSPEC char *SDLCALL SDL_strlwr(char *str); -extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c); -extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c); -extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle); -extern DECLSPEC char *SDLCALL SDL_strtokr(char *s1, const char *s2, char **saveptr); -extern DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str); - -extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix); -extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix); -extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix); -extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *str, int radix); -extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *str, int radix); -extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix); - -extern DECLSPEC int SDLCALL SDL_atoi(const char *str); -extern DECLSPEC double SDLCALL SDL_atof(const char *str); -extern DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base); -extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base); -extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base); -extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base); -extern DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp); - -extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); -extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); -extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); -extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len); - -extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2); -extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, const char *fmt, va_list ap); -extern DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... ) SDL_PRINTF_VARARG_FUNC(3); -extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap); - -#ifndef HAVE_M_PI -#ifndef M_PI -#define M_PI 3.14159265358979323846264338327950288 /**< pi */ -#endif -#endif - -extern DECLSPEC double SDLCALL SDL_acos(double x); -extern DECLSPEC float SDLCALL SDL_acosf(float x); -extern DECLSPEC double SDLCALL SDL_asin(double x); -extern DECLSPEC float SDLCALL SDL_asinf(float x); -extern DECLSPEC double SDLCALL SDL_atan(double x); -extern DECLSPEC float SDLCALL SDL_atanf(float x); -extern DECLSPEC double SDLCALL SDL_atan2(double x, double y); -extern DECLSPEC float SDLCALL SDL_atan2f(float x, float y); -extern DECLSPEC double SDLCALL SDL_ceil(double x); -extern DECLSPEC float SDLCALL SDL_ceilf(float x); -extern DECLSPEC double SDLCALL SDL_copysign(double x, double y); -extern DECLSPEC float SDLCALL SDL_copysignf(float x, float y); -extern DECLSPEC double SDLCALL SDL_cos(double x); -extern DECLSPEC float SDLCALL SDL_cosf(float x); -extern DECLSPEC double SDLCALL SDL_exp(double x); -extern DECLSPEC float SDLCALL SDL_expf(float x); -extern DECLSPEC double SDLCALL SDL_fabs(double x); -extern DECLSPEC float SDLCALL SDL_fabsf(float x); -extern DECLSPEC double SDLCALL SDL_floor(double x); -extern DECLSPEC float SDLCALL SDL_floorf(float x); -extern DECLSPEC double SDLCALL SDL_fmod(double x, double y); -extern DECLSPEC float SDLCALL SDL_fmodf(float x, float y); -extern DECLSPEC double SDLCALL SDL_log(double x); -extern DECLSPEC float SDLCALL SDL_logf(float x); -extern DECLSPEC double SDLCALL SDL_log10(double x); -extern DECLSPEC float SDLCALL SDL_log10f(float x); -extern DECLSPEC double SDLCALL SDL_pow(double x, double y); -extern DECLSPEC float SDLCALL SDL_powf(float x, float y); -extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n); -extern DECLSPEC float SDLCALL SDL_scalbnf(float x, int n); -extern DECLSPEC double SDLCALL SDL_sin(double x); -extern DECLSPEC float SDLCALL SDL_sinf(float x); -extern DECLSPEC double SDLCALL SDL_sqrt(double x); -extern DECLSPEC float SDLCALL SDL_sqrtf(float x); -extern DECLSPEC double SDLCALL SDL_tan(double x); -extern DECLSPEC float SDLCALL SDL_tanf(float x); - -/* The SDL implementation of iconv() returns these error codes */ -#define SDL_ICONV_ERROR (size_t)-1 -#define SDL_ICONV_E2BIG (size_t)-2 -#define SDL_ICONV_EILSEQ (size_t)-3 -#define SDL_ICONV_EINVAL (size_t)-4 - -/* SDL_iconv_* are now always real symbols/types, not macros or inlined. */ -typedef struct _SDL_iconv_t *SDL_iconv_t; -extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, - const char *fromcode); -extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); -extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, - size_t * inbytesleft, char **outbuf, - size_t * outbytesleft); -/** - * This function converts a string between encodings in one pass, returning a - * string that must be freed with SDL_free() or NULL on error. - */ -extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, - const char *fromcode, - const char *inbuf, - size_t inbytesleft); -#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) -#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) -#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) - -/* force builds using Clang's static analysis tools to use literal C runtime - here, since there are possibly tests that are ineffective otherwise. */ -#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS) -#define SDL_malloc malloc -#define SDL_calloc calloc -#define SDL_realloc realloc -#define SDL_free free -#define SDL_memset memset -#define SDL_memcpy memcpy -#define SDL_memmove memmove -#define SDL_memcmp memcmp -#define SDL_strlen strlen -#define SDL_strlcpy strlcpy -#define SDL_strlcat strlcat -#define SDL_strdup strdup -#define SDL_strchr strchr -#define SDL_strrchr strrchr -#define SDL_strstr strstr -#define SDL_strtokr strtok_r -#define SDL_strcmp strcmp -#define SDL_strncmp strncmp -#define SDL_strcasecmp strcasecmp -#define SDL_strncasecmp strncasecmp -#define SDL_sscanf sscanf -#define SDL_vsscanf vsscanf -#define SDL_snprintf snprintf -#define SDL_vsnprintf vsnprintf -#endif - -SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_BYTECAP(dwords*4) const void *src, size_t dwords) -{ - return SDL_memcpy(dst, src, dwords * 4); -} - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_stdinc_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_surface.h b/thirdparty/include/SDL2/SDL_surface.h deleted file mode 100644 index 0f11d178e..000000000 --- a/thirdparty/include/SDL2/SDL_surface.h +++ /dev/null @@ -1,554 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_surface.h - * - * Header file for ::SDL_Surface definition and management functions. - */ - -#ifndef SDL_surface_h_ -#define SDL_surface_h_ - -#include "SDL_stdinc.h" -#include "SDL_pixels.h" -#include "SDL_rect.h" -#include "SDL_blendmode.h" -#include "SDL_rwops.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \name Surface flags - * - * These are the currently supported flags for the ::SDL_Surface. - * - * \internal - * Used internally (read-only). - */ -/* @{ */ -#define SDL_SWSURFACE 0 /**< Just here for compatibility */ -#define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ -#define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ -#define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ -#define SDL_SIMD_ALIGNED 0x00000008 /**< Surface uses aligned memory */ -/* @} *//* Surface flags */ - -/** - * Evaluates to true if the surface needs to be locked before access. - */ -#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0) - -/** - * \brief A collection of pixels used in software blitting. - * - * \note This structure should be treated as read-only, except for \c pixels, - * which, if not NULL, contains the raw pixel data for the surface. - */ -typedef struct SDL_Surface -{ - Uint32 flags; /**< Read-only */ - SDL_PixelFormat *format; /**< Read-only */ - int w, h; /**< Read-only */ - int pitch; /**< Read-only */ - void *pixels; /**< Read-write */ - - /** Application data associated with the surface */ - void *userdata; /**< Read-write */ - - /** information needed for surfaces requiring locks */ - int locked; /**< Read-only */ - void *lock_data; /**< Read-only */ - - /** clipping information */ - SDL_Rect clip_rect; /**< Read-only */ - - /** info for fast blit mapping to other surfaces */ - struct SDL_BlitMap *map; /**< Private */ - - /** Reference count -- used when freeing surface */ - int refcount; /**< Read-mostly */ -} SDL_Surface; - -/** - * \brief The type of function used for surface blitting functions. - */ -typedef int (SDLCALL *SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect, - struct SDL_Surface * dst, SDL_Rect * dstrect); - -/** - * \brief The formula used for converting between YUV and RGB - */ -typedef enum -{ - SDL_YUV_CONVERSION_JPEG, /**< Full range JPEG */ - SDL_YUV_CONVERSION_BT601, /**< BT.601 (the default) */ - SDL_YUV_CONVERSION_BT709, /**< BT.709 */ - SDL_YUV_CONVERSION_AUTOMATIC /**< BT.601 for SD content, BT.709 for HD content */ -} SDL_YUV_CONVERSION_MODE; - -/** - * Allocate and free an RGB surface. - * - * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. - * If the depth is greater than 8 bits, the pixel format is set using the - * flags '[RGB]mask'. - * - * If the function runs out of memory, it will return NULL. - * - * \param flags The \c flags are obsolete and should be set to 0. - * \param width The width in pixels of the surface to create. - * \param height The height in pixels of the surface to create. - * \param depth The depth in bits of the surface to create. - * \param Rmask The red mask of the surface to create. - * \param Gmask The green mask of the surface to create. - * \param Bmask The blue mask of the surface to create. - * \param Amask The alpha mask of the surface to create. - */ -extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface - (Uint32 flags, int width, int height, int depth, - Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); - -/* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */ -extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat - (Uint32 flags, int width, int height, int depth, Uint32 format); - -extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, - int width, - int height, - int depth, - int pitch, - Uint32 Rmask, - Uint32 Gmask, - Uint32 Bmask, - Uint32 Amask); -extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormatFrom - (void *pixels, int width, int height, int depth, int pitch, Uint32 format); -extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface); - -/** - * \brief Set the palette used by a surface. - * - * \return 0, or -1 if the surface format doesn't use a palette. - * - * \note A single palette can be shared with many surfaces. - */ -extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface, - SDL_Palette * palette); - -/** - * \brief Sets up a surface for directly accessing the pixels. - * - * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write - * to and read from \c surface->pixels, using the pixel format stored in - * \c surface->format. Once you are done accessing the surface, you should - * use SDL_UnlockSurface() to release it. - * - * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates - * to 0, then you can read and write to the surface at any time, and the - * pixel format of the surface will not change. - * - * No operating system or library calls should be made between lock/unlock - * pairs, as critical system locks may be held during this time. - * - * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. - * - * \sa SDL_UnlockSurface() - */ -extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface); -/** \sa SDL_LockSurface() */ -extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface); - -/** - * Load a surface from a seekable SDL data stream (memory or file). - * - * If \c freesrc is non-zero, the stream will be closed after being read. - * - * The new surface should be freed with SDL_FreeSurface(). - * - * \return the new surface, or NULL if there was an error. - */ -extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src, - int freesrc); - -/** - * Load a surface from a file. - * - * Convenience macro. - */ -#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) - -/** - * Save a surface to a seekable SDL data stream (memory or file). - * - * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the - * BMP directly. Other RGB formats with 8-bit or higher get converted to a - * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit - * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are - * not supported. - * - * If \c freedst is non-zero, the stream will be closed after being written. - * - * \return 0 if successful or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_SaveBMP_RW - (SDL_Surface * surface, SDL_RWops * dst, int freedst); - -/** - * Save a surface to a file. - * - * Convenience macro. - */ -#define SDL_SaveBMP(surface, file) \ - SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) - -/** - * \brief Sets the RLE acceleration hint for a surface. - * - * \return 0 on success, or -1 if the surface is not valid - * - * \note If RLE is enabled, colorkey and alpha blending blits are much faster, - * but the surface must be locked before directly accessing the pixels. - */ -extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface, - int flag); - -/** - * \brief Sets the color key (transparent pixel) in a blittable surface. - * - * \param surface The surface to update - * \param flag Non-zero to enable colorkey and 0 to disable colorkey - * \param key The transparent pixel in the native surface format - * - * \return 0 on success, or -1 if the surface is not valid - * - * You can pass SDL_RLEACCEL to enable RLE accelerated blits. - */ -extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface, - int flag, Uint32 key); - -/** - * \brief Returns whether the surface has a color key - * - * \return SDL_TRUE if the surface has a color key, or SDL_FALSE if the surface is NULL or has no color key - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface * surface); - -/** - * \brief Gets the color key (transparent pixel) in a blittable surface. - * - * \param surface The surface to update - * \param key A pointer filled in with the transparent pixel in the native - * surface format - * - * \return 0 on success, or -1 if the surface is not valid or colorkey is not - * enabled. - */ -extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface, - Uint32 * key); - -/** - * \brief Set an additional color value used in blit operations. - * - * \param surface The surface to update. - * \param r The red color value multiplied into blit operations. - * \param g The green color value multiplied into blit operations. - * \param b The blue color value multiplied into blit operations. - * - * \return 0 on success, or -1 if the surface is not valid. - * - * \sa SDL_GetSurfaceColorMod() - */ -extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface, - Uint8 r, Uint8 g, Uint8 b); - - -/** - * \brief Get the additional color value used in blit operations. - * - * \param surface The surface to query. - * \param r A pointer filled in with the current red color value. - * \param g A pointer filled in with the current green color value. - * \param b A pointer filled in with the current blue color value. - * - * \return 0 on success, or -1 if the surface is not valid. - * - * \sa SDL_SetSurfaceColorMod() - */ -extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface, - Uint8 * r, Uint8 * g, - Uint8 * b); - -/** - * \brief Set an additional alpha value used in blit operations. - * - * \param surface The surface to update. - * \param alpha The alpha value multiplied into blit operations. - * - * \return 0 on success, or -1 if the surface is not valid. - * - * \sa SDL_GetSurfaceAlphaMod() - */ -extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface, - Uint8 alpha); - -/** - * \brief Get the additional alpha value used in blit operations. - * - * \param surface The surface to query. - * \param alpha A pointer filled in with the current alpha value. - * - * \return 0 on success, or -1 if the surface is not valid. - * - * \sa SDL_SetSurfaceAlphaMod() - */ -extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface, - Uint8 * alpha); - -/** - * \brief Set the blend mode used for blit operations. - * - * \param surface The surface to update. - * \param blendMode ::SDL_BlendMode to use for blit blending. - * - * \return 0 on success, or -1 if the parameters are not valid. - * - * \sa SDL_GetSurfaceBlendMode() - */ -extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface, - SDL_BlendMode blendMode); - -/** - * \brief Get the blend mode used for blit operations. - * - * \param surface The surface to query. - * \param blendMode A pointer filled in with the current blend mode. - * - * \return 0 on success, or -1 if the surface is not valid. - * - * \sa SDL_SetSurfaceBlendMode() - */ -extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface, - SDL_BlendMode *blendMode); - -/** - * Sets the clipping rectangle for the destination surface in a blit. - * - * If the clip rectangle is NULL, clipping will be disabled. - * - * If the clip rectangle doesn't intersect the surface, the function will - * return SDL_FALSE and blits will be completely clipped. Otherwise the - * function returns SDL_TRUE and blits to the surface will be clipped to - * the intersection of the surface area and the clipping rectangle. - * - * Note that blits are automatically clipped to the edges of the source - * and destination surfaces. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface, - const SDL_Rect * rect); - -/** - * Gets the clipping rectangle for the destination surface in a blit. - * - * \c rect must be a pointer to a valid rectangle which will be filled - * with the correct values. - */ -extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, - SDL_Rect * rect); - -/* - * Creates a new surface identical to the existing surface - */ -extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface); - -/** - * Creates a new surface of the specified format, and then copies and maps - * the given surface to it so the blit of the converted surface will be as - * fast as possible. If this function fails, it returns NULL. - * - * The \c flags parameter is passed to SDL_CreateRGBSurface() and has those - * semantics. You can also pass ::SDL_RLEACCEL in the flags parameter and - * SDL will try to RLE accelerate colorkey and alpha blits in the resulting - * surface. - */ -extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface - (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags); -extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat - (SDL_Surface * src, Uint32 pixel_format, Uint32 flags); - -/** - * \brief Copy a block of pixels of one format to another format - * - * \return 0 on success, or -1 if there was an error - */ -extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, - Uint32 src_format, - const void * src, int src_pitch, - Uint32 dst_format, - void * dst, int dst_pitch); - -/** - * Performs a fast fill of the given rectangle with \c color. - * - * If \c rect is NULL, the whole surface will be filled with \c color. - * - * The color should be a pixel of the format used by the surface, and - * can be generated by the SDL_MapRGB() function. - * - * \return 0 on success, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_FillRect - (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color); -extern DECLSPEC int SDLCALL SDL_FillRects - (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color); - -/** - * Performs a fast blit from the source surface to the destination surface. - * - * This assumes that the source and destination rectangles are - * the same size. If either \c srcrect or \c dstrect are NULL, the entire - * surface (\c src or \c dst) is copied. The final blit rectangles are saved - * in \c srcrect and \c dstrect after all clipping is performed. - * - * \return If the blit is successful, it returns 0, otherwise it returns -1. - * - * The blit function should not be called on a locked surface. - * - * The blit semantics for surfaces with and without blending and colorkey - * are defined as follows: - * \verbatim - RGBA->RGB: - Source surface blend mode set to SDL_BLENDMODE_BLEND: - alpha-blend (using the source alpha-channel and per-surface alpha) - SDL_SRCCOLORKEY ignored. - Source surface blend mode set to SDL_BLENDMODE_NONE: - copy RGB. - if SDL_SRCCOLORKEY set, only copy the pixels matching the - RGB values of the source color key, ignoring alpha in the - comparison. - - RGB->RGBA: - Source surface blend mode set to SDL_BLENDMODE_BLEND: - alpha-blend (using the source per-surface alpha) - Source surface blend mode set to SDL_BLENDMODE_NONE: - copy RGB, set destination alpha to source per-surface alpha value. - both: - if SDL_SRCCOLORKEY set, only copy the pixels matching the - source color key. - - RGBA->RGBA: - Source surface blend mode set to SDL_BLENDMODE_BLEND: - alpha-blend (using the source alpha-channel and per-surface alpha) - SDL_SRCCOLORKEY ignored. - Source surface blend mode set to SDL_BLENDMODE_NONE: - copy all of RGBA to the destination. - if SDL_SRCCOLORKEY set, only copy the pixels matching the - RGB values of the source color key, ignoring alpha in the - comparison. - - RGB->RGB: - Source surface blend mode set to SDL_BLENDMODE_BLEND: - alpha-blend (using the source per-surface alpha) - Source surface blend mode set to SDL_BLENDMODE_NONE: - copy RGB. - both: - if SDL_SRCCOLORKEY set, only copy the pixels matching the - source color key. - \endverbatim - * - * You should call SDL_BlitSurface() unless you know exactly how SDL - * blitting works internally and how to use the other blit functions. - */ -#define SDL_BlitSurface SDL_UpperBlit - -/** - * This is the public blit function, SDL_BlitSurface(), and it performs - * rectangle validation and clipping before passing it to SDL_LowerBlit() - */ -extern DECLSPEC int SDLCALL SDL_UpperBlit - (SDL_Surface * src, const SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); - -/** - * This is a semi-private blit function and it performs low-level surface - * blitting only. - */ -extern DECLSPEC int SDLCALL SDL_LowerBlit - (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); - -/** - * \brief Perform a fast, low quality, stretch blit between two surfaces of the - * same pixel format. - * - * \note This function uses a static buffer, and is not thread-safe. - */ -extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src, - const SDL_Rect * srcrect, - SDL_Surface * dst, - const SDL_Rect * dstrect); - -#define SDL_BlitScaled SDL_UpperBlitScaled - -/** - * This is the public scaled blit function, SDL_BlitScaled(), and it performs - * rectangle validation and clipping before passing it to SDL_LowerBlitScaled() - */ -extern DECLSPEC int SDLCALL SDL_UpperBlitScaled - (SDL_Surface * src, const SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); - -/** - * This is a semi-private blit function and it performs low-level surface - * scaled blitting only. - */ -extern DECLSPEC int SDLCALL SDL_LowerBlitScaled - (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); - -/** - * \brief Set the YUV conversion mode - */ -extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode); - -/** - * \brief Get the YUV conversion mode - */ -extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void); - -/** - * \brief Get the YUV conversion mode, returning the correct mode for the resolution when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC - */ -extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_surface_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_system.h b/thirdparty/include/SDL2/SDL_system.h deleted file mode 100644 index d7974eb03..000000000 --- a/thirdparty/include/SDL2/SDL_system.h +++ /dev/null @@ -1,316 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_system.h - * - * Include file for platform specific SDL API functions - */ - -#ifndef SDL_system_h_ -#define SDL_system_h_ - -#include "SDL_stdinc.h" -#include "SDL_keyboard.h" -#include "SDL_render.h" -#include "SDL_video.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - -/* Platform specific functions for Windows */ -#ifdef __WIN32__ - -/** - \brief Set a function that is called for every windows message, before TranslateMessage() -*/ -typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam); -extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata); - -/** - \brief Returns the D3D9 adapter index that matches the specified display index. - - This adapter index can be passed to IDirect3D9::CreateDevice and controls - on which monitor a full screen application will appear. -*/ -extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex ); - -typedef struct IDirect3DDevice9 IDirect3DDevice9; -/** - \brief Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. - - Once you are done using the device, you should release it to avoid a resource leak. - */ -extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer); - -/** - \brief Returns the DXGI Adapter and Output indices for the specified display index. - - These can be passed to EnumAdapters and EnumOutputs respectively to get the objects - required to create a DX10 or DX11 device and swap chain. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex ); - -#endif /* __WIN32__ */ - - -/* Platform specific functions for Linux */ -#ifdef __LINUX__ - -/** - \brief Sets the UNIX nice value for a thread, using setpriority() if possible, and RealtimeKit if available. - - \return 0 on success, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int priority); - -#endif /* __LINUX__ */ - -/* Platform specific functions for iOS */ -#ifdef __IPHONEOS__ - -#define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam) -extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam); - -#define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled) -extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled); - -#endif /* __IPHONEOS__ */ - - -/* Platform specific functions for Android */ -#ifdef __ANDROID__ - -/** - \brief Get the JNI environment for the current thread - - This returns JNIEnv*, but the prototype is void* so we don't need jni.h - */ -extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv(void); - -/** - \brief Get the SDL Activity object for the application - - This returns jobject, but the prototype is void* so we don't need jni.h - The jobject returned by SDL_AndroidGetActivity is a local reference. - It is the caller's responsibility to properly release it - (using env->Push/PopLocalFrame or manually with env->DeleteLocalRef) - */ -extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(void); - -/** - \brief Return API level of the current device - - API level 29: Android 10 - API level 28: Android 9 - API level 27: Android 8.1 - API level 26: Android 8.0 - API level 25: Android 7.1 - API level 24: Android 7.0 - API level 23: Android 6.0 - API level 22: Android 5.1 - API level 21: Android 5.0 - API level 20: Android 4.4W - API level 19: Android 4.4 - API level 18: Android 4.3 - API level 17: Android 4.2 - API level 16: Android 4.1 - API level 15: Android 4.0.3 - API level 14: Android 4.0 - API level 13: Android 3.2 - API level 12: Android 3.1 - API level 11: Android 3.0 - API level 10: Android 2.3.3 - */ -extern DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void); - -/** - \brief Return true if the application is running on Android TV - */ -extern DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void); - -/** - \brief Return true if the application is running on a Chromebook - */ -extern DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void); - -/** - \brief Return true is the application is running on a Samsung DeX docking station - */ -extern DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void); - -/** - \brief Trigger the Android system back button behavior. - */ -extern DECLSPEC void SDLCALL SDL_AndroidBackButton(void); - -/** - See the official Android developer guide for more information: - http://developer.android.com/guide/topics/data/data-storage.html -*/ -#define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01 -#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02 - -/** - \brief Get the path used for internal storage for this application. - - This path is unique to your application and cannot be written to - by other applications. - */ -extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath(void); - -/** - \brief Get the current state of external storage, a bitmask of these values: - SDL_ANDROID_EXTERNAL_STORAGE_READ - SDL_ANDROID_EXTERNAL_STORAGE_WRITE - - If external storage is currently unavailable, this will return 0. -*/ -extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState(void); - -/** - \brief Get the path used for external storage for this application. - - This path is unique to your application, but is public and can be - written to by other applications. - */ -extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(void); - -#endif /* __ANDROID__ */ - -/* Platform specific functions for WinRT */ -#ifdef __WINRT__ - -/** - * \brief WinRT / Windows Phone path types - */ -typedef enum -{ - /** \brief The installed app's root directory. - Files here are likely to be read-only. */ - SDL_WINRT_PATH_INSTALLED_LOCATION, - - /** \brief The app's local data store. Files may be written here */ - SDL_WINRT_PATH_LOCAL_FOLDER, - - /** \brief The app's roaming data store. Unsupported on Windows Phone. - Files written here may be copied to other machines via a network - connection. - */ - SDL_WINRT_PATH_ROAMING_FOLDER, - - /** \brief The app's temporary data store. Unsupported on Windows Phone. - Files written here may be deleted at any time. */ - SDL_WINRT_PATH_TEMP_FOLDER -} SDL_WinRT_Path; - - -/** - * \brief WinRT Device Family - */ -typedef enum -{ - /** \brief Unknown family */ - SDL_WINRT_DEVICEFAMILY_UNKNOWN, - - /** \brief Desktop family*/ - SDL_WINRT_DEVICEFAMILY_DESKTOP, - - /** \brief Mobile family (for example smartphone) */ - SDL_WINRT_DEVICEFAMILY_MOBILE, - - /** \brief XBox family */ - SDL_WINRT_DEVICEFAMILY_XBOX, -} SDL_WinRT_DeviceFamily; - - -/** - * \brief Retrieves a WinRT defined path on the local file system - * - * \note Documentation on most app-specific path types on WinRT - * can be found on MSDN, at the URL: - * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx - * - * \param pathType The type of path to retrieve. - * \return A UCS-2 string (16-bit, wide-char) containing the path, or NULL - * if the path is not available for any reason. Not all paths are - * available on all versions of Windows. This is especially true on - * Windows Phone. Check the documentation for the given - * SDL_WinRT_Path for more information on which path types are - * supported where. - */ -extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType); - -/** - * \brief Retrieves a WinRT defined path on the local file system - * - * \note Documentation on most app-specific path types on WinRT - * can be found on MSDN, at the URL: - * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx - * - * \param pathType The type of path to retrieve. - * \return A UTF-8 string (8-bit, multi-byte) containing the path, or NULL - * if the path is not available for any reason. Not all paths are - * available on all versions of Windows. This is especially true on - * Windows Phone. Check the documentation for the given - * SDL_WinRT_Path for more information on which path types are - * supported where. - */ -extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType); - -/** - * \brief Detects the device family of WinRT plattform on runtime - * - * \return Device family - */ -extern DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily(); - -#endif /* __WINRT__ */ - -/** - \brief Return true if the current device is a tablet. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_IsTablet(void); - -/* Functions used by iOS application delegates to notify SDL about state changes */ -extern DECLSPEC void SDLCALL SDL_OnApplicationWillTerminate(void); -extern DECLSPEC void SDLCALL SDL_OnApplicationDidReceiveMemoryWarning(void); -extern DECLSPEC void SDLCALL SDL_OnApplicationWillResignActive(void); -extern DECLSPEC void SDLCALL SDL_OnApplicationDidEnterBackground(void); -extern DECLSPEC void SDLCALL SDL_OnApplicationWillEnterForeground(void); -extern DECLSPEC void SDLCALL SDL_OnApplicationDidBecomeActive(void); -#ifdef __IPHONEOS__ -extern DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void); -#endif - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_system_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_syswm.h b/thirdparty/include/SDL2/SDL_syswm.h deleted file mode 100644 index e877b2aad..000000000 --- a/thirdparty/include/SDL2/SDL_syswm.h +++ /dev/null @@ -1,331 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_syswm.h - * - * Include file for SDL custom system window manager hooks. - */ - -#ifndef SDL_syswm_h_ -#define SDL_syswm_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_video.h" -#include "SDL_version.h" - -/** - * \brief SDL_syswm.h - * - * Your application has access to a special type of event ::SDL_SYSWMEVENT, - * which contains window-manager specific information and arrives whenever - * an unhandled window event occurs. This event is ignored by default, but - * you can enable it with SDL_EventState(). - */ -struct SDL_SysWMinfo; - -#if !defined(SDL_PROTOTYPES_ONLY) - -#if defined(SDL_VIDEO_DRIVER_WINDOWS) -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#ifndef NOMINMAX /* don't define min() and max(). */ -#define NOMINMAX -#endif -#include -#endif - -#if defined(SDL_VIDEO_DRIVER_WINRT) -#include -#endif - -/* This is the structure for custom window manager events */ -#if defined(SDL_VIDEO_DRIVER_X11) -#if defined(__APPLE__) && defined(__MACH__) -/* conflicts with Quickdraw.h */ -#define Cursor X11Cursor -#endif - -#include -#include - -#if defined(__APPLE__) && defined(__MACH__) -/* matches the re-define above */ -#undef Cursor -#endif - -#endif /* defined(SDL_VIDEO_DRIVER_X11) */ - -#if defined(SDL_VIDEO_DRIVER_DIRECTFB) -#include -#endif - -#if defined(SDL_VIDEO_DRIVER_COCOA) -#ifdef __OBJC__ -@class NSWindow; -#else -typedef struct _NSWindow NSWindow; -#endif -#endif - -#if defined(SDL_VIDEO_DRIVER_UIKIT) -#ifdef __OBJC__ -#include -#else -typedef struct _UIWindow UIWindow; -typedef struct _UIViewController UIViewController; -#endif -typedef Uint32 GLuint; -#endif - -#if defined(SDL_VIDEO_DRIVER_ANDROID) -typedef struct ANativeWindow ANativeWindow; -typedef void *EGLSurface; -#endif - -#if defined(SDL_VIDEO_DRIVER_VIVANTE) -#include "SDL_egl.h" -#endif -#endif /* SDL_PROTOTYPES_ONLY */ - - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(SDL_PROTOTYPES_ONLY) -/** - * These are the various supported windowing subsystems - */ -typedef enum -{ - SDL_SYSWM_UNKNOWN, - SDL_SYSWM_WINDOWS, - SDL_SYSWM_X11, - SDL_SYSWM_DIRECTFB, - SDL_SYSWM_COCOA, - SDL_SYSWM_UIKIT, - SDL_SYSWM_WAYLAND, - SDL_SYSWM_MIR, /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ - SDL_SYSWM_WINRT, - SDL_SYSWM_ANDROID, - SDL_SYSWM_VIVANTE, - SDL_SYSWM_OS2, - SDL_SYSWM_HAIKU -} SDL_SYSWM_TYPE; - -/** - * The custom event structure. - */ -struct SDL_SysWMmsg -{ - SDL_version version; - SDL_SYSWM_TYPE subsystem; - union - { -#if defined(SDL_VIDEO_DRIVER_WINDOWS) - struct { - HWND hwnd; /**< The window for the message */ - UINT msg; /**< The type of message */ - WPARAM wParam; /**< WORD message parameter */ - LPARAM lParam; /**< LONG message parameter */ - } win; -#endif -#if defined(SDL_VIDEO_DRIVER_X11) - struct { - XEvent event; - } x11; -#endif -#if defined(SDL_VIDEO_DRIVER_DIRECTFB) - struct { - DFBEvent event; - } dfb; -#endif -#if defined(SDL_VIDEO_DRIVER_COCOA) - struct - { - /* Latest version of Xcode clang complains about empty structs in C v. C++: - error: empty struct has size 0 in C, size 1 in C++ - */ - int dummy; - /* No Cocoa window events yet */ - } cocoa; -#endif -#if defined(SDL_VIDEO_DRIVER_UIKIT) - struct - { - int dummy; - /* No UIKit window events yet */ - } uikit; -#endif -#if defined(SDL_VIDEO_DRIVER_VIVANTE) - struct - { - int dummy; - /* No Vivante window events yet */ - } vivante; -#endif - /* Can't have an empty union */ - int dummy; - } msg; -}; - -/** - * The custom window manager information structure. - * - * When this structure is returned, it holds information about which - * low level system it is using, and will be one of SDL_SYSWM_TYPE. - */ -struct SDL_SysWMinfo -{ - SDL_version version; - SDL_SYSWM_TYPE subsystem; - union - { -#if defined(SDL_VIDEO_DRIVER_WINDOWS) - struct - { - HWND window; /**< The window handle */ - HDC hdc; /**< The window device context */ - HINSTANCE hinstance; /**< The instance handle */ - } win; -#endif -#if defined(SDL_VIDEO_DRIVER_WINRT) - struct - { - IInspectable * window; /**< The WinRT CoreWindow */ - } winrt; -#endif -#if defined(SDL_VIDEO_DRIVER_X11) - struct - { - Display *display; /**< The X11 display */ - Window window; /**< The X11 window */ - } x11; -#endif -#if defined(SDL_VIDEO_DRIVER_DIRECTFB) - struct - { - IDirectFB *dfb; /**< The directfb main interface */ - IDirectFBWindow *window; /**< The directfb window handle */ - IDirectFBSurface *surface; /**< The directfb client surface */ - } dfb; -#endif -#if defined(SDL_VIDEO_DRIVER_COCOA) - struct - { -#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) - NSWindow __unsafe_unretained *window; /**< The Cocoa window */ -#else - NSWindow *window; /**< The Cocoa window */ -#endif - } cocoa; -#endif -#if defined(SDL_VIDEO_DRIVER_UIKIT) - struct - { -#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) - UIWindow __unsafe_unretained *window; /**< The UIKit window */ -#else - UIWindow *window; /**< The UIKit window */ -#endif - GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */ - GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */ - GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */ - } uikit; -#endif -#if defined(SDL_VIDEO_DRIVER_WAYLAND) - struct - { - struct wl_display *display; /**< Wayland display */ - struct wl_surface *surface; /**< Wayland surface */ - struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */ - } wl; -#endif -#if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ - struct - { - void *connection; /**< Mir display server connection */ - void *surface; /**< Mir surface */ - } mir; -#endif - -#if defined(SDL_VIDEO_DRIVER_ANDROID) - struct - { - ANativeWindow *window; - EGLSurface surface; - } android; -#endif - -#if defined(SDL_VIDEO_DRIVER_VIVANTE) - struct - { - EGLNativeDisplayType display; - EGLNativeWindowType window; - } vivante; -#endif - - /* Make sure this union is always 64 bytes (8 64-bit pointers). */ - /* Be careful not to overflow this if you add a new target! */ - Uint8 dummy[64]; - } info; -}; - -#endif /* SDL_PROTOTYPES_ONLY */ - -typedef struct SDL_SysWMinfo SDL_SysWMinfo; - -/* Function prototypes */ -/** - * \brief This function allows access to driver-dependent window information. - * - * \param window The window about which information is being requested - * \param info This structure must be initialized with the SDL version, and is - * then filled in with information about the given window. - * - * \return SDL_TRUE if the function is implemented and the version member of - * the \c info struct is valid, SDL_FALSE otherwise. - * - * You typically use this function like this: - * \code - * SDL_SysWMinfo info; - * SDL_VERSION(&info.version); - * if ( SDL_GetWindowWMInfo(window, &info) ) { ... } - * \endcode - */ -extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, - SDL_SysWMinfo * info); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_syswm_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test.h b/thirdparty/include/SDL2/SDL_test.h deleted file mode 100644 index 7095427ae..000000000 --- a/thirdparty/include/SDL2/SDL_test.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -#ifndef SDL_test_h_ -#define SDL_test_h_ - -#include "SDL.h" -#include "SDL_test_assert.h" -#include "SDL_test_common.h" -#include "SDL_test_compare.h" -#include "SDL_test_crc32.h" -#include "SDL_test_font.h" -#include "SDL_test_fuzzer.h" -#include "SDL_test_harness.h" -#include "SDL_test_images.h" -#include "SDL_test_log.h" -#include "SDL_test_md5.h" -#include "SDL_test_memory.h" -#include "SDL_test_random.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Global definitions */ - -/* - * Note: Maximum size of SDLTest log message is less than SDL's limit - * to ensure we can fit additional information such as the timestamp. - */ -#define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_assert.h b/thirdparty/include/SDL2/SDL_test_assert.h deleted file mode 100644 index 19b90950e..000000000 --- a/thirdparty/include/SDL2/SDL_test_assert.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test_assert.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -/* - * - * Assert API for test code and test cases - * - */ - -#ifndef SDL_test_assert_h_ -#define SDL_test_assert_h_ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Fails the assert. - */ -#define ASSERT_FAIL 0 - -/** - * \brief Passes the assert. - */ -#define ASSERT_PASS 1 - -/** - * \brief Assert that logs and break execution flow on failures. - * - * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). - * \param assertDescription Message to log with the assert describing it. - */ -void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); - -/** - * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. - * - * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). - * \param assertDescription Message to log with the assert describing it. - * - * \returns Returns the assertCondition so it can be used to externally to break execution flow if desired. - */ -int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); - -/** - * \brief Explicitly pass without checking an assertion condition. Updates assertion counter. - * - * \param assertDescription Message to log with the assert describing it. - */ -void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1); - -/** - * \brief Resets the assert summary counters to zero. - */ -void SDLTest_ResetAssertSummary(void); - -/** - * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. - */ -void SDLTest_LogAssertSummary(void); - - -/** - * \brief Converts the current assert summary state to a test result. - * - * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT - */ -int SDLTest_AssertSummaryToTestResult(void); - -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_assert_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_common.h b/thirdparty/include/SDL2/SDL_test_common.h deleted file mode 100644 index 3ad203055..000000000 --- a/thirdparty/include/SDL2/SDL_test_common.h +++ /dev/null @@ -1,218 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test_common.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -/* Ported from original test\common.h file. */ - -#ifndef SDL_test_common_h_ -#define SDL_test_common_h_ - -#include "SDL.h" - -#if defined(__PSP__) -#define DEFAULT_WINDOW_WIDTH 480 -#define DEFAULT_WINDOW_HEIGHT 272 -#else -#define DEFAULT_WINDOW_WIDTH 640 -#define DEFAULT_WINDOW_HEIGHT 480 -#endif - -#define VERBOSE_VIDEO 0x00000001 -#define VERBOSE_MODES 0x00000002 -#define VERBOSE_RENDER 0x00000004 -#define VERBOSE_EVENT 0x00000008 -#define VERBOSE_AUDIO 0x00000010 - -typedef struct -{ - /* SDL init flags */ - char **argv; - Uint32 flags; - Uint32 verbose; - - /* Video info */ - const char *videodriver; - int display; - const char *window_title; - const char *window_icon; - Uint32 window_flags; - int window_x; - int window_y; - int window_w; - int window_h; - int window_minW; - int window_minH; - int window_maxW; - int window_maxH; - int logical_w; - int logical_h; - float scale; - int depth; - int refresh_rate; - int num_windows; - SDL_Window **windows; - - /* Renderer info */ - const char *renderdriver; - Uint32 render_flags; - SDL_bool skip_renderer; - SDL_Renderer **renderers; - SDL_Texture **targets; - - /* Audio info */ - const char *audiodriver; - SDL_AudioSpec audiospec; - - /* GL settings */ - int gl_red_size; - int gl_green_size; - int gl_blue_size; - int gl_alpha_size; - int gl_buffer_size; - int gl_depth_size; - int gl_stencil_size; - int gl_double_buffer; - int gl_accum_red_size; - int gl_accum_green_size; - int gl_accum_blue_size; - int gl_accum_alpha_size; - int gl_stereo; - int gl_multisamplebuffers; - int gl_multisamplesamples; - int gl_retained_backing; - int gl_accelerated; - int gl_major_version; - int gl_minor_version; - int gl_debug; - int gl_profile_mask; -} SDLTest_CommonState; - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Function prototypes */ - -/** - * \brief Parse command line parameters and create common state. - * - * \param argv Array of command line parameters - * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO) - * - * \returns Returns a newly allocated common state object. - */ -SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); - -/** - * \brief Process one common argument. - * - * \param state The common state describing the test window to create. - * \param index The index of the argument to process in argv[]. - * - * \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error. - */ -int SDLTest_CommonArg(SDLTest_CommonState * state, int index); - - -/** - * \brief Logs command line usage info. - * - * This logs the appropriate command line options for the subsystems in use - * plus other common options, and then any application-specific options. - * This uses the SDL_Log() function and splits up output to be friendly to - * 80-character-wide terminals. - * - * \param state The common state describing the test window for the app. - * \param argv0 argv[0], as passed to main/SDL_main. - * \param options an array of strings for application specific options. The last element of the array should be NULL. - */ -void SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const char **options); - -/** - * \brief Returns common usage information - * - * You should (probably) be using SDLTest_CommonLogUsage() instead, but this - * function remains for binary compatibility. Strings returned from this - * function are valid until SDLTest_CommonQuit() is called, in which case - * those strings' memory is freed and can no longer be used. - * - * \param state The common state describing the test window to create. - * \returns String with usage information - */ -const char *SDLTest_CommonUsage(SDLTest_CommonState * state); - -/** - * \brief Open test window. - * - * \param state The common state describing the test window to create. - * - * \returns True if initialization succeeded, false otherwise - */ -SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state); - -/** - * \brief Easy argument handling when test app doesn't need any custom args. - * - * \param state The common state describing the test window to create. - * \param argc argc, as supplied to SDL_main - * \param argv argv, as supplied to SDL_main - * - * \returns False if app should quit, true otherwise. - */ -SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState * state, const int argc, char **argv); - -/** - * \brief Common event handler for test windows. - * - * \param state The common state used to create test window. - * \param event The event to handle. - * \param done Flag indicating we are done. - * - */ -void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done); - -/** - * \brief Close test window. - * - * \param state The common state used to create test window. - * - */ -void SDLTest_CommonQuit(SDLTest_CommonState * state); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_common_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_compare.h b/thirdparty/include/SDL2/SDL_test_compare.h deleted file mode 100644 index 38b22bb3b..000000000 --- a/thirdparty/include/SDL2/SDL_test_compare.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test_compare.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -/* - - Defines comparison functions (i.e. for surfaces). - -*/ - -#ifndef SDL_test_compare_h_ -#define SDL_test_compare_h_ - -#include "SDL.h" - -#include "SDL_test_images.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Compares a surface and with reference image data for equality - * - * \param surface Surface used in comparison - * \param referenceSurface Test Surface used in comparison - * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy. - * - * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. - */ -int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_compare_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_crc32.h b/thirdparty/include/SDL2/SDL_test_crc32.h deleted file mode 100644 index 611066abf..000000000 --- a/thirdparty/include/SDL2/SDL_test_crc32.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test_crc32.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -/* - - Implements CRC32 calculations (default output is Perl String::CRC32 compatible). - -*/ - -#ifndef SDL_test_crc32_h_ -#define SDL_test_crc32_h_ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - -/* ------------ Definitions --------- */ - -/* Definition shared by all CRC routines */ - -#ifndef CrcUint32 - #define CrcUint32 unsigned int -#endif -#ifndef CrcUint8 - #define CrcUint8 unsigned char -#endif - -#ifdef ORIGINAL_METHOD - #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ -#else - #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ -#endif - -/** - * Data structure for CRC32 (checksum) computation - */ - typedef struct { - CrcUint32 crc32_table[256]; /* CRC table */ - } SDLTest_Crc32Context; - -/* ---------- Function Prototypes ------------- */ - -/** - * \brief Initialize the CRC context - * - * Note: The function initializes the crc table required for all crc calculations. - * - * \param crcContext pointer to context variable - * - * \returns 0 for OK, -1 on error - * - */ - int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext); - - -/** - * \brief calculate a crc32 from a data block - * - * \param crcContext pointer to context variable - * \param inBuf input buffer to checksum - * \param inLen length of input buffer - * \param crc32 pointer to Uint32 to store the final CRC into - * - * \returns 0 for OK, -1 on error - * - */ -int SDLTest_Crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); - -/* Same routine broken down into three steps */ -int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); -int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); -int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); - - -/** - * \brief clean up CRC context - * - * \param crcContext pointer to context variable - * - * \returns 0 for OK, -1 on error - * -*/ - -int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_crc32_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_font.h b/thirdparty/include/SDL2/SDL_test_font.h deleted file mode 100644 index dc4ce6dd6..000000000 --- a/thirdparty/include/SDL2/SDL_test_font.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test_font.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -#ifndef SDL_test_font_h_ -#define SDL_test_font_h_ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Function prototypes */ - -#define FONT_CHARACTER_SIZE 8 - -/** - * \brief Draw a string in the currently set font. - * - * \param renderer The renderer to draw on. - * \param x The X coordinate of the upper left corner of the character. - * \param y The Y coordinate of the upper left corner of the character. - * \param c The character to draw. - * - * \returns Returns 0 on success, -1 on failure. - */ -int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c); - -/** - * \brief Draw a string in the currently set font. - * - * \param renderer The renderer to draw on. - * \param x The X coordinate of the upper left corner of the string. - * \param y The Y coordinate of the upper left corner of the string. - * \param s The string to draw. - * - * \returns Returns 0 on success, -1 on failure. - */ -int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s); - - -/** - * \brief Cleanup textures used by font drawing functions. - */ -void SDLTest_CleanupTextDrawing(void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_font_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_fuzzer.h b/thirdparty/include/SDL2/SDL_test_fuzzer.h deleted file mode 100644 index cb5a17a10..000000000 --- a/thirdparty/include/SDL2/SDL_test_fuzzer.h +++ /dev/null @@ -1,384 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test_fuzzer.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -/* - - Data generators for fuzzing test data in a reproducible way. - -*/ - -#ifndef SDL_test_fuzzer_h_ -#define SDL_test_fuzzer_h_ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - -/* - Based on GSOC code by Markus Kauppila -*/ - - -/** - * \file - * Note: The fuzzer implementation uses a static instance of random context - * internally which makes it thread-UNsafe. - */ - -/** - * Initializes the fuzzer for a test - * - * \param execKey Execution "Key" that initializes the random number generator uniquely for the test. - * - */ -void SDLTest_FuzzerInit(Uint64 execKey); - - -/** - * Returns a random Uint8 - * - * \returns Generated integer - */ -Uint8 SDLTest_RandomUint8(void); - -/** - * Returns a random Sint8 - * - * \returns Generated signed integer - */ -Sint8 SDLTest_RandomSint8(void); - - -/** - * Returns a random Uint16 - * - * \returns Generated integer - */ -Uint16 SDLTest_RandomUint16(void); - -/** - * Returns a random Sint16 - * - * \returns Generated signed integer - */ -Sint16 SDLTest_RandomSint16(void); - - -/** - * Returns a random integer - * - * \returns Generated integer - */ -Sint32 SDLTest_RandomSint32(void); - - -/** - * Returns a random positive integer - * - * \returns Generated integer - */ -Uint32 SDLTest_RandomUint32(void); - -/** - * Returns random Uint64. - * - * \returns Generated integer - */ -Uint64 SDLTest_RandomUint64(void); - - -/** - * Returns random Sint64. - * - * \returns Generated signed integer - */ -Sint64 SDLTest_RandomSint64(void); - -/** - * \returns random float in range [0.0 - 1.0[ - */ -float SDLTest_RandomUnitFloat(void); - -/** - * \returns random double in range [0.0 - 1.0[ - */ -double SDLTest_RandomUnitDouble(void); - -/** - * \returns random float. - * - */ -float SDLTest_RandomFloat(void); - -/** - * \returns random double. - * - */ -double SDLTest_RandomDouble(void); - -/** - * Returns a random boundary value for Uint8 within the given boundaries. - * Boundaries are inclusive, see the usage examples below. If validDomain - * is true, the function will only return valid boundaries, otherwise non-valid - * boundaries are also possible. - * If boundary1 > boundary2, the values are swapped - * - * Usage examples: - * RandomUint8BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 - * RandomUint8BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 - * RandomUint8BoundaryValue(0, 99, SDL_FALSE) returns 100 - * RandomUint8BoundaryValue(0, 255, SDL_FALSE) returns 0 (error set) - * - * \param boundary1 Lower boundary limit - * \param boundary2 Upper boundary limit - * \param validDomain Should the generated boundary be valid (=within the bounds) or not? - * - * \returns Random boundary value for the given range and domain or 0 with error set - */ -Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain); - -/** - * Returns a random boundary value for Uint16 within the given boundaries. - * Boundaries are inclusive, see the usage examples below. If validDomain - * is true, the function will only return valid boundaries, otherwise non-valid - * boundaries are also possible. - * If boundary1 > boundary2, the values are swapped - * - * Usage examples: - * RandomUint16BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 - * RandomUint16BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 - * RandomUint16BoundaryValue(0, 99, SDL_FALSE) returns 100 - * RandomUint16BoundaryValue(0, 0xFFFF, SDL_FALSE) returns 0 (error set) - * - * \param boundary1 Lower boundary limit - * \param boundary2 Upper boundary limit - * \param validDomain Should the generated boundary be valid (=within the bounds) or not? - * - * \returns Random boundary value for the given range and domain or 0 with error set - */ -Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain); - -/** - * Returns a random boundary value for Uint32 within the given boundaries. - * Boundaries are inclusive, see the usage examples below. If validDomain - * is true, the function will only return valid boundaries, otherwise non-valid - * boundaries are also possible. - * If boundary1 > boundary2, the values are swapped - * - * Usage examples: - * RandomUint32BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 - * RandomUint32BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 - * RandomUint32BoundaryValue(0, 99, SDL_FALSE) returns 100 - * RandomUint32BoundaryValue(0, 0xFFFFFFFF, SDL_FALSE) returns 0 (with error set) - * - * \param boundary1 Lower boundary limit - * \param boundary2 Upper boundary limit - * \param validDomain Should the generated boundary be valid (=within the bounds) or not? - * - * \returns Random boundary value for the given range and domain or 0 with error set - */ -Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain); - -/** - * Returns a random boundary value for Uint64 within the given boundaries. - * Boundaries are inclusive, see the usage examples below. If validDomain - * is true, the function will only return valid boundaries, otherwise non-valid - * boundaries are also possible. - * If boundary1 > boundary2, the values are swapped - * - * Usage examples: - * RandomUint64BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 - * RandomUint64BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 - * RandomUint64BoundaryValue(0, 99, SDL_FALSE) returns 100 - * RandomUint64BoundaryValue(0, 0xFFFFFFFFFFFFFFFF, SDL_FALSE) returns 0 (with error set) - * - * \param boundary1 Lower boundary limit - * \param boundary2 Upper boundary limit - * \param validDomain Should the generated boundary be valid (=within the bounds) or not? - * - * \returns Random boundary value for the given range and domain or 0 with error set - */ -Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain); - -/** - * Returns a random boundary value for Sint8 within the given boundaries. - * Boundaries are inclusive, see the usage examples below. If validDomain - * is true, the function will only return valid boundaries, otherwise non-valid - * boundaries are also possible. - * If boundary1 > boundary2, the values are swapped - * - * Usage examples: - * RandomSint8BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 - * RandomSint8BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 - * RandomSint8BoundaryValue(SINT8_MIN, 99, SDL_FALSE) returns 100 - * RandomSint8BoundaryValue(SINT8_MIN, SINT8_MAX, SDL_FALSE) returns SINT8_MIN (== error value) with error set - * - * \param boundary1 Lower boundary limit - * \param boundary2 Upper boundary limit - * \param validDomain Should the generated boundary be valid (=within the bounds) or not? - * - * \returns Random boundary value for the given range and domain or SINT8_MIN with error set - */ -Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain); - - -/** - * Returns a random boundary value for Sint16 within the given boundaries. - * Boundaries are inclusive, see the usage examples below. If validDomain - * is true, the function will only return valid boundaries, otherwise non-valid - * boundaries are also possible. - * If boundary1 > boundary2, the values are swapped - * - * Usage examples: - * RandomSint16BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 - * RandomSint16BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 - * RandomSint16BoundaryValue(SINT16_MIN, 99, SDL_FALSE) returns 100 - * RandomSint16BoundaryValue(SINT16_MIN, SINT16_MAX, SDL_FALSE) returns SINT16_MIN (== error value) with error set - * - * \param boundary1 Lower boundary limit - * \param boundary2 Upper boundary limit - * \param validDomain Should the generated boundary be valid (=within the bounds) or not? - * - * \returns Random boundary value for the given range and domain or SINT16_MIN with error set - */ -Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain); - -/** - * Returns a random boundary value for Sint32 within the given boundaries. - * Boundaries are inclusive, see the usage examples below. If validDomain - * is true, the function will only return valid boundaries, otherwise non-valid - * boundaries are also possible. - * If boundary1 > boundary2, the values are swapped - * - * Usage examples: - * RandomSint32BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 - * RandomSint32BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 - * RandomSint32BoundaryValue(SINT32_MIN, 99, SDL_FALSE) returns 100 - * RandomSint32BoundaryValue(SINT32_MIN, SINT32_MAX, SDL_FALSE) returns SINT32_MIN (== error value) - * - * \param boundary1 Lower boundary limit - * \param boundary2 Upper boundary limit - * \param validDomain Should the generated boundary be valid (=within the bounds) or not? - * - * \returns Random boundary value for the given range and domain or SINT32_MIN with error set - */ -Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain); - -/** - * Returns a random boundary value for Sint64 within the given boundaries. - * Boundaries are inclusive, see the usage examples below. If validDomain - * is true, the function will only return valid boundaries, otherwise non-valid - * boundaries are also possible. - * If boundary1 > boundary2, the values are swapped - * - * Usage examples: - * RandomSint64BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 - * RandomSint64BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 - * RandomSint64BoundaryValue(SINT64_MIN, 99, SDL_FALSE) returns 100 - * RandomSint64BoundaryValue(SINT64_MIN, SINT64_MAX, SDL_FALSE) returns SINT64_MIN (== error value) and error set - * - * \param boundary1 Lower boundary limit - * \param boundary2 Upper boundary limit - * \param validDomain Should the generated boundary be valid (=within the bounds) or not? - * - * \returns Random boundary value for the given range and domain or SINT64_MIN with error set - */ -Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain); - - -/** - * Returns integer in range [min, max] (inclusive). - * Min and max values can be negative values. - * If Max in smaller than min, then the values are swapped. - * Min and max are the same value, that value will be returned. - * - * \param min Minimum inclusive value of returned random number - * \param max Maximum inclusive value of returned random number - * - * \returns Generated random integer in range - */ -Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max); - - -/** - * Generates random null-terminated string. The minimum length for - * the string is 1 character, maximum length for the string is 255 - * characters and it can contain ASCII characters from 32 to 126. - * - * Note: Returned string needs to be deallocated. - * - * \returns Newly allocated random string; or NULL if length was invalid or string could not be allocated. - */ -char * SDLTest_RandomAsciiString(void); - - -/** - * Generates random null-terminated string. The maximum length for - * the string is defined by the maxLength parameter. - * String can contain ASCII characters from 32 to 126. - * - * Note: Returned string needs to be deallocated. - * - * \param maxLength The maximum length of the generated string. - * - * \returns Newly allocated random string; or NULL if maxLength was invalid or string could not be allocated. - */ -char * SDLTest_RandomAsciiStringWithMaximumLength(int maxLength); - - -/** - * Generates random null-terminated string. The length for - * the string is defined by the size parameter. - * String can contain ASCII characters from 32 to 126. - * - * Note: Returned string needs to be deallocated. - * - * \param size The length of the generated string - * - * \returns Newly allocated random string; or NULL if size was invalid or string could not be allocated. - */ -char * SDLTest_RandomAsciiStringOfSize(int size); - -/** - * Returns the invocation count for the fuzzer since last ...FuzzerInit. - */ -int SDLTest_GetFuzzerInvocationCount(void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_fuzzer_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_harness.h b/thirdparty/include/SDL2/SDL_test_harness.h deleted file mode 100644 index 97d981281..000000000 --- a/thirdparty/include/SDL2/SDL_test_harness.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test_harness.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -/* - Defines types for test case definitions and the test execution harness API. - - Based on original GSOC code by Markus Kauppila -*/ - -#ifndef SDL_test_h_arness_h -#define SDL_test_h_arness_h - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - -/* ! Definitions for test case structures */ -#define TEST_ENABLED 1 -#define TEST_DISABLED 0 - -/* ! Definition of all the possible test return values of the test case method */ -#define TEST_ABORTED -1 -#define TEST_STARTED 0 -#define TEST_COMPLETED 1 -#define TEST_SKIPPED 2 - -/* ! Definition of all the possible test results for the harness */ -#define TEST_RESULT_PASSED 0 -#define TEST_RESULT_FAILED 1 -#define TEST_RESULT_NO_ASSERT 2 -#define TEST_RESULT_SKIPPED 3 -#define TEST_RESULT_SETUP_FAILURE 4 - -/* !< Function pointer to a test case setup function (run before every test) */ -typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); - -/* !< Function pointer to a test case function */ -typedef int (*SDLTest_TestCaseFp)(void *arg); - -/* !< Function pointer to a test case teardown function (run after every test) */ -typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); - -/** - * Holds information about a single test case. - */ -typedef struct SDLTest_TestCaseReference { - /* !< Func2Stress */ - SDLTest_TestCaseFp testCase; - /* !< Short name (or function name) "Func2Stress" */ - char *name; - /* !< Long name or full description "This test pushes func2() to the limit." */ - char *description; - /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ - int enabled; -} SDLTest_TestCaseReference; - -/** - * Holds information about a test suite (multiple test cases). - */ -typedef struct SDLTest_TestSuiteReference { - /* !< "PlatformSuite" */ - char *name; - /* !< The function that is run before each test. NULL skips. */ - SDLTest_TestCaseSetUpFp testSetUp; - /* !< The test cases that are run as part of the suite. Last item should be NULL. */ - const SDLTest_TestCaseReference **testCases; - /* !< The function that is run after each test. NULL skips. */ - SDLTest_TestCaseTearDownFp testTearDown; -} SDLTest_TestSuiteReference; - - -/** - * \brief Generates a random run seed string for the harness. The generated seed will contain alphanumeric characters (0-9A-Z). - * - * Note: The returned string needs to be deallocated by the caller. - * - * \param length The length of the seed string to generate - * - * \returns The generated seed string - */ -char *SDLTest_GenerateRunSeed(const int length); - -/** - * \brief Execute a test suite using the given run seed and execution key. - * - * \param testSuites Suites containing the test case. - * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one. - * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one. - * \param filter Filter specification. NULL disables. Case sensitive. - * \param testIterations Number of iterations to run each test case. - * - * \returns Test run result; 0 when all tests passed, 1 if any tests failed. - */ -int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_h_arness_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_images.h b/thirdparty/include/SDL2/SDL_test_images.h deleted file mode 100644 index 1cc3ee266..000000000 --- a/thirdparty/include/SDL2/SDL_test_images.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test_images.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -/* - - Defines some images for tests. - -*/ - -#ifndef SDL_test_images_h_ -#define SDL_test_images_h_ - -#include "SDL.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - *Type for test images. - */ -typedef struct SDLTest_SurfaceImage_s { - int width; - int height; - unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ - const char *pixel_data; -} SDLTest_SurfaceImage_t; - -/* Test images */ -SDL_Surface *SDLTest_ImageBlit(void); -SDL_Surface *SDLTest_ImageBlitColor(void); -SDL_Surface *SDLTest_ImageBlitAlpha(void); -SDL_Surface *SDLTest_ImageBlitBlendAdd(void); -SDL_Surface *SDLTest_ImageBlitBlend(void); -SDL_Surface *SDLTest_ImageBlitBlendMod(void); -SDL_Surface *SDLTest_ImageBlitBlendNone(void); -SDL_Surface *SDLTest_ImageBlitBlendAll(void); -SDL_Surface *SDLTest_ImageFace(void); -SDL_Surface *SDLTest_ImagePrimitives(void); -SDL_Surface *SDLTest_ImagePrimitivesBlend(void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_images_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_log.h b/thirdparty/include/SDL2/SDL_test_log.h deleted file mode 100644 index 6066f9041..000000000 --- a/thirdparty/include/SDL2/SDL_test_log.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test_log.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -/* - * - * Wrapper to log in the TEST category - * - */ - -#ifndef SDL_test_log_h_ -#define SDL_test_log_h_ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Prints given message with a timestamp in the TEST category and INFO priority. - * - * \param fmt Message to be logged - */ -void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); - -/** - * \brief Prints given message with a timestamp in the TEST category and the ERROR priority. - * - * \param fmt Message to be logged - */ -void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_log_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_md5.h b/thirdparty/include/SDL2/SDL_test_md5.h deleted file mode 100644 index b1c51d929..000000000 --- a/thirdparty/include/SDL2/SDL_test_md5.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test_md5.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -/* - *********************************************************************** - ** Header file for implementation of MD5 ** - ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** - ** Created: 2/17/90 RLR ** - ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** - ** Revised (for MD5): RLR 4/27/91 ** - ** -- G modified to have y&~z instead of y&z ** - ** -- FF, GG, HH modified to add in last register done ** - ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** - ** -- distinct additive constant for each step ** - ** -- round 4 added, working mod 7 ** - *********************************************************************** -*/ - -/* - *********************************************************************** - ** Message-digest routines: ** - ** To form the message digest for a message M ** - ** (1) Initialize a context buffer mdContext using MD5Init ** - ** (2) Call MD5Update on mdContext and M ** - ** (3) Call MD5Final on mdContext ** - ** The message digest is now in mdContext->digest[0...15] ** - *********************************************************************** -*/ - -#ifndef SDL_test_md5_h_ -#define SDL_test_md5_h_ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* ------------ Definitions --------- */ - -/* typedef a 32-bit type */ - typedef unsigned long int MD5UINT4; - -/* Data structure for MD5 (Message-Digest) computation */ - typedef struct { - MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ - MD5UINT4 buf[4]; /* scratch buffer */ - unsigned char in[64]; /* input buffer */ - unsigned char digest[16]; /* actual digest after Md5Final call */ - } SDLTest_Md5Context; - -/* ---------- Function Prototypes ------------- */ - -/** - * \brief initialize the context - * - * \param mdContext pointer to context variable - * - * Note: The function initializes the message-digest context - * mdContext. Call before each new use of the context - - * all fields are set to zero. - */ - void SDLTest_Md5Init(SDLTest_Md5Context * mdContext); - - -/** - * \brief update digest from variable length data - * - * \param mdContext pointer to context variable - * \param inBuf pointer to data array/string - * \param inLen length of data array/string - * - * Note: The function updates the message-digest context to account - * for the presence of each of the characters inBuf[0..inLen-1] - * in the message whose digest is being computed. -*/ - - void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, - unsigned int inLen); - - -/** - * \brief complete digest computation - * - * \param mdContext pointer to context variable - * - * Note: The function terminates the message-digest computation and - * ends with the desired message digest in mdContext.digest[0..15]. - * Always call before using the digest[] variable. -*/ - - void SDLTest_Md5Final(SDLTest_Md5Context * mdContext); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_md5_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_memory.h b/thirdparty/include/SDL2/SDL_test_memory.h deleted file mode 100644 index df69f93e8..000000000 --- a/thirdparty/include/SDL2/SDL_test_memory.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test_memory.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -#ifndef SDL_test_memory_h_ -#define SDL_test_memory_h_ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * \brief Start tracking SDL memory allocations - * - * \note This should be called before any other SDL functions for complete tracking coverage - */ -int SDLTest_TrackAllocations(void); - -/** - * \brief Print a log of any outstanding allocations - * - * \note This can be called after SDL_Quit() - */ -void SDLTest_LogAllocations(void); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_memory_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_random.h b/thirdparty/include/SDL2/SDL_test_random.h deleted file mode 100644 index 9404e9dcd..000000000 --- a/thirdparty/include/SDL2/SDL_test_random.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_test_random.h - * - * Include file for SDL test framework. - * - * This code is a part of the SDL2_test library, not the main SDL library. - */ - -/* - - A "32-bit Multiply with carry random number generator. Very fast. - Includes a list of recommended multipliers. - - multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32. - period: (a*2^31)-1 - -*/ - -#ifndef SDL_test_random_h_ -#define SDL_test_random_h_ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* --- Definitions */ - -/* - * Macros that return a random number in a specific format. - */ -#define SDLTest_RandomInt(c) ((int)SDLTest_Random(c)) - -/* - * Context structure for the random number generator state. - */ - typedef struct { - unsigned int a; - unsigned int x; - unsigned int c; - unsigned int ah; - unsigned int al; - } SDLTest_RandomContext; - - -/* --- Function prototypes */ - -/** - * \brief Initialize random number generator with two integers. - * - * Note: The random sequence of numbers returned by ...Random() is the - * same for the same two integers and has a period of 2^31. - * - * \param rndContext pointer to context structure - * \param xi integer that defines the random sequence - * \param ci integer that defines the random sequence - * - */ - void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, - unsigned int ci); - -/** - * \brief Initialize random number generator based on current system time. - * - * \param rndContext pointer to context structure - * - */ - void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext); - - -/** - * \brief Initialize random number generator based on current system time. - * - * Note: ...RandomInit() or ...RandomInitTime() must have been called - * before using this function. - * - * \param rndContext pointer to context structure - * - * \returns A random number (32bit unsigned integer) - * - */ - unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_test_random_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_thread.h b/thirdparty/include/SDL2/SDL_thread.h deleted file mode 100644 index cb5301174..000000000 --- a/thirdparty/include/SDL2/SDL_thread.h +++ /dev/null @@ -1,361 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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 SDL_thread_h_ -#define SDL_thread_h_ - -/** - * \file SDL_thread.h - * - * Header for the SDL thread management routines. - */ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -/* Thread synchronization primitives */ -#include "SDL_atomic.h" -#include "SDL_mutex.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* The SDL thread structure, defined in SDL_thread.c */ -struct SDL_Thread; -typedef struct SDL_Thread SDL_Thread; - -/* The SDL thread ID */ -typedef unsigned long SDL_threadID; - -/* Thread local storage ID, 0 is the invalid ID */ -typedef unsigned int SDL_TLSID; - -/** - * The SDL thread priority. - * - * \note On many systems you require special privileges to set high or time critical priority. - */ -typedef enum { - SDL_THREAD_PRIORITY_LOW, - SDL_THREAD_PRIORITY_NORMAL, - SDL_THREAD_PRIORITY_HIGH, - SDL_THREAD_PRIORITY_TIME_CRITICAL -} SDL_ThreadPriority; - -/** - * The function passed to SDL_CreateThread(). - * It is passed a void* user context parameter and returns an int. - */ -typedef int (SDLCALL * SDL_ThreadFunction) (void *data); - -#if defined(__WIN32__) -/** - * \file SDL_thread.h - * - * We compile SDL into a DLL. This means, that it's the DLL which - * creates a new thread for the calling process with the SDL_CreateThread() - * API. There is a problem with this, that only the RTL of the SDL2.DLL will - * be initialized for those threads, and not the RTL of the calling - * application! - * - * To solve this, we make a little hack here. - * - * We'll always use the caller's _beginthread() and _endthread() APIs to - * start a new thread. This way, if it's the SDL2.DLL which uses this API, - * then the RTL of SDL2.DLL will be used to create the new thread, and if it's - * the application, then the RTL of the application will be used. - * - * So, in short: - * Always use the _beginthread() and _endthread() of the calling runtime - * library! - */ -#define SDL_PASSED_BEGINTHREAD_ENDTHREAD -#include /* _beginthreadex() and _endthreadex() */ - -typedef uintptr_t (__cdecl * pfnSDL_CurrentBeginThread) - (void *, unsigned, unsigned (__stdcall *func)(void *), - void * /*arg*/, unsigned, unsigned * /* threadID */); -typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); - -#ifndef SDL_beginthread -#define SDL_beginthread _beginthreadex -#endif -#ifndef SDL_endthread -#define SDL_endthread _endthreadex -#endif - -/** - * Create a thread. - */ -extern DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data, - pfnSDL_CurrentBeginThread pfnBeginThread, - pfnSDL_CurrentEndThread pfnEndThread); - -extern DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *), - const char *name, const size_t stacksize, void *data, - pfnSDL_CurrentBeginThread pfnBeginThread, - pfnSDL_CurrentEndThread pfnEndThread); - - -/** - * Create a thread. - */ -#if defined(SDL_CreateThread) && SDL_DYNAMIC_API -#undef SDL_CreateThread -#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) -#undef SDL_CreateThreadWithStackSize -#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) -#else -#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) -#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)SDL_endthread) -#endif - -#elif defined(__OS2__) -/* - * just like the windows case above: We compile SDL2 - * into a dll with Watcom's runtime statically linked. - */ -#define SDL_PASSED_BEGINTHREAD_ENDTHREAD - -#ifndef __EMX__ -#include -#else -#include -#endif - -typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void * /*arg*/); -typedef void (*pfnSDL_CurrentEndThread)(void); - -#ifndef SDL_beginthread -#define SDL_beginthread _beginthread -#endif -#ifndef SDL_endthread -#define SDL_endthread _endthread -#endif - -extern DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data, - pfnSDL_CurrentBeginThread pfnBeginThread, - pfnSDL_CurrentEndThread pfnEndThread); -extern DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data, - pfnSDL_CurrentBeginThread pfnBeginThread, - pfnSDL_CurrentEndThread pfnEndThread); - -#if defined(SDL_CreateThread) && SDL_DYNAMIC_API -#undef SDL_CreateThread -#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) -#undef SDL_CreateThreadWithStackSize -#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) -#else -#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) -#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) -#endif - -#else - -/** - * Create a thread with a default stack size. - * - * This is equivalent to calling: - * SDL_CreateThreadWithStackSize(fn, name, 0, data); - */ -extern DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data); - -/** - * Create a thread. - * - * Thread naming is a little complicated: Most systems have very small - * limits for the string length (Haiku has 32 bytes, Linux currently has 16, - * Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll - * have to see what happens with your system's debugger. The name should be - * UTF-8 (but using the naming limits of C identifiers is a better bet). - * There are no requirements for thread naming conventions, so long as the - * string is null-terminated UTF-8, but these guidelines are helpful in - * choosing a name: - * - * http://stackoverflow.com/questions/149932/naming-conventions-for-threads - * - * If a system imposes requirements, SDL will try to munge the string for - * it (truncate, etc), but the original string contents will be available - * from SDL_GetThreadName(). - * - * The size (in bytes) of the new stack can be specified. Zero means "use - * the system default" which might be wildly different between platforms - * (x86 Linux generally defaults to eight megabytes, an embedded device - * might be a few kilobytes instead). - * - * In SDL 2.1, stacksize will be folded into the original SDL_CreateThread - * function. - */ -extern DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data); - -#endif - -/** - * Get the thread name, as it was specified in SDL_CreateThread(). - * This function returns a pointer to a UTF-8 string that names the - * specified thread, or NULL if it doesn't have a name. This is internal - * memory, not to be free()'d by the caller, and remains valid until the - * specified thread is cleaned up by SDL_WaitThread(). - */ -extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread); - -/** - * Get the thread identifier for the current thread. - */ -extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void); - -/** - * Get the thread identifier for the specified thread. - * - * Equivalent to SDL_ThreadID() if the specified thread is NULL. - */ -extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread); - -/** - * Set the priority for the current thread - */ -extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority); - -/** - * Wait for a thread to finish. Threads that haven't been detached will - * remain (as a "zombie") until this function cleans them up. Not doing so - * is a resource leak. - * - * Once a thread has been cleaned up through this function, the SDL_Thread - * that references it becomes invalid and should not be referenced again. - * As such, only one thread may call SDL_WaitThread() on another. - * - * The return code for the thread function is placed in the area - * pointed to by \c status, if \c status is not NULL. - * - * You may not wait on a thread that has been used in a call to - * SDL_DetachThread(). Use either that function or this one, but not - * both, or behavior is undefined. - * - * It is safe to pass NULL to this function; it is a no-op. - */ -extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status); - -/** - * A thread may be "detached" to signify that it should not remain until - * another thread has called SDL_WaitThread() on it. Detaching a thread - * is useful for long-running threads that nothing needs to synchronize - * with or further manage. When a detached thread is done, it simply - * goes away. - * - * There is no way to recover the return code of a detached thread. If you - * need this, don't detach the thread and instead use SDL_WaitThread(). - * - * Once a thread is detached, you should usually assume the SDL_Thread isn't - * safe to reference again, as it will become invalid immediately upon - * the detached thread's exit, instead of remaining until someone has called - * SDL_WaitThread() to finally clean it up. As such, don't detach the same - * thread more than once. - * - * If a thread has already exited when passed to SDL_DetachThread(), it will - * stop waiting for a call to SDL_WaitThread() and clean up immediately. - * It is not safe to detach a thread that might be used with SDL_WaitThread(). - * - * You may not call SDL_WaitThread() on a thread that has been detached. - * Use either that function or this one, but not both, or behavior is - * undefined. - * - * It is safe to pass NULL to this function; it is a no-op. - */ -extern DECLSPEC void SDLCALL SDL_DetachThread(SDL_Thread * thread); - -/** - * \brief Create an identifier that is globally visible to all threads but refers to data that is thread-specific. - * - * \return The newly created thread local storage identifier, or 0 on error - * - * \code - * static SDL_SpinLock tls_lock; - * static SDL_TLSID thread_local_storage; - * - * void SetMyThreadData(void *value) - * { - * if (!thread_local_storage) { - * SDL_AtomicLock(&tls_lock); - * if (!thread_local_storage) { - * thread_local_storage = SDL_TLSCreate(); - * } - * SDL_AtomicUnlock(&tls_lock); - * } - * SDL_TLSSet(thread_local_storage, value, 0); - * } - * - * void *GetMyThreadData(void) - * { - * return SDL_TLSGet(thread_local_storage); - * } - * \endcode - * - * \sa SDL_TLSGet() - * \sa SDL_TLSSet() - */ -extern DECLSPEC SDL_TLSID SDLCALL SDL_TLSCreate(void); - -/** - * \brief Get the value associated with a thread local storage ID for the current thread. - * - * \param id The thread local storage ID - * - * \return The value associated with the ID for the current thread, or NULL if no value has been set. - * - * \sa SDL_TLSCreate() - * \sa SDL_TLSSet() - */ -extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id); - -/** - * \brief Set the value associated with a thread local storage ID for the current thread. - * - * \param id The thread local storage ID - * \param value The value to associate with the ID for the current thread - * \param destructor A function called when the thread exits, to free the value. - * - * \return 0 on success, -1 on error - * - * \sa SDL_TLSCreate() - * \sa SDL_TLSGet() - */ -extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void*)); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_thread_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_timer.h b/thirdparty/include/SDL2/SDL_timer.h deleted file mode 100644 index aada7178b..000000000 --- a/thirdparty/include/SDL2/SDL_timer.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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 SDL_timer_h_ -#define SDL_timer_h_ - -/** - * \file SDL_timer.h - * - * Header for the SDL time management routines. - */ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Get the number of milliseconds since the SDL library initialization. - * - * \note This value wraps if the program runs for more than ~49 days. - */ -extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); - -/** - * \brief Compare SDL ticks values, and return true if A has passed B - * - * e.g. if you want to wait 100 ms, you could do this: - * Uint32 timeout = SDL_GetTicks() + 100; - * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { - * ... do work until timeout has elapsed - * } - */ -#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) - -/** - * \brief Get the current value of the high resolution counter - */ -extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); - -/** - * \brief Get the count per second of the high resolution counter - */ -extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); - -/** - * \brief Wait a specified number of milliseconds before returning. - */ -extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); - -/** - * Function prototype for the timer callback function. - * - * The callback function is passed the current timer interval and returns - * the next timer interval. If the returned value is the same as the one - * passed in, the periodic alarm continues, otherwise a new alarm is - * scheduled. If the callback returns 0, the periodic alarm is cancelled. - */ -typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); - -/** - * Definition of the timer ID type. - */ -typedef int SDL_TimerID; - -/** - * \brief Add a new timer to the pool of timers already running. - * - * \return A timer ID, or 0 when an error occurs. - */ -extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, - SDL_TimerCallback callback, - void *param); - -/** - * \brief Remove a timer knowing its ID. - * - * \return A boolean value indicating success or failure. - * - * \warning It is not safe to remove a timer multiple times. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_timer_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_touch.h b/thirdparty/include/SDL2/SDL_touch.h deleted file mode 100644 index fa5a37ce3..000000000 --- a/thirdparty/include/SDL2/SDL_touch.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_touch.h - * - * Include file for SDL touch event handling. - */ - -#ifndef SDL_touch_h_ -#define SDL_touch_h_ - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_video.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -typedef Sint64 SDL_TouchID; -typedef Sint64 SDL_FingerID; - -typedef enum -{ - SDL_TOUCH_DEVICE_INVALID = -1, - SDL_TOUCH_DEVICE_DIRECT, /* touch screen with window-relative coordinates */ - SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /* trackpad with absolute device coordinates */ - SDL_TOUCH_DEVICE_INDIRECT_RELATIVE /* trackpad with screen cursor-relative coordinates */ -} SDL_TouchDeviceType; - -typedef struct SDL_Finger -{ - SDL_FingerID id; - float x; - float y; - float pressure; -} SDL_Finger; - -/* Used as the device ID for mouse events simulated with touch input */ -#define SDL_TOUCH_MOUSEID ((Uint32)-1) - -/* Used as the SDL_TouchID for touch events simulated with mouse input */ -#define SDL_MOUSE_TOUCHID ((Sint64)-1) - - -/* Function prototypes */ - -/** - * \brief Get the number of registered touch devices. - */ -extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); - -/** - * \brief Get the touch ID with the given index, or 0 if the index is invalid. - */ -extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); - -/** - * \brief Get the type of the given touch device. - */ -extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID); - -/** - * \brief Get the number of active fingers for a given touch device. - */ -extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); - -/** - * \brief Get the finger object of the given touch, with the given index. - */ -extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_touch_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_types.h b/thirdparty/include/SDL2/SDL_types.h deleted file mode 100644 index b6bb57117..000000000 --- a/thirdparty/include/SDL2/SDL_types.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_types.h - * - * \deprecated - */ - -/* DEPRECATED */ -#include "SDL_stdinc.h" diff --git a/thirdparty/include/SDL2/SDL_version.h b/thirdparty/include/SDL2/SDL_version.h deleted file mode 100644 index c824b1d31..000000000 --- a/thirdparty/include/SDL2/SDL_version.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_version.h - * - * This header defines the current SDL version. - */ - -#ifndef SDL_version_h_ -#define SDL_version_h_ - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief Information the version of SDL in use. - * - * Represents the library's version as three levels: major revision - * (increments with massive changes, additions, and enhancements), - * minor revision (increments with backwards-compatible changes to the - * major revision), and patchlevel (increments with fixes to the minor - * revision). - * - * \sa SDL_VERSION - * \sa SDL_GetVersion - */ -typedef struct SDL_version -{ - Uint8 major; /**< major version */ - Uint8 minor; /**< minor version */ - Uint8 patch; /**< update version */ -} SDL_version; - -/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL -*/ -#define SDL_MAJOR_VERSION 2 -#define SDL_MINOR_VERSION 0 -#define SDL_PATCHLEVEL 12 - -/** - * \brief Macro to determine SDL version program was compiled against. - * - * This macro fills in a SDL_version structure with the version of the - * library you compiled against. This is determined by what header the - * compiler uses. Note that if you dynamically linked the library, you might - * have a slightly newer or older version at runtime. That version can be - * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), - * is not a macro. - * - * \param x A pointer to a SDL_version struct to initialize. - * - * \sa SDL_version - * \sa SDL_GetVersion - */ -#define SDL_VERSION(x) \ -{ \ - (x)->major = SDL_MAJOR_VERSION; \ - (x)->minor = SDL_MINOR_VERSION; \ - (x)->patch = SDL_PATCHLEVEL; \ -} - -/** - * This macro turns the version numbers into a numeric value: - * \verbatim - (1,2,3) -> (1203) - \endverbatim - * - * This assumes that there will never be more than 100 patchlevels. - */ -#define SDL_VERSIONNUM(X, Y, Z) \ - ((X)*1000 + (Y)*100 + (Z)) - -/** - * This is the version number macro for the current SDL version. - */ -#define SDL_COMPILEDVERSION \ - SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) - -/** - * This macro will evaluate to true if compiled with SDL at least X.Y.Z. - */ -#define SDL_VERSION_ATLEAST(X, Y, Z) \ - (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) - -/** - * \brief Get the version of SDL that is linked against your program. - * - * If you are linking to SDL dynamically, then it is possible that the - * current version will be different than the version you compiled against. - * This function returns the current version, while SDL_VERSION() is a - * macro that tells you what version you compiled with. - * - * \code - * SDL_version compiled; - * SDL_version linked; - * - * SDL_VERSION(&compiled); - * SDL_GetVersion(&linked); - * printf("We compiled against SDL version %d.%d.%d ...\n", - * compiled.major, compiled.minor, compiled.patch); - * printf("But we linked against SDL version %d.%d.%d.\n", - * linked.major, linked.minor, linked.patch); - * \endcode - * - * This function may be called safely at any time, even before SDL_Init(). - * - * \sa SDL_VERSION - */ -extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); - -/** - * \brief Get the code revision of SDL that is linked against your program. - * - * Returns an arbitrary string (a hash value) uniquely identifying the - * exact revision of the SDL library in use, and is only useful in comparing - * against other revisions. It is NOT an incrementing number. - */ -extern DECLSPEC const char *SDLCALL SDL_GetRevision(void); - -/** - * \brief Get the revision number of SDL that is linked against your program. - * - * Returns a number uniquely identifying the exact revision of the SDL - * library in use. It is an incrementing number based on commits to - * hg.libsdl.org. - */ -extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_version_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_video.h b/thirdparty/include/SDL2/SDL_video.h deleted file mode 100644 index 20d4ce2d4..000000000 --- a/thirdparty/include/SDL2/SDL_video.h +++ /dev/null @@ -1,1275 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file SDL_video.h - * - * Header file for SDL video functions. - */ - -#ifndef SDL_video_h_ -#define SDL_video_h_ - -#include "SDL_stdinc.h" -#include "SDL_pixels.h" -#include "SDL_rect.h" -#include "SDL_surface.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * \brief The structure that defines a display mode - * - * \sa SDL_GetNumDisplayModes() - * \sa SDL_GetDisplayMode() - * \sa SDL_GetDesktopDisplayMode() - * \sa SDL_GetCurrentDisplayMode() - * \sa SDL_GetClosestDisplayMode() - * \sa SDL_SetWindowDisplayMode() - * \sa SDL_GetWindowDisplayMode() - */ -typedef struct -{ - Uint32 format; /**< pixel format */ - int w; /**< width, in screen coordinates */ - int h; /**< height, in screen coordinates */ - int refresh_rate; /**< refresh rate (or zero for unspecified) */ - void *driverdata; /**< driver-specific data, initialize to 0 */ -} SDL_DisplayMode; - -/** - * \brief The type used to identify a window - * - * \sa SDL_CreateWindow() - * \sa SDL_CreateWindowFrom() - * \sa SDL_DestroyWindow() - * \sa SDL_GetWindowData() - * \sa SDL_GetWindowFlags() - * \sa SDL_GetWindowGrab() - * \sa SDL_GetWindowPosition() - * \sa SDL_GetWindowSize() - * \sa SDL_GetWindowTitle() - * \sa SDL_HideWindow() - * \sa SDL_MaximizeWindow() - * \sa SDL_MinimizeWindow() - * \sa SDL_RaiseWindow() - * \sa SDL_RestoreWindow() - * \sa SDL_SetWindowData() - * \sa SDL_SetWindowFullscreen() - * \sa SDL_SetWindowGrab() - * \sa SDL_SetWindowIcon() - * \sa SDL_SetWindowPosition() - * \sa SDL_SetWindowSize() - * \sa SDL_SetWindowBordered() - * \sa SDL_SetWindowResizable() - * \sa SDL_SetWindowTitle() - * \sa SDL_ShowWindow() - */ -typedef struct SDL_Window SDL_Window; - -/** - * \brief The flags on a window - * - * \sa SDL_GetWindowFlags() - */ -typedef enum -{ - SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */ - SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */ - SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */ - SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */ - SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */ - SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */ - SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */ - SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */ - SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */ - SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */ - SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ - SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), - SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */ - SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /**< window should be created in high-DPI mode if supported. - On macOS NSHighResolutionCapable must be set true in the - application's Info.plist for this to have any effect. */ - SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to INPUT_GRABBED) */ - SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */ - SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /**< window should not be added to the taskbar */ - SDL_WINDOW_UTILITY = 0x00020000, /**< window should be treated as a utility window */ - SDL_WINDOW_TOOLTIP = 0x00040000, /**< window should be treated as a tooltip */ - SDL_WINDOW_POPUP_MENU = 0x00080000, /**< window should be treated as a popup menu */ - SDL_WINDOW_VULKAN = 0x10000000 /**< window usable for Vulkan surface */ -} SDL_WindowFlags; - -/** - * \brief Used to indicate that you don't care what the window position is. - */ -#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u -#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) -#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) -#define SDL_WINDOWPOS_ISUNDEFINED(X) \ - (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) - -/** - * \brief Used to indicate that the window position should be centered. - */ -#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u -#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X)) -#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) -#define SDL_WINDOWPOS_ISCENTERED(X) \ - (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) - -/** - * \brief Event subtype for window events - */ -typedef enum -{ - SDL_WINDOWEVENT_NONE, /**< Never used */ - SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */ - SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */ - SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be - redrawn */ - SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2 - */ - SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */ - SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as - a result of an API call or through the - system or user changing the window size. */ - SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */ - SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */ - SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size - and position */ - SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */ - SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */ - SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */ - SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */ - SDL_WINDOWEVENT_CLOSE, /**< The window manager requests that the window be closed */ - SDL_WINDOWEVENT_TAKE_FOCUS, /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */ - SDL_WINDOWEVENT_HIT_TEST /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL. */ -} SDL_WindowEventID; - -/** - * \brief Event subtype for display events - */ -typedef enum -{ - SDL_DISPLAYEVENT_NONE, /**< Never used */ - SDL_DISPLAYEVENT_ORIENTATION /**< Display orientation has changed to data1 */ -} SDL_DisplayEventID; - -typedef enum -{ - SDL_ORIENTATION_UNKNOWN, /**< The display orientation can't be determined */ - SDL_ORIENTATION_LANDSCAPE, /**< The display is in landscape mode, with the right side up, relative to portrait mode */ - SDL_ORIENTATION_LANDSCAPE_FLIPPED, /**< The display is in landscape mode, with the left side up, relative to portrait mode */ - SDL_ORIENTATION_PORTRAIT, /**< The display is in portrait mode */ - SDL_ORIENTATION_PORTRAIT_FLIPPED /**< The display is in portrait mode, upside down */ -} SDL_DisplayOrientation; - -/** - * \brief An opaque handle to an OpenGL context. - */ -typedef void *SDL_GLContext; - -/** - * \brief OpenGL configuration attributes - */ -typedef enum -{ - SDL_GL_RED_SIZE, - SDL_GL_GREEN_SIZE, - SDL_GL_BLUE_SIZE, - SDL_GL_ALPHA_SIZE, - SDL_GL_BUFFER_SIZE, - SDL_GL_DOUBLEBUFFER, - SDL_GL_DEPTH_SIZE, - SDL_GL_STENCIL_SIZE, - SDL_GL_ACCUM_RED_SIZE, - SDL_GL_ACCUM_GREEN_SIZE, - SDL_GL_ACCUM_BLUE_SIZE, - SDL_GL_ACCUM_ALPHA_SIZE, - SDL_GL_STEREO, - SDL_GL_MULTISAMPLEBUFFERS, - SDL_GL_MULTISAMPLESAMPLES, - SDL_GL_ACCELERATED_VISUAL, - SDL_GL_RETAINED_BACKING, - SDL_GL_CONTEXT_MAJOR_VERSION, - SDL_GL_CONTEXT_MINOR_VERSION, - SDL_GL_CONTEXT_EGL, - SDL_GL_CONTEXT_FLAGS, - SDL_GL_CONTEXT_PROFILE_MASK, - SDL_GL_SHARE_WITH_CURRENT_CONTEXT, - SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, - SDL_GL_CONTEXT_RELEASE_BEHAVIOR, - SDL_GL_CONTEXT_RESET_NOTIFICATION, - SDL_GL_CONTEXT_NO_ERROR -} SDL_GLattr; - -typedef enum -{ - SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, - SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, - SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */ -} SDL_GLprofile; - -typedef enum -{ - SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001, - SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002, - SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004, - SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008 -} SDL_GLcontextFlag; - -typedef enum -{ - SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0x0000, - SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x0001 -} SDL_GLcontextReleaseFlag; - -typedef enum -{ - SDL_GL_CONTEXT_RESET_NO_NOTIFICATION = 0x0000, - SDL_GL_CONTEXT_RESET_LOSE_CONTEXT = 0x0001 -} SDL_GLContextResetNotification; - -/* Function prototypes */ - -/** - * \brief Get the number of video drivers compiled into SDL - * - * \sa SDL_GetVideoDriver() - */ -extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); - -/** - * \brief Get the name of a built in video driver. - * - * \note The video drivers are presented in the order in which they are - * normally checked during initialization. - * - * \sa SDL_GetNumVideoDrivers() - */ -extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index); - -/** - * \brief Initialize the video subsystem, optionally specifying a video driver. - * - * \param driver_name Initialize a specific driver by name, or NULL for the - * default video driver. - * - * \return 0 on success, -1 on error - * - * This function initializes the video subsystem; setting up a connection - * to the window manager, etc, and determines the available display modes - * and pixel formats, but does not initialize a window or graphics mode. - * - * \sa SDL_VideoQuit() - */ -extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name); - -/** - * \brief Shuts down the video subsystem. - * - * This function closes all windows, and restores the original video mode. - * - * \sa SDL_VideoInit() - */ -extern DECLSPEC void SDLCALL SDL_VideoQuit(void); - -/** - * \brief Returns the name of the currently initialized video driver. - * - * \return The name of the current video driver or NULL if no driver - * has been initialized - * - * \sa SDL_GetNumVideoDrivers() - * \sa SDL_GetVideoDriver() - */ -extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void); - -/** - * \brief Returns the number of available video displays. - * - * \sa SDL_GetDisplayBounds() - */ -extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void); - -/** - * \brief Get the name of a display in UTF-8 encoding - * - * \return The name of a display, or NULL for an invalid display index. - * - * \sa SDL_GetNumVideoDisplays() - */ -extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex); - -/** - * \brief Get the desktop area represented by a display, with the primary - * display located at 0,0 - * - * \return 0 on success, or -1 if the index is out of range. - * - * \sa SDL_GetNumVideoDisplays() - */ -extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect); - -/** - * \brief Get the usable desktop area represented by a display, with the - * primary display located at 0,0 - * - * This is the same area as SDL_GetDisplayBounds() reports, but with portions - * reserved by the system removed. For example, on Mac OS X, this subtracts - * the area occupied by the menu bar and dock. - * - * Setting a window to be fullscreen generally bypasses these unusable areas, - * so these are good guidelines for the maximum space available to a - * non-fullscreen window. - * - * \return 0 on success, or -1 if the index is out of range. - * - * \sa SDL_GetDisplayBounds() - * \sa SDL_GetNumVideoDisplays() - */ -extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect); - -/** - * \brief Get the dots/pixels-per-inch for a display - * - * \note Diagonal, horizontal and vertical DPI can all be optionally - * returned if the parameter is non-NULL. - * - * \return 0 on success, or -1 if no DPI information is available or the index is out of range. - * - * \sa SDL_GetNumVideoDisplays() - */ -extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi); - -/** - * \brief Get the orientation of a display - * - * \return The orientation of the display, or SDL_ORIENTATION_UNKNOWN if it isn't available. - * - * \sa SDL_GetNumVideoDisplays() - */ -extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(int displayIndex); - -/** - * \brief Returns the number of available display modes. - * - * \sa SDL_GetDisplayMode() - */ -extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex); - -/** - * \brief Fill in information about a specific display mode. - * - * \note The display modes are sorted in this priority: - * \li bits per pixel -> more colors to fewer colors - * \li width -> largest to smallest - * \li height -> largest to smallest - * \li refresh rate -> highest to lowest - * - * \sa SDL_GetNumDisplayModes() - */ -extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, - SDL_DisplayMode * mode); - -/** - * \brief Fill in information about the desktop display mode. - */ -extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode); - -/** - * \brief Fill in information about the current display mode. - */ -extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode); - - -/** - * \brief Get the closest match to the requested display mode. - * - * \param displayIndex The index of display from which mode should be queried. - * \param mode The desired display mode - * \param closest A pointer to a display mode to be filled in with the closest - * match of the available display modes. - * - * \return The passed in value \c closest, or NULL if no matching video mode - * was available. - * - * The available display modes are scanned, and \c closest is filled in with the - * closest mode matching the requested mode and returned. The mode format and - * refresh_rate default to the desktop mode if they are 0. The modes are - * scanned with size being first priority, format being second priority, and - * finally checking the refresh_rate. If all the available modes are too - * small, then NULL is returned. - * - * \sa SDL_GetNumDisplayModes() - * \sa SDL_GetDisplayMode() - */ -extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest); - -/** - * \brief Get the display index associated with a window. - * - * \return the display index of the display containing the center of the - * window, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window); - -/** - * \brief Set the display mode used when a fullscreen window is visible. - * - * By default the window's dimensions and the desktop format and refresh rate - * are used. - * - * \param window The window for which the display mode should be set. - * \param mode The mode to use, or NULL for the default mode. - * - * \return 0 on success, or -1 if setting the display mode failed. - * - * \sa SDL_GetWindowDisplayMode() - * \sa SDL_SetWindowFullscreen() - */ -extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window, - const SDL_DisplayMode - * mode); - -/** - * \brief Fill in information about the display mode used when a fullscreen - * window is visible. - * - * \sa SDL_SetWindowDisplayMode() - * \sa SDL_SetWindowFullscreen() - */ -extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window, - SDL_DisplayMode * mode); - -/** - * \brief Get the pixel format associated with the window. - */ -extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); - -/** - * \brief Create a window with the specified position, dimensions, and flags. - * - * \param title The title of the window, in UTF-8 encoding. - * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or - * ::SDL_WINDOWPOS_UNDEFINED. - * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or - * ::SDL_WINDOWPOS_UNDEFINED. - * \param w The width of the window, in screen coordinates. - * \param h The height of the window, in screen coordinates. - * \param flags The flags for the window, a mask of any of the following: - * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, - * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_BORDERLESS, - * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, - * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED, - * ::SDL_WINDOW_ALLOW_HIGHDPI, ::SDL_WINDOW_VULKAN. - * - * \return The created window, or NULL if window creation failed. - * - * If the window is created with the SDL_WINDOW_ALLOW_HIGHDPI flag, its size - * in pixels may differ from its size in screen coordinates on platforms with - * high-DPI support (e.g. iOS and Mac OS X). Use SDL_GetWindowSize() to query - * the client area's size in screen coordinates, and SDL_GL_GetDrawableSize(), - * SDL_Vulkan_GetDrawableSize(), or SDL_GetRendererOutputSize() to query the - * drawable size in pixels. - * - * If the window is created with any of the SDL_WINDOW_OPENGL or - * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function - * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the - * corresponding UnloadLibrary function is called by SDL_DestroyWindow(). - * - * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver, - * SDL_CreateWindow() will fail because SDL_Vulkan_LoadLibrary() will fail. - * - * \note On non-Apple devices, SDL requires you to either not link to the - * Vulkan loader or link to a dynamic library version. This limitation - * may be removed in a future version of SDL. - * - * \sa SDL_DestroyWindow() - * \sa SDL_GL_LoadLibrary() - * \sa SDL_Vulkan_LoadLibrary() - */ -extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, - int x, int y, int w, - int h, Uint32 flags); - -/** - * \brief Create an SDL window from an existing native window. - * - * \param data A pointer to driver-dependent window creation data - * - * \return The created window, or NULL if window creation failed. - * - * \sa SDL_DestroyWindow() - */ -extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data); - -/** - * \brief Get the numeric ID of a window, for logging purposes. - */ -extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window); - -/** - * \brief Get a window from a stored ID, or NULL if it doesn't exist. - */ -extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id); - -/** - * \brief Get the window flags. - */ -extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window); - -/** - * \brief Set the title of a window, in UTF-8 format. - * - * \sa SDL_GetWindowTitle() - */ -extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, - const char *title); - -/** - * \brief Get the title of a window, in UTF-8 format. - * - * \sa SDL_SetWindowTitle() - */ -extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window); - -/** - * \brief Set the icon for a window. - * - * \param window The window for which the icon should be set. - * \param icon The icon for the window. - */ -extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, - SDL_Surface * icon); - -/** - * \brief Associate an arbitrary named pointer with a window. - * - * \param window The window to associate with the pointer. - * \param name The name of the pointer. - * \param userdata The associated pointer. - * - * \return The previous value associated with 'name' - * - * \note The name is case-sensitive. - * - * \sa SDL_GetWindowData() - */ -extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window, - const char *name, - void *userdata); - -/** - * \brief Retrieve the data pointer associated with a window. - * - * \param window The window to query. - * \param name The name of the pointer. - * - * \return The value associated with 'name' - * - * \sa SDL_SetWindowData() - */ -extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window, - const char *name); - -/** - * \brief Set the position of a window. - * - * \param window The window to reposition. - * \param x The x coordinate of the window in screen coordinates, or - * ::SDL_WINDOWPOS_CENTERED or ::SDL_WINDOWPOS_UNDEFINED. - * \param y The y coordinate of the window in screen coordinates, or - * ::SDL_WINDOWPOS_CENTERED or ::SDL_WINDOWPOS_UNDEFINED. - * - * \note The window coordinate origin is the upper left of the display. - * - * \sa SDL_GetWindowPosition() - */ -extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, - int x, int y); - -/** - * \brief Get the position of a window. - * - * \param window The window to query. - * \param x Pointer to variable for storing the x position, in screen - * coordinates. May be NULL. - * \param y Pointer to variable for storing the y position, in screen - * coordinates. May be NULL. - * - * \sa SDL_SetWindowPosition() - */ -extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window, - int *x, int *y); - -/** - * \brief Set the size of a window's client area. - * - * \param window The window to resize. - * \param w The width of the window, in screen coordinates. Must be >0. - * \param h The height of the window, in screen coordinates. Must be >0. - * - * \note Fullscreen windows automatically match the size of the display mode, - * and you should use SDL_SetWindowDisplayMode() to change their size. - * - * The window size in screen coordinates may differ from the size in pixels, if - * the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with - * high-dpi support (e.g. iOS or OS X). Use SDL_GL_GetDrawableSize() or - * SDL_GetRendererOutputSize() to get the real client area size in pixels. - * - * \sa SDL_GetWindowSize() - * \sa SDL_SetWindowDisplayMode() - */ -extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, - int h); - -/** - * \brief Get the size of a window's client area. - * - * \param window The window to query. - * \param w Pointer to variable for storing the width, in screen - * coordinates. May be NULL. - * \param h Pointer to variable for storing the height, in screen - * coordinates. May be NULL. - * - * The window size in screen coordinates may differ from the size in pixels, if - * the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with - * high-dpi support (e.g. iOS or OS X). Use SDL_GL_GetDrawableSize() or - * SDL_GetRendererOutputSize() to get the real client area size in pixels. - * - * \sa SDL_SetWindowSize() - */ -extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w, - int *h); - -/** - * \brief Get the size of a window's borders (decorations) around the client area. - * - * \param window The window to query. - * \param top Pointer to variable for storing the size of the top border. NULL is permitted. - * \param left Pointer to variable for storing the size of the left border. NULL is permitted. - * \param bottom Pointer to variable for storing the size of the bottom border. NULL is permitted. - * \param right Pointer to variable for storing the size of the right border. NULL is permitted. - * - * \return 0 on success, or -1 if getting this information is not supported. - * - * \note if this function fails (returns -1), the size values will be - * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as - * if the window in question was borderless. - */ -extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window * window, - int *top, int *left, - int *bottom, int *right); - -/** - * \brief Set the minimum size of a window's client area. - * - * \param window The window to set a new minimum size. - * \param min_w The minimum width of the window, must be >0 - * \param min_h The minimum height of the window, must be >0 - * - * \note You can't change the minimum size of a fullscreen window, it - * automatically matches the size of the display mode. - * - * \sa SDL_GetWindowMinimumSize() - * \sa SDL_SetWindowMaximumSize() - */ -extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window, - int min_w, int min_h); - -/** - * \brief Get the minimum size of a window's client area. - * - * \param window The window to query. - * \param w Pointer to variable for storing the minimum width, may be NULL - * \param h Pointer to variable for storing the minimum height, may be NULL - * - * \sa SDL_GetWindowMaximumSize() - * \sa SDL_SetWindowMinimumSize() - */ -extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window, - int *w, int *h); - -/** - * \brief Set the maximum size of a window's client area. - * - * \param window The window to set a new maximum size. - * \param max_w The maximum width of the window, must be >0 - * \param max_h The maximum height of the window, must be >0 - * - * \note You can't change the maximum size of a fullscreen window, it - * automatically matches the size of the display mode. - * - * \sa SDL_GetWindowMaximumSize() - * \sa SDL_SetWindowMinimumSize() - */ -extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window, - int max_w, int max_h); - -/** - * \brief Get the maximum size of a window's client area. - * - * \param window The window to query. - * \param w Pointer to variable for storing the maximum width, may be NULL - * \param h Pointer to variable for storing the maximum height, may be NULL - * - * \sa SDL_GetWindowMinimumSize() - * \sa SDL_SetWindowMaximumSize() - */ -extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window, - int *w, int *h); - -/** - * \brief Set the border state of a window. - * - * This will add or remove the window's SDL_WINDOW_BORDERLESS flag and - * add or remove the border from the actual window. This is a no-op if the - * window's border already matches the requested state. - * - * \param window The window of which to change the border state. - * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border. - * - * \note You can't change the border state of a fullscreen window. - * - * \sa SDL_GetWindowFlags() - */ -extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window, - SDL_bool bordered); - -/** - * \brief Set the user-resizable state of a window. - * - * This will add or remove the window's SDL_WINDOW_RESIZABLE flag and - * allow/disallow user resizing of the window. This is a no-op if the - * window's resizable state already matches the requested state. - * - * \param window The window of which to change the resizable state. - * \param resizable SDL_TRUE to allow resizing, SDL_FALSE to disallow. - * - * \note You can't change the resizable state of a fullscreen window. - * - * \sa SDL_GetWindowFlags() - */ -extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window * window, - SDL_bool resizable); - -/** - * \brief Show a window. - * - * \sa SDL_HideWindow() - */ -extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window); - -/** - * \brief Hide a window. - * - * \sa SDL_ShowWindow() - */ -extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window); - -/** - * \brief Raise a window above other windows and set the input focus. - */ -extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window); - -/** - * \brief Make a window as large as possible. - * - * \sa SDL_RestoreWindow() - */ -extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window); - -/** - * \brief Minimize a window to an iconic representation. - * - * \sa SDL_RestoreWindow() - */ -extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window); - -/** - * \brief Restore the size and position of a minimized or maximized window. - * - * \sa SDL_MaximizeWindow() - * \sa SDL_MinimizeWindow() - */ -extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window); - -/** - * \brief Set a window's fullscreen state. - * - * \return 0 on success, or -1 if setting the display mode failed. - * - * \sa SDL_SetWindowDisplayMode() - * \sa SDL_GetWindowDisplayMode() - */ -extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, - Uint32 flags); - -/** - * \brief Get the SDL surface associated with the window. - * - * \return The window's framebuffer surface, or NULL on error. - * - * A new surface will be created with the optimal format for the window, - * if necessary. This surface will be freed when the window is destroyed. - * - * \note You may not combine this with 3D or the rendering API on this window. - * - * \sa SDL_UpdateWindowSurface() - * \sa SDL_UpdateWindowSurfaceRects() - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window); - -/** - * \brief Copy the window surface to the screen. - * - * \return 0 on success, or -1 on error. - * - * \sa SDL_GetWindowSurface() - * \sa SDL_UpdateWindowSurfaceRects() - */ -extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window); - -/** - * \brief Copy a number of rectangles on the window surface to the screen. - * - * \return 0 on success, or -1 on error. - * - * \sa SDL_GetWindowSurface() - * \sa SDL_UpdateWindowSurface() - */ -extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window, - const SDL_Rect * rects, - int numrects); - -/** - * \brief Set a window's input grab mode. - * - * \param window The window for which the input grab mode should be set. - * \param grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input. - * - * If the caller enables a grab while another window is currently grabbed, - * the other window loses its grab in favor of the caller's window. - * - * \sa SDL_GetWindowGrab() - */ -extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window, - SDL_bool grabbed); - -/** - * \brief Get a window's input grab mode. - * - * \return This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise. - * - * \sa SDL_SetWindowGrab() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window); - -/** - * \brief Get the window that currently has an input grab enabled. - * - * \return This returns the window if input is grabbed, and NULL otherwise. - * - * \sa SDL_SetWindowGrab() - */ -extern DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void); - -/** - * \brief Set the brightness (gamma correction) for a window. - * - * \return 0 on success, or -1 if setting the brightness isn't supported. - * - * \sa SDL_GetWindowBrightness() - * \sa SDL_SetWindowGammaRamp() - */ -extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float brightness); - -/** - * \brief Get the brightness (gamma correction) for a window. - * - * \return The last brightness value passed to SDL_SetWindowBrightness() - * - * \sa SDL_SetWindowBrightness() - */ -extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window); - -/** - * \brief Set the opacity for a window - * - * \param window The window which will be made transparent or opaque - * \param opacity Opacity (0.0f - transparent, 1.0f - opaque) This will be - * clamped internally between 0.0f and 1.0f. - * - * \return 0 on success, or -1 if setting the opacity isn't supported. - * - * \sa SDL_GetWindowOpacity() - */ -extern DECLSPEC int SDLCALL SDL_SetWindowOpacity(SDL_Window * window, float opacity); - -/** - * \brief Get the opacity of a window. - * - * If transparency isn't supported on this platform, opacity will be reported - * as 1.0f without error. - * - * \param window The window in question. - * \param out_opacity Opacity (0.0f - transparent, 1.0f - opaque) - * - * \return 0 on success, or -1 on error (invalid window, etc). - * - * \sa SDL_SetWindowOpacity() - */ -extern DECLSPEC int SDLCALL SDL_GetWindowOpacity(SDL_Window * window, float * out_opacity); - -/** - * \brief Sets the window as a modal for another window (TODO: reconsider this function and/or its name) - * - * \param modal_window The window that should be modal - * \param parent_window The parent window - * - * \return 0 on success, or -1 otherwise. - */ -extern DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window * modal_window, SDL_Window * parent_window); - -/** - * \brief Explicitly sets input focus to the window. - * - * You almost certainly want SDL_RaiseWindow() instead of this function. Use - * this with caution, as you might give focus to a window that's completely - * obscured by other windows. - * - * \param window The window that should get the input focus - * - * \return 0 on success, or -1 otherwise. - * \sa SDL_RaiseWindow() - */ -extern DECLSPEC int SDLCALL SDL_SetWindowInputFocus(SDL_Window * window); - -/** - * \brief Set the gamma ramp for a window. - * - * \param window The window for which the gamma ramp should be set. - * \param red The translation table for the red channel, or NULL. - * \param green The translation table for the green channel, or NULL. - * \param blue The translation table for the blue channel, or NULL. - * - * \return 0 on success, or -1 if gamma ramps are unsupported. - * - * Set the gamma translation table for the red, green, and blue channels - * of the video hardware. Each table is an array of 256 16-bit quantities, - * representing a mapping between the input and output for that channel. - * The input is the index into the array, and the output is the 16-bit - * gamma value at that index, scaled to the output color precision. - * - * \sa SDL_GetWindowGammaRamp() - */ -extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window, - const Uint16 * red, - const Uint16 * green, - const Uint16 * blue); - -/** - * \brief Get the gamma ramp for a window. - * - * \param window The window from which the gamma ramp should be queried. - * \param red A pointer to a 256 element array of 16-bit quantities to hold - * the translation table for the red channel, or NULL. - * \param green A pointer to a 256 element array of 16-bit quantities to hold - * the translation table for the green channel, or NULL. - * \param blue A pointer to a 256 element array of 16-bit quantities to hold - * the translation table for the blue channel, or NULL. - * - * \return 0 on success, or -1 if gamma ramps are unsupported. - * - * \sa SDL_SetWindowGammaRamp() - */ -extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window, - Uint16 * red, - Uint16 * green, - Uint16 * blue); - -/** - * \brief Possible return values from the SDL_HitTest callback. - * - * \sa SDL_HitTest - */ -typedef enum -{ - SDL_HITTEST_NORMAL, /**< Region is normal. No special properties. */ - SDL_HITTEST_DRAGGABLE, /**< Region can drag entire window. */ - SDL_HITTEST_RESIZE_TOPLEFT, - SDL_HITTEST_RESIZE_TOP, - SDL_HITTEST_RESIZE_TOPRIGHT, - SDL_HITTEST_RESIZE_RIGHT, - SDL_HITTEST_RESIZE_BOTTOMRIGHT, - SDL_HITTEST_RESIZE_BOTTOM, - SDL_HITTEST_RESIZE_BOTTOMLEFT, - SDL_HITTEST_RESIZE_LEFT -} SDL_HitTestResult; - -/** - * \brief Callback used for hit-testing. - * - * \sa SDL_SetWindowHitTest - */ -typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win, - const SDL_Point *area, - void *data); - -/** - * \brief Provide a callback that decides if a window region has special properties. - * - * Normally windows are dragged and resized by decorations provided by the - * system window manager (a title bar, borders, etc), but for some apps, it - * makes sense to drag them from somewhere else inside the window itself; for - * example, one might have a borderless window that wants to be draggable - * from any part, or simulate its own title bar, etc. - * - * This function lets the app provide a callback that designates pieces of - * a given window as special. This callback is run during event processing - * if we need to tell the OS to treat a region of the window specially; the - * use of this callback is known as "hit testing." - * - * Mouse input may not be delivered to your application if it is within - * a special area; the OS will often apply that input to moving the window or - * resizing the window and not deliver it to the application. - * - * Specifying NULL for a callback disables hit-testing. Hit-testing is - * disabled by default. - * - * Platforms that don't support this functionality will return -1 - * unconditionally, even if you're attempting to disable hit-testing. - * - * Your callback may fire at any time, and its firing does not indicate any - * specific behavior (for example, on Windows, this certainly might fire - * when the OS is deciding whether to drag your window, but it fires for lots - * of other reasons, too, some unrelated to anything you probably care about - * _and when the mouse isn't actually at the location it is testing_). - * Since this can fire at any time, you should try to keep your callback - * efficient, devoid of allocations, etc. - * - * \param window The window to set hit-testing on. - * \param callback The callback to call when doing a hit-test. - * \param callback_data An app-defined void pointer passed to the callback. - * \return 0 on success, -1 on error (including unsupported). - */ -extern DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window * window, - SDL_HitTest callback, - void *callback_data); - -/** - * \brief Destroy a window. - */ -extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window); - - -/** - * \brief Returns whether the screensaver is currently enabled (default off). - * - * \sa SDL_EnableScreenSaver() - * \sa SDL_DisableScreenSaver() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenSaverEnabled(void); - -/** - * \brief Allow the screen to be blanked by a screensaver - * - * \sa SDL_IsScreenSaverEnabled() - * \sa SDL_DisableScreenSaver() - */ -extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void); - -/** - * \brief Prevent the screen from being blanked by a screensaver - * - * \sa SDL_IsScreenSaverEnabled() - * \sa SDL_EnableScreenSaver() - */ -extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void); - - -/** - * \name OpenGL support functions - */ -/* @{ */ - -/** - * \brief Dynamically load an OpenGL library. - * - * \param path The platform dependent OpenGL library name, or NULL to open the - * default OpenGL library. - * - * \return 0 on success, or -1 if the library couldn't be loaded. - * - * This should be done after initializing the video driver, but before - * creating any OpenGL windows. If no OpenGL library is loaded, the default - * library will be loaded upon creation of the first OpenGL window. - * - * \note If you do this, you need to retrieve all of the GL functions used in - * your program from the dynamic library using SDL_GL_GetProcAddress(). - * - * \sa SDL_GL_GetProcAddress() - * \sa SDL_GL_UnloadLibrary() - */ -extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); - -/** - * \brief Get the address of an OpenGL function. - */ -extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc); - -/** - * \brief Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). - * - * \sa SDL_GL_LoadLibrary() - */ -extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); - -/** - * \brief Return true if an OpenGL extension is supported for the current - * context. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char - *extension); - -/** - * \brief Reset all previously set OpenGL context attributes to their default values - */ -extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void); - -/** - * \brief Set an OpenGL window attribute before window creation. - * - * \return 0 on success, or -1 if the attribute could not be set. - */ -extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); - -/** - * \brief Get the actual value for an attribute from the current context. - * - * \return 0 on success, or -1 if the attribute could not be retrieved. - * The integer at \c value will be modified in either case. - */ -extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value); - -/** - * \brief Create an OpenGL context for use with an OpenGL window, and make it - * current. - * - * \sa SDL_GL_DeleteContext() - */ -extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window * - window); - -/** - * \brief Set up an OpenGL context for rendering into an OpenGL window. - * - * \note The context must have been created with a compatible window. - */ -extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, - SDL_GLContext context); - -/** - * \brief Get the currently active OpenGL window. - */ -extern DECLSPEC SDL_Window* SDLCALL SDL_GL_GetCurrentWindow(void); - -/** - * \brief Get the currently active OpenGL context. - */ -extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void); - -/** - * \brief Get the size of a window's underlying drawable in pixels (for use - * with glViewport). - * - * \param window Window from which the drawable size should be queried - * \param w Pointer to variable for storing the width in pixels, may be NULL - * \param h Pointer to variable for storing the height in pixels, may be NULL - * - * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI - * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a - * platform with high-DPI support (Apple calls this "Retina"), and not disabled - * by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint. - * - * \sa SDL_GetWindowSize() - * \sa SDL_CreateWindow() - */ -extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w, - int *h); - -/** - * \brief Set the swap interval for the current OpenGL context. - * - * \param interval 0 for immediate updates, 1 for updates synchronized with the - * vertical retrace. If the system supports it, you may - * specify -1 to allow late swaps to happen immediately - * instead of waiting for the next retrace. - * - * \return 0 on success, or -1 if setting the swap interval is not supported. - * - * \sa SDL_GL_GetSwapInterval() - */ -extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval); - -/** - * \brief Get the swap interval for the current OpenGL context. - * - * \return 0 if there is no vertical retrace synchronization, 1 if the buffer - * swap is synchronized with the vertical retrace, and -1 if late - * swaps happen immediately instead of waiting for the next retrace. - * If the system can't determine the swap interval, or there isn't a - * valid current context, this will return 0 as a safe default. - * - * \sa SDL_GL_SetSwapInterval() - */ -extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void); - -/** - * \brief Swap the OpenGL buffers for a window, if double-buffering is - * supported. - */ -extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); - -/** - * \brief Delete an OpenGL context. - * - * \sa SDL_GL_CreateContext() - */ -extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); - -/* @} *//* OpenGL support functions */ - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_video_h_ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_vulkan.h b/thirdparty/include/SDL2/SDL_vulkan.h deleted file mode 100644 index d69a436b3..000000000 --- a/thirdparty/include/SDL2/SDL_vulkan.h +++ /dev/null @@ -1,278 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 2017, Mark Callow - - 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. -*/ - -/** - * \file SDL_vulkan.h - * - * Header file for functions to creating Vulkan surfaces on SDL windows. - */ - -#ifndef SDL_vulkan_h_ -#define SDL_vulkan_h_ - -#include "SDL_video.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Avoid including vulkan.h, don't define VkInstance if it's already included */ -#ifdef VULKAN_H_ -#define NO_SDL_VULKAN_TYPEDEFS -#endif -#ifndef NO_SDL_VULKAN_TYPEDEFS -#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; - -#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) -#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; -#else -#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; -#endif - -VK_DEFINE_HANDLE(VkInstance) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) - -#endif /* !NO_SDL_VULKAN_TYPEDEFS */ - -typedef VkInstance SDL_vulkanInstance; -typedef VkSurfaceKHR SDL_vulkanSurface; /* for compatibility with Tizen */ - -/** - * \name Vulkan support functions - * - * \note SDL_Vulkan_GetInstanceExtensions & SDL_Vulkan_CreateSurface API - * is compatable with Tizen's implementation of Vulkan in SDL. - */ -/* @{ */ - -/** - * \brief Dynamically load a Vulkan loader library. - * - * \param [in] path The platform dependent Vulkan loader library name, or - * \c NULL. - * - * \return \c 0 on success, or \c -1 if the library couldn't be loaded. - * - * If \a path is NULL SDL will use the value of the environment variable - * \c SDL_VULKAN_LIBRARY, if set, otherwise it loads the default Vulkan - * loader library. - * - * This should be called after initializing the video driver, but before - * creating any Vulkan windows. If no Vulkan loader library is loaded, the - * default library will be loaded upon creation of the first Vulkan window. - * - * \note It is fairly common for Vulkan applications to link with \a libvulkan - * instead of explicitly loading it at run time. This will work with - * SDL provided the application links to a dynamic library and both it - * and SDL use the same search path. - * - * \note If you specify a non-NULL \c path, an application should retrieve all - * of the Vulkan functions it uses from the dynamic library using - * \c SDL_Vulkan_GetVkGetInstanceProcAddr() unless you can guarantee - * \c path points to the same vulkan loader library the application - * linked to. - * - * \note On Apple devices, if \a path is NULL, SDL will attempt to find - * the vkGetInstanceProcAddr address within all the mach-o images of - * the current process. This is because it is fairly common for Vulkan - * applications to link with libvulkan (and historically MoltenVK was - * provided as a static library). If it is not found then, on macOS, SDL - * will attempt to load \c vulkan.framework/vulkan, \c libvulkan.1.dylib, - * followed by \c libvulkan.dylib, in that order. - * On iOS SDL will attempt to load \c libvulkan.dylib only. Applications - * using a dynamic framework or .dylib must ensure it is included in its - * application bundle. - * - * \note On non-Apple devices, application linking with a static libvulkan is - * not supported. Either do not link to the Vulkan loader or link to a - * dynamic library version. - * - * \note This function will fail if there are no working Vulkan drivers - * installed. - * - * \sa SDL_Vulkan_GetVkGetInstanceProcAddr() - * \sa SDL_Vulkan_UnloadLibrary() - */ -extern DECLSPEC int SDLCALL SDL_Vulkan_LoadLibrary(const char *path); - -/** - * \brief Get the address of the \c vkGetInstanceProcAddr function. - * - * \note This should be called after either calling SDL_Vulkan_LoadLibrary - * or creating an SDL_Window with the SDL_WINDOW_VULKAN flag. - */ -extern DECLSPEC void *SDLCALL SDL_Vulkan_GetVkGetInstanceProcAddr(void); - -/** - * \brief Unload the Vulkan loader library previously loaded by - * \c SDL_Vulkan_LoadLibrary(). - * - * \sa SDL_Vulkan_LoadLibrary() - */ -extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void); - -/** - * \brief Get the names of the Vulkan instance extensions needed to create - * a surface with \c SDL_Vulkan_CreateSurface(). - * - * \param [in] \c NULL or window Window for which the required Vulkan instance - * extensions should be retrieved - * \param [in,out] pCount pointer to an \c unsigned related to the number of - * required Vulkan instance extensions - * \param [out] pNames \c NULL or a pointer to an array to be filled with the - * required Vulkan instance extensions - * - * \return \c SDL_TRUE on success, \c SDL_FALSE on error. - * - * If \a pNames is \c NULL, then the number of required Vulkan instance - * extensions is returned in pCount. Otherwise, \a pCount must point to a - * variable set to the number of elements in the \a pNames array, and on - * return the variable is overwritten with the number of names actually - * written to \a pNames. If \a pCount is less than the number of required - * extensions, at most \a pCount structures will be written. If \a pCount - * is smaller than the number of required extensions, \c SDL_FALSE will be - * returned instead of \c SDL_TRUE, to indicate that not all the required - * extensions were returned. - * - * \note If \c window is not NULL, it will be checked against its creation - * flags to ensure that the Vulkan flag is present. This parameter - * will be removed in a future major release. - * - * \note The returned list of extensions will contain \c VK_KHR_surface - * and zero or more platform specific extensions - * - * \note The extension names queried here must be enabled when calling - * VkCreateInstance, otherwise surface creation will fail. - * - * \note \c window should have been created with the \c SDL_WINDOW_VULKAN flag - * or be \c NULL - * - * \code - * unsigned int count; - * // get count of required extensions - * if(!SDL_Vulkan_GetInstanceExtensions(NULL, &count, NULL)) - * handle_error(); - * - * static const char *const additionalExtensions[] = - * { - * VK_EXT_DEBUG_REPORT_EXTENSION_NAME, // example additional extension - * }; - * size_t additionalExtensionsCount = sizeof(additionalExtensions) / sizeof(additionalExtensions[0]); - * size_t extensionCount = count + additionalExtensionsCount; - * const char **names = malloc(sizeof(const char *) * extensionCount); - * if(!names) - * handle_error(); - * - * // get names of required extensions - * if(!SDL_Vulkan_GetInstanceExtensions(NULL, &count, names)) - * handle_error(); - * - * // copy additional extensions after required extensions - * for(size_t i = 0; i < additionalExtensionsCount; i++) - * names[i + count] = additionalExtensions[i]; - * - * VkInstanceCreateInfo instanceCreateInfo = {}; - * instanceCreateInfo.enabledExtensionCount = extensionCount; - * instanceCreateInfo.ppEnabledExtensionNames = names; - * // fill in rest of instanceCreateInfo - * - * VkInstance instance; - * // create the Vulkan instance - * VkResult result = vkCreateInstance(&instanceCreateInfo, NULL, &instance); - * free(names); - * \endcode - * - * \sa SDL_Vulkan_CreateSurface() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_GetInstanceExtensions( - SDL_Window *window, - unsigned int *pCount, - const char **pNames); - -/** - * \brief Create a Vulkan rendering surface for a window. - * - * \param [in] window SDL_Window to which to attach the rendering surface. - * \param [in] instance handle to the Vulkan instance to use. - * \param [out] surface pointer to a VkSurfaceKHR handle to receive the - * handle of the newly created surface. - * - * \return \c SDL_TRUE on success, \c SDL_FALSE on error. - * - * \code - * VkInstance instance; - * SDL_Window *window; - * - * // create instance and window - * - * // create the Vulkan surface - * VkSurfaceKHR surface; - * if(!SDL_Vulkan_CreateSurface(window, instance, &surface)) - * handle_error(); - * \endcode - * - * \note \a window should have been created with the \c SDL_WINDOW_VULKAN flag. - * - * \note \a instance should have been created with the extensions returned - * by \c SDL_Vulkan_CreateSurface() enabled. - * - * \sa SDL_Vulkan_GetInstanceExtensions() - */ -extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_CreateSurface( - SDL_Window *window, - VkInstance instance, - VkSurfaceKHR* surface); - -/** - * \brief Get the size of a window's underlying drawable in pixels (for use - * with setting viewport, scissor & etc). - * - * \param window SDL_Window from which the drawable size should be queried - * \param w Pointer to variable for storing the width in pixels, - * may be NULL - * \param h Pointer to variable for storing the height in pixels, - * may be NULL - * - * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI - * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a - * platform with high-DPI support (Apple calls this "Retina"), and not disabled - * by the \c SDL_HINT_VIDEO_HIGHDPI_DISABLED hint. - * - * \note On macOS high-DPI support must be enabled for an application by - * setting NSHighResolutionCapable to true in its Info.plist. - * - * \sa SDL_GetWindowSize() - * \sa SDL_CreateWindow() - */ -extern DECLSPEC void SDLCALL SDL_Vulkan_GetDrawableSize(SDL_Window * window, - int *w, int *h); - -/* @} *//* Vulkan support functions */ - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* SDL_vulkan_h_ */ diff --git a/thirdparty/include/SDL2/begin_code.h b/thirdparty/include/SDL2/begin_code.h deleted file mode 100644 index 170d69ec5..000000000 --- a/thirdparty/include/SDL2/begin_code.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file begin_code.h - * - * This file sets things up for C dynamic library function definitions, - * static inlined functions, and structures aligned at 4-byte alignment. - * If you don't like ugly C preprocessor code, don't look at this file. :) - */ - -/* This shouldn't be nested -- included it around code only. */ -#ifdef _begin_code_h -#error Nested inclusion of begin_code.h -#endif -#define _begin_code_h - -#ifndef SDL_DEPRECATED -# if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ -# define SDL_DEPRECATED __attribute__((deprecated)) -# else -# define SDL_DEPRECATED -# endif -#endif - -#ifndef SDL_UNUSED -# ifdef __GNUC__ -# define SDL_UNUSED __attribute__((unused)) -# else -# define SDL_UNUSED -# endif -#endif - -/* Some compilers use a special export keyword */ -#ifndef DECLSPEC -# if defined(__WIN32__) || defined(__WINRT__) -# ifdef __BORLANDC__ -# ifdef BUILD_SDL -# define DECLSPEC -# else -# define DECLSPEC __declspec(dllimport) -# endif -# else -# define DECLSPEC __declspec(dllexport) -# endif -# elif defined(__OS2__) -# ifdef BUILD_SDL -# define DECLSPEC __declspec(dllexport) -# else -# define DECLSPEC -# endif -# else -# if defined(__GNUC__) && __GNUC__ >= 4 -# define DECLSPEC __attribute__ ((visibility("default"))) -# else -# define DECLSPEC -# endif -# endif -#endif - -/* By default SDL uses the C calling convention */ -#ifndef SDLCALL -#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) -#define SDLCALL __cdecl -#elif defined(__OS2__) || defined(__EMX__) -#define SDLCALL _System -# if defined (__GNUC__) && !defined(_System) -# define _System /* for old EMX/GCC compat. */ -# endif -#else -#define SDLCALL -#endif -#endif /* SDLCALL */ - -/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ -#ifdef __SYMBIAN32__ -#undef DECLSPEC -#define DECLSPEC -#endif /* __SYMBIAN32__ */ - -/* Force structure packing at 4 byte alignment. - This is necessary if the header is included in code which has structure - packing set to an alternate value, say for loading structures from disk. - The packing is reset to the previous value in close_code.h - */ -#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) -#ifdef _MSC_VER -#pragma warning(disable: 4103) -#endif -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wpragma-pack" -#endif -#ifdef __BORLANDC__ -#pragma nopackwarning -#endif -#ifdef _M_X64 -/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ -#pragma pack(push,8) -#else -#pragma pack(push,4) -#endif -#endif /* Compiler needs structure packing set */ - -#ifndef SDL_INLINE -#if defined(__GNUC__) -#define SDL_INLINE __inline__ -#elif defined(_MSC_VER) || defined(__BORLANDC__) || \ - defined(__DMC__) || defined(__SC__) || \ - defined(__WATCOMC__) || defined(__LCC__) || \ - defined(__DECC) || defined(__CC_ARM) -#define SDL_INLINE __inline -#ifndef __inline__ -#define __inline__ __inline -#endif -#else -#define SDL_INLINE inline -#ifndef __inline__ -#define __inline__ inline -#endif -#endif -#endif /* SDL_INLINE not defined */ - -#ifndef SDL_FORCE_INLINE -#if defined(_MSC_VER) -#define SDL_FORCE_INLINE __forceinline -#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) -#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ -#else -#define SDL_FORCE_INLINE static SDL_INLINE -#endif -#endif /* SDL_FORCE_INLINE not defined */ - -#ifndef SDL_NORETURN -#if defined(__GNUC__) -#define SDL_NORETURN __attribute__((noreturn)) -#elif defined(_MSC_VER) -#define SDL_NORETURN __declspec(noreturn) -#else -#define SDL_NORETURN -#endif -#endif /* SDL_NORETURN not defined */ - -/* Apparently this is needed by several Windows compilers */ -#if !defined(__MACH__) -#ifndef NULL -#ifdef __cplusplus -#define NULL 0 -#else -#define NULL ((void *)0) -#endif -#endif /* NULL */ -#endif /* ! Mac OS X - breaks precompiled headers */ diff --git a/thirdparty/include/SDL2/close_code.h b/thirdparty/include/SDL2/close_code.h deleted file mode 100644 index 6aa411b0d..000000000 --- a/thirdparty/include/SDL2/close_code.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - - 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. -*/ - -/** - * \file close_code.h - * - * This file reverses the effects of begin_code.h and should be included - * after you finish any function and structure declarations in your headers - */ - -#ifndef _begin_code_h -#error close_code.h included without matching begin_code.h -#endif -#undef _begin_code_h - -/* Reset structure packing at previous byte alignment */ -#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) -#ifdef __BORLANDC__ -#pragma nopackwarning -#endif -#pragma pack(pop) -#endif /* Compiler needs structure packing set */ diff --git a/thirdparty/include/assimp/.editorconfig b/thirdparty/include/assimp/.editorconfig deleted file mode 100644 index 9ea66423a..000000000 --- a/thirdparty/include/assimp/.editorconfig +++ /dev/null @@ -1,8 +0,0 @@ -# See for details - -[*.{h,hpp,inl}] -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true -indent_size = 4 -indent_style = space diff --git a/thirdparty/include/assimp/Compiler/poppack1.h b/thirdparty/include/assimp/Compiler/poppack1.h deleted file mode 100644 index e033bc147..000000000 --- a/thirdparty/include/assimp/Compiler/poppack1.h +++ /dev/null @@ -1,22 +0,0 @@ - -// =============================================================================== -// May be included multiple times - resets structure packing to the defaults -// for all supported compilers. Reverts the changes made by #include -// -// Currently this works on the following compilers: -// MSVC 7,8,9 -// GCC -// BORLAND (complains about 'pack state changed but not reverted', but works) -// =============================================================================== - -#ifndef AI_PUSHPACK_IS_DEFINED -# error pushpack1.h must be included after poppack1.h -#endif - -// reset packing to the original value -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack( pop ) -#endif -#undef PACK_STRUCT - -#undef AI_PUSHPACK_IS_DEFINED diff --git a/thirdparty/include/assimp/Compiler/pstdint.h b/thirdparty/include/assimp/Compiler/pstdint.h deleted file mode 100644 index 4de4ce2a9..000000000 --- a/thirdparty/include/assimp/Compiler/pstdint.h +++ /dev/null @@ -1,912 +0,0 @@ -/* A portable stdint.h - **************************************************************************** - * BSD License: - **************************************************************************** - * - * Copyright (c) 2005-2016 Paul Hsieh - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - **************************************************************************** - * - * Version 0.1.15.4 - * - * The ANSI C standard committee, for the C99 standard, specified the - * inclusion of a new standard include file called stdint.h. This is - * a very useful and long desired include file which contains several - * very precise definitions for integer scalar types that is - * critically important for making portable several classes of - * applications including cryptography, hashing, variable length - * integer libraries and so on. But for most developers its likely - * useful just for programming sanity. - * - * The problem is that some compiler vendors chose to ignore the C99 - * standard and some older compilers have no opportunity to be updated. - * Because of this situation, simply including stdint.h in your code - * makes it unportable. - * - * So that's what this file is all about. Its an attempt to build a - * single universal include file that works on as many platforms as - * possible to deliver what stdint.h is supposed to. Even compilers - * that already come with stdint.h can use this file instead without - * any loss of functionality. A few things that should be noted about - * this file: - * - * 1) It is not guaranteed to be portable and/or present an identical - * interface on all platforms. The extreme variability of the - * ANSI C standard makes this an impossibility right from the - * very get go. Its really only meant to be useful for the vast - * majority of platforms that possess the capability of - * implementing usefully and precisely defined, standard sized - * integer scalars. Systems which are not intrinsically 2s - * complement may produce invalid constants. - * - * 2) There is an unavoidable use of non-reserved symbols. - * - * 3) Other standard include files are invoked. - * - * 4) This file may come in conflict with future platforms that do - * include stdint.h. The hope is that one or the other can be - * used with no real difference. - * - * 5) In the current version, if your platform can't represent - * int32_t, int16_t and int8_t, it just dumps out with a compiler - * error. - * - * 6) 64 bit integers may or may not be defined. Test for their - * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX. - * Note that this is different from the C99 specification which - * requires the existence of 64 bit support in the compiler. If - * this is not defined for your platform, yet it is capable of - * dealing with 64 bits then it is because this file has not yet - * been extended to cover all of your system's capabilities. - * - * 7) (u)intptr_t may or may not be defined. Test for its presence - * with the test: #ifdef PTRDIFF_MAX. If this is not defined - * for your platform, then it is because this file has not yet - * been extended to cover all of your system's capabilities, not - * because its optional. - * - * 8) The following might not been defined even if your platform is - * capable of defining it: - * - * WCHAR_MIN - * WCHAR_MAX - * (u)int64_t - * PTRDIFF_MIN - * PTRDIFF_MAX - * (u)intptr_t - * - * 9) The following have not been defined: - * - * WINT_MIN - * WINT_MAX - * - * 10) The criteria for defining (u)int_least(*)_t isn't clear, - * except for systems which don't have a type that precisely - * defined 8, 16, or 32 bit types (which this include file does - * not support anyways). Default definitions have been given. - * - * 11) The criteria for defining (u)int_fast(*)_t isn't something I - * would trust to any particular compiler vendor or the ANSI C - * committee. It is well known that "compatible systems" are - * commonly created that have very different performance - * characteristics from the systems they are compatible with, - * especially those whose vendors make both the compiler and the - * system. Default definitions have been given, but its strongly - * recommended that users never use these definitions for any - * reason (they do *NOT* deliver any serious guarantee of - * improved performance -- not in this file, nor any vendor's - * stdint.h). - * - * 12) The following macros: - * - * PRINTF_INTMAX_MODIFIER - * PRINTF_INT64_MODIFIER - * PRINTF_INT32_MODIFIER - * PRINTF_INT16_MODIFIER - * PRINTF_LEAST64_MODIFIER - * PRINTF_LEAST32_MODIFIER - * PRINTF_LEAST16_MODIFIER - * PRINTF_INTPTR_MODIFIER - * - * are strings which have been defined as the modifiers required - * for the "d", "u" and "x" printf formats to correctly output - * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t, - * (u)least32_t, (u)least16_t and (u)intptr_t types respectively. - * PRINTF_INTPTR_MODIFIER is not defined for some systems which - * provide their own stdint.h. PRINTF_INT64_MODIFIER is not - * defined if INT64_MAX is not defined. These are an extension - * beyond what C99 specifies must be in stdint.h. - * - * In addition, the following macros are defined: - * - * PRINTF_INTMAX_HEX_WIDTH - * PRINTF_INT64_HEX_WIDTH - * PRINTF_INT32_HEX_WIDTH - * PRINTF_INT16_HEX_WIDTH - * PRINTF_INT8_HEX_WIDTH - * PRINTF_INTMAX_DEC_WIDTH - * PRINTF_INT64_DEC_WIDTH - * PRINTF_INT32_DEC_WIDTH - * PRINTF_INT16_DEC_WIDTH - * PRINTF_UINT8_DEC_WIDTH - * PRINTF_UINTMAX_DEC_WIDTH - * PRINTF_UINT64_DEC_WIDTH - * PRINTF_UINT32_DEC_WIDTH - * PRINTF_UINT16_DEC_WIDTH - * PRINTF_UINT8_DEC_WIDTH - * - * Which specifies the maximum number of characters required to - * print the number of that type in either hexadecimal or decimal. - * These are an extension beyond what C99 specifies must be in - * stdint.h. - * - * Compilers tested (all with 0 warnings at their highest respective - * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32 - * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio - * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3 - * - * This file should be considered a work in progress. Suggestions for - * improvements, especially those which increase coverage are strongly - * encouraged. - * - * Acknowledgements - * - * The following people have made significant contributions to the - * development and testing of this file: - * - * Chris Howie - * John Steele Scott - * Dave Thorup - * John Dill - * Florian Wobbe - * Christopher Sean Morrison - * Mikkel Fahnoe Jorgensen - * - */ - -#include -#include -#include - -/* - * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and - * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_. - */ - -#if ((defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED) -#include -#define _PSTDINT_H_INCLUDED -# if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__)) -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "l" -# endif -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -# else -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "ll" -# endif -# ifndef PRINTF_INT32_MODIFIER -# if (UINT_MAX == UINT32_MAX) -# define PRINTF_INT32_MODIFIER "" -# else -# define PRINTF_INT32_MODIFIER "l" -# endif -# endif -# endif -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "h" -# endif -# ifndef PRINTF_INTMAX_MODIFIER -# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER -# endif -# ifndef PRINTF_INT64_HEX_WIDTH -# define PRINTF_INT64_HEX_WIDTH "16" -# endif -# ifndef PRINTF_UINT64_HEX_WIDTH -# define PRINTF_UINT64_HEX_WIDTH "16" -# endif -# ifndef PRINTF_INT32_HEX_WIDTH -# define PRINTF_INT32_HEX_WIDTH "8" -# endif -# ifndef PRINTF_UINT32_HEX_WIDTH -# define PRINTF_UINT32_HEX_WIDTH "8" -# endif -# ifndef PRINTF_INT16_HEX_WIDTH -# define PRINTF_INT16_HEX_WIDTH "4" -# endif -# ifndef PRINTF_UINT16_HEX_WIDTH -# define PRINTF_UINT16_HEX_WIDTH "4" -# endif -# ifndef PRINTF_INT8_HEX_WIDTH -# define PRINTF_INT8_HEX_WIDTH "2" -# endif -# ifndef PRINTF_UINT8_HEX_WIDTH -# define PRINTF_UINT8_HEX_WIDTH "2" -# endif -# ifndef PRINTF_INT64_DEC_WIDTH -# define PRINTF_INT64_DEC_WIDTH "19" -# endif -# ifndef PRINTF_UINT64_DEC_WIDTH -# define PRINTF_UINT64_DEC_WIDTH "20" -# endif -# ifndef PRINTF_INT32_DEC_WIDTH -# define PRINTF_INT32_DEC_WIDTH "10" -# endif -# ifndef PRINTF_UINT32_DEC_WIDTH -# define PRINTF_UINT32_DEC_WIDTH "10" -# endif -# ifndef PRINTF_INT16_DEC_WIDTH -# define PRINTF_INT16_DEC_WIDTH "5" -# endif -# ifndef PRINTF_UINT16_DEC_WIDTH -# define PRINTF_UINT16_DEC_WIDTH "5" -# endif -# ifndef PRINTF_INT8_DEC_WIDTH -# define PRINTF_INT8_DEC_WIDTH "3" -# endif -# ifndef PRINTF_UINT8_DEC_WIDTH -# define PRINTF_UINT8_DEC_WIDTH "3" -# endif -# ifndef PRINTF_INTMAX_HEX_WIDTH -# define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH -# endif -# ifndef PRINTF_UINTMAX_HEX_WIDTH -# define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH -# endif -# ifndef PRINTF_INTMAX_DEC_WIDTH -# define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH -# endif -# ifndef PRINTF_UINTMAX_DEC_WIDTH -# define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH -# endif - -/* - * Something really weird is going on with Open Watcom. Just pull some of - * these duplicated definitions from Open Watcom's stdint.h file for now. - */ - -# if defined (__WATCOMC__) && __WATCOMC__ >= 1250 -# if !defined (INT64_C) -# define INT64_C(x) (x + (INT64_MAX - INT64_MAX)) -# endif -# if !defined (UINT64_C) -# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX)) -# endif -# if !defined (INT32_C) -# define INT32_C(x) (x + (INT32_MAX - INT32_MAX)) -# endif -# if !defined (UINT32_C) -# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX)) -# endif -# if !defined (INT16_C) -# define INT16_C(x) (x) -# endif -# if !defined (UINT16_C) -# define UINT16_C(x) (x) -# endif -# if !defined (INT8_C) -# define INT8_C(x) (x) -# endif -# if !defined (UINT8_C) -# define UINT8_C(x) (x) -# endif -# if !defined (UINT64_MAX) -# define UINT64_MAX 18446744073709551615ULL -# endif -# if !defined (INT64_MAX) -# define INT64_MAX 9223372036854775807LL -# endif -# if !defined (UINT32_MAX) -# define UINT32_MAX 4294967295UL -# endif -# if !defined (INT32_MAX) -# define INT32_MAX 2147483647L -# endif -# if !defined (INTMAX_MAX) -# define INTMAX_MAX INT64_MAX -# endif -# if !defined (INTMAX_MIN) -# define INTMAX_MIN INT64_MIN -# endif -# endif -#endif - -/* - * I have no idea what is the truly correct thing to do on older Solaris. - * From some online discussions, this seems to be what is being - * recommended. For people who actually are developing on older Solaris, - * what I would like to know is, does this define all of the relevant - * macros of a complete stdint.h? Remember, in pstdint.h 64 bit is - * considered optional. - */ - -#if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x420) && !defined(_PSTDINT_H_INCLUDED) -#include -#define _PSTDINT_H_INCLUDED -#endif - -#ifndef _PSTDINT_H_INCLUDED -#define _PSTDINT_H_INCLUDED - -#ifndef SIZE_MAX -# define SIZE_MAX (~(size_t)0) -#endif - -/* - * Deduce the type assignments from limits.h under the assumption that - * integer sizes in bits are powers of 2, and follow the ANSI - * definitions. - */ - -#ifndef UINT8_MAX -# define UINT8_MAX 0xff -#endif -#if !defined(uint8_t) && !defined(_UINT8_T) && !defined(vxWorks) -# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S) - typedef unsigned char uint8_t; -# define UINT8_C(v) ((uint8_t) v) -# else -# error "Platform not supported" -# endif -#endif - -#ifndef INT8_MAX -# define INT8_MAX 0x7f -#endif -#ifndef INT8_MIN -# define INT8_MIN INT8_C(0x80) -#endif -#if !defined(int8_t) && !defined(_INT8_T) && !defined(vxWorks) -# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S) - typedef signed char int8_t; -# define INT8_C(v) ((int8_t) v) -# else -# error "Platform not supported" -# endif -#endif - -#ifndef UINT16_MAX -# define UINT16_MAX 0xffff -#endif -#if !defined(uint16_t) && !defined(_UINT16_T) && !defined(vxWorks) -#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S) - typedef unsigned int uint16_t; -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "" -# endif -# define UINT16_C(v) ((uint16_t) (v)) -#elif (USHRT_MAX == UINT16_MAX) - typedef unsigned short uint16_t; -# define UINT16_C(v) ((uint16_t) (v)) -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "h" -# endif -#else -#error "Platform not supported" -#endif -#endif - -#ifndef INT16_MAX -# define INT16_MAX 0x7fff -#endif -#ifndef INT16_MIN -# define INT16_MIN INT16_C(0x8000) -#endif -#if !defined(int16_t) && !defined(_INT16_T) && !defined(vxWorks) -#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S) - typedef signed int int16_t; -# define INT16_C(v) ((int16_t) (v)) -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "" -# endif -#elif (SHRT_MAX == INT16_MAX) - typedef signed short int16_t; -# define INT16_C(v) ((int16_t) (v)) -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "h" -# endif -#else -#error "Platform not supported" -#endif -#endif - -#ifndef UINT32_MAX -# define UINT32_MAX (0xffffffffUL) -#endif -#if !defined(uint32_t) && !defined(_UINT32_T) && !defined(vxWorks) -#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S) - typedef unsigned long uint32_t; -# define UINT32_C(v) v ## UL -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "l" -# endif -#elif (UINT_MAX == UINT32_MAX) - typedef unsigned int uint32_t; -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -# define UINT32_C(v) v ## U -#elif (USHRT_MAX == UINT32_MAX) - typedef unsigned short uint32_t; -# define UINT32_C(v) ((unsigned short) (v)) -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -#else -#error "Platform not supported" -#endif -#endif - -#ifndef INT32_MAX -# define INT32_MAX (0x7fffffffL) -#endif -#ifndef INT32_MIN -# define INT32_MIN INT32_C(0x80000000) -#endif -#if !defined(int32_t) && !defined(_INT32_T) && !defined(vxWorks) -#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S) - typedef signed long int32_t; -# define INT32_C(v) v ## L -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "l" -# endif -#elif (INT_MAX == INT32_MAX) - typedef signed int int32_t; -# define INT32_C(v) v -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -#elif (SHRT_MAX == INT32_MAX) - typedef signed short int32_t; -# define INT32_C(v) ((short) (v)) -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -#else -#error "Platform not supported" -#endif -#endif - -/* - * The macro stdint_int64_defined is temporarily used to record - * whether or not 64 integer support is available. It must be - * defined for any 64 integer extensions for new platforms that are - * added. - */ - -#undef stdint_int64_defined -#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S) -# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S) -# define stdint_int64_defined - typedef long long int64_t; - typedef unsigned long long uint64_t; -# define UINT64_C(v) v ## ULL -# define INT64_C(v) v ## LL -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "ll" -# endif -# endif -#endif - -#if !defined (stdint_int64_defined) -# if defined(__GNUC__) && !defined(vxWorks) -# define stdint_int64_defined - __extension__ typedef long long int64_t; - __extension__ typedef unsigned long long uint64_t; -# define UINT64_C(v) v ## ULL -# define INT64_C(v) v ## LL -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "ll" -# endif -# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S) -# define stdint_int64_defined - typedef long long int64_t; - typedef unsigned long long uint64_t; -# define UINT64_C(v) v ## ULL -# define INT64_C(v) v ## LL -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "ll" -# endif -# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC) -# define stdint_int64_defined - typedef __int64 int64_t; - typedef unsigned __int64 uint64_t; -# define UINT64_C(v) v ## UI64 -# define INT64_C(v) v ## I64 -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "I64" -# endif -# endif -#endif - -#if !defined (LONG_LONG_MAX) && defined (INT64_C) -# define LONG_LONG_MAX INT64_C (9223372036854775807) -#endif -#ifndef ULONG_LONG_MAX -# define ULONG_LONG_MAX UINT64_C (18446744073709551615) -#endif - -#if !defined (INT64_MAX) && defined (INT64_C) -# define INT64_MAX INT64_C (9223372036854775807) -#endif -#if !defined (INT64_MIN) && defined (INT64_C) -# define INT64_MIN INT64_C (-9223372036854775808) -#endif -#if !defined (UINT64_MAX) && defined (INT64_C) -# define UINT64_MAX UINT64_C (18446744073709551615) -#endif - -/* - * Width of hexadecimal for number field. - */ - -#ifndef PRINTF_INT64_HEX_WIDTH -# define PRINTF_INT64_HEX_WIDTH "16" -#endif -#ifndef PRINTF_INT32_HEX_WIDTH -# define PRINTF_INT32_HEX_WIDTH "8" -#endif -#ifndef PRINTF_INT16_HEX_WIDTH -# define PRINTF_INT16_HEX_WIDTH "4" -#endif -#ifndef PRINTF_INT8_HEX_WIDTH -# define PRINTF_INT8_HEX_WIDTH "2" -#endif -#ifndef PRINTF_INT64_DEC_WIDTH -# define PRINTF_INT64_DEC_WIDTH "19" -#endif -#ifndef PRINTF_INT32_DEC_WIDTH -# define PRINTF_INT32_DEC_WIDTH "10" -#endif -#ifndef PRINTF_INT16_DEC_WIDTH -# define PRINTF_INT16_DEC_WIDTH "5" -#endif -#ifndef PRINTF_INT8_DEC_WIDTH -# define PRINTF_INT8_DEC_WIDTH "3" -#endif -#ifndef PRINTF_UINT64_DEC_WIDTH -# define PRINTF_UINT64_DEC_WIDTH "20" -#endif -#ifndef PRINTF_UINT32_DEC_WIDTH -# define PRINTF_UINT32_DEC_WIDTH "10" -#endif -#ifndef PRINTF_UINT16_DEC_WIDTH -# define PRINTF_UINT16_DEC_WIDTH "5" -#endif -#ifndef PRINTF_UINT8_DEC_WIDTH -# define PRINTF_UINT8_DEC_WIDTH "3" -#endif - -/* - * Ok, lets not worry about 128 bit integers for now. Moore's law says - * we don't need to worry about that until about 2040 at which point - * we'll have bigger things to worry about. - */ - -#ifdef stdint_int64_defined - typedef int64_t intmax_t; - typedef uint64_t uintmax_t; -# define INTMAX_MAX INT64_MAX -# define INTMAX_MIN INT64_MIN -# define UINTMAX_MAX UINT64_MAX -# define UINTMAX_C(v) UINT64_C(v) -# define INTMAX_C(v) INT64_C(v) -# ifndef PRINTF_INTMAX_MODIFIER -# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER -# endif -# ifndef PRINTF_INTMAX_HEX_WIDTH -# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH -# endif -# ifndef PRINTF_INTMAX_DEC_WIDTH -# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH -# endif -#else - typedef int32_t intmax_t; - typedef uint32_t uintmax_t; -# define INTMAX_MAX INT32_MAX -# define UINTMAX_MAX UINT32_MAX -# define UINTMAX_C(v) UINT32_C(v) -# define INTMAX_C(v) INT32_C(v) -# ifndef PRINTF_INTMAX_MODIFIER -# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER -# endif -# ifndef PRINTF_INTMAX_HEX_WIDTH -# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH -# endif -# ifndef PRINTF_INTMAX_DEC_WIDTH -# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH -# endif -#endif - -/* - * Because this file currently only supports platforms which have - * precise powers of 2 as bit sizes for the default integers, the - * least definitions are all trivial. Its possible that a future - * version of this file could have different definitions. - */ - -#ifndef stdint_least_defined - typedef int8_t int_least8_t; - typedef uint8_t uint_least8_t; - typedef int16_t int_least16_t; - typedef uint16_t uint_least16_t; - typedef int32_t int_least32_t; - typedef uint32_t uint_least32_t; -# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER -# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER -# define UINT_LEAST8_MAX UINT8_MAX -# define INT_LEAST8_MAX INT8_MAX -# define UINT_LEAST16_MAX UINT16_MAX -# define INT_LEAST16_MAX INT16_MAX -# define UINT_LEAST32_MAX UINT32_MAX -# define INT_LEAST32_MAX INT32_MAX -# define INT_LEAST8_MIN INT8_MIN -# define INT_LEAST16_MIN INT16_MIN -# define INT_LEAST32_MIN INT32_MIN -# ifdef stdint_int64_defined - typedef int64_t int_least64_t; - typedef uint64_t uint_least64_t; -# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER -# define UINT_LEAST64_MAX UINT64_MAX -# define INT_LEAST64_MAX INT64_MAX -# define INT_LEAST64_MIN INT64_MIN -# endif -#endif -#undef stdint_least_defined - -/* - * The ANSI C committee pretending to know or specify anything about - * performance is the epitome of misguided arrogance. The mandate of - * this file is to *ONLY* ever support that absolute minimum - * definition of the fast integer types, for compatibility purposes. - * No extensions, and no attempt to suggest what may or may not be a - * faster integer type will ever be made in this file. Developers are - * warned to stay away from these types when using this or any other - * stdint.h. - */ - -typedef int_least8_t int_fast8_t; -typedef uint_least8_t uint_fast8_t; -typedef int_least16_t int_fast16_t; -typedef uint_least16_t uint_fast16_t; -typedef int_least32_t int_fast32_t; -typedef uint_least32_t uint_fast32_t; -#define UINT_FAST8_MAX UINT_LEAST8_MAX -#define INT_FAST8_MAX INT_LEAST8_MAX -#define UINT_FAST16_MAX UINT_LEAST16_MAX -#define INT_FAST16_MAX INT_LEAST16_MAX -#define UINT_FAST32_MAX UINT_LEAST32_MAX -#define INT_FAST32_MAX INT_LEAST32_MAX -#define INT_FAST8_MIN INT_LEAST8_MIN -#define INT_FAST16_MIN INT_LEAST16_MIN -#define INT_FAST32_MIN INT_LEAST32_MIN -#ifdef stdint_int64_defined - typedef int_least64_t int_fast64_t; - typedef uint_least64_t uint_fast64_t; -# define UINT_FAST64_MAX UINT_LEAST64_MAX -# define INT_FAST64_MAX INT_LEAST64_MAX -# define INT_FAST64_MIN INT_LEAST64_MIN -#endif - -#undef stdint_int64_defined - -/* - * Whatever piecemeal, per compiler thing we can do about the wchar_t - * type limits. - */ - -#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks) -# include -# ifndef WCHAR_MIN -# define WCHAR_MIN 0 -# endif -# ifndef WCHAR_MAX -# define WCHAR_MAX ((wchar_t)-1) -# endif -#endif - -/* - * Whatever piecemeal, per compiler/platform thing we can do about the - * (u)intptr_t types and limits. - */ - -#if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T) -# define STDINT_H_UINTPTR_T_DEFINED -#endif - -#ifndef STDINT_H_UINTPTR_T_DEFINED -# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__) -# define stdint_intptr_bits 64 -# elif defined (__WATCOMC__) || defined (__TURBOC__) -# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__) -# define stdint_intptr_bits 16 -# else -# define stdint_intptr_bits 32 -# endif -# elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__) -# define stdint_intptr_bits 32 -# elif defined (__INTEL_COMPILER) -/* TODO -- what did Intel do about x86-64? */ -# else -/* #error "This platform might not be supported yet" */ -# endif - -# ifdef stdint_intptr_bits -# define stdint_intptr_glue3_i(a,b,c) a##b##c -# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c) -# ifndef PRINTF_INTPTR_MODIFIER -# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER) -# endif -# ifndef PTRDIFF_MAX -# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) -# endif -# ifndef PTRDIFF_MIN -# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) -# endif -# ifndef UINTPTR_MAX -# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX) -# endif -# ifndef INTPTR_MAX -# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) -# endif -# ifndef INTPTR_MIN -# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) -# endif -# ifndef INTPTR_C -# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x) -# endif -# ifndef UINTPTR_C -# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x) -# endif - typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t; - typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t; -# else -/* TODO -- This following is likely wrong for some platforms, and does - nothing for the definition of uintptr_t. */ - typedef ptrdiff_t intptr_t; -# endif -# define STDINT_H_UINTPTR_T_DEFINED -#endif - -/* - * Assumes sig_atomic_t is signed and we have a 2s complement machine. - */ - -#ifndef SIG_ATOMIC_MAX -# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1) -#endif - -#endif - -#if defined (__TEST_PSTDINT_FOR_CORRECTNESS) - -/* - * Please compile with the maximum warning settings to make sure macros are - * not defined more than once. - */ - -#include -#include -#include - -#define glue3_aux(x,y,z) x ## y ## z -#define glue3(x,y,z) glue3_aux(x,y,z) - -#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0); -#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0); - -#define DECL(us,bits) glue3(DECL,us,) (bits) - -#define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits) - -#define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; } - -int main () { - int err_n = 0; - int err_first = 0; - DECL(I,8) - DECL(U,8) - DECL(I,16) - DECL(U,16) - DECL(I,32) - DECL(U,32) -#ifdef INT64_MAX - DECL(I,64) - DECL(U,64) -#endif - intmax_t imax = INTMAX_C(0); - uintmax_t umax = UINTMAX_C(0); - char str0[256], str1[256]; - - sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647)); - if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0)); - if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH)); - sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295)); - if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0)); - if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH)); -#ifdef INT64_MAX - sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807)); - if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1)); - if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1))); - sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591)); - if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1)); - if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1))); -#endif - - sprintf (str0, "%d %x\n", 0, ~0); - - sprintf (str1, "%d %x\n", i8, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1)); - sprintf (str1, "%u %x\n", u8, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1)); - sprintf (str1, "%d %x\n", i16, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1)); - sprintf (str1, "%u %x\n", u16, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1)); - sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1)); - sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1)); -#ifdef INT64_MAX - sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1)); -#endif - sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1)); - sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1)); - - TESTUMAX(8); - TESTUMAX(16); - TESTUMAX(32); -#ifdef INT64_MAX - TESTUMAX(64); -#endif - -#define STR(v) #v -#define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v)); - if (err_n) { - printf ("pstdint.h is not correct. Please use sizes below to correct it:\n"); - } - - Q(int) - Q(unsigned) - Q(long int) - Q(short int) - Q(int8_t) - Q(int16_t) - Q(int32_t) -#ifdef INT64_MAX - Q(int64_t) -#endif - - return EXIT_SUCCESS; -} - -#endif diff --git a/thirdparty/include/assimp/Compiler/pushpack1.h b/thirdparty/include/assimp/Compiler/pushpack1.h deleted file mode 100644 index 73973c50d..000000000 --- a/thirdparty/include/assimp/Compiler/pushpack1.h +++ /dev/null @@ -1,46 +0,0 @@ - - -// =============================================================================== -// May be included multiple times - sets structure packing to 1 -// for all supported compilers. #include reverts the changes. -// -// Currently this works on the following compilers: -// MSVC 7,8,9 -// GCC -// BORLAND (complains about 'pack state changed but not reverted', but works) -// Clang -// -// -// USAGE: -// -// struct StructToBePacked { -// } PACK_STRUCT; -// -// =============================================================================== - -#ifdef AI_PUSHPACK_IS_DEFINED -# error poppack1.h must be included after pushpack1.h -#endif - -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) -# pragma pack(push,1) -# define PACK_STRUCT -#elif defined( __GNUC__ ) -# if !defined(HOST_MINGW) -# define PACK_STRUCT __attribute__((__packed__)) -# else -# define PACK_STRUCT __attribute__((gcc_struct, __packed__)) -# endif -#else -# error Compiler not supported -#endif - -#if defined(_MSC_VER) - -// C4103: Packing was changed after the inclusion of the header, probably missing #pragma pop -# pragma warning (disable : 4103) -#endif - -#define AI_PUSHPACK_IS_DEFINED - - diff --git a/thirdparty/include/assimp/DefaultLogger.hpp b/thirdparty/include/assimp/DefaultLogger.hpp deleted file mode 100644 index 52574d5ea..000000000 --- a/thirdparty/include/assimp/DefaultLogger.hpp +++ /dev/null @@ -1,190 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ -/** @file DefaultLogger.hpp -*/ - -#ifndef INCLUDED_AI_DEFAULTLOGGER -#define INCLUDED_AI_DEFAULTLOGGER - -#include "Logger.hpp" -#include "LogStream.hpp" -#include "NullLogger.hpp" -#include - -namespace Assimp { -// ------------------------------------------------------------------------------------ -class IOStream; -struct LogStreamInfo; - -/** default name of logfile */ -#define ASSIMP_DEFAULT_LOG_NAME "AssimpLog.txt" - -// ------------------------------------------------------------------------------------ -/** @brief CPP-API: Primary logging facility of Assimp. - * - * The library stores its primary #Logger as a static member of this class. - * #get() returns this primary logger. By default the underlying implementation is - * just a #NullLogger which rejects all log messages. By calling #create(), logging - * is turned on. To capture the log output multiple log streams (#LogStream) can be - * attach to the logger. Some default streams for common streaming locations (such as - * a file, std::cout, OutputDebugString()) are also provided. - * - * If you wish to customize the logging at an even deeper level supply your own - * implementation of #Logger to #set(). - * @note The whole logging stuff causes a small extra overhead for all imports. */ -class ASSIMP_API DefaultLogger : - public Logger { - -public: - - // ---------------------------------------------------------------------- - /** @brief Creates a logging instance. - * @param name Name for log file. Only valid in combination - * with the aiDefaultLogStream_FILE flag. - * @param severity Log severity, VERBOSE turns on debug messages - * @param defStreams Default log streams to be attached. Any bitwise - * combination of the aiDefaultLogStream enumerated values. - * If #aiDefaultLogStream_FILE is specified but an empty string is - * passed for 'name', no log file is created at all. - * @param io IOSystem to be used to open external files (such as the - * log file). Pass NULL to rely on the default implementation. - * This replaces the default #NullLogger with a #DefaultLogger instance. */ - static Logger *create(const char* name = ASSIMP_DEFAULT_LOG_NAME, - LogSeverity severity = NORMAL, - unsigned int defStreams = aiDefaultLogStream_DEBUGGER | aiDefaultLogStream_FILE, - IOSystem* io = NULL); - - // ---------------------------------------------------------------------- - /** @brief Setup a custom #Logger implementation. - * - * Use this if the provided #DefaultLogger class doesn't fit into - * your needs. If the provided message formatting is OK for you, - * it's much easier to use #create() and to attach your own custom - * output streams to it. - * @param logger Pass NULL to setup a default NullLogger*/ - static void set (Logger *logger); - - // ---------------------------------------------------------------------- - /** @brief Getter for singleton instance - * @return Only instance. This is never null, but it could be a - * NullLogger. Use isNullLogger to check this.*/ - static Logger *get(); - - // ---------------------------------------------------------------------- - /** @brief Return whether a #NullLogger is currently active - * @return true if the current logger is a #NullLogger. - * Use create() or set() to setup a logger that does actually do - * something else than just rejecting all log messages. */ - static bool isNullLogger(); - - // ---------------------------------------------------------------------- - /** @brief Kills the current singleton logger and replaces it with a - * #NullLogger instance. */ - static void kill(); - - // ---------------------------------------------------------------------- - /** @copydoc Logger::attachStream */ - bool attachStream(LogStream *pStream, - unsigned int severity); - - // ---------------------------------------------------------------------- - /** @copydoc Logger::detatchStream */ - bool detatchStream(LogStream *pStream, - unsigned int severity); - - -private: - - // ---------------------------------------------------------------------- - /** @briefPrivate construction for internal use by create(). - * @param severity Logging granularity */ - explicit DefaultLogger(LogSeverity severity); - - // ---------------------------------------------------------------------- - /** @briefDestructor */ - ~DefaultLogger(); - -private: - - /** @brief Logs debug infos, only been written when severity level VERBOSE is set */ - void OnDebug(const char* message); - - /** @brief Logs an info message */ - void OnInfo(const char* message); - - /** @brief Logs a warning message */ - void OnWarn(const char* message); - - /** @brief Logs an error message */ - void OnError(const char* message); - - // ---------------------------------------------------------------------- - /** @brief Writes a message to all streams */ - void WriteToStreams(const char* message, ErrorSeverity ErrorSev ); - - // ---------------------------------------------------------------------- - /** @brief Returns the thread id. - * @note This is an OS specific feature, if not supported, a - * zero will be returned. - */ - unsigned int GetThreadID(); - -private: - // Aliases for stream container - typedef std::vector StreamArray; - typedef std::vector::iterator StreamIt; - typedef std::vector::const_iterator ConstStreamIt; - - //! only logging instance - static Logger *m_pLogger; - static NullLogger s_pNullLogger; - - //! Attached streams - StreamArray m_StreamArray; - - bool noRepeatMsg; - char lastMsg[MAX_LOG_MESSAGE_LENGTH*2]; - size_t lastLen; -}; -// ------------------------------------------------------------------------------------ - -} // Namespace Assimp - -#endif // !! INCLUDED_AI_DEFAULTLOGGER diff --git a/thirdparty/include/assimp/Exporter.hpp b/thirdparty/include/assimp/Exporter.hpp deleted file mode 100644 index 079060f4b..000000000 --- a/thirdparty/include/assimp/Exporter.hpp +++ /dev/null @@ -1,504 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2011, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file Exporter.hpp -* @brief Defines the CPP-API for the Assimp export interface -*/ -#ifndef AI_EXPORT_HPP_INC -#define AI_EXPORT_HPP_INC - -#ifndef ASSIMP_BUILD_NO_EXPORT - -#include "cexport.h" -#include - -namespace Assimp { - class ExporterPimpl; - class IOSystem; - - -// ---------------------------------------------------------------------------------- -/** CPP-API: The Exporter class forms an C++ interface to the export functionality - * of the Open Asset Import Library. Note that the export interface is available - * only if Assimp has been built with ASSIMP_BUILD_NO_EXPORT not defined. - * - * The interface is modelled after the importer interface and mostly - * symmetric. The same rules for threading etc. apply. - * - * In a nutshell, there are two export interfaces: #Export, which writes the - * output file(s) either to the regular file system or to a user-supplied - * #IOSystem, and #ExportToBlob which returns a linked list of memory - * buffers (blob), each referring to one output file (in most cases - * there will be only one output file of course, but this extra complexity is - * needed since Assimp aims at supporting a wide range of file formats). - * - * #ExportToBlob is especially useful if you intend to work - * with the data in-memory. -*/ - -class ASSIMP_API ExportProperties; - -class ASSIMP_API Exporter - // TODO: causes good ol' base class has no dll interface warning -//#ifdef __cplusplus -// : public boost::noncopyable -//#endif // __cplusplus -{ -public: - - /** Function pointer type of a Export worker function */ - typedef void (*fpExportFunc)(const char*, IOSystem*, const aiScene*, const ExportProperties*); - - /** Internal description of an Assimp export format option */ - struct ExportFormatEntry - { - /// Public description structure to be returned by aiGetExportFormatDescription() - aiExportFormatDesc mDescription; - - // Worker function to do the actual exporting - fpExportFunc mExportFunction; - - // Postprocessing steps to be executed PRIOR to invoking mExportFunction - unsigned int mEnforcePP; - - // Constructor to fill all entries - ExportFormatEntry( const char* pId, const char* pDesc, const char* pExtension, fpExportFunc pFunction, unsigned int pEnforcePP = 0u) - { - mDescription.id = pId; - mDescription.description = pDesc; - mDescription.fileExtension = pExtension; - mExportFunction = pFunction; - mEnforcePP = pEnforcePP; - } - - ExportFormatEntry() : - mExportFunction() - , mEnforcePP() - { - mDescription.id = NULL; - mDescription.description = NULL; - mDescription.fileExtension = NULL; - } - }; - - -public: - - - Exporter(); - ~Exporter(); - -public: - - - // ------------------------------------------------------------------- - /** Supplies a custom IO handler to the exporter to use to open and - * access files. - * - * If you need #Export to use custom IO logic to access the files, - * you need to supply a custom implementation of IOSystem and - * IOFile to the exporter. - * - * #Exporter takes ownership of the object and will destroy it - * afterwards. The previously assigned handler will be deleted. - * Pass NULL to take again ownership of your IOSystem and reset Assimp - * to use its default implementation, which uses plain file IO. - * - * @param pIOHandler The IO handler to be used in all file accesses - * of the Importer. */ - void SetIOHandler( IOSystem* pIOHandler); - - // ------------------------------------------------------------------- - /** Retrieves the IO handler that is currently set. - * You can use #IsDefaultIOHandler() to check whether the returned - * interface is the default IO handler provided by ASSIMP. The default - * handler is active as long the application doesn't supply its own - * custom IO handler via #SetIOHandler(). - * @return A valid IOSystem interface, never NULL. */ - IOSystem* GetIOHandler() const; - - // ------------------------------------------------------------------- - /** Checks whether a default IO handler is active - * A default handler is active as long the application doesn't - * supply its own custom IO handler via #SetIOHandler(). - * @return true by default */ - bool IsDefaultIOHandler() const; - - - - // ------------------------------------------------------------------- - /** Exports the given scene to a chosen file format. Returns the exported - * data as a binary blob which you can write into a file or something. - * When you're done with the data, simply let the #Exporter instance go - * out of scope to have it released automatically. - * @param pScene The scene to export. Stays in possession of the caller, - * is not changed by the function. - * @param pFormatId ID string to specify to which format you want to - * export to. Use - * #GetExportFormatCount / #GetExportFormatDescription to learn which - * export formats are available. - * @param pPreprocessing See the documentation for #Export - * @return the exported data or NULL in case of error. - * @note If the Exporter instance did already hold a blob from - * a previous call to #ExportToBlob, it will be disposed. - * Any IO handlers set via #SetIOHandler are ignored here. - * @note Use aiCopyScene() to get a modifiable copy of a previously - * imported scene. */ - const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL); - inline const aiExportDataBlob* ExportToBlob( const aiScene* pScene, const std::string& pFormatId, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL); - - - // ------------------------------------------------------------------- - /** Convenience function to export directly to a file. Use - * #SetIOSystem to supply a custom IOSystem to gain fine-grained control - * about the output data flow of the export process. - * @param pBlob A data blob obtained from a previous call to #aiExportScene. Must not be NULL. - * @param pPath Full target file name. Target must be accessible. - * @param pPreprocessing Accepts any choice of the #aiPostProcessSteps enumerated - * flags, but in reality only a subset of them makes sense here. Specifying - * 'preprocessing' flags is useful if the input scene does not conform to - * Assimp's default conventions as specified in the @link data Data Structures Page @endlink. - * In short, this means the geometry data should use a right-handed coordinate systems, face - * winding should be counter-clockwise and the UV coordinate origin is assumed to be in - * the upper left. The #aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and - * #aiProcess_FlipWindingOrder flags are used in the import side to allow users - * to have those defaults automatically adapted to their conventions. Specifying those flags - * for exporting has the opposite effect, respectively. Some other of the - * #aiPostProcessSteps enumerated values may be useful as well, but you'll need - * to try out what their effect on the exported file is. Many formats impose - * their own restrictions on the structure of the geometry stored therein, - * so some preprocessing may have little or no effect at all, or may be - * redundant as exporters would apply them anyhow. A good example - * is triangulation - whilst you can enforce it by specifying - * the #aiProcess_Triangulate flag, most export formats support only - * triangulate data so they would run the step even if it wasn't requested. - * - * If assimp detects that the input scene was directly taken from the importer side of - * the library (i.e. not copied using aiCopyScene and potetially modified afterwards), - * any postprocessing steps already applied to the scene will not be applied again, unless - * they show non-idempotent behaviour (#aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and - * #aiProcess_FlipWindingOrder). - * @return AI_SUCCESS if everything was fine. - * @note Use aiCopyScene() to get a modifiable copy of a previously - * imported scene.*/ - aiReturn Export( const aiScene* pScene, const char* pFormatId, const char* pPath, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL); - inline aiReturn Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing = 0u, const ExportProperties* pProperties = NULL); - - - // ------------------------------------------------------------------- - /** Returns an error description of an error that occurred in #Export - * or #ExportToBlob - * - * Returns an empty string if no error occurred. - * @return A description of the last error, an empty string if no - * error occurred. The string is never NULL. - * - * @note The returned function remains valid until one of the - * following methods is called: #Export, #ExportToBlob, #FreeBlob */ - const char* GetErrorString() const; - - - // ------------------------------------------------------------------- - /** Return the blob obtained from the last call to #ExportToBlob */ - const aiExportDataBlob* GetBlob() const; - - - // ------------------------------------------------------------------- - /** Orphan the blob from the last call to #ExportToBlob. This means - * the caller takes ownership and is thus responsible for calling - * the C API function #aiReleaseExportBlob to release it. */ - const aiExportDataBlob* GetOrphanedBlob() const; - - - // ------------------------------------------------------------------- - /** Frees the current blob. - * - * The function does nothing if no blob has previously been - * previously produced via #ExportToBlob. #FreeBlob is called - * automatically by the destructor. The only reason to call - * it manually would be to reclain as much storage as possible - * without giving up the #Exporter instance yet. */ - void FreeBlob( ); - - - // ------------------------------------------------------------------- - /** Returns the number of export file formats available in the current - * Assimp build. Use #Exporter::GetExportFormatDescription to - * retrieve infos of a specific export format. - * - * This includes built-in exporters as well as exporters registered - * using #RegisterExporter. - **/ - size_t GetExportFormatCount() const; - - - // ------------------------------------------------------------------- - /** Returns a description of the nth export file format. Use # - * #Exporter::GetExportFormatCount to learn how many export - * formats are supported. - * - * The returned pointer is of static storage duration iff the - * pIndex pertains to a built-in exporter (i.e. one not registered - * via #RegistrerExporter). It is restricted to the life-time of the - * #Exporter instance otherwise. - * - * @param pIndex Index of the export format to retrieve information - * for. Valid range is 0 to #Exporter::GetExportFormatCount - * @return A description of that specific export format. - * NULL if pIndex is out of range. */ - const aiExportFormatDesc* GetExportFormatDescription( size_t pIndex ) const; - - - // ------------------------------------------------------------------- - /** Register a custom exporter. Custom export formats are limited to - * to the current #Exporter instance and do not affect the - * library globally. The indexes under which the format's - * export format description can be queried are assigned - * monotonously. - * @param desc Exporter description. - * @return aiReturn_SUCCESS if the export format was successfully - * registered. A common cause that would prevent an exporter - * from being registered is that its format id is already - * occupied by another format. */ - aiReturn RegisterExporter(const ExportFormatEntry& desc); - - - // ------------------------------------------------------------------- - /** Remove an export format previously registered with #RegisterExporter - * from the #Exporter instance (this can also be used to drop - * builtin exporters because those are implicitly registered - * using #RegisterExporter). - * @param id Format id to be unregistered, this refers to the - * 'id' field of #aiExportFormatDesc. - * @note Calling this method on a format description not yet registered - * has no effect.*/ - void UnregisterExporter(const char* id); - - -protected: - - // Just because we don't want you to know how we're hacking around. - ExporterPimpl* pimpl; -}; - - -class ASSIMP_API ExportProperties -{ -public: - // Data type to store the key hash - typedef unsigned int KeyType; - - // typedefs for our four configuration maps. - // We don't need more, so there is no need for a generic solution - typedef std::map IntPropertyMap; - typedef std::map FloatPropertyMap; - typedef std::map StringPropertyMap; - typedef std::map MatrixPropertyMap; - -public: - - /** Standard constructor - * @see ExportProperties() - */ - - ExportProperties(); - - // ------------------------------------------------------------------- - /** Copy constructor. - * - * This copies the configuration properties of another ExportProperties. - * @see ExportProperties(const ExportProperties& other) - */ - ExportProperties(const ExportProperties& other); - - // ------------------------------------------------------------------- - /** Set an integer configuration property. - * @param szName Name of the property. All supported properties - * are defined in the aiConfig.g header (all constants share the - * prefix AI_CONFIG_XXX and are simple strings). - * @param iValue New value of the property - * @return true if the property was set before. The new value replaces - * the previous value in this case. - * @note Property of different types (float, int, string ..) are kept - * on different stacks, so calling SetPropertyInteger() for a - * floating-point property has no effect - the loader will call - * GetPropertyFloat() to read the property, but it won't be there. - */ - bool SetPropertyInteger(const char* szName, int iValue); - - // ------------------------------------------------------------------- - /** Set a boolean configuration property. Boolean properties - * are stored on the integer stack internally so it's possible - * to set them via #SetPropertyBool and query them with - * #GetPropertyBool and vice versa. - * @see SetPropertyInteger() - */ - bool SetPropertyBool(const char* szName, bool value) { - return SetPropertyInteger(szName,value); - } - - // ------------------------------------------------------------------- - /** Set a floating-point configuration property. - * @see SetPropertyInteger() - */ - bool SetPropertyFloat(const char* szName, float fValue); - - // ------------------------------------------------------------------- - /** Set a string configuration property. - * @see SetPropertyInteger() - */ - bool SetPropertyString(const char* szName, const std::string& sValue); - - // ------------------------------------------------------------------- - /** Set a matrix configuration property. - * @see SetPropertyInteger() - */ - bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue); - - // ------------------------------------------------------------------- - /** Get a configuration property. - * @param szName Name of the property. All supported properties - * are defined in the aiConfig.g header (all constants share the - * prefix AI_CONFIG_XXX). - * @param iErrorReturn Value that is returned if the property - * is not found. - * @return Current value of the property - * @note Property of different types (float, int, string ..) are kept - * on different lists, so calling SetPropertyInteger() for a - * floating-point property has no effect - the loader will call - * GetPropertyFloat() to read the property, but it won't be there. - */ - int GetPropertyInteger(const char* szName, - int iErrorReturn = 0xffffffff) const; - - // ------------------------------------------------------------------- - /** Get a boolean configuration property. Boolean properties - * are stored on the integer stack internally so it's possible - * to set them via #SetPropertyBool and query them with - * #GetPropertyBool and vice versa. - * @see GetPropertyInteger() - */ - bool GetPropertyBool(const char* szName, bool bErrorReturn = false) const { - return GetPropertyInteger(szName,bErrorReturn)!=0; - } - - // ------------------------------------------------------------------- - /** Get a floating-point configuration property - * @see GetPropertyInteger() - */ - float GetPropertyFloat(const char* szName, - float fErrorReturn = 10e10f) const; - - // ------------------------------------------------------------------- - /** Get a string configuration property - * - * The return value remains valid until the property is modified. - * @see GetPropertyInteger() - */ - const std::string GetPropertyString(const char* szName, - const std::string& sErrorReturn = "") const; - - // ------------------------------------------------------------------- - /** Get a matrix configuration property - * - * The return value remains valid until the property is modified. - * @see GetPropertyInteger() - */ - const aiMatrix4x4 GetPropertyMatrix(const char* szName, - const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const; - - // ------------------------------------------------------------------- - /** Determine a integer configuration property has been set. - * @see HasPropertyInteger() - */ - bool HasPropertyInteger(const char* szName) const; - - /** Determine a boolean configuration property has been set. - * @see HasPropertyBool() - */ - bool HasPropertyBool(const char* szName) const; - - /** Determine a boolean configuration property has been set. - * @see HasPropertyFloat() - */ - bool HasPropertyFloat(const char* szName) const; - - /** Determine a String configuration property has been set. - * @see HasPropertyString() - */ - bool HasPropertyString(const char* szName) const; - - /** Determine a Matrix configuration property has been set. - * @see HasPropertyMatrix() - */ - bool HasPropertyMatrix(const char* szName) const; - -protected: - - /** List of integer properties */ - IntPropertyMap mIntProperties; - - /** List of floating-point properties */ - FloatPropertyMap mFloatProperties; - - /** List of string properties */ - StringPropertyMap mStringProperties; - - /** List of Matrix properties */ - MatrixPropertyMap mMatrixProperties; -}; - - -// ---------------------------------------------------------------------------------- -inline const aiExportDataBlob* Exporter :: ExportToBlob( const aiScene* pScene, const std::string& pFormatId,unsigned int pPreprocessing, const ExportProperties* pProperties) -{ - return ExportToBlob(pScene,pFormatId.c_str(),pPreprocessing, pProperties); -} - -// ---------------------------------------------------------------------------------- -inline aiReturn Exporter :: Export( const aiScene* pScene, const std::string& pFormatId, const std::string& pPath, unsigned int pPreprocessing, const ExportProperties* pProperties) -{ - return Export(pScene,pFormatId.c_str(),pPath.c_str(),pPreprocessing, pProperties); -} - -} // namespace Assimp -#endif // ASSIMP_BUILD_NO_EXPORT -#endif // AI_EXPORT_HPP_INC diff --git a/thirdparty/include/assimp/IOStream.hpp b/thirdparty/include/assimp/IOStream.hpp deleted file mode 100644 index 6cc231b3d..000000000 --- a/thirdparty/include/assimp/IOStream.hpp +++ /dev/null @@ -1,138 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ -/** @file IOStream.hpp - * @brief File I/O wrappers for C++. - */ - -#ifndef AI_IOSTREAM_H_INC -#define AI_IOSTREAM_H_INC - -#include "types.h" - -#ifndef __cplusplus -# error This header requires C++ to be used. aiFileIO.h is the \ - corresponding C interface. -#endif - -namespace Assimp { - -// ---------------------------------------------------------------------------------- -/** @brief CPP-API: Class to handle file I/O for C++ - * - * Derive an own implementation from this interface to provide custom IO handling - * to the Importer. If you implement this interface, be sure to also provide an - * implementation for IOSystem that creates instances of your custom IO class. -*/ -class ASSIMP_API IOStream -#ifndef SWIG - : public Intern::AllocateFromAssimpHeap -#endif -{ -protected: - /** Constructor protected, use IOSystem::Open() to create an instance. */ - IOStream(void); - -public: - // ------------------------------------------------------------------- - /** @brief Destructor. Deleting the object closes the underlying file, - * alternatively you may use IOSystem::Close() to release the file. - */ - virtual ~IOStream(); - - // ------------------------------------------------------------------- - /** @brief Read from the file - * - * See fread() for more details - * This fails for write-only files */ - virtual size_t Read(void* pvBuffer, - size_t pSize, - size_t pCount) = 0; - - // ------------------------------------------------------------------- - /** @brief Write to the file - * - * See fwrite() for more details - * This fails for read-only files */ - virtual size_t Write(const void* pvBuffer, - size_t pSize, - size_t pCount) = 0; - - // ------------------------------------------------------------------- - /** @brief Set the read/write cursor of the file - * - * Note that the offset is _negative_ for aiOrigin_END. - * See fseek() for more details */ - virtual aiReturn Seek(size_t pOffset, - aiOrigin pOrigin) = 0; - - // ------------------------------------------------------------------- - /** @brief Get the current position of the read/write cursor - * - * See ftell() for more details */ - virtual size_t Tell() const = 0; - - // ------------------------------------------------------------------- - /** @brief Returns filesize - * Returns the filesize. */ - virtual size_t FileSize() const = 0; - - // ------------------------------------------------------------------- - /** @brief Flush the contents of the file buffer (for writers) - * See fflush() for more details. - */ - virtual void Flush() = 0; -}; //! class IOStream - -// ---------------------------------------------------------------------------------- -inline IOStream::IOStream() -{ - // empty -} - -// ---------------------------------------------------------------------------------- -inline IOStream::~IOStream() -{ - // empty -} -// ---------------------------------------------------------------------------------- -} //!namespace Assimp - -#endif //!!AI_IOSTREAM_H_INC diff --git a/thirdparty/include/assimp/IOSystem.hpp b/thirdparty/include/assimp/IOSystem.hpp deleted file mode 100644 index abd7e5837..000000000 --- a/thirdparty/include/assimp/IOSystem.hpp +++ /dev/null @@ -1,290 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file IOSystem.hpp - * @brief File system wrapper for C++. Inherit this class to supply - * custom file handling logic to the Import library. -*/ - -#ifndef AI_IOSYSTEM_H_INC -#define AI_IOSYSTEM_H_INC - -#ifndef __cplusplus -# error This header requires C++ to be used. aiFileIO.h is the \ - corresponding C interface. -#endif - -#include "types.h" - -#include - -namespace Assimp { -class IOStream; - -// --------------------------------------------------------------------------- -/** @brief CPP-API: Interface to the file system. - * - * Derive an own implementation from this interface to supply custom file handling - * to the importer library. If you implement this interface, you also want to - * supply a custom implementation for IOStream. - * - * @see Importer::SetIOHandler() */ -class ASSIMP_API IOSystem -#ifndef SWIG - : public Intern::AllocateFromAssimpHeap -#endif -{ -public: - - // ------------------------------------------------------------------- - /** @brief Default constructor. - * - * Create an instance of your derived class and assign it to an - * #Assimp::Importer instance by calling Importer::SetIOHandler(). - */ - IOSystem(); - - // ------------------------------------------------------------------- - /** @brief Virtual destructor. - * - * It is safe to be called from within DLL Assimp, we're constructed - * on Assimp's heap. - */ - virtual ~IOSystem(); - - -public: - - // ------------------------------------------------------------------- - /** @brief For backward compatibility - * @see Exists(const char*) - */ - AI_FORCE_INLINE bool Exists( const std::string& pFile) const; - - // ------------------------------------------------------------------- - /** @brief Tests for the existence of a file at the given path. - * - * @param pFile Path to the file - * @return true if there is a file with this path, else false. - */ - virtual bool Exists( const char* pFile) const = 0; - - // ------------------------------------------------------------------- - /** @brief Returns the system specific directory separator - * @return System specific directory separator - */ - virtual char getOsSeparator() const = 0; - - // ------------------------------------------------------------------- - /** @brief Open a new file with a given path. - * - * When the access to the file is finished, call Close() to release - * all associated resources (or the virtual dtor of the IOStream). - * - * @param pFile Path to the file - * @param pMode Desired file I/O mode. Required are: "wb", "w", "wt", - * "rb", "r", "rt". - * - * @return New IOStream interface allowing the lib to access - * the underlying file. - * @note When implementing this class to provide custom IO handling, - * you probably have to supply an own implementation of IOStream as well. - */ - virtual IOStream* Open(const char* pFile, - const char* pMode = "rb") = 0; - - // ------------------------------------------------------------------- - /** @brief For backward compatibility - * @see Open(const char*, const char*) - */ - inline IOStream* Open(const std::string& pFile, - const std::string& pMode = std::string("rb")); - - // ------------------------------------------------------------------- - /** @brief Closes the given file and releases all resources - * associated with it. - * @param pFile The file instance previously created by Open(). - */ - virtual void Close( IOStream* pFile) = 0; - - // ------------------------------------------------------------------- - /** @brief Compares two paths and check whether the point to - * identical files. - * - * The dummy implementation of this virtual member performs a - * case-insensitive comparison of the given strings. The default IO - * system implementation uses OS mechanisms to convert relative into - * absolute paths, so the result can be trusted. - * @param one First file - * @param second Second file - * @return true if the paths point to the same file. The file needn't - * be existing, however. - */ - virtual bool ComparePaths (const char* one, - const char* second) const; - - // ------------------------------------------------------------------- - /** @brief For backward compatibility - * @see ComparePaths(const char*, const char*) - */ - inline bool ComparePaths (const std::string& one, - const std::string& second) const; - - // ------------------------------------------------------------------- - /** @brief Pushes a new directory onto the directory stack. - * @param path Path to push onto the stack. - * @return True, when push was successful, false if path is empty. - */ - virtual bool PushDirectory( const std::string &path ); - - // ------------------------------------------------------------------- - /** @brief Returns the top directory from the stack. - * @return The directory on the top of the stack. - * Returns empty when no directory was pushed to the stack. - */ - virtual const std::string &CurrentDirectory() const; - - // ------------------------------------------------------------------- - /** @brief Returns the number of directories stored on the stack. - * @return The number of directories of the stack. - */ - virtual size_t StackSize() const; - - // ------------------------------------------------------------------- - /** @brief Pops the top directory from the stack. - * @return True, when a directory was on the stack. False if no - * directory was on the stack. - */ - virtual bool PopDirectory(); - -private: - std::vector m_pathStack; -}; - -// ---------------------------------------------------------------------------- -AI_FORCE_INLINE IOSystem::IOSystem() : - m_pathStack() -{ - // empty -} - -// ---------------------------------------------------------------------------- -AI_FORCE_INLINE IOSystem::~IOSystem() -{ - // empty -} - -// ---------------------------------------------------------------------------- -// For compatibility, the interface of some functions taking a std::string was -// changed to const char* to avoid crashes between binary incompatible STL -// versions. This code her is inlined, so it shouldn't cause any problems. -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -AI_FORCE_INLINE IOStream* IOSystem::Open(const std::string& pFile, - const std::string& pMode) -{ - // NOTE: - // For compatibility, interface was changed to const char* to - // avoid crashes between binary incompatible STL versions - return Open(pFile.c_str(),pMode.c_str()); -} - -// ---------------------------------------------------------------------------- -AI_FORCE_INLINE bool IOSystem::Exists( const std::string& pFile) const -{ - // NOTE: - // For compatibility, interface was changed to const char* to - // avoid crashes between binary incompatible STL versions - return Exists(pFile.c_str()); -} - -// ---------------------------------------------------------------------------- -inline bool IOSystem::ComparePaths (const std::string& one, - const std::string& second) const -{ - // NOTE: - // For compatibility, interface was changed to const char* to - // avoid crashes between binary incompatible STL versions - return ComparePaths(one.c_str(),second.c_str()); -} - -// ---------------------------------------------------------------------------- -inline bool IOSystem::PushDirectory( const std::string &path ) { - if ( path.empty() ) { - return false; - } - - m_pathStack.push_back( path ); - - return true; -} - -// ---------------------------------------------------------------------------- -inline const std::string &IOSystem::CurrentDirectory() const { - if ( m_pathStack.empty() ) { - static const std::string Dummy(""); - return Dummy; - } - return m_pathStack[ m_pathStack.size()-1 ]; -} - -// ---------------------------------------------------------------------------- -inline size_t IOSystem::StackSize() const { - return m_pathStack.size(); -} - -// ---------------------------------------------------------------------------- -inline bool IOSystem::PopDirectory() { - if ( m_pathStack.empty() ) { - return false; - } - - m_pathStack.pop_back(); - - return true; -} - -// ---------------------------------------------------------------------------- - -} //!ns Assimp - -#endif //AI_IOSYSTEM_H_INC diff --git a/thirdparty/include/assimp/Importer.hpp b/thirdparty/include/assimp/Importer.hpp deleted file mode 100644 index 4c01367ed..000000000 --- a/thirdparty/include/assimp/Importer.hpp +++ /dev/null @@ -1,661 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file Importer.hpp - * @brief Defines the C++-API to the Open Asset Import Library. - */ -#ifndef INCLUDED_AI_ASSIMP_HPP -#define INCLUDED_AI_ASSIMP_HPP - -#ifndef __cplusplus -# error This header requires C++ to be used. Use assimp.h for plain C. -#endif - -// Public ASSIMP data structures -#include "types.h" -#include "config.h" - -namespace Assimp { - // ======================================================================= - // Public interface to Assimp - class Importer; - class Exporter; // export.hpp - class IOStream; - class IOSystem; - class ProgressHandler; - - // ======================================================================= - // Plugin development - // - // Include the following headers for the declarations: - // BaseImporter.h - // BaseProcess.h - class BaseImporter; - class BaseProcess; - class SharedPostProcessInfo; - class BatchLoader; - - // ======================================================================= - // Holy stuff, only for members of the high council of the Jedi. - class ImporterPimpl; - class ExporterPimpl; // export.hpp -} //! namespace Assimp - -#define AI_PROPERTY_WAS_NOT_EXISTING 0xffffffff - -struct aiScene; - -// importerdesc.h -struct aiImporterDesc; - -/** @namespace Assimp Assimp's CPP-API and all internal APIs */ -namespace Assimp { - -// ---------------------------------------------------------------------------------- -/** CPP-API: The Importer class forms an C++ interface to the functionality of the -* Open Asset Import Library. -* -* Create an object of this class and call ReadFile() to import a file. -* If the import succeeds, the function returns a pointer to the imported data. -* The data remains property of the object, it is intended to be accessed -* read-only. The imported data will be destroyed along with the Importer -* object. If the import fails, ReadFile() returns a NULL pointer. In this -* case you can retrieve a human-readable error description be calling -* GetErrorString(). You can call ReadFile() multiple times with a single Importer -* instance. Actually, constructing Importer objects involves quite many -* allocations and may take some time, so it's better to reuse them as often as -* possible. -* -* If you need the Importer to do custom file handling to access the files, -* implement IOSystem and IOStream and supply an instance of your custom -* IOSystem implementation by calling SetIOHandler() before calling ReadFile(). -* If you do not assign a custion IO handler, a default handler using the -* standard C++ IO logic will be used. -* -* @note One Importer instance is not thread-safe. If you use multiple -* threads for loading, each thread should maintain its own Importer instance. -*/ -class ASSIMP_API Importer { -public: - /** - * @brief The upper limit for hints. - */ - static const unsigned int MaxLenHint = 200; - -public: - - // ------------------------------------------------------------------- - /** Constructor. Creates an empty importer object. - * - * Call ReadFile() to start the import process. The configuration - * property table is initially empty. - */ - Importer(); - - // ------------------------------------------------------------------- - /** Copy constructor. - * - * This copies the configuration properties of another Importer. - * If this Importer owns a scene it won't be copied. - * Call ReadFile() to start the import process. - */ - Importer(const Importer& other); - - // ------------------------------------------------------------------- - /** Destructor. The object kept ownership of the imported data, - * which now will be destroyed along with the object. - */ - ~Importer(); - - - // ------------------------------------------------------------------- - /** Registers a new loader. - * - * @param pImp Importer to be added. The Importer instance takes - * ownership of the pointer, so it will be automatically deleted - * with the Importer instance. - * @return AI_SUCCESS if the loader has been added. The registration - * fails if there is already a loader for a specific file extension. - */ - aiReturn RegisterLoader(BaseImporter* pImp); - - // ------------------------------------------------------------------- - /** Unregisters a loader. - * - * @param pImp Importer to be unregistered. - * @return AI_SUCCESS if the loader has been removed. The function - * fails if the loader is currently in use (this could happen - * if the #Importer instance is used by more than one thread) or - * if it has not yet been registered. - */ - aiReturn UnregisterLoader(BaseImporter* pImp); - - // ------------------------------------------------------------------- - /** Registers a new post-process step. - * - * At the moment, there's a small limitation: new post processing - * steps are added to end of the list, or in other words, executed - * last, after all built-in steps. - * @param pImp Post-process step to be added. The Importer instance - * takes ownership of the pointer, so it will be automatically - * deleted with the Importer instance. - * @return AI_SUCCESS if the step has been added correctly. - */ - aiReturn RegisterPPStep(BaseProcess* pImp); - - // ------------------------------------------------------------------- - /** Unregisters a post-process step. - * - * @param pImp Step to be unregistered. - * @return AI_SUCCESS if the step has been removed. The function - * fails if the step is currently in use (this could happen - * if the #Importer instance is used by more than one thread) or - * if it has not yet been registered. - */ - aiReturn UnregisterPPStep(BaseProcess* pImp); - - - // ------------------------------------------------------------------- - /** Set an integer configuration property. - * @param szName Name of the property. All supported properties - * are defined in the aiConfig.g header (all constants share the - * prefix AI_CONFIG_XXX and are simple strings). - * @param iValue New value of the property - * @return true if the property was set before. The new value replaces - * the previous value in this case. - * @note Property of different types (float, int, string ..) are kept - * on different stacks, so calling SetPropertyInteger() for a - * floating-point property has no effect - the loader will call - * GetPropertyFloat() to read the property, but it won't be there. - */ - bool SetPropertyInteger(const char* szName, int iValue); - - // ------------------------------------------------------------------- - /** Set a boolean configuration property. Boolean properties - * are stored on the integer stack internally so it's possible - * to set them via #SetPropertyBool and query them with - * #GetPropertyBool and vice versa. - * @see SetPropertyInteger() - */ - bool SetPropertyBool(const char* szName, bool value) { - return SetPropertyInteger(szName,value); - } - - // ------------------------------------------------------------------- - /** Set a floating-point configuration property. - * @see SetPropertyInteger() - */ - bool SetPropertyFloat(const char* szName, float fValue); - - // ------------------------------------------------------------------- - /** Set a string configuration property. - * @see SetPropertyInteger() - */ - bool SetPropertyString(const char* szName, const std::string& sValue); - - // ------------------------------------------------------------------- - /** Set a matrix configuration property. - * @see SetPropertyInteger() - */ - bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue); - - // ------------------------------------------------------------------- - /** Get a configuration property. - * @param szName Name of the property. All supported properties - * are defined in the aiConfig.g header (all constants share the - * prefix AI_CONFIG_XXX). - * @param iErrorReturn Value that is returned if the property - * is not found. - * @return Current value of the property - * @note Property of different types (float, int, string ..) are kept - * on different lists, so calling SetPropertyInteger() for a - * floating-point property has no effect - the loader will call - * GetPropertyFloat() to read the property, but it won't be there. - */ - int GetPropertyInteger(const char* szName, - int iErrorReturn = 0xffffffff) const; - - // ------------------------------------------------------------------- - /** Get a boolean configuration property. Boolean properties - * are stored on the integer stack internally so it's possible - * to set them via #SetPropertyBool and query them with - * #GetPropertyBool and vice versa. - * @see GetPropertyInteger() - */ - bool GetPropertyBool(const char* szName, bool bErrorReturn = false) const { - return GetPropertyInteger(szName,bErrorReturn)!=0; - } - - // ------------------------------------------------------------------- - /** Get a floating-point configuration property - * @see GetPropertyInteger() - */ - float GetPropertyFloat(const char* szName, - float fErrorReturn = 10e10f) const; - - // ------------------------------------------------------------------- - /** Get a string configuration property - * - * The return value remains valid until the property is modified. - * @see GetPropertyInteger() - */ - const std::string GetPropertyString(const char* szName, - const std::string& sErrorReturn = "") const; - - // ------------------------------------------------------------------- - /** Get a matrix configuration property - * - * The return value remains valid until the property is modified. - * @see GetPropertyInteger() - */ - const aiMatrix4x4 GetPropertyMatrix(const char* szName, - const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const; - - // ------------------------------------------------------------------- - /** Supplies a custom IO handler to the importer to use to open and - * access files. If you need the importer to use custion IO logic to - * access the files, you need to provide a custom implementation of - * IOSystem and IOFile to the importer. Then create an instance of - * your custion IOSystem implementation and supply it by this function. - * - * The Importer takes ownership of the object and will destroy it - * afterwards. The previously assigned handler will be deleted. - * Pass NULL to take again ownership of your IOSystem and reset Assimp - * to use its default implementation. - * - * @param pIOHandler The IO handler to be used in all file accesses - * of the Importer. - */ - void SetIOHandler( IOSystem* pIOHandler); - - // ------------------------------------------------------------------- - /** Retrieves the IO handler that is currently set. - * You can use #IsDefaultIOHandler() to check whether the returned - * interface is the default IO handler provided by ASSIMP. The default - * handler is active as long the application doesn't supply its own - * custom IO handler via #SetIOHandler(). - * @return A valid IOSystem interface, never NULL. - */ - IOSystem* GetIOHandler() const; - - // ------------------------------------------------------------------- - /** Checks whether a default IO handler is active - * A default handler is active as long the application doesn't - * supply its own custom IO handler via #SetIOHandler(). - * @return true by default - */ - bool IsDefaultIOHandler() const; - - // ------------------------------------------------------------------- - /** Supplies a custom progress handler to the importer. This - * interface exposes a #Update() callback, which is called - * more or less periodically (please don't sue us if it - * isn't as periodically as you'd like it to have ...). - * This can be used to implement progress bars and loading - * timeouts. - * @param pHandler Progress callback interface. Pass NULL to - * disable progress reporting. - * @note Progress handlers can be used to abort the loading - * at almost any time.*/ - void SetProgressHandler ( ProgressHandler* pHandler ); - - // ------------------------------------------------------------------- - /** Retrieves the progress handler that is currently set. - * You can use #IsDefaultProgressHandler() to check whether the returned - * interface is the default handler provided by ASSIMP. The default - * handler is active as long the application doesn't supply its own - * custom handler via #SetProgressHandler(). - * @return A valid ProgressHandler interface, never NULL. - */ - ProgressHandler* GetProgressHandler() const; - - // ------------------------------------------------------------------- - /** Checks whether a default progress handler is active - * A default handler is active as long the application doesn't - * supply its own custom progress handler via #SetProgressHandler(). - * @return true by default - */ - bool IsDefaultProgressHandler() const; - - // ------------------------------------------------------------------- - /** @brief Check whether a given set of postprocessing flags - * is supported. - * - * Some flags are mutually exclusive, others are probably - * not available because your excluded them from your - * Assimp builds. Calling this function is recommended if - * you're unsure. - * - * @param pFlags Bitwise combination of the aiPostProcess flags. - * @return true if this flag combination is fine. - */ - bool ValidateFlags(unsigned int pFlags) const; - - // ------------------------------------------------------------------- - /** Reads the given file and returns its contents if successful. - * - * If the call succeeds, the contents of the file are returned as a - * pointer to an aiScene object. The returned data is intended to be - * read-only, the importer object keeps ownership of the data and will - * destroy it upon destruction. If the import fails, NULL is returned. - * A human-readable error description can be retrieved by calling - * GetErrorString(). The previous scene will be deleted during this call. - * @param pFile Path and filename to the file to be imported. - * @param pFlags Optional post processing steps to be executed after - * a successful import. Provide a bitwise combination of the - * #aiPostProcessSteps flags. If you wish to inspect the imported - * scene first in order to fine-tune your post-processing setup, - * consider to use #ApplyPostProcessing(). - * @return A pointer to the imported data, NULL if the import failed. - * The pointer to the scene remains in possession of the Importer - * instance. Use GetOrphanedScene() to take ownership of it. - * - * @note Assimp is able to determine the file format of a file - * automatically. - */ - const aiScene* ReadFile( - const char* pFile, - unsigned int pFlags); - - // ------------------------------------------------------------------- - /** Reads the given file from a memory buffer and returns its - * contents if successful. - * - * If the call succeeds, the contents of the file are returned as a - * pointer to an aiScene object. The returned data is intended to be - * read-only, the importer object keeps ownership of the data and will - * destroy it upon destruction. If the import fails, NULL is returned. - * A human-readable error description can be retrieved by calling - * GetErrorString(). The previous scene will be deleted during this call. - * Calling this method doesn't affect the active IOSystem. - * @param pBuffer Pointer to the file data - * @param pLength Length of pBuffer, in bytes - * @param pFlags Optional post processing steps to be executed after - * a successful import. Provide a bitwise combination of the - * #aiPostProcessSteps flags. If you wish to inspect the imported - * scene first in order to fine-tune your post-processing setup, - * consider to use #ApplyPostProcessing(). - * @param pHint An additional hint to the library. If this is a non - * empty string, the library looks for a loader to support - * the file extension specified by pHint and passes the file to - * the first matching loader. If this loader is unable to completely - * the request, the library continues and tries to determine the - * file format on its own, a task that may or may not be successful. - * Check the return value, and you'll know ... - * @return A pointer to the imported data, NULL if the import failed. - * The pointer to the scene remains in possession of the Importer - * instance. Use GetOrphanedScene() to take ownership of it. - * - * @note This is a straightforward way to decode models from memory - * buffers, but it doesn't handle model formats that spread their - * data across multiple files or even directories. Examples include - * OBJ or MD3, which outsource parts of their material info into - * external scripts. If you need full functionality, provide - * a custom IOSystem to make Assimp find these files and use - * the regular ReadFile() API. - */ - const aiScene* ReadFileFromMemory( - const void* pBuffer, - size_t pLength, - unsigned int pFlags, - const char* pHint = ""); - - // ------------------------------------------------------------------- - /** Apply post-processing to an already-imported scene. - * - * This is strictly equivalent to calling #ReadFile() with the same - * flags. However, you can use this separate function to inspect - * the imported scene first to fine-tune your post-processing setup. - * @param pFlags Provide a bitwise combination of the - * #aiPostProcessSteps flags. - * @return A pointer to the post-processed data. This is still the - * same as the pointer returned by #ReadFile(). However, if - * post-processing fails, the scene could now be NULL. - * That's quite a rare case, post processing steps are not really - * designed to 'fail'. To be exact, the #aiProcess_ValidateDS - * flag is currently the only post processing step which can actually - * cause the scene to be reset to NULL. - * - * @note The method does nothing if no scene is currently bound - * to the #Importer instance. */ - const aiScene* ApplyPostProcessing(unsigned int pFlags); - - const aiScene* ApplyCustomizedPostProcessing( BaseProcess *rootProcess, bool requestValidation ); - - // ------------------------------------------------------------------- - /** @brief Reads the given file and returns its contents if successful. - * - * This function is provided for backward compatibility. - * See the const char* version for detailed docs. - * @see ReadFile(const char*, pFlags) */ - const aiScene* ReadFile( - const std::string& pFile, - unsigned int pFlags); - - // ------------------------------------------------------------------- - /** Frees the current scene. - * - * The function does nothing if no scene has previously been - * read via ReadFile(). FreeScene() is called automatically by the - * destructor and ReadFile() itself. */ - void FreeScene( ); - - // ------------------------------------------------------------------- - /** Returns an error description of an error that occurred in ReadFile(). - * - * Returns an empty string if no error occurred. - * @return A description of the last error, an empty string if no - * error occurred. The string is never NULL. - * - * @note The returned function remains valid until one of the - * following methods is called: #ReadFile(), #FreeScene(). */ - const char* GetErrorString() const; - - // ------------------------------------------------------------------- - /** Returns the scene loaded by the last successful call to ReadFile() - * - * @return Current scene or NULL if there is currently no scene loaded */ - const aiScene* GetScene() const; - - // ------------------------------------------------------------------- - /** Returns the scene loaded by the last successful call to ReadFile() - * and releases the scene from the ownership of the Importer - * instance. The application is now responsible for deleting the - * scene. Any further calls to GetScene() or GetOrphanedScene() - * will return NULL - until a new scene has been loaded via ReadFile(). - * - * @return Current scene or NULL if there is currently no scene loaded - * @note Use this method with maximal caution, and only if you have to. - * By design, aiScene's are exclusively maintained, allocated and - * deallocated by Assimp and no one else. The reasoning behind this - * is the golden rule that deallocations should always be done - * by the module that did the original allocation because heaps - * are not necessarily shared. GetOrphanedScene() enforces you - * to delete the returned scene by yourself, but this will only - * be fine if and only if you're using the same heap as assimp. - * On Windows, it's typically fine provided everything is linked - * against the multithreaded-dll version of the runtime library. - * It will work as well for static linkage with Assimp.*/ - aiScene* GetOrphanedScene(); - - - - - // ------------------------------------------------------------------- - /** Returns whether a given file extension is supported by ASSIMP. - * - * @param szExtension Extension to be checked. - * Must include a trailing dot '.'. Example: ".3ds", ".md3". - * Cases-insensitive. - * @return true if the extension is supported, false otherwise */ - bool IsExtensionSupported(const char* szExtension) const; - - // ------------------------------------------------------------------- - /** @brief Returns whether a given file extension is supported by ASSIMP. - * - * This function is provided for backward compatibility. - * See the const char* version for detailed and up-to-date docs. - * @see IsExtensionSupported(const char*) */ - inline bool IsExtensionSupported(const std::string& szExtension) const; - - // ------------------------------------------------------------------- - /** Get a full list of all file extensions supported by ASSIMP. - * - * If a file extension is contained in the list this does of course not - * mean that ASSIMP is able to load all files with this extension --- - * it simply means there is an importer loaded which claims to handle - * files with this file extension. - * @param szOut String to receive the extension list. - * Format of the list: "*.3ds;*.obj;*.dae". This is useful for - * use with the WinAPI call GetOpenFileName(Ex). */ - void GetExtensionList(aiString& szOut) const; - - // ------------------------------------------------------------------- - /** @brief Get a full list of all file extensions supported by ASSIMP. - * - * This function is provided for backward compatibility. - * See the aiString version for detailed and up-to-date docs. - * @see GetExtensionList(aiString&)*/ - inline void GetExtensionList(std::string& szOut) const; - - // ------------------------------------------------------------------- - /** Get the number of importrs currently registered with Assimp. */ - size_t GetImporterCount() const; - - // ------------------------------------------------------------------- - /** Get meta data for the importer corresponding to a specific index.. - * - * For the declaration of #aiImporterDesc, include . - * @param index Index to query, must be within [0,GetImporterCount()) - * @return Importer meta data structure, NULL if the index does not - * exist or if the importer doesn't offer meta information ( - * importers may do this at the cost of being hated by their peers).*/ - const aiImporterDesc* GetImporterInfo(size_t index) const; - - // ------------------------------------------------------------------- - /** Find the importer corresponding to a specific index. - * - * @param index Index to query, must be within [0,GetImporterCount()) - * @return Importer instance. NULL if the index does not - * exist. */ - BaseImporter* GetImporter(size_t index) const; - - // ------------------------------------------------------------------- - /** Find the importer corresponding to a specific file extension. - * - * This is quite similar to #IsExtensionSupported except a - * BaseImporter instance is returned. - * @param szExtension Extension to check for. The following formats - * are recognized (BAH being the file extension): "BAH" (comparison - * is case-insensitive), ".bah", "*.bah" (wild card and dot - * characters at the beginning of the extension are skipped). - * @return NULL if no importer is found*/ - BaseImporter* GetImporter (const char* szExtension) const; - - // ------------------------------------------------------------------- - /** Find the importer index corresponding to a specific file extension. - * - * @param szExtension Extension to check for. The following formats - * are recognized (BAH being the file extension): "BAH" (comparison - * is case-insensitive), ".bah", "*.bah" (wild card and dot - * characters at the beginning of the extension are skipped). - * @return (size_t)-1 if no importer is found */ - size_t GetImporterIndex (const char* szExtension) const; - - - - - // ------------------------------------------------------------------- - /** Returns the storage allocated by ASSIMP to hold the scene data - * in memory. - * - * This refers to the currently loaded file, see #ReadFile(). - * @param in Data structure to be filled. - * @note The returned memory statistics refer to the actual - * size of the use data of the aiScene. Heap-related overhead - * is (naturally) not included.*/ - void GetMemoryRequirements(aiMemoryInfo& in) const; - - // ------------------------------------------------------------------- - /** Enables "extra verbose" mode. - * - * 'Extra verbose' means the data structure is validated after *every* - * single post processing step to make sure everyone modifies the data - * structure in a well-defined manner. This is a debug feature and not - * intended for use in production environments. */ - void SetExtraVerbose(bool bDo); - - - // ------------------------------------------------------------------- - /** Private, do not use. */ - ImporterPimpl* Pimpl() { return pimpl; } - const ImporterPimpl* Pimpl() const { return pimpl; } - -protected: - - // Just because we don't want you to know how we're hacking around. - ImporterPimpl* pimpl; -}; //! class Importer - - -// ---------------------------------------------------------------------------- -// For compatibility, the interface of some functions taking a std::string was -// changed to const char* to avoid crashes between binary incompatible STL -// versions. This code her is inlined, so it shouldn't cause any problems. -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -AI_FORCE_INLINE const aiScene* Importer::ReadFile( const std::string& pFile,unsigned int pFlags){ - return ReadFile(pFile.c_str(),pFlags); -} -// ---------------------------------------------------------------------------- -AI_FORCE_INLINE void Importer::GetExtensionList(std::string& szOut) const { - aiString s; - GetExtensionList(s); - szOut = s.data; -} -// ---------------------------------------------------------------------------- -AI_FORCE_INLINE bool Importer::IsExtensionSupported(const std::string& szExtension) const { - return IsExtensionSupported(szExtension.c_str()); -} - -} // !namespace Assimp -#endif // INCLUDED_AI_ASSIMP_HPP diff --git a/thirdparty/include/assimp/LogStream.hpp b/thirdparty/include/assimp/LogStream.hpp deleted file mode 100644 index 477fe5321..000000000 --- a/thirdparty/include/assimp/LogStream.hpp +++ /dev/null @@ -1,96 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file LogStream.hpp - * @brief Abstract base class 'LogStream', representing an output log stream. - */ -#ifndef INCLUDED_AI_LOGSTREAM_H -#define INCLUDED_AI_LOGSTREAM_H -#include "types.h" -namespace Assimp { -class IOSystem; - -// ------------------------------------------------------------------------------------ -/** @brief CPP-API: Abstract interface for log stream implementations. - * - * Several default implementations are provided, see #aiDefaultLogStream for more - * details. Writing your own implementation of LogStream is just necessary if these - * are not enough for your purpose. */ -class ASSIMP_API LogStream -#ifndef SWIG - : public Intern::AllocateFromAssimpHeap -#endif -{ -protected: - /** @brief Default constructor */ - LogStream() { - } -public: - /** @brief Virtual destructor */ - virtual ~LogStream() { - } - - // ------------------------------------------------------------------- - /** @brief Overwrite this for your own output methods - * - * Log messages *may* consist of multiple lines and you shouldn't - * expect a consistent formatting. If you want custom formatting - * (e.g. generate HTML), supply a custom instance of Logger to - * #DefaultLogger:set(). Usually you can *expect* that a log message - * is exactly one line and terminated with a single \n character. - * @param message Message to be written */ - virtual void write(const char* message) = 0; - - // ------------------------------------------------------------------- - /** @brief Creates a default log stream - * @param streams Type of the default stream - * @param name For aiDefaultLogStream_FILE: name of the output file - * @param io For aiDefaultLogStream_FILE: IOSystem to be used to open the output - * file. Pass NULL for the default implementation. - * @return New LogStream instance. */ - static LogStream* createDefaultStream(aiDefaultLogStream stream, - const char* name = "AssimpLog.txt", - IOSystem* io = NULL); - -}; // !class LogStream -// ------------------------------------------------------------------------------------ -} // Namespace Assimp - -#endif diff --git a/thirdparty/include/assimp/Logger.hpp b/thirdparty/include/assimp/Logger.hpp deleted file mode 100644 index 7f355b5bf..000000000 --- a/thirdparty/include/assimp/Logger.hpp +++ /dev/null @@ -1,265 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file Logger.hpp - * @brief Abstract base class 'Logger', base of the logging system. - */ -#ifndef INCLUDED_AI_LOGGER_H -#define INCLUDED_AI_LOGGER_H - -#include "types.h" -namespace Assimp { -class LogStream; - -// Maximum length of a log message. Longer messages are rejected. -#define MAX_LOG_MESSAGE_LENGTH 1024u - -// ---------------------------------------------------------------------------------- -/** @brief CPP-API: Abstract interface for logger implementations. - * Assimp provides a default implementation and uses it for almost all - * logging stuff ('DefaultLogger'). This class defines just basic logging - * behaviour and is not of interest for you. Instead, take a look at #DefaultLogger. */ -class ASSIMP_API Logger -#ifndef SWIG - : public Intern::AllocateFromAssimpHeap -#endif -{ -public: - - // ---------------------------------------------------------------------- - /** @enum LogSeverity - * @brief Log severity to describe the granularity of logging. - */ - enum LogSeverity - { - NORMAL, //!< Normal granularity of logging - VERBOSE //!< Debug infos will be logged, too - }; - - // ---------------------------------------------------------------------- - /** @enum ErrorSeverity - * @brief Description for severity of a log message. - * - * Every LogStream has a bitwise combination of these flags. - * A LogStream doesn't receive any messages of a specific type - * if it doesn't specify the corresponding ErrorSeverity flag. - */ - enum ErrorSeverity - { - Debugging = 1, //!< Debug log message - Info = 2, //!< Info log message - Warn = 4, //!< Warn log message - Err = 8 //!< Error log message - }; - -public: - - /** @brief Virtual destructor */ - virtual ~Logger(); - - // ---------------------------------------------------------------------- - /** @brief Writes a debug message - * @param message Debug message*/ - void debug(const char* message); - inline void debug(const std::string &message); - - // ---------------------------------------------------------------------- - /** @brief Writes a info message - * @param message Info message*/ - void info(const char* message); - inline void info(const std::string &message); - - // ---------------------------------------------------------------------- - /** @brief Writes a warning message - * @param message Warn message*/ - void warn(const char* message); - inline void warn(const std::string &message); - - // ---------------------------------------------------------------------- - /** @brief Writes an error message - * @param message Error message*/ - void error(const char* message); - inline void error(const std::string &message); - - // ---------------------------------------------------------------------- - /** @brief Set a new log severity. - * @param log_severity New severity for logging*/ - void setLogSeverity(LogSeverity log_severity); - - // ---------------------------------------------------------------------- - /** @brief Get the current log severity*/ - LogSeverity getLogSeverity() const; - - // ---------------------------------------------------------------------- - /** @brief Attach a new log-stream - * - * The logger takes ownership of the stream and is responsible - * for its destruction (which is done using ::delete when the logger - * itself is destroyed). Call detachStream to detach a stream and to - * gain ownership of it again. - * @param pStream Log-stream to attach - * @param severity Message filter, specified which types of log - * messages are dispatched to the stream. Provide a bitwise - * combination of the ErrorSeverity flags. - * @return true if the stream has been attached, false otherwise.*/ - virtual bool attachStream(LogStream *pStream, - unsigned int severity = Debugging | Err | Warn | Info) = 0; - - // ---------------------------------------------------------------------- - /** @brief Detach a still attached stream from the logger (or - * modify the filter flags bits) - * @param pStream Log-stream instance for detaching - * @param severity Provide a bitwise combination of the ErrorSeverity - * flags. This value is &~ed with the current flags of the stream, - * if the result is 0 the stream is detached from the Logger and - * the caller retakes the possession of the stream. - * @return true if the stream has been detached, false otherwise.*/ - virtual bool detatchStream(LogStream *pStream, - unsigned int severity = Debugging | Err | Warn | Info) = 0; - -protected: - - /** Default constructor */ - Logger(); - - /** Construction with a given log severity */ - explicit Logger(LogSeverity severity); - - // ---------------------------------------------------------------------- - /** @brief Called as a request to write a specific debug message - * @param message Debug message. Never longer than - * MAX_LOG_MESSAGE_LENGTH characters (excluding the '0'). - * @note The message string is only valid until the scope of - * the function is left. - */ - virtual void OnDebug(const char* message)= 0; - - // ---------------------------------------------------------------------- - /** @brief Called as a request to write a specific info message - * @param message Info message. Never longer than - * MAX_LOG_MESSAGE_LENGTH characters (ecxluding the '0'). - * @note The message string is only valid until the scope of - * the function is left. - */ - virtual void OnInfo(const char* message) = 0; - - // ---------------------------------------------------------------------- - /** @brief Called as a request to write a specific warn message - * @param message Warn message. Never longer than - * MAX_LOG_MESSAGE_LENGTH characters (exluding the '0'). - * @note The message string is only valid until the scope of - * the function is left. - */ - virtual void OnWarn(const char* essage) = 0; - - // ---------------------------------------------------------------------- - /** @brief Called as a request to write a specific error message - * @param message Error message. Never longer than - * MAX_LOG_MESSAGE_LENGTH characters (exluding the '0'). - * @note The message string is only valid until the scope of - * the function is left. - */ - virtual void OnError(const char* message) = 0; - -protected: - - //! Logger severity - LogSeverity m_Severity; -}; - -// ---------------------------------------------------------------------------------- -// Default constructor -inline Logger::Logger() { - setLogSeverity(NORMAL); -} - -// ---------------------------------------------------------------------------------- -// Virtual destructor -inline Logger::~Logger() -{ -} - -// ---------------------------------------------------------------------------------- -// Construction with given logging severity -inline Logger::Logger(LogSeverity severity) { - setLogSeverity(severity); -} - -// ---------------------------------------------------------------------------------- -// Log severity setter -inline void Logger::setLogSeverity(LogSeverity log_severity){ - m_Severity = log_severity; -} - -// ---------------------------------------------------------------------------------- -// Log severity getter -inline Logger::LogSeverity Logger::getLogSeverity() const { - return m_Severity; -} - -// ---------------------------------------------------------------------------------- -inline void Logger::debug(const std::string &message) -{ - return debug(message.c_str()); -} - -// ---------------------------------------------------------------------------------- -inline void Logger::error(const std::string &message) -{ - return error(message.c_str()); -} - -// ---------------------------------------------------------------------------------- -inline void Logger::warn(const std::string &message) -{ - return warn(message.c_str()); -} - -// ---------------------------------------------------------------------------------- -inline void Logger::info(const std::string &message) -{ - return info(message.c_str()); -} - -// ---------------------------------------------------------------------------------- - -} // Namespace Assimp - -#endif // !! INCLUDED_AI_LOGGER_H diff --git a/thirdparty/include/assimp/NullLogger.hpp b/thirdparty/include/assimp/NullLogger.hpp deleted file mode 100644 index 64b59a4a0..000000000 --- a/thirdparty/include/assimp/NullLogger.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file NullLogger.hpp - * @brief Dummy logger -*/ - -#ifndef INCLUDED_AI_NULLLOGGER_H -#define INCLUDED_AI_NULLLOGGER_H - -#include "Logger.hpp" -namespace Assimp { -// --------------------------------------------------------------------------- -/** @brief CPP-API: Empty logging implementation. - * - * Does nothing! Used by default if the application hasn't requested a - * custom logger via #DefaultLogger::set() or #DefaultLogger::create(); */ -class ASSIMP_API NullLogger - : public Logger { - -public: - - /** @brief Logs a debug message */ - void OnDebug(const char* message) { - (void)message; //this avoids compiler warnings - } - - /** @brief Logs an info message */ - void OnInfo(const char* message) { - (void)message; //this avoids compiler warnings - } - - /** @brief Logs a warning message */ - void OnWarn(const char* message) { - (void)message; //this avoids compiler warnings - } - - /** @brief Logs an error message */ - void OnError(const char* message) { - (void)message; //this avoids compiler warnings - } - - /** @brief Detach a still attached stream from logger */ - bool attachStream(LogStream *pStream, unsigned int severity) { - (void)pStream; (void)severity; //this avoids compiler warnings - return false; - } - - /** @brief Detach a still attached stream from logger */ - bool detatchStream(LogStream *pStream, unsigned int severity) { - (void)pStream; (void)severity; //this avoids compiler warnings - return false; - } - -private: -}; -} -#endif // !! AI_NULLLOGGER_H_INCLUDED diff --git a/thirdparty/include/assimp/ProgressHandler.hpp b/thirdparty/include/assimp/ProgressHandler.hpp deleted file mode 100644 index 8b069c82e..000000000 --- a/thirdparty/include/assimp/ProgressHandler.hpp +++ /dev/null @@ -1,122 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file ProgressHandler.hpp - * @brief Abstract base class 'ProgressHandler'. - */ -#ifndef INCLUDED_AI_PROGRESSHANDLER_H -#define INCLUDED_AI_PROGRESSHANDLER_H -#include "types.h" -namespace Assimp { - -// ------------------------------------------------------------------------------------ -/** @brief CPP-API: Abstract interface for custom progress report receivers. - * - * Each #Importer instance maintains its own #ProgressHandler. The default - * implementation provided by Assimp doesn't do anything at all. */ -class ASSIMP_API ProgressHandler -#ifndef SWIG - : public Intern::AllocateFromAssimpHeap -#endif -{ -protected: - /** @brief Default constructor */ - ProgressHandler () { - } -public: - /** @brief Virtual destructor */ - virtual ~ProgressHandler () { - } - - // ------------------------------------------------------------------- - /** @brief Progress callback. - * @param percentage An estimate of the current loading progress, - * in percent. Or -1.f if such an estimate is not available. - * - * There are restriction on what you may do from within your - * implementation of this method: no exceptions may be thrown and no - * non-const #Importer methods may be called. It is - * not generally possible to predict the number of callbacks - * fired during a single import. - * - * @return Return false to abort loading at the next possible - * occasion (loaders and Assimp are generally allowed to perform - * all needed cleanup tasks prior to returning control to the - * caller). If the loading is aborted, #Importer::ReadFile() - * returns always NULL. - * */ - virtual bool Update(float percentage = -1.f) = 0; - - // ------------------------------------------------------------------- - /** @brief Progress callback for file loading steps - * @param numberOfSteps The number of total post-processing - * steps - * @param currentStep The index of the current post-processing - * step that will run, or equal to numberOfSteps if all of - * them has finished. This number is always strictly monotone - * increasing, although not necessarily linearly. - * - * @note This is currently only used at the start and the end - * of the file parsing. - * */ - virtual void UpdateFileRead(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) { - float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f; - Update( f * 0.5f ); - } - - // ------------------------------------------------------------------- - /** @brief Progress callback for post-processing steps - * @param numberOfSteps The number of total post-processing - * steps - * @param currentStep The index of the current post-processing - * step that will run, or equal to numberOfSteps if all of - * them has finished. This number is always strictly monotone - * increasing, although not necessarily linearly. - * */ - virtual void UpdatePostProcess(int currentStep /*= 0*/, int numberOfSteps /*= 0*/) { - float f = numberOfSteps ? currentStep / (float)numberOfSteps : 1.0f; - Update( f * 0.5f + 0.5f ); - } - -}; // !class ProgressHandler -// ------------------------------------------------------------------------------------ -} // Namespace Assimp - -#endif diff --git a/thirdparty/include/assimp/ai_assert.h b/thirdparty/include/assimp/ai_assert.h deleted file mode 100644 index 0caeff673..000000000 --- a/thirdparty/include/assimp/ai_assert.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ -#ifndef AI_DEBUG_H_INC -#define AI_DEBUG_H_INC - -#ifdef ASSIMP_BUILD_DEBUG -# include -# define ai_assert(expression) assert(expression) -#else -# define ai_assert(expression) -#endif - - -#endif diff --git a/thirdparty/include/assimp/anim.h b/thirdparty/include/assimp/anim.h deleted file mode 100644 index af5941755..000000000 --- a/thirdparty/include/assimp/anim.h +++ /dev/null @@ -1,484 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file anim.h - * @brief Defines the data structures in which the imported animations - * are returned. - */ -#ifndef AI_ANIM_H_INC -#define AI_ANIM_H_INC - -#include "types.h" -#include "quaternion.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// --------------------------------------------------------------------------- -/** A time-value pair specifying a certain 3D vector for the given time. */ -struct aiVectorKey -{ - /** The time of this key */ - double mTime; - - /** The value of this key */ - C_STRUCT aiVector3D mValue; - -#ifdef __cplusplus - - //! Default constructor - aiVectorKey(){} - - //! Construction from a given time and key value - aiVectorKey(double time, const aiVector3D& value) - : mTime (time) - , mValue (value) - {} - - - typedef aiVector3D elem_type; - - // Comparison operators. For use with std::find(); - bool operator == (const aiVectorKey& o) const { - return o.mValue == this->mValue; - } - bool operator != (const aiVectorKey& o) const { - return o.mValue != this->mValue; - } - - // Relational operators. For use with std::sort(); - bool operator < (const aiVectorKey& o) const { - return mTime < o.mTime; - } - bool operator > (const aiVectorKey& o) const { - return mTime > o.mTime; - } -#endif -}; - -// --------------------------------------------------------------------------- -/** A time-value pair specifying a rotation for the given time. - * Rotations are expressed with quaternions. */ -struct aiQuatKey -{ - /** The time of this key */ - double mTime; - - /** The value of this key */ - C_STRUCT aiQuaternion mValue; - -#ifdef __cplusplus - aiQuatKey(){ - } - - /** Construction from a given time and key value */ - aiQuatKey(double time, const aiQuaternion& value) - : mTime (time) - , mValue (value) - {} - - typedef aiQuaternion elem_type; - - // Comparison operators. For use with std::find(); - bool operator == (const aiQuatKey& o) const { - return o.mValue == this->mValue; - } - bool operator != (const aiQuatKey& o) const { - return o.mValue != this->mValue; - } - - // Relational operators. For use with std::sort(); - bool operator < (const aiQuatKey& o) const { - return mTime < o.mTime; - } - bool operator > (const aiQuatKey& o) const { - return mTime > o.mTime; - } -#endif -}; - -// --------------------------------------------------------------------------- -/** Binds a anim mesh to a specific point in time. */ -struct aiMeshKey -{ - /** The time of this key */ - double mTime; - - /** Index into the aiMesh::mAnimMeshes array of the - * mesh coresponding to the #aiMeshAnim hosting this - * key frame. The referenced anim mesh is evaluated - * according to the rules defined in the docs for #aiAnimMesh.*/ - unsigned int mValue; - -#ifdef __cplusplus - - aiMeshKey() { - } - - /** Construction from a given time and key value */ - aiMeshKey(double time, const unsigned int value) - : mTime (time) - , mValue (value) - {} - - typedef unsigned int elem_type; - - // Comparison operators. For use with std::find(); - bool operator == (const aiMeshKey& o) const { - return o.mValue == this->mValue; - } - bool operator != (const aiMeshKey& o) const { - return o.mValue != this->mValue; - } - - // Relational operators. For use with std::sort(); - bool operator < (const aiMeshKey& o) const { - return mTime < o.mTime; - } - bool operator > (const aiMeshKey& o) const { - return mTime > o.mTime; - } - -#endif -}; - -// --------------------------------------------------------------------------- -/** Defines how an animation channel behaves outside the defined time - * range. This corresponds to aiNodeAnim::mPreState and - * aiNodeAnim::mPostState.*/ -enum aiAnimBehaviour -{ - /** The value from the default node transformation is taken*/ - aiAnimBehaviour_DEFAULT = 0x0, - - /** The nearest key value is used without interpolation */ - aiAnimBehaviour_CONSTANT = 0x1, - - /** The value of the nearest two keys is linearly - * extrapolated for the current time value.*/ - aiAnimBehaviour_LINEAR = 0x2, - - /** The animation is repeated. - * - * If the animation key go from n to m and the current - * time is t, use the value at (t-n) % (|m-n|).*/ - aiAnimBehaviour_REPEAT = 0x3, - - - - /** This value is not used, it is just here to force the - * the compiler to map this enum to a 32 Bit integer */ -#ifndef SWIG - _aiAnimBehaviour_Force32Bit = INT_MAX -#endif -}; - -// --------------------------------------------------------------------------- -/** Describes the animation of a single node. The name specifies the - * bone/node which is affected by this animation channel. The keyframes - * are given in three separate series of values, one each for position, - * rotation and scaling. The transformation matrix computed from these - * values replaces the node's original transformation matrix at a - * specific time. - * This means all keys are absolute and not relative to the bone default pose. - * The order in which the transformations are applied is - * - as usual - scaling, rotation, translation. - * - * @note All keys are returned in their correct, chronological order. - * Duplicate keys don't pass the validation step. Most likely there - * will be no negative time values, but they are not forbidden also ( so - * implementations need to cope with them! ) */ -struct aiNodeAnim -{ - /** The name of the node affected by this animation. The node - * must exist and it must be unique.*/ - C_STRUCT aiString mNodeName; - - /** The number of position keys */ - unsigned int mNumPositionKeys; - - /** The position keys of this animation channel. Positions are - * specified as 3D vector. The array is mNumPositionKeys in size. - * - * If there are position keys, there will also be at least one - * scaling and one rotation key.*/ - C_STRUCT aiVectorKey* mPositionKeys; - - /** The number of rotation keys */ - unsigned int mNumRotationKeys; - - /** The rotation keys of this animation channel. Rotations are - * given as quaternions, which are 4D vectors. The array is - * mNumRotationKeys in size. - * - * If there are rotation keys, there will also be at least one - * scaling and one position key. */ - C_STRUCT aiQuatKey* mRotationKeys; - - - /** The number of scaling keys */ - unsigned int mNumScalingKeys; - - /** The scaling keys of this animation channel. Scalings are - * specified as 3D vector. The array is mNumScalingKeys in size. - * - * If there are scaling keys, there will also be at least one - * position and one rotation key.*/ - C_STRUCT aiVectorKey* mScalingKeys; - - - /** Defines how the animation behaves before the first - * key is encountered. - * - * The default value is aiAnimBehaviour_DEFAULT (the original - * transformation matrix of the affected node is used).*/ - C_ENUM aiAnimBehaviour mPreState; - - /** Defines how the animation behaves after the last - * key was processed. - * - * The default value is aiAnimBehaviour_DEFAULT (the original - * transformation matrix of the affected node is taken).*/ - C_ENUM aiAnimBehaviour mPostState; - -#ifdef __cplusplus - aiNodeAnim() - { - mNumPositionKeys = 0; mPositionKeys = NULL; - mNumRotationKeys = 0; mRotationKeys = NULL; - mNumScalingKeys = 0; mScalingKeys = NULL; - - mPreState = mPostState = aiAnimBehaviour_DEFAULT; - } - - ~aiNodeAnim() - { - delete [] mPositionKeys; - delete [] mRotationKeys; - delete [] mScalingKeys; - } -#endif // __cplusplus -}; - -// --------------------------------------------------------------------------- -/** Describes vertex-based animations for a single mesh or a group of - * meshes. Meshes carry the animation data for each frame in their - * aiMesh::mAnimMeshes array. The purpose of aiMeshAnim is to - * define keyframes linking each mesh attachment to a particular - * point in time. */ -struct aiMeshAnim -{ - /** Name of the mesh to be animated. An empty string is not allowed, - * animated meshes need to be named (not necessarily uniquely, - * the name can basically serve as wildcard to select a group - * of meshes with similar animation setup)*/ - C_STRUCT aiString mName; - - /** Size of the #mKeys array. Must be 1, at least. */ - unsigned int mNumKeys; - - /** Key frames of the animation. May not be NULL. */ - C_STRUCT aiMeshKey* mKeys; - -#ifdef __cplusplus - - aiMeshAnim() - : mNumKeys() - , mKeys() - {} - - ~aiMeshAnim() - { - delete[] mKeys; - } - -#endif -}; - -// --------------------------------------------------------------------------- -/** An animation consists of keyframe data for a number of nodes. For - * each node affected by the animation a separate series of data is given.*/ -struct aiAnimation -{ - /** The name of the animation. If the modeling package this data was - * exported from does support only a single animation channel, this - * name is usually empty (length is zero). */ - C_STRUCT aiString mName; - - /** Duration of the animation in ticks. */ - double mDuration; - - /** Ticks per second. 0 if not specified in the imported file */ - double mTicksPerSecond; - - /** The number of bone animation channels. Each channel affects - * a single node. */ - unsigned int mNumChannels; - - /** The node animation channels. Each channel affects a single node. - * The array is mNumChannels in size. */ - C_STRUCT aiNodeAnim** mChannels; - - - /** The number of mesh animation channels. Each channel affects - * a single mesh and defines vertex-based animation. */ - unsigned int mNumMeshChannels; - - /** The mesh animation channels. Each channel affects a single mesh. - * The array is mNumMeshChannels in size. */ - C_STRUCT aiMeshAnim** mMeshChannels; - -#ifdef __cplusplus - aiAnimation() - : mDuration(-1.) - , mTicksPerSecond() - , mNumChannels() - , mChannels() - , mNumMeshChannels() - , mMeshChannels() - { - } - - ~aiAnimation() - { - // DO NOT REMOVE THIS ADDITIONAL CHECK - if (mNumChannels && mChannels) { - for( unsigned int a = 0; a < mNumChannels; a++) { - delete mChannels[a]; - } - - delete [] mChannels; - } - if (mNumMeshChannels && mMeshChannels) { - for( unsigned int a = 0; a < mNumMeshChannels; a++) { - delete mMeshChannels[a]; - } - - delete [] mMeshChannels; - } - } -#endif // __cplusplus -}; - -#ifdef __cplusplus -} - - -// some C++ utilities for inter- and extrapolation -namespace Assimp { - -// --------------------------------------------------------------------------- -/** @brief CPP-API: Utility class to simplify interpolations of various data types. - * - * The type of interpolation is chosen automatically depending on the - * types of the arguments. */ -template -struct Interpolator -{ - // ------------------------------------------------------------------ - /** @brief Get the result of the interpolation between a,b. - * - * The interpolation algorithm depends on the type of the operands. - * aiQuaternion's and aiQuatKey's SLERP, the rest does a simple - * linear interpolation. */ - void operator () (T& out,const T& a, const T& b, float d) const { - out = a + (b-a)*d; - } -}; // ! Interpolator - -//! @cond Never - -template <> -struct Interpolator { - void operator () (aiQuaternion& out,const aiQuaternion& a, - const aiQuaternion& b, float d) const - { - aiQuaternion::Interpolate(out,a,b,d); - } -}; // ! Interpolator - -template <> -struct Interpolator { - void operator () (unsigned int& out,unsigned int a, - unsigned int b, float d) const - { - out = d>0.5f ? b : a; - } -}; // ! Interpolator - -template <> -struct Interpolator { - void operator () (aiVector3D& out,const aiVectorKey& a, - const aiVectorKey& b, float d) const - { - Interpolator ipl; - ipl(out,a.mValue,b.mValue,d); - } -}; // ! Interpolator - -template <> -struct Interpolator { - void operator () (aiQuaternion& out, const aiQuatKey& a, - const aiQuatKey& b, float d) const - { - Interpolator ipl; - ipl(out,a.mValue,b.mValue,d); - } -}; // ! Interpolator - -template <> -struct Interpolator { - void operator () (unsigned int& out, const aiMeshKey& a, - const aiMeshKey& b, float d) const - { - Interpolator ipl; - ipl(out,a.mValue,b.mValue,d); - } -}; // ! Interpolator - -//! @endcond -} // ! end namespace Assimp - - - -#endif // __cplusplus -#endif // AI_ANIM_H_INC diff --git a/thirdparty/include/assimp/camera.h b/thirdparty/include/assimp/camera.h deleted file mode 100644 index 37f1bdaa0..000000000 --- a/thirdparty/include/assimp/camera.h +++ /dev/null @@ -1,223 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file camera.h - * @brief Defines the aiCamera data structure - */ - -#ifndef AI_CAMERA_H_INC -#define AI_CAMERA_H_INC - -#include "types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// --------------------------------------------------------------------------- -/** Helper structure to describe a virtual camera. - * - * Cameras have a representation in the node graph and can be animated. - * An important aspect is that the camera itself is also part of the - * scenegraph. This means, any values such as the look-at vector are not - * *absolute*, they're relative to the coordinate system defined - * by the node which corresponds to the camera. This allows for camera - * animations. For static cameras parameters like the 'look-at' or 'up' vectors - * are usually specified directly in aiCamera, but beware, they could also - * be encoded in the node transformation. The following (pseudo)code sample - * shows how to do it:

- * @code - * // Get the camera matrix for a camera at a specific time - * // if the node hierarchy for the camera does not contain - * // at least one animated node this is a static computation - * get-camera-matrix (node sceneRoot, camera cam) : matrix - * { - * node cnd = find-node-for-camera(cam) - * matrix cmt = identity() - * - * // as usual - get the absolute camera transformation for this frame - * for each node nd in hierarchy from sceneRoot to cnd - * matrix cur - * if (is-animated(nd)) - * cur = eval-animation(nd) - * else cur = nd->mTransformation; - * cmt = mult-matrices( cmt, cur ) - * end for - * - * // now multiply with the camera's own local transform - * cam = mult-matrices (cam, get-camera-matrix(cmt) ) - * } - * @endcode - * - * @note some file formats (such as 3DS, ASE) export a "target point" - - * the point the camera is looking at (it can even be animated). Assimp - * writes the target point as a subnode of the camera's main node, - * called ".Target". However this is just additional information - * then the transformation tracks of the camera main node make the - * camera already look in the right direction. - * -*/ -struct aiCamera -{ - /** The name of the camera. - * - * There must be a node in the scenegraph with the same name. - * This node specifies the position of the camera in the scene - * hierarchy and can be animated. - */ - C_STRUCT aiString mName; - - /** Position of the camera relative to the coordinate space - * defined by the corresponding node. - * - * The default value is 0|0|0. - */ - C_STRUCT aiVector3D mPosition; - - - /** 'Up' - vector of the camera coordinate system relative to - * the coordinate space defined by the corresponding node. - * - * The 'right' vector of the camera coordinate system is - * the cross product of the up and lookAt vectors. - * The default value is 0|1|0. The vector - * may be normalized, but it needn't. - */ - C_STRUCT aiVector3D mUp; - - - /** 'LookAt' - vector of the camera coordinate system relative to - * the coordinate space defined by the corresponding node. - * - * This is the viewing direction of the user. - * The default value is 0|0|1. The vector - * may be normalized, but it needn't. - */ - C_STRUCT aiVector3D mLookAt; - - - /** Half horizontal field of view angle, in radians. - * - * The field of view angle is the angle between the center - * line of the screen and the left or right border. - * The default value is 1/4PI. - */ - float mHorizontalFOV; - - /** Distance of the near clipping plane from the camera. - * - * The value may not be 0.f (for arithmetic reasons to prevent - * a division through zero). The default value is 0.1f. - */ - float mClipPlaneNear; - - /** Distance of the far clipping plane from the camera. - * - * The far clipping plane must, of course, be further away than the - * near clipping plane. The default value is 1000.f. The ratio - * between the near and the far plane should not be too - * large (between 1000-10000 should be ok) to avoid floating-point - * inaccuracies which could lead to z-fighting. - */ - float mClipPlaneFar; - - - /** Screen aspect ratio. - * - * This is the ration between the width and the height of the - * screen. Typical values are 4/3, 1/2 or 1/1. This value is - * 0 if the aspect ratio is not defined in the source file. - * 0 is also the default value. - */ - float mAspect; - -#ifdef __cplusplus - - aiCamera() - : mUp (0.f,1.f,0.f) - , mLookAt (0.f,0.f,1.f) - , mHorizontalFOV (0.25f * (float)AI_MATH_PI) - , mClipPlaneNear (0.1f) - , mClipPlaneFar (1000.f) - , mAspect (0.f) - {} - - /** @brief Get a *right-handed* camera matrix from me - * @param out Camera matrix to be filled - */ - void GetCameraMatrix (aiMatrix4x4& out) const - { - /** todo: test ... should work, but i'm not absolutely sure */ - - /** We don't know whether these vectors are already normalized ...*/ - aiVector3D zaxis = mLookAt; zaxis.Normalize(); - aiVector3D yaxis = mUp; yaxis.Normalize(); - aiVector3D xaxis = mUp^mLookAt; xaxis.Normalize(); - - out.a4 = -(xaxis * mPosition); - out.b4 = -(yaxis * mPosition); - out.c4 = -(zaxis * mPosition); - - out.a1 = xaxis.x; - out.a2 = xaxis.y; - out.a3 = xaxis.z; - - out.b1 = yaxis.x; - out.b2 = yaxis.y; - out.b3 = yaxis.z; - - out.c1 = zaxis.x; - out.c2 = zaxis.y; - out.c3 = zaxis.z; - - out.d1 = out.d2 = out.d3 = 0.f; - out.d4 = 1.f; - } - -#endif -}; - - -#ifdef __cplusplus -} -#endif - -#endif // AI_CAMERA_H_INC diff --git a/thirdparty/include/assimp/cexport.h b/thirdparty/include/assimp/cexport.h deleted file mode 100644 index 71cb1f8ec..000000000 --- a/thirdparty/include/assimp/cexport.h +++ /dev/null @@ -1,262 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2011, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above -copyright notice, this list of conditions and the -following disclaimer. - -* Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other -materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its -contributors may be used to endorse or promote products -derived from this software without specific prior -written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file cexport.h -* @brief Defines the C-API for the Assimp export interface -*/ -#ifndef AI_EXPORT_H_INC -#define AI_EXPORT_H_INC - -#ifndef ASSIMP_BUILD_NO_EXPORT - -#include "types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct aiScene; // aiScene.h -struct aiFileIO; // aiFileIO.h - -// -------------------------------------------------------------------------------- -/** Describes an file format which Assimp can export to. Use #aiGetExportFormatCount() to -* learn how many export formats the current Assimp build supports and #aiGetExportFormatDescription() -* to retrieve a description of an export format option. -*/ -struct aiExportFormatDesc -{ - /// a short string ID to uniquely identify the export format. Use this ID string to - /// specify which file format you want to export to when calling #aiExportScene(). - /// Example: "dae" or "obj" - const char* id; - - /// A short description of the file format to present to users. Useful if you want - /// to allow the user to select an export format. - const char* description; - - /// Recommended file extension for the exported file in lower case. - const char* fileExtension; -}; - - -// -------------------------------------------------------------------------------- -/** Returns the number of export file formats available in the current Assimp build. - * Use aiGetExportFormatDescription() to retrieve infos of a specific export format. - */ -ASSIMP_API size_t aiGetExportFormatCount(void); - - -// -------------------------------------------------------------------------------- -/** Returns a description of the nth export file format. Use #aiGetExportFormatCount() - * to learn how many export formats are supported. The description must be released by - * calling aiReleaseExportFormatDescription afterwards. - * @param pIndex Index of the export format to retrieve information for. Valid range is - * 0 to #aiGetExportFormatCount() - * @return A description of that specific export format. NULL if pIndex is out of range. - */ -ASSIMP_API const C_STRUCT aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex); - -// -------------------------------------------------------------------------------- -/** Release a description of the nth export file format. Must be returned by -* aiGetExportFormatDescription -* @param desc Pointer to the description -*/ -ASSIMP_API void aiReleaseExportFormatDescription( const C_STRUCT aiExportFormatDesc *desc ); - -// -------------------------------------------------------------------------------- -/** Create a modifiable copy of a scene. - * This is useful to import files via Assimp, change their topology and - * export them again. Since the scene returned by the various importer functions - * is const, a modifiable copy is needed. - * @param pIn Valid scene to be copied - * @param pOut Receives a modifyable copy of the scene. Use aiFreeScene() to - * delete it again. - */ -ASSIMP_API void aiCopyScene(const C_STRUCT aiScene* pIn, - C_STRUCT aiScene** pOut); - - -// -------------------------------------------------------------------------------- -/** Frees a scene copy created using aiCopyScene() */ -ASSIMP_API void aiFreeScene(const C_STRUCT aiScene* pIn); - -// -------------------------------------------------------------------------------- -/** Exports the given scene to a chosen file format and writes the result file(s) to disk. -* @param pScene The scene to export. Stays in possession of the caller, is not changed by the function. -* The scene is expected to conform to Assimp's Importer output format as specified -* in the @link data Data Structures Page @endlink. In short, this means the model data -* should use a right-handed coordinate systems, face winding should be counter-clockwise -* and the UV coordinate origin is assumed to be in the upper left. If your input data -* uses different conventions, have a look at the last parameter. -* @param pFormatId ID string to specify to which format you want to export to. Use -* aiGetExportFormatCount() / aiGetExportFormatDescription() to learn which export formats are available. -* @param pFileName Output file to write -* @param pPreprocessing Accepts any choice of the #aiPostProcessSteps enumerated -* flags, but in reality only a subset of them makes sense here. Specifying -* 'preprocessing' flags is useful if the input scene does not conform to -* Assimp's default conventions as specified in the @link data Data Structures Page @endlink. -* In short, this means the geometry data should use a right-handed coordinate systems, face -* winding should be counter-clockwise and the UV coordinate origin is assumed to be in -* the upper left. The #aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and -* #aiProcess_FlipWindingOrder flags are used in the import side to allow users -* to have those defaults automatically adapted to their conventions. Specifying those flags -* for exporting has the opposite effect, respectively. Some other of the -* #aiPostProcessSteps enumerated values may be useful as well, but you'll need -* to try out what their effect on the exported file is. Many formats impose -* their own restrictions on the structure of the geometry stored therein, -* so some preprocessing may have little or no effect at all, or may be -* redundant as exporters would apply them anyhow. A good example -* is triangulation - whilst you can enforce it by specifying -* the #aiProcess_Triangulate flag, most export formats support only -* triangulate data so they would run the step anyway. -* -* If assimp detects that the input scene was directly taken from the importer side of -* the library (i.e. not copied using aiCopyScene and potetially modified afterwards), -* any postprocessing steps already applied to the scene will not be applied again, unless -* they show non-idempotent behaviour (#aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and -* #aiProcess_FlipWindingOrder). -* @return a status code indicating the result of the export -* @note Use aiCopyScene() to get a modifiable copy of a previously -* imported scene. -*/ -ASSIMP_API aiReturn aiExportScene( const C_STRUCT aiScene* pScene, - const char* pFormatId, - const char* pFileName, - unsigned int pPreprocessing); - - -// -------------------------------------------------------------------------------- -/** Exports the given scene to a chosen file format using custom IO logic supplied by you. -* @param pScene The scene to export. Stays in possession of the caller, is not changed by the function. -* @param pFormatId ID string to specify to which format you want to export to. Use -* aiGetExportFormatCount() / aiGetExportFormatDescription() to learn which export formats are available. -* @param pFileName Output file to write -* @param pIO custom IO implementation to be used. Use this if you use your own storage methods. -* If none is supplied, a default implementation using standard file IO is used. Note that -* #aiExportSceneToBlob is provided as convenience function to export to memory buffers. -* @param pPreprocessing Please see the documentation for #aiExportScene -* @return a status code indicating the result of the export -* @note Include for the definition of #aiFileIO. -* @note Use aiCopyScene() to get a modifiable copy of a previously -* imported scene. -*/ -ASSIMP_API aiReturn aiExportSceneEx( const C_STRUCT aiScene* pScene, - const char* pFormatId, - const char* pFileName, - C_STRUCT aiFileIO* pIO, - unsigned int pPreprocessing ); - - -// -------------------------------------------------------------------------------- -/** Describes a blob of exported scene data. Use #aiExportSceneToBlob() to create a blob containing an -* exported scene. The memory referred by this structure is owned by Assimp. -* to free its resources. Don't try to free the memory on your side - it will crash for most build configurations -* due to conflicting heaps. -* -* Blobs can be nested - each blob may reference another blob, which may in turn reference another blob and so on. -* This is used when exporters write more than one output file for a given #aiScene. See the remarks for -* #aiExportDataBlob::name for more information. -*/ -struct aiExportDataBlob -{ - /// Size of the data in bytes - size_t size; - - /// The data. - void* data; - - /** Name of the blob. An empty string always - indicates the first (and primary) blob, - which contains the actual file data. - Any other blobs are auxiliary files produced - by exporters (i.e. material files). Existence - of such files depends on the file format. Most - formats don't split assets across multiple files. - - If used, blob names usually contain the file - extension that should be used when writing - the data to disc. - */ - C_STRUCT aiString name; - - /** Pointer to the next blob in the chain or NULL if there is none. */ - C_STRUCT aiExportDataBlob * next; - -#ifdef __cplusplus - /// Default constructor - aiExportDataBlob() { size = 0; data = next = NULL; } - /// Releases the data - ~aiExportDataBlob() { delete [] static_cast( data ); delete next; } - -private: - // no copying - aiExportDataBlob(const aiExportDataBlob& ); - aiExportDataBlob& operator= (const aiExportDataBlob& ); -#endif // __cplusplus -}; - -// -------------------------------------------------------------------------------- -/** Exports the given scene to a chosen file format. Returns the exported data as a binary blob which -* you can write into a file or something. When you're done with the data, use #aiReleaseExportBlob() -* to free the resources associated with the export. -* @param pScene The scene to export. Stays in possession of the caller, is not changed by the function. -* @param pFormatId ID string to specify to which format you want to export to. Use -* #aiGetExportFormatCount() / #aiGetExportFormatDescription() to learn which export formats are available. -* @param pPreprocessing Please see the documentation for #aiExportScene -* @return the exported data or NULL in case of error -*/ -ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const C_STRUCT aiScene* pScene, const char* pFormatId, unsigned int pPreprocessing ); - - -// -------------------------------------------------------------------------------- -/** Releases the memory associated with the given exported data. Use this function to free a data blob -* returned by aiExportScene(). -* @param pData the data blob returned by #aiExportSceneToBlob -*/ -ASSIMP_API void aiReleaseExportBlob( const C_STRUCT aiExportDataBlob* pData ); - -#ifdef __cplusplus -} -#endif - -#endif // ASSIMP_BUILD_NO_EXPORT -#endif // AI_EXPORT_H_INC - diff --git a/thirdparty/include/assimp/cfileio.h b/thirdparty/include/assimp/cfileio.h deleted file mode 100644 index d91974b78..000000000 --- a/thirdparty/include/assimp/cfileio.h +++ /dev/null @@ -1,135 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file cfileio.h - * @brief Defines generic C routines to access memory-mapped files - */ -#ifndef AI_FILEIO_H_INC -#define AI_FILEIO_H_INC - -#include "types.h" -#ifdef __cplusplus -extern "C" { -#endif -struct aiFileIO; -struct aiFile; - -// aiFile callbacks -typedef size_t (*aiFileWriteProc) (C_STRUCT aiFile*, const char*, size_t, size_t); -typedef size_t (*aiFileReadProc) (C_STRUCT aiFile*, char*, size_t,size_t); -typedef size_t (*aiFileTellProc) (C_STRUCT aiFile*); -typedef void (*aiFileFlushProc) (C_STRUCT aiFile*); -typedef aiReturn (*aiFileSeek)(C_STRUCT aiFile*, size_t, aiOrigin); - -// aiFileIO callbacks -typedef aiFile* (*aiFileOpenProc) (C_STRUCT aiFileIO*, const char*, const char*); -typedef void (*aiFileCloseProc) (C_STRUCT aiFileIO*, C_STRUCT aiFile*); - -// Represents user-defined data -typedef char* aiUserData; - -// ---------------------------------------------------------------------------------- -/** @brief C-API: File system callbacks - * - * Provided are functions to open and close files. Supply a custom structure to - * the import function. If you don't, a default implementation is used. Use custom - * file systems to enable reading from other sources, such as ZIPs - * or memory locations. */ -struct aiFileIO -{ - /** Function used to open a new file - */ - aiFileOpenProc OpenProc; - - /** Function used to close an existing file - */ - aiFileCloseProc CloseProc; - - /** User-defined, opaque data */ - aiUserData UserData; -}; - -// ---------------------------------------------------------------------------------- -/** @brief C-API: File callbacks - * - * Actually, it's a data structure to wrap a set of fXXXX (e.g fopen) - * replacement functions. - * - * The default implementation of the functions utilizes the fXXX functions from - * the CRT. However, you can supply a custom implementation to Assimp by - * delivering a custom aiFileIO. Use this to enable reading from other sources, - * such as ZIP archives or memory locations. */ -struct aiFile -{ - /** Callback to read from a file */ - aiFileReadProc ReadProc; - - /** Callback to write to a file */ - aiFileWriteProc WriteProc; - - /** Callback to retrieve the current position of - * the file cursor (ftell()) - */ - aiFileTellProc TellProc; - - /** Callback to retrieve the size of the file, - * in bytes - */ - aiFileTellProc FileSizeProc; - - /** Callback to set the current position - * of the file cursor (fseek()) - */ - aiFileSeek SeekProc; - - /** Callback to flush the file contents - */ - aiFileFlushProc FlushProc; - - /** User-defined, opaque data - */ - aiUserData UserData; -}; - -#ifdef __cplusplus -} -#endif -#endif // AI_FILEIO_H_INC diff --git a/thirdparty/include/assimp/cimport.h b/thirdparty/include/assimp/cimport.h deleted file mode 100644 index de0cbae30..000000000 --- a/thirdparty/include/assimp/cimport.h +++ /dev/null @@ -1,561 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file cimport.h - * @brief Defines the C-API to the Open Asset Import Library. - */ -#ifndef AI_ASSIMP_H_INC -#define AI_ASSIMP_H_INC -#include "types.h" -#include "importerdesc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct aiScene; // aiScene.h -struct aiFileIO; // aiFileIO.h -typedef void (*aiLogStreamCallback)(const char* /* message */, char* /* user */); - -// -------------------------------------------------------------------------------- -/** C-API: Represents a log stream. A log stream receives all log messages and - * streams them _somewhere_. - * @see aiGetPredefinedLogStream - * @see aiAttachLogStream - * @see aiDetachLogStream */ -// -------------------------------------------------------------------------------- -struct aiLogStream -{ - /** callback to be called */ - aiLogStreamCallback callback; - - /** user data to be passed to the callback */ - char* user; -}; - - -// -------------------------------------------------------------------------------- -/** C-API: Represents an opaque set of settings to be used during importing. - * @see aiCreatePropertyStore - * @see aiReleasePropertyStore - * @see aiImportFileExWithProperties - * @see aiSetPropertyInteger - * @see aiSetPropertyFloat - * @see aiSetPropertyString - * @see aiSetPropertyMatrix - */ -// -------------------------------------------------------------------------------- -struct aiPropertyStore { char sentinel; }; - -/** Our own C boolean type */ -typedef int aiBool; - -#define AI_FALSE 0 -#define AI_TRUE 1 - -// -------------------------------------------------------------------------------- -/** Reads the given file and returns its content. - * - * If the call succeeds, the imported data is returned in an aiScene structure. - * The data is intended to be read-only, it stays property of the ASSIMP - * library and will be stable until aiReleaseImport() is called. After you're - * done with it, call aiReleaseImport() to free the resources associated with - * this file. If the import fails, NULL is returned instead. Call - * aiGetErrorString() to retrieve a human-readable error text. - * @param pFile Path and filename of the file to be imported, - * expected to be a null-terminated c-string. NULL is not a valid value. - * @param pFlags Optional post processing steps to be executed after - * a successful import. Provide a bitwise combination of the - * #aiPostProcessSteps flags. - * @return Pointer to the imported data or NULL if the import failed. - */ -ASSIMP_API const C_STRUCT aiScene* aiImportFile( - const char* pFile, - unsigned int pFlags); - -// -------------------------------------------------------------------------------- -/** Reads the given file using user-defined I/O functions and returns - * its content. - * - * If the call succeeds, the imported data is returned in an aiScene structure. - * The data is intended to be read-only, it stays property of the ASSIMP - * library and will be stable until aiReleaseImport() is called. After you're - * done with it, call aiReleaseImport() to free the resources associated with - * this file. If the import fails, NULL is returned instead. Call - * aiGetErrorString() to retrieve a human-readable error text. - * @param pFile Path and filename of the file to be imported, - * expected to be a null-terminated c-string. NULL is not a valid value. - * @param pFlags Optional post processing steps to be executed after - * a successful import. Provide a bitwise combination of the - * #aiPostProcessSteps flags. - * @param pFS aiFileIO structure. Will be used to open the model file itself - * and any other files the loader needs to open. Pass NULL to use the default - * implementation. - * @return Pointer to the imported data or NULL if the import failed. - * @note Include for the definition of #aiFileIO. - */ -ASSIMP_API const C_STRUCT aiScene* aiImportFileEx( - const char* pFile, - unsigned int pFlags, - C_STRUCT aiFileIO* pFS); - -// -------------------------------------------------------------------------------- -/** Same as #aiImportFileEx, but adds an extra parameter containing importer settings. - * - * @param pFile Path and filename of the file to be imported, - * expected to be a null-terminated c-string. NULL is not a valid value. - * @param pFlags Optional post processing steps to be executed after - * a successful import. Provide a bitwise combination of the - * #aiPostProcessSteps flags. - * @param pFS aiFileIO structure. Will be used to open the model file itself - * and any other files the loader needs to open. Pass NULL to use the default - * implementation. - * @param pProps #aiPropertyStore instance containing import settings. - * @return Pointer to the imported data or NULL if the import failed. - * @note Include for the definition of #aiFileIO. - * @see aiImportFileEx - */ -ASSIMP_API const C_STRUCT aiScene* aiImportFileExWithProperties( - const char* pFile, - unsigned int pFlags, - C_STRUCT aiFileIO* pFS, - const C_STRUCT aiPropertyStore* pProps); - -// -------------------------------------------------------------------------------- -/** Reads the given file from a given memory buffer, - * - * If the call succeeds, the contents of the file are returned as a pointer to an - * aiScene object. The returned data is intended to be read-only, the importer keeps - * ownership of the data and will destroy it upon destruction. If the import fails, - * NULL is returned. - * A human-readable error description can be retrieved by calling aiGetErrorString(). - * @param pBuffer Pointer to the file data - * @param pLength Length of pBuffer, in bytes - * @param pFlags Optional post processing steps to be executed after - * a successful import. Provide a bitwise combination of the - * #aiPostProcessSteps flags. If you wish to inspect the imported - * scene first in order to fine-tune your post-processing setup, - * consider to use #aiApplyPostProcessing(). - * @param pHint An additional hint to the library. If this is a non empty string, - * the library looks for a loader to support the file extension specified by pHint - * and passes the file to the first matching loader. If this loader is unable to - * completely the request, the library continues and tries to determine the file - * format on its own, a task that may or may not be successful. - * Check the return value, and you'll know ... - * @return A pointer to the imported data, NULL if the import failed. - * - * @note This is a straightforward way to decode models from memory - * buffers, but it doesn't handle model formats that spread their - * data across multiple files or even directories. Examples include - * OBJ or MD3, which outsource parts of their material info into - * external scripts. If you need full functionality, provide - * a custom IOSystem to make Assimp find these files and use - * the regular aiImportFileEx()/aiImportFileExWithProperties() API. - */ -ASSIMP_API const C_STRUCT aiScene* aiImportFileFromMemory( - const char* pBuffer, - unsigned int pLength, - unsigned int pFlags, - const char* pHint); - -// -------------------------------------------------------------------------------- -/** Same as #aiImportFileFromMemory, but adds an extra parameter containing importer settings. - * - * @param pBuffer Pointer to the file data - * @param pLength Length of pBuffer, in bytes - * @param pFlags Optional post processing steps to be executed after - * a successful import. Provide a bitwise combination of the - * #aiPostProcessSteps flags. If you wish to inspect the imported - * scene first in order to fine-tune your post-processing setup, - * consider to use #aiApplyPostProcessing(). - * @param pHint An additional hint to the library. If this is a non empty string, - * the library looks for a loader to support the file extension specified by pHint - * and passes the file to the first matching loader. If this loader is unable to - * completely the request, the library continues and tries to determine the file - * format on its own, a task that may or may not be successful. - * Check the return value, and you'll know ... - * @param pProps #aiPropertyStore instance containing import settings. - * @return A pointer to the imported data, NULL if the import failed. - * - * @note This is a straightforward way to decode models from memory - * buffers, but it doesn't handle model formats that spread their - * data across multiple files or even directories. Examples include - * OBJ or MD3, which outsource parts of their material info into - * external scripts. If you need full functionality, provide - * a custom IOSystem to make Assimp find these files and use - * the regular aiImportFileEx()/aiImportFileExWithProperties() API. - * @see aiImportFileFromMemory - */ -ASSIMP_API const C_STRUCT aiScene* aiImportFileFromMemoryWithProperties( - const char* pBuffer, - unsigned int pLength, - unsigned int pFlags, - const char* pHint, - const C_STRUCT aiPropertyStore* pProps); - -// -------------------------------------------------------------------------------- -/** Apply post-processing to an already-imported scene. - * - * This is strictly equivalent to calling #aiImportFile()/#aiImportFileEx with the - * same flags. However, you can use this separate function to inspect the imported - * scene first to fine-tune your post-processing setup. - * @param pScene Scene to work on. - * @param pFlags Provide a bitwise combination of the #aiPostProcessSteps flags. - * @return A pointer to the post-processed data. Post processing is done in-place, - * meaning this is still the same #aiScene which you passed for pScene. However, - * _if_ post-processing failed, the scene could now be NULL. That's quite a rare - * case, post processing steps are not really designed to 'fail'. To be exact, - * the #aiProcess_ValidateDataStructure flag is currently the only post processing step - * which can actually cause the scene to be reset to NULL. - */ -ASSIMP_API const C_STRUCT aiScene* aiApplyPostProcessing( - const C_STRUCT aiScene* pScene, - unsigned int pFlags); - -// -------------------------------------------------------------------------------- -/** Get one of the predefine log streams. This is the quick'n'easy solution to - * access Assimp's log system. Attaching a log stream can slightly reduce Assimp's - * overall import performance. - * - * Usage is rather simple (this will stream the log to a file, named log.txt, and - * the stdout stream of the process: - * @code - * struct aiLogStream c; - * c = aiGetPredefinedLogStream(aiDefaultLogStream_FILE,"log.txt"); - * aiAttachLogStream(&c); - * c = aiGetPredefinedLogStream(aiDefaultLogStream_STDOUT,NULL); - * aiAttachLogStream(&c); - * @endcode - * - * @param pStreams One of the #aiDefaultLogStream enumerated values. - * @param file Solely for the #aiDefaultLogStream_FILE flag: specifies the file to write to. - * Pass NULL for all other flags. - * @return The log stream. callback is set to NULL if something went wrong. - */ -ASSIMP_API C_STRUCT aiLogStream aiGetPredefinedLogStream( - C_ENUM aiDefaultLogStream pStreams, - const char* file); - -// -------------------------------------------------------------------------------- -/** Attach a custom log stream to the libraries' logging system. - * - * Attaching a log stream can slightly reduce Assimp's overall import - * performance. Multiple log-streams can be attached. - * @param stream Describes the new log stream. - * @note To ensure proper destruction of the logging system, you need to manually - * call aiDetachLogStream() on every single log stream you attach. - * Alternatively (for the lazy folks) #aiDetachAllLogStreams is provided. - */ -ASSIMP_API void aiAttachLogStream( - const C_STRUCT aiLogStream* stream); - -// -------------------------------------------------------------------------------- -/** Enable verbose logging. Verbose logging includes debug-related stuff and - * detailed import statistics. This can have severe impact on import performance - * and memory consumption. However, it might be useful to find out why a file - * didn't read correctly. - * @param d AI_TRUE or AI_FALSE, your decision. - */ -ASSIMP_API void aiEnableVerboseLogging(aiBool d); - -// -------------------------------------------------------------------------------- -/** Detach a custom log stream from the libraries' logging system. - * - * This is the counterpart of #aiAttachLogStream. If you attached a stream, - * don't forget to detach it again. - * @param stream The log stream to be detached. - * @return AI_SUCCESS if the log stream has been detached successfully. - * @see aiDetachAllLogStreams - */ -ASSIMP_API C_ENUM aiReturn aiDetachLogStream( - const C_STRUCT aiLogStream* stream); - -// -------------------------------------------------------------------------------- -/** Detach all active log streams from the libraries' logging system. - * This ensures that the logging system is terminated properly and all - * resources allocated by it are actually freed. If you attached a stream, - * don't forget to detach it again. - * @see aiAttachLogStream - * @see aiDetachLogStream - */ -ASSIMP_API void aiDetachAllLogStreams(void); - -// -------------------------------------------------------------------------------- -/** Releases all resources associated with the given import process. - * - * Call this function after you're done with the imported data. - * @param pScene The imported data to release. NULL is a valid value. - */ -ASSIMP_API void aiReleaseImport( - const C_STRUCT aiScene* pScene); - -// -------------------------------------------------------------------------------- -/** Returns the error text of the last failed import process. - * - * @return A textual description of the error that occurred at the last - * import process. NULL if there was no error. There can't be an error if you - * got a non-NULL #aiScene from #aiImportFile/#aiImportFileEx/#aiApplyPostProcessing. - */ -ASSIMP_API const char* aiGetErrorString(); - -// -------------------------------------------------------------------------------- -/** Returns whether a given file extension is supported by ASSIMP - * - * @param szExtension Extension for which the function queries support for. - * Must include a leading dot '.'. Example: ".3ds", ".md3" - * @return AI_TRUE if the file extension is supported. - */ -ASSIMP_API aiBool aiIsExtensionSupported( - const char* szExtension); - -// -------------------------------------------------------------------------------- -/** Get a list of all file extensions supported by ASSIMP. - * - * If a file extension is contained in the list this does, of course, not - * mean that ASSIMP is able to load all files with this extension. - * @param szOut String to receive the extension list. - * Format of the list: "*.3ds;*.obj;*.dae". NULL is not a valid parameter. - */ -ASSIMP_API void aiGetExtensionList( - C_STRUCT aiString* szOut); - -// -------------------------------------------------------------------------------- -/** Get the approximated storage required by an imported asset - * @param pIn Input asset. - * @param in Data structure to be filled. - */ -ASSIMP_API void aiGetMemoryRequirements( - const C_STRUCT aiScene* pIn, - C_STRUCT aiMemoryInfo* in); - - - -// -------------------------------------------------------------------------------- -/** Create an empty property store. Property stores are used to collect import - * settings. - * @return New property store. Property stores need to be manually destroyed using - * the #aiReleasePropertyStore API function. - */ -ASSIMP_API C_STRUCT aiPropertyStore* aiCreatePropertyStore(void); - -// -------------------------------------------------------------------------------- -/** Delete a property store. - * @param p Property store to be deleted. - */ -ASSIMP_API void aiReleasePropertyStore(C_STRUCT aiPropertyStore* p); - -// -------------------------------------------------------------------------------- -/** Set an integer property. - * - * This is the C-version of #Assimp::Importer::SetPropertyInteger(). In the C - * interface, properties are always shared by all imports. It is not possible to - * specify them per import. - * - * @param store Store to modify. Use #aiCreatePropertyStore to obtain a store. - * @param szName Name of the configuration property to be set. All supported - * public properties are defined in the config.h header file (AI_CONFIG_XXX). - * @param value New value for the property - */ -ASSIMP_API void aiSetImportPropertyInteger( - C_STRUCT aiPropertyStore* store, - const char* szName, - int value); - -// -------------------------------------------------------------------------------- -/** Set a floating-point property. - * - * This is the C-version of #Assimp::Importer::SetPropertyFloat(). In the C - * interface, properties are always shared by all imports. It is not possible to - * specify them per import. - * - * @param store Store to modify. Use #aiCreatePropertyStore to obtain a store. - * @param szName Name of the configuration property to be set. All supported - * public properties are defined in the config.h header file (AI_CONFIG_XXX). - * @param value New value for the property - */ -ASSIMP_API void aiSetImportPropertyFloat( - C_STRUCT aiPropertyStore* store, - const char* szName, - float value); - -// -------------------------------------------------------------------------------- -/** Set a string property. - * - * This is the C-version of #Assimp::Importer::SetPropertyString(). In the C - * interface, properties are always shared by all imports. It is not possible to - * specify them per import. - * - * @param store Store to modify. Use #aiCreatePropertyStore to obtain a store. - * @param szName Name of the configuration property to be set. All supported - * public properties are defined in the config.h header file (AI_CONFIG_XXX). - * @param st New value for the property - */ -ASSIMP_API void aiSetImportPropertyString( - C_STRUCT aiPropertyStore* store, - const char* szName, - const C_STRUCT aiString* st); - -// -------------------------------------------------------------------------------- -/** Set a matrix property. - * - * This is the C-version of #Assimp::Importer::SetPropertyMatrix(). In the C - * interface, properties are always shared by all imports. It is not possible to - * specify them per import. - * - * @param store Store to modify. Use #aiCreatePropertyStore to obtain a store. - * @param szName Name of the configuration property to be set. All supported - * public properties are defined in the config.h header file (AI_CONFIG_XXX). - * @param mat New value for the property - */ -ASSIMP_API void aiSetImportPropertyMatrix( - C_STRUCT aiPropertyStore* store, - const char* szName, - const C_STRUCT aiMatrix4x4* mat); - -// -------------------------------------------------------------------------------- -/** Construct a quaternion from a 3x3 rotation matrix. - * @param quat Receives the output quaternion. - * @param mat Matrix to 'quaternionize'. - * @see aiQuaternion(const aiMatrix3x3& pRotMatrix) - */ -ASSIMP_API void aiCreateQuaternionFromMatrix( - C_STRUCT aiQuaternion* quat, - const C_STRUCT aiMatrix3x3* mat); - -// -------------------------------------------------------------------------------- -/** Decompose a transformation matrix into its rotational, translational and - * scaling components. - * - * @param mat Matrix to decompose - * @param scaling Receives the scaling component - * @param rotation Receives the rotational component - * @param position Receives the translational component. - * @see aiMatrix4x4::Decompose (aiVector3D&, aiQuaternion&, aiVector3D&) const; - */ -ASSIMP_API void aiDecomposeMatrix( - const C_STRUCT aiMatrix4x4* mat, - C_STRUCT aiVector3D* scaling, - C_STRUCT aiQuaternion* rotation, - C_STRUCT aiVector3D* position); - -// -------------------------------------------------------------------------------- -/** Transpose a 4x4 matrix. - * @param mat Pointer to the matrix to be transposed - */ -ASSIMP_API void aiTransposeMatrix4( - C_STRUCT aiMatrix4x4* mat); - -// -------------------------------------------------------------------------------- -/** Transpose a 3x3 matrix. - * @param mat Pointer to the matrix to be transposed - */ -ASSIMP_API void aiTransposeMatrix3( - C_STRUCT aiMatrix3x3* mat); - -// -------------------------------------------------------------------------------- -/** Transform a vector by a 3x3 matrix - * @param vec Vector to be transformed. - * @param mat Matrix to transform the vector with. - */ -ASSIMP_API void aiTransformVecByMatrix3( - C_STRUCT aiVector3D* vec, - const C_STRUCT aiMatrix3x3* mat); - -// -------------------------------------------------------------------------------- -/** Transform a vector by a 4x4 matrix - * @param vec Vector to be transformed. - * @param mat Matrix to transform the vector with. - */ -ASSIMP_API void aiTransformVecByMatrix4( - C_STRUCT aiVector3D* vec, - const C_STRUCT aiMatrix4x4* mat); - -// -------------------------------------------------------------------------------- -/** Multiply two 4x4 matrices. - * @param dst First factor, receives result. - * @param src Matrix to be multiplied with 'dst'. - */ -ASSIMP_API void aiMultiplyMatrix4( - C_STRUCT aiMatrix4x4* dst, - const C_STRUCT aiMatrix4x4* src); - -// -------------------------------------------------------------------------------- -/** Multiply two 3x3 matrices. - * @param dst First factor, receives result. - * @param src Matrix to be multiplied with 'dst'. - */ -ASSIMP_API void aiMultiplyMatrix3( - C_STRUCT aiMatrix3x3* dst, - const C_STRUCT aiMatrix3x3* src); - -// -------------------------------------------------------------------------------- -/** Get a 3x3 identity matrix. - * @param mat Matrix to receive its personal identity - */ -ASSIMP_API void aiIdentityMatrix3( - C_STRUCT aiMatrix3x3* mat); - -// -------------------------------------------------------------------------------- -/** Get a 4x4 identity matrix. - * @param mat Matrix to receive its personal identity - */ -ASSIMP_API void aiIdentityMatrix4( - C_STRUCT aiMatrix4x4* mat); - -// -------------------------------------------------------------------------------- -/** Returns the number of import file formats available in the current Assimp build. - * Use aiGetImportFormatDescription() to retrieve infos of a specific import format. - */ -ASSIMP_API size_t aiGetImportFormatCount(void); - -// -------------------------------------------------------------------------------- -/** Returns a description of the nth import file format. Use #aiGetImportFormatCount() - * to learn how many import formats are supported. - * @param pIndex Index of the import format to retrieve information for. Valid range is - * 0 to #aiGetImportFormatCount() - * @return A description of that specific import format. NULL if pIndex is out of range. - */ -ASSIMP_API const C_STRUCT aiImporterDesc* aiGetImportFormatDescription( size_t pIndex); -#ifdef __cplusplus -} -#endif - -#endif // AI_ASSIMP_H_INC diff --git a/thirdparty/include/assimp/color4.h b/thirdparty/include/assimp/color4.h deleted file mode 100644 index 6bcab45df..000000000 --- a/thirdparty/include/assimp/color4.h +++ /dev/null @@ -1,104 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ -/** @file color4.h - * @brief RGBA color structure, including operators when compiling in C++ - */ -#ifndef AI_COLOR4D_H_INC -#define AI_COLOR4D_H_INC - -#include "./Compiler/pushpack1.h" - -#ifdef __cplusplus - -// ---------------------------------------------------------------------------------- -/** Represents a color in Red-Green-Blue space including an -* alpha component. Color values range from 0 to 1. */ -// ---------------------------------------------------------------------------------- -template -class aiColor4t -{ -public: - aiColor4t () : r(), g(), b(), a() {} - aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a) - : r(_r), g(_g), b(_b), a(_a) {} - explicit aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {} - aiColor4t (const aiColor4t& o) - : r(o.r), g(o.g), b(o.b), a(o.a) {} - -public: - // combined operators - const aiColor4t& operator += (const aiColor4t& o); - const aiColor4t& operator -= (const aiColor4t& o); - const aiColor4t& operator *= (TReal f); - const aiColor4t& operator /= (TReal f); - -public: - // comparison - bool operator == (const aiColor4t& other) const; - bool operator != (const aiColor4t& other) const; - bool operator < (const aiColor4t& other) const; - - // color tuple access, rgba order - inline TReal operator[](unsigned int i) const; - inline TReal& operator[](unsigned int i); - - /** check whether a color is (close to) black */ - inline bool IsBlack() const; - -public: - - // Red, green, blue and alpha color values - TReal r, g, b, a; -} PACK_STRUCT; // !struct aiColor4D - -typedef aiColor4t aiColor4D; - -#else - -struct aiColor4D { - float r, g, b, a; -} PACK_STRUCT; - -#endif // __cplusplus - -#include "./Compiler/poppack1.h" - -#endif // AI_COLOR4D_H_INC diff --git a/thirdparty/include/assimp/color4.inl b/thirdparty/include/assimp/color4.inl deleted file mode 100644 index d69814714..000000000 --- a/thirdparty/include/assimp/color4.inl +++ /dev/null @@ -1,182 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file color4.inl - * @brief Inline implementation of aiColor4t operators - */ -#ifndef AI_COLOR4D_INL_INC -#define AI_COLOR4D_INL_INC - -#ifdef __cplusplus -#include "color4.h" - -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE const aiColor4t& aiColor4t::operator += (const aiColor4t& o) { - r += o.r; g += o.g; b += o.b; a += o.a; - return *this; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE const aiColor4t& aiColor4t::operator -= (const aiColor4t& o) { - r -= o.r; g -= o.g; b -= o.b; a -= o.a; - return *this; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE const aiColor4t& aiColor4t::operator *= (TReal f) { - r *= f; g *= f; b *= f; a *= f; - return *this; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE const aiColor4t& aiColor4t::operator /= (TReal f) { - r /= f; g /= f; b /= f; a /= f; - return *this; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE TReal aiColor4t::operator[](unsigned int i) const { - return *(&r + i); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE TReal& aiColor4t::operator[](unsigned int i) { - return *(&r + i); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE bool aiColor4t::operator== (const aiColor4t& other) const { - return r == other.r && g == other.g && b == other.b && a == other.a; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE bool aiColor4t::operator!= (const aiColor4t& other) const { - return r != other.r || g != other.g || b != other.b || a != other.a; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE bool aiColor4t::operator< (const aiColor4t& other) const { - return r < other.r || ( - r == other.r && ( - g < other.g || ( - g == other.g && ( - b < other.b || ( - b == other.b && ( - a < other.a - ) - ) - ) - ) - ) - ); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiColor4t operator + (const aiColor4t& v1, const aiColor4t& v2) { - return aiColor4t( v1.r + v2.r, v1.g + v2.g, v1.b + v2.b, v1.a + v2.a); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiColor4t operator - (const aiColor4t& v1, const aiColor4t& v2) { - return aiColor4t( v1.r - v2.r, v1.g - v2.g, v1.b - v2.b, v1.a - v2.a); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiColor4t operator * (const aiColor4t& v1, const aiColor4t& v2) { - return aiColor4t( v1.r * v2.r, v1.g * v2.g, v1.b * v2.b, v1.a * v2.a); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiColor4t operator / (const aiColor4t& v1, const aiColor4t& v2) { - return aiColor4t( v1.r / v2.r, v1.g / v2.g, v1.b / v2.b, v1.a / v2.a); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiColor4t operator * ( TReal f, const aiColor4t& v) { - return aiColor4t( f*v.r, f*v.g, f*v.b, f*v.a); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiColor4t operator * ( const aiColor4t& v, TReal f) { - return aiColor4t( f*v.r, f*v.g, f*v.b, f*v.a); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiColor4t operator / ( const aiColor4t& v, TReal f) { - return v * (1/f); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiColor4t operator / ( TReal f,const aiColor4t& v) { - return aiColor4t(f,f,f,f)/v; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiColor4t operator + ( const aiColor4t& v, TReal f) { - return aiColor4t( f+v.r, f+v.g, f+v.b, f+v.a); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiColor4t operator - ( const aiColor4t& v, TReal f) { - return aiColor4t( v.r-f, v.g-f, v.b-f, v.a-f); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiColor4t operator + ( TReal f, const aiColor4t& v) { - return aiColor4t( f+v.r, f+v.g, f+v.b, f+v.a); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiColor4t operator - ( TReal f, const aiColor4t& v) { - return aiColor4t( f-v.r, f-v.g, f-v.b, f-v.a); -} - -// ------------------------------------------------------------------------------------------------ -template -inline bool aiColor4t :: IsBlack() const { - // The alpha component doesn't care here. black is black. - static const TReal epsilon = 10e-3f; - return std::fabs( r ) < epsilon && std::fabs( g ) < epsilon && std::fabs( b ) < epsilon; -} - -#endif // __cplusplus -#endif // AI_VECTOR3D_INL_INC diff --git a/thirdparty/include/assimp/config.h b/thirdparty/include/assimp/config.h deleted file mode 100644 index 3db8a5697..000000000 --- a/thirdparty/include/assimp/config.h +++ /dev/null @@ -1,907 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file config.h - * @brief Defines constants for configurable properties for the library - * - * Typically these properties are set via - * #Assimp::Importer::SetPropertyFloat, - * #Assimp::Importer::SetPropertyInteger or - * #Assimp::Importer::SetPropertyString, - * depending on the data type of a property. All properties have a - * default value. See the doc for the mentioned methods for more details. - * - *

- * The corresponding functions for use with the plain-c API are: - * #aiSetImportPropertyInteger, - * #aiSetImportPropertyFloat, - * #aiSetImportPropertyString - */ -#ifndef INCLUDED_AI_CONFIG_H -#define INCLUDED_AI_CONFIG_H - - -// ########################################################################### -// LIBRARY SETTINGS -// General, global settings -// ########################################################################### - -// --------------------------------------------------------------------------- -/** @brief Enables time measurements. - * - * If enabled, measures the time needed for each part of the loading - * process (i.e. IO time, importing, postprocessing, ..) and dumps - * these timings to the DefaultLogger. See the @link perf Performance - * Page@endlink for more information on this topic. - * - * Property type: bool. Default value: false. - */ -#define AI_CONFIG_GLOB_MEASURE_TIME \ - "GLOB_MEASURE_TIME" - - -// --------------------------------------------------------------------------- -/** @brief Global setting to disable generation of skeleton dummy meshes - * - * Skeleton dummy meshes are generated as a visualization aid in cases which - * the input data contains no geometry, but only animation data. - * Property data type: bool. Default value: false - */ -// --------------------------------------------------------------------------- -#define AI_CONFIG_IMPORT_NO_SKELETON_MESHES \ - "IMPORT_NO_SKELETON_MESHES" - - - -# if 0 // not implemented yet -// --------------------------------------------------------------------------- -/** @brief Set Assimp's multithreading policy. - * - * This setting is ignored if Assimp was built without boost.thread - * support (ASSIMP_BUILD_NO_THREADING, which is implied by ASSIMP_BUILD_BOOST_WORKAROUND). - * Possible values are: -1 to let Assimp decide what to do, 0 to disable - * multithreading entirely and any number larger than 0 to force a specific - * number of threads. Assimp is always free to ignore this settings, which is - * merely a hint. Usually, the default value (-1) will be fine. However, if - * Assimp is used concurrently from multiple user threads, it might be useful - * to limit each Importer instance to a specific number of cores. - * - * For more information, see the @link threading Threading page@endlink. - * Property type: int, default value: -1. - */ -#define AI_CONFIG_GLOB_MULTITHREADING \ - "GLOB_MULTITHREADING" -#endif - -// ########################################################################### -// POST PROCESSING SETTINGS -// Various stuff to fine-tune the behavior of a specific post processing step. -// ########################################################################### - - -// --------------------------------------------------------------------------- -/** @brief Maximum bone count per mesh for the SplitbyBoneCount step. - * - * Meshes are split until the maximum number of bones is reached. The default - * value is AI_SBBC_DEFAULT_MAX_BONES, which may be altered at - * compile-time. - * Property data type: integer. - */ -// --------------------------------------------------------------------------- -#define AI_CONFIG_PP_SBBC_MAX_BONES \ - "PP_SBBC_MAX_BONES" - - -// default limit for bone count -#if (!defined AI_SBBC_DEFAULT_MAX_BONES) -# define AI_SBBC_DEFAULT_MAX_BONES 60 -#endif - - -// --------------------------------------------------------------------------- -/** @brief Specifies the maximum angle that may be between two vertex tangents - * that their tangents and bi-tangents are smoothed. - * - * This applies to the CalcTangentSpace-Step. The angle is specified - * in degrees. The maximum value is 175. - * Property type: float. Default value: 45 degrees - */ -#define AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE \ - "PP_CT_MAX_SMOOTHING_ANGLE" - -// --------------------------------------------------------------------------- -/** @brief Source UV channel for tangent space computation. - * - * The specified channel must exist or an error will be raised. - * Property type: integer. Default value: 0 - */ -// --------------------------------------------------------------------------- -#define AI_CONFIG_PP_CT_TEXTURE_CHANNEL_INDEX \ - "PP_CT_TEXTURE_CHANNEL_INDEX" - -// --------------------------------------------------------------------------- -/** @brief Specifies the maximum angle that may be between two face normals - * at the same vertex position that their are smoothed together. - * - * Sometimes referred to as 'crease angle'. - * This applies to the GenSmoothNormals-Step. The angle is specified - * in degrees, so 180 is PI. The default value is 175 degrees (all vertex - * normals are smoothed). The maximum value is 175, too. Property type: float. - * Warning: setting this option may cause a severe loss of performance. The - * performance is unaffected if the #AI_CONFIG_FAVOUR_SPEED flag is set but - * the output quality may be reduced. - */ -#define AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE \ - "PP_GSN_MAX_SMOOTHING_ANGLE" - - -// --------------------------------------------------------------------------- -/** @brief Sets the colormap (= palette) to be used to decode embedded - * textures in MDL (Quake or 3DGS) files. - * - * This must be a valid path to a file. The file is 768 (256*3) bytes - * large and contains RGB triplets for each of the 256 palette entries. - * The default value is colormap.lmp. If the file is not found, - * a default palette (from Quake 1) is used. - * Property type: string. - */ -#define AI_CONFIG_IMPORT_MDL_COLORMAP \ - "IMPORT_MDL_COLORMAP" - -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_RemoveRedundantMaterials step to - * keep materials matching a name in a given list. - * - * This is a list of 1 to n strings, ' ' serves as delimiter character. - * Identifiers containing whitespaces must be enclosed in *single* - * quotation marks. For example: - * "keep-me and_me_to anotherMaterialToBeKept \'name with whitespace\'". - * If a material matches on of these names, it will not be modified or - * removed by the postprocessing step nor will other materials be replaced - * by a reference to it.
- * This option might be useful if you are using some magic material names - * to pass additional semantics through the content pipeline. This ensures - * they won't be optimized away, but a general optimization is still - * performed for materials not contained in the list. - * Property type: String. Default value: n/a - * @note Linefeeds, tabs or carriage returns are treated as whitespace. - * Material names are case sensitive. - */ -#define AI_CONFIG_PP_RRM_EXCLUDE_LIST \ - "PP_RRM_EXCLUDE_LIST" - -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_PreTransformVertices step to - * keep the scene hierarchy. Meshes are moved to worldspace, but - * no optimization is performed (read: meshes with equal materials are not - * joined. The total number of meshes won't change). - * - * This option could be of use for you if the scene hierarchy contains - * important additional information which you intend to parse. - * For rendering, you can still render all meshes in the scene without - * any transformations. - * Property type: bool. Default value: false. - */ -#define AI_CONFIG_PP_PTV_KEEP_HIERARCHY \ - "PP_PTV_KEEP_HIERARCHY" - -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_PreTransformVertices step to normalize - * all vertex components into the [-1,1] range. That is, a bounding box - * for the whole scene is computed, the maximum component is taken and all - * meshes are scaled appropriately (uniformly of course!). - * This might be useful if you don't know the spatial dimension of the input - * data*/ -#define AI_CONFIG_PP_PTV_NORMALIZE \ - "PP_PTV_NORMALIZE" - -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_PreTransformVertices step to use - * a users defined matrix as the scene root node transformation before - * transforming vertices. - * Property type: bool. Default value: false. - */ -#define AI_CONFIG_PP_PTV_ADD_ROOT_TRANSFORMATION \ - "PP_PTV_ADD_ROOT_TRANSFORMATION" - -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_PreTransformVertices step to use - * a users defined matrix as the scene root node transformation before - * transforming vertices. This property correspond to the 'a1' component - * of the transformation matrix. - * Property type: aiMatrix4x4. - */ -#define AI_CONFIG_PP_PTV_ROOT_TRANSFORMATION \ - "PP_PTV_ROOT_TRANSFORMATION" - -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_FindDegenerates step to - * remove degenerated primitives from the import - immediately. - * - * The default behaviour converts degenerated triangles to lines and - * degenerated lines to points. See the documentation to the - * #aiProcess_FindDegenerates step for a detailed example of the various ways - * to get rid of these lines and points if you don't want them. - * Property type: bool. Default value: false. - */ -#define AI_CONFIG_PP_FD_REMOVE \ - "PP_FD_REMOVE" - -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_OptimizeGraph step to preserve nodes - * matching a name in a given list. - * - * This is a list of 1 to n strings, ' ' serves as delimiter character. - * Identifiers containing whitespaces must be enclosed in *single* - * quotation marks. For example: - * "keep-me and_me_to anotherNodeToBeKept \'name with whitespace\'". - * If a node matches on of these names, it will not be modified or - * removed by the postprocessing step.
- * This option might be useful if you are using some magic node names - * to pass additional semantics through the content pipeline. This ensures - * they won't be optimized away, but a general optimization is still - * performed for nodes not contained in the list. - * Property type: String. Default value: n/a - * @note Linefeeds, tabs or carriage returns are treated as whitespace. - * Node names are case sensitive. - */ -#define AI_CONFIG_PP_OG_EXCLUDE_LIST \ - "PP_OG_EXCLUDE_LIST" - -// --------------------------------------------------------------------------- -/** @brief Set the maximum number of triangles in a mesh. - * - * This is used by the "SplitLargeMeshes" PostProcess-Step to determine - * whether a mesh must be split or not. - * @note The default value is AI_SLM_DEFAULT_MAX_TRIANGLES - * Property type: integer. - */ -#define AI_CONFIG_PP_SLM_TRIANGLE_LIMIT \ - "PP_SLM_TRIANGLE_LIMIT" - -// default value for AI_CONFIG_PP_SLM_TRIANGLE_LIMIT -#if (!defined AI_SLM_DEFAULT_MAX_TRIANGLES) -# define AI_SLM_DEFAULT_MAX_TRIANGLES 1000000 -#endif - -// --------------------------------------------------------------------------- -/** @brief Set the maximum number of vertices in a mesh. - * - * This is used by the "SplitLargeMeshes" PostProcess-Step to determine - * whether a mesh must be split or not. - * @note The default value is AI_SLM_DEFAULT_MAX_VERTICES - * Property type: integer. - */ -#define AI_CONFIG_PP_SLM_VERTEX_LIMIT \ - "PP_SLM_VERTEX_LIMIT" - -// default value for AI_CONFIG_PP_SLM_VERTEX_LIMIT -#if (!defined AI_SLM_DEFAULT_MAX_VERTICES) -# define AI_SLM_DEFAULT_MAX_VERTICES 1000000 -#endif - -// --------------------------------------------------------------------------- -/** @brief Set the maximum number of bones affecting a single vertex - * - * This is used by the #aiProcess_LimitBoneWeights PostProcess-Step. - * @note The default value is AI_LBW_MAX_WEIGHTS - * Property type: integer.*/ -#define AI_CONFIG_PP_LBW_MAX_WEIGHTS \ - "PP_LBW_MAX_WEIGHTS" - -// default value for AI_CONFIG_PP_LBW_MAX_WEIGHTS -#if (!defined AI_LMW_MAX_WEIGHTS) -# define AI_LMW_MAX_WEIGHTS 0x4 -#endif // !! AI_LMW_MAX_WEIGHTS - -// --------------------------------------------------------------------------- -/** @brief Lower the deboning threshold in order to remove more bones. - * - * This is used by the #aiProcess_Debone PostProcess-Step. - * @note The default value is AI_DEBONE_THRESHOLD - * Property type: float.*/ -#define AI_CONFIG_PP_DB_THRESHOLD \ - "PP_DB_THRESHOLD" - -// default value for AI_CONFIG_PP_LBW_MAX_WEIGHTS -#if (!defined AI_DEBONE_THRESHOLD) -# define AI_DEBONE_THRESHOLD 1.0f -#endif // !! AI_DEBONE_THRESHOLD - -// --------------------------------------------------------------------------- -/** @brief Require all bones qualify for deboning before removing any - * - * This is used by the #aiProcess_Debone PostProcess-Step. - * @note The default value is 0 - * Property type: bool.*/ -#define AI_CONFIG_PP_DB_ALL_OR_NONE \ - "PP_DB_ALL_OR_NONE" - -/** @brief Default value for the #AI_CONFIG_PP_ICL_PTCACHE_SIZE property - */ -#ifndef PP_ICL_PTCACHE_SIZE -# define PP_ICL_PTCACHE_SIZE 12 -#endif - -// --------------------------------------------------------------------------- -/** @brief Set the size of the post-transform vertex cache to optimize the - * vertices for. This configures the #aiProcess_ImproveCacheLocality step. - * - * The size is given in vertices. Of course you can't know how the vertex - * format will exactly look like after the import returns, but you can still - * guess what your meshes will probably have. - * @note The default value is #PP_ICL_PTCACHE_SIZE. That results in slight - * performance improvements for most nVidia/AMD cards since 2002. - * Property type: integer. - */ -#define AI_CONFIG_PP_ICL_PTCACHE_SIZE "PP_ICL_PTCACHE_SIZE" - -// --------------------------------------------------------------------------- -/** @brief Enumerates components of the aiScene and aiMesh data structures - * that can be excluded from the import using the #aiProcess_RemoveComponent step. - * - * See the documentation to #aiProcess_RemoveComponent for more details. - */ -enum aiComponent -{ - /** Normal vectors */ -#ifdef SWIG - aiComponent_NORMALS = 0x2, -#else - aiComponent_NORMALS = 0x2u, -#endif - - /** Tangents and bitangents go always together ... */ -#ifdef SWIG - aiComponent_TANGENTS_AND_BITANGENTS = 0x4, -#else - aiComponent_TANGENTS_AND_BITANGENTS = 0x4u, -#endif - - /** ALL color sets - * Use aiComponent_COLORn(N) to specify the N'th set */ - aiComponent_COLORS = 0x8, - - /** ALL texture UV sets - * aiComponent_TEXCOORDn(N) to specify the N'th set */ - aiComponent_TEXCOORDS = 0x10, - - /** Removes all bone weights from all meshes. - * The scenegraph nodes corresponding to the bones are NOT removed. - * use the #aiProcess_OptimizeGraph step to do this */ - aiComponent_BONEWEIGHTS = 0x20, - - /** Removes all node animations (aiScene::mAnimations). - * The corresponding scenegraph nodes are NOT removed. - * use the #aiProcess_OptimizeGraph step to do this */ - aiComponent_ANIMATIONS = 0x40, - - /** Removes all embedded textures (aiScene::mTextures) */ - aiComponent_TEXTURES = 0x80, - - /** Removes all light sources (aiScene::mLights). - * The corresponding scenegraph nodes are NOT removed. - * use the #aiProcess_OptimizeGraph step to do this */ - aiComponent_LIGHTS = 0x100, - - /** Removes all cameras (aiScene::mCameras). - * The corresponding scenegraph nodes are NOT removed. - * use the #aiProcess_OptimizeGraph step to do this */ - aiComponent_CAMERAS = 0x200, - - /** Removes all meshes (aiScene::mMeshes). */ - aiComponent_MESHES = 0x400, - - /** Removes all materials. One default material will - * be generated, so aiScene::mNumMaterials will be 1. */ - aiComponent_MATERIALS = 0x800, - - - /** This value is not used. It is just there to force the - * compiler to map this enum to a 32 Bit integer. */ -#ifndef SWIG - _aiComponent_Force32Bit = 0x9fffffff -#endif -}; - -// Remove a specific color channel 'n' -#define aiComponent_COLORSn(n) (1u << (n+20u)) - -// Remove a specific UV channel 'n' -#define aiComponent_TEXCOORDSn(n) (1u << (n+25u)) - -// --------------------------------------------------------------------------- -/** @brief Input parameter to the #aiProcess_RemoveComponent step: - * Specifies the parts of the data structure to be removed. - * - * See the documentation to this step for further details. The property - * is expected to be an integer, a bitwise combination of the - * #aiComponent flags defined above in this header. The default - * value is 0. Important: if no valid mesh is remaining after the - * step has been executed (e.g you thought it was funny to specify ALL - * of the flags defined above) the import FAILS. Mainly because there is - * no data to work on anymore ... - */ -#define AI_CONFIG_PP_RVC_FLAGS \ - "PP_RVC_FLAGS" - -// --------------------------------------------------------------------------- -/** @brief Input parameter to the #aiProcess_SortByPType step: - * Specifies which primitive types are removed by the step. - * - * This is a bitwise combination of the aiPrimitiveType flags. - * Specifying all of them is illegal, of course. A typical use would - * be to exclude all line and point meshes from the import. This - * is an integer property, its default value is 0. - */ -#define AI_CONFIG_PP_SBP_REMOVE \ - "PP_SBP_REMOVE" - -// --------------------------------------------------------------------------- -/** @brief Input parameter to the #aiProcess_FindInvalidData step: - * Specifies the floating-point accuracy for animation values. The step - * checks for animation tracks where all frame values are absolutely equal - * and removes them. This tweakable controls the epsilon for floating-point - * comparisons - two keys are considered equal if the invariant - * abs(n0-n1)>epsilon holds true for all vector respectively quaternion - * components. The default value is 0.f - comparisons are exact then. - */ -#define AI_CONFIG_PP_FID_ANIM_ACCURACY \ - "PP_FID_ANIM_ACCURACY" - - -// TransformUVCoords evaluates UV scalings -#define AI_UVTRAFO_SCALING 0x1 - -// TransformUVCoords evaluates UV rotations -#define AI_UVTRAFO_ROTATION 0x2 - -// TransformUVCoords evaluates UV translation -#define AI_UVTRAFO_TRANSLATION 0x4 - -// Everything baked together -> default value -#define AI_UVTRAFO_ALL (AI_UVTRAFO_SCALING | AI_UVTRAFO_ROTATION | AI_UVTRAFO_TRANSLATION) - -// --------------------------------------------------------------------------- -/** @brief Input parameter to the #aiProcess_TransformUVCoords step: - * Specifies which UV transformations are evaluated. - * - * This is a bitwise combination of the AI_UVTRAFO_XXX flags (integer - * property, of course). By default all transformations are enabled - * (AI_UVTRAFO_ALL). - */ -#define AI_CONFIG_PP_TUV_EVALUATE \ - "PP_TUV_EVALUATE" - -// --------------------------------------------------------------------------- -/** @brief A hint to assimp to favour speed against import quality. - * - * Enabling this option may result in faster loading, but it needn't. - * It represents just a hint to loaders and post-processing steps to use - * faster code paths, if possible. - * This property is expected to be an integer, != 0 stands for true. - * The default value is 0. - */ -#define AI_CONFIG_FAVOUR_SPEED \ - "FAVOUR_SPEED" - - -// ########################################################################### -// IMPORTER SETTINGS -// Various stuff to fine-tune the behaviour of specific importer plugins. -// ########################################################################### - - -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will merge all geometry layers present - * in the source file or take only the first. - * - * The default value is true (1) - * Property type: bool - */ -#define AI_CONFIG_IMPORT_FBX_READ_ALL_GEOMETRY_LAYERS \ - "IMPORT_FBX_READ_ALL_GEOMETRY_LAYERS" - -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read all materials present in the - * source file or take only the referenced materials. - * - * This is void unless IMPORT_FBX_READ_MATERIALS=1. - * - * The default value is false (0) - * Property type: bool - */ -#define AI_CONFIG_IMPORT_FBX_READ_ALL_MATERIALS \ - "IMPORT_FBX_READ_ALL_MATERIALS" - -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read materials. - * - * The default value is true (1) - * Property type: bool - */ -#define AI_CONFIG_IMPORT_FBX_READ_MATERIALS \ - "IMPORT_FBX_READ_MATERIALS" - -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read embedded textures. - * - * The default value is true (1) - * Property type: bool - */ -#define AI_CONFIG_IMPORT_FBX_READ_TEXTURES \ - "IMPORT_FBX_READ_TEXTURES" - -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read cameras. - * - * The default value is true (1) - * Property type: bool - */ -#define AI_CONFIG_IMPORT_FBX_READ_CAMERAS \ - "IMPORT_FBX_READ_CAMERAS" - -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read light sources. - * - * The default value is true (1) - * Property type: bool - */ -#define AI_CONFIG_IMPORT_FBX_READ_LIGHTS \ - "IMPORT_FBX_READ_LIGHTS" - -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read animations. - * - * The default value is true (1) - * Property type: bool - */ -#define AI_CONFIG_IMPORT_FBX_READ_ANIMATIONS \ - "IMPORT_FBX_READ_ANIMATIONS" - -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will act in strict mode in which only - * FBX 2013 is supported and any other sub formats are rejected. FBX 2013 - * is the primary target for the importer, so this format is best - * supported and well-tested. - * - * The default value is false (0) - * Property type: bool - */ -#define AI_CONFIG_IMPORT_FBX_STRICT_MODE \ - "IMPORT_FBX_STRICT_MODE" - -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will preserve pivot points for - * transformations (as extra nodes). If set to false, pivots and offsets - * will be evaluated whenever possible. - * - * The default value is true (1) - * Property type: bool - */ -#define AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS \ - "IMPORT_FBX_PRESERVE_PIVOTS" - -// --------------------------------------------------------------------------- -/** @brief Specifies whether the importer will drop empty animation curves or - * animation curves which match the bind pose transformation over their - * entire defined range. - * - * The default value is true (1) - * Property type: bool - */ -#define AI_CONFIG_IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES \ - "IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES" - - - -// --------------------------------------------------------------------------- -/** @brief Set the vertex animation keyframe to be imported - * - * ASSIMP does not support vertex keyframes (only bone animation is supported). - * The library reads only one frame of models with vertex animations. - * By default this is the first frame. - * \note The default value is 0. This option applies to all importers. - * However, it is also possible to override the global setting - * for a specific loader. You can use the AI_CONFIG_IMPORT_XXX_KEYFRAME - * options (where XXX is a placeholder for the file format for which you - * want to override the global setting). - * Property type: integer. - */ -#define AI_CONFIG_IMPORT_GLOBAL_KEYFRAME "IMPORT_GLOBAL_KEYFRAME" - -#define AI_CONFIG_IMPORT_MD3_KEYFRAME "IMPORT_MD3_KEYFRAME" -#define AI_CONFIG_IMPORT_MD2_KEYFRAME "IMPORT_MD2_KEYFRAME" -#define AI_CONFIG_IMPORT_MDL_KEYFRAME "IMPORT_MDL_KEYFRAME" -#define AI_CONFIG_IMPORT_MDC_KEYFRAME "IMPORT_MDC_KEYFRAME" -#define AI_CONFIG_IMPORT_SMD_KEYFRAME "IMPORT_SMD_KEYFRAME" -#define AI_CONFIG_IMPORT_UNREAL_KEYFRAME "IMPORT_UNREAL_KEYFRAME" - - -// --------------------------------------------------------------------------- -/** @brief Configures the AC loader to collect all surfaces which have the - * "Backface cull" flag set in separate meshes. - * - * Property type: bool. Default value: true. - */ -#define AI_CONFIG_IMPORT_AC_SEPARATE_BFCULL \ - "IMPORT_AC_SEPARATE_BFCULL" - -// --------------------------------------------------------------------------- -/** @brief Configures whether the AC loader evaluates subdivision surfaces ( - * indicated by the presence of the 'subdiv' attribute in the file). By - * default, Assimp performs the subdivision using the standard - * Catmull-Clark algorithm - * - * * Property type: bool. Default value: true. - */ -#define AI_CONFIG_IMPORT_AC_EVAL_SUBDIVISION \ - "IMPORT_AC_EVAL_SUBDIVISION" - -// --------------------------------------------------------------------------- -/** @brief Configures the UNREAL 3D loader to separate faces with different - * surface flags (e.g. two-sided vs. single-sided). - * - * * Property type: bool. Default value: true. - */ -#define AI_CONFIG_IMPORT_UNREAL_HANDLE_FLAGS \ - "UNREAL_HANDLE_FLAGS" - -// --------------------------------------------------------------------------- -/** @brief Configures the terragen import plugin to compute uv's for - * terrains, if not given. Furthermore a default texture is assigned. - * - * UV coordinates for terrains are so simple to compute that you'll usually - * want to compute them on your own, if you need them. This option is intended - * for model viewers which want to offer an easy way to apply textures to - * terrains. - * * Property type: bool. Default value: false. - */ -#define AI_CONFIG_IMPORT_TER_MAKE_UVS \ - "IMPORT_TER_MAKE_UVS" - -// --------------------------------------------------------------------------- -/** @brief Configures the ASE loader to always reconstruct normal vectors - * basing on the smoothing groups loaded from the file. - * - * Some ASE files have carry invalid normals, other don't. - * * Property type: bool. Default value: true. - */ -#define AI_CONFIG_IMPORT_ASE_RECONSTRUCT_NORMALS \ - "IMPORT_ASE_RECONSTRUCT_NORMALS" - -// --------------------------------------------------------------------------- -/** @brief Configures the M3D loader to detect and process multi-part - * Quake player models. - * - * These models usually consist of 3 files, lower.md3, upper.md3 and - * head.md3. If this property is set to true, Assimp will try to load and - * combine all three files if one of them is loaded. - * Property type: bool. Default value: true. - */ -#define AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART \ - "IMPORT_MD3_HANDLE_MULTIPART" - -// --------------------------------------------------------------------------- -/** @brief Tells the MD3 loader which skin files to load. - * - * When loading MD3 files, Assimp checks whether a file - * [md3_file_name]_[skin_name].skin is existing. These files are used by - * Quake III to be able to assign different skins (e.g. red and blue team) - * to models. 'default', 'red', 'blue' are typical skin names. - * Property type: String. Default value: "default". - */ -#define AI_CONFIG_IMPORT_MD3_SKIN_NAME \ - "IMPORT_MD3_SKIN_NAME" - -// --------------------------------------------------------------------------- -/** @brief Specify the Quake 3 shader file to be used for a particular - * MD3 file. This can also be a search path. - * - * By default Assimp's behaviour is as follows: If a MD3 file - * any_path/models/any_q3_subdir/model_name/file_name.md3 is - * loaded, the library tries to locate the corresponding shader file in - * any_path/scripts/model_name.shader. This property overrides this - * behaviour. It can either specify a full path to the shader to be loaded - * or alternatively the path (relative or absolute) to the directory where - * the shaders for all MD3s to be loaded reside. Assimp attempts to open - * IMPORT_MD3_SHADER_SRC/model_name.shader first, IMPORT_MD3_SHADER_SRC/file_name.shader - * is the fallback file. Note that IMPORT_MD3_SHADER_SRC should have a terminal (back)slash. - * Property type: String. Default value: n/a. - */ -#define AI_CONFIG_IMPORT_MD3_SHADER_SRC \ - "IMPORT_MD3_SHADER_SRC" - -// --------------------------------------------------------------------------- -/** @brief Configures the LWO loader to load just one layer from the model. - * - * LWO files consist of layers and in some cases it could be useful to load - * only one of them. This property can be either a string - which specifies - * the name of the layer - or an integer - the index of the layer. If the - * property is not set the whole LWO model is loaded. Loading fails if the - * requested layer is not available. The layer index is zero-based and the - * layer name may not be empty.
- * Property type: Integer. Default value: all layers are loaded. - */ -#define AI_CONFIG_IMPORT_LWO_ONE_LAYER_ONLY \ - "IMPORT_LWO_ONE_LAYER_ONLY" - -// --------------------------------------------------------------------------- -/** @brief Configures the MD5 loader to not load the MD5ANIM file for - * a MD5MESH file automatically. - * - * The default strategy is to look for a file with the same name but the - * MD5ANIM extension in the same directory. If it is found, it is loaded - * and combined with the MD5MESH file. This configuration option can be - * used to disable this behaviour. - * - * * Property type: bool. Default value: false. - */ -#define AI_CONFIG_IMPORT_MD5_NO_ANIM_AUTOLOAD \ - "IMPORT_MD5_NO_ANIM_AUTOLOAD" - -// --------------------------------------------------------------------------- -/** @brief Defines the begin of the time range for which the LWS loader - * evaluates animations and computes aiNodeAnim's. - * - * Assimp provides full conversion of LightWave's envelope system, including - * pre and post conditions. The loader computes linearly subsampled animation - * chanels with the frame rate given in the LWS file. This property defines - * the start time. Note: animation channels are only generated if a node - * has at least one envelope with more tan one key assigned. This property. - * is given in frames, '0' is the first frame. By default, if this property - * is not set, the importer takes the animation start from the input LWS - * file ('FirstFrame' line)
- * Property type: Integer. Default value: taken from file. - * - * @see AI_CONFIG_IMPORT_LWS_ANIM_END - end of the imported time range - */ -#define AI_CONFIG_IMPORT_LWS_ANIM_START \ - "IMPORT_LWS_ANIM_START" -#define AI_CONFIG_IMPORT_LWS_ANIM_END \ - "IMPORT_LWS_ANIM_END" - -// --------------------------------------------------------------------------- -/** @brief Defines the output frame rate of the IRR loader. - * - * IRR animations are difficult to convert for Assimp and there will - * always be a loss of quality. This setting defines how many keys per second - * are returned by the converter.
- * Property type: integer. Default value: 100 - */ -#define AI_CONFIG_IMPORT_IRR_ANIM_FPS \ - "IMPORT_IRR_ANIM_FPS" - -// --------------------------------------------------------------------------- -/** @brief Ogre Importer will try to find referenced materials from this file. - * - * Ogre meshes reference with material names, this does not tell Assimp the file - * where it is located in. Assimp will try to find the source file in the following - * order: .material, .material and - * lastly the material name defined by this config property. - *
- * Property type: String. Default value: Scene.material. - */ -#define AI_CONFIG_IMPORT_OGRE_MATERIAL_FILE \ - "IMPORT_OGRE_MATERIAL_FILE" - -// --------------------------------------------------------------------------- -/** @brief Ogre Importer detect the texture usage from its filename. - * - * Ogre material texture units do not define texture type, the textures usage - * depends on the used shader or Ogre's fixed pipeline. If this config property - * is true Assimp will try to detect the type from the textures filename postfix: - * _n, _nrm, _nrml, _normal, _normals and _normalmap for normal map, _s, _spec, - * _specular and _specularmap for specular map, _l, _light, _lightmap, _occ - * and _occlusion for light map, _disp and _displacement for displacement map. - * The matching is case insensitive. Post fix is taken between the last - * underscore and the last period. - * Default behavior is to detect type from lower cased texture unit name by - * matching against: normalmap, specularmap, lightmap and displacementmap. - * For both cases if no match is found aiTextureType_DIFFUSE is used. - *
- * Property type: Bool. Default value: false. - */ -#define AI_CONFIG_IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME \ - "IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME" - -/** @brief Specifies whether the IFC loader skips over IfcSpace elements. - * - * IfcSpace elements (and their geometric representations) are used to - * represent, well, free space in a building storey.
- * Property type: Bool. Default value: true. - */ -#define AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS "IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS" - - /** @brief Specifies whether the Android JNI asset extraction is supported. - * - * Turn on this option if you want to manage assets in native - * Android application without having to keep the internal directory and asset - * manager pointer. - */ - #define AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT "AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT" - - -// --------------------------------------------------------------------------- -/** @brief Specifies whether the IFC loader skips over - * shape representations of type 'Curve2D'. - * - * A lot of files contain both a faceted mesh representation and a outline - * with a presentation type of 'Curve2D'. Currently Assimp doesn't convert those, - * so turning this option off just clutters the log with errors.
- * Property type: Bool. Default value: true. - */ -#define AI_CONFIG_IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS "IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS" - -// --------------------------------------------------------------------------- -/** @brief Specifies whether the IFC loader will use its own, custom triangulation - * algorithm to triangulate wall and floor meshes. - * - * If this property is set to false, walls will be either triangulated by - * #aiProcess_Triangulate or will be passed through as huge polygons with - * faked holes (i.e. holes that are connected with the outer boundary using - * a dummy edge). It is highly recommended to set this property to true - * if you want triangulated data because #aiProcess_Triangulate is known to - * have problems with the kind of polygons that the IFC loader spits out for - * complicated meshes. - * Property type: Bool. Default value: true. - */ -#define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION" - -// --------------------------------------------------------------------------- -/** @brief Specifies whether the Collada loader will ignore the provided up direction. - * - * If this property is set to true, the up direction provided in the file header will - * be ignored and the file will be loaded as is. - * Property type: Bool. Default value: false. - */ -#define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION" - -// ---------- All the Export defines ------------ - -/** @brief Specifies the xfile use double for real values of float - * - * Property type: Bool. Default value: false. - */ - -#define AI_CONFIG_EXPORT_XFILE_64BIT "EXPORT_XFILE_64BIT" - -#endif // !! AI_CONFIG_H_INC diff --git a/thirdparty/include/assimp/defs.h b/thirdparty/include/assimp/defs.h deleted file mode 100644 index 4f670b2bd..000000000 --- a/thirdparty/include/assimp/defs.h +++ /dev/null @@ -1,273 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file defs.h - * @brief Assimp build configuration setup. See the notes in the comment - * blocks to find out how to customize _your_ Assimp build. - */ - -#ifndef INCLUDED_AI_DEFINES_H -#define INCLUDED_AI_DEFINES_H - - ////////////////////////////////////////////////////////////////////////// - /* Define ASSIMP_BUILD_NO_XX_IMPORTER to disable a specific - * file format loader. The loader is be excluded from the - * build in this case. 'XX' stands for the most common file - * extension of the file format. E.g.: - * ASSIMP_BUILD_NO_X_IMPORTER disables the X loader. - * - * If you're unsure about that, take a look at the implementation of the - * import plugin you wish to disable. You'll find the right define in the - * first lines of the corresponding unit. - * - * Other (mixed) configuration switches are listed here: - * ASSIMP_BUILD_NO_COMPRESSED_X - * - Disable support for compressed X files (zip) - * ASSIMP_BUILD_NO_COMPRESSED_BLEND - * - Disable support for compressed Blender files (zip) - * ASSIMP_BUILD_NO_COMPRESSED_IFC - * - Disable support for IFCZIP files (unzip) - */ - ////////////////////////////////////////////////////////////////////////// - -#ifndef ASSIMP_BUILD_NO_COMPRESSED_X -# define ASSIMP_BUILD_NEED_Z_INFLATE -#endif - -#ifndef ASSIMP_BUILD_NO_COMPRESSED_BLEND -# define ASSIMP_BUILD_NEED_Z_INFLATE -#endif - -#ifndef ASSIMP_BUILD_NO_COMPRESSED_IFC -# define ASSIMP_BUILD_NEED_Z_INFLATE -# define ASSIMP_BUILD_NEED_UNZIP -#endif - -#ifndef ASSIMP_BUILD_NO_Q3BSP_IMPORTER -# define ASSIMP_BUILD_NEED_Z_INFLATE -# define ASSIMP_BUILD_NEED_UNZIP -#endif - - ////////////////////////////////////////////////////////////////////////// - /* Define ASSIMP_BUILD_NO_XX_PROCESS to disable a specific - * post processing step. This is the current list of process names ('XX'): - * CALCTANGENTS - * JOINVERTICES - * TRIANGULATE - * GENFACENORMALS - * GENVERTEXNORMALS - * REMOVEVC - * SPLITLARGEMESHES - * PRETRANSFORMVERTICES - * LIMITBONEWEIGHTS - * VALIDATEDS - * IMPROVECACHELOCALITY - * FIXINFACINGNORMALS - * REMOVE_REDUNDANTMATERIALS - * OPTIMIZEGRAPH - * SORTBYPTYPE - * FINDINVALIDDATA - * TRANSFORMTEXCOORDS - * GENUVCOORDS - * ENTITYMESHBUILDER - * MAKELEFTHANDED - * FLIPUVS - * FLIPWINDINGORDER - * OPTIMIZEMESHES - * OPTIMIZEANIMS - * OPTIMIZEGRAPH - * GENENTITYMESHES - * FIXTEXTUREPATHS */ - ////////////////////////////////////////////////////////////////////////// - -#ifdef _MSC_VER -# undef ASSIMP_API - - ////////////////////////////////////////////////////////////////////////// - /* Define 'ASSIMP_BUILD_DLL_EXPORT' to build a DLL of the library */ - ////////////////////////////////////////////////////////////////////////// -# ifdef ASSIMP_BUILD_DLL_EXPORT - -# define ASSIMP_API __declspec(dllexport) -# define ASSIMP_API_WINONLY __declspec(dllexport) -# pragma warning (disable : 4251) - - ////////////////////////////////////////////////////////////////////////// - /* Define 'ASSIMP_DLL' before including Assimp to link to ASSIMP in - * an external DLL under Windows. Default is static linkage. */ - ////////////////////////////////////////////////////////////////////////// -# elif (defined ASSIMP_DLL) -# define ASSIMP_API __declspec(dllimport) -# define ASSIMP_API_WINONLY __declspec(dllimport) -# else -# define ASSIMP_API -# define ASSIMP_API_WINONLY -# endif - - /* Force the compiler to inline a function, if possible - */ -# define AI_FORCE_INLINE __forceinline - - /* Tells the compiler that a function never returns. Used in code analysis - * to skip dead paths (e.g. after an assertion evaluated to false). */ -# define AI_WONT_RETURN __declspec(noreturn) - -#elif defined(SWIG) - - /* Do nothing, the relevant defines are all in AssimpSwigPort.i */ - -#else - -# define AI_WONT_RETURN - -# define ASSIMP_API __attribute__ ((visibility("default"))) -# define ASSIMP_API_WINONLY -# define AI_FORCE_INLINE inline -#endif // (defined _MSC_VER) - -#ifdef __GNUC__ -# define AI_WONT_RETURN_SUFFIX __attribute__((noreturn)) -#else -# define AI_WONT_RETURN_SUFFIX -#endif // (defined __clang__) - -#ifdef __cplusplus - /* No explicit 'struct' and 'enum' tags for C++, this keeps showing up - * in doxydocs. - */ -# define C_STRUCT -# define C_ENUM -#else - ////////////////////////////////////////////////////////////////////////// - /* To build the documentation, make sure ASSIMP_DOXYGEN_BUILD - * is defined by Doxygen's preprocessor. The corresponding - * entries in the DOXYFILE are: */ - ////////////////////////////////////////////////////////////////////////// -#if 0 - ENABLE_PREPROCESSING = YES - MACRO_EXPANSION = YES - EXPAND_ONLY_PREDEF = YES - SEARCH_INCLUDES = YES - INCLUDE_PATH = - INCLUDE_FILE_PATTERNS = - PREDEFINED = ASSIMP_DOXYGEN_BUILD=1 - EXPAND_AS_DEFINED = C_STRUCT C_ENUM - SKIP_FUNCTION_MACROS = YES -#endif - ////////////////////////////////////////////////////////////////////////// - /* Doxygen gets confused if we use c-struct typedefs to avoid - * the explicit 'struct' notation. This trick here has the same - * effect as the TYPEDEF_HIDES_STRUCT option, but we don't need - * to typedef all structs/enums. */ - ////////////////////////////////////////////////////////////////////////// -# if (defined ASSIMP_DOXYGEN_BUILD) -# define C_STRUCT -# define C_ENUM -# else -# define C_STRUCT struct -# define C_ENUM enum -# endif -#endif - -#if (defined(__BORLANDC__) || defined (__BCPLUSPLUS__)) -#error Currently, Borland is unsupported. Feel free to port Assimp. - -// "W8059 Packgr��e der Struktur ge�ndert" - -#endif - - - ////////////////////////////////////////////////////////////////////////// - /* Define ASSIMP_BUILD_SINGLETHREADED to compile assimp - * without threading support. The library doesn't utilize - * threads then and is itself not threadsafe. */ - ////////////////////////////////////////////////////////////////////////// -#ifndef ASSIMP_BUILD_SINGLETHREADED -# define ASSIMP_BUILD_SINGLETHREADED -#endif - -#if defined(_DEBUG) || ! defined(NDEBUG) -# define ASSIMP_BUILD_DEBUG -#endif - - ////////////////////////////////////////////////////////////////////////// - /* Useful constants */ - ////////////////////////////////////////////////////////////////////////// - -/* This is PI. Hi PI. */ -#define AI_MATH_PI (3.141592653589793238462643383279 ) -#define AI_MATH_TWO_PI (AI_MATH_PI * 2.0) -#define AI_MATH_HALF_PI (AI_MATH_PI * 0.5) - -/* And this is to avoid endless casts to float */ -#define AI_MATH_PI_F (3.1415926538f) -#define AI_MATH_TWO_PI_F (AI_MATH_PI_F * 2.0f) -#define AI_MATH_HALF_PI_F (AI_MATH_PI_F * 0.5f) - -/* Tiny macro to convert from radians to degrees and back */ -#define AI_DEG_TO_RAD(x) ((x)*0.0174532925f) -#define AI_RAD_TO_DEG(x) ((x)*57.2957795f) - -/* Support for big-endian builds */ -#if defined(__BYTE_ORDER__) -# if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) -# if !defined(__BIG_ENDIAN__) -# define __BIG_ENDIAN__ -# endif -# else /* little endian */ -# if defined (__BIG_ENDIAN__) -# undef __BIG_ENDIAN__ -# endif -# endif -#endif -#if defined(__BIG_ENDIAN__) -# define AI_BUILD_BIG_ENDIAN -#endif - - -/* To avoid running out of memory - * This can be adjusted for specific use cases - * It's NOT a total limit, just a limit for individual allocations - */ -#define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type)) - - -#endif // !! INCLUDED_AI_DEFINES_H diff --git a/thirdparty/include/assimp/importerdesc.h b/thirdparty/include/assimp/importerdesc.h deleted file mode 100644 index b2b123aca..000000000 --- a/thirdparty/include/assimp/importerdesc.h +++ /dev/null @@ -1,143 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file importerdesc.h - * @brief #aiImporterFlags, aiImporterDesc implementation. - */ -#ifndef INCLUDED_AI_IMPORTER_DESC_H -#define INCLUDED_AI_IMPORTER_DESC_H - - -/** Mixed set of flags for #aiImporterDesc, indicating some features - * common to many importers*/ -enum aiImporterFlags -{ - /** Indicates that there is a textual encoding of the - * file format; and that it is supported.*/ - aiImporterFlags_SupportTextFlavour = 0x1, - - /** Indicates that there is a binary encoding of the - * file format; and that it is supported.*/ - aiImporterFlags_SupportBinaryFlavour = 0x2, - - /** Indicates that there is a compressed encoding of the - * file format; and that it is supported.*/ - aiImporterFlags_SupportCompressedFlavour = 0x4, - - /** Indicates that the importer reads only a very particular - * subset of the file format. This happens commonly for - * declarative or procedural formats which cannot easily - * be mapped to #aiScene */ - aiImporterFlags_LimitedSupport = 0x8, - - /** Indicates that the importer is highly experimental and - * should be used with care. This only happens for trunk - * (i.e. SVN) versions, experimental code is not included - * in releases. */ - aiImporterFlags_Experimental = 0x10 -}; - - -/** Meta information about a particular importer. Importers need to fill - * this structure, but they can freely decide how talkative they are. - * A common use case for loader meta info is a user interface - * in which the user can choose between various import/export file - * formats. Building such an UI by hand means a lot of maintenance - * as importers/exporters are added to Assimp, so it might be useful - * to have a common mechanism to query some rough importer - * characteristics. */ -struct aiImporterDesc -{ - /** Full name of the importer (i.e. Blender3D importer)*/ - const char* mName; - - /** Original author (left blank if unknown or whole assimp team) */ - const char* mAuthor; - - /** Current maintainer, left blank if the author maintains */ - const char* mMaintainer; - - /** Implementation comments, i.e. unimplemented features*/ - const char* mComments; - - /** These flags indicate some characteristics common to many - importers. */ - unsigned int mFlags; - - /** Minimum format version that can be loaded im major.minor format, - both are set to 0 if there is either no version scheme - or if the loader doesn't care. */ - unsigned int mMinMajor; - unsigned int mMinMinor; - - /** Maximum format version that can be loaded im major.minor format, - both are set to 0 if there is either no version scheme - or if the loader doesn't care. Loaders that expect to be - forward-compatible to potential future format versions should - indicate zero, otherwise they should specify the current - maximum version.*/ - unsigned int mMaxMajor; - unsigned int mMaxMinor; - - /** List of file extensions this importer can handle. - List entries are separated by space characters. - All entries are lower case without a leading dot (i.e. - "xml dae" would be a valid value. Note that multiple - importers may respond to the same file extension - - assimp calls all importers in the order in which they - are registered and each importer gets the opportunity - to load the file until one importer "claims" the file. Apart - from file extension checks, importers typically use - other methods to quickly reject files (i.e. magic - words) so this does not mean that common or generic - file extensions such as XML would be tediously slow. */ - const char* mFileExtensions; -}; - -/** \brief Returns the Importer description for a given extension. - -Will return a NULL-pointer if no assigned importer desc. was found for the given extension - \param extension [in] The extension to look for - \return A pointer showing to the ImporterDesc, \see aiImporterDesc. -*/ -ASSIMP_API const C_STRUCT aiImporterDesc* aiGetImporterDesc( const char *extension ); - -#endif diff --git a/thirdparty/include/assimp/light.h b/thirdparty/include/assimp/light.h deleted file mode 100644 index 939d5b6cd..000000000 --- a/thirdparty/include/assimp/light.h +++ /dev/null @@ -1,256 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file light.h - * @brief Defines the aiLight data structure - */ - -#ifndef __AI_LIGHT_H_INC__ -#define __AI_LIGHT_H_INC__ - -#include "types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// --------------------------------------------------------------------------- -/** Enumerates all supported types of light sources. - */ -enum aiLightSourceType -{ - aiLightSource_UNDEFINED = 0x0, - - //! A directional light source has a well-defined direction - //! but is infinitely far away. That's quite a good - //! approximation for sun light. - aiLightSource_DIRECTIONAL = 0x1, - - //! A point light source has a well-defined position - //! in space but no direction - it emits light in all - //! directions. A normal bulb is a point light. - aiLightSource_POINT = 0x2, - - //! A spot light source emits light in a specific - //! angle. It has a position and a direction it is pointing to. - //! A good example for a spot light is a light spot in - //! sport arenas. - aiLightSource_SPOT = 0x3, - - //! The generic light level of the world, including the bounces - //! of all other light sources. - //! Typically, there's at most one ambient light in a scene. - //! This light type doesn't have a valid position, direction, or - //! other properties, just a color. - aiLightSource_AMBIENT = 0x4, - - //! An area light is a rectangle with predefined size that uniformly - //! emits light from one of its sides. The position is center of the - //! rectangle and direction is its normal vector. - aiLightSource_AREA = 0x5, - - /** This value is not used. It is just there to force the - * compiler to map this enum to a 32 Bit integer. - */ -#ifndef SWIG - _aiLightSource_Force32Bit = INT_MAX -#endif -}; - -// --------------------------------------------------------------------------- -/** Helper structure to describe a light source. - * - * Assimp supports multiple sorts of light sources, including - * directional, point and spot lights. All of them are defined with just - * a single structure and distinguished by their parameters. - * Note - some file formats (such as 3DS, ASE) export a "target point" - - * the point a spot light is looking at (it can even be animated). Assimp - * writes the target point as a subnode of a spotlights's main node, - * called ".Target". However, this is just additional information - * then, the transformation tracks of the main node make the - * spot light already point in the right direction. -*/ -struct aiLight -{ - /** The name of the light source. - * - * There must be a node in the scenegraph with the same name. - * This node specifies the position of the light in the scene - * hierarchy and can be animated. - */ - C_STRUCT aiString mName; - - /** The type of the light source. - * - * aiLightSource_UNDEFINED is not a valid value for this member. - */ - C_ENUM aiLightSourceType mType; - - /** Position of the light source in space. Relative to the - * transformation of the node corresponding to the light. - * - * The position is undefined for directional lights. - */ - C_STRUCT aiVector3D mPosition; - - /** Direction of the light source in space. Relative to the - * transformation of the node corresponding to the light. - * - * The direction is undefined for point lights. The vector - * may be normalized, but it needn't. - */ - C_STRUCT aiVector3D mDirection; - - /** Up direction of the light source in space. Relative to the - * transformation of the node corresponding to the light. - * - * The direction is undefined for point lights. The vector - * may be normalized, but it needn't. - */ - C_STRUCT aiVector3D mUp; - - /** Constant light attenuation factor. - * - * The intensity of the light source at a given distance 'd' from - * the light's position is - * @code - * Atten = 1/( att0 + att1 * d + att2 * d*d) - * @endcode - * This member corresponds to the att0 variable in the equation. - * Naturally undefined for directional lights. - */ - float mAttenuationConstant; - - /** Linear light attenuation factor. - * - * The intensity of the light source at a given distance 'd' from - * the light's position is - * @code - * Atten = 1/( att0 + att1 * d + att2 * d*d) - * @endcode - * This member corresponds to the att1 variable in the equation. - * Naturally undefined for directional lights. - */ - float mAttenuationLinear; - - /** Quadratic light attenuation factor. - * - * The intensity of the light source at a given distance 'd' from - * the light's position is - * @code - * Atten = 1/( att0 + att1 * d + att2 * d*d) - * @endcode - * This member corresponds to the att2 variable in the equation. - * Naturally undefined for directional lights. - */ - float mAttenuationQuadratic; - - /** Diffuse color of the light source - * - * The diffuse light color is multiplied with the diffuse - * material color to obtain the final color that contributes - * to the diffuse shading term. - */ - C_STRUCT aiColor3D mColorDiffuse; - - /** Specular color of the light source - * - * The specular light color is multiplied with the specular - * material color to obtain the final color that contributes - * to the specular shading term. - */ - C_STRUCT aiColor3D mColorSpecular; - - /** Ambient color of the light source - * - * The ambient light color is multiplied with the ambient - * material color to obtain the final color that contributes - * to the ambient shading term. Most renderers will ignore - * this value it, is just a remaining of the fixed-function pipeline - * that is still supported by quite many file formats. - */ - C_STRUCT aiColor3D mColorAmbient; - - /** Inner angle of a spot light's light cone. - * - * The spot light has maximum influence on objects inside this - * angle. The angle is given in radians. It is 2PI for point - * lights and undefined for directional lights. - */ - float mAngleInnerCone; - - /** Outer angle of a spot light's light cone. - * - * The spot light does not affect objects outside this angle. - * The angle is given in radians. It is 2PI for point lights and - * undefined for directional lights. The outer angle must be - * greater than or equal to the inner angle. - * It is assumed that the application uses a smooth - * interpolation between the inner and the outer cone of the - * spot light. - */ - float mAngleOuterCone; - - /** Size of area light source. */ - C_STRUCT aiVector2D mSize; - -#ifdef __cplusplus - - aiLight() - : mType (aiLightSource_UNDEFINED) - , mAttenuationConstant (0.f) - , mAttenuationLinear (1.f) - , mAttenuationQuadratic (0.f) - , mAngleInnerCone ((float)AI_MATH_TWO_PI) - , mAngleOuterCone ((float)AI_MATH_TWO_PI) - , mSize (0.f, 0.f) - { - } - -#endif -}; - -#ifdef __cplusplus -} -#endif - - -#endif // !! __AI_LIGHT_H_INC__ diff --git a/thirdparty/include/assimp/material.h b/thirdparty/include/assimp/material.h deleted file mode 100644 index 87d27c569..000000000 --- a/thirdparty/include/assimp/material.h +++ /dev/null @@ -1,1542 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file material.h - * @brief Defines the material system of the library - */ - -#ifndef AI_MATERIAL_H_INC -#define AI_MATERIAL_H_INC - -#include "types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Name for default materials (2nd is used if meshes have UV coords) -#define AI_DEFAULT_MATERIAL_NAME "DefaultMaterial" - -// --------------------------------------------------------------------------- -/** @brief Defines how the Nth texture of a specific type is combined with - * the result of all previous layers. - * - * Example (left: key, right: value):
- * @code - * DiffColor0 - gray - * DiffTextureOp0 - aiTextureOpMultiply - * DiffTexture0 - tex1.png - * DiffTextureOp0 - aiTextureOpAdd - * DiffTexture1 - tex2.png - * @endcode - * Written as equation, the final diffuse term for a specific pixel would be: - * @code - * diffFinal = DiffColor0 * sampleTex(DiffTexture0,UV0) + - * sampleTex(DiffTexture1,UV0) * diffContrib; - * @endcode - * where 'diffContrib' is the intensity of the incoming light for that pixel. - */ -enum aiTextureOp -{ - /** T = T1 * T2 */ - aiTextureOp_Multiply = 0x0, - - /** T = T1 + T2 */ - aiTextureOp_Add = 0x1, - - /** T = T1 - T2 */ - aiTextureOp_Subtract = 0x2, - - /** T = T1 / T2 */ - aiTextureOp_Divide = 0x3, - - /** T = (T1 + T2) - (T1 * T2) */ - aiTextureOp_SmoothAdd = 0x4, - - /** T = T1 + (T2-0.5) */ - aiTextureOp_SignedAdd = 0x5, - - -#ifndef SWIG - _aiTextureOp_Force32Bit = INT_MAX -#endif -}; - -// --------------------------------------------------------------------------- -/** @brief Defines how UV coordinates outside the [0...1] range are handled. - * - * Commonly referred to as 'wrapping mode'. - */ -enum aiTextureMapMode -{ - /** A texture coordinate u|v is translated to u%1|v%1 - */ - aiTextureMapMode_Wrap = 0x0, - - /** Texture coordinates outside [0...1] - * are clamped to the nearest valid value. - */ - aiTextureMapMode_Clamp = 0x1, - - /** If the texture coordinates for a pixel are outside [0...1] - * the texture is not applied to that pixel - */ - aiTextureMapMode_Decal = 0x3, - - /** A texture coordinate u|v becomes u%1|v%1 if (u-(u%1))%2 is zero and - * 1-(u%1)|1-(v%1) otherwise - */ - aiTextureMapMode_Mirror = 0x2, - -#ifndef SWIG - _aiTextureMapMode_Force32Bit = INT_MAX -#endif -}; - -// --------------------------------------------------------------------------- -/** @brief Defines how the mapping coords for a texture are generated. - * - * Real-time applications typically require full UV coordinates, so the use of - * the aiProcess_GenUVCoords step is highly recommended. It generates proper - * UV channels for non-UV mapped objects, as long as an accurate description - * how the mapping should look like (e.g spherical) is given. - * See the #AI_MATKEY_MAPPING property for more details. - */ -enum aiTextureMapping -{ - /** The mapping coordinates are taken from an UV channel. - * - * The #AI_MATKEY_UVWSRC key specifies from which UV channel - * the texture coordinates are to be taken from (remember, - * meshes can have more than one UV channel). - */ - aiTextureMapping_UV = 0x0, - - /** Spherical mapping */ - aiTextureMapping_SPHERE = 0x1, - - /** Cylindrical mapping */ - aiTextureMapping_CYLINDER = 0x2, - - /** Cubic mapping */ - aiTextureMapping_BOX = 0x3, - - /** Planar mapping */ - aiTextureMapping_PLANE = 0x4, - - /** Undefined mapping. Have fun. */ - aiTextureMapping_OTHER = 0x5, - - -#ifndef SWIG - _aiTextureMapping_Force32Bit = INT_MAX -#endif -}; - -// --------------------------------------------------------------------------- -/** @brief Defines the purpose of a texture - * - * This is a very difficult topic. Different 3D packages support different - * kinds of textures. For very common texture types, such as bumpmaps, the - * rendering results depend on implementation details in the rendering - * pipelines of these applications. Assimp loads all texture references from - * the model file and tries to determine which of the predefined texture - * types below is the best choice to match the original use of the texture - * as closely as possible.
- * - * In content pipelines you'll usually define how textures have to be handled, - * and the artists working on models have to conform to this specification, - * regardless which 3D tool they're using. - */ -enum aiTextureType -{ - /** Dummy value. - * - * No texture, but the value to be used as 'texture semantic' - * (#aiMaterialProperty::mSemantic) for all material properties - * *not* related to textures. - */ - aiTextureType_NONE = 0x0, - - - - /** The texture is combined with the result of the diffuse - * lighting equation. - */ - aiTextureType_DIFFUSE = 0x1, - - /** The texture is combined with the result of the specular - * lighting equation. - */ - aiTextureType_SPECULAR = 0x2, - - /** The texture is combined with the result of the ambient - * lighting equation. - */ - aiTextureType_AMBIENT = 0x3, - - /** The texture is added to the result of the lighting - * calculation. It isn't influenced by incoming light. - */ - aiTextureType_EMISSIVE = 0x4, - - /** The texture is a height map. - * - * By convention, higher gray-scale values stand for - * higher elevations from the base height. - */ - aiTextureType_HEIGHT = 0x5, - - /** The texture is a (tangent space) normal-map. - * - * Again, there are several conventions for tangent-space - * normal maps. Assimp does (intentionally) not - * distinguish here. - */ - aiTextureType_NORMALS = 0x6, - - /** The texture defines the glossiness of the material. - * - * The glossiness is in fact the exponent of the specular - * (phong) lighting equation. Usually there is a conversion - * function defined to map the linear color values in the - * texture to a suitable exponent. Have fun. - */ - aiTextureType_SHININESS = 0x7, - - /** The texture defines per-pixel opacity. - * - * Usually 'white' means opaque and 'black' means - * 'transparency'. Or quite the opposite. Have fun. - */ - aiTextureType_OPACITY = 0x8, - - /** Displacement texture - * - * The exact purpose and format is application-dependent. - * Higher color values stand for higher vertex displacements. - */ - aiTextureType_DISPLACEMENT = 0x9, - - /** Lightmap texture (aka Ambient Occlusion) - * - * Both 'Lightmaps' and dedicated 'ambient occlusion maps' are - * covered by this material property. The texture contains a - * scaling value for the final color value of a pixel. Its - * intensity is not affected by incoming light. - */ - aiTextureType_LIGHTMAP = 0xA, - - /** Reflection texture - * - * Contains the color of a perfect mirror reflection. - * Rarely used, almost never for real-time applications. - */ - aiTextureType_REFLECTION = 0xB, - - /** Unknown texture - * - * A texture reference that does not match any of the definitions - * above is considered to be 'unknown'. It is still imported, - * but is excluded from any further postprocessing. - */ - aiTextureType_UNKNOWN = 0xC, - - -#ifndef SWIG - _aiTextureType_Force32Bit = INT_MAX -#endif -}; - -#define AI_TEXTURE_TYPE_MAX aiTextureType_UNKNOWN - -// --------------------------------------------------------------------------- -/** @brief Defines all shading models supported by the library - * - * The list of shading modes has been taken from Blender. - * See Blender documentation for more information. The API does - * not distinguish between "specular" and "diffuse" shaders (thus the - * specular term for diffuse shading models like Oren-Nayar remains - * undefined).
- * Again, this value is just a hint. Assimp tries to select the shader whose - * most common implementation matches the original rendering results of the - * 3D modeller which wrote a particular model as closely as possible. - */ -enum aiShadingMode -{ - /** Flat shading. Shading is done on per-face base, - * diffuse only. Also known as 'faceted shading'. - */ - aiShadingMode_Flat = 0x1, - - /** Simple Gouraud shading. - */ - aiShadingMode_Gouraud = 0x2, - - /** Phong-Shading - - */ - aiShadingMode_Phong = 0x3, - - /** Phong-Blinn-Shading - */ - aiShadingMode_Blinn = 0x4, - - /** Toon-Shading per pixel - * - * Also known as 'comic' shader. - */ - aiShadingMode_Toon = 0x5, - - /** OrenNayar-Shading per pixel - * - * Extension to standard Lambertian shading, taking the - * roughness of the material into account - */ - aiShadingMode_OrenNayar = 0x6, - - /** Minnaert-Shading per pixel - * - * Extension to standard Lambertian shading, taking the - * "darkness" of the material into account - */ - aiShadingMode_Minnaert = 0x7, - - /** CookTorrance-Shading per pixel - * - * Special shader for metallic surfaces. - */ - aiShadingMode_CookTorrance = 0x8, - - /** No shading at all. Constant light influence of 1.0. - */ - aiShadingMode_NoShading = 0x9, - - /** Fresnel shading - */ - aiShadingMode_Fresnel = 0xa, - - -#ifndef SWIG - _aiShadingMode_Force32Bit = INT_MAX -#endif -}; - - -// --------------------------------------------------------------------------- -/** @brief Defines some mixed flags for a particular texture. - * - * Usually you'll instruct your cg artists how textures have to look like ... - * and how they will be processed in your application. However, if you use - * Assimp for completely generic loading purposes you might also need to - * process these flags in order to display as many 'unknown' 3D models as - * possible correctly. - * - * This corresponds to the #AI_MATKEY_TEXFLAGS property. -*/ -enum aiTextureFlags -{ - /** The texture's color values have to be inverted (componentwise 1-n) - */ - aiTextureFlags_Invert = 0x1, - - /** Explicit request to the application to process the alpha channel - * of the texture. - * - * Mutually exclusive with #aiTextureFlags_IgnoreAlpha. These - * flags are set if the library can say for sure that the alpha - * channel is used/is not used. If the model format does not - * define this, it is left to the application to decide whether - * the texture alpha channel - if any - is evaluated or not. - */ - aiTextureFlags_UseAlpha = 0x2, - - /** Explicit request to the application to ignore the alpha channel - * of the texture. - * - * Mutually exclusive with #aiTextureFlags_UseAlpha. - */ - aiTextureFlags_IgnoreAlpha = 0x4, - -#ifndef SWIG - _aiTextureFlags_Force32Bit = INT_MAX -#endif -}; - - -// --------------------------------------------------------------------------- -/** @brief Defines alpha-blend flags. - * - * If you're familiar with OpenGL or D3D, these flags aren't new to you. - * They define *how* the final color value of a pixel is computed, basing - * on the previous color at that pixel and the new color value from the - * material. - * The blend formula is: - * @code - * SourceColor * SourceBlend + DestColor * DestBlend - * @endcode - * where DestColor is the previous color in the framebuffer at this - * position and SourceColor is the material colro before the transparency - * calculation.
- * This corresponds to the #AI_MATKEY_BLEND_FUNC property. -*/ -enum aiBlendMode -{ - /** - * Formula: - * @code - * SourceColor*SourceAlpha + DestColor*(1-SourceAlpha) - * @endcode - */ - aiBlendMode_Default = 0x0, - - /** Additive blending - * - * Formula: - * @code - * SourceColor*1 + DestColor*1 - * @endcode - */ - aiBlendMode_Additive = 0x1, - - // we don't need more for the moment, but we might need them - // in future versions ... - -#ifndef SWIG - _aiBlendMode_Force32Bit = INT_MAX -#endif -}; - - -#include "./Compiler/pushpack1.h" - -// --------------------------------------------------------------------------- -/** @brief Defines how an UV channel is transformed. - * - * This is just a helper structure for the #AI_MATKEY_UVTRANSFORM key. - * See its documentation for more details. - * - * Typically you'll want to build a matrix of this information. However, - * we keep separate scaling/translation/rotation values to make it - * easier to process and optimize UV transformations internally. - */ -struct aiUVTransform -{ - /** Translation on the u and v axes. - * - * The default value is (0|0). - */ - C_STRUCT aiVector2D mTranslation; - - /** Scaling on the u and v axes. - * - * The default value is (1|1). - */ - C_STRUCT aiVector2D mScaling; - - /** Rotation - in counter-clockwise direction. - * - * The rotation angle is specified in radians. The - * rotation center is 0.5f|0.5f. The default value - * 0.f. - */ - float mRotation; - - -#ifdef __cplusplus - aiUVTransform() - : mScaling (1.f,1.f) - , mRotation (0.f) - { - // nothing to be done here ... - } -#endif - -} PACK_STRUCT; - -#include "./Compiler/poppack1.h" - -//! @cond AI_DOX_INCLUDE_INTERNAL -// --------------------------------------------------------------------------- -/** @brief A very primitive RTTI system for the contents of material - * properties. - */ -enum aiPropertyTypeInfo -{ - /** Array of single-precision (32 Bit) floats - * - * It is possible to use aiGetMaterialInteger[Array]() (or the C++-API - * aiMaterial::Get()) to query properties stored in floating-point format. - * The material system performs the type conversion automatically. - */ - aiPTI_Float = 0x1, - - /** The material property is an aiString. - * - * Arrays of strings aren't possible, aiGetMaterialString() (or the - * C++-API aiMaterial::Get()) *must* be used to query a string property. - */ - aiPTI_String = 0x3, - - /** Array of (32 Bit) integers - * - * It is possible to use aiGetMaterialFloat[Array]() (or the C++-API - * aiMaterial::Get()) to query properties stored in integer format. - * The material system performs the type conversion automatically. - */ - aiPTI_Integer = 0x4, - - - /** Simple binary buffer, content undefined. Not convertible to anything. - */ - aiPTI_Buffer = 0x5, - - - /** This value is not used. It is just there to force the - * compiler to map this enum to a 32 Bit integer. - */ -#ifndef SWIG - _aiPTI_Force32Bit = INT_MAX -#endif -}; - -// --------------------------------------------------------------------------- -/** @brief Data structure for a single material property - * - * As an user, you'll probably never need to deal with this data structure. - * Just use the provided aiGetMaterialXXX() or aiMaterial::Get() family - * of functions to query material properties easily. Processing them - * manually is faster, but it is not the recommended way. It isn't worth - * the effort.
- * Material property names follow a simple scheme: - * @code - * $ - * ? - * A public property, there must be corresponding AI_MATKEY_XXX define - * 2nd: Public, but ignored by the #aiProcess_RemoveRedundantMaterials - * post-processing step. - * ~ - * A temporary property for internal use. - * @endcode - * @see aiMaterial - */ -struct aiMaterialProperty -{ - /** Specifies the name of the property (key) - * Keys are generally case insensitive. - */ - C_STRUCT aiString mKey; - - /** Textures: Specifies their exact usage semantic. - * For non-texture properties, this member is always 0 - * (or, better-said, #aiTextureType_NONE). - */ - unsigned int mSemantic; - - /** Textures: Specifies the index of the texture. - * For non-texture properties, this member is always 0. - */ - unsigned int mIndex; - - /** Size of the buffer mData is pointing to, in bytes. - * This value may not be 0. - */ - unsigned int mDataLength; - - /** Type information for the property. - * - * Defines the data layout inside the data buffer. This is used - * by the library internally to perform debug checks and to - * utilize proper type conversions. - * (It's probably a hacky solution, but it works.) - */ - C_ENUM aiPropertyTypeInfo mType; - - /** Binary buffer to hold the property's value. - * The size of the buffer is always mDataLength. - */ - char* mData; - -#ifdef __cplusplus - - aiMaterialProperty() - : mSemantic( 0 ) - , mIndex( 0 ) - , mDataLength( 0 ) - , mType( aiPTI_Float ) - , mData( NULL ) - { - } - - ~aiMaterialProperty() { - delete[] mData; - } - -#endif -}; -//! @endcond - -#ifdef __cplusplus -} // We need to leave the "C" block here to allow template member functions -#endif - -// --------------------------------------------------------------------------- -/** @brief Data structure for a material -* -* Material data is stored using a key-value structure. A single key-value -* pair is called a 'material property'. C++ users should use the provided -* member functions of aiMaterial to process material properties, C users -* have to stick with the aiMaterialGetXXX family of unbound functions. -* The library defines a set of standard keys (AI_MATKEY_XXX). -*/ -#ifdef __cplusplus -struct ASSIMP_API aiMaterial -#else -struct aiMaterial -#endif -{ - -#ifdef __cplusplus - -public: - - aiMaterial(); - ~aiMaterial(); - - // ------------------------------------------------------------------- - /** @brief Retrieve an array of Type values with a specific key - * from the material - * - * @param pKey Key to search for. One of the AI_MATKEY_XXX constants. - * @param type .. set by AI_MATKEY_XXX - * @param idx .. set by AI_MATKEY_XXX - * @param pOut Pointer to a buffer to receive the result. - * @param pMax Specifies the size of the given buffer, in Type's. - * Receives the number of values (not bytes!) read. - * NULL is a valid value for this parameter. - */ - template - aiReturn Get(const char* pKey,unsigned int type, - unsigned int idx, Type* pOut, unsigned int* pMax) const; - - aiReturn Get(const char* pKey,unsigned int type, - unsigned int idx, int* pOut, unsigned int* pMax) const; - - aiReturn Get(const char* pKey,unsigned int type, - unsigned int idx, float* pOut, unsigned int* pMax) const; - - // ------------------------------------------------------------------- - /** @brief Retrieve a Type value with a specific key - * from the material - * - * @param pKey Key to search for. One of the AI_MATKEY_XXX constants. - * @param type Specifies the type of the texture to be retrieved ( - * e.g. diffuse, specular, height map ...) - * @param idx Index of the texture to be retrieved. - * @param pOut Reference to receive the output value - */ - template - aiReturn Get(const char* pKey,unsigned int type, - unsigned int idx,Type& pOut) const; - - - aiReturn Get(const char* pKey,unsigned int type, - unsigned int idx, int& pOut) const; - - aiReturn Get(const char* pKey,unsigned int type, - unsigned int idx, float& pOut) const; - - aiReturn Get(const char* pKey,unsigned int type, - unsigned int idx, aiString& pOut) const; - - aiReturn Get(const char* pKey,unsigned int type, - unsigned int idx, aiColor3D& pOut) const; - - aiReturn Get(const char* pKey,unsigned int type, - unsigned int idx, aiColor4D& pOut) const; - - aiReturn Get(const char* pKey,unsigned int type, - unsigned int idx, aiUVTransform& pOut) const; - - // ------------------------------------------------------------------- - /** Get the number of textures for a particular texture type. - * @param type Texture type to check for - * @return Number of textures for this type. - * @note A texture can be easily queried using #GetTexture() */ - unsigned int GetTextureCount(aiTextureType type) const; - - // ------------------------------------------------------------------- - /** Helper function to get all parameters pertaining to a - * particular texture slot from a material. - * - * This function is provided just for convenience, you could also - * read the single material properties manually. - * @param type Specifies the type of the texture to be retrieved ( - * e.g. diffuse, specular, height map ...) - * @param index Index of the texture to be retrieved. The function fails - * if there is no texture of that type with this index. - * #GetTextureCount() can be used to determine the number of textures - * per texture type. - * @param path Receives the path to the texture. - * NULL is a valid value. - * @param mapping The texture mapping. - * NULL is allowed as value. - * @param uvindex Receives the UV index of the texture. - * NULL is a valid value. - * @param blend Receives the blend factor for the texture - * NULL is a valid value. - * @param op Receives the texture operation to be performed between - * this texture and the previous texture. NULL is allowed as value. - * @param mapmode Receives the mapping modes to be used for the texture. - * The parameter may be NULL but if it is a valid pointer it MUST - * point to an array of 3 aiTextureMapMode's (one for each - * axis: UVW order (=XYZ)). - */ - // ------------------------------------------------------------------- - aiReturn GetTexture(aiTextureType type, - unsigned int index, - C_STRUCT aiString* path, - aiTextureMapping* mapping = NULL, - unsigned int* uvindex = NULL, - float* blend = NULL, - aiTextureOp* op = NULL, - aiTextureMapMode* mapmode = NULL) const; - - - // Setters - - - // ------------------------------------------------------------------------------ - /** @brief Add a property with a given key and type info to the material - * structure - * - * @param pInput Pointer to input data - * @param pSizeInBytes Size of input data - * @param pKey Key/Usage of the property (AI_MATKEY_XXX) - * @param type Set by the AI_MATKEY_XXX macro - * @param index Set by the AI_MATKEY_XXX macro - * @param pType Type information hint */ - aiReturn AddBinaryProperty (const void* pInput, - unsigned int pSizeInBytes, - const char* pKey, - unsigned int type , - unsigned int index , - aiPropertyTypeInfo pType); - - // ------------------------------------------------------------------------------ - /** @brief Add a string property with a given key and type info to the - * material structure - * - * @param pInput Input string - * @param pKey Key/Usage of the property (AI_MATKEY_XXX) - * @param type Set by the AI_MATKEY_XXX macro - * @param index Set by the AI_MATKEY_XXX macro */ - aiReturn AddProperty (const aiString* pInput, - const char* pKey, - unsigned int type = 0, - unsigned int index = 0); - - // ------------------------------------------------------------------------------ - /** @brief Add a property with a given key to the material structure - * @param pInput Pointer to the input data - * @param pNumValues Number of values in the array - * @param pKey Key/Usage of the property (AI_MATKEY_XXX) - * @param type Set by the AI_MATKEY_XXX macro - * @param index Set by the AI_MATKEY_XXX macro */ - template - aiReturn AddProperty (const TYPE* pInput, - unsigned int pNumValues, - const char* pKey, - unsigned int type = 0, - unsigned int index = 0); - - aiReturn AddProperty (const aiVector3D* pInput, - unsigned int pNumValues, - const char* pKey, - unsigned int type = 0, - unsigned int index = 0); - - aiReturn AddProperty (const aiColor3D* pInput, - unsigned int pNumValues, - const char* pKey, - unsigned int type = 0, - unsigned int index = 0); - - aiReturn AddProperty (const aiColor4D* pInput, - unsigned int pNumValues, - const char* pKey, - unsigned int type = 0, - unsigned int index = 0); - - aiReturn AddProperty (const int* pInput, - unsigned int pNumValues, - const char* pKey, - unsigned int type = 0, - unsigned int index = 0); - - aiReturn AddProperty (const float* pInput, - unsigned int pNumValues, - const char* pKey, - unsigned int type = 0, - unsigned int index = 0); - - aiReturn AddProperty (const aiUVTransform* pInput, - unsigned int pNumValues, - const char* pKey, - unsigned int type = 0, - unsigned int index = 0); - - // ------------------------------------------------------------------------------ - /** @brief Remove a given key from the list. - * - * The function fails if the key isn't found - * @param pKey Key to be deleted - * @param type Set by the AI_MATKEY_XXX macro - * @param index Set by the AI_MATKEY_XXX macro */ - aiReturn RemoveProperty (const char* pKey, - unsigned int type = 0, - unsigned int index = 0); - - // ------------------------------------------------------------------------------ - /** @brief Removes all properties from the material. - * - * The data array remains allocated so adding new properties is quite fast. */ - void Clear(); - - // ------------------------------------------------------------------------------ - /** Copy the property list of a material - * @param pcDest Destination material - * @param pcSrc Source material - */ - static void CopyPropertyList(aiMaterial* pcDest, - const aiMaterial* pcSrc); - - -#endif - - /** List of all material properties loaded. */ - C_STRUCT aiMaterialProperty** mProperties; - - /** Number of properties in the data base */ - unsigned int mNumProperties; - - /** Storage allocated */ - unsigned int mNumAllocated; -}; - -// Go back to extern "C" again -#ifdef __cplusplus -extern "C" { -#endif - -// --------------------------------------------------------------------------- -#define AI_MATKEY_NAME "?mat.name",0,0 -#define AI_MATKEY_TWOSIDED "$mat.twosided",0,0 -#define AI_MATKEY_SHADING_MODEL "$mat.shadingm",0,0 -#define AI_MATKEY_ENABLE_WIREFRAME "$mat.wireframe",0,0 -#define AI_MATKEY_BLEND_FUNC "$mat.blend",0,0 -#define AI_MATKEY_OPACITY "$mat.opacity",0,0 -#define AI_MATKEY_BUMPSCALING "$mat.bumpscaling",0,0 -#define AI_MATKEY_SHININESS "$mat.shininess",0,0 -#define AI_MATKEY_REFLECTIVITY "$mat.reflectivity",0,0 -#define AI_MATKEY_SHININESS_STRENGTH "$mat.shinpercent",0,0 -#define AI_MATKEY_REFRACTI "$mat.refracti",0,0 -#define AI_MATKEY_COLOR_DIFFUSE "$clr.diffuse",0,0 -#define AI_MATKEY_COLOR_AMBIENT "$clr.ambient",0,0 -#define AI_MATKEY_COLOR_SPECULAR "$clr.specular",0,0 -#define AI_MATKEY_COLOR_EMISSIVE "$clr.emissive",0,0 -#define AI_MATKEY_COLOR_TRANSPARENT "$clr.transparent",0,0 -#define AI_MATKEY_COLOR_REFLECTIVE "$clr.reflective",0,0 -#define AI_MATKEY_GLOBAL_BACKGROUND_IMAGE "?bg.global",0,0 - -// --------------------------------------------------------------------------- -// Pure key names for all texture-related properties -//! @cond MATS_DOC_FULL -#define _AI_MATKEY_TEXTURE_BASE "$tex.file" -#define _AI_MATKEY_UVWSRC_BASE "$tex.uvwsrc" -#define _AI_MATKEY_TEXOP_BASE "$tex.op" -#define _AI_MATKEY_MAPPING_BASE "$tex.mapping" -#define _AI_MATKEY_TEXBLEND_BASE "$tex.blend" -#define _AI_MATKEY_MAPPINGMODE_U_BASE "$tex.mapmodeu" -#define _AI_MATKEY_MAPPINGMODE_V_BASE "$tex.mapmodev" -#define _AI_MATKEY_TEXMAP_AXIS_BASE "$tex.mapaxis" -#define _AI_MATKEY_UVTRANSFORM_BASE "$tex.uvtrafo" -#define _AI_MATKEY_TEXFLAGS_BASE "$tex.flags" -//! @endcond - -// --------------------------------------------------------------------------- -#define AI_MATKEY_TEXTURE(type, N) _AI_MATKEY_TEXTURE_BASE,type,N - -// For backward compatibility and simplicity -//! @cond MATS_DOC_FULL -#define AI_MATKEY_TEXTURE_DIFFUSE(N) \ - AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE,N) - -#define AI_MATKEY_TEXTURE_SPECULAR(N) \ - AI_MATKEY_TEXTURE(aiTextureType_SPECULAR,N) - -#define AI_MATKEY_TEXTURE_AMBIENT(N) \ - AI_MATKEY_TEXTURE(aiTextureType_AMBIENT,N) - -#define AI_MATKEY_TEXTURE_EMISSIVE(N) \ - AI_MATKEY_TEXTURE(aiTextureType_EMISSIVE,N) - -#define AI_MATKEY_TEXTURE_NORMALS(N) \ - AI_MATKEY_TEXTURE(aiTextureType_NORMALS,N) - -#define AI_MATKEY_TEXTURE_HEIGHT(N) \ - AI_MATKEY_TEXTURE(aiTextureType_HEIGHT,N) - -#define AI_MATKEY_TEXTURE_SHININESS(N) \ - AI_MATKEY_TEXTURE(aiTextureType_SHININESS,N) - -#define AI_MATKEY_TEXTURE_OPACITY(N) \ - AI_MATKEY_TEXTURE(aiTextureType_OPACITY,N) - -#define AI_MATKEY_TEXTURE_DISPLACEMENT(N) \ - AI_MATKEY_TEXTURE(aiTextureType_DISPLACEMENT,N) - -#define AI_MATKEY_TEXTURE_LIGHTMAP(N) \ - AI_MATKEY_TEXTURE(aiTextureType_LIGHTMAP,N) - -#define AI_MATKEY_TEXTURE_REFLECTION(N) \ - AI_MATKEY_TEXTURE(aiTextureType_REFLECTION,N) - -//! @endcond - -// --------------------------------------------------------------------------- -#define AI_MATKEY_UVWSRC(type, N) _AI_MATKEY_UVWSRC_BASE,type,N - -// For backward compatibility and simplicity -//! @cond MATS_DOC_FULL -#define AI_MATKEY_UVWSRC_DIFFUSE(N) \ - AI_MATKEY_UVWSRC(aiTextureType_DIFFUSE,N) - -#define AI_MATKEY_UVWSRC_SPECULAR(N) \ - AI_MATKEY_UVWSRC(aiTextureType_SPECULAR,N) - -#define AI_MATKEY_UVWSRC_AMBIENT(N) \ - AI_MATKEY_UVWSRC(aiTextureType_AMBIENT,N) - -#define AI_MATKEY_UVWSRC_EMISSIVE(N) \ - AI_MATKEY_UVWSRC(aiTextureType_EMISSIVE,N) - -#define AI_MATKEY_UVWSRC_NORMALS(N) \ - AI_MATKEY_UVWSRC(aiTextureType_NORMALS,N) - -#define AI_MATKEY_UVWSRC_HEIGHT(N) \ - AI_MATKEY_UVWSRC(aiTextureType_HEIGHT,N) - -#define AI_MATKEY_UVWSRC_SHININESS(N) \ - AI_MATKEY_UVWSRC(aiTextureType_SHININESS,N) - -#define AI_MATKEY_UVWSRC_OPACITY(N) \ - AI_MATKEY_UVWSRC(aiTextureType_OPACITY,N) - -#define AI_MATKEY_UVWSRC_DISPLACEMENT(N) \ - AI_MATKEY_UVWSRC(aiTextureType_DISPLACEMENT,N) - -#define AI_MATKEY_UVWSRC_LIGHTMAP(N) \ - AI_MATKEY_UVWSRC(aiTextureType_LIGHTMAP,N) - -#define AI_MATKEY_UVWSRC_REFLECTION(N) \ - AI_MATKEY_UVWSRC(aiTextureType_REFLECTION,N) - -//! @endcond -// --------------------------------------------------------------------------- -#define AI_MATKEY_TEXOP(type, N) _AI_MATKEY_TEXOP_BASE,type,N - -// For backward compatibility and simplicity -//! @cond MATS_DOC_FULL -#define AI_MATKEY_TEXOP_DIFFUSE(N) \ - AI_MATKEY_TEXOP(aiTextureType_DIFFUSE,N) - -#define AI_MATKEY_TEXOP_SPECULAR(N) \ - AI_MATKEY_TEXOP(aiTextureType_SPECULAR,N) - -#define AI_MATKEY_TEXOP_AMBIENT(N) \ - AI_MATKEY_TEXOP(aiTextureType_AMBIENT,N) - -#define AI_MATKEY_TEXOP_EMISSIVE(N) \ - AI_MATKEY_TEXOP(aiTextureType_EMISSIVE,N) - -#define AI_MATKEY_TEXOP_NORMALS(N) \ - AI_MATKEY_TEXOP(aiTextureType_NORMALS,N) - -#define AI_MATKEY_TEXOP_HEIGHT(N) \ - AI_MATKEY_TEXOP(aiTextureType_HEIGHT,N) - -#define AI_MATKEY_TEXOP_SHININESS(N) \ - AI_MATKEY_TEXOP(aiTextureType_SHININESS,N) - -#define AI_MATKEY_TEXOP_OPACITY(N) \ - AI_MATKEY_TEXOP(aiTextureType_OPACITY,N) - -#define AI_MATKEY_TEXOP_DISPLACEMENT(N) \ - AI_MATKEY_TEXOP(aiTextureType_DISPLACEMENT,N) - -#define AI_MATKEY_TEXOP_LIGHTMAP(N) \ - AI_MATKEY_TEXOP(aiTextureType_LIGHTMAP,N) - -#define AI_MATKEY_TEXOP_REFLECTION(N) \ - AI_MATKEY_TEXOP(aiTextureType_REFLECTION,N) - -//! @endcond -// --------------------------------------------------------------------------- -#define AI_MATKEY_MAPPING(type, N) _AI_MATKEY_MAPPING_BASE,type,N - -// For backward compatibility and simplicity -//! @cond MATS_DOC_FULL -#define AI_MATKEY_MAPPING_DIFFUSE(N) \ - AI_MATKEY_MAPPING(aiTextureType_DIFFUSE,N) - -#define AI_MATKEY_MAPPING_SPECULAR(N) \ - AI_MATKEY_MAPPING(aiTextureType_SPECULAR,N) - -#define AI_MATKEY_MAPPING_AMBIENT(N) \ - AI_MATKEY_MAPPING(aiTextureType_AMBIENT,N) - -#define AI_MATKEY_MAPPING_EMISSIVE(N) \ - AI_MATKEY_MAPPING(aiTextureType_EMISSIVE,N) - -#define AI_MATKEY_MAPPING_NORMALS(N) \ - AI_MATKEY_MAPPING(aiTextureType_NORMALS,N) - -#define AI_MATKEY_MAPPING_HEIGHT(N) \ - AI_MATKEY_MAPPING(aiTextureType_HEIGHT,N) - -#define AI_MATKEY_MAPPING_SHININESS(N) \ - AI_MATKEY_MAPPING(aiTextureType_SHININESS,N) - -#define AI_MATKEY_MAPPING_OPACITY(N) \ - AI_MATKEY_MAPPING(aiTextureType_OPACITY,N) - -#define AI_MATKEY_MAPPING_DISPLACEMENT(N) \ - AI_MATKEY_MAPPING(aiTextureType_DISPLACEMENT,N) - -#define AI_MATKEY_MAPPING_LIGHTMAP(N) \ - AI_MATKEY_MAPPING(aiTextureType_LIGHTMAP,N) - -#define AI_MATKEY_MAPPING_REFLECTION(N) \ - AI_MATKEY_MAPPING(aiTextureType_REFLECTION,N) - -//! @endcond -// --------------------------------------------------------------------------- -#define AI_MATKEY_TEXBLEND(type, N) _AI_MATKEY_TEXBLEND_BASE,type,N - -// For backward compatibility and simplicity -//! @cond MATS_DOC_FULL -#define AI_MATKEY_TEXBLEND_DIFFUSE(N) \ - AI_MATKEY_TEXBLEND(aiTextureType_DIFFUSE,N) - -#define AI_MATKEY_TEXBLEND_SPECULAR(N) \ - AI_MATKEY_TEXBLEND(aiTextureType_SPECULAR,N) - -#define AI_MATKEY_TEXBLEND_AMBIENT(N) \ - AI_MATKEY_TEXBLEND(aiTextureType_AMBIENT,N) - -#define AI_MATKEY_TEXBLEND_EMISSIVE(N) \ - AI_MATKEY_TEXBLEND(aiTextureType_EMISSIVE,N) - -#define AI_MATKEY_TEXBLEND_NORMALS(N) \ - AI_MATKEY_TEXBLEND(aiTextureType_NORMALS,N) - -#define AI_MATKEY_TEXBLEND_HEIGHT(N) \ - AI_MATKEY_TEXBLEND(aiTextureType_HEIGHT,N) - -#define AI_MATKEY_TEXBLEND_SHININESS(N) \ - AI_MATKEY_TEXBLEND(aiTextureType_SHININESS,N) - -#define AI_MATKEY_TEXBLEND_OPACITY(N) \ - AI_MATKEY_TEXBLEND(aiTextureType_OPACITY,N) - -#define AI_MATKEY_TEXBLEND_DISPLACEMENT(N) \ - AI_MATKEY_TEXBLEND(aiTextureType_DISPLACEMENT,N) - -#define AI_MATKEY_TEXBLEND_LIGHTMAP(N) \ - AI_MATKEY_TEXBLEND(aiTextureType_LIGHTMAP,N) - -#define AI_MATKEY_TEXBLEND_REFLECTION(N) \ - AI_MATKEY_TEXBLEND(aiTextureType_REFLECTION,N) - -//! @endcond -// --------------------------------------------------------------------------- -#define AI_MATKEY_MAPPINGMODE_U(type, N) _AI_MATKEY_MAPPINGMODE_U_BASE,type,N - -// For backward compatibility and simplicity -//! @cond MATS_DOC_FULL -#define AI_MATKEY_MAPPINGMODE_U_DIFFUSE(N) \ - AI_MATKEY_MAPPINGMODE_U(aiTextureType_DIFFUSE,N) - -#define AI_MATKEY_MAPPINGMODE_U_SPECULAR(N) \ - AI_MATKEY_MAPPINGMODE_U(aiTextureType_SPECULAR,N) - -#define AI_MATKEY_MAPPINGMODE_U_AMBIENT(N) \ - AI_MATKEY_MAPPINGMODE_U(aiTextureType_AMBIENT,N) - -#define AI_MATKEY_MAPPINGMODE_U_EMISSIVE(N) \ - AI_MATKEY_MAPPINGMODE_U(aiTextureType_EMISSIVE,N) - -#define AI_MATKEY_MAPPINGMODE_U_NORMALS(N) \ - AI_MATKEY_MAPPINGMODE_U(aiTextureType_NORMALS,N) - -#define AI_MATKEY_MAPPINGMODE_U_HEIGHT(N) \ - AI_MATKEY_MAPPINGMODE_U(aiTextureType_HEIGHT,N) - -#define AI_MATKEY_MAPPINGMODE_U_SHININESS(N) \ - AI_MATKEY_MAPPINGMODE_U(aiTextureType_SHININESS,N) - -#define AI_MATKEY_MAPPINGMODE_U_OPACITY(N) \ - AI_MATKEY_MAPPINGMODE_U(aiTextureType_OPACITY,N) - -#define AI_MATKEY_MAPPINGMODE_U_DISPLACEMENT(N) \ - AI_MATKEY_MAPPINGMODE_U(aiTextureType_DISPLACEMENT,N) - -#define AI_MATKEY_MAPPINGMODE_U_LIGHTMAP(N) \ - AI_MATKEY_MAPPINGMODE_U(aiTextureType_LIGHTMAP,N) - -#define AI_MATKEY_MAPPINGMODE_U_REFLECTION(N) \ - AI_MATKEY_MAPPINGMODE_U(aiTextureType_REFLECTION,N) - -//! @endcond -// --------------------------------------------------------------------------- -#define AI_MATKEY_MAPPINGMODE_V(type, N) _AI_MATKEY_MAPPINGMODE_V_BASE,type,N - -// For backward compatibility and simplicity -//! @cond MATS_DOC_FULL -#define AI_MATKEY_MAPPINGMODE_V_DIFFUSE(N) \ - AI_MATKEY_MAPPINGMODE_V(aiTextureType_DIFFUSE,N) - -#define AI_MATKEY_MAPPINGMODE_V_SPECULAR(N) \ - AI_MATKEY_MAPPINGMODE_V(aiTextureType_SPECULAR,N) - -#define AI_MATKEY_MAPPINGMODE_V_AMBIENT(N) \ - AI_MATKEY_MAPPINGMODE_V(aiTextureType_AMBIENT,N) - -#define AI_MATKEY_MAPPINGMODE_V_EMISSIVE(N) \ - AI_MATKEY_MAPPINGMODE_V(aiTextureType_EMISSIVE,N) - -#define AI_MATKEY_MAPPINGMODE_V_NORMALS(N) \ - AI_MATKEY_MAPPINGMODE_V(aiTextureType_NORMALS,N) - -#define AI_MATKEY_MAPPINGMODE_V_HEIGHT(N) \ - AI_MATKEY_MAPPINGMODE_V(aiTextureType_HEIGHT,N) - -#define AI_MATKEY_MAPPINGMODE_V_SHININESS(N) \ - AI_MATKEY_MAPPINGMODE_V(aiTextureType_SHININESS,N) - -#define AI_MATKEY_MAPPINGMODE_V_OPACITY(N) \ - AI_MATKEY_MAPPINGMODE_V(aiTextureType_OPACITY,N) - -#define AI_MATKEY_MAPPINGMODE_V_DISPLACEMENT(N) \ - AI_MATKEY_MAPPINGMODE_V(aiTextureType_DISPLACEMENT,N) - -#define AI_MATKEY_MAPPINGMODE_V_LIGHTMAP(N) \ - AI_MATKEY_MAPPINGMODE_V(aiTextureType_LIGHTMAP,N) - -#define AI_MATKEY_MAPPINGMODE_V_REFLECTION(N) \ - AI_MATKEY_MAPPINGMODE_V(aiTextureType_REFLECTION,N) - -//! @endcond -// --------------------------------------------------------------------------- -#define AI_MATKEY_TEXMAP_AXIS(type, N) _AI_MATKEY_TEXMAP_AXIS_BASE,type,N - -// For backward compatibility and simplicity -//! @cond MATS_DOC_FULL -#define AI_MATKEY_TEXMAP_AXIS_DIFFUSE(N) \ - AI_MATKEY_TEXMAP_AXIS(aiTextureType_DIFFUSE,N) - -#define AI_MATKEY_TEXMAP_AXIS_SPECULAR(N) \ - AI_MATKEY_TEXMAP_AXIS(aiTextureType_SPECULAR,N) - -#define AI_MATKEY_TEXMAP_AXIS_AMBIENT(N) \ - AI_MATKEY_TEXMAP_AXIS(aiTextureType_AMBIENT,N) - -#define AI_MATKEY_TEXMAP_AXIS_EMISSIVE(N) \ - AI_MATKEY_TEXMAP_AXIS(aiTextureType_EMISSIVE,N) - -#define AI_MATKEY_TEXMAP_AXIS_NORMALS(N) \ - AI_MATKEY_TEXMAP_AXIS(aiTextureType_NORMALS,N) - -#define AI_MATKEY_TEXMAP_AXIS_HEIGHT(N) \ - AI_MATKEY_TEXMAP_AXIS(aiTextureType_HEIGHT,N) - -#define AI_MATKEY_TEXMAP_AXIS_SHININESS(N) \ - AI_MATKEY_TEXMAP_AXIS(aiTextureType_SHININESS,N) - -#define AI_MATKEY_TEXMAP_AXIS_OPACITY(N) \ - AI_MATKEY_TEXMAP_AXIS(aiTextureType_OPACITY,N) - -#define AI_MATKEY_TEXMAP_AXIS_DISPLACEMENT(N) \ - AI_MATKEY_TEXMAP_AXIS(aiTextureType_DISPLACEMENT,N) - -#define AI_MATKEY_TEXMAP_AXIS_LIGHTMAP(N) \ - AI_MATKEY_TEXMAP_AXIS(aiTextureType_LIGHTMAP,N) - -#define AI_MATKEY_TEXMAP_AXIS_REFLECTION(N) \ - AI_MATKEY_TEXMAP_AXIS(aiTextureType_REFLECTION,N) - -//! @endcond -// --------------------------------------------------------------------------- -#define AI_MATKEY_UVTRANSFORM(type, N) _AI_MATKEY_UVTRANSFORM_BASE,type,N - -// For backward compatibility and simplicity -//! @cond MATS_DOC_FULL -#define AI_MATKEY_UVTRANSFORM_DIFFUSE(N) \ - AI_MATKEY_UVTRANSFORM(aiTextureType_DIFFUSE,N) - -#define AI_MATKEY_UVTRANSFORM_SPECULAR(N) \ - AI_MATKEY_UVTRANSFORM(aiTextureType_SPECULAR,N) - -#define AI_MATKEY_UVTRANSFORM_AMBIENT(N) \ - AI_MATKEY_UVTRANSFORM(aiTextureType_AMBIENT,N) - -#define AI_MATKEY_UVTRANSFORM_EMISSIVE(N) \ - AI_MATKEY_UVTRANSFORM(aiTextureType_EMISSIVE,N) - -#define AI_MATKEY_UVTRANSFORM_NORMALS(N) \ - AI_MATKEY_UVTRANSFORM(aiTextureType_NORMALS,N) - -#define AI_MATKEY_UVTRANSFORM_HEIGHT(N) \ - AI_MATKEY_UVTRANSFORM(aiTextureType_HEIGHT,N) - -#define AI_MATKEY_UVTRANSFORM_SHININESS(N) \ - AI_MATKEY_UVTRANSFORM(aiTextureType_SHININESS,N) - -#define AI_MATKEY_UVTRANSFORM_OPACITY(N) \ - AI_MATKEY_UVTRANSFORM(aiTextureType_OPACITY,N) - -#define AI_MATKEY_UVTRANSFORM_DISPLACEMENT(N) \ - AI_MATKEY_UVTRANSFORM(aiTextureType_DISPLACEMENT,N) - -#define AI_MATKEY_UVTRANSFORM_LIGHTMAP(N) \ - AI_MATKEY_UVTRANSFORM(aiTextureType_LIGHTMAP,N) - -#define AI_MATKEY_UVTRANSFORM_REFLECTION(N) \ - AI_MATKEY_UVTRANSFORM(aiTextureType_REFLECTION,N) - -#define AI_MATKEY_UVTRANSFORM_UNKNOWN(N) \ - AI_MATKEY_UVTRANSFORM(aiTextureType_UNKNOWN,N) - -//! @endcond -// --------------------------------------------------------------------------- -#define AI_MATKEY_TEXFLAGS(type, N) _AI_MATKEY_TEXFLAGS_BASE,type,N - -// For backward compatibility and simplicity -//! @cond MATS_DOC_FULL -#define AI_MATKEY_TEXFLAGS_DIFFUSE(N) \ - AI_MATKEY_TEXFLAGS(aiTextureType_DIFFUSE,N) - -#define AI_MATKEY_TEXFLAGS_SPECULAR(N) \ - AI_MATKEY_TEXFLAGS(aiTextureType_SPECULAR,N) - -#define AI_MATKEY_TEXFLAGS_AMBIENT(N) \ - AI_MATKEY_TEXFLAGS(aiTextureType_AMBIENT,N) - -#define AI_MATKEY_TEXFLAGS_EMISSIVE(N) \ - AI_MATKEY_TEXFLAGS(aiTextureType_EMISSIVE,N) - -#define AI_MATKEY_TEXFLAGS_NORMALS(N) \ - AI_MATKEY_TEXFLAGS(aiTextureType_NORMALS,N) - -#define AI_MATKEY_TEXFLAGS_HEIGHT(N) \ - AI_MATKEY_TEXFLAGS(aiTextureType_HEIGHT,N) - -#define AI_MATKEY_TEXFLAGS_SHININESS(N) \ - AI_MATKEY_TEXFLAGS(aiTextureType_SHININESS,N) - -#define AI_MATKEY_TEXFLAGS_OPACITY(N) \ - AI_MATKEY_TEXFLAGS(aiTextureType_OPACITY,N) - -#define AI_MATKEY_TEXFLAGS_DISPLACEMENT(N) \ - AI_MATKEY_TEXFLAGS(aiTextureType_DISPLACEMENT,N) - -#define AI_MATKEY_TEXFLAGS_LIGHTMAP(N) \ - AI_MATKEY_TEXFLAGS(aiTextureType_LIGHTMAP,N) - -#define AI_MATKEY_TEXFLAGS_REFLECTION(N) \ - AI_MATKEY_TEXFLAGS(aiTextureType_REFLECTION,N) - -#define AI_MATKEY_TEXFLAGS_UNKNOWN(N) \ - AI_MATKEY_TEXFLAGS(aiTextureType_UNKNOWN,N) - -//! @endcond -//! -// --------------------------------------------------------------------------- -/** @brief Retrieve a material property with a specific key from the material - * - * @param pMat Pointer to the input material. May not be NULL - * @param pKey Key to search for. One of the AI_MATKEY_XXX constants. - * @param type Specifies the type of the texture to be retrieved ( - * e.g. diffuse, specular, height map ...) - * @param index Index of the texture to be retrieved. - * @param pPropOut Pointer to receive a pointer to a valid aiMaterialProperty - * structure or NULL if the key has not been found. */ -// --------------------------------------------------------------------------- -ASSIMP_API C_ENUM aiReturn aiGetMaterialProperty( - const C_STRUCT aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - const C_STRUCT aiMaterialProperty** pPropOut); - -// --------------------------------------------------------------------------- -/** @brief Retrieve an array of float values with a specific key - * from the material - * - * Pass one of the AI_MATKEY_XXX constants for the last three parameters (the - * example reads the #AI_MATKEY_UVTRANSFORM property of the first diffuse texture) - * @code - * aiUVTransform trafo; - * unsigned int max = sizeof(aiUVTransform); - * if (AI_SUCCESS != aiGetMaterialFloatArray(mat, AI_MATKEY_UVTRANSFORM(aiTextureType_DIFFUSE,0), - * (float*)&trafo, &max) || sizeof(aiUVTransform) != max) - * { - * // error handling - * } - * @endcode - * - * @param pMat Pointer to the input material. May not be NULL - * @param pKey Key to search for. One of the AI_MATKEY_XXX constants. - * @param pOut Pointer to a buffer to receive the result. - * @param pMax Specifies the size of the given buffer, in float's. - * Receives the number of values (not bytes!) read. - * @param type (see the code sample above) - * @param index (see the code sample above) - * @return Specifies whether the key has been found. If not, the output - * arrays remains unmodified and pMax is set to 0.*/ -// --------------------------------------------------------------------------- -ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray( - const C_STRUCT aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - float* pOut, - unsigned int* pMax); - - -#ifdef __cplusplus - -// --------------------------------------------------------------------------- -/** @brief Retrieve a single float property with a specific key from the material. -* -* Pass one of the AI_MATKEY_XXX constants for the last three parameters (the -* example reads the #AI_MATKEY_SHININESS_STRENGTH property of the first diffuse texture) -* @code -* float specStrength = 1.f; // default value, remains unmodified if we fail. -* aiGetMaterialFloat(mat, AI_MATKEY_SHININESS_STRENGTH, -* (float*)&specStrength); -* @endcode -* -* @param pMat Pointer to the input material. May not be NULL -* @param pKey Key to search for. One of the AI_MATKEY_XXX constants. -* @param pOut Receives the output float. -* @param type (see the code sample above) -* @param index (see the code sample above) -* @return Specifies whether the key has been found. If not, the output -* float remains unmodified.*/ -// --------------------------------------------------------------------------- -inline aiReturn aiGetMaterialFloat(const aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - float* pOut) -{ - return aiGetMaterialFloatArray(pMat,pKey,type,index,pOut,(unsigned int*)0x0); -} - -#else - -// Use our friend, the C preprocessor -#define aiGetMaterialFloat (pMat, type, index, pKey, pOut) \ - aiGetMaterialFloatArray(pMat, type, index, pKey, pOut, NULL) - -#endif //!__cplusplus - - -// --------------------------------------------------------------------------- -/** @brief Retrieve an array of integer values with a specific key - * from a material - * - * See the sample for aiGetMaterialFloatArray for more information.*/ -ASSIMP_API C_ENUM aiReturn aiGetMaterialIntegerArray(const C_STRUCT aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - int* pOut, - unsigned int* pMax); - - -#ifdef __cplusplus - -// --------------------------------------------------------------------------- -/** @brief Retrieve an integer property with a specific key from a material - * - * See the sample for aiGetMaterialFloat for more information.*/ -// --------------------------------------------------------------------------- -inline aiReturn aiGetMaterialInteger(const C_STRUCT aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - int* pOut) -{ - return aiGetMaterialIntegerArray(pMat,pKey,type,index,pOut,(unsigned int*)0x0); -} - -#else - -// use our friend, the C preprocessor -#define aiGetMaterialInteger (pMat, type, index, pKey, pOut) \ - aiGetMaterialIntegerArray(pMat, type, index, pKey, pOut, NULL) - -#endif //!__cplusplus - - - -// --------------------------------------------------------------------------- -/** @brief Retrieve a color value from the material property table -* -* See the sample for aiGetMaterialFloat for more information*/ -// --------------------------------------------------------------------------- -ASSIMP_API C_ENUM aiReturn aiGetMaterialColor(const C_STRUCT aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - C_STRUCT aiColor4D* pOut); - - -// --------------------------------------------------------------------------- -/** @brief Retrieve a aiUVTransform value from the material property table -* -* See the sample for aiGetMaterialFloat for more information*/ -// --------------------------------------------------------------------------- -ASSIMP_API C_ENUM aiReturn aiGetMaterialUVTransform(const C_STRUCT aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - C_STRUCT aiUVTransform* pOut); - - -// --------------------------------------------------------------------------- -/** @brief Retrieve a string from the material property table -* -* See the sample for aiGetMaterialFloat for more information.*/ -// --------------------------------------------------------------------------- -ASSIMP_API C_ENUM aiReturn aiGetMaterialString(const C_STRUCT aiMaterial* pMat, - const char* pKey, - unsigned int type, - unsigned int index, - C_STRUCT aiString* pOut); - -// --------------------------------------------------------------------------- -/** Get the number of textures for a particular texture type. - * @param[in] pMat Pointer to the input material. May not be NULL - * @param type Texture type to check for - * @return Number of textures for this type. - * @note A texture can be easily queried using #aiGetMaterialTexture() */ -// --------------------------------------------------------------------------- -ASSIMP_API unsigned int aiGetMaterialTextureCount(const C_STRUCT aiMaterial* pMat, - C_ENUM aiTextureType type); - -// --------------------------------------------------------------------------- -/** @brief Helper function to get all values pertaining to a particular - * texture slot from a material structure. - * - * This function is provided just for convenience. You could also read the - * texture by parsing all of its properties manually. This function bundles - * all of them in a huge function monster. - * - * @param[in] mat Pointer to the input material. May not be NULL - * @param[in] type Specifies the texture stack to read from (e.g. diffuse, - * specular, height map ...). - * @param[in] index Index of the texture. The function fails if the - * requested index is not available for this texture type. - * #aiGetMaterialTextureCount() can be used to determine the number of - * textures in a particular texture stack. - * @param[out] path Receives the output path - * This parameter must be non-null. - * @param mapping The texture mapping mode to be used. - * Pass NULL if you're not interested in this information. - * @param[out] uvindex For UV-mapped textures: receives the index of the UV - * source channel. Unmodified otherwise. - * Pass NULL if you're not interested in this information. - * @param[out] blend Receives the blend factor for the texture - * Pass NULL if you're not interested in this information. - * @param[out] op Receives the texture blend operation to be perform between - * this texture and the previous texture. - * Pass NULL if you're not interested in this information. - * @param[out] mapmode Receives the mapping modes to be used for the texture. - * Pass NULL if you're not interested in this information. Otherwise, - * pass a pointer to an array of two aiTextureMapMode's (one for each - * axis, UV order). - * @param[out] flags Receives the the texture flags. - * @return AI_SUCCESS on success, otherwise something else. Have fun.*/ -// --------------------------------------------------------------------------- -#ifdef __cplusplus -ASSIMP_API aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat, - aiTextureType type, - unsigned int index, - aiString* path, - aiTextureMapping* mapping = NULL, - unsigned int* uvindex = NULL, - float* blend = NULL, - aiTextureOp* op = NULL, - aiTextureMapMode* mapmode = NULL, - unsigned int* flags = NULL); -#else -C_ENUM aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat, - C_ENUM aiTextureType type, - unsigned int index, - C_STRUCT aiString* path, - C_ENUM aiTextureMapping* mapping /*= NULL*/, - unsigned int* uvindex /*= NULL*/, - float* blend /*= NULL*/, - C_ENUM aiTextureOp* op /*= NULL*/, - C_ENUM aiTextureMapMode* mapmode /*= NULL*/, - unsigned int* flags /*= NULL*/); -#endif // !#ifdef __cplusplus - -#ifdef __cplusplus -} - -#include "material.inl" - -#endif //!__cplusplus -#endif //!!AI_MATERIAL_H_INC diff --git a/thirdparty/include/assimp/material.inl b/thirdparty/include/assimp/material.inl deleted file mode 100644 index 994e608b4..000000000 --- a/thirdparty/include/assimp/material.inl +++ /dev/null @@ -1,350 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file material.inl - * @brief Defines the C++ getters for the material system - */ - -#ifndef AI_MATERIAL_INL_INC -#define AI_MATERIAL_INL_INC - -//! @cond never - -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::GetTexture( aiTextureType type, - unsigned int index, - C_STRUCT aiString* path, - aiTextureMapping* mapping /*= NULL*/, - unsigned int* uvindex /*= NULL*/, - float* blend /*= NULL*/, - aiTextureOp* op /*= NULL*/, - aiTextureMapMode* mapmode /*= NULL*/) const -{ - return ::aiGetMaterialTexture(this,type,index,path,mapping,uvindex,blend,op,mapmode); -} - -// --------------------------------------------------------------------------- -inline unsigned int aiMaterial::GetTextureCount(aiTextureType type) const -{ - return ::aiGetMaterialTextureCount(this,type); -} - -// --------------------------------------------------------------------------- -template -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, - unsigned int idx, Type* pOut, - unsigned int* pMax) const -{ - unsigned int iNum = pMax ? *pMax : 1; - - const aiMaterialProperty* prop; - const aiReturn ret = ::aiGetMaterialProperty(this,pKey,type,idx, - (const aiMaterialProperty**)&prop); - if ( AI_SUCCESS == ret ) { - - if (prop->mDataLength < sizeof(Type)*iNum) { - return AI_FAILURE; - } - - if (prop->mType != aiPTI_Buffer) { - return AI_FAILURE; - } - - iNum = std::min((size_t)iNum,prop->mDataLength / sizeof(Type)); - ::memcpy(pOut,prop->mData,iNum * sizeof(Type)); - if (pMax) { - *pMax = iNum; - } - } - return ret; -} - -// --------------------------------------------------------------------------- -template -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, - unsigned int idx,Type& pOut) const -{ - const aiMaterialProperty* prop; - const aiReturn ret = ::aiGetMaterialProperty(this,pKey,type,idx, - (const aiMaterialProperty**)&prop); - if ( AI_SUCCESS == ret ) { - - if (prop->mDataLength < sizeof(Type)) { - return AI_FAILURE; - } - - if (prop->mType != aiPTI_Buffer) { - return AI_FAILURE; - } - - ::memcpy(&pOut,prop->mData,sizeof(Type)); - } - return ret; -} - -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, - unsigned int idx,float* pOut, - unsigned int* pMax) const -{ - return ::aiGetMaterialFloatArray(this,pKey,type,idx,pOut,pMax); -} -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, - unsigned int idx,int* pOut, - unsigned int* pMax) const -{ - return ::aiGetMaterialIntegerArray(this,pKey,type,idx,pOut,pMax); -} -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, - unsigned int idx,float& pOut) const -{ - return aiGetMaterialFloat(this,pKey,type,idx,&pOut); -} -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, - unsigned int idx,int& pOut) const -{ - return aiGetMaterialInteger(this,pKey,type,idx,&pOut); -} -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, - unsigned int idx,aiColor4D& pOut) const -{ - return aiGetMaterialColor(this,pKey,type,idx,&pOut); -} -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, - unsigned int idx,aiColor3D& pOut) const -{ - aiColor4D c; - const aiReturn ret = aiGetMaterialColor(this,pKey,type,idx,&c); - pOut = aiColor3D(c.r,c.g,c.b); - return ret; -} -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, - unsigned int idx,aiString& pOut) const -{ - return aiGetMaterialString(this,pKey,type,idx,&pOut); -} -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, - unsigned int idx,aiUVTransform& pOut) const -{ - return aiGetMaterialUVTransform(this,pKey,type,idx,&pOut); -} - - -// --------------------------------------------------------------------------- -template -aiReturn aiMaterial::AddProperty (const TYPE* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(TYPE), - pKey,type,index,aiPTI_Buffer); -} - -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::AddProperty(const float* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(float), - pKey,type,index,aiPTI_Float); -} - -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(aiUVTransform), - pKey,type,index,aiPTI_Float); -} - -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::AddProperty(const aiColor4D* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(aiColor4D), - pKey,type,index,aiPTI_Float); -} - -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::AddProperty(const aiColor3D* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(aiColor3D), - pKey,type,index,aiPTI_Float); -} - -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::AddProperty(const aiVector3D* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(aiVector3D), - pKey,type,index,aiPTI_Float); -} - -// --------------------------------------------------------------------------- -inline aiReturn aiMaterial::AddProperty(const int* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(int), - pKey,type,index,aiPTI_Integer); -} - - -// --------------------------------------------------------------------------- -// The template specializations below are for backwards compatibility. -// The recommended way to add material properties is using the non-template -// overloads. -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -template<> -inline aiReturn aiMaterial::AddProperty(const float* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(float), - pKey,type,index,aiPTI_Float); -} - -// --------------------------------------------------------------------------- -template<> -inline aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(aiUVTransform), - pKey,type,index,aiPTI_Float); -} - -// --------------------------------------------------------------------------- -template<> -inline aiReturn aiMaterial::AddProperty(const aiColor4D* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(aiColor4D), - pKey,type,index,aiPTI_Float); -} - -// --------------------------------------------------------------------------- -template<> -inline aiReturn aiMaterial::AddProperty(const aiColor3D* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(aiColor3D), - pKey,type,index,aiPTI_Float); -} - -// --------------------------------------------------------------------------- -template<> -inline aiReturn aiMaterial::AddProperty(const aiVector3D* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(aiVector3D), - pKey,type,index,aiPTI_Float); -} - -// --------------------------------------------------------------------------- -template<> -inline aiReturn aiMaterial::AddProperty(const int* pInput, - const unsigned int pNumValues, - const char* pKey, - unsigned int type, - unsigned int index) -{ - return AddBinaryProperty((const void*)pInput, - pNumValues * sizeof(int), - pKey,type,index,aiPTI_Integer); -} - -//! @endcond - -#endif //! AI_MATERIAL_INL_INC diff --git a/thirdparty/include/assimp/matrix3x3.h b/thirdparty/include/assimp/matrix3x3.h deleted file mode 100644 index 725b1c34c..000000000 --- a/thirdparty/include/assimp/matrix3x3.h +++ /dev/null @@ -1,182 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file matrix3x3.h - * @brief Definition of a 3x3 matrix, including operators when compiling in C++ - */ -#ifndef AI_MATRIX3x3_H_INC -#define AI_MATRIX3x3_H_INC - -#include "./Compiler/pushpack1.h" - -#ifdef __cplusplus - -template class aiMatrix4x4t; -template class aiVector2t; - -// --------------------------------------------------------------------------- -/** @brief Represents a row-major 3x3 matrix - * - * There's much confusion about matrix layouts (column vs. row order). - * This is *always* a row-major matrix. Not even with the - * #aiProcess_ConvertToLeftHanded flag, which absolutely does not affect - * matrix order - it just affects the handedness of the coordinate system - * defined thereby. - */ -template -class aiMatrix3x3t -{ -public: - - aiMatrix3x3t () : - a1(static_cast(1.0f)), a2(), a3(), - b1(), b2(static_cast(1.0f)), b3(), - c1(), c2(), c3(static_cast(1.0f)) {} - - aiMatrix3x3t ( TReal _a1, TReal _a2, TReal _a3, - TReal _b1, TReal _b2, TReal _b3, - TReal _c1, TReal _c2, TReal _c3) : - a1(_a1), a2(_a2), a3(_a3), - b1(_b1), b2(_b2), b3(_b3), - c1(_c1), c2(_c2), c3(_c3) - {} - -public: - - // matrix multiplication. - aiMatrix3x3t& operator *= (const aiMatrix3x3t& m); - aiMatrix3x3t operator * (const aiMatrix3x3t& m) const; - - // array access operators - TReal* operator[] (unsigned int p_iIndex); - const TReal* operator[] (unsigned int p_iIndex) const; - - // comparison operators - bool operator== (const aiMatrix4x4t& m) const; - bool operator!= (const aiMatrix4x4t& m) const; - - bool Equal(const aiMatrix4x4t& m, TReal epsilon = 1e-6) const; - - template - operator aiMatrix3x3t () const; - -public: - - // ------------------------------------------------------------------- - /** @brief Construction from a 4x4 matrix. The remaining parts - * of the matrix are ignored. - */ - explicit aiMatrix3x3t( const aiMatrix4x4t& pMatrix); - - // ------------------------------------------------------------------- - /** @brief Transpose the matrix - */ - aiMatrix3x3t& Transpose(); - - // ------------------------------------------------------------------- - /** @brief Invert the matrix. - * If the matrix is not invertible all elements are set to qnan. - * Beware, use (f != f) to check whether a TReal f is qnan. - */ - aiMatrix3x3t& Inverse(); - TReal Determinant() const; - -public: - // ------------------------------------------------------------------- - /** @brief Returns a rotation matrix for a rotation around z - * @param a Rotation angle, in radians - * @param out Receives the output matrix - * @return Reference to the output matrix - */ - static aiMatrix3x3t& RotationZ(TReal a, aiMatrix3x3t& out); - - // ------------------------------------------------------------------- - /** @brief Returns a rotation matrix for a rotation around - * an arbitrary axis. - * - * @param a Rotation angle, in radians - * @param axis Axis to rotate around - * @param out To be filled - */ - static aiMatrix3x3t& Rotation( TReal a, - const aiVector3t& axis, aiMatrix3x3t& out); - - // ------------------------------------------------------------------- - /** @brief Returns a translation matrix - * @param v Translation vector - * @param out Receives the output matrix - * @return Reference to the output matrix - */ - static aiMatrix3x3t& Translation( const aiVector2t& v, aiMatrix3x3t& out); - - // ------------------------------------------------------------------- - /** @brief A function for creating a rotation matrix that rotates a - * vector called "from" into another vector called "to". - * Input : from[3], to[3] which both must be *normalized* non-zero vectors - * Output: mtx[3][3] -- a 3x3 matrix in colum-major form - * Authors: Tomas M�ller, John Hughes - * "Efficiently Building a Matrix to Rotate One Vector to Another" - * Journal of Graphics Tools, 4(4):1-4, 1999 - */ - static aiMatrix3x3t& FromToMatrix(const aiVector3t& from, - const aiVector3t& to, aiMatrix3x3t& out); - -public: - TReal a1, a2, a3; - TReal b1, b2, b3; - TReal c1, c2, c3; -} PACK_STRUCT; - -typedef aiMatrix3x3t aiMatrix3x3; - -#else - -struct aiMatrix3x3 { - float a1, a2, a3; - float b1, b2, b3; - float c1, c2, c3; -} PACK_STRUCT; - -#endif // __cplusplus - -#include "./Compiler/poppack1.h" - -#endif // AI_MATRIX3x3_H_INC diff --git a/thirdparty/include/assimp/matrix3x3.inl b/thirdparty/include/assimp/matrix3x3.inl deleted file mode 100644 index 9ace3f97b..000000000 --- a/thirdparty/include/assimp/matrix3x3.inl +++ /dev/null @@ -1,336 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file matrix3x3.inl - * @brief Inline implementation of the 3x3 matrix operators - */ -#ifndef AI_MATRIX3x3_INL_INC -#define AI_MATRIX3x3_INL_INC - -#ifdef __cplusplus -#include "matrix3x3.h" - -#include "matrix4x4.h" -#include -#include -#include - -// ------------------------------------------------------------------------------------------------ -// Construction from a 4x4 matrix. The remaining parts of the matrix are ignored. -template -inline aiMatrix3x3t::aiMatrix3x3t( const aiMatrix4x4t& pMatrix) -{ - a1 = pMatrix.a1; a2 = pMatrix.a2; a3 = pMatrix.a3; - b1 = pMatrix.b1; b2 = pMatrix.b2; b3 = pMatrix.b3; - c1 = pMatrix.c1; c2 = pMatrix.c2; c3 = pMatrix.c3; -} - -// ------------------------------------------------------------------------------------------------ -template -inline aiMatrix3x3t& aiMatrix3x3t::operator *= (const aiMatrix3x3t& m) -{ - *this = aiMatrix3x3t(m.a1 * a1 + m.b1 * a2 + m.c1 * a3, - m.a2 * a1 + m.b2 * a2 + m.c2 * a3, - m.a3 * a1 + m.b3 * a2 + m.c3 * a3, - m.a1 * b1 + m.b1 * b2 + m.c1 * b3, - m.a2 * b1 + m.b2 * b2 + m.c2 * b3, - m.a3 * b1 + m.b3 * b2 + m.c3 * b3, - m.a1 * c1 + m.b1 * c2 + m.c1 * c3, - m.a2 * c1 + m.b2 * c2 + m.c2 * c3, - m.a3 * c1 + m.b3 * c2 + m.c3 * c3); - return *this; -} - -// ------------------------------------------------------------------------------------------------ -template -template -aiMatrix3x3t::operator aiMatrix3x3t () const -{ - return aiMatrix3x3t(static_cast(a1),static_cast(a2),static_cast(a3), - static_cast(b1),static_cast(b2),static_cast(b3), - static_cast(c1),static_cast(c2),static_cast(c3)); -} - -// ------------------------------------------------------------------------------------------------ -template -inline aiMatrix3x3t aiMatrix3x3t::operator* (const aiMatrix3x3t& m) const -{ - aiMatrix3x3t temp( *this); - temp *= m; - return temp; -} - -// ------------------------------------------------------------------------------------------------ -template -inline TReal* aiMatrix3x3t::operator[] (unsigned int p_iIndex) -{ - return &this->a1 + p_iIndex * 3; -} - -// ------------------------------------------------------------------------------------------------ -template -inline const TReal* aiMatrix3x3t::operator[] (unsigned int p_iIndex) const -{ - return &this->a1 + p_iIndex * 3; -} - -// ------------------------------------------------------------------------------------------------ -template -inline bool aiMatrix3x3t::operator== (const aiMatrix4x4t& m) const -{ - return a1 == m.a1 && a2 == m.a2 && a3 == m.a3 && - b1 == m.b1 && b2 == m.b2 && b3 == m.b3 && - c1 == m.c1 && c2 == m.c2 && c3 == m.c3; -} - -// ------------------------------------------------------------------------------------------------ -template -inline bool aiMatrix3x3t::operator!= (const aiMatrix4x4t& m) const -{ - return !(*this == m); -} - -// --------------------------------------------------------------------------- -template -inline bool aiMatrix3x3t::Equal(const aiMatrix4x4t& m, TReal epsilon) const { - return - std::abs(a1 - m.a1) <= epsilon && - std::abs(a2 - m.a2) <= epsilon && - std::abs(a3 - m.a3) <= epsilon && - std::abs(b1 - m.b1) <= epsilon && - std::abs(b2 - m.b2) <= epsilon && - std::abs(b3 - m.b3) <= epsilon && - std::abs(c1 - m.c1) <= epsilon && - std::abs(c2 - m.c2) <= epsilon && - std::abs(c3 - m.c3) <= epsilon; -} - -// ------------------------------------------------------------------------------------------------ -template -inline aiMatrix3x3t& aiMatrix3x3t::Transpose() -{ - // (TReal&) don't remove, GCC complains cause of packed fields - std::swap( (TReal&)a2, (TReal&)b1); - std::swap( (TReal&)a3, (TReal&)c1); - std::swap( (TReal&)b3, (TReal&)c2); - return *this; -} - -// ---------------------------------------------------------------------------------------- -template -inline TReal aiMatrix3x3t::Determinant() const -{ - return a1*b2*c3 - a1*b3*c2 + a2*b3*c1 - a2*b1*c3 + a3*b1*c2 - a3*b2*c1; -} - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix3x3t& aiMatrix3x3t::Inverse() -{ - // Compute the reciprocal determinant - TReal det = Determinant(); - if(det == static_cast(0.0)) - { - // Matrix not invertible. Setting all elements to nan is not really - // correct in a mathematical sense; but at least qnans are easy to - // spot. XXX we might throw an exception instead, which would - // be even much better to spot :/. - const TReal nan = std::numeric_limits::quiet_NaN(); - *this = aiMatrix3x3t( nan,nan,nan,nan,nan,nan,nan,nan,nan); - - return *this; - } - - TReal invdet = static_cast(1.0) / det; - - aiMatrix3x3t res; - res.a1 = invdet * (b2 * c3 - b3 * c2); - res.a2 = -invdet * (a2 * c3 - a3 * c2); - res.a3 = invdet * (a2 * b3 - a3 * b2); - res.b1 = -invdet * (b1 * c3 - b3 * c1); - res.b2 = invdet * (a1 * c3 - a3 * c1); - res.b3 = -invdet * (a1 * b3 - a3 * b1); - res.c1 = invdet * (b1 * c2 - b2 * c1); - res.c2 = -invdet * (a1 * c2 - a2 * c1); - res.c3 = invdet * (a1 * b2 - a2 * b1); - *this = res; - - return *this; -} - -// ------------------------------------------------------------------------------------------------ -template -inline aiMatrix3x3t& aiMatrix3x3t::RotationZ(TReal a, aiMatrix3x3t& out) -{ - out.a1 = out.b2 = std::cos(a); - out.b1 = std::sin(a); - out.a2 = - out.b1; - - out.a3 = out.b3 = out.c1 = out.c2 = 0.f; - out.c3 = 1.f; - - return out; -} - -// ------------------------------------------------------------------------------------------------ -// Returns a rotation matrix for a rotation around an arbitrary axis. -template -inline aiMatrix3x3t& aiMatrix3x3t::Rotation( TReal a, const aiVector3t& axis, aiMatrix3x3t& out) -{ - TReal c = std::cos( a), s = std::sin( a), t = 1 - c; - TReal x = axis.x, y = axis.y, z = axis.z; - - // Many thanks to MathWorld and Wikipedia - out.a1 = t*x*x + c; out.a2 = t*x*y - s*z; out.a3 = t*x*z + s*y; - out.b1 = t*x*y + s*z; out.b2 = t*y*y + c; out.b3 = t*y*z - s*x; - out.c1 = t*x*z - s*y; out.c2 = t*y*z + s*x; out.c3 = t*z*z + c; - - return out; -} - -// ------------------------------------------------------------------------------------------------ -template -inline aiMatrix3x3t& aiMatrix3x3t::Translation( const aiVector2t& v, aiMatrix3x3t& out) -{ - out = aiMatrix3x3t(); - out.a3 = v.x; - out.b3 = v.y; - return out; -} - -// ---------------------------------------------------------------------------------------- -/** A function for creating a rotation matrix that rotates a vector called - * "from" into another vector called "to". - * Input : from[3], to[3] which both must be *normalized* non-zero vectors - * Output: mtx[3][3] -- a 3x3 matrix in colum-major form - * Authors: Tomas M�ller, John Hughes - * "Efficiently Building a Matrix to Rotate One Vector to Another" - * Journal of Graphics Tools, 4(4):1-4, 1999 - */ -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix3x3t& aiMatrix3x3t::FromToMatrix(const aiVector3t& from, - const aiVector3t& to, aiMatrix3x3t& mtx) -{ - const TReal e = from * to; - const TReal f = (e < 0)? -e:e; - - if (f > static_cast(1.0) - static_cast(0.00001)) /* "from" and "to"-vector almost parallel */ - { - aiVector3D u,v; /* temporary storage vectors */ - aiVector3D x; /* vector most nearly orthogonal to "from" */ - - x.x = (from.x > 0.0)? from.x : -from.x; - x.y = (from.y > 0.0)? from.y : -from.y; - x.z = (from.z > 0.0)? from.z : -from.z; - - if (x.x < x.y) - { - if (x.x < x.z) - { - x.x = static_cast(1.0); - x.y = x.z = static_cast(0.0); - } - else - { - x.z = static_cast(1.0); - x.x = x.y = static_cast(0.0); - } - } - else - { - if (x.y < x.z) - { - x.y = static_cast(1.0); - x.x = x.z = static_cast(0.0); - } - else - { - x.z = static_cast(1.0); - x.x = x.y = static_cast(0.0); - } - } - - u.x = x.x - from.x; u.y = x.y - from.y; u.z = x.z - from.z; - v.x = x.x - to.x; v.y = x.y - to.y; v.z = x.z - to.z; - - const TReal c1 = static_cast(2.0) / (u * u); - const TReal c2 = static_cast(2.0) / (v * v); - const TReal c3 = c1 * c2 * (u * v); - - for (unsigned int i = 0; i < 3; i++) - { - for (unsigned int j = 0; j < 3; j++) - { - mtx[i][j] = - c1 * u[i] * u[j] - c2 * v[i] * v[j] - + c3 * v[i] * u[j]; - } - mtx[i][i] += static_cast(1.0); - } - } - else /* the most common case, unless "from"="to", or "from"=-"to" */ - { - const aiVector3D v = from ^ to; - /* ... use this hand optimized version (9 mults less) */ - const TReal h = static_cast(1.0)/(static_cast(1.0) + e); /* optimization by Gottfried Chen */ - const TReal hvx = h * v.x; - const TReal hvz = h * v.z; - const TReal hvxy = hvx * v.y; - const TReal hvxz = hvx * v.z; - const TReal hvyz = hvz * v.y; - mtx[0][0] = e + hvx * v.x; - mtx[0][1] = hvxy - v.z; - mtx[0][2] = hvxz + v.y; - - mtx[1][0] = hvxy + v.z; - mtx[1][1] = e + h * v.y * v.y; - mtx[1][2] = hvyz - v.x; - - mtx[2][0] = hvxz - v.y; - mtx[2][1] = hvyz + v.x; - mtx[2][2] = e + hvz * v.z; - } - return mtx; -} - - -#endif // __cplusplus -#endif // AI_MATRIX3x3_INL_INC diff --git a/thirdparty/include/assimp/matrix4x4.h b/thirdparty/include/assimp/matrix4x4.h deleted file mode 100644 index fc77b6964..000000000 --- a/thirdparty/include/assimp/matrix4x4.h +++ /dev/null @@ -1,247 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ -/** @file matrix4x4.h - * @brief 4x4 matrix structure, including operators when compiling in C++ - */ -#ifndef AI_MATRIX4X4_H_INC -#define AI_MATRIX4X4_H_INC - -#include "vector3.h" -#include "./Compiler/pushpack1.h" - -#ifdef __cplusplus - -template class aiMatrix3x3t; -template class aiQuaterniont; - -// --------------------------------------------------------------------------- -/** @brief Represents a row-major 4x4 matrix, use this for homogeneous - * coordinates. - * - * There's much confusion about matrix layouts (column vs. row order). - * This is *always* a row-major matrix. Not even with the - * #aiProcess_ConvertToLeftHanded flag, which absolutely does not affect - * matrix order - it just affects the handedness of the coordinate system - * defined thereby. - */ -template -class aiMatrix4x4t -{ -public: - - /** set to identity */ - aiMatrix4x4t (); - - /** construction from single values */ - aiMatrix4x4t ( TReal _a1, TReal _a2, TReal _a3, TReal _a4, - TReal _b1, TReal _b2, TReal _b3, TReal _b4, - TReal _c1, TReal _c2, TReal _c3, TReal _c4, - TReal _d1, TReal _d2, TReal _d3, TReal _d4); - - - /** construction from 3x3 matrix, remaining elements are set to identity */ - explicit aiMatrix4x4t( const aiMatrix3x3t& m); - - /** construction from position, rotation and scaling components - * @param scaling The scaling for the x,y,z axes - * @param rotation The rotation as a hamilton quaternion - * @param position The position for the x,y,z axes - */ - aiMatrix4x4t(const aiVector3t& scaling, const aiQuaterniont& rotation, - const aiVector3t& position); - -public: - - // array access operators - TReal* operator[] (unsigned int p_iIndex); - const TReal* operator[] (unsigned int p_iIndex) const; - - // comparison operators - bool operator== (const aiMatrix4x4t& m) const; - bool operator!= (const aiMatrix4x4t& m) const; - - bool Equal(const aiMatrix4x4t& m, TReal epsilon = 1e-6) const; - - // matrix multiplication. - aiMatrix4x4t& operator *= (const aiMatrix4x4t& m); - aiMatrix4x4t operator * (const aiMatrix4x4t& m) const; - - template - operator aiMatrix4x4t () const; - -public: - - // ------------------------------------------------------------------- - /** @brief Transpose the matrix */ - aiMatrix4x4t& Transpose(); - - // ------------------------------------------------------------------- - /** @brief Invert the matrix. - * If the matrix is not invertible all elements are set to qnan. - * Beware, use (f != f) to check whether a TReal f is qnan. - */ - aiMatrix4x4t& Inverse(); - TReal Determinant() const; - - - // ------------------------------------------------------------------- - /** @brief Returns true of the matrix is the identity matrix. - * The check is performed against a not so small epsilon. - */ - inline bool IsIdentity() const; - - // ------------------------------------------------------------------- - /** @brief Decompose a trafo matrix into its original components - * @param scaling Receives the output scaling for the x,y,z axes - * @param rotation Receives the output rotation as a hamilton - * quaternion - * @param position Receives the output position for the x,y,z axes - */ - void Decompose (aiVector3t& scaling, aiQuaterniont& rotation, - aiVector3t& position) const; - - // ------------------------------------------------------------------- - /** @brief Decompose a trafo matrix with no scaling into its - * original components - * @param rotation Receives the output rotation as a hamilton - * quaternion - * @param position Receives the output position for the x,y,z axes - */ - void DecomposeNoScaling (aiQuaterniont& rotation, - aiVector3t& position) const; - - - // ------------------------------------------------------------------- - /** @brief Creates a trafo matrix from a set of euler angles - * @param x Rotation angle for the x-axis, in radians - * @param y Rotation angle for the y-axis, in radians - * @param z Rotation angle for the z-axis, in radians - */ - aiMatrix4x4t& FromEulerAnglesXYZ(TReal x, TReal y, TReal z); - aiMatrix4x4t& FromEulerAnglesXYZ(const aiVector3t& blubb); - -public: - // ------------------------------------------------------------------- - /** @brief Returns a rotation matrix for a rotation around the x axis - * @param a Rotation angle, in radians - * @param out Receives the output matrix - * @return Reference to the output matrix - */ - static aiMatrix4x4t& RotationX(TReal a, aiMatrix4x4t& out); - - // ------------------------------------------------------------------- - /** @brief Returns a rotation matrix for a rotation around the y axis - * @param a Rotation angle, in radians - * @param out Receives the output matrix - * @return Reference to the output matrix - */ - static aiMatrix4x4t& RotationY(TReal a, aiMatrix4x4t& out); - - // ------------------------------------------------------------------- - /** @brief Returns a rotation matrix for a rotation around the z axis - * @param a Rotation angle, in radians - * @param out Receives the output matrix - * @return Reference to the output matrix - */ - static aiMatrix4x4t& RotationZ(TReal a, aiMatrix4x4t& out); - - // ------------------------------------------------------------------- - /** Returns a rotation matrix for a rotation around an arbitrary axis. - * @param a Rotation angle, in radians - * @param axis Rotation axis, should be a normalized vector. - * @param out Receives the output matrix - * @return Reference to the output matrix - */ - static aiMatrix4x4t& Rotation(TReal a, const aiVector3t& axis, - aiMatrix4x4t& out); - - // ------------------------------------------------------------------- - /** @brief Returns a translation matrix - * @param v Translation vector - * @param out Receives the output matrix - * @return Reference to the output matrix - */ - static aiMatrix4x4t& Translation( const aiVector3t& v, aiMatrix4x4t& out); - - // ------------------------------------------------------------------- - /** @brief Returns a scaling matrix - * @param v Scaling vector - * @param out Receives the output matrix - * @return Reference to the output matrix - */ - static aiMatrix4x4t& Scaling( const aiVector3t& v, aiMatrix4x4t& out); - - // ------------------------------------------------------------------- - /** @brief A function for creating a rotation matrix that rotates a - * vector called "from" into another vector called "to". - * Input : from[3], to[3] which both must be *normalized* non-zero vectors - * Output: mtx[3][3] -- a 3x3 matrix in column-major form - * Authors: Tomas Mueller, John Hughes - * "Efficiently Building a Matrix to Rotate One Vector to Another" - * Journal of Graphics Tools, 4(4):1-4, 1999 - */ - static aiMatrix4x4t& FromToMatrix(const aiVector3t& from, - const aiVector3t& to, aiMatrix4x4t& out); - -public: - TReal a1, a2, a3, a4; - TReal b1, b2, b3, b4; - TReal c1, c2, c3, c4; - TReal d1, d2, d3, d4; -} PACK_STRUCT; - -typedef aiMatrix4x4t aiMatrix4x4; - -#else - -struct aiMatrix4x4 { - float a1, a2, a3, a4; - float b1, b2, b3, b4; - float c1, c2, c3, c4; - float d1, d2, d3, d4; -} PACK_STRUCT; - - -#endif // __cplusplus - -#include "./Compiler/poppack1.h" - -#endif // AI_MATRIX4X4_H_INC diff --git a/thirdparty/include/assimp/matrix4x4.inl b/thirdparty/include/assimp/matrix4x4.inl deleted file mode 100644 index 9ce794f0a..000000000 --- a/thirdparty/include/assimp/matrix4x4.inl +++ /dev/null @@ -1,541 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file matrix4x4.inl - * @brief Inline implementation of the 4x4 matrix operators - */ -#ifndef AI_MATRIX4x4_INL_INC -#define AI_MATRIX4x4_INL_INC - -#ifdef __cplusplus - -#include "matrix4x4.h" -#include "matrix3x3.h" -#include "quaternion.h" - -#include -#include -#include - -// ---------------------------------------------------------------------------------------- -template -aiMatrix4x4t ::aiMatrix4x4t () : - a1(1.0f), a2(), a3(), a4(), - b1(), b2(1.0f), b3(), b4(), - c1(), c2(), c3(1.0f), c4(), - d1(), d2(), d3(), d4(1.0f) -{ - -} - -// ---------------------------------------------------------------------------------------- -template -aiMatrix4x4t ::aiMatrix4x4t (TReal _a1, TReal _a2, TReal _a3, TReal _a4, - TReal _b1, TReal _b2, TReal _b3, TReal _b4, - TReal _c1, TReal _c2, TReal _c3, TReal _c4, - TReal _d1, TReal _d2, TReal _d3, TReal _d4) : - a1(_a1), a2(_a2), a3(_a3), a4(_a4), - b1(_b1), b2(_b2), b3(_b3), b4(_b4), - c1(_c1), c2(_c2), c3(_c3), c4(_c4), - d1(_d1), d2(_d2), d3(_d3), d4(_d4) -{ - -} - -// ------------------------------------------------------------------------------------------------ -template -template -aiMatrix4x4t::operator aiMatrix4x4t () const -{ - return aiMatrix4x4t(static_cast(a1),static_cast(a2),static_cast(a3),static_cast(a4), - static_cast(b1),static_cast(b2),static_cast(b3),static_cast(b4), - static_cast(c1),static_cast(c2),static_cast(c3),static_cast(c4), - static_cast(d1),static_cast(d2),static_cast(d3),static_cast(d4)); -} - - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t::aiMatrix4x4t (const aiMatrix3x3t& m) -{ - a1 = m.a1; a2 = m.a2; a3 = m.a3; a4 = static_cast(0.0); - b1 = m.b1; b2 = m.b2; b3 = m.b3; b4 = static_cast(0.0); - c1 = m.c1; c2 = m.c2; c3 = m.c3; c4 = static_cast(0.0); - d1 = static_cast(0.0); d2 = static_cast(0.0); d3 = static_cast(0.0); d4 = static_cast(1.0); -} - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t::aiMatrix4x4t (const aiVector3t& scaling, const aiQuaterniont& rotation, const aiVector3t& position) -{ - // build a 3x3 rotation matrix - aiMatrix3x3t m = rotation.GetMatrix(); - - a1 = m.a1 * scaling.x; - a2 = m.a2 * scaling.x; - a3 = m.a3 * scaling.x; - a4 = position.x; - - b1 = m.b1 * scaling.y; - b2 = m.b2 * scaling.y; - b3 = m.b3 * scaling.y; - b4 = position.y; - - c1 = m.c1 * scaling.z; - c2 = m.c2 * scaling.z; - c3 = m.c3 * scaling.z; - c4= position.z; - - d1 = static_cast(0.0); - d2 = static_cast(0.0); - d3 = static_cast(0.0); - d4 = static_cast(1.0); -} - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t& aiMatrix4x4t::operator *= (const aiMatrix4x4t& m) -{ - *this = aiMatrix4x4t( - m.a1 * a1 + m.b1 * a2 + m.c1 * a3 + m.d1 * a4, - m.a2 * a1 + m.b2 * a2 + m.c2 * a3 + m.d2 * a4, - m.a3 * a1 + m.b3 * a2 + m.c3 * a3 + m.d3 * a4, - m.a4 * a1 + m.b4 * a2 + m.c4 * a3 + m.d4 * a4, - m.a1 * b1 + m.b1 * b2 + m.c1 * b3 + m.d1 * b4, - m.a2 * b1 + m.b2 * b2 + m.c2 * b3 + m.d2 * b4, - m.a3 * b1 + m.b3 * b2 + m.c3 * b3 + m.d3 * b4, - m.a4 * b1 + m.b4 * b2 + m.c4 * b3 + m.d4 * b4, - m.a1 * c1 + m.b1 * c2 + m.c1 * c3 + m.d1 * c4, - m.a2 * c1 + m.b2 * c2 + m.c2 * c3 + m.d2 * c4, - m.a3 * c1 + m.b3 * c2 + m.c3 * c3 + m.d3 * c4, - m.a4 * c1 + m.b4 * c2 + m.c4 * c3 + m.d4 * c4, - m.a1 * d1 + m.b1 * d2 + m.c1 * d3 + m.d1 * d4, - m.a2 * d1 + m.b2 * d2 + m.c2 * d3 + m.d2 * d4, - m.a3 * d1 + m.b3 * d2 + m.c3 * d3 + m.d3 * d4, - m.a4 * d1 + m.b4 * d2 + m.c4 * d3 + m.d4 * d4); - return *this; -} - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t aiMatrix4x4t::operator* (const aiMatrix4x4t& m) const -{ - aiMatrix4x4t temp( *this); - temp *= m; - return temp; -} - - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t& aiMatrix4x4t::Transpose() -{ - // (TReal&) don't remove, GCC complains cause of packed fields - std::swap( (TReal&)b1, (TReal&)a2); - std::swap( (TReal&)c1, (TReal&)a3); - std::swap( (TReal&)c2, (TReal&)b3); - std::swap( (TReal&)d1, (TReal&)a4); - std::swap( (TReal&)d2, (TReal&)b4); - std::swap( (TReal&)d3, (TReal&)c4); - return *this; -} - - -// ---------------------------------------------------------------------------------------- -template -inline TReal aiMatrix4x4t::Determinant() const -{ - return a1*b2*c3*d4 - a1*b2*c4*d3 + a1*b3*c4*d2 - a1*b3*c2*d4 - + a1*b4*c2*d3 - a1*b4*c3*d2 - a2*b3*c4*d1 + a2*b3*c1*d4 - - a2*b4*c1*d3 + a2*b4*c3*d1 - a2*b1*c3*d4 + a2*b1*c4*d3 - + a3*b4*c1*d2 - a3*b4*c2*d1 + a3*b1*c2*d4 - a3*b1*c4*d2 - + a3*b2*c4*d1 - a3*b2*c1*d4 - a4*b1*c2*d3 + a4*b1*c3*d2 - - a4*b2*c3*d1 + a4*b2*c1*d3 - a4*b3*c1*d2 + a4*b3*c2*d1; -} - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t& aiMatrix4x4t::Inverse() -{ - // Compute the reciprocal determinant - const TReal det = Determinant(); - if(det == static_cast(0.0)) - { - // Matrix not invertible. Setting all elements to nan is not really - // correct in a mathematical sense but it is easy to debug for the - // programmer. - const TReal nan = std::numeric_limits::quiet_NaN(); - *this = aiMatrix4x4t( - nan,nan,nan,nan, - nan,nan,nan,nan, - nan,nan,nan,nan, - nan,nan,nan,nan); - - return *this; - } - - const TReal invdet = static_cast(1.0) / det; - - aiMatrix4x4t res; - res.a1 = invdet * (b2 * (c3 * d4 - c4 * d3) + b3 * (c4 * d2 - c2 * d4) + b4 * (c2 * d3 - c3 * d2)); - res.a2 = -invdet * (a2 * (c3 * d4 - c4 * d3) + a3 * (c4 * d2 - c2 * d4) + a4 * (c2 * d3 - c3 * d2)); - res.a3 = invdet * (a2 * (b3 * d4 - b4 * d3) + a3 * (b4 * d2 - b2 * d4) + a4 * (b2 * d3 - b3 * d2)); - res.a4 = -invdet * (a2 * (b3 * c4 - b4 * c3) + a3 * (b4 * c2 - b2 * c4) + a4 * (b2 * c3 - b3 * c2)); - res.b1 = -invdet * (b1 * (c3 * d4 - c4 * d3) + b3 * (c4 * d1 - c1 * d4) + b4 * (c1 * d3 - c3 * d1)); - res.b2 = invdet * (a1 * (c3 * d4 - c4 * d3) + a3 * (c4 * d1 - c1 * d4) + a4 * (c1 * d3 - c3 * d1)); - res.b3 = -invdet * (a1 * (b3 * d4 - b4 * d3) + a3 * (b4 * d1 - b1 * d4) + a4 * (b1 * d3 - b3 * d1)); - res.b4 = invdet * (a1 * (b3 * c4 - b4 * c3) + a3 * (b4 * c1 - b1 * c4) + a4 * (b1 * c3 - b3 * c1)); - res.c1 = invdet * (b1 * (c2 * d4 - c4 * d2) + b2 * (c4 * d1 - c1 * d4) + b4 * (c1 * d2 - c2 * d1)); - res.c2 = -invdet * (a1 * (c2 * d4 - c4 * d2) + a2 * (c4 * d1 - c1 * d4) + a4 * (c1 * d2 - c2 * d1)); - res.c3 = invdet * (a1 * (b2 * d4 - b4 * d2) + a2 * (b4 * d1 - b1 * d4) + a4 * (b1 * d2 - b2 * d1)); - res.c4 = -invdet * (a1 * (b2 * c4 - b4 * c2) + a2 * (b4 * c1 - b1 * c4) + a4 * (b1 * c2 - b2 * c1)); - res.d1 = -invdet * (b1 * (c2 * d3 - c3 * d2) + b2 * (c3 * d1 - c1 * d3) + b3 * (c1 * d2 - c2 * d1)); - res.d2 = invdet * (a1 * (c2 * d3 - c3 * d2) + a2 * (c3 * d1 - c1 * d3) + a3 * (c1 * d2 - c2 * d1)); - res.d3 = -invdet * (a1 * (b2 * d3 - b3 * d2) + a2 * (b3 * d1 - b1 * d3) + a3 * (b1 * d2 - b2 * d1)); - res.d4 = invdet * (a1 * (b2 * c3 - b3 * c2) + a2 * (b3 * c1 - b1 * c3) + a3 * (b1 * c2 - b2 * c1)); - *this = res; - - return *this; -} - -// ---------------------------------------------------------------------------------------- -template -inline TReal* aiMatrix4x4t::operator[](unsigned int p_iIndex) { - if (p_iIndex > 3) { - return NULL; - } - - // XXX this is UB. Has been for years. The fact that it works now does not make it better. - return &this->a1 + p_iIndex * 4; -} - -// ---------------------------------------------------------------------------------------- -template -inline const TReal* aiMatrix4x4t::operator[](unsigned int p_iIndex) const { - if (p_iIndex > 3) { - return NULL; - } - - // XXX same - return &this->a1 + p_iIndex * 4; -} - -// ---------------------------------------------------------------------------------------- -template -inline bool aiMatrix4x4t::operator== (const aiMatrix4x4t& m) const -{ - return (a1 == m.a1 && a2 == m.a2 && a3 == m.a3 && a4 == m.a4 && - b1 == m.b1 && b2 == m.b2 && b3 == m.b3 && b4 == m.b4 && - c1 == m.c1 && c2 == m.c2 && c3 == m.c3 && c4 == m.c4 && - d1 == m.d1 && d2 == m.d2 && d3 == m.d3 && d4 == m.d4); -} - -// ---------------------------------------------------------------------------------------- -template -inline bool aiMatrix4x4t::operator!= (const aiMatrix4x4t& m) const -{ - return !(*this == m); -} - -// --------------------------------------------------------------------------- -template -inline bool aiMatrix4x4t::Equal(const aiMatrix4x4t& m, TReal epsilon) const { - return - std::abs(a1 - m.a1) <= epsilon && - std::abs(a2 - m.a2) <= epsilon && - std::abs(a3 - m.a3) <= epsilon && - std::abs(a4 - m.a4) <= epsilon && - std::abs(b1 - m.b1) <= epsilon && - std::abs(b2 - m.b2) <= epsilon && - std::abs(b3 - m.b3) <= epsilon && - std::abs(b4 - m.b4) <= epsilon && - std::abs(c1 - m.c1) <= epsilon && - std::abs(c2 - m.c2) <= epsilon && - std::abs(c3 - m.c3) <= epsilon && - std::abs(c4 - m.c4) <= epsilon && - std::abs(d1 - m.d1) <= epsilon && - std::abs(d2 - m.d2) <= epsilon && - std::abs(d3 - m.d3) <= epsilon && - std::abs(d4 - m.d4) <= epsilon; -} - -// ---------------------------------------------------------------------------------------- -template -inline void aiMatrix4x4t::Decompose (aiVector3t& scaling, aiQuaterniont& rotation, - aiVector3t& position) const -{ - const aiMatrix4x4t& _this = *this; - - // extract translation - position.x = _this[0][3]; - position.y = _this[1][3]; - position.z = _this[2][3]; - - // extract the rows of the matrix - aiVector3t vRows[3] = { - aiVector3t(_this[0][0],_this[1][0],_this[2][0]), - aiVector3t(_this[0][1],_this[1][1],_this[2][1]), - aiVector3t(_this[0][2],_this[1][2],_this[2][2]) - }; - - // extract the scaling factors - scaling.x = vRows[0].Length(); - scaling.y = vRows[1].Length(); - scaling.z = vRows[2].Length(); - - // and the sign of the scaling - if (Determinant() < 0) { - scaling.x = -scaling.x; - scaling.y = -scaling.y; - scaling.z = -scaling.z; - } - - // and remove all scaling from the matrix - if(scaling.x) - { - vRows[0] /= scaling.x; - } - if(scaling.y) - { - vRows[1] /= scaling.y; - } - if(scaling.z) - { - vRows[2] /= scaling.z; - } - - // build a 3x3 rotation matrix - aiMatrix3x3t m(vRows[0].x,vRows[1].x,vRows[2].x, - vRows[0].y,vRows[1].y,vRows[2].y, - vRows[0].z,vRows[1].z,vRows[2].z); - - // and generate the rotation quaternion from it - rotation = aiQuaterniont(m); -} - -// ---------------------------------------------------------------------------------------- -template -inline void aiMatrix4x4t::DecomposeNoScaling (aiQuaterniont& rotation, - aiVector3t& position) const -{ - const aiMatrix4x4t& _this = *this; - - // extract translation - position.x = _this[0][3]; - position.y = _this[1][3]; - position.z = _this[2][3]; - - // extract rotation - rotation = aiQuaterniont((aiMatrix3x3t)_this); -} - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t& aiMatrix4x4t::FromEulerAnglesXYZ(const aiVector3t& blubb) -{ - return FromEulerAnglesXYZ(blubb.x,blubb.y,blubb.z); -} - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t& aiMatrix4x4t::FromEulerAnglesXYZ(TReal x, TReal y, TReal z) -{ - aiMatrix4x4t& _this = *this; - - TReal cr = std::cos( x ); - TReal sr = std::sin( x ); - TReal cp = std::cos( y ); - TReal sp = std::sin( y ); - TReal cy = std::cos( z ); - TReal sy = std::sin( z ); - - _this.a1 = cp*cy ; - _this.a2 = cp*sy; - _this.a3 = -sp ; - - TReal srsp = sr*sp; - TReal crsp = cr*sp; - - _this.b1 = srsp*cy-cr*sy ; - _this.b2 = srsp*sy+cr*cy ; - _this.b3 = sr*cp ; - - _this.c1 = crsp*cy+sr*sy ; - _this.c2 = crsp*sy-sr*cy ; - _this.c3 = cr*cp ; - - return *this; -} - -// ---------------------------------------------------------------------------------------- -template -inline bool aiMatrix4x4t::IsIdentity() const -{ - // Use a small epsilon to solve floating-point inaccuracies - const static TReal epsilon = 10e-3f; - - return (a2 <= epsilon && a2 >= -epsilon && - a3 <= epsilon && a3 >= -epsilon && - a4 <= epsilon && a4 >= -epsilon && - b1 <= epsilon && b1 >= -epsilon && - b3 <= epsilon && b3 >= -epsilon && - b4 <= epsilon && b4 >= -epsilon && - c1 <= epsilon && c1 >= -epsilon && - c2 <= epsilon && c2 >= -epsilon && - c4 <= epsilon && c4 >= -epsilon && - d1 <= epsilon && d1 >= -epsilon && - d2 <= epsilon && d2 >= -epsilon && - d3 <= epsilon && d3 >= -epsilon && - a1 <= 1.f+epsilon && a1 >= 1.f-epsilon && - b2 <= 1.f+epsilon && b2 >= 1.f-epsilon && - c3 <= 1.f+epsilon && c3 >= 1.f-epsilon && - d4 <= 1.f+epsilon && d4 >= 1.f-epsilon); -} - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t& aiMatrix4x4t::RotationX(TReal a, aiMatrix4x4t& out) -{ - /* - | 1 0 0 0 | - M = | 0 cos(A) -sin(A) 0 | - | 0 sin(A) cos(A) 0 | - | 0 0 0 1 | */ - out = aiMatrix4x4t(); - out.b2 = out.c3 = std::cos(a); - out.b3 = -(out.c2 = std::sin(a)); - return out; -} - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t& aiMatrix4x4t::RotationY(TReal a, aiMatrix4x4t& out) -{ - /* - | cos(A) 0 sin(A) 0 | - M = | 0 1 0 0 | - | -sin(A) 0 cos(A) 0 | - | 0 0 0 1 | - */ - out = aiMatrix4x4t(); - out.a1 = out.c3 = std::cos(a); - out.c1 = -(out.a3 = std::sin(a)); - return out; -} - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t& aiMatrix4x4t::RotationZ(TReal a, aiMatrix4x4t& out) -{ - /* - | cos(A) -sin(A) 0 0 | - M = | sin(A) cos(A) 0 0 | - | 0 0 1 0 | - | 0 0 0 1 | */ - out = aiMatrix4x4t(); - out.a1 = out.b2 = std::cos(a); - out.a2 = -(out.b1 = std::sin(a)); - return out; -} - -// ---------------------------------------------------------------------------------------- -// Returns a rotation matrix for a rotation around an arbitrary axis. -template -inline aiMatrix4x4t& aiMatrix4x4t::Rotation( TReal a, const aiVector3t& axis, aiMatrix4x4t& out) -{ - TReal c = std::cos( a), s = std::sin( a), t = 1 - c; - TReal x = axis.x, y = axis.y, z = axis.z; - - // Many thanks to MathWorld and Wikipedia - out.a1 = t*x*x + c; out.a2 = t*x*y - s*z; out.a3 = t*x*z + s*y; - out.b1 = t*x*y + s*z; out.b2 = t*y*y + c; out.b3 = t*y*z - s*x; - out.c1 = t*x*z - s*y; out.c2 = t*y*z + s*x; out.c3 = t*z*z + c; - out.a4 = out.b4 = out.c4 = static_cast(0.0); - out.d1 = out.d2 = out.d3 = static_cast(0.0); - out.d4 = static_cast(1.0); - - return out; -} - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t& aiMatrix4x4t::Translation( const aiVector3t& v, aiMatrix4x4t& out) -{ - out = aiMatrix4x4t(); - out.a4 = v.x; - out.b4 = v.y; - out.c4 = v.z; - return out; -} - -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t& aiMatrix4x4t::Scaling( const aiVector3t& v, aiMatrix4x4t& out) -{ - out = aiMatrix4x4t(); - out.a1 = v.x; - out.b2 = v.y; - out.c3 = v.z; - return out; -} - -// ---------------------------------------------------------------------------------------- -/** A function for creating a rotation matrix that rotates a vector called - * "from" into another vector called "to". - * Input : from[3], to[3] which both must be *normalized* non-zero vectors - * Output: mtx[3][3] -- a 3x3 matrix in colum-major form - * Authors: Tomas M�ller, John Hughes - * "Efficiently Building a Matrix to Rotate One Vector to Another" - * Journal of Graphics Tools, 4(4):1-4, 1999 - */ -// ---------------------------------------------------------------------------------------- -template -inline aiMatrix4x4t& aiMatrix4x4t::FromToMatrix(const aiVector3t& from, - const aiVector3t& to, aiMatrix4x4t& mtx) -{ - aiMatrix3x3t m3; - aiMatrix3x3t::FromToMatrix(from,to,m3); - mtx = aiMatrix4x4t(m3); - return mtx; -} - -#endif // __cplusplus -#endif // AI_MATRIX4x4_INL_INC diff --git a/thirdparty/include/assimp/mesh.h b/thirdparty/include/assimp/mesh.h deleted file mode 100644 index a76a2d72b..000000000 --- a/thirdparty/include/assimp/mesh.h +++ /dev/null @@ -1,740 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file mesh.h - * @brief Declares the data structures in which the imported geometry is - returned by ASSIMP: aiMesh, aiFace and aiBone data structures. - */ -#ifndef INCLUDED_AI_MESH_H -#define INCLUDED_AI_MESH_H - -#include "types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// --------------------------------------------------------------------------- -// Limits. These values are required to match the settings Assimp was -// compiled against. Therfore, do not redefine them unless you build the -// library from source using the same definitions. -// --------------------------------------------------------------------------- - -/** @def AI_MAX_FACE_INDICES - * Maximum number of indices per face (polygon). */ - -#ifndef AI_MAX_FACE_INDICES -# define AI_MAX_FACE_INDICES 0x7fff -#endif - -/** @def AI_MAX_BONE_WEIGHTS - * Maximum number of indices per face (polygon). */ - -#ifndef AI_MAX_BONE_WEIGHTS -# define AI_MAX_BONE_WEIGHTS 0x7fffffff -#endif - -/** @def AI_MAX_VERTICES - * Maximum number of vertices per mesh. */ - -#ifndef AI_MAX_VERTICES -# define AI_MAX_VERTICES 0x7fffffff -#endif - -/** @def AI_MAX_FACES - * Maximum number of faces per mesh. */ - -#ifndef AI_MAX_FACES -# define AI_MAX_FACES 0x7fffffff -#endif - -/** @def AI_MAX_NUMBER_OF_COLOR_SETS - * Supported number of vertex color sets per mesh. */ - -#ifndef AI_MAX_NUMBER_OF_COLOR_SETS -# define AI_MAX_NUMBER_OF_COLOR_SETS 0x8 -#endif // !! AI_MAX_NUMBER_OF_COLOR_SETS - -/** @def AI_MAX_NUMBER_OF_TEXTURECOORDS - * Supported number of texture coord sets (UV(W) channels) per mesh */ - -#ifndef AI_MAX_NUMBER_OF_TEXTURECOORDS -# define AI_MAX_NUMBER_OF_TEXTURECOORDS 0x8 -#endif // !! AI_MAX_NUMBER_OF_TEXTURECOORDS - -// --------------------------------------------------------------------------- -/** @brief A single face in a mesh, referring to multiple vertices. - * - * If mNumIndices is 3, we call the face 'triangle', for mNumIndices > 3 - * it's called 'polygon' (hey, that's just a definition!). - *
- * aiMesh::mPrimitiveTypes can be queried to quickly examine which types of - * primitive are actually present in a mesh. The #aiProcess_SortByPType flag - * executes a special post-processing algorithm which splits meshes with - * *different* primitive types mixed up (e.g. lines and triangles) in several - * 'clean' submeshes. Furthermore there is a configuration option ( - * #AI_CONFIG_PP_SBP_REMOVE) to force #aiProcess_SortByPType to remove - * specific kinds of primitives from the imported scene, completely and forever. - * In many cases you'll probably want to set this setting to - * @code - * aiPrimitiveType_LINE|aiPrimitiveType_POINT - * @endcode - * Together with the #aiProcess_Triangulate flag you can then be sure that - * #aiFace::mNumIndices is always 3. - * @note Take a look at the @link data Data Structures page @endlink for - * more information on the layout and winding order of a face. - */ -struct aiFace -{ - //! Number of indices defining this face. - //! The maximum value for this member is #AI_MAX_FACE_INDICES. - unsigned int mNumIndices; - - //! Pointer to the indices array. Size of the array is given in numIndices. - unsigned int* mIndices; - -#ifdef __cplusplus - - //! Default constructor - aiFace() - : mNumIndices( 0 ) - , mIndices( NULL ) - { - } - - //! Default destructor. Delete the index array - ~aiFace() - { - delete [] mIndices; - } - - //! Copy constructor. Copy the index array - aiFace( const aiFace& o) - : mIndices( NULL ) - { - *this = o; - } - - //! Assignment operator. Copy the index array - aiFace& operator = ( const aiFace& o) - { - if (&o == this) - return *this; - - delete[] mIndices; - mNumIndices = o.mNumIndices; - if (mNumIndices) { - mIndices = new unsigned int[mNumIndices]; - ::memcpy( mIndices, o.mIndices, mNumIndices * sizeof( unsigned int)); - } - else { - mIndices = NULL; - } - return *this; - } - - //! Comparison operator. Checks whether the index array - //! of two faces is identical - bool operator== (const aiFace& o) const - { - if (mIndices == o.mIndices)return true; - else if (mIndices && mNumIndices == o.mNumIndices) - { - for (unsigned int i = 0;i < this->mNumIndices;++i) - if (mIndices[i] != o.mIndices[i])return false; - return true; - } - return false; - } - - //! Inverse comparison operator. Checks whether the index - //! array of two faces is NOT identical - bool operator != (const aiFace& o) const - { - return !(*this == o); - } -#endif // __cplusplus -}; // struct aiFace - - -// --------------------------------------------------------------------------- -/** @brief A single influence of a bone on a vertex. - */ -struct aiVertexWeight -{ - //! Index of the vertex which is influenced by the bone. - unsigned int mVertexId; - - //! The strength of the influence in the range (0...1). - //! The influence from all bones at one vertex amounts to 1. - float mWeight; - -#ifdef __cplusplus - - //! Default constructor - aiVertexWeight() { } - - //! Initialisation from a given index and vertex weight factor - //! \param pID ID - //! \param pWeight Vertex weight factor - aiVertexWeight( unsigned int pID, float pWeight) - : mVertexId( pID), mWeight( pWeight) - { /* nothing to do here */ } - -#endif // __cplusplus -}; - - -// --------------------------------------------------------------------------- -/** @brief A single bone of a mesh. - * - * A bone has a name by which it can be found in the frame hierarchy and by - * which it can be addressed by animations. In addition it has a number of - * influences on vertices. - */ -struct aiBone -{ - //! The name of the bone. - C_STRUCT aiString mName; - - //! The number of vertices affected by this bone - //! The maximum value for this member is #AI_MAX_BONE_WEIGHTS. - unsigned int mNumWeights; - - //! The vertices affected by this bone - C_STRUCT aiVertexWeight* mWeights; - - //! Matrix that transforms from mesh space to bone space in bind pose - C_STRUCT aiMatrix4x4 mOffsetMatrix; - -#ifdef __cplusplus - - //! Default constructor - aiBone() - : mName() - , mNumWeights( 0 ) - , mWeights( NULL ) - { - } - - //! Copy constructor - aiBone(const aiBone& other) - : mName( other.mName ) - , mNumWeights( other.mNumWeights ) - , mOffsetMatrix( other.mOffsetMatrix ) - { - if (other.mWeights && other.mNumWeights) - { - mWeights = new aiVertexWeight[mNumWeights]; - ::memcpy(mWeights,other.mWeights,mNumWeights * sizeof(aiVertexWeight)); - } - } - - //! Destructor - deletes the array of vertex weights - ~aiBone() - { - delete [] mWeights; - } -#endif // __cplusplus -}; - - -// --------------------------------------------------------------------------- -/** @brief Enumerates the types of geometric primitives supported by Assimp. - * - * @see aiFace Face data structure - * @see aiProcess_SortByPType Per-primitive sorting of meshes - * @see aiProcess_Triangulate Automatic triangulation - * @see AI_CONFIG_PP_SBP_REMOVE Removal of specific primitive types. - */ -enum aiPrimitiveType -{ - /** A point primitive. - * - * This is just a single vertex in the virtual world, - * #aiFace contains just one index for such a primitive. - */ - aiPrimitiveType_POINT = 0x1, - - /** A line primitive. - * - * This is a line defined through a start and an end position. - * #aiFace contains exactly two indices for such a primitive. - */ - aiPrimitiveType_LINE = 0x2, - - /** A triangular primitive. - * - * A triangle consists of three indices. - */ - aiPrimitiveType_TRIANGLE = 0x4, - - /** A higher-level polygon with more than 3 edges. - * - * A triangle is a polygon, but polygon in this context means - * "all polygons that are not triangles". The "Triangulate"-Step - * is provided for your convenience, it splits all polygons in - * triangles (which are much easier to handle). - */ - aiPrimitiveType_POLYGON = 0x8, - - - /** This value is not used. It is just here to force the - * compiler to map this enum to a 32 Bit integer. - */ -#ifndef SWIG - _aiPrimitiveType_Force32Bit = INT_MAX -#endif -}; //! enum aiPrimitiveType - -// Get the #aiPrimitiveType flag for a specific number of face indices -#define AI_PRIMITIVE_TYPE_FOR_N_INDICES(n) \ - ((n) > 3 ? aiPrimitiveType_POLYGON : (aiPrimitiveType)(1u << ((n)-1))) - - - -// --------------------------------------------------------------------------- -/** @brief NOT CURRENTLY IN USE. An AnimMesh is an attachment to an #aiMesh stores per-vertex - * animations for a particular frame. - * - * You may think of an #aiAnimMesh as a `patch` for the host mesh, which - * replaces only certain vertex data streams at a particular time. - * Each mesh stores n attached attached meshes (#aiMesh::mAnimMeshes). - * The actual relationship between the time line and anim meshes is - * established by #aiMeshAnim, which references singular mesh attachments - * by their ID and binds them to a time offset. -*/ -struct aiAnimMesh -{ - /** Replacement for aiMesh::mVertices. If this array is non-NULL, - * it *must* contain mNumVertices entries. The corresponding - * array in the host mesh must be non-NULL as well - animation - * meshes may neither add or nor remove vertex components (if - * a replacement array is NULL and the corresponding source - * array is not, the source data is taken instead)*/ - C_STRUCT aiVector3D* mVertices; - - /** Replacement for aiMesh::mNormals. */ - C_STRUCT aiVector3D* mNormals; - - /** Replacement for aiMesh::mTangents. */ - C_STRUCT aiVector3D* mTangents; - - /** Replacement for aiMesh::mBitangents. */ - C_STRUCT aiVector3D* mBitangents; - - /** Replacement for aiMesh::mColors */ - C_STRUCT aiColor4D* mColors[AI_MAX_NUMBER_OF_COLOR_SETS]; - - /** Replacement for aiMesh::mTextureCoords */ - C_STRUCT aiVector3D* mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS]; - - /** The number of vertices in the aiAnimMesh, and thus the length of all - * the member arrays. - * - * This has always the same value as the mNumVertices property in the - * corresponding aiMesh. It is duplicated here merely to make the length - * of the member arrays accessible even if the aiMesh is not known, e.g. - * from language bindings. - */ - unsigned int mNumVertices; - -#ifdef __cplusplus - - aiAnimMesh() - : mVertices( NULL ) - , mNormals( NULL ) - , mTangents( NULL ) - , mBitangents( NULL ) - , mNumVertices( 0 ) - { - // fixme consider moving this to the ctor initializer list as well - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++){ - mTextureCoords[a] = NULL; - } - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) { - mColors[a] = NULL; - } - } - - ~aiAnimMesh() - { - delete [] mVertices; - delete [] mNormals; - delete [] mTangents; - delete [] mBitangents; - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) { - delete [] mTextureCoords[a]; - } - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) { - delete [] mColors[a]; - } - } - - /** Check whether the anim mesh overrides the vertex positions - * of its host mesh*/ - bool HasPositions() const { - return mVertices != NULL; - } - - /** Check whether the anim mesh overrides the vertex normals - * of its host mesh*/ - bool HasNormals() const { - return mNormals != NULL; - } - - /** Check whether the anim mesh overrides the vertex tangents - * and bitangents of its host mesh. As for aiMesh, - * tangents and bitangents always go together. */ - bool HasTangentsAndBitangents() const { - return mTangents != NULL; - } - - /** Check whether the anim mesh overrides a particular - * set of vertex colors on his host mesh. - * @param pIndex 0= AI_MAX_NUMBER_OF_COLOR_SETS ? false : mColors[pIndex] != NULL; - } - - /** Check whether the anim mesh overrides a particular - * set of texture coordinates on his host mesh. - * @param pIndex 0= AI_MAX_NUMBER_OF_TEXTURECOORDS ? false : mTextureCoords[pIndex] != NULL; - } - -#endif -}; - - -// --------------------------------------------------------------------------- -/** @brief A mesh represents a geometry or model with a single material. -* -* It usually consists of a number of vertices and a series of primitives/faces -* referencing the vertices. In addition there might be a series of bones, each -* of them addressing a number of vertices with a certain weight. Vertex data -* is presented in channels with each channel containing a single per-vertex -* information such as a set of texture coords or a normal vector. -* If a data pointer is non-null, the corresponding data stream is present. -* From C++-programs you can also use the comfort functions Has*() to -* test for the presence of various data streams. -* -* A Mesh uses only a single material which is referenced by a material ID. -* @note The mPositions member is usually not optional. However, vertex positions -* *could* be missing if the #AI_SCENE_FLAGS_INCOMPLETE flag is set in -* @code -* aiScene::mFlags -* @endcode -*/ -struct aiMesh -{ - /** Bitwise combination of the members of the #aiPrimitiveType enum. - * This specifies which types of primitives are present in the mesh. - * The "SortByPrimitiveType"-Step can be used to make sure the - * output meshes consist of one primitive type each. - */ - unsigned int mPrimitiveTypes; - - /** The number of vertices in this mesh. - * This is also the size of all of the per-vertex data arrays. - * The maximum value for this member is #AI_MAX_VERTICES. - */ - unsigned int mNumVertices; - - /** The number of primitives (triangles, polygons, lines) in this mesh. - * This is also the size of the mFaces array. - * The maximum value for this member is #AI_MAX_FACES. - */ - unsigned int mNumFaces; - - /** Vertex positions. - * This array is always present in a mesh. The array is - * mNumVertices in size. - */ - C_STRUCT aiVector3D* mVertices; - - /** Vertex normals. - * The array contains normalized vectors, NULL if not present. - * The array is mNumVertices in size. Normals are undefined for - * point and line primitives. A mesh consisting of points and - * lines only may not have normal vectors. Meshes with mixed - * primitive types (i.e. lines and triangles) may have normals, - * but the normals for vertices that are only referenced by - * point or line primitives are undefined and set to QNaN (WARN: - * qNaN compares to inequal to *everything*, even to qNaN itself. - * Using code like this to check whether a field is qnan is: - * @code - * #define IS_QNAN(f) (f != f) - * @endcode - * still dangerous because even 1.f == 1.f could evaluate to false! ( - * remember the subtleties of IEEE754 artithmetics). Use stuff like - * @c fpclassify instead. - * @note Normal vectors computed by Assimp are always unit-length. - * However, this needn't apply for normals that have been taken - * directly from the model file. - */ - C_STRUCT aiVector3D* mNormals; - - /** Vertex tangents. - * The tangent of a vertex points in the direction of the positive - * X texture axis. The array contains normalized vectors, NULL if - * not present. The array is mNumVertices in size. A mesh consisting - * of points and lines only may not have normal vectors. Meshes with - * mixed primitive types (i.e. lines and triangles) may have - * normals, but the normals for vertices that are only referenced by - * point or line primitives are undefined and set to qNaN. See - * the #mNormals member for a detailed discussion of qNaNs. - * @note If the mesh contains tangents, it automatically also - * contains bitangents. - */ - C_STRUCT aiVector3D* mTangents; - - /** Vertex bitangents. - * The bitangent of a vertex points in the direction of the positive - * Y texture axis. The array contains normalized vectors, NULL if not - * present. The array is mNumVertices in size. - * @note If the mesh contains tangents, it automatically also contains - * bitangents. - */ - C_STRUCT aiVector3D* mBitangents; - - /** Vertex color sets. - * A mesh may contain 0 to #AI_MAX_NUMBER_OF_COLOR_SETS vertex - * colors per vertex. NULL if not present. Each array is - * mNumVertices in size if present. - */ - C_STRUCT aiColor4D* mColors[AI_MAX_NUMBER_OF_COLOR_SETS]; - - /** Vertex texture coords, also known as UV channels. - * A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per - * vertex. NULL if not present. The array is mNumVertices in size. - */ - C_STRUCT aiVector3D* mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS]; - - /** Specifies the number of components for a given UV channel. - * Up to three channels are supported (UVW, for accessing volume - * or cube maps). If the value is 2 for a given channel n, the - * component p.z of mTextureCoords[n][p] is set to 0.0f. - * If the value is 1 for a given channel, p.y is set to 0.0f, too. - * @note 4D coords are not supported - */ - unsigned int mNumUVComponents[AI_MAX_NUMBER_OF_TEXTURECOORDS]; - - /** The faces the mesh is constructed from. - * Each face refers to a number of vertices by their indices. - * This array is always present in a mesh, its size is given - * in mNumFaces. If the #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT - * is NOT set each face references an unique set of vertices. - */ - C_STRUCT aiFace* mFaces; - - /** The number of bones this mesh contains. - * Can be 0, in which case the mBones array is NULL. - */ - unsigned int mNumBones; - - /** The bones of this mesh. - * A bone consists of a name by which it can be found in the - * frame hierarchy and a set of vertex weights. - */ - C_STRUCT aiBone** mBones; - - /** The material used by this mesh. - * A mesh uses only a single material. If an imported model uses - * multiple materials, the import splits up the mesh. Use this value - * as index into the scene's material list. - */ - unsigned int mMaterialIndex; - - /** Name of the mesh. Meshes can be named, but this is not a - * requirement and leaving this field empty is totally fine. - * There are mainly three uses for mesh names: - * - some formats name nodes and meshes independently. - * - importers tend to split meshes up to meet the - * one-material-per-mesh requirement. Assigning - * the same (dummy) name to each of the result meshes - * aids the caller at recovering the original mesh - * partitioning. - * - Vertex animations refer to meshes by their names. - **/ - C_STRUCT aiString mName; - - - /** NOT CURRENTLY IN USE. The number of attachment meshes */ - unsigned int mNumAnimMeshes; - - /** NOT CURRENTLY IN USE. Attachment meshes for this mesh, for vertex-based animation. - * Attachment meshes carry replacement data for some of the - * mesh'es vertex components (usually positions, normals). */ - C_STRUCT aiAnimMesh** mAnimMeshes; - - -#ifdef __cplusplus - - //! Default constructor. Initializes all members to 0 - aiMesh() - : mPrimitiveTypes( 0 ) - , mNumVertices( 0 ) - , mNumFaces( 0 ) - , mVertices( NULL ) - , mNormals( NULL ) - , mTangents( NULL ) - , mBitangents( NULL ) - , mFaces( NULL ) - , mNumBones( 0 ) - , mBones( NULL ) - , mMaterialIndex( 0 ) - , mNumAnimMeshes( 0 ) - , mAnimMeshes( NULL ) - { - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) - { - mNumUVComponents[a] = 0; - mTextureCoords[a] = NULL; - } - - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) - mColors[a] = NULL; - } - - //! Deletes all storage allocated for the mesh - ~aiMesh() - { - delete [] mVertices; - delete [] mNormals; - delete [] mTangents; - delete [] mBitangents; - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; a++) { - delete [] mTextureCoords[a]; - } - for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++) { - delete [] mColors[a]; - } - - // DO NOT REMOVE THIS ADDITIONAL CHECK - if (mNumBones && mBones) { - for( unsigned int a = 0; a < mNumBones; a++) { - delete mBones[a]; - } - delete [] mBones; - } - - if (mNumAnimMeshes && mAnimMeshes) { - for( unsigned int a = 0; a < mNumAnimMeshes; a++) { - delete mAnimMeshes[a]; - } - delete [] mAnimMeshes; - } - - delete [] mFaces; - } - - //! Check whether the mesh contains positions. Provided no special - //! scene flags are set, this will always be true - bool HasPositions() const - { return mVertices != NULL && mNumVertices > 0; } - - //! Check whether the mesh contains faces. If no special scene flags - //! are set this should always return true - bool HasFaces() const - { return mFaces != NULL && mNumFaces > 0; } - - //! Check whether the mesh contains normal vectors - bool HasNormals() const - { return mNormals != NULL && mNumVertices > 0; } - - //! Check whether the mesh contains tangent and bitangent vectors - //! It is not possible that it contains tangents and no bitangents - //! (or the other way round). The existence of one of them - //! implies that the second is there, too. - bool HasTangentsAndBitangents() const - { return mTangents != NULL && mBitangents != NULL && mNumVertices > 0; } - - //! Check whether the mesh contains a vertex color set - //! \param pIndex Index of the vertex color set - bool HasVertexColors( unsigned int pIndex) const - { - if( pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS) - return false; - else - return mColors[pIndex] != NULL && mNumVertices > 0; - } - - //! Check whether the mesh contains a texture coordinate set - //! \param pIndex Index of the texture coordinates set - bool HasTextureCoords( unsigned int pIndex) const - { - if( pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS) - return false; - else - return mTextureCoords[pIndex] != NULL && mNumVertices > 0; - } - - //! Get the number of UV channels the mesh contains - unsigned int GetNumUVChannels() const - { - unsigned int n = 0; - while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && mTextureCoords[n])++n; - return n; - } - - //! Get the number of vertex color channels the mesh contains - unsigned int GetNumColorChannels() const - { - unsigned int n = 0; - while (n < AI_MAX_NUMBER_OF_COLOR_SETS && mColors[n])++n; - return n; - } - - //! Check whether the mesh contains bones - inline bool HasBones() const - { return mBones != NULL && mNumBones > 0; } - -#endif // __cplusplus -}; - - -#ifdef __cplusplus -} -#endif //! extern "C" -#endif // __AI_MESH_H_INC - diff --git a/thirdparty/include/assimp/metadata.h b/thirdparty/include/assimp/metadata.h deleted file mode 100644 index 814d89272..000000000 --- a/thirdparty/include/assimp/metadata.h +++ /dev/null @@ -1,251 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file metadata.h - * @brief Defines the data structures for holding node meta information. - */ -#ifndef __AI_METADATA_H_INC__ -#define __AI_METADATA_H_INC__ - -#include - -#if defined(_MSC_VER) && (_MSC_VER <= 1500) -#include "Compiler/pstdint.h" -#else -#include -#include -#endif - - - -// ------------------------------------------------------------------------------- -/** - * Enum used to distinguish data types - */ - // ------------------------------------------------------------------------------- -typedef enum aiMetadataType -{ - AI_BOOL = 0, - AI_INT = 1, - AI_UINT64 = 2, - AI_FLOAT = 3, - AI_AISTRING = 4, - AI_AIVECTOR3D = 5, - -#ifndef SWIG - FORCE_32BIT = INT_MAX -#endif -} aiMetadataType; - - - -// ------------------------------------------------------------------------------- -/** - * Metadata entry - * - * The type field uniquely identifies the underlying type of the data field - */ - // ------------------------------------------------------------------------------- -struct aiMetadataEntry -{ - aiMetadataType mType; - void* mData; -}; - - - -#ifdef __cplusplus - -#include - - - -// ------------------------------------------------------------------------------- -/** - * Helper functions to get the aiType enum entry for a type - */ - // ------------------------------------------------------------------------------- -inline aiMetadataType GetAiType( bool ) { return AI_BOOL; } -inline aiMetadataType GetAiType( int ) { return AI_INT; } -inline aiMetadataType GetAiType( uint64_t ) { return AI_UINT64; } -inline aiMetadataType GetAiType( float ) { return AI_FLOAT; } -inline aiMetadataType GetAiType( aiString ) { return AI_AISTRING; } -inline aiMetadataType GetAiType( aiVector3D ) { return AI_AIVECTOR3D; } - - - -#endif - - - -// ------------------------------------------------------------------------------- -/** - * Container for holding metadata. - * - * Metadata is a key-value store using string keys and values. - */ - // ------------------------------------------------------------------------------- -struct aiMetadata -{ - /** Length of the mKeys and mValues arrays, respectively */ - unsigned int mNumProperties; - - /** Arrays of keys, may not be NULL. Entries in this array may not be NULL as well. */ - C_STRUCT aiString* mKeys; - - /** Arrays of values, may not be NULL. Entries in this array may be NULL if the - * corresponding property key has no assigned value. */ - C_STRUCT aiMetadataEntry* mValues; - -#ifdef __cplusplus - - /** Constructor */ - aiMetadata() - // set all members to zero by default - : mNumProperties(0) - , mKeys(NULL) - , mValues(NULL) - {} - - - /** Destructor */ - ~aiMetadata() - { - delete[] mKeys; - mKeys = NULL; - if (mValues) - { - // Delete each metadata entry - for (unsigned i=0; i(data); - break; - case AI_INT: - delete static_cast(data); - break; - case AI_UINT64: - delete static_cast(data); - break; - case AI_FLOAT: - delete static_cast(data); - break; - case AI_AISTRING: - delete static_cast(data); - break; - case AI_AIVECTOR3D: - delete static_cast(data); - break; -#ifndef SWIG - case FORCE_32BIT: -#endif - default: - assert(false); - break; - } - } - - // Delete the metadata array - delete [] mValues; - mValues = NULL; - } - } - - - - template - inline void Set( unsigned index, const std::string& key, const T& value ) - { - // In range assertion - assert(index < mNumProperties); - - // Set metadata key - mKeys[index] = key; - - // Set metadata type - mValues[index].mType = GetAiType(value); - // Copy the given value to the dynamic storage - mValues[index].mData = new T(value); - } - - template - inline bool Get( unsigned index, T& value ) - { - // In range assertion - assert(index < mNumProperties); - - // Return false if the output data type does - // not match the found value's data type - if ( GetAiType( value ) != mValues[ index ].mType ) { - return false; - } - - // Otherwise, output the found value and - // return true - value = *static_cast(mValues[index].mData); - return true; - } - - template - inline bool Get( const aiString& key, T& value ) - { - // Search for the given key - for (unsigned i=0; i - inline bool Get( const std::string& key, T& value ) { - return Get(aiString(key), value); - } - -#endif // __cplusplus - -}; - -#endif // __AI_METADATA_H_INC__ - - diff --git a/thirdparty/include/assimp/port/AndroidJNI/AndroidJNIIOSystem.h b/thirdparty/include/assimp/port/AndroidJNI/AndroidJNIIOSystem.h deleted file mode 100644 index 6f806f922..000000000 --- a/thirdparty/include/assimp/port/AndroidJNI/AndroidJNIIOSystem.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file Android implementation of IOSystem using the standard C file functions. - * Aimed to ease the access to android assets */ - -#if __ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT) -#ifndef AI_ANDROIDJNIIOSYSTEM_H_INC -#define AI_ANDROIDJNIIOSYSTEM_H_INC - -#include "../code/DefaultIOSystem.h" -#include -#include -#include - -namespace Assimp { - -// --------------------------------------------------------------------------- -/** Android extension to DefaultIOSystem using the standard C file functions */ -class ASSIMP_API AndroidJNIIOSystem : public DefaultIOSystem -{ -public: - - /** Initialize android activity data */ - std::string mApkWorkspacePath; - AAssetManager* mApkAssetManager; - - /** Constructor. */ - AndroidJNIIOSystem(ANativeActivity* activity); - - /** Destructor. */ - ~AndroidJNIIOSystem(); - - // ------------------------------------------------------------------- - /** Tests for the existence of a file at the given path. */ - bool Exists( const char* pFile) const; - - // ------------------------------------------------------------------- - /** Opens a file at the given path, with given mode */ - IOStream* Open( const char* strFile, const char* strMode); - - // ------------------------------------------------------------------------------------------------ - // Inits Android extractor - void AndroidActivityInit(ANativeActivity* activity); - - // ------------------------------------------------------------------------------------------------ - // Extracts android asset - bool AndroidExtractAsset(std::string name); - -}; - -} //!ns Assimp - -#endif //AI_ANDROIDJNIIOSYSTEM_H_INC -#endif //__ANDROID__ and __ANDROID_API__ > 9 and defined(AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT) diff --git a/thirdparty/include/assimp/postprocess.h b/thirdparty/include/assimp/postprocess.h deleted file mode 100644 index 04de7a275..000000000 --- a/thirdparty/include/assimp/postprocess.h +++ /dev/null @@ -1,633 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file postprocess.h - * @brief Definitions for import post processing steps - */ -#ifndef AI_POSTPROCESS_H_INC -#define AI_POSTPROCESS_H_INC - -#include "types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// ----------------------------------------------------------------------------------- -/** @enum aiPostProcessSteps - * @brief Defines the flags for all possible post processing steps. - * - * @note Some steps are influenced by properties set on the Assimp::Importer itself - * - * @see Assimp::Importer::ReadFile() - * @see Assimp::Importer::SetPropertyInteger() - * @see aiImportFile - * @see aiImportFileEx - */ -// ----------------------------------------------------------------------------------- -enum aiPostProcessSteps -{ - - // ------------------------------------------------------------------------- - /**
Calculates the tangents and bitangents for the imported meshes. - * - * Does nothing if a mesh does not have normals. You might want this post - * processing step to be executed if you plan to use tangent space calculations - * such as normal mapping applied to the meshes. There's an importer property, - * #AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE, which allows you to specify - * a maximum smoothing angle for the algorithm. However, usually you'll - * want to leave it at the default value. - */ - aiProcess_CalcTangentSpace = 0x1, - - // ------------------------------------------------------------------------- - /**
Identifies and joins identical vertex data sets within all - * imported meshes. - * - * After this step is run, each mesh contains unique vertices, - * so a vertex may be used by multiple faces. You usually want - * to use this post processing step. If your application deals with - * indexed geometry, this step is compulsory or you'll just waste rendering - * time. If this flag is not specified, no vertices are referenced by - * more than one face and no index buffer is required for rendering. - */ - aiProcess_JoinIdenticalVertices = 0x2, - - // ------------------------------------------------------------------------- - /**
Converts all the imported data to a left-handed coordinate space. - * - * By default the data is returned in a right-handed coordinate space (which - * OpenGL prefers). In this space, +X points to the right, - * +Z points towards the viewer, and +Y points upwards. In the DirectX - * coordinate space +X points to the right, +Y points upwards, and +Z points - * away from the viewer. - * - * You'll probably want to consider this flag if you use Direct3D for - * rendering. The #aiProcess_ConvertToLeftHanded flag supersedes this - * setting and bundles all conversions typically required for D3D-based - * applications. - */ - aiProcess_MakeLeftHanded = 0x4, - - // ------------------------------------------------------------------------- - /**
Triangulates all faces of all meshes. - * - * By default the imported mesh data might contain faces with more than 3 - * indices. For rendering you'll usually want all faces to be triangles. - * This post processing step splits up faces with more than 3 indices into - * triangles. Line and point primitives are *not* modified! If you want - * 'triangles only' with no other kinds of primitives, try the following - * solution: - *
    - *
  • Specify both #aiProcess_Triangulate and #aiProcess_SortByPType
  • - *
  • Ignore all point and line meshes when you process assimp's output
  • - *
- */ - aiProcess_Triangulate = 0x8, - - // ------------------------------------------------------------------------- - /**
Removes some parts of the data structure (animations, materials, - * light sources, cameras, textures, vertex components). - * - * The components to be removed are specified in a separate - * importer property, #AI_CONFIG_PP_RVC_FLAGS. This is quite useful - * if you don't need all parts of the output structure. Vertex colors - * are rarely used today for example... Calling this step to remove unneeded - * data from the pipeline as early as possible results in increased - * performance and a more optimized output data structure. - * This step is also useful if you want to force Assimp to recompute - * normals or tangents. The corresponding steps don't recompute them if - * they're already there (loaded from the source asset). By using this - * step you can make sure they are NOT there. - * - * This flag is a poor one, mainly because its purpose is usually - * misunderstood. Consider the following case: a 3D model has been exported - * from a CAD app, and it has per-face vertex colors. Vertex positions can't be - * shared, thus the #aiProcess_JoinIdenticalVertices step fails to - * optimize the data because of these nasty little vertex colors. - * Most apps don't even process them, so it's all for nothing. By using - * this step, unneeded components are excluded as early as possible - * thus opening more room for internal optimizations. - */ - aiProcess_RemoveComponent = 0x10, - - // ------------------------------------------------------------------------- - /**
Generates normals for all faces of all meshes. - * - * This is ignored if normals are already there at the time this flag - * is evaluated. Model importers try to load them from the source file, so - * they're usually already there. Face normals are shared between all points - * of a single face, so a single point can have multiple normals, which - * forces the library to duplicate vertices in some cases. - * #aiProcess_JoinIdenticalVertices is *senseless* then. - * - * This flag may not be specified together with #aiProcess_GenSmoothNormals. - */ - aiProcess_GenNormals = 0x20, - - // ------------------------------------------------------------------------- - /**
Generates smooth normals for all vertices in the mesh. - * - * This is ignored if normals are already there at the time this flag - * is evaluated. Model importers try to load them from the source file, so - * they're usually already there. - * - * This flag may not be specified together with - * #aiProcess_GenNormals. There's a importer property, - * #AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE which allows you to specify - * an angle maximum for the normal smoothing algorithm. Normals exceeding - * this limit are not smoothed, resulting in a 'hard' seam between two faces. - * Using a decent angle here (e.g. 80 degrees) results in very good visual - * appearance. - */ - aiProcess_GenSmoothNormals = 0x40, - - // ------------------------------------------------------------------------- - /**
Splits large meshes into smaller sub-meshes. - * - * This is quite useful for real-time rendering, where the number of triangles - * which can be maximally processed in a single draw-call is limited - * by the video driver/hardware. The maximum vertex buffer is usually limited - * too. Both requirements can be met with this step: you may specify both a - * triangle and vertex limit for a single mesh. - * - * The split limits can (and should!) be set through the - * #AI_CONFIG_PP_SLM_VERTEX_LIMIT and #AI_CONFIG_PP_SLM_TRIANGLE_LIMIT - * importer properties. The default values are #AI_SLM_DEFAULT_MAX_VERTICES and - * #AI_SLM_DEFAULT_MAX_TRIANGLES. - * - * Note that splitting is generally a time-consuming task, but only if there's - * something to split. The use of this step is recommended for most users. - */ - aiProcess_SplitLargeMeshes = 0x80, - - // ------------------------------------------------------------------------- - /**
Removes the node graph and pre-transforms all vertices with - * the local transformation matrices of their nodes. - * - * The output scene still contains nodes, however there is only a - * root node with children, each one referencing only one mesh, - * and each mesh referencing one material. For rendering, you can - * simply render all meshes in order - you don't need to pay - * attention to local transformations and the node hierarchy. - * Animations are removed during this step. - * This step is intended for applications without a scenegraph. - * The step CAN cause some problems: if e.g. a mesh of the asset - * contains normals and another, using the same material index, does not, - * they will be brought together, but the first meshes's part of - * the normal list is zeroed. However, these artifacts are rare. - * @note The #AI_CONFIG_PP_PTV_NORMALIZE configuration property - * can be set to normalize the scene's spatial dimension to the -1...1 - * range. - */ - aiProcess_PreTransformVertices = 0x100, - - // ------------------------------------------------------------------------- - /**
Limits the number of bones simultaneously affecting a single vertex - * to a maximum value. - * - * If any vertex is affected by more than the maximum number of bones, the least - * important vertex weights are removed and the remaining vertex weights are - * renormalized so that the weights still sum up to 1. - * The default bone weight limit is 4 (defined as #AI_LMW_MAX_WEIGHTS in - * config.h), but you can use the #AI_CONFIG_PP_LBW_MAX_WEIGHTS importer - * property to supply your own limit to the post processing step. - * - * If you intend to perform the skinning in hardware, this post processing - * step might be of interest to you. - */ - aiProcess_LimitBoneWeights = 0x200, - - // ------------------------------------------------------------------------- - /**
Validates the imported scene data structure. - * This makes sure that all indices are valid, all animations and - * bones are linked correctly, all material references are correct .. etc. - * - * It is recommended that you capture Assimp's log output if you use this flag, - * so you can easily find out what's wrong if a file fails the - * validation. The validator is quite strict and will find *all* - * inconsistencies in the data structure... It is recommended that plugin - * developers use it to debug their loaders. There are two types of - * validation failures: - *
    - *
  • Error: There's something wrong with the imported data. Further - * postprocessing is not possible and the data is not usable at all. - * The import fails. #Importer::GetErrorString() or #aiGetErrorString() - * carry the error message around.
  • - *
  • Warning: There are some minor issues (e.g. 1000000 animation - * keyframes with the same time), but further postprocessing and use - * of the data structure is still safe. Warning details are written - * to the log file, #AI_SCENE_FLAGS_VALIDATION_WARNING is set - * in #aiScene::mFlags
  • - *
- * - * This post-processing step is not time-consuming. Its use is not - * compulsory, but recommended. - */ - aiProcess_ValidateDataStructure = 0x400, - - // ------------------------------------------------------------------------- - /**
Reorders triangles for better vertex cache locality. - * - * The step tries to improve the ACMR (average post-transform vertex cache - * miss ratio) for all meshes. The implementation runs in O(n) and is - * roughly based on the 'tipsify' algorithm (see this - * paper). - * - * If you intend to render huge models in hardware, this step might - * be of interest to you. The #AI_CONFIG_PP_ICL_PTCACHE_SIZE - * importer property can be used to fine-tune the cache optimization. - */ - aiProcess_ImproveCacheLocality = 0x800, - - // ------------------------------------------------------------------------- - /**
Searches for redundant/unreferenced materials and removes them. - * - * This is especially useful in combination with the - * #aiProcess_PreTransformVertices and #aiProcess_OptimizeMeshes flags. - * Both join small meshes with equal characteristics, but they can't do - * their work if two meshes have different materials. Because several - * material settings are lost during Assimp's import filters, - * (and because many exporters don't check for redundant materials), huge - * models often have materials which are are defined several times with - * exactly the same settings. - * - * Several material settings not contributing to the final appearance of - * a surface are ignored in all comparisons (e.g. the material name). - * So, if you're passing additional information through the - * content pipeline (probably using *magic* material names), don't - * specify this flag. Alternatively take a look at the - * #AI_CONFIG_PP_RRM_EXCLUDE_LIST importer property. - */ - aiProcess_RemoveRedundantMaterials = 0x1000, - - // ------------------------------------------------------------------------- - /**
This step tries to determine which meshes have normal vectors - * that are facing inwards and inverts them. - * - * The algorithm is simple but effective: - * the bounding box of all vertices + their normals is compared against - * the volume of the bounding box of all vertices without their normals. - * This works well for most objects, problems might occur with planar - * surfaces. However, the step tries to filter such cases. - * The step inverts all in-facing normals. Generally it is recommended - * to enable this step, although the result is not always correct. - */ - aiProcess_FixInfacingNormals = 0x2000, - - // ------------------------------------------------------------------------- - /**
This step splits meshes with more than one primitive type in - * homogeneous sub-meshes. - * - * The step is executed after the triangulation step. After the step - * returns, just one bit is set in aiMesh::mPrimitiveTypes. This is - * especially useful for real-time rendering where point and line - * primitives are often ignored or rendered separately. - * You can use the #AI_CONFIG_PP_SBP_REMOVE importer property to - * specify which primitive types you need. This can be used to easily - * exclude lines and points, which are rarely used, from the import. - */ - aiProcess_SortByPType = 0x8000, - - // ------------------------------------------------------------------------- - /**
This step searches all meshes for degenerate primitives and - * converts them to proper lines or points. - * - * A face is 'degenerate' if one or more of its points are identical. - * To have the degenerate stuff not only detected and collapsed but - * removed, try one of the following procedures: - *
1. (if you support lines and points for rendering but don't - * want the degenerates)
- *
    - *
  • Specify the #aiProcess_FindDegenerates flag. - *
  • - *
  • Set the #AI_CONFIG_PP_FD_REMOVE importer property to - * 1. This will cause the step to remove degenerate triangles from the - * import as soon as they're detected. They won't pass any further - * pipeline steps. - *
  • - *
- *
2.(if you don't support lines and points at all)
- *
    - *
  • Specify the #aiProcess_FindDegenerates flag. - *
  • - *
  • Specify the #aiProcess_SortByPType flag. This moves line and - * point primitives to separate meshes. - *
  • - *
  • Set the #AI_CONFIG_PP_SBP_REMOVE importer property to - * @code aiPrimitiveType_POINTS | aiPrimitiveType_LINES - * @endcode to cause SortByPType to reject point - * and line meshes from the scene. - *
  • - *
- * @note Degenerate polygons are not necessarily evil and that's why - * they're not removed by default. There are several file formats which - * don't support lines or points, and some exporters bypass the - * format specification and write them as degenerate triangles instead. - */ - aiProcess_FindDegenerates = 0x10000, - - // ------------------------------------------------------------------------- - /**
This step searches all meshes for invalid data, such as zeroed - * normal vectors or invalid UV coords and removes/fixes them. This is - * intended to get rid of some common exporter errors. - * - * This is especially useful for normals. If they are invalid, and - * the step recognizes this, they will be removed and can later - * be recomputed, i.e. by the #aiProcess_GenSmoothNormals flag.
- * The step will also remove meshes that are infinitely small and reduce - * animation tracks consisting of hundreds if redundant keys to a single - * key. The AI_CONFIG_PP_FID_ANIM_ACCURACY config property decides - * the accuracy of the check for duplicate animation tracks. - */ - aiProcess_FindInvalidData = 0x20000, - - // ------------------------------------------------------------------------- - /**
This step converts non-UV mappings (such as spherical or - * cylindrical mapping) to proper texture coordinate channels. - * - * Most applications will support UV mapping only, so you will - * probably want to specify this step in every case. Note that Assimp is not - * always able to match the original mapping implementation of the - * 3D app which produced a model perfectly. It's always better to let the - * modelling app compute the UV channels - 3ds max, Maya, Blender, - * LightWave, and Modo do this for example. - * - * @note If this step is not requested, you'll need to process the - * #AI_MATKEY_MAPPING material property in order to display all assets - * properly. - */ - aiProcess_GenUVCoords = 0x40000, - - // ------------------------------------------------------------------------- - /**
This step applies per-texture UV transformations and bakes - * them into stand-alone vtexture coordinate channels. - * - * UV transformations are specified per-texture - see the - * #AI_MATKEY_UVTRANSFORM material key for more information. - * This step processes all textures with - * transformed input UV coordinates and generates a new (pre-transformed) UV channel - * which replaces the old channel. Most applications won't support UV - * transformations, so you will probably want to specify this step. - * - * @note UV transformations are usually implemented in real-time apps by - * transforming texture coordinates at vertex shader stage with a 3x3 - * (homogenous) transformation matrix. - */ - aiProcess_TransformUVCoords = 0x80000, - - // ------------------------------------------------------------------------- - /**
This step searches for duplicate meshes and replaces them - * with references to the first mesh. - * - * This step takes a while, so don't use it if speed is a concern. - * Its main purpose is to workaround the fact that many export - * file formats don't support instanced meshes, so exporters need to - * duplicate meshes. This step removes the duplicates again. Please - * note that Assimp does not currently support per-node material - * assignment to meshes, which means that identical meshes with - * different materials are currently *not* joined, although this is - * planned for future versions. - */ - aiProcess_FindInstances = 0x100000, - - // ------------------------------------------------------------------------- - /**
A postprocessing step to reduce the number of meshes. - * - * This will, in fact, reduce the number of draw calls. - * - * This is a very effective optimization and is recommended to be used - * together with #aiProcess_OptimizeGraph, if possible. The flag is fully - * compatible with both #aiProcess_SplitLargeMeshes and #aiProcess_SortByPType. - */ - aiProcess_OptimizeMeshes = 0x200000, - - - // ------------------------------------------------------------------------- - /**
A postprocessing step to optimize the scene hierarchy. - * - * Nodes without animations, bones, lights or cameras assigned are - * collapsed and joined. - * - * Node names can be lost during this step. If you use special 'tag nodes' - * to pass additional information through your content pipeline, use the - * #AI_CONFIG_PP_OG_EXCLUDE_LIST importer property to specify a - * list of node names you want to be kept. Nodes matching one of the names - * in this list won't be touched or modified. - * - * Use this flag with caution. Most simple files will be collapsed to a - * single node, so complex hierarchies are usually completely lost. This is not - * useful for editor environments, but probably a very effective - * optimization if you just want to get the model data, convert it to your - * own format, and render it as fast as possible. - * - * This flag is designed to be used with #aiProcess_OptimizeMeshes for best - * results. - * - * @note 'Crappy' scenes with thousands of extremely small meshes packed - * in deeply nested nodes exist for almost all file formats. - * #aiProcess_OptimizeMeshes in combination with #aiProcess_OptimizeGraph - * usually fixes them all and makes them renderable. - */ - aiProcess_OptimizeGraph = 0x400000, - - // ------------------------------------------------------------------------- - /**
This step flips all UV coordinates along the y-axis and adjusts - * material settings and bitangents accordingly. - * - * Output UV coordinate system: - * @code - * 0y|0y ---------- 1x|0y - * | | - * | | - * | | - * 0x|1y ---------- 1x|1y - * @endcode - * - * You'll probably want to consider this flag if you use Direct3D for - * rendering. The #aiProcess_ConvertToLeftHanded flag supersedes this - * setting and bundles all conversions typically required for D3D-based - * applications. - */ - aiProcess_FlipUVs = 0x800000, - - // ------------------------------------------------------------------------- - /**
This step adjusts the output face winding order to be CW. - * - * The default face winding order is counter clockwise (CCW). - * - * Output face order: - * @code - * x2 - * - * x0 - * x1 - * @endcode - */ - aiProcess_FlipWindingOrder = 0x1000000, - - // ------------------------------------------------------------------------- - /**
This step splits meshes with many bones into sub-meshes so that each - * su-bmesh has fewer or as many bones as a given limit. - */ - aiProcess_SplitByBoneCount = 0x2000000, - - // ------------------------------------------------------------------------- - /**
This step removes bones losslessly or according to some threshold. - * - * In some cases (i.e. formats that require it) exporters are forced to - * assign dummy bone weights to otherwise static meshes assigned to - * animated meshes. Full, weight-based skinning is expensive while - * animating nodes is extremely cheap, so this step is offered to clean up - * the data in that regard. - * - * Use #AI_CONFIG_PP_DB_THRESHOLD to control this. - * Use #AI_CONFIG_PP_DB_ALL_OR_NONE if you want bones removed if and - * only if all bones within the scene qualify for removal. - */ - aiProcess_Debone = 0x4000000 - - // aiProcess_GenEntityMeshes = 0x100000, - // aiProcess_OptimizeAnimations = 0x200000 - // aiProcess_FixTexturePaths = 0x200000 -}; - - -// --------------------------------------------------------------------------------------- -/** @def aiProcess_ConvertToLeftHanded - * @brief Shortcut flag for Direct3D-based applications. - * - * Supersedes the #aiProcess_MakeLeftHanded and #aiProcess_FlipUVs and - * #aiProcess_FlipWindingOrder flags. - * The output data matches Direct3D's conventions: left-handed geometry, upper-left - * origin for UV coordinates and finally clockwise face order, suitable for CCW culling. - * - * @deprecated - */ -#define aiProcess_ConvertToLeftHanded ( \ - aiProcess_MakeLeftHanded | \ - aiProcess_FlipUVs | \ - aiProcess_FlipWindingOrder | \ - 0 ) - - -// --------------------------------------------------------------------------------------- -/** @def aiProcessPreset_TargetRealtime_Fast - * @brief Default postprocess configuration optimizing the data for real-time rendering. - * - * Applications would want to use this preset to load models on end-user PCs, - * maybe for direct use in game. - * - * If you're using DirectX, don't forget to combine this value with - * the #aiProcess_ConvertToLeftHanded step. If you don't support UV transformations - * in your application apply the #aiProcess_TransformUVCoords step, too. - * @note Please take the time to read the docs for the steps enabled by this preset. - * Some of them offer further configurable properties, while some of them might not be of - * use for you so it might be better to not specify them. - */ -#define aiProcessPreset_TargetRealtime_Fast ( \ - aiProcess_CalcTangentSpace | \ - aiProcess_GenNormals | \ - aiProcess_JoinIdenticalVertices | \ - aiProcess_Triangulate | \ - aiProcess_GenUVCoords | \ - aiProcess_SortByPType | \ - 0 ) - - // --------------------------------------------------------------------------------------- - /** @def aiProcessPreset_TargetRealtime_Quality - * @brief Default postprocess configuration optimizing the data for real-time rendering. - * - * Unlike #aiProcessPreset_TargetRealtime_Fast, this configuration - * performs some extra optimizations to improve rendering speed and - * to minimize memory usage. It could be a good choice for a level editor - * environment where import speed is not so important. - * - * If you're using DirectX, don't forget to combine this value with - * the #aiProcess_ConvertToLeftHanded step. If you don't support UV transformations - * in your application apply the #aiProcess_TransformUVCoords step, too. - * @note Please take the time to read the docs for the steps enabled by this preset. - * Some of them offer further configurable properties, while some of them might not be - * of use for you so it might be better to not specify them. - */ -#define aiProcessPreset_TargetRealtime_Quality ( \ - aiProcess_CalcTangentSpace | \ - aiProcess_GenSmoothNormals | \ - aiProcess_JoinIdenticalVertices | \ - aiProcess_ImproveCacheLocality | \ - aiProcess_LimitBoneWeights | \ - aiProcess_RemoveRedundantMaterials | \ - aiProcess_SplitLargeMeshes | \ - aiProcess_Triangulate | \ - aiProcess_GenUVCoords | \ - aiProcess_SortByPType | \ - aiProcess_FindDegenerates | \ - aiProcess_FindInvalidData | \ - 0 ) - - // --------------------------------------------------------------------------------------- - /** @def aiProcessPreset_TargetRealtime_MaxQuality - * @brief Default postprocess configuration optimizing the data for real-time rendering. - * - * This preset enables almost every optimization step to achieve perfectly - * optimized data. It's your choice for level editor environments where import speed - * is not important. - * - * If you're using DirectX, don't forget to combine this value with - * the #aiProcess_ConvertToLeftHanded step. If you don't support UV transformations - * in your application, apply the #aiProcess_TransformUVCoords step, too. - * @note Please take the time to read the docs for the steps enabled by this preset. - * Some of them offer further configurable properties, while some of them might not be - * of use for you so it might be better to not specify them. - */ -#define aiProcessPreset_TargetRealtime_MaxQuality ( \ - aiProcessPreset_TargetRealtime_Quality | \ - aiProcess_FindInstances | \ - aiProcess_ValidateDataStructure | \ - aiProcess_OptimizeMeshes | \ - 0 ) - - -#ifdef __cplusplus -} // end of extern "C" -#endif - -#endif // AI_POSTPROCESS_H_INC diff --git a/thirdparty/include/assimp/quaternion.h b/thirdparty/include/assimp/quaternion.h deleted file mode 100644 index fe213f71e..000000000 --- a/thirdparty/include/assimp/quaternion.h +++ /dev/null @@ -1,126 +0,0 @@ -/* -Open Asset Import Library (assimp) ----------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the -following conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------- -*/ - -/** @file quaternion.h - * @brief Quaternion structure, including operators when compiling in C++ - */ -#ifndef AI_QUATERNION_H_INC -#define AI_QUATERNION_H_INC - -#ifdef __cplusplus - -template class aiVector3t; -template class aiMatrix3x3t; - -// --------------------------------------------------------------------------- -/** Represents a quaternion in a 4D vector. */ -template -class aiQuaterniont -{ -public: - aiQuaterniont() : w(1.0), x(), y(), z() {} - aiQuaterniont(TReal pw, TReal px, TReal py, TReal pz) - : w(pw), x(px), y(py), z(pz) {} - - /** Construct from rotation matrix. Result is undefined if the matrix is not orthonormal. */ - explicit aiQuaterniont( const aiMatrix3x3t& pRotMatrix); - - /** Construct from euler angles */ - aiQuaterniont( TReal rotx, TReal roty, TReal rotz); - - /** Construct from an axis-angle pair */ - aiQuaterniont( aiVector3t axis, TReal angle); - - /** Construct from a normalized quaternion stored in a vec3 */ - explicit aiQuaterniont( aiVector3t normalized); - - /** Returns a matrix representation of the quaternion */ - aiMatrix3x3t GetMatrix() const; - -public: - - bool operator== (const aiQuaterniont& o) const; - bool operator!= (const aiQuaterniont& o) const; - - bool Equal(const aiQuaterniont& o, TReal epsilon = 1e-6) const; - -public: - - /** Normalize the quaternion */ - aiQuaterniont& Normalize(); - - /** Compute quaternion conjugate */ - aiQuaterniont& Conjugate (); - - /** Rotate a point by this quaternion */ - aiVector3t Rotate (const aiVector3t& in); - - /** Multiply two quaternions */ - aiQuaterniont operator* (const aiQuaterniont& two) const; - -public: - - /** Performs a spherical interpolation between two quaternions and writes the result into the third. - * @param pOut Target object to received the interpolated rotation. - * @param pStart Start rotation of the interpolation at factor == 0. - * @param pEnd End rotation, factor == 1. - * @param pFactor Interpolation factor between 0 and 1. Values outside of this range yield undefined results. - */ - static void Interpolate( aiQuaterniont& pOut, const aiQuaterniont& pStart, - const aiQuaterniont& pEnd, TReal pFactor); - -public: - - //! w,x,y,z components of the quaternion - TReal w, x, y, z; -} ; - -typedef aiQuaterniont aiQuaternion; - -#else - -struct aiQuaternion { - float w, x, y, z; -}; - -#endif - - -#endif // AI_QUATERNION_H_INC diff --git a/thirdparty/include/assimp/quaternion.inl b/thirdparty/include/assimp/quaternion.inl deleted file mode 100644 index db27c25ff..000000000 --- a/thirdparty/include/assimp/quaternion.inl +++ /dev/null @@ -1,283 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file quaternion.inl - * @brief Inline implementation of aiQuaterniont operators - */ -#ifndef AI_QUATERNION_INL_INC -#define AI_QUATERNION_INL_INC - -#ifdef __cplusplus -#include "quaternion.h" - -#include - -// --------------------------------------------------------------------------- -template -bool aiQuaterniont::operator== (const aiQuaterniont& o) const -{ - return x == o.x && y == o.y && z == o.z && w == o.w; -} - -// --------------------------------------------------------------------------- -template -bool aiQuaterniont::operator!= (const aiQuaterniont& o) const -{ - return !(*this == o); -} - -// --------------------------------------------------------------------------- -template -inline bool aiQuaterniont::Equal(const aiQuaterniont& o, TReal epsilon) const { - return - std::abs(x - o.x) <= epsilon && - std::abs(y - o.y) <= epsilon && - std::abs(z - o.z) <= epsilon && - std::abs(w - o.w) <= epsilon; -} - -// --------------------------------------------------------------------------- -// Constructs a quaternion from a rotation matrix -template -inline aiQuaterniont::aiQuaterniont( const aiMatrix3x3t &pRotMatrix) -{ - TReal t = pRotMatrix.a1 + pRotMatrix.b2 + pRotMatrix.c3; - - // large enough - if( t > static_cast(0)) - { - TReal s = std::sqrt(1 + t) * static_cast(2.0); - x = (pRotMatrix.c2 - pRotMatrix.b3) / s; - y = (pRotMatrix.a3 - pRotMatrix.c1) / s; - z = (pRotMatrix.b1 - pRotMatrix.a2) / s; - w = static_cast(0.25) * s; - } // else we have to check several cases - else if( pRotMatrix.a1 > pRotMatrix.b2 && pRotMatrix.a1 > pRotMatrix.c3 ) - { - // Column 0: - TReal s = std::sqrt( static_cast(1.0) + pRotMatrix.a1 - pRotMatrix.b2 - pRotMatrix.c3) * static_cast(2.0); - x = static_cast(0.25) * s; - y = (pRotMatrix.b1 + pRotMatrix.a2) / s; - z = (pRotMatrix.a3 + pRotMatrix.c1) / s; - w = (pRotMatrix.c2 - pRotMatrix.b3) / s; - } - else if( pRotMatrix.b2 > pRotMatrix.c3) - { - // Column 1: - TReal s = std::sqrt( static_cast(1.0) + pRotMatrix.b2 - pRotMatrix.a1 - pRotMatrix.c3) * static_cast(2.0); - x = (pRotMatrix.b1 + pRotMatrix.a2) / s; - y = static_cast(0.25) * s; - z = (pRotMatrix.c2 + pRotMatrix.b3) / s; - w = (pRotMatrix.a3 - pRotMatrix.c1) / s; - } else - { - // Column 2: - TReal s = std::sqrt( static_cast(1.0) + pRotMatrix.c3 - pRotMatrix.a1 - pRotMatrix.b2) * static_cast(2.0); - x = (pRotMatrix.a3 + pRotMatrix.c1) / s; - y = (pRotMatrix.c2 + pRotMatrix.b3) / s; - z = static_cast(0.25) * s; - w = (pRotMatrix.b1 - pRotMatrix.a2) / s; - } -} - -// --------------------------------------------------------------------------- -// Construction from euler angles -template -inline aiQuaterniont::aiQuaterniont( TReal fPitch, TReal fYaw, TReal fRoll ) -{ - const TReal fSinPitch(std::sin(fPitch*static_cast(0.5))); - const TReal fCosPitch(std::cos(fPitch*static_cast(0.5))); - const TReal fSinYaw(std::sin(fYaw*static_cast(0.5))); - const TReal fCosYaw(std::cos(fYaw*static_cast(0.5))); - const TReal fSinRoll(std::sin(fRoll*static_cast(0.5))); - const TReal fCosRoll(std::cos(fRoll*static_cast(0.5))); - const TReal fCosPitchCosYaw(fCosPitch*fCosYaw); - const TReal fSinPitchSinYaw(fSinPitch*fSinYaw); - x = fSinRoll * fCosPitchCosYaw - fCosRoll * fSinPitchSinYaw; - y = fCosRoll * fSinPitch * fCosYaw + fSinRoll * fCosPitch * fSinYaw; - z = fCosRoll * fCosPitch * fSinYaw - fSinRoll * fSinPitch * fCosYaw; - w = fCosRoll * fCosPitchCosYaw + fSinRoll * fSinPitchSinYaw; -} - -// --------------------------------------------------------------------------- -// Returns a matrix representation of the quaternion -template -inline aiMatrix3x3t aiQuaterniont::GetMatrix() const -{ - aiMatrix3x3t resMatrix; - resMatrix.a1 = static_cast(1.0) - static_cast(2.0) * (y * y + z * z); - resMatrix.a2 = static_cast(2.0) * (x * y - z * w); - resMatrix.a3 = static_cast(2.0) * (x * z + y * w); - resMatrix.b1 = static_cast(2.0) * (x * y + z * w); - resMatrix.b2 = static_cast(1.0) - static_cast(2.0) * (x * x + z * z); - resMatrix.b3 = static_cast(2.0) * (y * z - x * w); - resMatrix.c1 = static_cast(2.0) * (x * z - y * w); - resMatrix.c2 = static_cast(2.0) * (y * z + x * w); - resMatrix.c3 = static_cast(1.0) - static_cast(2.0) * (x * x + y * y); - - return resMatrix; -} - -// --------------------------------------------------------------------------- -// Construction from an axis-angle pair -template -inline aiQuaterniont::aiQuaterniont( aiVector3t axis, TReal angle) -{ - axis.Normalize(); - - const TReal sin_a = std::sin( angle / 2 ); - const TReal cos_a = std::cos( angle / 2 ); - x = axis.x * sin_a; - y = axis.y * sin_a; - z = axis.z * sin_a; - w = cos_a; -} -// --------------------------------------------------------------------------- -// Construction from am existing, normalized quaternion -template -inline aiQuaterniont::aiQuaterniont( aiVector3t normalized) -{ - x = normalized.x; - y = normalized.y; - z = normalized.z; - - const TReal t = static_cast(1.0) - (x*x) - (y*y) - (z*z); - - if (t < static_cast(0.0)) { - w = static_cast(0.0); - } - else w = std::sqrt (t); -} - -// --------------------------------------------------------------------------- -// Performs a spherical interpolation between two quaternions -// Implementation adopted from the gmtl project. All others I found on the net fail in some cases. -// Congrats, gmtl! -template -inline void aiQuaterniont::Interpolate( aiQuaterniont& pOut, const aiQuaterniont& pStart, const aiQuaterniont& pEnd, TReal pFactor) -{ - // calc cosine theta - TReal cosom = pStart.x * pEnd.x + pStart.y * pEnd.y + pStart.z * pEnd.z + pStart.w * pEnd.w; - - // adjust signs (if necessary) - aiQuaterniont end = pEnd; - if( cosom < static_cast(0.0)) - { - cosom = -cosom; - end.x = -end.x; // Reverse all signs - end.y = -end.y; - end.z = -end.z; - end.w = -end.w; - } - - // Calculate coefficients - TReal sclp, sclq; - if( (static_cast(1.0) - cosom) > static_cast(0.0001)) // 0.0001 -> some epsillon - { - // Standard case (slerp) - TReal omega, sinom; - omega = std::acos( cosom); // extract theta from dot product's cos theta - sinom = std::sin( omega); - sclp = std::sin( (static_cast(1.0) - pFactor) * omega) / sinom; - sclq = std::sin( pFactor * omega) / sinom; - } else - { - // Very close, do linear interp (because it's faster) - sclp = static_cast(1.0) - pFactor; - sclq = pFactor; - } - - pOut.x = sclp * pStart.x + sclq * end.x; - pOut.y = sclp * pStart.y + sclq * end.y; - pOut.z = sclp * pStart.z + sclq * end.z; - pOut.w = sclp * pStart.w + sclq * end.w; -} - -// --------------------------------------------------------------------------- -template -inline aiQuaterniont& aiQuaterniont::Normalize() -{ - // compute the magnitude and divide through it - const TReal mag = std::sqrt(x*x + y*y + z*z + w*w); - if (mag) - { - const TReal invMag = static_cast(1.0)/mag; - x *= invMag; - y *= invMag; - z *= invMag; - w *= invMag; - } - return *this; -} - -// --------------------------------------------------------------------------- -template -inline aiQuaterniont aiQuaterniont::operator* (const aiQuaterniont& t) const -{ - return aiQuaterniont(w*t.w - x*t.x - y*t.y - z*t.z, - w*t.x + x*t.w + y*t.z - z*t.y, - w*t.y + y*t.w + z*t.x - x*t.z, - w*t.z + z*t.w + x*t.y - y*t.x); -} - -// --------------------------------------------------------------------------- -template -inline aiQuaterniont& aiQuaterniont::Conjugate () -{ - x = -x; - y = -y; - z = -z; - return *this; -} - -// --------------------------------------------------------------------------- -template -inline aiVector3t aiQuaterniont::Rotate (const aiVector3t& v) -{ - aiQuaterniont q2(0.f,v.x,v.y,v.z), q = *this, qinv = q; - qinv.Conjugate(); - - q = q*q2*qinv; - return aiVector3t(q.x,q.y,q.z); -} - -#endif -#endif diff --git a/thirdparty/include/assimp/scene.h b/thirdparty/include/assimp/scene.h deleted file mode 100644 index 8987ac6a3..000000000 --- a/thirdparty/include/assimp/scene.h +++ /dev/null @@ -1,428 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file scene.h - * @brief Defines the data structures in which the imported scene is returned. - */ -#ifndef __AI_SCENE_H_INC__ -#define __AI_SCENE_H_INC__ - -#include "types.h" -#include "texture.h" -#include "mesh.h" -#include "light.h" -#include "camera.h" -#include "material.h" -#include "anim.h" -#include "metadata.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -// ------------------------------------------------------------------------------- -/** A node in the imported hierarchy. - * - * Each node has name, a parent node (except for the root node), - * a transformation relative to its parent and possibly several child nodes. - * Simple file formats don't support hierarchical structures - for these formats - * the imported scene does consist of only a single root node without children. - */ -// ------------------------------------------------------------------------------- -struct aiNode -{ - /** The name of the node. - * - * The name might be empty (length of zero) but all nodes which - * need to be referenced by either bones or animations are named. - * Multiple nodes may have the same name, except for nodes which are referenced - * by bones (see #aiBone and #aiMesh::mBones). Their names *must* be unique. - * - * Cameras and lights reference a specific node by name - if there - * are multiple nodes with this name, they are assigned to each of them. - *
- * There are no limitations with regard to the characters contained in - * the name string as it is usually taken directly from the source file. - * - * Implementations should be able to handle tokens such as whitespace, tabs, - * line feeds, quotation marks, ampersands etc. - * - * Sometimes assimp introduces new nodes not present in the source file - * into the hierarchy (usually out of necessity because sometimes the - * source hierarchy format is simply not compatible). Their names are - * surrounded by @verbatim <> @endverbatim e.g. - * @verbatim @endverbatim. - */ - C_STRUCT aiString mName; - - /** The transformation relative to the node's parent. */ - C_STRUCT aiMatrix4x4 mTransformation; - - /** Parent node. NULL if this node is the root node. */ - C_STRUCT aiNode* mParent; - - /** The number of child nodes of this node. */ - unsigned int mNumChildren; - - /** The child nodes of this node. NULL if mNumChildren is 0. */ - C_STRUCT aiNode** mChildren; - - /** The number of meshes of this node. */ - unsigned int mNumMeshes; - - /** The meshes of this node. Each entry is an index into the - * mesh list of the #aiScene. - */ - unsigned int* mMeshes; - - /** Metadata associated with this node or NULL if there is no metadata. - * Whether any metadata is generated depends on the source file format. See the - * @link importer_notes @endlink page for more information on every source file - * format. Importers that don't document any metadata don't write any. - */ - C_STRUCT aiMetadata* mMetaData; - -#ifdef __cplusplus - /** Constructor */ - aiNode() - // set all members to zero by default - : mName("") - , mParent(NULL) - , mNumChildren(0) - , mChildren(NULL) - , mNumMeshes(0) - , mMeshes(NULL) - , mMetaData(NULL) - { - } - - - /** Construction from a specific name */ - explicit aiNode(const std::string& name) - // set all members to zero by default - : mName(name) - , mParent(NULL) - , mNumChildren(0) - , mChildren(NULL) - , mNumMeshes(0) - , mMeshes(NULL) - , mMetaData(NULL) - { - } - - /** Destructor */ - ~aiNode() - { - // delete all children recursively - // to make sure we won't crash if the data is invalid ... - if (mChildren && mNumChildren) - { - for( unsigned int a = 0; a < mNumChildren; a++) - delete mChildren[a]; - } - delete [] mChildren; - delete [] mMeshes; - delete mMetaData; - } - - - /** Searches for a node with a specific name, beginning at this - * nodes. Normally you will call this method on the root node - * of the scene. - * - * @param name Name to search for - * @return NULL or a valid Node if the search was successful. - */ - inline const aiNode* FindNode(const aiString& name) const - { - return FindNode(name.data); - } - - - inline aiNode* FindNode(const aiString& name) - { - return FindNode(name.data); - } - - - inline const aiNode* FindNode(const char* name) const - { - if (!::strcmp( mName.data,name))return this; - for (unsigned int i = 0; i < mNumChildren;++i) - { - const aiNode* const p = mChildren[i]->FindNode(name); - if (p) { - return p; - } - } - // there is definitely no sub-node with this name - return NULL; - } - - inline aiNode* FindNode(const char* name) - { - if (!::strcmp( mName.data,name))return this; - for (unsigned int i = 0; i < mNumChildren;++i) - { - aiNode* const p = mChildren[i]->FindNode(name); - if (p) { - return p; - } - } - // there is definitely no sub-node with this name - return NULL; - } - -#endif // __cplusplus -}; - - -// ------------------------------------------------------------------------------- -/** - * Specifies that the scene data structure that was imported is not complete. - * This flag bypasses some internal validations and allows the import - * of animation skeletons, material libraries or camera animation paths - * using Assimp. Most applications won't support such data. - */ -#define AI_SCENE_FLAGS_INCOMPLETE 0x1 - -/** - * This flag is set by the validation postprocess-step (aiPostProcess_ValidateDS) - * if the validation is successful. In a validated scene you can be sure that - * any cross references in the data structure (e.g. vertex indices) are valid. - */ -#define AI_SCENE_FLAGS_VALIDATED 0x2 - -/** - * This flag is set by the validation postprocess-step (aiPostProcess_ValidateDS) - * if the validation is successful but some issues have been found. - * This can for example mean that a texture that does not exist is referenced - * by a material or that the bone weights for a vertex don't sum to 1.0 ... . - * In most cases you should still be able to use the import. This flag could - * be useful for applications which don't capture Assimp's log output. - */ -#define AI_SCENE_FLAGS_VALIDATION_WARNING 0x4 - -/** - * This flag is currently only set by the aiProcess_JoinIdenticalVertices step. - * It indicates that the vertices of the output meshes aren't in the internal - * verbose format anymore. In the verbose format all vertices are unique, - * no vertex is ever referenced by more than one face. - */ -#define AI_SCENE_FLAGS_NON_VERBOSE_FORMAT 0x8 - - /** - * Denotes pure height-map terrain data. Pure terrains usually consist of quads, - * sometimes triangles, in a regular grid. The x,y coordinates of all vertex - * positions refer to the x,y coordinates on the terrain height map, the z-axis - * stores the elevation at a specific point. - * - * TER (Terragen) and HMP (3D Game Studio) are height map formats. - * @note Assimp is probably not the best choice for loading *huge* terrains - - * fully triangulated data takes extremely much free store and should be avoided - * as long as possible (typically you'll do the triangulation when you actually - * need to render it). - */ -#define AI_SCENE_FLAGS_TERRAIN 0x10 - - -// ------------------------------------------------------------------------------- -/** The root structure of the imported data. - * - * Everything that was imported from the given file can be accessed from here. - * Objects of this class are generally maintained and owned by Assimp, not - * by the caller. You shouldn't want to instance it, nor should you ever try to - * delete a given scene on your own. - */ -// ------------------------------------------------------------------------------- -struct aiScene -{ - - /** Any combination of the AI_SCENE_FLAGS_XXX flags. By default - * this value is 0, no flags are set. Most applications will - * want to reject all scenes with the AI_SCENE_FLAGS_INCOMPLETE - * bit set. - */ - unsigned int mFlags; - - - /** The root node of the hierarchy. - * - * There will always be at least the root node if the import - * was successful (and no special flags have been set). - * Presence of further nodes depends on the format and content - * of the imported file. - */ - C_STRUCT aiNode* mRootNode; - - - - /** The number of meshes in the scene. */ - unsigned int mNumMeshes; - - /** The array of meshes. - * - * Use the indices given in the aiNode structure to access - * this array. The array is mNumMeshes in size. If the - * AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always - * be at least ONE material. - */ - C_STRUCT aiMesh** mMeshes; - - - - /** The number of materials in the scene. */ - unsigned int mNumMaterials; - - /** The array of materials. - * - * Use the index given in each aiMesh structure to access this - * array. The array is mNumMaterials in size. If the - * AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always - * be at least ONE material. - */ - C_STRUCT aiMaterial** mMaterials; - - - - /** The number of animations in the scene. */ - unsigned int mNumAnimations; - - /** The array of animations. - * - * All animations imported from the given file are listed here. - * The array is mNumAnimations in size. - */ - C_STRUCT aiAnimation** mAnimations; - - - - /** The number of textures embedded into the file */ - unsigned int mNumTextures; - - /** The array of embedded textures. - * - * Not many file formats embed their textures into the file. - * An example is Quake's MDL format (which is also used by - * some GameStudio versions) - */ - C_STRUCT aiTexture** mTextures; - - - /** The number of light sources in the scene. Light sources - * are fully optional, in most cases this attribute will be 0 - */ - unsigned int mNumLights; - - /** The array of light sources. - * - * All light sources imported from the given file are - * listed here. The array is mNumLights in size. - */ - C_STRUCT aiLight** mLights; - - - /** The number of cameras in the scene. Cameras - * are fully optional, in most cases this attribute will be 0 - */ - unsigned int mNumCameras; - - /** The array of cameras. - * - * All cameras imported from the given file are listed here. - * The array is mNumCameras in size. The first camera in the - * array (if existing) is the default camera view into - * the scene. - */ - C_STRUCT aiCamera** mCameras; - -#ifdef __cplusplus - - //! Default constructor - set everything to 0/NULL - ASSIMP_API aiScene(); - - //! Destructor - ASSIMP_API ~aiScene(); - - //! Check whether the scene contains meshes - //! Unless no special scene flags are set this will always be true. - inline bool HasMeshes() const - { return mMeshes != NULL && mNumMeshes > 0; } - - //! Check whether the scene contains materials - //! Unless no special scene flags are set this will always be true. - inline bool HasMaterials() const - { return mMaterials != NULL && mNumMaterials > 0; } - - //! Check whether the scene contains lights - inline bool HasLights() const - { return mLights != NULL && mNumLights > 0; } - - //! Check whether the scene contains textures - inline bool HasTextures() const - { return mTextures != NULL && mNumTextures > 0; } - - //! Check whether the scene contains cameras - inline bool HasCameras() const - { return mCameras != NULL && mNumCameras > 0; } - - //! Check whether the scene contains animations - inline bool HasAnimations() const - { return mAnimations != NULL && mNumAnimations > 0; } - -#endif // __cplusplus - - - /** Internal data, do not touch */ -#ifdef __cplusplus - void* mPrivate; -#else - char* mPrivate; -#endif - -}; - -#ifdef __cplusplus -} //! namespace Assimp -#endif - -#endif // __AI_SCENE_H_INC__ diff --git a/thirdparty/include/assimp/texture.h b/thirdparty/include/assimp/texture.h deleted file mode 100644 index ee3ee3149..000000000 --- a/thirdparty/include/assimp/texture.h +++ /dev/null @@ -1,201 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file texture.h - * @brief Defines texture helper structures for the library - * - * Used for file formats which embed their textures into the model file. - * Supported are both normal textures, which are stored as uncompressed - * pixels, and "compressed" textures, which are stored in a file format - * such as PNG or TGA. - */ - -#ifndef AI_TEXTURE_H_INC -#define AI_TEXTURE_H_INC - -#include "types.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -// -------------------------------------------------------------------------------- -/** @def AI_MAKE_EMBEDDED_TEXNAME - * Used to build the reserved path name used by the material system to - * reference textures that are embedded into their corresponding - * model files. The parameter specifies the index of the texture - * (zero-based, in the aiScene::mTextures array) - */ -#if (!defined AI_MAKE_EMBEDDED_TEXNAME) -# define AI_MAKE_EMBEDDED_TEXNAME(_n_) "*" # _n_ -#endif - - -#include "./Compiler/pushpack1.h" - -// -------------------------------------------------------------------------------- -/** @brief Helper structure to represent a texel in a ARGB8888 format -* -* Used by aiTexture. -*/ -struct aiTexel -{ - unsigned char b,g,r,a; - -#ifdef __cplusplus - //! Comparison operator - bool operator== (const aiTexel& other) const - { - return b == other.b && r == other.r && - g == other.g && a == other.a; - } - - //! Inverse comparison operator - bool operator!= (const aiTexel& other) const - { - return b != other.b || r != other.r || - g != other.g || a != other.a; - } - - //! Conversion to a floating-point 4d color - operator aiColor4D() const - { - return aiColor4D(r/255.f,g/255.f,b/255.f,a/255.f); - } -#endif // __cplusplus - -} PACK_STRUCT; - -#include "./Compiler/poppack1.h" - -// -------------------------------------------------------------------------------- -/** Helper structure to describe an embedded texture - * - * Normally textures are contained in external files but some file formats embed - * them directly in the model file. There are two types of embedded textures: - * 1. Uncompressed textures. The color data is given in an uncompressed format. - * 2. Compressed textures stored in a file format like png or jpg. The raw file - * bytes are given so the application must utilize an image decoder (e.g. DevIL) to - * get access to the actual color data. - * - * Embedded textures are referenced from materials using strings like "*0", "*1", etc. - * as the texture paths (a single asterisk character followed by the - * zero-based index of the texture in the aiScene::mTextures array). - */ -struct aiTexture -{ - /** Width of the texture, in pixels - * - * If mHeight is zero the texture is compressed in a format - * like JPEG. In this case mWidth specifies the size of the - * memory area pcData is pointing to, in bytes. - */ - unsigned int mWidth; - - /** Height of the texture, in pixels - * - * If this value is zero, pcData points to an compressed texture - * in any format (e.g. JPEG). - */ - unsigned int mHeight; - - /** A hint from the loader to make it easier for applications - * to determine the type of embedded compressed textures. - * - * If mHeight != 0 this member is undefined. Otherwise it - * is set set to '\\0\\0\\0\\0' if the loader has no additional - * information about the texture file format used OR the - * file extension of the format without a trailing dot. If there - * are multiple file extensions for a format, the shortest - * extension is chosen (JPEG maps to 'jpg', not to 'jpeg'). - * E.g. 'dds\\0', 'pcx\\0', 'jpg\\0'. All characters are lower-case. - * The fourth character will always be '\\0'. - */ - char achFormatHint[4]; - - /** Data of the texture. - * - * Points to an array of mWidth * mHeight aiTexel's. - * The format of the texture data is always ARGB8888 to - * make the implementation for user of the library as easy - * as possible. If mHeight = 0 this is a pointer to a memory - * buffer of size mWidth containing the compressed texture - * data. Good luck, have fun! - */ - C_STRUCT aiTexel* pcData; - -#ifdef __cplusplus - - //! For compressed textures (mHeight == 0): compare the - //! format hint against a given string. - //! @param s Input string. 3 characters are maximally processed. - //! Example values: "jpg", "png" - //! @return true if the given string matches the format hint - bool CheckFormat(const char* s) const - { - return (0 == ::strncmp(achFormatHint,s,3)); - } - - // Construction - aiTexture () - : mWidth (0) - , mHeight (0) - , pcData (NULL) - { - achFormatHint[0] = achFormatHint[1] = 0; - achFormatHint[2] = achFormatHint[3] = 0; - } - - // Destruction - ~aiTexture () - { - delete[] pcData; - } -#endif -}; - - -#ifdef __cplusplus -} -#endif - -#endif // AI_TEXTURE_H_INC diff --git a/thirdparty/include/assimp/types.h b/thirdparty/include/assimp/types.h deleted file mode 100644 index 592d5c64d..000000000 --- a/thirdparty/include/assimp/types.h +++ /dev/null @@ -1,515 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file types.h - * Basic data types and primitives, such as vectors or colors. - */ -#ifndef AI_TYPES_H_INC -#define AI_TYPES_H_INC - -// Some runtime headers -#include -#include -#include -#include -#include - -// Our compile configuration -#include "defs.h" - -// Some types moved to separate header due to size of operators -#include "vector3.h" -#include "vector2.h" -#include "color4.h" -#include "matrix3x3.h" -#include "matrix4x4.h" -#include "quaternion.h" - -#ifdef __cplusplus -#include -#include // for std::nothrow_t -#include // for aiString::Set(const std::string&) - -namespace Assimp { - //! @cond never -namespace Intern { - // -------------------------------------------------------------------- - /** @brief Internal helper class to utilize our internal new/delete - * routines for allocating object of this and derived classes. - * - * By doing this you can safely share class objects between Assimp - * and the application - it works even over DLL boundaries. A good - * example is the #IOSystem where the application allocates its custom - * #IOSystem, then calls #Importer::SetIOSystem(). When the Importer - * destructs, Assimp calls operator delete on the stored #IOSystem. - * If it lies on a different heap than Assimp is working with, - * the application is determined to crash. - */ - // -------------------------------------------------------------------- -#ifndef SWIG - struct ASSIMP_API AllocateFromAssimpHeap { - // http://www.gotw.ca/publications/mill15.htm - - // new/delete overload - void *operator new ( size_t num_bytes) /* throw( std::bad_alloc ) */; - void *operator new ( size_t num_bytes, const std::nothrow_t& ) throw(); - void operator delete ( void* data); - - // array new/delete overload - void *operator new[] ( size_t num_bytes) /* throw( std::bad_alloc ) */; - void *operator new[] ( size_t num_bytes, const std::nothrow_t& ) throw(); - void operator delete[] ( void* data); - - }; // struct AllocateFromAssimpHeap -#endif -} // namespace Intern - //! @endcond -} // namespace Assimp - -extern "C" { -#endif - -/** Maximum dimension for strings, ASSIMP strings are zero terminated. */ -#ifdef __cplusplus -const size_t MAXLEN = 1024; -#else -# define MAXLEN 1024 -#endif - -#include "./Compiler/pushpack1.h" - -// ---------------------------------------------------------------------------------- -/** Represents a plane in a three-dimensional, euclidean space -*/ -struct aiPlane -{ -#ifdef __cplusplus - aiPlane () : a(0.f), b(0.f), c(0.f), d(0.f) {} - aiPlane (float _a, float _b, float _c, float _d) - : a(_a), b(_b), c(_c), d(_d) {} - - aiPlane (const aiPlane& o) : a(o.a), b(o.b), c(o.c), d(o.d) {} - -#endif // !__cplusplus - - //! Plane equation - float a,b,c,d; -} PACK_STRUCT; // !struct aiPlane - -// ---------------------------------------------------------------------------------- -/** Represents a ray -*/ -struct aiRay -{ -#ifdef __cplusplus - aiRay () {} - aiRay (const aiVector3D& _pos, const aiVector3D& _dir) - : pos(_pos), dir(_dir) {} - - aiRay (const aiRay& o) : pos (o.pos), dir (o.dir) {} - -#endif // !__cplusplus - - //! Position and direction of the ray - C_STRUCT aiVector3D pos, dir; -} PACK_STRUCT; // !struct aiRay - -// ---------------------------------------------------------------------------------- -/** Represents a color in Red-Green-Blue space. -*/ -struct aiColor3D -{ -#ifdef __cplusplus - aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {} - aiColor3D (float _r, float _g, float _b) : r(_r), g(_g), b(_b) {} - explicit aiColor3D (float _r) : r(_r), g(_r), b(_r) {} - aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {} - - /** Component-wise comparison */ - // TODO: add epsilon? - bool operator == (const aiColor3D& other) const - {return r == other.r && g == other.g && b == other.b;} - - /** Component-wise inverse comparison */ - // TODO: add epsilon? - bool operator != (const aiColor3D& other) const - {return r != other.r || g != other.g || b != other.b;} - - /** Component-wise comparison */ - // TODO: add epsilon? - bool operator < (const aiColor3D& other) const { - return r < other.r || ( - r == other.r && (g < other.g || - (g == other.g && b < other.b) - ) - ); - } - - /** Component-wise addition */ - aiColor3D operator+(const aiColor3D& c) const { - return aiColor3D(r+c.r,g+c.g,b+c.b); - } - - /** Component-wise subtraction */ - aiColor3D operator-(const aiColor3D& c) const { - return aiColor3D(r-c.r,g-c.g,b-c.b); - } - - /** Component-wise multiplication */ - aiColor3D operator*(const aiColor3D& c) const { - return aiColor3D(r*c.r,g*c.g,b*c.b); - } - - /** Multiply with a scalar */ - aiColor3D operator*(float f) const { - return aiColor3D(r*f,g*f,b*f); - } - - /** Access a specific color component */ - float operator[](unsigned int i) const { - return *(&r + i); - } - - /** Access a specific color component */ - float& operator[](unsigned int i) { - return *(&r + i); - } - - /** Check whether a color is black */ - bool IsBlack() const { - static const float epsilon = 10e-3f; - return std::fabs( r ) < epsilon && std::fabs( g ) < epsilon && std::fabs( b ) < epsilon; - } - -#endif // !__cplusplus - - //! Red, green and blue color values - float r, g, b; -} PACK_STRUCT; // !struct aiColor3D -#include "./Compiler/poppack1.h" - -// ---------------------------------------------------------------------------------- -/** Represents an UTF-8 string, zero byte terminated. - * - * The character set of an aiString is explicitly defined to be UTF-8. This Unicode - * transformation was chosen in the belief that most strings in 3d files are limited - * to ASCII, thus the character set needed to be strictly ASCII compatible. - * - * Most text file loaders provide proper Unicode input file handling, special unicode - * characters are correctly transcoded to UTF8 and are kept throughout the libraries' - * import pipeline. - * - * For most applications, it will be absolutely sufficient to interpret the - * aiString as ASCII data and work with it as one would work with a plain char*. - * Windows users in need of proper support for i.e asian characters can use the - * MultiByteToWideChar(), WideCharToMultiByte() WinAPI functionality to convert the - * UTF-8 strings to their working character set (i.e. MBCS, WideChar). - * - * We use this representation instead of std::string to be C-compatible. The - * (binary) length of such a string is limited to MAXLEN characters (including the - * the terminating zero). -*/ -struct aiString -{ -#ifdef __cplusplus - /** Default constructor, the string is set to have zero length */ - aiString() : - length(0) - { - data[0] = '\0'; - -#ifdef ASSIMP_BUILD_DEBUG - // Debug build: overwrite the string on its full length with ESC (27) - memset(data+1,27,MAXLEN-1); -#endif - } - - /** Copy constructor */ - aiString(const aiString& rOther) : - length(rOther.length) - { - // Crop the string to the maximum length - length = length>=MAXLEN?MAXLEN-1:length; - memcpy( data, rOther.data, length); - data[length] = '\0'; - } - - /** Constructor from std::string */ - explicit aiString(const std::string& pString) : - length(pString.length()) - { - length = length>=MAXLEN?MAXLEN-1:length; - memcpy( data, pString.c_str(), length); - data[length] = '\0'; - } - - /** Copy a std::string to the aiString */ - void Set( const std::string& pString) { - if( pString.length() > MAXLEN - 1) { - return; - } - length = pString.length(); - memcpy( data, pString.c_str(), length); - data[length] = 0; - } - - /** Copy a const char* to the aiString */ - void Set( const char* sz) { - const size_t len = ::strlen(sz); - if( len > MAXLEN - 1) { - return; - } - length = len; - memcpy( data, sz, len); - data[len] = 0; - } - - /** Assign a const char* to the string */ - aiString& operator = (const char* sz) { - Set(sz); - return *this; - } - - /** Assign a cstd::string to the string */ - aiString& operator = ( const std::string& pString) { - Set(pString); - return *this; - } - - /** Comparison operator */ - bool operator==(const aiString& other) const { - return (length == other.length && 0 == memcmp(data,other.data,length)); - } - - /** Inverse comparison operator */ - bool operator!=(const aiString& other) const { - return (length != other.length || 0 != memcmp(data,other.data,length)); - } - - /** Append a string to the string */ - void Append (const char* app) { - const size_t len = ::strlen(app); - if (!len) { - return; - } - if (length + len >= MAXLEN) { - return; - } - - memcpy(&data[length],app,len+1); - length += len; - } - - /** Clear the string - reset its length to zero */ - void Clear () { - length = 0; - data[0] = '\0'; - -#ifdef ASSIMP_BUILD_DEBUG - // Debug build: overwrite the string on its full length with ESC (27) - memset(data+1,27,MAXLEN-1); -#endif - } - - /** Returns a pointer to the underlying zero-terminated array of characters */ - const char* C_Str() const { - return data; - } - -#endif // !__cplusplus - - /** Binary length of the string excluding the terminal 0. This is NOT the - * logical length of strings containing UTF-8 multibyte sequences! It's - * the number of bytes from the beginning of the string to its end.*/ - size_t length; - - /** String buffer. Size limit is MAXLEN */ - char data[MAXLEN]; -} ; // !struct aiString - - -// ---------------------------------------------------------------------------------- -/** Standard return type for some library functions. - * Rarely used, and if, mostly in the C API. - */ -typedef enum aiReturn -{ - /** Indicates that a function was successful */ - aiReturn_SUCCESS = 0x0, - - /** Indicates that a function failed */ - aiReturn_FAILURE = -0x1, - - /** Indicates that not enough memory was available - * to perform the requested operation - */ - aiReturn_OUTOFMEMORY = -0x3, - - /** @cond never - * Force 32-bit size enum - */ - _AI_ENFORCE_ENUM_SIZE = 0x7fffffff - - /// @endcond -} aiReturn; // !enum aiReturn - -// just for backwards compatibility, don't use these constants anymore -#define AI_SUCCESS aiReturn_SUCCESS -#define AI_FAILURE aiReturn_FAILURE -#define AI_OUTOFMEMORY aiReturn_OUTOFMEMORY - -// ---------------------------------------------------------------------------------- -/** Seek origins (for the virtual file system API). - * Much cooler than using SEEK_SET, SEEK_CUR or SEEK_END. - */ -enum aiOrigin -{ - /** Beginning of the file */ - aiOrigin_SET = 0x0, - - /** Current position of the file pointer */ - aiOrigin_CUR = 0x1, - - /** End of the file, offsets must be negative */ - aiOrigin_END = 0x2, - - /** @cond never - * Force 32-bit size enum - */ - _AI_ORIGIN_ENFORCE_ENUM_SIZE = 0x7fffffff - - /// @endcond -}; // !enum aiOrigin - -// ---------------------------------------------------------------------------------- -/** @brief Enumerates predefined log streaming destinations. - * Logging to these streams can be enabled with a single call to - * #LogStream::createDefaultStream. - */ -enum aiDefaultLogStream -{ - /** Stream the log to a file */ - aiDefaultLogStream_FILE = 0x1, - - /** Stream the log to std::cout */ - aiDefaultLogStream_STDOUT = 0x2, - - /** Stream the log to std::cerr */ - aiDefaultLogStream_STDERR = 0x4, - - /** MSVC only: Stream the log the the debugger - * (this relies on OutputDebugString from the Win32 SDK) - */ - aiDefaultLogStream_DEBUGGER = 0x8, - - /** @cond never - * Force 32-bit size enum - */ - _AI_DLS_ENFORCE_ENUM_SIZE = 0x7fffffff - /// @endcond -}; // !enum aiDefaultLogStream - -// just for backwards compatibility, don't use these constants anymore -#define DLS_FILE aiDefaultLogStream_FILE -#define DLS_STDOUT aiDefaultLogStream_STDOUT -#define DLS_STDERR aiDefaultLogStream_STDERR -#define DLS_DEBUGGER aiDefaultLogStream_DEBUGGER - -// ---------------------------------------------------------------------------------- -/** Stores the memory requirements for different components (e.g. meshes, materials, - * animations) of an import. All sizes are in bytes. - * @see Importer::GetMemoryRequirements() -*/ -struct aiMemoryInfo -{ -#ifdef __cplusplus - - /** Default constructor */ - aiMemoryInfo() - : textures (0) - , materials (0) - , meshes (0) - , nodes (0) - , animations (0) - , cameras (0) - , lights (0) - , total (0) - {} - -#endif - - /** Storage allocated for texture data */ - unsigned int textures; - - /** Storage allocated for material data */ - unsigned int materials; - - /** Storage allocated for mesh data */ - unsigned int meshes; - - /** Storage allocated for node data */ - unsigned int nodes; - - /** Storage allocated for animation data */ - unsigned int animations; - - /** Storage allocated for camera data */ - unsigned int cameras; - - /** Storage allocated for light data */ - unsigned int lights; - - /** Total storage allocated for the full import. */ - unsigned int total; -}; // !struct aiMemoryInfo - -#ifdef __cplusplus -} -#endif //! __cplusplus - -// Include implementation files -#include "vector2.inl" -#include "vector3.inl" -#include "color4.inl" -#include "quaternion.inl" -#include "matrix3x3.inl" -#include "matrix4x4.inl" -#endif diff --git a/thirdparty/include/assimp/vector2.h b/thirdparty/include/assimp/vector2.h deleted file mode 100644 index 199743e26..000000000 --- a/thirdparty/include/assimp/vector2.h +++ /dev/null @@ -1,113 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ -/** @file vector2.h - * @brief 2D vector structure, including operators when compiling in C++ - */ -#ifndef AI_VECTOR2D_H_INC -#define AI_VECTOR2D_H_INC - -#ifdef __cplusplus -# include -#else -# include -#endif - -#include "./Compiler/pushpack1.h" - -// ---------------------------------------------------------------------------------- -/** Represents a two-dimensional vector. - */ - -#ifdef __cplusplus -template -class aiVector2t -{ -public: - - aiVector2t () : x(), y() {} - aiVector2t (TReal _x, TReal _y) : x(_x), y(_y) {} - explicit aiVector2t (TReal _xyz) : x(_xyz), y(_xyz) {} - aiVector2t (const aiVector2t& o) : x(o.x), y(o.y) {} - -public: - - void Set( TReal pX, TReal pY); - TReal SquareLength() const ; - TReal Length() const ; - aiVector2t& Normalize(); - -public: - - const aiVector2t& operator += (const aiVector2t& o); - const aiVector2t& operator -= (const aiVector2t& o); - const aiVector2t& operator *= (TReal f); - const aiVector2t& operator /= (TReal f); - - TReal operator[](unsigned int i) const; - TReal& operator[](unsigned int i); - - bool operator== (const aiVector2t& other) const; - bool operator!= (const aiVector2t& other) const; - - bool Equal(const aiVector2t& other, TReal epsilon = 1e-6) const; - - aiVector2t& operator= (TReal f); - const aiVector2t SymMul(const aiVector2t& o); - - template - operator aiVector2t () const; - - TReal x, y; -} PACK_STRUCT; - -typedef aiVector2t aiVector2D; - -#else - -struct aiVector2D { - float x, y; -}; - -#endif // __cplusplus - -#include "./Compiler/poppack1.h" - -#endif // AI_VECTOR2D_H_INC diff --git a/thirdparty/include/assimp/vector2.inl b/thirdparty/include/assimp/vector2.inl deleted file mode 100644 index ae823fc1a..000000000 --- a/thirdparty/include/assimp/vector2.inl +++ /dev/null @@ -1,224 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file vector2.inl - * @brief Inline implementation of aiVector2t operators - */ -#ifndef AI_VECTOR2D_INL_INC -#define AI_VECTOR2D_INL_INC - -#ifdef __cplusplus -#include "vector2.h" - -#include - -// ------------------------------------------------------------------------------------------------ -template -template -aiVector2t::operator aiVector2t () const { - return aiVector2t(static_cast(x),static_cast(y)); -} -// ------------------------------------------------------------------------------------------------ -template -void aiVector2t::Set( TReal pX, TReal pY) { - x = pX; y = pY; -} - -// ------------------------------------------------------------------------------------------------ -template -TReal aiVector2t::SquareLength() const { - return x*x + y*y; -} - -// ------------------------------------------------------------------------------------------------ -template -TReal aiVector2t::Length() const { - return std::sqrt( SquareLength()); -} - -// ------------------------------------------------------------------------------------------------ -template -aiVector2t& aiVector2t::Normalize() { - *this /= Length(); - return *this; -} - -// ------------------------------------------------------------------------------------------------ -template -const aiVector2t& aiVector2t::operator += (const aiVector2t& o) { - x += o.x; y += o.y; - return *this; -} - -// ------------------------------------------------------------------------------------------------ -template -const aiVector2t& aiVector2t::operator -= (const aiVector2t& o) { - x -= o.x; y -= o.y; - return *this; -} - -// ------------------------------------------------------------------------------------------------ -template -const aiVector2t& aiVector2t::operator *= (TReal f) { - x *= f; y *= f; - return *this; -} - -// ------------------------------------------------------------------------------------------------ -template -const aiVector2t& aiVector2t::operator /= (TReal f) { - x /= f; y /= f; - return *this; -} - -// ------------------------------------------------------------------------------------------------ -template -TReal aiVector2t::operator[](unsigned int i) const { - return *(&x + i); -} - -// ------------------------------------------------------------------------------------------------ -template -TReal& aiVector2t::operator[](unsigned int i) { - return *(&x + i); -} - -// ------------------------------------------------------------------------------------------------ -template -bool aiVector2t::operator== (const aiVector2t& other) const { - return x == other.x && y == other.y; -} - -// ------------------------------------------------------------------------------------------------ -template -bool aiVector2t::operator!= (const aiVector2t& other) const { - return x != other.x || y != other.y; -} - -// --------------------------------------------------------------------------- -template -bool aiVector2t::Equal(const aiVector2t& other, TReal epsilon) const { - return - std::abs(x - other.x) <= epsilon && - std::abs(y - other.y) <= epsilon; -} - -// ------------------------------------------------------------------------------------------------ -template -aiVector2t& aiVector2t::operator= (TReal f) { - x = y = f; - return *this; -} - -// ------------------------------------------------------------------------------------------------ -template -const aiVector2t aiVector2t::SymMul(const aiVector2t& o) { - return aiVector2t(x*o.x,y*o.y); -} - - -// ------------------------------------------------------------------------------------------------ -// symmetric addition -template -inline aiVector2t operator + (const aiVector2t& v1, const aiVector2t& v2) -{ - return aiVector2t( v1.x + v2.x, v1.y + v2.y); -} - -// ------------------------------------------------------------------------------------------------ -// symmetric subtraction -template -inline aiVector2t operator - (const aiVector2t& v1, const aiVector2t& v2) -{ - return aiVector2t( v1.x - v2.x, v1.y - v2.y); -} - -// ------------------------------------------------------------------------------------------------ -// scalar product -template -inline TReal operator * (const aiVector2t& v1, const aiVector2t& v2) -{ - return v1.x*v2.x + v1.y*v2.y; -} - -// ------------------------------------------------------------------------------------------------ -// scalar multiplication -template -inline aiVector2t operator * ( TReal f, const aiVector2t& v) -{ - return aiVector2t( f*v.x, f*v.y); -} - -// ------------------------------------------------------------------------------------------------ -// and the other way around -template -inline aiVector2t operator * ( const aiVector2t& v, TReal f) -{ - return aiVector2t( f*v.x, f*v.y); -} - -// ------------------------------------------------------------------------------------------------ -// scalar division -template -inline aiVector2t operator / ( const aiVector2t& v, TReal f) -{ - - return v * (1/f); -} - -// ------------------------------------------------------------------------------------------------ -// vector division -template -inline aiVector2t operator / ( const aiVector2t& v, const aiVector2t& v2) -{ - return aiVector2t(v.x / v2.x,v.y / v2.y); -} - -// ------------------------------------------------------------------------------------------------ -// vector negation -template -inline aiVector2t operator - ( const aiVector2t& v) -{ - return aiVector2t( -v.x, -v.y); -} - -#endif -#endif diff --git a/thirdparty/include/assimp/vector3.h b/thirdparty/include/assimp/vector3.h deleted file mode 100644 index 84f785f8f..000000000 --- a/thirdparty/include/assimp/vector3.h +++ /dev/null @@ -1,150 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ -/** @file vector3.h - * @brief 3D vector structure, including operators when compiling in C++ - */ -#ifndef AI_VECTOR3D_H_INC -#define AI_VECTOR3D_H_INC - -#ifdef __cplusplus -# include -#else -# include -#endif - -#include "./Compiler/pushpack1.h" - -#ifdef __cplusplus - -template class aiMatrix3x3t; -template class aiMatrix4x4t; - -// --------------------------------------------------------------------------- -/** Represents a three-dimensional vector. */ -template -class aiVector3t -{ -public: - - aiVector3t () : x(), y(), z() {} - aiVector3t (TReal _x, TReal _y, TReal _z) : x(_x), y(_y), z(_z) {} - explicit aiVector3t (TReal _xyz) : x(_xyz), y(_xyz), z(_xyz) {} - aiVector3t (const aiVector3t& o) : x(o.x), y(o.y), z(o.z) {} - -public: - - // combined operators - const aiVector3t& operator += (const aiVector3t& o); - const aiVector3t& operator -= (const aiVector3t& o); - const aiVector3t& operator *= (TReal f); - const aiVector3t& operator /= (TReal f); - - // transform vector by matrix - aiVector3t& operator *= (const aiMatrix3x3t& mat); - aiVector3t& operator *= (const aiMatrix4x4t& mat); - - // access a single element - TReal operator[](unsigned int i) const; - TReal& operator[](unsigned int i); - - // comparison - bool operator== (const aiVector3t& other) const; - bool operator!= (const aiVector3t& other) const; - bool operator < (const aiVector3t& other) const; - - bool Equal(const aiVector3t& other, TReal epsilon = 1e-6) const; - - template - operator aiVector3t () const; - -public: - - /** @brief Set the components of a vector - * @param pX X component - * @param pY Y component - * @param pZ Z component */ - void Set( TReal pX, TReal pY, TReal pZ); - - /** @brief Get the squared length of the vector - * @return Square length */ - TReal SquareLength() const; - - - /** @brief Get the length of the vector - * @return length */ - TReal Length() const; - - - /** @brief Normalize the vector */ - aiVector3t& Normalize(); - - /** @brief Normalize the vector with extra check for zero vectors */ - aiVector3t& NormalizeSafe(); - - /** @brief Componentwise multiplication of two vectors - * - * Note that vec*vec yields the dot product. - * @param o Second factor */ - const aiVector3t SymMul(const aiVector3t& o); - - TReal x, y, z; -} PACK_STRUCT; - - -typedef aiVector3t aiVector3D; - -#else - -struct aiVector3D { - float x, y, z; -} PACK_STRUCT; - -#endif // __cplusplus - -#include "./Compiler/poppack1.h" - -#ifdef __cplusplus - - - -#endif // __cplusplus - -#endif // AI_VECTOR3D_H_INC diff --git a/thirdparty/include/assimp/vector3.inl b/thirdparty/include/assimp/vector3.inl deleted file mode 100644 index 0d0d62968..000000000 --- a/thirdparty/include/assimp/vector3.inl +++ /dev/null @@ -1,236 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file vector3.inl - * @brief Inline implementation of aiVector3t operators - */ -#ifndef AI_VECTOR3D_INL_INC -#define AI_VECTOR3D_INL_INC - -#ifdef __cplusplus -#include "vector3.h" - -#include - -// ------------------------------------------------------------------------------------------------ -/** Transformation of a vector by a 3x3 matrix */ -template -inline aiVector3t operator * (const aiMatrix3x3t& pMatrix, const aiVector3t& pVector) -{ - aiVector3t res; - res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z; - res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z; - res.z = pMatrix.c1 * pVector.x + pMatrix.c2 * pVector.y + pMatrix.c3 * pVector.z; - return res; -} - -// ------------------------------------------------------------------------------------------------ -/** Transformation of a vector by a 4x4 matrix */ -template -inline aiVector3t operator * (const aiMatrix4x4t& pMatrix, const aiVector3t& pVector) -{ - aiVector3t res; - res.x = pMatrix.a1 * pVector.x + pMatrix.a2 * pVector.y + pMatrix.a3 * pVector.z + pMatrix.a4; - res.y = pMatrix.b1 * pVector.x + pMatrix.b2 * pVector.y + pMatrix.b3 * pVector.z + pMatrix.b4; - res.z = pMatrix.c1 * pVector.x + pMatrix.c2 * pVector.y + pMatrix.c3 * pVector.z + pMatrix.c4; - return res; -} -// ------------------------------------------------------------------------------------------------ -template -template -aiVector3t::operator aiVector3t () const { - return aiVector3t(static_cast(x),static_cast(y),static_cast(z)); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE void aiVector3t::Set( TReal pX, TReal pY, TReal pZ) { - x = pX; y = pY; z = pZ; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE TReal aiVector3t::SquareLength() const { - return x*x + y*y + z*z; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE TReal aiVector3t::Length() const { - return std::sqrt( SquareLength()); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiVector3t& aiVector3t::Normalize() { - *this /= Length(); return *this; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiVector3t& aiVector3t::NormalizeSafe() { - TReal len = Length(); - if (len > static_cast(0)) - *this /= len; - return *this; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE const aiVector3t& aiVector3t::operator += (const aiVector3t& o) { - x += o.x; y += o.y; z += o.z; return *this; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE const aiVector3t& aiVector3t::operator -= (const aiVector3t& o) { - x -= o.x; y -= o.y; z -= o.z; return *this; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE const aiVector3t& aiVector3t::operator *= (TReal f) { - x *= f; y *= f; z *= f; return *this; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE const aiVector3t& aiVector3t::operator /= (TReal f) { - x /= f; y /= f; z /= f; return *this; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiVector3t& aiVector3t::operator *= (const aiMatrix3x3t& mat){ - return(*this = mat * (*this)); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE aiVector3t& aiVector3t::operator *= (const aiMatrix4x4t& mat){ - return(*this = mat * (*this)); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE TReal aiVector3t::operator[](unsigned int i) const { - return *(&x + i); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE TReal& aiVector3t::operator[](unsigned int i) { - return *(&x + i); -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE bool aiVector3t::operator== (const aiVector3t& other) const { - return x == other.x && y == other.y && z == other.z; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE bool aiVector3t::operator!= (const aiVector3t& other) const { - return x != other.x || y != other.y || z != other.z; -} -// --------------------------------------------------------------------------- -template -AI_FORCE_INLINE bool aiVector3t::Equal(const aiVector3t& other, TReal epsilon) const { - return - std::abs(x - other.x) <= epsilon && - std::abs(y - other.y) <= epsilon && - std::abs(z - other.z) <= epsilon; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE bool aiVector3t::operator < (const aiVector3t& other) const { - return x != other.x ? x < other.x : y != other.y ? y < other.y : z < other.z; -} -// ------------------------------------------------------------------------------------------------ -template -AI_FORCE_INLINE const aiVector3t aiVector3t::SymMul(const aiVector3t& o) { - return aiVector3t(x*o.x,y*o.y,z*o.z); -} -// ------------------------------------------------------------------------------------------------ -// symmetric addition -template -AI_FORCE_INLINE aiVector3t operator + (const aiVector3t& v1, const aiVector3t& v2) { - return aiVector3t( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); -} -// ------------------------------------------------------------------------------------------------ -// symmetric subtraction -template -AI_FORCE_INLINE aiVector3t operator - (const aiVector3t& v1, const aiVector3t& v2) { - return aiVector3t( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); -} -// ------------------------------------------------------------------------------------------------ -// scalar product -template -AI_FORCE_INLINE TReal operator * (const aiVector3t& v1, const aiVector3t& v2) { - return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; -} -// ------------------------------------------------------------------------------------------------ -// scalar multiplication -template -AI_FORCE_INLINE aiVector3t operator * ( TReal f, const aiVector3t& v) { - return aiVector3t( f*v.x, f*v.y, f*v.z); -} -// ------------------------------------------------------------------------------------------------ -// and the other way around -template -AI_FORCE_INLINE aiVector3t operator * ( const aiVector3t& v, TReal f) { - return aiVector3t( f*v.x, f*v.y, f*v.z); -} -// ------------------------------------------------------------------------------------------------ -// scalar division -template -AI_FORCE_INLINE aiVector3t operator / ( const aiVector3t& v, TReal f) { - return v * (1/f); -} -// ------------------------------------------------------------------------------------------------ -// vector division -template -AI_FORCE_INLINE aiVector3t operator / ( const aiVector3t& v, const aiVector3t& v2) { - return aiVector3t(v.x / v2.x,v.y / v2.y,v.z / v2.z); -} -// ------------------------------------------------------------------------------------------------ -// cross product -template -AI_FORCE_INLINE aiVector3t operator ^ ( const aiVector3t& v1, const aiVector3t& v2) { - return aiVector3t( v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x); -} -// ------------------------------------------------------------------------------------------------ -// vector negation -template -AI_FORCE_INLINE aiVector3t operator - ( const aiVector3t& v) { - return aiVector3t( -v.x, -v.y, -v.z); -} - -// ------------------------------------------------------------------------------------------------ - -#endif // __cplusplus -#endif // AI_VECTOR3D_INL_INC diff --git a/thirdparty/include/assimp/version.h b/thirdparty/include/assimp/version.h deleted file mode 100644 index 403798c1b..000000000 --- a/thirdparty/include/assimp/version.h +++ /dev/null @@ -1,105 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2016, assimp team - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -/** @file version.h - * @brief Functions to query the version of the Assimp runtime, check - * compile flags, ... - */ -#ifndef INCLUDED_AI_VERSION_H -#define INCLUDED_AI_VERSION_H - -#include "defs.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// --------------------------------------------------------------------------- -/** @brief Returns a string with legal copyright and licensing information - * about Assimp. The string may include multiple lines. - * @return Pointer to static string. - */ -ASSIMP_API const char* aiGetLegalString (void); - -// --------------------------------------------------------------------------- -/** @brief Returns the current minor version number of Assimp. - * @return Minor version of the Assimp runtime the application was - * linked/built against - */ -ASSIMP_API unsigned int aiGetVersionMinor (void); - -// --------------------------------------------------------------------------- -/** @brief Returns the current major version number of Assimp. - * @return Major version of the Assimp runtime the application was - * linked/built against - */ -ASSIMP_API unsigned int aiGetVersionMajor (void); - -// --------------------------------------------------------------------------- -/** @brief Returns the repository revision of the Assimp runtime. - * @return SVN Repository revision number of the Assimp runtime the - * application was linked/built against. - */ -ASSIMP_API unsigned int aiGetVersionRevision (void); - -//! Assimp was compiled as a shared object (Windows: DLL) -#define ASSIMP_CFLAGS_SHARED 0x1 -//! Assimp was compiled against STLport -#define ASSIMP_CFLAGS_STLPORT 0x2 -//! Assimp was compiled as a debug build -#define ASSIMP_CFLAGS_DEBUG 0x4 - -//! Assimp was compiled with ASSIMP_BUILD_BOOST_WORKAROUND defined -#define ASSIMP_CFLAGS_NOBOOST 0x8 -//! Assimp was compiled with ASSIMP_BUILD_SINGLETHREADED defined -#define ASSIMP_CFLAGS_SINGLETHREADED 0x10 - -// --------------------------------------------------------------------------- -/** @brief Returns assimp's compile flags - * @return Any bitwise combination of the ASSIMP_CFLAGS_xxx constants. - */ -ASSIMP_API unsigned int aiGetCompileFlags (void); - -#ifdef __cplusplus -} // end extern "C" -#endif - -#endif // !! #ifndef INCLUDED_AI_VERSION_H diff --git a/thirdparty/include/chipmunk/chipmunk.h b/thirdparty/include/chipmunk/chipmunk.h deleted file mode 100644 index 128019063..000000000 --- a/thirdparty/include/chipmunk/chipmunk.h +++ /dev/null @@ -1,232 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef CHIPMUNK_H -#define CHIPMUNK_H - -#include -#include - -#ifndef alloca - #ifdef _WIN32 - #include - #elif defined(__FreeBSD__) - /* already included in */ - #else - #include - #endif -#endif - -#ifdef _WIN32 - #define CP_EXPORT __declspec(dllexport) -#else - #define CP_EXPORT -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -CP_EXPORT void cpMessage(const char *condition, const char *file, int line, int isError, int isHardError, const char *message, ...); -#ifdef NDEBUG - #define cpAssertWarn(__condition__, ...) - #define cpAssertSoft(__condition__, ...) -#else - #define cpAssertSoft(__condition__, ...) if(!(__condition__)){cpMessage(#__condition__, __FILE__, __LINE__, 1, 0, __VA_ARGS__); abort();} - #define cpAssertWarn(__condition__, ...) if(!(__condition__)) cpMessage(#__condition__, __FILE__, __LINE__, 0, 0, __VA_ARGS__) -#endif - -// Hard assertions are used in situations where the program definitely will crash anyway, and the reason is inexpensive to detect. -#define cpAssertHard(__condition__, ...) if(!(__condition__)){cpMessage(#__condition__, __FILE__, __LINE__, 1, 1, __VA_ARGS__); abort();} - -#include "chipmunk_types.h" - -/// @defgroup misc Misc -/// @{ - -/// Allocated size for various Chipmunk buffers -#ifndef CP_BUFFER_BYTES - #define CP_BUFFER_BYTES (32*1024) -#endif - -#ifndef cpcalloc - /// Chipmunk calloc() alias. - #define cpcalloc calloc -#endif - -#ifndef cprealloc - /// Chipmunk realloc() alias. - #define cprealloc realloc -#endif - -#ifndef cpfree - /// Chipmunk free() alias. - #define cpfree free -#endif - -typedef struct cpArray cpArray; -typedef struct cpHashSet cpHashSet; - -typedef struct cpBody cpBody; - -typedef struct cpShape cpShape; -typedef struct cpCircleShape cpCircleShape; -typedef struct cpSegmentShape cpSegmentShape; -typedef struct cpPolyShape cpPolyShape; - -typedef struct cpConstraint cpConstraint; -typedef struct cpPinJoint cpPinJoint; -typedef struct cpSlideJoint cpSlideJoint; -typedef struct cpPivotJoint cpPivotJoint; -typedef struct cpGrooveJoint cpGrooveJoint; -typedef struct cpDampedSpring cpDampedSpring; -typedef struct cpDampedRotarySpring cpDampedRotarySpring; -typedef struct cpRotaryLimitJoint cpRotaryLimitJoint; -typedef struct cpRatchetJoint cpRatchetJoint; -typedef struct cpGearJoint cpGearJoint; -typedef struct cpSimpleMotorJoint cpSimpleMotorJoint; - -typedef struct cpCollisionHandler cpCollisionHandler; -typedef struct cpContactPointSet cpContactPointSet; -typedef struct cpArbiter cpArbiter; - -typedef struct cpSpace cpSpace; - -#include "cpVect.h" -#include "cpBB.h" -#include "cpTransform.h" -#include "cpSpatialIndex.h" - -#include "cpArbiter.h" - -#include "cpBody.h" -#include "cpShape.h" -#include "cpPolyShape.h" - -#include "cpConstraint.h" - -#include "cpSpace.h" - -// Chipmunk 7.0.2 -#define CP_VERSION_MAJOR 7 -#define CP_VERSION_MINOR 0 -#define CP_VERSION_RELEASE 2 - -/// Version string. -CP_EXPORT extern const char *cpVersionString; - -/// Calculate the moment of inertia for a circle. -/// @c r1 and @c r2 are the inner and outer diameters. A solid circle has an inner diameter of 0. -CP_EXPORT cpFloat cpMomentForCircle(cpFloat m, cpFloat r1, cpFloat r2, cpVect offset); - -/// Calculate area of a hollow circle. -/// @c r1 and @c r2 are the inner and outer diameters. A solid circle has an inner diameter of 0. -CP_EXPORT cpFloat cpAreaForCircle(cpFloat r1, cpFloat r2); - -/// Calculate the moment of inertia for a line segment. -/// Beveling radius is not supported. -CP_EXPORT cpFloat cpMomentForSegment(cpFloat m, cpVect a, cpVect b, cpFloat radius); - -/// Calculate the area of a fattened (capsule shaped) line segment. -CP_EXPORT cpFloat cpAreaForSegment(cpVect a, cpVect b, cpFloat radius); - -/// Calculate the moment of inertia for a solid polygon shape assuming it's center of gravity is at it's centroid. The offset is added to each vertex. -CP_EXPORT cpFloat cpMomentForPoly(cpFloat m, int count, const cpVect *verts, cpVect offset, cpFloat radius); - -/// Calculate the signed area of a polygon. A Clockwise winding gives positive area. -/// This is probably backwards from what you expect, but matches Chipmunk's the winding for poly shapes. -CP_EXPORT cpFloat cpAreaForPoly(const int count, const cpVect *verts, cpFloat radius); - -/// Calculate the natural centroid of a polygon. -CP_EXPORT cpVect cpCentroidForPoly(const int count, const cpVect *verts); - -/// Calculate the moment of inertia for a solid box. -CP_EXPORT cpFloat cpMomentForBox(cpFloat m, cpFloat width, cpFloat height); - -/// Calculate the moment of inertia for a solid box. -CP_EXPORT cpFloat cpMomentForBox2(cpFloat m, cpBB box); - -/// Calculate the convex hull of a given set of points. Returns the count of points in the hull. -/// @c result must be a pointer to a @c cpVect array with at least @c count elements. If @c verts == @c result, then @c verts will be reduced inplace. -/// @c first is an optional pointer to an integer to store where the first vertex in the hull came from (i.e. verts[first] == result[0]) -/// @c tol is the allowed amount to shrink the hull when simplifying it. A tolerance of 0.0 creates an exact hull. -CP_EXPORT int cpConvexHull(int count, const cpVect *verts, cpVect *result, int *first, cpFloat tol); - -/// Convenience macro to work with cpConvexHull. -/// @c count and @c verts is the input array passed to cpConvexHull(). -/// @c count_var and @c verts_var are the names of the variables the macro creates to store the result. -/// The output vertex array is allocated on the stack using alloca() so it will be freed automatically, but cannot be returned from the current scope. -#define CP_CONVEX_HULL(__count__, __verts__, __count_var__, __verts_var__) \ -cpVect *__verts_var__ = (cpVect *)alloca(__count__*sizeof(cpVect)); \ -int __count_var__ = cpConvexHull(__count__, __verts__, __verts_var__, NULL, 0.0); \ - -/// Returns the closest point on the line segment ab, to the point p. -static inline cpVect -cpClosetPointOnSegment(const cpVect p, const cpVect a, const cpVect b) -{ - cpVect delta = cpvsub(a, b); - cpFloat t = cpfclamp01(cpvdot(delta, cpvsub(p, b))/cpvlengthsq(delta)); - return cpvadd(b, cpvmult(delta, t)); -} - -#if defined(__has_extension) -#if __has_extension(blocks) -// Define alternate block based alternatives for a few of the callback heavy functions. -// Collision handlers are post-step callbacks are not included to avoid memory management issues. -// If you want to use blocks for those and are aware of how to correctly manage the memory, the implementation is trivial. - -void cpSpaceEachBody_b(cpSpace *space, void (^block)(cpBody *body)); -void cpSpaceEachShape_b(cpSpace *space, void (^block)(cpShape *shape)); -void cpSpaceEachConstraint_b(cpSpace *space, void (^block)(cpConstraint *constraint)); - -void cpBodyEachShape_b(cpBody *body, void (^block)(cpShape *shape)); -void cpBodyEachConstraint_b(cpBody *body, void (^block)(cpConstraint *constraint)); -void cpBodyEachArbiter_b(cpBody *body, void (^block)(cpArbiter *arbiter)); - -typedef void (^cpSpacePointQueryBlock)(cpShape *shape, cpVect point, cpFloat distance, cpVect gradient); -void cpSpacePointQuery_b(cpSpace *space, cpVect point, cpFloat maxDistance, cpShapeFilter filter, cpSpacePointQueryBlock block); - -typedef void (^cpSpaceSegmentQueryBlock)(cpShape *shape, cpVect point, cpVect normal, cpFloat alpha); -void cpSpaceSegmentQuery_b(cpSpace *space, cpVect start, cpVect end, cpFloat radius, cpShapeFilter filter, cpSpaceSegmentQueryBlock block); - -typedef void (^cpSpaceBBQueryBlock)(cpShape *shape); -void cpSpaceBBQuery_b(cpSpace *space, cpBB bb, cpShapeFilter filter, cpSpaceBBQueryBlock block); - -typedef void (^cpSpaceShapeQueryBlock)(cpShape *shape, cpContactPointSet *points); -cpBool cpSpaceShapeQuery_b(cpSpace *space, cpShape *shape, cpSpaceShapeQueryBlock block); - -#endif -#endif - - -//@} - -#ifdef __cplusplus -} - -static inline cpVect operator *(const cpVect v, const cpFloat s){return cpvmult(v, s);} -static inline cpVect operator +(const cpVect v1, const cpVect v2){return cpvadd(v1, v2);} -static inline cpVect operator -(const cpVect v1, const cpVect v2){return cpvsub(v1, v2);} -static inline cpBool operator ==(const cpVect v1, const cpVect v2){return cpveql(v1, v2);} -static inline cpVect operator -(const cpVect v){return cpvneg(v);} - -#endif -#endif diff --git a/thirdparty/include/chipmunk/chipmunk_ffi.h b/thirdparty/include/chipmunk/chipmunk_ffi.h deleted file mode 100644 index 86e3d9fcd..000000000 --- a/thirdparty/include/chipmunk/chipmunk_ffi.h +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifdef CHIPMUNK_FFI - -// Create non static inlined copies of Chipmunk functions, useful for working with dynamic FFIs -// For many languages, it may be faster to reimplement these functions natively instead. -// Note: This file should only be included by chipmunk.c. - -#ifdef _MSC_VER - #if _MSC_VER >= 1600 - #define MAKE_REF(name) CP_EXPORT decltype(name) *_##name = name - #else - #define MAKE_REF(name) - #endif -#else - #define MAKE_REF(name) __typeof__(name) *_##name = name -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -MAKE_REF(cpv); // makes a variable named _cpv that contains the function pointer for cpv() -MAKE_REF(cpveql); -MAKE_REF(cpvadd); -MAKE_REF(cpvneg); -MAKE_REF(cpvsub); -MAKE_REF(cpvmult); -MAKE_REF(cpvdot); -MAKE_REF(cpvcross); -MAKE_REF(cpvperp); -MAKE_REF(cpvrperp); -MAKE_REF(cpvproject); -MAKE_REF(cpvforangle); -MAKE_REF(cpvtoangle); -MAKE_REF(cpvrotate); -MAKE_REF(cpvunrotate); -MAKE_REF(cpvlengthsq); -MAKE_REF(cpvlength); -MAKE_REF(cpvlerp); -MAKE_REF(cpvnormalize); -MAKE_REF(cpvclamp); -MAKE_REF(cpvlerpconst); -MAKE_REF(cpvdist); -MAKE_REF(cpvdistsq); -MAKE_REF(cpvnear); - -MAKE_REF(cpfmax); -MAKE_REF(cpfmin); -MAKE_REF(cpfabs); -MAKE_REF(cpfclamp); -MAKE_REF(cpflerp); -MAKE_REF(cpflerpconst); - -MAKE_REF(cpBBNew); -MAKE_REF(cpBBNewForExtents); -MAKE_REF(cpBBNewForCircle); -MAKE_REF(cpBBIntersects); -MAKE_REF(cpBBContainsBB); -MAKE_REF(cpBBContainsVect); -MAKE_REF(cpBBMerge); -MAKE_REF(cpBBExpand); -MAKE_REF(cpBBCenter); -MAKE_REF(cpBBArea); -MAKE_REF(cpBBMergedArea); -MAKE_REF(cpBBSegmentQuery); -MAKE_REF(cpBBIntersectsSegment); -MAKE_REF(cpBBClampVect); - -MAKE_REF(cpSpatialIndexDestroy); -MAKE_REF(cpSpatialIndexCount); -MAKE_REF(cpSpatialIndexEach); -MAKE_REF(cpSpatialIndexContains); -MAKE_REF(cpSpatialIndexInsert); -MAKE_REF(cpSpatialIndexRemove); -MAKE_REF(cpSpatialIndexReindex); -MAKE_REF(cpSpatialIndexReindexObject); -MAKE_REF(cpSpatialIndexSegmentQuery); -MAKE_REF(cpSpatialIndexQuery); -MAKE_REF(cpSpatialIndexReindexQuery); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/thirdparty/include/chipmunk/chipmunk_private.h b/thirdparty/include/chipmunk/chipmunk_private.h deleted file mode 100644 index a27fdec5e..000000000 --- a/thirdparty/include/chipmunk/chipmunk_private.h +++ /dev/null @@ -1,344 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef CHIPMUNK_PRIVATE_H -#define CHIPMUNK_PRIVATE_H - -#include "chipmunk/chipmunk.h" -#include "chipmunk/chipmunk_structs.h" - -#define CP_HASH_COEF (3344921057ul) -#define CP_HASH_PAIR(A, B) ((cpHashValue)(A)*CP_HASH_COEF ^ (cpHashValue)(B)*CP_HASH_COEF) - -// TODO: Eww. Magic numbers. -#define MAGIC_EPSILON 1e-5 - - -//MARK: cpArray - -cpArray *cpArrayNew(int size); - -void cpArrayFree(cpArray *arr); - -void cpArrayPush(cpArray *arr, void *object); -void *cpArrayPop(cpArray *arr); -void cpArrayDeleteObj(cpArray *arr, void *obj); -cpBool cpArrayContains(cpArray *arr, void *ptr); - -void cpArrayFreeEach(cpArray *arr, void (freeFunc)(void*)); - - -//MARK: cpHashSet - -typedef cpBool (*cpHashSetEqlFunc)(void *ptr, void *elt); -typedef void *(*cpHashSetTransFunc)(void *ptr, void *data); - -cpHashSet *cpHashSetNew(int size, cpHashSetEqlFunc eqlFunc); -void cpHashSetSetDefaultValue(cpHashSet *set, void *default_value); - -void cpHashSetFree(cpHashSet *set); - -int cpHashSetCount(cpHashSet *set); -void *cpHashSetInsert(cpHashSet *set, cpHashValue hash, void *ptr, cpHashSetTransFunc trans, void *data); -void *cpHashSetRemove(cpHashSet *set, cpHashValue hash, void *ptr); -void *cpHashSetFind(cpHashSet *set, cpHashValue hash, void *ptr); - -typedef void (*cpHashSetIteratorFunc)(void *elt, void *data); -void cpHashSetEach(cpHashSet *set, cpHashSetIteratorFunc func, void *data); - -typedef cpBool (*cpHashSetFilterFunc)(void *elt, void *data); -void cpHashSetFilter(cpHashSet *set, cpHashSetFilterFunc func, void *data); - - -//MARK: Bodies - -void cpBodyAddShape(cpBody *body, cpShape *shape); -void cpBodyRemoveShape(cpBody *body, cpShape *shape); - -//void cpBodyAccumulateMassForShape(cpBody *body, cpShape *shape); -void cpBodyAccumulateMassFromShapes(cpBody *body); - -void cpBodyRemoveConstraint(cpBody *body, cpConstraint *constraint); - - -//MARK: Spatial Index Functions - -cpSpatialIndex *cpSpatialIndexInit(cpSpatialIndex *index, cpSpatialIndexClass *klass, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); - - -//MARK: Arbiters - -cpArbiter* cpArbiterInit(cpArbiter *arb, cpShape *a, cpShape *b); - -static inline struct cpArbiterThread * -cpArbiterThreadForBody(cpArbiter *arb, cpBody *body) -{ - return (arb->body_a == body ? &arb->thread_a : &arb->thread_b); -} - -void cpArbiterUnthread(cpArbiter *arb); - -void cpArbiterUpdate(cpArbiter *arb, struct cpCollisionInfo *info, cpSpace *space); -void cpArbiterPreStep(cpArbiter *arb, cpFloat dt, cpFloat bias, cpFloat slop); -void cpArbiterApplyCachedImpulse(cpArbiter *arb, cpFloat dt_coef); -void cpArbiterApplyImpulse(cpArbiter *arb); - - -//MARK: Shapes/Collisions - -cpShape *cpShapeInit(cpShape *shape, const cpShapeClass *klass, cpBody *body, struct cpShapeMassInfo massInfo); - -static inline cpBool -cpShapeActive(cpShape *shape) -{ - // checks if the shape is added to a shape list. - // TODO could this just check the space now? - return (shape->prev || (shape->body && shape->body->shapeList == shape)); -} - -// Note: This function returns contact points with r1/r2 in absolute coordinates, not body relative. -struct cpCollisionInfo cpCollide(const cpShape *a, const cpShape *b, cpCollisionID id, struct cpContact *contacts); - -static inline void -CircleSegmentQuery(cpShape *shape, cpVect center, cpFloat r1, cpVect a, cpVect b, cpFloat r2, cpSegmentQueryInfo *info) -{ - cpVect da = cpvsub(a, center); - cpVect db = cpvsub(b, center); - cpFloat rsum = r1 + r2; - - cpFloat qa = cpvdot(da, da) - 2.0f*cpvdot(da, db) + cpvdot(db, db); - cpFloat qb = cpvdot(da, db) - cpvdot(da, da); - cpFloat det = qb*qb - qa*(cpvdot(da, da) - rsum*rsum); - - if(det >= 0.0f){ - cpFloat t = (-qb - cpfsqrt(det))/(qa); - if(0.0f<= t && t <= 1.0f){ - cpVect n = cpvnormalize(cpvlerp(da, db, t)); - - info->shape = shape; - info->point = cpvsub(cpvlerp(a, b, t), cpvmult(n, r2)); - info->normal = n; - info->alpha = t; - } - } -} - -static inline cpBool -cpShapeFilterReject(cpShapeFilter a, cpShapeFilter b) -{ - // Reject the collision if: - return ( - // They are in the same non-zero group. - (a.group != 0 && a.group == b.group) || - // One of the category/mask combinations fails. - (a.categories & b.mask) == 0 || - (b.categories & a.mask) == 0 - ); -} - -void cpLoopIndexes(const cpVect *verts, int count, int *start, int *end); - - -//MARK: Constraints -// TODO naming conventions here - -void cpConstraintInit(cpConstraint *constraint, const struct cpConstraintClass *klass, cpBody *a, cpBody *b); - -static inline void -cpConstraintActivateBodies(cpConstraint *constraint) -{ - cpBody *a = constraint->a; cpBodyActivate(a); - cpBody *b = constraint->b; cpBodyActivate(b); -} - -static inline cpVect -relative_velocity(cpBody *a, cpBody *b, cpVect r1, cpVect r2){ - cpVect v1_sum = cpvadd(a->v, cpvmult(cpvperp(r1), a->w)); - cpVect v2_sum = cpvadd(b->v, cpvmult(cpvperp(r2), b->w)); - - return cpvsub(v2_sum, v1_sum); -} - -static inline cpFloat -normal_relative_velocity(cpBody *a, cpBody *b, cpVect r1, cpVect r2, cpVect n){ - return cpvdot(relative_velocity(a, b, r1, r2), n); -} - -static inline void -apply_impulse(cpBody *body, cpVect j, cpVect r){ - body->v = cpvadd(body->v, cpvmult(j, body->m_inv)); - body->w += body->i_inv*cpvcross(r, j); -} - -static inline void -apply_impulses(cpBody *a , cpBody *b, cpVect r1, cpVect r2, cpVect j) -{ - apply_impulse(a, cpvneg(j), r1); - apply_impulse(b, j, r2); -} - -static inline void -apply_bias_impulse(cpBody *body, cpVect j, cpVect r) -{ - body->v_bias = cpvadd(body->v_bias, cpvmult(j, body->m_inv)); - body->w_bias += body->i_inv*cpvcross(r, j); -} - -static inline void -apply_bias_impulses(cpBody *a , cpBody *b, cpVect r1, cpVect r2, cpVect j) -{ - apply_bias_impulse(a, cpvneg(j), r1); - apply_bias_impulse(b, j, r2); -} - -static inline cpFloat -k_scalar_body(cpBody *body, cpVect r, cpVect n) -{ - cpFloat rcn = cpvcross(r, n); - return body->m_inv + body->i_inv*rcn*rcn; -} - -static inline cpFloat -k_scalar(cpBody *a, cpBody *b, cpVect r1, cpVect r2, cpVect n) -{ - cpFloat value = k_scalar_body(a, r1, n) + k_scalar_body(b, r2, n); - cpAssertSoft(value != 0.0, "Unsolvable collision or constraint."); - - return value; -} - -static inline cpMat2x2 -k_tensor(cpBody *a, cpBody *b, cpVect r1, cpVect r2) -{ - cpFloat m_sum = a->m_inv + b->m_inv; - - // start with Identity*m_sum - cpFloat k11 = m_sum, k12 = 0.0f; - cpFloat k21 = 0.0f, k22 = m_sum; - - // add the influence from r1 - cpFloat a_i_inv = a->i_inv; - cpFloat r1xsq = r1.x * r1.x * a_i_inv; - cpFloat r1ysq = r1.y * r1.y * a_i_inv; - cpFloat r1nxy = -r1.x * r1.y * a_i_inv; - k11 += r1ysq; k12 += r1nxy; - k21 += r1nxy; k22 += r1xsq; - - // add the influnce from r2 - cpFloat b_i_inv = b->i_inv; - cpFloat r2xsq = r2.x * r2.x * b_i_inv; - cpFloat r2ysq = r2.y * r2.y * b_i_inv; - cpFloat r2nxy = -r2.x * r2.y * b_i_inv; - k11 += r2ysq; k12 += r2nxy; - k21 += r2nxy; k22 += r2xsq; - - // invert - cpFloat det = k11*k22 - k12*k21; - cpAssertSoft(det != 0.0, "Unsolvable constraint."); - - cpFloat det_inv = 1.0f/det; - return cpMat2x2New( - k22*det_inv, -k12*det_inv, - -k21*det_inv, k11*det_inv - ); -} - -static inline cpFloat -bias_coef(cpFloat errorBias, cpFloat dt) -{ - return 1.0f - cpfpow(errorBias, dt); -} - - -//MARK: Spaces - -#define cpAssertSpaceUnlocked(space) \ - cpAssertHard(!space->locked, \ - "This operation cannot be done safely during a call to cpSpaceStep() or during a query. " \ - "Put these calls into a post-step callback." \ - ); - -void cpSpaceSetStaticBody(cpSpace *space, cpBody *body); - -extern cpCollisionHandler cpCollisionHandlerDoNothing; - -void cpSpaceProcessComponents(cpSpace *space, cpFloat dt); - -void cpSpacePushFreshContactBuffer(cpSpace *space); -struct cpContact *cpContactBufferGetArray(cpSpace *space); -void cpSpacePushContacts(cpSpace *space, int count); - -cpPostStepCallback *cpSpaceGetPostStepCallback(cpSpace *space, void *key); - -cpBool cpSpaceArbiterSetFilter(cpArbiter *arb, cpSpace *space); -void cpSpaceFilterArbiters(cpSpace *space, cpBody *body, cpShape *filter); - -void cpSpaceActivateBody(cpSpace *space, cpBody *body); -void cpSpaceLock(cpSpace *space); -void cpSpaceUnlock(cpSpace *space, cpBool runPostStep); - -static inline void -cpSpaceUncacheArbiter(cpSpace *space, cpArbiter *arb) -{ - const cpShape *a = arb->a, *b = arb->b; - const cpShape *shape_pair[] = {a, b}; - cpHashValue arbHashID = CP_HASH_PAIR((cpHashValue)a, (cpHashValue)b); - cpHashSetRemove(space->cachedArbiters, arbHashID, shape_pair); - cpArrayDeleteObj(space->arbiters, arb); -} - -static inline cpArray * -cpSpaceArrayForBodyType(cpSpace *space, cpBodyType type) -{ - return (type == CP_BODY_TYPE_STATIC ? space->staticBodies : space->dynamicBodies); -} - -void cpShapeUpdateFunc(cpShape *shape, void *unused); -cpCollisionID cpSpaceCollideShapes(cpShape *a, cpShape *b, cpCollisionID id, cpSpace *space); - - -//MARK: Foreach loops - -static inline cpConstraint * -cpConstraintNext(cpConstraint *node, cpBody *body) -{ - return (node->a == body ? node->next_a : node->next_b); -} - -#define CP_BODY_FOREACH_CONSTRAINT(bdy, var)\ - for(cpConstraint *var = bdy->constraintList; var; var = cpConstraintNext(var, bdy)) - -static inline cpArbiter * -cpArbiterNext(cpArbiter *node, cpBody *body) -{ - return (node->body_a == body ? node->thread_a.next : node->thread_b.next); -} - -#define CP_BODY_FOREACH_ARBITER(bdy, var)\ - for(cpArbiter *var = bdy->arbiterList; var; var = cpArbiterNext(var, bdy)) - -#define CP_BODY_FOREACH_SHAPE(body, var)\ - for(cpShape *var = body->shapeList; var; var = var->next) - -#define CP_BODY_FOREACH_COMPONENT(root, var)\ - for(cpBody *var = root; var; var = var->sleeping.next) - -#endif diff --git a/thirdparty/include/chipmunk/chipmunk_structs.h b/thirdparty/include/chipmunk/chipmunk_structs.h deleted file mode 100644 index d8b1e6ff2..000000000 --- a/thirdparty/include/chipmunk/chipmunk_structs.h +++ /dev/null @@ -1,450 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// All of the struct definitions for Chipmunk should be considered part of the private API. -// However, it is very valuable to know the struct sizes for preallocating memory. - -#ifndef CHIPMUNK_STRUCTS_H -#define CHIPMUNK_STRUCTS_H - -#include "chipmunk/chipmunk.h" - -struct cpArray { - int num, max; - void **arr; -}; - -struct cpBody { - // Integration functions - cpBodyVelocityFunc velocity_func; - cpBodyPositionFunc position_func; - - // mass and it's inverse - cpFloat m; - cpFloat m_inv; - - // moment of inertia and it's inverse - cpFloat i; - cpFloat i_inv; - - // center of gravity - cpVect cog; - - // position, velocity, force - cpVect p; - cpVect v; - cpVect f; - - // Angle, angular velocity, torque (radians) - cpFloat a; - cpFloat w; - cpFloat t; - - cpTransform transform; - - cpDataPointer userData; - - // "pseudo-velocities" used for eliminating overlap. - // Erin Catto has some papers that talk about what these are. - cpVect v_bias; - cpFloat w_bias; - - cpSpace *space; - - cpShape *shapeList; - cpArbiter *arbiterList; - cpConstraint *constraintList; - - struct { - cpBody *root; - cpBody *next; - cpFloat idleTime; - } sleeping; -}; - -enum cpArbiterState { - // Arbiter is active and its the first collision. - CP_ARBITER_STATE_FIRST_COLLISION, - // Arbiter is active and its not the first collision. - CP_ARBITER_STATE_NORMAL, - // Collision has been explicitly ignored. - // Either by returning false from a begin collision handler or calling cpArbiterIgnore(). - CP_ARBITER_STATE_IGNORE, - // Collison is no longer active. A space will cache an arbiter for up to cpSpace.collisionPersistence more steps. - CP_ARBITER_STATE_CACHED, - // Collison arbiter is invalid because one of the shapes was removed. - CP_ARBITER_STATE_INVALIDATED, -}; - -struct cpArbiterThread { - struct cpArbiter *next, *prev; -}; - -struct cpContact { - cpVect r1, r2; - - cpFloat nMass, tMass; - cpFloat bounce; // TODO: look for an alternate bounce solution. - - cpFloat jnAcc, jtAcc, jBias; - cpFloat bias; - - cpHashValue hash; -}; - -struct cpCollisionInfo { - const cpShape *a, *b; - cpCollisionID id; - - cpVect n; - - int count; - // TODO Should this be a unique struct type? - struct cpContact *arr; -}; - -struct cpArbiter { - cpFloat e; - cpFloat u; - cpVect surface_vr; - - cpDataPointer data; - - const cpShape *a, *b; - cpBody *body_a, *body_b; - struct cpArbiterThread thread_a, thread_b; - - int count; - struct cpContact *contacts; - cpVect n; - - // Regular, wildcard A and wildcard B collision handlers. - cpCollisionHandler *handler, *handlerA, *handlerB; - cpBool swapped; - - cpTimestamp stamp; - enum cpArbiterState state; -}; - -struct cpShapeMassInfo { - cpFloat m; - cpFloat i; - cpVect cog; - cpFloat area; -}; - -typedef enum cpShapeType{ - CP_CIRCLE_SHAPE, - CP_SEGMENT_SHAPE, - CP_POLY_SHAPE, - CP_NUM_SHAPES -} cpShapeType; - -typedef cpBB (*cpShapeCacheDataImpl)(cpShape *shape, cpTransform transform); -typedef void (*cpShapeDestroyImpl)(cpShape *shape); -typedef void (*cpShapePointQueryImpl)(const cpShape *shape, cpVect p, cpPointQueryInfo *info); -typedef void (*cpShapeSegmentQueryImpl)(const cpShape *shape, cpVect a, cpVect b, cpFloat radius, cpSegmentQueryInfo *info); - -typedef struct cpShapeClass cpShapeClass; - -struct cpShapeClass { - cpShapeType type; - - cpShapeCacheDataImpl cacheData; - cpShapeDestroyImpl destroy; - cpShapePointQueryImpl pointQuery; - cpShapeSegmentQueryImpl segmentQuery; -}; - -struct cpShape { - const cpShapeClass *klass; - - cpSpace *space; - cpBody *body; - struct cpShapeMassInfo massInfo; - cpBB bb; - - cpBool sensor; - - cpFloat e; - cpFloat u; - cpVect surfaceV; - - cpDataPointer userData; - - cpCollisionType type; - cpShapeFilter filter; - - cpShape *next; - cpShape *prev; - - cpHashValue hashid; -}; - -struct cpCircleShape { - cpShape shape; - - cpVect c, tc; - cpFloat r; -}; - -struct cpSegmentShape { - cpShape shape; - - cpVect a, b, n; - cpVect ta, tb, tn; - cpFloat r; - - cpVect a_tangent, b_tangent; -}; - -struct cpSplittingPlane { - cpVect v0, n; -}; - -#define CP_POLY_SHAPE_INLINE_ALLOC 6 - -struct cpPolyShape { - cpShape shape; - - cpFloat r; - - int count; - // The untransformed planes are appended at the end of the transformed planes. - struct cpSplittingPlane *planes; - - // Allocate a small number of splitting planes internally for simple poly. - struct cpSplittingPlane _planes[2*CP_POLY_SHAPE_INLINE_ALLOC]; -}; - -typedef void (*cpConstraintPreStepImpl)(cpConstraint *constraint, cpFloat dt); -typedef void (*cpConstraintApplyCachedImpulseImpl)(cpConstraint *constraint, cpFloat dt_coef); -typedef void (*cpConstraintApplyImpulseImpl)(cpConstraint *constraint, cpFloat dt); -typedef cpFloat (*cpConstraintGetImpulseImpl)(cpConstraint *constraint); - -typedef struct cpConstraintClass { - cpConstraintPreStepImpl preStep; - cpConstraintApplyCachedImpulseImpl applyCachedImpulse; - cpConstraintApplyImpulseImpl applyImpulse; - cpConstraintGetImpulseImpl getImpulse; -} cpConstraintClass; - -struct cpConstraint { - const cpConstraintClass *klass; - - cpSpace *space; - - cpBody *a, *b; - cpConstraint *next_a, *next_b; - - cpFloat maxForce; - cpFloat errorBias; - cpFloat maxBias; - - cpBool collideBodies; - - cpConstraintPreSolveFunc preSolve; - cpConstraintPostSolveFunc postSolve; - - cpDataPointer userData; -}; - -struct cpPinJoint { - cpConstraint constraint; - cpVect anchorA, anchorB; - cpFloat dist; - - cpVect r1, r2; - cpVect n; - cpFloat nMass; - - cpFloat jnAcc; - cpFloat bias; -}; - -struct cpSlideJoint { - cpConstraint constraint; - cpVect anchorA, anchorB; - cpFloat min, max; - - cpVect r1, r2; - cpVect n; - cpFloat nMass; - - cpFloat jnAcc; - cpFloat bias; -}; - -struct cpPivotJoint { - cpConstraint constraint; - cpVect anchorA, anchorB; - - cpVect r1, r2; - cpMat2x2 k; - - cpVect jAcc; - cpVect bias; -}; - -struct cpGrooveJoint { - cpConstraint constraint; - cpVect grv_n, grv_a, grv_b; - cpVect anchorB; - - cpVect grv_tn; - cpFloat clamp; - cpVect r1, r2; - cpMat2x2 k; - - cpVect jAcc; - cpVect bias; -}; - -struct cpDampedSpring { - cpConstraint constraint; - cpVect anchorA, anchorB; - cpFloat restLength; - cpFloat stiffness; - cpFloat damping; - cpDampedSpringForceFunc springForceFunc; - - cpFloat target_vrn; - cpFloat v_coef; - - cpVect r1, r2; - cpFloat nMass; - cpVect n; - - cpFloat jAcc; -}; - -struct cpDampedRotarySpring { - cpConstraint constraint; - cpFloat restAngle; - cpFloat stiffness; - cpFloat damping; - cpDampedRotarySpringTorqueFunc springTorqueFunc; - - cpFloat target_wrn; - cpFloat w_coef; - - cpFloat iSum; - cpFloat jAcc; -}; - -struct cpRotaryLimitJoint { - cpConstraint constraint; - cpFloat min, max; - - cpFloat iSum; - - cpFloat bias; - cpFloat jAcc; -}; - -struct cpRatchetJoint { - cpConstraint constraint; - cpFloat angle, phase, ratchet; - - cpFloat iSum; - - cpFloat bias; - cpFloat jAcc; -}; - -struct cpGearJoint { - cpConstraint constraint; - cpFloat phase, ratio; - cpFloat ratio_inv; - - cpFloat iSum; - - cpFloat bias; - cpFloat jAcc; -}; - -struct cpSimpleMotor { - cpConstraint constraint; - cpFloat rate; - - cpFloat iSum; - - cpFloat jAcc; -}; - -typedef struct cpContactBufferHeader cpContactBufferHeader; -typedef void (*cpSpaceArbiterApplyImpulseFunc)(cpArbiter *arb); - -struct cpSpace { - int iterations; - - cpVect gravity; - cpFloat damping; - - cpFloat idleSpeedThreshold; - cpFloat sleepTimeThreshold; - - cpFloat collisionSlop; - cpFloat collisionBias; - cpTimestamp collisionPersistence; - - cpDataPointer userData; - - cpTimestamp stamp; - cpFloat curr_dt; - - cpArray *dynamicBodies; - cpArray *staticBodies; - cpArray *rousedBodies; - cpArray *sleepingComponents; - - cpHashValue shapeIDCounter; - cpSpatialIndex *staticShapes; - cpSpatialIndex *dynamicShapes; - - cpArray *constraints; - - cpArray *arbiters; - cpContactBufferHeader *contactBuffersHead; - cpHashSet *cachedArbiters; - cpArray *pooledArbiters; - - cpArray *allocatedBuffers; - unsigned int locked; - - cpBool usesWildcards; - cpHashSet *collisionHandlers; - cpCollisionHandler defaultHandler; - - cpBool skipPostStep; - cpArray *postStepCallbacks; - - cpBody *staticBody; - cpBody _staticBody; -}; - -typedef struct cpPostStepCallback { - cpPostStepFunc func; - void *key; - void *data; -} cpPostStepCallback; - -#endif diff --git a/thirdparty/include/chipmunk/chipmunk_types.h b/thirdparty/include/chipmunk/chipmunk_types.h deleted file mode 100644 index 9544da893..000000000 --- a/thirdparty/include/chipmunk/chipmunk_types.h +++ /dev/null @@ -1,268 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef CHIPMUNK_TYPES_H -#define CHIPMUNK_TYPES_H - -#include -#include -#include - -#ifdef __APPLE__ - #include "TargetConditionals.h" -#endif - -// Use CGTypes by default on iOS and Mac. -// Also enables usage of doubles on 64 bit. -// Performance is usually very comparable when the CPU cache is well utilised. -#if (TARGET_OS_IPHONE || TARGET_OS_MAC) && (!defined CP_USE_CGTYPES) - #define CP_USE_CGTYPES 1 -#endif - -#if CP_USE_CGTYPES - #if TARGET_OS_IPHONE - #include - #include - #elif TARGET_OS_MAC - #include - #endif - - #if defined(__LP64__) && __LP64__ - #define CP_USE_DOUBLES 1 - #else - #define CP_USE_DOUBLES 0 - #endif -#endif - -#ifndef CP_USE_DOUBLES - // Use doubles by default for higher precision. - #define CP_USE_DOUBLES 1 -#endif - -/// @defgroup basicTypes Basic Types -/// Most of these types can be configured at compile time. -/// @{ - -#if CP_USE_DOUBLES -/// Chipmunk's floating point type. -/// Can be reconfigured at compile time. - typedef double cpFloat; - #define cpfsqrt sqrt - #define cpfsin sin - #define cpfcos cos - #define cpfacos acos - #define cpfatan2 atan2 - #define cpfmod fmod - #define cpfexp exp - #define cpfpow pow - #define cpffloor floor - #define cpfceil ceil - #define CPFLOAT_MIN DBL_MIN -#else - typedef float cpFloat; - #define cpfsqrt sqrtf - #define cpfsin sinf - #define cpfcos cosf - #define cpfacos acosf - #define cpfatan2 atan2f - #define cpfmod fmodf - #define cpfexp expf - #define cpfpow powf - #define cpffloor floorf - #define cpfceil ceilf - #define CPFLOAT_MIN FLT_MIN -#endif - -#ifndef INFINITY - #ifdef _MSC_VER - union MSVC_EVIL_FLOAT_HACK - { - unsigned __int8 Bytes[4]; - float Value; - }; - static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}}; - #define INFINITY (INFINITY_HACK.Value) - #endif - - #ifdef __GNUC__ - #define INFINITY (__builtin_inf()) - #endif - - #ifndef INFINITY - #define INFINITY (1e1000) - #endif -#endif - - -#define CP_PI ((cpFloat)3.14159265358979323846264338327950288) - - -/// Return the max of two cpFloats. -static inline cpFloat cpfmax(cpFloat a, cpFloat b) -{ - return (a > b) ? a : b; -} - -/// Return the min of two cpFloats. -static inline cpFloat cpfmin(cpFloat a, cpFloat b) -{ - return (a < b) ? a : b; -} - -/// Return the absolute value of a cpFloat. -static inline cpFloat cpfabs(cpFloat f) -{ - return (f < 0) ? -f : f; -} - -/// Clamp @c f to be between @c min and @c max. -static inline cpFloat cpfclamp(cpFloat f, cpFloat min, cpFloat max) -{ - return cpfmin(cpfmax(f, min), max); -} - -/// Clamp @c f to be between 0 and 1. -static inline cpFloat cpfclamp01(cpFloat f) -{ - return cpfmax(0.0f, cpfmin(f, 1.0f)); -} - - - -/// Linearly interpolate (or extrapolate) between @c f1 and @c f2 by @c t percent. -static inline cpFloat cpflerp(cpFloat f1, cpFloat f2, cpFloat t) -{ - return f1*(1.0f - t) + f2*t; -} - -/// Linearly interpolate from @c f1 to @c f2 by no more than @c d. -static inline cpFloat cpflerpconst(cpFloat f1, cpFloat f2, cpFloat d) -{ - return f1 + cpfclamp(f2 - f1, -d, d); -} - -/// Hash value type. -#ifdef CP_HASH_VALUE_TYPE - typedef CP_HASH_VALUE_TYPE cpHashValue; -#else - typedef uintptr_t cpHashValue; -#endif - -/// Type used internally to cache colliding object info for cpCollideShapes(). -/// Should be at least 32 bits. -typedef uint32_t cpCollisionID; - -// Oh C, how we love to define our own boolean types to get compiler compatibility -/// Chipmunk's boolean type. -#ifdef CP_BOOL_TYPE - typedef CP_BOOL_TYPE cpBool; -#else - typedef unsigned char cpBool; -#endif - -#ifndef cpTrue -/// true value. - #define cpTrue 1 -#endif - -#ifndef cpFalse -/// false value. - #define cpFalse 0 -#endif - -#ifdef CP_DATA_POINTER_TYPE - typedef CP_DATA_POINTER_TYPE cpDataPointer; -#else -/// Type used for user data pointers. - typedef void * cpDataPointer; -#endif - -#ifdef CP_COLLISION_TYPE_TYPE - typedef CP_COLLISION_TYPE_TYPE cpCollisionType; -#else -/// Type used for cpSpace.collision_type. - typedef uintptr_t cpCollisionType; -#endif - -#ifdef CP_GROUP_TYPE - typedef CP_GROUP_TYPE cpGroup; -#else -/// Type used for cpShape.group. - typedef uintptr_t cpGroup; -#endif - -#ifdef CP_BITMASK_TYPE - typedef CP_BITMASK_TYPE cpBitmask; -#else -/// Type used for cpShapeFilter category and mask. - typedef unsigned int cpBitmask; -#endif - -#ifdef CP_TIMESTAMP_TYPE - typedef CP_TIMESTAMP_TYPE cpTimestamp; -#else -/// Type used for various timestamps in Chipmunk. - typedef unsigned int cpTimestamp; -#endif - -#ifndef CP_NO_GROUP -/// Value for cpShape.group signifying that a shape is in no group. - #define CP_NO_GROUP ((cpGroup)0) -#endif - -#ifndef CP_ALL_CATEGORIES -/// Value for cpShape.layers signifying that a shape is in every layer. - #define CP_ALL_CATEGORIES (~(cpBitmask)0) -#endif - -#ifndef CP_WILDCARD_COLLISION_TYPE -/// cpCollisionType value internally reserved for hashing wildcard handlers. - #define CP_WILDCARD_COLLISION_TYPE (~(cpCollisionType)0) -#endif - -/// @} - -// CGPoints are structurally the same, and allow -// easy interoperability with other Cocoa libraries -#if CP_USE_CGTYPES - typedef CGPoint cpVect; -#else -/// Chipmunk's 2D vector type. -/// @addtogroup cpVect - typedef struct cpVect{cpFloat x,y;} cpVect; -#endif - -#if CP_USE_CGTYPES - typedef CGAffineTransform cpTransform; -#else - /// Column major affine transform. - typedef struct cpTransform { - cpFloat a, b, c, d, tx, ty; - } cpTransform; -#endif - -// NUKE -typedef struct cpMat2x2 { - // Row major [[a, b][c d]] - cpFloat a, b, c, d; -} cpMat2x2; - -#endif diff --git a/thirdparty/include/chipmunk/chipmunk_unsafe.h b/thirdparty/include/chipmunk/chipmunk_unsafe.h deleted file mode 100644 index 990bd012a..000000000 --- a/thirdparty/include/chipmunk/chipmunk_unsafe.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/* This header defines a number of "unsafe" operations on Chipmunk objects. - * In this case "unsafe" is referring to operations which may reduce the - * physical accuracy or numerical stability of the simulation, but will not - * cause crashes. - * - * The prime example is mutating collision shapes. Chipmunk does not support - * this directly. Mutating shapes using this API will caused objects in contact - * to be pushed apart using Chipmunk's overlap solver, but not using real - * persistent velocities. Probably not what you meant, but perhaps close enough. - */ - -/// @defgroup unsafe Chipmunk Unsafe Shape Operations -/// These functions are used for mutating collision shapes. -/// Chipmunk does not have any way to get velocity information on changing shapes, -/// so the results will be unrealistic. You must explicity include the chipmunk_unsafe.h header to use them. -/// @{ - -#ifndef CHIPMUNK_UNSAFE_H -#define CHIPMUNK_UNSAFE_H - -#ifdef __cplusplus -extern "C" { -#endif - -/// Set the radius of a circle shape. -CP_EXPORT void cpCircleShapeSetRadius(cpShape *shape, cpFloat radius); -/// Set the offset of a circle shape. -CP_EXPORT void cpCircleShapeSetOffset(cpShape *shape, cpVect offset); - -/// Set the endpoints of a segment shape. -CP_EXPORT void cpSegmentShapeSetEndpoints(cpShape *shape, cpVect a, cpVect b); -/// Set the radius of a segment shape. -CP_EXPORT void cpSegmentShapeSetRadius(cpShape *shape, cpFloat radius); - -/// Set the vertexes of a poly shape. -CP_EXPORT void cpPolyShapeSetVerts(cpShape *shape, int count, cpVect *verts, cpTransform transform); -CP_EXPORT void cpPolyShapeSetVertsRaw(cpShape *shape, int count, cpVect *verts); -/// Set the radius of a poly shape. -CP_EXPORT void cpPolyShapeSetRadius(cpShape *shape, cpFloat radius); - -#ifdef __cplusplus -} -#endif -#endif -/// @} diff --git a/thirdparty/include/chipmunk/cpArbiter.h b/thirdparty/include/chipmunk/cpArbiter.h deleted file mode 100644 index 1dc130afb..000000000 --- a/thirdparty/include/chipmunk/cpArbiter.h +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpArbiter cpArbiter -/// The cpArbiter struct tracks pairs of colliding shapes. -/// They are also used in conjuction with collision handler callbacks -/// allowing you to retrieve information on the collision or change it. -/// A unique arbiter value is used for each pair of colliding objects. It persists until the shapes separate. -/// @{ - -#define CP_MAX_CONTACTS_PER_ARBITER 2 - -/// Get the restitution (elasticity) that will be applied to the pair of colliding objects. -CP_EXPORT cpFloat cpArbiterGetRestitution(const cpArbiter *arb); -/// Override the restitution (elasticity) that will be applied to the pair of colliding objects. -CP_EXPORT void cpArbiterSetRestitution(cpArbiter *arb, cpFloat restitution); -/// Get the friction coefficient that will be applied to the pair of colliding objects. -CP_EXPORT cpFloat cpArbiterGetFriction(const cpArbiter *arb); -/// Override the friction coefficient that will be applied to the pair of colliding objects. -CP_EXPORT void cpArbiterSetFriction(cpArbiter *arb, cpFloat friction); - -// Get the relative surface velocity of the two shapes in contact. -CP_EXPORT cpVect cpArbiterGetSurfaceVelocity(cpArbiter *arb); - -// Override the relative surface velocity of the two shapes in contact. -// By default this is calculated to be the difference of the two surface velocities clamped to the tangent plane. -CP_EXPORT void cpArbiterSetSurfaceVelocity(cpArbiter *arb, cpVect vr); - -/// Get the user data pointer associated with this pair of colliding objects. -CP_EXPORT cpDataPointer cpArbiterGetUserData(const cpArbiter *arb); -/// Set a user data point associated with this pair of colliding objects. -/// If you need to perform any cleanup for this pointer, you must do it yourself, in the separate callback for instance. -CP_EXPORT void cpArbiterSetUserData(cpArbiter *arb, cpDataPointer userData); - -/// Calculate the total impulse including the friction that was applied by this arbiter. -/// This function should only be called from a post-solve, post-step or cpBodyEachArbiter callback. -CP_EXPORT cpVect cpArbiterTotalImpulse(const cpArbiter *arb); -/// Calculate the amount of energy lost in a collision including static, but not dynamic friction. -/// This function should only be called from a post-solve, post-step or cpBodyEachArbiter callback. -CP_EXPORT cpFloat cpArbiterTotalKE(const cpArbiter *arb); - -/// Mark a collision pair to be ignored until the two objects separate. -/// Pre-solve and post-solve callbacks will not be called, but the separate callback will be called. -CP_EXPORT cpBool cpArbiterIgnore(cpArbiter *arb); - -/// Return the colliding shapes involved for this arbiter. -/// The order of their cpSpace.collision_type values will match -/// the order set when the collision handler was registered. -CP_EXPORT void cpArbiterGetShapes(const cpArbiter *arb, cpShape **a, cpShape **b); - -/// A macro shortcut for defining and retrieving the shapes from an arbiter. -#define CP_ARBITER_GET_SHAPES(__arb__, __a__, __b__) cpShape *__a__, *__b__; cpArbiterGetShapes(__arb__, &__a__, &__b__); - -/// Return the colliding bodies involved for this arbiter. -/// The order of the cpSpace.collision_type the bodies are associated with values will match -/// the order set when the collision handler was registered. -CP_EXPORT void cpArbiterGetBodies(const cpArbiter *arb, cpBody **a, cpBody **b); - -/// A macro shortcut for defining and retrieving the bodies from an arbiter. -#define CP_ARBITER_GET_BODIES(__arb__, __a__, __b__) cpBody *__a__, *__b__; cpArbiterGetBodies(__arb__, &__a__, &__b__); - -/// A struct that wraps up the important collision data for an arbiter. -struct cpContactPointSet { - /// The number of contact points in the set. - int count; - - /// The normal of the collision. - cpVect normal; - - /// The array of contact points. - struct { - /// The position of the contact on the surface of each shape. - cpVect pointA, pointB; - /// Penetration distance of the two shapes. Overlapping means it will be negative. - /// This value is calculated as cpvdot(cpvsub(point2, point1), normal) and is ignored by cpArbiterSetContactPointSet(). - cpFloat distance; - } points[CP_MAX_CONTACTS_PER_ARBITER]; -}; - -/// Return a contact set from an arbiter. -CP_EXPORT cpContactPointSet cpArbiterGetContactPointSet(const cpArbiter *arb); - -/// Replace the contact point set for an arbiter. -/// This can be a very powerful feature, but use it with caution! -CP_EXPORT void cpArbiterSetContactPointSet(cpArbiter *arb, cpContactPointSet *set); - -/// Returns true if this is the first step a pair of objects started colliding. -CP_EXPORT cpBool cpArbiterIsFirstContact(const cpArbiter *arb); -/// Returns true if the separate callback is due to a shape being removed from the space. -CP_EXPORT cpBool cpArbiterIsRemoval(const cpArbiter *arb); - -/// Get the number of contact points for this arbiter. -CP_EXPORT int cpArbiterGetCount(const cpArbiter *arb); -/// Get the normal of the collision. -CP_EXPORT cpVect cpArbiterGetNormal(const cpArbiter *arb); -/// Get the position of the @c ith contact point on the surface of the first shape. -CP_EXPORT cpVect cpArbiterGetPointA(const cpArbiter *arb, int i); -/// Get the position of the @c ith contact point on the surface of the second shape. -CP_EXPORT cpVect cpArbiterGetPointB(const cpArbiter *arb, int i); -/// Get the depth of the @c ith contact point. -CP_EXPORT cpFloat cpArbiterGetDepth(const cpArbiter *arb, int i); - -/// If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly. -/// You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own. -CP_EXPORT cpBool cpArbiterCallWildcardBeginA(cpArbiter *arb, cpSpace *space); -/// If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly. -/// You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own. -CP_EXPORT cpBool cpArbiterCallWildcardBeginB(cpArbiter *arb, cpSpace *space); - -/// If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly. -/// You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own. -CP_EXPORT cpBool cpArbiterCallWildcardPreSolveA(cpArbiter *arb, cpSpace *space); -/// If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly. -/// You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own. -CP_EXPORT cpBool cpArbiterCallWildcardPreSolveB(cpArbiter *arb, cpSpace *space); - -/// If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly. -CP_EXPORT void cpArbiterCallWildcardPostSolveA(cpArbiter *arb, cpSpace *space); -/// If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly. -CP_EXPORT void cpArbiterCallWildcardPostSolveB(cpArbiter *arb, cpSpace *space); - -/// If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly. -CP_EXPORT void cpArbiterCallWildcardSeparateA(cpArbiter *arb, cpSpace *space); -/// If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly. -CP_EXPORT void cpArbiterCallWildcardSeparateB(cpArbiter *arb, cpSpace *space); - -/// @} diff --git a/thirdparty/include/chipmunk/cpBB.h b/thirdparty/include/chipmunk/cpBB.h deleted file mode 100644 index 8fc87049c..000000000 --- a/thirdparty/include/chipmunk/cpBB.h +++ /dev/null @@ -1,187 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef CHIPMUNK_BB_H -#define CHIPMUNK_BB_H - -#include "chipmunk_types.h" -#include "cpVect.h" - -/// @defgroup cpBBB cpBB -/// Chipmunk's axis-aligned 2D bounding box type along with a few handy routines. -/// @{ - -/// Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top) -typedef struct cpBB{ - cpFloat l, b, r ,t; -} cpBB; - -/// Convenience constructor for cpBB structs. -static inline cpBB cpBBNew(const cpFloat l, const cpFloat b, const cpFloat r, const cpFloat t) -{ - cpBB bb = {l, b, r, t}; - return bb; -} - -/// Constructs a cpBB centered on a point with the given extents (half sizes). -static inline cpBB -cpBBNewForExtents(const cpVect c, const cpFloat hw, const cpFloat hh) -{ - return cpBBNew(c.x - hw, c.y - hh, c.x + hw, c.y + hh); -} - -/// Constructs a cpBB for a circle with the given position and radius. -static inline cpBB cpBBNewForCircle(const cpVect p, const cpFloat r) -{ - return cpBBNewForExtents(p, r, r); -} - -/// Returns true if @c a and @c b intersect. -static inline cpBool cpBBIntersects(const cpBB a, const cpBB b) -{ - return (a.l <= b.r && b.l <= a.r && a.b <= b.t && b.b <= a.t); -} - -/// Returns true if @c other lies completely within @c bb. -static inline cpBool cpBBContainsBB(const cpBB bb, const cpBB other) -{ - return (bb.l <= other.l && bb.r >= other.r && bb.b <= other.b && bb.t >= other.t); -} - -/// Returns true if @c bb contains @c v. -static inline cpBool cpBBContainsVect(const cpBB bb, const cpVect v) -{ - return (bb.l <= v.x && bb.r >= v.x && bb.b <= v.y && bb.t >= v.y); -} - -/// Returns a bounding box that holds both bounding boxes. -static inline cpBB cpBBMerge(const cpBB a, const cpBB b){ - return cpBBNew( - cpfmin(a.l, b.l), - cpfmin(a.b, b.b), - cpfmax(a.r, b.r), - cpfmax(a.t, b.t) - ); -} - -/// Returns a bounding box that holds both @c bb and @c v. -static inline cpBB cpBBExpand(const cpBB bb, const cpVect v){ - return cpBBNew( - cpfmin(bb.l, v.x), - cpfmin(bb.b, v.y), - cpfmax(bb.r, v.x), - cpfmax(bb.t, v.y) - ); -} - -/// Returns the center of a bounding box. -static inline cpVect -cpBBCenter(cpBB bb) -{ - return cpvlerp(cpv(bb.l, bb.b), cpv(bb.r, bb.t), 0.5f); -} - -/// Returns the area of the bounding box. -static inline cpFloat cpBBArea(cpBB bb) -{ - return (bb.r - bb.l)*(bb.t - bb.b); -} - -/// Merges @c a and @c b and returns the area of the merged bounding box. -static inline cpFloat cpBBMergedArea(cpBB a, cpBB b) -{ - return (cpfmax(a.r, b.r) - cpfmin(a.l, b.l))*(cpfmax(a.t, b.t) - cpfmin(a.b, b.b)); -} - -/// Returns the fraction along the segment query the cpBB is hit. Returns INFINITY if it doesn't hit. -static inline cpFloat cpBBSegmentQuery(cpBB bb, cpVect a, cpVect b) -{ - cpVect delta = cpvsub(b, a); - cpFloat tmin = -INFINITY, tmax = INFINITY; - - if(delta.x == 0.0f){ - if(a.x < bb.l || bb.r < a.x) return INFINITY; - } else { - cpFloat t1 = (bb.l - a.x)/delta.x; - cpFloat t2 = (bb.r - a.x)/delta.x; - tmin = cpfmax(tmin, cpfmin(t1, t2)); - tmax = cpfmin(tmax, cpfmax(t1, t2)); - } - - if(delta.y == 0.0f){ - if(a.y < bb.b || bb.t < a.y) return INFINITY; - } else { - cpFloat t1 = (bb.b - a.y)/delta.y; - cpFloat t2 = (bb.t - a.y)/delta.y; - tmin = cpfmax(tmin, cpfmin(t1, t2)); - tmax = cpfmin(tmax, cpfmax(t1, t2)); - } - - if(tmin <= tmax && 0.0f <= tmax && tmin <= 1.0f){ - return cpfmax(tmin, 0.0f); - } else { - return INFINITY; - } -} - -/// Return true if the bounding box intersects the line segment with ends @c a and @c b. -static inline cpBool cpBBIntersectsSegment(cpBB bb, cpVect a, cpVect b) -{ - return (cpBBSegmentQuery(bb, a, b) != INFINITY); -} - -/// Clamp a vector to a bounding box. -static inline cpVect -cpBBClampVect(const cpBB bb, const cpVect v) -{ - return cpv(cpfclamp(v.x, bb.l, bb.r), cpfclamp(v.y, bb.b, bb.t)); -} - -/// Wrap a vector to a bounding box. -static inline cpVect -cpBBWrapVect(const cpBB bb, const cpVect v) -{ - cpFloat dx = cpfabs(bb.r - bb.l); - cpFloat modx = cpfmod(v.x - bb.l, dx); - cpFloat x = (modx > 0.0f) ? modx : modx + dx; - - cpFloat dy = cpfabs(bb.t - bb.b); - cpFloat mody = cpfmod(v.y - bb.b, dy); - cpFloat y = (mody > 0.0f) ? mody : mody + dy; - - return cpv(x + bb.l, y + bb.b); -} - -/// Returns a bounding box offseted by @c v. -static inline cpBB -cpBBOffset(const cpBB bb, const cpVect v) -{ - return cpBBNew( - bb.l + v.x, - bb.b + v.y, - bb.r + v.x, - bb.t + v.y - ); -} - -///@} - -#endif diff --git a/thirdparty/include/chipmunk/cpBody.h b/thirdparty/include/chipmunk/cpBody.h deleted file mode 100644 index 7e6943d15..000000000 --- a/thirdparty/include/chipmunk/cpBody.h +++ /dev/null @@ -1,189 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpBody cpBody -/// Chipmunk's rigid body type. Rigid bodies hold the physical properties of an object like -/// it's mass, and position and velocity of it's center of gravity. They don't have an shape on their own. -/// They are given a shape by creating collision shapes (cpShape) that point to the body. -/// @{ - -typedef enum cpBodyType { - /// A dynamic body is one that is affected by gravity, forces, and collisions. - /// This is the default body type. - CP_BODY_TYPE_DYNAMIC, - /// A kinematic body is an infinite mass, user controlled body that is not affected by gravity, forces or collisions. - /// Instead the body only moves based on it's velocity. - /// Dynamic bodies collide normally with kinematic bodies, though the kinematic body will be unaffected. - /// Collisions between two kinematic bodies, or a kinematic body and a static body produce collision callbacks, but no collision response. - CP_BODY_TYPE_KINEMATIC, - /// A static body is a body that never (or rarely) moves. If you move a static body, you must call one of the cpSpaceReindex*() functions. - /// Chipmunk uses this information to optimize the collision detection. - /// Static bodies do not produce collision callbacks when colliding with other static bodies. - CP_BODY_TYPE_STATIC, -} cpBodyType; - -/// Rigid body velocity update function type. -typedef void (*cpBodyVelocityFunc)(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt); -/// Rigid body position update function type. -typedef void (*cpBodyPositionFunc)(cpBody *body, cpFloat dt); - -/// Allocate a cpBody. -CP_EXPORT cpBody* cpBodyAlloc(void); -/// Initialize a cpBody. -CP_EXPORT cpBody* cpBodyInit(cpBody *body, cpFloat mass, cpFloat moment); -/// Allocate and initialize a cpBody. -CP_EXPORT cpBody* cpBodyNew(cpFloat mass, cpFloat moment); - -/// Allocate and initialize a cpBody, and set it as a kinematic body. -CP_EXPORT cpBody* cpBodyNewKinematic(void); -/// Allocate and initialize a cpBody, and set it as a static body. -CP_EXPORT cpBody* cpBodyNewStatic(void); - -/// Destroy a cpBody. -CP_EXPORT void cpBodyDestroy(cpBody *body); -/// Destroy and free a cpBody. -CP_EXPORT void cpBodyFree(cpBody *body); - -// Defined in cpSpace.c -/// Wake up a sleeping or idle body. -CP_EXPORT void cpBodyActivate(cpBody *body); -/// Wake up any sleeping or idle bodies touching a static body. -CP_EXPORT void cpBodyActivateStatic(cpBody *body, cpShape *filter); - -/// Force a body to fall asleep immediately. -CP_EXPORT void cpBodySleep(cpBody *body); -/// Force a body to fall asleep immediately along with other bodies in a group. -CP_EXPORT void cpBodySleepWithGroup(cpBody *body, cpBody *group); - -/// Returns true if the body is sleeping. -CP_EXPORT cpBool cpBodyIsSleeping(const cpBody *body); - -/// Get the type of the body. -CP_EXPORT cpBodyType cpBodyGetType(cpBody *body); -/// Set the type of the body. -CP_EXPORT void cpBodySetType(cpBody *body, cpBodyType type); - -/// Get the space this body is added to. -CP_EXPORT cpSpace* cpBodyGetSpace(const cpBody *body); - -/// Get the mass of the body. -CP_EXPORT cpFloat cpBodyGetMass(const cpBody *body); -/// Set the mass of the body. -CP_EXPORT void cpBodySetMass(cpBody *body, cpFloat m); - -/// Get the moment of inertia of the body. -CP_EXPORT cpFloat cpBodyGetMoment(const cpBody *body); -/// Set the moment of inertia of the body. -CP_EXPORT void cpBodySetMoment(cpBody *body, cpFloat i); - -/// Set the position of a body. -CP_EXPORT cpVect cpBodyGetPosition(const cpBody *body); -/// Set the position of the body. -CP_EXPORT void cpBodySetPosition(cpBody *body, cpVect pos); - -/// Get the offset of the center of gravity in body local coordinates. -CP_EXPORT cpVect cpBodyGetCenterOfGravity(const cpBody *body); -/// Set the offset of the center of gravity in body local coordinates. -CP_EXPORT void cpBodySetCenterOfGravity(cpBody *body, cpVect cog); - -/// Get the velocity of the body. -CP_EXPORT cpVect cpBodyGetVelocity(const cpBody *body); -/// Set the velocity of the body. -CP_EXPORT void cpBodySetVelocity(cpBody *body, cpVect velocity); - -/// Get the force applied to the body for the next time step. -CP_EXPORT cpVect cpBodyGetForce(const cpBody *body); -/// Set the force applied to the body for the next time step. -CP_EXPORT void cpBodySetForce(cpBody *body, cpVect force); - -/// Get the angle of the body. -CP_EXPORT cpFloat cpBodyGetAngle(const cpBody *body); -/// Set the angle of a body. -CP_EXPORT void cpBodySetAngle(cpBody *body, cpFloat a); - -/// Get the angular velocity of the body. -CP_EXPORT cpFloat cpBodyGetAngularVelocity(const cpBody *body); -/// Set the angular velocity of the body. -CP_EXPORT void cpBodySetAngularVelocity(cpBody *body, cpFloat angularVelocity); - -/// Get the torque applied to the body for the next time step. -CP_EXPORT cpFloat cpBodyGetTorque(const cpBody *body); -/// Set the torque applied to the body for the next time step. -CP_EXPORT void cpBodySetTorque(cpBody *body, cpFloat torque); - -/// Get the rotation vector of the body. (The x basis vector of it's transform.) -CP_EXPORT cpVect cpBodyGetRotation(const cpBody *body); - -/// Get the user data pointer assigned to the body. -CP_EXPORT cpDataPointer cpBodyGetUserData(const cpBody *body); -/// Set the user data pointer assigned to the body. -CP_EXPORT void cpBodySetUserData(cpBody *body, cpDataPointer userData); - -/// Set the callback used to update a body's velocity. -CP_EXPORT void cpBodySetVelocityUpdateFunc(cpBody *body, cpBodyVelocityFunc velocityFunc); -/// Set the callback used to update a body's position. -/// NOTE: It's not generally recommended to override this unless you call the default position update function. -CP_EXPORT void cpBodySetPositionUpdateFunc(cpBody *body, cpBodyPositionFunc positionFunc); - -/// Default velocity integration function.. -CP_EXPORT void cpBodyUpdateVelocity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt); -/// Default position integration function. -CP_EXPORT void cpBodyUpdatePosition(cpBody *body, cpFloat dt); - -/// Convert body relative/local coordinates to absolute/world coordinates. -CP_EXPORT cpVect cpBodyLocalToWorld(const cpBody *body, const cpVect point); -/// Convert body absolute/world coordinates to relative/local coordinates. -CP_EXPORT cpVect cpBodyWorldToLocal(const cpBody *body, const cpVect point); - -/// Apply a force to a body. Both the force and point are expressed in world coordinates. -CP_EXPORT void cpBodyApplyForceAtWorldPoint(cpBody *body, cpVect force, cpVect point); -/// Apply a force to a body. Both the force and point are expressed in body local coordinates. -CP_EXPORT void cpBodyApplyForceAtLocalPoint(cpBody *body, cpVect force, cpVect point); - -/// Apply an impulse to a body. Both the impulse and point are expressed in world coordinates. -CP_EXPORT void cpBodyApplyImpulseAtWorldPoint(cpBody *body, cpVect impulse, cpVect point); -/// Apply an impulse to a body. Both the impulse and point are expressed in body local coordinates. -CP_EXPORT void cpBodyApplyImpulseAtLocalPoint(cpBody *body, cpVect impulse, cpVect point); - -/// Get the velocity on a body (in world units) at a point on the body in world coordinates. -CP_EXPORT cpVect cpBodyGetVelocityAtWorldPoint(const cpBody *body, cpVect point); -/// Get the velocity on a body (in world units) at a point on the body in local coordinates. -CP_EXPORT cpVect cpBodyGetVelocityAtLocalPoint(const cpBody *body, cpVect point); - -/// Get the amount of kinetic energy contained by the body. -CP_EXPORT cpFloat cpBodyKineticEnergy(const cpBody *body); - -/// Body/shape iterator callback function type. -typedef void (*cpBodyShapeIteratorFunc)(cpBody *body, cpShape *shape, void *data); -/// Call @c func once for each shape attached to @c body and added to the space. -CP_EXPORT void cpBodyEachShape(cpBody *body, cpBodyShapeIteratorFunc func, void *data); - -/// Body/constraint iterator callback function type. -typedef void (*cpBodyConstraintIteratorFunc)(cpBody *body, cpConstraint *constraint, void *data); -/// Call @c func once for each constraint attached to @c body and added to the space. -CP_EXPORT void cpBodyEachConstraint(cpBody *body, cpBodyConstraintIteratorFunc func, void *data); - -/// Body/arbiter iterator callback function type. -typedef void (*cpBodyArbiterIteratorFunc)(cpBody *body, cpArbiter *arbiter, void *data); -/// Call @c func once for each arbiter that is currently active on the body. -CP_EXPORT void cpBodyEachArbiter(cpBody *body, cpBodyArbiterIteratorFunc func, void *data); - -///@} diff --git a/thirdparty/include/chipmunk/cpConstraint.h b/thirdparty/include/chipmunk/cpConstraint.h deleted file mode 100644 index b1a439f7b..000000000 --- a/thirdparty/include/chipmunk/cpConstraint.h +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpConstraint cpConstraint -/// @{ - -/// Callback function type that gets called before solving a joint. -typedef void (*cpConstraintPreSolveFunc)(cpConstraint *constraint, cpSpace *space); -/// Callback function type that gets called after solving a joint. -typedef void (*cpConstraintPostSolveFunc)(cpConstraint *constraint, cpSpace *space); - -/// Destroy a constraint. -CP_EXPORT void cpConstraintDestroy(cpConstraint *constraint); -/// Destroy and free a constraint. -CP_EXPORT void cpConstraintFree(cpConstraint *constraint); - -/// Get the cpSpace this constraint is added to. -CP_EXPORT cpSpace* cpConstraintGetSpace(const cpConstraint *constraint); - -/// Get the first body the constraint is attached to. -CP_EXPORT cpBody* cpConstraintGetBodyA(const cpConstraint *constraint); - -/// Get the second body the constraint is attached to. -CP_EXPORT cpBody* cpConstraintGetBodyB(const cpConstraint *constraint); - -/// Get the maximum force that this constraint is allowed to use. -CP_EXPORT cpFloat cpConstraintGetMaxForce(const cpConstraint *constraint); -/// Set the maximum force that this constraint is allowed to use. (defaults to INFINITY) -CP_EXPORT void cpConstraintSetMaxForce(cpConstraint *constraint, cpFloat maxForce); - -/// Get rate at which joint error is corrected. -CP_EXPORT cpFloat cpConstraintGetErrorBias(const cpConstraint *constraint); -/// Set rate at which joint error is corrected. -/// Defaults to pow(1.0 - 0.1, 60.0) meaning that it will -/// correct 10% of the error every 1/60th of a second. -CP_EXPORT void cpConstraintSetErrorBias(cpConstraint *constraint, cpFloat errorBias); - -/// Get the maximum rate at which joint error is corrected. -CP_EXPORT cpFloat cpConstraintGetMaxBias(const cpConstraint *constraint); -/// Set the maximum rate at which joint error is corrected. (defaults to INFINITY) -CP_EXPORT void cpConstraintSetMaxBias(cpConstraint *constraint, cpFloat maxBias); - -/// Get if the two bodies connected by the constraint are allowed to collide or not. -CP_EXPORT cpBool cpConstraintGetCollideBodies(const cpConstraint *constraint); -/// Set if the two bodies connected by the constraint are allowed to collide or not. (defaults to cpFalse) -CP_EXPORT void cpConstraintSetCollideBodies(cpConstraint *constraint, cpBool collideBodies); - -/// Get the pre-solve function that is called before the solver runs. -CP_EXPORT cpConstraintPreSolveFunc cpConstraintGetPreSolveFunc(const cpConstraint *constraint); -/// Set the pre-solve function that is called before the solver runs. -CP_EXPORT void cpConstraintSetPreSolveFunc(cpConstraint *constraint, cpConstraintPreSolveFunc preSolveFunc); - -/// Get the post-solve function that is called before the solver runs. -CP_EXPORT cpConstraintPostSolveFunc cpConstraintGetPostSolveFunc(const cpConstraint *constraint); -/// Set the post-solve function that is called before the solver runs. -CP_EXPORT void cpConstraintSetPostSolveFunc(cpConstraint *constraint, cpConstraintPostSolveFunc postSolveFunc); - -/// Get the user definable data pointer for this constraint -CP_EXPORT cpDataPointer cpConstraintGetUserData(const cpConstraint *constraint); -/// Set the user definable data pointer for this constraint -CP_EXPORT void cpConstraintSetUserData(cpConstraint *constraint, cpDataPointer userData); - -/// Get the last impulse applied by this constraint. -CP_EXPORT cpFloat cpConstraintGetImpulse(cpConstraint *constraint); - -#include "cpPinJoint.h" -#include "cpSlideJoint.h" -#include "cpPivotJoint.h" -#include "cpGrooveJoint.h" -#include "cpDampedSpring.h" -#include "cpDampedRotarySpring.h" -#include "cpRotaryLimitJoint.h" -#include "cpRatchetJoint.h" -#include "cpGearJoint.h" -#include "cpSimpleMotor.h" - -///@} diff --git a/thirdparty/include/chipmunk/cpDampedRotarySpring.h b/thirdparty/include/chipmunk/cpDampedRotarySpring.h deleted file mode 100644 index 6f60e86e3..000000000 --- a/thirdparty/include/chipmunk/cpDampedRotarySpring.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpDampedRotarySpring cpDampedRotarySpring -/// @{ - -/// Check if a constraint is a damped rotary springs. -CP_EXPORT cpBool cpConstraintIsDampedRotarySpring(const cpConstraint *constraint); - -/// Function type used for damped rotary spring force callbacks. -typedef cpFloat (*cpDampedRotarySpringTorqueFunc)(struct cpConstraint *spring, cpFloat relativeAngle); - -/// Allocate a damped rotary spring. -CP_EXPORT cpDampedRotarySpring* cpDampedRotarySpringAlloc(void); -/// Initialize a damped rotary spring. -CP_EXPORT cpDampedRotarySpring* cpDampedRotarySpringInit(cpDampedRotarySpring *joint, cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping); -/// Allocate and initialize a damped rotary spring. -CP_EXPORT cpConstraint* cpDampedRotarySpringNew(cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping); - -/// Get the rest length of the spring. -CP_EXPORT cpFloat cpDampedRotarySpringGetRestAngle(const cpConstraint *constraint); -/// Set the rest length of the spring. -CP_EXPORT void cpDampedRotarySpringSetRestAngle(cpConstraint *constraint, cpFloat restAngle); - -/// Get the stiffness of the spring in force/distance. -CP_EXPORT cpFloat cpDampedRotarySpringGetStiffness(const cpConstraint *constraint); -/// Set the stiffness of the spring in force/distance. -CP_EXPORT void cpDampedRotarySpringSetStiffness(cpConstraint *constraint, cpFloat stiffness); - -/// Get the damping of the spring. -CP_EXPORT cpFloat cpDampedRotarySpringGetDamping(const cpConstraint *constraint); -/// Set the damping of the spring. -CP_EXPORT void cpDampedRotarySpringSetDamping(cpConstraint *constraint, cpFloat damping); - -/// Get the damping of the spring. -CP_EXPORT cpDampedRotarySpringTorqueFunc cpDampedRotarySpringGetSpringTorqueFunc(const cpConstraint *constraint); -/// Set the damping of the spring. -CP_EXPORT void cpDampedRotarySpringSetSpringTorqueFunc(cpConstraint *constraint, cpDampedRotarySpringTorqueFunc springTorqueFunc); - -/// @} diff --git a/thirdparty/include/chipmunk/cpDampedSpring.h b/thirdparty/include/chipmunk/cpDampedSpring.h deleted file mode 100644 index b332fc7f0..000000000 --- a/thirdparty/include/chipmunk/cpDampedSpring.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpDampedSpring cpDampedSpring -/// @{ - -/// Check if a constraint is a slide joint. -CP_EXPORT cpBool cpConstraintIsDampedSpring(const cpConstraint *constraint); - -/// Function type used for damped spring force callbacks. -typedef cpFloat (*cpDampedSpringForceFunc)(cpConstraint *spring, cpFloat dist); - -/// Allocate a damped spring. -CP_EXPORT cpDampedSpring* cpDampedSpringAlloc(void); -/// Initialize a damped spring. -CP_EXPORT cpDampedSpring* cpDampedSpringInit(cpDampedSpring *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat restLength, cpFloat stiffness, cpFloat damping); -/// Allocate and initialize a damped spring. -CP_EXPORT cpConstraint* cpDampedSpringNew(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat restLength, cpFloat stiffness, cpFloat damping); - -/// Get the location of the first anchor relative to the first body. -CP_EXPORT cpVect cpDampedSpringGetAnchorA(const cpConstraint *constraint); -/// Set the location of the first anchor relative to the first body. -CP_EXPORT void cpDampedSpringSetAnchorA(cpConstraint *constraint, cpVect anchorA); - -/// Get the location of the second anchor relative to the second body. -CP_EXPORT cpVect cpDampedSpringGetAnchorB(const cpConstraint *constraint); -/// Set the location of the second anchor relative to the second body. -CP_EXPORT void cpDampedSpringSetAnchorB(cpConstraint *constraint, cpVect anchorB); - -/// Get the rest length of the spring. -CP_EXPORT cpFloat cpDampedSpringGetRestLength(const cpConstraint *constraint); -/// Set the rest length of the spring. -CP_EXPORT void cpDampedSpringSetRestLength(cpConstraint *constraint, cpFloat restLength); - -/// Get the stiffness of the spring in force/distance. -CP_EXPORT cpFloat cpDampedSpringGetStiffness(const cpConstraint *constraint); -/// Set the stiffness of the spring in force/distance. -CP_EXPORT void cpDampedSpringSetStiffness(cpConstraint *constraint, cpFloat stiffness); - -/// Get the damping of the spring. -CP_EXPORT cpFloat cpDampedSpringGetDamping(const cpConstraint *constraint); -/// Set the damping of the spring. -CP_EXPORT void cpDampedSpringSetDamping(cpConstraint *constraint, cpFloat damping); - -/// Get the damping of the spring. -CP_EXPORT cpDampedSpringForceFunc cpDampedSpringGetSpringForceFunc(const cpConstraint *constraint); -/// Set the damping of the spring. -CP_EXPORT void cpDampedSpringSetSpringForceFunc(cpConstraint *constraint, cpDampedSpringForceFunc springForceFunc); - -/// @} diff --git a/thirdparty/include/chipmunk/cpGearJoint.h b/thirdparty/include/chipmunk/cpGearJoint.h deleted file mode 100644 index 8cd80e0b9..000000000 --- a/thirdparty/include/chipmunk/cpGearJoint.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpGearJoint cpGearJoint -/// @{ - -/// Check if a constraint is a damped rotary springs. -CP_EXPORT cpBool cpConstraintIsGearJoint(const cpConstraint *constraint); - -/// Allocate a gear joint. -CP_EXPORT cpGearJoint* cpGearJointAlloc(void); -/// Initialize a gear joint. -CP_EXPORT cpGearJoint* cpGearJointInit(cpGearJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio); -/// Allocate and initialize a gear joint. -CP_EXPORT cpConstraint* cpGearJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio); - -/// Get the phase offset of the gears. -CP_EXPORT cpFloat cpGearJointGetPhase(const cpConstraint *constraint); -/// Set the phase offset of the gears. -CP_EXPORT void cpGearJointSetPhase(cpConstraint *constraint, cpFloat phase); - -/// Get the angular distance of each ratchet. -CP_EXPORT cpFloat cpGearJointGetRatio(const cpConstraint *constraint); -/// Set the ratio of a gear joint. -CP_EXPORT void cpGearJointSetRatio(cpConstraint *constraint, cpFloat ratio); - -/// @} diff --git a/thirdparty/include/chipmunk/cpGrooveJoint.h b/thirdparty/include/chipmunk/cpGrooveJoint.h deleted file mode 100644 index 8bdafc14a..000000000 --- a/thirdparty/include/chipmunk/cpGrooveJoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpGrooveJoint cpGrooveJoint -/// @{ - -/// Check if a constraint is a slide joint. -CP_EXPORT cpBool cpConstraintIsGrooveJoint(const cpConstraint *constraint); - -/// Allocate a groove joint. -CP_EXPORT cpGrooveJoint* cpGrooveJointAlloc(void); -/// Initialize a groove joint. -CP_EXPORT cpGrooveJoint* cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchorB); -/// Allocate and initialize a groove joint. -CP_EXPORT cpConstraint* cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchorB); - -/// Get the first endpoint of the groove relative to the first body. -CP_EXPORT cpVect cpGrooveJointGetGrooveA(const cpConstraint *constraint); -/// Set the first endpoint of the groove relative to the first body. -CP_EXPORT void cpGrooveJointSetGrooveA(cpConstraint *constraint, cpVect grooveA); - -/// Get the first endpoint of the groove relative to the first body. -CP_EXPORT cpVect cpGrooveJointGetGrooveB(const cpConstraint *constraint); -/// Set the first endpoint of the groove relative to the first body. -CP_EXPORT void cpGrooveJointSetGrooveB(cpConstraint *constraint, cpVect grooveB); - -/// Get the location of the second anchor relative to the second body. -CP_EXPORT cpVect cpGrooveJointGetAnchorB(const cpConstraint *constraint); -/// Set the location of the second anchor relative to the second body. -CP_EXPORT void cpGrooveJointSetAnchorB(cpConstraint *constraint, cpVect anchorB); - -/// @} diff --git a/thirdparty/include/chipmunk/cpHastySpace.h b/thirdparty/include/chipmunk/cpHastySpace.h deleted file mode 100644 index 6de2283b9..000000000 --- a/thirdparty/include/chipmunk/cpHastySpace.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 Howling Moon Software. All rights reserved. -// See http://chipmunk2d.net/legal.php for more information. - -/// cpHastySpace is exclusive to Chipmunk Pro -/// Currently it enables ARM NEON optimizations in the solver, but in the future will include other optimizations such as -/// a multi-threaded solver and multi-threaded collision broadphases. - -struct cpHastySpace; -typedef struct cpHastySpace cpHastySpace; - -/// Create a new hasty space. -/// On ARM platforms that support NEON, this will enable the vectorized solver. -/// cpHastySpace also supports multiple threads, but runs single threaded by default for determinism. -CP_EXPORT cpSpace *cpHastySpaceNew(void); -CP_EXPORT void cpHastySpaceFree(cpSpace *space); - -/// Set the number of threads to use for the solver. -/// Currently Chipmunk is limited to 2 threads as using more generally provides very minimal performance gains. -/// Passing 0 as the thread count on iOS or OS X will cause Chipmunk to automatically detect the number of threads it should use. -/// On other platforms passing 0 for the thread count will set 1 thread. -CP_EXPORT void cpHastySpaceSetThreads(cpSpace *space, unsigned long threads); - -/// Returns the number of threads the solver is using to run. -CP_EXPORT unsigned long cpHastySpaceGetThreads(cpSpace *space); - -/// When stepping a hasty space, you must use this function. -CP_EXPORT void cpHastySpaceStep(cpSpace *space, cpFloat dt); diff --git a/thirdparty/include/chipmunk/cpMarch.h b/thirdparty/include/chipmunk/cpMarch.h deleted file mode 100644 index cc1f5c061..000000000 --- a/thirdparty/include/chipmunk/cpMarch.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013 Howling Moon Software. All rights reserved. -// See http://chipmunk2d.net/legal.php for more information. - -/// Function type used as a callback from the marching squares algorithm to sample an image function. -/// It passes you the point to sample and your context pointer, and you return the density. -typedef cpFloat (*cpMarchSampleFunc)(cpVect point, void *data); - -/// Function type used as a callback from the marching squares algorithm to output a line segment. -/// It passes you the two endpoints and your context pointer. -typedef void (*cpMarchSegmentFunc)(cpVect v0, cpVect v1, void *data); - -/// Trace an anti-aliased contour of an image along a particular threshold. -/// The given number of samples will be taken and spread across the bounding box area using the sampling function and context. -/// The segment function will be called for each segment detected that lies along the density contour for @c threshold. -CP_EXPORT void cpMarchSoft( - cpBB bb, unsigned long x_samples, unsigned long y_samples, cpFloat threshold, - cpMarchSegmentFunc segment, void *segment_data, - cpMarchSampleFunc sample, void *sample_data -); - -/// Trace an aliased curve of an image along a particular threshold. -/// The given number of samples will be taken and spread across the bounding box area using the sampling function and context. -/// The segment function will be called for each segment detected that lies along the density contour for @c threshold. -CP_EXPORT void cpMarchHard( - cpBB bb, unsigned long x_samples, unsigned long y_samples, cpFloat threshold, - cpMarchSegmentFunc segment, void *segment_data, - cpMarchSampleFunc sample, void *sample_data -); diff --git a/thirdparty/include/chipmunk/cpPinJoint.h b/thirdparty/include/chipmunk/cpPinJoint.h deleted file mode 100644 index 45aaa3e33..000000000 --- a/thirdparty/include/chipmunk/cpPinJoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpPinJoint cpPinJoint -/// @{ - -/// Check if a constraint is a pin joint. -CP_EXPORT cpBool cpConstraintIsPinJoint(const cpConstraint *constraint); - -/// Allocate a pin joint. -CP_EXPORT cpPinJoint* cpPinJointAlloc(void); -/// Initialize a pin joint. -CP_EXPORT cpPinJoint* cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); -/// Allocate and initialize a pin joint. -CP_EXPORT cpConstraint* cpPinJointNew(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); - -/// Get the location of the first anchor relative to the first body. -CP_EXPORT cpVect cpPinJointGetAnchorA(const cpConstraint *constraint); -/// Set the location of the first anchor relative to the first body. -CP_EXPORT void cpPinJointSetAnchorA(cpConstraint *constraint, cpVect anchorA); - -/// Get the location of the second anchor relative to the second body. -CP_EXPORT cpVect cpPinJointGetAnchorB(const cpConstraint *constraint); -/// Set the location of the second anchor relative to the second body. -CP_EXPORT void cpPinJointSetAnchorB(cpConstraint *constraint, cpVect anchorB); - -/// Get the distance the joint will maintain between the two anchors. -CP_EXPORT cpFloat cpPinJointGetDist(const cpConstraint *constraint); -/// Set the distance the joint will maintain between the two anchors. -CP_EXPORT void cpPinJointSetDist(cpConstraint *constraint, cpFloat dist); - -///@} diff --git a/thirdparty/include/chipmunk/cpPivotJoint.h b/thirdparty/include/chipmunk/cpPivotJoint.h deleted file mode 100644 index 4a620ef25..000000000 --- a/thirdparty/include/chipmunk/cpPivotJoint.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpPivotJoint cpPivotJoint -/// @{ - -/// Check if a constraint is a slide joint. -CP_EXPORT cpBool cpConstraintIsPivotJoint(const cpConstraint *constraint); - -/// Allocate a pivot joint -CP_EXPORT cpPivotJoint* cpPivotJointAlloc(void); -/// Initialize a pivot joint. -CP_EXPORT cpPivotJoint* cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); -/// Allocate and initialize a pivot joint. -CP_EXPORT cpConstraint* cpPivotJointNew(cpBody *a, cpBody *b, cpVect pivot); -/// Allocate and initialize a pivot joint with specific anchors. -CP_EXPORT cpConstraint* cpPivotJointNew2(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); - -/// Get the location of the first anchor relative to the first body. -CP_EXPORT cpVect cpPivotJointGetAnchorA(const cpConstraint *constraint); -/// Set the location of the first anchor relative to the first body. -CP_EXPORT void cpPivotJointSetAnchorA(cpConstraint *constraint, cpVect anchorA); - -/// Get the location of the second anchor relative to the second body. -CP_EXPORT cpVect cpPivotJointGetAnchorB(const cpConstraint *constraint); -/// Set the location of the second anchor relative to the second body. -CP_EXPORT void cpPivotJointSetAnchorB(cpConstraint *constraint, cpVect anchorB); - -/// @} diff --git a/thirdparty/include/chipmunk/cpPolyShape.h b/thirdparty/include/chipmunk/cpPolyShape.h deleted file mode 100644 index 25f688b89..000000000 --- a/thirdparty/include/chipmunk/cpPolyShape.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpPolyShape cpPolyShape -/// @{ - -/// Allocate a polygon shape. -CP_EXPORT cpPolyShape* cpPolyShapeAlloc(void); -/// Initialize a polygon shape with rounded corners. -/// A convex hull will be created from the vertexes. -CP_EXPORT cpPolyShape* cpPolyShapeInit(cpPolyShape *poly, cpBody *body, int count, const cpVect *verts, cpTransform transform, cpFloat radius); -/// Initialize a polygon shape with rounded corners. -/// The vertexes must be convex with a counter-clockwise winding. -CP_EXPORT cpPolyShape* cpPolyShapeInitRaw(cpPolyShape *poly, cpBody *body, int count, const cpVect *verts, cpFloat radius); -/// Allocate and initialize a polygon shape with rounded corners. -/// A convex hull will be created from the vertexes. -CP_EXPORT cpShape* cpPolyShapeNew(cpBody *body, int count, const cpVect *verts, cpTransform transform, cpFloat radius); -/// Allocate and initialize a polygon shape with rounded corners. -/// The vertexes must be convex with a counter-clockwise winding. -CP_EXPORT cpShape* cpPolyShapeNewRaw(cpBody *body, int count, const cpVect *verts, cpFloat radius); - -/// Initialize a box shaped polygon shape with rounded corners. -CP_EXPORT cpPolyShape* cpBoxShapeInit(cpPolyShape *poly, cpBody *body, cpFloat width, cpFloat height, cpFloat radius); -/// Initialize an offset box shaped polygon shape with rounded corners. -CP_EXPORT cpPolyShape* cpBoxShapeInit2(cpPolyShape *poly, cpBody *body, cpBB box, cpFloat radius); -/// Allocate and initialize a box shaped polygon shape. -CP_EXPORT cpShape* cpBoxShapeNew(cpBody *body, cpFloat width, cpFloat height, cpFloat radius); -/// Allocate and initialize an offset box shaped polygon shape. -CP_EXPORT cpShape* cpBoxShapeNew2(cpBody *body, cpBB box, cpFloat radius); - -/// Get the number of verts in a polygon shape. -CP_EXPORT int cpPolyShapeGetCount(const cpShape *shape); -/// Get the @c ith vertex of a polygon shape. -CP_EXPORT cpVect cpPolyShapeGetVert(const cpShape *shape, int index); -/// Get the radius of a polygon shape. -CP_EXPORT cpFloat cpPolyShapeGetRadius(const cpShape *shape); - -/// @} diff --git a/thirdparty/include/chipmunk/cpPolyline.h b/thirdparty/include/chipmunk/cpPolyline.h deleted file mode 100644 index 4e878f0c9..000000000 --- a/thirdparty/include/chipmunk/cpPolyline.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2013 Howling Moon Software. All rights reserved. -// See http://chipmunk2d.net/legal.php for more information. - -// Polylines are just arrays of vertexes. -// They are looped if the first vertex is equal to the last. -// cpPolyline structs are intended to be passed by value and destroyed when you are done with them. -typedef struct cpPolyline { - int count, capacity; - cpVect verts[]; -} cpPolyline; - -/// Destroy and free a polyline instance. -CP_EXPORT void cpPolylineFree(cpPolyline *line); - -/// Returns true if the first vertex is equal to the last. -CP_EXPORT cpBool cpPolylineIsClosed(cpPolyline *line); - -/** - Returns a copy of a polyline simplified by using the Douglas-Peucker algorithm. - This works very well on smooth or gently curved shapes, but not well on straight edged or angular shapes. -*/ -CP_EXPORT cpPolyline *cpPolylineSimplifyCurves(cpPolyline *line, cpFloat tol); - -/** - Returns a copy of a polyline simplified by discarding "flat" vertexes. - This works well on straigt edged or angular shapes, not as well on smooth shapes. -*/ -CP_EXPORT cpPolyline *cpPolylineSimplifyVertexes(cpPolyline *line, cpFloat tol); - -/// Get the convex hull of a polyline as a looped polyline. -CP_EXPORT cpPolyline *cpPolylineToConvexHull(cpPolyline *line, cpFloat tol); - - -/// Polyline sets are collections of polylines, generally built by cpMarchSoft() or cpMarchHard(). -typedef struct cpPolylineSet { - int count, capacity; - cpPolyline **lines; -} cpPolylineSet; - -/// Allocate a new polyline set. -CP_EXPORT cpPolylineSet *cpPolylineSetAlloc(void); - -/// Initialize a new polyline set. -CP_EXPORT cpPolylineSet *cpPolylineSetInit(cpPolylineSet *set); - -/// Allocate and initialize a polyline set. -CP_EXPORT cpPolylineSet *cpPolylineSetNew(void); - -/// Destroy a polyline set. -CP_EXPORT void cpPolylineSetDestroy(cpPolylineSet *set, cpBool freePolylines); - -/// Destroy and free a polyline set. -CP_EXPORT void cpPolylineSetFree(cpPolylineSet *set, cpBool freePolylines); - -/** - Add a line segment to a polyline set. - A segment will either start a new polyline, join two others, or add to or loop an existing polyline. - This is mostly intended to be used as a callback directly from cpMarchSoft() or cpMarchHard(). -*/ -CP_EXPORT void cpPolylineSetCollectSegment(cpVect v0, cpVect v1, cpPolylineSet *lines); - -/** - Get an approximate convex decomposition from a polyline. - Returns a cpPolylineSet of convex hulls that match the original shape to within 'tol'. - NOTE: If the input is a self intersecting polygon, the output might end up overly simplified. -*/ - -CP_EXPORT cpPolylineSet *cpPolylineConvexDecomposition(cpPolyline *line, cpFloat tol); - -#define cpPolylineConvexDecomposition_BETA cpPolylineConvexDecomposition diff --git a/thirdparty/include/chipmunk/cpRatchetJoint.h b/thirdparty/include/chipmunk/cpRatchetJoint.h deleted file mode 100644 index 3ed4c915e..000000000 --- a/thirdparty/include/chipmunk/cpRatchetJoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpRatchetJoint cpRatchetJoint -/// @{ - -/// Check if a constraint is a damped rotary springs. -CP_EXPORT cpBool cpConstraintIsRatchetJoint(const cpConstraint *constraint); - -/// Allocate a ratchet joint. -CP_EXPORT cpRatchetJoint* cpRatchetJointAlloc(void); -/// Initialize a ratched joint. -CP_EXPORT cpRatchetJoint* cpRatchetJointInit(cpRatchetJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet); -/// Allocate and initialize a ratchet joint. -CP_EXPORT cpConstraint* cpRatchetJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet); - -/// Get the angle of the current ratchet tooth. -CP_EXPORT cpFloat cpRatchetJointGetAngle(const cpConstraint *constraint); -/// Set the angle of the current ratchet tooth. -CP_EXPORT void cpRatchetJointSetAngle(cpConstraint *constraint, cpFloat angle); - -/// Get the phase offset of the ratchet. -CP_EXPORT cpFloat cpRatchetJointGetPhase(const cpConstraint *constraint); -/// Get the phase offset of the ratchet. -CP_EXPORT void cpRatchetJointSetPhase(cpConstraint *constraint, cpFloat phase); - -/// Get the angular distance of each ratchet. -CP_EXPORT cpFloat cpRatchetJointGetRatchet(const cpConstraint *constraint); -/// Set the angular distance of each ratchet. -CP_EXPORT void cpRatchetJointSetRatchet(cpConstraint *constraint, cpFloat ratchet); - -/// @} diff --git a/thirdparty/include/chipmunk/cpRobust.h b/thirdparty/include/chipmunk/cpRobust.h deleted file mode 100644 index e4b2c4208..000000000 --- a/thirdparty/include/chipmunk/cpRobust.h +++ /dev/null @@ -1,11 +0,0 @@ -#include "chipmunk/cpVect.h" - -// This is a private header for functions (currently just one) that need strict floating point results. -// It was easier to put this in it's own file than to fiddle with 4 different compiler specific pragmas or attributes. -// "Fast math" should be disabled here. - -// Check if c is to the left of segment (a, b). -cpBool cpCheckPointGreater(const cpVect a, const cpVect b, const cpVect c); - -// Check if p is behind one of v0 or v1 on axis n. -cpBool cpCheckAxis(cpVect v0, cpVect v1, cpVect p, cpVect n); diff --git a/thirdparty/include/chipmunk/cpRotaryLimitJoint.h b/thirdparty/include/chipmunk/cpRotaryLimitJoint.h deleted file mode 100644 index fac7ad859..000000000 --- a/thirdparty/include/chipmunk/cpRotaryLimitJoint.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpRotaryLimitJoint cpRotaryLimitJoint -/// @{ - -/// Check if a constraint is a damped rotary springs. -CP_EXPORT cpBool cpConstraintIsRotaryLimitJoint(const cpConstraint *constraint); - -/// Allocate a damped rotary limit joint. -CP_EXPORT cpRotaryLimitJoint* cpRotaryLimitJointAlloc(void); -/// Initialize a damped rotary limit joint. -CP_EXPORT cpRotaryLimitJoint* cpRotaryLimitJointInit(cpRotaryLimitJoint *joint, cpBody *a, cpBody *b, cpFloat min, cpFloat max); -/// Allocate and initialize a damped rotary limit joint. -CP_EXPORT cpConstraint* cpRotaryLimitJointNew(cpBody *a, cpBody *b, cpFloat min, cpFloat max); - -/// Get the minimum distance the joint will maintain between the two anchors. -CP_EXPORT cpFloat cpRotaryLimitJointGetMin(const cpConstraint *constraint); -/// Set the minimum distance the joint will maintain between the two anchors. -CP_EXPORT void cpRotaryLimitJointSetMin(cpConstraint *constraint, cpFloat min); - -/// Get the maximum distance the joint will maintain between the two anchors. -CP_EXPORT cpFloat cpRotaryLimitJointGetMax(const cpConstraint *constraint); -/// Set the maximum distance the joint will maintain between the two anchors. -CP_EXPORT void cpRotaryLimitJointSetMax(cpConstraint *constraint, cpFloat max); - -/// @} diff --git a/thirdparty/include/chipmunk/cpShape.h b/thirdparty/include/chipmunk/cpShape.h deleted file mode 100644 index c78ed05d0..000000000 --- a/thirdparty/include/chipmunk/cpShape.h +++ /dev/null @@ -1,199 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpShape cpShape -/// The cpShape struct defines the shape of a rigid body. -/// @{ - -/// Point query info struct. -typedef struct cpPointQueryInfo { - /// The nearest shape, NULL if no shape was within range. - const cpShape *shape; - /// The closest point on the shape's surface. (in world space coordinates) - cpVect point; - /// The distance to the point. The distance is negative if the point is inside the shape. - cpFloat distance; - /// The gradient of the signed distance function. - /// The value should be similar to info.p/info.d, but accurate even for very small values of info.d. - cpVect gradient; -} cpPointQueryInfo; - -/// Segment query info struct. -typedef struct cpSegmentQueryInfo { - /// The shape that was hit, or NULL if no collision occured. - const cpShape *shape; - /// The point of impact. - cpVect point; - /// The normal of the surface hit. - cpVect normal; - /// The normalized distance along the query segment in the range [0, 1]. - cpFloat alpha; -} cpSegmentQueryInfo; - -/// Fast collision filtering type that is used to determine if two objects collide before calling collision or query callbacks. -typedef struct cpShapeFilter { - /// Two objects with the same non-zero group value do not collide. - /// This is generally used to group objects in a composite object together to disable self collisions. - cpGroup group; - /// A bitmask of user definable categories that this object belongs to. - /// The category/mask combinations of both objects in a collision must agree for a collision to occur. - cpBitmask categories; - /// A bitmask of user definable category types that this object object collides with. - /// The category/mask combinations of both objects in a collision must agree for a collision to occur. - cpBitmask mask; -} cpShapeFilter; - -/// Collision filter value for a shape that will collide with anything except CP_SHAPE_FILTER_NONE. -static const cpShapeFilter CP_SHAPE_FILTER_ALL = {CP_NO_GROUP, CP_ALL_CATEGORIES, CP_ALL_CATEGORIES}; -/// Collision filter value for a shape that does not collide with anything. -static const cpShapeFilter CP_SHAPE_FILTER_NONE = {CP_NO_GROUP, ~CP_ALL_CATEGORIES, ~CP_ALL_CATEGORIES}; - -/// Create a new collision filter. -static inline cpShapeFilter -cpShapeFilterNew(cpGroup group, cpBitmask categories, cpBitmask mask) -{ - cpShapeFilter filter = {group, categories, mask}; - return filter; -} - -/// Destroy a shape. -CP_EXPORT void cpShapeDestroy(cpShape *shape); -/// Destroy and Free a shape. -CP_EXPORT void cpShapeFree(cpShape *shape); - -/// Update, cache and return the bounding box of a shape based on the body it's attached to. -CP_EXPORT cpBB cpShapeCacheBB(cpShape *shape); -/// Update, cache and return the bounding box of a shape with an explicit transformation. -CP_EXPORT cpBB cpShapeUpdate(cpShape *shape, cpTransform transform); - -/// Perform a nearest point query. It finds the closest point on the surface of shape to a specific point. -/// The value returned is the distance between the points. A negative distance means the point is inside the shape. -CP_EXPORT cpFloat cpShapePointQuery(const cpShape *shape, cpVect p, cpPointQueryInfo *out); - -/// Perform a segment query against a shape. @c info must be a pointer to a valid cpSegmentQueryInfo structure. -CP_EXPORT cpBool cpShapeSegmentQuery(const cpShape *shape, cpVect a, cpVect b, cpFloat radius, cpSegmentQueryInfo *info); - -/// Return contact information about two shapes. -CP_EXPORT cpContactPointSet cpShapesCollide(const cpShape *a, const cpShape *b); - -/// The cpSpace this body is added to. -CP_EXPORT cpSpace* cpShapeGetSpace(const cpShape *shape); - -/// The cpBody this shape is connected to. -CP_EXPORT cpBody* cpShapeGetBody(const cpShape *shape); -/// Set the cpBody this shape is connected to. -/// Can only be used if the shape is not currently added to a space. -CP_EXPORT void cpShapeSetBody(cpShape *shape, cpBody *body); - -/// Get the mass of the shape if you are having Chipmunk calculate mass properties for you. -CP_EXPORT cpFloat cpShapeGetMass(cpShape *shape); -/// Set the mass of this shape to have Chipmunk calculate mass properties for you. -CP_EXPORT void cpShapeSetMass(cpShape *shape, cpFloat mass); - -/// Get the density of the shape if you are having Chipmunk calculate mass properties for you. -CP_EXPORT cpFloat cpShapeGetDensity(cpShape *shape); -/// Set the density of this shape to have Chipmunk calculate mass properties for you. -CP_EXPORT void cpShapeSetDensity(cpShape *shape, cpFloat density); - -/// Get the calculated moment of inertia for this shape. -CP_EXPORT cpFloat cpShapeGetMoment(cpShape *shape); -/// Get the calculated area of this shape. -CP_EXPORT cpFloat cpShapeGetArea(cpShape *shape); -/// Get the centroid of this shape. -CP_EXPORT cpVect cpShapeGetCenterOfGravity(cpShape *shape); - -/// Get the bounding box that contains the shape given it's current position and angle. -CP_EXPORT cpBB cpShapeGetBB(const cpShape *shape); - -/// Get if the shape is set to be a sensor or not. -CP_EXPORT cpBool cpShapeGetSensor(const cpShape *shape); -/// Set if the shape is a sensor or not. -CP_EXPORT void cpShapeSetSensor(cpShape *shape, cpBool sensor); - -/// Get the elasticity of this shape. -CP_EXPORT cpFloat cpShapeGetElasticity(const cpShape *shape); -/// Set the elasticity of this shape. -CP_EXPORT void cpShapeSetElasticity(cpShape *shape, cpFloat elasticity); - -/// Get the friction of this shape. -CP_EXPORT cpFloat cpShapeGetFriction(const cpShape *shape); -/// Set the friction of this shape. -CP_EXPORT void cpShapeSetFriction(cpShape *shape, cpFloat friction); - -/// Get the surface velocity of this shape. -CP_EXPORT cpVect cpShapeGetSurfaceVelocity(const cpShape *shape); -/// Set the surface velocity of this shape. -CP_EXPORT void cpShapeSetSurfaceVelocity(cpShape *shape, cpVect surfaceVelocity); - -/// Get the user definable data pointer of this shape. -CP_EXPORT cpDataPointer cpShapeGetUserData(const cpShape *shape); -/// Set the user definable data pointer of this shape. -CP_EXPORT void cpShapeSetUserData(cpShape *shape, cpDataPointer userData); - -/// Set the collision type of this shape. -CP_EXPORT cpCollisionType cpShapeGetCollisionType(const cpShape *shape); -/// Get the collision type of this shape. -CP_EXPORT void cpShapeSetCollisionType(cpShape *shape, cpCollisionType collisionType); - -/// Get the collision filtering parameters of this shape. -CP_EXPORT cpShapeFilter cpShapeGetFilter(const cpShape *shape); -/// Set the collision filtering parameters of this shape. -CP_EXPORT void cpShapeSetFilter(cpShape *shape, cpShapeFilter filter); - - -/// @} -/// @defgroup cpCircleShape cpCircleShape - -/// Allocate a circle shape. -CP_EXPORT cpCircleShape* cpCircleShapeAlloc(void); -/// Initialize a circle shape. -CP_EXPORT cpCircleShape* cpCircleShapeInit(cpCircleShape *circle, cpBody *body, cpFloat radius, cpVect offset); -/// Allocate and initialize a circle shape. -CP_EXPORT cpShape* cpCircleShapeNew(cpBody *body, cpFloat radius, cpVect offset); - -/// Get the offset of a circle shape. -CP_EXPORT cpVect cpCircleShapeGetOffset(const cpShape *shape); -/// Get the radius of a circle shape. -CP_EXPORT cpFloat cpCircleShapeGetRadius(const cpShape *shape); - -/// @} -/// @defgroup cpSegmentShape cpSegmentShape - -/// Allocate a segment shape. -CP_EXPORT cpSegmentShape* cpSegmentShapeAlloc(void); -/// Initialize a segment shape. -CP_EXPORT cpSegmentShape* cpSegmentShapeInit(cpSegmentShape *seg, cpBody *body, cpVect a, cpVect b, cpFloat radius); -/// Allocate and initialize a segment shape. -CP_EXPORT cpShape* cpSegmentShapeNew(cpBody *body, cpVect a, cpVect b, cpFloat radius); - -/// Let Chipmunk know about the geometry of adjacent segments to avoid colliding with endcaps. -CP_EXPORT void cpSegmentShapeSetNeighbors(cpShape *shape, cpVect prev, cpVect next); - -/// Get the first endpoint of a segment shape. -CP_EXPORT cpVect cpSegmentShapeGetA(const cpShape *shape); -/// Get the second endpoint of a segment shape. -CP_EXPORT cpVect cpSegmentShapeGetB(const cpShape *shape); -/// Get the normal of a segment shape. -CP_EXPORT cpVect cpSegmentShapeGetNormal(const cpShape *shape); -/// Get the first endpoint of a segment shape. -CP_EXPORT cpFloat cpSegmentShapeGetRadius(const cpShape *shape); - -/// @} diff --git a/thirdparty/include/chipmunk/cpSimpleMotor.h b/thirdparty/include/chipmunk/cpSimpleMotor.h deleted file mode 100644 index 811b01143..000000000 --- a/thirdparty/include/chipmunk/cpSimpleMotor.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpSimpleMotor cpSimpleMotor -/// @{ - -/// Opaque struct type for damped rotary springs. -typedef struct cpSimpleMotor cpSimpleMotor; - -/// Check if a constraint is a damped rotary springs. -CP_EXPORT cpBool cpConstraintIsSimpleMotor(const cpConstraint *constraint); - -/// Allocate a simple motor. -CP_EXPORT cpSimpleMotor* cpSimpleMotorAlloc(void); -/// initialize a simple motor. -CP_EXPORT cpSimpleMotor* cpSimpleMotorInit(cpSimpleMotor *joint, cpBody *a, cpBody *b, cpFloat rate); -/// Allocate and initialize a simple motor. -CP_EXPORT cpConstraint* cpSimpleMotorNew(cpBody *a, cpBody *b, cpFloat rate); - -/// Get the rate of the motor. -CP_EXPORT cpFloat cpSimpleMotorGetRate(const cpConstraint *constraint); -/// Set the rate of the motor. -CP_EXPORT void cpSimpleMotorSetRate(cpConstraint *constraint, cpFloat rate); - -/// @} diff --git a/thirdparty/include/chipmunk/cpSlideJoint.h b/thirdparty/include/chipmunk/cpSlideJoint.h deleted file mode 100644 index c41f9a42e..000000000 --- a/thirdparty/include/chipmunk/cpSlideJoint.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpSlideJoint cpSlideJoint -/// @{ - -/// Check if a constraint is a slide joint. -CP_EXPORT cpBool cpConstraintIsSlideJoint(const cpConstraint *constraint); - -/// Allocate a slide joint. -CP_EXPORT cpSlideJoint* cpSlideJointAlloc(void); -/// Initialize a slide joint. -CP_EXPORT cpSlideJoint* cpSlideJointInit(cpSlideJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat min, cpFloat max); -/// Allocate and initialize a slide joint. -CP_EXPORT cpConstraint* cpSlideJointNew(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat min, cpFloat max); - -/// Get the location of the first anchor relative to the first body. -CP_EXPORT cpVect cpSlideJointGetAnchorA(const cpConstraint *constraint); -/// Set the location of the first anchor relative to the first body. -CP_EXPORT void cpSlideJointSetAnchorA(cpConstraint *constraint, cpVect anchorA); - -/// Get the location of the second anchor relative to the second body. -CP_EXPORT cpVect cpSlideJointGetAnchorB(const cpConstraint *constraint); -/// Set the location of the second anchor relative to the second body. -CP_EXPORT void cpSlideJointSetAnchorB(cpConstraint *constraint, cpVect anchorB); - -/// Get the minimum distance the joint will maintain between the two anchors. -CP_EXPORT cpFloat cpSlideJointGetMin(const cpConstraint *constraint); -/// Set the minimum distance the joint will maintain between the two anchors. -CP_EXPORT void cpSlideJointSetMin(cpConstraint *constraint, cpFloat min); - -/// Get the maximum distance the joint will maintain between the two anchors. -CP_EXPORT cpFloat cpSlideJointGetMax(const cpConstraint *constraint); -/// Set the maximum distance the joint will maintain between the two anchors. -CP_EXPORT void cpSlideJointSetMax(cpConstraint *constraint, cpFloat max); - -/// @} diff --git a/thirdparty/include/chipmunk/cpSpace.h b/thirdparty/include/chipmunk/cpSpace.h deleted file mode 100644 index 7bbabb857..000000000 --- a/thirdparty/include/chipmunk/cpSpace.h +++ /dev/null @@ -1,319 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/// @defgroup cpSpace cpSpace -/// @{ - -//MARK: Definitions - -/// Collision begin event function callback type. -/// Returning false from a begin callback causes the collision to be ignored until -/// the the separate callback is called when the objects stop colliding. -typedef cpBool (*cpCollisionBeginFunc)(cpArbiter *arb, cpSpace *space, cpDataPointer userData); -/// Collision pre-solve event function callback type. -/// Returning false from a pre-step callback causes the collision to be ignored until the next step. -typedef cpBool (*cpCollisionPreSolveFunc)(cpArbiter *arb, cpSpace *space, cpDataPointer userData); -/// Collision post-solve event function callback type. -typedef void (*cpCollisionPostSolveFunc)(cpArbiter *arb, cpSpace *space, cpDataPointer userData); -/// Collision separate event function callback type. -typedef void (*cpCollisionSeparateFunc)(cpArbiter *arb, cpSpace *space, cpDataPointer userData); - -/// Struct that holds function callback pointers to configure custom collision handling. -/// Collision handlers have a pair of types; when a collision occurs between two shapes that have these types, the collision handler functions are triggered. -struct cpCollisionHandler { - /// Collision type identifier of the first shape that this handler recognizes. - /// In the collision handler callback, the shape with this type will be the first argument. Read only. - const cpCollisionType typeA; - /// Collision type identifier of the second shape that this handler recognizes. - /// In the collision handler callback, the shape with this type will be the second argument. Read only. - const cpCollisionType typeB; - /// This function is called when two shapes with types that match this collision handler begin colliding. - cpCollisionBeginFunc beginFunc; - /// This function is called each step when two shapes with types that match this collision handler are colliding. - /// It's called before the collision solver runs so that you can affect a collision's outcome. - cpCollisionPreSolveFunc preSolveFunc; - /// This function is called each step when two shapes with types that match this collision handler are colliding. - /// It's called after the collision solver runs so that you can read back information about the collision to trigger events in your game. - cpCollisionPostSolveFunc postSolveFunc; - /// This function is called when two shapes with types that match this collision handler stop colliding. - cpCollisionSeparateFunc separateFunc; - /// This is a user definable context pointer that is passed to all of the collision handler functions. - cpDataPointer userData; -}; - -// TODO: Make timestep a parameter? - - -//MARK: Memory and Initialization - -/// Allocate a cpSpace. -CP_EXPORT cpSpace* cpSpaceAlloc(void); -/// Initialize a cpSpace. -CP_EXPORT cpSpace* cpSpaceInit(cpSpace *space); -/// Allocate and initialize a cpSpace. -CP_EXPORT cpSpace* cpSpaceNew(void); - -/// Destroy a cpSpace. -CP_EXPORT void cpSpaceDestroy(cpSpace *space); -/// Destroy and free a cpSpace. -CP_EXPORT void cpSpaceFree(cpSpace *space); - - -//MARK: Properties - -/// Number of iterations to use in the impulse solver to solve contacts and other constraints. -CP_EXPORT int cpSpaceGetIterations(const cpSpace *space); -CP_EXPORT void cpSpaceSetIterations(cpSpace *space, int iterations); - -/// Gravity to pass to rigid bodies when integrating velocity. -CP_EXPORT cpVect cpSpaceGetGravity(const cpSpace *space); -CP_EXPORT void cpSpaceSetGravity(cpSpace *space, cpVect gravity); - -/// Damping rate expressed as the fraction of velocity bodies retain each second. -/// A value of 0.9 would mean that each body's velocity will drop 10% per second. -/// The default value is 1.0, meaning no damping is applied. -/// @note This damping value is different than those of cpDampedSpring and cpDampedRotarySpring. -CP_EXPORT cpFloat cpSpaceGetDamping(const cpSpace *space); -CP_EXPORT void cpSpaceSetDamping(cpSpace *space, cpFloat damping); - -/// Speed threshold for a body to be considered idle. -/// The default value of 0 means to let the space guess a good threshold based on gravity. -CP_EXPORT cpFloat cpSpaceGetIdleSpeedThreshold(const cpSpace *space); -CP_EXPORT void cpSpaceSetIdleSpeedThreshold(cpSpace *space, cpFloat idleSpeedThreshold); - -/// Time a group of bodies must remain idle in order to fall asleep. -/// Enabling sleeping also implicitly enables the the contact graph. -/// The default value of INFINITY disables the sleeping algorithm. -CP_EXPORT cpFloat cpSpaceGetSleepTimeThreshold(const cpSpace *space); -CP_EXPORT void cpSpaceSetSleepTimeThreshold(cpSpace *space, cpFloat sleepTimeThreshold); - -/// Amount of encouraged penetration between colliding shapes. -/// Used to reduce oscillating contacts and keep the collision cache warm. -/// Defaults to 0.1. If you have poor simulation quality, -/// increase this number as much as possible without allowing visible amounts of overlap. -CP_EXPORT cpFloat cpSpaceGetCollisionSlop(const cpSpace *space); -CP_EXPORT void cpSpaceSetCollisionSlop(cpSpace *space, cpFloat collisionSlop); - -/// Determines how fast overlapping shapes are pushed apart. -/// Expressed as a fraction of the error remaining after each second. -/// Defaults to pow(1.0 - 0.1, 60.0) meaning that Chipmunk fixes 10% of overlap each frame at 60Hz. -CP_EXPORT cpFloat cpSpaceGetCollisionBias(const cpSpace *space); -CP_EXPORT void cpSpaceSetCollisionBias(cpSpace *space, cpFloat collisionBias); - -/// Number of frames that contact information should persist. -/// Defaults to 3. There is probably never a reason to change this value. -CP_EXPORT cpTimestamp cpSpaceGetCollisionPersistence(const cpSpace *space); -CP_EXPORT void cpSpaceSetCollisionPersistence(cpSpace *space, cpTimestamp collisionPersistence); - -/// User definable data pointer. -/// Generally this points to your game's controller or game state -/// class so you can access it when given a cpSpace reference in a callback. -CP_EXPORT cpDataPointer cpSpaceGetUserData(const cpSpace *space); -CP_EXPORT void cpSpaceSetUserData(cpSpace *space, cpDataPointer userData); - -/// The Space provided static body for a given cpSpace. -/// This is merely provided for convenience and you are not required to use it. -CP_EXPORT cpBody* cpSpaceGetStaticBody(const cpSpace *space); - -/// Returns the current (or most recent) time step used with the given space. -/// Useful from callbacks if your time step is not a compile-time global. -CP_EXPORT cpFloat cpSpaceGetCurrentTimeStep(const cpSpace *space); - -/// returns true from inside a callback when objects cannot be added/removed. -CP_EXPORT cpBool cpSpaceIsLocked(cpSpace *space); - - -//MARK: Collision Handlers - -/// Create or return the existing collision handler that is called for all collisions that are not handled by a more specific collision handler. -CP_EXPORT cpCollisionHandler *cpSpaceAddDefaultCollisionHandler(cpSpace *space); -/// Create or return the existing collision handler for the specified pair of collision types. -/// If wildcard handlers are used with either of the collision types, it's the responibility of the custom handler to invoke the wildcard handlers. -CP_EXPORT cpCollisionHandler *cpSpaceAddCollisionHandler(cpSpace *space, cpCollisionType a, cpCollisionType b); -/// Create or return the existing wildcard collision handler for the specified type. -CP_EXPORT cpCollisionHandler *cpSpaceAddWildcardHandler(cpSpace *space, cpCollisionType type); - - -//MARK: Add/Remove objects - -/// Add a collision shape to the simulation. -/// If the shape is attached to a static body, it will be added as a static shape. -CP_EXPORT cpShape* cpSpaceAddShape(cpSpace *space, cpShape *shape); -/// Add a rigid body to the simulation. -CP_EXPORT cpBody* cpSpaceAddBody(cpSpace *space, cpBody *body); -/// Add a constraint to the simulation. -CP_EXPORT cpConstraint* cpSpaceAddConstraint(cpSpace *space, cpConstraint *constraint); - -/// Remove a collision shape from the simulation. -CP_EXPORT void cpSpaceRemoveShape(cpSpace *space, cpShape *shape); -/// Remove a rigid body from the simulation. -CP_EXPORT void cpSpaceRemoveBody(cpSpace *space, cpBody *body); -/// Remove a constraint from the simulation. -CP_EXPORT void cpSpaceRemoveConstraint(cpSpace *space, cpConstraint *constraint); - -/// Test if a collision shape has been added to the space. -CP_EXPORT cpBool cpSpaceContainsShape(cpSpace *space, cpShape *shape); -/// Test if a rigid body has been added to the space. -CP_EXPORT cpBool cpSpaceContainsBody(cpSpace *space, cpBody *body); -/// Test if a constraint has been added to the space. -CP_EXPORT cpBool cpSpaceContainsConstraint(cpSpace *space, cpConstraint *constraint); - -//MARK: Post-Step Callbacks - -/// Post Step callback function type. -typedef void (*cpPostStepFunc)(cpSpace *space, void *key, void *data); -/// Schedule a post-step callback to be called when cpSpaceStep() finishes. -/// You can only register one callback per unique value for @c key. -/// Returns true only if @c key has never been scheduled before. -/// It's possible to pass @c NULL for @c func if you only want to mark @c key as being used. -CP_EXPORT cpBool cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *key, void *data); - - -//MARK: Queries - -// TODO: Queries and iterators should take a cpSpace parametery. -// TODO: They should also be abortable. - -/// Nearest point query callback function type. -typedef void (*cpSpacePointQueryFunc)(cpShape *shape, cpVect point, cpFloat distance, cpVect gradient, void *data); -/// Query the space at a point and call @c func for each shape found. -CP_EXPORT void cpSpacePointQuery(cpSpace *space, cpVect point, cpFloat maxDistance, cpShapeFilter filter, cpSpacePointQueryFunc func, void *data); -/// Query the space at a point and return the nearest shape found. Returns NULL if no shapes were found. -CP_EXPORT cpShape *cpSpacePointQueryNearest(cpSpace *space, cpVect point, cpFloat maxDistance, cpShapeFilter filter, cpPointQueryInfo *out); - -/// Segment query callback function type. -typedef void (*cpSpaceSegmentQueryFunc)(cpShape *shape, cpVect point, cpVect normal, cpFloat alpha, void *data); -/// Perform a directed line segment query (like a raycast) against the space calling @c func for each shape intersected. -CP_EXPORT void cpSpaceSegmentQuery(cpSpace *space, cpVect start, cpVect end, cpFloat radius, cpShapeFilter filter, cpSpaceSegmentQueryFunc func, void *data); -/// Perform a directed line segment query (like a raycast) against the space and return the first shape hit. Returns NULL if no shapes were hit. -CP_EXPORT cpShape *cpSpaceSegmentQueryFirst(cpSpace *space, cpVect start, cpVect end, cpFloat radius, cpShapeFilter filter, cpSegmentQueryInfo *out); - -/// Rectangle Query callback function type. -typedef void (*cpSpaceBBQueryFunc)(cpShape *shape, void *data); -/// Perform a fast rectangle query on the space calling @c func for each shape found. -/// Only the shape's bounding boxes are checked for overlap, not their full shape. -CP_EXPORT void cpSpaceBBQuery(cpSpace *space, cpBB bb, cpShapeFilter filter, cpSpaceBBQueryFunc func, void *data); - -/// Shape query callback function type. -typedef void (*cpSpaceShapeQueryFunc)(cpShape *shape, cpContactPointSet *points, void *data); -/// Query a space for any shapes overlapping the given shape and call @c func for each shape found. -CP_EXPORT cpBool cpSpaceShapeQuery(cpSpace *space, cpShape *shape, cpSpaceShapeQueryFunc func, void *data); - - -//MARK: Iteration - -/// Space/body iterator callback function type. -typedef void (*cpSpaceBodyIteratorFunc)(cpBody *body, void *data); -/// Call @c func for each body in the space. -CP_EXPORT void cpSpaceEachBody(cpSpace *space, cpSpaceBodyIteratorFunc func, void *data); - -/// Space/body iterator callback function type. -typedef void (*cpSpaceShapeIteratorFunc)(cpShape *shape, void *data); -/// Call @c func for each shape in the space. -CP_EXPORT void cpSpaceEachShape(cpSpace *space, cpSpaceShapeIteratorFunc func, void *data); - -/// Space/constraint iterator callback function type. -typedef void (*cpSpaceConstraintIteratorFunc)(cpConstraint *constraint, void *data); -/// Call @c func for each shape in the space. -CP_EXPORT void cpSpaceEachConstraint(cpSpace *space, cpSpaceConstraintIteratorFunc func, void *data); - - -//MARK: Indexing - -/// Update the collision detection info for the static shapes in the space. -CP_EXPORT void cpSpaceReindexStatic(cpSpace *space); -/// Update the collision detection data for a specific shape in the space. -CP_EXPORT void cpSpaceReindexShape(cpSpace *space, cpShape *shape); -/// Update the collision detection data for all shapes attached to a body. -CP_EXPORT void cpSpaceReindexShapesForBody(cpSpace *space, cpBody *body); - -/// Switch the space to use a spatial has as it's spatial index. -CP_EXPORT void cpSpaceUseSpatialHash(cpSpace *space, cpFloat dim, int count); - - -//MARK: Time Stepping - -/// Step the space forward in time by @c dt. -CP_EXPORT void cpSpaceStep(cpSpace *space, cpFloat dt); - - -//MARK: Debug API - -#ifndef CP_SPACE_DISABLE_DEBUG_API - -/// Color type to use with the space debug drawing API. -typedef struct cpSpaceDebugColor { - float r, g, b, a; -} cpSpaceDebugColor; - -/// Callback type for a function that draws a filled, stroked circle. -typedef void (*cpSpaceDebugDrawCircleImpl)(cpVect pos, cpFloat angle, cpFloat radius, cpSpaceDebugColor outlineColor, cpSpaceDebugColor fillColor, cpDataPointer data); -/// Callback type for a function that draws a line segment. -typedef void (*cpSpaceDebugDrawSegmentImpl)(cpVect a, cpVect b, cpSpaceDebugColor color, cpDataPointer data); -/// Callback type for a function that draws a thick line segment. -typedef void (*cpSpaceDebugDrawFatSegmentImpl)(cpVect a, cpVect b, cpFloat radius, cpSpaceDebugColor outlineColor, cpSpaceDebugColor fillColor, cpDataPointer data); -/// Callback type for a function that draws a convex polygon. -typedef void (*cpSpaceDebugDrawPolygonImpl)(int count, const cpVect *verts, cpFloat radius, cpSpaceDebugColor outlineColor, cpSpaceDebugColor fillColor, cpDataPointer data); -/// Callback type for a function that draws a dot. -typedef void (*cpSpaceDebugDrawDotImpl)(cpFloat size, cpVect pos, cpSpaceDebugColor color, cpDataPointer data); -/// Callback type for a function that returns a color for a given shape. This gives you an opportunity to color shapes based on how they are used in your engine. -typedef cpSpaceDebugColor (*cpSpaceDebugDrawColorForShapeImpl)(cpShape *shape, cpDataPointer data); - -typedef enum cpSpaceDebugDrawFlags { - CP_SPACE_DEBUG_DRAW_SHAPES = 1<<0, - CP_SPACE_DEBUG_DRAW_CONSTRAINTS = 1<<1, - CP_SPACE_DEBUG_DRAW_COLLISION_POINTS = 1<<2, -} cpSpaceDebugDrawFlags; - -/// Struct used with cpSpaceDebugDraw() containing drawing callbacks and other drawing settings. -typedef struct cpSpaceDebugDrawOptions { - /// Function that will be invoked to draw circles. - cpSpaceDebugDrawCircleImpl drawCircle; - /// Function that will be invoked to draw line segments. - cpSpaceDebugDrawSegmentImpl drawSegment; - /// Function that will be invoked to draw thick line segments. - cpSpaceDebugDrawFatSegmentImpl drawFatSegment; - /// Function that will be invoked to draw convex polygons. - cpSpaceDebugDrawPolygonImpl drawPolygon; - /// Function that will be invoked to draw dots. - cpSpaceDebugDrawDotImpl drawDot; - - /// Flags that request which things to draw (collision shapes, constraints, contact points). - cpSpaceDebugDrawFlags flags; - /// Outline color passed to the drawing function. - cpSpaceDebugColor shapeOutlineColor; - /// Function that decides what fill color to draw shapes using. - cpSpaceDebugDrawColorForShapeImpl colorForShape; - /// Color passed to drawing functions for constraints. - cpSpaceDebugColor constraintColor; - /// Color passed to drawing functions for collision points. - cpSpaceDebugColor collisionPointColor; - - /// User defined context pointer passed to all of the callback functions as the 'data' argument. - cpDataPointer data; -} cpSpaceDebugDrawOptions; - -/// Debug draw the current state of the space using the supplied drawing options. -CP_EXPORT void cpSpaceDebugDraw(cpSpace *space, cpSpaceDebugDrawOptions *options); - -#endif - -/// @} diff --git a/thirdparty/include/chipmunk/cpSpatialIndex.h b/thirdparty/include/chipmunk/cpSpatialIndex.h deleted file mode 100644 index 1f7c68ca9..000000000 --- a/thirdparty/include/chipmunk/cpSpatialIndex.h +++ /dev/null @@ -1,227 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -/** - @defgroup cpSpatialIndex cpSpatialIndex - - Spatial indexes are data structures that are used to accelerate collision detection - and spatial queries. Chipmunk provides a number of spatial index algorithms to pick from - and they are programmed in a generic way so that you can use them for holding more than - just cpShape structs. - - It works by using @c void pointers to the objects you add and using a callback to ask your code - for bounding boxes when it needs them. Several types of queries can be performed an index as well - as reindexing and full collision information. All communication to the spatial indexes is performed - through callback functions. - - Spatial indexes should be treated as opaque structs. - This meanns you shouldn't be reading any of the struct fields. - @{ -*/ - -//MARK: Spatial Index - -/// Spatial index bounding box callback function type. -/// The spatial index calls this function and passes you a pointer to an object you added -/// when it needs to get the bounding box associated with that object. -typedef cpBB (*cpSpatialIndexBBFunc)(void *obj); -/// Spatial index/object iterator callback function type. -typedef void (*cpSpatialIndexIteratorFunc)(void *obj, void *data); -/// Spatial query callback function type. -typedef cpCollisionID (*cpSpatialIndexQueryFunc)(void *obj1, void *obj2, cpCollisionID id, void *data); -/// Spatial segment query callback function type. -typedef cpFloat (*cpSpatialIndexSegmentQueryFunc)(void *obj1, void *obj2, void *data); - - -typedef struct cpSpatialIndexClass cpSpatialIndexClass; -typedef struct cpSpatialIndex cpSpatialIndex; - -/// @private -struct cpSpatialIndex { - cpSpatialIndexClass *klass; - - cpSpatialIndexBBFunc bbfunc; - - cpSpatialIndex *staticIndex, *dynamicIndex; -}; - - -//MARK: Spatial Hash - -typedef struct cpSpaceHash cpSpaceHash; - -/// Allocate a spatial hash. -CP_EXPORT cpSpaceHash* cpSpaceHashAlloc(void); -/// Initialize a spatial hash. -CP_EXPORT cpSpatialIndex* cpSpaceHashInit(cpSpaceHash *hash, cpFloat celldim, int numcells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); -/// Allocate and initialize a spatial hash. -CP_EXPORT cpSpatialIndex* cpSpaceHashNew(cpFloat celldim, int cells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); - -/// Change the cell dimensions and table size of the spatial hash to tune it. -/// The cell dimensions should roughly match the average size of your objects -/// and the table size should be ~10 larger than the number of objects inserted. -/// Some trial and error is required to find the optimum numbers for efficiency. -CP_EXPORT void cpSpaceHashResize(cpSpaceHash *hash, cpFloat celldim, int numcells); - -//MARK: AABB Tree - -typedef struct cpBBTree cpBBTree; - -/// Allocate a bounding box tree. -CP_EXPORT cpBBTree* cpBBTreeAlloc(void); -/// Initialize a bounding box tree. -CP_EXPORT cpSpatialIndex* cpBBTreeInit(cpBBTree *tree, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); -/// Allocate and initialize a bounding box tree. -CP_EXPORT cpSpatialIndex* cpBBTreeNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); - -/// Perform a static top down optimization of the tree. -CP_EXPORT void cpBBTreeOptimize(cpSpatialIndex *index); - -/// Bounding box tree velocity callback function. -/// This function should return an estimate for the object's velocity. -typedef cpVect (*cpBBTreeVelocityFunc)(void *obj); -/// Set the velocity function for the bounding box tree to enable temporal coherence. -CP_EXPORT void cpBBTreeSetVelocityFunc(cpSpatialIndex *index, cpBBTreeVelocityFunc func); - -//MARK: Single Axis Sweep - -typedef struct cpSweep1D cpSweep1D; - -/// Allocate a 1D sort and sweep broadphase. -CP_EXPORT cpSweep1D* cpSweep1DAlloc(void); -/// Initialize a 1D sort and sweep broadphase. -CP_EXPORT cpSpatialIndex* cpSweep1DInit(cpSweep1D *sweep, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); -/// Allocate and initialize a 1D sort and sweep broadphase. -CP_EXPORT cpSpatialIndex* cpSweep1DNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); - -//MARK: Spatial Index Implementation - -typedef void (*cpSpatialIndexDestroyImpl)(cpSpatialIndex *index); - -typedef int (*cpSpatialIndexCountImpl)(cpSpatialIndex *index); -typedef void (*cpSpatialIndexEachImpl)(cpSpatialIndex *index, cpSpatialIndexIteratorFunc func, void *data); - -typedef cpBool (*cpSpatialIndexContainsImpl)(cpSpatialIndex *index, void *obj, cpHashValue hashid); -typedef void (*cpSpatialIndexInsertImpl)(cpSpatialIndex *index, void *obj, cpHashValue hashid); -typedef void (*cpSpatialIndexRemoveImpl)(cpSpatialIndex *index, void *obj, cpHashValue hashid); - -typedef void (*cpSpatialIndexReindexImpl)(cpSpatialIndex *index); -typedef void (*cpSpatialIndexReindexObjectImpl)(cpSpatialIndex *index, void *obj, cpHashValue hashid); -typedef void (*cpSpatialIndexReindexQueryImpl)(cpSpatialIndex *index, cpSpatialIndexQueryFunc func, void *data); - -typedef void (*cpSpatialIndexQueryImpl)(cpSpatialIndex *index, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data); -typedef void (*cpSpatialIndexSegmentQueryImpl)(cpSpatialIndex *index, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data); - -struct cpSpatialIndexClass { - cpSpatialIndexDestroyImpl destroy; - - cpSpatialIndexCountImpl count; - cpSpatialIndexEachImpl each; - - cpSpatialIndexContainsImpl contains; - cpSpatialIndexInsertImpl insert; - cpSpatialIndexRemoveImpl remove; - - cpSpatialIndexReindexImpl reindex; - cpSpatialIndexReindexObjectImpl reindexObject; - cpSpatialIndexReindexQueryImpl reindexQuery; - - cpSpatialIndexQueryImpl query; - cpSpatialIndexSegmentQueryImpl segmentQuery; -}; - -/// Destroy and free a spatial index. -CP_EXPORT void cpSpatialIndexFree(cpSpatialIndex *index); -/// Collide the objects in @c dynamicIndex against the objects in @c staticIndex using the query callback function. -CP_EXPORT void cpSpatialIndexCollideStatic(cpSpatialIndex *dynamicIndex, cpSpatialIndex *staticIndex, cpSpatialIndexQueryFunc func, void *data); - -/// Destroy a spatial index. -static inline void cpSpatialIndexDestroy(cpSpatialIndex *index) -{ - if(index->klass) index->klass->destroy(index); -} - -/// Get the number of objects in the spatial index. -static inline int cpSpatialIndexCount(cpSpatialIndex *index) -{ - return index->klass->count(index); -} - -/// Iterate the objects in the spatial index. @c func will be called once for each object. -static inline void cpSpatialIndexEach(cpSpatialIndex *index, cpSpatialIndexIteratorFunc func, void *data) -{ - index->klass->each(index, func, data); -} - -/// Returns true if the spatial index contains the given object. -/// Most spatial indexes use hashed storage, so you must provide a hash value too. -static inline cpBool cpSpatialIndexContains(cpSpatialIndex *index, void *obj, cpHashValue hashid) -{ - return index->klass->contains(index, obj, hashid); -} - -/// Add an object to a spatial index. -/// Most spatial indexes use hashed storage, so you must provide a hash value too. -static inline void cpSpatialIndexInsert(cpSpatialIndex *index, void *obj, cpHashValue hashid) -{ - index->klass->insert(index, obj, hashid); -} - -/// Remove an object from a spatial index. -/// Most spatial indexes use hashed storage, so you must provide a hash value too. -static inline void cpSpatialIndexRemove(cpSpatialIndex *index, void *obj, cpHashValue hashid) -{ - index->klass->remove(index, obj, hashid); -} - -/// Perform a full reindex of a spatial index. -static inline void cpSpatialIndexReindex(cpSpatialIndex *index) -{ - index->klass->reindex(index); -} - -/// Reindex a single object in the spatial index. -static inline void cpSpatialIndexReindexObject(cpSpatialIndex *index, void *obj, cpHashValue hashid) -{ - index->klass->reindexObject(index, obj, hashid); -} - -/// Perform a rectangle query against the spatial index, calling @c func for each potential match. -static inline void cpSpatialIndexQuery(cpSpatialIndex *index, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data) -{ - index->klass->query(index, obj, bb, func, data); -} - -/// Perform a segment query against the spatial index, calling @c func for each potential match. -static inline void cpSpatialIndexSegmentQuery(cpSpatialIndex *index, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data) -{ - index->klass->segmentQuery(index, obj, a, b, t_exit, func, data); -} - -/// Simultaneously reindex and find all colliding objects. -/// @c func will be called once for each potentially overlapping pair of objects found. -/// If the spatial index was initialized with a static index, it will collide it's objects against that as well. -static inline void cpSpatialIndexReindexQuery(cpSpatialIndex *index, cpSpatialIndexQueryFunc func, void *data) -{ - index->klass->reindexQuery(index, func, data); -} - -///@} diff --git a/thirdparty/include/chipmunk/cpTransform.h b/thirdparty/include/chipmunk/cpTransform.h deleted file mode 100644 index 4a6256b91..000000000 --- a/thirdparty/include/chipmunk/cpTransform.h +++ /dev/null @@ -1,198 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef CHIPMUNK_TRANSFORM_H -#define CHIPMUNK_TRANSFORM_H - -#include "chipmunk_types.h" -#include "cpVect.h" -#include "cpBB.h" - -/// Identity transform matrix. -static const cpTransform cpTransformIdentity = {1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}; - -/// Construct a new transform matrix. -/// (a, b) is the x basis vector. -/// (c, d) is the y basis vector. -/// (tx, ty) is the translation. -static inline cpTransform -cpTransformNew(cpFloat a, cpFloat b, cpFloat c, cpFloat d, cpFloat tx, cpFloat ty) -{ - cpTransform t = {a, b, c, d, tx, ty}; - return t; -} - -/// Construct a new transform matrix in transposed order. -static inline cpTransform -cpTransformNewTranspose(cpFloat a, cpFloat c, cpFloat tx, cpFloat b, cpFloat d, cpFloat ty) -{ - cpTransform t = {a, b, c, d, tx, ty}; - return t; -} - -/// Get the inverse of a transform matrix. -static inline cpTransform -cpTransformInverse(cpTransform t) -{ - cpFloat inv_det = 1.0/(t.a*t.d - t.c*t.b); - return cpTransformNewTranspose( - t.d*inv_det, -t.c*inv_det, (t.c*t.ty - t.tx*t.d)*inv_det, - -t.b*inv_det, t.a*inv_det, (t.tx*t.b - t.a*t.ty)*inv_det - ); -} - -/// Multiply two transformation matrices. -static inline cpTransform -cpTransformMult(cpTransform t1, cpTransform t2) -{ - return cpTransformNewTranspose( - t1.a*t2.a + t1.c*t2.b, t1.a*t2.c + t1.c*t2.d, t1.a*t2.tx + t1.c*t2.ty + t1.tx, - t1.b*t2.a + t1.d*t2.b, t1.b*t2.c + t1.d*t2.d, t1.b*t2.tx + t1.d*t2.ty + t1.ty - ); -} - -/// Transform an absolute point. (i.e. a vertex) -static inline cpVect -cpTransformPoint(cpTransform t, cpVect p) -{ - return cpv(t.a*p.x + t.c*p.y + t.tx, t.b*p.x + t.d*p.y + t.ty); -} - -/// Transform a vector (i.e. a normal) -static inline cpVect -cpTransformVect(cpTransform t, cpVect v) -{ - return cpv(t.a*v.x + t.c*v.y, t.b*v.x + t.d*v.y); -} - -/// Transform a cpBB. -static inline cpBB -cpTransformbBB(cpTransform t, cpBB bb) -{ - cpVect center = cpBBCenter(bb); - cpFloat hw = (bb.r - bb.l)*0.5; - cpFloat hh = (bb.t - bb.b)*0.5; - - cpFloat a = t.a*hw, b = t.c*hh, d = t.b*hw, e = t.d*hh; - cpFloat hw_max = cpfmax(cpfabs(a + b), cpfabs(a - b)); - cpFloat hh_max = cpfmax(cpfabs(d + e), cpfabs(d - e)); - return cpBBNewForExtents(cpTransformPoint(t, center), hw_max, hh_max); -} - -/// Create a transation matrix. -static inline cpTransform -cpTransformTranslate(cpVect translate) -{ - return cpTransformNewTranspose( - 1.0, 0.0, translate.x, - 0.0, 1.0, translate.y - ); -} - -/// Create a scale matrix. -static inline cpTransform -cpTransformScale(cpFloat scaleX, cpFloat scaleY) -{ - return cpTransformNewTranspose( - scaleX, 0.0, 0.0, - 0.0, scaleY, 0.0 - ); -} - -/// Create a rotation matrix. -static inline cpTransform -cpTransformRotate(cpFloat radians) -{ - cpVect rot = cpvforangle(radians); - return cpTransformNewTranspose( - rot.x, -rot.y, 0.0, - rot.y, rot.x, 0.0 - ); -} - -/// Create a rigid transformation matrix. (transation + rotation) -static inline cpTransform -cpTransformRigid(cpVect translate, cpFloat radians) -{ - cpVect rot = cpvforangle(radians); - return cpTransformNewTranspose( - rot.x, -rot.y, translate.x, - rot.y, rot.x, translate.y - ); -} - -/// Fast inverse of a rigid transformation matrix. -static inline cpTransform -cpTransformRigidInverse(cpTransform t) -{ - return cpTransformNewTranspose( - t.d, -t.c, (t.c*t.ty - t.tx*t.d), - -t.b, t.a, (t.tx*t.b - t.a*t.ty) - ); -} - -//MARK: Miscellaneous (but useful) transformation matrices. -// See source for documentation... - -static inline cpTransform -cpTransformWrap(cpTransform outer, cpTransform inner) -{ - return cpTransformMult(cpTransformInverse(outer), cpTransformMult(inner, outer)); -} - -static inline cpTransform -cpTransformWrapInverse(cpTransform outer, cpTransform inner) -{ - return cpTransformMult(outer, cpTransformMult(inner, cpTransformInverse(outer))); -} - -static inline cpTransform -cpTransformOrtho(cpBB bb) -{ - return cpTransformNewTranspose( - 2.0/(bb.r - bb.l), 0.0, -(bb.r + bb.l)/(bb.r - bb.l), - 0.0, 2.0/(bb.t - bb.b), -(bb.t + bb.b)/(bb.t - bb.b) - ); -} - -static inline cpTransform -cpTransformBoneScale(cpVect v0, cpVect v1) -{ - cpVect d = cpvsub(v1, v0); - return cpTransformNewTranspose( - d.x, -d.y, v0.x, - d.y, d.x, v0.y - ); -} - -static inline cpTransform -cpTransformAxialScale(cpVect axis, cpVect pivot, cpFloat scale) -{ - cpFloat A = axis.x*axis.y*(scale - 1.0); - cpFloat B = cpvdot(axis, pivot)*(1.0 - scale); - - return cpTransformNewTranspose( - scale*axis.x*axis.x + axis.y*axis.y, A, axis.x*B, - A, axis.x*axis.x + scale*axis.y*axis.y, axis.y*B - ); -} - -#endif diff --git a/thirdparty/include/chipmunk/cpVect.h b/thirdparty/include/chipmunk/cpVect.h deleted file mode 100644 index 8ec02bdce..000000000 --- a/thirdparty/include/chipmunk/cpVect.h +++ /dev/null @@ -1,230 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef CHIPMUNK_VECT_H -#define CHIPMUNK_VECT_H - -#include "chipmunk_types.h" - -/// @defgroup cpVect cpVect -/// Chipmunk's 2D vector type along with a handy 2D vector math lib. -/// @{ - -/// Constant for the zero vector. -static const cpVect cpvzero = {0.0f,0.0f}; - -/// Convenience constructor for cpVect structs. -static inline cpVect cpv(const cpFloat x, const cpFloat y) -{ - cpVect v = {x, y}; - return v; -} - -/// Check if two vectors are equal. (Be careful when comparing floating point numbers!) -static inline cpBool cpveql(const cpVect v1, const cpVect v2) -{ - return (v1.x == v2.x && v1.y == v2.y); -} - -/// Add two vectors -static inline cpVect cpvadd(const cpVect v1, const cpVect v2) -{ - return cpv(v1.x + v2.x, v1.y + v2.y); -} - -/// Subtract two vectors. -static inline cpVect cpvsub(const cpVect v1, const cpVect v2) -{ - return cpv(v1.x - v2.x, v1.y - v2.y); -} - -/// Negate a vector. -static inline cpVect cpvneg(const cpVect v) -{ - return cpv(-v.x, -v.y); -} - -/// Scalar multiplication. -static inline cpVect cpvmult(const cpVect v, const cpFloat s) -{ - return cpv(v.x*s, v.y*s); -} - -/// Vector dot product. -static inline cpFloat cpvdot(const cpVect v1, const cpVect v2) -{ - return v1.x*v2.x + v1.y*v2.y; -} - -/// 2D vector cross product analog. -/// The cross product of 2D vectors results in a 3D vector with only a z component. -/// This function returns the magnitude of the z value. -static inline cpFloat cpvcross(const cpVect v1, const cpVect v2) -{ - return v1.x*v2.y - v1.y*v2.x; -} - -/// Returns a perpendicular vector. (90 degree rotation) -static inline cpVect cpvperp(const cpVect v) -{ - return cpv(-v.y, v.x); -} - -/// Returns a perpendicular vector. (-90 degree rotation) -static inline cpVect cpvrperp(const cpVect v) -{ - return cpv(v.y, -v.x); -} - -/// Returns the vector projection of v1 onto v2. -static inline cpVect cpvproject(const cpVect v1, const cpVect v2) -{ - return cpvmult(v2, cpvdot(v1, v2)/cpvdot(v2, v2)); -} - -/// Returns the unit length vector for the given angle (in radians). -static inline cpVect cpvforangle(const cpFloat a) -{ - return cpv(cpfcos(a), cpfsin(a)); -} - -/// Returns the angular direction v is pointing in (in radians). -static inline cpFloat cpvtoangle(const cpVect v) -{ - return cpfatan2(v.y, v.x); -} - -/// Uses complex number multiplication to rotate v1 by v2. Scaling will occur if v1 is not a unit vector. -static inline cpVect cpvrotate(const cpVect v1, const cpVect v2) -{ - return cpv(v1.x*v2.x - v1.y*v2.y, v1.x*v2.y + v1.y*v2.x); -} - -/// Inverse of cpvrotate(). -static inline cpVect cpvunrotate(const cpVect v1, const cpVect v2) -{ - return cpv(v1.x*v2.x + v1.y*v2.y, v1.y*v2.x - v1.x*v2.y); -} - -/// Returns the squared length of v. Faster than cpvlength() when you only need to compare lengths. -static inline cpFloat cpvlengthsq(const cpVect v) -{ - return cpvdot(v, v); -} - -/// Returns the length of v. -static inline cpFloat cpvlength(const cpVect v) -{ - return cpfsqrt(cpvdot(v, v)); -} - -/// Linearly interpolate between v1 and v2. -static inline cpVect cpvlerp(const cpVect v1, const cpVect v2, const cpFloat t) -{ - return cpvadd(cpvmult(v1, 1.0f - t), cpvmult(v2, t)); -} - -/// Returns a normalized copy of v. -static inline cpVect cpvnormalize(const cpVect v) -{ - // Neat trick I saw somewhere to avoid div/0. - return cpvmult(v, 1.0f/(cpvlength(v) + CPFLOAT_MIN)); -} - -/// Spherical linearly interpolate between v1 and v2. -static inline cpVect -cpvslerp(const cpVect v1, const cpVect v2, const cpFloat t) -{ - cpFloat dot = cpvdot(cpvnormalize(v1), cpvnormalize(v2)); - cpFloat omega = cpfacos(cpfclamp(dot, -1.0f, 1.0f)); - - if(omega < 1e-3){ - // If the angle between two vectors is very small, lerp instead to avoid precision issues. - return cpvlerp(v1, v2, t); - } else { - cpFloat denom = 1.0f/cpfsin(omega); - return cpvadd(cpvmult(v1, cpfsin((1.0f - t)*omega)*denom), cpvmult(v2, cpfsin(t*omega)*denom)); - } -} - -/// Spherical linearly interpolate between v1 towards v2 by no more than angle a radians -static inline cpVect -cpvslerpconst(const cpVect v1, const cpVect v2, const cpFloat a) -{ - cpFloat dot = cpvdot(cpvnormalize(v1), cpvnormalize(v2)); - cpFloat omega = cpfacos(cpfclamp(dot, -1.0f, 1.0f)); - - return cpvslerp(v1, v2, cpfmin(a, omega)/omega); -} - -/// Clamp v to length len. -static inline cpVect cpvclamp(const cpVect v, const cpFloat len) -{ - return (cpvdot(v,v) > len*len) ? cpvmult(cpvnormalize(v), len) : v; -} - -/// Linearly interpolate between v1 towards v2 by distance d. -static inline cpVect cpvlerpconst(cpVect v1, cpVect v2, cpFloat d) -{ - return cpvadd(v1, cpvclamp(cpvsub(v2, v1), d)); -} - -/// Returns the distance between v1 and v2. -static inline cpFloat cpvdist(const cpVect v1, const cpVect v2) -{ - return cpvlength(cpvsub(v1, v2)); -} - -/// Returns the squared distance between v1 and v2. Faster than cpvdist() when you only need to compare distances. -static inline cpFloat cpvdistsq(const cpVect v1, const cpVect v2) -{ - return cpvlengthsq(cpvsub(v1, v2)); -} - -/// Returns true if the distance between v1 and v2 is less than dist. -static inline cpBool cpvnear(const cpVect v1, const cpVect v2, const cpFloat dist) -{ - return cpvdistsq(v1, v2) < dist*dist; -} - -/// @} - -/// @defgroup cpMat2x2 cpMat2x2 -/// 2x2 matrix type used for tensors and such. -/// @{ - -// NUKE -static inline cpMat2x2 -cpMat2x2New(cpFloat a, cpFloat b, cpFloat c, cpFloat d) -{ - cpMat2x2 m = {a, b, c, d}; - return m; -} - -static inline cpVect -cpMat2x2Transform(cpMat2x2 m, cpVect v) -{ - return cpv(v.x*m.a + v.y*m.b, v.x*m.c + v.y*m.d); -} - -///@} - -#endif diff --git a/thirdparty/include/freetype/config/ftconfig.h b/thirdparty/include/freetype/config/ftconfig.h deleted file mode 100644 index 7a05f0801..000000000 --- a/thirdparty/include/freetype/config/ftconfig.h +++ /dev/null @@ -1,672 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftconfig.h */ -/* */ -/* ANSI-specific configuration file (specification only). */ -/* */ -/* Copyright 1996-2004, 2006-2008, 2010-2011, 2013, 2014 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This header file contains a number of macro definitions that are used */ - /* by the rest of the engine. Most of the macros here are automatically */ - /* determined at compile time, and you should not need to change it to */ - /* port FreeType, except to compile the library with a non-ANSI */ - /* compiler. */ - /* */ - /* Note however that if some specific modifications are needed, we */ - /* advise you to place a modified copy in your build directory. */ - /* */ - /* The build directory is usually `builds/', and contains */ - /* system-specific files that are always included first when building */ - /* the library. */ - /* */ - /* This ANSI version should stay in `include/config/'. */ - /* */ - /*************************************************************************/ - -#ifndef __FTCONFIG_H__ -#define __FTCONFIG_H__ - -#include -#include FT_CONFIG_OPTIONS_H -#include FT_CONFIG_STANDARD_LIBRARY_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* PLATFORM-SPECIFIC CONFIGURATION MACROS */ - /* */ - /* These macros can be toggled to suit a specific system. The current */ - /* ones are defaults used to compile FreeType in an ANSI C environment */ - /* (16bit compilers are also supported). Copy this file to your own */ - /* `builds/' directory, and edit it to port the engine. */ - /* */ - /*************************************************************************/ - - - /* There are systems (like the Texas Instruments 'C54x) where a `char' */ - /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */ - /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */ - /* is probably unexpected. */ - /* */ - /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */ - /* `char' type. */ - -#ifndef FT_CHAR_BIT -#define FT_CHAR_BIT CHAR_BIT -#endif - - - /* The size of an `int' type. */ -#if FT_UINT_MAX == 0xFFFFUL -#define FT_SIZEOF_INT (16 / FT_CHAR_BIT) -#elif FT_UINT_MAX == 0xFFFFFFFFUL -#define FT_SIZEOF_INT (32 / FT_CHAR_BIT) -#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL -#define FT_SIZEOF_INT (64 / FT_CHAR_BIT) -#else -#error "Unsupported size of `int' type!" -#endif - - /* The size of a `long' type. A five-byte `long' (as used e.g. on the */ - /* DM642) is recognized but avoided. */ -#if FT_ULONG_MAX == 0xFFFFFFFFUL -#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT) -#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL -#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT) -#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL -#define FT_SIZEOF_LONG (64 / FT_CHAR_BIT) -#else -#error "Unsupported size of `long' type!" -#endif - - - /* FT_UNUSED is a macro used to indicate that a given parameter is not */ - /* used -- this is only used to get rid of unpleasant compiler warnings */ -#ifndef FT_UNUSED -#define FT_UNUSED( arg ) ( (arg) = (arg) ) -#endif - - - /*************************************************************************/ - /* */ - /* AUTOMATIC CONFIGURATION MACROS */ - /* */ - /* These macros are computed from the ones defined above. Don't touch */ - /* their definition, unless you know precisely what you are doing. No */ - /* porter should need to mess with them. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Mac support */ - /* */ - /* This is the only necessary change, so it is defined here instead */ - /* providing a new configuration file. */ - /* */ -#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) ) - /* no Carbon frameworks for 64bit 10.4.x */ - /* AvailabilityMacros.h is available since Mac OS X 10.2, */ - /* so guess the system version by maximum errno before inclusion */ -#include -#ifdef ECANCELED /* defined since 10.2 */ -#include "AvailabilityMacros.h" -#endif -#if defined( __LP64__ ) && \ - ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 ) -#undef FT_MACINTOSH -#endif - -#elif defined( __SC__ ) || defined( __MRC__ ) - /* Classic MacOS compilers */ -#include "ConditionalMacros.h" -#if TARGET_OS_MAC -#define FT_MACINTOSH 1 -#endif - -#endif - - - /*************************************************************************/ - /* */ - /*
*/ - /* basic_types */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Int16 */ - /* */ - /* */ - /* A typedef for a 16bit signed integer type. */ - /* */ - typedef signed short FT_Int16; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt16 */ - /* */ - /* */ - /* A typedef for a 16bit unsigned integer type. */ - /* */ - typedef unsigned short FT_UInt16; - - /* */ - - - /* this #if 0 ... #endif clause is for documentation purposes */ -#if 0 - - /*************************************************************************/ - /* */ - /* */ - /* FT_Int32 */ - /* */ - /* */ - /* A typedef for a 32bit signed integer type. The size depends on */ - /* the configuration. */ - /* */ - typedef signed XXX FT_Int32; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt32 */ - /* */ - /* A typedef for a 32bit unsigned integer type. The size depends on */ - /* the configuration. */ - /* */ - typedef unsigned XXX FT_UInt32; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Int64 */ - /* */ - /* A typedef for a 64bit signed integer type. The size depends on */ - /* the configuration. Only defined if there is real 64bit support; */ - /* otherwise, it gets emulated with a structure (if necessary). */ - /* */ - typedef signed XXX FT_Int64; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt64 */ - /* */ - /* A typedef for a 64bit unsigned integer type. The size depends on */ - /* the configuration. Only defined if there is real 64bit support; */ - /* otherwise, it gets emulated with a structure (if necessary). */ - /* */ - typedef unsigned XXX FT_UInt64; - - /* */ - -#endif - -#if FT_SIZEOF_INT == (32 / FT_CHAR_BIT) - - typedef signed int FT_Int32; - typedef unsigned int FT_UInt32; - -#elif FT_SIZEOF_LONG == (32 / FT_CHAR_BIT) - - typedef signed long FT_Int32; - typedef unsigned long FT_UInt32; - -#else -#error "no 32bit type found -- please check your configuration files" -#endif - - - /* look up an integer type that is at least 32 bits */ -#if FT_SIZEOF_INT >= (32 / FT_CHAR_BIT) - - typedef int FT_Fast; - typedef unsigned int FT_UFast; - -#elif FT_SIZEOF_LONG >= (32 / FT_CHAR_BIT) - - typedef long FT_Fast; - typedef unsigned long FT_UFast; - -#endif - - - /* determine whether we have a 64-bit int type for platforms without */ - /* Autoconf */ -#if FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) - - /* FT_LONG64 must be defined if a 64-bit type is available */ -#define FT_LONG64 -#define FT_INT64 long -#define FT_UINT64 unsigned long - -#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ - - /* this compiler provides the __int64 type */ -#define FT_LONG64 -#define FT_INT64 __int64 -#define FT_UINT64 unsigned __int64 - -#elif defined( __BORLANDC__ ) /* Borland C++ */ - - /* XXXX: We should probably check the value of __BORLANDC__ in order */ - /* to test the compiler version. */ - - /* this compiler provides the __int64 type */ -#define FT_LONG64 -#define FT_INT64 __int64 -#define FT_UINT64 unsigned __int64 - -#elif defined( __WATCOMC__ ) /* Watcom C++ */ - - /* Watcom doesn't provide 64-bit data types */ - -#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */ - -#define FT_LONG64 -#define FT_INT64 long long int -#define FT_UINT64 unsigned long long int - -#elif defined( __GNUC__ ) - - /* GCC provides the `long long' type */ -#define FT_LONG64 -#define FT_INT64 long long int -#define FT_UINT64 unsigned long long int - -#endif /* FT_SIZEOF_LONG == (64 / FT_CHAR_BIT) */ - - - /*************************************************************************/ - /* */ - /* A 64-bit data type will create compilation problems if you compile */ - /* in strict ANSI mode. To avoid them, we disable its use if __STDC__ */ - /* is defined. You can however ignore this rule by defining the */ - /* FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */ - /* */ -#if defined( FT_LONG64 ) && !defined( FT_CONFIG_OPTION_FORCE_INT64 ) - -#ifdef __STDC__ - - /* undefine the 64-bit macros in strict ANSI compilation mode */ -#undef FT_LONG64 -#undef FT_INT64 - -#endif /* __STDC__ */ - -#endif /* FT_LONG64 && !FT_CONFIG_OPTION_FORCE_INT64 */ - -#ifdef FT_LONG64 - typedef FT_INT64 FT_Int64; - typedef FT_UINT64 FT_UInt64; -#endif - - -#define FT_BEGIN_STMNT do { -#define FT_END_STMNT } while ( 0 ) -#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT - - -#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER - /* Provide assembler fragments for performance-critical functions. */ - /* These must be defined `static __inline__' with GCC. */ - -#if defined( __CC_ARM ) || defined( __ARMCC__ ) /* RVCT */ - -#define FT_MULFIX_ASSEMBLER FT_MulFix_arm - - /* documentation is in freetype.h */ - - static __inline FT_Int32 - FT_MulFix_arm( FT_Int32 a, - FT_Int32 b ) - { - register FT_Int32 t, t2; - - - __asm - { - smull t2, t, b, a /* (lo=t2,hi=t) = a*b */ - mov a, t, asr #31 /* a = (hi >> 31) */ - add a, a, #0x8000 /* a += 0x8000 */ - adds t2, t2, a /* t2 += a */ - adc t, t, #0 /* t += carry */ - mov a, t2, lsr #16 /* a = t2 >> 16 */ - orr a, a, t, lsl #16 /* a |= t << 16 */ - } - return a; - } - -#endif /* __CC_ARM || __ARMCC__ */ - - -#ifdef __GNUC__ - -#if defined( __arm__ ) && \ - ( !defined( __thumb__ ) || defined( __thumb2__ ) ) && \ - !( defined( __CC_ARM ) || defined( __ARMCC__ ) ) - -#define FT_MULFIX_ASSEMBLER FT_MulFix_arm - - /* documentation is in freetype.h */ - - static __inline__ FT_Int32 - FT_MulFix_arm( FT_Int32 a, - FT_Int32 b ) - { - register FT_Int32 t, t2; - - - __asm__ __volatile__ ( - "smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */ - "mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */ -#if defined( __clang__ ) && defined( __thumb2__ ) - "add.w %0, %0, #0x8000\n\t" /* %0 += 0x8000 */ -#else - "add %0, %0, #0x8000\n\t" /* %0 += 0x8000 */ -#endif - "adds %1, %1, %0\n\t" /* %1 += %0 */ - "adc %2, %2, #0\n\t" /* %2 += carry */ - "mov %0, %1, lsr #16\n\t" /* %0 = %1 >> 16 */ - "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */ - : "=r"(a), "=&r"(t2), "=&r"(t) - : "r"(a), "r"(b) - : "cc" ); - return a; - } - -#endif /* __arm__ && */ - /* ( __thumb2__ || !__thumb__ ) && */ - /* !( __CC_ARM || __ARMCC__ ) */ - - -#if defined( __i386__ ) - -#define FT_MULFIX_ASSEMBLER FT_MulFix_i386 - - /* documentation is in freetype.h */ - - static __inline__ FT_Int32 - FT_MulFix_i386( FT_Int32 a, - FT_Int32 b ) - { - register FT_Int32 result; - - - __asm__ __volatile__ ( - "imul %%edx\n" - "movl %%edx, %%ecx\n" - "sarl $31, %%ecx\n" - "addl $0x8000, %%ecx\n" - "addl %%ecx, %%eax\n" - "adcl $0, %%edx\n" - "shrl $16, %%eax\n" - "shll $16, %%edx\n" - "addl %%edx, %%eax\n" - : "=a"(result), "=d"(b) - : "a"(a), "d"(b) - : "%ecx", "cc" ); - return result; - } - -#endif /* i386 */ - -#endif /* __GNUC__ */ - - -#ifdef _MSC_VER /* Visual C++ */ - -#ifdef _M_IX86 - -#define FT_MULFIX_ASSEMBLER FT_MulFix_i386 - - /* documentation is in freetype.h */ - - static __inline FT_Int32 - FT_MulFix_i386( FT_Int32 a, - FT_Int32 b ) - { - register FT_Int32 result; - - __asm - { - mov eax, a - mov edx, b - imul edx - mov ecx, edx - sar ecx, 31 - add ecx, 8000h - add eax, ecx - adc edx, 0 - shr eax, 16 - shl edx, 16 - add eax, edx - mov result, eax - } - return result; - } - -#endif /* _M_IX86 */ - -#endif /* _MSC_VER */ - - -#if defined( __GNUC__ ) && defined( __x86_64__ ) - -#define FT_MULFIX_ASSEMBLER FT_MulFix_x86_64 - - static __inline__ FT_Int32 - FT_MulFix_x86_64( FT_Int32 a, - FT_Int32 b ) - { - /* Temporarily disable the warning that C90 doesn't support */ - /* `long long'. */ -#if ( __GNUC__ > 4 ) || ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 6 ) ) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wlong-long" -#endif - -#if 1 - /* Technically not an assembly fragment, but GCC does a really good */ - /* job at inlining it and generating good machine code for it. */ - long long ret, tmp; - - - ret = (long long)a * b; - tmp = ret >> 63; - ret += 0x8000 + tmp; - - return (FT_Int32)( ret >> 16 ); -#else - - /* For some reason, GCC 4.6 on Ubuntu 12.04 generates invalid machine */ - /* code from the lines below. The main issue is that `wide_a' is not */ - /* properly initialized by sign-extending `a'. Instead, the generated */ - /* machine code assumes that the register that contains `a' on input */ - /* can be used directly as a 64-bit value, which is wrong most of the */ - /* time. */ - long long wide_a = (long long)a; - long long wide_b = (long long)b; - long long result; - - - __asm__ __volatile__ ( - "imul %2, %1\n" - "mov %1, %0\n" - "sar $63, %0\n" - "lea 0x8000(%1, %0), %0\n" - "sar $16, %0\n" - : "=&r"(result), "=&r"(wide_a) - : "r"(wide_b) - : "cc" ); - - return (FT_Int32)result; -#endif - -#if ( __GNUC__ > 4 ) || ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 6 ) ) -#pragma GCC diagnostic pop -#endif - } - -#endif /* __GNUC__ && __x86_64__ */ - -#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */ - - -#ifdef FT_CONFIG_OPTION_INLINE_MULFIX -#ifdef FT_MULFIX_ASSEMBLER -#define FT_MULFIX_INLINED FT_MULFIX_ASSEMBLER -#endif -#endif - - -#ifdef FT_MAKE_OPTION_SINGLE_OBJECT - -#define FT_LOCAL( x ) static x -#define FT_LOCAL_DEF( x ) static x - -#else - -#ifdef __cplusplus -#define FT_LOCAL( x ) extern "C" x -#define FT_LOCAL_DEF( x ) extern "C" x -#else -#define FT_LOCAL( x ) extern x -#define FT_LOCAL_DEF( x ) x -#endif - -#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */ - -#define FT_LOCAL_ARRAY( x ) extern const x -#define FT_LOCAL_ARRAY_DEF( x ) const x - - -#ifndef FT_BASE - -#ifdef __cplusplus -#define FT_BASE( x ) extern "C" x -#else -#define FT_BASE( x ) extern x -#endif - -#endif /* !FT_BASE */ - - -#ifndef FT_BASE_DEF - -#ifdef __cplusplus -#define FT_BASE_DEF( x ) x -#else -#define FT_BASE_DEF( x ) x -#endif - -#endif /* !FT_BASE_DEF */ - - -#ifndef FT_EXPORT - -#ifdef __cplusplus -#define FT_EXPORT( x ) extern "C" x -#else -#define FT_EXPORT( x ) extern x -#endif - -#endif /* !FT_EXPORT */ - - -#ifndef FT_EXPORT_DEF - -#ifdef __cplusplus -#define FT_EXPORT_DEF( x ) extern "C" x -#else -#define FT_EXPORT_DEF( x ) extern x -#endif - -#endif /* !FT_EXPORT_DEF */ - - -#ifndef FT_EXPORT_VAR - -#ifdef __cplusplus -#define FT_EXPORT_VAR( x ) extern "C" x -#else -#define FT_EXPORT_VAR( x ) extern x -#endif - -#endif /* !FT_EXPORT_VAR */ - - /* The following macros are needed to compile the library with a */ - /* C++ compiler and with 16bit compilers. */ - /* */ - - /* This is special. Within C++, you must specify `extern "C"' for */ - /* functions which are used via function pointers, and you also */ - /* must do that for structures which contain function pointers to */ - /* assure C linkage -- it's not possible to have (local) anonymous */ - /* functions which are accessed by (global) function pointers. */ - /* */ - /* */ - /* FT_CALLBACK_DEF is used to _define_ a callback function. */ - /* */ - /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */ - /* contains pointers to callback functions. */ - /* */ - /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */ - /* that contains pointers to callback functions. */ - /* */ - /* */ - /* Some 16bit compilers have to redefine these macros to insert */ - /* the infamous `_cdecl' or `__fastcall' declarations. */ - /* */ -#ifndef FT_CALLBACK_DEF -#ifdef __cplusplus -#define FT_CALLBACK_DEF( x ) extern "C" x -#else -#define FT_CALLBACK_DEF( x ) static x -#endif -#endif /* FT_CALLBACK_DEF */ - -#ifndef FT_CALLBACK_TABLE -#ifdef __cplusplus -#define FT_CALLBACK_TABLE extern "C" -#define FT_CALLBACK_TABLE_DEF extern "C" -#else -#define FT_CALLBACK_TABLE extern -#define FT_CALLBACK_TABLE_DEF /* nothing */ -#endif -#endif /* FT_CALLBACK_TABLE */ - - -FT_END_HEADER - - -#endif /* __FTCONFIG_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/config/ftheader.h b/thirdparty/include/freetype/config/ftheader.h deleted file mode 100644 index 8632f88c8..000000000 --- a/thirdparty/include/freetype/config/ftheader.h +++ /dev/null @@ -1,832 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftheader.h */ -/* */ -/* Build macros of the FreeType 2 library. */ -/* */ -/* Copyright 1996-2008, 2010, 2012, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -#ifndef __FT_HEADER_H__ -#define __FT_HEADER_H__ - - - /*@***********************************************************************/ - /* */ - /* */ - /* FT_BEGIN_HEADER */ - /* */ - /* */ - /* This macro is used in association with @FT_END_HEADER in header */ - /* files to ensure that the declarations within are properly */ - /* encapsulated in an `extern "C" { .. }' block when included from a */ - /* C++ compiler. */ - /* */ -#ifdef __cplusplus -#define FT_BEGIN_HEADER extern "C" { -#else -#define FT_BEGIN_HEADER /* nothing */ -#endif - - - /*@***********************************************************************/ - /* */ - /* */ - /* FT_END_HEADER */ - /* */ - /* */ - /* This macro is used in association with @FT_BEGIN_HEADER in header */ - /* files to ensure that the declarations within are properly */ - /* encapsulated in an `extern "C" { .. }' block when included from a */ - /* C++ compiler. */ - /* */ -#ifdef __cplusplus -#define FT_END_HEADER } -#else -#define FT_END_HEADER /* nothing */ -#endif - - - /*************************************************************************/ - /* */ - /* Aliases for the FreeType 2 public and configuration files. */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /*
*/ - /* header_file_macros */ - /* */ - /* */ - /* Header File Macros */ - /* */ - /* <Abstract> */ - /* Macro definitions used to #include specific header files. */ - /* */ - /* <Description> */ - /* The following macros are defined to the name of specific */ - /* FreeType~2 header files. They can be used directly in #include */ - /* statements as in: */ - /* */ - /* { */ - /* #include FT_FREETYPE_H */ - /* #include FT_MULTIPLE_MASTERS_H */ - /* #include FT_GLYPH_H */ - /* } */ - /* */ - /* There are several reasons why we are now using macros to name */ - /* public header files. The first one is that such macros are not */ - /* limited to the infamous 8.3~naming rule required by DOS (and */ - /* `FT_MULTIPLE_MASTERS_H' is a lot more meaningful than `ftmm.h'). */ - /* */ - /* The second reason is that it allows for more flexibility in the */ - /* way FreeType~2 is installed on a given system. */ - /* */ - /*************************************************************************/ - - - /* configuration files */ - - /************************************************************************* - * - * @macro: - * FT_CONFIG_CONFIG_H - * - * @description: - * A macro used in #include statements to name the file containing - * FreeType~2 configuration data. - * - */ -#ifndef FT_CONFIG_CONFIG_H -#define FT_CONFIG_CONFIG_H <freetype/config/ftconfig.h> -#endif - - - /************************************************************************* - * - * @macro: - * FT_CONFIG_STANDARD_LIBRARY_H - * - * @description: - * A macro used in #include statements to name the file containing - * FreeType~2 interface to the standard C library functions. - * - */ -#ifndef FT_CONFIG_STANDARD_LIBRARY_H -#define FT_CONFIG_STANDARD_LIBRARY_H <freetype/config/ftstdlib.h> -#endif - - - /************************************************************************* - * - * @macro: - * FT_CONFIG_OPTIONS_H - * - * @description: - * A macro used in #include statements to name the file containing - * FreeType~2 project-specific configuration options. - * - */ -#ifndef FT_CONFIG_OPTIONS_H -#define FT_CONFIG_OPTIONS_H <freetype/config/ftoption.h> -#endif - - - /************************************************************************* - * - * @macro: - * FT_CONFIG_MODULES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * list of FreeType~2 modules that are statically linked to new library - * instances in @FT_Init_FreeType. - * - */ -#ifndef FT_CONFIG_MODULES_H -#define FT_CONFIG_MODULES_H <freetype/config/ftmodule.h> -#endif - - /* */ - - /* public headers */ - - /************************************************************************* - * - * @macro: - * FT_FREETYPE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * base FreeType~2 API. - * - */ -#define FT_FREETYPE_H <freetype/freetype.h> - - - /************************************************************************* - * - * @macro: - * FT_ERRORS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * list of FreeType~2 error codes (and messages). - * - * It is included by @FT_FREETYPE_H. - * - */ -#define FT_ERRORS_H <freetype/fterrors.h> - - - /************************************************************************* - * - * @macro: - * FT_MODULE_ERRORS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * list of FreeType~2 module error offsets (and messages). - * - */ -#define FT_MODULE_ERRORS_H <freetype/ftmoderr.h> - - - /************************************************************************* - * - * @macro: - * FT_SYSTEM_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 interface to low-level operations (i.e., memory management - * and stream i/o). - * - * It is included by @FT_FREETYPE_H. - * - */ -#define FT_SYSTEM_H <freetype/ftsystem.h> - - - /************************************************************************* - * - * @macro: - * FT_IMAGE_H - * - * @description: - * A macro used in #include statements to name the file containing type - * definitions related to glyph images (i.e., bitmaps, outlines, - * scan-converter parameters). - * - * It is included by @FT_FREETYPE_H. - * - */ -#define FT_IMAGE_H <freetype/ftimage.h> - - - /************************************************************************* - * - * @macro: - * FT_TYPES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * basic data types defined by FreeType~2. - * - * It is included by @FT_FREETYPE_H. - * - */ -#define FT_TYPES_H <freetype/fttypes.h> - - - /************************************************************************* - * - * @macro: - * FT_LIST_H - * - * @description: - * A macro used in #include statements to name the file containing the - * list management API of FreeType~2. - * - * (Most applications will never need to include this file.) - * - */ -#define FT_LIST_H <freetype/ftlist.h> - - - /************************************************************************* - * - * @macro: - * FT_OUTLINE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * scalable outline management API of FreeType~2. - * - */ -#define FT_OUTLINE_H <freetype/ftoutln.h> - - - /************************************************************************* - * - * @macro: - * FT_SIZES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * API which manages multiple @FT_Size objects per face. - * - */ -#define FT_SIZES_H <freetype/ftsizes.h> - - - /************************************************************************* - * - * @macro: - * FT_MODULE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * module management API of FreeType~2. - * - */ -#define FT_MODULE_H <freetype/ftmodapi.h> - - - /************************************************************************* - * - * @macro: - * FT_RENDER_H - * - * @description: - * A macro used in #include statements to name the file containing the - * renderer module management API of FreeType~2. - * - */ -#define FT_RENDER_H <freetype/ftrender.h> - - - /************************************************************************* - * - * @macro: - * FT_AUTOHINTER_H - * - * @description: - * A macro used in #include statements to name the file containing - * structures and macros related to the auto-hinting module. - * - */ -#define FT_AUTOHINTER_H <freetype/ftautoh.h> - - - /************************************************************************* - * - * @macro: - * FT_CFF_DRIVER_H - * - * @description: - * A macro used in #include statements to name the file containing - * structures and macros related to the CFF driver module. - * - */ -#define FT_CFF_DRIVER_H <freetype/ftcffdrv.h> - - - /************************************************************************* - * - * @macro: - * FT_TRUETYPE_DRIVER_H - * - * @description: - * A macro used in #include statements to name the file containing - * structures and macros related to the TrueType driver module. - * - */ -#define FT_TRUETYPE_DRIVER_H <freetype/ftttdrv.h> - - - /************************************************************************* - * - * @macro: - * FT_TYPE1_TABLES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * types and API specific to the Type~1 format. - * - */ -#define FT_TYPE1_TABLES_H <freetype/t1tables.h> - - - /************************************************************************* - * - * @macro: - * FT_TRUETYPE_IDS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * enumeration values which identify name strings, languages, encodings, - * etc. This file really contains a _large_ set of constant macro - * definitions, taken from the TrueType and OpenType specifications. - * - */ -#define FT_TRUETYPE_IDS_H <freetype/ttnameid.h> - - - /************************************************************************* - * - * @macro: - * FT_TRUETYPE_TABLES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * types and API specific to the TrueType (as well as OpenType) format. - * - */ -#define FT_TRUETYPE_TABLES_H <freetype/tttables.h> - - - /************************************************************************* - * - * @macro: - * FT_TRUETYPE_TAGS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of TrueType four-byte `tags' which identify blocks in - * SFNT-based font formats (i.e., TrueType and OpenType). - * - */ -#define FT_TRUETYPE_TAGS_H <freetype/tttags.h> - - - /************************************************************************* - * - * @macro: - * FT_BDF_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which accesses BDF-specific strings from a - * face. - * - */ -#define FT_BDF_H <freetype/ftbdf.h> - - - /************************************************************************* - * - * @macro: - * FT_CID_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which access CID font information from a - * face. - * - */ -#define FT_CID_H <freetype/ftcid.h> - - - /************************************************************************* - * - * @macro: - * FT_GZIP_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which supports gzip-compressed files. - * - */ -#define FT_GZIP_H <freetype/ftgzip.h> - - - /************************************************************************* - * - * @macro: - * FT_LZW_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which supports LZW-compressed files. - * - */ -#define FT_LZW_H <freetype/ftlzw.h> - - - /************************************************************************* - * - * @macro: - * FT_BZIP2_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which supports bzip2-compressed files. - * - */ -#define FT_BZIP2_H <freetype/ftbzip2.h> - - - /************************************************************************* - * - * @macro: - * FT_WINFONTS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which supports Windows FNT files. - * - */ -#define FT_WINFONTS_H <freetype/ftwinfnt.h> - - - /************************************************************************* - * - * @macro: - * FT_GLYPH_H - * - * @description: - * A macro used in #include statements to name the file containing the - * API of the optional glyph management component. - * - */ -#define FT_GLYPH_H <freetype/ftglyph.h> - - - /************************************************************************* - * - * @macro: - * FT_BITMAP_H - * - * @description: - * A macro used in #include statements to name the file containing the - * API of the optional bitmap conversion component. - * - */ -#define FT_BITMAP_H <freetype/ftbitmap.h> - - - /************************************************************************* - * - * @macro: - * FT_BBOX_H - * - * @description: - * A macro used in #include statements to name the file containing the - * API of the optional exact bounding box computation routines. - * - */ -#define FT_BBOX_H <freetype/ftbbox.h> - - - /************************************************************************* - * - * @macro: - * FT_CACHE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * API of the optional FreeType~2 cache sub-system. - * - */ -#define FT_CACHE_H <freetype/ftcache.h> - - - /************************************************************************* - * - * @macro: - * FT_CACHE_IMAGE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * `glyph image' API of the FreeType~2 cache sub-system. - * - * It is used to define a cache for @FT_Glyph elements. You can also - * use the API defined in @FT_CACHE_SMALL_BITMAPS_H if you only need to - * store small glyph bitmaps, as it will use less memory. - * - * This macro is deprecated. Simply include @FT_CACHE_H to have all - * glyph image-related cache declarations. - * - */ -#define FT_CACHE_IMAGE_H FT_CACHE_H - - - /************************************************************************* - * - * @macro: - * FT_CACHE_SMALL_BITMAPS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * `small bitmaps' API of the FreeType~2 cache sub-system. - * - * It is used to define a cache for small glyph bitmaps in a relatively - * memory-efficient way. You can also use the API defined in - * @FT_CACHE_IMAGE_H if you want to cache arbitrary glyph images, - * including scalable outlines. - * - * This macro is deprecated. Simply include @FT_CACHE_H to have all - * small bitmaps-related cache declarations. - * - */ -#define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H - - - /************************************************************************* - * - * @macro: - * FT_CACHE_CHARMAP_H - * - * @description: - * A macro used in #include statements to name the file containing the - * `charmap' API of the FreeType~2 cache sub-system. - * - * This macro is deprecated. Simply include @FT_CACHE_H to have all - * charmap-based cache declarations. - * - */ -#define FT_CACHE_CHARMAP_H FT_CACHE_H - - - /************************************************************************* - * - * @macro: - * FT_MAC_H - * - * @description: - * A macro used in #include statements to name the file containing the - * Macintosh-specific FreeType~2 API. The latter is used to access - * fonts embedded in resource forks. - * - * This header file must be explicitly included by client applications - * compiled on the Mac (note that the base API still works though). - * - */ -#define FT_MAC_H <freetype/ftmac.h> - - - /************************************************************************* - * - * @macro: - * FT_MULTIPLE_MASTERS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * optional multiple-masters management API of FreeType~2. - * - */ -#define FT_MULTIPLE_MASTERS_H <freetype/ftmm.h> - - - /************************************************************************* - * - * @macro: - * FT_SFNT_NAMES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * optional FreeType~2 API which accesses embedded `name' strings in - * SFNT-based font formats (i.e., TrueType and OpenType). - * - */ -#define FT_SFNT_NAMES_H <freetype/ftsnames.h> - - - /************************************************************************* - * - * @macro: - * FT_OPENTYPE_VALIDATE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * optional FreeType~2 API which validates OpenType tables (BASE, GDEF, - * GPOS, GSUB, JSTF). - * - */ -#define FT_OPENTYPE_VALIDATE_H <freetype/ftotval.h> - - - /************************************************************************* - * - * @macro: - * FT_GX_VALIDATE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * optional FreeType~2 API which validates TrueTypeGX/AAT tables (feat, - * mort, morx, bsln, just, kern, opbd, trak, prop). - * - */ -#define FT_GX_VALIDATE_H <freetype/ftgxval.h> - - - /************************************************************************* - * - * @macro: - * FT_PFR_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which accesses PFR-specific data. - * - */ -#define FT_PFR_H <freetype/ftpfr.h> - - - /************************************************************************* - * - * @macro: - * FT_STROKER_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which provides functions to stroke outline paths. - */ -#define FT_STROKER_H <freetype/ftstroke.h> - - - /************************************************************************* - * - * @macro: - * FT_SYNTHESIS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which performs artificial obliquing and emboldening. - */ -#define FT_SYNTHESIS_H <freetype/ftsynth.h> - - - /************************************************************************* - * - * @macro: - * FT_XFREE86_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which provides functions specific to the XFree86 and - * X.Org X11 servers. - */ -#define FT_XFREE86_H <freetype/ftxf86.h> - - - /************************************************************************* - * - * @macro: - * FT_TRIGONOMETRY_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which performs trigonometric computations (e.g., - * cosines and arc tangents). - */ -#define FT_TRIGONOMETRY_H <freetype/fttrigon.h> - - - /************************************************************************* - * - * @macro: - * FT_LCD_FILTER_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which performs color filtering for subpixel rendering. - */ -#define FT_LCD_FILTER_H <freetype/ftlcdfil.h> - - - /************************************************************************* - * - * @macro: - * FT_UNPATENTED_HINTING_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which performs color filtering for subpixel rendering. - */ -#define FT_UNPATENTED_HINTING_H <freetype/ttunpat.h> - - - /************************************************************************* - * - * @macro: - * FT_INCREMENTAL_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which performs color filtering for subpixel rendering. - */ -#define FT_INCREMENTAL_H <freetype/ftincrem.h> - - - /************************************************************************* - * - * @macro: - * FT_GASP_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which returns entries from the TrueType GASP table. - */ -#define FT_GASP_H <freetype/ftgasp.h> - - - /************************************************************************* - * - * @macro: - * FT_ADVANCES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which returns individual and ranged glyph advances. - */ -#define FT_ADVANCES_H <freetype/ftadvanc.h> - - - /* */ - -#define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h> - - - /* The internals of the cache sub-system are no longer exposed. We */ - /* default to FT_CACHE_H at the moment just in case, but we know of */ - /* no rogue client that uses them. */ - /* */ -#define FT_CACHE_MANAGER_H <freetype/ftcache.h> -#define FT_CACHE_INTERNAL_MRU_H <freetype/ftcache.h> -#define FT_CACHE_INTERNAL_MANAGER_H <freetype/ftcache.h> -#define FT_CACHE_INTERNAL_CACHE_H <freetype/ftcache.h> -#define FT_CACHE_INTERNAL_GLYPH_H <freetype/ftcache.h> -#define FT_CACHE_INTERNAL_IMAGE_H <freetype/ftcache.h> -#define FT_CACHE_INTERNAL_SBITS_H <freetype/ftcache.h> - - -#define FT_INCREMENTAL_H <freetype/ftincrem.h> - -#define FT_TRUETYPE_UNPATENTED_H <freetype/ttunpat.h> - - - /* - * Include internal headers definitions from <internal/...> - * only when building the library. - */ -#ifdef FT2_BUILD_LIBRARY -#define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h> -#include FT_INTERNAL_INTERNAL_H -#endif /* FT2_BUILD_LIBRARY */ - - -#endif /* __FT2_BUILD_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/config/ftmodule.h b/thirdparty/include/freetype/config/ftmodule.h deleted file mode 100644 index 76d271a74..000000000 --- a/thirdparty/include/freetype/config/ftmodule.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file registers the FreeType modules compiled into the library. - * - * If you use GNU make, this file IS NOT USED! Instead, it is created in - * the objects directory (normally `<topdir>/objs/') based on information - * from `<topdir>/modules.cfg'. - * - * Please read `docs/INSTALL.ANY' and `docs/CUSTOMIZE' how to compile - * FreeType without GNU make. - * - */ - -FT_USE_MODULE( FT_Module_Class, autofit_module_class ) -FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class ) -FT_USE_MODULE( FT_Module_Class, psaux_module_class ) -FT_USE_MODULE( FT_Module_Class, psnames_module_class ) -FT_USE_MODULE( FT_Module_Class, pshinter_module_class ) -FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class ) -FT_USE_MODULE( FT_Module_Class, sfnt_module_class ) -FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class ) -FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class ) -FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class ) -FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class ) - -/* EOF */ diff --git a/thirdparty/include/freetype/config/ftoption.h b/thirdparty/include/freetype/config/ftoption.h deleted file mode 100644 index 78d96e51b..000000000 --- a/thirdparty/include/freetype/config/ftoption.h +++ /dev/null @@ -1,846 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftoption.h */ -/* */ -/* User-selectable configuration macros (specification only). */ -/* */ -/* Copyright 1996-2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTOPTION_H__ -#define __FTOPTION_H__ - - -#include <freetype/ft2build.h> - - -FT_BEGIN_HEADER - - /*************************************************************************/ - /* */ - /* USER-SELECTABLE CONFIGURATION MACROS */ - /* */ - /* This file contains the default configuration macro definitions for */ - /* a standard build of the FreeType library. There are three ways to */ - /* use this file to build project-specific versions of the library: */ - /* */ - /* - You can modify this file by hand, but this is not recommended in */ - /* cases where you would like to build several versions of the */ - /* library from a single source directory. */ - /* */ - /* - You can put a copy of this file in your build directory, more */ - /* precisely in `$BUILD/config/ftoption.h', where `$BUILD' is the */ - /* name of a directory that is included _before_ the FreeType include */ - /* path during compilation. */ - /* */ - /* The default FreeType Makefiles and Jamfiles use the build */ - /* directory `builds/<system>' by default, but you can easily change */ - /* that for your own projects. */ - /* */ - /* - Copy the file <ft2build.h> to `$BUILD/ft2build.h' and modify it */ - /* slightly to pre-define the macro FT_CONFIG_OPTIONS_H used to */ - /* locate this file during the build. For example, */ - /* */ - /* #define FT_CONFIG_OPTIONS_H <myftoptions.h> */ - /* #include <config/ftheader.h> */ - /* */ - /* will use `$BUILD/myftoptions.h' instead of this file for macro */ - /* definitions. */ - /* */ - /* Note also that you can similarly pre-define the macro */ - /* FT_CONFIG_MODULES_H used to locate the file listing of the modules */ - /* that are statically linked to the library at compile time. By */ - /* default, this file is <config/ftmodule.h>. */ - /* */ - /* We highly recommend using the third method whenever possible. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Uncomment the line below if you want to activate sub-pixel rendering */ - /* (a.k.a. LCD rendering, or ClearType) in this build of the library. */ - /* */ - /* Note that this feature is covered by several Microsoft patents */ - /* and should not be activated in any default build of the library. */ - /* */ - /* This macro has no impact on the FreeType API, only on its */ - /* _implementation_. For example, using FT_RENDER_MODE_LCD when calling */ - /* FT_Render_Glyph still generates a bitmap that is 3 times wider than */ - /* the original size in case this macro isn't defined; however, each */ - /* triplet of subpixels has R=G=B. */ - /* */ - /* This is done to allow FreeType clients to run unmodified, forcing */ - /* them to display normal gray-level anti-aliased glyphs. */ - /* */ -/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - - - /*************************************************************************/ - /* */ - /* Many compilers provide a non-ANSI 64-bit data type that can be used */ - /* by FreeType to speed up some computations. However, this will create */ - /* some problems when compiling the library in strict ANSI mode. */ - /* */ - /* For this reason, the use of 64-bit integers is normally disabled when */ - /* the __STDC__ macro is defined. You can however disable this by */ - /* defining the macro FT_CONFIG_OPTION_FORCE_INT64 here. */ - /* */ - /* For most compilers, this will only create compilation warnings when */ - /* building the library. */ - /* */ - /* ObNote: The compiler-specific 64-bit integers are detected in the */ - /* file `ftconfig.h' either statically or through the */ - /* `configure' script on supported platforms. */ - /* */ -#undef FT_CONFIG_OPTION_FORCE_INT64 - - - /*************************************************************************/ - /* */ - /* If this macro is defined, do not try to use an assembler version of */ - /* performance-critical functions (e.g. FT_MulFix). You should only do */ - /* that to verify that the assembler function works properly, or to */ - /* execute benchmark tests of the various implementations. */ -/* #define FT_CONFIG_OPTION_NO_ASSEMBLER */ - - - /*************************************************************************/ - /* */ - /* If this macro is defined, try to use an inlined assembler version of */ - /* the `FT_MulFix' function, which is a `hotspot' when loading and */ - /* hinting glyphs, and which should be executed as fast as possible. */ - /* */ - /* Note that if your compiler or CPU is not supported, this will default */ - /* to the standard and portable implementation found in `ftcalc.c'. */ - /* */ -#define FT_CONFIG_OPTION_INLINE_MULFIX - - - /*************************************************************************/ - /* */ - /* LZW-compressed file support. */ - /* */ - /* FreeType now handles font files that have been compressed with the */ - /* `compress' program. This is mostly used to parse many of the PCF */ - /* files that come with various X11 distributions. The implementation */ - /* uses NetBSD's `zopen' to partially uncompress the file on the fly */ - /* (see src/lzw/ftgzip.c). */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ -#define FT_CONFIG_OPTION_USE_LZW - - - /*************************************************************************/ - /* */ - /* Gzip-compressed file support. */ - /* */ - /* FreeType now handles font files that have been compressed with the */ - /* `gzip' program. This is mostly used to parse many of the PCF files */ - /* that come with XFree86. The implementation uses `zlib' to */ - /* partially uncompress the file on the fly (see src/gzip/ftgzip.c). */ - /* */ - /* Define this macro if you want to enable this `feature'. See also */ - /* the macro FT_CONFIG_OPTION_SYSTEM_ZLIB below. */ - /* */ -#define FT_CONFIG_OPTION_USE_ZLIB - - - /*************************************************************************/ - /* */ - /* ZLib library selection */ - /* */ - /* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */ - /* It allows FreeType's `ftgzip' component to link to the system's */ - /* installation of the ZLib library. This is useful on systems like */ - /* Unix or VMS where it generally is already available. */ - /* */ - /* If you let it undefined, the component will use its own copy */ - /* of the zlib sources instead. These have been modified to be */ - /* included directly within the component and *not* export external */ - /* function names. This allows you to link any program with FreeType */ - /* _and_ ZLib without linking conflicts. */ - /* */ - /* Do not #undef this macro here since the build system might define */ - /* it for certain configurations only. */ - /* */ -/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */ - - - /*************************************************************************/ - /* */ - /* Bzip2-compressed file support. */ - /* */ - /* FreeType now handles font files that have been compressed with the */ - /* `bzip2' program. This is mostly used to parse many of the PCF */ - /* files that come with XFree86. The implementation uses `libbz2' to */ - /* partially uncompress the file on the fly (see src/bzip2/ftbzip2.c). */ - /* Contrary to gzip, bzip2 currently is not included and need to use */ - /* the system available bzip2 implementation. */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ -/* #define FT_CONFIG_OPTION_USE_BZIP2 */ - - - /*************************************************************************/ - /* */ - /* Define to disable the use of file stream functions and types, FILE, */ - /* fopen() etc. Enables the use of smaller system libraries on embedded */ - /* systems that have multiple system libraries, some with or without */ - /* file stream support, in the cases where file stream support is not */ - /* necessary such as memory loading of font files. */ - /* */ -/* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */ - - - /*************************************************************************/ - /* */ - /* PNG bitmap support. */ - /* */ - /* FreeType now handles loading color bitmap glyphs in the PNG format. */ - /* This requires help from the external libpng library. Uncompressed */ - /* color bitmaps do not need any external libraries and will be */ - /* supported regardless of this configuration. */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ -/* #define FT_CONFIG_OPTION_USE_PNG */ - - - /*************************************************************************/ - /* */ - /* HarfBuzz support. */ - /* */ - /* FreeType uses the HarfBuzz library to improve auto-hinting of */ - /* OpenType fonts. If available, many glyphs not directly addressable */ - /* by a font's character map will be hinted also. */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ -/* #define FT_CONFIG_OPTION_USE_HARFBUZZ */ - - - /*************************************************************************/ - /* */ - /* DLL export compilation */ - /* */ - /* When compiling FreeType as a DLL, some systems/compilers need a */ - /* special keyword in front OR after the return type of function */ - /* declarations. */ - /* */ - /* Two macros are used within the FreeType source code to define */ - /* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */ - /* */ - /* FT_EXPORT( return_type ) */ - /* */ - /* is used in a function declaration, as in */ - /* */ - /* FT_EXPORT( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ); */ - /* */ - /* */ - /* FT_EXPORT_DEF( return_type ) */ - /* */ - /* is used in a function definition, as in */ - /* */ - /* FT_EXPORT_DEF( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ) */ - /* { */ - /* ... some code ... */ - /* return FT_Err_Ok; */ - /* } */ - /* */ - /* You can provide your own implementation of FT_EXPORT and */ - /* FT_EXPORT_DEF here if you want. If you leave them undefined, they */ - /* will be later automatically defined as `extern return_type' to */ - /* allow normal compilation. */ - /* */ - /* Do not #undef these macros here since the build system might define */ - /* them for certain configurations only. */ - /* */ -/* #define FT_EXPORT(x) extern x */ -/* #define FT_EXPORT_DEF(x) x */ - - - /*************************************************************************/ - /* */ - /* Glyph Postscript Names handling */ - /* */ - /* By default, FreeType 2 is compiled with the `psnames' module. This */ - /* module is in charge of converting a glyph name string into a */ - /* Unicode value, or return a Macintosh standard glyph name for the */ - /* use with the TrueType `post' table. */ - /* */ - /* Undefine this macro if you do not want `psnames' compiled in your */ - /* build of FreeType. This has the following effects: */ - /* */ - /* - The TrueType driver will provide its own set of glyph names, */ - /* if you build it to support postscript names in the TrueType */ - /* `post' table. */ - /* */ - /* - The Type 1 driver will not be able to synthesize a Unicode */ - /* charmap out of the glyphs found in the fonts. */ - /* */ - /* You would normally undefine this configuration macro when building */ - /* a version of FreeType that doesn't contain a Type 1 or CFF driver. */ - /* */ -#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES - - - /*************************************************************************/ - /* */ - /* Postscript Names to Unicode Values support */ - /* */ - /* By default, FreeType 2 is built with the `PSNames' module compiled */ - /* in. Among other things, the module is used to convert a glyph name */ - /* into a Unicode value. This is especially useful in order to */ - /* synthesize on the fly a Unicode charmap from the CFF/Type 1 driver */ - /* through a big table named the `Adobe Glyph List' (AGL). */ - /* */ - /* Undefine this macro if you do not want the Adobe Glyph List */ - /* compiled in your `PSNames' module. The Type 1 driver will not be */ - /* able to synthesize a Unicode charmap out of the glyphs found in the */ - /* fonts. */ - /* */ -#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST - - - /*************************************************************************/ - /* */ - /* Support for Mac fonts */ - /* */ - /* Define this macro if you want support for outline fonts in Mac */ - /* format (mac dfont, mac resource, macbinary containing a mac */ - /* resource) on non-Mac platforms. */ - /* */ - /* Note that the `FOND' resource isn't checked. */ - /* */ -#define FT_CONFIG_OPTION_MAC_FONTS - - - /*************************************************************************/ - /* */ - /* Guessing methods to access embedded resource forks */ - /* */ - /* Enable extra Mac fonts support on non-Mac platforms (e.g. */ - /* GNU/Linux). */ - /* */ - /* Resource forks which include fonts data are stored sometimes in */ - /* locations which users or developers don't expected. In some cases, */ - /* resource forks start with some offset from the head of a file. In */ - /* other cases, the actual resource fork is stored in file different */ - /* from what the user specifies. If this option is activated, */ - /* FreeType tries to guess whether such offsets or different file */ - /* names must be used. */ - /* */ - /* Note that normal, direct access of resource forks is controlled via */ - /* the FT_CONFIG_OPTION_MAC_FONTS option. */ - /* */ -#ifdef FT_CONFIG_OPTION_MAC_FONTS -#define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK -#endif - - - /*************************************************************************/ - /* */ - /* Allow the use of FT_Incremental_Interface to load typefaces that */ - /* contain no glyph data, but supply it via a callback function. */ - /* This is required by clients supporting document formats which */ - /* supply font data incrementally as the document is parsed, such */ - /* as the Ghostscript interpreter for the PostScript language. */ - /* */ -#define FT_CONFIG_OPTION_INCREMENTAL - - - /*************************************************************************/ - /* */ - /* The size in bytes of the render pool used by the scan-line converter */ - /* to do all of its work. */ - /* */ - /* This must be greater than 4KByte if you use FreeType to rasterize */ - /* glyphs; otherwise, you may set it to zero to avoid unnecessary */ - /* allocation of the render pool. */ - /* */ -#define FT_RENDER_POOL_SIZE 16384L - - - /*************************************************************************/ - /* */ - /* FT_MAX_MODULES */ - /* */ - /* The maximum number of modules that can be registered in a single */ - /* FreeType library object. 32 is the default. */ - /* */ -#define FT_MAX_MODULES 32 - - - /*************************************************************************/ - /* */ - /* Debug level */ - /* */ - /* FreeType can be compiled in debug or trace mode. In debug mode, */ - /* errors are reported through the `ftdebug' component. In trace */ - /* mode, additional messages are sent to the standard output during */ - /* execution. */ - /* */ - /* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */ - /* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */ - /* */ - /* Don't define any of these macros to compile in `release' mode! */ - /* */ - /* Do not #undef these macros here since the build system might define */ - /* them for certain configurations only. */ - /* */ -/* #define FT_DEBUG_LEVEL_ERROR */ -/* #define FT_DEBUG_LEVEL_TRACE */ - - - /*************************************************************************/ - /* */ - /* Autofitter debugging */ - /* */ - /* If FT_DEBUG_AUTOFIT is defined, FreeType provides some means to */ - /* control the autofitter behaviour for debugging purposes with global */ - /* boolean variables (consequently, you should *never* enable this */ - /* while compiling in `release' mode): */ - /* */ - /* _af_debug_disable_horz_hints */ - /* _af_debug_disable_vert_hints */ - /* _af_debug_disable_blue_hints */ - /* */ - /* Additionally, the following functions provide dumps of various */ - /* internal autofit structures to stdout (using `printf'): */ - /* */ - /* af_glyph_hints_dump_points */ - /* af_glyph_hints_dump_segments */ - /* af_glyph_hints_dump_edges */ - /* */ - /* As an argument, they use another global variable: */ - /* */ - /* _af_debug_hints */ - /* */ - /* Please have a look at the `ftgrid' demo program to see how those */ - /* variables and macros should be used. */ - /* */ - /* Do not #undef these macros here since the build system might define */ - /* them for certain configurations only. */ - /* */ -/* #define FT_DEBUG_AUTOFIT */ - - - /*************************************************************************/ - /* */ - /* Memory Debugging */ - /* */ - /* FreeType now comes with an integrated memory debugger that is */ - /* capable of detecting simple errors like memory leaks or double */ - /* deletes. To compile it within your build of the library, you */ - /* should define FT_DEBUG_MEMORY here. */ - /* */ - /* Note that the memory debugger is only activated at runtime when */ - /* when the _environment_ variable `FT2_DEBUG_MEMORY' is defined also! */ - /* */ - /* Do not #undef this macro here since the build system might define */ - /* it for certain configurations only. */ - /* */ -/* #define FT_DEBUG_MEMORY */ - - - /*************************************************************************/ - /* */ - /* Module errors */ - /* */ - /* If this macro is set (which is _not_ the default), the higher byte */ - /* of an error code gives the module in which the error has occurred, */ - /* while the lower byte is the real error code. */ - /* */ - /* Setting this macro makes sense for debugging purposes only, since */ - /* it would break source compatibility of certain programs that use */ - /* FreeType 2. */ - /* */ - /* More details can be found in the files ftmoderr.h and fterrors.h. */ - /* */ -#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS - - - /*************************************************************************/ - /* */ - /* Position Independent Code */ - /* */ - /* If this macro is set (which is _not_ the default), FreeType2 will */ - /* avoid creating constants that require address fixups. Instead the */ - /* constants will be moved into a struct and additional intialization */ - /* code will be used. */ - /* */ - /* Setting this macro is needed for systems that prohibit address */ - /* fixups, such as BREW. */ - /* */ -/* #define FT_CONFIG_OPTION_PIC */ - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** S F N T D R I V E R C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_EMBEDDED_BITMAPS if you want to support */ - /* embedded bitmaps in all formats using the SFNT module (namely */ - /* TrueType & OpenType). */ - /* */ -#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */ - /* load and enumerate the glyph Postscript names in a TrueType or */ - /* OpenType file. */ - /* */ - /* Note that when you do not compile the `PSNames' module by undefining */ - /* the above FT_CONFIG_OPTION_POSTSCRIPT_NAMES, the `sfnt' module will */ - /* contain additional code used to read the PS Names table from a font. */ - /* */ - /* (By default, the module uses `PSNames' to extract glyph names.) */ - /* */ -#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */ - /* access the internal name table in a SFNT-based format like TrueType */ - /* or OpenType. The name table contains various strings used to */ - /* describe the font, like family name, copyright, version, etc. It */ - /* does not contain any glyph name though. */ - /* */ - /* Accessing SFNT names is done through the functions declared in */ - /* `ftsnames.h'. */ - /* */ -#define TT_CONFIG_OPTION_SFNT_NAMES - - - /*************************************************************************/ - /* */ - /* TrueType CMap support */ - /* */ - /* Here you can fine-tune which TrueType CMap table format shall be */ - /* supported. */ -#define TT_CONFIG_CMAP_FORMAT_0 -#define TT_CONFIG_CMAP_FORMAT_2 -#define TT_CONFIG_CMAP_FORMAT_4 -#define TT_CONFIG_CMAP_FORMAT_6 -#define TT_CONFIG_CMAP_FORMAT_8 -#define TT_CONFIG_CMAP_FORMAT_10 -#define TT_CONFIG_CMAP_FORMAT_12 -#define TT_CONFIG_CMAP_FORMAT_13 -#define TT_CONFIG_CMAP_FORMAT_14 - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */ - /* a bytecode interpreter in the TrueType driver. */ - /* */ - /* By undefining this, you will only compile the code necessary to load */ - /* TrueType glyphs without hinting. */ - /* */ - /* Do not #undef this macro here, since the build system might */ - /* define it for certain configurations only. */ - /* */ -#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING if you want to compile */ - /* EXPERIMENTAL subpixel hinting support into the TrueType driver. This */ - /* replaces the native TrueType hinting mechanism when anything but */ - /* FT_RENDER_MODE_MONO is requested. */ - /* */ - /* Enabling this causes the TrueType driver to ignore instructions under */ - /* certain conditions. This is done in accordance with the guide here, */ - /* with some minor differences: */ - /* */ - /* http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */ - /* */ - /* By undefining this, you only compile the code necessary to hint */ - /* TrueType glyphs with native TT hinting. */ - /* */ - /* This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be */ - /* defined. */ - /* */ -/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING */ - - - /*************************************************************************/ - /* */ - /* If you define TT_CONFIG_OPTION_UNPATENTED_HINTING, a special version */ - /* of the TrueType bytecode interpreter is used that doesn't implement */ - /* any of the patented opcodes and algorithms. The patents related to */ - /* TrueType hinting have expired worldwide since May 2010; this option */ - /* is now deprecated. */ - /* */ - /* Note that the TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* */ - /* if you define TT_CONFIG_OPTION_BYTECODE_INTERPRETER; in other words, */ - /* either define TT_CONFIG_OPTION_BYTECODE_INTERPRETER or */ - /* TT_CONFIG_OPTION_UNPATENTED_HINTING but not both at the same time. */ - /* */ - /* This macro is only useful for a small number of font files (mostly */ - /* for Asian scripts) that require bytecode interpretation to properly */ - /* load glyphs. For all other fonts, this produces unpleasant results, */ - /* thus the unpatented interpreter is never used to load glyphs from */ - /* TrueType fonts unless one of the following two options is used. */ - /* */ - /* - The unpatented interpreter is explicitly activated by the user */ - /* through the FT_PARAM_TAG_UNPATENTED_HINTING parameter tag */ - /* when opening the FT_Face. */ - /* */ - /* - FreeType detects that the FT_Face corresponds to one of the */ - /* `trick' fonts (e.g., `Mingliu') it knows about. The font engine */ - /* contains a hard-coded list of font names and other matching */ - /* parameters (see function `tt_face_init' in file */ - /* `src/truetype/ttobjs.c'). */ - /* */ - /* Here a sample code snippet for using FT_PARAM_TAG_UNPATENTED_HINTING. */ - /* */ - /* { */ - /* FT_Parameter parameter; */ - /* FT_Open_Args open_args; */ - /* */ - /* */ - /* parameter.tag = FT_PARAM_TAG_UNPATENTED_HINTING; */ - /* */ - /* open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS; */ - /* open_args.pathname = my_font_pathname; */ - /* open_args.num_params = 1; */ - /* open_args.params = ¶meter; */ - /* */ - /* error = FT_Open_Face( library, &open_args, index, &face ); */ - /* ... */ - /* } */ - /* */ -/* #define TT_CONFIG_OPTION_UNPATENTED_HINTING */ - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_INTERPRETER_SWITCH to compile the TrueType */ - /* bytecode interpreter with a huge switch statement, rather than a call */ - /* table. This results in smaller and faster code for a number of */ - /* architectures. */ - /* */ - /* Note however that on some compiler/processor combinations, undefining */ - /* this macro will generate faster, though larger, code. */ - /* */ -#define TT_CONFIG_OPTION_INTERPRETER_SWITCH - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the */ - /* TrueType glyph loader to use Apple's definition of how to handle */ - /* component offsets in composite glyphs. */ - /* */ - /* Apple and MS disagree on the default behavior of component offsets */ - /* in composites. Apple says that they should be scaled by the scaling */ - /* factors in the transformation matrix (roughly, it's more complex) */ - /* while MS says they should not. OpenType defines two bits in the */ - /* composite flags array which can be used to disambiguate, but old */ - /* fonts will not have them. */ - /* */ - /* http://www.microsoft.com/typography/otspec/glyf.htm */ - /* http://fonts.apple.com/TTRefMan/RM06/Chap6glyf.html */ - /* */ -#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_GX_VAR_SUPPORT if you want to include */ - /* support for Apple's distortable font technology (fvar, gvar, cvar, */ - /* and avar tables). This has many similarities to Type 1 Multiple */ - /* Masters support. */ - /* */ -#define TT_CONFIG_OPTION_GX_VAR_SUPPORT - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_BDF if you want to include support for */ - /* an embedded `BDF ' table within SFNT-based bitmap formats. */ - /* */ -#define TT_CONFIG_OPTION_BDF - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* T1_MAX_DICT_DEPTH is the maximum depth of nest dictionaries and */ - /* arrays in the Type 1 stream (see t1load.c). A minimum of 4 is */ - /* required. */ - /* */ -#define T1_MAX_DICT_DEPTH 5 - - - /*************************************************************************/ - /* */ - /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ - /* calls during glyph loading. */ - /* */ -#define T1_MAX_SUBRS_CALLS 16 - - - /*************************************************************************/ - /* */ - /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ - /* minimum of 16 is required. */ - /* */ - /* The Chinese font MingTiEG-Medium (CNS 11643 character set) needs 256. */ - /* */ -#define T1_MAX_CHARSTRINGS_OPERANDS 256 - - - /*************************************************************************/ - /* */ - /* Define this configuration macro if you want to prevent the */ - /* compilation of `t1afm', which is in charge of reading Type 1 AFM */ - /* files into an existing face. Note that if set, the T1 driver will be */ - /* unable to produce kerning distances. */ - /* */ -#undef T1_CONFIG_OPTION_NO_AFM - - - /*************************************************************************/ - /* */ - /* Define this configuration macro if you want to prevent the */ - /* compilation of the Multiple Masters font support in the Type 1 */ - /* driver. */ - /* */ -#undef T1_CONFIG_OPTION_NO_MM_SUPPORT - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** C F F D R I V E R C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF */ - /* engine gets compiled into FreeType. If defined, it is possible to */ - /* switch between the two engines using the `hinting-engine' property of */ - /* the cff driver module. */ - /* */ -/* #define CFF_CONFIG_OPTION_OLD_ENGINE */ - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** A U T O F I T M O D U L E C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Compile autofit module with CJK (Chinese, Japanese, Korean) script */ - /* support. */ - /* */ -#define AF_CONFIG_OPTION_CJK - - /*************************************************************************/ - /* */ - /* Compile autofit module with Indic script support. */ - /* */ -#define AF_CONFIG_OPTION_INDIC - - /*************************************************************************/ - /* */ - /* Compile autofit module with warp hinting. The idea of the warping */ - /* code is to slightly scale and shift a glyph within a single dimension */ - /* so that as much of its segments are aligned (more or less) on the */ - /* grid. To find out the optimal scaling and shifting value, various */ - /* parameter combinations are tried and scored. */ - /* */ - /* This experimental option is only active if the render mode is */ - /* FT_RENDER_MODE_LIGHT. */ - /* */ -/* #define AF_CONFIG_OPTION_USE_WARPER */ - - /* */ - - - /* - * This macro is obsolete. Support has been removed in FreeType - * version 2.5. - */ -/* #define FT_CONFIG_OPTION_OLD_INTERNALS */ - - - /* - * This macro is defined if either unpatented or native TrueType - * hinting is requested by the definitions above. - */ -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER -#define TT_USE_BYTECODE_INTERPRETER -#undef TT_CONFIG_OPTION_UNPATENTED_HINTING -#elif defined TT_CONFIG_OPTION_UNPATENTED_HINTING -#define TT_USE_BYTECODE_INTERPRETER -#endif - -FT_END_HEADER - - -#endif /* __FTOPTION_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/config/ftstdlib.h b/thirdparty/include/freetype/config/ftstdlib.h deleted file mode 100644 index b940efc42..000000000 --- a/thirdparty/include/freetype/config/ftstdlib.h +++ /dev/null @@ -1,174 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftstdlib.h */ -/* */ -/* ANSI-specific library and header configuration file (specification */ -/* only). */ -/* */ -/* Copyright 2002-2007, 2009, 2011-2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to group all #includes to the ANSI C library that */ - /* FreeType normally requires. It also defines macros to rename the */ - /* standard functions within the FreeType source code. */ - /* */ - /* Load a file which defines __FTSTDLIB_H__ before this one to override */ - /* it. */ - /* */ - /*************************************************************************/ - - -#ifndef __FTSTDLIB_H__ -#define __FTSTDLIB_H__ - - -#include <stddef.h> - -#define ft_ptrdiff_t ptrdiff_t - - - /**********************************************************************/ - /* */ - /* integer limits */ - /* */ - /* UINT_MAX and ULONG_MAX are used to automatically compute the size */ - /* of `int' and `long' in bytes at compile-time. So far, this works */ - /* for all platforms the library has been tested on. */ - /* */ - /* Note that on the extremely rare platforms that do not provide */ - /* integer types that are _exactly_ 16 and 32 bits wide (e.g. some */ - /* old Crays where `int' is 36 bits), we do not make any guarantee */ - /* about the correct behaviour of FT2 with all fonts. */ - /* */ - /* In these case, `ftconfig.h' will refuse to compile anyway with a */ - /* message like `couldn't find 32-bit type' or something similar. */ - /* */ - /**********************************************************************/ - - -#include <limits.h> - -#define FT_CHAR_BIT CHAR_BIT -#define FT_USHORT_MAX USHRT_MAX -#define FT_INT_MAX INT_MAX -#define FT_INT_MIN INT_MIN -#define FT_UINT_MAX UINT_MAX -#define FT_ULONG_MAX ULONG_MAX - - - /**********************************************************************/ - /* */ - /* character and string processing */ - /* */ - /**********************************************************************/ - - -#include <string.h> - -#define ft_memchr memchr -#define ft_memcmp memcmp -#define ft_memcpy memcpy -#define ft_memmove memmove -#define ft_memset memset -#define ft_strcat strcat -#define ft_strcmp strcmp -#define ft_strcpy strcpy -#define ft_strlen strlen -#define ft_strncmp strncmp -#define ft_strncpy strncpy -#define ft_strrchr strrchr -#define ft_strstr strstr - - - /**********************************************************************/ - /* */ - /* file handling */ - /* */ - /**********************************************************************/ - - -#include <stdio.h> - -#define FT_FILE FILE -#define ft_fclose fclose -#define ft_fopen fopen -#define ft_fread fread -#define ft_fseek fseek -#define ft_ftell ftell -#define ft_sprintf sprintf - - - /**********************************************************************/ - /* */ - /* sorting */ - /* */ - /**********************************************************************/ - - -#include <stdlib.h> - -#define ft_qsort qsort - - - /**********************************************************************/ - /* */ - /* memory allocation */ - /* */ - /**********************************************************************/ - - -#define ft_scalloc calloc -#define ft_sfree free -#define ft_smalloc malloc -#define ft_srealloc realloc - - - /**********************************************************************/ - /* */ - /* miscellaneous */ - /* */ - /**********************************************************************/ - - -#define ft_atol atol -#define ft_labs labs - - - /**********************************************************************/ - /* */ - /* execution control */ - /* */ - /**********************************************************************/ - - -#include <setjmp.h> - -#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */ - /* jmp_buf is defined as a macro */ - /* on certain platforms */ - -#define ft_longjmp longjmp -#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */ - - - /* the following is only used for debugging purposes, i.e., if */ - /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */ - -#include <stdarg.h> - - -#endif /* __FTSTDLIB_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/freetype.h b/thirdparty/include/freetype/freetype.h deleted file mode 100644 index f7e340791..000000000 --- a/thirdparty/include/freetype/freetype.h +++ /dev/null @@ -1,4076 +0,0 @@ -/***************************************************************************/ -/* */ -/* freetype.h */ -/* */ -/* FreeType high-level API and common types (specification only). */ -/* */ -/* Copyright 1996-2014 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FREETYPE_H__ -#define __FREETYPE_H__ - - -#ifndef FT_FREETYPE_H -#error "`ft2build.h' hasn't been included yet!" -#error "Please always use macros to include FreeType header files." -#error "Example:" -#error " #include <freetype/ft2build.h>" -#error " #include FT_FREETYPE_H" -#endif - - -#include <freetype/ft2build.h> -#include FT_CONFIG_CONFIG_H -#include FT_TYPES_H -#include FT_ERRORS_H - - -FT_BEGIN_HEADER - - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* header_inclusion */ - /* */ - /* <Title> */ - /* FreeType's header inclusion scheme */ - /* */ - /* <Abstract> */ - /* How client applications should include FreeType header files. */ - /* */ - /* <Description> */ - /* To be as flexible as possible (and for historical reasons), */ - /* FreeType uses a very special inclusion scheme to load header */ - /* files, for example */ - /* */ - /* { */ - /* #include <freetype/ft2build.h> */ - /* */ - /* #include FT_FREETYPE_H */ - /* #include FT_OUTLINE_H */ - /* } */ - /* */ - /* A compiler and its preprocessor only needs an include path to find */ - /* the file `ft2build.h'; the exact locations and names of the other */ - /* FreeType header files are hidden by preprocessor macro names, */ - /* loaded by `ft2build.h'. The API documentation always gives the */ - /* header macro name needed for a particular function. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* user_allocation */ - /* */ - /* <Title> */ - /* User allocation */ - /* */ - /* <Abstract> */ - /* How client applications should allocate FreeType data structures. */ - /* */ - /* <Description> */ - /* FreeType assumes that structures allocated by the user and passed */ - /* as arguments are zeroed out except for the actual data. In other */ - /* words, it is recommended to use `calloc' (or variants of it) */ - /* instead of `malloc' for allocation. */ - /* */ - /*************************************************************************/ - - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* B A S I C T Y P E S */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* base_interface */ - /* */ - /* <Title> */ - /* Base Interface */ - /* */ - /* <Abstract> */ - /* The FreeType~2 base font interface. */ - /* */ - /* <Description> */ - /* This section describes the public high-level API of FreeType~2. */ - /* */ - /* <Order> */ - /* FT_Library */ - /* FT_Face */ - /* FT_Size */ - /* FT_GlyphSlot */ - /* FT_CharMap */ - /* FT_Encoding */ - /* */ - /* FT_FaceRec */ - /* */ - /* FT_FACE_FLAG_SCALABLE */ - /* FT_FACE_FLAG_FIXED_SIZES */ - /* FT_FACE_FLAG_FIXED_WIDTH */ - /* FT_FACE_FLAG_HORIZONTAL */ - /* FT_FACE_FLAG_VERTICAL */ - /* FT_FACE_FLAG_COLOR */ - /* FT_FACE_FLAG_SFNT */ - /* FT_FACE_FLAG_CID_KEYED */ - /* FT_FACE_FLAG_TRICKY */ - /* FT_FACE_FLAG_KERNING */ - /* FT_FACE_FLAG_MULTIPLE_MASTERS */ - /* FT_FACE_FLAG_GLYPH_NAMES */ - /* FT_FACE_FLAG_EXTERNAL_STREAM */ - /* FT_FACE_FLAG_FAST_GLYPHS */ - /* FT_FACE_FLAG_HINTER */ - /* */ - /* FT_STYLE_FLAG_BOLD */ - /* FT_STYLE_FLAG_ITALIC */ - /* */ - /* FT_SizeRec */ - /* FT_Size_Metrics */ - /* */ - /* FT_GlyphSlotRec */ - /* FT_Glyph_Metrics */ - /* FT_SubGlyph */ - /* */ - /* FT_Bitmap_Size */ - /* */ - /* FT_Init_FreeType */ - /* FT_Done_FreeType */ - /* */ - /* FT_New_Face */ - /* FT_Done_Face */ - /* FT_New_Memory_Face */ - /* FT_Open_Face */ - /* FT_Open_Args */ - /* FT_Parameter */ - /* FT_Attach_File */ - /* FT_Attach_Stream */ - /* */ - /* FT_Set_Char_Size */ - /* FT_Set_Pixel_Sizes */ - /* FT_Request_Size */ - /* FT_Select_Size */ - /* FT_Size_Request_Type */ - /* FT_Size_Request */ - /* FT_Set_Transform */ - /* FT_Load_Glyph */ - /* FT_Get_Char_Index */ - /* FT_Get_Name_Index */ - /* FT_Load_Char */ - /* */ - /* FT_OPEN_MEMORY */ - /* FT_OPEN_STREAM */ - /* FT_OPEN_PATHNAME */ - /* FT_OPEN_DRIVER */ - /* FT_OPEN_PARAMS */ - /* */ - /* FT_LOAD_DEFAULT */ - /* FT_LOAD_RENDER */ - /* FT_LOAD_MONOCHROME */ - /* FT_LOAD_LINEAR_DESIGN */ - /* FT_LOAD_NO_SCALE */ - /* FT_LOAD_NO_HINTING */ - /* FT_LOAD_NO_BITMAP */ - /* FT_LOAD_CROP_BITMAP */ - /* */ - /* FT_LOAD_VERTICAL_LAYOUT */ - /* FT_LOAD_IGNORE_TRANSFORM */ - /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */ - /* FT_LOAD_FORCE_AUTOHINT */ - /* FT_LOAD_NO_RECURSE */ - /* FT_LOAD_PEDANTIC */ - /* */ - /* FT_LOAD_TARGET_NORMAL */ - /* FT_LOAD_TARGET_LIGHT */ - /* FT_LOAD_TARGET_MONO */ - /* FT_LOAD_TARGET_LCD */ - /* FT_LOAD_TARGET_LCD_V */ - /* */ - /* FT_Render_Glyph */ - /* FT_Render_Mode */ - /* FT_Get_Kerning */ - /* FT_Kerning_Mode */ - /* FT_Get_Track_Kerning */ - /* FT_Get_Glyph_Name */ - /* FT_Get_Postscript_Name */ - /* */ - /* FT_CharMapRec */ - /* FT_Select_Charmap */ - /* FT_Set_Charmap */ - /* FT_Get_Charmap_Index */ - /* */ - /* FT_FSTYPE_INSTALLABLE_EMBEDDING */ - /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING */ - /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING */ - /* FT_FSTYPE_EDITABLE_EMBEDDING */ - /* FT_FSTYPE_NO_SUBSETTING */ - /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY */ - /* */ - /* FT_Get_FSType_Flags */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Glyph_Metrics */ - /* */ - /* <Description> */ - /* A structure used to model the metrics of a single glyph. The */ - /* values are expressed in 26.6 fractional pixel format; if the flag */ - /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */ - /* are expressed in font units instead. */ - /* */ - /* <Fields> */ - /* width :: */ - /* The glyph's width. */ - /* */ - /* height :: */ - /* The glyph's height. */ - /* */ - /* horiBearingX :: */ - /* Left side bearing for horizontal layout. */ - /* */ - /* horiBearingY :: */ - /* Top side bearing for horizontal layout. */ - /* */ - /* horiAdvance :: */ - /* Advance width for horizontal layout. */ - /* */ - /* vertBearingX :: */ - /* Left side bearing for vertical layout. */ - /* */ - /* vertBearingY :: */ - /* Top side bearing for vertical layout. Larger positive values */ - /* mean further below the vertical glyph origin. */ - /* */ - /* vertAdvance :: */ - /* Advance height for vertical layout. Positive values mean the */ - /* glyph has a positive advance downward. */ - /* */ - /* <Note> */ - /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */ - /* dimensions of the hinted glyph (in case hinting is applicable). */ - /* */ - /* Stroking a glyph with an outside border does not increase */ - /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */ - /* values to account for the added width and height. */ - /* */ - typedef struct FT_Glyph_Metrics_ - { - FT_Pos width; - FT_Pos height; - - FT_Pos horiBearingX; - FT_Pos horiBearingY; - FT_Pos horiAdvance; - - FT_Pos vertBearingX; - FT_Pos vertBearingY; - FT_Pos vertAdvance; - - } FT_Glyph_Metrics; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Bitmap_Size */ - /* */ - /* <Description> */ - /* This structure models the metrics of a bitmap strike (i.e., a set */ - /* of glyphs for a given point size and resolution) in a bitmap font. */ - /* It is used for the `available_sizes' field of @FT_Face. */ - /* */ - /* <Fields> */ - /* height :: The vertical distance, in pixels, between two */ - /* consecutive baselines. It is always positive. */ - /* */ - /* width :: The average width, in pixels, of all glyphs in the */ - /* strike. */ - /* */ - /* size :: The nominal size of the strike in 26.6 fractional */ - /* points. This field is not very useful. */ - /* */ - /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */ - /* pixels. */ - /* */ - /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */ - /* pixels. */ - /* */ - /* <Note> */ - /* Windows FNT: */ - /* The nominal size given in a FNT font is not reliable. Thus when */ - /* the driver finds it incorrect, it sets `size' to some calculated */ - /* values and sets `x_ppem' and `y_ppem' to the pixel width and */ - /* height given in the font, respectively. */ - /* */ - /* TrueType embedded bitmaps: */ - /* `size', `width', and `height' values are not contained in the */ - /* bitmap strike itself. They are computed from the global font */ - /* parameters. */ - /* */ - typedef struct FT_Bitmap_Size_ - { - FT_Short height; - FT_Short width; - - FT_Pos size; - - FT_Pos x_ppem; - FT_Pos y_ppem; - - } FT_Bitmap_Size; - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* O B J E C T C L A S S E S */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Library */ - /* */ - /* <Description> */ - /* A handle to a FreeType library instance. Each `library' is */ - /* completely independent from the others; it is the `root' of a set */ - /* of objects like fonts, faces, sizes, etc. */ - /* */ - /* It also embeds a memory manager (see @FT_Memory), as well as a */ - /* scan-line converter object (see @FT_Raster). */ - /* */ - /* In multi-threaded applications, make sure that the same FT_Library */ - /* object or any of its children doesn't get accessed in parallel. */ - /* */ - /* <Note> */ - /* Library objects are normally created by @FT_Init_FreeType, and */ - /* destroyed with @FT_Done_FreeType. If you need reference-counting */ - /* (cf. @FT_Reference_Library), use @FT_New_Library and */ - /* @FT_Done_Library. */ - /* */ - typedef struct FT_LibraryRec_ *FT_Library; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Module */ - /* */ - /* <Description> */ - /* A handle to a given FreeType module object. Each module can be a */ - /* font driver, a renderer, or anything else that provides services */ - /* to the formers. */ - /* */ - typedef struct FT_ModuleRec_* FT_Module; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Driver */ - /* */ - /* <Description> */ - /* A handle to a given FreeType font driver object. Each font driver */ - /* is a special module capable of creating faces from font files. */ - /* */ - typedef struct FT_DriverRec_* FT_Driver; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Renderer */ - /* */ - /* <Description> */ - /* A handle to a given FreeType renderer. A renderer is a special */ - /* module in charge of converting a glyph image to a bitmap, when */ - /* necessary. Each renderer supports a given glyph image format, and */ - /* one or more target surface depths. */ - /* */ - typedef struct FT_RendererRec_* FT_Renderer; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Face */ - /* */ - /* <Description> */ - /* A handle to a given typographic face object. A face object models */ - /* a given typeface, in a given style. */ - /* */ - /* <Note> */ - /* Each face object also owns a single @FT_GlyphSlot object, as well */ - /* as one or more @FT_Size objects. */ - /* */ - /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */ - /* a given filepathname or a custom input stream. */ - /* */ - /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */ - /* */ - /* <Also> */ - /* See @FT_FaceRec for the publicly accessible fields of a given face */ - /* object. */ - /* */ - typedef struct FT_FaceRec_* FT_Face; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Size */ - /* */ - /* <Description> */ - /* A handle to an object used to model a face scaled to a given */ - /* character size. */ - /* */ - /* <Note> */ - /* Each @FT_Face has an _active_ @FT_Size object that is used by */ - /* functions like @FT_Load_Glyph to determine the scaling */ - /* transformation that in turn is used to load and hint glyphs and */ - /* metrics. */ - /* */ - /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */ - /* @FT_Request_Size or even @FT_Select_Size to change the content */ - /* (i.e., the scaling values) of the active @FT_Size. */ - /* */ - /* You can use @FT_New_Size to create additional size objects for a */ - /* given @FT_Face, but they won't be used by other functions until */ - /* you activate it through @FT_Activate_Size. Only one size can be */ - /* activated at any given time per face. */ - /* */ - /* <Also> */ - /* See @FT_SizeRec for the publicly accessible fields of a given size */ - /* object. */ - /* */ - typedef struct FT_SizeRec_* FT_Size; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to a given `glyph slot'. A slot is a container where it */ - /* is possible to load any of the glyphs contained in its parent */ - /* face. */ - /* */ - /* In other words, each time you call @FT_Load_Glyph or */ - /* @FT_Load_Char, the slot's content is erased by the new glyph data, */ - /* i.e., the glyph's metrics, its image (bitmap or outline), and */ - /* other control information. */ - /* */ - /* <Also> */ - /* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */ - /* */ - typedef struct FT_GlyphSlotRec_* FT_GlyphSlot; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_CharMap */ - /* */ - /* <Description> */ - /* A handle to a given character map. A charmap is used to translate */ - /* character codes in a given encoding into glyph indexes for its */ - /* parent's face. Some font formats may provide several charmaps per */ - /* font. */ - /* */ - /* Each face object owns zero or more charmaps, but only one of them */ - /* can be `active' and used by @FT_Get_Char_Index or @FT_Load_Char. */ - /* */ - /* The list of available charmaps in a face is available through the */ - /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */ - /* */ - /* The currently active charmap is available as `face->charmap'. */ - /* You should call @FT_Set_Charmap to change it. */ - /* */ - /* <Note> */ - /* When a new face is created (either through @FT_New_Face or */ - /* @FT_Open_Face), the library looks for a Unicode charmap within */ - /* the list and automatically activates it. */ - /* */ - /* <Also> */ - /* See @FT_CharMapRec for the publicly accessible fields of a given */ - /* character map. */ - /* */ - typedef struct FT_CharMapRec_* FT_CharMap; - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_ENC_TAG */ - /* */ - /* <Description> */ - /* This macro converts four-letter tags into an unsigned long. It is */ - /* used to define `encoding' identifiers (see @FT_Encoding). */ - /* */ - /* <Note> */ - /* Since many 16-bit compilers don't like 32-bit enumerations, you */ - /* should redefine this macro in case of problems to something like */ - /* this: */ - /* */ - /* { */ - /* #define FT_ENC_TAG( value, a, b, c, d ) value */ - /* } */ - /* */ - /* to get a simple enumeration without assigning special numbers. */ - /* */ - -#ifndef FT_ENC_TAG -#define FT_ENC_TAG( value, a, b, c, d ) \ - value = ( ( (FT_UInt32)(a) << 24 ) | \ - ( (FT_UInt32)(b) << 16 ) | \ - ( (FT_UInt32)(c) << 8 ) | \ - (FT_UInt32)(d) ) - -#endif /* FT_ENC_TAG */ - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Encoding */ - /* */ - /* <Description> */ - /* An enumeration used to specify character sets supported by */ - /* charmaps. Used in the @FT_Select_Charmap API function. */ - /* */ - /* <Note> */ - /* Despite the name, this enumeration lists specific character */ - /* repertories (i.e., charsets), and not text encoding methods (e.g., */ - /* UTF-8, UTF-16, etc.). */ - /* */ - /* Other encodings might be defined in the future. */ - /* */ - /* <Values> */ - /* FT_ENCODING_NONE :: */ - /* The encoding value~0 is reserved. */ - /* */ - /* FT_ENCODING_UNICODE :: */ - /* Corresponds to the Unicode character set. This value covers */ - /* all versions of the Unicode repertoire, including ASCII and */ - /* Latin-1. Most fonts include a Unicode charmap, but not all */ - /* of them. */ - /* */ - /* For example, if you want to access Unicode value U+1F028 (and */ - /* the font contains it), use value 0x1F028 as the input value for */ - /* @FT_Get_Char_Index. */ - /* */ - /* FT_ENCODING_MS_SYMBOL :: */ - /* Corresponds to the Microsoft Symbol encoding, used to encode */ - /* mathematical symbols in the 32..255 character code range. For */ - /* more information, see */ - /* `http://www.kostis.net/charsets/symbol.htm'. */ - /* */ - /* FT_ENCODING_SJIS :: */ - /* Corresponds to Japanese SJIS encoding. More info at */ - /* at `http://en.wikipedia.org/wiki/Shift_JIS'. */ - /* See note on multi-byte encodings below. */ - /* */ - /* FT_ENCODING_GB2312 :: */ - /* Corresponds to an encoding system for Simplified Chinese as used */ - /* used in mainland China. */ - /* */ - /* FT_ENCODING_BIG5 :: */ - /* Corresponds to an encoding system for Traditional Chinese as */ - /* used in Taiwan and Hong Kong. */ - /* */ - /* FT_ENCODING_WANSUNG :: */ - /* Corresponds to the Korean encoding system known as Wansung. */ - /* For more information see */ - /* `http://msdn.microsoft.com/en-US/goglobal/cc305154'. */ - /* */ - /* FT_ENCODING_JOHAB :: */ - /* The Korean standard character set (KS~C 5601-1992), which */ - /* corresponds to MS Windows code page 1361. This character set */ - /* includes all possible Hangeul character combinations. */ - /* */ - /* FT_ENCODING_ADOBE_LATIN_1 :: */ - /* Corresponds to a Latin-1 encoding as defined in a Type~1 */ - /* PostScript font. It is limited to 256 character codes. */ - /* */ - /* FT_ENCODING_ADOBE_STANDARD :: */ - /* Corresponds to the Adobe Standard encoding, as found in Type~1, */ - /* CFF, and OpenType/CFF fonts. It is limited to 256 character */ - /* codes. */ - /* */ - /* FT_ENCODING_ADOBE_EXPERT :: */ - /* Corresponds to the Adobe Expert encoding, as found in Type~1, */ - /* CFF, and OpenType/CFF fonts. It is limited to 256 character */ - /* codes. */ - /* */ - /* FT_ENCODING_ADOBE_CUSTOM :: */ - /* Corresponds to a custom encoding, as found in Type~1, CFF, and */ - /* OpenType/CFF fonts. It is limited to 256 character codes. */ - /* */ - /* FT_ENCODING_APPLE_ROMAN :: */ - /* Corresponds to the 8-bit Apple roman encoding. Many TrueType */ - /* and OpenType fonts contain a charmap for this encoding, since */ - /* older versions of Mac OS are able to use it. */ - /* */ - /* FT_ENCODING_OLD_LATIN_2 :: */ - /* This value is deprecated and was never used nor reported by */ - /* FreeType. Don't use or test for it. */ - /* */ - /* FT_ENCODING_MS_SJIS :: */ - /* Same as FT_ENCODING_SJIS. Deprecated. */ - /* */ - /* FT_ENCODING_MS_GB2312 :: */ - /* Same as FT_ENCODING_GB2312. Deprecated. */ - /* */ - /* FT_ENCODING_MS_BIG5 :: */ - /* Same as FT_ENCODING_BIG5. Deprecated. */ - /* */ - /* FT_ENCODING_MS_WANSUNG :: */ - /* Same as FT_ENCODING_WANSUNG. Deprecated. */ - /* */ - /* FT_ENCODING_MS_JOHAB :: */ - /* Same as FT_ENCODING_JOHAB. Deprecated. */ - /* */ - /* <Note> */ - /* By default, FreeType automatically synthesizes a Unicode charmap */ - /* for PostScript fonts, using their glyph names dictionaries. */ - /* However, it also reports the encodings defined explicitly in the */ - /* font file, for the cases when they are needed, with the Adobe */ - /* values as well. */ - /* */ - /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */ - /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */ - /* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */ - /* which encoding is really present. If, for example, the */ - /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */ - /* the font is encoded in KOI8-R. */ - /* */ - /* FT_ENCODING_NONE is always set (with a single exception) by the */ - /* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */ - /* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */ - /* which encoding is really present. For example, */ - /* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */ - /* Russian). */ - /* */ - /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */ - /* and `encoding_id' is not @TT_MAC_ID_ROMAN (otherwise it is set to */ - /* FT_ENCODING_APPLE_ROMAN). */ - /* */ - /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */ - /* @FT_Get_CMap_Language_ID to query the Mac language ID that may */ - /* be needed to be able to distinguish Apple encoding variants. See */ - /* */ - /* http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt */ - /* */ - /* to get an idea how to do that. Basically, if the language ID */ - /* is~0, don't use it, otherwise subtract 1 from the language ID. */ - /* Then examine `encoding_id'. If, for example, `encoding_id' is */ - /* @TT_MAC_ID_ROMAN and the language ID (minus~1) is */ - /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */ - /* @TT_MAC_ID_ARABIC with `TT_MAC_LANGID_FARSI' means the Farsi */ - /* variant the Arabic encoding. */ - /* */ - typedef enum FT_Encoding_ - { - FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ), - - FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ), - FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ), - - FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ), - FT_ENC_TAG( FT_ENCODING_GB2312, 'g', 'b', ' ', ' ' ), - FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ), - FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ), - FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ), - - /* for backwards compatibility */ - FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS, - FT_ENCODING_MS_GB2312 = FT_ENCODING_GB2312, - FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5, - FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG, - FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB, - - FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ), - FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ), - FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ), - FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ), - - FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ), - - FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' ) - - } FT_Encoding; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* ft_encoding_xxx */ - /* */ - /* <Description> */ - /* These constants are deprecated; use the corresponding @FT_Encoding */ - /* values instead. */ - /* */ -#define ft_encoding_none FT_ENCODING_NONE -#define ft_encoding_unicode FT_ENCODING_UNICODE -#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL -#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1 -#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2 -#define ft_encoding_sjis FT_ENCODING_SJIS -#define ft_encoding_gb2312 FT_ENCODING_GB2312 -#define ft_encoding_big5 FT_ENCODING_BIG5 -#define ft_encoding_wansung FT_ENCODING_WANSUNG -#define ft_encoding_johab FT_ENCODING_JOHAB - -#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD -#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT -#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM -#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_CharMapRec */ - /* */ - /* <Description> */ - /* The base charmap structure. */ - /* */ - /* <Fields> */ - /* face :: A handle to the parent face object. */ - /* */ - /* encoding :: An @FT_Encoding tag identifying the charmap. Use */ - /* this with @FT_Select_Charmap. */ - /* */ - /* platform_id :: An ID number describing the platform for the */ - /* following encoding ID. This comes directly from */ - /* the TrueType specification and should be emulated */ - /* for other formats. */ - /* */ - /* encoding_id :: A platform specific encoding number. This also */ - /* comes from the TrueType specification and should be */ - /* emulated similarly. */ - /* */ - typedef struct FT_CharMapRec_ - { - FT_Face face; - FT_Encoding encoding; - FT_UShort platform_id; - FT_UShort encoding_id; - - } FT_CharMapRec; - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* B A S E O B J E C T C L A S S E S */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Face_Internal */ - /* */ - /* <Description> */ - /* An opaque handle to an `FT_Face_InternalRec' structure, used to */ - /* model private data of a given @FT_Face object. */ - /* */ - /* This structure might change between releases of FreeType~2 and is */ - /* not generally available to client applications. */ - /* */ - typedef struct FT_Face_InternalRec_* FT_Face_Internal; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_FaceRec */ - /* */ - /* <Description> */ - /* FreeType root face class structure. A face object models a */ - /* typeface in a font file. */ - /* */ - /* <Fields> */ - /* num_faces :: The number of faces in the font file. Some */ - /* font formats can have multiple faces in */ - /* a font file. */ - /* */ - /* face_index :: The index of the face in the font file. It */ - /* is set to~0 if there is only one face in */ - /* the font file. */ - /* */ - /* face_flags :: A set of bit flags that give important */ - /* information about the face; see */ - /* @FT_FACE_FLAG_XXX for the details. */ - /* */ - /* style_flags :: A set of bit flags indicating the style of */ - /* the face; see @FT_STYLE_FLAG_XXX for the */ - /* details. */ - /* */ - /* num_glyphs :: The number of glyphs in the face. If the */ - /* face is scalable and has sbits (see */ - /* `num_fixed_sizes'), it is set to the number */ - /* of outline glyphs. */ - /* */ - /* For CID-keyed fonts, this value gives the */ - /* highest CID used in the font. */ - /* */ - /* family_name :: The face's family name. This is an ASCII */ - /* string, usually in English, that describes */ - /* the typeface's family (like `Times New */ - /* Roman', `Bodoni', `Garamond', etc). This */ - /* is a least common denominator used to list */ - /* fonts. Some formats (TrueType & OpenType) */ - /* provide localized and Unicode versions of */ - /* this string. Applications should use the */ - /* format specific interface to access them. */ - /* Can be NULL (e.g., in fonts embedded in a */ - /* PDF file). */ - /* */ - /* style_name :: The face's style name. This is an ASCII */ - /* string, usually in English, that describes */ - /* the typeface's style (like `Italic', */ - /* `Bold', `Condensed', etc). Not all font */ - /* formats provide a style name, so this field */ - /* is optional, and can be set to NULL. As */ - /* for `family_name', some formats provide */ - /* localized and Unicode versions of this */ - /* string. Applications should use the format */ - /* specific interface to access them. */ - /* */ - /* num_fixed_sizes :: The number of bitmap strikes in the face. */ - /* Even if the face is scalable, there might */ - /* still be bitmap strikes, which are called */ - /* `sbits' in that case. */ - /* */ - /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */ - /* strikes in the face. It is set to NULL if */ - /* there is no bitmap strike. */ - /* */ - /* num_charmaps :: The number of charmaps in the face. */ - /* */ - /* charmaps :: An array of the charmaps of the face. */ - /* */ - /* generic :: A field reserved for client uses. See the */ - /* @FT_Generic type description. */ - /* */ - /* bbox :: The font bounding box. Coordinates are */ - /* expressed in font units (see */ - /* `units_per_EM'). The box is large enough */ - /* to contain any glyph from the font. Thus, */ - /* `bbox.yMax' can be seen as the `maximum */ - /* ascender', and `bbox.yMin' as the `minimum */ - /* descender'. Only relevant for scalable */ - /* formats. */ - /* */ - /* Note that the bounding box might be off by */ - /* (at least) one pixel for hinted fonts. See */ - /* @FT_Size_Metrics for further discussion. */ - /* */ - /* units_per_EM :: The number of font units per EM square for */ - /* this face. This is typically 2048 for */ - /* TrueType fonts, and 1000 for Type~1 fonts. */ - /* Only relevant for scalable formats. */ - /* */ - /* ascender :: The typographic ascender of the face, */ - /* expressed in font units. For font formats */ - /* not having this information, it is set to */ - /* `bbox.yMax'. Only relevant for scalable */ - /* formats. */ - /* */ - /* descender :: The typographic descender of the face, */ - /* expressed in font units. For font formats */ - /* not having this information, it is set to */ - /* `bbox.yMin'. Note that this field is */ - /* usually negative. Only relevant for */ - /* scalable formats. */ - /* */ - /* height :: This value is the vertical distance */ - /* between two consecutive baselines, */ - /* expressed in font units. It is always */ - /* positive. Only relevant for scalable */ - /* formats. */ - /* */ - /* If you want the global glyph height, use */ - /* `ascender - descender'. */ - /* */ - /* max_advance_width :: The maximum advance width, in font units, */ - /* for all glyphs in this face. This can be */ - /* used to make word wrapping computations */ - /* faster. Only relevant for scalable */ - /* formats. */ - /* */ - /* max_advance_height :: The maximum advance height, in font units, */ - /* for all glyphs in this face. This is only */ - /* relevant for vertical layouts, and is set */ - /* to `height' for fonts that do not provide */ - /* vertical metrics. Only relevant for */ - /* scalable formats. */ - /* */ - /* underline_position :: The position, in font units, of the */ - /* underline line for this face. It is the */ - /* center of the underlining stem. Only */ - /* relevant for scalable formats. */ - /* */ - /* underline_thickness :: The thickness, in font units, of the */ - /* underline for this face. Only relevant for */ - /* scalable formats. */ - /* */ - /* glyph :: The face's associated glyph slot(s). */ - /* */ - /* size :: The current active size for this face. */ - /* */ - /* charmap :: The current active charmap for this face. */ - /* */ - /* <Note> */ - /* Fields may be changed after a call to @FT_Attach_File or */ - /* @FT_Attach_Stream. */ - /* */ - typedef struct FT_FaceRec_ - { - FT_Long num_faces; - FT_Long face_index; - - FT_Long face_flags; - FT_Long style_flags; - - FT_Long num_glyphs; - - FT_String* family_name; - FT_String* style_name; - - FT_Int num_fixed_sizes; - FT_Bitmap_Size* available_sizes; - - FT_Int num_charmaps; - FT_CharMap* charmaps; - - FT_Generic generic; - - /*# The following member variables (down to `underline_thickness') */ - /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */ - /*# for bitmap fonts. */ - FT_BBox bbox; - - FT_UShort units_per_EM; - FT_Short ascender; - FT_Short descender; - FT_Short height; - - FT_Short max_advance_width; - FT_Short max_advance_height; - - FT_Short underline_position; - FT_Short underline_thickness; - - FT_GlyphSlot glyph; - FT_Size size; - FT_CharMap charmap; - - /*@private begin */ - - FT_Driver driver; - FT_Memory memory; - FT_Stream stream; - - FT_ListRec sizes_list; - - FT_Generic autohint; /* face-specific auto-hinter data */ - void* extensions; /* unused */ - - FT_Face_Internal internal; - - /*@private end */ - - } FT_FaceRec; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_FACE_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags used in the `face_flags' field of the */ - /* @FT_FaceRec structure. They inform client applications of */ - /* properties of the corresponding face. */ - /* */ - /* <Values> */ - /* FT_FACE_FLAG_SCALABLE :: */ - /* Indicates that the face contains outline glyphs. This doesn't */ - /* prevent bitmap strikes, i.e., a face can have both this and */ - /* and @FT_FACE_FLAG_FIXED_SIZES set. */ - /* */ - /* FT_FACE_FLAG_FIXED_SIZES :: */ - /* Indicates that the face contains bitmap strikes. See also the */ - /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */ - /* */ - /* FT_FACE_FLAG_FIXED_WIDTH :: */ - /* Indicates that the face contains fixed-width characters (like */ - /* Courier, Lucido, MonoType, etc.). */ - /* */ - /* FT_FACE_FLAG_SFNT :: */ - /* Indicates that the face uses the `sfnt' storage scheme. For */ - /* now, this means TrueType and OpenType. */ - /* */ - /* FT_FACE_FLAG_HORIZONTAL :: */ - /* Indicates that the face contains horizontal glyph metrics. This */ - /* should be set for all common formats. */ - /* */ - /* FT_FACE_FLAG_VERTICAL :: */ - /* Indicates that the face contains vertical glyph metrics. This */ - /* is only available in some formats, not all of them. */ - /* */ - /* FT_FACE_FLAG_KERNING :: */ - /* Indicates that the face contains kerning information. If set, */ - /* the kerning distance can be retrieved through the function */ - /* @FT_Get_Kerning. Otherwise the function always return the */ - /* vector (0,0). Note that FreeType doesn't handle kerning data */ - /* from the `GPOS' table (as present in some OpenType fonts). */ - /* */ - /* FT_FACE_FLAG_FAST_GLYPHS :: */ - /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */ - /* */ - /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */ - /* Indicates that the font contains multiple masters and is capable */ - /* of interpolating between them. See the multiple-masters */ - /* specific API for details. */ - /* */ - /* FT_FACE_FLAG_GLYPH_NAMES :: */ - /* Indicates that the font contains glyph names that can be */ - /* retrieved through @FT_Get_Glyph_Name. Note that some TrueType */ - /* fonts contain broken glyph name tables. Use the function */ - /* @FT_Has_PS_Glyph_Names when needed. */ - /* */ - /* FT_FACE_FLAG_EXTERNAL_STREAM :: */ - /* Used internally by FreeType to indicate that a face's stream was */ - /* provided by the client application and should not be destroyed */ - /* when @FT_Done_Face is called. Don't read or test this flag. */ - /* */ - /* FT_FACE_FLAG_HINTER :: */ - /* Set if the font driver has a hinting machine of its own. For */ - /* example, with TrueType fonts, it makes sense to use data from */ - /* the SFNT `gasp' table only if the native TrueType hinting engine */ - /* (with the bytecode interpreter) is available and active. */ - /* */ - /* FT_FACE_FLAG_CID_KEYED :: */ - /* Set if the font is CID-keyed. In that case, the font is not */ - /* accessed by glyph indices but by CID values. For subsetted */ - /* CID-keyed fonts this has the consequence that not all index */ - /* values are a valid argument to FT_Load_Glyph. Only the CID */ - /* values for which corresponding glyphs in the subsetted font */ - /* exist make FT_Load_Glyph return successfully; in all other cases */ - /* you get an `FT_Err_Invalid_Argument' error. */ - /* */ - /* Note that CID-keyed fonts that are in an SFNT wrapper don't */ - /* have this flag set since the glyphs are accessed in the normal */ - /* way (using contiguous indices); the `CID-ness' isn't visible to */ - /* the application. */ - /* */ - /* FT_FACE_FLAG_TRICKY :: */ - /* Set if the font is `tricky', this is, it always needs the */ - /* font format's native hinting engine to get a reasonable result. */ - /* A typical example is the Chinese font `mingli.ttf' that uses */ - /* TrueType bytecode instructions to move and scale all of its */ - /* subglyphs. */ - /* */ - /* It is not possible to autohint such fonts using */ - /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */ - /* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */ - /* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */ - /* probably never want this except for demonstration purposes. */ - /* */ - /* Currently, there are about a dozen TrueType fonts in the list of */ - /* tricky fonts; they are hard-coded in file `ttobjs.c'. */ - /* */ - /* FT_FACE_FLAG_COLOR :: */ - /* Set if the font has color glyph tables. To access color glyphs */ - /* use @FT_LOAD_COLOR. */ - /* */ -#define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) -#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) -#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 ) -#define FT_FACE_FLAG_SFNT ( 1L << 3 ) -#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 ) -#define FT_FACE_FLAG_VERTICAL ( 1L << 5 ) -#define FT_FACE_FLAG_KERNING ( 1L << 6 ) -#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 ) -#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 ) -#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 ) -#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 ) -#define FT_FACE_FLAG_HINTER ( 1L << 11 ) -#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 ) -#define FT_FACE_FLAG_TRICKY ( 1L << 13 ) -#define FT_FACE_FLAG_COLOR ( 1L << 14 ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_HORIZONTAL( face ) - * - * @description: - * A macro that returns true whenever a face object contains - * horizontal metrics (this is true for all font formats though). - * - * @also: - * @FT_HAS_VERTICAL can be used to check for vertical metrics. - * - */ -#define FT_HAS_HORIZONTAL( face ) \ - ( face->face_flags & FT_FACE_FLAG_HORIZONTAL ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_VERTICAL( face ) - * - * @description: - * A macro that returns true whenever a face object contains real - * vertical metrics (and not only synthesized ones). - * - */ -#define FT_HAS_VERTICAL( face ) \ - ( face->face_flags & FT_FACE_FLAG_VERTICAL ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_KERNING( face ) - * - * @description: - * A macro that returns true whenever a face object contains kerning - * data that can be accessed with @FT_Get_Kerning. - * - */ -#define FT_HAS_KERNING( face ) \ - ( face->face_flags & FT_FACE_FLAG_KERNING ) - - - /************************************************************************* - * - * @macro: - * FT_IS_SCALABLE( face ) - * - * @description: - * A macro that returns true whenever a face object contains a scalable - * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, - * and PFR font formats. - * - */ -#define FT_IS_SCALABLE( face ) \ - ( face->face_flags & FT_FACE_FLAG_SCALABLE ) - - - /************************************************************************* - * - * @macro: - * FT_IS_SFNT( face ) - * - * @description: - * A macro that returns true whenever a face object contains a font - * whose format is based on the SFNT storage scheme. This usually - * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded - * bitmap fonts. - * - * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and - * @FT_TRUETYPE_TABLES_H are available. - * - */ -#define FT_IS_SFNT( face ) \ - ( face->face_flags & FT_FACE_FLAG_SFNT ) - - - /************************************************************************* - * - * @macro: - * FT_IS_FIXED_WIDTH( face ) - * - * @description: - * A macro that returns true whenever a face object contains a font face - * that contains fixed-width (or `monospace', `fixed-pitch', etc.) - * glyphs. - * - */ -#define FT_IS_FIXED_WIDTH( face ) \ - ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_FIXED_SIZES( face ) - * - * @description: - * A macro that returns true whenever a face object contains some - * embedded bitmaps. See the `available_sizes' field of the - * @FT_FaceRec structure. - * - */ -#define FT_HAS_FIXED_SIZES( face ) \ - ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_FAST_GLYPHS( face ) - * - * @description: - * Deprecated. - * - */ -#define FT_HAS_FAST_GLYPHS( face ) 0 - - - /************************************************************************* - * - * @macro: - * FT_HAS_GLYPH_NAMES( face ) - * - * @description: - * A macro that returns true whenever a face object contains some glyph - * names that can be accessed through @FT_Get_Glyph_Name. - * - */ -#define FT_HAS_GLYPH_NAMES( face ) \ - ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_MULTIPLE_MASTERS( face ) - * - * @description: - * A macro that returns true whenever a face object contains some - * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H - * are then available to choose the exact design you want. - * - */ -#define FT_HAS_MULTIPLE_MASTERS( face ) \ - ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) - - - /************************************************************************* - * - * @macro: - * FT_IS_CID_KEYED( face ) - * - * @description: - * A macro that returns true whenever a face object contains a CID-keyed - * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more - * details. - * - * If this macro is true, all functions defined in @FT_CID_H are - * available. - * - */ -#define FT_IS_CID_KEYED( face ) \ - ( face->face_flags & FT_FACE_FLAG_CID_KEYED ) - - - /************************************************************************* - * - * @macro: - * FT_IS_TRICKY( face ) - * - * @description: - * A macro that returns true whenever a face represents a `tricky' font. - * See the discussion of @FT_FACE_FLAG_TRICKY for more details. - * - */ -#define FT_IS_TRICKY( face ) \ - ( face->face_flags & FT_FACE_FLAG_TRICKY ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_COLOR( face ) - * - * @description: - * A macro that returns true whenever a face object contains - * tables for color glyphs. - * - */ -#define FT_HAS_COLOR( face ) \ - ( face->face_flags & FT_FACE_FLAG_COLOR ) - - - /*************************************************************************/ - /* */ - /* <Const> */ - /* FT_STYLE_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit-flags used to indicate the style of a given face. */ - /* These are used in the `style_flags' field of @FT_FaceRec. */ - /* */ - /* <Values> */ - /* FT_STYLE_FLAG_ITALIC :: */ - /* Indicates that a given face style is italic or oblique. */ - /* */ - /* FT_STYLE_FLAG_BOLD :: */ - /* Indicates that a given face is bold. */ - /* */ - /* <Note> */ - /* The style information as provided by FreeType is very basic. More */ - /* details are beyond the scope and should be done on a higher level */ - /* (for example, by analyzing various fields of the `OS/2' table in */ - /* SFNT based fonts). */ - /* */ -#define FT_STYLE_FLAG_ITALIC ( 1 << 0 ) -#define FT_STYLE_FLAG_BOLD ( 1 << 1 ) - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Size_Internal */ - /* */ - /* <Description> */ - /* An opaque handle to an `FT_Size_InternalRec' structure, used to */ - /* model private data of a given @FT_Size object. */ - /* */ - typedef struct FT_Size_InternalRec_* FT_Size_Internal; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_Metrics */ - /* */ - /* <Description> */ - /* The size metrics structure gives the metrics of a size object. */ - /* */ - /* <Fields> */ - /* x_ppem :: The width of the scaled EM square in pixels, hence */ - /* the term `ppem' (pixels per EM). It is also */ - /* referred to as `nominal width'. */ - /* */ - /* y_ppem :: The height of the scaled EM square in pixels, */ - /* hence the term `ppem' (pixels per EM). It is also */ - /* referred to as `nominal height'. */ - /* */ - /* x_scale :: A 16.16 fractional scaling value used to convert */ - /* horizontal metrics from font units to 26.6 */ - /* fractional pixels. Only relevant for scalable */ - /* font formats. */ - /* */ - /* y_scale :: A 16.16 fractional scaling value used to convert */ - /* vertical metrics from font units to 26.6 */ - /* fractional pixels. Only relevant for scalable */ - /* font formats. */ - /* */ - /* ascender :: The ascender in 26.6 fractional pixels. See */ - /* @FT_FaceRec for the details. */ - /* */ - /* descender :: The descender in 26.6 fractional pixels. See */ - /* @FT_FaceRec for the details. */ - /* */ - /* height :: The height in 26.6 fractional pixels. See */ - /* @FT_FaceRec for the details. */ - /* */ - /* max_advance :: The maximum advance width in 26.6 fractional */ - /* pixels. See @FT_FaceRec for the details. */ - /* */ - /* <Note> */ - /* The scaling values, if relevant, are determined first during a */ - /* size changing operation. The remaining fields are then set by the */ - /* driver. For scalable formats, they are usually set to scaled */ - /* values of the corresponding fields in @FT_FaceRec. */ - /* */ - /* Note that due to glyph hinting, these values might not be exact */ - /* for certain fonts. Thus they must be treated as unreliable */ - /* with an error margin of at least one pixel! */ - /* */ - /* Indeed, the only way to get the exact metrics is to render _all_ */ - /* glyphs. As this would be a definite performance hit, it is up to */ - /* client applications to perform such computations. */ - /* */ - /* The FT_Size_Metrics structure is valid for bitmap fonts also. */ - /* */ - typedef struct FT_Size_Metrics_ - { - FT_UShort x_ppem; /* horizontal pixels per EM */ - FT_UShort y_ppem; /* vertical pixels per EM */ - - FT_Fixed x_scale; /* scaling values used to convert font */ - FT_Fixed y_scale; /* units to 26.6 fractional pixels */ - - FT_Pos ascender; /* ascender in 26.6 frac. pixels */ - FT_Pos descender; /* descender in 26.6 frac. pixels */ - FT_Pos height; /* text height in 26.6 frac. pixels */ - FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */ - - } FT_Size_Metrics; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SizeRec */ - /* */ - /* <Description> */ - /* FreeType root size class structure. A size object models a face */ - /* object at a given size. */ - /* */ - /* <Fields> */ - /* face :: Handle to the parent face object. */ - /* */ - /* generic :: A typeless pointer, unused by the FreeType library or */ - /* any of its drivers. It can be used by client */ - /* applications to link their own data to each size */ - /* object. */ - /* */ - /* metrics :: Metrics for this size object. This field is read-only. */ - /* */ - typedef struct FT_SizeRec_ - { - FT_Face face; /* parent face object */ - FT_Generic generic; /* generic pointer for client uses */ - FT_Size_Metrics metrics; /* size metrics */ - FT_Size_Internal internal; - - } FT_SizeRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SubGlyph */ - /* */ - /* <Description> */ - /* The subglyph structure is an internal object used to describe */ - /* subglyphs (for example, in the case of composites). */ - /* */ - /* <Note> */ - /* The subglyph implementation is not part of the high-level API, */ - /* hence the forward structure declaration. */ - /* */ - /* You can however retrieve subglyph information with */ - /* @FT_Get_SubGlyph_Info. */ - /* */ - typedef struct FT_SubGlyphRec_* FT_SubGlyph; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Slot_Internal */ - /* */ - /* <Description> */ - /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */ - /* model private data of a given @FT_GlyphSlot object. */ - /* */ - typedef struct FT_Slot_InternalRec_* FT_Slot_Internal; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_GlyphSlotRec */ - /* */ - /* <Description> */ - /* FreeType root glyph slot class structure. A glyph slot is a */ - /* container where individual glyphs can be loaded, be they in */ - /* outline or bitmap format. */ - /* */ - /* <Fields> */ - /* library :: A handle to the FreeType library instance */ - /* this slot belongs to. */ - /* */ - /* face :: A handle to the parent face object. */ - /* */ - /* next :: In some cases (like some font tools), several */ - /* glyph slots per face object can be a good */ - /* thing. As this is rare, the glyph slots are */ - /* listed through a direct, single-linked list */ - /* using its `next' field. */ - /* */ - /* generic :: A typeless pointer unused by the FreeType */ - /* library or any of its drivers. It can be */ - /* used by client applications to link their own */ - /* data to each glyph slot object. */ - /* */ - /* metrics :: The metrics of the last loaded glyph in the */ - /* slot. The returned values depend on the last */ - /* load flags (see the @FT_Load_Glyph API */ - /* function) and can be expressed either in 26.6 */ - /* fractional pixels or font units. */ - /* */ - /* Note that even when the glyph image is */ - /* transformed, the metrics are not. */ - /* */ - /* linearHoriAdvance :: The advance width of the unhinted glyph. */ - /* Its value is expressed in 16.16 fractional */ - /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ - /* when loading the glyph. This field can be */ - /* important to perform correct WYSIWYG layout. */ - /* Only relevant for outline glyphs. */ - /* */ - /* linearVertAdvance :: The advance height of the unhinted glyph. */ - /* Its value is expressed in 16.16 fractional */ - /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ - /* when loading the glyph. This field can be */ - /* important to perform correct WYSIWYG layout. */ - /* Only relevant for outline glyphs. */ - /* */ - /* advance :: This shorthand is, depending on */ - /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */ - /* (hinted) advance width for the glyph, in 26.6 */ - /* fractional pixel format. As specified with */ - /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */ - /* `horiAdvance' or the `vertAdvance' value of */ - /* `metrics' field. */ - /* */ - /* format :: This field indicates the format of the image */ - /* contained in the glyph slot. Typically */ - /* @FT_GLYPH_FORMAT_BITMAP, */ - /* @FT_GLYPH_FORMAT_OUTLINE, or */ - /* @FT_GLYPH_FORMAT_COMPOSITE, but others are */ - /* possible. */ - /* */ - /* bitmap :: This field is used as a bitmap descriptor */ - /* when the slot format is */ - /* @FT_GLYPH_FORMAT_BITMAP. Note that the */ - /* address and content of the bitmap buffer can */ - /* change between calls of @FT_Load_Glyph and a */ - /* few other functions. */ - /* */ - /* bitmap_left :: This is the bitmap's left bearing expressed */ - /* in integer pixels. Of course, this is only */ - /* valid if the format is */ - /* @FT_GLYPH_FORMAT_BITMAP. */ - /* */ - /* bitmap_top :: This is the bitmap's top bearing expressed in */ - /* integer pixels. Remember that this is the */ - /* distance from the baseline to the top-most */ - /* glyph scanline, upwards y~coordinates being */ - /* *positive*. */ - /* */ - /* outline :: The outline descriptor for the current glyph */ - /* image if its format is */ - /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */ - /* loaded, `outline' can be transformed, */ - /* distorted, embolded, etc. However, it must */ - /* not be freed. */ - /* */ - /* num_subglyphs :: The number of subglyphs in a composite glyph. */ - /* This field is only valid for the composite */ - /* glyph format that should normally only be */ - /* loaded with the @FT_LOAD_NO_RECURSE flag. */ - /* For now this is internal to FreeType. */ - /* */ - /* subglyphs :: An array of subglyph descriptors for */ - /* composite glyphs. There are `num_subglyphs' */ - /* elements in there. Currently internal to */ - /* FreeType. */ - /* */ - /* control_data :: Certain font drivers can also return the */ - /* control data for a given glyph image (e.g. */ - /* TrueType bytecode, Type~1 charstrings, etc.). */ - /* This field is a pointer to such data. */ - /* */ - /* control_len :: This is the length in bytes of the control */ - /* data. */ - /* */ - /* other :: Really wicked formats can use this pointer to */ - /* present their own glyph image to client */ - /* applications. Note that the application */ - /* needs to know about the image format. */ - /* */ - /* lsb_delta :: The difference between hinted and unhinted */ - /* left side bearing while autohinting is */ - /* active. Zero otherwise. */ - /* */ - /* rsb_delta :: The difference between hinted and unhinted */ - /* right side bearing while autohinting is */ - /* active. Zero otherwise. */ - /* */ - /* <Note> */ - /* If @FT_Load_Glyph is called with default flags (see */ - /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */ - /* its native format (e.g., an outline glyph for TrueType and Type~1 */ - /* formats). */ - /* */ - /* This image can later be converted into a bitmap by calling */ - /* @FT_Render_Glyph. This function finds the current renderer for */ - /* the native image's format, then invokes it. */ - /* */ - /* The renderer is in charge of transforming the native image through */ - /* the slot's face transformation fields, then converting it into a */ - /* bitmap that is returned in `slot->bitmap'. */ - /* */ - /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */ - /* to specify the position of the bitmap relative to the current pen */ - /* position (e.g., coordinates (0,0) on the baseline). Of course, */ - /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */ - /* */ - /* <Note> */ - /* Here a small pseudo code fragment that shows how to use */ - /* `lsb_delta' and `rsb_delta': */ - /* */ - /* { */ - /* FT_Pos origin_x = 0; */ - /* FT_Pos prev_rsb_delta = 0; */ - /* */ - /* */ - /* for all glyphs do */ - /* <compute kern between current and previous glyph and add it to */ - /* `origin_x'> */ - /* */ - /* <load glyph with `FT_Load_Glyph'> */ - /* */ - /* if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) */ - /* origin_x -= 64; */ - /* else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) */ - /* origin_x += 64; */ - /* */ - /* prev_rsb_delta = face->glyph->rsb_delta; */ - /* */ - /* <save glyph image, or render glyph, or ...> */ - /* */ - /* origin_x += face->glyph->advance.x; */ - /* endfor */ - /* } */ - /* */ - typedef struct FT_GlyphSlotRec_ - { - FT_Library library; - FT_Face face; - FT_GlyphSlot next; - FT_UInt reserved; /* retained for binary compatibility */ - FT_Generic generic; - - FT_Glyph_Metrics metrics; - FT_Fixed linearHoriAdvance; - FT_Fixed linearVertAdvance; - FT_Vector advance; - - FT_Glyph_Format format; - - FT_Bitmap bitmap; - FT_Int bitmap_left; - FT_Int bitmap_top; - - FT_Outline outline; - - FT_UInt num_subglyphs; - FT_SubGlyph subglyphs; - - void* control_data; - long control_len; - - FT_Pos lsb_delta; - FT_Pos rsb_delta; - - void* other; - - FT_Slot_Internal internal; - - } FT_GlyphSlotRec; - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* F U N C T I O N S */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Init_FreeType */ - /* */ - /* <Description> */ - /* Initialize a new FreeType library object. The set of modules */ - /* that are registered by this function is determined at build time. */ - /* */ - /* <Output> */ - /* alibrary :: A handle to a new library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* In case you want to provide your own memory allocating routines, */ - /* use @FT_New_Library instead, followed by a call to */ - /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module). */ - /* */ - /* For multi-threading applications each thread should have its own */ - /* FT_Library object. */ - /* */ - /* If you need reference-counting (cf. @FT_Reference_Library), use */ - /* @FT_New_Library and @FT_Done_Library. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Init_FreeType( FT_Library *alibrary ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_FreeType */ - /* */ - /* <Description> */ - /* Destroy a given FreeType library object and all of its children, */ - /* including resources, drivers, faces, sizes, etc. */ - /* */ - /* <Input> */ - /* library :: A handle to the target library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Done_FreeType( FT_Library library ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_OPEN_XXX */ - /* */ - /* <Description> */ - /* A list of bit-field constants used within the `flags' field of the */ - /* @FT_Open_Args structure. */ - /* */ - /* <Values> */ - /* FT_OPEN_MEMORY :: This is a memory-based stream. */ - /* */ - /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */ - /* */ - /* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */ - /* name. */ - /* */ - /* FT_OPEN_DRIVER :: Use the `driver' field. */ - /* */ - /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */ - /* */ - /* ft_open_memory :: Deprecated; use @FT_OPEN_MEMORY instead. */ - /* */ - /* ft_open_stream :: Deprecated; use @FT_OPEN_STREAM instead. */ - /* */ - /* ft_open_pathname :: Deprecated; use @FT_OPEN_PATHNAME instead. */ - /* */ - /* ft_open_driver :: Deprecated; use @FT_OPEN_DRIVER instead. */ - /* */ - /* ft_open_params :: Deprecated; use @FT_OPEN_PARAMS instead. */ - /* */ - /* <Note> */ - /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */ - /* flags are mutually exclusive. */ - /* */ -#define FT_OPEN_MEMORY 0x1 -#define FT_OPEN_STREAM 0x2 -#define FT_OPEN_PATHNAME 0x4 -#define FT_OPEN_DRIVER 0x8 -#define FT_OPEN_PARAMS 0x10 - -#define ft_open_memory FT_OPEN_MEMORY /* deprecated */ -#define ft_open_stream FT_OPEN_STREAM /* deprecated */ -#define ft_open_pathname FT_OPEN_PATHNAME /* deprecated */ -#define ft_open_driver FT_OPEN_DRIVER /* deprecated */ -#define ft_open_params FT_OPEN_PARAMS /* deprecated */ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Parameter */ - /* */ - /* <Description> */ - /* A simple structure used to pass more or less generic parameters to */ - /* @FT_Open_Face. */ - /* */ - /* <Fields> */ - /* tag :: A four-byte identification tag. */ - /* */ - /* data :: A pointer to the parameter data. */ - /* */ - /* <Note> */ - /* The ID and function of parameters are driver-specific. See the */ - /* various FT_PARAM_TAG_XXX flags for more information. */ - /* */ - typedef struct FT_Parameter_ - { - FT_ULong tag; - FT_Pointer data; - - } FT_Parameter; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Open_Args */ - /* */ - /* <Description> */ - /* A structure used to indicate how to open a new font file or */ - /* stream. A pointer to such a structure can be used as a parameter */ - /* for the functions @FT_Open_Face and @FT_Attach_Stream. */ - /* */ - /* <Fields> */ - /* flags :: A set of bit flags indicating how to use the */ - /* structure. */ - /* */ - /* memory_base :: The first byte of the file in memory. */ - /* */ - /* memory_size :: The size in bytes of the file in memory. */ - /* */ - /* pathname :: A pointer to an 8-bit file pathname. */ - /* */ - /* stream :: A handle to a source stream object. */ - /* */ - /* driver :: This field is exclusively used by @FT_Open_Face; */ - /* it simply specifies the font driver to use to open */ - /* the face. If set to~0, FreeType tries to load the */ - /* face with each one of the drivers in its list. */ - /* */ - /* num_params :: The number of extra parameters. */ - /* */ - /* params :: Extra parameters passed to the font driver when */ - /* opening a new face. */ - /* */ - /* <Note> */ - /* The stream type is determined by the contents of `flags' that */ - /* are tested in the following order by @FT_Open_Face: */ - /* */ - /* If the `FT_OPEN_MEMORY' bit is set, assume that this is a */ - /* memory file of `memory_size' bytes, located at `memory_address'. */ - /* The data are are not copied, and the client is responsible for */ - /* releasing and destroying them _after_ the corresponding call to */ - /* @FT_Done_Face. */ - /* */ - /* Otherwise, if the `FT_OPEN_STREAM' bit is set, assume that a */ - /* custom input stream `stream' is used. */ - /* */ - /* Otherwise, if the `FT_OPEN_PATHNAME' bit is set, assume that this */ - /* is a normal file and use `pathname' to open it. */ - /* */ - /* If the `FT_OPEN_DRIVER' bit is set, @FT_Open_Face only tries to */ - /* open the file with the driver whose handler is in `driver'. */ - /* */ - /* If the `FT_OPEN_PARAMS' bit is set, the parameters given by */ - /* `num_params' and `params' is used. They are ignored otherwise. */ - /* */ - /* Ideally, both the `pathname' and `params' fields should be tagged */ - /* as `const'; this is missing for API backwards compatibility. In */ - /* other words, applications should treat them as read-only. */ - /* */ - typedef struct FT_Open_Args_ - { - FT_UInt flags; - const FT_Byte* memory_base; - FT_Long memory_size; - FT_String* pathname; - FT_Stream stream; - FT_Module driver; - FT_Int num_params; - FT_Parameter* params; - - } FT_Open_Args; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face */ - /* */ - /* <Description> */ - /* This function calls @FT_Open_Face to open a font by its pathname. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* pathname :: A path to the font file. */ - /* */ - /* face_index :: The index of the face within the font. The first */ - /* face has index~0. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. If `face_index' is */ - /* greater than or equal to zero, it must be non-NULL. */ - /* See @FT_Open_Face for more details. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Use @FT_Done_Face to destroy the created @FT_Face object (along */ - /* with its slot and sizes). */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Face( FT_Library library, - const char* filepathname, - FT_Long face_index, - FT_Face *aface ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Memory_Face */ - /* */ - /* <Description> */ - /* This function calls @FT_Open_Face to open a font that has been */ - /* loaded into memory. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* file_base :: A pointer to the beginning of the font data. */ - /* */ - /* file_size :: The size of the memory chunk used by the font data. */ - /* */ - /* face_index :: The index of the face within the font. The first */ - /* face has index~0. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. If `face_index' is */ - /* greater than or equal to zero, it must be non-NULL. */ - /* See @FT_Open_Face for more details. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You must not deallocate the memory before calling @FT_Done_Face. */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Memory_Face( FT_Library library, - const FT_Byte* file_base, - FT_Long file_size, - FT_Long face_index, - FT_Face *aface ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Open_Face */ - /* */ - /* <Description> */ - /* Create a face object from a given resource described by */ - /* @FT_Open_Args. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* args :: A pointer to an `FT_Open_Args' structure that must */ - /* be filled by the caller. */ - /* */ - /* face_index :: The index of the face within the font. The first */ - /* face has index~0. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. If `face_index' is */ - /* greater than or equal to zero, it must be non-NULL. */ - /* See note below. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Unlike FreeType 1.x, this function automatically creates a glyph */ - /* slot for the face object that can be accessed directly through */ - /* `face->glyph'. */ - /* */ - /* FT_Open_Face can be used to quickly check whether the font */ - /* format of a given font resource is supported by FreeType. If the */ - /* `face_index' field is negative, the function's return value is~0 */ - /* if the font format is recognized, or non-zero otherwise; */ - /* the function returns a more or less empty face handle in `*aface' */ - /* (if `aface' isn't NULL). The only useful field in this special */ - /* case is `face->num_faces' that gives the number of faces within */ - /* the font file. After examination, the returned @FT_Face structure */ - /* should be deallocated with a call to @FT_Done_Face. */ - /* */ - /* Each new face object created with this function also owns a */ - /* default @FT_Size object, accessible as `face->size'. */ - /* */ - /* One @FT_Library instance can have multiple face objects, this is, */ - /* @FT_Open_Face and its siblings can be called multiple times using */ - /* the same `library' argument. */ - /* */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Face. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Open_Face( FT_Library library, - const FT_Open_Args* args, - FT_Long face_index, - FT_Face *aface ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Attach_File */ - /* */ - /* <Description> */ - /* This function calls @FT_Attach_Stream to attach a file. */ - /* */ - /* <InOut> */ - /* face :: The target face object. */ - /* */ - /* <Input> */ - /* filepathname :: The pathname. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Attach_File( FT_Face face, - const char* filepathname ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Attach_Stream */ - /* */ - /* <Description> */ - /* `Attach' data to a face object. Normally, this is used to read */ - /* additional information for the face object. For example, you can */ - /* attach an AFM file that comes with a Type~1 font to get the */ - /* kerning values and other metrics. */ - /* */ - /* <InOut> */ - /* face :: The target face object. */ - /* */ - /* <Input> */ - /* parameters :: A pointer to @FT_Open_Args that must be filled by */ - /* the caller. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The meaning of the `attach' (i.e., what really happens when the */ - /* new file is read) is not fixed by FreeType itself. It really */ - /* depends on the font format (and thus the font driver). */ - /* */ - /* Client applications are expected to know what they are doing */ - /* when invoking this function. Most drivers simply do not implement */ - /* file attachments. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Attach_Stream( FT_Face face, - FT_Open_Args* parameters ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Reference_Face */ - /* */ - /* <Description> */ - /* A counter gets initialized to~1 at the time an @FT_Face structure */ - /* is created. This function increments the counter. @FT_Done_Face */ - /* then only destroys a face if the counter is~1, otherwise it simply */ - /* decrements the counter. */ - /* */ - /* This function helps in managing life-cycles of structures that */ - /* reference @FT_Face objects. */ - /* */ - /* <Input> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.4.2 */ - /* */ - FT_EXPORT( FT_Error ) - FT_Reference_Face( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Face */ - /* */ - /* <Description> */ - /* Discard a given face object, as well as all of its child slots and */ - /* sizes. */ - /* */ - /* <Input> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Face. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Done_Face( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Select_Size */ - /* */ - /* <Description> */ - /* Select a bitmap strike. */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Input> */ - /* strike_index :: The index of the bitmap strike in the */ - /* `available_sizes' field of @FT_FaceRec structure. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Select_Size( FT_Face face, - FT_Int strike_index ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Size_Request_Type */ - /* */ - /* <Description> */ - /* An enumeration type that lists the supported size request types. */ - /* */ - /* <Values> */ - /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */ - /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */ - /* used to determine both scaling values. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */ - /* The real dimension. The sum of the the `ascender' and (minus */ - /* of) the `descender' fields of @FT_FaceRec are used to determine */ - /* both scaling values. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_BBOX :: */ - /* The font bounding box. The width and height of the `bbox' field */ - /* of @FT_FaceRec are used to determine the horizontal and vertical */ - /* scaling value, respectively. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_CELL :: */ - /* The `max_advance_width' field of @FT_FaceRec is used to */ - /* determine the horizontal scaling value; the vertical scaling */ - /* value is determined the same way as */ - /* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */ - /* values are set to the smaller one. This type is useful if you */ - /* want to specify the font size for, say, a window of a given */ - /* dimension and 80x24 cells. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_SCALES :: */ - /* Specify the scaling values directly. */ - /* */ - /* <Note> */ - /* The above descriptions only apply to scalable formats. For bitmap */ - /* formats, the behaviour is up to the driver. */ - /* */ - /* See the note section of @FT_Size_Metrics if you wonder how size */ - /* requesting relates to scaling values. */ - /* */ - typedef enum FT_Size_Request_Type_ - { - FT_SIZE_REQUEST_TYPE_NOMINAL, - FT_SIZE_REQUEST_TYPE_REAL_DIM, - FT_SIZE_REQUEST_TYPE_BBOX, - FT_SIZE_REQUEST_TYPE_CELL, - FT_SIZE_REQUEST_TYPE_SCALES, - - FT_SIZE_REQUEST_TYPE_MAX - - } FT_Size_Request_Type; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_RequestRec */ - /* */ - /* <Description> */ - /* A structure used to model a size request. */ - /* */ - /* <Fields> */ - /* type :: See @FT_Size_Request_Type. */ - /* */ - /* width :: The desired width. */ - /* */ - /* height :: The desired height. */ - /* */ - /* horiResolution :: The horizontal resolution. If set to zero, */ - /* `width' is treated as a 26.6 fractional pixel */ - /* value. */ - /* */ - /* vertResolution :: The vertical resolution. If set to zero, */ - /* `height' is treated as a 26.6 fractional pixel */ - /* value. */ - /* */ - /* <Note> */ - /* If `width' is zero, then the horizontal scaling value is set equal */ - /* to the vertical scaling value, and vice versa. */ - /* */ - typedef struct FT_Size_RequestRec_ - { - FT_Size_Request_Type type; - FT_Long width; - FT_Long height; - FT_UInt horiResolution; - FT_UInt vertResolution; - - } FT_Size_RequestRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_Request */ - /* */ - /* <Description> */ - /* A handle to a size request structure. */ - /* */ - typedef struct FT_Size_RequestRec_ *FT_Size_Request; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Request_Size */ - /* */ - /* <Description> */ - /* Resize the scale of the active @FT_Size object in a face. */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Input> */ - /* req :: A pointer to a @FT_Size_RequestRec. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Although drivers may select the bitmap strike matching the */ - /* request, you should not rely on this if you intend to select a */ - /* particular bitmap strike. Use @FT_Select_Size instead in that */ - /* case. */ - /* */ - /* The relation between the requested size and the resulting glyph */ - /* size is dependent entirely on how the size is defined in the */ - /* source face. The font designer chooses the final size of each */ - /* glyph relative to this size. For more information refer to */ - /* `http://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html' */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Request_Size( FT_Face face, - FT_Size_Request req ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Char_Size */ - /* */ - /* <Description> */ - /* This function calls @FT_Request_Size to request the nominal size */ - /* (in points). */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Input> */ - /* char_width :: The nominal width, in 26.6 fractional points. */ - /* */ - /* char_height :: The nominal height, in 26.6 fractional points. */ - /* */ - /* horz_resolution :: The horizontal resolution in dpi. */ - /* */ - /* vert_resolution :: The vertical resolution in dpi. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If either the character width or height is zero, it is set equal */ - /* to the other value. */ - /* */ - /* If either the horizontal or vertical resolution is zero, it is set */ - /* equal to the other value. */ - /* */ - /* A character width or height smaller than 1pt is set to 1pt; if */ - /* both resolution values are zero, they are set to 72dpi. */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_Char_Size( FT_Face face, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Pixel_Sizes */ - /* */ - /* <Description> */ - /* This function calls @FT_Request_Size to request the nominal size */ - /* (in pixels). */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* pixel_width :: The nominal width, in pixels. */ - /* */ - /* pixel_height :: The nominal height, in pixels. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You should not rely on the resulting glyphs matching, or being */ - /* constrained, to this pixel size. Refer to @FT_Request_Size to */ - /* understand how requested sizes relate to actual sizes. */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_Pixel_Sizes( FT_Face face, - FT_UInt pixel_width, - FT_UInt pixel_height ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Load_Glyph */ - /* */ - /* <Description> */ - /* A function used to load a single glyph into the glyph slot of a */ - /* face object. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object where the glyph */ - /* is loaded. */ - /* */ - /* <Input> */ - /* glyph_index :: The index of the glyph in the font file. For */ - /* CID-keyed fonts (either in PS or in CFF format) */ - /* this argument specifies the CID value. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* @FT_LOAD_XXX constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The loaded glyph may be transformed. See @FT_Set_Transform for */ - /* the details. */ - /* */ - /* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */ - /* returned for invalid CID values (this is, for CID values that */ - /* don't have a corresponding glyph in the font). See the discussion */ - /* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Load_Glyph( FT_Face face, - FT_UInt glyph_index, - FT_Int32 load_flags ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Load_Char */ - /* */ - /* <Description> */ - /* A function used to load a single glyph into the glyph slot of a */ - /* face object, according to its character code. */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object where the glyph */ - /* is loaded. */ - /* */ - /* <Input> */ - /* char_code :: The glyph's character code, according to the */ - /* current charmap used in the face. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* @FT_LOAD_XXX constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Load_Char( FT_Face face, - FT_ULong char_code, - FT_Int32 load_flags ); - - - /************************************************************************* - * - * @enum: - * FT_LOAD_XXX - * - * @description: - * A list of bit-field constants used with @FT_Load_Glyph to indicate - * what kind of operations to perform during glyph loading. - * - * @values: - * FT_LOAD_DEFAULT :: - * Corresponding to~0, this value is used as the default glyph load - * operation. In this case, the following happens: - * - * 1. FreeType looks for a bitmap for the glyph corresponding to the - * face's current size. If one is found, the function returns. - * The bitmap data can be accessed from the glyph slot (see note - * below). - * - * 2. If no embedded bitmap is searched or found, FreeType looks for a - * scalable outline. If one is found, it is loaded from the font - * file, scaled to device pixels, then `hinted' to the pixel grid - * in order to optimize it. The outline data can be accessed from - * the glyph slot (see note below). - * - * Note that by default, the glyph loader doesn't render outlines into - * bitmaps. The following flags are used to modify this default - * behaviour to more specific and useful cases. - * - * FT_LOAD_NO_SCALE :: - * Don't scale the loaded outline glyph but keep it in font units. - * - * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and - * unsets @FT_LOAD_RENDER. - * - * If the font is `tricky' (see @FT_FACE_FLAG_TRICKY for more), using - * FT_LOAD_NO_SCALE usually yields meaningless outlines because the - * subglyphs must be scaled and positioned with hinting instructions. - * This can be solved by loading the font without FT_LOAD_NO_SCALE and - * setting the character size to `font->units_per_EM'. - * - * FT_LOAD_NO_HINTING :: - * Disable hinting. This generally generates `blurrier' bitmap glyphs - * when the glyph are rendered in any of the anti-aliased modes. See - * also the note below. - * - * This flag is implied by @FT_LOAD_NO_SCALE. - * - * FT_LOAD_RENDER :: - * Call @FT_Render_Glyph after the glyph is loaded. By default, the - * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be - * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME. - * - * This flag is unset by @FT_LOAD_NO_SCALE. - * - * FT_LOAD_NO_BITMAP :: - * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this - * flag. - * - * @FT_LOAD_NO_SCALE always sets this flag. - * - * FT_LOAD_VERTICAL_LAYOUT :: - * Load the glyph for vertical text layout. In particular, the - * `advance' value in the @FT_GlyphSlotRec structure is set to the - * `vertAdvance' value of the `metrics' field. - * - * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use - * this flag currently. Reason is that in this case vertical metrics - * get synthesized, and those values are not always consistent across - * various font formats. - * - * FT_LOAD_FORCE_AUTOHINT :: - * Indicates that the auto-hinter is preferred over the font's native - * hinter. See also the note below. - * - * FT_LOAD_CROP_BITMAP :: - * Indicates that the font driver should crop the loaded bitmap glyph - * (i.e., remove all space around its black bits). Not all drivers - * implement this. - * - * FT_LOAD_PEDANTIC :: - * Indicates that the font driver should perform pedantic verifications - * during glyph loading. This is mostly used to detect broken glyphs - * in fonts. By default, FreeType tries to handle broken fonts also. - * - * In particular, errors from the TrueType bytecode engine are not - * passed to the application if this flag is not set; this might - * result in partially hinted or distorted glyphs in case a glyph's - * bytecode is buggy. - * - * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH :: - * Ignored. Deprecated. - * - * FT_LOAD_NO_RECURSE :: - * This flag is only used internally. It merely indicates that the - * font driver should not load composite glyphs recursively. Instead, - * it should set the `num_subglyph' and `subglyphs' values of the - * glyph slot accordingly, and set `glyph->format' to - * @FT_GLYPH_FORMAT_COMPOSITE. - * - * The description of sub-glyphs is not available to client - * applications for now. - * - * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM. - * - * FT_LOAD_IGNORE_TRANSFORM :: - * Indicates that the transform matrix set by @FT_Set_Transform should - * be ignored. - * - * FT_LOAD_MONOCHROME :: - * This flag is used with @FT_LOAD_RENDER to indicate that you want to - * render an outline glyph to a 1-bit monochrome bitmap glyph, with - * 8~pixels packed into each byte of the bitmap data. - * - * Note that this has no effect on the hinting algorithm used. You - * should rather use @FT_LOAD_TARGET_MONO so that the - * monochrome-optimized hinting algorithm is used. - * - * FT_LOAD_LINEAR_DESIGN :: - * Indicates that the `linearHoriAdvance' and `linearVertAdvance' - * fields of @FT_GlyphSlotRec should be kept in font units. See - * @FT_GlyphSlotRec for details. - * - * FT_LOAD_NO_AUTOHINT :: - * Disable auto-hinter. See also the note below. - * - * FT_LOAD_COLOR :: - * This flag is used to request loading of color embedded-bitmap - * images. The resulting color bitmaps, if available, will have the - * @FT_PIXEL_MODE_BGRA format. When the flag is not used and color - * bitmaps are found, they will be converted to 256-level gray - * bitmaps transparently. Those bitmaps will be in the - * @FT_PIXEL_MODE_GRAY format. - * - * @note: - * By default, hinting is enabled and the font's native hinter (see - * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can - * disable hinting by setting @FT_LOAD_NO_HINTING or change the - * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set - * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be - * used at all. - * - * See the description of @FT_FACE_FLAG_TRICKY for a special exception - * (affecting only a handful of Asian fonts). - * - * Besides deciding which hinter to use, you can also decide which - * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details. - * - * Note that the auto-hinter needs a valid Unicode cmap (either a native - * one or synthesized by FreeType) for producing correct results. If a - * font provides an incorrect mapping (for example, assigning the - * character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a - * mathematical integral sign), the auto-hinter might produce useless - * results. - * - */ -#define FT_LOAD_DEFAULT 0x0 -#define FT_LOAD_NO_SCALE ( 1L << 0 ) -#define FT_LOAD_NO_HINTING ( 1L << 1 ) -#define FT_LOAD_RENDER ( 1L << 2 ) -#define FT_LOAD_NO_BITMAP ( 1L << 3 ) -#define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 ) -#define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 ) -#define FT_LOAD_CROP_BITMAP ( 1L << 6 ) -#define FT_LOAD_PEDANTIC ( 1L << 7 ) -#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 ) -#define FT_LOAD_NO_RECURSE ( 1L << 10 ) -#define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 ) -#define FT_LOAD_MONOCHROME ( 1L << 12 ) -#define FT_LOAD_LINEAR_DESIGN ( 1L << 13 ) -#define FT_LOAD_NO_AUTOHINT ( 1L << 15 ) - /* Bits 16..19 are used by `FT_LOAD_TARGET_' */ -#define FT_LOAD_COLOR ( 1L << 20 ) - - /* */ - - /* used internally only by certain font drivers! */ -#define FT_LOAD_ADVANCE_ONLY ( 1L << 8 ) -#define FT_LOAD_SBITS_ONLY ( 1L << 14 ) - - - /************************************************************************** - * - * @enum: - * FT_LOAD_TARGET_XXX - * - * @description: - * A list of values that are used to select a specific hinting algorithm - * to use by the hinter. You should OR one of these values to your - * `load_flags' when calling @FT_Load_Glyph. - * - * Note that font's native hinters may ignore the hinting algorithm you - * have specified (e.g., the TrueType bytecode interpreter). You can set - * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used. - * - * Also note that @FT_LOAD_TARGET_LIGHT is an exception, in that it - * always implies @FT_LOAD_FORCE_AUTOHINT. - * - * @values: - * FT_LOAD_TARGET_NORMAL :: - * This corresponds to the default hinting algorithm, optimized for - * standard gray-level rendering. For monochrome output, use - * @FT_LOAD_TARGET_MONO instead. - * - * FT_LOAD_TARGET_LIGHT :: - * A lighter hinting algorithm for non-monochrome modes. Many - * generated glyphs are more fuzzy but better resemble its original - * shape. A bit like rendering on Mac OS~X. - * - * As a special exception, this target implies @FT_LOAD_FORCE_AUTOHINT. - * - * FT_LOAD_TARGET_MONO :: - * Strong hinting algorithm that should only be used for monochrome - * output. The result is probably unpleasant if the glyph is rendered - * in non-monochrome modes. - * - * FT_LOAD_TARGET_LCD :: - * A variant of @FT_LOAD_TARGET_NORMAL optimized for horizontally - * decimated LCD displays. - * - * FT_LOAD_TARGET_LCD_V :: - * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically - * decimated LCD displays. - * - * @note: - * You should use only _one_ of the FT_LOAD_TARGET_XXX values in your - * `load_flags'. They can't be ORed. - * - * If @FT_LOAD_RENDER is also set, the glyph is rendered in the - * corresponding mode (i.e., the mode that matches the used algorithm - * best). An exeption is FT_LOAD_TARGET_MONO since it implies - * @FT_LOAD_MONOCHROME. - * - * You can use a hinting algorithm that doesn't correspond to the same - * rendering mode. As an example, it is possible to use the `light' - * hinting algorithm and have the results rendered in horizontal LCD - * pixel mode, with code like - * - * { - * FT_Load_Glyph( face, glyph_index, - * load_flags | FT_LOAD_TARGET_LIGHT ); - * - * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); - * } - * - */ -#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 ) - -#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL ) -#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT ) -#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO ) -#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD ) -#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V ) - - - /************************************************************************** - * - * @macro: - * FT_LOAD_TARGET_MODE - * - * @description: - * Return the @FT_Render_Mode corresponding to a given - * @FT_LOAD_TARGET_XXX value. - * - */ -#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) ) - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Transform */ - /* */ - /* <Description> */ - /* A function used to set the transformation that is applied to glyph */ - /* images when they are loaded into a glyph slot through */ - /* @FT_Load_Glyph. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to the transformation's 2x2 matrix. Use~0 for */ - /* the identity matrix. */ - /* delta :: A pointer to the translation vector. Use~0 for the null */ - /* vector. */ - /* */ - /* <Note> */ - /* The transformation is only applied to scalable image formats after */ - /* the glyph has been loaded. It means that hinting is unaltered by */ - /* the transformation and is performed on the character size given in */ - /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */ - /* */ - /* Note that this also transforms the `face.glyph.advance' field, but */ - /* *not* the values in `face.glyph.metrics'. */ - /* */ - FT_EXPORT( void ) - FT_Set_Transform( FT_Face face, - FT_Matrix* matrix, - FT_Vector* delta ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Render_Mode */ - /* */ - /* <Description> */ - /* An enumeration type that lists the render modes supported by */ - /* FreeType~2. Each mode corresponds to a specific type of scanline */ - /* conversion performed on the outline. */ - /* */ - /* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */ - /* field in the @FT_GlyphSlotRec structure gives the format of the */ - /* returned bitmap. */ - /* */ - /* All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity. */ - /* */ - /* <Values> */ - /* FT_RENDER_MODE_NORMAL :: */ - /* This is the default render mode; it corresponds to 8-bit */ - /* anti-aliased bitmaps. */ - /* */ - /* FT_RENDER_MODE_LIGHT :: */ - /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */ - /* defined as a separate value because render modes are also used */ - /* indirectly to define hinting algorithm selectors. See */ - /* @FT_LOAD_TARGET_XXX for details. */ - /* */ - /* FT_RENDER_MODE_MONO :: */ - /* This mode corresponds to 1-bit bitmaps (with 2~levels of */ - /* opacity). */ - /* */ - /* FT_RENDER_MODE_LCD :: */ - /* This mode corresponds to horizontal RGB and BGR sub-pixel */ - /* displays like LCD screens. It produces 8-bit bitmaps that are */ - /* 3~times the width of the original glyph outline in pixels, and */ - /* which use the @FT_PIXEL_MODE_LCD mode. */ - /* */ - /* FT_RENDER_MODE_LCD_V :: */ - /* This mode corresponds to vertical RGB and BGR sub-pixel displays */ - /* (like PDA screens, rotated LCD displays, etc.). It produces */ - /* 8-bit bitmaps that are 3~times the height of the original */ - /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */ - /* */ - /* <Note> */ - /* The LCD-optimized glyph bitmaps produced by FT_Render_Glyph can be */ - /* filtered to reduce color-fringes by using @FT_Library_SetLcdFilter */ - /* (not active in the default builds). It is up to the caller to */ - /* either call @FT_Library_SetLcdFilter (if available) or do the */ - /* filtering itself. */ - /* */ - /* The selected render mode only affects vector glyphs of a font. */ - /* Embedded bitmaps often have a different pixel mode like */ - /* @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform */ - /* them into 8-bit pixmaps. */ - /* */ - typedef enum FT_Render_Mode_ - { - FT_RENDER_MODE_NORMAL = 0, - FT_RENDER_MODE_LIGHT, - FT_RENDER_MODE_MONO, - FT_RENDER_MODE_LCD, - FT_RENDER_MODE_LCD_V, - - FT_RENDER_MODE_MAX - - } FT_Render_Mode; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* ft_render_mode_xxx */ - /* */ - /* <Description> */ - /* These constants are deprecated. Use the corresponding */ - /* @FT_Render_Mode values instead. */ - /* */ - /* <Values> */ - /* ft_render_mode_normal :: see @FT_RENDER_MODE_NORMAL */ - /* ft_render_mode_mono :: see @FT_RENDER_MODE_MONO */ - /* */ -#define ft_render_mode_normal FT_RENDER_MODE_NORMAL -#define ft_render_mode_mono FT_RENDER_MODE_MONO - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Render_Glyph */ - /* */ - /* <Description> */ - /* Convert a given glyph image to a bitmap. It does so by inspecting */ - /* the glyph image format, finding the relevant renderer, and */ - /* invoking it. */ - /* */ - /* <InOut> */ - /* slot :: A handle to the glyph slot containing the image to */ - /* convert. */ - /* */ - /* <Input> */ - /* render_mode :: This is the render mode used to render the glyph */ - /* image into a bitmap. See @FT_Render_Mode for a */ - /* list of possible values. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* To get meaningful results, font scaling values must be set with */ - /* functions like @FT_Set_Char_Size before calling FT_Render_Glyph. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Render_Glyph( FT_GlyphSlot slot, - FT_Render_Mode render_mode ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Kerning_Mode */ - /* */ - /* <Description> */ - /* An enumeration used to specify which kerning values to return in */ - /* @FT_Get_Kerning. */ - /* */ - /* <Values> */ - /* FT_KERNING_DEFAULT :: Return scaled and grid-fitted kerning */ - /* distances (value is~0). */ - /* */ - /* FT_KERNING_UNFITTED :: Return scaled but un-grid-fitted kerning */ - /* distances. */ - /* */ - /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */ - /* units. */ - /* */ - typedef enum FT_Kerning_Mode_ - { - FT_KERNING_DEFAULT = 0, - FT_KERNING_UNFITTED, - FT_KERNING_UNSCALED - - } FT_Kerning_Mode; - - - /*************************************************************************/ - /* */ - /* <Const> */ - /* ft_kerning_default */ - /* */ - /* <Description> */ - /* This constant is deprecated. Please use @FT_KERNING_DEFAULT */ - /* instead. */ - /* */ -#define ft_kerning_default FT_KERNING_DEFAULT - - - /*************************************************************************/ - /* */ - /* <Const> */ - /* ft_kerning_unfitted */ - /* */ - /* <Description> */ - /* This constant is deprecated. Please use @FT_KERNING_UNFITTED */ - /* instead. */ - /* */ -#define ft_kerning_unfitted FT_KERNING_UNFITTED - - - /*************************************************************************/ - /* */ - /* <Const> */ - /* ft_kerning_unscaled */ - /* */ - /* <Description> */ - /* This constant is deprecated. Please use @FT_KERNING_UNSCALED */ - /* instead. */ - /* */ -#define ft_kerning_unscaled FT_KERNING_UNSCALED - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Kerning */ - /* */ - /* <Description> */ - /* Return the kerning vector between two glyphs of a same face. */ - /* */ - /* <Input> */ - /* face :: A handle to a source face object. */ - /* */ - /* left_glyph :: The index of the left glyph in the kern pair. */ - /* */ - /* right_glyph :: The index of the right glyph in the kern pair. */ - /* */ - /* kern_mode :: See @FT_Kerning_Mode for more information. */ - /* Determines the scale and dimension of the returned */ - /* kerning vector. */ - /* */ - /* <Output> */ - /* akerning :: The kerning vector. This is either in font units */ - /* or in pixels (26.6 format) for scalable formats, */ - /* and in pixels for fixed-sizes formats. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Only horizontal layouts (left-to-right & right-to-left) are */ - /* supported by this method. Other layouts, or more sophisticated */ - /* kernings, are out of the scope of this API function -- they can be */ - /* implemented through format-specific interfaces. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Kerning( FT_Face face, - FT_UInt left_glyph, - FT_UInt right_glyph, - FT_UInt kern_mode, - FT_Vector *akerning ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Track_Kerning */ - /* */ - /* <Description> */ - /* Return the track kerning for a given face object at a given size. */ - /* */ - /* <Input> */ - /* face :: A handle to a source face object. */ - /* */ - /* point_size :: The point size in 16.16 fractional points. */ - /* */ - /* degree :: The degree of tightness. Increasingly negative */ - /* values represent tighter track kerning, while */ - /* increasingly positive values represent looser track */ - /* kerning. Value zero means no track kerning. */ - /* */ - /* <Output> */ - /* akerning :: The kerning in 16.16 fractional points, to be */ - /* uniformly applied between all glyphs. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Currently, only the Type~1 font driver supports track kerning, */ - /* using data from AFM files (if attached with @FT_Attach_File or */ - /* @FT_Attach_Stream). */ - /* */ - /* Only very few AFM files come with track kerning data; please refer */ - /* to the Adobe's AFM specification for more details. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Track_Kerning( FT_Face face, - FT_Fixed point_size, - FT_Int degree, - FT_Fixed* akerning ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Glyph_Name */ - /* */ - /* <Description> */ - /* Retrieve the ASCII name of a given glyph in a face. This only */ - /* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. */ - /* */ - /* <Input> */ - /* face :: A handle to a source face object. */ - /* */ - /* glyph_index :: The glyph index. */ - /* */ - /* buffer_max :: The maximum number of bytes available in the */ - /* buffer. */ - /* */ - /* <Output> */ - /* buffer :: A pointer to a target buffer where the name is */ - /* copied to. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* An error is returned if the face doesn't provide glyph names or if */ - /* the glyph index is invalid. In all cases of failure, the first */ - /* byte of `buffer' is set to~0 to indicate an empty name. */ - /* */ - /* The glyph name is truncated to fit within the buffer if it is too */ - /* long. The returned string is always zero-terminated. */ - /* */ - /* Be aware that FreeType reorders glyph indices internally so that */ - /* glyph index~0 always corresponds to the `missing glyph' (called */ - /* `.notdef'). */ - /* */ - /* This function is not compiled within the library if the config */ - /* macro `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is defined in */ - /* `ftoptions.h'. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Glyph_Name( FT_Face face, - FT_UInt glyph_index, - FT_Pointer buffer, - FT_UInt buffer_max ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Postscript_Name */ - /* */ - /* <Description> */ - /* Retrieve the ASCII PostScript name of a given face, if available. */ - /* This only works with PostScript and TrueType fonts. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Return> */ - /* A pointer to the face's PostScript name. NULL if unavailable. */ - /* */ - /* <Note> */ - /* The returned pointer is owned by the face and is destroyed with */ - /* it. */ - /* */ - FT_EXPORT( const char* ) - FT_Get_Postscript_Name( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Select_Charmap */ - /* */ - /* <Description> */ - /* Select a given charmap by its encoding tag (as listed in */ - /* `freetype.h'). */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Input> */ - /* encoding :: A handle to the selected encoding. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function returns an error if no charmap in the face */ - /* corresponds to the encoding queried here. */ - /* */ - /* Because many fonts contain more than a single cmap for Unicode */ - /* encoding, this function has some special code to select the one */ - /* that covers Unicode best (`best' in the sense that a UCS-4 cmap is */ - /* preferred to a UCS-2 cmap). It is thus preferable to */ - /* @FT_Set_Charmap in this case. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Select_Charmap( FT_Face face, - FT_Encoding encoding ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Charmap */ - /* */ - /* <Description> */ - /* Select a given charmap for character code to glyph index mapping. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Input> */ - /* charmap :: A handle to the selected charmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function returns an error if the charmap is not part of */ - /* the face (i.e., if it is not listed in the `face->charmaps' */ - /* table). */ - /* */ - /* It also fails if a type~14 charmap is selected. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_Charmap( FT_Face face, - FT_CharMap charmap ); - - - /************************************************************************* - * - * @function: - * FT_Get_Charmap_Index - * - * @description: - * Retrieve index of a given charmap. - * - * @input: - * charmap :: - * A handle to a charmap. - * - * @return: - * The index into the array of character maps within the face to which - * `charmap' belongs. If an error occurs, -1 is returned. - * - */ - FT_EXPORT( FT_Int ) - FT_Get_Charmap_Index( FT_CharMap charmap ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Char_Index */ - /* */ - /* <Description> */ - /* Return the glyph index of a given character code. This function */ - /* uses a charmap object to do the mapping. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* <Return> */ - /* The glyph index. 0~means `undefined character code'. */ - /* */ - /* <Note> */ - /* If you use FreeType to manipulate the contents of font files */ - /* directly, be aware that the glyph index returned by this function */ - /* doesn't always correspond to the internal indices used within the */ - /* file. This is done to ensure that value~0 always corresponds to */ - /* the `missing glyph'. If the first glyph is not named `.notdef', */ - /* then for Type~1 and Type~42 fonts, `.notdef' will be moved into */ - /* the glyph ID~0 position, and whatever was there will be moved to */ - /* the position `.notdef' had. For Type~1 fonts, if there is no */ - /* `.notdef' glyph at all, then one will be created at index~0 and */ - /* whatever was there will be moved to the last index -- Type~42 */ - /* fonts are considered invalid under this condition. */ - /* */ - FT_EXPORT( FT_UInt ) - FT_Get_Char_Index( FT_Face face, - FT_ULong charcode ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_First_Char */ - /* */ - /* <Description> */ - /* This function is used to return the first character code in the */ - /* current charmap of a given face. It also returns the */ - /* corresponding glyph index. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Output> */ - /* agindex :: Glyph index of first character code. 0~if charmap is */ - /* empty. */ - /* */ - /* <Return> */ - /* The charmap's first character code. */ - /* */ - /* <Note> */ - /* You should use this function with @FT_Get_Next_Char to be able to */ - /* parse all character codes available in a given charmap. The code */ - /* should look like this: */ - /* */ - /* { */ - /* FT_ULong charcode; */ - /* FT_UInt gindex; */ - /* */ - /* */ - /* charcode = FT_Get_First_Char( face, &gindex ); */ - /* while ( gindex != 0 ) */ - /* { */ - /* ... do something with (charcode,gindex) pair ... */ - /* */ - /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */ - /* } */ - /* } */ - /* */ - /* Note that `*agindex' is set to~0 if the charmap is empty. The */ - /* result itself can be~0 in two cases: if the charmap is empty or */ - /* if the value~0 is the first valid character code. */ - /* */ - FT_EXPORT( FT_ULong ) - FT_Get_First_Char( FT_Face face, - FT_UInt *agindex ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Next_Char */ - /* */ - /* <Description> */ - /* This function is used to return the next character code in the */ - /* current charmap of a given face following the value `char_code', */ - /* as well as the corresponding glyph index. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* char_code :: The starting character code. */ - /* */ - /* <Output> */ - /* agindex :: Glyph index of next character code. 0~if charmap */ - /* is empty. */ - /* */ - /* <Return> */ - /* The charmap's next character code. */ - /* */ - /* <Note> */ - /* You should use this function with @FT_Get_First_Char to walk */ - /* over all character codes available in a given charmap. See the */ - /* note for this function for a simple code example. */ - /* */ - /* Note that `*agindex' is set to~0 when there are no more codes in */ - /* the charmap. */ - /* */ - FT_EXPORT( FT_ULong ) - FT_Get_Next_Char( FT_Face face, - FT_ULong char_code, - FT_UInt *agindex ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Name_Index */ - /* */ - /* <Description> */ - /* Return the glyph index of a given glyph name. This function uses */ - /* driver specific objects to do the translation. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* glyph_name :: The glyph name. */ - /* */ - /* <Return> */ - /* The glyph index. 0~means `undefined character code'. */ - /* */ - FT_EXPORT( FT_UInt ) - FT_Get_Name_Index( FT_Face face, - FT_String* glyph_name ); - - - /************************************************************************* - * - * @macro: - * FT_SUBGLYPH_FLAG_XXX - * - * @description: - * A list of constants used to describe subglyphs. Please refer to the - * TrueType specification for the meaning of the various flags. - * - * @values: - * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS :: - * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES :: - * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID :: - * FT_SUBGLYPH_FLAG_SCALE :: - * FT_SUBGLYPH_FLAG_XY_SCALE :: - * FT_SUBGLYPH_FLAG_2X2 :: - * FT_SUBGLYPH_FLAG_USE_MY_METRICS :: - * - */ -#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1 -#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2 -#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4 -#define FT_SUBGLYPH_FLAG_SCALE 8 -#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40 -#define FT_SUBGLYPH_FLAG_2X2 0x80 -#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200 - - - /************************************************************************* - * - * @func: - * FT_Get_SubGlyph_Info - * - * @description: - * Retrieve a description of a given subglyph. Only use it if - * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE; an error is - * returned otherwise. - * - * @input: - * glyph :: - * The source glyph slot. - * - * sub_index :: - * The index of the subglyph. Must be less than - * `glyph->num_subglyphs'. - * - * @output: - * p_index :: - * The glyph index of the subglyph. - * - * p_flags :: - * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX. - * - * p_arg1 :: - * The subglyph's first argument (if any). - * - * p_arg2 :: - * The subglyph's second argument (if any). - * - * p_transform :: - * The subglyph transformation (if any). - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be - * interpreted depending on the flags returned in `*p_flags'. See the - * TrueType specification for details. - * - */ - FT_EXPORT( FT_Error ) - FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, - FT_UInt sub_index, - FT_Int *p_index, - FT_UInt *p_flags, - FT_Int *p_arg1, - FT_Int *p_arg2, - FT_Matrix *p_transform ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_FSTYPE_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags used in the `fsType' field of the OS/2 table */ - /* in a TrueType or OpenType font and the `FSType' entry in a */ - /* PostScript font. These bit flags are returned by */ - /* @FT_Get_FSType_Flags; they inform client applications of embedding */ - /* and subsetting restrictions associated with a font. */ - /* */ - /* See http://www.adobe.com/devnet/acrobat/pdfs/FontPolicies.pdf for */ - /* more details. */ - /* */ - /* <Values> */ - /* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */ - /* Fonts with no fsType bit set may be embedded and permanently */ - /* installed on the remote system by an application. */ - /* */ - /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */ - /* Fonts that have only this bit set must not be modified, embedded */ - /* or exchanged in any manner without first obtaining permission of */ - /* the font software copyright owner. */ - /* */ - /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */ - /* If this bit is set, the font may be embedded and temporarily */ - /* loaded on the remote system. Documents containing Preview & */ - /* Print fonts must be opened `read-only'; no edits can be applied */ - /* to the document. */ - /* */ - /* FT_FSTYPE_EDITABLE_EMBEDDING :: */ - /* If this bit is set, the font may be embedded but must only be */ - /* installed temporarily on other systems. In contrast to Preview */ - /* & Print fonts, documents containing editable fonts may be opened */ - /* for reading, editing is permitted, and changes may be saved. */ - /* */ - /* FT_FSTYPE_NO_SUBSETTING :: */ - /* If this bit is set, the font may not be subsetted prior to */ - /* embedding. */ - /* */ - /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */ - /* If this bit is set, only bitmaps contained in the font may be */ - /* embedded; no outline data may be embedded. If there are no */ - /* bitmaps available in the font, then the font is unembeddable. */ - /* */ - /* <Note> */ - /* While the fsType flags can indicate that a font may be embedded, a */ - /* license with the font vendor may be separately required to use the */ - /* font in this way. */ - /* */ -#define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000 -#define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002 -#define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004 -#define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008 -#define FT_FSTYPE_NO_SUBSETTING 0x0100 -#define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200 - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_FSType_Flags */ - /* */ - /* <Description> */ - /* Return the fsType flags for a font. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Return> */ - /* The fsType flags, @FT_FSTYPE_XXX. */ - /* */ - /* <Note> */ - /* Use this function rather than directly reading the `fs_type' field */ - /* in the @PS_FontInfoRec structure, which is only guaranteed to */ - /* return the correct results for Type~1 fonts. */ - /* */ - /* <Since> */ - /* 2.3.8 */ - /* */ - FT_EXPORT( FT_UShort ) - FT_Get_FSType_Flags( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* glyph_variants */ - /* */ - /* <Title> */ - /* Glyph Variants */ - /* */ - /* <Abstract> */ - /* The FreeType~2 interface to Unicode Ideographic Variation */ - /* Sequences (IVS), using the SFNT cmap format~14. */ - /* */ - /* <Description> */ - /* Many CJK characters have variant forms. They are a sort of grey */ - /* area somewhere between being totally irrelevant and semantically */ - /* distinct; for this reason, the Unicode consortium decided to */ - /* introduce Ideographic Variation Sequences (IVS), consisting of a */ - /* Unicode base character and one of 240 variant selectors */ - /* (U+E0100-U+E01EF), instead of further extending the already huge */ - /* code range for CJK characters. */ - /* */ - /* An IVS is registered and unique; for further details please refer */ - /* to Unicode Technical Standard #37, the Ideographic Variation */ - /* Database: */ - /* */ - /* http://www.unicode.org/reports/tr37/ */ - /* */ - /* To date (November 2012), the character with the most variants is */ - /* U+9089, having 31 such IVS. */ - /* */ - /* Adobe and MS decided to support IVS with a new cmap subtable */ - /* (format~14). It is an odd subtable because it is not a mapping of */ - /* input code points to glyphs, but contains lists of all variants */ - /* supported by the font. */ - /* */ - /* A variant may be either `default' or `non-default'. A default */ - /* variant is the one you will get for that code point if you look it */ - /* up in the standard Unicode cmap. A non-default variant is a */ - /* different glyph. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetCharVariantIndex */ - /* */ - /* <Description> */ - /* Return the glyph index of a given character code as modified by */ - /* the variation selector. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* charcode :: */ - /* The character code point in Unicode. */ - /* */ - /* variantSelector :: */ - /* The Unicode code point of the variation selector. */ - /* */ - /* <Return> */ - /* The glyph index. 0~means either `undefined character code', or */ - /* `undefined selector code', or `no variation selector cmap */ - /* subtable', or `current CharMap is not Unicode'. */ - /* */ - /* <Note> */ - /* If you use FreeType to manipulate the contents of font files */ - /* directly, be aware that the glyph index returned by this function */ - /* doesn't always correspond to the internal indices used within */ - /* the file. This is done to ensure that value~0 always corresponds */ - /* to the `missing glyph'. */ - /* */ - /* This function is only meaningful if */ - /* a) the font has a variation selector cmap sub table, */ - /* and */ - /* b) the current charmap has a Unicode encoding. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ - FT_EXPORT( FT_UInt ) - FT_Face_GetCharVariantIndex( FT_Face face, - FT_ULong charcode, - FT_ULong variantSelector ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetCharVariantIsDefault */ - /* */ - /* <Description> */ - /* Check whether this variant of this Unicode character is the one to */ - /* be found in the `cmap'. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* charcode :: */ - /* The character codepoint in Unicode. */ - /* */ - /* variantSelector :: */ - /* The Unicode codepoint of the variation selector. */ - /* */ - /* <Return> */ - /* 1~if found in the standard (Unicode) cmap, 0~if found in the */ - /* variation selector cmap, or -1 if it is not a variant. */ - /* */ - /* <Note> */ - /* This function is only meaningful if the font has a variation */ - /* selector cmap subtable. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ - FT_EXPORT( FT_Int ) - FT_Face_GetCharVariantIsDefault( FT_Face face, - FT_ULong charcode, - FT_ULong variantSelector ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetVariantSelectors */ - /* */ - /* <Description> */ - /* Return a zero-terminated list of Unicode variant selectors found */ - /* in the font. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* <Return> */ - /* A pointer to an array of selector code points, or NULL if there is */ - /* no valid variant selector cmap subtable. */ - /* */ - /* <Note> */ - /* The last item in the array is~0; the array is owned by the */ - /* @FT_Face object but can be overwritten or released on the next */ - /* call to a FreeType function. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ - FT_EXPORT( FT_UInt32* ) - FT_Face_GetVariantSelectors( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetVariantsOfChar */ - /* */ - /* <Description> */ - /* Return a zero-terminated list of Unicode variant selectors found */ - /* for the specified character code. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* charcode :: */ - /* The character codepoint in Unicode. */ - /* */ - /* <Return> */ - /* A pointer to an array of variant selector code points that are */ - /* active for the given character, or NULL if the corresponding list */ - /* is empty. */ - /* */ - /* <Note> */ - /* The last item in the array is~0; the array is owned by the */ - /* @FT_Face object but can be overwritten or released on the next */ - /* call to a FreeType function. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ - FT_EXPORT( FT_UInt32* ) - FT_Face_GetVariantsOfChar( FT_Face face, - FT_ULong charcode ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetCharsOfVariant */ - /* */ - /* <Description> */ - /* Return a zero-terminated list of Unicode character codes found for */ - /* the specified variant selector. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* variantSelector :: */ - /* The variant selector code point in Unicode. */ - /* */ - /* <Return> */ - /* A list of all the code points that are specified by this selector */ - /* (both default and non-default codes are returned) or NULL if there */ - /* is no valid cmap or the variant selector is invalid. */ - /* */ - /* <Note> */ - /* The last item in the array is~0; the array is owned by the */ - /* @FT_Face object but can be overwritten or released on the next */ - /* call to a FreeType function. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ - FT_EXPORT( FT_UInt32* ) - FT_Face_GetCharsOfVariant( FT_Face face, - FT_ULong variantSelector ); - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* computations */ - /* */ - /* <Title> */ - /* Computations */ - /* */ - /* <Abstract> */ - /* Crunching fixed numbers and vectors. */ - /* */ - /* <Description> */ - /* This section contains various functions used to perform */ - /* computations on 16.16 fixed-float numbers or 2d vectors. */ - /* */ - /* <Order> */ - /* FT_MulDiv */ - /* FT_MulFix */ - /* FT_DivFix */ - /* FT_RoundFix */ - /* FT_CeilFix */ - /* FT_FloorFix */ - /* FT_Vector_Transform */ - /* FT_Matrix_Multiply */ - /* FT_Matrix_Invert */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_MulDiv */ - /* */ - /* <Description> */ - /* A very simple function used to perform the computation `(a*b)/c' */ - /* with maximum accuracy (it uses a 64-bit intermediate integer */ - /* whenever necessary). */ - /* */ - /* This function isn't necessarily as fast as some processor specific */ - /* operations, but is at least completely portable. */ - /* */ - /* <Input> */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. */ - /* c :: The divisor. */ - /* */ - /* <Return> */ - /* The result of `(a*b)/c'. This function never traps when trying to */ - /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ - /* on the signs of `a' and `b'. */ - /* */ - FT_EXPORT( FT_Long ) - FT_MulDiv( FT_Long a, - FT_Long b, - FT_Long c ); - - - /* */ - - /* The following #if 0 ... #endif is for the documentation formatter, */ - /* hiding the internal `FT_MULFIX_INLINED' macro. */ - -#if 0 - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_MulFix */ - /* */ - /* <Description> */ - /* A very simple function used to perform the computation */ - /* `(a*b)/0x10000' with maximum accuracy. Most of the time this is */ - /* used to multiply a given value by a 16.16 fixed-point factor. */ - /* */ - /* <Input> */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. Use a 16.16 factor here whenever */ - /* possible (see note below). */ - /* */ - /* <Return> */ - /* The result of `(a*b)/0x10000'. */ - /* */ - /* <Note> */ - /* This function has been optimized for the case where the absolute */ - /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */ - /* As this happens mainly when scaling from notional units to */ - /* fractional pixels in FreeType, it resulted in noticeable speed */ - /* improvements between versions 2.x and 1.x. */ - /* */ - /* As a conclusion, always try to place a 16.16 factor as the */ - /* _second_ argument of this function; this can make a great */ - /* difference. */ - /* */ - FT_EXPORT( FT_Long ) - FT_MulFix( FT_Long a, - FT_Long b ); - - /* */ -#endif - -#ifdef FT_MULFIX_INLINED -#define FT_MulFix( a, b ) FT_MULFIX_INLINED( a, b ) -#else - FT_EXPORT( FT_Long ) - FT_MulFix( FT_Long a, - FT_Long b ); -#endif - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_DivFix */ - /* */ - /* <Description> */ - /* A very simple function used to perform the computation */ - /* `(a*0x10000)/b' with maximum accuracy. Most of the time, this is */ - /* used to divide a given value by a 16.16 fixed-point factor. */ - /* */ - /* <Input> */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. Use a 16.16 factor here whenever */ - /* possible (see note below). */ - /* */ - /* <Return> */ - /* The result of `(a*0x10000)/b'. */ - /* */ - /* <Note> */ - /* The optimization for FT_DivFix() is simple: If (a~<<~16) fits in */ - /* 32~bits, then the division is computed directly. Otherwise, we */ - /* use a specialized version of @FT_MulDiv. */ - /* */ - FT_EXPORT( FT_Long ) - FT_DivFix( FT_Long a, - FT_Long b ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_RoundFix */ - /* */ - /* <Description> */ - /* A very simple function used to round a 16.16 fixed number. */ - /* */ - /* <Input> */ - /* a :: The number to be rounded. */ - /* */ - /* <Return> */ - /* The result of `(a + 0x8000) & -0x10000'. */ - /* */ - FT_EXPORT( FT_Fixed ) - FT_RoundFix( FT_Fixed a ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_CeilFix */ - /* */ - /* <Description> */ - /* A very simple function used to compute the ceiling function of a */ - /* 16.16 fixed number. */ - /* */ - /* <Input> */ - /* a :: The number for which the ceiling function is to be computed. */ - /* */ - /* <Return> */ - /* The result of `(a + 0x10000 - 1) & -0x10000'. */ - /* */ - FT_EXPORT( FT_Fixed ) - FT_CeilFix( FT_Fixed a ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_FloorFix */ - /* */ - /* <Description> */ - /* A very simple function used to compute the floor function of a */ - /* 16.16 fixed number. */ - /* */ - /* <Input> */ - /* a :: The number for which the floor function is to be computed. */ - /* */ - /* <Return> */ - /* The result of `a & -0x10000'. */ - /* */ - FT_EXPORT( FT_Fixed ) - FT_FloorFix( FT_Fixed a ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Vector_Transform */ - /* */ - /* <Description> */ - /* Transform a single vector through a 2x2 matrix. */ - /* */ - /* <InOut> */ - /* vector :: The target vector to transform. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to the source 2x2 matrix. */ - /* */ - /* <Note> */ - /* The result is undefined if either `vector' or `matrix' is invalid. */ - /* */ - FT_EXPORT( void ) - FT_Vector_Transform( FT_Vector* vec, - const FT_Matrix* matrix ); - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* version */ - /* */ - /* <Title> */ - /* FreeType Version */ - /* */ - /* <Abstract> */ - /* Functions and macros related to FreeType versions. */ - /* */ - /* <Description> */ - /* Note that those functions and macros are of limited use because */ - /* even a new release of FreeType with only documentation changes */ - /* increases the version number. */ - /* */ - /*************************************************************************/ - - - /************************************************************************* - * - * @enum: - * FREETYPE_XXX - * - * @description: - * These three macros identify the FreeType source code version. - * Use @FT_Library_Version to access them at runtime. - * - * @values: - * FREETYPE_MAJOR :: The major version number. - * FREETYPE_MINOR :: The minor version number. - * FREETYPE_PATCH :: The patch level. - * - * @note: - * The version number of FreeType if built as a dynamic link library - * with the `libtool' package is _not_ controlled by these three - * macros. - * - */ -#define FREETYPE_MAJOR 2 -#define FREETYPE_MINOR 5 -#define FREETYPE_PATCH 3 - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Library_Version */ - /* */ - /* <Description> */ - /* Return the version of the FreeType library being used. This is */ - /* useful when dynamically linking to the library, since one cannot */ - /* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */ - /* @FREETYPE_PATCH. */ - /* */ - /* <Input> */ - /* library :: A source library handle. */ - /* */ - /* <Output> */ - /* amajor :: The major version number. */ - /* */ - /* aminor :: The minor version number. */ - /* */ - /* apatch :: The patch version number. */ - /* */ - /* <Note> */ - /* The reason why this function takes a `library' argument is because */ - /* certain programs implement library initialization in a custom way */ - /* that doesn't use @FT_Init_FreeType. */ - /* */ - /* In such cases, the library version might not be available before */ - /* the library object has been created. */ - /* */ - FT_EXPORT( void ) - FT_Library_Version( FT_Library library, - FT_Int *amajor, - FT_Int *aminor, - FT_Int *apatch ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_CheckTrueTypePatents */ - /* */ - /* <Description> */ - /* Parse all bytecode instructions of a TrueType font file to check */ - /* whether any of the patented opcodes are used. This is only useful */ - /* if you want to be able to use the unpatented hinter with */ - /* fonts that do *not* use these opcodes. */ - /* */ - /* Note that this function parses *all* glyph instructions in the */ - /* font file, which may be slow. */ - /* */ - /* <Input> */ - /* face :: A face handle. */ - /* */ - /* <Return> */ - /* 1~if this is a TrueType font that uses one of the patented */ - /* opcodes, 0~otherwise. */ - /* */ - /* <Note> */ - /* Since May 2010, TrueType hinting is no longer patented. */ - /* */ - /* <Since> */ - /* 2.3.5 */ - /* */ - FT_EXPORT( FT_Bool ) - FT_Face_CheckTrueTypePatents( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_SetUnpatentedHinting */ - /* */ - /* <Description> */ - /* Enable or disable the unpatented hinter for a given face. */ - /* Only enable it if you have determined that the face doesn't */ - /* use any patented opcodes (see @FT_Face_CheckTrueTypePatents). */ - /* */ - /* <Input> */ - /* face :: A face handle. */ - /* */ - /* value :: New boolean setting. */ - /* */ - /* <Return> */ - /* The old setting value. This will always be false if this is not */ - /* an SFNT font, or if the unpatented hinter is not compiled in this */ - /* instance of the library. */ - /* */ - /* <Note> */ - /* Since May 2010, TrueType hinting is no longer patented. */ - /* */ - /* <Since> */ - /* 2.3.5 */ - /* */ - FT_EXPORT( FT_Bool ) - FT_Face_SetUnpatentedHinting( FT_Face face, - FT_Bool value ); - - /* */ - - -FT_END_HEADER - -#endif /* __FREETYPE_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ft2build.h b/thirdparty/include/freetype/ft2build.h deleted file mode 100644 index 1f0436cfb..000000000 --- a/thirdparty/include/freetype/ft2build.h +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************/ -/* */ -/* ft2build.h */ -/* */ -/* FreeType 2 build and setup macros. */ -/* */ -/* Copyright 1996-2001, 2006, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This is the `entry point' for FreeType header file inclusions. It is */ - /* the only header file which should be included directly; all other */ - /* FreeType header files should be accessed with macro names (after */ - /* including `ft2build.h'). */ - /* */ - /* A typical example is */ - /* */ - /* #include <freetype/ft2build.h> */ - /* #include FT_FREETYPE_H */ - /* */ - /*************************************************************************/ - - -#ifndef __FT2BUILD_H__ -#define __FT2BUILD_H__ - -#include <freetype/config/ftheader.h> - -#endif /* __FT2BUILD_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftadvanc.h b/thirdparty/include/freetype/ftadvanc.h deleted file mode 100644 index ce4a6d893..000000000 --- a/thirdparty/include/freetype/ftadvanc.h +++ /dev/null @@ -1,182 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftadvanc.h */ -/* */ -/* Quick computation of advance widths (specification only). */ -/* */ -/* Copyright 2008, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTADVANC_H__ -#define __FTADVANC_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /************************************************************************** - * - * @section: - * quick_advance - * - * @title: - * Quick retrieval of advance values - * - * @abstract: - * Retrieve horizontal and vertical advance values without processing - * glyph outlines, if possible. - * - * @description: - * This section contains functions to quickly extract advance values - * without handling glyph outlines, if possible. - */ - - - /*************************************************************************/ - /* */ - /* <Const> */ - /* FT_ADVANCE_FLAG_FAST_ONLY */ - /* */ - /* <Description> */ - /* A bit-flag to be OR-ed with the `flags' parameter of the */ - /* @FT_Get_Advance and @FT_Get_Advances functions. */ - /* */ - /* If set, it indicates that you want these functions to fail if the */ - /* corresponding hinting mode or font driver doesn't allow for very */ - /* quick advance computation. */ - /* */ - /* Typically, glyphs that are either unscaled, unhinted, bitmapped, */ - /* or light-hinted can have their advance width computed very */ - /* quickly. */ - /* */ - /* Normal and bytecode hinted modes that require loading, scaling, */ - /* and hinting of the glyph outline, are extremely slow by */ - /* comparison. */ - /* */ -#define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000UL - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Advance */ - /* */ - /* <Description> */ - /* Retrieve the advance value of a given glyph outline in an */ - /* @FT_Face. */ - /* */ - /* <Input> */ - /* face :: The source @FT_Face handle. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* load_flags :: A set of bit flags similar to those used when */ - /* calling @FT_Load_Glyph, used to determine what kind */ - /* of advances you need. */ - /* <Output> */ - /* padvance :: The advance value. If scaling is performed (based on */ - /* the value of `load_flags'), the advance value is in */ - /* 16.16 format. Otherwise, it is in font units. */ - /* */ - /* If @FT_LOAD_VERTICAL_LAYOUT is set, this is the */ - /* vertical advance corresponding to a vertical layout. */ - /* Otherwise, it is the horizontal advance in a */ - /* horizontal layout. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */ - /* if the corresponding font backend doesn't have a quick way to */ - /* retrieve the advances. */ - /* */ - /* A scaled advance is returned in 16.16 format but isn't transformed */ - /* by the affine transformation specified by @FT_Set_Transform. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Advance( FT_Face face, - FT_UInt gindex, - FT_Int32 load_flags, - FT_Fixed *padvance ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Advances */ - /* */ - /* <Description> */ - /* Retrieve the advance values of several glyph outlines in an */ - /* @FT_Face. */ - /* */ - /* <Input> */ - /* face :: The source @FT_Face handle. */ - /* */ - /* start :: The first glyph index. */ - /* */ - /* count :: The number of advance values you want to retrieve. */ - /* */ - /* load_flags :: A set of bit flags similar to those used when */ - /* calling @FT_Load_Glyph. */ - /* */ - /* <Output> */ - /* padvance :: The advance values. This array, to be provided by the */ - /* caller, must contain at least `count' elements. */ - /* */ - /* If scaling is performed (based on the value of */ - /* `load_flags'), the advance values are in 16.16 format. */ - /* Otherwise, they are in font units. */ - /* */ - /* If @FT_LOAD_VERTICAL_LAYOUT is set, these are the */ - /* vertical advances corresponding to a vertical layout. */ - /* Otherwise, they are the horizontal advances in a */ - /* horizontal layout. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */ - /* if the corresponding font backend doesn't have a quick way to */ - /* retrieve the advances. */ - /* */ - /* Scaled advances are returned in 16.16 format but aren't */ - /* transformed by the affine transformation specified by */ - /* @FT_Set_Transform. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Advances( FT_Face face, - FT_UInt start, - FT_UInt count, - FT_Int32 load_flags, - FT_Fixed *padvances ); - -/* */ - - -FT_END_HEADER - -#endif /* __FTADVANC_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftautoh.h b/thirdparty/include/freetype/ftautoh.h deleted file mode 100644 index 74aa9d906..000000000 --- a/thirdparty/include/freetype/ftautoh.h +++ /dev/null @@ -1,402 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftautoh.h */ -/* */ -/* FreeType API for controlling the auto-hinter (specification only). */ -/* */ -/* Copyright 2012, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTAUTOH_H__ -#define __FTAUTOH_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /************************************************************************** - * - * @section: - * auto_hinter - * - * @title: - * The auto-hinter - * - * @abstract: - * Controlling the auto-hinting module. - * - * @description: - * While FreeType's auto-hinter doesn't expose API functions by itself, - * it is possible to control its behaviour with @FT_Property_Set and - * @FT_Property_Get. The following lists the available properties - * together with the necessary macros and structures. - * - * Note that the auto-hinter's module name is `autofitter' for - * historical reasons. - * - */ - - - /************************************************************************** - * - * @property: - * glyph-to-script-map - * - * @description: - * *Experimental* *only* - * - * The auto-hinter provides various script modules to hint glyphs. - * Examples of supported scripts are Latin or CJK. Before a glyph is - * auto-hinted, the Unicode character map of the font gets examined, and - * the script is then determined based on Unicode character ranges, see - * below. - * - * OpenType fonts, however, often provide much more glyphs than - * character codes (small caps, superscripts, ligatures, swashes, etc.), - * to be controlled by so-called `features'. Handling OpenType features - * can be quite complicated and thus needs a separate library on top of - * FreeType. - * - * The mapping between glyph indices and scripts (in the auto-hinter - * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an - * array with `num_glyphs' elements, as found in the font's @FT_Face - * structure. The `glyph-to-script-map' property returns a pointer to - * this array, which can be modified as needed. Note that the - * modification should happen before the first glyph gets processed by - * the auto-hinter so that the global analysis of the font shapes - * actually uses the modified mapping. - * - * The following example code demonstrates how to access it (omitting - * the error handling). - * - * { - * FT_Library library; - * FT_Face face; - * FT_Prop_GlyphToScriptMap prop; - * - * - * FT_Init_FreeType( &library ); - * FT_New_Face( library, "foo.ttf", 0, &face ); - * - * prop.face = face; - * - * FT_Property_Get( library, "autofitter", - * "glyph-to-script-map", &prop ); - * - * // adjust `prop.map' as needed right here - * - * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT ); - * } - * - */ - - - /************************************************************************** - * - * @enum: - * FT_AUTOHINTER_SCRIPT_XXX - * - * @description: - * *Experimental* *only* - * - * A list of constants used for the @glyph-to-script-map property to - * specify the script submodule the auto-hinter should use for hinting a - * particular glyph. - * - * @values: - * FT_AUTOHINTER_SCRIPT_NONE :: - * Don't auto-hint this glyph. - * - * FT_AUTOHINTER_SCRIPT_LATIN :: - * Apply the latin auto-hinter. For the auto-hinter, `latin' is a - * very broad term, including Cyrillic and Greek also since characters - * from those scripts share the same design constraints. - * - * By default, characters from the following Unicode ranges are - * assigned to this submodule. - * - * { - * U+0020 - U+007F // Basic Latin (no control characters) - * U+00A0 - U+00FF // Latin-1 Supplement (no control characters) - * U+0100 - U+017F // Latin Extended-A - * U+0180 - U+024F // Latin Extended-B - * U+0250 - U+02AF // IPA Extensions - * U+02B0 - U+02FF // Spacing Modifier Letters - * U+0300 - U+036F // Combining Diacritical Marks - * U+0370 - U+03FF // Greek and Coptic - * U+0400 - U+04FF // Cyrillic - * U+0500 - U+052F // Cyrillic Supplement - * U+1D00 - U+1D7F // Phonetic Extensions - * U+1D80 - U+1DBF // Phonetic Extensions Supplement - * U+1DC0 - U+1DFF // Combining Diacritical Marks Supplement - * U+1E00 - U+1EFF // Latin Extended Additional - * U+1F00 - U+1FFF // Greek Extended - * U+2000 - U+206F // General Punctuation - * U+2070 - U+209F // Superscripts and Subscripts - * U+20A0 - U+20CF // Currency Symbols - * U+2150 - U+218F // Number Forms - * U+2460 - U+24FF // Enclosed Alphanumerics - * U+2C60 - U+2C7F // Latin Extended-C - * U+2DE0 - U+2DFF // Cyrillic Extended-A - * U+2E00 - U+2E7F // Supplemental Punctuation - * U+A640 - U+A69F // Cyrillic Extended-B - * U+A720 - U+A7FF // Latin Extended-D - * U+FB00 - U+FB06 // Alphab. Present. Forms (Latin Ligatures) - * U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols - * U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement - * } - * - * FT_AUTOHINTER_SCRIPT_CJK :: - * Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old - * Vietnamese, and some other scripts. - * - * By default, characters from the following Unicode ranges are - * assigned to this submodule. - * - * { - * U+1100 - U+11FF // Hangul Jamo - * U+2E80 - U+2EFF // CJK Radicals Supplement - * U+2F00 - U+2FDF // Kangxi Radicals - * U+2FF0 - U+2FFF // Ideographic Description Characters - * U+3000 - U+303F // CJK Symbols and Punctuation - * U+3040 - U+309F // Hiragana - * U+30A0 - U+30FF // Katakana - * U+3100 - U+312F // Bopomofo - * U+3130 - U+318F // Hangul Compatibility Jamo - * U+3190 - U+319F // Kanbun - * U+31A0 - U+31BF // Bopomofo Extended - * U+31C0 - U+31EF // CJK Strokes - * U+31F0 - U+31FF // Katakana Phonetic Extensions - * U+3200 - U+32FF // Enclosed CJK Letters and Months - * U+3300 - U+33FF // CJK Compatibility - * U+3400 - U+4DBF // CJK Unified Ideographs Extension A - * U+4DC0 - U+4DFF // Yijing Hexagram Symbols - * U+4E00 - U+9FFF // CJK Unified Ideographs - * U+A960 - U+A97F // Hangul Jamo Extended-A - * U+AC00 - U+D7AF // Hangul Syllables - * U+D7B0 - U+D7FF // Hangul Jamo Extended-B - * U+F900 - U+FAFF // CJK Compatibility Ideographs - * U+FE10 - U+FE1F // Vertical forms - * U+FE30 - U+FE4F // CJK Compatibility Forms - * U+FF00 - U+FFEF // Halfwidth and Fullwidth Forms - * U+1B000 - U+1B0FF // Kana Supplement - * U+1D300 - U+1D35F // Tai Xuan Hing Symbols - * U+1F200 - U+1F2FF // Enclosed Ideographic Supplement - * U+20000 - U+2A6DF // CJK Unified Ideographs Extension B - * U+2A700 - U+2B73F // CJK Unified Ideographs Extension C - * U+2B740 - U+2B81F // CJK Unified Ideographs Extension D - * U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement - * } - * - * FT_AUTOHINTER_SCRIPT_INDIC :: - * Apply the indic auto-hinter, covering all major scripts from the - * Indian sub-continent and some other related scripts like Thai, Lao, - * or Tibetan. - * - * By default, characters from the following Unicode ranges are - * assigned to this submodule. - * - * { - * U+0900 - U+0DFF // Indic Range - * U+0F00 - U+0FFF // Tibetan - * U+1900 - U+194F // Limbu - * U+1B80 - U+1BBF // Sundanese - * U+1C80 - U+1CDF // Meetei Mayak - * U+A800 - U+A82F // Syloti Nagri - * U+11800 - U+118DF // Sharada - * } - * - * Note that currently Indic support is rudimentary only, missing blue - * zone support. - * - */ -#define FT_AUTOHINTER_SCRIPT_NONE 0 -#define FT_AUTOHINTER_SCRIPT_LATIN 1 -#define FT_AUTOHINTER_SCRIPT_CJK 2 -#define FT_AUTOHINTER_SCRIPT_INDIC 3 - - - /************************************************************************** - * - * @struct: - * FT_Prop_GlyphToScriptMap - * - * @description: - * *Experimental* *only* - * - * The data exchange structure for the @glyph-to-script-map property. - * - */ - typedef struct FT_Prop_GlyphToScriptMap_ - { - FT_Face face; - FT_Byte* map; - - } FT_Prop_GlyphToScriptMap; - - - /************************************************************************** - * - * @property: - * fallback-script - * - * @description: - * *Experimental* *only* - * - * If no auto-hinter script module can be assigned to a glyph, a - * fallback script gets assigned to it (see also the - * @glyph-to-script-map property). By default, this is - * @FT_AUTOHINTER_SCRIPT_CJK. Using the `fallback-script' property, - * this fallback value can be changed. - * - * { - * FT_Library library; - * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "autofitter", - * "fallback-script", &fallback_script ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * It's important to use the right timing for changing this value: The - * creation of the glyph-to-script map that eventually uses the - * fallback script value gets triggered either by setting or reading a - * face-specific property like @glyph-to-script-map, or by auto-hinting - * any glyph from that face. In particular, if you have already created - * an @FT_Face structure but not loaded any glyph (using the - * auto-hinter), a change of the fallback script will affect this face. - * - */ - - - /************************************************************************** - * - * @property: - * default-script - * - * @description: - * *Experimental* *only* - * - * If Freetype gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make - * the HarfBuzz library access OpenType features for getting better - * glyph coverages, this property sets the (auto-fitter) script to be - * used for the default (OpenType) script data of a font's GSUB table. - * Features for the default script are intended for all scripts not - * explicitly handled in GSUB; an example is a `dlig' feature, - * containing the combination of the characters `T', `E', and `L' to - * form a `TEL' ligature. - * - * By default, this is @FT_AUTOHINTER_SCRIPT_LATIN. Using the - * `default-script' property, this default value can be changed. - * - * { - * FT_Library library; - * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "autofitter", - * "default-script", &default_script ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * It's important to use the right timing for changing this value: The - * creation of the glyph-to-script map that eventually uses the - * default script value gets triggered either by setting or reading a - * face-specific property like @glyph-to-script-map, or by auto-hinting - * any glyph from that face. In particular, if you have already created - * an @FT_Face structure but not loaded any glyph (using the - * auto-hinter), a change of the default script will affect this face. - * - */ - - - /************************************************************************** - * - * @property: - * increase-x-height - * - * @description: - * For ppem values in the range 6~<= ppem <= `increase-x-height', round - * up the font's x~height much more often than normally. If the value - * is set to~0, which is the default, this feature is switched off. Use - * this property to improve the legibility of small font sizes if - * necessary. - * - * { - * FT_Library library; - * FT_Face face; - * FT_Prop_IncreaseXHeight prop; - * - * - * FT_Init_FreeType( &library ); - * FT_New_Face( library, "foo.ttf", 0, &face ); - * FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 ); - * - * prop.face = face; - * prop.limit = 14; - * - * FT_Property_Set( library, "autofitter", - * "increase-x-height", &prop ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * Set this value right after calling @FT_Set_Char_Size, but before - * loading any glyph (using the auto-hinter). - * - */ - - - /************************************************************************** - * - * @struct: - * FT_Prop_IncreaseXHeight - * - * @description: - * The data exchange structure for the @increase-x-height property. - * - */ - typedef struct FT_Prop_IncreaseXHeight_ - { - FT_Face face; - FT_UInt limit; - - } FT_Prop_IncreaseXHeight; - - - /* */ - -FT_END_HEADER - -#endif /* __FTAUTOH_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftbbox.h b/thirdparty/include/freetype/ftbbox.h deleted file mode 100644 index aa2227d20..000000000 --- a/thirdparty/include/freetype/ftbbox.h +++ /dev/null @@ -1,102 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftbbox.h */ -/* */ -/* FreeType exact bbox computation (specification). */ -/* */ -/* Copyright 1996-2001, 2003, 2007, 2011, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This component has a _single_ role: to compute exact outline bounding */ - /* boxes. */ - /* */ - /* It is separated from the rest of the engine for various technical */ - /* reasons. It may well be integrated in `ftoutln' later. */ - /* */ - /*************************************************************************/ - - -#ifndef __FTBBOX_H__ -#define __FTBBOX_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* outline_processing */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_BBox */ - /* */ - /* <Description> */ - /* Compute the exact bounding box of an outline. This is slower */ - /* than computing the control box. However, it uses an advanced */ - /* algorithm that returns _very_ quickly when the two boxes */ - /* coincide. Otherwise, the outline Bézier arcs are traversed to */ - /* extract their extrema. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source outline. */ - /* */ - /* <Output> */ - /* abbox :: The outline's exact bounding box. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If the font is tricky and the glyph has been loaded with */ - /* @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get */ - /* reasonable values for the BBox it is necessary to load the glyph */ - /* at a large ppem value (so that the hinting instructions can */ - /* properly shift and scale the subglyphs), then extracting the BBox, */ - /* which can be eventually converted back to font units. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Get_BBox( FT_Outline* outline, - FT_BBox *abbox ); - - - /* */ - - -FT_END_HEADER - -#endif /* __FTBBOX_H__ */ - - -/* END */ - - -/* Local Variables: */ -/* coding: utf-8 */ -/* End: */ diff --git a/thirdparty/include/freetype/ftbdf.h b/thirdparty/include/freetype/ftbdf.h deleted file mode 100644 index fdac606c4..000000000 --- a/thirdparty/include/freetype/ftbdf.h +++ /dev/null @@ -1,210 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftbdf.h */ -/* */ -/* FreeType API for accessing BDF-specific strings (specification). */ -/* */ -/* Copyright 2002-2004, 2006, 2009, 2014 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTBDF_H__ -#define __FTBDF_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* bdf_fonts */ - /* */ - /* <Title> */ - /* BDF and PCF Files */ - /* */ - /* <Abstract> */ - /* BDF and PCF specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of functions specific to BDF */ - /* and PCF fonts. */ - /* */ - /*************************************************************************/ - - - /********************************************************************** - * - * @enum: - * FT_PropertyType - * - * @description: - * A list of BDF property types. - * - * @values: - * BDF_PROPERTY_TYPE_NONE :: - * Value~0 is used to indicate a missing property. - * - * BDF_PROPERTY_TYPE_ATOM :: - * Property is a string atom. - * - * BDF_PROPERTY_TYPE_INTEGER :: - * Property is a 32-bit signed integer. - * - * BDF_PROPERTY_TYPE_CARDINAL :: - * Property is a 32-bit unsigned integer. - */ - typedef enum BDF_PropertyType_ - { - BDF_PROPERTY_TYPE_NONE = 0, - BDF_PROPERTY_TYPE_ATOM = 1, - BDF_PROPERTY_TYPE_INTEGER = 2, - BDF_PROPERTY_TYPE_CARDINAL = 3 - - } BDF_PropertyType; - - - /********************************************************************** - * - * @type: - * BDF_Property - * - * @description: - * A handle to a @BDF_PropertyRec structure to model a given - * BDF/PCF property. - */ - typedef struct BDF_PropertyRec_* BDF_Property; - - - /********************************************************************** - * - * @struct: - * BDF_PropertyRec - * - * @description: - * This structure models a given BDF/PCF property. - * - * @fields: - * type :: - * The property type. - * - * u.atom :: - * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be - * NULL, indicating an empty string. - * - * u.integer :: - * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. - * - * u.cardinal :: - * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL. - */ - typedef struct BDF_PropertyRec_ - { - BDF_PropertyType type; - union { - const char* atom; - FT_Int32 integer; - FT_UInt32 cardinal; - - } u; - - } BDF_PropertyRec; - - - /********************************************************************** - * - * @function: - * FT_Get_BDF_Charset_ID - * - * @description: - * Retrieve a BDF font character set identity, according to - * the BDF specification. - * - * @input: - * face :: - * A handle to the input face. - * - * @output: - * acharset_encoding :: - * Charset encoding, as a C~string, owned by the face. - * - * acharset_registry :: - * Charset registry, as a C~string, owned by the face. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with BDF faces, returning an error otherwise. - */ - FT_EXPORT( FT_Error ) - FT_Get_BDF_Charset_ID( FT_Face face, - const char* *acharset_encoding, - const char* *acharset_registry ); - - - /********************************************************************** - * - * @function: - * FT_Get_BDF_Property - * - * @description: - * Retrieve a BDF property from a BDF or PCF font file. - * - * @input: - * face :: A handle to the input face. - * - * name :: The property name. - * - * @output: - * aproperty :: The property. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function works with BDF _and_ PCF fonts. It returns an error - * otherwise. It also returns an error if the property is not in the - * font. - * - * A `property' is a either key-value pair within the STARTPROPERTIES - * ... ENDPROPERTIES block of a BDF font or a key-value pair from the - * `info->props' array within a `FontRec' structure of a PCF font. - * - * Integer properties are always stored as `signed' within PCF fonts; - * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value - * for BDF fonts only. - * - * In case of error, `aproperty->type' is always set to - * @BDF_PROPERTY_TYPE_NONE. - */ - FT_EXPORT( FT_Error ) - FT_Get_BDF_Property( FT_Face face, - const char* prop_name, - BDF_PropertyRec *aproperty ); - - /* */ - -FT_END_HEADER - -#endif /* __FTBDF_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftbitmap.h b/thirdparty/include/freetype/ftbitmap.h deleted file mode 100644 index 318f85a46..000000000 --- a/thirdparty/include/freetype/ftbitmap.h +++ /dev/null @@ -1,227 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftbitmap.h */ -/* */ -/* FreeType utility functions for bitmaps (specification). */ -/* */ -/* Copyright 2004-2006, 2008, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTBITMAP_H__ -#define __FTBITMAP_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* bitmap_handling */ - /* */ - /* <Title> */ - /* Bitmap Handling */ - /* */ - /* <Abstract> */ - /* Handling FT_Bitmap objects. */ - /* */ - /* <Description> */ - /* This section contains functions for converting FT_Bitmap objects. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_New */ - /* */ - /* <Description> */ - /* Initialize a pointer to an @FT_Bitmap structure. */ - /* */ - /* <InOut> */ - /* abitmap :: A pointer to the bitmap structure. */ - /* */ - FT_EXPORT( void ) - FT_Bitmap_New( FT_Bitmap *abitmap ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Copy */ - /* */ - /* <Description> */ - /* Copy a bitmap into another one. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* source :: A handle to the source bitmap. */ - /* */ - /* <Output> */ - /* target :: A handle to the target bitmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Bitmap_Copy( FT_Library library, - const FT_Bitmap *source, - FT_Bitmap *target); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Embolden */ - /* */ - /* <Description> */ - /* Embolden a bitmap. The new bitmap will be about `xStrength' */ - /* pixels wider and `yStrength' pixels higher. The left and bottom */ - /* borders are kept unchanged. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* xStrength :: How strong the glyph is emboldened horizontally. */ - /* Expressed in 26.6 pixel format. */ - /* */ - /* yStrength :: How strong the glyph is emboldened vertically. */ - /* Expressed in 26.6 pixel format. */ - /* */ - /* <InOut> */ - /* bitmap :: A handle to the target bitmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The current implementation restricts `xStrength' to be less than */ - /* or equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */ - /* */ - /* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */ - /* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Bitmap_Embolden( FT_Library library, - FT_Bitmap* bitmap, - FT_Pos xStrength, - FT_Pos yStrength ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Convert */ - /* */ - /* <Description> */ - /* Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp */ - /* to a bitmap object with depth 8bpp, making the number of used */ - /* bytes line (a.k.a. the `pitch') a multiple of `alignment'. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* source :: The source bitmap. */ - /* */ - /* alignment :: The pitch of the bitmap is a multiple of this */ - /* parameter. Common values are 1, 2, or 4. */ - /* */ - /* <Output> */ - /* target :: The target bitmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* It is possible to call @FT_Bitmap_Convert multiple times without */ - /* calling @FT_Bitmap_Done (the memory is simply reallocated). */ - /* */ - /* Use @FT_Bitmap_Done to finally remove the bitmap object. */ - /* */ - /* The `library' argument is taken to have access to FreeType's */ - /* memory handling functions. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Bitmap_Convert( FT_Library library, - const FT_Bitmap *source, - FT_Bitmap *target, - FT_Int alignment ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GlyphSlot_Own_Bitmap */ - /* */ - /* <Description> */ - /* Make sure that a glyph slot owns `slot->bitmap'. */ - /* */ - /* <Input> */ - /* slot :: The glyph slot. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function is to be used in combination with */ - /* @FT_Bitmap_Embolden. */ - /* */ - FT_EXPORT( FT_Error ) - FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Done */ - /* */ - /* <Description> */ - /* Destroy a bitmap object created with @FT_Bitmap_New. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* bitmap :: The bitmap object to be freed. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `library' argument is taken to have access to FreeType's */ - /* memory handling functions. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Bitmap_Done( FT_Library library, - FT_Bitmap *bitmap ); - - - /* */ - - -FT_END_HEADER - -#endif /* __FTBITMAP_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftbzip2.h b/thirdparty/include/freetype/ftbzip2.h deleted file mode 100644 index edb2c3086..000000000 --- a/thirdparty/include/freetype/ftbzip2.h +++ /dev/null @@ -1,102 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftbzip2.h */ -/* */ -/* Bzip2-compressed stream support. */ -/* */ -/* Copyright 2010 by */ -/* Joel Klinghed. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTBZIP2_H__ -#define __FTBZIP2_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /*************************************************************************/ - /* */ - /* <Section> */ - /* bzip2 */ - /* */ - /* <Title> */ - /* BZIP2 Streams */ - /* */ - /* <Abstract> */ - /* Using bzip2-compressed font files. */ - /* */ - /* <Description> */ - /* This section contains the declaration of Bzip2-specific functions. */ - /* */ - /*************************************************************************/ - - - /************************************************************************ - * - * @function: - * FT_Stream_OpenBzip2 - * - * @description: - * Open a new stream to parse bzip2-compressed font files. This is - * mainly used to support the compressed `*.pcf.bz2' fonts that come - * with XFree86. - * - * @input: - * stream :: - * The target embedding stream. - * - * source :: - * The source stream. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source stream must be opened _before_ calling this function. - * - * Calling the internal function `FT_Stream_Close' on the new stream will - * *not* call `FT_Stream_Close' on the source stream. None of the stream - * objects will be released to the heap. - * - * The stream implementation is very basic and resets the decompression - * process each time seeking backwards is needed within the stream. - * - * In certain builds of the library, bzip2 compression recognition is - * automatically handled when calling @FT_New_Face or @FT_Open_Face. - * This means that if no font driver is capable of handling the raw - * compressed file, the library will try to open a bzip2 compressed stream - * from it and re-open the face with it. - * - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with bzip2 support. - */ - FT_EXPORT( FT_Error ) - FT_Stream_OpenBzip2( FT_Stream stream, - FT_Stream source ); - - /* */ - - -FT_END_HEADER - -#endif /* __FTBZIP2_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftcache.h b/thirdparty/include/freetype/ftcache.h deleted file mode 100644 index b3023e047..000000000 --- a/thirdparty/include/freetype/ftcache.h +++ /dev/null @@ -1,1057 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftcache.h */ -/* */ -/* FreeType Cache subsystem (specification). */ -/* */ -/* Copyright 1996-2008, 2010, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTCACHE_H__ -#define __FTCACHE_H__ - - -#include <freetype/ft2build.h> -#include FT_GLYPH_H - - -FT_BEGIN_HEADER - - - /************************************************************************* - * - * <Section> - * cache_subsystem - * - * <Title> - * Cache Sub-System - * - * <Abstract> - * How to cache face, size, and glyph data with FreeType~2. - * - * <Description> - * This section describes the FreeType~2 cache sub-system, which is used - * to limit the number of concurrently opened @FT_Face and @FT_Size - * objects, as well as caching information like character maps and glyph - * images while limiting their maximum memory usage. - * - * Note that all types and functions begin with the `FTC_' prefix. - * - * The cache is highly portable and thus doesn't know anything about the - * fonts installed on your system, or how to access them. This implies - * the following scheme: - * - * First, available or installed font faces are uniquely identified by - * @FTC_FaceID values, provided to the cache by the client. Note that - * the cache only stores and compares these values, and doesn't try to - * interpret them in any way. - * - * Second, the cache calls, only when needed, a client-provided function - * to convert an @FTC_FaceID into a new @FT_Face object. The latter is - * then completely managed by the cache, including its termination - * through @FT_Done_Face. To monitor termination of face objects, the - * finalizer callback in the `generic' field of the @FT_Face object can - * be used, which might also be used to store the @FTC_FaceID of the - * face. - * - * Clients are free to map face IDs to anything else. The most simple - * usage is to associate them to a (pathname,face_index) pair that is - * used to call @FT_New_Face. However, more complex schemes are also - * possible. - * - * Note that for the cache to work correctly, the face ID values must be - * *persistent*, which means that the contents they point to should not - * change at runtime, or that their value should not become invalid. - * - * If this is unavoidable (e.g., when a font is uninstalled at runtime), - * you should call @FTC_Manager_RemoveFaceID as soon as possible, to let - * the cache get rid of any references to the old @FTC_FaceID it may - * keep internally. Failure to do so will lead to incorrect behaviour - * or even crashes. - * - * To use the cache, start with calling @FTC_Manager_New to create a new - * @FTC_Manager object, which models a single cache instance. You can - * then look up @FT_Face and @FT_Size objects with - * @FTC_Manager_LookupFace and @FTC_Manager_LookupSize, respectively. - * - * If you want to use the charmap caching, call @FTC_CMapCache_New, then - * later use @FTC_CMapCache_Lookup to perform the equivalent of - * @FT_Get_Char_Index, only much faster. - * - * If you want to use the @FT_Glyph caching, call @FTC_ImageCache, then - * later use @FTC_ImageCache_Lookup to retrieve the corresponding - * @FT_Glyph objects from the cache. - * - * If you need lots of small bitmaps, it is much more memory efficient - * to call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup. This - * returns @FTC_SBitRec structures, which are used to store small - * bitmaps directly. (A small bitmap is one whose metrics and - * dimensions all fit into 8-bit integers). - * - * We hope to also provide a kerning cache in the near future. - * - * - * <Order> - * FTC_Manager - * FTC_FaceID - * FTC_Face_Requester - * - * FTC_Manager_New - * FTC_Manager_Reset - * FTC_Manager_Done - * FTC_Manager_LookupFace - * FTC_Manager_LookupSize - * FTC_Manager_RemoveFaceID - * - * FTC_Node - * FTC_Node_Unref - * - * FTC_ImageCache - * FTC_ImageCache_New - * FTC_ImageCache_Lookup - * - * FTC_SBit - * FTC_SBitCache - * FTC_SBitCache_New - * FTC_SBitCache_Lookup - * - * FTC_CMapCache - * FTC_CMapCache_New - * FTC_CMapCache_Lookup - * - *************************************************************************/ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** BASIC TYPE DEFINITIONS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /************************************************************************* - * - * @type: FTC_FaceID - * - * @description: - * An opaque pointer type that is used to identity face objects. The - * contents of such objects is application-dependent. - * - * These pointers are typically used to point to a user-defined - * structure containing a font file path, and face index. - * - * @note: - * Never use NULL as a valid @FTC_FaceID. - * - * Face IDs are passed by the client to the cache manager that calls, - * when needed, the @FTC_Face_Requester to translate them into new - * @FT_Face objects. - * - * If the content of a given face ID changes at runtime, or if the value - * becomes invalid (e.g., when uninstalling a font), you should - * immediately call @FTC_Manager_RemoveFaceID before any other cache - * function. - * - * Failure to do so will result in incorrect behaviour or even - * memory leaks and crashes. - */ - typedef FT_Pointer FTC_FaceID; - - - /************************************************************************ - * - * @functype: - * FTC_Face_Requester - * - * @description: - * A callback function provided by client applications. It is used by - * the cache manager to translate a given @FTC_FaceID into a new valid - * @FT_Face object, on demand. - * - * <Input> - * face_id :: - * The face ID to resolve. - * - * library :: - * A handle to a FreeType library object. - * - * req_data :: - * Application-provided request data (see note below). - * - * <Output> - * aface :: - * A new @FT_Face handle. - * - * <Return> - * FreeType error code. 0~means success. - * - * <Note> - * The third parameter `req_data' is the same as the one passed by the - * client when @FTC_Manager_New is called. - * - * The face requester should not perform funny things on the returned - * face object, like creating a new @FT_Size for it, or setting a - * transformation through @FT_Set_Transform! - */ - typedef FT_Error - (*FTC_Face_Requester)( FTC_FaceID face_id, - FT_Library library, - FT_Pointer request_data, - FT_Face* aface ); - - /* */ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** CACHE MANAGER OBJECT *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_Manager */ - /* */ - /* <Description> */ - /* This object corresponds to one instance of the cache-subsystem. */ - /* It is used to cache one or more @FT_Face objects, along with */ - /* corresponding @FT_Size objects. */ - /* */ - /* The manager intentionally limits the total number of opened */ - /* @FT_Face and @FT_Size objects to control memory usage. See the */ - /* `max_faces' and `max_sizes' parameters of @FTC_Manager_New. */ - /* */ - /* The manager is also used to cache `nodes' of various types while */ - /* limiting their total memory usage. */ - /* */ - /* All limitations are enforced by keeping lists of managed objects */ - /* in most-recently-used order, and flushing old nodes to make room */ - /* for new ones. */ - /* */ - typedef struct FTC_ManagerRec_* FTC_Manager; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_Node */ - /* */ - /* <Description> */ - /* An opaque handle to a cache node object. Each cache node is */ - /* reference-counted. A node with a count of~0 might be flushed */ - /* out of a full cache whenever a lookup request is performed. */ - /* */ - /* If you look up nodes, you have the ability to `acquire' them, */ - /* i.e., to increment their reference count. This will prevent the */ - /* node from being flushed out of the cache until you explicitly */ - /* `release' it (see @FTC_Node_Unref). */ - /* */ - /* See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. */ - /* */ - typedef struct FTC_NodeRec_* FTC_Node; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_New */ - /* */ - /* <Description> */ - /* Create a new cache manager. */ - /* */ - /* <Input> */ - /* library :: The parent FreeType library handle to use. */ - /* */ - /* max_faces :: Maximum number of opened @FT_Face objects managed by */ - /* this cache instance. Use~0 for defaults. */ - /* */ - /* max_sizes :: Maximum number of opened @FT_Size objects managed by */ - /* this cache instance. Use~0 for defaults. */ - /* */ - /* max_bytes :: Maximum number of bytes to use for cached data nodes. */ - /* Use~0 for defaults. Note that this value does not */ - /* account for managed @FT_Face and @FT_Size objects. */ - /* */ - /* requester :: An application-provided callback used to translate */ - /* face IDs into real @FT_Face objects. */ - /* */ - /* req_data :: A generic pointer that is passed to the requester */ - /* each time it is called (see @FTC_Face_Requester). */ - /* */ - /* <Output> */ - /* amanager :: A handle to a new manager object. 0~in case of */ - /* failure. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_Manager_New( FT_Library library, - FT_UInt max_faces, - FT_UInt max_sizes, - FT_ULong max_bytes, - FTC_Face_Requester requester, - FT_Pointer req_data, - FTC_Manager *amanager ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_Reset */ - /* */ - /* <Description> */ - /* Empty a given cache manager. This simply gets rid of all the */ - /* currently cached @FT_Face and @FT_Size objects within the manager. */ - /* */ - /* <InOut> */ - /* manager :: A handle to the manager. */ - /* */ - FT_EXPORT( void ) - FTC_Manager_Reset( FTC_Manager manager ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_Done */ - /* */ - /* <Description> */ - /* Destroy a given manager after emptying it. */ - /* */ - /* <Input> */ - /* manager :: A handle to the target cache manager object. */ - /* */ - FT_EXPORT( void ) - FTC_Manager_Done( FTC_Manager manager ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_LookupFace */ - /* */ - /* <Description> */ - /* Retrieve the @FT_Face object that corresponds to a given face ID */ - /* through a cache manager. */ - /* */ - /* <Input> */ - /* manager :: A handle to the cache manager. */ - /* */ - /* face_id :: The ID of the face object. */ - /* */ - /* <Output> */ - /* aface :: A handle to the face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The returned @FT_Face object is always owned by the manager. You */ - /* should never try to discard it yourself. */ - /* */ - /* The @FT_Face object doesn't necessarily have a current size object */ - /* (i.e., face->size can be~0). If you need a specific `font size', */ - /* use @FTC_Manager_LookupSize instead. */ - /* */ - /* Never change the face's transformation matrix (i.e., never call */ - /* the @FT_Set_Transform function) on a returned face! If you need */ - /* to transform glyphs, do it yourself after glyph loading. */ - /* */ - /* When you perform a lookup, out-of-memory errors are detected */ - /* _within_ the lookup and force incremental flushes of the cache */ - /* until enough memory is released for the lookup to succeed. */ - /* */ - /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */ - /* already been completely flushed, and still no memory was available */ - /* for the operation. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_Manager_LookupFace( FTC_Manager manager, - FTC_FaceID face_id, - FT_Face *aface ); - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FTC_ScalerRec */ - /* */ - /* <Description> */ - /* A structure used to describe a given character size in either */ - /* pixels or points to the cache manager. See */ - /* @FTC_Manager_LookupSize. */ - /* */ - /* <Fields> */ - /* face_id :: The source face ID. */ - /* */ - /* width :: The character width. */ - /* */ - /* height :: The character height. */ - /* */ - /* pixel :: A Boolean. If 1, the `width' and `height' fields are */ - /* interpreted as integer pixel character sizes. */ - /* Otherwise, they are expressed as 1/64th of points. */ - /* */ - /* x_res :: Only used when `pixel' is value~0 to indicate the */ - /* horizontal resolution in dpi. */ - /* */ - /* y_res :: Only used when `pixel' is value~0 to indicate the */ - /* vertical resolution in dpi. */ - /* */ - /* <Note> */ - /* This type is mainly used to retrieve @FT_Size objects through the */ - /* cache manager. */ - /* */ - typedef struct FTC_ScalerRec_ - { - FTC_FaceID face_id; - FT_UInt width; - FT_UInt height; - FT_Int pixel; - FT_UInt x_res; - FT_UInt y_res; - - } FTC_ScalerRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FTC_Scaler */ - /* */ - /* <Description> */ - /* A handle to an @FTC_ScalerRec structure. */ - /* */ - typedef struct FTC_ScalerRec_* FTC_Scaler; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_LookupSize */ - /* */ - /* <Description> */ - /* Retrieve the @FT_Size object that corresponds to a given */ - /* @FTC_ScalerRec pointer through a cache manager. */ - /* */ - /* <Input> */ - /* manager :: A handle to the cache manager. */ - /* */ - /* scaler :: A scaler handle. */ - /* */ - /* <Output> */ - /* asize :: A handle to the size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The returned @FT_Size object is always owned by the manager. You */ - /* should never try to discard it by yourself. */ - /* */ - /* You can access the parent @FT_Face object simply as `size->face' */ - /* if you need it. Note that this object is also owned by the */ - /* manager. */ - /* */ - /* <Note> */ - /* When you perform a lookup, out-of-memory errors are detected */ - /* _within_ the lookup and force incremental flushes of the cache */ - /* until enough memory is released for the lookup to succeed. */ - /* */ - /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */ - /* already been completely flushed, and still no memory is available */ - /* for the operation. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_Manager_LookupSize( FTC_Manager manager, - FTC_Scaler scaler, - FT_Size *asize ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Node_Unref */ - /* */ - /* <Description> */ - /* Decrement a cache node's internal reference count. When the count */ - /* reaches 0, it is not destroyed but becomes eligible for subsequent */ - /* cache flushes. */ - /* */ - /* <Input> */ - /* node :: The cache node handle. */ - /* */ - /* manager :: The cache manager handle. */ - /* */ - FT_EXPORT( void ) - FTC_Node_Unref( FTC_Node node, - FTC_Manager manager ); - - - /************************************************************************* - * - * @function: - * FTC_Manager_RemoveFaceID - * - * @description: - * A special function used to indicate to the cache manager that - * a given @FTC_FaceID is no longer valid, either because its - * content changed, or because it was deallocated or uninstalled. - * - * @input: - * manager :: - * The cache manager handle. - * - * face_id :: - * The @FTC_FaceID to be removed. - * - * @note: - * This function flushes all nodes from the cache corresponding to this - * `face_id', with the exception of nodes with a non-null reference - * count. - * - * Such nodes are however modified internally so as to never appear - * in later lookups with the same `face_id' value, and to be immediately - * destroyed when released by all their users. - * - */ - FT_EXPORT( void ) - FTC_Manager_RemoveFaceID( FTC_Manager manager, - FTC_FaceID face_id ); - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* cache_subsystem */ - /* */ - /*************************************************************************/ - - /************************************************************************* - * - * @type: - * FTC_CMapCache - * - * @description: - * An opaque handle used to model a charmap cache. This cache is to - * hold character codes -> glyph indices mappings. - * - */ - typedef struct FTC_CMapCacheRec_* FTC_CMapCache; - - - /************************************************************************* - * - * @function: - * FTC_CMapCache_New - * - * @description: - * Create a new charmap cache. - * - * @input: - * manager :: - * A handle to the cache manager. - * - * @output: - * acache :: - * A new cache handle. NULL in case of error. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * Like all other caches, this one will be destroyed with the cache - * manager. - * - */ - FT_EXPORT( FT_Error ) - FTC_CMapCache_New( FTC_Manager manager, - FTC_CMapCache *acache ); - - - /************************************************************************ - * - * @function: - * FTC_CMapCache_Lookup - * - * @description: - * Translate a character code into a glyph index, using the charmap - * cache. - * - * @input: - * cache :: - * A charmap cache handle. - * - * face_id :: - * The source face ID. - * - * cmap_index :: - * The index of the charmap in the source face. Any negative value - * means to use the cache @FT_Face's default charmap. - * - * char_code :: - * The character code (in the corresponding charmap). - * - * @return: - * Glyph index. 0~means `no glyph'. - * - */ - FT_EXPORT( FT_UInt ) - FTC_CMapCache_Lookup( FTC_CMapCache cache, - FTC_FaceID face_id, - FT_Int cmap_index, - FT_UInt32 char_code ); - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* cache_subsystem */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** IMAGE CACHE OBJECT *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /************************************************************************* - * - * @struct: - * FTC_ImageTypeRec - * - * @description: - * A structure used to model the type of images in a glyph cache. - * - * @fields: - * face_id :: - * The face ID. - * - * width :: - * The width in pixels. - * - * height :: - * The height in pixels. - * - * flags :: - * The load flags, as in @FT_Load_Glyph. - * - */ - typedef struct FTC_ImageTypeRec_ - { - FTC_FaceID face_id; - FT_Int width; - FT_Int height; - FT_Int32 flags; - - } FTC_ImageTypeRec; - - - /************************************************************************* - * - * @type: - * FTC_ImageType - * - * @description: - * A handle to an @FTC_ImageTypeRec structure. - * - */ - typedef struct FTC_ImageTypeRec_* FTC_ImageType; - - - /* */ - - -#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \ - ( (d1)->face_id == (d2)->face_id && \ - (d1)->width == (d2)->width && \ - (d1)->flags == (d2)->flags ) - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_ImageCache */ - /* */ - /* <Description> */ - /* A handle to a glyph image cache object. They are designed to */ - /* hold many distinct glyph images while not exceeding a certain */ - /* memory threshold. */ - /* */ - typedef struct FTC_ImageCacheRec_* FTC_ImageCache; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_ImageCache_New */ - /* */ - /* <Description> */ - /* Create a new glyph image cache. */ - /* */ - /* <Input> */ - /* manager :: The parent manager for the image cache. */ - /* */ - /* <Output> */ - /* acache :: A handle to the new glyph image cache object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_ImageCache_New( FTC_Manager manager, - FTC_ImageCache *acache ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_ImageCache_Lookup */ - /* */ - /* <Description> */ - /* Retrieve a given glyph image from a glyph image cache. */ - /* */ - /* <Input> */ - /* cache :: A handle to the source glyph image cache. */ - /* */ - /* type :: A pointer to a glyph image type descriptor. */ - /* */ - /* gindex :: The glyph index to retrieve. */ - /* */ - /* <Output> */ - /* aglyph :: The corresponding @FT_Glyph object. 0~in case of */ - /* failure. */ - /* */ - /* anode :: Used to return the address of of the corresponding cache */ - /* node after incrementing its reference count (see note */ - /* below). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The returned glyph is owned and managed by the glyph image cache. */ - /* Never try to transform or discard it manually! You can however */ - /* create a copy with @FT_Glyph_Copy and modify the new one. */ - /* */ - /* If `anode' is _not_ NULL, it receives the address of the cache */ - /* node containing the glyph image, after increasing its reference */ - /* count. This ensures that the node (as well as the @FT_Glyph) will */ - /* always be kept in the cache until you call @FTC_Node_Unref to */ - /* `release' it. */ - /* */ - /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the @FT_Glyph could be flushed out of the cache on the next */ - /* call to one of the caching sub-system APIs. Don't assume that it */ - /* is persistent! */ - /* */ - FT_EXPORT( FT_Error ) - FTC_ImageCache_Lookup( FTC_ImageCache cache, - FTC_ImageType type, - FT_UInt gindex, - FT_Glyph *aglyph, - FTC_Node *anode ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_ImageCache_LookupScaler */ - /* */ - /* <Description> */ - /* A variant of @FTC_ImageCache_Lookup that uses an @FTC_ScalerRec */ - /* to specify the face ID and its size. */ - /* */ - /* <Input> */ - /* cache :: A handle to the source glyph image cache. */ - /* */ - /* scaler :: A pointer to a scaler descriptor. */ - /* */ - /* load_flags :: The corresponding load flags. */ - /* */ - /* gindex :: The glyph index to retrieve. */ - /* */ - /* <Output> */ - /* aglyph :: The corresponding @FT_Glyph object. 0~in case of */ - /* failure. */ - /* */ - /* anode :: Used to return the address of of the corresponding */ - /* cache node after incrementing its reference count */ - /* (see note below). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The returned glyph is owned and managed by the glyph image cache. */ - /* Never try to transform or discard it manually! You can however */ - /* create a copy with @FT_Glyph_Copy and modify the new one. */ - /* */ - /* If `anode' is _not_ NULL, it receives the address of the cache */ - /* node containing the glyph image, after increasing its reference */ - /* count. This ensures that the node (as well as the @FT_Glyph) will */ - /* always be kept in the cache until you call @FTC_Node_Unref to */ - /* `release' it. */ - /* */ - /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the @FT_Glyph could be flushed out of the cache on the next */ - /* call to one of the caching sub-system APIs. Don't assume that it */ - /* is persistent! */ - /* */ - /* Calls to @FT_Set_Char_Size and friends have no effect on cached */ - /* glyphs; you should always use the FreeType cache API instead. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_ImageCache_LookupScaler( FTC_ImageCache cache, - FTC_Scaler scaler, - FT_ULong load_flags, - FT_UInt gindex, - FT_Glyph *aglyph, - FTC_Node *anode ); - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_SBit */ - /* */ - /* <Description> */ - /* A handle to a small bitmap descriptor. See the @FTC_SBitRec */ - /* structure for details. */ - /* */ - typedef struct FTC_SBitRec_* FTC_SBit; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FTC_SBitRec */ - /* */ - /* <Description> */ - /* A very compact structure used to describe a small glyph bitmap. */ - /* */ - /* <Fields> */ - /* width :: The bitmap width in pixels. */ - /* */ - /* height :: The bitmap height in pixels. */ - /* */ - /* left :: The horizontal distance from the pen position to the */ - /* left bitmap border (a.k.a. `left side bearing', or */ - /* `lsb'). */ - /* */ - /* top :: The vertical distance from the pen position (on the */ - /* baseline) to the upper bitmap border (a.k.a. `top */ - /* side bearing'). The distance is positive for upwards */ - /* y~coordinates. */ - /* */ - /* format :: The format of the glyph bitmap (monochrome or gray). */ - /* */ - /* max_grays :: Maximum gray level value (in the range 1 to~255). */ - /* */ - /* pitch :: The number of bytes per bitmap line. May be positive */ - /* or negative. */ - /* */ - /* xadvance :: The horizontal advance width in pixels. */ - /* */ - /* yadvance :: The vertical advance height in pixels. */ - /* */ - /* buffer :: A pointer to the bitmap pixels. */ - /* */ - typedef struct FTC_SBitRec_ - { - FT_Byte width; - FT_Byte height; - FT_Char left; - FT_Char top; - - FT_Byte format; - FT_Byte max_grays; - FT_Short pitch; - FT_Char xadvance; - FT_Char yadvance; - - FT_Byte* buffer; - - } FTC_SBitRec; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_SBitCache */ - /* */ - /* <Description> */ - /* A handle to a small bitmap cache. These are special cache objects */ - /* used to store small glyph bitmaps (and anti-aliased pixmaps) in a */ - /* much more efficient way than the traditional glyph image cache */ - /* implemented by @FTC_ImageCache. */ - /* */ - typedef struct FTC_SBitCacheRec_* FTC_SBitCache; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_SBitCache_New */ - /* */ - /* <Description> */ - /* Create a new cache to store small glyph bitmaps. */ - /* */ - /* <Input> */ - /* manager :: A handle to the source cache manager. */ - /* */ - /* <Output> */ - /* acache :: A handle to the new sbit cache. NULL in case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_SBitCache_New( FTC_Manager manager, - FTC_SBitCache *acache ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_SBitCache_Lookup */ - /* */ - /* <Description> */ - /* Look up a given small glyph bitmap in a given sbit cache and */ - /* `lock' it to prevent its flushing from the cache until needed. */ - /* */ - /* <Input> */ - /* cache :: A handle to the source sbit cache. */ - /* */ - /* type :: A pointer to the glyph image type descriptor. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* <Output> */ - /* sbit :: A handle to a small bitmap descriptor. */ - /* */ - /* anode :: Used to return the address of of the corresponding cache */ - /* node after incrementing its reference count (see note */ - /* below). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The small bitmap descriptor and its bit buffer are owned by the */ - /* cache and should never be freed by the application. They might */ - /* as well disappear from memory on the next cache lookup, so don't */ - /* treat them as persistent data. */ - /* */ - /* The descriptor's `buffer' field is set to~0 to indicate a missing */ - /* glyph bitmap. */ - /* */ - /* If `anode' is _not_ NULL, it receives the address of the cache */ - /* node containing the bitmap, after increasing its reference count. */ - /* This ensures that the node (as well as the image) will always be */ - /* kept in the cache until you call @FTC_Node_Unref to `release' it. */ - /* */ - /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the bitmap could be flushed out of the cache on the next */ - /* call to one of the caching sub-system APIs. Don't assume that it */ - /* is persistent! */ - /* */ - FT_EXPORT( FT_Error ) - FTC_SBitCache_Lookup( FTC_SBitCache cache, - FTC_ImageType type, - FT_UInt gindex, - FTC_SBit *sbit, - FTC_Node *anode ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_SBitCache_LookupScaler */ - /* */ - /* <Description> */ - /* A variant of @FTC_SBitCache_Lookup that uses an @FTC_ScalerRec */ - /* to specify the face ID and its size. */ - /* */ - /* <Input> */ - /* cache :: A handle to the source sbit cache. */ - /* */ - /* scaler :: A pointer to the scaler descriptor. */ - /* */ - /* load_flags :: The corresponding load flags. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* <Output> */ - /* sbit :: A handle to a small bitmap descriptor. */ - /* */ - /* anode :: Used to return the address of of the corresponding */ - /* cache node after incrementing its reference count */ - /* (see note below). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The small bitmap descriptor and its bit buffer are owned by the */ - /* cache and should never be freed by the application. They might */ - /* as well disappear from memory on the next cache lookup, so don't */ - /* treat them as persistent data. */ - /* */ - /* The descriptor's `buffer' field is set to~0 to indicate a missing */ - /* glyph bitmap. */ - /* */ - /* If `anode' is _not_ NULL, it receives the address of the cache */ - /* node containing the bitmap, after increasing its reference count. */ - /* This ensures that the node (as well as the image) will always be */ - /* kept in the cache until you call @FTC_Node_Unref to `release' it. */ - /* */ - /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the bitmap could be flushed out of the cache on the next */ - /* call to one of the caching sub-system APIs. Don't assume that it */ - /* is persistent! */ - /* */ - FT_EXPORT( FT_Error ) - FTC_SBitCache_LookupScaler( FTC_SBitCache cache, - FTC_Scaler scaler, - FT_ULong load_flags, - FT_UInt gindex, - FTC_SBit *sbit, - FTC_Node *anode ); - - - /* */ - -FT_END_HEADER - -#endif /* __FTCACHE_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftcffdrv.h b/thirdparty/include/freetype/ftcffdrv.h deleted file mode 100644 index c71f11e5f..000000000 --- a/thirdparty/include/freetype/ftcffdrv.h +++ /dev/null @@ -1,254 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftcffdrv.h */ -/* */ -/* FreeType API for controlling the CFF driver (specification only). */ -/* */ -/* Copyright 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTCFFDRV_H__ -#define __FTCFFDRV_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /************************************************************************** - * - * @section: - * cff_driver - * - * @title: - * The CFF driver - * - * @abstract: - * Controlling the CFF driver module. - * - * @description: - * While FreeType's CFF driver doesn't expose API functions by itself, - * it is possible to control its behaviour with @FT_Property_Set and - * @FT_Property_Get. The list below gives the available properties - * together with the necessary macros and structures. - * - * The CFF driver's module name is `cff'. - * - * *Hinting* *and* *antialiasing* *principles* *of* *the* *new* *engine* - * - * The rasterizer is positioning horizontal features (e.g., ascender - * height & x-height, or crossbars) on the pixel grid and minimizing the - * amount of antialiasing applied to them, while placing vertical - * features (vertical stems) on the pixel grid without hinting, thus - * representing the stem position and weight accurately. Sometimes the - * vertical stems may be only partially black. In this context, - * `antialiasing' means that stems are not positioned exactly on pixel - * borders, causing a fuzzy appearance. - * - * There are two principles behind this approach. - * - * 1) No hinting in the horizontal direction: Unlike `superhinted' - * TrueType, which changes glyph widths to accommodate regular - * inter-glyph spacing, Adobe's approach is `faithful to the design' in - * representing both the glyph width and the inter-glyph spacing - * designed for the font. This makes the screen display as close as it - * can be to the result one would get with infinite resolution, while - * preserving what is considered the key characteristics of each glyph. - * Note that the distances between unhinted and grid-fitted positions at - * small sizes are comparable to kerning values and thus would be - * noticeable (and distracting) while reading if hinting were applied. - * - * One of the reasons to not hint horizontally is antialiasing for LCD - * screens: The pixel geometry of modern displays supplies three - * vertical sub-pixels as the eye moves horizontally across each visible - * pixel. On devices where we can be certain this characteristic is - * present a rasterizer can take advantage of the sub-pixels to add - * increments of weight. In Western writing systems this turns out to - * be the more critical direction anyway; the weights and spacing of - * vertical stems (see above) are central to Armenian, Cyrillic, Greek, - * and Latin type designs. Even when the rasterizer uses greyscale - * antialiasing instead of color (a necessary compromise when one - * doesn't know the screen characteristics), the unhinted vertical - * features preserve the design's weight and spacing much better than - * aliased type would. - * - * 2) Aligment in the vertical direction: Weights and spacing along the - * y~axis are less critical; what is much more important is the visual - * alignment of related features (like cap-height and x-height). The - * sense of alignment for these is enhanced by the sharpness of grid-fit - * edges, while the cruder vertical resolution (full pixels instead of - * 1/3 pixels) is less of a problem. - * - * On the technical side, horizontal alignment zones for ascender, - * x-height, and other important height values (traditionally called - * `blue zones') as defined in the font are positioned independently, - * each being rounded to the nearest pixel edge, taking care of - * overshoot suppression at small sizes, stem darkening, and scaling. - * - * Hstems (this is, hint values defined in the font to help align - * horizontal features) that fall within a blue zone are said to be - * `captured' and are aligned to that zone. Uncaptured stems are moved - * in one of four ways, top edge up or down, bottom edge up or down. - * Unless there are conflicting hstems, the smallest movement is taken - * to minimize distortion. - */ - - - /************************************************************************** - * - * @property: - * hinting-engine - * - * @description: - * Thanks to Adobe, which contributed a new hinting (and parsing) - * engine, an application can select between `freetype' and `adobe' if - * compiled with CFF_CONFIG_OPTION_OLD_ENGINE. If this configuration - * macro isn't defined, `hinting-engine' does nothing. - * - * The default engine is `freetype' if CFF_CONFIG_OPTION_OLD_ENGINE is - * defined, and `adobe' otherwise. - * - * The following example code demonstrates how to select Adobe's hinting - * engine (omitting the error handling). - * - * { - * FT_Library library; - * FT_UInt hinting_engine = FT_CFF_HINTING_ADOBE; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "cff", - * "hinting-engine", &hinting_engine ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - */ - - - /************************************************************************** - * - * @enum: - * FT_CFF_HINTING_XXX - * - * @description: - * A list of constants used for the @hinting-engine property to select - * the hinting engine for CFF fonts. - * - * @values: - * FT_CFF_HINTING_FREETYPE :: - * Use the old FreeType hinting engine. - * - * FT_CFF_HINTING_ADOBE :: - * Use the hinting engine contributed by Adobe. - * - */ -#define FT_CFF_HINTING_FREETYPE 0 -#define FT_CFF_HINTING_ADOBE 1 - - - /************************************************************************** - * - * @property: - * no-stem-darkening - * - * @description: - * By default, the Adobe CFF engine darkens stems at smaller sizes, - * regardless of hinting, to enhance contrast. This feature requires - * a rendering system with proper gamma correction. Setting this - * property, stem darkening gets switched off. - * - * Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is set. - * - * { - * FT_Library library; - * FT_Bool no_stem_darkening = TRUE; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "cff", - * "no-stem-darkening", &no_stem_darkening ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - */ - - - /************************************************************************** - * - * @property: - * darkening-parameters - * - * @description: - * By default, the Adobe CFF engine darkens stems as follows (if the - * `no-stem-darkening' property isn't set): - * - * { - * stem width <= 0.5px: darkening amount = 0.4px - * stem width = 1px: darkening amount = 0.275px - * stem width = 1.667px: darkening amount = 0.275px - * stem width >= 2.333px: darkening amount = 0px - * } - * - * and piecewise linear in-between. Using the `darkening-parameters' - * property, these four control points can be changed, as the following - * example demonstrates. - * - * { - * FT_Library library; - * FT_Int darken_params[8] = { 500, 300, // x1, y1 - * 1000, 200, // x2, y2 - * 1500, 100, // x3, y3 - * 2000, 0 }; // x4, y4 - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "cff", - * "darkening-parameters", darken_params ); - * } - * - * The x~values give the stem width, and the y~values the darkening - * amount. The unit is 1000th of pixels. All coordinate values must be - * positive; the x~values must be monotonically increasing; the - * y~values must be monotonically decreasing and smaller than or - * equal to 500 (corresponding to half a pixel); the slope of each - * linear piece must be shallower than -1 (e.g., -.4). - * - * @note: - * This property can be used with @FT_Property_Get also. - * - */ - - - /* */ - -FT_END_HEADER - - -#endif /* __FTCFFDRV_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftchapters.h b/thirdparty/include/freetype/ftchapters.h deleted file mode 100644 index d333761c8..000000000 --- a/thirdparty/include/freetype/ftchapters.h +++ /dev/null @@ -1,121 +0,0 @@ -/***************************************************************************/ -/* */ -/* This file defines the structure of the FreeType reference. */ -/* It is used by the python script that generates the HTML files. */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* general_remarks */ -/* */ -/* <Title> */ -/* General Remarks */ -/* */ -/* <Sections> */ -/* header_inclusion */ -/* user_allocation */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* core_api */ -/* */ -/* <Title> */ -/* Core API */ -/* */ -/* <Sections> */ -/* version */ -/* basic_types */ -/* base_interface */ -/* glyph_variants */ -/* glyph_management */ -/* mac_specific */ -/* sizes_management */ -/* header_file_macros */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* format_specific */ -/* */ -/* <Title> */ -/* Format-Specific API */ -/* */ -/* <Sections> */ -/* multiple_masters */ -/* truetype_tables */ -/* type1_tables */ -/* sfnt_names */ -/* bdf_fonts */ -/* cid_fonts */ -/* pfr_fonts */ -/* winfnt_fonts */ -/* font_formats */ -/* gasp_table */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* module_specific */ -/* */ -/* <Title> */ -/* Controlling FreeType Modules */ -/* */ -/* <Sections> */ -/* auto_hinter */ -/* cff_driver */ -/* tt_driver */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* cache_subsystem */ -/* */ -/* <Title> */ -/* Cache Sub-System */ -/* */ -/* <Sections> */ -/* cache_subsystem */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* support_api */ -/* */ -/* <Title> */ -/* Support API */ -/* */ -/* <Sections> */ -/* computations */ -/* list_processing */ -/* outline_processing */ -/* quick_advance */ -/* bitmap_handling */ -/* raster */ -/* glyph_stroker */ -/* system_interface */ -/* module_management */ -/* gzip */ -/* lzw */ -/* bzip2 */ -/* lcd_filtering */ -/* */ -/***************************************************************************/ diff --git a/thirdparty/include/freetype/ftcid.h b/thirdparty/include/freetype/ftcid.h deleted file mode 100644 index 6361298a2..000000000 --- a/thirdparty/include/freetype/ftcid.h +++ /dev/null @@ -1,166 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftcid.h */ -/* */ -/* FreeType API for accessing CID font information (specification). */ -/* */ -/* Copyright 2007, 2009 by Dereg Clegg, Michael Toftdal. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTCID_H__ -#define __FTCID_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* cid_fonts */ - /* */ - /* <Title> */ - /* CID Fonts */ - /* */ - /* <Abstract> */ - /* CID-keyed font specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of CID-keyed font specific */ - /* functions. */ - /* */ - /*************************************************************************/ - - - /********************************************************************** - * - * @function: - * FT_Get_CID_Registry_Ordering_Supplement - * - * @description: - * Retrieve the Registry/Ordering/Supplement triple (also known as the - * "R/O/S") from a CID-keyed font. - * - * @input: - * face :: - * A handle to the input face. - * - * @output: - * registry :: - * The registry, as a C~string, owned by the face. - * - * ordering :: - * The ordering, as a C~string, owned by the face. - * - * supplement :: - * The supplement. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with CID faces, returning an error - * otherwise. - * - * @since: - * 2.3.6 - */ - FT_EXPORT( FT_Error ) - FT_Get_CID_Registry_Ordering_Supplement( FT_Face face, - const char* *registry, - const char* *ordering, - FT_Int *supplement); - - - /********************************************************************** - * - * @function: - * FT_Get_CID_Is_Internally_CID_Keyed - * - * @description: - * Retrieve the type of the input face, CID keyed or not. In - * constrast to the @FT_IS_CID_KEYED macro this function returns - * successfully also for CID-keyed fonts in an SNFT wrapper. - * - * @input: - * face :: - * A handle to the input face. - * - * @output: - * is_cid :: - * The type of the face as an @FT_Bool. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with CID faces and OpenType fonts, - * returning an error otherwise. - * - * @since: - * 2.3.9 - */ - FT_EXPORT( FT_Error ) - FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face, - FT_Bool *is_cid ); - - - /********************************************************************** - * - * @function: - * FT_Get_CID_From_Glyph_Index - * - * @description: - * Retrieve the CID of the input glyph index. - * - * @input: - * face :: - * A handle to the input face. - * - * glyph_index :: - * The input glyph index. - * - * @output: - * cid :: - * The CID as an @FT_UInt. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with CID faces and OpenType fonts, - * returning an error otherwise. - * - * @since: - * 2.3.9 - */ - FT_EXPORT( FT_Error ) - FT_Get_CID_From_Glyph_Index( FT_Face face, - FT_UInt glyph_index, - FT_UInt *cid ); - - /* */ - -FT_END_HEADER - -#endif /* __FTCID_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/fterrdef.h b/thirdparty/include/freetype/fterrdef.h deleted file mode 100644 index 76c7b9e36..000000000 --- a/thirdparty/include/freetype/fterrdef.h +++ /dev/null @@ -1,249 +0,0 @@ -/***************************************************************************/ -/* */ -/* fterrdef.h */ -/* */ -/* FreeType error codes (specification). */ -/* */ -/* Copyright 2002, 2004, 2006, 2007, 2010-2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*******************************************************************/ - /*******************************************************************/ - /***** *****/ - /***** LIST OF ERROR CODES/MESSAGES *****/ - /***** *****/ - /*******************************************************************/ - /*******************************************************************/ - - - /* You need to define both FT_ERRORDEF_ and FT_NOERRORDEF_ before */ - /* including this file. */ - - - /* generic errors */ - - FT_NOERRORDEF_( Ok, 0x00, \ - "no error" ) - - FT_ERRORDEF_( Cannot_Open_Resource, 0x01, \ - "cannot open resource" ) - FT_ERRORDEF_( Unknown_File_Format, 0x02, \ - "unknown file format" ) - FT_ERRORDEF_( Invalid_File_Format, 0x03, \ - "broken file" ) - FT_ERRORDEF_( Invalid_Version, 0x04, \ - "invalid FreeType version" ) - FT_ERRORDEF_( Lower_Module_Version, 0x05, \ - "module version is too low" ) - FT_ERRORDEF_( Invalid_Argument, 0x06, \ - "invalid argument" ) - FT_ERRORDEF_( Unimplemented_Feature, 0x07, \ - "unimplemented feature" ) - FT_ERRORDEF_( Invalid_Table, 0x08, \ - "broken table" ) - FT_ERRORDEF_( Invalid_Offset, 0x09, \ - "broken offset within table" ) - FT_ERRORDEF_( Array_Too_Large, 0x0A, \ - "array allocation size too large" ) - FT_ERRORDEF_( Missing_Module, 0x0B, \ - "missing module" ) - FT_ERRORDEF_( Missing_Property, 0x0C, \ - "missing property" ) - - /* glyph/character errors */ - - FT_ERRORDEF_( Invalid_Glyph_Index, 0x10, \ - "invalid glyph index" ) - FT_ERRORDEF_( Invalid_Character_Code, 0x11, \ - "invalid character code" ) - FT_ERRORDEF_( Invalid_Glyph_Format, 0x12, \ - "unsupported glyph image format" ) - FT_ERRORDEF_( Cannot_Render_Glyph, 0x13, \ - "cannot render this glyph format" ) - FT_ERRORDEF_( Invalid_Outline, 0x14, \ - "invalid outline" ) - FT_ERRORDEF_( Invalid_Composite, 0x15, \ - "invalid composite glyph" ) - FT_ERRORDEF_( Too_Many_Hints, 0x16, \ - "too many hints" ) - FT_ERRORDEF_( Invalid_Pixel_Size, 0x17, \ - "invalid pixel size" ) - - /* handle errors */ - - FT_ERRORDEF_( Invalid_Handle, 0x20, \ - "invalid object handle" ) - FT_ERRORDEF_( Invalid_Library_Handle, 0x21, \ - "invalid library handle" ) - FT_ERRORDEF_( Invalid_Driver_Handle, 0x22, \ - "invalid module handle" ) - FT_ERRORDEF_( Invalid_Face_Handle, 0x23, \ - "invalid face handle" ) - FT_ERRORDEF_( Invalid_Size_Handle, 0x24, \ - "invalid size handle" ) - FT_ERRORDEF_( Invalid_Slot_Handle, 0x25, \ - "invalid glyph slot handle" ) - FT_ERRORDEF_( Invalid_CharMap_Handle, 0x26, \ - "invalid charmap handle" ) - FT_ERRORDEF_( Invalid_Cache_Handle, 0x27, \ - "invalid cache manager handle" ) - FT_ERRORDEF_( Invalid_Stream_Handle, 0x28, \ - "invalid stream handle" ) - - /* driver errors */ - - FT_ERRORDEF_( Too_Many_Drivers, 0x30, \ - "too many modules" ) - FT_ERRORDEF_( Too_Many_Extensions, 0x31, \ - "too many extensions" ) - - /* memory errors */ - - FT_ERRORDEF_( Out_Of_Memory, 0x40, \ - "out of memory" ) - FT_ERRORDEF_( Unlisted_Object, 0x41, \ - "unlisted object" ) - - /* stream errors */ - - FT_ERRORDEF_( Cannot_Open_Stream, 0x51, \ - "cannot open stream" ) - FT_ERRORDEF_( Invalid_Stream_Seek, 0x52, \ - "invalid stream seek" ) - FT_ERRORDEF_( Invalid_Stream_Skip, 0x53, \ - "invalid stream skip" ) - FT_ERRORDEF_( Invalid_Stream_Read, 0x54, \ - "invalid stream read" ) - FT_ERRORDEF_( Invalid_Stream_Operation, 0x55, \ - "invalid stream operation" ) - FT_ERRORDEF_( Invalid_Frame_Operation, 0x56, \ - "invalid frame operation" ) - FT_ERRORDEF_( Nested_Frame_Access, 0x57, \ - "nested frame access" ) - FT_ERRORDEF_( Invalid_Frame_Read, 0x58, \ - "invalid frame read" ) - - /* raster errors */ - - FT_ERRORDEF_( Raster_Uninitialized, 0x60, \ - "raster uninitialized" ) - FT_ERRORDEF_( Raster_Corrupted, 0x61, \ - "raster corrupted" ) - FT_ERRORDEF_( Raster_Overflow, 0x62, \ - "raster overflow" ) - FT_ERRORDEF_( Raster_Negative_Height, 0x63, \ - "negative height while rastering" ) - - /* cache errors */ - - FT_ERRORDEF_( Too_Many_Caches, 0x70, \ - "too many registered caches" ) - - /* TrueType and SFNT errors */ - - FT_ERRORDEF_( Invalid_Opcode, 0x80, \ - "invalid opcode" ) - FT_ERRORDEF_( Too_Few_Arguments, 0x81, \ - "too few arguments" ) - FT_ERRORDEF_( Stack_Overflow, 0x82, \ - "stack overflow" ) - FT_ERRORDEF_( Code_Overflow, 0x83, \ - "code overflow" ) - FT_ERRORDEF_( Bad_Argument, 0x84, \ - "bad argument" ) - FT_ERRORDEF_( Divide_By_Zero, 0x85, \ - "division by zero" ) - FT_ERRORDEF_( Invalid_Reference, 0x86, \ - "invalid reference" ) - FT_ERRORDEF_( Debug_OpCode, 0x87, \ - "found debug opcode" ) - FT_ERRORDEF_( ENDF_In_Exec_Stream, 0x88, \ - "found ENDF opcode in execution stream" ) - FT_ERRORDEF_( Nested_DEFS, 0x89, \ - "nested DEFS" ) - FT_ERRORDEF_( Invalid_CodeRange, 0x8A, \ - "invalid code range" ) - FT_ERRORDEF_( Execution_Too_Long, 0x8B, \ - "execution context too long" ) - FT_ERRORDEF_( Too_Many_Function_Defs, 0x8C, \ - "too many function definitions" ) - FT_ERRORDEF_( Too_Many_Instruction_Defs, 0x8D, \ - "too many instruction definitions" ) - FT_ERRORDEF_( Table_Missing, 0x8E, \ - "SFNT font table missing" ) - FT_ERRORDEF_( Horiz_Header_Missing, 0x8F, \ - "horizontal header (hhea) table missing" ) - FT_ERRORDEF_( Locations_Missing, 0x90, \ - "locations (loca) table missing" ) - FT_ERRORDEF_( Name_Table_Missing, 0x91, \ - "name table missing" ) - FT_ERRORDEF_( CMap_Table_Missing, 0x92, \ - "character map (cmap) table missing" ) - FT_ERRORDEF_( Hmtx_Table_Missing, 0x93, \ - "horizontal metrics (hmtx) table missing" ) - FT_ERRORDEF_( Post_Table_Missing, 0x94, \ - "PostScript (post) table missing" ) - FT_ERRORDEF_( Invalid_Horiz_Metrics, 0x95, \ - "invalid horizontal metrics" ) - FT_ERRORDEF_( Invalid_CharMap_Format, 0x96, \ - "invalid character map (cmap) format" ) - FT_ERRORDEF_( Invalid_PPem, 0x97, \ - "invalid ppem value" ) - FT_ERRORDEF_( Invalid_Vert_Metrics, 0x98, \ - "invalid vertical metrics" ) - FT_ERRORDEF_( Could_Not_Find_Context, 0x99, \ - "could not find context" ) - FT_ERRORDEF_( Invalid_Post_Table_Format, 0x9A, \ - "invalid PostScript (post) table format" ) - FT_ERRORDEF_( Invalid_Post_Table, 0x9B, \ - "invalid PostScript (post) table" ) - - /* CFF, CID, and Type 1 errors */ - - FT_ERRORDEF_( Syntax_Error, 0xA0, \ - "opcode syntax error" ) - FT_ERRORDEF_( Stack_Underflow, 0xA1, \ - "argument stack underflow" ) - FT_ERRORDEF_( Ignore, 0xA2, \ - "ignore" ) - FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3, \ - "no Unicode glyph name found" ) - FT_ERRORDEF_( Glyph_Too_Big, 0xA4, \ - "glyph to big for hinting" ) - - /* BDF errors */ - - FT_ERRORDEF_( Missing_Startfont_Field, 0xB0, \ - "`STARTFONT' field missing" ) - FT_ERRORDEF_( Missing_Font_Field, 0xB1, \ - "`FONT' field missing" ) - FT_ERRORDEF_( Missing_Size_Field, 0xB2, \ - "`SIZE' field missing" ) - FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3, \ - "`FONTBOUNDINGBOX' field missing" ) - FT_ERRORDEF_( Missing_Chars_Field, 0xB4, \ - "`CHARS' field missing" ) - FT_ERRORDEF_( Missing_Startchar_Field, 0xB5, \ - "`STARTCHAR' field missing" ) - FT_ERRORDEF_( Missing_Encoding_Field, 0xB6, \ - "`ENCODING' field missing" ) - FT_ERRORDEF_( Missing_Bbx_Field, 0xB7, \ - "`BBX' field missing" ) - FT_ERRORDEF_( Bbx_Too_Big, 0xB8, \ - "`BBX' too big" ) - FT_ERRORDEF_( Corrupted_Font_Header, 0xB9, \ - "Font header corrupted or missing fields" ) - FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA, \ - "Font glyphs corrupted or missing fields" ) - - -/* END */ diff --git a/thirdparty/include/freetype/fterrors.h b/thirdparty/include/freetype/fterrors.h deleted file mode 100644 index 0fa3e4dce..000000000 --- a/thirdparty/include/freetype/fterrors.h +++ /dev/null @@ -1,198 +0,0 @@ -/***************************************************************************/ -/* */ -/* fterrors.h */ -/* */ -/* FreeType error code handling (specification). */ -/* */ -/* Copyright 1996-2002, 2004, 2007, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This special header file is used to define the handling of FT2 */ - /* enumeration constants. It can also be used to generate error message */ - /* strings with a small macro trick explained below. */ - /* */ - /* I - Error Formats */ - /* ----------------- */ - /* */ - /* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be */ - /* defined in ftoption.h in order to make the higher byte indicate */ - /* the module where the error has happened (this is not compatible */ - /* with standard builds of FreeType 2). See the file `ftmoderr.h' for */ - /* more details. */ - /* */ - /* */ - /* II - Error Message strings */ - /* -------------------------- */ - /* */ - /* The error definitions below are made through special macros that */ - /* allow client applications to build a table of error message strings */ - /* if they need it. The strings are not included in a normal build of */ - /* FreeType 2 to save space (most client applications do not use */ - /* them). */ - /* */ - /* To do so, you have to define the following macros before including */ - /* this file: */ - /* */ - /* FT_ERROR_START_LIST :: */ - /* This macro is called before anything else to define the start of */ - /* the error list. It is followed by several FT_ERROR_DEF calls */ - /* (see below). */ - /* */ - /* FT_ERROR_DEF( e, v, s ) :: */ - /* This macro is called to define one single error. */ - /* `e' is the error code identifier (e.g. FT_Err_Invalid_Argument). */ - /* `v' is the error numerical value. */ - /* `s' is the corresponding error string. */ - /* */ - /* FT_ERROR_END_LIST :: */ - /* This macro ends the list. */ - /* */ - /* Additionally, you have to undefine __FTERRORS_H__ before #including */ - /* this file. */ - /* */ - /* Here is a simple example: */ - /* */ - /* { */ - /* #undef __FTERRORS_H__ */ - /* #define FT_ERRORDEF( e, v, s ) { e, s }, */ - /* #define FT_ERROR_START_LIST { */ - /* #define FT_ERROR_END_LIST { 0, 0 } }; */ - /* */ - /* const struct */ - /* { */ - /* int err_code; */ - /* const char* err_msg; */ - /* } ft_errors[] = */ - /* */ - /* #include FT_ERRORS_H */ - /* } */ - /* */ - /*************************************************************************/ - - -#ifndef __FTERRORS_H__ -#define __FTERRORS_H__ - - - /* include module base error codes */ -#include FT_MODULE_ERRORS_H - - - /*******************************************************************/ - /*******************************************************************/ - /***** *****/ - /***** SETUP MACROS *****/ - /***** *****/ - /*******************************************************************/ - /*******************************************************************/ - - -#undef FT_NEED_EXTERN_C - - - /* FT_ERR_PREFIX is used as a prefix for error identifiers. */ - /* By default, we use `FT_Err_'. */ - /* */ -#ifndef FT_ERR_PREFIX -#define FT_ERR_PREFIX FT_Err_ -#endif - - - /* FT_ERR_BASE is used as the base for module-specific errors. */ - /* */ -#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS - -#ifndef FT_ERR_BASE -#define FT_ERR_BASE FT_Mod_Err_Base -#endif - -#else - -#undef FT_ERR_BASE -#define FT_ERR_BASE 0 - -#endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */ - - - /* If FT_ERRORDEF is not defined, we need to define a simple */ - /* enumeration type. */ - /* */ -#ifndef FT_ERRORDEF - -#define FT_ERRORDEF( e, v, s ) e = v, -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) }; - -#ifdef __cplusplus -#define FT_NEED_EXTERN_C - extern "C" { -#endif - -#endif /* !FT_ERRORDEF */ - - - /* this macro is used to define an error */ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s ) - - /* this is only used for <module>_Err_Ok, which must be 0! */ -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s ) - - -#ifdef FT_ERROR_START_LIST - FT_ERROR_START_LIST -#endif - - - /* now include the error codes */ -#include FT_ERROR_DEFINITIONS_H - - -#ifdef FT_ERROR_END_LIST - FT_ERROR_END_LIST -#endif - - - /*******************************************************************/ - /*******************************************************************/ - /***** *****/ - /***** SIMPLE CLEANUP *****/ - /***** *****/ - /*******************************************************************/ - /*******************************************************************/ - -#ifdef FT_NEED_EXTERN_C - } -#endif - -#undef FT_ERROR_START_LIST -#undef FT_ERROR_END_LIST - -#undef FT_ERRORDEF -#undef FT_ERRORDEF_ -#undef FT_NOERRORDEF_ - -#undef FT_NEED_EXTERN_C -#undef FT_ERR_BASE - - /* FT_ERR_PREFIX is needed internally */ -#ifndef FT2_BUILD_LIBRARY -#undef FT_ERR_PREFIX -#endif - -#endif /* __FTERRORS_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftgasp.h b/thirdparty/include/freetype/ftgasp.h deleted file mode 100644 index 051dc261b..000000000 --- a/thirdparty/include/freetype/ftgasp.h +++ /dev/null @@ -1,128 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftgasp.h */ -/* */ -/* Access of TrueType's `gasp' table (specification). */ -/* */ -/* Copyright 2007, 2008, 2011 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef _FT_GASP_H_ -#define _FT_GASP_H_ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - - /*************************************************************************** - * - * @section: - * gasp_table - * - * @title: - * Gasp Table - * - * @abstract: - * Retrieving TrueType `gasp' table entries. - * - * @description: - * The function @FT_Get_Gasp can be used to query a TrueType or OpenType - * font for specific entries in its `gasp' table, if any. This is - * mainly useful when implementing native TrueType hinting with the - * bytecode interpreter to duplicate the Windows text rendering results. - */ - - /************************************************************************* - * - * @enum: - * FT_GASP_XXX - * - * @description: - * A list of values and/or bit-flags returned by the @FT_Get_Gasp - * function. - * - * @values: - * FT_GASP_NO_TABLE :: - * This special value means that there is no GASP table in this face. - * It is up to the client to decide what to do. - * - * FT_GASP_DO_GRIDFIT :: - * Grid-fitting and hinting should be performed at the specified ppem. - * This *really* means TrueType bytecode interpretation. If this bit - * is not set, no hinting gets applied. - * - * FT_GASP_DO_GRAY :: - * Anti-aliased rendering should be performed at the specified ppem. - * If not set, do monochrome rendering. - * - * FT_GASP_SYMMETRIC_SMOOTHING :: - * If set, smoothing along multiple axes must be used with ClearType. - * - * FT_GASP_SYMMETRIC_GRIDFIT :: - * Grid-fitting must be used with ClearType's symmetric smoothing. - * - * @note: - * The bit-flags `FT_GASP_DO_GRIDFIT' and `FT_GASP_DO_GRAY' are to be - * used for standard font rasterization only. Independently of that, - * `FT_GASP_SYMMETRIC_SMOOTHING' and `FT_GASP_SYMMETRIC_GRIDFIT' are to - * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT' and - * `FT_GASP_DO_GRAY' are consequently ignored). - * - * `ClearType' is Microsoft's implementation of LCD rendering, partly - * protected by patents. - * - * @since: - * 2.3.0 - */ -#define FT_GASP_NO_TABLE -1 -#define FT_GASP_DO_GRIDFIT 0x01 -#define FT_GASP_DO_GRAY 0x02 -#define FT_GASP_SYMMETRIC_SMOOTHING 0x08 -#define FT_GASP_SYMMETRIC_GRIDFIT 0x10 - - - /************************************************************************* - * - * @func: - * FT_Get_Gasp - * - * @description: - * Read the `gasp' table from a TrueType or OpenType font file and - * return the entry corresponding to a given character pixel size. - * - * @input: - * face :: The source face handle. - * ppem :: The vertical character pixel size. - * - * @return: - * Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no - * `gasp' table in the face. - * - * @since: - * 2.3.0 - */ - FT_EXPORT( FT_Int ) - FT_Get_Gasp( FT_Face face, - FT_UInt ppem ); - -/* */ - -#endif /* _FT_GASP_H_ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftglyph.h b/thirdparty/include/freetype/ftglyph.h deleted file mode 100644 index d0d4fdcf9..000000000 --- a/thirdparty/include/freetype/ftglyph.h +++ /dev/null @@ -1,620 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftglyph.h */ -/* */ -/* FreeType convenience functions to handle glyphs (specification). */ -/* */ -/* Copyright 1996-2003, 2006, 2008, 2009, 2011, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file contains the definition of several convenience functions */ - /* that can be used by client applications to easily retrieve glyph */ - /* bitmaps and outlines from a given face. */ - /* */ - /* These functions should be optional if you are writing a font server */ - /* or text layout engine on top of FreeType. However, they are pretty */ - /* handy for many other simple uses of the library. */ - /* */ - /*************************************************************************/ - - -#ifndef __FTGLYPH_H__ -#define __FTGLYPH_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* glyph_management */ - /* */ - /* <Title> */ - /* Glyph Management */ - /* */ - /* <Abstract> */ - /* Generic interface to manage individual glyph data. */ - /* */ - /* <Description> */ - /* This section contains definitions used to manage glyph data */ - /* through generic FT_Glyph objects. Each of them can contain a */ - /* bitmap, a vector outline, or even images in other formats. */ - /* */ - /*************************************************************************/ - - - /* forward declaration to a private type */ - typedef struct FT_Glyph_Class_ FT_Glyph_Class; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Glyph */ - /* */ - /* <Description> */ - /* Handle to an object used to model generic glyph images. It is a */ - /* pointer to the @FT_GlyphRec structure and can contain a glyph */ - /* bitmap or pointer. */ - /* */ - /* <Note> */ - /* Glyph objects are not owned by the library. You must thus release */ - /* them manually (through @FT_Done_Glyph) _before_ calling */ - /* @FT_Done_FreeType. */ - /* */ - typedef struct FT_GlyphRec_* FT_Glyph; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_GlyphRec */ - /* */ - /* <Description> */ - /* The root glyph structure contains a given glyph image plus its */ - /* advance width in 16.16 fixed-point format. */ - /* */ - /* <Fields> */ - /* library :: A handle to the FreeType library object. */ - /* */ - /* clazz :: A pointer to the glyph's class. Private. */ - /* */ - /* format :: The format of the glyph's image. */ - /* */ - /* advance :: A 16.16 vector that gives the glyph's advance width. */ - /* */ - typedef struct FT_GlyphRec_ - { - FT_Library library; - const FT_Glyph_Class* clazz; - FT_Glyph_Format format; - FT_Vector advance; - - } FT_GlyphRec; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_BitmapGlyph */ - /* */ - /* <Description> */ - /* A handle to an object used to model a bitmap glyph image. This is */ - /* a sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec. */ - /* */ - typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_BitmapGlyphRec */ - /* */ - /* <Description> */ - /* A structure used for bitmap glyph images. This really is a */ - /* `sub-class' of @FT_GlyphRec. */ - /* */ - /* <Fields> */ - /* root :: The root @FT_Glyph fields. */ - /* */ - /* left :: The left-side bearing, i.e., the horizontal distance */ - /* from the current pen position to the left border of the */ - /* glyph bitmap. */ - /* */ - /* top :: The top-side bearing, i.e., the vertical distance from */ - /* the current pen position to the top border of the glyph */ - /* bitmap. This distance is positive for upwards~y! */ - /* */ - /* bitmap :: A descriptor for the bitmap. */ - /* */ - /* <Note> */ - /* You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have */ - /* `glyph->format == FT_GLYPH_FORMAT_BITMAP'. This lets you access */ - /* the bitmap's contents easily. */ - /* */ - /* The corresponding pixel buffer is always owned by @FT_BitmapGlyph */ - /* and is thus created and destroyed with it. */ - /* */ - typedef struct FT_BitmapGlyphRec_ - { - FT_GlyphRec root; - FT_Int left; - FT_Int top; - FT_Bitmap bitmap; - - } FT_BitmapGlyphRec; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_OutlineGlyph */ - /* */ - /* <Description> */ - /* A handle to an object used to model an outline glyph image. This */ - /* is a sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. */ - /* */ - typedef struct FT_OutlineGlyphRec_* FT_OutlineGlyph; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_OutlineGlyphRec */ - /* */ - /* <Description> */ - /* A structure used for outline (vectorial) glyph images. This */ - /* really is a `sub-class' of @FT_GlyphRec. */ - /* */ - /* <Fields> */ - /* root :: The root @FT_Glyph fields. */ - /* */ - /* outline :: A descriptor for the outline. */ - /* */ - /* <Note> */ - /* You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have */ - /* `glyph->format == FT_GLYPH_FORMAT_OUTLINE'. This lets you access */ - /* the outline's content easily. */ - /* */ - /* As the outline is extracted from a glyph slot, its coordinates are */ - /* expressed normally in 26.6 pixels, unless the flag */ - /* @FT_LOAD_NO_SCALE was used in @FT_Load_Glyph() or @FT_Load_Char(). */ - /* */ - /* The outline's tables are always owned by the object and are */ - /* destroyed with it. */ - /* */ - typedef struct FT_OutlineGlyphRec_ - { - FT_GlyphRec root; - FT_Outline outline; - - } FT_OutlineGlyphRec; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Glyph */ - /* */ - /* <Description> */ - /* A function used to extract a glyph image from a slot. Note that */ - /* the created @FT_Glyph object must be released with @FT_Done_Glyph. */ - /* */ - /* <Input> */ - /* slot :: A handle to the source glyph slot. */ - /* */ - /* <Output> */ - /* aglyph :: A handle to the glyph object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Glyph( FT_GlyphSlot slot, - FT_Glyph *aglyph ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_Copy */ - /* */ - /* <Description> */ - /* A function used to copy a glyph image. Note that the created */ - /* @FT_Glyph object must be released with @FT_Done_Glyph. */ - /* */ - /* <Input> */ - /* source :: A handle to the source glyph object. */ - /* */ - /* <Output> */ - /* target :: A handle to the target glyph object. 0~in case of */ - /* error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Glyph_Copy( FT_Glyph source, - FT_Glyph *target ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_Transform */ - /* */ - /* <Description> */ - /* Transform a glyph image if its format is scalable. */ - /* */ - /* <InOut> */ - /* glyph :: A handle to the target glyph object. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to a 2x2 matrix to apply. */ - /* */ - /* delta :: A pointer to a 2d vector to apply. Coordinates are */ - /* expressed in 1/64th of a pixel. */ - /* */ - /* <Return> */ - /* FreeType error code (if not 0, the glyph format is not scalable). */ - /* */ - /* <Note> */ - /* The 2x2 transformation matrix is also applied to the glyph's */ - /* advance vector. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Glyph_Transform( FT_Glyph glyph, - FT_Matrix* matrix, - FT_Vector* delta ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Glyph_BBox_Mode */ - /* */ - /* <Description> */ - /* The mode how the values of @FT_Glyph_Get_CBox are returned. */ - /* */ - /* <Values> */ - /* FT_GLYPH_BBOX_UNSCALED :: */ - /* Return unscaled font units. */ - /* */ - /* FT_GLYPH_BBOX_SUBPIXELS :: */ - /* Return unfitted 26.6 coordinates. */ - /* */ - /* FT_GLYPH_BBOX_GRIDFIT :: */ - /* Return grid-fitted 26.6 coordinates. */ - /* */ - /* FT_GLYPH_BBOX_TRUNCATE :: */ - /* Return coordinates in integer pixels. */ - /* */ - /* FT_GLYPH_BBOX_PIXELS :: */ - /* Return grid-fitted pixel coordinates. */ - /* */ - typedef enum FT_Glyph_BBox_Mode_ - { - FT_GLYPH_BBOX_UNSCALED = 0, - FT_GLYPH_BBOX_SUBPIXELS = 0, - FT_GLYPH_BBOX_GRIDFIT = 1, - FT_GLYPH_BBOX_TRUNCATE = 2, - FT_GLYPH_BBOX_PIXELS = 3 - - } FT_Glyph_BBox_Mode; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* ft_glyph_bbox_xxx */ - /* */ - /* <Description> */ - /* These constants are deprecated. Use the corresponding */ - /* @FT_Glyph_BBox_Mode values instead. */ - /* */ - /* <Values> */ - /* ft_glyph_bbox_unscaled :: See @FT_GLYPH_BBOX_UNSCALED. */ - /* ft_glyph_bbox_subpixels :: See @FT_GLYPH_BBOX_SUBPIXELS. */ - /* ft_glyph_bbox_gridfit :: See @FT_GLYPH_BBOX_GRIDFIT. */ - /* ft_glyph_bbox_truncate :: See @FT_GLYPH_BBOX_TRUNCATE. */ - /* ft_glyph_bbox_pixels :: See @FT_GLYPH_BBOX_PIXELS. */ - /* */ -#define ft_glyph_bbox_unscaled FT_GLYPH_BBOX_UNSCALED -#define ft_glyph_bbox_subpixels FT_GLYPH_BBOX_SUBPIXELS -#define ft_glyph_bbox_gridfit FT_GLYPH_BBOX_GRIDFIT -#define ft_glyph_bbox_truncate FT_GLYPH_BBOX_TRUNCATE -#define ft_glyph_bbox_pixels FT_GLYPH_BBOX_PIXELS - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_Get_CBox */ - /* */ - /* <Description> */ - /* Return a glyph's `control box'. The control box encloses all the */ - /* outline's points, including Bézier control points. Though it */ - /* coincides with the exact bounding box for most glyphs, it can be */ - /* slightly larger in some situations (like when rotating an outline */ - /* that contains Bézier outside arcs). */ - /* */ - /* Computing the control box is very fast, while getting the bounding */ - /* box can take much more time as it needs to walk over all segments */ - /* and arcs in the outline. To get the latter, you can use the */ - /* `ftbbox' component, which is dedicated to this single task. */ - /* */ - /* <Input> */ - /* glyph :: A handle to the source glyph object. */ - /* */ - /* mode :: The mode that indicates how to interpret the returned */ - /* bounding box values. */ - /* */ - /* <Output> */ - /* acbox :: The glyph coordinate bounding box. Coordinates are */ - /* expressed in 1/64th of pixels if it is grid-fitted. */ - /* */ - /* <Note> */ - /* Coordinates are relative to the glyph origin, using the y~upwards */ - /* convention. */ - /* */ - /* If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode' */ - /* must be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font */ - /* units in 26.6 pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS */ - /* is another name for this constant. */ - /* */ - /* If the font is tricky and the glyph has been loaded with */ - /* @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get */ - /* reasonable values for the CBox it is necessary to load the glyph */ - /* at a large ppem value (so that the hinting instructions can */ - /* properly shift and scale the subglyphs), then extracting the CBox, */ - /* which can be eventually converted back to font units. */ - /* */ - /* Note that the maximum coordinates are exclusive, which means that */ - /* one can compute the width and height of the glyph image (be it in */ - /* integer or 26.6 pixels) as: */ - /* */ - /* { */ - /* width = bbox.xMax - bbox.xMin; */ - /* height = bbox.yMax - bbox.yMin; */ - /* } */ - /* */ - /* Note also that for 26.6 coordinates, if `bbox_mode' is set to */ - /* @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, */ - /* which corresponds to: */ - /* */ - /* { */ - /* bbox.xMin = FLOOR(bbox.xMin); */ - /* bbox.yMin = FLOOR(bbox.yMin); */ - /* bbox.xMax = CEILING(bbox.xMax); */ - /* bbox.yMax = CEILING(bbox.yMax); */ - /* } */ - /* */ - /* To get the bbox in pixel coordinates, set `bbox_mode' to */ - /* @FT_GLYPH_BBOX_TRUNCATE. */ - /* */ - /* To get the bbox in grid-fitted pixel coordinates, set `bbox_mode' */ - /* to @FT_GLYPH_BBOX_PIXELS. */ - /* */ - FT_EXPORT( void ) - FT_Glyph_Get_CBox( FT_Glyph glyph, - FT_UInt bbox_mode, - FT_BBox *acbox ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_To_Bitmap */ - /* */ - /* <Description> */ - /* Convert a given glyph object to a bitmap glyph object. */ - /* */ - /* <InOut> */ - /* the_glyph :: A pointer to a handle to the target glyph. */ - /* */ - /* <Input> */ - /* render_mode :: An enumeration that describes how the data is */ - /* rendered. */ - /* */ - /* origin :: A pointer to a vector used to translate the glyph */ - /* image before rendering. Can be~0 (if no */ - /* translation). The origin is expressed in */ - /* 26.6 pixels. */ - /* */ - /* destroy :: A boolean that indicates that the original glyph */ - /* image should be destroyed by this function. It is */ - /* never destroyed in case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function does nothing if the glyph format isn't scalable. */ - /* */ - /* The glyph image is translated with the `origin' vector before */ - /* rendering. */ - /* */ - /* The first parameter is a pointer to an @FT_Glyph handle, that will */ - /* be _replaced_ by this function (with newly allocated data). */ - /* Typically, you would use (omitting error handling): */ - /* */ - /* */ - /* { */ - /* FT_Glyph glyph; */ - /* FT_BitmapGlyph glyph_bitmap; */ - /* */ - /* */ - /* // load glyph */ - /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT ); */ - /* */ - /* // extract glyph image */ - /* error = FT_Get_Glyph( face->glyph, &glyph ); */ - /* */ - /* // convert to a bitmap (default render mode + destroying old) */ - /* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */ - /* { */ - /* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, */ - /* 0, 1 ); */ - /* if ( error ) // `glyph' unchanged */ - /* ... */ - /* } */ - /* */ - /* // access bitmap content by typecasting */ - /* glyph_bitmap = (FT_BitmapGlyph)glyph; */ - /* */ - /* // do funny stuff with it, like blitting/drawing */ - /* ... */ - /* */ - /* // discard glyph image (bitmap or not) */ - /* FT_Done_Glyph( glyph ); */ - /* } */ - /* */ - /* */ - /* Here another example, again without error handling: */ - /* */ - /* */ - /* { */ - /* FT_Glyph glyphs[MAX_GLYPHS] */ - /* */ - /* */ - /* ... */ - /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || */ - /* FT_Get_Glyph ( face->glyph, &glyph[idx] ); */ - /* */ - /* ... */ - /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* { */ - /* FT_Glyph bitmap = glyphs[idx]; */ - /* */ - /* */ - /* ... */ - /* */ - /* // after this call, `bitmap' no longer points into */ - /* // the `glyphs' array (and the old value isn't destroyed) */ - /* FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); */ - /* */ - /* ... */ - /* */ - /* FT_Done_Glyph( bitmap ); */ - /* } */ - /* */ - /* ... */ - /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* FT_Done_Glyph( glyphs[idx] ); */ - /* } */ - /* */ - FT_EXPORT( FT_Error ) - FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, - FT_Render_Mode render_mode, - FT_Vector* origin, - FT_Bool destroy ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Glyph */ - /* */ - /* <Description> */ - /* Destroy a given glyph. */ - /* */ - /* <Input> */ - /* glyph :: A handle to the target glyph object. */ - /* */ - FT_EXPORT( void ) - FT_Done_Glyph( FT_Glyph glyph ); - - /* */ - - - /* other helpful functions */ - - /*************************************************************************/ - /* */ - /* <Section> */ - /* computations */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Matrix_Multiply */ - /* */ - /* <Description> */ - /* Perform the matrix operation `b = a*b'. */ - /* */ - /* <Input> */ - /* a :: A pointer to matrix `a'. */ - /* */ - /* <InOut> */ - /* b :: A pointer to matrix `b'. */ - /* */ - /* <Note> */ - /* The result is undefined if either `a' or `b' is zero. */ - /* */ - FT_EXPORT( void ) - FT_Matrix_Multiply( const FT_Matrix* a, - FT_Matrix* b ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Matrix_Invert */ - /* */ - /* <Description> */ - /* Invert a 2x2 matrix. Return an error if it can't be inverted. */ - /* */ - /* <InOut> */ - /* matrix :: A pointer to the target matrix. Remains untouched in */ - /* case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Matrix_Invert( FT_Matrix* matrix ); - - - /* */ - - -FT_END_HEADER - -#endif /* __FTGLYPH_H__ */ - - -/* END */ - - -/* Local Variables: */ -/* coding: utf-8 */ -/* End: */ diff --git a/thirdparty/include/freetype/ftgxval.h b/thirdparty/include/freetype/ftgxval.h deleted file mode 100644 index d2c76d8f1..000000000 --- a/thirdparty/include/freetype/ftgxval.h +++ /dev/null @@ -1,358 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftgxval.h */ -/* */ -/* FreeType API for validating TrueTypeGX/AAT tables (specification). */ -/* */ -/* Copyright 2004-2006, 2013 by */ -/* Masatake YAMATO, Redhat K.K, */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTGXVAL_H__ -#define __FTGXVAL_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* gx_validation */ - /* */ - /* <Title> */ - /* TrueTypeGX/AAT Validation */ - /* */ - /* <Abstract> */ - /* An API to validate TrueTypeGX/AAT tables. */ - /* */ - /* <Description> */ - /* This section contains the declaration of functions to validate */ - /* some TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, */ - /* trak, prop, lcar). */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* Warning: Use FT_VALIDATE_XXX to validate a table. */ - /* Following definitions are for gxvalid developers. */ - /* */ - /* */ - /*************************************************************************/ - -#define FT_VALIDATE_feat_INDEX 0 -#define FT_VALIDATE_mort_INDEX 1 -#define FT_VALIDATE_morx_INDEX 2 -#define FT_VALIDATE_bsln_INDEX 3 -#define FT_VALIDATE_just_INDEX 4 -#define FT_VALIDATE_kern_INDEX 5 -#define FT_VALIDATE_opbd_INDEX 6 -#define FT_VALIDATE_trak_INDEX 7 -#define FT_VALIDATE_prop_INDEX 8 -#define FT_VALIDATE_lcar_INDEX 9 -#define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX - - - /************************************************************************* - * - * @macro: - * FT_VALIDATE_GX_LENGTH - * - * @description: - * The number of tables checked in this module. Use it as a parameter - * for the `table-length' argument of function @FT_TrueTypeGX_Validate. - */ -#define FT_VALIDATE_GX_LENGTH (FT_VALIDATE_GX_LAST_INDEX + 1) - - /* */ - - /* Up to 0x1000 is used by otvalid. - Ox2xxx is reserved for feature OT extension. */ -#define FT_VALIDATE_GX_START 0x4000 -#define FT_VALIDATE_GX_BITFIELD( tag ) \ - ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX ) - - - /********************************************************************** - * - * @enum: - * FT_VALIDATE_GXXXX - * - * @description: - * A list of bit-field constants used with @FT_TrueTypeGX_Validate to - * indicate which TrueTypeGX/AAT Type tables should be validated. - * - * @values: - * FT_VALIDATE_feat :: - * Validate `feat' table. - * - * FT_VALIDATE_mort :: - * Validate `mort' table. - * - * FT_VALIDATE_morx :: - * Validate `morx' table. - * - * FT_VALIDATE_bsln :: - * Validate `bsln' table. - * - * FT_VALIDATE_just :: - * Validate `just' table. - * - * FT_VALIDATE_kern :: - * Validate `kern' table. - * - * FT_VALIDATE_opbd :: - * Validate `opbd' table. - * - * FT_VALIDATE_trak :: - * Validate `trak' table. - * - * FT_VALIDATE_prop :: - * Validate `prop' table. - * - * FT_VALIDATE_lcar :: - * Validate `lcar' table. - * - * FT_VALIDATE_GX :: - * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern, - * opbd, trak, prop and lcar). - * - */ - -#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat ) -#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort ) -#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx ) -#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln ) -#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just ) -#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern ) -#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd ) -#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak ) -#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop ) -#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar ) - -#define FT_VALIDATE_GX ( FT_VALIDATE_feat | \ - FT_VALIDATE_mort | \ - FT_VALIDATE_morx | \ - FT_VALIDATE_bsln | \ - FT_VALIDATE_just | \ - FT_VALIDATE_kern | \ - FT_VALIDATE_opbd | \ - FT_VALIDATE_trak | \ - FT_VALIDATE_prop | \ - FT_VALIDATE_lcar ) - - - /* */ - - /********************************************************************** - * - * @function: - * FT_TrueTypeGX_Validate - * - * @description: - * Validate various TrueTypeGX tables to assure that all offsets and - * indices are valid. The idea is that a higher-level library that - * actually does the text layout can access those tables without - * error checking (which can be quite time consuming). - * - * @input: - * face :: - * A handle to the input face. - * - * validation_flags :: - * A bit field that specifies the tables to be validated. See - * @FT_VALIDATE_GXXXX for possible values. - * - * table_length :: - * The size of the `tables' array. Normally, @FT_VALIDATE_GX_LENGTH - * should be passed. - * - * @output: - * tables :: - * The array where all validated sfnt tables are stored. - * The array itself must be allocated by a client. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with TrueTypeGX fonts, returning an error - * otherwise. - * - * After use, the application should deallocate the buffers pointed to by - * each `tables' element, by calling @FT_TrueTypeGX_Free. A NULL value - * indicates that the table either doesn't exist in the font, the - * application hasn't asked for validation, or the validator doesn't have - * the ability to validate the sfnt table. - */ - FT_EXPORT( FT_Error ) - FT_TrueTypeGX_Validate( FT_Face face, - FT_UInt validation_flags, - FT_Bytes tables[FT_VALIDATE_GX_LENGTH], - FT_UInt table_length ); - - - /* */ - - /********************************************************************** - * - * @function: - * FT_TrueTypeGX_Free - * - * @description: - * Free the buffer allocated by TrueTypeGX validator. - * - * @input: - * face :: - * A handle to the input face. - * - * table :: - * The pointer to the buffer allocated by - * @FT_TrueTypeGX_Validate. - * - * @note: - * This function must be used to free the buffer allocated by - * @FT_TrueTypeGX_Validate only. - */ - FT_EXPORT( void ) - FT_TrueTypeGX_Free( FT_Face face, - FT_Bytes table ); - - - /* */ - - /********************************************************************** - * - * @enum: - * FT_VALIDATE_CKERNXXX - * - * @description: - * A list of bit-field constants used with @FT_ClassicKern_Validate - * to indicate the classic kern dialect or dialects. If the selected - * type doesn't fit, @FT_ClassicKern_Validate regards the table as - * invalid. - * - * @values: - * FT_VALIDATE_MS :: - * Handle the `kern' table as a classic Microsoft kern table. - * - * FT_VALIDATE_APPLE :: - * Handle the `kern' table as a classic Apple kern table. - * - * FT_VALIDATE_CKERN :: - * Handle the `kern' as either classic Apple or Microsoft kern table. - */ -#define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 ) -#define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 ) - -#define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE ) - - - /* */ - - /********************************************************************** - * - * @function: - * FT_ClassicKern_Validate - * - * @description: - * Validate classic (16-bit format) kern table to assure that the offsets - * and indices are valid. The idea is that a higher-level library that - * actually does the text layout can access those tables without error - * checking (which can be quite time consuming). - * - * The `kern' table validator in @FT_TrueTypeGX_Validate deals with both - * the new 32-bit format and the classic 16-bit format, while - * FT_ClassicKern_Validate only supports the classic 16-bit format. - * - * @input: - * face :: - * A handle to the input face. - * - * validation_flags :: - * A bit field that specifies the dialect to be validated. See - * @FT_VALIDATE_CKERNXXX for possible values. - * - * @output: - * ckern_table :: - * A pointer to the kern table. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * After use, the application should deallocate the buffers pointed to by - * `ckern_table', by calling @FT_ClassicKern_Free. A NULL value - * indicates that the table doesn't exist in the font. - */ - FT_EXPORT( FT_Error ) - FT_ClassicKern_Validate( FT_Face face, - FT_UInt validation_flags, - FT_Bytes *ckern_table ); - - - /* */ - - /********************************************************************** - * - * @function: - * FT_ClassicKern_Free - * - * @description: - * Free the buffer allocated by classic Kern validator. - * - * @input: - * face :: - * A handle to the input face. - * - * table :: - * The pointer to the buffer that is allocated by - * @FT_ClassicKern_Validate. - * - * @note: - * This function must be used to free the buffer allocated by - * @FT_ClassicKern_Validate only. - */ - FT_EXPORT( void ) - FT_ClassicKern_Free( FT_Face face, - FT_Bytes table ); - - - /* */ - - -FT_END_HEADER - -#endif /* __FTGXVAL_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftgzip.h b/thirdparty/include/freetype/ftgzip.h deleted file mode 100644 index 76b38695a..000000000 --- a/thirdparty/include/freetype/ftgzip.h +++ /dev/null @@ -1,149 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftgzip.h */ -/* */ -/* Gzip-compressed stream support. */ -/* */ -/* Copyright 2002-2004, 2006, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTGZIP_H__ -#define __FTGZIP_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /*************************************************************************/ - /* */ - /* <Section> */ - /* gzip */ - /* */ - /* <Title> */ - /* GZIP Streams */ - /* */ - /* <Abstract> */ - /* Using gzip-compressed font files. */ - /* */ - /* <Description> */ - /* This section contains the declaration of Gzip-specific functions. */ - /* */ - /*************************************************************************/ - - - /************************************************************************ - * - * @function: - * FT_Stream_OpenGzip - * - * @description: - * Open a new stream to parse gzip-compressed font files. This is - * mainly used to support the compressed `*.pcf.gz' fonts that come - * with XFree86. - * - * @input: - * stream :: - * The target embedding stream. - * - * source :: - * The source stream. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source stream must be opened _before_ calling this function. - * - * Calling the internal function `FT_Stream_Close' on the new stream will - * *not* call `FT_Stream_Close' on the source stream. None of the stream - * objects will be released to the heap. - * - * The stream implementation is very basic and resets the decompression - * process each time seeking backwards is needed within the stream. - * - * In certain builds of the library, gzip compression recognition is - * automatically handled when calling @FT_New_Face or @FT_Open_Face. - * This means that if no font driver is capable of handling the raw - * compressed file, the library will try to open a gzipped stream from - * it and re-open the face with it. - * - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with zlib support. - */ - FT_EXPORT( FT_Error ) - FT_Stream_OpenGzip( FT_Stream stream, - FT_Stream source ); - - - /************************************************************************ - * - * @function: - * FT_Gzip_Uncompress - * - * @description: - * Decompress a zipped input buffer into an output buffer. This function - * is modeled after zlib's `uncompress' function. - * - * @input: - * memory :: - * A FreeType memory handle. - * - * input :: - * The input buffer. - * - * input_len :: - * The length of the input buffer. - * - * @output: - * output:: - * The output buffer. - * - * @inout: - * output_len :: - * Before calling the function, this is the the total size of the - * output buffer, which must be large enough to hold the entire - * uncompressed data (so the size of the uncompressed data must be - * known in advance). After calling the function, `output_len' is the - * size of the used data in `output'. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with zlib support. - */ - FT_EXPORT( FT_Error ) - FT_Gzip_Uncompress( FT_Memory memory, - FT_Byte* output, - FT_ULong* output_len, - const FT_Byte* input, - FT_ULong input_len ); - - - /* */ - - -FT_END_HEADER - -#endif /* __FTGZIP_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftimage.h b/thirdparty/include/freetype/ftimage.h deleted file mode 100644 index 2c3e06e36..000000000 --- a/thirdparty/include/freetype/ftimage.h +++ /dev/null @@ -1,1322 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftimage.h */ -/* */ -/* FreeType glyph image formats and default raster interface */ -/* (specification). */ -/* */ -/* Copyright 1996-2010, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* Note: A `raster' is simply a scan-line converter, used to render */ - /* FT_Outlines into FT_Bitmaps. */ - /* */ - /*************************************************************************/ - - -#ifndef __FTIMAGE_H__ -#define __FTIMAGE_H__ - - - /* _STANDALONE_ is from ftgrays.c */ -#ifndef _STANDALONE_ -#include <freetype/ft2build.h> -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* basic_types */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Pos */ - /* */ - /* <Description> */ - /* The type FT_Pos is used to store vectorial coordinates. Depending */ - /* on the context, these can represent distances in integer font */ - /* units, or 16.16, or 26.6 fixed-point pixel coordinates. */ - /* */ - typedef signed long FT_Pos; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Vector */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2D vector; coordinates are of */ - /* the FT_Pos type. */ - /* */ - /* <Fields> */ - /* x :: The horizontal coordinate. */ - /* y :: The vertical coordinate. */ - /* */ - typedef struct FT_Vector_ - { - FT_Pos x; - FT_Pos y; - - } FT_Vector; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_BBox */ - /* */ - /* <Description> */ - /* A structure used to hold an outline's bounding box, i.e., the */ - /* coordinates of its extrema in the horizontal and vertical */ - /* directions. */ - /* */ - /* <Fields> */ - /* xMin :: The horizontal minimum (left-most). */ - /* */ - /* yMin :: The vertical minimum (bottom-most). */ - /* */ - /* xMax :: The horizontal maximum (right-most). */ - /* */ - /* yMax :: The vertical maximum (top-most). */ - /* */ - /* <Note> */ - /* The bounding box is specified with the coordinates of the lower */ - /* left and the upper right corner. In PostScript, those values are */ - /* often called (llx,lly) and (urx,ury), respectively. */ - /* */ - /* If `yMin' is negative, this value gives the glyph's descender. */ - /* Otherwise, the glyph doesn't descend below the baseline. */ - /* Similarly, if `ymax' is positive, this value gives the glyph's */ - /* ascender. */ - /* */ - /* `xMin' gives the horizontal distance from the glyph's origin to */ - /* the left edge of the glyph's bounding box. If `xMin' is negative, */ - /* the glyph extends to the left of the origin. */ - /* */ - typedef struct FT_BBox_ - { - FT_Pos xMin, yMin; - FT_Pos xMax, yMax; - - } FT_BBox; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Pixel_Mode */ - /* */ - /* <Description> */ - /* An enumeration type used to describe the format of pixels in a */ - /* given bitmap. Note that additional formats may be added in the */ - /* future. */ - /* */ - /* <Values> */ - /* FT_PIXEL_MODE_NONE :: */ - /* Value~0 is reserved. */ - /* */ - /* FT_PIXEL_MODE_MONO :: */ - /* A monochrome bitmap, using 1~bit per pixel. Note that pixels */ - /* are stored in most-significant order (MSB), which means that */ - /* the left-most pixel in a byte has value 128. */ - /* */ - /* FT_PIXEL_MODE_GRAY :: */ - /* An 8-bit bitmap, generally used to represent anti-aliased glyph */ - /* images. Each pixel is stored in one byte. Note that the number */ - /* of `gray' levels is stored in the `num_grays' field of the */ - /* @FT_Bitmap structure (it generally is 256). */ - /* */ - /* FT_PIXEL_MODE_GRAY2 :: */ - /* A 2-bit per pixel bitmap, used to represent embedded */ - /* anti-aliased bitmaps in font files according to the OpenType */ - /* specification. We haven't found a single font using this */ - /* format, however. */ - /* */ - /* FT_PIXEL_MODE_GRAY4 :: */ - /* A 4-bit per pixel bitmap, representing embedded anti-aliased */ - /* bitmaps in font files according to the OpenType specification. */ - /* We haven't found a single font using this format, however. */ - /* */ - /* FT_PIXEL_MODE_LCD :: */ - /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ - /* used for display on LCD displays; the bitmap is three times */ - /* wider than the original glyph image. See also */ - /* @FT_RENDER_MODE_LCD. */ - /* */ - /* FT_PIXEL_MODE_LCD_V :: */ - /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ - /* used for display on rotated LCD displays; the bitmap is three */ - /* times taller than the original glyph image. See also */ - /* @FT_RENDER_MODE_LCD_V. */ - /* */ - /* FT_PIXEL_MODE_BGRA :: */ - /* An image with four 8-bit channels per pixel, representing a */ - /* color image (such as emoticons) with alpha channel. For each */ - /* pixel, the format is BGRA, which means, the blue channel comes */ - /* first in memory. The color channels are pre-multiplied and in */ - /* the sRGB colorspace. For example, full red at half-translucent */ - /* opacity will be represented as `00,00,80,80', not `00,00,FF,80'. */ - /* See also @FT_LOAD_COLOR. */ - /* */ - typedef enum FT_Pixel_Mode_ - { - FT_PIXEL_MODE_NONE = 0, - FT_PIXEL_MODE_MONO, - FT_PIXEL_MODE_GRAY, - FT_PIXEL_MODE_GRAY2, - FT_PIXEL_MODE_GRAY4, - FT_PIXEL_MODE_LCD, - FT_PIXEL_MODE_LCD_V, - FT_PIXEL_MODE_BGRA, - - FT_PIXEL_MODE_MAX /* do not remove */ - - } FT_Pixel_Mode; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* ft_pixel_mode_xxx */ - /* */ - /* <Description> */ - /* A list of deprecated constants. Use the corresponding */ - /* @FT_Pixel_Mode values instead. */ - /* */ - /* <Values> */ - /* ft_pixel_mode_none :: See @FT_PIXEL_MODE_NONE. */ - /* ft_pixel_mode_mono :: See @FT_PIXEL_MODE_MONO. */ - /* ft_pixel_mode_grays :: See @FT_PIXEL_MODE_GRAY. */ - /* ft_pixel_mode_pal2 :: See @FT_PIXEL_MODE_GRAY2. */ - /* ft_pixel_mode_pal4 :: See @FT_PIXEL_MODE_GRAY4. */ - /* */ -#define ft_pixel_mode_none FT_PIXEL_MODE_NONE -#define ft_pixel_mode_mono FT_PIXEL_MODE_MONO -#define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY -#define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2 -#define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4 - - /* */ - -#if 0 - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Palette_Mode */ - /* */ - /* <Description> */ - /* THIS TYPE IS DEPRECATED. DO NOT USE IT! */ - /* */ - /* An enumeration type to describe the format of a bitmap palette, */ - /* used with ft_pixel_mode_pal4 and ft_pixel_mode_pal8. */ - /* */ - /* <Values> */ - /* ft_palette_mode_rgb :: The palette is an array of 3-byte RGB */ - /* records. */ - /* */ - /* ft_palette_mode_rgba :: The palette is an array of 4-byte RGBA */ - /* records. */ - /* */ - /* <Note> */ - /* As ft_pixel_mode_pal2, pal4 and pal8 are currently unused by */ - /* FreeType, these types are not handled by the library itself. */ - /* */ - typedef enum FT_Palette_Mode_ - { - ft_palette_mode_rgb = 0, - ft_palette_mode_rgba, - - ft_palette_mode_max /* do not remove */ - - } FT_Palette_Mode; - - /* */ - -#endif - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Bitmap */ - /* */ - /* <Description> */ - /* A structure used to describe a bitmap or pixmap to the raster. */ - /* Note that we now manage pixmaps of various depths through the */ - /* `pixel_mode' field. */ - /* */ - /* <Fields> */ - /* rows :: The number of bitmap rows. */ - /* */ - /* width :: The number of pixels in bitmap row. */ - /* */ - /* pitch :: The pitch's absolute value is the number of bytes */ - /* taken by one bitmap row, including padding. */ - /* However, the pitch is positive when the bitmap has */ - /* a `down' flow, and negative when it has an `up' */ - /* flow. In all cases, the pitch is an offset to add */ - /* to a bitmap pointer in order to go down one row. */ - /* */ - /* Note that `padding' means the alignment of a */ - /* bitmap to a byte border, and FreeType functions */ - /* normally align to the smallest possible integer */ - /* value. */ - /* */ - /* For the B/W rasterizer, `pitch' is always an even */ - /* number. */ - /* */ - /* To change the pitch of a bitmap (say, to make it a */ - /* multiple of 4), use @FT_Bitmap_Convert. */ - /* Alternatively, you might use callback functions to */ - /* directly render to the application's surface; see */ - /* the file `example2.cpp' in the tutorial for a */ - /* demonstration. */ - /* */ - /* buffer :: A typeless pointer to the bitmap buffer. This */ - /* value should be aligned on 32-bit boundaries in */ - /* most cases. */ - /* */ - /* num_grays :: This field is only used with */ - /* @FT_PIXEL_MODE_GRAY; it gives the number of gray */ - /* levels used in the bitmap. */ - /* */ - /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */ - /* See @FT_Pixel_Mode for possible values. */ - /* */ - /* palette_mode :: This field is intended for paletted pixel modes; */ - /* it indicates how the palette is stored. Not */ - /* used currently. */ - /* */ - /* palette :: A typeless pointer to the bitmap palette; this */ - /* field is intended for paletted pixel modes. Not */ - /* used currently. */ - /* */ - /* <Note> */ - /* For now, the only pixel modes supported by FreeType are mono and */ - /* grays. However, drivers might be added in the future to support */ - /* more `colorful' options. */ - /* */ - typedef struct FT_Bitmap_ - { - int rows; - int width; - int pitch; - unsigned char* buffer; - short num_grays; - char pixel_mode; - char palette_mode; - void* palette; - - } FT_Bitmap; - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* outline_processing */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Outline */ - /* */ - /* <Description> */ - /* This structure is used to describe an outline to the scan-line */ - /* converter. */ - /* */ - /* <Fields> */ - /* n_contours :: The number of contours in the outline. */ - /* */ - /* n_points :: The number of points in the outline. */ - /* */ - /* points :: A pointer to an array of `n_points' @FT_Vector */ - /* elements, giving the outline's point coordinates. */ - /* */ - /* tags :: A pointer to an array of `n_points' chars, giving */ - /* each outline point's type. */ - /* */ - /* If bit~0 is unset, the point is `off' the curve, */ - /* i.e., a Bézier control point, while it is `on' if */ - /* set. */ - /* */ - /* Bit~1 is meaningful for `off' points only. If set, */ - /* it indicates a third-order Bézier arc control point; */ - /* and a second-order control point if unset. */ - /* */ - /* If bit~2 is set, bits 5-7 contain the drop-out mode */ - /* (as defined in the OpenType specification; the value */ - /* is the same as the argument to the SCANMODE */ - /* instruction). */ - /* */ - /* Bits 3 and~4 are reserved for internal purposes. */ - /* */ - /* contours :: An array of `n_contours' shorts, giving the end */ - /* point of each contour within the outline. For */ - /* example, the first contour is defined by the points */ - /* `0' to `contours[0]', the second one is defined by */ - /* the points `contours[0]+1' to `contours[1]', etc. */ - /* */ - /* flags :: A set of bit flags used to characterize the outline */ - /* and give hints to the scan-converter and hinter on */ - /* how to convert/grid-fit it. See @FT_OUTLINE_FLAGS. */ - /* */ - /* <Note> */ - /* The B/W rasterizer only checks bit~2 in the `tags' array for the */ - /* first point of each contour. The drop-out mode as given with */ - /* @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and */ - /* @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden. */ - /* */ - typedef struct FT_Outline_ - { - short n_contours; /* number of contours in glyph */ - short n_points; /* number of points in the glyph */ - - FT_Vector* points; /* the outline's points */ - char* tags; /* the points flags */ - short* contours; /* the contour end points */ - - int flags; /* outline masks */ - - } FT_Outline; - - /* Following limits must be consistent with */ - /* FT_Outline.{n_contours,n_points} */ -#define FT_OUTLINE_CONTOURS_MAX SHRT_MAX -#define FT_OUTLINE_POINTS_MAX SHRT_MAX - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_OUTLINE_FLAGS */ - /* */ - /* <Description> */ - /* A list of bit-field constants use for the flags in an outline's */ - /* `flags' field. */ - /* */ - /* <Values> */ - /* FT_OUTLINE_NONE :: */ - /* Value~0 is reserved. */ - /* */ - /* FT_OUTLINE_OWNER :: */ - /* If set, this flag indicates that the outline's field arrays */ - /* (i.e., `points', `flags', and `contours') are `owned' by the */ - /* outline object, and should thus be freed when it is destroyed. */ - /* */ - /* FT_OUTLINE_EVEN_ODD_FILL :: */ - /* By default, outlines are filled using the non-zero winding rule. */ - /* If set to 1, the outline will be filled using the even-odd fill */ - /* rule (only works with the smooth rasterizer). */ - /* */ - /* FT_OUTLINE_REVERSE_FILL :: */ - /* By default, outside contours of an outline are oriented in */ - /* clock-wise direction, as defined in the TrueType specification. */ - /* This flag is set if the outline uses the opposite direction */ - /* (typically for Type~1 fonts). This flag is ignored by the scan */ - /* converter. */ - /* */ - /* FT_OUTLINE_IGNORE_DROPOUTS :: */ - /* By default, the scan converter will try to detect drop-outs in */ - /* an outline and correct the glyph bitmap to ensure consistent */ - /* shape continuity. If set, this flag hints the scan-line */ - /* converter to ignore such cases. See below for more information. */ - /* */ - /* FT_OUTLINE_SMART_DROPOUTS :: */ - /* Select smart dropout control. If unset, use simple dropout */ - /* control. Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See */ - /* below for more information. */ - /* */ - /* FT_OUTLINE_INCLUDE_STUBS :: */ - /* If set, turn pixels on for `stubs', otherwise exclude them. */ - /* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for */ - /* more information. */ - /* */ - /* FT_OUTLINE_HIGH_PRECISION :: */ - /* This flag indicates that the scan-line converter should try to */ - /* convert this outline to bitmaps with the highest possible */ - /* quality. It is typically set for small character sizes. Note */ - /* that this is only a hint that might be completely ignored by a */ - /* given scan-converter. */ - /* */ - /* FT_OUTLINE_SINGLE_PASS :: */ - /* This flag is set to force a given scan-converter to only use a */ - /* single pass over the outline to render a bitmap glyph image. */ - /* Normally, it is set for very large character sizes. It is only */ - /* a hint that might be completely ignored by a given */ - /* scan-converter. */ - /* */ - /* <Note> */ - /* The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, */ - /* and @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth */ - /* rasterizer. */ - /* */ - /* There exists a second mechanism to pass the drop-out mode to the */ - /* B/W rasterizer; see the `tags' field in @FT_Outline. */ - /* */ - /* Please refer to the description of the `SCANTYPE' instruction in */ - /* the OpenType specification (in file `ttinst1.doc') how simple */ - /* drop-outs, smart drop-outs, and stubs are defined. */ - /* */ -#define FT_OUTLINE_NONE 0x0 -#define FT_OUTLINE_OWNER 0x1 -#define FT_OUTLINE_EVEN_ODD_FILL 0x2 -#define FT_OUTLINE_REVERSE_FILL 0x4 -#define FT_OUTLINE_IGNORE_DROPOUTS 0x8 -#define FT_OUTLINE_SMART_DROPOUTS 0x10 -#define FT_OUTLINE_INCLUDE_STUBS 0x20 - -#define FT_OUTLINE_HIGH_PRECISION 0x100 -#define FT_OUTLINE_SINGLE_PASS 0x200 - - - /************************************************************************* - * - * @enum: - * ft_outline_flags - * - * @description: - * These constants are deprecated. Please use the corresponding - * @FT_OUTLINE_FLAGS values. - * - * @values: - * ft_outline_none :: See @FT_OUTLINE_NONE. - * ft_outline_owner :: See @FT_OUTLINE_OWNER. - * ft_outline_even_odd_fill :: See @FT_OUTLINE_EVEN_ODD_FILL. - * ft_outline_reverse_fill :: See @FT_OUTLINE_REVERSE_FILL. - * ft_outline_ignore_dropouts :: See @FT_OUTLINE_IGNORE_DROPOUTS. - * ft_outline_high_precision :: See @FT_OUTLINE_HIGH_PRECISION. - * ft_outline_single_pass :: See @FT_OUTLINE_SINGLE_PASS. - */ -#define ft_outline_none FT_OUTLINE_NONE -#define ft_outline_owner FT_OUTLINE_OWNER -#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL -#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL -#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS -#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION -#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS - - /* */ - -#define FT_CURVE_TAG( flag ) ( flag & 3 ) - -#define FT_CURVE_TAG_ON 1 -#define FT_CURVE_TAG_CONIC 0 -#define FT_CURVE_TAG_CUBIC 2 - -#define FT_CURVE_TAG_HAS_SCANMODE 4 - -#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */ -#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */ - -#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \ - FT_CURVE_TAG_TOUCH_Y ) - -#define FT_Curve_Tag_On FT_CURVE_TAG_ON -#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC -#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC -#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X -#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_MoveToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `move */ - /* to' function during outline walking/decomposition. */ - /* */ - /* A `move to' is emitted to start a new contour in an outline. */ - /* */ - /* <Input> */ - /* to :: A pointer to the target point of the `move to'. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of the */ - /* decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - typedef int - (*FT_Outline_MoveToFunc)( const FT_Vector* to, - void* user ); - -#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_LineToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `line */ - /* to' function during outline walking/decomposition. */ - /* */ - /* A `line to' is emitted to indicate a segment in the outline. */ - /* */ - /* <Input> */ - /* to :: A pointer to the target point of the `line to'. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of the */ - /* decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - typedef int - (*FT_Outline_LineToFunc)( const FT_Vector* to, - void* user ); - -#define FT_Outline_LineTo_Func FT_Outline_LineToFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_ConicToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `conic */ - /* to' function during outline walking or decomposition. */ - /* */ - /* A `conic to' is emitted to indicate a second-order Bézier arc in */ - /* the outline. */ - /* */ - /* <Input> */ - /* control :: An intermediate control point between the last position */ - /* and the new target in `to'. */ - /* */ - /* to :: A pointer to the target end point of the conic arc. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of */ - /* the decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - typedef int - (*FT_Outline_ConicToFunc)( const FT_Vector* control, - const FT_Vector* to, - void* user ); - -#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_CubicToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `cubic */ - /* to' function during outline walking or decomposition. */ - /* */ - /* A `cubic to' is emitted to indicate a third-order Bézier arc. */ - /* */ - /* <Input> */ - /* control1 :: A pointer to the first Bézier control point. */ - /* */ - /* control2 :: A pointer to the second Bézier control point. */ - /* */ - /* to :: A pointer to the target end point. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of */ - /* the decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - typedef int - (*FT_Outline_CubicToFunc)( const FT_Vector* control1, - const FT_Vector* control2, - const FT_Vector* to, - void* user ); - -#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Outline_Funcs */ - /* */ - /* <Description> */ - /* A structure to hold various function pointers used during outline */ - /* decomposition in order to emit segments, conic, and cubic Béziers. */ - /* */ - /* <Fields> */ - /* move_to :: The `move to' emitter. */ - /* */ - /* line_to :: The segment emitter. */ - /* */ - /* conic_to :: The second-order Bézier arc emitter. */ - /* */ - /* cubic_to :: The third-order Bézier arc emitter. */ - /* */ - /* shift :: The shift that is applied to coordinates before they */ - /* are sent to the emitter. */ - /* */ - /* delta :: The delta that is applied to coordinates before they */ - /* are sent to the emitter, but after the shift. */ - /* */ - /* <Note> */ - /* The point coordinates sent to the emitters are the transformed */ - /* version of the original coordinates (this is important for high */ - /* accuracy during scan-conversion). The transformation is simple: */ - /* */ - /* { */ - /* x' = (x << shift) - delta */ - /* y' = (x << shift) - delta */ - /* } */ - /* */ - /* Set the values of `shift' and `delta' to~0 to get the original */ - /* point coordinates. */ - /* */ - typedef struct FT_Outline_Funcs_ - { - FT_Outline_MoveToFunc move_to; - FT_Outline_LineToFunc line_to; - FT_Outline_ConicToFunc conic_to; - FT_Outline_CubicToFunc cubic_to; - - int shift; - FT_Pos delta; - - } FT_Outline_Funcs; - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* basic_types */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_IMAGE_TAG */ - /* */ - /* <Description> */ - /* This macro converts four-letter tags to an unsigned long type. */ - /* */ - /* <Note> */ - /* Since many 16-bit compilers don't like 32-bit enumerations, you */ - /* should redefine this macro in case of problems to something like */ - /* this: */ - /* */ - /* { */ - /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */ - /* } */ - /* */ - /* to get a simple enumeration without assigning special numbers. */ - /* */ -#ifndef FT_IMAGE_TAG -#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ - value = ( ( (unsigned long)_x1 << 24 ) | \ - ( (unsigned long)_x2 << 16 ) | \ - ( (unsigned long)_x3 << 8 ) | \ - (unsigned long)_x4 ) -#endif /* FT_IMAGE_TAG */ - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Glyph_Format */ - /* */ - /* <Description> */ - /* An enumeration type used to describe the format of a given glyph */ - /* image. Note that this version of FreeType only supports two image */ - /* formats, even though future font drivers will be able to register */ - /* their own format. */ - /* */ - /* <Values> */ - /* FT_GLYPH_FORMAT_NONE :: */ - /* The value~0 is reserved. */ - /* */ - /* FT_GLYPH_FORMAT_COMPOSITE :: */ - /* The glyph image is a composite of several other images. This */ - /* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */ - /* report compound glyphs (like accented characters). */ - /* */ - /* FT_GLYPH_FORMAT_BITMAP :: */ - /* The glyph image is a bitmap, and can be described as an */ - /* @FT_Bitmap. You generally need to access the `bitmap' field of */ - /* the @FT_GlyphSlotRec structure to read it. */ - /* */ - /* FT_GLYPH_FORMAT_OUTLINE :: */ - /* The glyph image is a vectorial outline made of line segments */ - /* and Bézier arcs; it can be described as an @FT_Outline; you */ - /* generally want to access the `outline' field of the */ - /* @FT_GlyphSlotRec structure to read it. */ - /* */ - /* FT_GLYPH_FORMAT_PLOTTER :: */ - /* The glyph image is a vectorial path with no inside and outside */ - /* contours. Some Type~1 fonts, like those in the Hershey family, */ - /* contain glyphs in this format. These are described as */ - /* @FT_Outline, but FreeType isn't currently capable of rendering */ - /* them correctly. */ - /* */ - typedef enum FT_Glyph_Format_ - { - FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), - - FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ), - FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ), - FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ), - FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ) - - } FT_Glyph_Format; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* ft_glyph_format_xxx */ - /* */ - /* <Description> */ - /* A list of deprecated constants. Use the corresponding */ - /* @FT_Glyph_Format values instead. */ - /* */ - /* <Values> */ - /* ft_glyph_format_none :: See @FT_GLYPH_FORMAT_NONE. */ - /* ft_glyph_format_composite :: See @FT_GLYPH_FORMAT_COMPOSITE. */ - /* ft_glyph_format_bitmap :: See @FT_GLYPH_FORMAT_BITMAP. */ - /* ft_glyph_format_outline :: See @FT_GLYPH_FORMAT_OUTLINE. */ - /* ft_glyph_format_plotter :: See @FT_GLYPH_FORMAT_PLOTTER. */ - /* */ -#define ft_glyph_format_none FT_GLYPH_FORMAT_NONE -#define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE -#define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP -#define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE -#define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** R A S T E R D E F I N I T I O N S *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* A raster is a scan converter, in charge of rendering an outline into */ - /* a a bitmap. This section contains the public API for rasters. */ - /* */ - /* Note that in FreeType 2, all rasters are now encapsulated within */ - /* specific modules called `renderers'. See `ftrender.h' for more */ - /* details on renderers. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* raster */ - /* */ - /* <Title> */ - /* Scanline Converter */ - /* */ - /* <Abstract> */ - /* How vectorial outlines are converted into bitmaps and pixmaps. */ - /* */ - /* <Description> */ - /* This section contains technical definitions. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Raster */ - /* */ - /* <Description> */ - /* A handle (pointer) to a raster object. Each object can be used */ - /* independently to convert an outline into a bitmap or pixmap. */ - /* */ - typedef struct FT_RasterRec_* FT_Raster; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Span */ - /* */ - /* <Description> */ - /* A structure used to model a single span of gray (or black) pixels */ - /* when rendering a monochrome or anti-aliased bitmap. */ - /* */ - /* <Fields> */ - /* x :: The span's horizontal start position. */ - /* */ - /* len :: The span's length in pixels. */ - /* */ - /* coverage :: The span color/coverage, ranging from 0 (background) */ - /* to 255 (foreground). Only used for anti-aliased */ - /* rendering. */ - /* */ - /* <Note> */ - /* This structure is used by the span drawing callback type named */ - /* @FT_SpanFunc that takes the y~coordinate of the span as a */ - /* parameter. */ - /* */ - /* The coverage value is always between 0 and 255. If you want less */ - /* gray values, the callback function has to reduce them. */ - /* */ - typedef struct FT_Span_ - { - short x; - unsigned short len; - unsigned char coverage; - - } FT_Span; - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_SpanFunc */ - /* */ - /* <Description> */ - /* A function used as a call-back by the anti-aliased renderer in */ - /* order to let client applications draw themselves the gray pixel */ - /* spans on each scan line. */ - /* */ - /* <Input> */ - /* y :: The scanline's y~coordinate. */ - /* */ - /* count :: The number of spans to draw on this scanline. */ - /* */ - /* spans :: A table of `count' spans to draw on the scanline. */ - /* */ - /* user :: User-supplied data that is passed to the callback. */ - /* */ - /* <Note> */ - /* This callback allows client applications to directly render the */ - /* gray spans of the anti-aliased bitmap to any kind of surfaces. */ - /* */ - /* This can be used to write anti-aliased outlines directly to a */ - /* given background bitmap, and even perform translucency. */ - /* */ - /* Note that the `count' field cannot be greater than a fixed value */ - /* defined by the `FT_MAX_GRAY_SPANS' configuration macro in */ - /* `ftoption.h'. By default, this value is set to~32, which means */ - /* that if there are more than 32~spans on a given scanline, the */ - /* callback is called several times with the same `y' parameter in */ - /* order to draw all callbacks. */ - /* */ - /* Otherwise, the callback is only called once per scan-line, and */ - /* only for those scanlines that do have `gray' pixels on them. */ - /* */ - typedef void - (*FT_SpanFunc)( int y, - int count, - const FT_Span* spans, - void* user ); - -#define FT_Raster_Span_Func FT_SpanFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_BitTest_Func */ - /* */ - /* <Description> */ - /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */ - /* */ - /* A function used as a call-back by the monochrome scan-converter */ - /* to test whether a given target pixel is already set to the drawing */ - /* `color'. These tests are crucial to implement drop-out control */ - /* per-se the TrueType spec. */ - /* */ - /* <Input> */ - /* y :: The pixel's y~coordinate. */ - /* */ - /* x :: The pixel's x~coordinate. */ - /* */ - /* user :: User-supplied data that is passed to the callback. */ - /* */ - /* <Return> */ - /* 1~if the pixel is `set', 0~otherwise. */ - /* */ - typedef int - (*FT_Raster_BitTest_Func)( int y, - int x, - void* user ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_BitSet_Func */ - /* */ - /* <Description> */ - /* THIS TYPE IS DEPRECATED. DO NOT USE IT. */ - /* */ - /* A function used as a call-back by the monochrome scan-converter */ - /* to set an individual target pixel. This is crucial to implement */ - /* drop-out control according to the TrueType specification. */ - /* */ - /* <Input> */ - /* y :: The pixel's y~coordinate. */ - /* */ - /* x :: The pixel's x~coordinate. */ - /* */ - /* user :: User-supplied data that is passed to the callback. */ - /* */ - /* <Return> */ - /* 1~if the pixel is `set', 0~otherwise. */ - /* */ - typedef void - (*FT_Raster_BitSet_Func)( int y, - int x, - void* user ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_RASTER_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flag constants as used in the `flags' field of a */ - /* @FT_Raster_Params structure. */ - /* */ - /* <Values> */ - /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */ - /* */ - /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */ - /* anti-aliased glyph image should be */ - /* generated. Otherwise, it will be */ - /* monochrome (1-bit). */ - /* */ - /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */ - /* rendering. In this mode, client */ - /* applications must provide their own span */ - /* callback. This lets them directly */ - /* draw or compose over an existing bitmap. */ - /* If this bit is not set, the target */ - /* pixmap's buffer _must_ be zeroed before */ - /* rendering. */ - /* */ - /* Note that for now, direct rendering is */ - /* only possible with anti-aliased glyphs. */ - /* */ - /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */ - /* rendering mode. If set, the output will */ - /* be clipped to a box specified in the */ - /* `clip_box' field of the */ - /* @FT_Raster_Params structure. */ - /* */ - /* Note that by default, the glyph bitmap */ - /* is clipped to the target pixmap, except */ - /* in direct rendering mode where all spans */ - /* are generated if no clipping box is set. */ - /* */ -#define FT_RASTER_FLAG_DEFAULT 0x0 -#define FT_RASTER_FLAG_AA 0x1 -#define FT_RASTER_FLAG_DIRECT 0x2 -#define FT_RASTER_FLAG_CLIP 0x4 - - /* deprecated */ -#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT -#define ft_raster_flag_aa FT_RASTER_FLAG_AA -#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT -#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Raster_Params */ - /* */ - /* <Description> */ - /* A structure to hold the arguments used by a raster's render */ - /* function. */ - /* */ - /* <Fields> */ - /* target :: The target bitmap. */ - /* */ - /* source :: A pointer to the source glyph image (e.g., an */ - /* @FT_Outline). */ - /* */ - /* flags :: The rendering flags. */ - /* */ - /* gray_spans :: The gray span drawing callback. */ - /* */ - /* black_spans :: The black span drawing callback. UNIMPLEMENTED! */ - /* */ - /* bit_test :: The bit test callback. UNIMPLEMENTED! */ - /* */ - /* bit_set :: The bit set callback. UNIMPLEMENTED! */ - /* */ - /* user :: User-supplied data that is passed to each drawing */ - /* callback. */ - /* */ - /* clip_box :: An optional clipping box. It is only used in */ - /* direct rendering mode. Note that coordinates here */ - /* should be expressed in _integer_ pixels (and not in */ - /* 26.6 fixed-point units). */ - /* */ - /* <Note> */ - /* An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA */ - /* bit flag is set in the `flags' field, otherwise a monochrome */ - /* bitmap is generated. */ - /* */ - /* If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */ - /* raster will call the `gray_spans' callback to draw gray pixel */ - /* spans, in the case of an aa glyph bitmap, it will call */ - /* `black_spans', and `bit_test' and `bit_set' in the case of a */ - /* monochrome bitmap. This allows direct composition over a */ - /* pre-existing bitmap through user-provided callbacks to perform the */ - /* span drawing/composition. */ - /* */ - /* Note that the `bit_test' and `bit_set' callbacks are required when */ - /* rendering a monochrome bitmap, as they are crucial to implement */ - /* correct drop-out control as defined in the TrueType specification. */ - /* */ - typedef struct FT_Raster_Params_ - { - const FT_Bitmap* target; - const void* source; - int flags; - FT_SpanFunc gray_spans; - FT_SpanFunc black_spans; /* doesn't work! */ - FT_Raster_BitTest_Func bit_test; /* doesn't work! */ - FT_Raster_BitSet_Func bit_set; /* doesn't work! */ - void* user; - FT_BBox clip_box; - - } FT_Raster_Params; - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_NewFunc */ - /* */ - /* <Description> */ - /* A function used to create a new raster object. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory allocator. */ - /* */ - /* <Output> */ - /* raster :: A handle to the new raster object. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `memory' parameter is a typeless pointer in order to avoid */ - /* un-wanted dependencies on the rest of the FreeType code. In */ - /* practice, it is an @FT_Memory object, i.e., a handle to the */ - /* standard FreeType memory allocator. However, this field can be */ - /* completely ignored by a given raster implementation. */ - /* */ - typedef int - (*FT_Raster_NewFunc)( void* memory, - FT_Raster* raster ); - -#define FT_Raster_New_Func FT_Raster_NewFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_DoneFunc */ - /* */ - /* <Description> */ - /* A function used to destroy a given raster object. */ - /* */ - /* <Input> */ - /* raster :: A handle to the raster object. */ - /* */ - typedef void - (*FT_Raster_DoneFunc)( FT_Raster raster ); - -#define FT_Raster_Done_Func FT_Raster_DoneFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_ResetFunc */ - /* */ - /* <Description> */ - /* FreeType provides an area of memory called the `render pool', */ - /* available to all registered rasters. This pool can be freely used */ - /* during a given scan-conversion but is shared by all rasters. Its */ - /* content is thus transient. */ - /* */ - /* This function is called each time the render pool changes, or just */ - /* after a new raster object is created. */ - /* */ - /* <Input> */ - /* raster :: A handle to the new raster object. */ - /* */ - /* pool_base :: The address in memory of the render pool. */ - /* */ - /* pool_size :: The size in bytes of the render pool. */ - /* */ - /* <Note> */ - /* Rasters can ignore the render pool and rely on dynamic memory */ - /* allocation if they want to (a handle to the memory allocator is */ - /* passed to the raster constructor). However, this is not */ - /* recommended for efficiency purposes. */ - /* */ - typedef void - (*FT_Raster_ResetFunc)( FT_Raster raster, - unsigned char* pool_base, - unsigned long pool_size ); - -#define FT_Raster_Reset_Func FT_Raster_ResetFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_SetModeFunc */ - /* */ - /* <Description> */ - /* This function is a generic facility to change modes or attributes */ - /* in a given raster. This can be used for debugging purposes, or */ - /* simply to allow implementation-specific `features' in a given */ - /* raster module. */ - /* */ - /* <Input> */ - /* raster :: A handle to the new raster object. */ - /* */ - /* mode :: A 4-byte tag used to name the mode or property. */ - /* */ - /* args :: A pointer to the new mode/property to use. */ - /* */ - typedef int - (*FT_Raster_SetModeFunc)( FT_Raster raster, - unsigned long mode, - void* args ); - -#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_RenderFunc */ - /* */ - /* <Description> */ - /* Invoke a given raster to scan-convert a given glyph image into a */ - /* target bitmap. */ - /* */ - /* <Input> */ - /* raster :: A handle to the raster object. */ - /* */ - /* params :: A pointer to an @FT_Raster_Params structure used to */ - /* store the rendering parameters. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - /* <Note> */ - /* The exact format of the source image depends on the raster's glyph */ - /* format defined in its @FT_Raster_Funcs structure. It can be an */ - /* @FT_Outline or anything else in order to support a large array of */ - /* glyph formats. */ - /* */ - /* Note also that the render function can fail and return a */ - /* `FT_Err_Unimplemented_Feature' error code if the raster used does */ - /* not support direct composition. */ - /* */ - /* XXX: For now, the standard raster doesn't support direct */ - /* composition but this should change for the final release (see */ - /* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */ - /* for examples of distinct implementations that support direct */ - /* composition). */ - /* */ - typedef int - (*FT_Raster_RenderFunc)( FT_Raster raster, - const FT_Raster_Params* params ); - -#define FT_Raster_Render_Func FT_Raster_RenderFunc - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Raster_Funcs */ - /* */ - /* <Description> */ - /* A structure used to describe a given raster class to the library. */ - /* */ - /* <Fields> */ - /* glyph_format :: The supported glyph format for this raster. */ - /* */ - /* raster_new :: The raster constructor. */ - /* */ - /* raster_reset :: Used to reset the render pool within the raster. */ - /* */ - /* raster_render :: A function to render a glyph into a given bitmap. */ - /* */ - /* raster_done :: The raster destructor. */ - /* */ - typedef struct FT_Raster_Funcs_ - { - FT_Glyph_Format glyph_format; - FT_Raster_NewFunc raster_new; - FT_Raster_ResetFunc raster_reset; - FT_Raster_SetModeFunc raster_set_mode; - FT_Raster_RenderFunc raster_render; - FT_Raster_DoneFunc raster_done; - - } FT_Raster_Funcs; - - - /* */ - - -FT_END_HEADER - -#endif /* __FTIMAGE_H__ */ - - -/* END */ - - -/* Local Variables: */ -/* coding: utf-8 */ -/* End: */ diff --git a/thirdparty/include/freetype/ftincrem.h b/thirdparty/include/freetype/ftincrem.h deleted file mode 100644 index ea01c26ae..000000000 --- a/thirdparty/include/freetype/ftincrem.h +++ /dev/null @@ -1,353 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftincrem.h */ -/* */ -/* FreeType incremental loading (specification). */ -/* */ -/* Copyright 2002, 2003, 2006, 2007, 2008, 2010 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTINCREM_H__ -#define __FTINCREM_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /*************************************************************************** - * - * @section: - * incremental - * - * @title: - * Incremental Loading - * - * @abstract: - * Custom Glyph Loading. - * - * @description: - * This section contains various functions used to perform so-called - * `incremental' glyph loading. This is a mode where all glyphs loaded - * from a given @FT_Face are provided by the client application, - * - * Apart from that, all other tables are loaded normally from the font - * file. This mode is useful when FreeType is used within another - * engine, e.g., a PostScript Imaging Processor. - * - * To enable this mode, you must use @FT_Open_Face, passing an - * @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an - * @FT_Incremental_Interface value. See the comments for - * @FT_Incremental_InterfaceRec for an example. - * - */ - - - /*************************************************************************** - * - * @type: - * FT_Incremental - * - * @description: - * An opaque type describing a user-provided object used to implement - * `incremental' glyph loading within FreeType. This is used to support - * embedded fonts in certain environments (e.g., PostScript interpreters), - * where the glyph data isn't in the font file, or must be overridden by - * different values. - * - * @note: - * It is up to client applications to create and implement @FT_Incremental - * objects, as long as they provide implementations for the methods - * @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc - * and @FT_Incremental_GetGlyphMetricsFunc. - * - * See the description of @FT_Incremental_InterfaceRec to understand how - * to use incremental objects with FreeType. - * - */ - typedef struct FT_IncrementalRec_* FT_Incremental; - - - /*************************************************************************** - * - * @struct: - * FT_Incremental_MetricsRec - * - * @description: - * A small structure used to contain the basic glyph metrics returned - * by the @FT_Incremental_GetGlyphMetricsFunc method. - * - * @fields: - * bearing_x :: - * Left bearing, in font units. - * - * bearing_y :: - * Top bearing, in font units. - * - * advance :: - * Horizontal component of glyph advance, in font units. - * - * advance_v :: - * Vertical component of glyph advance, in font units. - * - * @note: - * These correspond to horizontal or vertical metrics depending on the - * value of the `vertical' argument to the function - * @FT_Incremental_GetGlyphMetricsFunc. - * - */ - typedef struct FT_Incremental_MetricsRec_ - { - FT_Long bearing_x; - FT_Long bearing_y; - FT_Long advance; - FT_Long advance_v; /* since 2.3.12 */ - - } FT_Incremental_MetricsRec; - - - /*************************************************************************** - * - * @struct: - * FT_Incremental_Metrics - * - * @description: - * A handle to an @FT_Incremental_MetricsRec structure. - * - */ - typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics; - - - /*************************************************************************** - * - * @type: - * FT_Incremental_GetGlyphDataFunc - * - * @description: - * A function called by FreeType to access a given glyph's data bytes - * during @FT_Load_Glyph or @FT_Load_Char if incremental loading is - * enabled. - * - * Note that the format of the glyph's data bytes depends on the font - * file format. For TrueType, it must correspond to the raw bytes within - * the `glyf' table. For PostScript formats, it must correspond to the - * *unencrypted* charstring bytes, without any `lenIV' header. It is - * undefined for any other format. - * - * @input: - * incremental :: - * Handle to an opaque @FT_Incremental handle provided by the client - * application. - * - * glyph_index :: - * Index of relevant glyph. - * - * @output: - * adata :: - * A structure describing the returned glyph data bytes (which will be - * accessed as a read-only byte block). - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If this function returns successfully the method - * @FT_Incremental_FreeGlyphDataFunc will be called later to release - * the data bytes. - * - * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for - * compound glyphs. - * - */ - typedef FT_Error - (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental, - FT_UInt glyph_index, - FT_Data* adata ); - - - /*************************************************************************** - * - * @type: - * FT_Incremental_FreeGlyphDataFunc - * - * @description: - * A function used to release the glyph data bytes returned by a - * successful call to @FT_Incremental_GetGlyphDataFunc. - * - * @input: - * incremental :: - * A handle to an opaque @FT_Incremental handle provided by the client - * application. - * - * data :: - * A structure describing the glyph data bytes (which will be accessed - * as a read-only byte block). - * - */ - typedef void - (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental, - FT_Data* data ); - - - /*************************************************************************** - * - * @type: - * FT_Incremental_GetGlyphMetricsFunc - * - * @description: - * A function used to retrieve the basic metrics of a given glyph index - * before accessing its data. This is necessary because, in certain - * formats like TrueType, the metrics are stored in a different place from - * the glyph images proper. - * - * @input: - * incremental :: - * A handle to an opaque @FT_Incremental handle provided by the client - * application. - * - * glyph_index :: - * Index of relevant glyph. - * - * vertical :: - * If true, return vertical metrics. - * - * ametrics :: - * This parameter is used for both input and output. - * The original glyph metrics, if any, in font units. If metrics are - * not available all the values must be set to zero. - * - * @output: - * ametrics :: - * The replacement glyph metrics in font units. - * - */ - typedef FT_Error - (*FT_Incremental_GetGlyphMetricsFunc) - ( FT_Incremental incremental, - FT_UInt glyph_index, - FT_Bool vertical, - FT_Incremental_MetricsRec *ametrics ); - - - /************************************************************************** - * - * @struct: - * FT_Incremental_FuncsRec - * - * @description: - * A table of functions for accessing fonts that load data - * incrementally. Used in @FT_Incremental_InterfaceRec. - * - * @fields: - * get_glyph_data :: - * The function to get glyph data. Must not be null. - * - * free_glyph_data :: - * The function to release glyph data. Must not be null. - * - * get_glyph_metrics :: - * The function to get glyph metrics. May be null if the font does - * not provide overriding glyph metrics. - * - */ - typedef struct FT_Incremental_FuncsRec_ - { - FT_Incremental_GetGlyphDataFunc get_glyph_data; - FT_Incremental_FreeGlyphDataFunc free_glyph_data; - FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics; - - } FT_Incremental_FuncsRec; - - - /*************************************************************************** - * - * @struct: - * FT_Incremental_InterfaceRec - * - * @description: - * A structure to be used with @FT_Open_Face to indicate that the user - * wants to support incremental glyph loading. You should use it with - * @FT_PARAM_TAG_INCREMENTAL as in the following example: - * - * { - * FT_Incremental_InterfaceRec inc_int; - * FT_Parameter parameter; - * FT_Open_Args open_args; - * - * - * // set up incremental descriptor - * inc_int.funcs = my_funcs; - * inc_int.object = my_object; - * - * // set up optional parameter - * parameter.tag = FT_PARAM_TAG_INCREMENTAL; - * parameter.data = &inc_int; - * - * // set up FT_Open_Args structure - * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS; - * open_args.pathname = my_font_pathname; - * open_args.num_params = 1; - * open_args.params = ¶meter; // we use one optional argument - * - * // open the font - * error = FT_Open_Face( library, &open_args, index, &face ); - * ... - * } - * - */ - typedef struct FT_Incremental_InterfaceRec_ - { - const FT_Incremental_FuncsRec* funcs; - FT_Incremental object; - - } FT_Incremental_InterfaceRec; - - - /*************************************************************************** - * - * @type: - * FT_Incremental_Interface - * - * @description: - * A pointer to an @FT_Incremental_InterfaceRec structure. - * - */ - typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface; - - - /*************************************************************************** - * - * @constant: - * FT_PARAM_TAG_INCREMENTAL - * - * @description: - * A constant used as the tag of @FT_Parameter structures to indicate - * an incremental loading object to be used by FreeType. - * - */ -#define FT_PARAM_TAG_INCREMENTAL FT_MAKE_TAG( 'i', 'n', 'c', 'r' ) - - /* */ - -FT_END_HEADER - -#endif /* __FTINCREM_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftlcdfil.h b/thirdparty/include/freetype/ftlcdfil.h deleted file mode 100644 index a95af6e15..000000000 --- a/thirdparty/include/freetype/ftlcdfil.h +++ /dev/null @@ -1,251 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftlcdfil.h */ -/* */ -/* FreeType API for color filtering of subpixel bitmap glyphs */ -/* (specification). */ -/* */ -/* Copyright 2006-2008, 2010, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FT_LCD_FILTER_H__ -#define __FT_LCD_FILTER_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /*************************************************************************** - * - * @section: - * lcd_filtering - * - * @title: - * LCD Filtering - * - * @abstract: - * Reduce color fringes of LCD-optimized bitmaps. - * - * @description: - * The @FT_Library_SetLcdFilter API can be used to specify a low-pass - * filter, which is then applied to LCD-optimized bitmaps generated - * through @FT_Render_Glyph. This is useful to reduce color fringes - * that would occur with unfiltered rendering. - * - * Note that no filter is active by default, and that this function is - * *not* implemented in default builds of the library. You need to - * #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your `ftoption.h' file - * in order to activate it. - * - * FreeType generates alpha coverage maps, which are linear by nature. - * For instance, the value 0x80 in bitmap representation means that - * (within numerical precision) 0x80/0xff fraction of that pixel is - * covered by the glyph's outline. The blending function for placing - * text over a background is - * - * { - * dst = alpha * src + (1 - alpha) * dst , - * } - * - * which is known as OVER. However, when calculating the output of the - * OVER operator, the source colors should first be transformed to a - * linear color space, then alpha blended in that space, and transformed - * back to the output color space. - * - * When linear light blending is used, the default FIR5 filtering - * weights (as given by FT_LCD_FILTER_DEFAULT) are no longer optimal, as - * they have been designed for black on white rendering while lacking - * gamma correction. To preserve color neutrality, weights for a FIR5 - * filter should be chosen according to two free parameters `a' and `c', - * and the FIR weights should be - * - * { - * [a - c, a + c, 2 * a, a + c, a - c] . - * } - * - * This formula generates equal weights for all the color primaries - * across the filter kernel, which makes it colorless. One suggested - * set of weights is - * - * { - * [0x10, 0x50, 0x60, 0x50, 0x10] , - * } - * - * where `a' has value 0x30 and `b' value 0x20. The weights in filter - * may have a sum larger than 0x100, which increases coloration slightly - * but also improves contrast. - */ - - - /**************************************************************************** - * - * @enum: - * FT_LcdFilter - * - * @description: - * A list of values to identify various types of LCD filters. - * - * @values: - * FT_LCD_FILTER_NONE :: - * Do not perform filtering. When used with subpixel rendering, this - * results in sometimes severe color fringes. - * - * FT_LCD_FILTER_DEFAULT :: - * The default filter reduces color fringes considerably, at the cost - * of a slight blurriness in the output. - * - * FT_LCD_FILTER_LIGHT :: - * The light filter is a variant that produces less blurriness at the - * cost of slightly more color fringes than the default one. It might - * be better, depending on taste, your monitor, or your personal vision. - * - * FT_LCD_FILTER_LEGACY :: - * This filter corresponds to the original libXft color filter. It - * provides high contrast output but can exhibit really bad color - * fringes if glyphs are not extremely well hinted to the pixel grid. - * In other words, it only works well if the TrueType bytecode - * interpreter is enabled *and* high-quality hinted fonts are used. - * - * This filter is only provided for comparison purposes, and might be - * disabled or stay unsupported in the future. - * - * @since: - * 2.3.0 - */ - typedef enum FT_LcdFilter_ - { - FT_LCD_FILTER_NONE = 0, - FT_LCD_FILTER_DEFAULT = 1, - FT_LCD_FILTER_LIGHT = 2, - FT_LCD_FILTER_LEGACY = 16, - - FT_LCD_FILTER_MAX /* do not remove */ - - } FT_LcdFilter; - - - /************************************************************************** - * - * @func: - * FT_Library_SetLcdFilter - * - * @description: - * This function is used to apply color filtering to LCD decimated - * bitmaps, like the ones used when calling @FT_Render_Glyph with - * @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V. - * - * @input: - * library :: - * A handle to the target library instance. - * - * filter :: - * The filter type. - * - * You can use @FT_LCD_FILTER_NONE here to disable this feature, or - * @FT_LCD_FILTER_DEFAULT to use a default filter that should work - * well on most LCD screens. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This feature is always disabled by default. Clients must make an - * explicit call to this function with a `filter' value other than - * @FT_LCD_FILTER_NONE in order to enable it. - * - * Due to *PATENTS* covering subpixel rendering, this function doesn't - * do anything except returning `FT_Err_Unimplemented_Feature' if the - * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not - * defined in your build of the library, which should correspond to all - * default builds of FreeType. - * - * The filter affects glyph bitmaps rendered through @FT_Render_Glyph, - * @FT_Outline_Get_Bitmap, @FT_Load_Glyph, and @FT_Load_Char. - * - * It does _not_ affect the output of @FT_Outline_Render and - * @FT_Outline_Get_Bitmap. - * - * If this feature is activated, the dimensions of LCD glyph bitmaps are - * either larger or taller than the dimensions of the corresponding - * outline with regards to the pixel grid. For example, for - * @FT_RENDER_MODE_LCD, the filter adds up to 3~pixels to the left, and - * up to 3~pixels to the right. - * - * The bitmap offset values are adjusted correctly, so clients shouldn't - * need to modify their layout and glyph positioning code when enabling - * the filter. - * - * @since: - * 2.3.0 - */ - FT_EXPORT( FT_Error ) - FT_Library_SetLcdFilter( FT_Library library, - FT_LcdFilter filter ); - - - /************************************************************************** - * - * @func: - * FT_Library_SetLcdFilterWeights - * - * @description: - * Use this function to override the filter weights selected by - * @FT_Library_SetLcdFilter. By default, FreeType uses the quintuple - * (0x00, 0x55, 0x56, 0x55, 0x00) for FT_LCD_FILTER_LIGHT, and (0x10, - * 0x40, 0x70, 0x40, 0x10) for FT_LCD_FILTER_DEFAULT and - * FT_LCD_FILTER_LEGACY. - * - * @input: - * library :: - * A handle to the target library instance. - * - * weights :: - * A pointer to an array; the function copies the first five bytes and - * uses them to specify the filter weights. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * Due to *PATENTS* covering subpixel rendering, this function doesn't - * do anything except returning `FT_Err_Unimplemented_Feature' if the - * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not - * defined in your build of the library, which should correspond to all - * default builds of FreeType. - * - * This function must be called after @FT_Library_SetLcdFilter to have - * any effect. - * - * @since: - * 2.4.0 - */ - FT_EXPORT( FT_Error ) - FT_Library_SetLcdFilterWeights( FT_Library library, - unsigned char *weights ); - - /* */ - - -FT_END_HEADER - -#endif /* __FT_LCD_FILTER_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftlist.h b/thirdparty/include/freetype/ftlist.h deleted file mode 100644 index 3f53ecb5c..000000000 --- a/thirdparty/include/freetype/ftlist.h +++ /dev/null @@ -1,277 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftlist.h */ -/* */ -/* Generic list support for FreeType (specification). */ -/* */ -/* Copyright 1996-2001, 2003, 2007, 2010, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file implements functions relative to list processing. Its */ - /* data structures are defined in `freetype.h'. */ - /* */ - /*************************************************************************/ - - -#ifndef __FTLIST_H__ -#define __FTLIST_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* list_processing */ - /* */ - /* <Title> */ - /* List Processing */ - /* */ - /* <Abstract> */ - /* Simple management of lists. */ - /* */ - /* <Description> */ - /* This section contains various definitions related to list */ - /* processing using doubly-linked nodes. */ - /* */ - /* <Order> */ - /* FT_List */ - /* FT_ListNode */ - /* FT_ListRec */ - /* FT_ListNodeRec */ - /* */ - /* FT_List_Add */ - /* FT_List_Insert */ - /* FT_List_Find */ - /* FT_List_Remove */ - /* FT_List_Up */ - /* FT_List_Iterate */ - /* FT_List_Iterator */ - /* FT_List_Finalize */ - /* FT_List_Destructor */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Find */ - /* */ - /* <Description> */ - /* Find the list node for a given listed object. */ - /* */ - /* <Input> */ - /* list :: A pointer to the parent list. */ - /* data :: The address of the listed object. */ - /* */ - /* <Return> */ - /* List node. NULL if it wasn't found. */ - /* */ - FT_EXPORT( FT_ListNode ) - FT_List_Find( FT_List list, - void* data ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Add */ - /* */ - /* <Description> */ - /* Append an element to the end of a list. */ - /* */ - /* <InOut> */ - /* list :: A pointer to the parent list. */ - /* node :: The node to append. */ - /* */ - FT_EXPORT( void ) - FT_List_Add( FT_List list, - FT_ListNode node ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Insert */ - /* */ - /* <Description> */ - /* Insert an element at the head of a list. */ - /* */ - /* <InOut> */ - /* list :: A pointer to parent list. */ - /* node :: The node to insert. */ - /* */ - FT_EXPORT( void ) - FT_List_Insert( FT_List list, - FT_ListNode node ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Remove */ - /* */ - /* <Description> */ - /* Remove a node from a list. This function doesn't check whether */ - /* the node is in the list! */ - /* */ - /* <Input> */ - /* node :: The node to remove. */ - /* */ - /* <InOut> */ - /* list :: A pointer to the parent list. */ - /* */ - FT_EXPORT( void ) - FT_List_Remove( FT_List list, - FT_ListNode node ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Up */ - /* */ - /* <Description> */ - /* Move a node to the head/top of a list. Used to maintain LRU */ - /* lists. */ - /* */ - /* <InOut> */ - /* list :: A pointer to the parent list. */ - /* node :: The node to move. */ - /* */ - FT_EXPORT( void ) - FT_List_Up( FT_List list, - FT_ListNode node ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_List_Iterator */ - /* */ - /* <Description> */ - /* An FT_List iterator function that is called during a list parse */ - /* by @FT_List_Iterate. */ - /* */ - /* <Input> */ - /* node :: The current iteration list node. */ - /* */ - /* user :: A typeless pointer passed to @FT_List_Iterate. */ - /* Can be used to point to the iteration's state. */ - /* */ - typedef FT_Error - (*FT_List_Iterator)( FT_ListNode node, - void* user ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Iterate */ - /* */ - /* <Description> */ - /* Parse a list and calls a given iterator function on each element. */ - /* Note that parsing is stopped as soon as one of the iterator calls */ - /* returns a non-zero value. */ - /* */ - /* <Input> */ - /* list :: A handle to the list. */ - /* iterator :: An iterator function, called on each node of the list. */ - /* user :: A user-supplied field that is passed as the second */ - /* argument to the iterator. */ - /* */ - /* <Return> */ - /* The result (a FreeType error code) of the last iterator call. */ - /* */ - FT_EXPORT( FT_Error ) - FT_List_Iterate( FT_List list, - FT_List_Iterator iterator, - void* user ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_List_Destructor */ - /* */ - /* <Description> */ - /* An @FT_List iterator function that is called during a list */ - /* finalization by @FT_List_Finalize to destroy all elements in a */ - /* given list. */ - /* */ - /* <Input> */ - /* system :: The current system object. */ - /* */ - /* data :: The current object to destroy. */ - /* */ - /* user :: A typeless pointer passed to @FT_List_Iterate. It can */ - /* be used to point to the iteration's state. */ - /* */ - typedef void - (*FT_List_Destructor)( FT_Memory memory, - void* data, - void* user ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Finalize */ - /* */ - /* <Description> */ - /* Destroy all elements in the list as well as the list itself. */ - /* */ - /* <Input> */ - /* list :: A handle to the list. */ - /* */ - /* destroy :: A list destructor that will be applied to each element */ - /* of the list. */ - /* */ - /* memory :: The current memory object that handles deallocation. */ - /* */ - /* user :: A user-supplied field that is passed as the last */ - /* argument to the destructor. */ - /* */ - /* <Note> */ - /* This function expects that all nodes added by @FT_List_Add or */ - /* @FT_List_Insert have been dynamically allocated. */ - /* */ - FT_EXPORT( void ) - FT_List_Finalize( FT_List list, - FT_List_Destructor destroy, - FT_Memory memory, - void* user ); - - - /* */ - - -FT_END_HEADER - -#endif /* __FTLIST_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftlzw.h b/thirdparty/include/freetype/ftlzw.h deleted file mode 100644 index 22200a637..000000000 --- a/thirdparty/include/freetype/ftlzw.h +++ /dev/null @@ -1,99 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftlzw.h */ -/* */ -/* LZW-compressed stream support. */ -/* */ -/* Copyright 2004, 2006 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTLZW_H__ -#define __FTLZW_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /*************************************************************************/ - /* */ - /* <Section> */ - /* lzw */ - /* */ - /* <Title> */ - /* LZW Streams */ - /* */ - /* <Abstract> */ - /* Using LZW-compressed font files. */ - /* */ - /* <Description> */ - /* This section contains the declaration of LZW-specific functions. */ - /* */ - /*************************************************************************/ - - /************************************************************************ - * - * @function: - * FT_Stream_OpenLZW - * - * @description: - * Open a new stream to parse LZW-compressed font files. This is - * mainly used to support the compressed `*.pcf.Z' fonts that come - * with XFree86. - * - * @input: - * stream :: The target embedding stream. - * - * source :: The source stream. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source stream must be opened _before_ calling this function. - * - * Calling the internal function `FT_Stream_Close' on the new stream will - * *not* call `FT_Stream_Close' on the source stream. None of the stream - * objects will be released to the heap. - * - * The stream implementation is very basic and resets the decompression - * process each time seeking backwards is needed within the stream - * - * In certain builds of the library, LZW compression recognition is - * automatically handled when calling @FT_New_Face or @FT_Open_Face. - * This means that if no font driver is capable of handling the raw - * compressed file, the library will try to open a LZW stream from it - * and re-open the face with it. - * - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with LZW support. - */ - FT_EXPORT( FT_Error ) - FT_Stream_OpenLZW( FT_Stream stream, - FT_Stream source ); - - /* */ - - -FT_END_HEADER - -#endif /* __FTLZW_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftmac.h b/thirdparty/include/freetype/ftmac.h deleted file mode 100644 index 314b7d08c..000000000 --- a/thirdparty/include/freetype/ftmac.h +++ /dev/null @@ -1,274 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftmac.h */ -/* */ -/* Additional Mac-specific API. */ -/* */ -/* Copyright 1996-2001, 2004, 2006, 2007, 2013 by */ -/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* NOTE: Include this file after FT_FREETYPE_H and after any */ -/* Mac-specific headers (because this header uses Mac types such as */ -/* Handle, FSSpec, FSRef, etc.) */ -/* */ -/***************************************************************************/ - - -#ifndef __FTMAC_H__ -#define __FTMAC_H__ - - -#include <freetype/ft2build.h> - - -FT_BEGIN_HEADER - - -/* gcc-3.4.1 and later can warn about functions tagged as deprecated */ -#ifndef FT_DEPRECATED_ATTRIBUTE -#if defined(__GNUC__) && \ - ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) -#define FT_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) -#else -#define FT_DEPRECATED_ATTRIBUTE -#endif -#endif - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* mac_specific */ - /* */ - /* <Title> */ - /* Mac Specific Interface */ - /* */ - /* <Abstract> */ - /* Only available on the Macintosh. */ - /* */ - /* <Description> */ - /* The following definitions are only available if FreeType is */ - /* compiled on a Macintosh. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FOND */ - /* */ - /* <Description> */ - /* Create a new face object from a FOND resource. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* fond :: A FOND resource. */ - /* */ - /* face_index :: Only supported for the -1 `sanity check' special */ - /* case. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Notes> */ - /* This function can be used to create @FT_Face objects from fonts */ - /* that are installed in the system as follows. */ - /* */ - /* { */ - /* fond = GetResource( 'FOND', fontName ); */ - /* error = FT_New_Face_From_FOND( library, fond, 0, &face ); */ - /* } */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Face_From_FOND( FT_Library library, - Handle fond, - FT_Long face_index, - FT_Face *aface ) - FT_DEPRECATED_ATTRIBUTE; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GetFile_From_Mac_Name */ - /* */ - /* <Description> */ - /* Return an FSSpec for the disk file containing the named font. */ - /* */ - /* <Input> */ - /* fontName :: Mac OS name of the font (e.g., Times New Roman */ - /* Bold). */ - /* */ - /* <Output> */ - /* pathSpec :: FSSpec to the file. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* face_index :: Index of the face. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_GetFile_From_Mac_Name( const char* fontName, - FSSpec* pathSpec, - FT_Long* face_index ) - FT_DEPRECATED_ATTRIBUTE; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GetFile_From_Mac_ATS_Name */ - /* */ - /* <Description> */ - /* Return an FSSpec for the disk file containing the named font. */ - /* */ - /* <Input> */ - /* fontName :: Mac OS name of the font in ATS framework. */ - /* */ - /* <Output> */ - /* pathSpec :: FSSpec to the file. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* face_index :: Index of the face. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_GetFile_From_Mac_ATS_Name( const char* fontName, - FSSpec* pathSpec, - FT_Long* face_index ) - FT_DEPRECATED_ATTRIBUTE; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GetFilePath_From_Mac_ATS_Name */ - /* */ - /* <Description> */ - /* Return a pathname of the disk file and face index for given font */ - /* name that is handled by ATS framework. */ - /* */ - /* <Input> */ - /* fontName :: Mac OS name of the font in ATS framework. */ - /* */ - /* <Output> */ - /* path :: Buffer to store pathname of the file. For passing */ - /* to @FT_New_Face. The client must allocate this */ - /* buffer before calling this function. */ - /* */ - /* maxPathSize :: Lengths of the buffer `path' that client allocated. */ - /* */ - /* face_index :: Index of the face. For passing to @FT_New_Face. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_GetFilePath_From_Mac_ATS_Name( const char* fontName, - UInt8* path, - UInt32 maxPathSize, - FT_Long* face_index ) - FT_DEPRECATED_ATTRIBUTE; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FSSpec */ - /* */ - /* <Description> */ - /* Create a new face object from a given resource and typeface index */ - /* using an FSSpec to the font file. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* spec :: FSSpec to the font file. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index~0. */ - /* <Output> */ - /* aface :: A handle to a new face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* @FT_New_Face_From_FSSpec is identical to @FT_New_Face except */ - /* it accepts an FSSpec instead of a path. */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Face_From_FSSpec( FT_Library library, - const FSSpec *spec, - FT_Long face_index, - FT_Face *aface ) - FT_DEPRECATED_ATTRIBUTE; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FSRef */ - /* */ - /* <Description> */ - /* Create a new face object from a given resource and typeface index */ - /* using an FSRef to the font file. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* spec :: FSRef to the font file. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index~0. */ - /* <Output> */ - /* aface :: A handle to a new face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* @FT_New_Face_From_FSRef is identical to @FT_New_Face except */ - /* it accepts an FSRef instead of a path. */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Face_From_FSRef( FT_Library library, - const FSRef *ref, - FT_Long face_index, - FT_Face *aface ) - FT_DEPRECATED_ATTRIBUTE; - - /* */ - - -FT_END_HEADER - - -#endif /* __FTMAC_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftmm.h b/thirdparty/include/freetype/ftmm.h deleted file mode 100644 index 45fd5c1a5..000000000 --- a/thirdparty/include/freetype/ftmm.h +++ /dev/null @@ -1,377 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftmm.h */ -/* */ -/* FreeType Multiple Master font interface (specification). */ -/* */ -/* Copyright 1996-2001, 2003, 2004, 2006, 2009, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTMM_H__ -#define __FTMM_H__ - - -#include <freetype/ft2build.h> -#include FT_TYPE1_TABLES_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* multiple_masters */ - /* */ - /* <Title> */ - /* Multiple Masters */ - /* */ - /* <Abstract> */ - /* How to manage Multiple Masters fonts. */ - /* */ - /* <Description> */ - /* The following types and functions are used to manage Multiple */ - /* Master fonts, i.e., the selection of specific design instances by */ - /* setting design axis coordinates. */ - /* */ - /* George Williams has extended this interface to make it work with */ - /* both Type~1 Multiple Masters fonts and GX distortable (var) */ - /* fonts. Some of these routines only work with MM fonts, others */ - /* will work with both types. They are similar enough that a */ - /* consistent interface makes sense. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_MM_Axis */ - /* */ - /* <Description> */ - /* A simple structure used to model a given axis in design space for */ - /* Multiple Masters fonts. */ - /* */ - /* This structure can't be used for GX var fonts. */ - /* */ - /* <Fields> */ - /* name :: The axis's name. */ - /* */ - /* minimum :: The axis's minimum design coordinate. */ - /* */ - /* maximum :: The axis's maximum design coordinate. */ - /* */ - typedef struct FT_MM_Axis_ - { - FT_String* name; - FT_Long minimum; - FT_Long maximum; - - } FT_MM_Axis; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Multi_Master */ - /* */ - /* <Description> */ - /* A structure used to model the axes and space of a Multiple Masters */ - /* font. */ - /* */ - /* This structure can't be used for GX var fonts. */ - /* */ - /* <Fields> */ - /* num_axis :: Number of axes. Cannot exceed~4. */ - /* */ - /* num_designs :: Number of designs; should be normally 2^num_axis */ - /* even though the Type~1 specification strangely */ - /* allows for intermediate designs to be present. This */ - /* number cannot exceed~16. */ - /* */ - /* axis :: A table of axis descriptors. */ - /* */ - typedef struct FT_Multi_Master_ - { - FT_UInt num_axis; - FT_UInt num_designs; - FT_MM_Axis axis[T1_MAX_MM_AXIS]; - - } FT_Multi_Master; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Var_Axis */ - /* */ - /* <Description> */ - /* A simple structure used to model a given axis in design space for */ - /* Multiple Masters and GX var fonts. */ - /* */ - /* <Fields> */ - /* name :: The axis's name. */ - /* Not always meaningful for GX. */ - /* */ - /* minimum :: The axis's minimum design coordinate. */ - /* */ - /* def :: The axis's default design coordinate. */ - /* FreeType computes meaningful default values for MM; it */ - /* is then an integer value, not in 16.16 format. */ - /* */ - /* maximum :: The axis's maximum design coordinate. */ - /* */ - /* tag :: The axis's tag (the GX equivalent to `name'). */ - /* FreeType provides default values for MM if possible. */ - /* */ - /* strid :: The entry in `name' table (another GX version of */ - /* `name'). */ - /* Not meaningful for MM. */ - /* */ - typedef struct FT_Var_Axis_ - { - FT_String* name; - - FT_Fixed minimum; - FT_Fixed def; - FT_Fixed maximum; - - FT_ULong tag; - FT_UInt strid; - - } FT_Var_Axis; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Var_Named_Style */ - /* */ - /* <Description> */ - /* A simple structure used to model a named style in a GX var font. */ - /* */ - /* This structure can't be used for MM fonts. */ - /* */ - /* <Fields> */ - /* coords :: The design coordinates for this style. */ - /* This is an array with one entry for each axis. */ - /* */ - /* strid :: The entry in `name' table identifying this style. */ - /* */ - typedef struct FT_Var_Named_Style_ - { - FT_Fixed* coords; - FT_UInt strid; - - } FT_Var_Named_Style; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_MM_Var */ - /* */ - /* <Description> */ - /* A structure used to model the axes and space of a Multiple Masters */ - /* or GX var distortable font. */ - /* */ - /* Some fields are specific to one format and not to the other. */ - /* */ - /* <Fields> */ - /* num_axis :: The number of axes. The maximum value is~4 for */ - /* MM; no limit in GX. */ - /* */ - /* num_designs :: The number of designs; should be normally */ - /* 2^num_axis for MM fonts. Not meaningful for GX */ - /* (where every glyph could have a different */ - /* number of designs). */ - /* */ - /* num_namedstyles :: The number of named styles; only meaningful for */ - /* GX that allows certain design coordinates to */ - /* have a string ID (in the `name' table) */ - /* associated with them. The font can tell the */ - /* user that, for example, Weight=1.5 is `Bold'. */ - /* */ - /* axis :: A table of axis descriptors. */ - /* GX fonts contain slightly more data than MM. */ - /* */ - /* namedstyles :: A table of named styles. */ - /* Only meaningful with GX. */ - /* */ - typedef struct FT_MM_Var_ - { - FT_UInt num_axis; - FT_UInt num_designs; - FT_UInt num_namedstyles; - FT_Var_Axis* axis; - FT_Var_Named_Style* namedstyle; - - } FT_MM_Var; - - - /* */ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Multi_Master */ - /* */ - /* <Description> */ - /* Retrieve the Multiple Master descriptor of a given font. */ - /* */ - /* This function can't be used with GX fonts. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* <Output> */ - /* amaster :: The Multiple Masters descriptor. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Multi_Master( FT_Face face, - FT_Multi_Master *amaster ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_MM_Var */ - /* */ - /* <Description> */ - /* Retrieve the Multiple Master/GX var descriptor of a given font. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* <Output> */ - /* amaster :: The Multiple Masters/GX var descriptor. */ - /* Allocates a data structure, which the user must free. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_MM_Var( FT_Face face, - FT_MM_Var* *amaster ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_MM_Design_Coordinates */ - /* */ - /* <Description> */ - /* For Multiple Masters fonts, choose an interpolated font design */ - /* through design coordinates. */ - /* */ - /* This function can't be used with GX fonts. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face. */ - /* */ - /* <Input> */ - /* num_coords :: The number of design coordinates (must be equal to */ - /* the number of axes in the font). */ - /* */ - /* coords :: An array of design coordinates. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_MM_Design_Coordinates( FT_Face face, - FT_UInt num_coords, - FT_Long* coords ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Var_Design_Coordinates */ - /* */ - /* <Description> */ - /* For Multiple Master or GX Var fonts, choose an interpolated font */ - /* design through design coordinates. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face. */ - /* */ - /* <Input> */ - /* num_coords :: The number of design coordinates (must be equal to */ - /* the number of axes in the font). */ - /* */ - /* coords :: An array of design coordinates. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_Var_Design_Coordinates( FT_Face face, - FT_UInt num_coords, - FT_Fixed* coords ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_MM_Blend_Coordinates */ - /* */ - /* <Description> */ - /* For Multiple Masters and GX var fonts, choose an interpolated font */ - /* design through normalized blend coordinates. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face. */ - /* */ - /* <Input> */ - /* num_coords :: The number of design coordinates (must be equal to */ - /* the number of axes in the font). */ - /* */ - /* coords :: The design coordinates array (each element must be */ - /* between 0 and 1.0). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_MM_Blend_Coordinates( FT_Face face, - FT_UInt num_coords, - FT_Fixed* coords ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Var_Blend_Coordinates */ - /* */ - /* <Description> */ - /* This is another name of @FT_Set_MM_Blend_Coordinates. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_Var_Blend_Coordinates( FT_Face face, - FT_UInt num_coords, - FT_Fixed* coords ); - - - /* */ - - -FT_END_HEADER - -#endif /* __FTMM_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftmodapi.h b/thirdparty/include/freetype/ftmodapi.h deleted file mode 100644 index 08729bc94..000000000 --- a/thirdparty/include/freetype/ftmodapi.h +++ /dev/null @@ -1,641 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftmodapi.h */ -/* */ -/* FreeType modules public interface (specification). */ -/* */ -/* Copyright 1996-2003, 2006, 2008-2010, 2012, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTMODAPI_H__ -#define __FTMODAPI_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* module_management */ - /* */ - /* <Title> */ - /* Module Management */ - /* */ - /* <Abstract> */ - /* How to add, upgrade, remove, and control modules from FreeType. */ - /* */ - /* <Description> */ - /* The definitions below are used to manage modules within FreeType. */ - /* Modules can be added, upgraded, and removed at runtime. */ - /* Additionally, some module properties can be controlled also. */ - /* */ - /* Here is a list of possible values of the `module_name' field in */ - /* the @FT_Module_Class structure. */ - /* */ - /* { */ - /* autofitter */ - /* bdf */ - /* cff */ - /* gxvalid */ - /* otvalid */ - /* pcf */ - /* pfr */ - /* psaux */ - /* pshinter */ - /* psnames */ - /* raster1, raster5 */ - /* sfnt */ - /* smooth, smooth-lcd, smooth-lcdv */ - /* truetype */ - /* type1 */ - /* type42 */ - /* t1cid */ - /* winfonts */ - /* } */ - /* */ - /* Note that the FreeType Cache sub-system is not a FreeType module. */ - /* */ - /*************************************************************************/ - - - /* module bit flags */ -#define FT_MODULE_FONT_DRIVER 1 /* this module is a font driver */ -#define FT_MODULE_RENDERER 2 /* this module is a renderer */ -#define FT_MODULE_HINTER 4 /* this module is a glyph hinter */ -#define FT_MODULE_STYLER 8 /* this module is a styler */ - -#define FT_MODULE_DRIVER_SCALABLE 0x100 /* the driver supports */ - /* scalable fonts */ -#define FT_MODULE_DRIVER_NO_OUTLINES 0x200 /* the driver does not */ - /* support vector outlines */ -#define FT_MODULE_DRIVER_HAS_HINTER 0x400 /* the driver provides its */ - /* own hinter */ - - - /* deprecated values */ -#define ft_module_font_driver FT_MODULE_FONT_DRIVER -#define ft_module_renderer FT_MODULE_RENDERER -#define ft_module_hinter FT_MODULE_HINTER -#define ft_module_styler FT_MODULE_STYLER - -#define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE -#define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES -#define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER - - - typedef FT_Pointer FT_Module_Interface; - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Constructor */ - /* */ - /* <Description> */ - /* A function used to initialize (not create) a new module object. */ - /* */ - /* <Input> */ - /* module :: The module to initialize. */ - /* */ - typedef FT_Error - (*FT_Module_Constructor)( FT_Module module ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Destructor */ - /* */ - /* <Description> */ - /* A function used to finalize (not destroy) a given module object. */ - /* */ - /* <Input> */ - /* module :: The module to finalize. */ - /* */ - typedef void - (*FT_Module_Destructor)( FT_Module module ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Requester */ - /* */ - /* <Description> */ - /* A function used to query a given module for a specific interface. */ - /* */ - /* <Input> */ - /* module :: The module to be searched. */ - /* */ - /* name :: The name of the interface in the module. */ - /* */ - typedef FT_Module_Interface - (*FT_Module_Requester)( FT_Module module, - const char* name ); - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Module_Class */ - /* */ - /* <Description> */ - /* The module class descriptor. */ - /* */ - /* <Fields> */ - /* module_flags :: Bit flags describing the module. */ - /* */ - /* module_size :: The size of one module object/instance in */ - /* bytes. */ - /* */ - /* module_name :: The name of the module. */ - /* */ - /* module_version :: The version, as a 16.16 fixed number */ - /* (major.minor). */ - /* */ - /* module_requires :: The version of FreeType this module requires, */ - /* as a 16.16 fixed number (major.minor). Starts */ - /* at version 2.0, i.e., 0x20000. */ - /* */ - /* module_init :: The initializing function. */ - /* */ - /* module_done :: The finalizing function. */ - /* */ - /* get_interface :: The interface requesting function. */ - /* */ - typedef struct FT_Module_Class_ - { - FT_ULong module_flags; - FT_Long module_size; - const FT_String* module_name; - FT_Fixed module_version; - FT_Fixed module_requires; - - const void* module_interface; - - FT_Module_Constructor module_init; - FT_Module_Destructor module_done; - FT_Module_Requester get_interface; - - } FT_Module_Class; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Add_Module */ - /* */ - /* <Description> */ - /* Add a new module to a given library instance. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library object. */ - /* */ - /* <Input> */ - /* clazz :: A pointer to class descriptor for the module. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* An error will be returned if a module already exists by that name, */ - /* or if the module requires a version of FreeType that is too great. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Add_Module( FT_Library library, - const FT_Module_Class* clazz ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Module */ - /* */ - /* <Description> */ - /* Find a module by its name. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object. */ - /* */ - /* module_name :: The module's name (as an ASCII string). */ - /* */ - /* <Return> */ - /* A module handle. 0~if none was found. */ - /* */ - /* <Note> */ - /* FreeType's internal modules aren't documented very well, and you */ - /* should look up the source code for details. */ - /* */ - FT_EXPORT( FT_Module ) - FT_Get_Module( FT_Library library, - const char* module_name ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Remove_Module */ - /* */ - /* <Description> */ - /* Remove a given module from a library instance. */ - /* */ - /* <InOut> */ - /* library :: A handle to a library object. */ - /* */ - /* <Input> */ - /* module :: A handle to a module object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The module object is destroyed by the function in case of success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Remove_Module( FT_Library library, - FT_Module module ); - - - /********************************************************************** - * - * @function: - * FT_Property_Set - * - * @description: - * Set a property for a given module. - * - * @input: - * library :: - * A handle to the library the module is part of. - * - * module_name :: - * The module name. - * - * property_name :: - * The property name. Properties are described in the `Synopsis' - * subsection of the module's documentation. - * - * Note that only a few modules have properties. - * - * value :: - * A generic pointer to a variable or structure that gives the new - * value of the property. The exact definition of `value' is - * dependent on the property; see the `Synopsis' subsection of the - * module's documentation. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If `module_name' isn't a valid module name, or `property_name' - * doesn't specify a valid property, or if `value' doesn't represent a - * valid value for the given property, an error is returned. - * - * The following example sets property `bar' (a simple integer) in - * module `foo' to value~1. - * - * { - * FT_UInt bar; - * - * - * bar = 1; - * FT_Property_Set( library, "foo", "bar", &bar ); - * } - * - * Note that the FreeType Cache sub-system doesn't recognize module - * property changes. To avoid glyph lookup confusion within the cache - * you should call @FTC_Manager_Reset to completely flush the cache if - * a module property gets changed after @FTC_Manager_New has been - * called. - * - * It is not possible to set properties of the FreeType Cache - * sub-system itself with FT_Property_Set; use @FTC_Property_Set - * instead. - * - * @since: - * 2.4.11 - * - */ - FT_EXPORT( FT_Error ) - FT_Property_Set( FT_Library library, - const FT_String* module_name, - const FT_String* property_name, - const void* value ); - - - /********************************************************************** - * - * @function: - * FT_Property_Get - * - * @description: - * Get a module's property value. - * - * @input: - * library :: - * A handle to the library the module is part of. - * - * module_name :: - * The module name. - * - * property_name :: - * The property name. Properties are described in the `Synopsis' - * subsection of the module's documentation. - * - * @inout: - * value :: - * A generic pointer to a variable or structure that gives the - * value of the property. The exact definition of `value' is - * dependent on the property; see the `Synopsis' subsection of the - * module's documentation. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If `module_name' isn't a valid module name, or `property_name' - * doesn't specify a valid property, or if `value' doesn't represent a - * valid value for the given property, an error is returned. - * - * The following example gets property `baz' (a range) in module `foo'. - * - * { - * typedef range_ - * { - * FT_Int32 min; - * FT_Int32 max; - * - * } range; - * - * range baz; - * - * - * FT_Property_Get( library, "foo", "baz", &baz ); - * } - * - * It is not possible to retrieve properties of the FreeType Cache - * sub-system with FT_Property_Get; use @FTC_Property_Get instead. - * - * @since: - * 2.4.11 - * - */ - FT_EXPORT( FT_Error ) - FT_Property_Get( FT_Library library, - const FT_String* module_name, - const FT_String* property_name, - void* value ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Reference_Library */ - /* */ - /* <Description> */ - /* A counter gets initialized to~1 at the time an @FT_Library */ - /* structure is created. This function increments the counter. */ - /* @FT_Done_Library then only destroys a library if the counter is~1, */ - /* otherwise it simply decrements the counter. */ - /* */ - /* This function helps in managing life-cycles of structures that */ - /* reference @FT_Library objects. */ - /* */ - /* <Input> */ - /* library :: A handle to a target library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.4.2 */ - /* */ - FT_EXPORT( FT_Error ) - FT_Reference_Library( FT_Library library ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Library */ - /* */ - /* <Description> */ - /* This function is used to create a new FreeType library instance */ - /* from a given memory object. It is thus possible to use libraries */ - /* with distinct memory allocators within the same program. */ - /* */ - /* Normally, you would call this function (followed by a call to */ - /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module) */ - /* instead of @FT_Init_FreeType to initialize the FreeType library. */ - /* */ - /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */ - /* library instance. */ - /* */ - /* <Input> */ - /* memory :: A handle to the original memory object. */ - /* */ - /* <Output> */ - /* alibrary :: A pointer to handle of a new library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Library. */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Library( FT_Memory memory, - FT_Library *alibrary ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Library */ - /* */ - /* <Description> */ - /* Discard a given library object. This closes all drivers and */ - /* discards all resource objects. */ - /* */ - /* <Input> */ - /* library :: A handle to the target library. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Library. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Done_Library( FT_Library library ); - -/* */ - - typedef void - (*FT_DebugHook_Func)( void* arg ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Debug_Hook */ - /* */ - /* <Description> */ - /* Set a debug hook function for debugging the interpreter of a font */ - /* format. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library object. */ - /* */ - /* <Input> */ - /* hook_index :: The index of the debug hook. You should use the */ - /* values defined in `ftobjs.h', e.g., */ - /* `FT_DEBUG_HOOK_TRUETYPE'. */ - /* */ - /* debug_hook :: The function used to debug the interpreter. */ - /* */ - /* <Note> */ - /* Currently, four debug hook slots are available, but only two (for */ - /* the TrueType and the Type~1 interpreter) are defined. */ - /* */ - /* Since the internal headers of FreeType are no longer installed, */ - /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */ - /* This is a bug and will be fixed in a forthcoming release. */ - /* */ - FT_EXPORT( void ) - FT_Set_Debug_Hook( FT_Library library, - FT_UInt hook_index, - FT_DebugHook_Func debug_hook ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Add_Default_Modules */ - /* */ - /* <Description> */ - /* Add the set of default drivers to a given library object. */ - /* This is only useful when you create a library object with */ - /* @FT_New_Library (usually to plug a custom memory manager). */ - /* */ - /* <InOut> */ - /* library :: A handle to a new library object. */ - /* */ - FT_EXPORT( void ) - FT_Add_Default_Modules( FT_Library library ); - - - - /************************************************************************** - * - * @section: - * truetype_engine - * - * @title: - * The TrueType Engine - * - * @abstract: - * TrueType bytecode support. - * - * @description: - * This section contains a function used to query the level of TrueType - * bytecode support compiled in this version of the library. - * - */ - - - /************************************************************************** - * - * @enum: - * FT_TrueTypeEngineType - * - * @description: - * A list of values describing which kind of TrueType bytecode - * engine is implemented in a given FT_Library instance. It is used - * by the @FT_Get_TrueType_Engine_Type function. - * - * @values: - * FT_TRUETYPE_ENGINE_TYPE_NONE :: - * The library doesn't implement any kind of bytecode interpreter. - * - * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED :: - * The library implements a bytecode interpreter that doesn't - * support the patented operations of the TrueType virtual machine. - * - * Its main use is to load certain Asian fonts that position and - * scale glyph components with bytecode instructions. It produces - * bad output for most other fonts. - * - * FT_TRUETYPE_ENGINE_TYPE_PATENTED :: - * The library implements a bytecode interpreter that covers - * the full instruction set of the TrueType virtual machine (this - * was governed by patents until May 2010, hence the name). - * - * @since: - * 2.2 - * - */ - typedef enum FT_TrueTypeEngineType_ - { - FT_TRUETYPE_ENGINE_TYPE_NONE = 0, - FT_TRUETYPE_ENGINE_TYPE_UNPATENTED, - FT_TRUETYPE_ENGINE_TYPE_PATENTED - - } FT_TrueTypeEngineType; - - - /************************************************************************** - * - * @func: - * FT_Get_TrueType_Engine_Type - * - * @description: - * Return an @FT_TrueTypeEngineType value to indicate which level of - * the TrueType virtual machine a given library instance supports. - * - * @input: - * library :: - * A library instance. - * - * @return: - * A value indicating which level is supported. - * - * @since: - * 2.2 - * - */ - FT_EXPORT( FT_TrueTypeEngineType ) - FT_Get_TrueType_Engine_Type( FT_Library library ); - - - /* */ - - -FT_END_HEADER - -#endif /* __FTMODAPI_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftmoderr.h b/thirdparty/include/freetype/ftmoderr.h deleted file mode 100644 index 5a27db151..000000000 --- a/thirdparty/include/freetype/ftmoderr.h +++ /dev/null @@ -1,194 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftmoderr.h */ -/* */ -/* FreeType module error offsets (specification). */ -/* */ -/* Copyright 2001-2005, 2010, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the FreeType module error codes. */ - /* */ - /* If the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS in `ftoption.h' is */ - /* set, the lower byte of an error value identifies the error code as */ - /* usual. In addition, the higher byte identifies the module. For */ - /* example, the error `FT_Err_Invalid_File_Format' has value 0x0003, the */ - /* error `TT_Err_Invalid_File_Format' has value 0x1303, the error */ - /* `T1_Err_Invalid_File_Format' has value 0x1403, etc. */ - /* */ - /* Note that `FT_Err_Ok', `TT_Err_Ok', etc. are always equal to zero, */ - /* including the high byte. */ - /* */ - /* If FT_CONFIG_OPTION_USE_MODULE_ERRORS isn't set, the higher byte of */ - /* an error value is set to zero. */ - /* */ - /* To hide the various `XXX_Err_' prefixes in the source code, FreeType */ - /* provides some macros in `fttypes.h'. */ - /* */ - /* FT_ERR( err ) */ - /* Add current error module prefix (as defined with the */ - /* `FT_ERR_PREFIX' macro) to `err'. For example, in the BDF module */ - /* the line */ - /* */ - /* error = FT_ERR( Invalid_Outline ); */ - /* */ - /* expands to */ - /* */ - /* error = BDF_Err_Invalid_Outline; */ - /* */ - /* For simplicity, you can always use `FT_Err_Ok' directly instead */ - /* of `FT_ERR( Ok )'. */ - /* */ - /* FT_ERR_EQ( errcode, err ) */ - /* FT_ERR_NEQ( errcode, err ) */ - /* Compare error code `errcode' with the error `err' for equality */ - /* and inequality, respectively. Example: */ - /* */ - /* if ( FT_ERR_EQ( error, Invalid_Outline ) ) */ - /* ... */ - /* */ - /* Using this macro you don't have to think about error prefixes. */ - /* Of course, if module errors are not active, the above example is */ - /* the same as */ - /* */ - /* if ( error == FT_Err_Invalid_Outline ) */ - /* ... */ - /* */ - /* FT_ERROR_BASE( errcode ) */ - /* FT_ERROR_MODULE( errcode ) */ - /* Get base error and module error code, respectively. */ - /* */ - /* */ - /* It can also be used to create a module error message table easily */ - /* with something like */ - /* */ - /* { */ - /* #undef __FTMODERR_H__ */ - /* #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, */ - /* #define FT_MODERR_START_LIST { */ - /* #define FT_MODERR_END_LIST { 0, 0 } }; */ - /* */ - /* const struct */ - /* { */ - /* int mod_err_offset; */ - /* const char* mod_err_msg */ - /* } ft_mod_errors[] = */ - /* */ - /* #include FT_MODULE_ERRORS_H */ - /* } */ - /* */ - /*************************************************************************/ - - -#ifndef __FTMODERR_H__ -#define __FTMODERR_H__ - - - /*******************************************************************/ - /*******************************************************************/ - /***** *****/ - /***** SETUP MACROS *****/ - /***** *****/ - /*******************************************************************/ - /*******************************************************************/ - - -#undef FT_NEED_EXTERN_C - -#ifndef FT_MODERRDEF - -#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS -#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v, -#else -#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0, -#endif - -#define FT_MODERR_START_LIST enum { -#define FT_MODERR_END_LIST FT_Mod_Err_Max }; - -#ifdef __cplusplus -#define FT_NEED_EXTERN_C - extern "C" { -#endif - -#endif /* !FT_MODERRDEF */ - - - /*******************************************************************/ - /*******************************************************************/ - /***** *****/ - /***** LIST MODULE ERROR BASES *****/ - /***** *****/ - /*******************************************************************/ - /*******************************************************************/ - - -#ifdef FT_MODERR_START_LIST - FT_MODERR_START_LIST -#endif - - - FT_MODERRDEF( Base, 0x000, "base module" ) - FT_MODERRDEF( Autofit, 0x100, "autofitter module" ) - FT_MODERRDEF( BDF, 0x200, "BDF module" ) - FT_MODERRDEF( Bzip2, 0x300, "Bzip2 module" ) - FT_MODERRDEF( Cache, 0x400, "cache module" ) - FT_MODERRDEF( CFF, 0x500, "CFF module" ) - FT_MODERRDEF( CID, 0x600, "CID module" ) - FT_MODERRDEF( Gzip, 0x700, "Gzip module" ) - FT_MODERRDEF( LZW, 0x800, "LZW module" ) - FT_MODERRDEF( OTvalid, 0x900, "OpenType validation module" ) - FT_MODERRDEF( PCF, 0xA00, "PCF module" ) - FT_MODERRDEF( PFR, 0xB00, "PFR module" ) - FT_MODERRDEF( PSaux, 0xC00, "PS auxiliary module" ) - FT_MODERRDEF( PShinter, 0xD00, "PS hinter module" ) - FT_MODERRDEF( PSnames, 0xE00, "PS names module" ) - FT_MODERRDEF( Raster, 0xF00, "raster module" ) - FT_MODERRDEF( SFNT, 0x1000, "SFNT module" ) - FT_MODERRDEF( Smooth, 0x1100, "smooth raster module" ) - FT_MODERRDEF( TrueType, 0x1200, "TrueType module" ) - FT_MODERRDEF( Type1, 0x1300, "Type 1 module" ) - FT_MODERRDEF( Type42, 0x1400, "Type 42 module" ) - FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" ) - FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" ) - - -#ifdef FT_MODERR_END_LIST - FT_MODERR_END_LIST -#endif - - - /*******************************************************************/ - /*******************************************************************/ - /***** *****/ - /***** CLEANUP *****/ - /***** *****/ - /*******************************************************************/ - /*******************************************************************/ - - -#ifdef FT_NEED_EXTERN_C - } -#endif - -#undef FT_MODERR_START_LIST -#undef FT_MODERR_END_LIST -#undef FT_MODERRDEF -#undef FT_NEED_EXTERN_C - - -#endif /* __FTMODERR_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftotval.h b/thirdparty/include/freetype/ftotval.h deleted file mode 100644 index 3d74105db..000000000 --- a/thirdparty/include/freetype/ftotval.h +++ /dev/null @@ -1,203 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftotval.h */ -/* */ -/* FreeType API for validating OpenType tables (specification). */ -/* */ -/* Copyright 2004-2007, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* */ -/* Warning: This module might be moved to a different library in the */ -/* future to avoid a tight dependency between FreeType and the */ -/* OpenType specification. */ -/* */ -/* */ -/***************************************************************************/ - - -#ifndef __FTOTVAL_H__ -#define __FTOTVAL_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* ot_validation */ - /* */ - /* <Title> */ - /* OpenType Validation */ - /* */ - /* <Abstract> */ - /* An API to validate OpenType tables. */ - /* */ - /* <Description> */ - /* This section contains the declaration of functions to validate */ - /* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). */ - /* */ - /*************************************************************************/ - - - /********************************************************************** - * - * @enum: - * FT_VALIDATE_OTXXX - * - * @description: - * A list of bit-field constants used with @FT_OpenType_Validate to - * indicate which OpenType tables should be validated. - * - * @values: - * FT_VALIDATE_BASE :: - * Validate BASE table. - * - * FT_VALIDATE_GDEF :: - * Validate GDEF table. - * - * FT_VALIDATE_GPOS :: - * Validate GPOS table. - * - * FT_VALIDATE_GSUB :: - * Validate GSUB table. - * - * FT_VALIDATE_JSTF :: - * Validate JSTF table. - * - * FT_VALIDATE_MATH :: - * Validate MATH table. - * - * FT_VALIDATE_OT :: - * Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). - * - */ -#define FT_VALIDATE_BASE 0x0100 -#define FT_VALIDATE_GDEF 0x0200 -#define FT_VALIDATE_GPOS 0x0400 -#define FT_VALIDATE_GSUB 0x0800 -#define FT_VALIDATE_JSTF 0x1000 -#define FT_VALIDATE_MATH 0x2000 - -#define FT_VALIDATE_OT FT_VALIDATE_BASE | \ - FT_VALIDATE_GDEF | \ - FT_VALIDATE_GPOS | \ - FT_VALIDATE_GSUB | \ - FT_VALIDATE_JSTF | \ - FT_VALIDATE_MATH - - /* */ - - /********************************************************************** - * - * @function: - * FT_OpenType_Validate - * - * @description: - * Validate various OpenType tables to assure that all offsets and - * indices are valid. The idea is that a higher-level library that - * actually does the text layout can access those tables without - * error checking (which can be quite time consuming). - * - * @input: - * face :: - * A handle to the input face. - * - * validation_flags :: - * A bit field that specifies the tables to be validated. See - * @FT_VALIDATE_OTXXX for possible values. - * - * @output: - * BASE_table :: - * A pointer to the BASE table. - * - * GDEF_table :: - * A pointer to the GDEF table. - * - * GPOS_table :: - * A pointer to the GPOS table. - * - * GSUB_table :: - * A pointer to the GSUB table. - * - * JSTF_table :: - * A pointer to the JSTF table. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with OpenType fonts, returning an error - * otherwise. - * - * After use, the application should deallocate the five tables with - * @FT_OpenType_Free. A NULL value indicates that the table either - * doesn't exist in the font, or the application hasn't asked for - * validation. - */ - FT_EXPORT( FT_Error ) - FT_OpenType_Validate( FT_Face face, - FT_UInt validation_flags, - FT_Bytes *BASE_table, - FT_Bytes *GDEF_table, - FT_Bytes *GPOS_table, - FT_Bytes *GSUB_table, - FT_Bytes *JSTF_table ); - - /* */ - - /********************************************************************** - * - * @function: - * FT_OpenType_Free - * - * @description: - * Free the buffer allocated by OpenType validator. - * - * @input: - * face :: - * A handle to the input face. - * - * table :: - * The pointer to the buffer that is allocated by - * @FT_OpenType_Validate. - * - * @note: - * This function must be used to free the buffer allocated by - * @FT_OpenType_Validate only. - */ - FT_EXPORT( void ) - FT_OpenType_Free( FT_Face face, - FT_Bytes table ); - - - /* */ - - -FT_END_HEADER - -#endif /* __FTOTVAL_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftoutln.h b/thirdparty/include/freetype/ftoutln.h deleted file mode 100644 index a56290af9..000000000 --- a/thirdparty/include/freetype/ftoutln.h +++ /dev/null @@ -1,572 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftoutln.h */ -/* */ -/* Support for the FT_Outline type used to store glyph shapes of */ -/* most scalable font formats (specification). */ -/* */ -/* Copyright 1996-2003, 2005-2014 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTOUTLN_H__ -#define __FTOUTLN_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* outline_processing */ - /* */ - /* <Title> */ - /* Outline Processing */ - /* */ - /* <Abstract> */ - /* Functions to create, transform, and render vectorial glyph images. */ - /* */ - /* <Description> */ - /* This section contains routines used to create and destroy scalable */ - /* glyph images known as `outlines'. These can also be measured, */ - /* transformed, and converted into bitmaps and pixmaps. */ - /* */ - /* <Order> */ - /* FT_Outline */ - /* FT_OUTLINE_FLAGS */ - /* FT_Outline_New */ - /* FT_Outline_Done */ - /* FT_Outline_Copy */ - /* FT_Outline_Translate */ - /* FT_Outline_Transform */ - /* FT_Outline_Embolden */ - /* FT_Outline_EmboldenXY */ - /* FT_Outline_Reverse */ - /* FT_Outline_Check */ - /* */ - /* FT_Outline_Get_CBox */ - /* FT_Outline_Get_BBox */ - /* */ - /* FT_Outline_Get_Bitmap */ - /* FT_Outline_Render */ - /* */ - /* FT_Outline_Decompose */ - /* FT_Outline_Funcs */ - /* FT_Outline_MoveTo_Func */ - /* FT_Outline_LineTo_Func */ - /* FT_Outline_ConicTo_Func */ - /* FT_Outline_CubicTo_Func */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Decompose */ - /* */ - /* <Description> */ - /* Walk over an outline's structure to decompose it into individual */ - /* segments and Bézier arcs. This function also emits `move to' */ - /* operations to indicate the start of new contours in the outline. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source target. */ - /* */ - /* func_interface :: A table of `emitters', i.e., function pointers */ - /* called during decomposition to indicate path */ - /* operations. */ - /* */ - /* <InOut> */ - /* user :: A typeless pointer that is passed to each */ - /* emitter during the decomposition. It can be */ - /* used to store the state during the */ - /* decomposition. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* A contour that contains a single point only is represented by a */ - /* `move to' operation followed by `line to' to the same point. In */ - /* most cases, it is best to filter this out before using the */ - /* outline for stroking purposes (otherwise it would result in a */ - /* visible dot when round caps are used). */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Decompose( FT_Outline* outline, - const FT_Outline_Funcs* func_interface, - void* user ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_New */ - /* */ - /* <Description> */ - /* Create a new outline of a given size. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object from where the */ - /* outline is allocated. Note however that the new */ - /* outline will *not* necessarily be *freed*, when */ - /* destroying the library, by @FT_Done_FreeType. */ - /* */ - /* numPoints :: The maximum number of points within the outline. */ - /* Must be smaller than or equal to 0xFFFF (65535). */ - /* */ - /* numContours :: The maximum number of contours within the outline. */ - /* This value must be in the range 0 to `numPoints'. */ - /* */ - /* <Output> */ - /* anoutline :: A handle to the new outline. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The reason why this function takes a `library' parameter is simply */ - /* to use the library's memory allocator. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_New( FT_Library library, - FT_UInt numPoints, - FT_Int numContours, - FT_Outline *anoutline ); - - - FT_EXPORT( FT_Error ) - FT_Outline_New_Internal( FT_Memory memory, - FT_UInt numPoints, - FT_Int numContours, - FT_Outline *anoutline ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Done */ - /* */ - /* <Description> */ - /* Destroy an outline created with @FT_Outline_New. */ - /* */ - /* <Input> */ - /* library :: A handle of the library object used to allocate the */ - /* outline. */ - /* */ - /* outline :: A pointer to the outline object to be discarded. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If the outline's `owner' field is not set, only the outline */ - /* descriptor will be released. */ - /* */ - /* The reason why this function takes an `library' parameter is */ - /* simply to use ft_mem_free(). */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Done( FT_Library library, - FT_Outline* outline ); - - - FT_EXPORT( FT_Error ) - FT_Outline_Done_Internal( FT_Memory memory, - FT_Outline* outline ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Check */ - /* */ - /* <Description> */ - /* Check the contents of an outline descriptor. */ - /* */ - /* <Input> */ - /* outline :: A handle to a source outline. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Check( FT_Outline* outline ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_CBox */ - /* */ - /* <Description> */ - /* Return an outline's `control box'. The control box encloses all */ - /* the outline's points, including Bézier control points. Though it */ - /* coincides with the exact bounding box for most glyphs, it can be */ - /* slightly larger in some situations (like when rotating an outline */ - /* that contains Bézier outside arcs). */ - /* */ - /* Computing the control box is very fast, while getting the bounding */ - /* box can take much more time as it needs to walk over all segments */ - /* and arcs in the outline. To get the latter, you can use the */ - /* `ftbbox' component, which is dedicated to this single task. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <Output> */ - /* acbox :: The outline's control box. */ - /* */ - /* <Note> */ - /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */ - /* */ - FT_EXPORT( void ) - FT_Outline_Get_CBox( const FT_Outline* outline, - FT_BBox *acbox ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Translate */ - /* */ - /* <Description> */ - /* Apply a simple translation to the points of an outline. */ - /* */ - /* <InOut> */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* <Input> */ - /* xOffset :: The horizontal offset. */ - /* */ - /* yOffset :: The vertical offset. */ - /* */ - FT_EXPORT( void ) - FT_Outline_Translate( const FT_Outline* outline, - FT_Pos xOffset, - FT_Pos yOffset ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Copy */ - /* */ - /* <Description> */ - /* Copy an outline into another one. Both objects must have the */ - /* same sizes (number of points & number of contours) when this */ - /* function is called. */ - /* */ - /* <Input> */ - /* source :: A handle to the source outline. */ - /* */ - /* <Output> */ - /* target :: A handle to the target outline. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Copy( const FT_Outline* source, - FT_Outline *target ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Transform */ - /* */ - /* <Description> */ - /* Apply a simple 2x2 matrix to all of an outline's points. Useful */ - /* for applying rotations, slanting, flipping, etc. */ - /* */ - /* <InOut> */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to the transformation matrix. */ - /* */ - /* <Note> */ - /* You can use @FT_Outline_Translate if you need to translate the */ - /* outline's points. */ - /* */ - FT_EXPORT( void ) - FT_Outline_Transform( const FT_Outline* outline, - const FT_Matrix* matrix ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Embolden */ - /* */ - /* <Description> */ - /* Embolden an outline. The new outline will be at most 4~times */ - /* `strength' pixels wider and higher. You may think of the left and */ - /* bottom borders as unchanged. */ - /* */ - /* Negative `strength' values to reduce the outline thickness are */ - /* possible also. */ - /* */ - /* <InOut> */ - /* outline :: A handle to the target outline. */ - /* */ - /* <Input> */ - /* strength :: How strong the glyph is emboldened. Expressed in */ - /* 26.6 pixel format. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The used algorithm to increase or decrease the thickness of the */ - /* glyph doesn't change the number of points; this means that certain */ - /* situations like acute angles or intersections are sometimes */ - /* handled incorrectly. */ - /* */ - /* If you need `better' metrics values you should call */ - /* @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. */ - /* */ - /* Example call: */ - /* */ - /* { */ - /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */ - /* if ( face->slot->format == FT_GLYPH_FORMAT_OUTLINE ) */ - /* FT_Outline_Embolden( &face->slot->outline, strength ); */ - /* } */ - /* */ - /* To get meaningful results, font scaling values must be set with */ - /* functions like @FT_Set_Char_Size before calling FT_Render_Glyph. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Embolden( FT_Outline* outline, - FT_Pos strength ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_EmboldenXY */ - /* */ - /* <Description> */ - /* Embolden an outline. The new outline will be `xstrength' pixels */ - /* wider and `ystrength' pixels higher. Otherwise, it is similar to */ - /* @FT_Outline_Embolden, which uses the same strength in both */ - /* directions. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_EmboldenXY( FT_Outline* outline, - FT_Pos xstrength, - FT_Pos ystrength ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Reverse */ - /* */ - /* <Description> */ - /* Reverse the drawing direction of an outline. This is used to */ - /* ensure consistent fill conventions for mirrored glyphs. */ - /* */ - /* <InOut> */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* <Note> */ - /* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */ - /* the outline's `flags' field. */ - /* */ - /* It shouldn't be used by a normal client application, unless it */ - /* knows what it is doing. */ - /* */ - FT_EXPORT( void ) - FT_Outline_Reverse( FT_Outline* outline ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_Bitmap */ - /* */ - /* <Description> */ - /* Render an outline within a bitmap. The outline's image is simply */ - /* OR-ed to the target bitmap. */ - /* */ - /* <Input> */ - /* library :: A handle to a FreeType library object. */ - /* */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <InOut> */ - /* abitmap :: A pointer to the target bitmap descriptor. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function does NOT CREATE the bitmap, it only renders an */ - /* outline image within the one you pass to it! Consequently, the */ - /* various fields in `abitmap' should be set accordingly. */ - /* */ - /* It will use the raster corresponding to the default glyph format. */ - /* */ - /* The value of the `num_grays' field in `abitmap' is ignored. If */ - /* you select the gray-level rasterizer, and you want less than 256 */ - /* gray levels, you have to use @FT_Outline_Render directly. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Get_Bitmap( FT_Library library, - FT_Outline* outline, - const FT_Bitmap *abitmap ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Render */ - /* */ - /* <Description> */ - /* Render an outline within a bitmap using the current scan-convert. */ - /* This function uses an @FT_Raster_Params structure as an argument, */ - /* allowing advanced features like direct composition, translucency, */ - /* etc. */ - /* */ - /* <Input> */ - /* library :: A handle to a FreeType library object. */ - /* */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <InOut> */ - /* params :: A pointer to an @FT_Raster_Params structure used to */ - /* describe the rendering operation. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You should know what you are doing and how @FT_Raster_Params works */ - /* to use this function. */ - /* */ - /* The field `params.source' will be set to `outline' before the scan */ - /* converter is called, which means that the value you give to it is */ - /* actually ignored. */ - /* */ - /* The gray-level rasterizer always uses 256 gray levels. If you */ - /* want less gray levels, you have to provide your own span callback. */ - /* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */ - /* @FT_Raster_Params structure for more details. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Render( FT_Library library, - FT_Outline* outline, - FT_Raster_Params* params ); - - - /************************************************************************** - * - * @enum: - * FT_Orientation - * - * @description: - * A list of values used to describe an outline's contour orientation. - * - * The TrueType and PostScript specifications use different conventions - * to determine whether outline contours should be filled or unfilled. - * - * @values: - * FT_ORIENTATION_TRUETYPE :: - * According to the TrueType specification, clockwise contours must - * be filled, and counter-clockwise ones must be unfilled. - * - * FT_ORIENTATION_POSTSCRIPT :: - * According to the PostScript specification, counter-clockwise contours - * must be filled, and clockwise ones must be unfilled. - * - * FT_ORIENTATION_FILL_RIGHT :: - * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to - * remember that in TrueType, everything that is to the right of - * the drawing direction of a contour must be filled. - * - * FT_ORIENTATION_FILL_LEFT :: - * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to - * remember that in PostScript, everything that is to the left of - * the drawing direction of a contour must be filled. - * - * FT_ORIENTATION_NONE :: - * The orientation cannot be determined. That is, different parts of - * the glyph have different orientation. - * - */ - typedef enum FT_Orientation_ - { - FT_ORIENTATION_TRUETYPE = 0, - FT_ORIENTATION_POSTSCRIPT = 1, - FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE, - FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT, - FT_ORIENTATION_NONE - - } FT_Orientation; - - - /************************************************************************** - * - * @function: - * FT_Outline_Get_Orientation - * - * @description: - * This function analyzes a glyph outline and tries to compute its - * fill orientation (see @FT_Orientation). This is done by integrating - * the total area covered by the outline. The positive integral - * corresponds to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT - * is returned. The negative integral corresponds to the counter-clockwise - * orientation and @FT_ORIENTATION_TRUETYPE is returned. - * - * Note that this will return @FT_ORIENTATION_TRUETYPE for empty - * outlines. - * - * @input: - * outline :: - * A handle to the source outline. - * - * @return: - * The orientation. - * - */ - FT_EXPORT( FT_Orientation ) - FT_Outline_Get_Orientation( FT_Outline* outline ); - - - /* */ - - -FT_END_HEADER - -#endif /* __FTOUTLN_H__ */ - - -/* END */ - - -/* Local Variables: */ -/* coding: utf-8 */ -/* End: */ diff --git a/thirdparty/include/freetype/ftpfr.h b/thirdparty/include/freetype/ftpfr.h deleted file mode 100644 index f777eecea..000000000 --- a/thirdparty/include/freetype/ftpfr.h +++ /dev/null @@ -1,172 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftpfr.h */ -/* */ -/* FreeType API for accessing PFR-specific data (specification only). */ -/* */ -/* Copyright 2002, 2003, 2004, 2006, 2008, 2009 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTPFR_H__ -#define __FTPFR_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* pfr_fonts */ - /* */ - /* <Title> */ - /* PFR Fonts */ - /* */ - /* <Abstract> */ - /* PFR/TrueDoc specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of PFR-specific functions. */ - /* */ - /*************************************************************************/ - - - /********************************************************************** - * - * @function: - * FT_Get_PFR_Metrics - * - * @description: - * Return the outline and metrics resolutions of a given PFR face. - * - * @input: - * face :: Handle to the input face. It can be a non-PFR face. - * - * @output: - * aoutline_resolution :: - * Outline resolution. This is equivalent to `face->units_per_EM' - * for non-PFR fonts. Optional (parameter can be NULL). - * - * ametrics_resolution :: - * Metrics resolution. This is equivalent to `outline_resolution' - * for non-PFR fonts. Optional (parameter can be NULL). - * - * ametrics_x_scale :: - * A 16.16 fixed-point number used to scale distance expressed - * in metrics units to device sub-pixels. This is equivalent to - * `face->size->x_scale', but for metrics only. Optional (parameter - * can be NULL). - * - * ametrics_y_scale :: - * Same as `ametrics_x_scale' but for the vertical direction. - * optional (parameter can be NULL). - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If the input face is not a PFR, this function will return an error. - * However, in all cases, it will return valid values. - */ - FT_EXPORT( FT_Error ) - FT_Get_PFR_Metrics( FT_Face face, - FT_UInt *aoutline_resolution, - FT_UInt *ametrics_resolution, - FT_Fixed *ametrics_x_scale, - FT_Fixed *ametrics_y_scale ); - - - /********************************************************************** - * - * @function: - * FT_Get_PFR_Kerning - * - * @description: - * Return the kerning pair corresponding to two glyphs in a PFR face. - * The distance is expressed in metrics units, unlike the result of - * @FT_Get_Kerning. - * - * @input: - * face :: A handle to the input face. - * - * left :: Index of the left glyph. - * - * right :: Index of the right glyph. - * - * @output: - * avector :: A kerning vector. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function always return distances in original PFR metrics - * units. This is unlike @FT_Get_Kerning with the @FT_KERNING_UNSCALED - * mode, which always returns distances converted to outline units. - * - * You can use the value of the `x_scale' and `y_scale' parameters - * returned by @FT_Get_PFR_Metrics to scale these to device sub-pixels. - */ - FT_EXPORT( FT_Error ) - FT_Get_PFR_Kerning( FT_Face face, - FT_UInt left, - FT_UInt right, - FT_Vector *avector ); - - - /********************************************************************** - * - * @function: - * FT_Get_PFR_Advance - * - * @description: - * Return a given glyph advance, expressed in original metrics units, - * from a PFR font. - * - * @input: - * face :: A handle to the input face. - * - * gindex :: The glyph index. - * - * @output: - * aadvance :: The glyph advance in metrics units. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * You can use the `x_scale' or `y_scale' results of @FT_Get_PFR_Metrics - * to convert the advance to device sub-pixels (i.e., 1/64th of pixels). - */ - FT_EXPORT( FT_Error ) - FT_Get_PFR_Advance( FT_Face face, - FT_UInt gindex, - FT_Pos *aadvance ); - - /* */ - - -FT_END_HEADER - -#endif /* __FTPFR_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftrender.h b/thirdparty/include/freetype/ftrender.h deleted file mode 100644 index 41f0e43a7..000000000 --- a/thirdparty/include/freetype/ftrender.h +++ /dev/null @@ -1,238 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftrender.h */ -/* */ -/* FreeType renderer modules public interface (specification). */ -/* */ -/* Copyright 1996-2001, 2005, 2006, 2010 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTRENDER_H__ -#define __FTRENDER_H__ - - -#include <freetype/ft2build.h> -#include FT_MODULE_H -#include FT_GLYPH_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* module_management */ - /* */ - /*************************************************************************/ - - - /* create a new glyph object */ - typedef FT_Error - (*FT_Glyph_InitFunc)( FT_Glyph glyph, - FT_GlyphSlot slot ); - - /* destroys a given glyph object */ - typedef void - (*FT_Glyph_DoneFunc)( FT_Glyph glyph ); - - typedef void - (*FT_Glyph_TransformFunc)( FT_Glyph glyph, - const FT_Matrix* matrix, - const FT_Vector* delta ); - - typedef void - (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph, - FT_BBox* abbox ); - - typedef FT_Error - (*FT_Glyph_CopyFunc)( FT_Glyph source, - FT_Glyph target ); - - typedef FT_Error - (*FT_Glyph_PrepareFunc)( FT_Glyph glyph, - FT_GlyphSlot slot ); - -/* deprecated */ -#define FT_Glyph_Init_Func FT_Glyph_InitFunc -#define FT_Glyph_Done_Func FT_Glyph_DoneFunc -#define FT_Glyph_Transform_Func FT_Glyph_TransformFunc -#define FT_Glyph_BBox_Func FT_Glyph_GetBBoxFunc -#define FT_Glyph_Copy_Func FT_Glyph_CopyFunc -#define FT_Glyph_Prepare_Func FT_Glyph_PrepareFunc - - - struct FT_Glyph_Class_ - { - FT_Long glyph_size; - FT_Glyph_Format glyph_format; - FT_Glyph_InitFunc glyph_init; - FT_Glyph_DoneFunc glyph_done; - FT_Glyph_CopyFunc glyph_copy; - FT_Glyph_TransformFunc glyph_transform; - FT_Glyph_GetBBoxFunc glyph_bbox; - FT_Glyph_PrepareFunc glyph_prepare; - }; - - - typedef FT_Error - (*FT_Renderer_RenderFunc)( FT_Renderer renderer, - FT_GlyphSlot slot, - FT_UInt mode, - const FT_Vector* origin ); - - typedef FT_Error - (*FT_Renderer_TransformFunc)( FT_Renderer renderer, - FT_GlyphSlot slot, - const FT_Matrix* matrix, - const FT_Vector* delta ); - - - typedef void - (*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer, - FT_GlyphSlot slot, - FT_BBox* cbox ); - - - typedef FT_Error - (*FT_Renderer_SetModeFunc)( FT_Renderer renderer, - FT_ULong mode_tag, - FT_Pointer mode_ptr ); - -/* deprecated identifiers */ -#define FTRenderer_render FT_Renderer_RenderFunc -#define FTRenderer_transform FT_Renderer_TransformFunc -#define FTRenderer_getCBox FT_Renderer_GetCBoxFunc -#define FTRenderer_setMode FT_Renderer_SetModeFunc - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Renderer_Class */ - /* */ - /* <Description> */ - /* The renderer module class descriptor. */ - /* */ - /* <Fields> */ - /* root :: The root @FT_Module_Class fields. */ - /* */ - /* glyph_format :: The glyph image format this renderer handles. */ - /* */ - /* render_glyph :: A method used to render the image that is in a */ - /* given glyph slot into a bitmap. */ - /* */ - /* transform_glyph :: A method used to transform the image that is in */ - /* a given glyph slot. */ - /* */ - /* get_glyph_cbox :: A method used to access the glyph's cbox. */ - /* */ - /* set_mode :: A method used to pass additional parameters. */ - /* */ - /* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */ - /* This is a pointer to its raster's class. */ - /* */ - typedef struct FT_Renderer_Class_ - { - FT_Module_Class root; - - FT_Glyph_Format glyph_format; - - FT_Renderer_RenderFunc render_glyph; - FT_Renderer_TransformFunc transform_glyph; - FT_Renderer_GetCBoxFunc get_glyph_cbox; - FT_Renderer_SetModeFunc set_mode; - - FT_Raster_Funcs* raster_class; - - } FT_Renderer_Class; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Renderer */ - /* */ - /* <Description> */ - /* Retrieve the current renderer for a given glyph format. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object. */ - /* */ - /* format :: The glyph format. */ - /* */ - /* <Return> */ - /* A renderer handle. 0~if none found. */ - /* */ - /* <Note> */ - /* An error will be returned if a module already exists by that name, */ - /* or if the module requires a version of FreeType that is too great. */ - /* */ - /* To add a new renderer, simply use @FT_Add_Module. To retrieve a */ - /* renderer by its name, use @FT_Get_Module. */ - /* */ - FT_EXPORT( FT_Renderer ) - FT_Get_Renderer( FT_Library library, - FT_Glyph_Format format ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Renderer */ - /* */ - /* <Description> */ - /* Set the current renderer to use, and set additional mode. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library object. */ - /* */ - /* <Input> */ - /* renderer :: A handle to the renderer object. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* parameters :: Additional parameters. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* In case of success, the renderer will be used to convert glyph */ - /* images in the renderer's known format into bitmaps. */ - /* */ - /* This doesn't change the current renderer for other formats. */ - /* */ - /* Currently, only the B/W renderer, if compiled with */ - /* FT_RASTER_OPTION_ANTI_ALIASING (providing a 5-levels */ - /* anti-aliasing mode; this option must be set directly in */ - /* `ftraster.c' and is undefined by default) accepts a single tag */ - /* `pal5' to set its gray palette as a character string with */ - /* 5~elements. Consequently, the third and fourth argument are zero */ - /* normally. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_Renderer( FT_Library library, - FT_Renderer renderer, - FT_UInt num_params, - FT_Parameter* parameters ); - - - /* */ - - -FT_END_HEADER - -#endif /* __FTRENDER_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftsizes.h b/thirdparty/include/freetype/ftsizes.h deleted file mode 100644 index 3e5990c49..000000000 --- a/thirdparty/include/freetype/ftsizes.h +++ /dev/null @@ -1,159 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftsizes.h */ -/* */ -/* FreeType size objects management (specification). */ -/* */ -/* Copyright 1996-2001, 2003, 2004, 2006, 2009, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Typical application would normally not need to use these functions. */ - /* However, they have been placed in a public API for the rare cases */ - /* where they are needed. */ - /* */ - /*************************************************************************/ - - -#ifndef __FTSIZES_H__ -#define __FTSIZES_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* sizes_management */ - /* */ - /* <Title> */ - /* Size Management */ - /* */ - /* <Abstract> */ - /* Managing multiple sizes per face. */ - /* */ - /* <Description> */ - /* When creating a new face object (e.g., with @FT_New_Face), an */ - /* @FT_Size object is automatically created and used to store all */ - /* pixel-size dependent information, available in the `face->size' */ - /* field. */ - /* */ - /* It is however possible to create more sizes for a given face, */ - /* mostly in order to manage several character pixel sizes of the */ - /* same font family and style. See @FT_New_Size and @FT_Done_Size. */ - /* */ - /* Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only */ - /* modify the contents of the current `active' size; you thus need */ - /* to use @FT_Activate_Size to change it. */ - /* */ - /* 99% of applications won't need the functions provided here, */ - /* especially if they use the caching sub-system, so be cautious */ - /* when using these. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Size */ - /* */ - /* <Description> */ - /* Create a new size object from a given face object. */ - /* */ - /* <Input> */ - /* face :: A handle to a parent face object. */ - /* */ - /* <Output> */ - /* asize :: A handle to a new size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You need to call @FT_Activate_Size in order to select the new size */ - /* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */ - /* @FT_Load_Glyph, @FT_Load_Char, etc. */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Size( FT_Face face, - FT_Size* size ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Size */ - /* */ - /* <Description> */ - /* Discard a given size object. Note that @FT_Done_Face */ - /* automatically discards all size objects allocated with */ - /* @FT_New_Size. */ - /* */ - /* <Input> */ - /* size :: A handle to a target size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Done_Size( FT_Size size ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Activate_Size */ - /* */ - /* <Description> */ - /* Even though it is possible to create several size objects for a */ - /* given face (see @FT_New_Size for details), functions like */ - /* @FT_Load_Glyph or @FT_Load_Char only use the one that has been */ - /* activated last to determine the `current character pixel size'. */ - /* */ - /* This function can be used to `activate' a previously created size */ - /* object. */ - /* */ - /* <Input> */ - /* size :: A handle to a target size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If `face' is the size's parent face object, this function changes */ - /* the value of `face->size' to the input size handle. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Activate_Size( FT_Size size ); - - /* */ - - -FT_END_HEADER - -#endif /* __FTSIZES_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftsnames.h b/thirdparty/include/freetype/ftsnames.h deleted file mode 100644 index 9dacda447..000000000 --- a/thirdparty/include/freetype/ftsnames.h +++ /dev/null @@ -1,200 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftsnames.h */ -/* */ -/* Simple interface to access SFNT name tables (which are used */ -/* to hold font names, copyright info, notices, etc.) (specification). */ -/* */ -/* This is _not_ used to retrieve glyph names! */ -/* */ -/* Copyright 1996-2003, 2006, 2009, 2010, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FT_SFNT_NAMES_H__ -#define __FT_SFNT_NAMES_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* sfnt_names */ - /* */ - /* <Title> */ - /* SFNT Names */ - /* */ - /* <Abstract> */ - /* Access the names embedded in TrueType and OpenType files. */ - /* */ - /* <Description> */ - /* The TrueType and OpenType specifications allow the inclusion of */ - /* a special `names table' in font files. This table contains */ - /* textual (and internationalized) information regarding the font, */ - /* like family name, copyright, version, etc. */ - /* */ - /* The definitions below are used to access them if available. */ - /* */ - /* Note that this has nothing to do with glyph names! */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SfntName */ - /* */ - /* <Description> */ - /* A structure used to model an SFNT `name' table entry. */ - /* */ - /* <Fields> */ - /* platform_id :: The platform ID for `string'. */ - /* */ - /* encoding_id :: The encoding ID for `string'. */ - /* */ - /* language_id :: The language ID for `string'. */ - /* */ - /* name_id :: An identifier for `string'. */ - /* */ - /* string :: The `name' string. Note that its format differs */ - /* depending on the (platform,encoding) pair. It can */ - /* be a Pascal String, a UTF-16 one, etc. */ - /* */ - /* Generally speaking, the string is not */ - /* zero-terminated. Please refer to the TrueType */ - /* specification for details. */ - /* */ - /* string_len :: The length of `string' in bytes. */ - /* */ - /* <Note> */ - /* Possible values for `platform_id', `encoding_id', `language_id', */ - /* and `name_id' are given in the file `ttnameid.h'. For details */ - /* please refer to the TrueType or OpenType specification. */ - /* */ - /* See also @TT_PLATFORM_XXX, @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, */ - /* @TT_ISO_ID_XXX, and @TT_MS_ID_XXX. */ - /* */ - typedef struct FT_SfntName_ - { - FT_UShort platform_id; - FT_UShort encoding_id; - FT_UShort language_id; - FT_UShort name_id; - - FT_Byte* string; /* this string is *not* null-terminated! */ - FT_UInt string_len; /* in bytes */ - - } FT_SfntName; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_Name_Count */ - /* */ - /* <Description> */ - /* Retrieve the number of name strings in the SFNT `name' table. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* <Return> */ - /* The number of strings in the `name' table. */ - /* */ - FT_EXPORT( FT_UInt ) - FT_Get_Sfnt_Name_Count( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_Name */ - /* */ - /* <Description> */ - /* Retrieve a string of the SFNT `name' table for a given index. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* idx :: The index of the `name' string. */ - /* */ - /* <Output> */ - /* aname :: The indexed @FT_SfntName structure. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `string' array returned in the `aname' structure is not */ - /* null-terminated. The application should deallocate it if it is no */ - /* longer in use. */ - /* */ - /* Use @FT_Get_Sfnt_Name_Count to get the total number of available */ - /* `name' table entries, then do a loop until you get the right */ - /* platform, encoding, and name ID. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Sfnt_Name( FT_Face face, - FT_UInt idx, - FT_SfntName *aname ); - - - /*************************************************************************** - * - * @constant: - * FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY - * - * @description: - * A constant used as the tag of @FT_Parameter structures to make - * FT_Open_Face() ignore preferred family subfamily names in `name' - * table since OpenType version 1.4. For backwards compatibility with - * legacy systems that have a 4-face-per-family restriction. - * - */ -#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY FT_MAKE_TAG( 'i', 'g', 'p', 'f' ) - - - /*************************************************************************** - * - * @constant: - * FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY - * - * @description: - * A constant used as the tag of @FT_Parameter structures to make - * FT_Open_Face() ignore preferred subfamily names in `name' table since - * OpenType version 1.4. For backwards compatibility with legacy - * systems that have a 4-face-per-family restriction. - * - */ -#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY FT_MAKE_TAG( 'i', 'g', 'p', 's' ) - - /* */ - - -FT_END_HEADER - -#endif /* __FT_SFNT_NAMES_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftstroke.h b/thirdparty/include/freetype/ftstroke.h deleted file mode 100644 index 008add566..000000000 --- a/thirdparty/include/freetype/ftstroke.h +++ /dev/null @@ -1,751 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftstroke.h */ -/* */ -/* FreeType path stroker (specification). */ -/* */ -/* Copyright 2002-2006, 2008, 2009, 2011-2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FT_STROKE_H__ -#define __FT_STROKE_H__ - -#include <freetype/ft2build.h> -#include FT_OUTLINE_H -#include FT_GLYPH_H - - -FT_BEGIN_HEADER - - - /************************************************************************ - * - * @section: - * glyph_stroker - * - * @title: - * Glyph Stroker - * - * @abstract: - * Generating bordered and stroked glyphs. - * - * @description: - * This component generates stroked outlines of a given vectorial - * glyph. It also allows you to retrieve the `outside' and/or the - * `inside' borders of the stroke. - * - * This can be useful to generate `bordered' glyph, i.e., glyphs - * displayed with a coloured (and anti-aliased) border around their - * shape. - */ - - - /************************************************************** - * - * @type: - * FT_Stroker - * - * @description: - * Opaque handler to a path stroker object. - */ - typedef struct FT_StrokerRec_* FT_Stroker; - - - /************************************************************** - * - * @enum: - * FT_Stroker_LineJoin - * - * @description: - * These values determine how two joining lines are rendered - * in a stroker. - * - * @values: - * FT_STROKER_LINEJOIN_ROUND :: - * Used to render rounded line joins. Circular arcs are used - * to join two lines smoothly. - * - * FT_STROKER_LINEJOIN_BEVEL :: - * Used to render beveled line joins. The outer corner of - * the joined lines is filled by enclosing the triangular - * region of the corner with a straight line between the - * outer corners of each stroke. - * - * FT_STROKER_LINEJOIN_MITER_FIXED :: - * Used to render mitered line joins, with fixed bevels if the - * miter limit is exceeded. The outer edges of the strokes - * for the two segments are extended until they meet at an - * angle. If the segments meet at too sharp an angle (such - * that the miter would extend from the intersection of the - * segments a distance greater than the product of the miter - * limit value and the border radius), then a bevel join (see - * above) is used instead. This prevents long spikes being - * created. FT_STROKER_LINEJOIN_MITER_FIXED generates a miter - * line join as used in PostScript and PDF. - * - * FT_STROKER_LINEJOIN_MITER_VARIABLE :: - * FT_STROKER_LINEJOIN_MITER :: - * Used to render mitered line joins, with variable bevels if - * the miter limit is exceeded. The intersection of the - * strokes is clipped at a line perpendicular to the bisector - * of the angle between the strokes, at the distance from the - * intersection of the segments equal to the product of the - * miter limit value and the border radius. This prevents - * long spikes being created. - * FT_STROKER_LINEJOIN_MITER_VARIABLE generates a mitered line - * join as used in XPS. FT_STROKER_LINEJOIN_MITER is an alias - * for FT_STROKER_LINEJOIN_MITER_VARIABLE, retained for - * backwards compatibility. - */ - typedef enum FT_Stroker_LineJoin_ - { - FT_STROKER_LINEJOIN_ROUND = 0, - FT_STROKER_LINEJOIN_BEVEL = 1, - FT_STROKER_LINEJOIN_MITER_VARIABLE = 2, - FT_STROKER_LINEJOIN_MITER = FT_STROKER_LINEJOIN_MITER_VARIABLE, - FT_STROKER_LINEJOIN_MITER_FIXED = 3 - - } FT_Stroker_LineJoin; - - - /************************************************************** - * - * @enum: - * FT_Stroker_LineCap - * - * @description: - * These values determine how the end of opened sub-paths are - * rendered in a stroke. - * - * @values: - * FT_STROKER_LINECAP_BUTT :: - * The end of lines is rendered as a full stop on the last - * point itself. - * - * FT_STROKER_LINECAP_ROUND :: - * The end of lines is rendered as a half-circle around the - * last point. - * - * FT_STROKER_LINECAP_SQUARE :: - * The end of lines is rendered as a square around the - * last point. - */ - typedef enum FT_Stroker_LineCap_ - { - FT_STROKER_LINECAP_BUTT = 0, - FT_STROKER_LINECAP_ROUND, - FT_STROKER_LINECAP_SQUARE - - } FT_Stroker_LineCap; - - - /************************************************************** - * - * @enum: - * FT_StrokerBorder - * - * @description: - * These values are used to select a given stroke border - * in @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder. - * - * @values: - * FT_STROKER_BORDER_LEFT :: - * Select the left border, relative to the drawing direction. - * - * FT_STROKER_BORDER_RIGHT :: - * Select the right border, relative to the drawing direction. - * - * @note: - * Applications are generally interested in the `inside' and `outside' - * borders. However, there is no direct mapping between these and the - * `left' and `right' ones, since this really depends on the glyph's - * drawing orientation, which varies between font formats. - * - * You can however use @FT_Outline_GetInsideBorder and - * @FT_Outline_GetOutsideBorder to get these. - */ - typedef enum FT_StrokerBorder_ - { - FT_STROKER_BORDER_LEFT = 0, - FT_STROKER_BORDER_RIGHT - - } FT_StrokerBorder; - - - /************************************************************** - * - * @function: - * FT_Outline_GetInsideBorder - * - * @description: - * Retrieve the @FT_StrokerBorder value corresponding to the - * `inside' borders of a given outline. - * - * @input: - * outline :: - * The source outline handle. - * - * @return: - * The border index. @FT_STROKER_BORDER_RIGHT for empty or invalid - * outlines. - */ - FT_EXPORT( FT_StrokerBorder ) - FT_Outline_GetInsideBorder( FT_Outline* outline ); - - - /************************************************************** - * - * @function: - * FT_Outline_GetOutsideBorder - * - * @description: - * Retrieve the @FT_StrokerBorder value corresponding to the - * `outside' borders of a given outline. - * - * @input: - * outline :: - * The source outline handle. - * - * @return: - * The border index. @FT_STROKER_BORDER_LEFT for empty or invalid - * outlines. - */ - FT_EXPORT( FT_StrokerBorder ) - FT_Outline_GetOutsideBorder( FT_Outline* outline ); - - - /************************************************************** - * - * @function: - * FT_Stroker_New - * - * @description: - * Create a new stroker object. - * - * @input: - * library :: - * FreeType library handle. - * - * @output: - * astroker :: - * A new stroker object handle. NULL in case of error. - * - * @return: - * FreeType error code. 0~means success. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_New( FT_Library library, - FT_Stroker *astroker ); - - - /************************************************************** - * - * @function: - * FT_Stroker_Set - * - * @description: - * Reset a stroker object's attributes. - * - * @input: - * stroker :: - * The target stroker handle. - * - * radius :: - * The border radius. - * - * line_cap :: - * The line cap style. - * - * line_join :: - * The line join style. - * - * miter_limit :: - * The miter limit for the FT_STROKER_LINEJOIN_MITER_FIXED and - * FT_STROKER_LINEJOIN_MITER_VARIABLE line join styles, - * expressed as 16.16 fixed-point value. - * - * @note: - * The radius is expressed in the same units as the outline - * coordinates. - */ - FT_EXPORT( void ) - FT_Stroker_Set( FT_Stroker stroker, - FT_Fixed radius, - FT_Stroker_LineCap line_cap, - FT_Stroker_LineJoin line_join, - FT_Fixed miter_limit ); - - - /************************************************************** - * - * @function: - * FT_Stroker_Rewind - * - * @description: - * Reset a stroker object without changing its attributes. - * You should call this function before beginning a new - * series of calls to @FT_Stroker_BeginSubPath or - * @FT_Stroker_EndSubPath. - * - * @input: - * stroker :: - * The target stroker handle. - */ - FT_EXPORT( void ) - FT_Stroker_Rewind( FT_Stroker stroker ); - - - /************************************************************** - * - * @function: - * FT_Stroker_ParseOutline - * - * @description: - * A convenience function used to parse a whole outline with - * the stroker. The resulting outline(s) can be retrieved - * later by functions like @FT_Stroker_GetCounts and @FT_Stroker_Export. - * - * @input: - * stroker :: - * The target stroker handle. - * - * outline :: - * The source outline. - * - * opened :: - * A boolean. If~1, the outline is treated as an open path instead - * of a closed one. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If `opened' is~0 (the default), the outline is treated as a closed - * path, and the stroker generates two distinct `border' outlines. - * - * If `opened' is~1, the outline is processed as an open path, and the - * stroker generates a single `stroke' outline. - * - * This function calls @FT_Stroker_Rewind automatically. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_ParseOutline( FT_Stroker stroker, - FT_Outline* outline, - FT_Bool opened ); - - - /************************************************************** - * - * @function: - * FT_Stroker_BeginSubPath - * - * @description: - * Start a new sub-path in the stroker. - * - * @input: - * stroker :: - * The target stroker handle. - * - * to :: - * A pointer to the start vector. - * - * open :: - * A boolean. If~1, the sub-path is treated as an open one. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function is useful when you need to stroke a path that is - * not stored as an @FT_Outline object. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_BeginSubPath( FT_Stroker stroker, - FT_Vector* to, - FT_Bool open ); - - - /************************************************************** - * - * @function: - * FT_Stroker_EndSubPath - * - * @description: - * Close the current sub-path in the stroker. - * - * @input: - * stroker :: - * The target stroker handle. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * You should call this function after @FT_Stroker_BeginSubPath. - * If the subpath was not `opened', this function `draws' a - * single line segment to the start position when needed. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_EndSubPath( FT_Stroker stroker ); - - - /************************************************************** - * - * @function: - * FT_Stroker_LineTo - * - * @description: - * `Draw' a single line segment in the stroker's current sub-path, - * from the last position. - * - * @input: - * stroker :: - * The target stroker handle. - * - * to :: - * A pointer to the destination point. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * You should call this function between @FT_Stroker_BeginSubPath and - * @FT_Stroker_EndSubPath. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_LineTo( FT_Stroker stroker, - FT_Vector* to ); - - - /************************************************************** - * - * @function: - * FT_Stroker_ConicTo - * - * @description: - * `Draw' a single quadratic Bézier in the stroker's current sub-path, - * from the last position. - * - * @input: - * stroker :: - * The target stroker handle. - * - * control :: - * A pointer to a Bézier control point. - * - * to :: - * A pointer to the destination point. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * You should call this function between @FT_Stroker_BeginSubPath and - * @FT_Stroker_EndSubPath. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_ConicTo( FT_Stroker stroker, - FT_Vector* control, - FT_Vector* to ); - - - /************************************************************** - * - * @function: - * FT_Stroker_CubicTo - * - * @description: - * `Draw' a single cubic Bézier in the stroker's current sub-path, - * from the last position. - * - * @input: - * stroker :: - * The target stroker handle. - * - * control1 :: - * A pointer to the first Bézier control point. - * - * control2 :: - * A pointer to second Bézier control point. - * - * to :: - * A pointer to the destination point. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * You should call this function between @FT_Stroker_BeginSubPath and - * @FT_Stroker_EndSubPath. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_CubicTo( FT_Stroker stroker, - FT_Vector* control1, - FT_Vector* control2, - FT_Vector* to ); - - - /************************************************************** - * - * @function: - * FT_Stroker_GetBorderCounts - * - * @description: - * Call this function once you have finished parsing your paths - * with the stroker. It returns the number of points and - * contours necessary to export one of the `border' or `stroke' - * outlines generated by the stroker. - * - * @input: - * stroker :: - * The target stroker handle. - * - * border :: - * The border index. - * - * @output: - * anum_points :: - * The number of points. - * - * anum_contours :: - * The number of contours. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * When an outline, or a sub-path, is `closed', the stroker generates - * two independent `border' outlines, named `left' and `right'. - * - * When the outline, or a sub-path, is `opened', the stroker merges - * the `border' outlines with caps. The `left' border receives all - * points, while the `right' border becomes empty. - * - * Use the function @FT_Stroker_GetCounts instead if you want to - * retrieve the counts associated to both borders. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_GetBorderCounts( FT_Stroker stroker, - FT_StrokerBorder border, - FT_UInt *anum_points, - FT_UInt *anum_contours ); - - - /************************************************************** - * - * @function: - * FT_Stroker_ExportBorder - * - * @description: - * Call this function after @FT_Stroker_GetBorderCounts to - * export the corresponding border to your own @FT_Outline - * structure. - * - * Note that this function appends the border points and - * contours to your outline, but does not try to resize its - * arrays. - * - * @input: - * stroker :: - * The target stroker handle. - * - * border :: - * The border index. - * - * outline :: - * The target outline handle. - * - * @note: - * Always call this function after @FT_Stroker_GetBorderCounts to - * get sure that there is enough room in your @FT_Outline object to - * receive all new data. - * - * When an outline, or a sub-path, is `closed', the stroker generates - * two independent `border' outlines, named `left' and `right' - * - * When the outline, or a sub-path, is `opened', the stroker merges - * the `border' outlines with caps. The `left' border receives all - * points, while the `right' border becomes empty. - * - * Use the function @FT_Stroker_Export instead if you want to - * retrieve all borders at once. - */ - FT_EXPORT( void ) - FT_Stroker_ExportBorder( FT_Stroker stroker, - FT_StrokerBorder border, - FT_Outline* outline ); - - - /************************************************************** - * - * @function: - * FT_Stroker_GetCounts - * - * @description: - * Call this function once you have finished parsing your paths - * with the stroker. It returns the number of points and - * contours necessary to export all points/borders from the stroked - * outline/path. - * - * @input: - * stroker :: - * The target stroker handle. - * - * @output: - * anum_points :: - * The number of points. - * - * anum_contours :: - * The number of contours. - * - * @return: - * FreeType error code. 0~means success. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_GetCounts( FT_Stroker stroker, - FT_UInt *anum_points, - FT_UInt *anum_contours ); - - - /************************************************************** - * - * @function: - * FT_Stroker_Export - * - * @description: - * Call this function after @FT_Stroker_GetBorderCounts to - * export all borders to your own @FT_Outline structure. - * - * Note that this function appends the border points and - * contours to your outline, but does not try to resize its - * arrays. - * - * @input: - * stroker :: - * The target stroker handle. - * - * outline :: - * The target outline handle. - */ - FT_EXPORT( void ) - FT_Stroker_Export( FT_Stroker stroker, - FT_Outline* outline ); - - - /************************************************************** - * - * @function: - * FT_Stroker_Done - * - * @description: - * Destroy a stroker object. - * - * @input: - * stroker :: - * A stroker handle. Can be NULL. - */ - FT_EXPORT( void ) - FT_Stroker_Done( FT_Stroker stroker ); - - - /************************************************************** - * - * @function: - * FT_Glyph_Stroke - * - * @description: - * Stroke a given outline glyph object with a given stroker. - * - * @inout: - * pglyph :: - * Source glyph handle on input, new glyph handle on output. - * - * @input: - * stroker :: - * A stroker handle. - * - * destroy :: - * A Boolean. If~1, the source glyph object is destroyed - * on success. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source glyph is untouched in case of error. - * - * Adding stroke may yield a significantly wider and taller glyph - * depending on how large of a radius was used to stroke the glyph. You - * may need to manually adjust horizontal and vertical advance amounts - * to account for this added size. - */ - FT_EXPORT( FT_Error ) - FT_Glyph_Stroke( FT_Glyph *pglyph, - FT_Stroker stroker, - FT_Bool destroy ); - - - /************************************************************** - * - * @function: - * FT_Glyph_StrokeBorder - * - * @description: - * Stroke a given outline glyph object with a given stroker, but - * only return either its inside or outside border. - * - * @inout: - * pglyph :: - * Source glyph handle on input, new glyph handle on output. - * - * @input: - * stroker :: - * A stroker handle. - * - * inside :: - * A Boolean. If~1, return the inside border, otherwise - * the outside border. - * - * destroy :: - * A Boolean. If~1, the source glyph object is destroyed - * on success. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source glyph is untouched in case of error. - * - * Adding stroke may yield a significantly wider and taller glyph - * depending on how large of a radius was used to stroke the glyph. You - * may need to manually adjust horizontal and vertical advance amounts - * to account for this added size. - */ - FT_EXPORT( FT_Error ) - FT_Glyph_StrokeBorder( FT_Glyph *pglyph, - FT_Stroker stroker, - FT_Bool inside, - FT_Bool destroy ); - - /* */ - -FT_END_HEADER - -#endif /* __FT_STROKE_H__ */ - - -/* END */ - - -/* Local Variables: */ -/* coding: utf-8 */ -/* End: */ diff --git a/thirdparty/include/freetype/ftsynth.h b/thirdparty/include/freetype/ftsynth.h deleted file mode 100644 index 98b4c78ff..000000000 --- a/thirdparty/include/freetype/ftsynth.h +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftsynth.h */ -/* */ -/* FreeType synthesizing code for emboldening and slanting */ -/* (specification). */ -/* */ -/* Copyright 2000-2001, 2003, 2006, 2008, 2012, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********* *********/ - /********* WARNING, THIS IS ALPHA CODE! THIS API *********/ - /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/ - /********* FREETYPE DEVELOPMENT TEAM *********/ - /********* *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* Main reason for not lifting the functions in this module to a */ - /* `standard' API is that the used parameters for emboldening and */ - /* slanting are not configurable. Consider the functions as a */ - /* code resource that should be copied into the application and */ - /* adapted to the particular needs. */ - - -#ifndef __FTSYNTH_H__ -#define __FTSYNTH_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /* Embolden a glyph by a `reasonable' value (which is highly a matter of */ - /* taste). This function is actually a convenience function, providing */ - /* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden. */ - /* */ - /* For emboldened outlines the height, width, and advance metrics are */ - /* increased by the strength of the emboldening. You can also call */ - /* @FT_Outline_Get_CBox to get precise values. */ - FT_EXPORT( void ) - FT_GlyphSlot_Embolden( FT_GlyphSlot slot ); - - /* Slant an outline glyph to the right by about 12 degrees. */ - FT_EXPORT( void ) - FT_GlyphSlot_Oblique( FT_GlyphSlot slot ); - - /* */ - -FT_END_HEADER - -#endif /* __FTSYNTH_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftsystem.h b/thirdparty/include/freetype/ftsystem.h deleted file mode 100644 index 545b399da..000000000 --- a/thirdparty/include/freetype/ftsystem.h +++ /dev/null @@ -1,347 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftsystem.h */ -/* */ -/* FreeType low-level system interface definition (specification). */ -/* */ -/* Copyright 1996-2001, 2002, 2005, 2010 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTSYSTEM_H__ -#define __FTSYSTEM_H__ - - -#include <freetype/ft2build.h> - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* system_interface */ - /* */ - /* <Title> */ - /* System Interface */ - /* */ - /* <Abstract> */ - /* How FreeType manages memory and i/o. */ - /* */ - /* <Description> */ - /* This section contains various definitions related to memory */ - /* management and i/o access. You need to understand this */ - /* information if you want to use a custom memory manager or you own */ - /* i/o streams. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* M E M O R Y M A N A G E M E N T */ - /* */ - /*************************************************************************/ - - - /************************************************************************* - * - * @type: - * FT_Memory - * - * @description: - * A handle to a given memory manager object, defined with an - * @FT_MemoryRec structure. - * - */ - typedef struct FT_MemoryRec_* FT_Memory; - - - /************************************************************************* - * - * @functype: - * FT_Alloc_Func - * - * @description: - * A function used to allocate `size' bytes from `memory'. - * - * @input: - * memory :: - * A handle to the source memory manager. - * - * size :: - * The size in bytes to allocate. - * - * @return: - * Address of new memory block. 0~in case of failure. - * - */ - typedef void* - (*FT_Alloc_Func)( FT_Memory memory, - long size ); - - - /************************************************************************* - * - * @functype: - * FT_Free_Func - * - * @description: - * A function used to release a given block of memory. - * - * @input: - * memory :: - * A handle to the source memory manager. - * - * block :: - * The address of the target memory block. - * - */ - typedef void - (*FT_Free_Func)( FT_Memory memory, - void* block ); - - - /************************************************************************* - * - * @functype: - * FT_Realloc_Func - * - * @description: - * A function used to re-allocate a given block of memory. - * - * @input: - * memory :: - * A handle to the source memory manager. - * - * cur_size :: - * The block's current size in bytes. - * - * new_size :: - * The block's requested new size. - * - * block :: - * The block's current address. - * - * @return: - * New block address. 0~in case of memory shortage. - * - * @note: - * In case of error, the old block must still be available. - * - */ - typedef void* - (*FT_Realloc_Func)( FT_Memory memory, - long cur_size, - long new_size, - void* block ); - - - /************************************************************************* - * - * @struct: - * FT_MemoryRec - * - * @description: - * A structure used to describe a given memory manager to FreeType~2. - * - * @fields: - * user :: - * A generic typeless pointer for user data. - * - * alloc :: - * A pointer type to an allocation function. - * - * free :: - * A pointer type to an memory freeing function. - * - * realloc :: - * A pointer type to a reallocation function. - * - */ - struct FT_MemoryRec_ - { - void* user; - FT_Alloc_Func alloc; - FT_Free_Func free; - FT_Realloc_Func realloc; - }; - - - /*************************************************************************/ - /* */ - /* I / O M A N A G E M E N T */ - /* */ - /*************************************************************************/ - - - /************************************************************************* - * - * @type: - * FT_Stream - * - * @description: - * A handle to an input stream. - * - */ - typedef struct FT_StreamRec_* FT_Stream; - - - /************************************************************************* - * - * @struct: - * FT_StreamDesc - * - * @description: - * A union type used to store either a long or a pointer. This is used - * to store a file descriptor or a `FILE*' in an input stream. - * - */ - typedef union FT_StreamDesc_ - { - long value; - void* pointer; - - } FT_StreamDesc; - - - /************************************************************************* - * - * @functype: - * FT_Stream_IoFunc - * - * @description: - * A function used to seek and read data from a given input stream. - * - * @input: - * stream :: - * A handle to the source stream. - * - * offset :: - * The offset of read in stream (always from start). - * - * buffer :: - * The address of the read buffer. - * - * count :: - * The number of bytes to read from the stream. - * - * @return: - * The number of bytes effectively read by the stream. - * - * @note: - * This function might be called to perform a seek or skip operation - * with a `count' of~0. A non-zero return value then indicates an - * error. - * - */ - typedef unsigned long - (*FT_Stream_IoFunc)( FT_Stream stream, - unsigned long offset, - unsigned char* buffer, - unsigned long count ); - - - /************************************************************************* - * - * @functype: - * FT_Stream_CloseFunc - * - * @description: - * A function used to close a given input stream. - * - * @input: - * stream :: - * A handle to the target stream. - * - */ - typedef void - (*FT_Stream_CloseFunc)( FT_Stream stream ); - - - /************************************************************************* - * - * @struct: - * FT_StreamRec - * - * @description: - * A structure used to describe an input stream. - * - * @input: - * base :: - * For memory-based streams, this is the address of the first stream - * byte in memory. This field should always be set to NULL for - * disk-based streams. - * - * size :: - * The stream size in bytes. - * - * pos :: - * The current position within the stream. - * - * descriptor :: - * This field is a union that can hold an integer or a pointer. It is - * used by stream implementations to store file descriptors or `FILE*' - * pointers. - * - * pathname :: - * This field is completely ignored by FreeType. However, it is often - * useful during debugging to use it to store the stream's filename - * (where available). - * - * read :: - * The stream's input function. - * - * close :: - * The stream's close function. - * - * memory :: - * The memory manager to use to preload frames. This is set - * internally by FreeType and shouldn't be touched by stream - * implementations. - * - * cursor :: - * This field is set and used internally by FreeType when parsing - * frames. - * - * limit :: - * This field is set and used internally by FreeType when parsing - * frames. - * - */ - typedef struct FT_StreamRec_ - { - unsigned char* base; - unsigned long size; - unsigned long pos; - - FT_StreamDesc descriptor; - FT_StreamDesc pathname; - FT_Stream_IoFunc read; - FT_Stream_CloseFunc close; - - FT_Memory memory; - unsigned char* cursor; - unsigned char* limit; - - } FT_StreamRec; - - - /* */ - - -FT_END_HEADER - -#endif /* __FTSYSTEM_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/fttrigon.h b/thirdparty/include/freetype/fttrigon.h deleted file mode 100644 index 65143cb8c..000000000 --- a/thirdparty/include/freetype/fttrigon.h +++ /dev/null @@ -1,350 +0,0 @@ -/***************************************************************************/ -/* */ -/* fttrigon.h */ -/* */ -/* FreeType trigonometric functions (specification). */ -/* */ -/* Copyright 2001, 2003, 2005, 2007, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTTRIGON_H__ -#define __FTTRIGON_H__ - -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* computations */ - /* */ - /*************************************************************************/ - - - /************************************************************************* - * - * @type: - * FT_Angle - * - * @description: - * This type is used to model angle values in FreeType. Note that the - * angle is a 16.16 fixed-point value expressed in degrees. - * - */ - typedef FT_Fixed FT_Angle; - - - /************************************************************************* - * - * @macro: - * FT_ANGLE_PI - * - * @description: - * The angle pi expressed in @FT_Angle units. - * - */ -#define FT_ANGLE_PI ( 180L << 16 ) - - - /************************************************************************* - * - * @macro: - * FT_ANGLE_2PI - * - * @description: - * The angle 2*pi expressed in @FT_Angle units. - * - */ -#define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 ) - - - /************************************************************************* - * - * @macro: - * FT_ANGLE_PI2 - * - * @description: - * The angle pi/2 expressed in @FT_Angle units. - * - */ -#define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 ) - - - /************************************************************************* - * - * @macro: - * FT_ANGLE_PI4 - * - * @description: - * The angle pi/4 expressed in @FT_Angle units. - * - */ -#define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 ) - - - /************************************************************************* - * - * @function: - * FT_Sin - * - * @description: - * Return the sinus of a given angle in fixed-point format. - * - * @input: - * angle :: - * The input angle. - * - * @return: - * The sinus value. - * - * @note: - * If you need both the sinus and cosinus for a given angle, use the - * function @FT_Vector_Unit. - * - */ - FT_EXPORT( FT_Fixed ) - FT_Sin( FT_Angle angle ); - - - /************************************************************************* - * - * @function: - * FT_Cos - * - * @description: - * Return the cosinus of a given angle in fixed-point format. - * - * @input: - * angle :: - * The input angle. - * - * @return: - * The cosinus value. - * - * @note: - * If you need both the sinus and cosinus for a given angle, use the - * function @FT_Vector_Unit. - * - */ - FT_EXPORT( FT_Fixed ) - FT_Cos( FT_Angle angle ); - - - /************************************************************************* - * - * @function: - * FT_Tan - * - * @description: - * Return the tangent of a given angle in fixed-point format. - * - * @input: - * angle :: - * The input angle. - * - * @return: - * The tangent value. - * - */ - FT_EXPORT( FT_Fixed ) - FT_Tan( FT_Angle angle ); - - - /************************************************************************* - * - * @function: - * FT_Atan2 - * - * @description: - * Return the arc-tangent corresponding to a given vector (x,y) in - * the 2d plane. - * - * @input: - * x :: - * The horizontal vector coordinate. - * - * y :: - * The vertical vector coordinate. - * - * @return: - * The arc-tangent value (i.e. angle). - * - */ - FT_EXPORT( FT_Angle ) - FT_Atan2( FT_Fixed x, - FT_Fixed y ); - - - /************************************************************************* - * - * @function: - * FT_Angle_Diff - * - * @description: - * Return the difference between two angles. The result is always - * constrained to the ]-PI..PI] interval. - * - * @input: - * angle1 :: - * First angle. - * - * angle2 :: - * Second angle. - * - * @return: - * Constrained value of `value2-value1'. - * - */ - FT_EXPORT( FT_Angle ) - FT_Angle_Diff( FT_Angle angle1, - FT_Angle angle2 ); - - - /************************************************************************* - * - * @function: - * FT_Vector_Unit - * - * @description: - * Return the unit vector corresponding to a given angle. After the - * call, the value of `vec.x' will be `sin(angle)', and the value of - * `vec.y' will be `cos(angle)'. - * - * This function is useful to retrieve both the sinus and cosinus of a - * given angle quickly. - * - * @output: - * vec :: - * The address of target vector. - * - * @input: - * angle :: - * The address of angle. - * - */ - FT_EXPORT( void ) - FT_Vector_Unit( FT_Vector* vec, - FT_Angle angle ); - - - /************************************************************************* - * - * @function: - * FT_Vector_Rotate - * - * @description: - * Rotate a vector by a given angle. - * - * @inout: - * vec :: - * The address of target vector. - * - * @input: - * angle :: - * The address of angle. - * - */ - FT_EXPORT( void ) - FT_Vector_Rotate( FT_Vector* vec, - FT_Angle angle ); - - - /************************************************************************* - * - * @function: - * FT_Vector_Length - * - * @description: - * Return the length of a given vector. - * - * @input: - * vec :: - * The address of target vector. - * - * @return: - * The vector length, expressed in the same units that the original - * vector coordinates. - * - */ - FT_EXPORT( FT_Fixed ) - FT_Vector_Length( FT_Vector* vec ); - - - /************************************************************************* - * - * @function: - * FT_Vector_Polarize - * - * @description: - * Compute both the length and angle of a given vector. - * - * @input: - * vec :: - * The address of source vector. - * - * @output: - * length :: - * The vector length. - * - * angle :: - * The vector angle. - * - */ - FT_EXPORT( void ) - FT_Vector_Polarize( FT_Vector* vec, - FT_Fixed *length, - FT_Angle *angle ); - - - /************************************************************************* - * - * @function: - * FT_Vector_From_Polar - * - * @description: - * Compute vector coordinates from a length and angle. - * - * @output: - * vec :: - * The address of source vector. - * - * @input: - * length :: - * The vector length. - * - * angle :: - * The vector angle. - * - */ - FT_EXPORT( void ) - FT_Vector_From_Polar( FT_Vector* vec, - FT_Fixed length, - FT_Angle angle ); - - /* */ - - -FT_END_HEADER - -#endif /* __FTTRIGON_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftttdrv.h b/thirdparty/include/freetype/ftttdrv.h deleted file mode 100644 index 0129585c6..000000000 --- a/thirdparty/include/freetype/ftttdrv.h +++ /dev/null @@ -1,170 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftttdrv.h */ -/* */ -/* FreeType API for controlling the TrueType driver */ -/* (specification only). */ -/* */ -/* Copyright 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTTTDRV_H__ -#define __FTTTDRV_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /************************************************************************** - * - * @section: - * tt_driver - * - * @title: - * The TrueType driver - * - * @abstract: - * Controlling the TrueType driver module. - * - * @description: - * While FreeType's TrueType driver doesn't expose API functions by - * itself, it is possible to control its behaviour with @FT_Property_Set - * and @FT_Property_Get. The following lists the available properties - * together with the necessary macros and structures. - * - * The TrueType driver's module name is `truetype'. - * - */ - - - /************************************************************************** - * - * @property: - * interpreter-version - * - * @description: - * Currently, two versions are available, representing the bytecode - * interpreter with and without subpixel hinting support, - * respectively. The default is subpixel support if - * TT_CONFIG_OPTION_SUBPIXEL_HINTING is defined, and no subpixel - * support otherwise (since it isn't available then). - * - * If subpixel hinting is on, many TrueType bytecode instructions - * behave differently compared to B/W or grayscale rendering. The - * main idea is to render at a much increased horizontal resolution, - * then sampling down the created output to subpixel precision. - * However, many older fonts are not suited to this and must be - * specially taken care of by applying (hardcoded) font-specific - * tweaks. - * - * Details on subpixel hinting and some of the necessary tweaks can be - * found in Greg Hitchcock's whitepaper at - * `http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'. - * - * The following example code demonstrates how to activate subpixel - * hinting (omitting the error handling). - * - * { - * FT_Library library; - * FT_Face face; - * FT_UInt interpreter_version = TT_INTERPRETER_VERSION_38; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "truetype", - * "interpreter-version", - * &interpreter_version ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - */ - - - /************************************************************************** - * - * @enum: - * TT_INTERPRETER_VERSION_XXX - * - * @description: - * A list of constants used for the @interpreter-version property to - * select the hinting engine for Truetype fonts. - * - * The numeric value in the constant names represents the version - * number as returned by the `GETINFO' bytecode instruction. - * - * @values: - * TT_INTERPRETER_VERSION_35 :: - * Version~35 corresponds to MS rasterizer v.1.7 as used e.g. in - * Windows~98; only grayscale and B/W rasterizing is supported. - * - * TT_INTERPRETER_VERSION_38 :: - * Version~38 corresponds to MS rasterizer v.1.9; it is roughly - * equivalent to the hinting provided by DirectWrite ClearType (as - * can be found, for example, in the Internet Explorer~9 running on - * Windows~7). - * - * @note: - * This property controls the behaviour of the bytecode interpreter - * and thus how outlines get hinted. It does *not* control how glyph - * get rasterized! In particular, it does not control subpixel color - * filtering. - * - * If FreeType has not been compiled with configuration option - * FT_CONFIG_OPTION_SUBPIXEL_HINTING, selecting version~38 causes an - * `FT_Err_Unimplemented_Feature' error. - * - * Depending on the graphics framework, Microsoft uses different - * bytecode engines. As a consequence, the version numbers returned by - * a call to the `GETINFO[1]' bytecode instruction are more convoluted - * than desired. - * - * { - * framework Windows version result of GETINFO[1] - * ---------------------------------------------------- - * GDI before XP 35 - * GDI XP and later 37 - * GDI+ old before Vista 37 - * GDI+ old Vista, 7 38 - * GDI+ after 7 40 - * DWrite before 8 39 - * DWrite 8 and later 40 - * } - * - * Since FreeType doesn't provide all capabilities of DWrite ClearType, - * using version~38 seems justified. - * - */ -#define TT_INTERPRETER_VERSION_35 35 -#define TT_INTERPRETER_VERSION_38 38 - - - /* */ - -FT_END_HEADER - - -#endif /* __FTTTDRV_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/fttypes.h b/thirdparty/include/freetype/fttypes.h deleted file mode 100644 index b66bc0367..000000000 --- a/thirdparty/include/freetype/fttypes.h +++ /dev/null @@ -1,598 +0,0 @@ -/***************************************************************************/ -/* */ -/* fttypes.h */ -/* */ -/* FreeType simple types definitions (specification only). */ -/* */ -/* Copyright 1996-2002, 2004, 2006-2009, 2012, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTTYPES_H__ -#define __FTTYPES_H__ - - -#include <freetype/ft2build.h> -#include FT_CONFIG_CONFIG_H -#include FT_SYSTEM_H -#include FT_IMAGE_H - -#include <stddef.h> - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* basic_types */ - /* */ - /* <Title> */ - /* Basic Data Types */ - /* */ - /* <Abstract> */ - /* The basic data types defined by the library. */ - /* */ - /* <Description> */ - /* This section contains the basic data types defined by FreeType~2, */ - /* ranging from simple scalar types to bitmap descriptors. More */ - /* font-specific structures are defined in a different section. */ - /* */ - /* <Order> */ - /* FT_Byte */ - /* FT_Bytes */ - /* FT_Char */ - /* FT_Int */ - /* FT_UInt */ - /* FT_Int16 */ - /* FT_UInt16 */ - /* FT_Int32 */ - /* FT_UInt32 */ - /* FT_Short */ - /* FT_UShort */ - /* FT_Long */ - /* FT_ULong */ - /* FT_Bool */ - /* FT_Offset */ - /* FT_PtrDist */ - /* FT_String */ - /* FT_Tag */ - /* FT_Error */ - /* FT_Fixed */ - /* FT_Pointer */ - /* FT_Pos */ - /* FT_Vector */ - /* FT_BBox */ - /* FT_Matrix */ - /* FT_FWord */ - /* FT_UFWord */ - /* FT_F2Dot14 */ - /* FT_UnitVector */ - /* FT_F26Dot6 */ - /* */ - /* */ - /* FT_Generic */ - /* FT_Generic_Finalizer */ - /* */ - /* FT_Bitmap */ - /* FT_Pixel_Mode */ - /* FT_Palette_Mode */ - /* FT_Glyph_Format */ - /* FT_IMAGE_TAG */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Bool */ - /* */ - /* <Description> */ - /* A typedef of unsigned char, used for simple booleans. As usual, */ - /* values 1 and~0 represent true and false, respectively. */ - /* */ - typedef unsigned char FT_Bool; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_FWord */ - /* */ - /* <Description> */ - /* A signed 16-bit integer used to store a distance in original font */ - /* units. */ - /* */ - typedef signed short FT_FWord; /* distance in FUnits */ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UFWord */ - /* */ - /* <Description> */ - /* An unsigned 16-bit integer used to store a distance in original */ - /* font units. */ - /* */ - typedef unsigned short FT_UFWord; /* unsigned distance */ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Char */ - /* */ - /* <Description> */ - /* A simple typedef for the _signed_ char type. */ - /* */ - typedef signed char FT_Char; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Byte */ - /* */ - /* <Description> */ - /* A simple typedef for the _unsigned_ char type. */ - /* */ - typedef unsigned char FT_Byte; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Bytes */ - /* */ - /* <Description> */ - /* A typedef for constant memory areas. */ - /* */ - typedef const FT_Byte* FT_Bytes; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Tag */ - /* */ - /* <Description> */ - /* A typedef for 32-bit tags (as used in the SFNT format). */ - /* */ - typedef FT_UInt32 FT_Tag; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_String */ - /* */ - /* <Description> */ - /* A simple typedef for the char type, usually used for strings. */ - /* */ - typedef char FT_String; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Short */ - /* */ - /* <Description> */ - /* A typedef for signed short. */ - /* */ - typedef signed short FT_Short; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UShort */ - /* */ - /* <Description> */ - /* A typedef for unsigned short. */ - /* */ - typedef unsigned short FT_UShort; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Int */ - /* */ - /* <Description> */ - /* A typedef for the int type. */ - /* */ - typedef signed int FT_Int; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UInt */ - /* */ - /* <Description> */ - /* A typedef for the unsigned int type. */ - /* */ - typedef unsigned int FT_UInt; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Long */ - /* */ - /* <Description> */ - /* A typedef for signed long. */ - /* */ - typedef signed long FT_Long; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_ULong */ - /* */ - /* <Description> */ - /* A typedef for unsigned long. */ - /* */ - typedef unsigned long FT_ULong; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_F2Dot14 */ - /* */ - /* <Description> */ - /* A signed 2.14 fixed-point type used for unit vectors. */ - /* */ - typedef signed short FT_F2Dot14; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_F26Dot6 */ - /* */ - /* <Description> */ - /* A signed 26.6 fixed-point type used for vectorial pixel */ - /* coordinates. */ - /* */ - typedef signed long FT_F26Dot6; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Fixed */ - /* */ - /* <Description> */ - /* This type is used to store 16.16 fixed-point values, like scaling */ - /* values or matrix coefficients. */ - /* */ - typedef signed long FT_Fixed; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Error */ - /* */ - /* <Description> */ - /* The FreeType error code type. A value of~0 is always interpreted */ - /* as a successful operation. */ - /* */ - typedef int FT_Error; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Pointer */ - /* */ - /* <Description> */ - /* A simple typedef for a typeless pointer. */ - /* */ - typedef void* FT_Pointer; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Offset */ - /* */ - /* <Description> */ - /* This is equivalent to the ANSI~C `size_t' type, i.e., the largest */ - /* _unsigned_ integer type used to express a file size or position, */ - /* or a memory block size. */ - /* */ - typedef size_t FT_Offset; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_PtrDist */ - /* */ - /* <Description> */ - /* This is equivalent to the ANSI~C `ptrdiff_t' type, i.e., the */ - /* largest _signed_ integer type used to express the distance */ - /* between two pointers. */ - /* */ - typedef ft_ptrdiff_t FT_PtrDist; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_UnitVector */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2D vector unit vector. Uses */ - /* FT_F2Dot14 types. */ - /* */ - /* <Fields> */ - /* x :: Horizontal coordinate. */ - /* */ - /* y :: Vertical coordinate. */ - /* */ - typedef struct FT_UnitVector_ - { - FT_F2Dot14 x; - FT_F2Dot14 y; - - } FT_UnitVector; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Matrix */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2x2 matrix. Coefficients are */ - /* in 16.16 fixed-point format. The computation performed is: */ - /* */ - /* { */ - /* x' = x*xx + y*xy */ - /* y' = x*yx + y*yy */ - /* } */ - /* */ - /* <Fields> */ - /* xx :: Matrix coefficient. */ - /* */ - /* xy :: Matrix coefficient. */ - /* */ - /* yx :: Matrix coefficient. */ - /* */ - /* yy :: Matrix coefficient. */ - /* */ - typedef struct FT_Matrix_ - { - FT_Fixed xx, xy; - FT_Fixed yx, yy; - - } FT_Matrix; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Data */ - /* */ - /* <Description> */ - /* Read-only binary data represented as a pointer and a length. */ - /* */ - /* <Fields> */ - /* pointer :: The data. */ - /* */ - /* length :: The length of the data in bytes. */ - /* */ - typedef struct FT_Data_ - { - const FT_Byte* pointer; - FT_Int length; - - } FT_Data; - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Generic_Finalizer */ - /* */ - /* <Description> */ - /* Describe a function used to destroy the `client' data of any */ - /* FreeType object. See the description of the @FT_Generic type for */ - /* details of usage. */ - /* */ - /* <Input> */ - /* The address of the FreeType object that is under finalization. */ - /* Its client data is accessed through its `generic' field. */ - /* */ - typedef void (*FT_Generic_Finalizer)(void* object); - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Generic */ - /* */ - /* <Description> */ - /* Client applications often need to associate their own data to a */ - /* variety of FreeType core objects. For example, a text layout API */ - /* might want to associate a glyph cache to a given size object. */ - /* */ - /* Some FreeType object contains a `generic' field, of type */ - /* FT_Generic, which usage is left to client applications and font */ - /* servers. */ - /* */ - /* It can be used to store a pointer to client-specific data, as well */ - /* as the address of a `finalizer' function, which will be called by */ - /* FreeType when the object is destroyed (for example, the previous */ - /* client example would put the address of the glyph cache destructor */ - /* in the `finalizer' field). */ - /* */ - /* <Fields> */ - /* data :: A typeless pointer to any client-specified data. This */ - /* field is completely ignored by the FreeType library. */ - /* */ - /* finalizer :: A pointer to a `generic finalizer' function, which */ - /* will be called when the object is destroyed. If this */ - /* field is set to NULL, no code will be called. */ - /* */ - typedef struct FT_Generic_ - { - void* data; - FT_Generic_Finalizer finalizer; - - } FT_Generic; - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_MAKE_TAG */ - /* */ - /* <Description> */ - /* This macro converts four-letter tags that are used to label */ - /* TrueType tables into an unsigned long, to be used within FreeType. */ - /* */ - /* <Note> */ - /* The produced values *must* be 32-bit integers. Don't redefine */ - /* this macro. */ - /* */ -#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ - (FT_Tag) \ - ( ( (FT_ULong)_x1 << 24 ) | \ - ( (FT_ULong)_x2 << 16 ) | \ - ( (FT_ULong)_x3 << 8 ) | \ - (FT_ULong)_x4 ) - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* L I S T M A N A G E M E N T */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* list_processing */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_ListNode */ - /* */ - /* <Description> */ - /* Many elements and objects in FreeType are listed through an */ - /* @FT_List record (see @FT_ListRec). As its name suggests, an */ - /* FT_ListNode is a handle to a single list element. */ - /* */ - typedef struct FT_ListNodeRec_* FT_ListNode; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_List */ - /* */ - /* <Description> */ - /* A handle to a list record (see @FT_ListRec). */ - /* */ - typedef struct FT_ListRec_* FT_List; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ListNodeRec */ - /* */ - /* <Description> */ - /* A structure used to hold a single list element. */ - /* */ - /* <Fields> */ - /* prev :: The previous element in the list. NULL if first. */ - /* */ - /* next :: The next element in the list. NULL if last. */ - /* */ - /* data :: A typeless pointer to the listed object. */ - /* */ - typedef struct FT_ListNodeRec_ - { - FT_ListNode prev; - FT_ListNode next; - void* data; - - } FT_ListNodeRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ListRec */ - /* */ - /* <Description> */ - /* A structure used to hold a simple doubly-linked list. These are */ - /* used in many parts of FreeType. */ - /* */ - /* <Fields> */ - /* head :: The head (first element) of doubly-linked list. */ - /* */ - /* tail :: The tail (last element) of doubly-linked list. */ - /* */ - typedef struct FT_ListRec_ - { - FT_ListNode head; - FT_ListNode tail; - - } FT_ListRec; - - - /* */ - -#define FT_IS_EMPTY( list ) ( (list).head == 0 ) -#define FT_BOOL( x ) ( (FT_Bool)( x ) ) - - /* concatenate C tokens */ -#define FT_ERR_XCAT( x, y ) x ## y -#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) - - /* see `ftmoderr.h' for descriptions of the following macros */ - -#define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) - -#define FT_ERROR_BASE( x ) ( (x) & 0xFF ) -#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U ) - -#define FT_ERR_EQ( x, e ) \ - ( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) ) -#define FT_ERR_NEQ( x, e ) \ - ( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) ) - - -FT_END_HEADER - -#endif /* __FTTYPES_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ftwinfnt.h b/thirdparty/include/freetype/ftwinfnt.h deleted file mode 100644 index 243637caa..000000000 --- a/thirdparty/include/freetype/ftwinfnt.h +++ /dev/null @@ -1,275 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftwinfnt.h */ -/* */ -/* FreeType API for accessing Windows fnt-specific data. */ -/* */ -/* Copyright 2003, 2004, 2008 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTWINFNT_H__ -#define __FTWINFNT_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* winfnt_fonts */ - /* */ - /* <Title> */ - /* Window FNT Files */ - /* */ - /* <Abstract> */ - /* Windows FNT specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of Windows FNT specific */ - /* functions. */ - /* */ - /*************************************************************************/ - - - /************************************************************************* - * - * @enum: - * FT_WinFNT_ID_XXX - * - * @description: - * A list of valid values for the `charset' byte in - * @FT_WinFNT_HeaderRec. Exact mapping tables for the various cpXXXX - * encodings (except for cp1361) can be found at - * ftp://ftp.unicode.org/public in the MAPPINGS/VENDORS/MICSFT/WINDOWS - * subdirectory. cp1361 is roughly a superset of - * MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT. - * - * @values: - * FT_WinFNT_ID_DEFAULT :: - * This is used for font enumeration and font creation as a - * `don't care' value. Valid font files don't contain this value. - * When querying for information about the character set of the font - * that is currently selected into a specified device context, this - * return value (of the related Windows API) simply denotes failure. - * - * FT_WinFNT_ID_SYMBOL :: - * There is no known mapping table available. - * - * FT_WinFNT_ID_MAC :: - * Mac Roman encoding. - * - * FT_WinFNT_ID_OEM :: - * From Michael Pöttgen <michael@poettgen.de>: - * - * The `Windows Font Mapping' article says that FT_WinFNT_ID_OEM - * is used for the charset of vector fonts, like `modern.fon', - * `roman.fon', and `script.fon' on Windows. - * - * The `CreateFont' documentation says: The FT_WinFNT_ID_OEM value - * specifies a character set that is operating-system dependent. - * - * The `IFIMETRICS' documentation from the `Windows Driver - * Development Kit' says: This font supports an OEM-specific - * character set. The OEM character set is system dependent. - * - * In general OEM, as opposed to ANSI (i.e., cp1252), denotes the - * second default codepage that most international versions of - * Windows have. It is one of the OEM codepages from - * - * http://www.microsoft.com/globaldev/reference/cphome.mspx, - * - * and is used for the `DOS boxes', to support legacy applications. - * A German Windows version for example usually uses ANSI codepage - * 1252 and OEM codepage 850. - * - * FT_WinFNT_ID_CP874 :: - * A superset of Thai TIS 620 and ISO 8859-11. - * - * FT_WinFNT_ID_CP932 :: - * A superset of Japanese Shift-JIS (with minor deviations). - * - * FT_WinFNT_ID_CP936 :: - * A superset of simplified Chinese GB 2312-1980 (with different - * ordering and minor deviations). - * - * FT_WinFNT_ID_CP949 :: - * A superset of Korean Hangul KS~C 5601-1987 (with different - * ordering and minor deviations). - * - * FT_WinFNT_ID_CP950 :: - * A superset of traditional Chinese Big~5 ETen (with different - * ordering and minor deviations). - * - * FT_WinFNT_ID_CP1250 :: - * A superset of East European ISO 8859-2 (with slightly different - * ordering). - * - * FT_WinFNT_ID_CP1251 :: - * A superset of Russian ISO 8859-5 (with different ordering). - * - * FT_WinFNT_ID_CP1252 :: - * ANSI encoding. A superset of ISO 8859-1. - * - * FT_WinFNT_ID_CP1253 :: - * A superset of Greek ISO 8859-7 (with minor modifications). - * - * FT_WinFNT_ID_CP1254 :: - * A superset of Turkish ISO 8859-9. - * - * FT_WinFNT_ID_CP1255 :: - * A superset of Hebrew ISO 8859-8 (with some modifications). - * - * FT_WinFNT_ID_CP1256 :: - * A superset of Arabic ISO 8859-6 (with different ordering). - * - * FT_WinFNT_ID_CP1257 :: - * A superset of Baltic ISO 8859-13 (with some deviations). - * - * FT_WinFNT_ID_CP1258 :: - * For Vietnamese. This encoding doesn't cover all necessary - * characters. - * - * FT_WinFNT_ID_CP1361 :: - * Korean (Johab). - */ - -#define FT_WinFNT_ID_CP1252 0 -#define FT_WinFNT_ID_DEFAULT 1 -#define FT_WinFNT_ID_SYMBOL 2 -#define FT_WinFNT_ID_MAC 77 -#define FT_WinFNT_ID_CP932 128 -#define FT_WinFNT_ID_CP949 129 -#define FT_WinFNT_ID_CP1361 130 -#define FT_WinFNT_ID_CP936 134 -#define FT_WinFNT_ID_CP950 136 -#define FT_WinFNT_ID_CP1253 161 -#define FT_WinFNT_ID_CP1254 162 -#define FT_WinFNT_ID_CP1258 163 -#define FT_WinFNT_ID_CP1255 177 -#define FT_WinFNT_ID_CP1256 178 -#define FT_WinFNT_ID_CP1257 186 -#define FT_WinFNT_ID_CP1251 204 -#define FT_WinFNT_ID_CP874 222 -#define FT_WinFNT_ID_CP1250 238 -#define FT_WinFNT_ID_OEM 255 - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_WinFNT_HeaderRec */ - /* */ - /* <Description> */ - /* Windows FNT Header info. */ - /* */ - typedef struct FT_WinFNT_HeaderRec_ - { - FT_UShort version; - FT_ULong file_size; - FT_Byte copyright[60]; - FT_UShort file_type; - FT_UShort nominal_point_size; - FT_UShort vertical_resolution; - FT_UShort horizontal_resolution; - FT_UShort ascent; - FT_UShort internal_leading; - FT_UShort external_leading; - FT_Byte italic; - FT_Byte underline; - FT_Byte strike_out; - FT_UShort weight; - FT_Byte charset; - FT_UShort pixel_width; - FT_UShort pixel_height; - FT_Byte pitch_and_family; - FT_UShort avg_width; - FT_UShort max_width; - FT_Byte first_char; - FT_Byte last_char; - FT_Byte default_char; - FT_Byte break_char; - FT_UShort bytes_per_row; - FT_ULong device_offset; - FT_ULong face_name_offset; - FT_ULong bits_pointer; - FT_ULong bits_offset; - FT_Byte reserved; - FT_ULong flags; - FT_UShort A_space; - FT_UShort B_space; - FT_UShort C_space; - FT_UShort color_table_offset; - FT_ULong reserved1[4]; - - } FT_WinFNT_HeaderRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_WinFNT_Header */ - /* */ - /* <Description> */ - /* A handle to an @FT_WinFNT_HeaderRec structure. */ - /* */ - typedef struct FT_WinFNT_HeaderRec_* FT_WinFNT_Header; - - - /********************************************************************** - * - * @function: - * FT_Get_WinFNT_Header - * - * @description: - * Retrieve a Windows FNT font info header. - * - * @input: - * face :: A handle to the input face. - * - * @output: - * aheader :: The WinFNT header. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with Windows FNT faces, returning an error - * otherwise. - */ - FT_EXPORT( FT_Error ) - FT_Get_WinFNT_Header( FT_Face face, - FT_WinFNT_HeaderRec *aheader ); - - - /* */ - -FT_END_HEADER - -#endif /* __FTWINFNT_H__ */ - - -/* END */ - - -/* Local Variables: */ -/* coding: utf-8 */ -/* End: */ diff --git a/thirdparty/include/freetype/ftxf86.h b/thirdparty/include/freetype/ftxf86.h deleted file mode 100644 index e7bb4dc4e..000000000 --- a/thirdparty/include/freetype/ftxf86.h +++ /dev/null @@ -1,83 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftxf86.h */ -/* */ -/* Support functions for X11. */ -/* */ -/* Copyright 2002-2004, 2006, 2007, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTXF86_H__ -#define __FTXF86_H__ - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* font_formats */ - /* */ - /* <Title> */ - /* Font Formats */ - /* */ - /* <Abstract> */ - /* Getting the font format. */ - /* */ - /* <Description> */ - /* The single function in this section can be used to get the font */ - /* format. Note that this information is not needed normally; */ - /* however, there are special cases (like in PDF devices) where it is */ - /* important to differentiate, in spite of FreeType's uniform API. */ - /* */ - /* This function is in the X11/xf86 namespace for historical reasons */ - /* and in no way depends on that windowing system. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_X11_Font_Format */ - /* */ - /* <Description> */ - /* Return a string describing the format of a given face, using values */ - /* that can be used as an X11 FONT_PROPERTY. Possible values are */ - /* `TrueType', `Type~1', `BDF', `PCF', `Type~42', `CID~Type~1', `CFF', */ - /* `PFR', and `Windows~FNT'. */ - /* */ - /* <Input> */ - /* face :: */ - /* Input face handle. */ - /* */ - /* <Return> */ - /* Font format string. NULL in case of error. */ - /* */ - FT_EXPORT( const char* ) - FT_Get_X11_Font_Format( FT_Face face ); - - /* */ - -FT_END_HEADER - -#endif /* __FTXF86_H__ */ diff --git a/thirdparty/include/freetype/internal/autohint.h b/thirdparty/include/freetype/internal/autohint.h deleted file mode 100644 index 9075a7a3d..000000000 --- a/thirdparty/include/freetype/internal/autohint.h +++ /dev/null @@ -1,244 +0,0 @@ -/***************************************************************************/ -/* */ -/* autohint.h */ -/* */ -/* High-level `autohint' module-specific interface (specification). */ -/* */ -/* Copyright 1996-2002, 2007, 2009, 2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* The auto-hinter is used to load and automatically hint glyphs if a */ - /* format-specific hinter isn't available. */ - /* */ - /*************************************************************************/ - - -#ifndef __AUTOHINT_H__ -#define __AUTOHINT_H__ - - - /*************************************************************************/ - /* */ - /* A small technical note regarding automatic hinting in order to */ - /* clarify this module interface. */ - /* */ - /* An automatic hinter might compute two kinds of data for a given face: */ - /* */ - /* - global hints: Usually some metrics that describe global properties */ - /* of the face. It is computed by scanning more or less */ - /* aggressively the glyphs in the face, and thus can be */ - /* very slow to compute (even if the size of global */ - /* hints is really small). */ - /* */ - /* - glyph hints: These describe some important features of the glyph */ - /* outline, as well as how to align them. They are */ - /* generally much faster to compute than global hints. */ - /* */ - /* The current FreeType auto-hinter does a pretty good job while */ - /* performing fast computations for both global and glyph hints. */ - /* However, we might be interested in introducing more complex and */ - /* powerful algorithms in the future, like the one described in the John */ - /* D. Hobby paper, which unfortunately requires a lot more horsepower. */ - /* */ - /* Because a sufficiently sophisticated font management system would */ - /* typically implement an LRU cache of opened face objects to reduce */ - /* memory usage, it is a good idea to be able to avoid recomputing */ - /* global hints every time the same face is re-opened. */ - /* */ - /* We thus provide the ability to cache global hints outside of the face */ - /* object, in order to speed up font re-opening time. Of course, this */ - /* feature is purely optional, so most client programs won't even notice */ - /* it. */ - /* */ - /* I initially thought that it would be a good idea to cache the glyph */ - /* hints too. However, my general idea now is that if you really need */ - /* to cache these too, you are simply in need of a new font format, */ - /* where all this information could be stored within the font file and */ - /* decoded on the fly. */ - /* */ - /*************************************************************************/ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - - -FT_BEGIN_HEADER - - - typedef struct FT_AutoHinterRec_ *FT_AutoHinter; - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_AutoHinter_GlobalGetFunc */ - /* */ - /* <Description> */ - /* Retrieve the global hints computed for a given face object. The */ - /* resulting data is dissociated from the face and will survive a */ - /* call to FT_Done_Face(). It must be discarded through the API */ - /* FT_AutoHinter_GlobalDoneFunc(). */ - /* */ - /* <Input> */ - /* hinter :: A handle to the source auto-hinter. */ - /* */ - /* face :: A handle to the source face object. */ - /* */ - /* <Output> */ - /* global_hints :: A typeless pointer to the global hints. */ - /* */ - /* global_len :: The size in bytes of the global hints. */ - /* */ - typedef void - (*FT_AutoHinter_GlobalGetFunc)( FT_AutoHinter hinter, - FT_Face face, - void** global_hints, - long* global_len ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_AutoHinter_GlobalDoneFunc */ - /* */ - /* <Description> */ - /* Discard the global hints retrieved through */ - /* FT_AutoHinter_GlobalGetFunc(). This is the only way these hints */ - /* are freed from memory. */ - /* */ - /* <Input> */ - /* hinter :: A handle to the auto-hinter module. */ - /* */ - /* global :: A pointer to retrieved global hints to discard. */ - /* */ - typedef void - (*FT_AutoHinter_GlobalDoneFunc)( FT_AutoHinter hinter, - void* global ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_AutoHinter_GlobalResetFunc */ - /* */ - /* <Description> */ - /* This function is used to recompute the global metrics in a given */ - /* font. This is useful when global font data changes (e.g. Multiple */ - /* Masters fonts where blend coordinates change). */ - /* */ - /* <Input> */ - /* hinter :: A handle to the source auto-hinter. */ - /* */ - /* face :: A handle to the face. */ - /* */ - typedef void - (*FT_AutoHinter_GlobalResetFunc)( FT_AutoHinter hinter, - FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_AutoHinter_GlyphLoadFunc */ - /* */ - /* <Description> */ - /* This function is used to load, scale, and automatically hint a */ - /* glyph from a given face. */ - /* */ - /* <Input> */ - /* face :: A handle to the face. */ - /* */ - /* glyph_index :: The glyph index. */ - /* */ - /* load_flags :: The load flags. */ - /* */ - /* <Note> */ - /* This function is capable of loading composite glyphs by hinting */ - /* each sub-glyph independently (which improves quality). */ - /* */ - /* It will call the font driver with @FT_Load_Glyph, with */ - /* @FT_LOAD_NO_SCALE set. */ - /* */ - typedef FT_Error - (*FT_AutoHinter_GlyphLoadFunc)( FT_AutoHinter hinter, - FT_GlyphSlot slot, - FT_Size size, - FT_UInt glyph_index, - FT_Int32 load_flags ); - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_AutoHinter_InterfaceRec */ - /* */ - /* <Description> */ - /* The auto-hinter module's interface. */ - /* */ - typedef struct FT_AutoHinter_InterfaceRec_ - { - FT_AutoHinter_GlobalResetFunc reset_face; - FT_AutoHinter_GlobalGetFunc get_global_hints; - FT_AutoHinter_GlobalDoneFunc done_global_hints; - FT_AutoHinter_GlyphLoadFunc load_glyph; - - } FT_AutoHinter_InterfaceRec, *FT_AutoHinter_Interface; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_AUTOHINTER_INTERFACE( \ - class_, \ - reset_face_, \ - get_global_hints_, \ - done_global_hints_, \ - load_glyph_ ) \ - FT_CALLBACK_TABLE_DEF \ - const FT_AutoHinter_InterfaceRec class_ = \ - { \ - reset_face_, \ - get_global_hints_, \ - done_global_hints_, \ - load_glyph_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_AUTOHINTER_INTERFACE( \ - class_, \ - reset_face_, \ - get_global_hints_, \ - done_global_hints_, \ - load_glyph_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_AutoHinter_InterfaceRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->reset_face = reset_face_; \ - clazz->get_global_hints = get_global_hints_; \ - clazz->done_global_hints = done_global_hints_; \ - clazz->load_glyph = load_glyph_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - -FT_END_HEADER - -#endif /* __AUTOHINT_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/ftcalc.h b/thirdparty/include/freetype/internal/ftcalc.h deleted file mode 100644 index 5d351eca4..000000000 --- a/thirdparty/include/freetype/internal/ftcalc.h +++ /dev/null @@ -1,171 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftcalc.h */ -/* */ -/* Arithmetic computations (specification). */ -/* */ -/* Copyright 1996-2006, 2008, 2009, 2012-2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTCALC_H__ -#define __FTCALC_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - - -FT_BEGIN_HEADER - - -#if 0 - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_SqrtFixed */ - /* */ - /* <Description> */ - /* Computes the square root of a 16.16 fixed-point value. */ - /* */ - /* <Input> */ - /* x :: The value to compute the root for. */ - /* */ - /* <Return> */ - /* The result of `sqrt(x)'. */ - /* */ - /* <Note> */ - /* This function is not very fast. */ - /* */ - FT_BASE( FT_Int32 ) - FT_SqrtFixed( FT_Int32 x ); - -#endif /* 0 */ - - - /*************************************************************************/ - /* */ - /* FT_MulDiv() and FT_MulFix() are declared in freetype.h. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_MulDiv_No_Round */ - /* */ - /* <Description> */ - /* A very simple function used to perform the computation `(a*b)/c' */ - /* (without rounding) with maximum accuracy (it uses a 64-bit */ - /* intermediate integer whenever necessary). */ - /* */ - /* This function isn't necessarily as fast as some processor specific */ - /* operations, but is at least completely portable. */ - /* */ - /* <Input> */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. */ - /* c :: The divisor. */ - /* */ - /* <Return> */ - /* The result of `(a*b)/c'. This function never traps when trying to */ - /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ - /* on the signs of `a' and `b'. */ - /* */ - FT_BASE( FT_Long ) - FT_MulDiv_No_Round( FT_Long a, - FT_Long b, - FT_Long c ); - - - /* - * A variant of FT_Matrix_Multiply which scales its result afterwards. - * The idea is that both `a' and `b' are scaled by factors of 10 so that - * the values are as precise as possible to get a correct result during - * the 64bit multiplication. Let `sa' and `sb' be the scaling factors of - * `a' and `b', respectively, then the scaling factor of the result is - * `sa*sb'. - */ - FT_BASE( void ) - FT_Matrix_Multiply_Scaled( const FT_Matrix* a, - FT_Matrix *b, - FT_Long scaling ); - - - /* - * A variant of FT_Vector_Transform. See comments for - * FT_Matrix_Multiply_Scaled. - */ - FT_BASE( void ) - FT_Vector_Transform_Scaled( FT_Vector* vector, - const FT_Matrix* matrix, - FT_Long scaling ); - - - /* - * Return -1, 0, or +1, depending on the orientation of a given corner. - * We use the Cartesian coordinate system, with positive vertical values - * going upwards. The function returns +1 if the corner turns to the - * left, -1 to the right, and 0 for undecidable cases. - */ - FT_BASE( FT_Int ) - ft_corner_orientation( FT_Pos in_x, - FT_Pos in_y, - FT_Pos out_x, - FT_Pos out_y ); - - /* - * Return TRUE if a corner is flat or nearly flat. This is equivalent to - * saying that the angle difference between the `in' and `out' vectors is - * very small. - */ - FT_BASE( FT_Int ) - ft_corner_is_flat( FT_Pos in_x, - FT_Pos in_y, - FT_Pos out_x, - FT_Pos out_y ); - - - /* - * Return the most significant bit index. - */ - FT_BASE( FT_Int ) - FT_MSB( FT_UInt32 z ); - - - /* - * Return sqrt(x*x+y*y), which is the same as `FT_Vector_Length' but uses - * two fixed-point arguments instead. - */ - FT_BASE( FT_Fixed ) - FT_Hypot( FT_Fixed x, - FT_Fixed y ); - - -#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 ) -#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 ) -#define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 ) -#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 ) -#define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) ) -#define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 ) - -#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \ - : ( -( ( 32 - (x) ) & -64 ) ) ) - - -FT_END_HEADER - -#endif /* __FTCALC_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/ftdebug.h b/thirdparty/include/freetype/internal/ftdebug.h deleted file mode 100644 index 63ea1722e..000000000 --- a/thirdparty/include/freetype/internal/ftdebug.h +++ /dev/null @@ -1,255 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftdebug.h */ -/* */ -/* Debugging and logging component (specification). */ -/* */ -/* Copyright 1996-2002, 2004, 2006-2009, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* */ -/* IMPORTANT: A description of FreeType's debugging support can be */ -/* found in `docs/DEBUG.TXT'. Read it if you need to use or */ -/* understand this code. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTDEBUG_H__ -#define __FTDEBUG_H__ - - -#include <freetype/ft2build.h> -#include FT_CONFIG_CONFIG_H -#include FT_FREETYPE_H - - -FT_BEGIN_HEADER - - - /* force the definition of FT_DEBUG_LEVEL_ERROR if FT_DEBUG_LEVEL_TRACE */ - /* is already defined; this simplifies the following #ifdefs */ - /* */ -#ifdef FT_DEBUG_LEVEL_TRACE -#undef FT_DEBUG_LEVEL_ERROR -#define FT_DEBUG_LEVEL_ERROR -#endif - - - /*************************************************************************/ - /* */ - /* Define the trace enums as well as the trace levels array when they */ - /* are needed. */ - /* */ - /*************************************************************************/ - -#ifdef FT_DEBUG_LEVEL_TRACE - -#define FT_TRACE_DEF( x ) trace_ ## x , - - /* defining the enumeration */ - typedef enum FT_Trace_ - { -#include FT_INTERNAL_TRACE_H - trace_count - - } FT_Trace; - - - /* defining the array of trace levels, provided by `src/base/ftdebug.c' */ - extern int ft_trace_levels[trace_count]; - -#undef FT_TRACE_DEF - -#endif /* FT_DEBUG_LEVEL_TRACE */ - - - /*************************************************************************/ - /* */ - /* Define the FT_TRACE macro */ - /* */ - /* IMPORTANT! */ - /* */ - /* Each component must define the macro FT_COMPONENT to a valid FT_Trace */ - /* value before using any TRACE macro. */ - /* */ - /*************************************************************************/ - -#ifdef FT_DEBUG_LEVEL_TRACE - -#define FT_TRACE( level, varformat ) \ - do \ - { \ - if ( ft_trace_levels[FT_COMPONENT] >= level ) \ - FT_Message varformat; \ - } while ( 0 ) - -#else /* !FT_DEBUG_LEVEL_TRACE */ - -#define FT_TRACE( level, varformat ) do { } while ( 0 ) /* nothing */ - -#endif /* !FT_DEBUG_LEVEL_TRACE */ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Trace_Get_Count */ - /* */ - /* <Description> */ - /* Return the number of available trace components. */ - /* */ - /* <Return> */ - /* The number of trace components. 0 if FreeType 2 is not built with */ - /* FT_DEBUG_LEVEL_TRACE definition. */ - /* */ - /* <Note> */ - /* This function may be useful if you want to access elements of */ - /* the internal `ft_trace_levels' array by an index. */ - /* */ - FT_BASE( FT_Int ) - FT_Trace_Get_Count( void ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Trace_Get_Name */ - /* */ - /* <Description> */ - /* Return the name of a trace component. */ - /* */ - /* <Input> */ - /* The index of the trace component. */ - /* */ - /* <Return> */ - /* The name of the trace component. This is a statically allocated */ - /* C string, so do not free it after use. NULL if FreeType 2 is not */ - /* built with FT_DEBUG_LEVEL_TRACE definition. */ - /* */ - /* <Note> */ - /* Use @FT_Trace_Get_Count to get the number of available trace */ - /* components. */ - /* */ - /* This function may be useful if you want to control FreeType 2's */ - /* debug level in your application. */ - /* */ - FT_BASE( const char * ) - FT_Trace_Get_Name( FT_Int idx ); - - - /*************************************************************************/ - /* */ - /* You need two opening and closing parentheses! */ - /* */ - /* Example: FT_TRACE0(( "Value is %i", foo )) */ - /* */ - /* Output of the FT_TRACEX macros is sent to stderr. */ - /* */ - /*************************************************************************/ - -#define FT_TRACE0( varformat ) FT_TRACE( 0, varformat ) -#define FT_TRACE1( varformat ) FT_TRACE( 1, varformat ) -#define FT_TRACE2( varformat ) FT_TRACE( 2, varformat ) -#define FT_TRACE3( varformat ) FT_TRACE( 3, varformat ) -#define FT_TRACE4( varformat ) FT_TRACE( 4, varformat ) -#define FT_TRACE5( varformat ) FT_TRACE( 5, varformat ) -#define FT_TRACE6( varformat ) FT_TRACE( 6, varformat ) -#define FT_TRACE7( varformat ) FT_TRACE( 7, varformat ) - - - /*************************************************************************/ - /* */ - /* Define the FT_ERROR macro. */ - /* */ - /* Output of this macro is sent to stderr. */ - /* */ - /*************************************************************************/ - -#ifdef FT_DEBUG_LEVEL_ERROR - -#define FT_ERROR( varformat ) FT_Message varformat - -#else /* !FT_DEBUG_LEVEL_ERROR */ - -#define FT_ERROR( varformat ) do { } while ( 0 ) /* nothing */ - -#endif /* !FT_DEBUG_LEVEL_ERROR */ - - - /*************************************************************************/ - /* */ - /* Define the FT_ASSERT and FT_THROW macros. The call to `FT_Throw' */ - /* makes it possible to easily set a breakpoint at this function. */ - /* */ - /*************************************************************************/ - -#ifdef FT_DEBUG_LEVEL_ERROR - -#define FT_ASSERT( condition ) \ - do \ - { \ - if ( !( condition ) ) \ - FT_Panic( "assertion failed on line %d of file %s\n", \ - __LINE__, __FILE__ ); \ - } while ( 0 ) - -#define FT_THROW( e ) \ - ( FT_Throw( FT_ERR_CAT( FT_ERR_PREFIX, e ), \ - __LINE__, \ - __FILE__ ) | \ - FT_ERR_CAT( FT_ERR_PREFIX, e ) ) - -#else /* !FT_DEBUG_LEVEL_ERROR */ - -#define FT_ASSERT( condition ) do { } while ( 0 ) - -#define FT_THROW( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) - -#endif /* !FT_DEBUG_LEVEL_ERROR */ - - - /*************************************************************************/ - /* */ - /* Define `FT_Message' and `FT_Panic' when needed. */ - /* */ - /*************************************************************************/ - -#ifdef FT_DEBUG_LEVEL_ERROR - -#include "stdio.h" /* for vfprintf() */ - - /* print a message */ - FT_BASE( void ) - FT_Message( const char* fmt, - ... ); - - /* print a message and exit */ - FT_BASE( void ) - FT_Panic( const char* fmt, - ... ); - - /* report file name and line number of an error */ - FT_BASE( int ) - FT_Throw( FT_Error error, - int line, - const char* file ); - -#endif /* FT_DEBUG_LEVEL_ERROR */ - - - FT_BASE( void ) - ft_debug_init( void ); - -FT_END_HEADER - -#endif /* __FTDEBUG_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/ftdriver.h b/thirdparty/include/freetype/internal/ftdriver.h deleted file mode 100644 index cb19a24af..000000000 --- a/thirdparty/include/freetype/internal/ftdriver.h +++ /dev/null @@ -1,409 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftdriver.h */ -/* */ -/* FreeType font driver interface (specification). */ -/* */ -/* Copyright 1996-2003, 2006, 2008, 2011-2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTDRIVER_H__ -#define __FTDRIVER_H__ - - -#include <freetype/ft2build.h> -#include FT_MODULE_H - - -FT_BEGIN_HEADER - - - typedef FT_Error - (*FT_Face_InitFunc)( FT_Stream stream, - FT_Face face, - FT_Int typeface_index, - FT_Int num_params, - FT_Parameter* parameters ); - - typedef void - (*FT_Face_DoneFunc)( FT_Face face ); - - - typedef FT_Error - (*FT_Size_InitFunc)( FT_Size size ); - - typedef void - (*FT_Size_DoneFunc)( FT_Size size ); - - - typedef FT_Error - (*FT_Slot_InitFunc)( FT_GlyphSlot slot ); - - typedef void - (*FT_Slot_DoneFunc)( FT_GlyphSlot slot ); - - - typedef FT_Error - (*FT_Size_RequestFunc)( FT_Size size, - FT_Size_Request req ); - - typedef FT_Error - (*FT_Size_SelectFunc)( FT_Size size, - FT_ULong size_index ); - - typedef FT_Error - (*FT_Slot_LoadFunc)( FT_GlyphSlot slot, - FT_Size size, - FT_UInt glyph_index, - FT_Int32 load_flags ); - - - typedef FT_UInt - (*FT_CharMap_CharIndexFunc)( FT_CharMap charmap, - FT_Long charcode ); - - typedef FT_Long - (*FT_CharMap_CharNextFunc)( FT_CharMap charmap, - FT_Long charcode ); - - - typedef FT_Error - (*FT_Face_GetKerningFunc)( FT_Face face, - FT_UInt left_glyph, - FT_UInt right_glyph, - FT_Vector* kerning ); - - - typedef FT_Error - (*FT_Face_AttachFunc)( FT_Face face, - FT_Stream stream ); - - - typedef FT_Error - (*FT_Face_GetAdvancesFunc)( FT_Face face, - FT_UInt first, - FT_UInt count, - FT_Int32 flags, - FT_Fixed* advances ); - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Driver_ClassRec */ - /* */ - /* <Description> */ - /* The font driver class. This structure mostly contains pointers to */ - /* driver methods. */ - /* */ - /* <Fields> */ - /* root :: The parent module. */ - /* */ - /* face_object_size :: The size of a face object in bytes. */ - /* */ - /* size_object_size :: The size of a size object in bytes. */ - /* */ - /* slot_object_size :: The size of a glyph object in bytes. */ - /* */ - /* init_face :: The format-specific face constructor. */ - /* */ - /* done_face :: The format-specific face destructor. */ - /* */ - /* init_size :: The format-specific size constructor. */ - /* */ - /* done_size :: The format-specific size destructor. */ - /* */ - /* init_slot :: The format-specific slot constructor. */ - /* */ - /* done_slot :: The format-specific slot destructor. */ - /* */ - /* */ - /* load_glyph :: A function handle to load a glyph to a slot. */ - /* This field is mandatory! */ - /* */ - /* get_kerning :: A function handle to return the unscaled */ - /* kerning for a given pair of glyphs. Can be */ - /* set to 0 if the format doesn't support */ - /* kerning. */ - /* */ - /* attach_file :: This function handle is used to read */ - /* additional data for a face from another */ - /* file/stream. For example, this can be used to */ - /* add data from AFM or PFM files on a Type 1 */ - /* face, or a CIDMap on a CID-keyed face. */ - /* */ - /* get_advances :: A function handle used to return advance */ - /* widths of `count' glyphs (in font units), */ - /* starting at `first'. The `vertical' flag must */ - /* be set to get vertical advance heights. The */ - /* `advances' buffer is caller-allocated. */ - /* The idea of this function is to be able to */ - /* perform device-independent text layout without */ - /* loading a single glyph image. */ - /* */ - /* request_size :: A handle to a function used to request the new */ - /* character size. Can be set to 0 if the */ - /* scaling done in the base layer suffices. */ - /* */ - /* select_size :: A handle to a function used to select a new */ - /* fixed size. It is used only if */ - /* @FT_FACE_FLAG_FIXED_SIZES is set. Can be set */ - /* to 0 if the scaling done in the base layer */ - /* suffices. */ - /* <Note> */ - /* Most function pointers, with the exception of `load_glyph', can be */ - /* set to 0 to indicate a default behaviour. */ - /* */ - typedef struct FT_Driver_ClassRec_ - { - FT_Module_Class root; - - FT_Long face_object_size; - FT_Long size_object_size; - FT_Long slot_object_size; - - FT_Face_InitFunc init_face; - FT_Face_DoneFunc done_face; - - FT_Size_InitFunc init_size; - FT_Size_DoneFunc done_size; - - FT_Slot_InitFunc init_slot; - FT_Slot_DoneFunc done_slot; - - FT_Slot_LoadFunc load_glyph; - - FT_Face_GetKerningFunc get_kerning; - FT_Face_AttachFunc attach_file; - FT_Face_GetAdvancesFunc get_advances; - - /* since version 2.2 */ - FT_Size_RequestFunc request_size; - FT_Size_SelectFunc select_size; - - } FT_Driver_ClassRec, *FT_Driver_Class; - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DECLARE_DRIVER */ - /* */ - /* <Description> */ - /* Used to create a forward declaration of an FT_Driver_ClassRec */ - /* struct instance. */ - /* */ - /* <Macro> */ - /* FT_DEFINE_DRIVER */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Driver_ClassRec struct. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is defined a `create' function has to be */ - /* called with a pointer where the allocated structure is returned. */ - /* And when it is no longer needed a `destroy' function needs to be */ - /* called to release that allocation. */ - /* */ - /* `fcinit.c' (ft_create_default_module_classes) already contains a */ - /* mechanism to call these functions for the default modules */ - /* described in `ftmodule.h'. */ - /* */ - /* Notice that the created `create' and `destroy' functions call */ - /* `pic_init' and `pic_free' to allow you to manually allocate and */ - /* initialize any additional global data, like a module specific */ - /* interface, and put them in the global pic container defined in */ - /* `ftpic.h'. If you don't need them just implement the functions as */ - /* empty to resolve the link error. Also the `pic_init' and */ - /* `pic_free' functions should be declared in `pic.h', to be referred */ - /* by driver definition calling `FT_DEFINE_DRIVER' in following. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro is */ - /* used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DECLARE_DRIVER( class_ ) \ - FT_CALLBACK_TABLE \ - const FT_Driver_ClassRec class_; - -#define FT_DEFINE_DRIVER( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_, \ - face_object_size_, \ - size_object_size_, \ - slot_object_size_, \ - init_face_, \ - done_face_, \ - init_size_, \ - done_size_, \ - init_slot_, \ - done_slot_, \ - load_glyph_, \ - get_kerning_, \ - attach_file_, \ - get_advances_, \ - request_size_, \ - select_size_ ) \ - FT_CALLBACK_TABLE_DEF \ - const FT_Driver_ClassRec class_ = \ - { \ - FT_DEFINE_ROOT_MODULE( flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - \ - face_object_size_, \ - size_object_size_, \ - slot_object_size_, \ - \ - init_face_, \ - done_face_, \ - \ - init_size_, \ - done_size_, \ - \ - init_slot_, \ - done_slot_, \ - \ - load_glyph_, \ - \ - get_kerning_, \ - attach_file_, \ - get_advances_, \ - \ - request_size_, \ - select_size_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DECLARE_DRIVER( class_ ) FT_DECLARE_MODULE( class_ ) - -#define FT_DEFINE_DRIVER( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_, \ - face_object_size_, \ - size_object_size_, \ - slot_object_size_, \ - init_face_, \ - done_face_, \ - init_size_, \ - done_size_, \ - init_slot_, \ - done_slot_, \ - load_glyph_, \ - get_kerning_, \ - attach_file_, \ - get_advances_, \ - request_size_, \ - select_size_ ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_Module_Class* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - FT_Driver_Class dclazz = (FT_Driver_Class)clazz; \ - \ - \ - class_ ## _pic_free( library ); \ - if ( dclazz ) \ - FT_FREE( dclazz ); \ - } \ - \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_Module_Class** output_class ) \ - { \ - FT_Driver_Class clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ - return error; \ - \ - error = class_ ## _pic_init( library ); \ - if ( error ) \ - { \ - FT_FREE( clazz ); \ - return error; \ - } \ - \ - FT_DEFINE_ROOT_MODULE( flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - \ - clazz->face_object_size = face_object_size_; \ - clazz->size_object_size = size_object_size_; \ - clazz->slot_object_size = slot_object_size_; \ - \ - clazz->init_face = init_face_; \ - clazz->done_face = done_face_; \ - \ - clazz->init_size = init_size_; \ - clazz->done_size = done_size_; \ - \ - clazz->init_slot = init_slot_; \ - clazz->done_slot = done_slot_; \ - \ - clazz->load_glyph = load_glyph_; \ - \ - clazz->get_kerning = get_kerning_; \ - clazz->attach_file = attach_file_; \ - clazz->get_advances = get_advances_; \ - \ - clazz->request_size = request_size_; \ - clazz->select_size = select_size_; \ - \ - *output_class = (FT_Module_Class*)clazz; \ - \ - return FT_Err_Ok; \ - } - - -#endif /* FT_CONFIG_OPTION_PIC */ - -FT_END_HEADER - -#endif /* __FTDRIVER_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/ftgloadr.h b/thirdparty/include/freetype/internal/ftgloadr.h deleted file mode 100644 index a52e97e61..000000000 --- a/thirdparty/include/freetype/internal/ftgloadr.h +++ /dev/null @@ -1,168 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftgloadr.h */ -/* */ -/* The FreeType glyph loader (specification). */ -/* */ -/* Copyright 2002, 2003, 2005, 2006 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTGLOADR_H__ -#define __FTGLOADR_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_GlyphLoader */ - /* */ - /* <Description> */ - /* The glyph loader is an internal object used to load several glyphs */ - /* together (for example, in the case of composites). */ - /* */ - /* <Note> */ - /* The glyph loader implementation is not part of the high-level API, */ - /* hence the forward structure declaration. */ - /* */ - typedef struct FT_GlyphLoaderRec_* FT_GlyphLoader ; - - -#if 0 /* moved to freetype.h in version 2.2 */ -#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1 -#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2 -#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4 -#define FT_SUBGLYPH_FLAG_SCALE 8 -#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40 -#define FT_SUBGLYPH_FLAG_2X2 0x80 -#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200 -#endif - - - typedef struct FT_SubGlyphRec_ - { - FT_Int index; - FT_UShort flags; - FT_Int arg1; - FT_Int arg2; - FT_Matrix transform; - - } FT_SubGlyphRec; - - - typedef struct FT_GlyphLoadRec_ - { - FT_Outline outline; /* outline */ - FT_Vector* extra_points; /* extra points table */ - FT_Vector* extra_points2; /* second extra points table */ - FT_UInt num_subglyphs; /* number of subglyphs */ - FT_SubGlyph subglyphs; /* subglyphs */ - - } FT_GlyphLoadRec, *FT_GlyphLoad; - - - typedef struct FT_GlyphLoaderRec_ - { - FT_Memory memory; - FT_UInt max_points; - FT_UInt max_contours; - FT_UInt max_subglyphs; - FT_Bool use_extra; - - FT_GlyphLoadRec base; - FT_GlyphLoadRec current; - - void* other; /* for possible future extension? */ - - } FT_GlyphLoaderRec; - - - /* create new empty glyph loader */ - FT_BASE( FT_Error ) - FT_GlyphLoader_New( FT_Memory memory, - FT_GlyphLoader *aloader ); - - /* add an extra points table to a glyph loader */ - FT_BASE( FT_Error ) - FT_GlyphLoader_CreateExtra( FT_GlyphLoader loader ); - - /* destroy a glyph loader */ - FT_BASE( void ) - FT_GlyphLoader_Done( FT_GlyphLoader loader ); - - /* reset a glyph loader (frees everything int it) */ - FT_BASE( void ) - FT_GlyphLoader_Reset( FT_GlyphLoader loader ); - - /* rewind a glyph loader */ - FT_BASE( void ) - FT_GlyphLoader_Rewind( FT_GlyphLoader loader ); - - /* check that there is enough space to add `n_points' and `n_contours' */ - /* to the glyph loader */ - FT_BASE( FT_Error ) - FT_GlyphLoader_CheckPoints( FT_GlyphLoader loader, - FT_UInt n_points, - FT_UInt n_contours ); - - -#define FT_GLYPHLOADER_CHECK_P( _loader, _count ) \ - ( (_count) == 0 || ((_loader)->base.outline.n_points + \ - (_loader)->current.outline.n_points + \ - (unsigned long)(_count)) <= (_loader)->max_points ) - -#define FT_GLYPHLOADER_CHECK_C( _loader, _count ) \ - ( (_count) == 0 || ((_loader)->base.outline.n_contours + \ - (_loader)->current.outline.n_contours + \ - (unsigned long)(_count)) <= (_loader)->max_contours ) - -#define FT_GLYPHLOADER_CHECK_POINTS( _loader, _points,_contours ) \ - ( ( FT_GLYPHLOADER_CHECK_P( _loader, _points ) && \ - FT_GLYPHLOADER_CHECK_C( _loader, _contours ) ) \ - ? 0 \ - : FT_GlyphLoader_CheckPoints( (_loader), (_points), (_contours) ) ) - - - /* check that there is enough space to add `n_subs' sub-glyphs to */ - /* a glyph loader */ - FT_BASE( FT_Error ) - FT_GlyphLoader_CheckSubGlyphs( FT_GlyphLoader loader, - FT_UInt n_subs ); - - /* prepare a glyph loader, i.e. empty the current glyph */ - FT_BASE( void ) - FT_GlyphLoader_Prepare( FT_GlyphLoader loader ); - - /* add the current glyph to the base glyph */ - FT_BASE( void ) - FT_GlyphLoader_Add( FT_GlyphLoader loader ); - - /* copy points from one glyph loader to another */ - FT_BASE( FT_Error ) - FT_GlyphLoader_CopyPoints( FT_GlyphLoader target, - FT_GlyphLoader source ); - - /* */ - - -FT_END_HEADER - -#endif /* __FTGLOADR_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/ftmemory.h b/thirdparty/include/freetype/internal/ftmemory.h deleted file mode 100644 index 2ece9c7f5..000000000 --- a/thirdparty/include/freetype/internal/ftmemory.h +++ /dev/null @@ -1,378 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftmemory.h */ -/* */ -/* The FreeType memory management macros (specification). */ -/* */ -/* Copyright 1996-2002, 2004-2007, 2010, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTMEMORY_H__ -#define __FTMEMORY_H__ - - -#include <freetype/ft2build.h> -#include FT_CONFIG_CONFIG_H -#include FT_TYPES_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_SET_ERROR */ - /* */ - /* <Description> */ - /* This macro is used to set an implicit `error' variable to a given */ - /* expression's value (usually a function call), and convert it to a */ - /* boolean which is set whenever the value is != 0. */ - /* */ -#undef FT_SET_ERROR -#define FT_SET_ERROR( expression ) \ - ( ( error = (expression) ) != 0 ) - - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** M E M O R Y ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* - * C++ refuses to handle statements like p = (void*)anything, with `p' a - * typed pointer. Since we don't have a `typeof' operator in standard - * C++, we have to use a template to emulate it. - */ - -#ifdef __cplusplus - - extern "C++" - template <typename T> inline T* - cplusplus_typeof( T*, - void *v ) - { - return static_cast <T*> ( v ); - } - -#define FT_ASSIGNP( p, val ) (p) = cplusplus_typeof( (p), (val) ) - -#else - -#define FT_ASSIGNP( p, val ) (p) = (val) - -#endif - - - -#ifdef FT_DEBUG_MEMORY - - FT_BASE( const char* ) _ft_debug_file; - FT_BASE( long ) _ft_debug_lineno; - -#define FT_DEBUG_INNER( exp ) ( _ft_debug_file = __FILE__, \ - _ft_debug_lineno = __LINE__, \ - (exp) ) - -#define FT_ASSIGNP_INNER( p, exp ) ( _ft_debug_file = __FILE__, \ - _ft_debug_lineno = __LINE__, \ - FT_ASSIGNP( p, exp ) ) - -#else /* !FT_DEBUG_MEMORY */ - -#define FT_DEBUG_INNER( exp ) (exp) -#define FT_ASSIGNP_INNER( p, exp ) FT_ASSIGNP( p, exp ) - -#endif /* !FT_DEBUG_MEMORY */ - - - /* - * The allocation functions return a pointer, and the error code - * is written to through the `p_error' parameter. See below for - * for documentation. - */ - - FT_BASE( FT_Pointer ) - ft_mem_alloc( FT_Memory memory, - FT_Long size, - FT_Error *p_error ); - - FT_BASE( FT_Pointer ) - ft_mem_qalloc( FT_Memory memory, - FT_Long size, - FT_Error *p_error ); - - FT_BASE( FT_Pointer ) - ft_mem_realloc( FT_Memory memory, - FT_Long item_size, - FT_Long cur_count, - FT_Long new_count, - void* block, - FT_Error *p_error ); - - FT_BASE( FT_Pointer ) - ft_mem_qrealloc( FT_Memory memory, - FT_Long item_size, - FT_Long cur_count, - FT_Long new_count, - void* block, - FT_Error *p_error ); - - FT_BASE( void ) - ft_mem_free( FT_Memory memory, - const void* P ); - - -#define FT_MEM_ALLOC( ptr, size ) \ - FT_ASSIGNP_INNER( ptr, ft_mem_alloc( memory, \ - (FT_Long)(size), \ - &error ) ) - -#define FT_MEM_FREE( ptr ) \ - FT_BEGIN_STMNT \ - ft_mem_free( memory, (ptr) ); \ - (ptr) = NULL; \ - FT_END_STMNT - -#define FT_MEM_NEW( ptr ) \ - FT_MEM_ALLOC( ptr, sizeof ( *(ptr) ) ) - -#define FT_MEM_REALLOC( ptr, cursz, newsz ) \ - FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ - 1, \ - (FT_Long)(cursz), \ - (FT_Long)(newsz), \ - (ptr), \ - &error ) ) - -#define FT_MEM_QALLOC( ptr, size ) \ - FT_ASSIGNP_INNER( ptr, ft_mem_qalloc( memory, \ - (FT_Long)(size), \ - &error ) ) - -#define FT_MEM_QNEW( ptr ) \ - FT_MEM_QALLOC( ptr, sizeof ( *(ptr) ) ) - -#define FT_MEM_QREALLOC( ptr, cursz, newsz ) \ - FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ - 1, \ - (FT_Long)(cursz), \ - (FT_Long)(newsz), \ - (ptr), \ - &error ) ) - -#define FT_MEM_ALLOC_MULT( ptr, count, item_size ) \ - FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ - (FT_Long)(item_size), \ - 0, \ - (FT_Long)(count), \ - NULL, \ - &error ) ) - -#define FT_MEM_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ - FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ - (FT_Long)(itmsz), \ - (FT_Long)(oldcnt), \ - (FT_Long)(newcnt), \ - (ptr), \ - &error ) ) - -#define FT_MEM_QALLOC_MULT( ptr, count, item_size ) \ - FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ - (FT_Long)(item_size), \ - 0, \ - (FT_Long)(count), \ - NULL, \ - &error ) ) - -#define FT_MEM_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz) \ - FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ - (FT_Long)(itmsz), \ - (FT_Long)(oldcnt), \ - (FT_Long)(newcnt), \ - (ptr), \ - &error ) ) - - -#define FT_MEM_SET_ERROR( cond ) ( (cond), error != 0 ) - - -#define FT_MEM_SET( dest, byte, count ) ft_memset( dest, byte, count ) - -#define FT_MEM_COPY( dest, source, count ) ft_memcpy( dest, source, count ) - -#define FT_MEM_MOVE( dest, source, count ) ft_memmove( dest, source, count ) - - -#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count ) - -#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) ) - - -#define FT_ARRAY_ZERO( dest, count ) \ - FT_MEM_ZERO( dest, (count) * sizeof ( *(dest) ) ) - -#define FT_ARRAY_COPY( dest, source, count ) \ - FT_MEM_COPY( dest, source, (count) * sizeof ( *(dest) ) ) - -#define FT_ARRAY_MOVE( dest, source, count ) \ - FT_MEM_MOVE( dest, source, (count) * sizeof ( *(dest) ) ) - - - /* - * Return the maximum number of addressable elements in an array. - * We limit ourselves to INT_MAX, rather than UINT_MAX, to avoid - * any problems. - */ -#define FT_ARRAY_MAX( ptr ) ( FT_INT_MAX / sizeof ( *(ptr) ) ) - -#define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) ) - - - /*************************************************************************/ - /* */ - /* The following functions macros expect that their pointer argument is */ - /* _typed_ in order to automatically compute array element sizes. */ - /* */ - -#define FT_MEM_NEW_ARRAY( ptr, count ) \ - FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ - sizeof ( *(ptr) ), \ - 0, \ - (FT_Long)(count), \ - NULL, \ - &error ) ) - -#define FT_MEM_RENEW_ARRAY( ptr, cursz, newsz ) \ - FT_ASSIGNP_INNER( ptr, ft_mem_realloc( memory, \ - sizeof ( *(ptr) ), \ - (FT_Long)(cursz), \ - (FT_Long)(newsz), \ - (ptr), \ - &error ) ) - -#define FT_MEM_QNEW_ARRAY( ptr, count ) \ - FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ - sizeof ( *(ptr) ), \ - 0, \ - (FT_Long)(count), \ - NULL, \ - &error ) ) - -#define FT_MEM_QRENEW_ARRAY( ptr, cursz, newsz ) \ - FT_ASSIGNP_INNER( ptr, ft_mem_qrealloc( memory, \ - sizeof ( *(ptr) ), \ - (FT_Long)(cursz), \ - (FT_Long)(newsz), \ - (ptr), \ - &error ) ) - -#define FT_ALLOC( ptr, size ) \ - FT_MEM_SET_ERROR( FT_MEM_ALLOC( ptr, size ) ) - -#define FT_REALLOC( ptr, cursz, newsz ) \ - FT_MEM_SET_ERROR( FT_MEM_REALLOC( ptr, cursz, newsz ) ) - -#define FT_ALLOC_MULT( ptr, count, item_size ) \ - FT_MEM_SET_ERROR( FT_MEM_ALLOC_MULT( ptr, count, item_size ) ) - -#define FT_REALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ - FT_MEM_SET_ERROR( FT_MEM_REALLOC_MULT( ptr, oldcnt, \ - newcnt, itmsz ) ) - -#define FT_QALLOC( ptr, size ) \ - FT_MEM_SET_ERROR( FT_MEM_QALLOC( ptr, size ) ) - -#define FT_QREALLOC( ptr, cursz, newsz ) \ - FT_MEM_SET_ERROR( FT_MEM_QREALLOC( ptr, cursz, newsz ) ) - -#define FT_QALLOC_MULT( ptr, count, item_size ) \ - FT_MEM_SET_ERROR( FT_MEM_QALLOC_MULT( ptr, count, item_size ) ) - -#define FT_QREALLOC_MULT( ptr, oldcnt, newcnt, itmsz ) \ - FT_MEM_SET_ERROR( FT_MEM_QREALLOC_MULT( ptr, oldcnt, \ - newcnt, itmsz ) ) - -#define FT_FREE( ptr ) FT_MEM_FREE( ptr ) - -#define FT_NEW( ptr ) FT_MEM_SET_ERROR( FT_MEM_NEW( ptr ) ) - -#define FT_NEW_ARRAY( ptr, count ) \ - FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) - -#define FT_RENEW_ARRAY( ptr, curcnt, newcnt ) \ - FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) - -#define FT_QNEW( ptr ) \ - FT_MEM_SET_ERROR( FT_MEM_QNEW( ptr ) ) - -#define FT_QNEW_ARRAY( ptr, count ) \ - FT_MEM_SET_ERROR( FT_MEM_NEW_ARRAY( ptr, count ) ) - -#define FT_QRENEW_ARRAY( ptr, curcnt, newcnt ) \ - FT_MEM_SET_ERROR( FT_MEM_RENEW_ARRAY( ptr, curcnt, newcnt ) ) - - - FT_BASE( FT_Pointer ) - ft_mem_strdup( FT_Memory memory, - const char* str, - FT_Error *p_error ); - - FT_BASE( FT_Pointer ) - ft_mem_dup( FT_Memory memory, - const void* address, - FT_ULong size, - FT_Error *p_error ); - - -#define FT_MEM_STRDUP( dst, str ) \ - (dst) = (char*)ft_mem_strdup( memory, (const char*)(str), &error ) - -#define FT_STRDUP( dst, str ) \ - FT_MEM_SET_ERROR( FT_MEM_STRDUP( dst, str ) ) - -#define FT_MEM_DUP( dst, address, size ) \ - (dst) = ft_mem_dup( memory, (address), (FT_ULong)(size), &error ) - -#define FT_DUP( dst, address, size ) \ - FT_MEM_SET_ERROR( FT_MEM_DUP( dst, address, size ) ) - - - /* Return >= 1 if a truncation occurs. */ - /* Return 0 if the source string fits the buffer. */ - /* This is *not* the same as strlcpy(). */ - FT_BASE( FT_Int ) - ft_mem_strcpyn( char* dst, - const char* src, - FT_ULong size ); - -#define FT_STRCPYN( dst, src, size ) \ - ft_mem_strcpyn( (char*)dst, (const char*)(src), (FT_ULong)(size) ) - - /* */ - - -FT_END_HEADER - -#endif /* __FTMEMORY_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/ftobjs.h b/thirdparty/include/freetype/internal/ftobjs.h deleted file mode 100644 index 9a9cc0ba9..000000000 --- a/thirdparty/include/freetype/internal/ftobjs.h +++ /dev/null @@ -1,1569 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftobjs.h */ -/* */ -/* The FreeType private base classes (specification). */ -/* */ -/* Copyright 1996-2006, 2008, 2010, 2012-2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file contains the definition of all internal FreeType classes. */ - /* */ - /*************************************************************************/ - - -#ifndef __FTOBJS_H__ -#define __FTOBJS_H__ - -#include <freetype/ft2build.h> -#include FT_RENDER_H -#include FT_SIZES_H -#include FT_LCD_FILTER_H -#include FT_INTERNAL_MEMORY_H -#include FT_INTERNAL_GLYPH_LOADER_H -#include FT_INTERNAL_DRIVER_H -#include FT_INTERNAL_AUTOHINT_H -#include FT_INTERNAL_SERVICE_H -#include FT_INTERNAL_PIC_H - -#ifdef FT_CONFIG_OPTION_INCREMENTAL -#include FT_INCREMENTAL_H -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* Some generic definitions. */ - /* */ -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef NULL -#define NULL (void*)0 -#endif - - - /*************************************************************************/ - /* */ - /* The min and max functions missing in C. As usual, be careful not to */ - /* write things like FT_MIN( a++, b++ ) to avoid side effects. */ - /* */ -#define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) ) -#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) ) - -#define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) ) - - -#define FT_PAD_FLOOR( x, n ) ( (x) & ~((n)-1) ) -#define FT_PAD_ROUND( x, n ) FT_PAD_FLOOR( (x) + ((n)/2), n ) -#define FT_PAD_CEIL( x, n ) FT_PAD_FLOOR( (x) + ((n)-1), n ) - -#define FT_PIX_FLOOR( x ) ( (x) & ~63 ) -#define FT_PIX_ROUND( x ) FT_PIX_FLOOR( (x) + 32 ) -#define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 ) - - - /* - * Return the highest power of 2 that is <= value; this correspond to - * the highest bit in a given 32-bit value. - */ - FT_BASE( FT_UInt32 ) - ft_highpow2( FT_UInt32 value ); - - - /* - * character classification functions -- since these are used to parse - * font files, we must not use those in <ctypes.h> which are - * locale-dependent - */ -#define ft_isdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U ) - -#define ft_isxdigit( x ) ( ( (unsigned)(x) - '0' ) < 10U || \ - ( (unsigned)(x) - 'a' ) < 6U || \ - ( (unsigned)(x) - 'A' ) < 6U ) - - /* the next two macros assume ASCII representation */ -#define ft_isupper( x ) ( ( (unsigned)(x) - 'A' ) < 26U ) -#define ft_islower( x ) ( ( (unsigned)(x) - 'a' ) < 26U ) - -#define ft_isalpha( x ) ( ft_isupper( x ) || ft_islower( x ) ) -#define ft_isalnum( x ) ( ft_isdigit( x ) || ft_isalpha( x ) ) - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** C H A R M A P S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - /* handle to internal charmap object */ - typedef struct FT_CMapRec_* FT_CMap; - - /* handle to charmap class structure */ - typedef const struct FT_CMap_ClassRec_* FT_CMap_Class; - - /* internal charmap object structure */ - typedef struct FT_CMapRec_ - { - FT_CharMapRec charmap; - FT_CMap_Class clazz; - - } FT_CMapRec; - - /* typecase any pointer to a charmap handle */ -#define FT_CMAP( x ) ((FT_CMap)( x )) - - /* obvious macros */ -#define FT_CMAP_PLATFORM_ID( x ) FT_CMAP( x )->charmap.platform_id -#define FT_CMAP_ENCODING_ID( x ) FT_CMAP( x )->charmap.encoding_id -#define FT_CMAP_ENCODING( x ) FT_CMAP( x )->charmap.encoding -#define FT_CMAP_FACE( x ) FT_CMAP( x )->charmap.face - - - /* class method definitions */ - typedef FT_Error - (*FT_CMap_InitFunc)( FT_CMap cmap, - FT_Pointer init_data ); - - typedef void - (*FT_CMap_DoneFunc)( FT_CMap cmap ); - - typedef FT_UInt - (*FT_CMap_CharIndexFunc)( FT_CMap cmap, - FT_UInt32 char_code ); - - typedef FT_UInt - (*FT_CMap_CharNextFunc)( FT_CMap cmap, - FT_UInt32 *achar_code ); - - typedef FT_UInt - (*FT_CMap_CharVarIndexFunc)( FT_CMap cmap, - FT_CMap unicode_cmap, - FT_UInt32 char_code, - FT_UInt32 variant_selector ); - - typedef FT_Bool - (*FT_CMap_CharVarIsDefaultFunc)( FT_CMap cmap, - FT_UInt32 char_code, - FT_UInt32 variant_selector ); - - typedef FT_UInt32 * - (*FT_CMap_VariantListFunc)( FT_CMap cmap, - FT_Memory mem ); - - typedef FT_UInt32 * - (*FT_CMap_CharVariantListFunc)( FT_CMap cmap, - FT_Memory mem, - FT_UInt32 char_code ); - - typedef FT_UInt32 * - (*FT_CMap_VariantCharListFunc)( FT_CMap cmap, - FT_Memory mem, - FT_UInt32 variant_selector ); - - - typedef struct FT_CMap_ClassRec_ - { - FT_ULong size; - FT_CMap_InitFunc init; - FT_CMap_DoneFunc done; - FT_CMap_CharIndexFunc char_index; - FT_CMap_CharNextFunc char_next; - - /* Subsequent entries are special ones for format 14 -- the variant */ - /* selector subtable which behaves like no other */ - - FT_CMap_CharVarIndexFunc char_var_index; - FT_CMap_CharVarIsDefaultFunc char_var_default; - FT_CMap_VariantListFunc variant_list; - FT_CMap_CharVariantListFunc charvariant_list; - FT_CMap_VariantCharListFunc variantchar_list; - - } FT_CMap_ClassRec; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DECLARE_CMAP_CLASS( class_ ) \ - FT_CALLBACK_TABLE const FT_CMap_ClassRec class_; - -#define FT_DEFINE_CMAP_CLASS( \ - class_, \ - size_, \ - init_, \ - done_, \ - char_index_, \ - char_next_, \ - char_var_index_, \ - char_var_default_, \ - variant_list_, \ - charvariant_list_, \ - variantchar_list_ ) \ - FT_CALLBACK_TABLE_DEF \ - const FT_CMap_ClassRec class_ = \ - { \ - size_, \ - init_, \ - done_, \ - char_index_, \ - char_next_, \ - char_var_index_, \ - char_var_default_, \ - variant_list_, \ - charvariant_list_, \ - variantchar_list_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DECLARE_CMAP_CLASS( class_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_CMap_ClassRec* clazz ); - -#define FT_DEFINE_CMAP_CLASS( \ - class_, \ - size_, \ - init_, \ - done_, \ - char_index_, \ - char_next_, \ - char_var_index_, \ - char_var_default_, \ - variant_list_, \ - charvariant_list_, \ - variantchar_list_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_CMap_ClassRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->size = size_; \ - clazz->init = init_; \ - clazz->done = done_; \ - clazz->char_index = char_index_; \ - clazz->char_next = char_next_; \ - clazz->char_var_index = char_var_index_; \ - clazz->char_var_default = char_var_default_; \ - clazz->variant_list = variant_list_; \ - clazz->charvariant_list = charvariant_list_; \ - clazz->variantchar_list = variantchar_list_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - - /* create a new charmap and add it to charmap->face */ - FT_BASE( FT_Error ) - FT_CMap_New( FT_CMap_Class clazz, - FT_Pointer init_data, - FT_CharMap charmap, - FT_CMap *acmap ); - - /* destroy a charmap and remove it from face's list */ - FT_BASE( void ) - FT_CMap_Done( FT_CMap cmap ); - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Face_InternalRec */ - /* */ - /* <Description> */ - /* This structure contains the internal fields of each FT_Face */ - /* object. These fields may change between different releases of */ - /* FreeType. */ - /* */ - /* <Fields> */ - /* max_points :: */ - /* The maximum number of points used to store the vectorial outline */ - /* of any glyph in this face. If this value cannot be known in */ - /* advance, or if the face isn't scalable, this should be set to 0. */ - /* Only relevant for scalable formats. */ - /* */ - /* max_contours :: */ - /* The maximum number of contours used to store the vectorial */ - /* outline of any glyph in this face. If this value cannot be */ - /* known in advance, or if the face isn't scalable, this should be */ - /* set to 0. Only relevant for scalable formats. */ - /* */ - /* transform_matrix :: */ - /* A 2x2 matrix of 16.16 coefficients used to transform glyph */ - /* outlines after they are loaded from the font. Only used by the */ - /* convenience functions. */ - /* */ - /* transform_delta :: */ - /* A translation vector used to transform glyph outlines after they */ - /* are loaded from the font. Only used by the convenience */ - /* functions. */ - /* */ - /* transform_flags :: */ - /* Some flags used to classify the transform. Only used by the */ - /* convenience functions. */ - /* */ - /* services :: */ - /* A cache for frequently used services. It should be only */ - /* accessed with the macro `FT_FACE_LOOKUP_SERVICE'. */ - /* */ - /* incremental_interface :: */ - /* If non-null, the interface through which glyph data and metrics */ - /* are loaded incrementally for faces that do not provide all of */ - /* this data when first opened. This field exists only if */ - /* @FT_CONFIG_OPTION_INCREMENTAL is defined. */ - /* */ - /* ignore_unpatented_hinter :: */ - /* This boolean flag instructs the glyph loader to ignore the */ - /* native font hinter, if one is found. This is exclusively used */ - /* in the case when the unpatented hinter is compiled within the */ - /* library. */ - /* */ - /* refcount :: */ - /* A counter initialized to~1 at the time an @FT_Face structure is */ - /* created. @FT_Reference_Face increments this counter, and */ - /* @FT_Done_Face only destroys a face if the counter is~1, */ - /* otherwise it simply decrements it. */ - /* */ - typedef struct FT_Face_InternalRec_ - { - FT_Matrix transform_matrix; - FT_Vector transform_delta; - FT_Int transform_flags; - - FT_ServiceCacheRec services; - -#ifdef FT_CONFIG_OPTION_INCREMENTAL - FT_Incremental_InterfaceRec* incremental_interface; -#endif - - FT_Bool ignore_unpatented_hinter; - FT_Int refcount; - - } FT_Face_InternalRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Slot_InternalRec */ - /* */ - /* <Description> */ - /* This structure contains the internal fields of each FT_GlyphSlot */ - /* object. These fields may change between different releases of */ - /* FreeType. */ - /* */ - /* <Fields> */ - /* loader :: The glyph loader object used to load outlines */ - /* into the glyph slot. */ - /* */ - /* flags :: Possible values are zero or */ - /* FT_GLYPH_OWN_BITMAP. The latter indicates */ - /* that the FT_GlyphSlot structure owns the */ - /* bitmap buffer. */ - /* */ - /* glyph_transformed :: Boolean. Set to TRUE when the loaded glyph */ - /* must be transformed through a specific */ - /* font transformation. This is _not_ the same */ - /* as the face transform set through */ - /* FT_Set_Transform(). */ - /* */ - /* glyph_matrix :: The 2x2 matrix corresponding to the glyph */ - /* transformation, if necessary. */ - /* */ - /* glyph_delta :: The 2d translation vector corresponding to */ - /* the glyph transformation, if necessary. */ - /* */ - /* glyph_hints :: Format-specific glyph hints management. */ - /* */ - -#define FT_GLYPH_OWN_BITMAP 0x1 - - typedef struct FT_Slot_InternalRec_ - { - FT_GlyphLoader loader; - FT_UInt flags; - FT_Bool glyph_transformed; - FT_Matrix glyph_matrix; - FT_Vector glyph_delta; - void* glyph_hints; - - } FT_GlyphSlot_InternalRec; - - -#if 0 - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_InternalRec */ - /* */ - /* <Description> */ - /* This structure contains the internal fields of each FT_Size */ - /* object. Currently, it's empty. */ - /* */ - /*************************************************************************/ - - typedef struct FT_Size_InternalRec_ - { - /* empty */ - - } FT_Size_InternalRec; - -#endif - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** M O D U L E S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ModuleRec */ - /* */ - /* <Description> */ - /* A module object instance. */ - /* */ - /* <Fields> */ - /* clazz :: A pointer to the module's class. */ - /* */ - /* library :: A handle to the parent library object. */ - /* */ - /* memory :: A handle to the memory manager. */ - /* */ - typedef struct FT_ModuleRec_ - { - FT_Module_Class* clazz; - FT_Library library; - FT_Memory memory; - - } FT_ModuleRec; - - - /* typecast an object to an FT_Module */ -#define FT_MODULE( x ) ((FT_Module)( x )) -#define FT_MODULE_CLASS( x ) FT_MODULE( x )->clazz -#define FT_MODULE_LIBRARY( x ) FT_MODULE( x )->library -#define FT_MODULE_MEMORY( x ) FT_MODULE( x )->memory - - -#define FT_MODULE_IS_DRIVER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ - FT_MODULE_FONT_DRIVER ) - -#define FT_MODULE_IS_RENDERER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ - FT_MODULE_RENDERER ) - -#define FT_MODULE_IS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ - FT_MODULE_HINTER ) - -#define FT_MODULE_IS_STYLER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ - FT_MODULE_STYLER ) - -#define FT_DRIVER_IS_SCALABLE( x ) ( FT_MODULE_CLASS( x )->module_flags & \ - FT_MODULE_DRIVER_SCALABLE ) - -#define FT_DRIVER_USES_OUTLINES( x ) !( FT_MODULE_CLASS( x )->module_flags & \ - FT_MODULE_DRIVER_NO_OUTLINES ) - -#define FT_DRIVER_HAS_HINTER( x ) ( FT_MODULE_CLASS( x )->module_flags & \ - FT_MODULE_DRIVER_HAS_HINTER ) - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Module_Interface */ - /* */ - /* <Description> */ - /* Finds a module and returns its specific interface as a typeless */ - /* pointer. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object. */ - /* */ - /* module_name :: The module's name (as an ASCII string). */ - /* */ - /* <Return> */ - /* A module-specific interface if available, 0 otherwise. */ - /* */ - /* <Note> */ - /* You should better be familiar with FreeType internals to know */ - /* which module to look for, and what its interface is :-) */ - /* */ - FT_BASE( const void* ) - FT_Get_Module_Interface( FT_Library library, - const char* mod_name ); - - FT_BASE( FT_Pointer ) - ft_module_get_service( FT_Module module, - const char* service_id ); - - /* */ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** F A C E, S I Z E & G L Y P H S L O T O B J E C T S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - /* a few macros used to perform easy typecasts with minimal brain damage */ - -#define FT_FACE( x ) ((FT_Face)(x)) -#define FT_SIZE( x ) ((FT_Size)(x)) -#define FT_SLOT( x ) ((FT_GlyphSlot)(x)) - -#define FT_FACE_DRIVER( x ) FT_FACE( x )->driver -#define FT_FACE_LIBRARY( x ) FT_FACE_DRIVER( x )->root.library -#define FT_FACE_MEMORY( x ) FT_FACE( x )->memory -#define FT_FACE_STREAM( x ) FT_FACE( x )->stream - -#define FT_SIZE_FACE( x ) FT_SIZE( x )->face -#define FT_SLOT_FACE( x ) FT_SLOT( x )->face - -#define FT_FACE_SLOT( x ) FT_FACE( x )->glyph -#define FT_FACE_SIZE( x ) FT_FACE( x )->size - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_GlyphSlot */ - /* */ - /* <Description> */ - /* It is sometimes useful to have more than one glyph slot for a */ - /* given face object. This function is used to create additional */ - /* slots. All of them are automatically discarded when the face is */ - /* destroyed. */ - /* */ - /* <Input> */ - /* face :: A handle to a parent face object. */ - /* */ - /* <Output> */ - /* aslot :: A handle to a new glyph slot object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - FT_BASE( FT_Error ) - FT_New_GlyphSlot( FT_Face face, - FT_GlyphSlot *aslot ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_GlyphSlot */ - /* */ - /* <Description> */ - /* Destroys a given glyph slot. Remember however that all slots are */ - /* automatically destroyed with its parent. Using this function is */ - /* not always mandatory. */ - /* */ - /* <Input> */ - /* slot :: A handle to a target glyph slot. */ - /* */ - FT_BASE( void ) - FT_Done_GlyphSlot( FT_GlyphSlot slot ); - - /* */ - -#define FT_REQUEST_WIDTH( req ) \ - ( (req)->horiResolution \ - ? (FT_Pos)( (req)->width * (req)->horiResolution + 36 ) / 72 \ - : (req)->width ) - -#define FT_REQUEST_HEIGHT( req ) \ - ( (req)->vertResolution \ - ? (FT_Pos)( (req)->height * (req)->vertResolution + 36 ) / 72 \ - : (req)->height ) - - - /* Set the metrics according to a bitmap strike. */ - FT_BASE( void ) - FT_Select_Metrics( FT_Face face, - FT_ULong strike_index ); - - - /* Set the metrics according to a size request. */ - FT_BASE( void ) - FT_Request_Metrics( FT_Face face, - FT_Size_Request req ); - - - /* Match a size request against `available_sizes'. */ - FT_BASE( FT_Error ) - FT_Match_Size( FT_Face face, - FT_Size_Request req, - FT_Bool ignore_width, - FT_ULong* size_index ); - - - /* Use the horizontal metrics to synthesize the vertical metrics. */ - /* If `advance' is zero, it is also synthesized. */ - FT_BASE( void ) - ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics, - FT_Pos advance ); - - - /* Free the bitmap of a given glyphslot when needed (i.e., only when it */ - /* was allocated with ft_glyphslot_alloc_bitmap). */ - FT_BASE( void ) - ft_glyphslot_free_bitmap( FT_GlyphSlot slot ); - - - /* Allocate a new bitmap buffer in a glyph slot. */ - FT_BASE( FT_Error ) - ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot, - FT_ULong size ); - - - /* Set the bitmap buffer in a glyph slot to a given pointer. The buffer */ - /* will not be freed by a later call to ft_glyphslot_free_bitmap. */ - FT_BASE( void ) - ft_glyphslot_set_bitmap( FT_GlyphSlot slot, - FT_Byte* buffer ); - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** R E N D E R E R S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - -#define FT_RENDERER( x ) ((FT_Renderer)( x )) -#define FT_GLYPH( x ) ((FT_Glyph)( x )) -#define FT_BITMAP_GLYPH( x ) ((FT_BitmapGlyph)( x )) -#define FT_OUTLINE_GLYPH( x ) ((FT_OutlineGlyph)( x )) - - - typedef struct FT_RendererRec_ - { - FT_ModuleRec root; - FT_Renderer_Class* clazz; - FT_Glyph_Format glyph_format; - FT_Glyph_Class glyph_class; - - FT_Raster raster; - FT_Raster_Render_Func raster_render; - FT_Renderer_RenderFunc render; - - } FT_RendererRec; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** F O N T D R I V E R S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* typecast a module into a driver easily */ -#define FT_DRIVER( x ) ((FT_Driver)(x)) - - /* typecast a module as a driver, and get its driver class */ -#define FT_DRIVER_CLASS( x ) FT_DRIVER( x )->clazz - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_DriverRec */ - /* */ - /* <Description> */ - /* The root font driver class. A font driver is responsible for */ - /* managing and loading font files of a given format. */ - /* */ - /* <Fields> */ - /* root :: Contains the fields of the root module class. */ - /* */ - /* clazz :: A pointer to the font driver's class. Note that */ - /* this is NOT root.clazz. `class' wasn't used */ - /* as it is a reserved word in C++. */ - /* */ - /* faces_list :: The list of faces currently opened by this */ - /* driver. */ - /* */ - /* glyph_loader :: The glyph loader for all faces managed by this */ - /* driver. This object isn't defined for unscalable */ - /* formats. */ - /* */ - typedef struct FT_DriverRec_ - { - FT_ModuleRec root; - FT_Driver_Class clazz; - FT_ListRec faces_list; - FT_GlyphLoader glyph_loader; - - } FT_DriverRec; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** L I B R A R I E S ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* This hook is used by the TrueType debugger. It must be set to an */ - /* alternate truetype bytecode interpreter function. */ -#define FT_DEBUG_HOOK_TRUETYPE 0 - - - /* Set this debug hook to a non-null pointer to force unpatented hinting */ - /* for all faces when both TT_USE_BYTECODE_INTERPRETER and */ - /* TT_CONFIG_OPTION_UNPATENTED_HINTING are defined. This is only used */ - /* during debugging. */ -#define FT_DEBUG_HOOK_UNPATENTED_HINTING 1 - - - typedef void (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap* bitmap, - FT_Render_Mode render_mode, - FT_Library library ); - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_LibraryRec */ - /* */ - /* <Description> */ - /* The FreeType library class. This is the root of all FreeType */ - /* data. Use FT_New_Library() to create a library object, and */ - /* FT_Done_Library() to discard it and all child objects. */ - /* */ - /* <Fields> */ - /* memory :: The library's memory object. Manages memory */ - /* allocation. */ - /* */ - /* version_major :: The major version number of the library. */ - /* */ - /* version_minor :: The minor version number of the library. */ - /* */ - /* version_patch :: The current patch level of the library. */ - /* */ - /* num_modules :: The number of modules currently registered */ - /* within this library. This is set to 0 for new */ - /* libraries. New modules are added through the */ - /* FT_Add_Module() API function. */ - /* */ - /* modules :: A table used to store handles to the currently */ - /* registered modules. Note that each font driver */ - /* contains a list of its opened faces. */ - /* */ - /* renderers :: The list of renderers currently registered */ - /* within the library. */ - /* */ - /* cur_renderer :: The current outline renderer. This is a */ - /* shortcut used to avoid parsing the list on */ - /* each call to FT_Outline_Render(). It is a */ - /* handle to the current renderer for the */ - /* FT_GLYPH_FORMAT_OUTLINE format. */ - /* */ - /* auto_hinter :: XXX */ - /* */ - /* raster_pool :: The raster object's render pool. This can */ - /* ideally be changed dynamically at run-time. */ - /* */ - /* raster_pool_size :: The size of the render pool in bytes. */ - /* */ - /* debug_hooks :: XXX */ - /* */ - /* lcd_filter :: If subpixel rendering is activated, the */ - /* selected LCD filter mode. */ - /* */ - /* lcd_extra :: If subpixel rendering is activated, the number */ - /* of extra pixels needed for the LCD filter. */ - /* */ - /* lcd_weights :: If subpixel rendering is activated, the LCD */ - /* filter weights, if any. */ - /* */ - /* lcd_filter_func :: If subpixel rendering is activated, the LCD */ - /* filtering callback function. */ - /* */ - /* pic_container :: Contains global structs and tables, instead */ - /* of defining them globallly. */ - /* */ - /* refcount :: A counter initialized to~1 at the time an */ - /* @FT_Library structure is created. */ - /* @FT_Reference_Library increments this counter, */ - /* and @FT_Done_Library only destroys a library */ - /* if the counter is~1, otherwise it simply */ - /* decrements it. */ - /* */ - typedef struct FT_LibraryRec_ - { - FT_Memory memory; /* library's memory manager */ - - FT_Int version_major; - FT_Int version_minor; - FT_Int version_patch; - - FT_UInt num_modules; - FT_Module modules[FT_MAX_MODULES]; /* module objects */ - - FT_ListRec renderers; /* list of renderers */ - FT_Renderer cur_renderer; /* current outline renderer */ - FT_Module auto_hinter; - - FT_Byte* raster_pool; /* scan-line conversion */ - /* render pool */ - FT_ULong raster_pool_size; /* size of render pool in bytes */ - - FT_DebugHook_Func debug_hooks[4]; - -#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - FT_LcdFilter lcd_filter; - FT_Int lcd_extra; /* number of extra pixels */ - FT_Byte lcd_weights[7]; /* filter weights, if any */ - FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */ -#endif - -#ifdef FT_CONFIG_OPTION_PIC - FT_PIC_Container pic_container; -#endif - - FT_Int refcount; - - } FT_LibraryRec; - - - FT_BASE( FT_Renderer ) - FT_Lookup_Renderer( FT_Library library, - FT_Glyph_Format format, - FT_ListNode* node ); - - FT_BASE( FT_Error ) - FT_Render_Glyph_Internal( FT_Library library, - FT_GlyphSlot slot, - FT_Render_Mode render_mode ); - - typedef const char* - (*FT_Face_GetPostscriptNameFunc)( FT_Face face ); - - typedef FT_Error - (*FT_Face_GetGlyphNameFunc)( FT_Face face, - FT_UInt glyph_index, - FT_Pointer buffer, - FT_UInt buffer_max ); - - typedef FT_UInt - (*FT_Face_GetGlyphNameIndexFunc)( FT_Face face, - FT_String* glyph_name ); - - -#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Memory */ - /* */ - /* <Description> */ - /* Creates a new memory object. */ - /* */ - /* <Return> */ - /* A pointer to the new memory object. 0 in case of error. */ - /* */ - FT_BASE( FT_Memory ) - FT_New_Memory( void ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Memory */ - /* */ - /* <Description> */ - /* Discards memory manager. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory manager. */ - /* */ - FT_BASE( void ) - FT_Done_Memory( FT_Memory memory ); - -#endif /* !FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */ - - - /* Define default raster's interface. The default raster is located in */ - /* `src/base/ftraster.c'. */ - /* */ - /* Client applications can register new rasters through the */ - /* FT_Set_Raster() API. */ - -#ifndef FT_NO_DEFAULT_RASTER - FT_EXPORT_VAR( FT_Raster_Funcs ) ft_default_raster; -#endif - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** P I C S U P P O R T ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* PIC support macros for ftimage.h */ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DEFINE_OUTLINE_FUNCS */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Outline_Funcs struct. */ - /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */ - /* be called with a pre-allocated structure to be filled. */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_OUTLINE_FUNCS( \ - class_, \ - move_to_, \ - line_to_, \ - conic_to_, \ - cubic_to_, \ - shift_, \ - delta_ ) \ - static const FT_Outline_Funcs class_ = \ - { \ - move_to_, \ - line_to_, \ - conic_to_, \ - cubic_to_, \ - shift_, \ - delta_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_OUTLINE_FUNCS( \ - class_, \ - move_to_, \ - line_to_, \ - conic_to_, \ - cubic_to_, \ - shift_, \ - delta_ ) \ - static FT_Error \ - Init_Class_ ## class_( FT_Outline_Funcs* clazz ) \ - { \ - clazz->move_to = move_to_; \ - clazz->line_to = line_to_; \ - clazz->conic_to = conic_to_; \ - clazz->cubic_to = cubic_to_; \ - clazz->shift = shift_; \ - clazz->delta = delta_; \ - \ - return FT_Err_Ok; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DEFINE_RASTER_FUNCS */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Raster_Funcs struct. */ - /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */ - /* be called with a pre-allocated structure to be filled. */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_RASTER_FUNCS( \ - class_, \ - glyph_format_, \ - raster_new_, \ - raster_reset_, \ - raster_set_mode_, \ - raster_render_, \ - raster_done_ ) \ - const FT_Raster_Funcs class_ = \ - { \ - glyph_format_, \ - raster_new_, \ - raster_reset_, \ - raster_set_mode_, \ - raster_render_, \ - raster_done_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_RASTER_FUNCS( \ - class_, \ - glyph_format_, \ - raster_new_, \ - raster_reset_, \ - raster_set_mode_, \ - raster_render_, \ - raster_done_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Raster_Funcs* clazz ) \ - { \ - clazz->glyph_format = glyph_format_; \ - clazz->raster_new = raster_new_; \ - clazz->raster_reset = raster_reset_; \ - clazz->raster_set_mode = raster_set_mode_; \ - clazz->raster_render = raster_render_; \ - clazz->raster_done = raster_done_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - - /* PIC support macros for ftrender.h */ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DEFINE_GLYPH */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Glyph_Class struct. */ - /* When FT_CONFIG_OPTION_PIC is defined an init funtion will need to */ - /* be called with a pre-allocated stcture to be filled. */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_GLYPH( \ - class_, \ - size_, \ - format_, \ - init_, \ - done_, \ - copy_, \ - transform_, \ - bbox_, \ - prepare_ ) \ - FT_CALLBACK_TABLE_DEF \ - const FT_Glyph_Class class_ = \ - { \ - size_, \ - format_, \ - init_, \ - done_, \ - copy_, \ - transform_, \ - bbox_, \ - prepare_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_GLYPH( \ - class_, \ - size_, \ - format_, \ - init_, \ - done_, \ - copy_, \ - transform_, \ - bbox_, \ - prepare_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Glyph_Class* clazz ) \ - { \ - clazz->glyph_size = size_; \ - clazz->glyph_format = format_; \ - clazz->glyph_init = init_; \ - clazz->glyph_done = done_; \ - clazz->glyph_copy = copy_; \ - clazz->glyph_transform = transform_; \ - clazz->glyph_bbox = bbox_; \ - clazz->glyph_prepare = prepare_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DECLARE_RENDERER */ - /* */ - /* <Description> */ - /* Used to create a forward declaration of a */ - /* FT_Renderer_Class struct instance. */ - /* */ - /* <Macro> */ - /* FT_DEFINE_RENDERER */ - /* */ - /* <Description> */ - /* Used to initialize an instance of FT_Renderer_Class struct. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is defined a `create' funtion will need */ - /* to be called with a pointer where the allocated structure is */ - /* returned. And when it is no longer needed a `destroy' function */ - /* needs to be called to release that allocation. */ - /* `fcinit.c' (ft_create_default_module_classes) already contains */ - /* a mechanism to call these functions for the default modules */ - /* described in `ftmodule.h'. */ - /* */ - /* Notice that the created `create' and `destroy' functions call */ - /* `pic_init' and `pic_free' to allow you to manually allocate and */ - /* initialize any additional global data, like a module specific */ - /* interface, and put them in the global pic container defined in */ - /* `ftpic.h'. If you don't need them just implement the functions as */ - /* empty to resolve the link error. Also the `pic_init' and */ - /* `pic_free' functions should be declared in `pic.h', to be referred */ - /* by the renderer definition calling `FT_DEFINE_RENDERER' in the */ - /* following. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DECLARE_RENDERER( class_ ) \ - FT_EXPORT_VAR( const FT_Renderer_Class ) class_; - -#define FT_DEFINE_RENDERER( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_, \ - glyph_format_, \ - render_glyph_, \ - transform_glyph_, \ - get_glyph_cbox_, \ - set_mode_, \ - raster_class_ ) \ - FT_CALLBACK_TABLE_DEF \ - const FT_Renderer_Class class_ = \ - { \ - FT_DEFINE_ROOT_MODULE( flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - glyph_format_, \ - \ - render_glyph_, \ - transform_glyph_, \ - get_glyph_cbox_, \ - set_mode_, \ - \ - raster_class_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DECLARE_RENDERER( class_ ) FT_DECLARE_MODULE( class_ ) - -#define FT_DEFINE_RENDERER( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_, \ - glyph_format_, \ - render_glyph_, \ - transform_glyph_, \ - get_glyph_cbox_, \ - set_mode_, \ - raster_class_ ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_Module_Class* clazz ) \ - { \ - FT_Renderer_Class* rclazz = (FT_Renderer_Class*)clazz; \ - FT_Memory memory = library->memory; \ - \ - \ - class_ ## _pic_free( library ); \ - if ( rclazz ) \ - FT_FREE( rclazz ); \ - } \ - \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_Module_Class** output_class ) \ - { \ - FT_Renderer_Class* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ - return error; \ - \ - error = class_ ## _pic_init( library ); \ - if ( error ) \ - { \ - FT_FREE( clazz ); \ - return error; \ - } \ - \ - FT_DEFINE_ROOT_MODULE( flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - \ - clazz->glyph_format = glyph_format_; \ - \ - clazz->render_glyph = render_glyph_; \ - clazz->transform_glyph = transform_glyph_; \ - clazz->get_glyph_cbox = get_glyph_cbox_; \ - clazz->set_mode = set_mode_; \ - \ - clazz->raster_class = raster_class_; \ - \ - *output_class = (FT_Module_Class*)clazz; \ - \ - return FT_Err_Ok; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - - /* PIC support macros for ftmodapi.h **/ - - -#ifdef FT_CONFIG_OPTION_PIC - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Creator */ - /* */ - /* <Description> */ - /* A function used to create (allocate) a new module class object. */ - /* The object's members are initialized, but the module itself is */ - /* not. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory manager. */ - /* output_class :: Initialized with the newly allocated class. */ - /* */ - typedef FT_Error - (*FT_Module_Creator)( FT_Memory memory, - FT_Module_Class** output_class ); - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Destroyer */ - /* */ - /* <Description> */ - /* A function used to destroy (deallocate) a module class object. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory manager. */ - /* clazz :: Module class to destroy. */ - /* */ - typedef void - (*FT_Module_Destroyer)( FT_Memory memory, - FT_Module_Class* clazz ); - -#endif - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DECLARE_MODULE */ - /* */ - /* <Description> */ - /* Used to create a forward declaration of a */ - /* FT_Module_Class struct instance. */ - /* */ - /* <Macro> */ - /* FT_DEFINE_MODULE */ - /* */ - /* <Description> */ - /* Used to initialize an instance of an FT_Module_Class struct. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is defined a `create' funtion needs to */ - /* be called with a pointer where the allocated structure is */ - /* returned. And when it is no longer needed a `destroy' function */ - /* needs to be called to release that allocation. */ - /* `fcinit.c' (ft_create_default_module_classes) already contains */ - /* a mechanism to call these functions for the default modules */ - /* described in `ftmodule.h'. */ - /* */ - /* Notice that the created `create' and `destroy' functions call */ - /* `pic_init' and `pic_free' to allow you to manually allocate and */ - /* initialize any additional global data, like a module specific */ - /* interface, and put them in the global pic container defined in */ - /* `ftpic.h'. If you don't need them just implement the functions as */ - /* empty to resolve the link error. Also the `pic_init' and */ - /* `pic_free' functions should be declared in `pic.h', to be referred */ - /* by the module definition calling `FT_DEFINE_MODULE' in the */ - /* following. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is not defined the struct will be */ - /* allocated in the global scope (or the scope where the macro */ - /* is used). */ - /* */ - /* <Macro> */ - /* FT_DEFINE_ROOT_MODULE */ - /* */ - /* <Description> */ - /* Used to initialize an instance of an FT_Module_Class struct inside */ - /* another struct that contains it or in a function that initializes */ - /* that containing struct. */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DECLARE_MODULE( class_ ) \ - FT_CALLBACK_TABLE \ - const FT_Module_Class class_; - -#define FT_DEFINE_ROOT_MODULE( \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - { \ - flags_, \ - size_, \ - \ - name_, \ - version_, \ - requires_, \ - \ - interface_, \ - \ - init_, \ - done_, \ - get_interface_, \ - }, - -#define FT_DEFINE_MODULE( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - FT_CALLBACK_TABLE_DEF \ - const FT_Module_Class class_ = \ - { \ - flags_, \ - size_, \ - \ - name_, \ - version_, \ - requires_, \ - \ - interface_, \ - \ - init_, \ - done_, \ - get_interface_, \ - }; - - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DECLARE_MODULE( class_ ) \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_Module_Class** output_class ); \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_Module_Class* clazz ); - -#define FT_DEFINE_ROOT_MODULE( \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - clazz->root.module_flags = flags_; \ - clazz->root.module_size = size_; \ - clazz->root.module_name = name_; \ - clazz->root.module_version = version_; \ - clazz->root.module_requires = requires_; \ - \ - clazz->root.module_interface = interface_; \ - \ - clazz->root.module_init = init_; \ - clazz->root.module_done = done_; \ - clazz->root.get_interface = get_interface_; - -#define FT_DEFINE_MODULE( \ - class_, \ - flags_, \ - size_, \ - name_, \ - version_, \ - requires_, \ - interface_, \ - init_, \ - done_, \ - get_interface_ ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_Module_Class* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - class_ ## _pic_free( library ); \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_Module_Class** output_class ) \ - { \ - FT_Memory memory = library->memory; \ - FT_Module_Class* clazz = NULL; \ - FT_Error error; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) ) ) \ - return error; \ - error = class_ ## _pic_init( library ); \ - if ( error ) \ - { \ - FT_FREE( clazz ); \ - return error; \ - } \ - \ - clazz->module_flags = flags_; \ - clazz->module_size = size_; \ - clazz->module_name = name_; \ - clazz->module_version = version_; \ - clazz->module_requires = requires_; \ - \ - clazz->module_interface = interface_; \ - \ - clazz->module_init = init_; \ - clazz->module_done = done_; \ - clazz->get_interface = get_interface_; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - -FT_END_HEADER - -#endif /* __FTOBJS_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/ftpic.h b/thirdparty/include/freetype/internal/ftpic.h deleted file mode 100644 index 485ce7a24..000000000 --- a/thirdparty/include/freetype/internal/ftpic.h +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftpic.h */ -/* */ -/* The FreeType position independent code services (declaration). */ -/* */ -/* Copyright 2009, 2012 by */ -/* Oran Agra and Mickey Gabel. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* Modules that ordinarily have const global data that need address */ - /* can instead define pointers here. */ - /* */ - /*************************************************************************/ - - -#ifndef __FTPIC_H__ -#define __FTPIC_H__ - - -FT_BEGIN_HEADER - -#ifdef FT_CONFIG_OPTION_PIC - - typedef struct FT_PIC_Container_ - { - /* pic containers for base */ - void* base; - - /* pic containers for modules */ - void* autofit; - void* cff; - void* pshinter; - void* psnames; - void* raster; - void* sfnt; - void* smooth; - void* truetype; - - } FT_PIC_Container; - - - /* Initialize the various function tables, structs, etc. */ - /* stored in the container. */ - FT_BASE( FT_Error ) - ft_pic_container_init( FT_Library library ); - - - /* Destroy the contents of the container. */ - FT_BASE( void ) - ft_pic_container_destroy( FT_Library library ); - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - -FT_END_HEADER - -#endif /* __FTPIC_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/ftrfork.h b/thirdparty/include/freetype/internal/ftrfork.h deleted file mode 100644 index 1e16de265..000000000 --- a/thirdparty/include/freetype/internal/ftrfork.h +++ /dev/null @@ -1,266 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftrfork.h */ -/* */ -/* Embedded resource forks accessor (specification). */ -/* */ -/* Copyright 2004, 2006, 2007, 2012, 2013 by */ -/* Masatake YAMATO and Redhat K.K. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* Development of the code in this file is support of */ -/* Information-technology Promotion Agency, Japan. */ -/***************************************************************************/ - - -#ifndef __FTRFORK_H__ -#define __FTRFORK_H__ - - -#include <freetype/ft2build.h> -#include FT_INTERNAL_OBJECTS_H - - -FT_BEGIN_HEADER - - - /* Number of guessing rules supported in `FT_Raccess_Guess'. */ - /* Don't forget to increment the number if you add a new guessing rule. */ -#define FT_RACCESS_N_RULES 9 - - - /* A structure to describe a reference in a resource by its resource ID */ - /* and internal offset. The `POST' resource expects to be concatenated */ - /* by the order of resource IDs instead of its appearance in the file. */ - - typedef struct FT_RFork_Ref_ - { - FT_UShort res_id; - FT_ULong offset; - - } FT_RFork_Ref; - -#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK - typedef FT_Error - (*ft_raccess_guess_func)( FT_Library library, - FT_Stream stream, - char *base_file_name, - char **result_file_name, - FT_Long *result_offset ); - - typedef enum FT_RFork_Rule_ { - FT_RFork_Rule_invalid = -2, - FT_RFork_Rule_uknown, /* -1 */ - FT_RFork_Rule_apple_double, - FT_RFork_Rule_apple_single, - FT_RFork_Rule_darwin_ufs_export, - FT_RFork_Rule_darwin_newvfs, - FT_RFork_Rule_darwin_hfsplus, - FT_RFork_Rule_vfat, - FT_RFork_Rule_linux_cap, - FT_RFork_Rule_linux_double, - FT_RFork_Rule_linux_netatalk - } FT_RFork_Rule; - - /* For fast translation between rule index and rule type, - * the macros FT_RFORK_xxx should be kept consistent with - * the raccess_guess_funcs table - */ - typedef struct ft_raccess_guess_rec_ { - ft_raccess_guess_func func; - FT_RFork_Rule type; - } ft_raccess_guess_rec; - -#ifndef FT_CONFIG_OPTION_PIC - - /* this array is a storage in non-PIC mode, so ; is needed in END */ -#define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \ - const type name[] = { -#define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \ - { raccess_guess_ ## func_suffix, \ - FT_RFork_Rule_ ## type_suffix }, -#define CONST_FT_RFORK_RULE_ARRAY_END }; - -#else /* FT_CONFIG_OPTION_PIC */ - - /* this array is a function in PIC mode, so no ; is needed in END */ -#define CONST_FT_RFORK_RULE_ARRAY_BEGIN( name, type ) \ - void \ - FT_Init_Table_ ## name( type* storage ) \ - { \ - type* local = storage; \ - \ - \ - int i = 0; -#define CONST_FT_RFORK_RULE_ARRAY_ENTRY( func_suffix, type_suffix ) \ - local[i].func = raccess_guess_ ## func_suffix; \ - local[i].type = FT_RFork_Rule_ ## type_suffix; \ - i++; -#define CONST_FT_RFORK_RULE_ARRAY_END } - -#endif /* FT_CONFIG_OPTION_PIC */ - -#endif /* FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Raccess_Guess */ - /* */ - /* <Description> */ - /* Guess a file name and offset where the actual resource fork is */ - /* stored. The macro FT_RACCESS_N_RULES holds the number of */ - /* guessing rules; the guessed result for the Nth rule is */ - /* represented as a triplet: a new file name (new_names[N]), a file */ - /* offset (offsets[N]), and an error code (errors[N]). */ - /* */ - /* <Input> */ - /* library :: */ - /* A FreeType library instance. */ - /* */ - /* stream :: */ - /* A file stream containing the resource fork. */ - /* */ - /* base_name :: */ - /* The (base) file name of the resource fork used for some */ - /* guessing rules. */ - /* */ - /* <Output> */ - /* new_names :: */ - /* An array of guessed file names in which the resource forks may */ - /* exist. If `new_names[N]' is NULL, the guessed file name is */ - /* equal to `base_name'. */ - /* */ - /* offsets :: */ - /* An array of guessed file offsets. `offsets[N]' holds the file */ - /* offset of the possible start of the resource fork in file */ - /* `new_names[N]'. */ - /* */ - /* errors :: */ - /* An array of FreeType error codes. `errors[N]' is the error */ - /* code of Nth guessing rule function. If `errors[N]' is not */ - /* FT_Err_Ok, `new_names[N]' and `offsets[N]' are meaningless. */ - /* */ - FT_BASE( void ) - FT_Raccess_Guess( FT_Library library, - FT_Stream stream, - char* base_name, - char** new_names, - FT_Long* offsets, - FT_Error* errors ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Raccess_Get_HeaderInfo */ - /* */ - /* <Description> */ - /* Get the information from the header of resource fork. The */ - /* information includes the file offset where the resource map */ - /* starts, and the file offset where the resource data starts. */ - /* `FT_Raccess_Get_DataOffsets' requires these two data. */ - /* */ - /* <Input> */ - /* library :: */ - /* A FreeType library instance. */ - /* */ - /* stream :: */ - /* A file stream containing the resource fork. */ - /* */ - /* rfork_offset :: */ - /* The file offset where the resource fork starts. */ - /* */ - /* <Output> */ - /* map_offset :: */ - /* The file offset where the resource map starts. */ - /* */ - /* rdata_pos :: */ - /* The file offset where the resource data starts. */ - /* */ - /* <Return> */ - /* FreeType error code. FT_Err_Ok means success. */ - /* */ - FT_BASE( FT_Error ) - FT_Raccess_Get_HeaderInfo( FT_Library library, - FT_Stream stream, - FT_Long rfork_offset, - FT_Long *map_offset, - FT_Long *rdata_pos ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Raccess_Get_DataOffsets */ - /* */ - /* <Description> */ - /* Get the data offsets for a tag in a resource fork. Offsets are */ - /* stored in an array because, in some cases, resources in a resource */ - /* fork have the same tag. */ - /* */ - /* <Input> */ - /* library :: */ - /* A FreeType library instance. */ - /* */ - /* stream :: */ - /* A file stream containing the resource fork. */ - /* */ - /* map_offset :: */ - /* The file offset where the resource map starts. */ - /* */ - /* rdata_pos :: */ - /* The file offset where the resource data starts. */ - /* */ - /* tag :: */ - /* The resource tag. */ - /* */ - /* sort_by_res_id :: */ - /* A Boolean to sort the fragmented resource by their ids. */ - /* The fragmented resources for `POST' resource should be sorted */ - /* to restore Type1 font properly. For `snft' resources, sorting */ - /* may induce a different order of the faces in comparison to that */ - /* by QuickDraw API. */ - /* */ - /* <Output> */ - /* offsets :: */ - /* The stream offsets for the resource data specified by `tag'. */ - /* This array is allocated by the function, so you have to call */ - /* @ft_mem_free after use. */ - /* */ - /* count :: */ - /* The length of offsets array. */ - /* */ - /* <Return> */ - /* FreeType error code. FT_Err_Ok means success. */ - /* */ - /* <Note> */ - /* Normally you should use `FT_Raccess_Get_HeaderInfo' to get the */ - /* value for `map_offset' and `rdata_pos'. */ - /* */ - FT_BASE( FT_Error ) - FT_Raccess_Get_DataOffsets( FT_Library library, - FT_Stream stream, - FT_Long map_offset, - FT_Long rdata_pos, - FT_Long tag, - FT_Bool sort_by_res_id, - FT_Long **offsets, - FT_Long *count ); - - -FT_END_HEADER - -#endif /* __FTRFORK_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/ftserv.h b/thirdparty/include/freetype/internal/ftserv.h deleted file mode 100644 index 1203ec812..000000000 --- a/thirdparty/include/freetype/internal/ftserv.h +++ /dev/null @@ -1,763 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftserv.h */ -/* */ -/* The FreeType services (specification only). */ -/* */ -/* Copyright 2003-2007, 2009, 2012, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* Each module can export one or more `services'. Each service is */ - /* identified by a constant string and modeled by a pointer; the latter */ - /* generally corresponds to a structure containing function pointers. */ - /* */ - /* Note that a service's data cannot be a mere function pointer because */ - /* in C it is possible that function pointers might be implemented */ - /* differently than data pointers (e.g. 48 bits instead of 32). */ - /* */ - /*************************************************************************/ - - -#ifndef __FTSERV_H__ -#define __FTSERV_H__ - - -FT_BEGIN_HEADER - - /* - * @macro: - * FT_FACE_FIND_SERVICE - * - * @description: - * This macro is used to look up a service from a face's driver module. - * - * @input: - * face :: - * The source face handle. - * - * id :: - * A string describing the service as defined in the service's - * header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to - * `multi-masters'). It is automatically prefixed with - * `FT_SERVICE_ID_'. - * - * @output: - * ptr :: - * A variable that receives the service pointer. Will be NULL - * if not found. - */ -#ifdef __cplusplus - -#define FT_FACE_FIND_SERVICE( face, ptr, id ) \ - FT_BEGIN_STMNT \ - FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \ - FT_Pointer _tmp_ = NULL; \ - FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \ - \ - \ - if ( module->clazz->get_interface ) \ - _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \ - *_pptr_ = _tmp_; \ - FT_END_STMNT - -#else /* !C++ */ - -#define FT_FACE_FIND_SERVICE( face, ptr, id ) \ - FT_BEGIN_STMNT \ - FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \ - FT_Pointer _tmp_ = NULL; \ - \ - if ( module->clazz->get_interface ) \ - _tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \ - ptr = _tmp_; \ - FT_END_STMNT - -#endif /* !C++ */ - - - /* - * @macro: - * FT_FACE_FIND_GLOBAL_SERVICE - * - * @description: - * This macro is used to look up a service from all modules. - * - * @input: - * face :: - * The source face handle. - * - * id :: - * A string describing the service as defined in the service's - * header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to - * `multi-masters'). It is automatically prefixed with - * `FT_SERVICE_ID_'. - * - * @output: - * ptr :: - * A variable that receives the service pointer. Will be NULL - * if not found. - */ -#ifdef __cplusplus - -#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \ - FT_BEGIN_STMNT \ - FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \ - FT_Pointer _tmp_; \ - FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \ - \ - \ - _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \ - *_pptr_ = _tmp_; \ - FT_END_STMNT - -#else /* !C++ */ - -#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \ - FT_BEGIN_STMNT \ - FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \ - FT_Pointer _tmp_; \ - \ - \ - _tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \ - ptr = _tmp_; \ - FT_END_STMNT - -#endif /* !C++ */ - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** S E R V I C E D E S C R I P T O R S *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /* - * The following structure is used to _describe_ a given service - * to the library. This is useful to build simple static service lists. - */ - typedef struct FT_ServiceDescRec_ - { - const char* serv_id; /* service name */ - const void* serv_data; /* service pointer/data */ - - } FT_ServiceDescRec; - - typedef const FT_ServiceDescRec* FT_ServiceDesc; - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_DEFINE_SERVICEDESCREC1 */ - /* FT_DEFINE_SERVICEDESCREC2 */ - /* FT_DEFINE_SERVICEDESCREC3 */ - /* FT_DEFINE_SERVICEDESCREC4 */ - /* FT_DEFINE_SERVICEDESCREC5 */ - /* FT_DEFINE_SERVICEDESCREC6 */ - /* FT_DEFINE_SERVICEDESCREC7 */ - /* */ - /* <Description> */ - /* Used to initialize an array of FT_ServiceDescRec structures. */ - /* */ - /* When FT_CONFIG_OPTION_PIC is defined a `create' function needs to */ - /* be called with a pointer to return an allocated array. As soon as */ - /* it is no longer needed, a `destroy' function needs to be called to */ - /* release that allocation. */ - /* */ - /* These functions should be manually called from the `pic_init' and */ - /* `pic_free' functions of your module (see FT_DEFINE_MODULE). */ - /* */ - /* When FT_CONFIG_OPTION_PIC is not defined the array will be */ - /* allocated in the global scope (or the scope where the macro is */ - /* used). */ - /* */ -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICEDESCREC1( class_, \ - serv_id_1, serv_data_1 ) \ - static const FT_ServiceDescRec class_[] = \ - { \ - { serv_id_1, serv_data_1 }, \ - { NULL, NULL } \ - }; - -#define FT_DEFINE_SERVICEDESCREC2( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2 ) \ - static const FT_ServiceDescRec class_[] = \ - { \ - { serv_id_1, serv_data_1 }, \ - { serv_id_2, serv_data_2 }, \ - { NULL, NULL } \ - }; - -#define FT_DEFINE_SERVICEDESCREC3( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3 ) \ - static const FT_ServiceDescRec class_[] = \ - { \ - { serv_id_1, serv_data_1 }, \ - { serv_id_2, serv_data_2 }, \ - { serv_id_3, serv_data_3 }, \ - { NULL, NULL } \ - }; - -#define FT_DEFINE_SERVICEDESCREC4( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4 ) \ - static const FT_ServiceDescRec class_[] = \ - { \ - { serv_id_1, serv_data_1 }, \ - { serv_id_2, serv_data_2 }, \ - { serv_id_3, serv_data_3 }, \ - { serv_id_4, serv_data_4 }, \ - { NULL, NULL } \ - }; - -#define FT_DEFINE_SERVICEDESCREC5( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5 ) \ - static const FT_ServiceDescRec class_[] = \ - { \ - { serv_id_1, serv_data_1 }, \ - { serv_id_2, serv_data_2 }, \ - { serv_id_3, serv_data_3 }, \ - { serv_id_4, serv_data_4 }, \ - { serv_id_5, serv_data_5 }, \ - { NULL, NULL } \ - }; - -#define FT_DEFINE_SERVICEDESCREC6( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6 ) \ - static const FT_ServiceDescRec class_[] = \ - { \ - { serv_id_1, serv_data_1 }, \ - { serv_id_2, serv_data_2 }, \ - { serv_id_3, serv_data_3 }, \ - { serv_id_4, serv_data_4 }, \ - { serv_id_5, serv_data_5 }, \ - { serv_id_6, serv_data_6 }, \ - { NULL, NULL } \ - }; - -#define FT_DEFINE_SERVICEDESCREC7( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6, \ - serv_id_7, serv_data_7 ) \ - static const FT_ServiceDescRec class_[] = \ - { \ - { serv_id_1, serv_data_1 }, \ - { serv_id_2, serv_data_2 }, \ - { serv_id_3, serv_data_3 }, \ - { serv_id_4, serv_data_4 }, \ - { serv_id_5, serv_data_5 }, \ - { serv_id_6, serv_data_6 }, \ - { serv_id_7, serv_data_7 }, \ - { NULL, NULL } \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICEDESCREC1( class_, \ - serv_id_1, serv_data_1 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 2 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = NULL; \ - clazz[1].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC2( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 3 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = NULL; \ - clazz[2].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC3( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 4 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = NULL; \ - clazz[3].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC4( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 5 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = NULL; \ - clazz[4].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC5( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class ) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 6 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = NULL; \ - clazz[5].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC6( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 7 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = serv_id_6; \ - clazz[5].serv_data = serv_data_6; \ - clazz[6].serv_id = NULL; \ - clazz[6].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#define FT_DEFINE_SERVICEDESCREC7( class_, \ - serv_id_1, serv_data_1, \ - serv_id_2, serv_data_2, \ - serv_id_3, serv_data_3, \ - serv_id_4, serv_data_4, \ - serv_id_5, serv_data_5, \ - serv_id_6, serv_data_6, \ - serv_id_7, serv_data_7 ) \ - void \ - FT_Destroy_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec* clazz ) \ - { \ - FT_Memory memory = library->memory; \ - \ - \ - if ( clazz ) \ - FT_FREE( clazz ); \ - } \ - \ - FT_Error \ - FT_Create_Class_ ## class_( FT_Library library, \ - FT_ServiceDescRec** output_class) \ - { \ - FT_ServiceDescRec* clazz = NULL; \ - FT_Error error; \ - FT_Memory memory = library->memory; \ - \ - \ - if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 8 ) ) \ - return error; \ - \ - clazz[0].serv_id = serv_id_1; \ - clazz[0].serv_data = serv_data_1; \ - clazz[1].serv_id = serv_id_2; \ - clazz[1].serv_data = serv_data_2; \ - clazz[2].serv_id = serv_id_3; \ - clazz[2].serv_data = serv_data_3; \ - clazz[3].serv_id = serv_id_4; \ - clazz[3].serv_data = serv_data_4; \ - clazz[4].serv_id = serv_id_5; \ - clazz[4].serv_data = serv_data_5; \ - clazz[5].serv_id = serv_id_6; \ - clazz[5].serv_data = serv_data_6; \ - clazz[6].serv_id = serv_id_7; \ - clazz[6].serv_data = serv_data_7; \ - clazz[7].serv_id = NULL; \ - clazz[7].serv_data = NULL; \ - \ - *output_class = clazz; \ - \ - return FT_Err_Ok; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - - /* - * Parse a list of FT_ServiceDescRec descriptors and look for - * a specific service by ID. Note that the last element in the - * array must be { NULL, NULL }, and that the function should - * return NULL if the service isn't available. - * - * This function can be used by modules to implement their - * `get_service' method. - */ - FT_BASE( FT_Pointer ) - ft_service_list_lookup( FT_ServiceDesc service_descriptors, - const char* service_id ); - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** S E R V I C E S C A C H E *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /* - * This structure is used to store a cache for several frequently used - * services. It is the type of `face->internal->services'. You - * should only use FT_FACE_LOOKUP_SERVICE to access it. - * - * All fields should have the type FT_Pointer to relax compilation - * dependencies. We assume the developer isn't completely stupid. - * - * Each field must be named `service_XXXX' where `XXX' corresponds to - * the correct FT_SERVICE_ID_XXXX macro. See the definition of - * FT_FACE_LOOKUP_SERVICE below how this is implemented. - * - */ - typedef struct FT_ServiceCacheRec_ - { - FT_Pointer service_POSTSCRIPT_FONT_NAME; - FT_Pointer service_MULTI_MASTERS; - FT_Pointer service_GLYPH_DICT; - FT_Pointer service_PFR_METRICS; - FT_Pointer service_WINFNT; - - } FT_ServiceCacheRec, *FT_ServiceCache; - - - /* - * A magic number used within the services cache. - */ - - /* ensure that value `1' has the same width as a pointer */ -#define FT_SERVICE_UNAVAILABLE ((FT_Pointer)~(FT_PtrDist)1) - - - /* - * @macro: - * FT_FACE_LOOKUP_SERVICE - * - * @description: - * This macro is used to lookup a service from a face's driver module - * using its cache. - * - * @input: - * face:: - * The source face handle containing the cache. - * - * field :: - * The field name in the cache. - * - * id :: - * The service ID. - * - * @output: - * ptr :: - * A variable receiving the service data. NULL if not available. - */ -#ifdef __cplusplus - -#define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \ - FT_BEGIN_STMNT \ - FT_Pointer svc; \ - FT_Pointer* Pptr = (FT_Pointer*)&(ptr); \ - \ - \ - svc = FT_FACE( face )->internal->services. service_ ## id; \ - if ( svc == FT_SERVICE_UNAVAILABLE ) \ - svc = NULL; \ - else if ( svc == NULL ) \ - { \ - FT_FACE_FIND_SERVICE( face, svc, id ); \ - \ - FT_FACE( face )->internal->services. service_ ## id = \ - (FT_Pointer)( svc != NULL ? svc \ - : FT_SERVICE_UNAVAILABLE ); \ - } \ - *Pptr = svc; \ - FT_END_STMNT - -#else /* !C++ */ - -#define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \ - FT_BEGIN_STMNT \ - FT_Pointer svc; \ - \ - \ - svc = FT_FACE( face )->internal->services. service_ ## id; \ - if ( svc == FT_SERVICE_UNAVAILABLE ) \ - svc = NULL; \ - else if ( svc == NULL ) \ - { \ - FT_FACE_FIND_SERVICE( face, svc, id ); \ - \ - FT_FACE( face )->internal->services. service_ ## id = \ - (FT_Pointer)( svc != NULL ? svc \ - : FT_SERVICE_UNAVAILABLE ); \ - } \ - ptr = svc; \ - FT_END_STMNT - -#endif /* !C++ */ - - /* - * A macro used to define new service structure types. - */ - -#define FT_DEFINE_SERVICE( name ) \ - typedef struct FT_Service_ ## name ## Rec_ \ - FT_Service_ ## name ## Rec ; \ - typedef struct FT_Service_ ## name ## Rec_ \ - const * FT_Service_ ## name ; \ - struct FT_Service_ ## name ## Rec_ - - /* */ - - /* - * The header files containing the services. - */ - -#define FT_SERVICE_BDF_H <internal/services/svbdf.h> -#define FT_SERVICE_CID_H <internal/services/svcid.h> -#define FT_SERVICE_GLYPH_DICT_H <internal/services/svgldict.h> -#define FT_SERVICE_GX_VALIDATE_H <internal/services/svgxval.h> -#define FT_SERVICE_KERNING_H <internal/services/svkern.h> -#define FT_SERVICE_MULTIPLE_MASTERS_H <internal/services/svmm.h> -#define FT_SERVICE_OPENTYPE_VALIDATE_H <internal/services/svotval.h> -#define FT_SERVICE_PFR_H <internal/services/svpfr.h> -#define FT_SERVICE_POSTSCRIPT_CMAPS_H <internal/services/svpscmap.h> -#define FT_SERVICE_POSTSCRIPT_INFO_H <internal/services/svpsinfo.h> -#define FT_SERVICE_POSTSCRIPT_NAME_H <internal/services/svpostnm.h> -#define FT_SERVICE_PROPERTIES_H <internal/services/svprop.h> -#define FT_SERVICE_SFNT_H <internal/services/svsfnt.h> -#define FT_SERVICE_TRUETYPE_ENGINE_H <internal/services/svtteng.h> -#define FT_SERVICE_TT_CMAP_H <internal/services/svttcmap.h> -#define FT_SERVICE_WINFNT_H <internal/services/svwinfnt.h> -#define FT_SERVICE_XFREE86_NAME_H <internal/services/svxf86nm.h> -#define FT_SERVICE_TRUETYPE_GLYF_H <internal/services/svttglyf.h> - - /* */ - -FT_END_HEADER - -#endif /* __FTSERV_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/ftstream.h b/thirdparty/include/freetype/internal/ftstream.h deleted file mode 100644 index bf52c5907..000000000 --- a/thirdparty/include/freetype/internal/ftstream.h +++ /dev/null @@ -1,536 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftstream.h */ -/* */ -/* Stream handling (specification). */ -/* */ -/* Copyright 1996-2002, 2004-2006, 2011, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTSTREAM_H__ -#define __FTSTREAM_H__ - - -#include <freetype/ft2build.h> -#include FT_SYSTEM_H -#include FT_INTERNAL_OBJECTS_H - - -FT_BEGIN_HEADER - - - /* format of an 8-bit frame_op value: */ - /* */ - /* bit 76543210 */ - /* xxxxxxes */ - /* */ - /* s is set to 1 if the value is signed. */ - /* e is set to 1 if the value is little-endian. */ - /* xxx is a command. */ - -#define FT_FRAME_OP_SHIFT 2 -#define FT_FRAME_OP_SIGNED 1 -#define FT_FRAME_OP_LITTLE 2 -#define FT_FRAME_OP_COMMAND( x ) ( x >> FT_FRAME_OP_SHIFT ) - -#define FT_MAKE_FRAME_OP( command, little, sign ) \ - ( ( command << FT_FRAME_OP_SHIFT ) | ( little << 1 ) | sign ) - -#define FT_FRAME_OP_END 0 -#define FT_FRAME_OP_START 1 /* start a new frame */ -#define FT_FRAME_OP_BYTE 2 /* read 1-byte value */ -#define FT_FRAME_OP_SHORT 3 /* read 2-byte value */ -#define FT_FRAME_OP_LONG 4 /* read 4-byte value */ -#define FT_FRAME_OP_OFF3 5 /* read 3-byte value */ -#define FT_FRAME_OP_BYTES 6 /* read a bytes sequence */ - - - typedef enum FT_Frame_Op_ - { - ft_frame_end = 0, - ft_frame_start = FT_MAKE_FRAME_OP( FT_FRAME_OP_START, 0, 0 ), - - ft_frame_byte = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 0 ), - ft_frame_schar = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTE, 0, 1 ), - - ft_frame_ushort_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 0 ), - ft_frame_short_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 0, 1 ), - ft_frame_ushort_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 0 ), - ft_frame_short_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_SHORT, 1, 1 ), - - ft_frame_ulong_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 0 ), - ft_frame_long_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 0, 1 ), - ft_frame_ulong_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 0 ), - ft_frame_long_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_LONG, 1, 1 ), - - ft_frame_uoff3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 0 ), - ft_frame_off3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 1 ), - ft_frame_uoff3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 0 ), - ft_frame_off3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 1 ), - - ft_frame_bytes = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 0 ), - ft_frame_skip = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 1 ) - - } FT_Frame_Op; - - - typedef struct FT_Frame_Field_ - { - FT_Byte value; - FT_Byte size; - FT_UShort offset; - - } FT_Frame_Field; - - - /* Construct an FT_Frame_Field out of a structure type and a field name. */ - /* The structure type must be set in the FT_STRUCTURE macro before */ - /* calling the FT_FRAME_START() macro. */ - /* */ -#define FT_FIELD_SIZE( f ) \ - (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f ) - -#define FT_FIELD_SIZE_DELTA( f ) \ - (FT_Byte)sizeof ( ((FT_STRUCTURE*)0)->f[0] ) - -#define FT_FIELD_OFFSET( f ) \ - (FT_UShort)( offsetof( FT_STRUCTURE, f ) ) - -#define FT_FRAME_FIELD( frame_op, field ) \ - { \ - frame_op, \ - FT_FIELD_SIZE( field ), \ - FT_FIELD_OFFSET( field ) \ - } - -#define FT_MAKE_EMPTY_FIELD( frame_op ) { frame_op, 0, 0 } - -#define FT_FRAME_START( size ) { ft_frame_start, 0, size } -#define FT_FRAME_END { ft_frame_end, 0, 0 } - -#define FT_FRAME_LONG( f ) FT_FRAME_FIELD( ft_frame_long_be, f ) -#define FT_FRAME_ULONG( f ) FT_FRAME_FIELD( ft_frame_ulong_be, f ) -#define FT_FRAME_SHORT( f ) FT_FRAME_FIELD( ft_frame_short_be, f ) -#define FT_FRAME_USHORT( f ) FT_FRAME_FIELD( ft_frame_ushort_be, f ) -#define FT_FRAME_OFF3( f ) FT_FRAME_FIELD( ft_frame_off3_be, f ) -#define FT_FRAME_UOFF3( f ) FT_FRAME_FIELD( ft_frame_uoff3_be, f ) -#define FT_FRAME_BYTE( f ) FT_FRAME_FIELD( ft_frame_byte, f ) -#define FT_FRAME_CHAR( f ) FT_FRAME_FIELD( ft_frame_schar, f ) - -#define FT_FRAME_LONG_LE( f ) FT_FRAME_FIELD( ft_frame_long_le, f ) -#define FT_FRAME_ULONG_LE( f ) FT_FRAME_FIELD( ft_frame_ulong_le, f ) -#define FT_FRAME_SHORT_LE( f ) FT_FRAME_FIELD( ft_frame_short_le, f ) -#define FT_FRAME_USHORT_LE( f ) FT_FRAME_FIELD( ft_frame_ushort_le, f ) -#define FT_FRAME_OFF3_LE( f ) FT_FRAME_FIELD( ft_frame_off3_le, f ) -#define FT_FRAME_UOFF3_LE( f ) FT_FRAME_FIELD( ft_frame_uoff3_le, f ) - -#define FT_FRAME_SKIP_LONG { ft_frame_long_be, 0, 0 } -#define FT_FRAME_SKIP_SHORT { ft_frame_short_be, 0, 0 } -#define FT_FRAME_SKIP_BYTE { ft_frame_byte, 0, 0 } - -#define FT_FRAME_BYTES( field, count ) \ - { \ - ft_frame_bytes, \ - count, \ - FT_FIELD_OFFSET( field ) \ - } - -#define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 } - - - /*************************************************************************/ - /* */ - /* Integer extraction macros -- the `buffer' parameter must ALWAYS be of */ - /* type `char*' or equivalent (1-byte elements). */ - /* */ - -#define FT_BYTE_( p, i ) ( ((const FT_Byte*)(p))[(i)] ) - -#define FT_INT16( x ) ( (FT_Int16)(x) ) -#define FT_UINT16( x ) ( (FT_UInt16)(x) ) -#define FT_INT32( x ) ( (FT_Int32)(x) ) -#define FT_UINT32( x ) ( (FT_UInt32)(x) ) - - -#define FT_BYTE_U16( p, i, s ) ( FT_UINT16( FT_BYTE_( p, i ) ) << (s) ) -#define FT_BYTE_U32( p, i, s ) ( FT_UINT32( FT_BYTE_( p, i ) ) << (s) ) - - -#define FT_PEEK_SHORT( p ) FT_INT16( FT_BYTE_U16( p, 0, 8) | \ - FT_BYTE_U16( p, 1, 0) ) - -#define FT_PEEK_USHORT( p ) FT_UINT16( FT_BYTE_U16( p, 0, 8 ) | \ - FT_BYTE_U16( p, 1, 0 ) ) - -#define FT_PEEK_LONG( p ) FT_INT32( FT_BYTE_U32( p, 0, 24 ) | \ - FT_BYTE_U32( p, 1, 16 ) | \ - FT_BYTE_U32( p, 2, 8 ) | \ - FT_BYTE_U32( p, 3, 0 ) ) - -#define FT_PEEK_ULONG( p ) FT_UINT32( FT_BYTE_U32( p, 0, 24 ) | \ - FT_BYTE_U32( p, 1, 16 ) | \ - FT_BYTE_U32( p, 2, 8 ) | \ - FT_BYTE_U32( p, 3, 0 ) ) - -#define FT_PEEK_OFF3( p ) FT_INT32( FT_BYTE_U32( p, 0, 16 ) | \ - FT_BYTE_U32( p, 1, 8 ) | \ - FT_BYTE_U32( p, 2, 0 ) ) - -#define FT_PEEK_UOFF3( p ) FT_UINT32( FT_BYTE_U32( p, 0, 16 ) | \ - FT_BYTE_U32( p, 1, 8 ) | \ - FT_BYTE_U32( p, 2, 0 ) ) - -#define FT_PEEK_SHORT_LE( p ) FT_INT16( FT_BYTE_U16( p, 1, 8 ) | \ - FT_BYTE_U16( p, 0, 0 ) ) - -#define FT_PEEK_USHORT_LE( p ) FT_UINT16( FT_BYTE_U16( p, 1, 8 ) | \ - FT_BYTE_U16( p, 0, 0 ) ) - -#define FT_PEEK_LONG_LE( p ) FT_INT32( FT_BYTE_U32( p, 3, 24 ) | \ - FT_BYTE_U32( p, 2, 16 ) | \ - FT_BYTE_U32( p, 1, 8 ) | \ - FT_BYTE_U32( p, 0, 0 ) ) - -#define FT_PEEK_ULONG_LE( p ) FT_UINT32( FT_BYTE_U32( p, 3, 24 ) | \ - FT_BYTE_U32( p, 2, 16 ) | \ - FT_BYTE_U32( p, 1, 8 ) | \ - FT_BYTE_U32( p, 0, 0 ) ) - -#define FT_PEEK_OFF3_LE( p ) FT_INT32( FT_BYTE_U32( p, 2, 16 ) | \ - FT_BYTE_U32( p, 1, 8 ) | \ - FT_BYTE_U32( p, 0, 0 ) ) - -#define FT_PEEK_UOFF3_LE( p ) FT_UINT32( FT_BYTE_U32( p, 2, 16 ) | \ - FT_BYTE_U32( p, 1, 8 ) | \ - FT_BYTE_U32( p, 0, 0 ) ) - - -#define FT_NEXT_CHAR( buffer ) \ - ( (signed char)*buffer++ ) - -#define FT_NEXT_BYTE( buffer ) \ - ( (unsigned char)*buffer++ ) - -#define FT_NEXT_SHORT( buffer ) \ - ( (short)( buffer += 2, FT_PEEK_SHORT( buffer - 2 ) ) ) - -#define FT_NEXT_USHORT( buffer ) \ - ( (unsigned short)( buffer += 2, FT_PEEK_USHORT( buffer - 2 ) ) ) - -#define FT_NEXT_OFF3( buffer ) \ - ( (long)( buffer += 3, FT_PEEK_OFF3( buffer - 3 ) ) ) - -#define FT_NEXT_UOFF3( buffer ) \ - ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3( buffer - 3 ) ) ) - -#define FT_NEXT_LONG( buffer ) \ - ( (long)( buffer += 4, FT_PEEK_LONG( buffer - 4 ) ) ) - -#define FT_NEXT_ULONG( buffer ) \ - ( (unsigned long)( buffer += 4, FT_PEEK_ULONG( buffer - 4 ) ) ) - - -#define FT_NEXT_SHORT_LE( buffer ) \ - ( (short)( buffer += 2, FT_PEEK_SHORT_LE( buffer - 2 ) ) ) - -#define FT_NEXT_USHORT_LE( buffer ) \ - ( (unsigned short)( buffer += 2, FT_PEEK_USHORT_LE( buffer - 2 ) ) ) - -#define FT_NEXT_OFF3_LE( buffer ) \ - ( (long)( buffer += 3, FT_PEEK_OFF3_LE( buffer - 3 ) ) ) - -#define FT_NEXT_UOFF3_LE( buffer ) \ - ( (unsigned long)( buffer += 3, FT_PEEK_UOFF3_LE( buffer - 3 ) ) ) - -#define FT_NEXT_LONG_LE( buffer ) \ - ( (long)( buffer += 4, FT_PEEK_LONG_LE( buffer - 4 ) ) ) - -#define FT_NEXT_ULONG_LE( buffer ) \ - ( (unsigned long)( buffer += 4, FT_PEEK_ULONG_LE( buffer - 4 ) ) ) - - - /*************************************************************************/ - /* */ - /* Each GET_xxxx() macro uses an implicit `stream' variable. */ - /* */ -#if 0 -#define FT_GET_MACRO( type ) FT_NEXT_ ## type ( stream->cursor ) - -#define FT_GET_CHAR() FT_GET_MACRO( CHAR ) -#define FT_GET_BYTE() FT_GET_MACRO( BYTE ) -#define FT_GET_SHORT() FT_GET_MACRO( SHORT ) -#define FT_GET_USHORT() FT_GET_MACRO( USHORT ) -#define FT_GET_OFF3() FT_GET_MACRO( OFF3 ) -#define FT_GET_UOFF3() FT_GET_MACRO( UOFF3 ) -#define FT_GET_LONG() FT_GET_MACRO( LONG ) -#define FT_GET_ULONG() FT_GET_MACRO( ULONG ) -#define FT_GET_TAG4() FT_GET_MACRO( ULONG ) - -#define FT_GET_SHORT_LE() FT_GET_MACRO( SHORT_LE ) -#define FT_GET_USHORT_LE() FT_GET_MACRO( USHORT_LE ) -#define FT_GET_LONG_LE() FT_GET_MACRO( LONG_LE ) -#define FT_GET_ULONG_LE() FT_GET_MACRO( ULONG_LE ) - -#else -#define FT_GET_MACRO( func, type ) ( (type)func( stream ) ) - -#define FT_GET_CHAR() FT_GET_MACRO( FT_Stream_GetChar, FT_Char ) -#define FT_GET_BYTE() FT_GET_MACRO( FT_Stream_GetChar, FT_Byte ) -#define FT_GET_SHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_Short ) -#define FT_GET_USHORT() FT_GET_MACRO( FT_Stream_GetUShort, FT_UShort ) -#define FT_GET_OFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_Long ) -#define FT_GET_UOFF3() FT_GET_MACRO( FT_Stream_GetUOffset, FT_ULong ) -#define FT_GET_LONG() FT_GET_MACRO( FT_Stream_GetULong, FT_Long ) -#define FT_GET_ULONG() FT_GET_MACRO( FT_Stream_GetULong, FT_ULong ) -#define FT_GET_TAG4() FT_GET_MACRO( FT_Stream_GetULong, FT_ULong ) - -#define FT_GET_SHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_Short ) -#define FT_GET_USHORT_LE() FT_GET_MACRO( FT_Stream_GetUShortLE, FT_UShort ) -#define FT_GET_LONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_Long ) -#define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetULongLE, FT_ULong ) -#endif - -#define FT_READ_MACRO( func, type, var ) \ - ( var = (type)func( stream, &error ), \ - error != FT_Err_Ok ) - -#define FT_READ_BYTE( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Byte, var ) -#define FT_READ_CHAR( var ) FT_READ_MACRO( FT_Stream_ReadChar, FT_Char, var ) -#define FT_READ_SHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_Short, var ) -#define FT_READ_USHORT( var ) FT_READ_MACRO( FT_Stream_ReadUShort, FT_UShort, var ) -#define FT_READ_OFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_Long, var ) -#define FT_READ_UOFF3( var ) FT_READ_MACRO( FT_Stream_ReadUOffset, FT_ULong, var ) -#define FT_READ_LONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_Long, var ) -#define FT_READ_ULONG( var ) FT_READ_MACRO( FT_Stream_ReadULong, FT_ULong, var ) - -#define FT_READ_SHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_Short, var ) -#define FT_READ_USHORT_LE( var ) FT_READ_MACRO( FT_Stream_ReadUShortLE, FT_UShort, var ) -#define FT_READ_LONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_Long, var ) -#define FT_READ_ULONG_LE( var ) FT_READ_MACRO( FT_Stream_ReadULongLE, FT_ULong, var ) - - -#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM - - /* initialize a stream for reading a regular system stream */ - FT_BASE( FT_Error ) - FT_Stream_Open( FT_Stream stream, - const char* filepathname ); - -#endif /* FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM */ - - - /* create a new (input) stream from an FT_Open_Args structure */ - FT_BASE( FT_Error ) - FT_Stream_New( FT_Library library, - const FT_Open_Args* args, - FT_Stream *astream ); - - /* free a stream */ - FT_BASE( void ) - FT_Stream_Free( FT_Stream stream, - FT_Int external ); - - /* initialize a stream for reading in-memory data */ - FT_BASE( void ) - FT_Stream_OpenMemory( FT_Stream stream, - const FT_Byte* base, - FT_ULong size ); - - /* close a stream (does not destroy the stream structure) */ - FT_BASE( void ) - FT_Stream_Close( FT_Stream stream ); - - - /* seek within a stream. position is relative to start of stream */ - FT_BASE( FT_Error ) - FT_Stream_Seek( FT_Stream stream, - FT_ULong pos ); - - /* skip bytes in a stream */ - FT_BASE( FT_Error ) - FT_Stream_Skip( FT_Stream stream, - FT_Long distance ); - - /* return current stream position */ - FT_BASE( FT_Long ) - FT_Stream_Pos( FT_Stream stream ); - - /* read bytes from a stream into a user-allocated buffer, returns an */ - /* error if not all bytes could be read. */ - FT_BASE( FT_Error ) - FT_Stream_Read( FT_Stream stream, - FT_Byte* buffer, - FT_ULong count ); - - /* read bytes from a stream at a given position */ - FT_BASE( FT_Error ) - FT_Stream_ReadAt( FT_Stream stream, - FT_ULong pos, - FT_Byte* buffer, - FT_ULong count ); - - /* try to read bytes at the end of a stream; return number of bytes */ - /* really available */ - FT_BASE( FT_ULong ) - FT_Stream_TryRead( FT_Stream stream, - FT_Byte* buffer, - FT_ULong count ); - - /* Enter a frame of `count' consecutive bytes in a stream. Returns an */ - /* error if the frame could not be read/accessed. The caller can use */ - /* the FT_Stream_Get_XXX functions to retrieve frame data without */ - /* error checks. */ - /* */ - /* You must _always_ call FT_Stream_ExitFrame() once you have entered */ - /* a stream frame! */ - /* */ - FT_BASE( FT_Error ) - FT_Stream_EnterFrame( FT_Stream stream, - FT_ULong count ); - - /* exit a stream frame */ - FT_BASE( void ) - FT_Stream_ExitFrame( FT_Stream stream ); - - /* Extract a stream frame. If the stream is disk-based, a heap block */ - /* is allocated and the frame bytes are read into it. If the stream */ - /* is memory-based, this function simply set a pointer to the data. */ - /* */ - /* Useful to optimize access to memory-based streams transparently. */ - /* */ - /* All extracted frames must be `freed' with a call to the function */ - /* FT_Stream_ReleaseFrame(). */ - /* */ - FT_BASE( FT_Error ) - FT_Stream_ExtractFrame( FT_Stream stream, - FT_ULong count, - FT_Byte** pbytes ); - - /* release an extract frame (see FT_Stream_ExtractFrame) */ - FT_BASE( void ) - FT_Stream_ReleaseFrame( FT_Stream stream, - FT_Byte** pbytes ); - - /* read a byte from an entered frame */ - FT_BASE( FT_Char ) - FT_Stream_GetChar( FT_Stream stream ); - - /* read a 16-bit big-endian unsigned integer from an entered frame */ - FT_BASE( FT_UShort ) - FT_Stream_GetUShort( FT_Stream stream ); - - /* read a 24-bit big-endian unsigned integer from an entered frame */ - FT_BASE( FT_ULong ) - FT_Stream_GetUOffset( FT_Stream stream ); - - /* read a 32-bit big-endian unsigned integer from an entered frame */ - FT_BASE( FT_ULong ) - FT_Stream_GetULong( FT_Stream stream ); - - /* read a 16-bit little-endian unsigned integer from an entered frame */ - FT_BASE( FT_UShort ) - FT_Stream_GetUShortLE( FT_Stream stream ); - - /* read a 32-bit little-endian unsigned integer from an entered frame */ - FT_BASE( FT_ULong ) - FT_Stream_GetULongLE( FT_Stream stream ); - - - /* read a byte from a stream */ - FT_BASE( FT_Char ) - FT_Stream_ReadChar( FT_Stream stream, - FT_Error* error ); - - /* read a 16-bit big-endian unsigned integer from a stream */ - FT_BASE( FT_UShort ) - FT_Stream_ReadUShort( FT_Stream stream, - FT_Error* error ); - - /* read a 24-bit big-endian unsigned integer from a stream */ - FT_BASE( FT_ULong ) - FT_Stream_ReadUOffset( FT_Stream stream, - FT_Error* error ); - - /* read a 32-bit big-endian integer from a stream */ - FT_BASE( FT_ULong ) - FT_Stream_ReadULong( FT_Stream stream, - FT_Error* error ); - - /* read a 16-bit little-endian unsigned integer from a stream */ - FT_BASE( FT_UShort ) - FT_Stream_ReadUShortLE( FT_Stream stream, - FT_Error* error ); - - /* read a 32-bit little-endian unsigned integer from a stream */ - FT_BASE( FT_ULong ) - FT_Stream_ReadULongLE( FT_Stream stream, - FT_Error* error ); - - /* Read a structure from a stream. The structure must be described */ - /* by an array of FT_Frame_Field records. */ - FT_BASE( FT_Error ) - FT_Stream_ReadFields( FT_Stream stream, - const FT_Frame_Field* fields, - void* structure ); - - -#define FT_STREAM_POS() \ - FT_Stream_Pos( stream ) - -#define FT_STREAM_SEEK( position ) \ - FT_SET_ERROR( FT_Stream_Seek( stream, \ - (FT_ULong)(position) ) ) - -#define FT_STREAM_SKIP( distance ) \ - FT_SET_ERROR( FT_Stream_Skip( stream, \ - (FT_Long)(distance) ) ) - -#define FT_STREAM_READ( buffer, count ) \ - FT_SET_ERROR( FT_Stream_Read( stream, \ - (FT_Byte*)(buffer), \ - (FT_ULong)(count) ) ) - -#define FT_STREAM_READ_AT( position, buffer, count ) \ - FT_SET_ERROR( FT_Stream_ReadAt( stream, \ - (FT_ULong)(position), \ - (FT_Byte*)buffer, \ - (FT_ULong)(count) ) ) - -#define FT_STREAM_READ_FIELDS( fields, object ) \ - FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) ) - - -#define FT_FRAME_ENTER( size ) \ - FT_SET_ERROR( \ - FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, \ - (FT_ULong)(size) ) ) ) - -#define FT_FRAME_EXIT() \ - FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) ) - -#define FT_FRAME_EXTRACT( size, bytes ) \ - FT_SET_ERROR( \ - FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, \ - (FT_ULong)(size), \ - (FT_Byte**)&(bytes) ) ) ) - -#define FT_FRAME_RELEASE( bytes ) \ - FT_DEBUG_INNER( FT_Stream_ReleaseFrame( stream, \ - (FT_Byte**)&(bytes) ) ) - - -FT_END_HEADER - -#endif /* __FTSTREAM_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/fttrace.h b/thirdparty/include/freetype/internal/fttrace.h deleted file mode 100644 index d5253db78..000000000 --- a/thirdparty/include/freetype/internal/fttrace.h +++ /dev/null @@ -1,154 +0,0 @@ -/***************************************************************************/ -/* */ -/* fttrace.h */ -/* */ -/* Tracing handling (specification only). */ -/* */ -/* Copyright 2002, 2004-2007, 2009, 2011-2014 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /* definitions of trace levels for FreeType 2 */ - - /* the first level must always be `trace_any' */ -FT_TRACE_DEF( any ) - - /* base components */ -FT_TRACE_DEF( calc ) /* calculations (ftcalc.c) */ -FT_TRACE_DEF( memory ) /* memory manager (ftobjs.c) */ -FT_TRACE_DEF( stream ) /* stream manager (ftstream.c) */ -FT_TRACE_DEF( io ) /* i/o interface (ftsystem.c) */ -FT_TRACE_DEF( list ) /* list management (ftlist.c) */ -FT_TRACE_DEF( init ) /* initialization (ftinit.c) */ -FT_TRACE_DEF( objs ) /* base objects (ftobjs.c) */ -FT_TRACE_DEF( outline ) /* outline management (ftoutln.c) */ -FT_TRACE_DEF( glyph ) /* glyph management (ftglyph.c) */ -FT_TRACE_DEF( gloader ) /* glyph loader (ftgloadr.c) */ - -FT_TRACE_DEF( raster ) /* monochrome rasterizer (ftraster.c) */ -FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */ -FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */ -FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */ -FT_TRACE_DEF( synth ) /* bold/slant synthesizer (ftsynth.c) */ -FT_TRACE_DEF( bitmap ) /* bitmap checksum (ftobjs.c) */ - - /* Cache sub-system */ -FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */ - - /* SFNT driver components */ -FT_TRACE_DEF( sfdriver ) /* SFNT font driver (sfdriver.c) */ -FT_TRACE_DEF( sfobjs ) /* SFNT object handler (sfobjs.c) */ -FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */ -FT_TRACE_DEF( ttkern ) /* kerning handler (ttkern.c) */ -FT_TRACE_DEF( ttload ) /* basic TrueType tables (ttload.c) */ -FT_TRACE_DEF( ttmtx ) /* metrics-related tables (ttmtx.c) */ -FT_TRACE_DEF( ttpost ) /* PS table processing (ttpost.c) */ -FT_TRACE_DEF( ttsbit ) /* TrueType sbit handling (ttsbit.c) */ -FT_TRACE_DEF( ttbdf ) /* TrueType embedded BDF (ttbdf.c) */ - - /* TrueType driver components */ -FT_TRACE_DEF( ttdriver ) /* TT font driver (ttdriver.c) */ -FT_TRACE_DEF( ttgload ) /* TT glyph loader (ttgload.c) */ -FT_TRACE_DEF( ttinterp ) /* bytecode interpreter (ttinterp.c) */ -FT_TRACE_DEF( ttobjs ) /* TT objects manager (ttobjs.c) */ -FT_TRACE_DEF( ttpload ) /* TT data/program loader (ttpload.c) */ -FT_TRACE_DEF( ttgxvar ) /* TrueType GX var handler (ttgxvar.c) */ - - /* Type 1 driver components */ -FT_TRACE_DEF( t1afm ) -FT_TRACE_DEF( t1driver ) -FT_TRACE_DEF( t1gload ) -FT_TRACE_DEF( t1hint ) -FT_TRACE_DEF( t1load ) -FT_TRACE_DEF( t1objs ) -FT_TRACE_DEF( t1parse ) - - /* PostScript helper module `psaux' */ -FT_TRACE_DEF( t1decode ) -FT_TRACE_DEF( psobjs ) -FT_TRACE_DEF( psconv ) - - /* PostScript hinting module `pshinter' */ -FT_TRACE_DEF( pshrec ) -FT_TRACE_DEF( pshalgo1 ) -FT_TRACE_DEF( pshalgo2 ) - - /* Type 2 driver components */ -FT_TRACE_DEF( cffdriver ) -FT_TRACE_DEF( cffgload ) -FT_TRACE_DEF( cffload ) -FT_TRACE_DEF( cffobjs ) -FT_TRACE_DEF( cffparse ) - -FT_TRACE_DEF( cf2blues ) -FT_TRACE_DEF( cf2hints ) -FT_TRACE_DEF( cf2interp ) - - /* Type 42 driver component */ -FT_TRACE_DEF( t42 ) - - /* CID driver components */ -FT_TRACE_DEF( cidafm ) -FT_TRACE_DEF( ciddriver ) -FT_TRACE_DEF( cidgload ) -FT_TRACE_DEF( cidload ) -FT_TRACE_DEF( cidobjs ) -FT_TRACE_DEF( cidparse ) - - /* Windows font component */ -FT_TRACE_DEF( winfnt ) - - /* PCF font components */ -FT_TRACE_DEF( pcfdriver ) -FT_TRACE_DEF( pcfread ) - - /* BDF font components */ -FT_TRACE_DEF( bdfdriver ) -FT_TRACE_DEF( bdflib ) - - /* PFR font component */ -FT_TRACE_DEF( pfr ) - - /* OpenType validation components */ -FT_TRACE_DEF( otvmodule ) -FT_TRACE_DEF( otvcommon ) -FT_TRACE_DEF( otvbase ) -FT_TRACE_DEF( otvgdef ) -FT_TRACE_DEF( otvgpos ) -FT_TRACE_DEF( otvgsub ) -FT_TRACE_DEF( otvjstf ) -FT_TRACE_DEF( otvmath ) - - /* TrueTypeGX/AAT validation components */ -FT_TRACE_DEF( gxvmodule ) -FT_TRACE_DEF( gxvcommon ) -FT_TRACE_DEF( gxvfeat ) -FT_TRACE_DEF( gxvmort ) -FT_TRACE_DEF( gxvmorx ) -FT_TRACE_DEF( gxvbsln ) -FT_TRACE_DEF( gxvjust ) -FT_TRACE_DEF( gxvkern ) -FT_TRACE_DEF( gxvopbd ) -FT_TRACE_DEF( gxvtrak ) -FT_TRACE_DEF( gxvprop ) -FT_TRACE_DEF( gxvlcar ) - - /* autofit components */ -FT_TRACE_DEF( afmodule ) -FT_TRACE_DEF( afhints ) -FT_TRACE_DEF( afcjk ) -FT_TRACE_DEF( aflatin ) -FT_TRACE_DEF( aflatin2 ) -FT_TRACE_DEF( afwarp ) -FT_TRACE_DEF( afharfbuzz ) -FT_TRACE_DEF( afglobal ) - -/* END */ diff --git a/thirdparty/include/freetype/internal/ftvalid.h b/thirdparty/include/freetype/internal/ftvalid.h deleted file mode 100644 index 1c4942401..000000000 --- a/thirdparty/include/freetype/internal/ftvalid.h +++ /dev/null @@ -1,161 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftvalid.h */ -/* */ -/* FreeType validation support (specification). */ -/* */ -/* Copyright 2004, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __FTVALID_H__ -#define __FTVALID_H__ - -#include <freetype/ft2build.h> -#include FT_CONFIG_STANDARD_LIBRARY_H /* for ft_setjmp and ft_longjmp */ - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** ****/ - /**** V A L I D A T I O N ****/ - /**** ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - /* handle to a validation object */ - typedef struct FT_ValidatorRec_ volatile* FT_Validator; - - - /*************************************************************************/ - /* */ - /* There are three distinct validation levels defined here: */ - /* */ - /* FT_VALIDATE_DEFAULT :: */ - /* A table that passes this validation level can be used reliably by */ - /* FreeType. It generally means that all offsets have been checked to */ - /* prevent out-of-bound reads, that array counts are correct, etc. */ - /* */ - /* FT_VALIDATE_TIGHT :: */ - /* A table that passes this validation level can be used reliably and */ - /* doesn't contain invalid data. For example, a charmap table that */ - /* returns invalid glyph indices will not pass, even though it can */ - /* be used with FreeType in default mode (the library will simply */ - /* return an error later when trying to load the glyph). */ - /* */ - /* It also checks that fields which must be a multiple of 2, 4, or 8, */ - /* don't have incorrect values, etc. */ - /* */ - /* FT_VALIDATE_PARANOID :: */ - /* Only for font debugging. Checks that a table follows the */ - /* specification by 100%. Very few fonts will be able to pass this */ - /* level anyway but it can be useful for certain tools like font */ - /* editors/converters. */ - /* */ - typedef enum FT_ValidationLevel_ - { - FT_VALIDATE_DEFAULT = 0, - FT_VALIDATE_TIGHT, - FT_VALIDATE_PARANOID - - } FT_ValidationLevel; - - -#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ - /* We disable the warning `structure was padded due to */ - /* __declspec(align())' in order to compile cleanly with */ - /* the maximum level of warnings. */ -#pragma warning( push ) -#pragma warning( disable : 4324 ) -#endif /* _MSC_VER */ - - /* validator structure */ - typedef struct FT_ValidatorRec_ - { - const FT_Byte* base; /* address of table in memory */ - const FT_Byte* limit; /* `base' + sizeof(table) in memory */ - FT_ValidationLevel level; /* validation level */ - FT_Error error; /* error returned. 0 means success */ - - ft_jmp_buf jump_buffer; /* used for exception handling */ - - } FT_ValidatorRec; - -#if defined( _MSC_VER ) -#pragma warning( pop ) -#endif - -#define FT_VALIDATOR( x ) ( (FT_Validator)( x ) ) - - - FT_BASE( void ) - ft_validator_init( FT_Validator valid, - const FT_Byte* base, - const FT_Byte* limit, - FT_ValidationLevel level ); - - /* Do not use this. It's broken and will cause your validator to crash */ - /* if you run it on an invalid font. */ - FT_BASE( FT_Int ) - ft_validator_run( FT_Validator valid ); - - /* Sets the error field in a validator, then calls `longjmp' to return */ - /* to high-level caller. Using `setjmp/longjmp' avoids many stupid */ - /* error checks within the validation routines. */ - /* */ - FT_BASE( void ) - ft_validator_error( FT_Validator valid, - FT_Error error ); - - - /* Calls ft_validate_error. Assumes that the `valid' local variable */ - /* holds a pointer to the current validator object. */ - /* */ - /* Use preprocessor prescan to pass FT_ERR_PREFIX. */ - /* */ -#define FT_INVALID( _prefix, _error ) FT_INVALID_( _prefix, _error ) -#define FT_INVALID_( _prefix, _error ) \ - ft_validator_error( valid, _prefix ## _error ) - - /* called when a broken table is detected */ -#define FT_INVALID_TOO_SHORT \ - FT_INVALID( FT_ERR_PREFIX, Invalid_Table ) - - /* called when an invalid offset is detected */ -#define FT_INVALID_OFFSET \ - FT_INVALID( FT_ERR_PREFIX, Invalid_Offset ) - - /* called when an invalid format/value is detected */ -#define FT_INVALID_FORMAT \ - FT_INVALID( FT_ERR_PREFIX, Invalid_Table ) - - /* called when an invalid glyph index is detected */ -#define FT_INVALID_GLYPH_ID \ - FT_INVALID( FT_ERR_PREFIX, Invalid_Glyph_Index ) - - /* called when an invalid field value is detected */ -#define FT_INVALID_DATA \ - FT_INVALID( FT_ERR_PREFIX, Invalid_Table ) - - -FT_END_HEADER - -#endif /* __FTVALID_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/internal.h b/thirdparty/include/freetype/internal/internal.h deleted file mode 100644 index e0ddb06b7..000000000 --- a/thirdparty/include/freetype/internal/internal.h +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************/ -/* */ -/* internal.h */ -/* */ -/* Internal header files (specification only). */ -/* */ -/* Copyright 1996-2004, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is automatically included by `ft2build.h'. */ - /* Do not include it manually! */ - /* */ - /*************************************************************************/ - - -#define FT_INTERNAL_OBJECTS_H <internal/ftobjs.h> -#define FT_INTERNAL_PIC_H <internal/ftpic.h> -#define FT_INTERNAL_STREAM_H <internal/ftstream.h> -#define FT_INTERNAL_MEMORY_H <internal/ftmemory.h> -#define FT_INTERNAL_DEBUG_H <internal/ftdebug.h> -#define FT_INTERNAL_CALC_H <internal/ftcalc.h> -#define FT_INTERNAL_DRIVER_H <internal/ftdriver.h> -#define FT_INTERNAL_TRACE_H <internal/fttrace.h> -#define FT_INTERNAL_GLYPH_LOADER_H <internal/ftgloadr.h> -#define FT_INTERNAL_SFNT_H <internal/sfnt.h> -#define FT_INTERNAL_SERVICE_H <internal/ftserv.h> -#define FT_INTERNAL_RFORK_H <internal/ftrfork.h> -#define FT_INTERNAL_VALIDATE_H <internal/ftvalid.h> - -#define FT_INTERNAL_TRUETYPE_TYPES_H <internal/tttypes.h> -#define FT_INTERNAL_TYPE1_TYPES_H <internal/t1types.h> - -#define FT_INTERNAL_POSTSCRIPT_AUX_H <internal/psaux.h> -#define FT_INTERNAL_POSTSCRIPT_HINTS_H <internal/pshints.h> -#define FT_INTERNAL_POSTSCRIPT_GLOBALS_H <internal/psglobal.h> - -#define FT_INTERNAL_AUTOHINT_H <internal/autohint.h> - - -#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ - - /* We disable the warning `conditional expression is constant' here */ - /* in order to compile cleanly with the maximum level of warnings. */ - /* In particular, the warning complains about stuff like `while(0)' */ - /* which is very useful in macro definitions. There is no benefit */ - /* in having it enabled. */ -#pragma warning( disable : 4127 ) - -#endif /* _MSC_VER */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/psaux.h b/thirdparty/include/freetype/internal/psaux.h deleted file mode 100644 index 97efcd8ae..000000000 --- a/thirdparty/include/freetype/internal/psaux.h +++ /dev/null @@ -1,877 +0,0 @@ -/***************************************************************************/ -/* */ -/* psaux.h */ -/* */ -/* Auxiliary functions and data structures related to PostScript fonts */ -/* (specification). */ -/* */ -/* Copyright 1996-2004, 2006, 2008, 2009, 2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __PSAUX_H__ -#define __PSAUX_H__ - - -#include <freetype/ft2build.h> -#include FT_INTERNAL_OBJECTS_H -#include FT_INTERNAL_TYPE1_TYPES_H -#include FT_SERVICE_POSTSCRIPT_CMAPS_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** T1_TABLE *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - - typedef struct PS_TableRec_* PS_Table; - typedef const struct PS_Table_FuncsRec_* PS_Table_Funcs; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_Table_FuncsRec */ - /* */ - /* <Description> */ - /* A set of function pointers to manage PS_Table objects. */ - /* */ - /* <Fields> */ - /* table_init :: Used to initialize a table. */ - /* */ - /* table_done :: Finalizes resp. destroy a given table. */ - /* */ - /* table_add :: Adds a new object to a table. */ - /* */ - /* table_release :: Releases table data, then finalizes it. */ - /* */ - typedef struct PS_Table_FuncsRec_ - { - FT_Error - (*init)( PS_Table table, - FT_Int count, - FT_Memory memory ); - - void - (*done)( PS_Table table ); - - FT_Error - (*add)( PS_Table table, - FT_Int idx, - void* object, - FT_PtrDist length ); - - void - (*release)( PS_Table table ); - - } PS_Table_FuncsRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_TableRec */ - /* */ - /* <Description> */ - /* A PS_Table is a simple object used to store an array of objects in */ - /* a single memory block. */ - /* */ - /* <Fields> */ - /* block :: The address in memory of the growheap's block. This */ - /* can change between two object adds, due to */ - /* reallocation. */ - /* */ - /* cursor :: The current top of the grow heap within its block. */ - /* */ - /* capacity :: The current size of the heap block. Increments by */ - /* 1kByte chunks. */ - /* */ - /* init :: Set to 0xDEADBEEF if `elements' and `lengths' have */ - /* been allocated. */ - /* */ - /* max_elems :: The maximum number of elements in table. */ - /* */ - /* num_elems :: The current number of elements in table. */ - /* */ - /* elements :: A table of element addresses within the block. */ - /* */ - /* lengths :: A table of element sizes within the block. */ - /* */ - /* memory :: The object used for memory operations */ - /* (alloc/realloc). */ - /* */ - /* funcs :: A table of method pointers for this object. */ - /* */ - typedef struct PS_TableRec_ - { - FT_Byte* block; /* current memory block */ - FT_Offset cursor; /* current cursor in memory block */ - FT_Offset capacity; /* current size of memory block */ - FT_Long init; - - FT_Int max_elems; - FT_Int num_elems; - FT_Byte** elements; /* addresses of table elements */ - FT_PtrDist* lengths; /* lengths of table elements */ - - FT_Memory memory; - PS_Table_FuncsRec funcs; - - } PS_TableRec; - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** T1 FIELDS & TOKENS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - typedef struct PS_ParserRec_* PS_Parser; - - typedef struct T1_TokenRec_* T1_Token; - - typedef struct T1_FieldRec_* T1_Field; - - - /* simple enumeration type used to identify token types */ - typedef enum T1_TokenType_ - { - T1_TOKEN_TYPE_NONE = 0, - T1_TOKEN_TYPE_ANY, - T1_TOKEN_TYPE_STRING, - T1_TOKEN_TYPE_ARRAY, - T1_TOKEN_TYPE_KEY, /* aka `name' */ - - /* do not remove */ - T1_TOKEN_TYPE_MAX - - } T1_TokenType; - - - /* a simple structure used to identify tokens */ - typedef struct T1_TokenRec_ - { - FT_Byte* start; /* first character of token in input stream */ - FT_Byte* limit; /* first character after the token */ - T1_TokenType type; /* type of token */ - - } T1_TokenRec; - - - /* enumeration type used to identify object fields */ - typedef enum T1_FieldType_ - { - T1_FIELD_TYPE_NONE = 0, - T1_FIELD_TYPE_BOOL, - T1_FIELD_TYPE_INTEGER, - T1_FIELD_TYPE_FIXED, - T1_FIELD_TYPE_FIXED_1000, - T1_FIELD_TYPE_STRING, - T1_FIELD_TYPE_KEY, - T1_FIELD_TYPE_BBOX, - T1_FIELD_TYPE_MM_BBOX, - T1_FIELD_TYPE_INTEGER_ARRAY, - T1_FIELD_TYPE_FIXED_ARRAY, - T1_FIELD_TYPE_CALLBACK, - - /* do not remove */ - T1_FIELD_TYPE_MAX - - } T1_FieldType; - - - typedef enum T1_FieldLocation_ - { - T1_FIELD_LOCATION_CID_INFO, - T1_FIELD_LOCATION_FONT_DICT, - T1_FIELD_LOCATION_FONT_EXTRA, - T1_FIELD_LOCATION_FONT_INFO, - T1_FIELD_LOCATION_PRIVATE, - T1_FIELD_LOCATION_BBOX, - T1_FIELD_LOCATION_LOADER, - T1_FIELD_LOCATION_FACE, - T1_FIELD_LOCATION_BLEND, - - /* do not remove */ - T1_FIELD_LOCATION_MAX - - } T1_FieldLocation; - - - typedef void - (*T1_Field_ParseFunc)( FT_Face face, - FT_Pointer parser ); - - - /* structure type used to model object fields */ - typedef struct T1_FieldRec_ - { - const char* ident; /* field identifier */ - T1_FieldLocation location; - T1_FieldType type; /* type of field */ - T1_Field_ParseFunc reader; - FT_UInt offset; /* offset of field in object */ - FT_Byte size; /* size of field in bytes */ - FT_UInt array_max; /* maximum number of elements for */ - /* array */ - FT_UInt count_offset; /* offset of element count for */ - /* arrays; must not be zero if in */ - /* use -- in other words, a */ - /* `num_FOO' element must not */ - /* start the used structure if we */ - /* parse a `FOO' array */ - FT_UInt dict; /* where we expect it */ - } T1_FieldRec; - -#define T1_FIELD_DICT_FONTDICT ( 1 << 0 ) /* also FontInfo and FDArray */ -#define T1_FIELD_DICT_PRIVATE ( 1 << 1 ) - - - -#define T1_NEW_SIMPLE_FIELD( _ident, _type, _fname, _dict ) \ - { \ - _ident, T1CODE, _type, \ - 0, \ - FT_FIELD_OFFSET( _fname ), \ - FT_FIELD_SIZE( _fname ), \ - 0, 0, \ - _dict \ - }, - -#define T1_NEW_CALLBACK_FIELD( _ident, _reader, _dict ) \ - { \ - _ident, T1CODE, T1_FIELD_TYPE_CALLBACK, \ - (T1_Field_ParseFunc)_reader, \ - 0, 0, \ - 0, 0, \ - _dict \ - }, - -#define T1_NEW_TABLE_FIELD( _ident, _type, _fname, _max, _dict ) \ - { \ - _ident, T1CODE, _type, \ - 0, \ - FT_FIELD_OFFSET( _fname ), \ - FT_FIELD_SIZE_DELTA( _fname ), \ - _max, \ - FT_FIELD_OFFSET( num_ ## _fname ), \ - _dict \ - }, - -#define T1_NEW_TABLE_FIELD2( _ident, _type, _fname, _max, _dict ) \ - { \ - _ident, T1CODE, _type, \ - 0, \ - FT_FIELD_OFFSET( _fname ), \ - FT_FIELD_SIZE_DELTA( _fname ), \ - _max, 0, \ - _dict \ - }, - - -#define T1_FIELD_BOOL( _ident, _fname, _dict ) \ - T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL, _fname, _dict ) - -#define T1_FIELD_NUM( _ident, _fname, _dict ) \ - T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER, _fname, _dict ) - -#define T1_FIELD_FIXED( _ident, _fname, _dict ) \ - T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED, _fname, _dict ) - -#define T1_FIELD_FIXED_1000( _ident, _fname, _dict ) \ - T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_1000, _fname, \ - _dict ) - -#define T1_FIELD_STRING( _ident, _fname, _dict ) \ - T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname, _dict ) - -#define T1_FIELD_KEY( _ident, _fname, _dict ) \ - T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_KEY, _fname, _dict ) - -#define T1_FIELD_BBOX( _ident, _fname, _dict ) \ - T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BBOX, _fname, _dict ) - - -#define T1_FIELD_NUM_TABLE( _ident, _fname, _fmax, _dict ) \ - T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \ - _fname, _fmax, _dict ) - -#define T1_FIELD_FIXED_TABLE( _ident, _fname, _fmax, _dict ) \ - T1_NEW_TABLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \ - _fname, _fmax, _dict ) - -#define T1_FIELD_NUM_TABLE2( _ident, _fname, _fmax, _dict ) \ - T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_INTEGER_ARRAY, \ - _fname, _fmax, _dict ) - -#define T1_FIELD_FIXED_TABLE2( _ident, _fname, _fmax, _dict ) \ - T1_NEW_TABLE_FIELD2( _ident, T1_FIELD_TYPE_FIXED_ARRAY, \ - _fname, _fmax, _dict ) - -#define T1_FIELD_CALLBACK( _ident, _name, _dict ) \ - T1_NEW_CALLBACK_FIELD( _ident, _name, _dict ) - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** T1 PARSER *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - typedef const struct PS_Parser_FuncsRec_* PS_Parser_Funcs; - - typedef struct PS_Parser_FuncsRec_ - { - void - (*init)( PS_Parser parser, - FT_Byte* base, - FT_Byte* limit, - FT_Memory memory ); - - void - (*done)( PS_Parser parser ); - - void - (*skip_spaces)( PS_Parser parser ); - void - (*skip_PS_token)( PS_Parser parser ); - - FT_Long - (*to_int)( PS_Parser parser ); - FT_Fixed - (*to_fixed)( PS_Parser parser, - FT_Int power_ten ); - - FT_Error - (*to_bytes)( PS_Parser parser, - FT_Byte* bytes, - FT_Offset max_bytes, - FT_Long* pnum_bytes, - FT_Bool delimiters ); - - FT_Int - (*to_coord_array)( PS_Parser parser, - FT_Int max_coords, - FT_Short* coords ); - FT_Int - (*to_fixed_array)( PS_Parser parser, - FT_Int max_values, - FT_Fixed* values, - FT_Int power_ten ); - - void - (*to_token)( PS_Parser parser, - T1_Token token ); - void - (*to_token_array)( PS_Parser parser, - T1_Token tokens, - FT_UInt max_tokens, - FT_Int* pnum_tokens ); - - FT_Error - (*load_field)( PS_Parser parser, - const T1_Field field, - void** objects, - FT_UInt max_objects, - FT_ULong* pflags ); - - FT_Error - (*load_field_table)( PS_Parser parser, - const T1_Field field, - void** objects, - FT_UInt max_objects, - FT_ULong* pflags ); - - } PS_Parser_FuncsRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_ParserRec */ - /* */ - /* <Description> */ - /* A PS_Parser is an object used to parse a Type 1 font very quickly. */ - /* */ - /* <Fields> */ - /* cursor :: The current position in the text. */ - /* */ - /* base :: Start of the processed text. */ - /* */ - /* limit :: End of the processed text. */ - /* */ - /* error :: The last error returned. */ - /* */ - /* memory :: The object used for memory operations (alloc/realloc). */ - /* */ - /* funcs :: A table of functions for the parser. */ - /* */ - typedef struct PS_ParserRec_ - { - FT_Byte* cursor; - FT_Byte* base; - FT_Byte* limit; - FT_Error error; - FT_Memory memory; - - PS_Parser_FuncsRec funcs; - - } PS_ParserRec; - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** T1 BUILDER *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - - typedef struct T1_BuilderRec_* T1_Builder; - - - typedef FT_Error - (*T1_Builder_Check_Points_Func)( T1_Builder builder, - FT_Int count ); - - typedef void - (*T1_Builder_Add_Point_Func)( T1_Builder builder, - FT_Pos x, - FT_Pos y, - FT_Byte flag ); - - typedef FT_Error - (*T1_Builder_Add_Point1_Func)( T1_Builder builder, - FT_Pos x, - FT_Pos y ); - - typedef FT_Error - (*T1_Builder_Add_Contour_Func)( T1_Builder builder ); - - typedef FT_Error - (*T1_Builder_Start_Point_Func)( T1_Builder builder, - FT_Pos x, - FT_Pos y ); - - typedef void - (*T1_Builder_Close_Contour_Func)( T1_Builder builder ); - - - typedef const struct T1_Builder_FuncsRec_* T1_Builder_Funcs; - - typedef struct T1_Builder_FuncsRec_ - { - void - (*init)( T1_Builder builder, - FT_Face face, - FT_Size size, - FT_GlyphSlot slot, - FT_Bool hinting ); - - void - (*done)( T1_Builder builder ); - - T1_Builder_Check_Points_Func check_points; - T1_Builder_Add_Point_Func add_point; - T1_Builder_Add_Point1_Func add_point1; - T1_Builder_Add_Contour_Func add_contour; - T1_Builder_Start_Point_Func start_point; - T1_Builder_Close_Contour_Func close_contour; - - } T1_Builder_FuncsRec; - - - /* an enumeration type to handle charstring parsing states */ - typedef enum T1_ParseState_ - { - T1_Parse_Start, - T1_Parse_Have_Width, - T1_Parse_Have_Moveto, - T1_Parse_Have_Path - - } T1_ParseState; - - - /*************************************************************************/ - /* */ - /* <Structure> */ - /* T1_BuilderRec */ - /* */ - /* <Description> */ - /* A structure used during glyph loading to store its outline. */ - /* */ - /* <Fields> */ - /* memory :: The current memory object. */ - /* */ - /* face :: The current face object. */ - /* */ - /* glyph :: The current glyph slot. */ - /* */ - /* loader :: XXX */ - /* */ - /* base :: The base glyph outline. */ - /* */ - /* current :: The current glyph outline. */ - /* */ - /* max_points :: maximum points in builder outline */ - /* */ - /* max_contours :: Maximum number of contours in builder outline. */ - /* */ - /* pos_x :: The horizontal translation (if composite glyph). */ - /* */ - /* pos_y :: The vertical translation (if composite glyph). */ - /* */ - /* left_bearing :: The left side bearing point. */ - /* */ - /* advance :: The horizontal advance vector. */ - /* */ - /* bbox :: Unused. */ - /* */ - /* parse_state :: An enumeration which controls the charstring */ - /* parsing state. */ - /* */ - /* load_points :: If this flag is not set, no points are loaded. */ - /* */ - /* no_recurse :: Set but not used. */ - /* */ - /* metrics_only :: A boolean indicating that we only want to compute */ - /* the metrics of a given glyph, not load all of its */ - /* points. */ - /* */ - /* funcs :: An array of function pointers for the builder. */ - /* */ - typedef struct T1_BuilderRec_ - { - FT_Memory memory; - FT_Face face; - FT_GlyphSlot glyph; - FT_GlyphLoader loader; - FT_Outline* base; - FT_Outline* current; - - FT_Pos pos_x; - FT_Pos pos_y; - - FT_Vector left_bearing; - FT_Vector advance; - - FT_BBox bbox; /* bounding box */ - T1_ParseState parse_state; - FT_Bool load_points; - FT_Bool no_recurse; - - FT_Bool metrics_only; - - void* hints_funcs; /* hinter-specific */ - void* hints_globals; /* hinter-specific */ - - T1_Builder_FuncsRec funcs; - - } T1_BuilderRec; - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** T1 DECODER *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - -#if 0 - - /*************************************************************************/ - /* */ - /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ - /* calls during glyph loading. */ - /* */ -#define T1_MAX_SUBRS_CALLS 8 - - - /*************************************************************************/ - /* */ - /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ - /* minimum of 16 is required. */ - /* */ -#define T1_MAX_CHARSTRINGS_OPERANDS 32 - -#endif /* 0 */ - - - typedef struct T1_Decoder_ZoneRec_ - { - FT_Byte* cursor; - FT_Byte* base; - FT_Byte* limit; - - } T1_Decoder_ZoneRec, *T1_Decoder_Zone; - - - typedef struct T1_DecoderRec_* T1_Decoder; - typedef const struct T1_Decoder_FuncsRec_* T1_Decoder_Funcs; - - - typedef FT_Error - (*T1_Decoder_Callback)( T1_Decoder decoder, - FT_UInt glyph_index ); - - - typedef struct T1_Decoder_FuncsRec_ - { - FT_Error - (*init)( T1_Decoder decoder, - FT_Face face, - FT_Size size, - FT_GlyphSlot slot, - FT_Byte** glyph_names, - PS_Blend blend, - FT_Bool hinting, - FT_Render_Mode hint_mode, - T1_Decoder_Callback callback ); - - void - (*done)( T1_Decoder decoder ); - - FT_Error - (*parse_charstrings)( T1_Decoder decoder, - FT_Byte* base, - FT_UInt len ); - - } T1_Decoder_FuncsRec; - - - typedef struct T1_DecoderRec_ - { - T1_BuilderRec builder; - - FT_Long stack[T1_MAX_CHARSTRINGS_OPERANDS]; - FT_Long* top; - - T1_Decoder_ZoneRec zones[T1_MAX_SUBRS_CALLS + 1]; - T1_Decoder_Zone zone; - - FT_Service_PsCMaps psnames; /* for seac */ - FT_UInt num_glyphs; - FT_Byte** glyph_names; - - FT_Int lenIV; /* internal for sub routine calls */ - FT_UInt num_subrs; - FT_Byte** subrs; - FT_PtrDist* subrs_len; /* array of subrs length (optional) */ - - FT_Matrix font_matrix; - FT_Vector font_offset; - - FT_Int flex_state; - FT_Int num_flex_vectors; - FT_Vector flex_vectors[7]; - - PS_Blend blend; /* for multiple master support */ - - FT_Render_Mode hint_mode; - - T1_Decoder_Callback parse_callback; - T1_Decoder_FuncsRec funcs; - - FT_Long* buildchar; - FT_UInt len_buildchar; - - FT_Bool seac; - - } T1_DecoderRec; - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** AFM PARSER *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - typedef struct AFM_ParserRec_* AFM_Parser; - - typedef struct AFM_Parser_FuncsRec_ - { - FT_Error - (*init)( AFM_Parser parser, - FT_Memory memory, - FT_Byte* base, - FT_Byte* limit ); - - void - (*done)( AFM_Parser parser ); - - FT_Error - (*parse)( AFM_Parser parser ); - - } AFM_Parser_FuncsRec; - - - typedef struct AFM_StreamRec_* AFM_Stream; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* AFM_ParserRec */ - /* */ - /* <Description> */ - /* An AFM_Parser is a parser for the AFM files. */ - /* */ - /* <Fields> */ - /* memory :: The object used for memory operations (alloc and */ - /* realloc). */ - /* */ - /* stream :: This is an opaque object. */ - /* */ - /* FontInfo :: The result will be stored here. */ - /* */ - /* get_index :: A user provided function to get a glyph index by its */ - /* name. */ - /* */ - typedef struct AFM_ParserRec_ - { - FT_Memory memory; - AFM_Stream stream; - - AFM_FontInfo FontInfo; - - FT_Int - (*get_index)( const char* name, - FT_Offset len, - void* user_data ); - - void* user_data; - - } AFM_ParserRec; - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** TYPE1 CHARMAPS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - typedef const struct T1_CMap_ClassesRec_* T1_CMap_Classes; - - typedef struct T1_CMap_ClassesRec_ - { - FT_CMap_Class standard; - FT_CMap_Class expert; - FT_CMap_Class custom; - FT_CMap_Class unicode; - - } T1_CMap_ClassesRec; - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** PSAux Module Interface *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - typedef struct PSAux_ServiceRec_ - { - /* don't use `PS_Table_Funcs' and friends to avoid compiler warnings */ - const PS_Table_FuncsRec* ps_table_funcs; - const PS_Parser_FuncsRec* ps_parser_funcs; - const T1_Builder_FuncsRec* t1_builder_funcs; - const T1_Decoder_FuncsRec* t1_decoder_funcs; - - void - (*t1_decrypt)( FT_Byte* buffer, - FT_Offset length, - FT_UShort seed ); - - T1_CMap_Classes t1_cmap_classes; - - /* fields after this comment line were added after version 2.1.10 */ - const AFM_Parser_FuncsRec* afm_parser_funcs; - - } PSAux_ServiceRec, *PSAux_Service; - - /* backwards-compatible type definition */ - typedef PSAux_ServiceRec PSAux_Interface; - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** Some convenience functions *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - -#define IS_PS_NEWLINE( ch ) \ - ( (ch) == '\r' || \ - (ch) == '\n' ) - -#define IS_PS_SPACE( ch ) \ - ( (ch) == ' ' || \ - IS_PS_NEWLINE( ch ) || \ - (ch) == '\t' || \ - (ch) == '\f' || \ - (ch) == '\0' ) - -#define IS_PS_SPECIAL( ch ) \ - ( (ch) == '/' || \ - (ch) == '(' || (ch) == ')' || \ - (ch) == '<' || (ch) == '>' || \ - (ch) == '[' || (ch) == ']' || \ - (ch) == '{' || (ch) == '}' || \ - (ch) == '%' ) - -#define IS_PS_DELIM( ch ) \ - ( IS_PS_SPACE( ch ) || \ - IS_PS_SPECIAL( ch ) ) - -#define IS_PS_DIGIT( ch ) \ - ( (ch) >= '0' && (ch) <= '9' ) - -#define IS_PS_XDIGIT( ch ) \ - ( IS_PS_DIGIT( ch ) || \ - ( (ch) >= 'A' && (ch) <= 'F' ) || \ - ( (ch) >= 'a' && (ch) <= 'f' ) ) - -#define IS_PS_BASE85( ch ) \ - ( (ch) >= '!' && (ch) <= 'u' ) - -#define IS_PS_TOKEN( cur, limit, token ) \ - ( (char)(cur)[0] == (token)[0] && \ - ( (cur) + sizeof ( (token) ) == (limit) || \ - ( (cur) + sizeof( (token) ) < (limit) && \ - IS_PS_DELIM( (cur)[sizeof ( (token) ) - 1] ) ) ) && \ - ft_strncmp( (char*)(cur), (token), sizeof ( (token) ) - 1 ) == 0 ) - - -FT_END_HEADER - -#endif /* __PSAUX_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/pshints.h b/thirdparty/include/freetype/internal/pshints.h deleted file mode 100644 index 6b6af9c05..000000000 --- a/thirdparty/include/freetype/internal/pshints.h +++ /dev/null @@ -1,722 +0,0 @@ -/***************************************************************************/ -/* */ -/* pshints.h */ -/* */ -/* Interface to Postscript-specific (Type 1 and Type 2) hints */ -/* recorders (specification only). These are used to support native */ -/* T1/T2 hints in the `type1', `cid', and `cff' font drivers. */ -/* */ -/* Copyright 2001-2003, 2005-2007, 2009, 2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __PSHINTS_H__ -#define __PSHINTS_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H -#include FT_TYPE1_TABLES_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** INTERNAL REPRESENTATION OF GLOBALS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - typedef struct PSH_GlobalsRec_* PSH_Globals; - - typedef FT_Error - (*PSH_Globals_NewFunc)( FT_Memory memory, - T1_Private* private_dict, - PSH_Globals* aglobals ); - - typedef FT_Error - (*PSH_Globals_SetScaleFunc)( PSH_Globals globals, - FT_Fixed x_scale, - FT_Fixed y_scale, - FT_Fixed x_delta, - FT_Fixed y_delta ); - - typedef void - (*PSH_Globals_DestroyFunc)( PSH_Globals globals ); - - - typedef struct PSH_Globals_FuncsRec_ - { - PSH_Globals_NewFunc create; - PSH_Globals_SetScaleFunc set_scale; - PSH_Globals_DestroyFunc destroy; - - } PSH_Globals_FuncsRec, *PSH_Globals_Funcs; - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** PUBLIC TYPE 1 HINTS RECORDER *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /************************************************************************* - * - * @type: - * T1_Hints - * - * @description: - * This is a handle to an opaque structure used to record glyph hints - * from a Type 1 character glyph character string. - * - * The methods used to operate on this object are defined by the - * @T1_Hints_FuncsRec structure. Recording glyph hints is normally - * achieved through the following scheme: - * - * - Open a new hint recording session by calling the `open' method. - * This rewinds the recorder and prepare it for new input. - * - * - For each hint found in the glyph charstring, call the corresponding - * method (`stem', `stem3', or `reset'). Note that these functions do - * not return an error code. - * - * - Close the recording session by calling the `close' method. It - * returns an error code if the hints were invalid or something - * strange happened (e.g., memory shortage). - * - * The hints accumulated in the object can later be used by the - * PostScript hinter. - * - */ - typedef struct T1_HintsRec_* T1_Hints; - - - /************************************************************************* - * - * @type: - * T1_Hints_Funcs - * - * @description: - * A pointer to the @T1_Hints_FuncsRec structure that defines the API of - * a given @T1_Hints object. - * - */ - typedef const struct T1_Hints_FuncsRec_* T1_Hints_Funcs; - - - /************************************************************************* - * - * @functype: - * T1_Hints_OpenFunc - * - * @description: - * A method of the @T1_Hints class used to prepare it for a new Type 1 - * hints recording session. - * - * @input: - * hints :: - * A handle to the Type 1 hints recorder. - * - * @note: - * You should always call the @T1_Hints_CloseFunc method in order to - * close an opened recording session. - * - */ - typedef void - (*T1_Hints_OpenFunc)( T1_Hints hints ); - - - /************************************************************************* - * - * @functype: - * T1_Hints_SetStemFunc - * - * @description: - * A method of the @T1_Hints class used to record a new horizontal or - * vertical stem. This corresponds to the Type 1 `hstem' and `vstem' - * operators. - * - * @input: - * hints :: - * A handle to the Type 1 hints recorder. - * - * dimension :: - * 0 for horizontal stems (hstem), 1 for vertical ones (vstem). - * - * coords :: - * Array of 2 coordinates in 16.16 format, used as (position,length) - * stem descriptor. - * - * @note: - * Use vertical coordinates (y) for horizontal stems (dim=0). Use - * horizontal coordinates (x) for vertical stems (dim=1). - * - * `coords[0]' is the absolute stem position (lowest coordinate); - * `coords[1]' is the length. - * - * The length can be negative, in which case it must be either -20 or - * -21. It is interpreted as a `ghost' stem, according to the Type 1 - * specification. - * - * If the length is -21 (corresponding to a bottom ghost stem), then - * the real stem position is `coords[0]+coords[1]'. - * - */ - typedef void - (*T1_Hints_SetStemFunc)( T1_Hints hints, - FT_UInt dimension, - FT_Fixed* coords ); - - - /************************************************************************* - * - * @functype: - * T1_Hints_SetStem3Func - * - * @description: - * A method of the @T1_Hints class used to record three - * counter-controlled horizontal or vertical stems at once. - * - * @input: - * hints :: - * A handle to the Type 1 hints recorder. - * - * dimension :: - * 0 for horizontal stems, 1 for vertical ones. - * - * coords :: - * An array of 6 values in 16.16 format, holding 3 (position,length) - * pairs for the counter-controlled stems. - * - * @note: - * Use vertical coordinates (y) for horizontal stems (dim=0). Use - * horizontal coordinates (x) for vertical stems (dim=1). - * - * The lengths cannot be negative (ghost stems are never - * counter-controlled). - * - */ - typedef void - (*T1_Hints_SetStem3Func)( T1_Hints hints, - FT_UInt dimension, - FT_Fixed* coords ); - - - /************************************************************************* - * - * @functype: - * T1_Hints_ResetFunc - * - * @description: - * A method of the @T1_Hints class used to reset the stems hints in a - * recording session. - * - * @input: - * hints :: - * A handle to the Type 1 hints recorder. - * - * end_point :: - * The index of the last point in the input glyph in which the - * previously defined hints apply. - * - */ - typedef void - (*T1_Hints_ResetFunc)( T1_Hints hints, - FT_UInt end_point ); - - - /************************************************************************* - * - * @functype: - * T1_Hints_CloseFunc - * - * @description: - * A method of the @T1_Hints class used to close a hint recording - * session. - * - * @input: - * hints :: - * A handle to the Type 1 hints recorder. - * - * end_point :: - * The index of the last point in the input glyph. - * - * @return: - * FreeType error code. 0 means success. - * - * @note: - * The error code is set to indicate that an error occurred during the - * recording session. - * - */ - typedef FT_Error - (*T1_Hints_CloseFunc)( T1_Hints hints, - FT_UInt end_point ); - - - /************************************************************************* - * - * @functype: - * T1_Hints_ApplyFunc - * - * @description: - * A method of the @T1_Hints class used to apply hints to the - * corresponding glyph outline. Must be called once all hints have been - * recorded. - * - * @input: - * hints :: - * A handle to the Type 1 hints recorder. - * - * outline :: - * A pointer to the target outline descriptor. - * - * globals :: - * The hinter globals for this font. - * - * hint_mode :: - * Hinting information. - * - * @return: - * FreeType error code. 0 means success. - * - * @note: - * On input, all points within the outline are in font coordinates. On - * output, they are in 1/64th of pixels. - * - * The scaling transformation is taken from the `globals' object which - * must correspond to the same font as the glyph. - * - */ - typedef FT_Error - (*T1_Hints_ApplyFunc)( T1_Hints hints, - FT_Outline* outline, - PSH_Globals globals, - FT_Render_Mode hint_mode ); - - - /************************************************************************* - * - * @struct: - * T1_Hints_FuncsRec - * - * @description: - * The structure used to provide the API to @T1_Hints objects. - * - * @fields: - * hints :: - * A handle to the T1 Hints recorder. - * - * open :: - * The function to open a recording session. - * - * close :: - * The function to close a recording session. - * - * stem :: - * The function to set a simple stem. - * - * stem3 :: - * The function to set counter-controlled stems. - * - * reset :: - * The function to reset stem hints. - * - * apply :: - * The function to apply the hints to the corresponding glyph outline. - * - */ - typedef struct T1_Hints_FuncsRec_ - { - T1_Hints hints; - T1_Hints_OpenFunc open; - T1_Hints_CloseFunc close; - T1_Hints_SetStemFunc stem; - T1_Hints_SetStem3Func stem3; - T1_Hints_ResetFunc reset; - T1_Hints_ApplyFunc apply; - - } T1_Hints_FuncsRec; - - - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** PUBLIC TYPE 2 HINTS RECORDER *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - - /************************************************************************* - * - * @type: - * T2_Hints - * - * @description: - * This is a handle to an opaque structure used to record glyph hints - * from a Type 2 character glyph character string. - * - * The methods used to operate on this object are defined by the - * @T2_Hints_FuncsRec structure. Recording glyph hints is normally - * achieved through the following scheme: - * - * - Open a new hint recording session by calling the `open' method. - * This rewinds the recorder and prepare it for new input. - * - * - For each hint found in the glyph charstring, call the corresponding - * method (`stems', `hintmask', `counters'). Note that these - * functions do not return an error code. - * - * - Close the recording session by calling the `close' method. It - * returns an error code if the hints were invalid or something - * strange happened (e.g., memory shortage). - * - * The hints accumulated in the object can later be used by the - * Postscript hinter. - * - */ - typedef struct T2_HintsRec_* T2_Hints; - - - /************************************************************************* - * - * @type: - * T2_Hints_Funcs - * - * @description: - * A pointer to the @T2_Hints_FuncsRec structure that defines the API of - * a given @T2_Hints object. - * - */ - typedef const struct T2_Hints_FuncsRec_* T2_Hints_Funcs; - - - /************************************************************************* - * - * @functype: - * T2_Hints_OpenFunc - * - * @description: - * A method of the @T2_Hints class used to prepare it for a new Type 2 - * hints recording session. - * - * @input: - * hints :: - * A handle to the Type 2 hints recorder. - * - * @note: - * You should always call the @T2_Hints_CloseFunc method in order to - * close an opened recording session. - * - */ - typedef void - (*T2_Hints_OpenFunc)( T2_Hints hints ); - - - /************************************************************************* - * - * @functype: - * T2_Hints_StemsFunc - * - * @description: - * A method of the @T2_Hints class used to set the table of stems in - * either the vertical or horizontal dimension. Equivalent to the - * `hstem', `vstem', `hstemhm', and `vstemhm' Type 2 operators. - * - * @input: - * hints :: - * A handle to the Type 2 hints recorder. - * - * dimension :: - * 0 for horizontal stems (hstem), 1 for vertical ones (vstem). - * - * count :: - * The number of stems. - * - * coords :: - * An array of `count' (position,length) pairs in 16.16 format. - * - * @note: - * Use vertical coordinates (y) for horizontal stems (dim=0). Use - * horizontal coordinates (x) for vertical stems (dim=1). - * - * There are `2*count' elements in the `coords' array. Each even - * element is an absolute position in font units, each odd element is a - * length in font units. - * - * A length can be negative, in which case it must be either -20 or - * -21. It is interpreted as a `ghost' stem, according to the Type 1 - * specification. - * - */ - typedef void - (*T2_Hints_StemsFunc)( T2_Hints hints, - FT_UInt dimension, - FT_UInt count, - FT_Fixed* coordinates ); - - - /************************************************************************* - * - * @functype: - * T2_Hints_MaskFunc - * - * @description: - * A method of the @T2_Hints class used to set a given hintmask (this - * corresponds to the `hintmask' Type 2 operator). - * - * @input: - * hints :: - * A handle to the Type 2 hints recorder. - * - * end_point :: - * The glyph index of the last point to which the previously defined - * or activated hints apply. - * - * bit_count :: - * The number of bits in the hint mask. - * - * bytes :: - * An array of bytes modelling the hint mask. - * - * @note: - * If the hintmask starts the charstring (before any glyph point - * definition), the value of `end_point' should be 0. - * - * `bit_count' is the number of meaningful bits in the `bytes' array; it - * must be equal to the total number of hints defined so far (i.e., - * horizontal+verticals). - * - * The `bytes' array can come directly from the Type 2 charstring and - * respects the same format. - * - */ - typedef void - (*T2_Hints_MaskFunc)( T2_Hints hints, - FT_UInt end_point, - FT_UInt bit_count, - const FT_Byte* bytes ); - - - /************************************************************************* - * - * @functype: - * T2_Hints_CounterFunc - * - * @description: - * A method of the @T2_Hints class used to set a given counter mask - * (this corresponds to the `hintmask' Type 2 operator). - * - * @input: - * hints :: - * A handle to the Type 2 hints recorder. - * - * end_point :: - * A glyph index of the last point to which the previously defined or - * active hints apply. - * - * bit_count :: - * The number of bits in the hint mask. - * - * bytes :: - * An array of bytes modelling the hint mask. - * - * @note: - * If the hintmask starts the charstring (before any glyph point - * definition), the value of `end_point' should be 0. - * - * `bit_count' is the number of meaningful bits in the `bytes' array; it - * must be equal to the total number of hints defined so far (i.e., - * horizontal+verticals). - * - * The `bytes' array can come directly from the Type 2 charstring and - * respects the same format. - * - */ - typedef void - (*T2_Hints_CounterFunc)( T2_Hints hints, - FT_UInt bit_count, - const FT_Byte* bytes ); - - - /************************************************************************* - * - * @functype: - * T2_Hints_CloseFunc - * - * @description: - * A method of the @T2_Hints class used to close a hint recording - * session. - * - * @input: - * hints :: - * A handle to the Type 2 hints recorder. - * - * end_point :: - * The index of the last point in the input glyph. - * - * @return: - * FreeType error code. 0 means success. - * - * @note: - * The error code is set to indicate that an error occurred during the - * recording session. - * - */ - typedef FT_Error - (*T2_Hints_CloseFunc)( T2_Hints hints, - FT_UInt end_point ); - - - /************************************************************************* - * - * @functype: - * T2_Hints_ApplyFunc - * - * @description: - * A method of the @T2_Hints class used to apply hints to the - * corresponding glyph outline. Must be called after the `close' - * method. - * - * @input: - * hints :: - * A handle to the Type 2 hints recorder. - * - * outline :: - * A pointer to the target outline descriptor. - * - * globals :: - * The hinter globals for this font. - * - * hint_mode :: - * Hinting information. - * - * @return: - * FreeType error code. 0 means success. - * - * @note: - * On input, all points within the outline are in font coordinates. On - * output, they are in 1/64th of pixels. - * - * The scaling transformation is taken from the `globals' object which - * must correspond to the same font than the glyph. - * - */ - typedef FT_Error - (*T2_Hints_ApplyFunc)( T2_Hints hints, - FT_Outline* outline, - PSH_Globals globals, - FT_Render_Mode hint_mode ); - - - /************************************************************************* - * - * @struct: - * T2_Hints_FuncsRec - * - * @description: - * The structure used to provide the API to @T2_Hints objects. - * - * @fields: - * hints :: - * A handle to the T2 hints recorder object. - * - * open :: - * The function to open a recording session. - * - * close :: - * The function to close a recording session. - * - * stems :: - * The function to set the dimension's stems table. - * - * hintmask :: - * The function to set hint masks. - * - * counter :: - * The function to set counter masks. - * - * apply :: - * The function to apply the hints on the corresponding glyph outline. - * - */ - typedef struct T2_Hints_FuncsRec_ - { - T2_Hints hints; - T2_Hints_OpenFunc open; - T2_Hints_CloseFunc close; - T2_Hints_StemsFunc stems; - T2_Hints_MaskFunc hintmask; - T2_Hints_CounterFunc counter; - T2_Hints_ApplyFunc apply; - - } T2_Hints_FuncsRec; - - - /* */ - - - typedef struct PSHinter_Interface_ - { - PSH_Globals_Funcs (*get_globals_funcs)( FT_Module module ); - T1_Hints_Funcs (*get_t1_funcs) ( FT_Module module ); - T2_Hints_Funcs (*get_t2_funcs) ( FT_Module module ); - - } PSHinter_Interface; - - typedef PSHinter_Interface* PSHinter_Service; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_PSHINTER_INTERFACE( \ - class_, \ - get_globals_funcs_, \ - get_t1_funcs_, \ - get_t2_funcs_ ) \ - static const PSHinter_Interface class_ = \ - { \ - get_globals_funcs_, \ - get_t1_funcs_, \ - get_t2_funcs_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_PSHINTER_INTERFACE( \ - class_, \ - get_globals_funcs_, \ - get_t1_funcs_, \ - get_t2_funcs_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - PSHinter_Interface* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_globals_funcs = get_globals_funcs_; \ - clazz->get_t1_funcs = get_t1_funcs_; \ - clazz->get_t2_funcs = get_t2_funcs_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - -FT_END_HEADER - -#endif /* __PSHINTS_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svbdf.h b/thirdparty/include/freetype/internal/services/svbdf.h deleted file mode 100644 index 0974752a7..000000000 --- a/thirdparty/include/freetype/internal/services/svbdf.h +++ /dev/null @@ -1,82 +0,0 @@ -/***************************************************************************/ -/* */ -/* svbdf.h */ -/* */ -/* The FreeType BDF services (specification). */ -/* */ -/* Copyright 2003, 2009, 2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVBDF_H__ -#define __SVBDF_H__ - -#include FT_BDF_H -#include FT_INTERNAL_SERVICE_H - - -FT_BEGIN_HEADER - - -#define FT_SERVICE_ID_BDF "bdf" - - typedef FT_Error - (*FT_BDF_GetCharsetIdFunc)( FT_Face face, - const char* *acharset_encoding, - const char* *acharset_registry ); - - typedef FT_Error - (*FT_BDF_GetPropertyFunc)( FT_Face face, - const char* prop_name, - BDF_PropertyRec *aproperty ); - - - FT_DEFINE_SERVICE( BDF ) - { - FT_BDF_GetCharsetIdFunc get_charset_id; - FT_BDF_GetPropertyFunc get_property; - }; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_BDFRec( class_, \ - get_charset_id_, \ - get_property_ ) \ - static const FT_Service_BDFRec class_ = \ - { \ - get_charset_id_, get_property_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_BDFRec( class_, \ - get_charset_id_, \ - get_property_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_BDFRec* clazz ) \ - { \ - clazz->get_charset_id = get_charset_id_; \ - clazz->get_property = get_property_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - - -FT_END_HEADER - - -#endif /* __SVBDF_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svcid.h b/thirdparty/include/freetype/internal/services/svcid.h deleted file mode 100644 index 6be3f9374..000000000 --- a/thirdparty/include/freetype/internal/services/svcid.h +++ /dev/null @@ -1,89 +0,0 @@ -/***************************************************************************/ -/* */ -/* svcid.h */ -/* */ -/* The FreeType CID font services (specification). */ -/* */ -/* Copyright 2007, 2009, 2012 by Derek Clegg, Michael Toftdal. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVCID_H__ -#define __SVCID_H__ - -#include FT_INTERNAL_SERVICE_H - - -FT_BEGIN_HEADER - - -#define FT_SERVICE_ID_CID "CID" - - typedef FT_Error - (*FT_CID_GetRegistryOrderingSupplementFunc)( FT_Face face, - const char* *registry, - const char* *ordering, - FT_Int *supplement ); - typedef FT_Error - (*FT_CID_GetIsInternallyCIDKeyedFunc)( FT_Face face, - FT_Bool *is_cid ); - typedef FT_Error - (*FT_CID_GetCIDFromGlyphIndexFunc)( FT_Face face, - FT_UInt glyph_index, - FT_UInt *cid ); - - FT_DEFINE_SERVICE( CID ) - { - FT_CID_GetRegistryOrderingSupplementFunc get_ros; - FT_CID_GetIsInternallyCIDKeyedFunc get_is_cid; - FT_CID_GetCIDFromGlyphIndexFunc get_cid_from_glyph_index; - }; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_CIDREC( class_, \ - get_ros_, \ - get_is_cid_, \ - get_cid_from_glyph_index_ ) \ - static const FT_Service_CIDRec class_ = \ - { \ - get_ros_, get_is_cid_, get_cid_from_glyph_index_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_CIDREC( class_, \ - get_ros_, \ - get_is_cid_, \ - get_cid_from_glyph_index_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_CIDRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_ros = get_ros_; \ - clazz->get_is_cid = get_is_cid_; \ - clazz->get_cid_from_glyph_index = get_cid_from_glyph_index_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - - -FT_END_HEADER - - -#endif /* __SVCID_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svgldict.h b/thirdparty/include/freetype/internal/services/svgldict.h deleted file mode 100644 index 1d1253472..000000000 --- a/thirdparty/include/freetype/internal/services/svgldict.h +++ /dev/null @@ -1,88 +0,0 @@ -/***************************************************************************/ -/* */ -/* svgldict.h */ -/* */ -/* The FreeType glyph dictionary services (specification). */ -/* */ -/* Copyright 2003, 2009, 2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVGLDICT_H__ -#define __SVGLDICT_H__ - -#include FT_INTERNAL_SERVICE_H - - -FT_BEGIN_HEADER - - - /* - * A service used to retrieve glyph names, as well as to find the - * index of a given glyph name in a font. - * - */ - -#define FT_SERVICE_ID_GLYPH_DICT "glyph-dict" - - - typedef FT_Error - (*FT_GlyphDict_GetNameFunc)( FT_Face face, - FT_UInt glyph_index, - FT_Pointer buffer, - FT_UInt buffer_max ); - - typedef FT_UInt - (*FT_GlyphDict_NameIndexFunc)( FT_Face face, - FT_String* glyph_name ); - - - FT_DEFINE_SERVICE( GlyphDict ) - { - FT_GlyphDict_GetNameFunc get_name; - FT_GlyphDict_NameIndexFunc name_index; /* optional */ - }; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \ - get_name_, \ - name_index_) \ - static const FT_Service_GlyphDictRec class_ = \ - { \ - get_name_, name_index_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_GLYPHDICTREC( class_, \ - get_name_, \ - name_index_) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_GlyphDictRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_name = get_name_; \ - clazz->name_index = name_index_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - - -FT_END_HEADER - - -#endif /* __SVGLDICT_H__ */ diff --git a/thirdparty/include/freetype/internal/services/svgxval.h b/thirdparty/include/freetype/internal/services/svgxval.h deleted file mode 100644 index 2cdab5065..000000000 --- a/thirdparty/include/freetype/internal/services/svgxval.h +++ /dev/null @@ -1,72 +0,0 @@ -/***************************************************************************/ -/* */ -/* svgxval.h */ -/* */ -/* FreeType API for validating TrueTypeGX/AAT tables (specification). */ -/* */ -/* Copyright 2004, 2005 by */ -/* Masatake YAMATO, Red Hat K.K., */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVGXVAL_H__ -#define __SVGXVAL_H__ - -#include FT_GX_VALIDATE_H -#include FT_INTERNAL_VALIDATE_H - -FT_BEGIN_HEADER - - -#define FT_SERVICE_ID_GX_VALIDATE "truetypegx-validate" -#define FT_SERVICE_ID_CLASSICKERN_VALIDATE "classickern-validate" - - typedef FT_Error - (*gxv_validate_func)( FT_Face face, - FT_UInt gx_flags, - FT_Bytes tables[FT_VALIDATE_GX_LENGTH], - FT_UInt table_length ); - - - typedef FT_Error - (*ckern_validate_func)( FT_Face face, - FT_UInt ckern_flags, - FT_Bytes *ckern_table ); - - - FT_DEFINE_SERVICE( GXvalidate ) - { - gxv_validate_func validate; - }; - - FT_DEFINE_SERVICE( CKERNvalidate ) - { - ckern_validate_func validate; - }; - - /* */ - - -FT_END_HEADER - - -#endif /* __SVGXVAL_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svkern.h b/thirdparty/include/freetype/internal/services/svkern.h deleted file mode 100644 index 1488adf49..000000000 --- a/thirdparty/include/freetype/internal/services/svkern.h +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************/ -/* */ -/* svkern.h */ -/* */ -/* The FreeType Kerning service (specification). */ -/* */ -/* Copyright 2006 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVKERN_H__ -#define __SVKERN_H__ - -#include FT_INTERNAL_SERVICE_H -#include FT_TRUETYPE_TABLES_H - - -FT_BEGIN_HEADER - -#define FT_SERVICE_ID_KERNING "kerning" - - - typedef FT_Error - (*FT_Kerning_TrackGetFunc)( FT_Face face, - FT_Fixed point_size, - FT_Int degree, - FT_Fixed* akerning ); - - FT_DEFINE_SERVICE( Kerning ) - { - FT_Kerning_TrackGetFunc get_track; - }; - - /* */ - - -FT_END_HEADER - - -#endif /* __SVKERN_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svmm.h b/thirdparty/include/freetype/internal/services/svmm.h deleted file mode 100644 index b08a663d6..000000000 --- a/thirdparty/include/freetype/internal/services/svmm.h +++ /dev/null @@ -1,113 +0,0 @@ -/***************************************************************************/ -/* */ -/* svmm.h */ -/* */ -/* The FreeType Multiple Masters and GX var services (specification). */ -/* */ -/* Copyright 2003, 2004, 2009, 2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVMM_H__ -#define __SVMM_H__ - -#include FT_INTERNAL_SERVICE_H - - -FT_BEGIN_HEADER - - - /* - * A service used to manage multiple-masters data in a given face. - * - * See the related APIs in `ftmm.h' (FT_MULTIPLE_MASTERS_H). - * - */ - -#define FT_SERVICE_ID_MULTI_MASTERS "multi-masters" - - - typedef FT_Error - (*FT_Get_MM_Func)( FT_Face face, - FT_Multi_Master* master ); - - typedef FT_Error - (*FT_Get_MM_Var_Func)( FT_Face face, - FT_MM_Var* *master ); - - typedef FT_Error - (*FT_Set_MM_Design_Func)( FT_Face face, - FT_UInt num_coords, - FT_Long* coords ); - - typedef FT_Error - (*FT_Set_Var_Design_Func)( FT_Face face, - FT_UInt num_coords, - FT_Fixed* coords ); - - typedef FT_Error - (*FT_Set_MM_Blend_Func)( FT_Face face, - FT_UInt num_coords, - FT_Long* coords ); - - - FT_DEFINE_SERVICE( MultiMasters ) - { - FT_Get_MM_Func get_mm; - FT_Set_MM_Design_Func set_mm_design; - FT_Set_MM_Blend_Func set_mm_blend; - FT_Get_MM_Var_Func get_mm_var; - FT_Set_Var_Design_Func set_var_design; - }; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ - get_mm_, \ - set_mm_design_, \ - set_mm_blend_, \ - get_mm_var_, \ - set_var_design_ ) \ - static const FT_Service_MultiMastersRec class_ = \ - { \ - get_mm_, set_mm_design_, set_mm_blend_, get_mm_var_, set_var_design_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_, \ - get_mm_, \ - set_mm_design_, \ - set_mm_blend_, \ - get_mm_var_, \ - set_var_design_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_MultiMastersRec* clazz ) \ - { \ - clazz->get_mm = get_mm_; \ - clazz->set_mm_design = set_mm_design_; \ - clazz->set_mm_blend = set_mm_blend_; \ - clazz->get_mm_var = get_mm_var_; \ - clazz->set_var_design = set_var_design_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - - -FT_END_HEADER - -#endif /* __SVMM_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svotval.h b/thirdparty/include/freetype/internal/services/svotval.h deleted file mode 100644 index 970bbd575..000000000 --- a/thirdparty/include/freetype/internal/services/svotval.h +++ /dev/null @@ -1,55 +0,0 @@ -/***************************************************************************/ -/* */ -/* svotval.h */ -/* */ -/* The FreeType OpenType validation service (specification). */ -/* */ -/* Copyright 2004, 2006 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVOTVAL_H__ -#define __SVOTVAL_H__ - -#include FT_OPENTYPE_VALIDATE_H -#include FT_INTERNAL_VALIDATE_H - -FT_BEGIN_HEADER - - -#define FT_SERVICE_ID_OPENTYPE_VALIDATE "opentype-validate" - - - typedef FT_Error - (*otv_validate_func)( FT_Face volatile face, - FT_UInt ot_flags, - FT_Bytes *base, - FT_Bytes *gdef, - FT_Bytes *gpos, - FT_Bytes *gsub, - FT_Bytes *jstf ); - - - FT_DEFINE_SERVICE( OTvalidate ) - { - otv_validate_func validate; - }; - - /* */ - - -FT_END_HEADER - - -#endif /* __SVOTVAL_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svpfr.h b/thirdparty/include/freetype/internal/services/svpfr.h deleted file mode 100644 index 462786f9c..000000000 --- a/thirdparty/include/freetype/internal/services/svpfr.h +++ /dev/null @@ -1,66 +0,0 @@ -/***************************************************************************/ -/* */ -/* svpfr.h */ -/* */ -/* Internal PFR service functions (specification). */ -/* */ -/* Copyright 2003, 2006 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVPFR_H__ -#define __SVPFR_H__ - -#include FT_PFR_H -#include FT_INTERNAL_SERVICE_H - - -FT_BEGIN_HEADER - - -#define FT_SERVICE_ID_PFR_METRICS "pfr-metrics" - - - typedef FT_Error - (*FT_PFR_GetMetricsFunc)( FT_Face face, - FT_UInt *aoutline, - FT_UInt *ametrics, - FT_Fixed *ax_scale, - FT_Fixed *ay_scale ); - - typedef FT_Error - (*FT_PFR_GetKerningFunc)( FT_Face face, - FT_UInt left, - FT_UInt right, - FT_Vector *avector ); - - typedef FT_Error - (*FT_PFR_GetAdvanceFunc)( FT_Face face, - FT_UInt gindex, - FT_Pos *aadvance ); - - - FT_DEFINE_SERVICE( PfrMetrics ) - { - FT_PFR_GetMetricsFunc get_metrics; - FT_PFR_GetKerningFunc get_kerning; - FT_PFR_GetAdvanceFunc get_advance; - - }; - - /* */ - -FT_END_HEADER - -#endif /* __SVPFR_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svpostnm.h b/thirdparty/include/freetype/internal/services/svpostnm.h deleted file mode 100644 index a76b4fe05..000000000 --- a/thirdparty/include/freetype/internal/services/svpostnm.h +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************/ -/* */ -/* svpostnm.h */ -/* */ -/* The FreeType PostScript name services (specification). */ -/* */ -/* Copyright 2003, 2007, 2009, 2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVPOSTNM_H__ -#define __SVPOSTNM_H__ - -#include FT_INTERNAL_SERVICE_H - - -FT_BEGIN_HEADER - - /* - * A trivial service used to retrieve the PostScript name of a given - * font when available. The `get_name' field should never be NULL. - * - * The corresponding function can return NULL to indicate that the - * PostScript name is not available. - * - * The name is owned by the face and will be destroyed with it. - */ - -#define FT_SERVICE_ID_POSTSCRIPT_FONT_NAME "postscript-font-name" - - - typedef const char* - (*FT_PsName_GetFunc)( FT_Face face ); - - - FT_DEFINE_SERVICE( PsFontName ) - { - FT_PsName_GetFunc get_ps_font_name; - }; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \ - static const FT_Service_PsFontNameRec class_ = \ - { \ - get_ps_font_name_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_PSFONTNAMEREC( class_, get_ps_font_name_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_PsFontNameRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_ps_font_name = get_ps_font_name_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - - -FT_END_HEADER - - -#endif /* __SVPOSTNM_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svprop.h b/thirdparty/include/freetype/internal/services/svprop.h deleted file mode 100644 index 22da0bbc6..000000000 --- a/thirdparty/include/freetype/internal/services/svprop.h +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************/ -/* */ -/* svprop.h */ -/* */ -/* The FreeType property service (specification). */ -/* */ -/* Copyright 2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVPROP_H__ -#define __SVPROP_H__ - - -FT_BEGIN_HEADER - - -#define FT_SERVICE_ID_PROPERTIES "properties" - - - typedef FT_Error - (*FT_Properties_SetFunc)( FT_Module module, - const char* property_name, - const void* value ); - - typedef FT_Error - (*FT_Properties_GetFunc)( FT_Module module, - const char* property_name, - void* value ); - - - FT_DEFINE_SERVICE( Properties ) - { - FT_Properties_SetFunc set_property; - FT_Properties_GetFunc get_property; - }; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_PROPERTIESREC( class_, \ - set_property_, \ - get_property_ ) \ - static const FT_Service_PropertiesRec class_ = \ - { \ - set_property_, \ - get_property_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_PROPERTIESREC( class_, \ - set_property_, \ - get_property_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_PropertiesRec* clazz ) \ - { \ - clazz->set_property = set_property_; \ - clazz->get_property = get_property_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - - -FT_END_HEADER - - -#endif /* __SVPROP_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svpscmap.h b/thirdparty/include/freetype/internal/services/svpscmap.h deleted file mode 100644 index 030948ea6..000000000 --- a/thirdparty/include/freetype/internal/services/svpscmap.h +++ /dev/null @@ -1,177 +0,0 @@ -/***************************************************************************/ -/* */ -/* svpscmap.h */ -/* */ -/* The FreeType PostScript charmap service (specification). */ -/* */ -/* Copyright 2003, 2006, 2009, 2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVPSCMAP_H__ -#define __SVPSCMAP_H__ - -#include FT_INTERNAL_OBJECTS_H - - -FT_BEGIN_HEADER - - -#define FT_SERVICE_ID_POSTSCRIPT_CMAPS "postscript-cmaps" - - - /* - * Adobe glyph name to unicode value. - */ - typedef FT_UInt32 - (*PS_Unicode_ValueFunc)( const char* glyph_name ); - - /* - * Macintosh name id to glyph name. NULL if invalid index. - */ - typedef const char* - (*PS_Macintosh_NameFunc)( FT_UInt name_index ); - - /* - * Adobe standard string ID to glyph name. NULL if invalid index. - */ - typedef const char* - (*PS_Adobe_Std_StringsFunc)( FT_UInt string_index ); - - - /* - * Simple unicode -> glyph index charmap built from font glyph names - * table. - */ - typedef struct PS_UniMap_ - { - FT_UInt32 unicode; /* bit 31 set: is glyph variant */ - FT_UInt glyph_index; - - } PS_UniMap; - - - typedef struct PS_UnicodesRec_* PS_Unicodes; - - typedef struct PS_UnicodesRec_ - { - FT_CMapRec cmap; - FT_UInt num_maps; - PS_UniMap* maps; - - } PS_UnicodesRec; - - - /* - * A function which returns a glyph name for a given index. Returns - * NULL if invalid index. - */ - typedef const char* - (*PS_GetGlyphNameFunc)( FT_Pointer data, - FT_UInt string_index ); - - /* - * A function used to release the glyph name returned by - * PS_GetGlyphNameFunc, when needed - */ - typedef void - (*PS_FreeGlyphNameFunc)( FT_Pointer data, - const char* name ); - - typedef FT_Error - (*PS_Unicodes_InitFunc)( FT_Memory memory, - PS_Unicodes unicodes, - FT_UInt num_glyphs, - PS_GetGlyphNameFunc get_glyph_name, - PS_FreeGlyphNameFunc free_glyph_name, - FT_Pointer glyph_data ); - - typedef FT_UInt - (*PS_Unicodes_CharIndexFunc)( PS_Unicodes unicodes, - FT_UInt32 unicode ); - - typedef FT_UInt32 - (*PS_Unicodes_CharNextFunc)( PS_Unicodes unicodes, - FT_UInt32 *unicode ); - - - FT_DEFINE_SERVICE( PsCMaps ) - { - PS_Unicode_ValueFunc unicode_value; - - PS_Unicodes_InitFunc unicodes_init; - PS_Unicodes_CharIndexFunc unicodes_char_index; - PS_Unicodes_CharNextFunc unicodes_char_next; - - PS_Macintosh_NameFunc macintosh_name; - PS_Adobe_Std_StringsFunc adobe_std_strings; - const unsigned short* adobe_std_encoding; - const unsigned short* adobe_expert_encoding; - }; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_PSCMAPSREC( class_, \ - unicode_value_, \ - unicodes_init_, \ - unicodes_char_index_, \ - unicodes_char_next_, \ - macintosh_name_, \ - adobe_std_strings_, \ - adobe_std_encoding_, \ - adobe_expert_encoding_ ) \ - static const FT_Service_PsCMapsRec class_ = \ - { \ - unicode_value_, unicodes_init_, \ - unicodes_char_index_, unicodes_char_next_, macintosh_name_, \ - adobe_std_strings_, adobe_std_encoding_, adobe_expert_encoding_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_PSCMAPSREC( class_, \ - unicode_value_, \ - unicodes_init_, \ - unicodes_char_index_, \ - unicodes_char_next_, \ - macintosh_name_, \ - adobe_std_strings_, \ - adobe_std_encoding_, \ - adobe_expert_encoding_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_PsCMapsRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->unicode_value = unicode_value_; \ - clazz->unicodes_init = unicodes_init_; \ - clazz->unicodes_char_index = unicodes_char_index_; \ - clazz->unicodes_char_next = unicodes_char_next_; \ - clazz->macintosh_name = macintosh_name_; \ - clazz->adobe_std_strings = adobe_std_strings_; \ - clazz->adobe_std_encoding = adobe_std_encoding_; \ - clazz->adobe_expert_encoding = adobe_expert_encoding_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - - -FT_END_HEADER - - -#endif /* __SVPSCMAP_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svpsinfo.h b/thirdparty/include/freetype/internal/services/svpsinfo.h deleted file mode 100644 index 4bfb50671..000000000 --- a/thirdparty/include/freetype/internal/services/svpsinfo.h +++ /dev/null @@ -1,111 +0,0 @@ -/***************************************************************************/ -/* */ -/* svpsinfo.h */ -/* */ -/* The FreeType PostScript info service (specification). */ -/* */ -/* Copyright 2003, 2004, 2009, 2011, 2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVPSINFO_H__ -#define __SVPSINFO_H__ - -#include FT_INTERNAL_SERVICE_H -#include FT_INTERNAL_TYPE1_TYPES_H - - -FT_BEGIN_HEADER - - -#define FT_SERVICE_ID_POSTSCRIPT_INFO "postscript-info" - - - typedef FT_Error - (*PS_GetFontInfoFunc)( FT_Face face, - PS_FontInfoRec* afont_info ); - - typedef FT_Error - (*PS_GetFontExtraFunc)( FT_Face face, - PS_FontExtraRec* afont_extra ); - - typedef FT_Int - (*PS_HasGlyphNamesFunc)( FT_Face face ); - - typedef FT_Error - (*PS_GetFontPrivateFunc)( FT_Face face, - PS_PrivateRec* afont_private ); - - typedef FT_Long - (*PS_GetFontValueFunc)( FT_Face face, - PS_Dict_Keys key, - FT_UInt idx, - void *value, - FT_Long value_len ); - - - FT_DEFINE_SERVICE( PsInfo ) - { - PS_GetFontInfoFunc ps_get_font_info; - PS_GetFontExtraFunc ps_get_font_extra; - PS_HasGlyphNamesFunc ps_has_glyph_names; - PS_GetFontPrivateFunc ps_get_font_private; - PS_GetFontValueFunc ps_get_font_value; - }; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_PSINFOREC( class_, \ - get_font_info_, \ - ps_get_font_extra_, \ - has_glyph_names_, \ - get_font_private_, \ - get_font_value_ ) \ - static const FT_Service_PsInfoRec class_ = \ - { \ - get_font_info_, ps_get_font_extra_, has_glyph_names_, \ - get_font_private_, get_font_value_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_PSINFOREC( class_, \ - get_font_info_, \ - ps_get_font_extra_, \ - has_glyph_names_, \ - get_font_private_, \ - get_font_value_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_PsInfoRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->ps_get_font_info = get_font_info_; \ - clazz->ps_get_font_extra = ps_get_font_extra_; \ - clazz->ps_has_glyph_names = has_glyph_names_; \ - clazz->ps_get_font_private = get_font_private_; \ - clazz->ps_get_font_value = get_font_value_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - - -FT_END_HEADER - - -#endif /* __SVPSINFO_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svsfnt.h b/thirdparty/include/freetype/internal/services/svsfnt.h deleted file mode 100644 index d3835aa1c..000000000 --- a/thirdparty/include/freetype/internal/services/svsfnt.h +++ /dev/null @@ -1,103 +0,0 @@ -/***************************************************************************/ -/* */ -/* svsfnt.h */ -/* */ -/* The FreeType SFNT table loading service (specification). */ -/* */ -/* Copyright 2003, 2004, 2009, 2012 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVSFNT_H__ -#define __SVSFNT_H__ - -#include FT_INTERNAL_SERVICE_H -#include FT_TRUETYPE_TABLES_H - - -FT_BEGIN_HEADER - - - /* - * SFNT table loading service. - */ - -#define FT_SERVICE_ID_SFNT_TABLE "sfnt-table" - - - /* - * Used to implement FT_Load_Sfnt_Table(). - */ - typedef FT_Error - (*FT_SFNT_TableLoadFunc)( FT_Face face, - FT_ULong tag, - FT_Long offset, - FT_Byte* buffer, - FT_ULong* length ); - - /* - * Used to implement FT_Get_Sfnt_Table(). - */ - typedef void* - (*FT_SFNT_TableGetFunc)( FT_Face face, - FT_Sfnt_Tag tag ); - - - /* - * Used to implement FT_Sfnt_Table_Info(). - */ - typedef FT_Error - (*FT_SFNT_TableInfoFunc)( FT_Face face, - FT_UInt idx, - FT_ULong *tag, - FT_ULong *offset, - FT_ULong *length ); - - - FT_DEFINE_SERVICE( SFNT_Table ) - { - FT_SFNT_TableLoadFunc load_table; - FT_SFNT_TableGetFunc get_table; - FT_SFNT_TableInfoFunc table_info; - }; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \ - static const FT_Service_SFNT_TableRec class_ = \ - { \ - load_, get_, info_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_SFNT_TableRec* clazz ) \ - { \ - clazz->load_table = load_; \ - clazz->get_table = get_; \ - clazz->table_info = info_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - - -FT_END_HEADER - - -#endif /* __SVSFNT_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svttcmap.h b/thirdparty/include/freetype/internal/services/svttcmap.h deleted file mode 100644 index 4370f4c2d..000000000 --- a/thirdparty/include/freetype/internal/services/svttcmap.h +++ /dev/null @@ -1,107 +0,0 @@ -/***************************************************************************/ -/* */ -/* svttcmap.h */ -/* */ -/* The FreeType TrueType/sfnt cmap extra information service. */ -/* */ -/* Copyright 2003 by */ -/* Masatake YAMATO, Redhat K.K. */ -/* */ -/* Copyright 2003, 2008, 2009, 2012, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/* Development of this service is support of - Information-technology Promotion Agency, Japan. */ - -#ifndef __SVTTCMAP_H__ -#define __SVTTCMAP_H__ - -#include FT_INTERNAL_SERVICE_H -#include FT_TRUETYPE_TABLES_H - - -FT_BEGIN_HEADER - - -#define FT_SERVICE_ID_TT_CMAP "tt-cmaps" - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_CMapInfo */ - /* */ - /* <Description> */ - /* A structure used to store TrueType/sfnt specific cmap information */ - /* which is not covered by the generic @FT_CharMap structure. This */ - /* structure can be accessed with the @FT_Get_TT_CMap_Info function. */ - /* */ - /* <Fields> */ - /* language :: */ - /* The language ID used in Mac fonts. Definitions of values are in */ - /* `ttnameid.h'. */ - /* */ - /* format :: */ - /* The cmap format. OpenType 1.5 defines the formats 0 (byte */ - /* encoding table), 2~(high-byte mapping through table), 4~(segment */ - /* mapping to delta values), 6~(trimmed table mapping), 8~(mixed */ - /* 16-bit and 32-bit coverage), 10~(trimmed array), 12~(segmented */ - /* coverage), and 14 (Unicode Variation Sequences). */ - /* */ - typedef struct TT_CMapInfo_ - { - FT_ULong language; - FT_Long format; - - } TT_CMapInfo; - - - typedef FT_Error - (*TT_CMap_Info_GetFunc)( FT_CharMap charmap, - TT_CMapInfo *cmap_info ); - - - FT_DEFINE_SERVICE( TTCMaps ) - { - TT_CMap_Info_GetFunc get_cmap_info; - }; - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_TTCMAPSREC( class_, get_cmap_info_ ) \ - static const FT_Service_TTCMapsRec class_ = \ - { \ - get_cmap_info_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_TTCMAPSREC( class_, get_cmap_info_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - FT_Service_TTCMapsRec* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->get_cmap_info = get_cmap_info_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - - -FT_END_HEADER - -#endif /* __SVTTCMAP_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svtteng.h b/thirdparty/include/freetype/internal/services/svtteng.h deleted file mode 100644 index 58e02a6f9..000000000 --- a/thirdparty/include/freetype/internal/services/svtteng.h +++ /dev/null @@ -1,53 +0,0 @@ -/***************************************************************************/ -/* */ -/* svtteng.h */ -/* */ -/* The FreeType TrueType engine query service (specification). */ -/* */ -/* Copyright 2006 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVTTENG_H__ -#define __SVTTENG_H__ - -#include FT_INTERNAL_SERVICE_H -#include FT_MODULE_H - - -FT_BEGIN_HEADER - - - /* - * SFNT table loading service. - */ - -#define FT_SERVICE_ID_TRUETYPE_ENGINE "truetype-engine" - - /* - * Used to implement FT_Get_TrueType_Engine_Type - */ - - FT_DEFINE_SERVICE( TrueTypeEngine ) - { - FT_TrueTypeEngineType engine_type; - }; - - /* */ - - -FT_END_HEADER - - -#endif /* __SVTTENG_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svttglyf.h b/thirdparty/include/freetype/internal/services/svttglyf.h deleted file mode 100644 index 369eb8421..000000000 --- a/thirdparty/include/freetype/internal/services/svttglyf.h +++ /dev/null @@ -1,68 +0,0 @@ -/***************************************************************************/ -/* */ -/* svttglyf.h */ -/* */ -/* The FreeType TrueType glyph service. */ -/* */ -/* Copyright 2007, 2009, 2012 by David Turner. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -#ifndef __SVTTGLYF_H__ -#define __SVTTGLYF_H__ - -#include FT_INTERNAL_SERVICE_H -#include FT_TRUETYPE_TABLES_H - - -FT_BEGIN_HEADER - - -#define FT_SERVICE_ID_TT_GLYF "tt-glyf" - - - typedef FT_ULong - (*TT_Glyf_GetLocationFunc)( FT_Face face, - FT_UInt gindex, - FT_ULong *psize ); - - FT_DEFINE_SERVICE( TTGlyf ) - { - TT_Glyf_GetLocationFunc get_location; - }; - - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \ - static const FT_Service_TTGlyfRec class_ = \ - { \ - get_location_ \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Service_TTGlyfRec* clazz ) \ - { \ - clazz->get_location = get_location_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - - /* */ - - -FT_END_HEADER - -#endif /* __SVTTGLYF_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svwinfnt.h b/thirdparty/include/freetype/internal/services/svwinfnt.h deleted file mode 100644 index 57f7765d9..000000000 --- a/thirdparty/include/freetype/internal/services/svwinfnt.h +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************/ -/* */ -/* svwinfnt.h */ -/* */ -/* The FreeType Windows FNT/FONT service (specification). */ -/* */ -/* Copyright 2003 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVWINFNT_H__ -#define __SVWINFNT_H__ - -#include FT_INTERNAL_SERVICE_H -#include FT_WINFONTS_H - - -FT_BEGIN_HEADER - - -#define FT_SERVICE_ID_WINFNT "winfonts" - - typedef FT_Error - (*FT_WinFnt_GetHeaderFunc)( FT_Face face, - FT_WinFNT_HeaderRec *aheader ); - - - FT_DEFINE_SERVICE( WinFnt ) - { - FT_WinFnt_GetHeaderFunc get_header; - }; - - /* */ - - -FT_END_HEADER - - -#endif /* __SVWINFNT_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/services/svxf86nm.h b/thirdparty/include/freetype/internal/services/svxf86nm.h deleted file mode 100644 index ca5d884a8..000000000 --- a/thirdparty/include/freetype/internal/services/svxf86nm.h +++ /dev/null @@ -1,55 +0,0 @@ -/***************************************************************************/ -/* */ -/* svxf86nm.h */ -/* */ -/* The FreeType XFree86 services (specification only). */ -/* */ -/* Copyright 2003 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SVXF86NM_H__ -#define __SVXF86NM_H__ - -#include FT_INTERNAL_SERVICE_H - - -FT_BEGIN_HEADER - - - /* - * A trivial service used to return the name of a face's font driver, - * according to the XFree86 nomenclature. Note that the service data - * is a simple constant string pointer. - */ - -#define FT_SERVICE_ID_XF86_NAME "xf86-driver-name" - -#define FT_XF86_FORMAT_TRUETYPE "TrueType" -#define FT_XF86_FORMAT_TYPE_1 "Type 1" -#define FT_XF86_FORMAT_BDF "BDF" -#define FT_XF86_FORMAT_PCF "PCF" -#define FT_XF86_FORMAT_TYPE_42 "Type 42" -#define FT_XF86_FORMAT_CID "CID Type 1" -#define FT_XF86_FORMAT_CFF "CFF" -#define FT_XF86_FORMAT_PFR "PFR" -#define FT_XF86_FORMAT_WINFNT "Windows FNT" - - /* */ - - -FT_END_HEADER - - -#endif /* __SVXF86NM_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/sfnt.h b/thirdparty/include/freetype/internal/sfnt.h deleted file mode 100644 index b9ba503d6..000000000 --- a/thirdparty/include/freetype/internal/sfnt.h +++ /dev/null @@ -1,707 +0,0 @@ -/***************************************************************************/ -/* */ -/* sfnt.h */ -/* */ -/* High-level `sfnt' driver interface (specification). */ -/* */ -/* Copyright 1996-2006, 2009, 2012-2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __SFNT_H__ -#define __SFNT_H__ - - -#include <freetype/ft2build.h> -#include FT_INTERNAL_DRIVER_H -#include FT_INTERNAL_TRUETYPE_TYPES_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Init_Face_Func */ - /* */ - /* <Description> */ - /* First part of the SFNT face object initialization. This finds */ - /* the face in a SFNT file or collection, and load its format tag in */ - /* face->format_tag. */ - /* */ - /* <Input> */ - /* stream :: The input stream. */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* face_index :: The index of the TrueType font, if we are opening a */ - /* collection. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* params :: Optional additional parameters. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The stream cursor must be at the font file's origin. */ - /* */ - /* This function recognizes fonts embedded in a `TrueType */ - /* collection'. */ - /* */ - /* Once the format tag has been validated by the font driver, it */ - /* should then call the TT_Load_Face_Func() callback to read the rest */ - /* of the SFNT tables in the object. */ - /* */ - typedef FT_Error - (*TT_Init_Face_Func)( FT_Stream stream, - TT_Face face, - FT_Int face_index, - FT_Int num_params, - FT_Parameter* params ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Face_Func */ - /* */ - /* <Description> */ - /* Second part of the SFNT face object initialization. This loads */ - /* the common SFNT tables (head, OS/2, maxp, metrics, etc.) in the */ - /* face object. */ - /* */ - /* <Input> */ - /* stream :: The input stream. */ - /* */ - /* face :: A handle to the target face object. */ - /* */ - /* face_index :: The index of the TrueType font, if we are opening a */ - /* collection. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* params :: Optional additional parameters. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function must be called after TT_Init_Face_Func(). */ - /* */ - typedef FT_Error - (*TT_Load_Face_Func)( FT_Stream stream, - TT_Face face, - FT_Int face_index, - FT_Int num_params, - FT_Parameter* params ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Done_Face_Func */ - /* */ - /* <Description> */ - /* A callback used to delete the common SFNT data from a face. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Note> */ - /* This function does NOT destroy the face object. */ - /* */ - typedef void - (*TT_Done_Face_Func)( TT_Face face ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Any_Func */ - /* */ - /* <Description> */ - /* Load any font table into client memory. */ - /* */ - /* <Input> */ - /* face :: The face object to look for. */ - /* */ - /* tag :: The tag of table to load. Use the value 0 if you want */ - /* to access the whole font file, else set this parameter */ - /* to a valid TrueType table tag that you can forge with */ - /* the MAKE_TT_TAG macro. */ - /* */ - /* offset :: The starting offset in the table (or the file if */ - /* tag == 0). */ - /* */ - /* length :: The address of the decision variable: */ - /* */ - /* If length == NULL: */ - /* Loads the whole table. Returns an error if */ - /* `offset' == 0! */ - /* */ - /* If *length == 0: */ - /* Exits immediately; returning the length of the given */ - /* table or of the font file, depending on the value of */ - /* `tag'. */ - /* */ - /* If *length != 0: */ - /* Loads the next `length' bytes of table or font, */ - /* starting at offset `offset' (in table or font too). */ - /* */ - /* <Output> */ - /* buffer :: The address of target buffer. */ - /* */ - /* <Return> */ - /* TrueType error code. 0 means success. */ - /* */ - typedef FT_Error - (*TT_Load_Any_Func)( TT_Face face, - FT_ULong tag, - FT_Long offset, - FT_Byte *buffer, - FT_ULong* length ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Find_SBit_Image_Func */ - /* */ - /* <Description> */ - /* Check whether an embedded bitmap (an `sbit') exists for a given */ - /* glyph, at a given strike. */ - /* */ - /* <Input> */ - /* face :: The target face object. */ - /* */ - /* glyph_index :: The glyph index. */ - /* */ - /* strike_index :: The current strike index. */ - /* */ - /* <Output> */ - /* arange :: The SBit range containing the glyph index. */ - /* */ - /* astrike :: The SBit strike containing the glyph index. */ - /* */ - /* aglyph_offset :: The offset of the glyph data in `EBDT' table. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. Returns */ - /* SFNT_Err_Invalid_Argument if no sbit exists for the requested */ - /* glyph. */ - /* */ - typedef FT_Error - (*TT_Find_SBit_Image_Func)( TT_Face face, - FT_UInt glyph_index, - FT_ULong strike_index, - TT_SBit_Range *arange, - TT_SBit_Strike *astrike, - FT_ULong *aglyph_offset ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_SBit_Metrics_Func */ - /* */ - /* <Description> */ - /* Get the big metrics for a given embedded bitmap. */ - /* */ - /* <Input> */ - /* stream :: The input stream. */ - /* */ - /* range :: The SBit range containing the glyph. */ - /* */ - /* <Output> */ - /* big_metrics :: A big SBit metrics structure for the glyph. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The stream cursor must be positioned at the glyph's offset within */ - /* the `EBDT' table before the call. */ - /* */ - /* If the image format uses variable metrics, the stream cursor is */ - /* positioned just after the metrics header in the `EBDT' table on */ - /* function exit. */ - /* */ - typedef FT_Error - (*TT_Load_SBit_Metrics_Func)( FT_Stream stream, - TT_SBit_Range range, - TT_SBit_Metrics metrics ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_SBit_Image_Func */ - /* */ - /* <Description> */ - /* Load a given glyph sbit image from the font resource. This also */ - /* returns its metrics. */ - /* */ - /* <Input> */ - /* face :: */ - /* The target face object. */ - /* */ - /* strike_index :: */ - /* The strike index. */ - /* */ - /* glyph_index :: */ - /* The current glyph index. */ - /* */ - /* load_flags :: */ - /* The current load flags. */ - /* */ - /* stream :: */ - /* The input stream. */ - /* */ - /* <Output> */ - /* amap :: */ - /* The target pixmap. */ - /* */ - /* ametrics :: */ - /* A big sbit metrics structure for the glyph image. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. Returns an error if no */ - /* glyph sbit exists for the index. */ - /* */ - /* <Note> */ - /* The `map.buffer' field is always freed before the glyph is loaded. */ - /* */ - typedef FT_Error - (*TT_Load_SBit_Image_Func)( TT_Face face, - FT_ULong strike_index, - FT_UInt glyph_index, - FT_UInt load_flags, - FT_Stream stream, - FT_Bitmap *amap, - TT_SBit_MetricsRec *ametrics ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Set_SBit_Strike_Func */ - /* */ - /* <Description> */ - /* Select an sbit strike for a given size request. */ - /* */ - /* <Input> */ - /* face :: The target face object. */ - /* */ - /* req :: The size request. */ - /* */ - /* <Output> */ - /* astrike_index :: The index of the sbit strike. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. Returns an error if no */ - /* sbit strike exists for the selected ppem values. */ - /* */ - typedef FT_Error - (*TT_Set_SBit_Strike_Func)( TT_Face face, - FT_Size_Request req, - FT_ULong* astrike_index ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Strike_Metrics_Func */ - /* */ - /* <Description> */ - /* Load the metrics of a given strike. */ - /* */ - /* <Input> */ - /* face :: The target face object. */ - /* */ - /* strike_index :: The strike index. */ - /* */ - /* <Output> */ - /* metrics :: the metrics of the strike. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. Returns an error if no */ - /* such sbit strike exists. */ - /* */ - typedef FT_Error - (*TT_Load_Strike_Metrics_Func)( TT_Face face, - FT_ULong strike_index, - FT_Size_Metrics* metrics ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Get_PS_Name_Func */ - /* */ - /* <Description> */ - /* Get the PostScript glyph name of a glyph. */ - /* */ - /* <Input> */ - /* idx :: The glyph index. */ - /* */ - /* PSname :: The address of a string pointer. Will be NULL in case */ - /* of error, otherwise it is a pointer to the glyph name. */ - /* */ - /* You must not modify the returned string! */ - /* */ - /* <Output> */ - /* FreeType error code. 0 means success. */ - /* */ - typedef FT_Error - (*TT_Get_PS_Name_Func)( TT_Face face, - FT_UInt idx, - FT_String** PSname ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Metrics_Func */ - /* */ - /* <Description> */ - /* Load a metrics table, which is a table with a horizontal and a */ - /* vertical version. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* vertical :: A boolean flag. If set, load the vertical one. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - typedef FT_Error - (*TT_Load_Metrics_Func)( TT_Face face, - FT_Stream stream, - FT_Bool vertical ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Get_Metrics_Func */ - /* */ - /* <Description> */ - /* Load the horizontal or vertical header in a face object. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* vertical :: A boolean flag. If set, load vertical metrics. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - typedef FT_Error - (*TT_Get_Metrics_Func)( TT_Face face, - FT_Bool vertical, - FT_UInt gindex, - FT_Short* abearing, - FT_UShort* aadvance ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Load_Table_Func */ - /* */ - /* <Description> */ - /* Load a given TrueType table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The function uses `face->goto_table' to seek the stream to the */ - /* start of the table, except while loading the font directory. */ - /* */ - typedef FT_Error - (*TT_Load_Table_Func)( TT_Face face, - FT_Stream stream ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Free_Table_Func */ - /* */ - /* <Description> */ - /* Free a given TrueType table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - typedef void - (*TT_Free_Table_Func)( TT_Face face ); - - - /* - * @functype: - * TT_Face_GetKerningFunc - * - * @description: - * Return the horizontal kerning value between two glyphs. - * - * @input: - * face :: A handle to the source face object. - * left_glyph :: The left glyph index. - * right_glyph :: The right glyph index. - * - * @return: - * The kerning value in font units. - */ - typedef FT_Int - (*TT_Face_GetKerningFunc)( TT_Face face, - FT_UInt left_glyph, - FT_UInt right_glyph ); - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* SFNT_Interface */ - /* */ - /* <Description> */ - /* This structure holds pointers to the functions used to load and */ - /* free the basic tables that are required in a `sfnt' font file. */ - /* */ - /* <Fields> */ - /* Check the various xxx_Func() descriptions for details. */ - /* */ - typedef struct SFNT_Interface_ - { - TT_Loader_GotoTableFunc goto_table; - - TT_Init_Face_Func init_face; - TT_Load_Face_Func load_face; - TT_Done_Face_Func done_face; - FT_Module_Requester get_interface; - - TT_Load_Any_Func load_any; - - /* these functions are called by `load_face' but they can also */ - /* be called from external modules, if there is a need to do so */ - TT_Load_Table_Func load_head; - TT_Load_Metrics_Func load_hhea; - TT_Load_Table_Func load_cmap; - TT_Load_Table_Func load_maxp; - TT_Load_Table_Func load_os2; - TT_Load_Table_Func load_post; - - TT_Load_Table_Func load_name; - TT_Free_Table_Func free_name; - - /* this field was called `load_kerning' up to version 2.1.10 */ - TT_Load_Table_Func load_kern; - - TT_Load_Table_Func load_gasp; - TT_Load_Table_Func load_pclt; - - /* see `ttload.h'; this field was called `load_bitmap_header' up to */ - /* version 2.1.10 */ - TT_Load_Table_Func load_bhed; - - TT_Load_SBit_Image_Func load_sbit_image; - - /* see `ttpost.h' */ - TT_Get_PS_Name_Func get_psname; - TT_Free_Table_Func free_psnames; - - /* starting here, the structure differs from version 2.1.7 */ - - /* this field was introduced in version 2.1.8, named `get_psname' */ - TT_Face_GetKerningFunc get_kerning; - - /* new elements introduced after version 2.1.10 */ - - /* load the font directory, i.e., the offset table and */ - /* the table directory */ - TT_Load_Table_Func load_font_dir; - TT_Load_Metrics_Func load_hmtx; - - TT_Load_Table_Func load_eblc; - TT_Free_Table_Func free_eblc; - - TT_Set_SBit_Strike_Func set_sbit_strike; - TT_Load_Strike_Metrics_Func load_strike_metrics; - - TT_Get_Metrics_Func get_metrics; - - } SFNT_Interface; - - - /* transitional */ - typedef SFNT_Interface* SFNT_Service; - -#ifndef FT_CONFIG_OPTION_PIC - -#define FT_DEFINE_SFNT_INTERFACE( \ - class_, \ - goto_table_, \ - init_face_, \ - load_face_, \ - done_face_, \ - get_interface_, \ - load_any_, \ - load_head_, \ - load_hhea_, \ - load_cmap_, \ - load_maxp_, \ - load_os2_, \ - load_post_, \ - load_name_, \ - free_name_, \ - load_kern_, \ - load_gasp_, \ - load_pclt_, \ - load_bhed_, \ - load_sbit_image_, \ - get_psname_, \ - free_psnames_, \ - get_kerning_, \ - load_font_dir_, \ - load_hmtx_, \ - load_eblc_, \ - free_eblc_, \ - set_sbit_strike_, \ - load_strike_metrics_, \ - get_metrics_ ) \ - static const SFNT_Interface class_ = \ - { \ - goto_table_, \ - init_face_, \ - load_face_, \ - done_face_, \ - get_interface_, \ - load_any_, \ - load_head_, \ - load_hhea_, \ - load_cmap_, \ - load_maxp_, \ - load_os2_, \ - load_post_, \ - load_name_, \ - free_name_, \ - load_kern_, \ - load_gasp_, \ - load_pclt_, \ - load_bhed_, \ - load_sbit_image_, \ - get_psname_, \ - free_psnames_, \ - get_kerning_, \ - load_font_dir_, \ - load_hmtx_, \ - load_eblc_, \ - free_eblc_, \ - set_sbit_strike_, \ - load_strike_metrics_, \ - get_metrics_, \ - }; - -#else /* FT_CONFIG_OPTION_PIC */ - -#define FT_INTERNAL( a, a_ ) \ - clazz->a = a_; - -#define FT_DEFINE_SFNT_INTERFACE( \ - class_, \ - goto_table_, \ - init_face_, \ - load_face_, \ - done_face_, \ - get_interface_, \ - load_any_, \ - load_head_, \ - load_hhea_, \ - load_cmap_, \ - load_maxp_, \ - load_os2_, \ - load_post_, \ - load_name_, \ - free_name_, \ - load_kern_, \ - load_gasp_, \ - load_pclt_, \ - load_bhed_, \ - load_sbit_image_, \ - get_psname_, \ - free_psnames_, \ - get_kerning_, \ - load_font_dir_, \ - load_hmtx_, \ - load_eblc_, \ - free_eblc_, \ - set_sbit_strike_, \ - load_strike_metrics_, \ - get_metrics_ ) \ - void \ - FT_Init_Class_ ## class_( FT_Library library, \ - SFNT_Interface* clazz ) \ - { \ - FT_UNUSED( library ); \ - \ - clazz->goto_table = goto_table_; \ - clazz->init_face = init_face_; \ - clazz->load_face = load_face_; \ - clazz->done_face = done_face_; \ - clazz->get_interface = get_interface_; \ - clazz->load_any = load_any_; \ - clazz->load_head = load_head_; \ - clazz->load_hhea = load_hhea_; \ - clazz->load_cmap = load_cmap_; \ - clazz->load_maxp = load_maxp_; \ - clazz->load_os2 = load_os2_; \ - clazz->load_post = load_post_; \ - clazz->load_name = load_name_; \ - clazz->free_name = free_name_; \ - clazz->load_kern = load_kern_; \ - clazz->load_gasp = load_gasp_; \ - clazz->load_pclt = load_pclt_; \ - clazz->load_bhed = load_bhed_; \ - clazz->load_sbit_image = load_sbit_image_; \ - clazz->get_psname = get_psname_; \ - clazz->free_psnames = free_psnames_; \ - clazz->get_kerning = get_kerning_; \ - clazz->load_font_dir = load_font_dir_; \ - clazz->load_hmtx = load_hmtx_; \ - clazz->load_eblc = load_eblc_; \ - clazz->free_eblc = free_eblc_; \ - clazz->set_sbit_strike = set_sbit_strike_; \ - clazz->load_strike_metrics = load_strike_metrics_; \ - clazz->get_metrics = get_metrics_; \ - } - -#endif /* FT_CONFIG_OPTION_PIC */ - -FT_END_HEADER - -#endif /* __SFNT_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/t1types.h b/thirdparty/include/freetype/internal/t1types.h deleted file mode 100644 index b5fe435e5..000000000 --- a/thirdparty/include/freetype/internal/t1types.h +++ /dev/null @@ -1,255 +0,0 @@ -/***************************************************************************/ -/* */ -/* t1types.h */ -/* */ -/* Basic Type1/Type2 type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2004, 2006, 2008, 2009, 2011, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __T1TYPES_H__ -#define __T1TYPES_H__ - - -#include <freetype/ft2build.h> -#include FT_TYPE1_TABLES_H -#include FT_INTERNAL_POSTSCRIPT_HINTS_H -#include FT_INTERNAL_SERVICE_H -#include FT_SERVICE_POSTSCRIPT_CMAPS_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** REQUIRED TYPE1/TYPE2 TABLES DEFINITIONS ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_EncodingRec */ - /* */ - /* <Description> */ - /* A structure modeling a custom encoding. */ - /* */ - /* <Fields> */ - /* num_chars :: The number of character codes in the encoding. */ - /* Usually 256. */ - /* */ - /* code_first :: The lowest valid character code in the encoding. */ - /* */ - /* code_last :: The highest valid character code in the encoding */ - /* + 1. When equal to code_first there are no valid */ - /* character codes. */ - /* */ - /* char_index :: An array of corresponding glyph indices. */ - /* */ - /* char_name :: An array of corresponding glyph names. */ - /* */ - typedef struct T1_EncodingRecRec_ - { - FT_Int num_chars; - FT_Int code_first; - FT_Int code_last; - - FT_UShort* char_index; - FT_String** char_name; - - } T1_EncodingRec, *T1_Encoding; - - - /* used to hold extra data of PS_FontInfoRec that - * cannot be stored in the publicly defined structure. - * - * Note these can't be blended with multiple-masters. - */ - typedef struct PS_FontExtraRec_ - { - FT_UShort fs_type; - - } PS_FontExtraRec; - - - typedef struct T1_FontRec_ - { - PS_FontInfoRec font_info; /* font info dictionary */ - PS_FontExtraRec font_extra; /* font info extra fields */ - PS_PrivateRec private_dict; /* private dictionary */ - FT_String* font_name; /* top-level dictionary */ - - T1_EncodingType encoding_type; - T1_EncodingRec encoding; - - FT_Byte* subrs_block; - FT_Byte* charstrings_block; - FT_Byte* glyph_names_block; - - FT_Int num_subrs; - FT_Byte** subrs; - FT_PtrDist* subrs_len; - - FT_Int num_glyphs; - FT_String** glyph_names; /* array of glyph names */ - FT_Byte** charstrings; /* array of glyph charstrings */ - FT_PtrDist* charstrings_len; - - FT_Byte paint_type; - FT_Byte font_type; - FT_Matrix font_matrix; - FT_Vector font_offset; - FT_BBox font_bbox; - FT_Long font_id; - - FT_Fixed stroke_width; - - } T1_FontRec, *T1_Font; - - - typedef struct CID_SubrsRec_ - { - FT_UInt num_subrs; - FT_Byte** code; - - } CID_SubrsRec, *CID_Subrs; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** AFM FONT INFORMATION STRUCTURES ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - typedef struct AFM_TrackKernRec_ - { - FT_Int degree; - FT_Fixed min_ptsize; - FT_Fixed min_kern; - FT_Fixed max_ptsize; - FT_Fixed max_kern; - - } AFM_TrackKernRec, *AFM_TrackKern; - - typedef struct AFM_KernPairRec_ - { - FT_Int index1; - FT_Int index2; - FT_Int x; - FT_Int y; - - } AFM_KernPairRec, *AFM_KernPair; - - typedef struct AFM_FontInfoRec_ - { - FT_Bool IsCIDFont; - FT_BBox FontBBox; - FT_Fixed Ascender; - FT_Fixed Descender; - AFM_TrackKern TrackKerns; /* free if non-NULL */ - FT_Int NumTrackKern; - AFM_KernPair KernPairs; /* free if non-NULL */ - FT_Int NumKernPair; - - } AFM_FontInfoRec, *AFM_FontInfo; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** ORIGINAL T1_FACE CLASS DEFINITION ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - typedef struct T1_FaceRec_* T1_Face; - typedef struct CID_FaceRec_* CID_Face; - - - typedef struct T1_FaceRec_ - { - FT_FaceRec root; - T1_FontRec type1; - const void* psnames; - const void* psaux; - const void* afm_data; - FT_CharMapRec charmaprecs[2]; - FT_CharMap charmaps[2]; - - /* support for Multiple Masters fonts */ - PS_Blend blend; - - /* undocumented, optional: indices of subroutines that express */ - /* the NormalizeDesignVector and the ConvertDesignVector procedure, */ - /* respectively, as Type 2 charstrings; -1 if keywords not present */ - FT_Int ndv_idx; - FT_Int cdv_idx; - - /* undocumented, optional: has the same meaning as len_buildchar */ - /* for Type 2 fonts; manipulated by othersubrs 19, 24, and 25 */ - FT_UInt len_buildchar; - FT_Long* buildchar; - - /* since version 2.1 - interface to PostScript hinter */ - const void* pshinter; - - } T1_FaceRec; - - - typedef struct CID_FaceRec_ - { - FT_FaceRec root; - void* psnames; - void* psaux; - CID_FaceInfoRec cid; - PS_FontExtraRec font_extra; -#if 0 - void* afm_data; -#endif - CID_Subrs subrs; - - /* since version 2.1 - interface to PostScript hinter */ - void* pshinter; - - /* since version 2.1.8, but was originally positioned after `afm_data' */ - FT_Byte* binary_data; /* used if hex data has been converted */ - FT_Stream cid_stream; - - } CID_FaceRec; - - -FT_END_HEADER - -#endif /* __T1TYPES_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/internal/tttypes.h b/thirdparty/include/freetype/internal/tttypes.h deleted file mode 100644 index 876733417..000000000 --- a/thirdparty/include/freetype/internal/tttypes.h +++ /dev/null @@ -1,1516 +0,0 @@ -/***************************************************************************/ -/* */ -/* tttypes.h */ -/* */ -/* Basic SFNT/TrueType type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2002, 2004-2008, 2012-2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __TTTYPES_H__ -#define __TTTYPES_H__ - - -#include <freetype/ft2build.h> -#include FT_TRUETYPE_TABLES_H -#include FT_INTERNAL_OBJECTS_H - -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT -#include FT_MULTIPLE_MASTERS_H -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** REQUIRED TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TTC_HeaderRec */ - /* */ - /* <Description> */ - /* TrueType collection header. This table contains the offsets of */ - /* the font headers of each distinct TrueType face in the file. */ - /* */ - /* <Fields> */ - /* tag :: Must be `ttc ' to indicate a TrueType collection. */ - /* */ - /* version :: The version number. */ - /* */ - /* count :: The number of faces in the collection. The */ - /* specification says this should be an unsigned long, but */ - /* we use a signed long since we need the value -1 for */ - /* specific purposes. */ - /* */ - /* offsets :: The offsets of the font headers, one per face. */ - /* */ - typedef struct TTC_HeaderRec_ - { - FT_ULong tag; - FT_Fixed version; - FT_Long count; - FT_ULong* offsets; - - } TTC_HeaderRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* SFNT_HeaderRec */ - /* */ - /* <Description> */ - /* SFNT file format header. */ - /* */ - /* <Fields> */ - /* format_tag :: The font format tag. */ - /* */ - /* num_tables :: The number of tables in file. */ - /* */ - /* search_range :: Must be `16 * (max power of 2 <= num_tables)'. */ - /* */ - /* entry_selector :: Must be log2 of `search_range / 16'. */ - /* */ - /* range_shift :: Must be `num_tables * 16 - search_range'. */ - /* */ - typedef struct SFNT_HeaderRec_ - { - FT_ULong format_tag; - FT_UShort num_tables; - FT_UShort search_range; - FT_UShort entry_selector; - FT_UShort range_shift; - - FT_ULong offset; /* not in file */ - - } SFNT_HeaderRec, *SFNT_Header; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_TableRec */ - /* */ - /* <Description> */ - /* This structure describes a given table of a TrueType font. */ - /* */ - /* <Fields> */ - /* Tag :: A four-bytes tag describing the table. */ - /* */ - /* CheckSum :: The table checksum. This value can be ignored. */ - /* */ - /* Offset :: The offset of the table from the start of the TrueType */ - /* font in its resource. */ - /* */ - /* Length :: The table length (in bytes). */ - /* */ - typedef struct TT_TableRec_ - { - FT_ULong Tag; /* table type */ - FT_ULong CheckSum; /* table checksum */ - FT_ULong Offset; /* table file offset */ - FT_ULong Length; /* table length */ - - } TT_TableRec, *TT_Table; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* WOFF_HeaderRec */ - /* */ - /* <Description> */ - /* WOFF file format header. */ - /* */ - /* <Fields> */ - /* See */ - /* */ - /* http://www.w3.org/TR/WOFF/#WOFFHeader */ - /* */ - typedef struct WOFF_HeaderRec_ - { - FT_ULong signature; - FT_ULong flavor; - FT_ULong length; - FT_UShort num_tables; - FT_UShort reserved; - FT_ULong totalSfntSize; - FT_UShort majorVersion; - FT_UShort minorVersion; - FT_ULong metaOffset; - FT_ULong metaLength; - FT_ULong metaOrigLength; - FT_ULong privOffset; - FT_ULong privLength; - - } WOFF_HeaderRec, *WOFF_Header; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* WOFF_TableRec */ - /* */ - /* <Description> */ - /* This structure describes a given table of a WOFF font. */ - /* */ - /* <Fields> */ - /* Tag :: A four-bytes tag describing the table. */ - /* */ - /* Offset :: The offset of the table from the start of the WOFF */ - /* font in its resource. */ - /* */ - /* CompLength :: Compressed table length (in bytes). */ - /* */ - /* OrigLength :: Unompressed table length (in bytes). */ - /* */ - /* CheckSum :: The table checksum. This value can be ignored. */ - /* */ - /* OrigOffset :: The uncompressed table file offset. This value gets */ - /* computed while constructing the (uncompressed) SFNT */ - /* header. It is not contained in the WOFF file. */ - /* */ - typedef struct WOFF_TableRec_ - { - FT_ULong Tag; /* table ID */ - FT_ULong Offset; /* table file offset */ - FT_ULong CompLength; /* compressed table length */ - FT_ULong OrigLength; /* uncompressed table length */ - FT_ULong CheckSum; /* uncompressed checksum */ - - FT_ULong OrigOffset; /* uncompressed table file offset */ - /* (not in the WOFF file) */ - } WOFF_TableRec, *WOFF_Table; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_LongMetricsRec */ - /* */ - /* <Description> */ - /* A structure modeling the long metrics of the `hmtx' and `vmtx' */ - /* TrueType tables. The values are expressed in font units. */ - /* */ - /* <Fields> */ - /* advance :: The advance width or height for the glyph. */ - /* */ - /* bearing :: The left-side or top-side bearing for the glyph. */ - /* */ - typedef struct TT_LongMetricsRec_ - { - FT_UShort advance; - FT_Short bearing; - - } TT_LongMetricsRec, *TT_LongMetrics; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* TT_ShortMetrics */ - /* */ - /* <Description> */ - /* A simple type to model the short metrics of the `hmtx' and `vmtx' */ - /* tables. */ - /* */ - typedef FT_Short TT_ShortMetrics; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_NameEntryRec */ - /* */ - /* <Description> */ - /* A structure modeling TrueType name records. Name records are used */ - /* to store important strings like family name, style name, */ - /* copyright, etc. in _localized_ versions (i.e., language, encoding, */ - /* etc). */ - /* */ - /* <Fields> */ - /* platformID :: The ID of the name's encoding platform. */ - /* */ - /* encodingID :: The platform-specific ID for the name's encoding. */ - /* */ - /* languageID :: The platform-specific ID for the name's language. */ - /* */ - /* nameID :: The ID specifying what kind of name this is. */ - /* */ - /* stringLength :: The length of the string in bytes. */ - /* */ - /* stringOffset :: The offset to the string in the `name' table. */ - /* */ - /* string :: A pointer to the string's bytes. Note that these */ - /* are usually UTF-16 encoded characters. */ - /* */ - typedef struct TT_NameEntryRec_ - { - FT_UShort platformID; - FT_UShort encodingID; - FT_UShort languageID; - FT_UShort nameID; - FT_UShort stringLength; - FT_ULong stringOffset; - - /* this last field is not defined in the spec */ - /* but used by the FreeType engine */ - - FT_Byte* string; - - } TT_NameEntryRec, *TT_NameEntry; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_NameTableRec */ - /* */ - /* <Description> */ - /* A structure modeling the TrueType name table. */ - /* */ - /* <Fields> */ - /* format :: The format of the name table. */ - /* */ - /* numNameRecords :: The number of names in table. */ - /* */ - /* storageOffset :: The offset of the name table in the `name' */ - /* TrueType table. */ - /* */ - /* names :: An array of name records. */ - /* */ - /* stream :: the file's input stream. */ - /* */ - typedef struct TT_NameTableRec_ - { - FT_UShort format; - FT_UInt numNameRecords; - FT_UInt storageOffset; - TT_NameEntryRec* names; - FT_Stream stream; - - } TT_NameTableRec, *TT_NameTable; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_GaspRangeRec */ - /* */ - /* <Description> */ - /* A tiny structure used to model a gasp range according to the */ - /* TrueType specification. */ - /* */ - /* <Fields> */ - /* maxPPEM :: The maximum ppem value to which `gaspFlag' applies. */ - /* */ - /* gaspFlag :: A flag describing the grid-fitting and anti-aliasing */ - /* modes to be used. */ - /* */ - typedef struct TT_GaspRangeRec_ - { - FT_UShort maxPPEM; - FT_UShort gaspFlag; - - } TT_GaspRangeRec, *TT_GaspRange; - - -#define TT_GASP_GRIDFIT 0x01 -#define TT_GASP_DOGRAY 0x02 - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_GaspRec */ - /* */ - /* <Description> */ - /* A structure modeling the TrueType `gasp' table used to specify */ - /* grid-fitting and anti-aliasing behaviour. */ - /* */ - /* <Fields> */ - /* version :: The version number. */ - /* */ - /* numRanges :: The number of gasp ranges in table. */ - /* */ - /* gaspRanges :: An array of gasp ranges. */ - /* */ - typedef struct TT_Gasp_ - { - FT_UShort version; - FT_UShort numRanges; - TT_GaspRange gaspRanges; - - } TT_GaspRec; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** EMBEDDED BITMAPS SUPPORT ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_MetricsRec */ - /* */ - /* <Description> */ - /* A structure used to hold the big metrics of a given glyph bitmap */ - /* in a TrueType or OpenType font. These are usually found in the */ - /* `EBDT' (Microsoft) or `bloc' (Apple) table. */ - /* */ - /* <Fields> */ - /* height :: The glyph height in pixels. */ - /* */ - /* width :: The glyph width in pixels. */ - /* */ - /* horiBearingX :: The horizontal left bearing. */ - /* */ - /* horiBearingY :: The horizontal top bearing. */ - /* */ - /* horiAdvance :: The horizontal advance. */ - /* */ - /* vertBearingX :: The vertical left bearing. */ - /* */ - /* vertBearingY :: The vertical top bearing. */ - /* */ - /* vertAdvance :: The vertical advance. */ - /* */ - typedef struct TT_SBit_MetricsRec_ - { - FT_UShort height; - FT_UShort width; - - FT_Short horiBearingX; - FT_Short horiBearingY; - FT_UShort horiAdvance; - - FT_Short vertBearingX; - FT_Short vertBearingY; - FT_UShort vertAdvance; - - } TT_SBit_MetricsRec, *TT_SBit_Metrics; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_SmallMetricsRec */ - /* */ - /* <Description> */ - /* A structure used to hold the small metrics of a given glyph bitmap */ - /* in a TrueType or OpenType font. These are usually found in the */ - /* `EBDT' (Microsoft) or the `bdat' (Apple) table. */ - /* */ - /* <Fields> */ - /* height :: The glyph height in pixels. */ - /* */ - /* width :: The glyph width in pixels. */ - /* */ - /* bearingX :: The left-side bearing. */ - /* */ - /* bearingY :: The top-side bearing. */ - /* */ - /* advance :: The advance width or height. */ - /* */ - typedef struct TT_SBit_Small_Metrics_ - { - FT_Byte height; - FT_Byte width; - - FT_Char bearingX; - FT_Char bearingY; - FT_Byte advance; - - } TT_SBit_SmallMetricsRec, *TT_SBit_SmallMetrics; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_LineMetricsRec */ - /* */ - /* <Description> */ - /* A structure used to describe the text line metrics of a given */ - /* bitmap strike, for either a horizontal or vertical layout. */ - /* */ - /* <Fields> */ - /* ascender :: The ascender in pixels. */ - /* */ - /* descender :: The descender in pixels. */ - /* */ - /* max_width :: The maximum glyph width in pixels. */ - /* */ - /* caret_slope_enumerator :: Rise of the caret slope, typically set */ - /* to 1 for non-italic fonts. */ - /* */ - /* caret_slope_denominator :: Rise of the caret slope, typically set */ - /* to 0 for non-italic fonts. */ - /* */ - /* caret_offset :: Offset in pixels to move the caret for */ - /* proper positioning. */ - /* */ - /* min_origin_SB :: Minimum of horiBearingX (resp. */ - /* vertBearingY). */ - /* min_advance_SB :: Minimum of */ - /* */ - /* horizontal advance - */ - /* ( horiBearingX + width ) */ - /* */ - /* resp. */ - /* */ - /* vertical advance - */ - /* ( vertBearingY + height ) */ - /* */ - /* max_before_BL :: Maximum of horiBearingY (resp. */ - /* vertBearingY). */ - /* */ - /* min_after_BL :: Minimum of */ - /* */ - /* horiBearingY - height */ - /* */ - /* resp. */ - /* */ - /* vertBearingX - width */ - /* */ - /* pads :: Unused (to make the size of the record */ - /* a multiple of 32 bits. */ - /* */ - typedef struct TT_SBit_LineMetricsRec_ - { - FT_Char ascender; - FT_Char descender; - FT_Byte max_width; - FT_Char caret_slope_numerator; - FT_Char caret_slope_denominator; - FT_Char caret_offset; - FT_Char min_origin_SB; - FT_Char min_advance_SB; - FT_Char max_before_BL; - FT_Char min_after_BL; - FT_Char pads[2]; - - } TT_SBit_LineMetricsRec, *TT_SBit_LineMetrics; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_RangeRec */ - /* */ - /* <Description> */ - /* A TrueType/OpenType subIndexTable as defined in the `EBLC' */ - /* (Microsoft) or `bloc' (Apple) tables. */ - /* */ - /* <Fields> */ - /* first_glyph :: The first glyph index in the range. */ - /* */ - /* last_glyph :: The last glyph index in the range. */ - /* */ - /* index_format :: The format of index table. Valid values are 1 */ - /* to 5. */ - /* */ - /* image_format :: The format of `EBDT' image data. */ - /* */ - /* image_offset :: The offset to image data in `EBDT'. */ - /* */ - /* image_size :: For index formats 2 and 5. This is the size in */ - /* bytes of each glyph bitmap. */ - /* */ - /* big_metrics :: For index formats 2 and 5. This is the big */ - /* metrics for each glyph bitmap. */ - /* */ - /* num_glyphs :: For index formats 4 and 5. This is the number of */ - /* glyphs in the code array. */ - /* */ - /* glyph_offsets :: For index formats 1 and 3. */ - /* */ - /* glyph_codes :: For index formats 4 and 5. */ - /* */ - /* table_offset :: The offset of the index table in the `EBLC' */ - /* table. Only used during strike loading. */ - /* */ - typedef struct TT_SBit_RangeRec_ - { - FT_UShort first_glyph; - FT_UShort last_glyph; - - FT_UShort index_format; - FT_UShort image_format; - FT_ULong image_offset; - - FT_ULong image_size; - TT_SBit_MetricsRec metrics; - FT_ULong num_glyphs; - - FT_ULong* glyph_offsets; - FT_UShort* glyph_codes; - - FT_ULong table_offset; - - } TT_SBit_RangeRec, *TT_SBit_Range; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_StrikeRec */ - /* */ - /* <Description> */ - /* A structure used describe a given bitmap strike in the `EBLC' */ - /* (Microsoft) or `bloc' (Apple) tables. */ - /* */ - /* <Fields> */ - /* num_index_ranges :: The number of index ranges. */ - /* */ - /* index_ranges :: An array of glyph index ranges. */ - /* */ - /* color_ref :: Unused. `color_ref' is put in for future */ - /* enhancements, but these fields are already */ - /* in use by other platforms (e.g. Newton). */ - /* For details, please see */ - /* */ - /* http://fonts.apple.com/ */ - /* TTRefMan/RM06/Chap6bloc.html */ - /* */ - /* hori :: The line metrics for horizontal layouts. */ - /* */ - /* vert :: The line metrics for vertical layouts. */ - /* */ - /* start_glyph :: The lowest glyph index for this strike. */ - /* */ - /* end_glyph :: The highest glyph index for this strike. */ - /* */ - /* x_ppem :: The number of horizontal pixels per EM. */ - /* */ - /* y_ppem :: The number of vertical pixels per EM. */ - /* */ - /* bit_depth :: The bit depth. Valid values are 1, 2, 4, */ - /* and 8. */ - /* */ - /* flags :: Is this a vertical or horizontal strike? For */ - /* details, please see */ - /* */ - /* http://fonts.apple.com/ */ - /* TTRefMan/RM06/Chap6bloc.html */ - /* */ - typedef struct TT_SBit_StrikeRec_ - { - FT_Int num_ranges; - TT_SBit_Range sbit_ranges; - FT_ULong ranges_offset; - - FT_ULong color_ref; - - TT_SBit_LineMetricsRec hori; - TT_SBit_LineMetricsRec vert; - - FT_UShort start_glyph; - FT_UShort end_glyph; - - FT_Byte x_ppem; - FT_Byte y_ppem; - - FT_Byte bit_depth; - FT_Char flags; - - } TT_SBit_StrikeRec, *TT_SBit_Strike; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_ComponentRec */ - /* */ - /* <Description> */ - /* A simple structure to describe a compound sbit element. */ - /* */ - /* <Fields> */ - /* glyph_code :: The element's glyph index. */ - /* */ - /* x_offset :: The element's left bearing. */ - /* */ - /* y_offset :: The element's top bearing. */ - /* */ - typedef struct TT_SBit_ComponentRec_ - { - FT_UShort glyph_code; - FT_Char x_offset; - FT_Char y_offset; - - } TT_SBit_ComponentRec, *TT_SBit_Component; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_SBit_ScaleRec */ - /* */ - /* <Description> */ - /* A structure used describe a given bitmap scaling table, as defined */ - /* in the `EBSC' table. */ - /* */ - /* <Fields> */ - /* hori :: The horizontal line metrics. */ - /* */ - /* vert :: The vertical line metrics. */ - /* */ - /* x_ppem :: The number of horizontal pixels per EM. */ - /* */ - /* y_ppem :: The number of vertical pixels per EM. */ - /* */ - /* x_ppem_substitute :: Substitution x_ppem value. */ - /* */ - /* y_ppem_substitute :: Substitution y_ppem value. */ - /* */ - typedef struct TT_SBit_ScaleRec_ - { - TT_SBit_LineMetricsRec hori; - TT_SBit_LineMetricsRec vert; - - FT_Byte x_ppem; - FT_Byte y_ppem; - - FT_Byte x_ppem_substitute; - FT_Byte y_ppem_substitute; - - } TT_SBit_ScaleRec, *TT_SBit_Scale; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** POSTSCRIPT GLYPH NAMES SUPPORT ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Post_20Rec */ - /* */ - /* <Description> */ - /* Postscript names sub-table, format 2.0. Stores the PS name of */ - /* each glyph in the font face. */ - /* */ - /* <Fields> */ - /* num_glyphs :: The number of named glyphs in the table. */ - /* */ - /* num_names :: The number of PS names stored in the table. */ - /* */ - /* glyph_indices :: The indices of the glyphs in the names arrays. */ - /* */ - /* glyph_names :: The PS names not in Mac Encoding. */ - /* */ - typedef struct TT_Post_20Rec_ - { - FT_UShort num_glyphs; - FT_UShort num_names; - FT_UShort* glyph_indices; - FT_Char** glyph_names; - - } TT_Post_20Rec, *TT_Post_20; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Post_25Rec */ - /* */ - /* <Description> */ - /* Postscript names sub-table, format 2.5. Stores the PS name of */ - /* each glyph in the font face. */ - /* */ - /* <Fields> */ - /* num_glyphs :: The number of glyphs in the table. */ - /* */ - /* offsets :: An array of signed offsets in a normal Mac */ - /* Postscript name encoding. */ - /* */ - typedef struct TT_Post_25_ - { - FT_UShort num_glyphs; - FT_Char* offsets; - - } TT_Post_25Rec, *TT_Post_25; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Post_NamesRec */ - /* */ - /* <Description> */ - /* Postscript names table, either format 2.0 or 2.5. */ - /* */ - /* <Fields> */ - /* loaded :: A flag to indicate whether the PS names are loaded. */ - /* */ - /* format_20 :: The sub-table used for format 2.0. */ - /* */ - /* format_25 :: The sub-table used for format 2.5. */ - /* */ - typedef struct TT_Post_NamesRec_ - { - FT_Bool loaded; - - union - { - TT_Post_20Rec format_20; - TT_Post_25Rec format_25; - - } names; - - } TT_Post_NamesRec, *TT_Post_Names; - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** GX VARIATION TABLE SUPPORT ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - typedef struct GX_BlendRec_ *GX_Blend; -#endif - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** EMBEDDED BDF PROPERTIES TABLE SUPPORT ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - /* - * These types are used to support a `BDF ' table that isn't part of the - * official TrueType specification. It is mainly used in SFNT-based - * bitmap fonts that were generated from a set of BDF fonts. - * - * The format of the table is as follows. - * - * USHORT version `BDF ' table version number, should be 0x0001. - * USHORT strikeCount Number of strikes (bitmap sizes) in this table. - * ULONG stringTable Offset (from start of BDF table) to string - * table. - * - * This is followed by an array of `strikeCount' descriptors, having the - * following format. - * - * USHORT ppem Vertical pixels per EM for this strike. - * USHORT numItems Number of items for this strike (properties and - * atoms). Maximum is 255. - * - * This array in turn is followed by `strikeCount' value sets. Each - * `value set' is an array of `numItems' items with the following format. - * - * ULONG item_name Offset in string table to item name. - * USHORT item_type The item type. Possible values are - * 0 => string (e.g., COMMENT) - * 1 => atom (e.g., FONT or even SIZE) - * 2 => int32 - * 3 => uint32 - * 0x10 => A flag to indicate a properties. This - * is ORed with the above values. - * ULONG item_value For strings => Offset into string table without - * the corresponding double quotes. - * For atoms => Offset into string table. - * For integers => Direct value. - * - * All strings in the string table consist of bytes and are - * zero-terminated. - * - */ - -#ifdef TT_CONFIG_OPTION_BDF - - typedef struct TT_BDFRec_ - { - FT_Byte* table; - FT_Byte* table_end; - FT_Byte* strings; - FT_ULong strings_size; - FT_UInt num_strikes; - FT_Bool loaded; - - } TT_BDFRec, *TT_BDF; - -#endif /* TT_CONFIG_OPTION_BDF */ - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*** ***/ - /*** ***/ - /*** ORIGINAL TT_FACE CLASS DEFINITION ***/ - /*** ***/ - /*** ***/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This structure/class is defined here because it is common to the */ - /* following formats: TTF, OpenType-TT, and OpenType-CFF. */ - /* */ - /* Note, however, that the classes TT_Size and TT_GlyphSlot are not */ - /* shared between font drivers, and are thus defined in `ttobjs.h'. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* TT_Face */ - /* */ - /* <Description> */ - /* A handle to a TrueType face/font object. A TT_Face encapsulates */ - /* the resolution and scaling independent parts of a TrueType font */ - /* resource. */ - /* */ - /* <Note> */ - /* The TT_Face structure is also used as a `parent class' for the */ - /* OpenType-CFF class (T2_Face). */ - /* */ - typedef struct TT_FaceRec_* TT_Face; - - - /* a function type used for the truetype bytecode interpreter hooks */ - typedef FT_Error - (*TT_Interpreter)( void* exec_context ); - - /* forward declaration */ - typedef struct TT_LoaderRec_* TT_Loader; - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Loader_GotoTableFunc */ - /* */ - /* <Description> */ - /* Seeks a stream to the start of a given TrueType table. */ - /* */ - /* <Input> */ - /* face :: A handle to the target face object. */ - /* */ - /* tag :: A 4-byte tag used to name the table. */ - /* */ - /* stream :: The input stream. */ - /* */ - /* <Output> */ - /* length :: The length of the table in bytes. Set to 0 if not */ - /* needed. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* The stream cursor must be at the font file's origin. */ - /* */ - typedef FT_Error - (*TT_Loader_GotoTableFunc)( TT_Face face, - FT_ULong tag, - FT_Stream stream, - FT_ULong* length ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Loader_StartGlyphFunc */ - /* */ - /* <Description> */ - /* Seeks a stream to the start of a given glyph element, and opens a */ - /* frame for it. */ - /* */ - /* <Input> */ - /* loader :: The current TrueType glyph loader object. */ - /* */ - /* glyph index :: The index of the glyph to access. */ - /* */ - /* offset :: The offset of the glyph according to the */ - /* `locations' table. */ - /* */ - /* byte_count :: The size of the frame in bytes. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function is normally equivalent to FT_STREAM_SEEK(offset) */ - /* followed by FT_FRAME_ENTER(byte_count) with the loader's stream, */ - /* but alternative formats (e.g. compressed ones) might use something */ - /* different. */ - /* */ - typedef FT_Error - (*TT_Loader_StartGlyphFunc)( TT_Loader loader, - FT_UInt glyph_index, - FT_ULong offset, - FT_UInt byte_count ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Loader_ReadGlyphFunc */ - /* */ - /* <Description> */ - /* Reads one glyph element (its header, a simple glyph, or a */ - /* composite) from the loader's current stream frame. */ - /* */ - /* <Input> */ - /* loader :: The current TrueType glyph loader object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - typedef FT_Error - (*TT_Loader_ReadGlyphFunc)( TT_Loader loader ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* TT_Loader_EndGlyphFunc */ - /* */ - /* <Description> */ - /* Closes the current loader stream frame for the glyph. */ - /* */ - /* <Input> */ - /* loader :: The current TrueType glyph loader object. */ - /* */ - typedef void - (*TT_Loader_EndGlyphFunc)( TT_Loader loader ); - - - typedef enum TT_SbitTableType_ - { - TT_SBIT_TABLE_TYPE_NONE = 0, - TT_SBIT_TABLE_TYPE_EBLC, /* `EBLC' (Microsoft), */ - /* `bloc' (Apple) */ - TT_SBIT_TABLE_TYPE_CBLC, /* `CBLC' (Google) */ - TT_SBIT_TABLE_TYPE_SBIX, /* `sbix' (Apple) */ - - /* do not remove */ - TT_SBIT_TABLE_TYPE_MAX - - } TT_SbitTableType; - - - /*************************************************************************/ - /* */ - /* TrueType Face Type */ - /* */ - /* <Struct> */ - /* TT_Face */ - /* */ - /* <Description> */ - /* The TrueType face class. These objects model the resolution and */ - /* point-size independent data found in a TrueType font file. */ - /* */ - /* <Fields> */ - /* root :: The base FT_Face structure, managed by the */ - /* base layer. */ - /* */ - /* ttc_header :: The TrueType collection header, used when */ - /* the file is a `ttc' rather than a `ttf'. */ - /* For ordinary font files, the field */ - /* `ttc_header.count' is set to 0. */ - /* */ - /* format_tag :: The font format tag. */ - /* */ - /* num_tables :: The number of TrueType tables in this font */ - /* file. */ - /* */ - /* dir_tables :: The directory of TrueType tables for this */ - /* font file. */ - /* */ - /* header :: The font's font header (`head' table). */ - /* Read on font opening. */ - /* */ - /* horizontal :: The font's horizontal header (`hhea' */ - /* table). This field also contains the */ - /* associated horizontal metrics table */ - /* (`hmtx'). */ - /* */ - /* max_profile :: The font's maximum profile table. Read on */ - /* font opening. Note that some maximum */ - /* values cannot be taken directly from this */ - /* table. We thus define additional fields */ - /* below to hold the computed maxima. */ - /* */ - /* vertical_info :: A boolean which is set when the font file */ - /* contains vertical metrics. If not, the */ - /* value of the `vertical' field is */ - /* undefined. */ - /* */ - /* vertical :: The font's vertical header (`vhea' table). */ - /* This field also contains the associated */ - /* vertical metrics table (`vmtx'), if found. */ - /* IMPORTANT: The contents of this field is */ - /* undefined if the `verticalInfo' field is */ - /* unset. */ - /* */ - /* num_names :: The number of name records within this */ - /* TrueType font. */ - /* */ - /* name_table :: The table of name records (`name'). */ - /* */ - /* os2 :: The font's OS/2 table (`OS/2'). */ - /* */ - /* postscript :: The font's PostScript table (`post' */ - /* table). The PostScript glyph names are */ - /* not loaded by the driver on face opening. */ - /* See the `ttpost' module for more details. */ - /* */ - /* cmap_table :: Address of the face's `cmap' SFNT table */ - /* in memory (it's an extracted frame). */ - /* */ - /* cmap_size :: The size in bytes of the `cmap_table' */ - /* described above. */ - /* */ - /* goto_table :: A function called by each TrueType table */ - /* loader to position a stream's cursor to */ - /* the start of a given table according to */ - /* its tag. It defaults to TT_Goto_Face but */ - /* can be different for strange formats (e.g. */ - /* Type 42). */ - /* */ - /* access_glyph_frame :: A function used to access the frame of a */ - /* given glyph within the face's font file. */ - /* */ - /* forget_glyph_frame :: A function used to forget the frame of a */ - /* given glyph when all data has been loaded. */ - /* */ - /* read_glyph_header :: A function used to read a glyph header. */ - /* It must be called between an `access' and */ - /* `forget'. */ - /* */ - /* read_simple_glyph :: A function used to read a simple glyph. */ - /* It must be called after the header was */ - /* read, and before the `forget'. */ - /* */ - /* read_composite_glyph :: A function used to read a composite glyph. */ - /* It must be called after the header was */ - /* read, and before the `forget'. */ - /* */ - /* sfnt :: A pointer to the SFNT service. */ - /* */ - /* psnames :: A pointer to the PostScript names service. */ - /* */ - /* hdmx :: The face's horizontal device metrics */ - /* (`hdmx' table). This table is optional in */ - /* TrueType/OpenType fonts. */ - /* */ - /* gasp :: The grid-fitting and scaling properties */ - /* table (`gasp'). This table is optional in */ - /* TrueType/OpenType fonts. */ - /* */ - /* pclt :: The `pclt' SFNT table. */ - /* */ - /* num_sbit_scales :: The number of sbit scales for this font. */ - /* */ - /* sbit_scales :: Array of sbit scales embedded in this */ - /* font. This table is optional in a */ - /* TrueType/OpenType font. */ - /* */ - /* postscript_names :: A table used to store the Postscript names */ - /* of the glyphs for this font. See the */ - /* file `ttconfig.h' for comments on the */ - /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES option. */ - /* */ - /* num_locations :: The number of glyph locations in this */ - /* TrueType file. This should be */ - /* identical to the number of glyphs. */ - /* Ignored for Type 2 fonts. */ - /* */ - /* glyph_locations :: An array of longs. These are offsets to */ - /* glyph data within the `glyf' table. */ - /* Ignored for Type 2 font faces. */ - /* */ - /* glyf_len :: The length of the `glyf' table. Needed */ - /* for malformed `loca' tables. */ - /* */ - /* font_program_size :: Size in bytecodes of the face's font */ - /* program. 0 if none defined. Ignored for */ - /* Type 2 fonts. */ - /* */ - /* font_program :: The face's font program (bytecode stream) */ - /* executed at load time, also used during */ - /* glyph rendering. Comes from the `fpgm' */ - /* table. Ignored for Type 2 font fonts. */ - /* */ - /* cvt_program_size :: The size in bytecodes of the face's cvt */ - /* program. Ignored for Type 2 fonts. */ - /* */ - /* cvt_program :: The face's cvt program (bytecode stream) */ - /* executed each time an instance/size is */ - /* changed/reset. Comes from the `prep' */ - /* table. Ignored for Type 2 fonts. */ - /* */ - /* cvt_size :: Size of the control value table (in */ - /* entries). Ignored for Type 2 fonts. */ - /* */ - /* cvt :: The face's original control value table. */ - /* Coordinates are expressed in unscaled font */ - /* units. Comes from the `cvt ' table. */ - /* Ignored for Type 2 fonts. */ - /* */ - /* num_kern_pairs :: The number of kerning pairs present in the */ - /* font file. The engine only loads the */ - /* first horizontal format 0 kern table it */ - /* finds in the font file. Ignored for */ - /* Type 2 fonts. */ - /* */ - /* kern_table_index :: The index of the kerning table in the font */ - /* kerning directory. Ignored for Type 2 */ - /* fonts. */ - /* */ - /* interpreter :: A pointer to the TrueType bytecode */ - /* interpreters field is also used to hook */ - /* the debugger in `ttdebug'. */ - /* */ - /* unpatented_hinting :: If true, use only unpatented methods in */ - /* the bytecode interpreter. */ - /* */ - /* doblend :: A boolean which is set if the font should */ - /* be blended (this is for GX var). */ - /* */ - /* blend :: Contains the data needed to control GX */ - /* variation tables (rather like Multiple */ - /* Master data). */ - /* */ - /* extra :: Reserved for third-party font drivers. */ - /* */ - /* postscript_name :: The PS name of the font. Used by the */ - /* postscript name service. */ - /* */ - typedef struct TT_FaceRec_ - { - FT_FaceRec root; - - TTC_HeaderRec ttc_header; - - FT_ULong format_tag; - FT_UShort num_tables; - TT_Table dir_tables; - - TT_Header header; /* TrueType header table */ - TT_HoriHeader horizontal; /* TrueType horizontal header */ - - TT_MaxProfile max_profile; - - FT_Bool vertical_info; - TT_VertHeader vertical; /* TT Vertical header, if present */ - - FT_UShort num_names; /* number of name records */ - TT_NameTableRec name_table; /* name table */ - - TT_OS2 os2; /* TrueType OS/2 table */ - TT_Postscript postscript; /* TrueType Postscript table */ - - FT_Byte* cmap_table; /* extracted `cmap' table */ - FT_ULong cmap_size; - - TT_Loader_GotoTableFunc goto_table; - - TT_Loader_StartGlyphFunc access_glyph_frame; - TT_Loader_EndGlyphFunc forget_glyph_frame; - TT_Loader_ReadGlyphFunc read_glyph_header; - TT_Loader_ReadGlyphFunc read_simple_glyph; - TT_Loader_ReadGlyphFunc read_composite_glyph; - - /* a typeless pointer to the SFNT_Interface table used to load */ - /* the basic TrueType tables in the face object */ - void* sfnt; - - /* a typeless pointer to the FT_Service_PsCMapsRec table used to */ - /* handle glyph names <-> unicode & Mac values */ - void* psnames; - - - /***********************************************************************/ - /* */ - /* Optional TrueType/OpenType tables */ - /* */ - /***********************************************************************/ - - /* grid-fitting and scaling table */ - TT_GaspRec gasp; /* the `gasp' table */ - - /* PCL 5 table */ - TT_PCLT pclt; - - /* embedded bitmaps support */ - FT_ULong num_sbit_scales; - TT_SBit_Scale sbit_scales; - - /* postscript names table */ - TT_Post_NamesRec postscript_names; - - - /***********************************************************************/ - /* */ - /* TrueType-specific fields (ignored by the OTF-Type2 driver) */ - /* */ - /***********************************************************************/ - - /* the font program, if any */ - FT_ULong font_program_size; - FT_Byte* font_program; - - /* the cvt program, if any */ - FT_ULong cvt_program_size; - FT_Byte* cvt_program; - - /* the original, unscaled, control value table */ - FT_ULong cvt_size; - FT_Short* cvt; - - /* A pointer to the bytecode interpreter to use. This is also */ - /* used to hook the debugger for the `ttdebug' utility. */ - TT_Interpreter interpreter; - -#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING - /* Use unpatented hinting only. */ - FT_Bool unpatented_hinting; -#endif - - /***********************************************************************/ - /* */ - /* Other tables or fields. This is used by derivative formats like */ - /* OpenType. */ - /* */ - /***********************************************************************/ - - FT_Generic extra; - - const char* postscript_name; - - FT_ULong glyf_len; - -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_Bool doblend; - GX_Blend blend; -#endif - - /* since version 2.2 */ - - FT_Byte* horz_metrics; - FT_ULong horz_metrics_size; - - FT_Byte* vert_metrics; - FT_ULong vert_metrics_size; - - FT_ULong num_locations; /* in broken TTF, gid > 0xFFFF */ - FT_Byte* glyph_locations; - - FT_Byte* hdmx_table; - FT_ULong hdmx_table_size; - FT_UInt hdmx_record_count; - FT_ULong hdmx_record_size; - FT_Byte* hdmx_record_sizes; - - FT_Byte* sbit_table; - FT_ULong sbit_table_size; - TT_SbitTableType sbit_table_type; - FT_UInt sbit_num_strikes; - - FT_Byte* kern_table; - FT_ULong kern_table_size; - FT_UInt num_kern_tables; - FT_UInt32 kern_avail_bits; - FT_UInt32 kern_order_bits; - -#ifdef TT_CONFIG_OPTION_BDF - TT_BDFRec bdf; -#endif /* TT_CONFIG_OPTION_BDF */ - - /* since 2.3.0 */ - FT_ULong horz_metrics_offset; - FT_ULong vert_metrics_offset; - -#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING - /* since 2.4.12 */ - FT_ULong sph_found_func_flags; /* special functions found */ - /* for this face */ - FT_Bool sph_compatibility_mode; -#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ - - } TT_FaceRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_GlyphZoneRec */ - /* */ - /* <Description> */ - /* A glyph zone is used to load, scale and hint glyph outline */ - /* coordinates. */ - /* */ - /* <Fields> */ - /* memory :: A handle to the memory manager. */ - /* */ - /* max_points :: The maximum size in points of the zone. */ - /* */ - /* max_contours :: Max size in links contours of the zone. */ - /* */ - /* n_points :: The current number of points in the zone. */ - /* */ - /* n_contours :: The current number of contours in the zone. */ - /* */ - /* org :: The original glyph coordinates (font */ - /* units/scaled). */ - /* */ - /* cur :: The current glyph coordinates (scaled/hinted). */ - /* */ - /* tags :: The point control tags. */ - /* */ - /* contours :: The contours end points. */ - /* */ - /* first_point :: Offset of the current subglyph's first point. */ - /* */ - typedef struct TT_GlyphZoneRec_ - { - FT_Memory memory; - FT_UShort max_points; - FT_UShort max_contours; - FT_UShort n_points; /* number of points in zone */ - FT_Short n_contours; /* number of contours */ - - FT_Vector* org; /* original point coordinates */ - FT_Vector* cur; /* current point coordinates */ - FT_Vector* orus; /* original (unscaled) point coordinates */ - - FT_Byte* tags; /* current touch flags */ - FT_UShort* contours; /* contour end points */ - - FT_UShort first_point; /* offset of first (#0) point */ - - } TT_GlyphZoneRec, *TT_GlyphZone; - - - /* handle to execution context */ - typedef struct TT_ExecContextRec_* TT_ExecContext; - - /* glyph loader structure */ - typedef struct TT_LoaderRec_ - { - FT_Face face; - FT_Size size; - FT_GlyphSlot glyph; - FT_GlyphLoader gloader; - - FT_ULong load_flags; - FT_UInt glyph_index; - - FT_Stream stream; - FT_Int byte_len; - - FT_Short n_contours; - FT_BBox bbox; - FT_Int left_bearing; - FT_Int advance; - FT_Int linear; - FT_Bool linear_def; - FT_Vector pp1; - FT_Vector pp2; - - FT_ULong glyf_offset; - - /* the zone where we load our glyphs */ - TT_GlyphZoneRec base; - TT_GlyphZoneRec zone; - - TT_ExecContext exec; - FT_Byte* instructions; - FT_ULong ins_pos; - - /* for possible extensibility in other formats */ - void* other; - - /* since version 2.1.8 */ - FT_Int top_bearing; - FT_Int vadvance; - FT_Vector pp3; - FT_Vector pp4; - - /* since version 2.2.1 */ - FT_Byte* cursor; - FT_Byte* limit; - - } TT_LoaderRec; - - -FT_END_HEADER - -#endif /* __TTTYPES_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/t1tables.h b/thirdparty/include/freetype/t1tables.h deleted file mode 100644 index f44a05b02..000000000 --- a/thirdparty/include/freetype/t1tables.h +++ /dev/null @@ -1,662 +0,0 @@ -/***************************************************************************/ -/* */ -/* t1tables.h */ -/* */ -/* Basic Type 1/Type 2 tables definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2004, 2006, 2008, 2009, 2011 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __T1TABLES_H__ -#define __T1TABLES_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* type1_tables */ - /* */ - /* <Title> */ - /* Type 1 Tables */ - /* */ - /* <Abstract> */ - /* Type~1 (PostScript) specific font tables. */ - /* */ - /* <Description> */ - /* This section contains the definition of Type 1-specific tables, */ - /* including structures related to other PostScript font formats. */ - /* */ - /*************************************************************************/ - - - /* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */ - /* structures in order to support Multiple Master fonts. */ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_FontInfoRec */ - /* */ - /* <Description> */ - /* A structure used to model a Type~1 or Type~2 FontInfo dictionary. */ - /* Note that for Multiple Master fonts, each instance has its own */ - /* FontInfo dictionary. */ - /* */ - typedef struct PS_FontInfoRec_ - { - FT_String* version; - FT_String* notice; - FT_String* full_name; - FT_String* family_name; - FT_String* weight; - FT_Long italic_angle; - FT_Bool is_fixed_pitch; - FT_Short underline_position; - FT_UShort underline_thickness; - - } PS_FontInfoRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_FontInfo */ - /* */ - /* <Description> */ - /* A handle to a @PS_FontInfoRec structure. */ - /* */ - typedef struct PS_FontInfoRec_* PS_FontInfo; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_FontInfo */ - /* */ - /* <Description> */ - /* This type is equivalent to @PS_FontInfoRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ - typedef PS_FontInfoRec T1_FontInfo; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_PrivateRec */ - /* */ - /* <Description> */ - /* A structure used to model a Type~1 or Type~2 private dictionary. */ - /* Note that for Multiple Master fonts, each instance has its own */ - /* Private dictionary. */ - /* */ - typedef struct PS_PrivateRec_ - { - FT_Int unique_id; - FT_Int lenIV; - - FT_Byte num_blue_values; - FT_Byte num_other_blues; - FT_Byte num_family_blues; - FT_Byte num_family_other_blues; - - FT_Short blue_values[14]; - FT_Short other_blues[10]; - - FT_Short family_blues [14]; - FT_Short family_other_blues[10]; - - FT_Fixed blue_scale; - FT_Int blue_shift; - FT_Int blue_fuzz; - - FT_UShort standard_width[1]; - FT_UShort standard_height[1]; - - FT_Byte num_snap_widths; - FT_Byte num_snap_heights; - FT_Bool force_bold; - FT_Bool round_stem_up; - - FT_Short snap_widths [13]; /* including std width */ - FT_Short snap_heights[13]; /* including std height */ - - FT_Fixed expansion_factor; - - FT_Long language_group; - FT_Long password; - - FT_Short min_feature[2]; - - } PS_PrivateRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_Private */ - /* */ - /* <Description> */ - /* A handle to a @PS_PrivateRec structure. */ - /* */ - typedef struct PS_PrivateRec_* PS_Private; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_Private */ - /* */ - /* <Description> */ - /* This type is equivalent to @PS_PrivateRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ - typedef PS_PrivateRec T1_Private; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* T1_Blend_Flags */ - /* */ - /* <Description> */ - /* A set of flags used to indicate which fields are present in a */ - /* given blend dictionary (font info or private). Used to support */ - /* Multiple Masters fonts. */ - /* */ - typedef enum T1_Blend_Flags_ - { - /*# required fields in a FontInfo blend dictionary */ - T1_BLEND_UNDERLINE_POSITION = 0, - T1_BLEND_UNDERLINE_THICKNESS, - T1_BLEND_ITALIC_ANGLE, - - /*# required fields in a Private blend dictionary */ - T1_BLEND_BLUE_VALUES, - T1_BLEND_OTHER_BLUES, - T1_BLEND_STANDARD_WIDTH, - T1_BLEND_STANDARD_HEIGHT, - T1_BLEND_STEM_SNAP_WIDTHS, - T1_BLEND_STEM_SNAP_HEIGHTS, - T1_BLEND_BLUE_SCALE, - T1_BLEND_BLUE_SHIFT, - T1_BLEND_FAMILY_BLUES, - T1_BLEND_FAMILY_OTHER_BLUES, - T1_BLEND_FORCE_BOLD, - - /*# never remove */ - T1_BLEND_MAX - - } T1_Blend_Flags; - - /* */ - - - /*# backwards compatible definitions */ -#define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION -#define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS -#define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE -#define t1_blend_blue_values T1_BLEND_BLUE_VALUES -#define t1_blend_other_blues T1_BLEND_OTHER_BLUES -#define t1_blend_standard_widths T1_BLEND_STANDARD_WIDTH -#define t1_blend_standard_height T1_BLEND_STANDARD_HEIGHT -#define t1_blend_stem_snap_widths T1_BLEND_STEM_SNAP_WIDTHS -#define t1_blend_stem_snap_heights T1_BLEND_STEM_SNAP_HEIGHTS -#define t1_blend_blue_scale T1_BLEND_BLUE_SCALE -#define t1_blend_blue_shift T1_BLEND_BLUE_SHIFT -#define t1_blend_family_blues T1_BLEND_FAMILY_BLUES -#define t1_blend_family_other_blues T1_BLEND_FAMILY_OTHER_BLUES -#define t1_blend_force_bold T1_BLEND_FORCE_BOLD -#define t1_blend_max T1_BLEND_MAX - - - /* maximum number of Multiple Masters designs, as defined in the spec */ -#define T1_MAX_MM_DESIGNS 16 - - /* maximum number of Multiple Masters axes, as defined in the spec */ -#define T1_MAX_MM_AXIS 4 - - /* maximum number of elements in a design map */ -#define T1_MAX_MM_MAP_POINTS 20 - - - /* this structure is used to store the BlendDesignMap entry for an axis */ - typedef struct PS_DesignMap_ - { - FT_Byte num_points; - FT_Long* design_points; - FT_Fixed* blend_points; - - } PS_DesignMapRec, *PS_DesignMap; - - /* backwards-compatible definition */ - typedef PS_DesignMapRec T1_DesignMap; - - - typedef struct PS_BlendRec_ - { - FT_UInt num_designs; - FT_UInt num_axis; - - FT_String* axis_names[T1_MAX_MM_AXIS]; - FT_Fixed* design_pos[T1_MAX_MM_DESIGNS]; - PS_DesignMapRec design_map[T1_MAX_MM_AXIS]; - - FT_Fixed* weight_vector; - FT_Fixed* default_weight_vector; - - PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1]; - PS_Private privates [T1_MAX_MM_DESIGNS + 1]; - - FT_ULong blend_bitflags; - - FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1]; - - /* since 2.3.0 */ - - /* undocumented, optional: the default design instance; */ - /* corresponds to default_weight_vector -- */ - /* num_default_design_vector == 0 means it is not present */ - /* in the font and associated metrics files */ - FT_UInt default_design_vector[T1_MAX_MM_DESIGNS]; - FT_UInt num_default_design_vector; - - } PS_BlendRec, *PS_Blend; - - - /* backwards-compatible definition */ - typedef PS_BlendRec T1_Blend; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceDictRec */ - /* */ - /* <Description> */ - /* A structure used to represent data in a CID top-level dictionary. */ - /* */ - typedef struct CID_FaceDictRec_ - { - PS_PrivateRec private_dict; - - FT_UInt len_buildchar; - FT_Fixed forcebold_threshold; - FT_Pos stroke_width; - FT_Fixed expansion_factor; - - FT_Byte paint_type; - FT_Byte font_type; - FT_Matrix font_matrix; - FT_Vector font_offset; - - FT_UInt num_subrs; - FT_ULong subrmap_offset; - FT_Int sd_bytes; - - } CID_FaceDictRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceDict */ - /* */ - /* <Description> */ - /* A handle to a @CID_FaceDictRec structure. */ - /* */ - typedef struct CID_FaceDictRec_* CID_FaceDict; - - /* */ - - - /* backwards-compatible definition */ - typedef CID_FaceDictRec CID_FontDict; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceInfoRec */ - /* */ - /* <Description> */ - /* A structure used to represent CID Face information. */ - /* */ - typedef struct CID_FaceInfoRec_ - { - FT_String* cid_font_name; - FT_Fixed cid_version; - FT_Int cid_font_type; - - FT_String* registry; - FT_String* ordering; - FT_Int supplement; - - PS_FontInfoRec font_info; - FT_BBox font_bbox; - FT_ULong uid_base; - - FT_Int num_xuid; - FT_ULong xuid[16]; - - FT_ULong cidmap_offset; - FT_Int fd_bytes; - FT_Int gd_bytes; - FT_ULong cid_count; - - FT_Int num_dicts; - CID_FaceDict font_dicts; - - FT_ULong data_offset; - - } CID_FaceInfoRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceInfo */ - /* */ - /* <Description> */ - /* A handle to a @CID_FaceInfoRec structure. */ - /* */ - typedef struct CID_FaceInfoRec_* CID_FaceInfo; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_Info */ - /* */ - /* <Description> */ - /* This type is equivalent to @CID_FaceInfoRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ - typedef CID_FaceInfoRec CID_Info; - - - /************************************************************************ - * - * @function: - * FT_Has_PS_Glyph_Names - * - * @description: - * Return true if a given face provides reliable PostScript glyph - * names. This is similar to using the @FT_HAS_GLYPH_NAMES macro, - * except that certain fonts (mostly TrueType) contain incorrect - * glyph name tables. - * - * When this function returns true, the caller is sure that the glyph - * names returned by @FT_Get_Glyph_Name are reliable. - * - * @input: - * face :: - * face handle - * - * @return: - * Boolean. True if glyph names are reliable. - * - */ - FT_EXPORT( FT_Int ) - FT_Has_PS_Glyph_Names( FT_Face face ); - - - /************************************************************************ - * - * @function: - * FT_Get_PS_Font_Info - * - * @description: - * Retrieve the @PS_FontInfoRec structure corresponding to a given - * PostScript font. - * - * @input: - * face :: - * PostScript face handle. - * - * @output: - * afont_info :: - * Output font info structure pointer. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The string pointers within the font info structure are owned by - * the face and don't need to be freed by the caller. - * - * If the font's format is not PostScript-based, this function will - * return the `FT_Err_Invalid_Argument' error code. - * - */ - FT_EXPORT( FT_Error ) - FT_Get_PS_Font_Info( FT_Face face, - PS_FontInfo afont_info ); - - - /************************************************************************ - * - * @function: - * FT_Get_PS_Font_Private - * - * @description: - * Retrieve the @PS_PrivateRec structure corresponding to a given - * PostScript font. - * - * @input: - * face :: - * PostScript face handle. - * - * @output: - * afont_private :: - * Output private dictionary structure pointer. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The string pointers within the @PS_PrivateRec structure are owned by - * the face and don't need to be freed by the caller. - * - * If the font's format is not PostScript-based, this function returns - * the `FT_Err_Invalid_Argument' error code. - * - */ - FT_EXPORT( FT_Error ) - FT_Get_PS_Font_Private( FT_Face face, - PS_Private afont_private ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* T1_EncodingType */ - /* */ - /* <Description> */ - /* An enumeration describing the `Encoding' entry in a Type 1 */ - /* dictionary. */ - /* */ - typedef enum T1_EncodingType_ - { - T1_ENCODING_TYPE_NONE = 0, - T1_ENCODING_TYPE_ARRAY, - T1_ENCODING_TYPE_STANDARD, - T1_ENCODING_TYPE_ISOLATIN1, - T1_ENCODING_TYPE_EXPERT - - } T1_EncodingType; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* PS_Dict_Keys */ - /* */ - /* <Description> */ - /* An enumeration used in calls to @FT_Get_PS_Font_Value to identify */ - /* the Type~1 dictionary entry to retrieve. */ - /* */ - typedef enum PS_Dict_Keys_ - { - /* conventionally in the font dictionary */ - PS_DICT_FONT_TYPE, /* FT_Byte */ - PS_DICT_FONT_MATRIX, /* FT_Fixed */ - PS_DICT_FONT_BBOX, /* FT_Fixed */ - PS_DICT_PAINT_TYPE, /* FT_Byte */ - PS_DICT_FONT_NAME, /* FT_String* */ - PS_DICT_UNIQUE_ID, /* FT_Int */ - PS_DICT_NUM_CHAR_STRINGS, /* FT_Int */ - PS_DICT_CHAR_STRING_KEY, /* FT_String* */ - PS_DICT_CHAR_STRING, /* FT_String* */ - PS_DICT_ENCODING_TYPE, /* T1_EncodingType */ - PS_DICT_ENCODING_ENTRY, /* FT_String* */ - - /* conventionally in the font Private dictionary */ - PS_DICT_NUM_SUBRS, /* FT_Int */ - PS_DICT_SUBR, /* FT_String* */ - PS_DICT_STD_HW, /* FT_UShort */ - PS_DICT_STD_VW, /* FT_UShort */ - PS_DICT_NUM_BLUE_VALUES, /* FT_Byte */ - PS_DICT_BLUE_VALUE, /* FT_Short */ - PS_DICT_BLUE_FUZZ, /* FT_Int */ - PS_DICT_NUM_OTHER_BLUES, /* FT_Byte */ - PS_DICT_OTHER_BLUE, /* FT_Short */ - PS_DICT_NUM_FAMILY_BLUES, /* FT_Byte */ - PS_DICT_FAMILY_BLUE, /* FT_Short */ - PS_DICT_NUM_FAMILY_OTHER_BLUES, /* FT_Byte */ - PS_DICT_FAMILY_OTHER_BLUE, /* FT_Short */ - PS_DICT_BLUE_SCALE, /* FT_Fixed */ - PS_DICT_BLUE_SHIFT, /* FT_Int */ - PS_DICT_NUM_STEM_SNAP_H, /* FT_Byte */ - PS_DICT_STEM_SNAP_H, /* FT_Short */ - PS_DICT_NUM_STEM_SNAP_V, /* FT_Byte */ - PS_DICT_STEM_SNAP_V, /* FT_Short */ - PS_DICT_FORCE_BOLD, /* FT_Bool */ - PS_DICT_RND_STEM_UP, /* FT_Bool */ - PS_DICT_MIN_FEATURE, /* FT_Short */ - PS_DICT_LEN_IV, /* FT_Int */ - PS_DICT_PASSWORD, /* FT_Long */ - PS_DICT_LANGUAGE_GROUP, /* FT_Long */ - - /* conventionally in the font FontInfo dictionary */ - PS_DICT_VERSION, /* FT_String* */ - PS_DICT_NOTICE, /* FT_String* */ - PS_DICT_FULL_NAME, /* FT_String* */ - PS_DICT_FAMILY_NAME, /* FT_String* */ - PS_DICT_WEIGHT, /* FT_String* */ - PS_DICT_IS_FIXED_PITCH, /* FT_Bool */ - PS_DICT_UNDERLINE_POSITION, /* FT_Short */ - PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */ - PS_DICT_FS_TYPE, /* FT_UShort */ - PS_DICT_ITALIC_ANGLE, /* FT_Long */ - - PS_DICT_MAX = PS_DICT_ITALIC_ANGLE - - } PS_Dict_Keys; - - - /************************************************************************ - * - * @function: - * FT_Get_PS_Font_Value - * - * @description: - * Retrieve the value for the supplied key from a PostScript font. - * - * @input: - * face :: - * PostScript face handle. - * - * key :: - * An enumeration value representing the dictionary key to retrieve. - * - * idx :: - * For array values, this specifies the index to be returned. - * - * value :: - * A pointer to memory into which to write the value. - * - * valen_len :: - * The size, in bytes, of the memory supplied for the value. - * - * @output: - * value :: - * The value matching the above key, if it exists. - * - * @return: - * The amount of memory (in bytes) required to hold the requested - * value (if it exists, -1 otherwise). - * - * @note: - * The values returned are not pointers into the internal structures of - * the face, but are `fresh' copies, so that the memory containing them - * belongs to the calling application. This also enforces the - * `read-only' nature of these values, i.e., this function cannot be - * used to manipulate the face. - * - * `value' is a void pointer because the values returned can be of - * various types. - * - * If either `value' is NULL or `value_len' is too small, just the - * required memory size for the requested entry is returned. - * - * The `idx' parameter is used, not only to retrieve elements of, for - * example, the FontMatrix or FontBBox, but also to retrieve name keys - * from the CharStrings dictionary, and the charstrings themselves. It - * is ignored for atomic values. - * - * PS_DICT_BLUE_SCALE returns a value that is scaled up by 1000. To - * get the value as in the font stream, you need to divide by - * 65536000.0 (to remove the FT_Fixed scale, and the x1000 scale). - * - * IMPORTANT: Only key/value pairs read by the FreeType interpreter can - * be retrieved. So, for example, PostScript procedures such as NP, - * ND, and RD are not available. Arbitrary keys are, obviously, not be - * available either. - * - * If the font's format is not PostScript-based, this function returns - * the `FT_Err_Invalid_Argument' error code. - * - */ - FT_EXPORT( FT_Long ) - FT_Get_PS_Font_Value( FT_Face face, - PS_Dict_Keys key, - FT_UInt idx, - void *value, - FT_Long value_len ); - - /* */ - -FT_END_HEADER - -#endif /* __T1TABLES_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ttnameid.h b/thirdparty/include/freetype/ttnameid.h deleted file mode 100644 index 850869760..000000000 --- a/thirdparty/include/freetype/ttnameid.h +++ /dev/null @@ -1,1237 +0,0 @@ -/***************************************************************************/ -/* */ -/* ttnameid.h */ -/* */ -/* TrueType name ID definitions (specification only). */ -/* */ -/* Copyright 1996-2004, 2006-2008, 2012, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __TTNAMEID_H__ -#define __TTNAMEID_H__ - - -#include <freetype/ft2build.h> - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* truetype_tables */ - /* */ - - - /*************************************************************************/ - /* */ - /* Possible values for the `platform' identifier code in the name */ - /* records of the TTF `name' table. */ - /* */ - /*************************************************************************/ - - - /*********************************************************************** - * - * @enum: - * TT_PLATFORM_XXX - * - * @description: - * A list of valid values for the `platform_id' identifier code in - * @FT_CharMapRec and @FT_SfntName structures. - * - * @values: - * TT_PLATFORM_APPLE_UNICODE :: - * Used by Apple to indicate a Unicode character map and/or name entry. - * See @TT_APPLE_ID_XXX for corresponding `encoding_id' values. Note - * that name entries in this format are coded as big-endian UCS-2 - * character codes _only_. - * - * TT_PLATFORM_MACINTOSH :: - * Used by Apple to indicate a MacOS-specific charmap and/or name entry. - * See @TT_MAC_ID_XXX for corresponding `encoding_id' values. Note that - * most TrueType fonts contain an Apple roman charmap to be usable on - * MacOS systems (even if they contain a Microsoft charmap as well). - * - * TT_PLATFORM_ISO :: - * This value was used to specify ISO/IEC 10646 charmaps. It is however - * now deprecated. See @TT_ISO_ID_XXX for a list of corresponding - * `encoding_id' values. - * - * TT_PLATFORM_MICROSOFT :: - * Used by Microsoft to indicate Windows-specific charmaps. See - * @TT_MS_ID_XXX for a list of corresponding `encoding_id' values. - * Note that most fonts contain a Unicode charmap using - * (TT_PLATFORM_MICROSOFT, @TT_MS_ID_UNICODE_CS). - * - * TT_PLATFORM_CUSTOM :: - * Used to indicate application-specific charmaps. - * - * TT_PLATFORM_ADOBE :: - * This value isn't part of any font format specification, but is used - * by FreeType to report Adobe-specific charmaps in an @FT_CharMapRec - * structure. See @TT_ADOBE_ID_XXX. - */ - -#define TT_PLATFORM_APPLE_UNICODE 0 -#define TT_PLATFORM_MACINTOSH 1 -#define TT_PLATFORM_ISO 2 /* deprecated */ -#define TT_PLATFORM_MICROSOFT 3 -#define TT_PLATFORM_CUSTOM 4 -#define TT_PLATFORM_ADOBE 7 /* artificial */ - - - /*********************************************************************** - * - * @enum: - * TT_APPLE_ID_XXX - * - * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_APPLE_UNICODE charmaps and name entries. - * - * @values: - * TT_APPLE_ID_DEFAULT :: - * Unicode version 1.0. - * - * TT_APPLE_ID_UNICODE_1_1 :: - * Unicode 1.1; specifies Hangul characters starting at U+34xx. - * - * TT_APPLE_ID_ISO_10646 :: - * Deprecated (identical to preceding). - * - * TT_APPLE_ID_UNICODE_2_0 :: - * Unicode 2.0 and beyond (UTF-16 BMP only). - * - * TT_APPLE_ID_UNICODE_32 :: - * Unicode 3.1 and beyond, using UTF-32. - * - * TT_APPLE_ID_VARIANT_SELECTOR :: - * From Adobe, not Apple. Not a normal cmap. Specifies variations - * on a real cmap. - */ - -#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */ -#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */ -#define TT_APPLE_ID_ISO_10646 2 /* deprecated */ -#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */ -#define TT_APPLE_ID_UNICODE_32 4 /* 2.0 or later, full repertoire */ -#define TT_APPLE_ID_VARIANT_SELECTOR 5 /* variation selector data */ - - - /*********************************************************************** - * - * @enum: - * TT_MAC_ID_XXX - * - * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_MACINTOSH charmaps and name entries. - * - * @values: - * TT_MAC_ID_ROMAN :: - * TT_MAC_ID_JAPANESE :: - * TT_MAC_ID_TRADITIONAL_CHINESE :: - * TT_MAC_ID_KOREAN :: - * TT_MAC_ID_ARABIC :: - * TT_MAC_ID_HEBREW :: - * TT_MAC_ID_GREEK :: - * TT_MAC_ID_RUSSIAN :: - * TT_MAC_ID_RSYMBOL :: - * TT_MAC_ID_DEVANAGARI :: - * TT_MAC_ID_GURMUKHI :: - * TT_MAC_ID_GUJARATI :: - * TT_MAC_ID_ORIYA :: - * TT_MAC_ID_BENGALI :: - * TT_MAC_ID_TAMIL :: - * TT_MAC_ID_TELUGU :: - * TT_MAC_ID_KANNADA :: - * TT_MAC_ID_MALAYALAM :: - * TT_MAC_ID_SINHALESE :: - * TT_MAC_ID_BURMESE :: - * TT_MAC_ID_KHMER :: - * TT_MAC_ID_THAI :: - * TT_MAC_ID_LAOTIAN :: - * TT_MAC_ID_GEORGIAN :: - * TT_MAC_ID_ARMENIAN :: - * TT_MAC_ID_MALDIVIAN :: - * TT_MAC_ID_SIMPLIFIED_CHINESE :: - * TT_MAC_ID_TIBETAN :: - * TT_MAC_ID_MONGOLIAN :: - * TT_MAC_ID_GEEZ :: - * TT_MAC_ID_SLAVIC :: - * TT_MAC_ID_VIETNAMESE :: - * TT_MAC_ID_SINDHI :: - * TT_MAC_ID_UNINTERP :: - */ - -#define TT_MAC_ID_ROMAN 0 -#define TT_MAC_ID_JAPANESE 1 -#define TT_MAC_ID_TRADITIONAL_CHINESE 2 -#define TT_MAC_ID_KOREAN 3 -#define TT_MAC_ID_ARABIC 4 -#define TT_MAC_ID_HEBREW 5 -#define TT_MAC_ID_GREEK 6 -#define TT_MAC_ID_RUSSIAN 7 -#define TT_MAC_ID_RSYMBOL 8 -#define TT_MAC_ID_DEVANAGARI 9 -#define TT_MAC_ID_GURMUKHI 10 -#define TT_MAC_ID_GUJARATI 11 -#define TT_MAC_ID_ORIYA 12 -#define TT_MAC_ID_BENGALI 13 -#define TT_MAC_ID_TAMIL 14 -#define TT_MAC_ID_TELUGU 15 -#define TT_MAC_ID_KANNADA 16 -#define TT_MAC_ID_MALAYALAM 17 -#define TT_MAC_ID_SINHALESE 18 -#define TT_MAC_ID_BURMESE 19 -#define TT_MAC_ID_KHMER 20 -#define TT_MAC_ID_THAI 21 -#define TT_MAC_ID_LAOTIAN 22 -#define TT_MAC_ID_GEORGIAN 23 -#define TT_MAC_ID_ARMENIAN 24 -#define TT_MAC_ID_MALDIVIAN 25 -#define TT_MAC_ID_SIMPLIFIED_CHINESE 25 -#define TT_MAC_ID_TIBETAN 26 -#define TT_MAC_ID_MONGOLIAN 27 -#define TT_MAC_ID_GEEZ 28 -#define TT_MAC_ID_SLAVIC 29 -#define TT_MAC_ID_VIETNAMESE 30 -#define TT_MAC_ID_SINDHI 31 -#define TT_MAC_ID_UNINTERP 32 - - - /*********************************************************************** - * - * @enum: - * TT_ISO_ID_XXX - * - * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_ISO charmaps and name entries. - * - * Their use is now deprecated. - * - * @values: - * TT_ISO_ID_7BIT_ASCII :: - * ASCII. - * TT_ISO_ID_10646 :: - * ISO/10646. - * TT_ISO_ID_8859_1 :: - * Also known as Latin-1. - */ - -#define TT_ISO_ID_7BIT_ASCII 0 -#define TT_ISO_ID_10646 1 -#define TT_ISO_ID_8859_1 2 - - - /*********************************************************************** - * - * @enum: - * TT_MS_ID_XXX - * - * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_MICROSOFT charmaps and name entries. - * - * @values: - * TT_MS_ID_SYMBOL_CS :: - * Corresponds to Microsoft symbol encoding. See - * @FT_ENCODING_MS_SYMBOL. - * - * TT_MS_ID_UNICODE_CS :: - * Corresponds to a Microsoft WGL4 charmap, matching Unicode. See - * @FT_ENCODING_UNICODE. - * - * TT_MS_ID_SJIS :: - * Corresponds to SJIS Japanese encoding. See @FT_ENCODING_SJIS. - * - * TT_MS_ID_GB2312 :: - * Corresponds to Simplified Chinese as used in Mainland China. See - * @FT_ENCODING_GB2312. - * - * TT_MS_ID_BIG_5 :: - * Corresponds to Traditional Chinese as used in Taiwan and Hong Kong. - * See @FT_ENCODING_BIG5. - * - * TT_MS_ID_WANSUNG :: - * Corresponds to Korean Wansung encoding. See @FT_ENCODING_WANSUNG. - * - * TT_MS_ID_JOHAB :: - * Corresponds to Johab encoding. See @FT_ENCODING_JOHAB. - * - * TT_MS_ID_UCS_4 :: - * Corresponds to UCS-4 or UTF-32 charmaps. This has been added to - * the OpenType specification version 1.4 (mid-2001.) - */ - -#define TT_MS_ID_SYMBOL_CS 0 -#define TT_MS_ID_UNICODE_CS 1 -#define TT_MS_ID_SJIS 2 -#define TT_MS_ID_GB2312 3 -#define TT_MS_ID_BIG_5 4 -#define TT_MS_ID_WANSUNG 5 -#define TT_MS_ID_JOHAB 6 -#define TT_MS_ID_UCS_4 10 - - - /*********************************************************************** - * - * @enum: - * TT_ADOBE_ID_XXX - * - * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_ADOBE charmaps. This is a FreeType-specific extension! - * - * @values: - * TT_ADOBE_ID_STANDARD :: - * Adobe standard encoding. - * TT_ADOBE_ID_EXPERT :: - * Adobe expert encoding. - * TT_ADOBE_ID_CUSTOM :: - * Adobe custom encoding. - * TT_ADOBE_ID_LATIN_1 :: - * Adobe Latin~1 encoding. - */ - -#define TT_ADOBE_ID_STANDARD 0 -#define TT_ADOBE_ID_EXPERT 1 -#define TT_ADOBE_ID_CUSTOM 2 -#define TT_ADOBE_ID_LATIN_1 3 - - - /*************************************************************************/ - /* */ - /* Possible values of the language identifier field in the name records */ - /* of the TTF `name' table if the `platform' identifier code is */ - /* TT_PLATFORM_MACINTOSH. These values are also used as return values */ - /* for function @FT_Get_CMap_Language_ID. */ - /* */ - /* The canonical source for the Apple assigned Language ID's is at */ - /* */ - /* https://developer.apple.com/fonts/TTRefMan/RM06/Chap6name.html */ - /* */ -#define TT_MAC_LANGID_ENGLISH 0 -#define TT_MAC_LANGID_FRENCH 1 -#define TT_MAC_LANGID_GERMAN 2 -#define TT_MAC_LANGID_ITALIAN 3 -#define TT_MAC_LANGID_DUTCH 4 -#define TT_MAC_LANGID_SWEDISH 5 -#define TT_MAC_LANGID_SPANISH 6 -#define TT_MAC_LANGID_DANISH 7 -#define TT_MAC_LANGID_PORTUGUESE 8 -#define TT_MAC_LANGID_NORWEGIAN 9 -#define TT_MAC_LANGID_HEBREW 10 -#define TT_MAC_LANGID_JAPANESE 11 -#define TT_MAC_LANGID_ARABIC 12 -#define TT_MAC_LANGID_FINNISH 13 -#define TT_MAC_LANGID_GREEK 14 -#define TT_MAC_LANGID_ICELANDIC 15 -#define TT_MAC_LANGID_MALTESE 16 -#define TT_MAC_LANGID_TURKISH 17 -#define TT_MAC_LANGID_CROATIAN 18 -#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19 -#define TT_MAC_LANGID_URDU 20 -#define TT_MAC_LANGID_HINDI 21 -#define TT_MAC_LANGID_THAI 22 -#define TT_MAC_LANGID_KOREAN 23 -#define TT_MAC_LANGID_LITHUANIAN 24 -#define TT_MAC_LANGID_POLISH 25 -#define TT_MAC_LANGID_HUNGARIAN 26 -#define TT_MAC_LANGID_ESTONIAN 27 -#define TT_MAC_LANGID_LETTISH 28 -#define TT_MAC_LANGID_SAAMISK 29 -#define TT_MAC_LANGID_FAEROESE 30 -#define TT_MAC_LANGID_FARSI 31 -#define TT_MAC_LANGID_RUSSIAN 32 -#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33 -#define TT_MAC_LANGID_FLEMISH 34 -#define TT_MAC_LANGID_IRISH 35 -#define TT_MAC_LANGID_ALBANIAN 36 -#define TT_MAC_LANGID_ROMANIAN 37 -#define TT_MAC_LANGID_CZECH 38 -#define TT_MAC_LANGID_SLOVAK 39 -#define TT_MAC_LANGID_SLOVENIAN 40 -#define TT_MAC_LANGID_YIDDISH 41 -#define TT_MAC_LANGID_SERBIAN 42 -#define TT_MAC_LANGID_MACEDONIAN 43 -#define TT_MAC_LANGID_BULGARIAN 44 -#define TT_MAC_LANGID_UKRAINIAN 45 -#define TT_MAC_LANGID_BYELORUSSIAN 46 -#define TT_MAC_LANGID_UZBEK 47 -#define TT_MAC_LANGID_KAZAKH 48 -#define TT_MAC_LANGID_AZERBAIJANI 49 -#define TT_MAC_LANGID_AZERBAIJANI_CYRILLIC_SCRIPT 49 -#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50 -#define TT_MAC_LANGID_ARMENIAN 51 -#define TT_MAC_LANGID_GEORGIAN 52 -#define TT_MAC_LANGID_MOLDAVIAN 53 -#define TT_MAC_LANGID_KIRGHIZ 54 -#define TT_MAC_LANGID_TAJIKI 55 -#define TT_MAC_LANGID_TURKMEN 56 -#define TT_MAC_LANGID_MONGOLIAN 57 -#define TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT 57 -#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58 -#define TT_MAC_LANGID_PASHTO 59 -#define TT_MAC_LANGID_KURDISH 60 -#define TT_MAC_LANGID_KASHMIRI 61 -#define TT_MAC_LANGID_SINDHI 62 -#define TT_MAC_LANGID_TIBETAN 63 -#define TT_MAC_LANGID_NEPALI 64 -#define TT_MAC_LANGID_SANSKRIT 65 -#define TT_MAC_LANGID_MARATHI 66 -#define TT_MAC_LANGID_BENGALI 67 -#define TT_MAC_LANGID_ASSAMESE 68 -#define TT_MAC_LANGID_GUJARATI 69 -#define TT_MAC_LANGID_PUNJABI 70 -#define TT_MAC_LANGID_ORIYA 71 -#define TT_MAC_LANGID_MALAYALAM 72 -#define TT_MAC_LANGID_KANNADA 73 -#define TT_MAC_LANGID_TAMIL 74 -#define TT_MAC_LANGID_TELUGU 75 -#define TT_MAC_LANGID_SINHALESE 76 -#define TT_MAC_LANGID_BURMESE 77 -#define TT_MAC_LANGID_KHMER 78 -#define TT_MAC_LANGID_LAO 79 -#define TT_MAC_LANGID_VIETNAMESE 80 -#define TT_MAC_LANGID_INDONESIAN 81 -#define TT_MAC_LANGID_TAGALOG 82 -#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83 -#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84 -#define TT_MAC_LANGID_AMHARIC 85 -#define TT_MAC_LANGID_TIGRINYA 86 -#define TT_MAC_LANGID_GALLA 87 -#define TT_MAC_LANGID_SOMALI 88 -#define TT_MAC_LANGID_SWAHILI 89 -#define TT_MAC_LANGID_RUANDA 90 -#define TT_MAC_LANGID_RUNDI 91 -#define TT_MAC_LANGID_CHEWA 92 -#define TT_MAC_LANGID_MALAGASY 93 -#define TT_MAC_LANGID_ESPERANTO 94 -#define TT_MAC_LANGID_WELSH 128 -#define TT_MAC_LANGID_BASQUE 129 -#define TT_MAC_LANGID_CATALAN 130 -#define TT_MAC_LANGID_LATIN 131 -#define TT_MAC_LANGID_QUECHUA 132 -#define TT_MAC_LANGID_GUARANI 133 -#define TT_MAC_LANGID_AYMARA 134 -#define TT_MAC_LANGID_TATAR 135 -#define TT_MAC_LANGID_UIGHUR 136 -#define TT_MAC_LANGID_DZONGKHA 137 -#define TT_MAC_LANGID_JAVANESE 138 -#define TT_MAC_LANGID_SUNDANESE 139 - - -#if 0 /* these seem to be errors that have been dropped */ - -#define TT_MAC_LANGID_SCOTTISH_GAELIC 140 -#define TT_MAC_LANGID_IRISH_GAELIC 141 - -#endif - - - /* The following codes are new as of 2000-03-10 */ -#define TT_MAC_LANGID_GALICIAN 140 -#define TT_MAC_LANGID_AFRIKAANS 141 -#define TT_MAC_LANGID_BRETON 142 -#define TT_MAC_LANGID_INUKTITUT 143 -#define TT_MAC_LANGID_SCOTTISH_GAELIC 144 -#define TT_MAC_LANGID_MANX_GAELIC 145 -#define TT_MAC_LANGID_IRISH_GAELIC 146 -#define TT_MAC_LANGID_TONGAN 147 -#define TT_MAC_LANGID_GREEK_POLYTONIC 148 -#define TT_MAC_LANGID_GREELANDIC 149 -#define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150 - - - /*************************************************************************/ - /* */ - /* Possible values of the language identifier field in the name records */ - /* of the TTF `name' table if the `platform' identifier code is */ - /* TT_PLATFORM_MICROSOFT. */ - /* */ - /* The canonical source for the MS assigned LCIDs is */ - /* */ - /* http://www.microsoft.com/globaldev/reference/lcid-all.mspx */ - /* */ - -#define TT_MS_LANGID_ARABIC_GENERAL 0x0001 -#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401 -#define TT_MS_LANGID_ARABIC_IRAQ 0x0801 -#define TT_MS_LANGID_ARABIC_EGYPT 0x0c01 -#define TT_MS_LANGID_ARABIC_LIBYA 0x1001 -#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401 -#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801 -#define TT_MS_LANGID_ARABIC_TUNISIA 0x1c01 -#define TT_MS_LANGID_ARABIC_OMAN 0x2001 -#define TT_MS_LANGID_ARABIC_YEMEN 0x2401 -#define TT_MS_LANGID_ARABIC_SYRIA 0x2801 -#define TT_MS_LANGID_ARABIC_JORDAN 0x2c01 -#define TT_MS_LANGID_ARABIC_LEBANON 0x3001 -#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401 -#define TT_MS_LANGID_ARABIC_UAE 0x3801 -#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3c01 -#define TT_MS_LANGID_ARABIC_QATAR 0x4001 -#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402 -#define TT_MS_LANGID_CATALAN_SPAIN 0x0403 -#define TT_MS_LANGID_CHINESE_GENERAL 0x0004 -#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404 -#define TT_MS_LANGID_CHINESE_PRC 0x0804 -#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0c04 -#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004 - -#if 1 /* this looks like the correct value */ -#define TT_MS_LANGID_CHINESE_MACAU 0x1404 -#else /* but beware, Microsoft may change its mind... - the most recent Word reference has the following: */ -#define TT_MS_LANGID_CHINESE_MACAU TT_MS_LANGID_CHINESE_HONG_KONG -#endif - -#if 0 /* used only with .NET `cultures'; commented out */ -#define TT_MS_LANGID_CHINESE_TRADITIONAL 0x7C04 -#endif - -#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405 -#define TT_MS_LANGID_DANISH_DENMARK 0x0406 -#define TT_MS_LANGID_GERMAN_GERMANY 0x0407 -#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807 -#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0c07 -#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007 -#define TT_MS_LANGID_GERMAN_LIECHTENSTEI 0x1407 -#define TT_MS_LANGID_GREEK_GREECE 0x0408 - - /* don't ask what this one means... It is commented out currently. */ -#if 0 -#define TT_MS_LANGID_GREEK_GREECE2 0x2008 -#endif - -#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009 -#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409 -#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809 -#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0c09 -#define TT_MS_LANGID_ENGLISH_CANADA 0x1009 -#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409 -#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809 -#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1c09 -#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009 -#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409 -#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809 -#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2c09 -#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009 -#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409 -#define TT_MS_LANGID_ENGLISH_INDONESIA 0x3809 -#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3c09 -#define TT_MS_LANGID_ENGLISH_INDIA 0x4009 -#define TT_MS_LANGID_ENGLISH_MALAYSIA 0x4409 -#define TT_MS_LANGID_ENGLISH_SINGAPORE 0x4809 -#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040a -#define TT_MS_LANGID_SPANISH_MEXICO 0x080a -#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT 0x0c0a -#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100a -#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140a -#define TT_MS_LANGID_SPANISH_PANAMA 0x180a -#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1c0a -#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200a -#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240a -#define TT_MS_LANGID_SPANISH_PERU 0x280a -#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2c0a -#define TT_MS_LANGID_SPANISH_ECUADOR 0x300a -#define TT_MS_LANGID_SPANISH_CHILE 0x340a -#define TT_MS_LANGID_SPANISH_URUGUAY 0x380a -#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3c0a -#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400a -#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440a -#define TT_MS_LANGID_SPANISH_HONDURAS 0x480a -#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4c0a -#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500a -#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540a - /* The following ID blatantly violate MS specs by using a */ - /* sublanguage > 0x1F. */ -#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40aU -#define TT_MS_LANGID_FINNISH_FINLAND 0x040b -#define TT_MS_LANGID_FRENCH_FRANCE 0x040c -#define TT_MS_LANGID_FRENCH_BELGIUM 0x080c -#define TT_MS_LANGID_FRENCH_CANADA 0x0c0c -#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100c -#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140c -#define TT_MS_LANGID_FRENCH_MONACO 0x180c -#define TT_MS_LANGID_FRENCH_WEST_INDIES 0x1c0c -#define TT_MS_LANGID_FRENCH_REUNION 0x200c -#define TT_MS_LANGID_FRENCH_CONGO 0x240c - /* which was formerly: */ -#define TT_MS_LANGID_FRENCH_ZAIRE TT_MS_LANGID_FRENCH_CONGO -#define TT_MS_LANGID_FRENCH_SENEGAL 0x280c -#define TT_MS_LANGID_FRENCH_CAMEROON 0x2c0c -#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE 0x300c -#define TT_MS_LANGID_FRENCH_MALI 0x340c -#define TT_MS_LANGID_FRENCH_MOROCCO 0x380c -#define TT_MS_LANGID_FRENCH_HAITI 0x3c0c - /* and another violation of the spec (see 0xE40aU) */ -#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40cU -#define TT_MS_LANGID_HEBREW_ISRAEL 0x040d -#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040e -#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040f -#define TT_MS_LANGID_ITALIAN_ITALY 0x0410 -#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810 -#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411 -#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA 0x0412 -#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812 -#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413 -#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813 -#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414 -#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814 -#define TT_MS_LANGID_POLISH_POLAND 0x0415 -#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416 -#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816 -#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND 0x0417 -#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418 -#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818 -#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419 -#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819 -#define TT_MS_LANGID_CROATIAN_CROATIA 0x041a -#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081a -#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0c1a - -#if 0 /* this used to be this value, but it looks like we were wrong */ -#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x101a -#else /* current sources say */ -#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA 0x101a -#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x141a - /* and XPsp2 Platform SDK added (2004-07-26) */ - /* Names are shortened to be significant within 40 chars. */ -#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN 0x181a -#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC 0x181a -#endif - -#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041b -#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041c -#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041d -#define TT_MS_LANGID_SWEDISH_FINLAND 0x081d -#define TT_MS_LANGID_THAI_THAILAND 0x041e -#define TT_MS_LANGID_TURKISH_TURKEY 0x041f -#define TT_MS_LANGID_URDU_PAKISTAN 0x0420 -#define TT_MS_LANGID_URDU_INDIA 0x0820 -#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421 -#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422 -#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423 -#define TT_MS_LANGID_SLOVENE_SLOVENIA 0x0424 -#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425 -#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426 -#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427 -#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827 -#define TT_MS_LANGID_TAJIK_TAJIKISTAN 0x0428 -#define TT_MS_LANGID_FARSI_IRAN 0x0429 -#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042a -#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042b -#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042c -#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082c -#define TT_MS_LANGID_BASQUE_SPAIN 0x042d -#define TT_MS_LANGID_SORBIAN_GERMANY 0x042e -#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042f -#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430 -#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431 -#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA 0x0432 -#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433 -#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA 0x0434 -#define TT_MS_LANGID_ZULU_SOUTH_AFRICA 0x0435 -#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436 -#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437 -#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438 -#define TT_MS_LANGID_HINDI_INDIA 0x0439 -#define TT_MS_LANGID_MALTESE_MALTA 0x043a - /* Added by XPsp2 Platform SDK (2004-07-26) */ -#define TT_MS_LANGID_SAMI_NORTHERN_NORWAY 0x043b -#define TT_MS_LANGID_SAMI_NORTHERN_SWEDEN 0x083b -#define TT_MS_LANGID_SAMI_NORTHERN_FINLAND 0x0C3b -#define TT_MS_LANGID_SAMI_LULE_NORWAY 0x103b -#define TT_MS_LANGID_SAMI_LULE_SWEDEN 0x143b -#define TT_MS_LANGID_SAMI_SOUTHERN_NORWAY 0x183b -#define TT_MS_LANGID_SAMI_SOUTHERN_SWEDEN 0x1C3b -#define TT_MS_LANGID_SAMI_SKOLT_FINLAND 0x203b -#define TT_MS_LANGID_SAMI_INARI_FINLAND 0x243b - /* ... and we also keep our old identifier... */ -#define TT_MS_LANGID_SAAMI_LAPONIA 0x043b - -#if 0 /* this seems to be a previous inversion */ -#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043c -#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083c -#else -#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083c -#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043c -#endif - -#define TT_MS_LANGID_YIDDISH_GERMANY 0x043d -#define TT_MS_LANGID_MALAY_MALAYSIA 0x043e -#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083e -#define TT_MS_LANGID_KAZAK_KAZAKSTAN 0x043f -#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN /* Cyrillic*/ 0x0440 - /* alias declared in Windows 2000 */ -#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \ - TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN - -#define TT_MS_LANGID_SWAHILI_KENYA 0x0441 -#define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442 -#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443 -#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843 -#define TT_MS_LANGID_TATAR_TATARSTAN 0x0444 -#define TT_MS_LANGID_BENGALI_INDIA 0x0445 -#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845 -#define TT_MS_LANGID_PUNJABI_INDIA 0x0446 -#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846 -#define TT_MS_LANGID_GUJARATI_INDIA 0x0447 -#define TT_MS_LANGID_ORIYA_INDIA 0x0448 -#define TT_MS_LANGID_TAMIL_INDIA 0x0449 -#define TT_MS_LANGID_TELUGU_INDIA 0x044a -#define TT_MS_LANGID_KANNADA_INDIA 0x044b -#define TT_MS_LANGID_MALAYALAM_INDIA 0x044c -#define TT_MS_LANGID_ASSAMESE_INDIA 0x044d -#define TT_MS_LANGID_MARATHI_INDIA 0x044e -#define TT_MS_LANGID_SANSKRIT_INDIA 0x044f -#define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450 -#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN 0x0850 -#define TT_MS_LANGID_TIBETAN_CHINA 0x0451 - /* Don't use the next constant! It has */ - /* (1) the wrong spelling (Dzonghka) */ - /* (2) Microsoft doesn't officially define it -- */ - /* at least it is not in the List of Local */ - /* ID Values. */ - /* (3) Dzongkha is not the same language as */ - /* Tibetan, so merging it is wrong anyway. */ - /* */ - /* TT_MS_LANGID_TIBETAN_BHUTAN is correct, BTW. */ -#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851 - -#if 0 - /* the following used to be defined */ -#define TT_MS_LANGID_TIBETAN_BHUTAN 0x0451 - /* ... but it was changed; */ -#else - /* So we will continue to #define it, but with the correct value */ -#define TT_MS_LANGID_TIBETAN_BHUTAN TT_MS_LANGID_DZONGHKA_BHUTAN -#endif - -#define TT_MS_LANGID_WELSH_WALES 0x0452 -#define TT_MS_LANGID_KHMER_CAMBODIA 0x0453 -#define TT_MS_LANGID_LAO_LAOS 0x0454 -#define TT_MS_LANGID_BURMESE_MYANMAR 0x0455 -#define TT_MS_LANGID_GALICIAN_SPAIN 0x0456 -#define TT_MS_LANGID_KONKANI_INDIA 0x0457 -#define TT_MS_LANGID_MANIPURI_INDIA /* Bengali */ 0x0458 -#define TT_MS_LANGID_SINDHI_INDIA /* Arabic */ 0x0459 -#define TT_MS_LANGID_SINDHI_PAKISTAN 0x0859 - /* Missing a LCID for Sindhi in Devanagari script */ -#define TT_MS_LANGID_SYRIAC_SYRIA 0x045a -#define TT_MS_LANGID_SINHALESE_SRI_LANKA 0x045b -#define TT_MS_LANGID_CHEROKEE_UNITED_STATES 0x045c -#define TT_MS_LANGID_INUKTITUT_CANADA 0x045d -#define TT_MS_LANGID_AMHARIC_ETHIOPIA 0x045e -#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */ 0x045f -#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN 0x085f - /* Missing a LCID for Tifinagh script */ -#define TT_MS_LANGID_KASHMIRI_PAKISTAN /* Arabic */ 0x0460 - /* Spelled this way by XPsp2 Platform SDK (2004-07-26) */ - /* script is yet unclear... might be Arabic, Nagari or Sharada */ -#define TT_MS_LANGID_KASHMIRI_SASIA 0x0860 - /* ... and aliased (by MS) for compatibility reasons. */ -#define TT_MS_LANGID_KASHMIRI_INDIA TT_MS_LANGID_KASHMIRI_SASIA -#define TT_MS_LANGID_NEPALI_NEPAL 0x0461 -#define TT_MS_LANGID_NEPALI_INDIA 0x0861 -#define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462 -#define TT_MS_LANGID_PASHTO_AFGHANISTAN 0x0463 -#define TT_MS_LANGID_FILIPINO_PHILIPPINES 0x0464 -#define TT_MS_LANGID_DHIVEHI_MALDIVES 0x0465 - /* alias declared in Windows 2000 */ -#define TT_MS_LANGID_DIVEHI_MALDIVES TT_MS_LANGID_DHIVEHI_MALDIVES -#define TT_MS_LANGID_EDO_NIGERIA 0x0466 -#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467 -#define TT_MS_LANGID_HAUSA_NIGERIA 0x0468 -#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469 -#define TT_MS_LANGID_YORUBA_NIGERIA 0x046a -#define TT_MS_LANGID_QUECHUA_BOLIVIA 0x046b -#define TT_MS_LANGID_QUECHUA_ECUADOR 0x086b -#define TT_MS_LANGID_QUECHUA_PERU 0x0c6b -#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA 0x046c - /* Also spelled by XPsp2 Platform SDK (2004-07-26) */ -#define TT_MS_LANGID_SOTHO_SOUTHERN_SOUTH_AFRICA \ - TT_MS_LANGID_SEPEDI_SOUTH_AFRICA - /* language codes 0x046d, 0x046e and 0x046f are (still) unknown. */ -#define TT_MS_LANGID_IGBO_NIGERIA 0x0470 -#define TT_MS_LANGID_KANURI_NIGERIA 0x0471 -#define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472 -#define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473 -#define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873 - /* also spelled in the `Passport SDK' list as: */ -#define TT_MS_LANGID_TIGRIGNA_ERYTREA TT_MS_LANGID_TIGRIGNA_ERYTHREA -#define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474 -#define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475 -#define TT_MS_LANGID_LATIN 0x0476 -#define TT_MS_LANGID_SOMALI_SOMALIA 0x0477 - /* Note: Yi does not have a (proper) ISO 639-2 code, since it is mostly */ - /* not written (but OTOH the peculiar writing system is worth */ - /* studying). */ -#define TT_MS_LANGID_YI_CHINA 0x0478 -#define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479 - /* language codes from 0x047a to 0x047f are (still) unknown. */ -#define TT_MS_LANGID_UIGHUR_CHINA 0x0480 -#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0481 - -#if 0 /* not deemed useful for fonts */ -#define TT_MS_LANGID_HUMAN_INTERFACE_DEVICE 0x04ff -#endif - - - /*************************************************************************/ - /* */ - /* Possible values of the `name' identifier field in the name records of */ - /* the TTF `name' table. These values are platform independent. */ - /* */ -#define TT_NAME_ID_COPYRIGHT 0 -#define TT_NAME_ID_FONT_FAMILY 1 -#define TT_NAME_ID_FONT_SUBFAMILY 2 -#define TT_NAME_ID_UNIQUE_ID 3 -#define TT_NAME_ID_FULL_NAME 4 -#define TT_NAME_ID_VERSION_STRING 5 -#define TT_NAME_ID_PS_NAME 6 -#define TT_NAME_ID_TRADEMARK 7 - - /* the following values are from the OpenType spec */ -#define TT_NAME_ID_MANUFACTURER 8 -#define TT_NAME_ID_DESIGNER 9 -#define TT_NAME_ID_DESCRIPTION 10 -#define TT_NAME_ID_VENDOR_URL 11 -#define TT_NAME_ID_DESIGNER_URL 12 -#define TT_NAME_ID_LICENSE 13 -#define TT_NAME_ID_LICENSE_URL 14 - /* number 15 is reserved */ -#define TT_NAME_ID_PREFERRED_FAMILY 16 -#define TT_NAME_ID_PREFERRED_SUBFAMILY 17 -#define TT_NAME_ID_MAC_FULL_NAME 18 - - /* The following code is new as of 2000-01-21 */ -#define TT_NAME_ID_SAMPLE_TEXT 19 - - /* This is new in OpenType 1.3 */ -#define TT_NAME_ID_CID_FINDFONT_NAME 20 - - /* This is new in OpenType 1.5 */ -#define TT_NAME_ID_WWS_FAMILY 21 -#define TT_NAME_ID_WWS_SUBFAMILY 22 - - - /*************************************************************************/ - /* */ - /* Bit mask values for the Unicode Ranges from the TTF `OS2 ' table. */ - /* */ - /* Updated 08-Nov-2008. */ - /* */ - - /* Bit 0 Basic Latin */ -#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0020-U+007E */ - /* Bit 1 C1 Controls and Latin-1 Supplement */ -#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+0080-U+00FF */ - /* Bit 2 Latin Extended-A */ -#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */ - /* Bit 3 Latin Extended-B */ -#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */ - /* Bit 4 IPA Extensions */ - /* Phonetic Extensions */ - /* Phonetic Extensions Supplement */ -#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */ - /* U+1D00-U+1D7F */ - /* U+1D80-U+1DBF */ - /* Bit 5 Spacing Modifier Letters */ - /* Modifier Tone Letters */ -#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */ - /* U+A700-U+A71F */ - /* Bit 6 Combining Diacritical Marks */ - /* Combining Diacritical Marks Supplement */ -#define TT_UCR_COMBINING_DIACRITICS (1L << 6) /* U+0300-U+036F */ - /* U+1DC0-U+1DFF */ - /* Bit 7 Greek and Coptic */ -#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */ - /* Bit 8 Coptic */ -#define TT_UCR_COPTIC (1L << 8) /* U+2C80-U+2CFF */ - /* Bit 9 Cyrillic */ - /* Cyrillic Supplement */ - /* Cyrillic Extended-A */ - /* Cyrillic Extended-B */ -#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */ - /* U+0500-U+052F */ - /* U+2DE0-U+2DFF */ - /* U+A640-U+A69F */ - /* Bit 10 Armenian */ -#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */ - /* Bit 11 Hebrew */ -#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */ - /* Bit 12 Vai */ -#define TT_UCR_VAI (1L << 12) /* U+A500-U+A63F */ - /* Bit 13 Arabic */ - /* Arabic Supplement */ -#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */ - /* U+0750-U+077F */ - /* Bit 14 NKo */ -#define TT_UCR_NKO (1L << 14) /* U+07C0-U+07FF */ - /* Bit 15 Devanagari */ -#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */ - /* Bit 16 Bengali */ -#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */ - /* Bit 17 Gurmukhi */ -#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */ - /* Bit 18 Gujarati */ -#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */ - /* Bit 19 Oriya */ -#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */ - /* Bit 20 Tamil */ -#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */ - /* Bit 21 Telugu */ -#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */ - /* Bit 22 Kannada */ -#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */ - /* Bit 23 Malayalam */ -#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */ - /* Bit 24 Thai */ -#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */ - /* Bit 25 Lao */ -#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */ - /* Bit 26 Georgian */ - /* Georgian Supplement */ -#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */ - /* U+2D00-U+2D2F */ - /* Bit 27 Balinese */ -#define TT_UCR_BALINESE (1L << 27) /* U+1B00-U+1B7F */ - /* Bit 28 Hangul Jamo */ -#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */ - /* Bit 29 Latin Extended Additional */ - /* Latin Extended-C */ - /* Latin Extended-D */ -#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */ - /* U+2C60-U+2C7F */ - /* U+A720-U+A7FF */ - /* Bit 30 Greek Extended */ -#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */ - /* Bit 31 General Punctuation */ - /* Supplemental Punctuation */ -#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */ - /* U+2E00-U+2E7F */ - /* Bit 32 Superscripts And Subscripts */ -#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */ - /* Bit 33 Currency Symbols */ -#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */ - /* Bit 34 Combining Diacritical Marks For Symbols */ -#define TT_UCR_COMBINING_DIACRITICS_SYMB (1L << 2) /* U+20D0-U+20FF */ - /* Bit 35 Letterlike Symbols */ -#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */ - /* Bit 36 Number Forms */ -#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */ - /* Bit 37 Arrows */ - /* Supplemental Arrows-A */ - /* Supplemental Arrows-B */ - /* Miscellaneous Symbols and Arrows */ -#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */ - /* U+27F0-U+27FF */ - /* U+2900-U+297F */ - /* U+2B00-U+2BFF */ - /* Bit 38 Mathematical Operators */ - /* Supplemental Mathematical Operators */ - /* Miscellaneous Mathematical Symbols-A */ - /* Miscellaneous Mathematical Symbols-B */ -#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */ - /* U+2A00-U+2AFF */ - /* U+27C0-U+27EF */ - /* U+2980-U+29FF */ - /* Bit 39 Miscellaneous Technical */ -#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */ - /* Bit 40 Control Pictures */ -#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */ - /* Bit 41 Optical Character Recognition */ -#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */ - /* Bit 42 Enclosed Alphanumerics */ -#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */ - /* Bit 43 Box Drawing */ -#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */ - /* Bit 44 Block Elements */ -#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */ - /* Bit 45 Geometric Shapes */ -#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */ - /* Bit 46 Miscellaneous Symbols */ -#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */ - /* Bit 47 Dingbats */ -#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */ - /* Bit 48 CJK Symbols and Punctuation */ -#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */ - /* Bit 49 Hiragana */ -#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */ - /* Bit 50 Katakana */ - /* Katakana Phonetic Extensions */ -#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */ - /* U+31F0-U+31FF */ - /* Bit 51 Bopomofo */ - /* Bopomofo Extended */ -#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */ - /* U+31A0-U+31BF */ - /* Bit 52 Hangul Compatibility Jamo */ -#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */ - /* Bit 53 Phags-Pa */ -#define TT_UCR_CJK_MISC (1L << 21) /* U+A840-U+A87F */ -#define TT_UCR_KANBUN TT_UCR_CJK_MISC /* deprecated */ -#define TT_UCR_PHAGSPA - /* Bit 54 Enclosed CJK Letters and Months */ -#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */ - /* Bit 55 CJK Compatibility */ -#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */ - /* Bit 56 Hangul Syllables */ -#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */ - /* Bit 57 High Surrogates */ - /* High Private Use Surrogates */ - /* Low Surrogates */ - /* */ - /* According to OpenType specs v.1.3+, */ - /* setting bit 57 implies that there is */ - /* at least one codepoint beyond the */ - /* Basic Multilingual Plane that is */ - /* supported by this font. So it really */ - /* means >= U+10000 */ -#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DB7F */ - /* U+DB80-U+DBFF */ - /* U+DC00-U+DFFF */ -#define TT_UCR_NON_PLANE_0 TT_UCR_SURROGATES - /* Bit 58 Phoenician */ -#define TT_UCR_PHOENICIAN (1L << 26) /*U+10900-U+1091F*/ - /* Bit 59 CJK Unified Ideographs */ - /* CJK Radicals Supplement */ - /* Kangxi Radicals */ - /* Ideographic Description Characters */ - /* CJK Unified Ideographs Extension A */ - /* CJK Unified Ideographs Extension B */ - /* Kanbun */ -#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */ - /* U+2E80-U+2EFF */ - /* U+2F00-U+2FDF */ - /* U+2FF0-U+2FFF */ - /* U+3400-U+4DB5 */ - /*U+20000-U+2A6DF*/ - /* U+3190-U+319F */ - /* Bit 60 Private Use */ -#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */ - /* Bit 61 CJK Strokes */ - /* CJK Compatibility Ideographs */ - /* CJK Compatibility Ideographs Supplement */ -#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+31C0-U+31EF */ - /* U+F900-U+FAFF */ - /*U+2F800-U+2FA1F*/ - /* Bit 62 Alphabetic Presentation Forms */ -#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */ - /* Bit 63 Arabic Presentation Forms-A */ -#define TT_UCR_ARABIC_PRESENTATIONS_A (1L << 31) /* U+FB50-U+FDFF */ - /* Bit 64 Combining Half Marks */ -#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */ - /* Bit 65 Vertical forms */ - /* CJK Compatibility Forms */ -#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE10-U+FE1F */ - /* U+FE30-U+FE4F */ - /* Bit 66 Small Form Variants */ -#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */ - /* Bit 67 Arabic Presentation Forms-B */ -#define TT_UCR_ARABIC_PRESENTATIONS_B (1L << 3) /* U+FE70-U+FEFE */ - /* Bit 68 Halfwidth and Fullwidth Forms */ -#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */ - /* Bit 69 Specials */ -#define TT_UCR_SPECIALS (1L << 5) /* U+FFF0-U+FFFD */ - /* Bit 70 Tibetan */ -#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FFF */ - /* Bit 71 Syriac */ -#define TT_UCR_SYRIAC (1L << 7) /* U+0700-U+074F */ - /* Bit 72 Thaana */ -#define TT_UCR_THAANA (1L << 8) /* U+0780-U+07BF */ - /* Bit 73 Sinhala */ -#define TT_UCR_SINHALA (1L << 9) /* U+0D80-U+0DFF */ - /* Bit 74 Myanmar */ -#define TT_UCR_MYANMAR (1L << 10) /* U+1000-U+109F */ - /* Bit 75 Ethiopic */ - /* Ethiopic Supplement */ - /* Ethiopic Extended */ -#define TT_UCR_ETHIOPIC (1L << 11) /* U+1200-U+137F */ - /* U+1380-U+139F */ - /* U+2D80-U+2DDF */ - /* Bit 76 Cherokee */ -#define TT_UCR_CHEROKEE (1L << 12) /* U+13A0-U+13FF */ - /* Bit 77 Unified Canadian Aboriginal Syllabics */ -#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS (1L << 13) /* U+1400-U+167F */ - /* Bit 78 Ogham */ -#define TT_UCR_OGHAM (1L << 14) /* U+1680-U+169F */ - /* Bit 79 Runic */ -#define TT_UCR_RUNIC (1L << 15) /* U+16A0-U+16FF */ - /* Bit 80 Khmer */ - /* Khmer Symbols */ -#define TT_UCR_KHMER (1L << 16) /* U+1780-U+17FF */ - /* U+19E0-U+19FF */ - /* Bit 81 Mongolian */ -#define TT_UCR_MONGOLIAN (1L << 17) /* U+1800-U+18AF */ - /* Bit 82 Braille Patterns */ -#define TT_UCR_BRAILLE (1L << 18) /* U+2800-U+28FF */ - /* Bit 83 Yi Syllables */ - /* Yi Radicals */ -#define TT_UCR_YI (1L << 19) /* U+A000-U+A48F */ - /* U+A490-U+A4CF */ - /* Bit 84 Tagalog */ - /* Hanunoo */ - /* Buhid */ - /* Tagbanwa */ -#define TT_UCR_PHILIPPINE (1L << 20) /* U+1700-U+171F */ - /* U+1720-U+173F */ - /* U+1740-U+175F */ - /* U+1760-U+177F */ - /* Bit 85 Old Italic */ -#define TT_UCR_OLD_ITALIC (1L << 21) /*U+10300-U+1032F*/ - /* Bit 86 Gothic */ -#define TT_UCR_GOTHIC (1L << 22) /*U+10330-U+1034F*/ - /* Bit 87 Deseret */ -#define TT_UCR_DESERET (1L << 23) /*U+10400-U+1044F*/ - /* Bit 88 Byzantine Musical Symbols */ - /* Musical Symbols */ - /* Ancient Greek Musical Notation */ -#define TT_UCR_MUSICAL_SYMBOLS (1L << 24) /*U+1D000-U+1D0FF*/ - /*U+1D100-U+1D1FF*/ - /*U+1D200-U+1D24F*/ - /* Bit 89 Mathematical Alphanumeric Symbols */ -#define TT_UCR_MATH_ALPHANUMERIC_SYMBOLS (1L << 25) /*U+1D400-U+1D7FF*/ - /* Bit 90 Private Use (plane 15) */ - /* Private Use (plane 16) */ -#define TT_UCR_PRIVATE_USE_SUPPLEMENTARY (1L << 26) /*U+F0000-U+FFFFD*/ - /*U+100000-U+10FFFD*/ - /* Bit 91 Variation Selectors */ - /* Variation Selectors Supplement */ -#define TT_UCR_VARIATION_SELECTORS (1L << 27) /* U+FE00-U+FE0F */ - /*U+E0100-U+E01EF*/ - /* Bit 92 Tags */ -#define TT_UCR_TAGS (1L << 28) /*U+E0000-U+E007F*/ - /* Bit 93 Limbu */ -#define TT_UCR_LIMBU (1L << 29) /* U+1900-U+194F */ - /* Bit 94 Tai Le */ -#define TT_UCR_TAI_LE (1L << 30) /* U+1950-U+197F */ - /* Bit 95 New Tai Lue */ -#define TT_UCR_NEW_TAI_LUE (1L << 31) /* U+1980-U+19DF */ - /* Bit 96 Buginese */ -#define TT_UCR_BUGINESE (1L << 0) /* U+1A00-U+1A1F */ - /* Bit 97 Glagolitic */ -#define TT_UCR_GLAGOLITIC (1L << 1) /* U+2C00-U+2C5F */ - /* Bit 98 Tifinagh */ -#define TT_UCR_TIFINAGH (1L << 2) /* U+2D30-U+2D7F */ - /* Bit 99 Yijing Hexagram Symbols */ -#define TT_UCR_YIJING (1L << 3) /* U+4DC0-U+4DFF */ - /* Bit 100 Syloti Nagri */ -#define TT_UCR_SYLOTI_NAGRI (1L << 4) /* U+A800-U+A82F */ - /* Bit 101 Linear B Syllabary */ - /* Linear B Ideograms */ - /* Aegean Numbers */ -#define TT_UCR_LINEAR_B (1L << 5) /*U+10000-U+1007F*/ - /*U+10080-U+100FF*/ - /*U+10100-U+1013F*/ - /* Bit 102 Ancient Greek Numbers */ -#define TT_UCR_ANCIENT_GREEK_NUMBERS (1L << 6) /*U+10140-U+1018F*/ - /* Bit 103 Ugaritic */ -#define TT_UCR_UGARITIC (1L << 7) /*U+10380-U+1039F*/ - /* Bit 104 Old Persian */ -#define TT_UCR_OLD_PERSIAN (1L << 8) /*U+103A0-U+103DF*/ - /* Bit 105 Shavian */ -#define TT_UCR_SHAVIAN (1L << 9) /*U+10450-U+1047F*/ - /* Bit 106 Osmanya */ -#define TT_UCR_OSMANYA (1L << 10) /*U+10480-U+104AF*/ - /* Bit 107 Cypriot Syllabary */ -#define TT_UCR_CYPRIOT_SYLLABARY (1L << 11) /*U+10800-U+1083F*/ - /* Bit 108 Kharoshthi */ -#define TT_UCR_KHAROSHTHI (1L << 12) /*U+10A00-U+10A5F*/ - /* Bit 109 Tai Xuan Jing Symbols */ -#define TT_UCR_TAI_XUAN_JING (1L << 13) /*U+1D300-U+1D35F*/ - /* Bit 110 Cuneiform */ - /* Cuneiform Numbers and Punctuation */ -#define TT_UCR_CUNEIFORM (1L << 14) /*U+12000-U+123FF*/ - /*U+12400-U+1247F*/ - /* Bit 111 Counting Rod Numerals */ -#define TT_UCR_COUNTING_ROD_NUMERALS (1L << 15) /*U+1D360-U+1D37F*/ - /* Bit 112 Sundanese */ -#define TT_UCR_SUNDANESE (1L << 16) /* U+1B80-U+1BBF */ - /* Bit 113 Lepcha */ -#define TT_UCR_LEPCHA (1L << 17) /* U+1C00-U+1C4F */ - /* Bit 114 Ol Chiki */ -#define TT_UCR_OL_CHIKI (1L << 18) /* U+1C50-U+1C7F */ - /* Bit 115 Saurashtra */ -#define TT_UCR_SAURASHTRA (1L << 19) /* U+A880-U+A8DF */ - /* Bit 116 Kayah Li */ -#define TT_UCR_KAYAH_LI (1L << 20) /* U+A900-U+A92F */ - /* Bit 117 Rejang */ -#define TT_UCR_REJANG (1L << 21) /* U+A930-U+A95F */ - /* Bit 118 Cham */ -#define TT_UCR_CHAM (1L << 22) /* U+AA00-U+AA5F */ - /* Bit 119 Ancient Symbols */ -#define TT_UCR_ANCIENT_SYMBOLS (1L << 23) /*U+10190-U+101CF*/ - /* Bit 120 Phaistos Disc */ -#define TT_UCR_PHAISTOS_DISC (1L << 24) /*U+101D0-U+101FF*/ - /* Bit 121 Carian */ - /* Lycian */ - /* Lydian */ -#define TT_UCR_OLD_ANATOLIAN (1L << 25) /*U+102A0-U+102DF*/ - /*U+10280-U+1029F*/ - /*U+10920-U+1093F*/ - /* Bit 122 Domino Tiles */ - /* Mahjong Tiles */ -#define TT_UCR_GAME_TILES (1L << 26) /*U+1F030-U+1F09F*/ - /*U+1F000-U+1F02F*/ - /* Bit 123-127 Reserved for process-internal usage */ - - - /*************************************************************************/ - /* */ - /* Some compilers have a very limited length of identifiers. */ - /* */ -#if defined( __TURBOC__ ) && __TURBOC__ < 0x0410 || defined( __PACIFIC__ ) -#define HAVE_LIMIT_ON_IDENTS -#endif - - -#ifndef HAVE_LIMIT_ON_IDENTS - - - /*************************************************************************/ - /* */ - /* Here some alias #defines in order to be clearer. */ - /* */ - /* These are not always #defined to stay within the 31~character limit, */ - /* which some compilers have. */ - /* */ - /* Credits go to Dave Hoo <dhoo@flash.net> for pointing out that modern */ - /* Borland compilers (read: from BC++ 3.1 on) can increase this limit. */ - /* If you get a warning with such a compiler, use the -i40 switch. */ - /* */ -#define TT_UCR_ARABIC_PRESENTATION_FORMS_A \ - TT_UCR_ARABIC_PRESENTATIONS_A -#define TT_UCR_ARABIC_PRESENTATION_FORMS_B \ - TT_UCR_ARABIC_PRESENTATIONS_B - -#define TT_UCR_COMBINING_DIACRITICAL_MARKS \ - TT_UCR_COMBINING_DIACRITICS -#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \ - TT_UCR_COMBINING_DIACRITICS_SYMB - - -#endif /* !HAVE_LIMIT_ON_IDENTS */ - - -FT_END_HEADER - -#endif /* __TTNAMEID_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/tttables.h b/thirdparty/include/freetype/tttables.h deleted file mode 100644 index 9dbad5b0b..000000000 --- a/thirdparty/include/freetype/tttables.h +++ /dev/null @@ -1,787 +0,0 @@ -/***************************************************************************/ -/* */ -/* tttables.h */ -/* */ -/* Basic SFNT/TrueType tables definitions and interface */ -/* (specification only). */ -/* */ -/* Copyright 1996-2005, 2008-2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __TTTABLES_H__ -#define __TTTABLES_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /*************************************************************************/ - /* */ - /* <Section> */ - /* truetype_tables */ - /* */ - /* <Title> */ - /* TrueType Tables */ - /* */ - /* <Abstract> */ - /* TrueType specific table types and functions. */ - /* */ - /* <Description> */ - /* This section contains the definition of TrueType-specific tables */ - /* as well as some routines used to access and process them. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Header */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType font header table. All */ - /* fields follow the TrueType specification. */ - /* */ - typedef struct TT_Header_ - { - FT_Fixed Table_Version; - FT_Fixed Font_Revision; - - FT_Long CheckSum_Adjust; - FT_Long Magic_Number; - - FT_UShort Flags; - FT_UShort Units_Per_EM; - - FT_Long Created [2]; - FT_Long Modified[2]; - - FT_Short xMin; - FT_Short yMin; - FT_Short xMax; - FT_Short yMax; - - FT_UShort Mac_Style; - FT_UShort Lowest_Rec_PPEM; - - FT_Short Font_Direction; - FT_Short Index_To_Loc_Format; - FT_Short Glyph_Data_Format; - - } TT_Header; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_HoriHeader */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType horizontal header, the `hhea' */ - /* table, as well as the corresponding horizontal metrics table, */ - /* i.e., the `hmtx' table. */ - /* */ - /* <Fields> */ - /* Version :: The table version. */ - /* */ - /* Ascender :: The font's ascender, i.e., the distance */ - /* from the baseline to the top-most of all */ - /* glyph points found in the font. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of the */ - /* glyphs found in the font (maybe ASCII). */ - /* */ - /* You should use the `sTypoAscender' field */ - /* of the OS/2 table instead if you want */ - /* the correct one. */ - /* */ - /* Descender :: The font's descender, i.e., the distance */ - /* from the baseline to the bottom-most of */ - /* all glyph points found in the font. It */ - /* is negative. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of the */ - /* glyphs found in the font (maybe ASCII). */ - /* */ - /* You should use the `sTypoDescender' */ - /* field of the OS/2 table instead if you */ - /* want the correct one. */ - /* */ - /* Line_Gap :: The font's line gap, i.e., the distance */ - /* to add to the ascender and descender to */ - /* get the BTB, i.e., the */ - /* baseline-to-baseline distance for the */ - /* font. */ - /* */ - /* advance_Width_Max :: This field is the maximum of all advance */ - /* widths found in the font. It can be */ - /* used to compute the maximum width of an */ - /* arbitrary string of text. */ - /* */ - /* min_Left_Side_Bearing :: The minimum left side bearing of all */ - /* glyphs within the font. */ - /* */ - /* min_Right_Side_Bearing :: The minimum right side bearing of all */ - /* glyphs within the font. */ - /* */ - /* xMax_Extent :: The maximum horizontal extent (i.e., the */ - /* `width' of a glyph's bounding box) for */ - /* all glyphs in the font. */ - /* */ - /* caret_Slope_Rise :: The rise coefficient of the cursor's */ - /* slope of the cursor (slope=rise/run). */ - /* */ - /* caret_Slope_Run :: The run coefficient of the cursor's */ - /* slope. */ - /* */ - /* Reserved :: 8~reserved bytes. */ - /* */ - /* metric_Data_Format :: Always~0. */ - /* */ - /* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */ - /* table -- this value can be smaller than */ - /* the total number of glyphs in the font. */ - /* */ - /* long_metrics :: A pointer into the `hmtx' table. */ - /* */ - /* short_metrics :: A pointer into the `hmtx' table. */ - /* */ - /* <Note> */ - /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */ - /* be identical except for the names of their fields, */ - /* which are different. */ - /* */ - /* This ensures that a single function in the `ttload' */ - /* module is able to read both the horizontal and vertical */ - /* headers. */ - /* */ - typedef struct TT_HoriHeader_ - { - FT_Fixed Version; - FT_Short Ascender; - FT_Short Descender; - FT_Short Line_Gap; - - FT_UShort advance_Width_Max; /* advance width maximum */ - - FT_Short min_Left_Side_Bearing; /* minimum left-sb */ - FT_Short min_Right_Side_Bearing; /* minimum right-sb */ - FT_Short xMax_Extent; /* xmax extents */ - FT_Short caret_Slope_Rise; - FT_Short caret_Slope_Run; - FT_Short caret_Offset; - - FT_Short Reserved[4]; - - FT_Short metric_Data_Format; - FT_UShort number_Of_HMetrics; - - /* The following fields are not defined by the TrueType specification */ - /* but they are used to connect the metrics header to the relevant */ - /* `HMTX' table. */ - - void* long_metrics; - void* short_metrics; - - } TT_HoriHeader; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_VertHeader */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType vertical header, the `vhea' */ - /* table, as well as the corresponding vertical metrics table, i.e., */ - /* the `vmtx' table. */ - /* */ - /* <Fields> */ - /* Version :: The table version. */ - /* */ - /* Ascender :: The font's ascender, i.e., the distance */ - /* from the baseline to the top-most of */ - /* all glyph points found in the font. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of */ - /* the glyphs found in the font (maybe */ - /* ASCII). */ - /* */ - /* You should use the `sTypoAscender' */ - /* field of the OS/2 table instead if you */ - /* want the correct one. */ - /* */ - /* Descender :: The font's descender, i.e., the */ - /* distance from the baseline to the */ - /* bottom-most of all glyph points found */ - /* in the font. It is negative. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of */ - /* the glyphs found in the font (maybe */ - /* ASCII). */ - /* */ - /* You should use the `sTypoDescender' */ - /* field of the OS/2 table instead if you */ - /* want the correct one. */ - /* */ - /* Line_Gap :: The font's line gap, i.e., the distance */ - /* to add to the ascender and descender to */ - /* get the BTB, i.e., the */ - /* baseline-to-baseline distance for the */ - /* font. */ - /* */ - /* advance_Height_Max :: This field is the maximum of all */ - /* advance heights found in the font. It */ - /* can be used to compute the maximum */ - /* height of an arbitrary string of text. */ - /* */ - /* min_Top_Side_Bearing :: The minimum top side bearing of all */ - /* glyphs within the font. */ - /* */ - /* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */ - /* glyphs within the font. */ - /* */ - /* yMax_Extent :: The maximum vertical extent (i.e., the */ - /* `height' of a glyph's bounding box) for */ - /* all glyphs in the font. */ - /* */ - /* caret_Slope_Rise :: The rise coefficient of the cursor's */ - /* slope of the cursor (slope=rise/run). */ - /* */ - /* caret_Slope_Run :: The run coefficient of the cursor's */ - /* slope. */ - /* */ - /* caret_Offset :: The cursor's offset for slanted fonts. */ - /* This value is `reserved' in vmtx */ - /* version 1.0. */ - /* */ - /* Reserved :: 8~reserved bytes. */ - /* */ - /* metric_Data_Format :: Always~0. */ - /* */ - /* number_Of_HMetrics :: Number of VMetrics entries in the */ - /* `vmtx' table -- this value can be */ - /* smaller than the total number of glyphs */ - /* in the font. */ - /* */ - /* long_metrics :: A pointer into the `vmtx' table. */ - /* */ - /* short_metrics :: A pointer into the `vmtx' table. */ - /* */ - /* <Note> */ - /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */ - /* be identical except for the names of their fields, */ - /* which are different. */ - /* */ - /* This ensures that a single function in the `ttload' */ - /* module is able to read both the horizontal and vertical */ - /* headers. */ - /* */ - typedef struct TT_VertHeader_ - { - FT_Fixed Version; - FT_Short Ascender; - FT_Short Descender; - FT_Short Line_Gap; - - FT_UShort advance_Height_Max; /* advance height maximum */ - - FT_Short min_Top_Side_Bearing; /* minimum left-sb or top-sb */ - FT_Short min_Bottom_Side_Bearing; /* minimum right-sb or bottom-sb */ - FT_Short yMax_Extent; /* xmax or ymax extents */ - FT_Short caret_Slope_Rise; - FT_Short caret_Slope_Run; - FT_Short caret_Offset; - - FT_Short Reserved[4]; - - FT_Short metric_Data_Format; - FT_UShort number_Of_VMetrics; - - /* The following fields are not defined by the TrueType specification */ - /* but they're used to connect the metrics header to the relevant */ - /* `HMTX' or `VMTX' table. */ - - void* long_metrics; - void* short_metrics; - - } TT_VertHeader; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_OS2 */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType OS/2 table. All fields */ - /* comply to the OpenType specification. */ - /* */ - /* Note that we now support old Mac fonts that do not include an OS/2 */ - /* table. In this case, the `version' field is always set to 0xFFFF. */ - /* */ - typedef struct TT_OS2_ - { - FT_UShort version; /* 0x0001 - more or 0xFFFF */ - FT_Short xAvgCharWidth; - FT_UShort usWeightClass; - FT_UShort usWidthClass; - FT_Short fsType; - FT_Short ySubscriptXSize; - FT_Short ySubscriptYSize; - FT_Short ySubscriptXOffset; - FT_Short ySubscriptYOffset; - FT_Short ySuperscriptXSize; - FT_Short ySuperscriptYSize; - FT_Short ySuperscriptXOffset; - FT_Short ySuperscriptYOffset; - FT_Short yStrikeoutSize; - FT_Short yStrikeoutPosition; - FT_Short sFamilyClass; - - FT_Byte panose[10]; - - FT_ULong ulUnicodeRange1; /* Bits 0-31 */ - FT_ULong ulUnicodeRange2; /* Bits 32-63 */ - FT_ULong ulUnicodeRange3; /* Bits 64-95 */ - FT_ULong ulUnicodeRange4; /* Bits 96-127 */ - - FT_Char achVendID[4]; - - FT_UShort fsSelection; - FT_UShort usFirstCharIndex; - FT_UShort usLastCharIndex; - FT_Short sTypoAscender; - FT_Short sTypoDescender; - FT_Short sTypoLineGap; - FT_UShort usWinAscent; - FT_UShort usWinDescent; - - /* only version 1 and higher: */ - - FT_ULong ulCodePageRange1; /* Bits 0-31 */ - FT_ULong ulCodePageRange2; /* Bits 32-63 */ - - /* only version 2 and higher: */ - - FT_Short sxHeight; - FT_Short sCapHeight; - FT_UShort usDefaultChar; - FT_UShort usBreakChar; - FT_UShort usMaxContext; - - /* only version 5 and higher: */ - - FT_UShort usLowerOpticalPointSize; /* in twips (1/20th points) */ - FT_UShort usUpperOpticalPointSize; /* in twips (1/20th points) */ - - } TT_OS2; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Postscript */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType PostScript table. All fields */ - /* comply to the TrueType specification. This structure does not */ - /* reference the PostScript glyph names, which can be nevertheless */ - /* accessed with the `ttpost' module. */ - /* */ - typedef struct TT_Postscript_ - { - FT_Fixed FormatType; - FT_Fixed italicAngle; - FT_Short underlinePosition; - FT_Short underlineThickness; - FT_ULong isFixedPitch; - FT_ULong minMemType42; - FT_ULong maxMemType42; - FT_ULong minMemType1; - FT_ULong maxMemType1; - - /* Glyph names follow in the file, but we don't */ - /* load them by default. See the ttpost.c file. */ - - } TT_Postscript; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_PCLT */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType PCLT table. All fields */ - /* comply to the TrueType specification. */ - /* */ - typedef struct TT_PCLT_ - { - FT_Fixed Version; - FT_ULong FontNumber; - FT_UShort Pitch; - FT_UShort xHeight; - FT_UShort Style; - FT_UShort TypeFamily; - FT_UShort CapHeight; - FT_UShort SymbolSet; - FT_Char TypeFace[16]; - FT_Char CharacterComplement[8]; - FT_Char FileName[6]; - FT_Char StrokeWeight; - FT_Char WidthType; - FT_Byte SerifStyle; - FT_Byte Reserved; - - } TT_PCLT; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_MaxProfile */ - /* */ - /* <Description> */ - /* The maximum profile is a table containing many max values, which */ - /* can be used to pre-allocate arrays. This ensures that no memory */ - /* allocation occurs during a glyph load. */ - /* */ - /* <Fields> */ - /* version :: The version number. */ - /* */ - /* numGlyphs :: The number of glyphs in this TrueType */ - /* font. */ - /* */ - /* maxPoints :: The maximum number of points in a */ - /* non-composite TrueType glyph. See also */ - /* the structure element */ - /* `maxCompositePoints'. */ - /* */ - /* maxContours :: The maximum number of contours in a */ - /* non-composite TrueType glyph. See also */ - /* the structure element */ - /* `maxCompositeContours'. */ - /* */ - /* maxCompositePoints :: The maximum number of points in a */ - /* composite TrueType glyph. See also the */ - /* structure element `maxPoints'. */ - /* */ - /* maxCompositeContours :: The maximum number of contours in a */ - /* composite TrueType glyph. See also the */ - /* structure element `maxContours'. */ - /* */ - /* maxZones :: The maximum number of zones used for */ - /* glyph hinting. */ - /* */ - /* maxTwilightPoints :: The maximum number of points in the */ - /* twilight zone used for glyph hinting. */ - /* */ - /* maxStorage :: The maximum number of elements in the */ - /* storage area used for glyph hinting. */ - /* */ - /* maxFunctionDefs :: The maximum number of function */ - /* definitions in the TrueType bytecode for */ - /* this font. */ - /* */ - /* maxInstructionDefs :: The maximum number of instruction */ - /* definitions in the TrueType bytecode for */ - /* this font. */ - /* */ - /* maxStackElements :: The maximum number of stack elements used */ - /* during bytecode interpretation. */ - /* */ - /* maxSizeOfInstructions :: The maximum number of TrueType opcodes */ - /* used for glyph hinting. */ - /* */ - /* maxComponentElements :: The maximum number of simple (i.e., non- */ - /* composite) glyphs in a composite glyph. */ - /* */ - /* maxComponentDepth :: The maximum nesting depth of composite */ - /* glyphs. */ - /* */ - /* <Note> */ - /* This structure is only used during font loading. */ - /* */ - typedef struct TT_MaxProfile_ - { - FT_Fixed version; - FT_UShort numGlyphs; - FT_UShort maxPoints; - FT_UShort maxContours; - FT_UShort maxCompositePoints; - FT_UShort maxCompositeContours; - FT_UShort maxZones; - FT_UShort maxTwilightPoints; - FT_UShort maxStorage; - FT_UShort maxFunctionDefs; - FT_UShort maxInstructionDefs; - FT_UShort maxStackElements; - FT_UShort maxSizeOfInstructions; - FT_UShort maxComponentElements; - FT_UShort maxComponentDepth; - - } TT_MaxProfile; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Sfnt_Tag */ - /* */ - /* <Description> */ - /* An enumeration used to specify the index of an SFNT table. */ - /* Used in the @FT_Get_Sfnt_Table API function. */ - /* */ - typedef enum FT_Sfnt_Tag_ - { - ft_sfnt_head = 0, /* TT_Header */ - ft_sfnt_maxp = 1, /* TT_MaxProfile */ - ft_sfnt_os2 = 2, /* TT_OS2 */ - ft_sfnt_hhea = 3, /* TT_HoriHeader */ - ft_sfnt_vhea = 4, /* TT_VertHeader */ - ft_sfnt_post = 5, /* TT_Postscript */ - ft_sfnt_pclt = 6, /* TT_PCLT */ - - sfnt_max /* internal end mark */ - - } FT_Sfnt_Tag; - - /* */ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_Table */ - /* */ - /* <Description> */ - /* Return a pointer to a given SFNT table within a face. */ - /* */ - /* <Input> */ - /* face :: A handle to the source. */ - /* */ - /* tag :: The index of the SFNT table. */ - /* */ - /* <Return> */ - /* A type-less pointer to the table. This will be~0 in case of */ - /* error, or if the corresponding table was not found *OR* loaded */ - /* from the file. */ - /* */ - /* Use a typecast according to `tag' to access the structure */ - /* elements. */ - /* */ - /* <Note> */ - /* The table is owned by the face object and disappears with it. */ - /* */ - /* This function is only useful to access SFNT tables that are loaded */ - /* by the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for */ - /* a list. */ - /* */ - /* Here an example how to access the `vhea' table: */ - /* */ - /* { */ - /* TT_VertHeader* vert_header; */ - /* */ - /* */ - /* vert_header = */ - /* (TT_VertHeader*)FT_Get_Sfnt_Table( face, ft_sfnt_vhea ); */ - /* } */ - /* */ - FT_EXPORT( void* ) - FT_Get_Sfnt_Table( FT_Face face, - FT_Sfnt_Tag tag ); - - - /************************************************************************** - * - * @function: - * FT_Load_Sfnt_Table - * - * @description: - * Load any font table into client memory. - * - * @input: - * face :: - * A handle to the source face. - * - * tag :: - * The four-byte tag of the table to load. Use the value~0 if you want - * to access the whole font file. Otherwise, you can use one of the - * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new - * one with @FT_MAKE_TAG. - * - * offset :: - * The starting offset in the table (or file if tag == 0). - * - * @output: - * buffer :: - * The target buffer address. The client must ensure that the memory - * array is big enough to hold the data. - * - * @inout: - * length :: - * If the `length' parameter is NULL, then try to load the whole table. - * Return an error code if it fails. - * - * Else, if `*length' is~0, exit immediately while returning the - * table's (or file) full size in it. - * - * Else the number of bytes to read from the table or file, from the - * starting offset. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If you need to determine the table's length you should first call this - * function with `*length' set to~0, as in the following example: - * - * { - * FT_ULong length = 0; - * - * - * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); - * if ( error ) { ... table does not exist ... } - * - * buffer = malloc( length ); - * if ( buffer == NULL ) { ... not enough memory ... } - * - * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); - * if ( error ) { ... could not load table ... } - * } - * - * Note that structures like @TT_Header or @TT_OS2 can't be used with - * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that - * those structures depend on the processor architecture, with varying - * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian). - * - */ - FT_EXPORT( FT_Error ) - FT_Load_Sfnt_Table( FT_Face face, - FT_ULong tag, - FT_Long offset, - FT_Byte* buffer, - FT_ULong* length ); - - - /************************************************************************** - * - * @function: - * FT_Sfnt_Table_Info - * - * @description: - * Return information on an SFNT table. - * - * @input: - * face :: - * A handle to the source face. - * - * table_index :: - * The index of an SFNT table. The function returns - * FT_Err_Table_Missing for an invalid value. - * - * @inout: - * tag :: - * The name tag of the SFNT table. If the value is NULL, `table_index' - * is ignored, and `length' returns the number of SFNT tables in the - * font. - * - * @output: - * length :: - * The length of the SFNT table (or the number of SFNT tables, depending - * on `tag'). - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * While parsing fonts, FreeType handles SFNT tables with length zero as - * missing. - * - */ - FT_EXPORT( FT_Error ) - FT_Sfnt_Table_Info( FT_Face face, - FT_UInt table_index, - FT_ULong *tag, - FT_ULong *length ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_CMap_Language_ID */ - /* */ - /* <Description> */ - /* Return TrueType/sfnt specific cmap language ID. Definitions of */ - /* language ID values are in `ttnameid.h'. */ - /* */ - /* <Input> */ - /* charmap :: */ - /* The target charmap. */ - /* */ - /* <Return> */ - /* The language ID of `charmap'. If `charmap' doesn't belong to a */ - /* TrueType/sfnt face, just return~0 as the default value. */ - /* */ - /* For a format~14 cmap (to access Unicode IVS), the return value is */ - /* 0xFFFFFFFF. */ - /* */ - FT_EXPORT( FT_ULong ) - FT_Get_CMap_Language_ID( FT_CharMap charmap ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_CMap_Format */ - /* */ - /* <Description> */ - /* Return TrueType/sfnt specific cmap format. */ - /* */ - /* <Input> */ - /* charmap :: */ - /* The target charmap. */ - /* */ - /* <Return> */ - /* The format of `charmap'. If `charmap' doesn't belong to a */ - /* TrueType/sfnt face, return -1. */ - /* */ - FT_EXPORT( FT_Long ) - FT_Get_CMap_Format( FT_CharMap charmap ); - - /* */ - - -FT_END_HEADER - -#endif /* __TTTABLES_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/tttags.h b/thirdparty/include/freetype/tttags.h deleted file mode 100644 index 7d3976e00..000000000 --- a/thirdparty/include/freetype/tttags.h +++ /dev/null @@ -1,111 +0,0 @@ -/***************************************************************************/ -/* */ -/* tttags.h */ -/* */ -/* Tags for TrueType and OpenType tables (specification only). */ -/* */ -/* Copyright 1996-2001, 2004, 2005, 2007, 2008, 2013 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __TTAGS_H__ -#define __TTAGS_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - -#define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' ) -#define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' ) -#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' ) -#define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' ) -#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' ) -#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) -#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' ) -#define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' ) -#define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' ) -#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) -#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) -#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) -#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) -#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) -#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' ) -#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' ) -#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' ) -#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' ) -#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' ) -#define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' ) -#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' ) -#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' ) -#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' ) -#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' ) -#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' ) -#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' ) -#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' ) -#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' ) -#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' ) -#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' ) -#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' ) -#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' ) -#define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' ) -#define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' ) -#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' ) -#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' ) -#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' ) -#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' ) -#define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' ) -#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' ) -#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' ) -#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' ) -#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' ) -#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' ) -#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' ) -#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' ) -#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' ) -#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' ) -#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' ) -#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) -#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' ) -#define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' ) -#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' ) -#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' ) -#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' ) -#define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' ) -#define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' ) -#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' ) -#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' ) -#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' ) -#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' ) -#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' ) -#define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' ) -#define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' ) -#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' ) -#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' ) -#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' ) -#define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' ) - - -FT_END_HEADER - -#endif /* __TTAGS_H__ */ - - -/* END */ diff --git a/thirdparty/include/freetype/ttunpat.h b/thirdparty/include/freetype/ttunpat.h deleted file mode 100644 index 51e168702..000000000 --- a/thirdparty/include/freetype/ttunpat.h +++ /dev/null @@ -1,59 +0,0 @@ -/***************************************************************************/ -/* */ -/* ttunpat.h */ -/* */ -/* Definitions for the unpatented TrueType hinting system */ -/* */ -/* Copyright 2003, 2006 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* Written by Graham Asher <graham.asher@btinternet.com> */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef __TTUNPAT_H__ -#define __TTUNPAT_H__ - - -#include <freetype/ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************** - * - * @constant: - * FT_PARAM_TAG_UNPATENTED_HINTING - * - * @description: - * A constant used as the tag of an @FT_Parameter structure to indicate - * that unpatented methods only should be used by the TrueType bytecode - * interpreter for a typeface opened by @FT_Open_Face. - * - */ -#define FT_PARAM_TAG_UNPATENTED_HINTING FT_MAKE_TAG( 'u', 'n', 'p', 'a' ) - - /* */ - -FT_END_HEADER - - -#endif /* __TTUNPAT_H__ */ - - -/* END */ diff --git a/thirdparty/include/sndfile/sndfile.h b/thirdparty/include/sndfile/sndfile.h deleted file mode 100644 index d0b26deda..000000000 --- a/thirdparty/include/sndfile/sndfile.h +++ /dev/null @@ -1,666 +0,0 @@ -/* -** Copyright (C) 1999-2011Erik de Castro Lopo <erikd@mega-nerd.com> -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation; either version 2.1 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/* -** sndfile.h -- system-wide definitions -** -** API documentation is in the doc/ directory of the source code tarball -** and at http://www.mega-nerd.com/libsndfile/api.html. -*/ - -#ifndef SNDFILE_H -#define SNDFILE_H - -/* This is the version 1.0.X header file. */ -#define SNDFILE_1 - -#include <stdio.h> -#include <sys/types.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* The following file types can be read and written. -** A file type would consist of a major type (ie SF_FORMAT_WAV) bitwise -** ORed with a minor type (ie SF_FORMAT_PCM). SF_FORMAT_TYPEMASK and -** SF_FORMAT_SUBMASK can be used to separate the major and minor file -** types. -*/ - -enum -{ /* Major formats. */ - SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian default). */ - SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */ - SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */ - SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */ - SF_FORMAT_PAF = 0x050000, /* Ensoniq PARIS file format. */ - SF_FORMAT_SVX = 0x060000, /* Amiga IFF / SVX8 / SV16 format. */ - SF_FORMAT_NIST = 0x070000, /* Sphere NIST format. */ - SF_FORMAT_VOC = 0x080000, /* VOC files. */ - SF_FORMAT_IRCAM = 0x0A0000, /* Berkeley/IRCAM/CARL */ - SF_FORMAT_W64 = 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */ - SF_FORMAT_MAT4 = 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */ - SF_FORMAT_MAT5 = 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */ - SF_FORMAT_PVF = 0x0E0000, /* Portable Voice Format */ - SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */ - SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */ - SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */ - SF_FORMAT_AVR = 0x120000, /* Audio Visual Research */ - SF_FORMAT_WAVEX = 0x130000, /* MS WAVE with WAVEFORMATEX */ - SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */ - SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */ - SF_FORMAT_CAF = 0x180000, /* Core Audio File format */ - SF_FORMAT_WVE = 0x190000, /* Psion WVE format */ - SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */ - SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */ - SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */ - - /* Subtypes from here on. */ - - SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */ - SF_FORMAT_PCM_16 = 0x0002, /* Signed 16 bit data */ - SF_FORMAT_PCM_24 = 0x0003, /* Signed 24 bit data */ - SF_FORMAT_PCM_32 = 0x0004, /* Signed 32 bit data */ - - SF_FORMAT_PCM_U8 = 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */ - - SF_FORMAT_FLOAT = 0x0006, /* 32 bit float data */ - SF_FORMAT_DOUBLE = 0x0007, /* 64 bit float data */ - - SF_FORMAT_ULAW = 0x0010, /* U-Law encoded. */ - SF_FORMAT_ALAW = 0x0011, /* A-Law encoded. */ - SF_FORMAT_IMA_ADPCM = 0x0012, /* IMA ADPCM. */ - SF_FORMAT_MS_ADPCM = 0x0013, /* Microsoft ADPCM. */ - - SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */ - SF_FORMAT_VOX_ADPCM = 0x0021, /* OKI / Dialogix ADPCM */ - - SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */ - SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */ - SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */ - - SF_FORMAT_DWVW_12 = 0x0040, /* 12 bit Delta Width Variable Word encoding. */ - SF_FORMAT_DWVW_16 = 0x0041, /* 16 bit Delta Width Variable Word encoding. */ - SF_FORMAT_DWVW_24 = 0x0042, /* 24 bit Delta Width Variable Word encoding. */ - SF_FORMAT_DWVW_N = 0x0043, /* N bit Delta Width Variable Word encoding. */ - - SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */ - SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */ - - SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */ - - /* Endian-ness options. */ - - SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */ - SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */ - SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */ - SF_ENDIAN_CPU = 0x30000000, /* Force CPU endian-ness. */ - - SF_FORMAT_SUBMASK = 0x0000FFFF, - SF_FORMAT_TYPEMASK = 0x0FFF0000, - SF_FORMAT_ENDMASK = 0x30000000 -} ; - -/* -** The following are the valid command numbers for the sf_command() -** interface. The use of these commands is documented in the file -** command.html in the doc directory of the source code distribution. -*/ - -enum -{ SFC_GET_LIB_VERSION = 0x1000, - SFC_GET_LOG_INFO = 0x1001, - SFC_GET_CURRENT_SF_INFO = 0x1002, - - - SFC_GET_NORM_DOUBLE = 0x1010, - SFC_GET_NORM_FLOAT = 0x1011, - SFC_SET_NORM_DOUBLE = 0x1012, - SFC_SET_NORM_FLOAT = 0x1013, - SFC_SET_SCALE_FLOAT_INT_READ = 0x1014, - SFC_SET_SCALE_INT_FLOAT_WRITE = 0x1015, - - SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020, - SFC_GET_SIMPLE_FORMAT = 0x1021, - - SFC_GET_FORMAT_INFO = 0x1028, - - SFC_GET_FORMAT_MAJOR_COUNT = 0x1030, - SFC_GET_FORMAT_MAJOR = 0x1031, - SFC_GET_FORMAT_SUBTYPE_COUNT = 0x1032, - SFC_GET_FORMAT_SUBTYPE = 0x1033, - - SFC_CALC_SIGNAL_MAX = 0x1040, - SFC_CALC_NORM_SIGNAL_MAX = 0x1041, - SFC_CALC_MAX_ALL_CHANNELS = 0x1042, - SFC_CALC_NORM_MAX_ALL_CHANNELS = 0x1043, - SFC_GET_SIGNAL_MAX = 0x1044, - SFC_GET_MAX_ALL_CHANNELS = 0x1045, - - SFC_SET_ADD_PEAK_CHUNK = 0x1050, - SFC_SET_ADD_HEADER_PAD_CHUNK = 0x1051, - - SFC_UPDATE_HEADER_NOW = 0x1060, - SFC_SET_UPDATE_HEADER_AUTO = 0x1061, - - SFC_FILE_TRUNCATE = 0x1080, - - SFC_SET_RAW_START_OFFSET = 0x1090, - - SFC_SET_DITHER_ON_WRITE = 0x10A0, - SFC_SET_DITHER_ON_READ = 0x10A1, - - SFC_GET_DITHER_INFO_COUNT = 0x10A2, - SFC_GET_DITHER_INFO = 0x10A3, - - SFC_GET_EMBED_FILE_INFO = 0x10B0, - - SFC_SET_CLIPPING = 0x10C0, - SFC_GET_CLIPPING = 0x10C1, - - SFC_GET_INSTRUMENT = 0x10D0, - SFC_SET_INSTRUMENT = 0x10D1, - - SFC_GET_LOOP_INFO = 0x10E0, - - SFC_GET_BROADCAST_INFO = 0x10F0, - SFC_SET_BROADCAST_INFO = 0x10F1, - - SFC_GET_CHANNEL_MAP_INFO = 0x1100, - SFC_SET_CHANNEL_MAP_INFO = 0x1101, - - SFC_RAW_DATA_NEEDS_ENDSWAP = 0x1110, - - /* Support for Wavex Ambisonics Format */ - SFC_WAVEX_SET_AMBISONIC = 0x1200, - SFC_WAVEX_GET_AMBISONIC = 0x1201, - - SFC_SET_VBR_ENCODING_QUALITY = 0x1300, - - /* Following commands for testing only. */ - SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001, - - /* - ** SFC_SET_ADD_* values are deprecated and will disappear at some - ** time in the future. They are guaranteed to be here up to and - ** including version 1.0.8 to avoid breakage of existng software. - ** They currently do nothing and will continue to do nothing. - */ - SFC_SET_ADD_DITHER_ON_WRITE = 0x1070, - SFC_SET_ADD_DITHER_ON_READ = 0x1071 -} ; - - -/* -** String types that can be set and read from files. Not all file types -** support this and even the file types which support one, may not support -** all string types. -*/ - -enum -{ SF_STR_TITLE = 0x01, - SF_STR_COPYRIGHT = 0x02, - SF_STR_SOFTWARE = 0x03, - SF_STR_ARTIST = 0x04, - SF_STR_COMMENT = 0x05, - SF_STR_DATE = 0x06, - SF_STR_ALBUM = 0x07, - SF_STR_LICENSE = 0x08, - SF_STR_TRACKNUMBER = 0x09, - SF_STR_GENRE = 0x10 -} ; - -/* -** Use the following as the start and end index when doing metadata -** transcoding. -*/ - -#define SF_STR_FIRST SF_STR_TITLE -#define SF_STR_LAST SF_STR_GENRE - -enum -{ /* True and false */ - SF_FALSE = 0, - SF_TRUE = 1, - - /* Modes for opening files. */ - SFM_READ = 0x10, - SFM_WRITE = 0x20, - SFM_RDWR = 0x30, - - SF_AMBISONIC_NONE = 0x40, - SF_AMBISONIC_B_FORMAT = 0x41 -} ; - -/* Public error values. These are guaranteed to remain unchanged for the duration -** of the library major version number. -** There are also a large number of private error numbers which are internal to -** the library which can change at any time. -*/ - -enum -{ SF_ERR_NO_ERROR = 0, - SF_ERR_UNRECOGNISED_FORMAT = 1, - SF_ERR_SYSTEM = 2, - SF_ERR_MALFORMED_FILE = 3, - SF_ERR_UNSUPPORTED_ENCODING = 4 -} ; - - -/* Channel map values (used with SFC_SET/GET_CHANNEL_MAP). -*/ - -enum -{ SF_CHANNEL_MAP_INVALID = 0, - SF_CHANNEL_MAP_MONO = 1, - SF_CHANNEL_MAP_LEFT, /* Apple calls this 'Left' */ - SF_CHANNEL_MAP_RIGHT, /* Apple calls this 'Right' */ - SF_CHANNEL_MAP_CENTER, /* Apple calls this 'Center' */ - SF_CHANNEL_MAP_FRONT_LEFT, - SF_CHANNEL_MAP_FRONT_RIGHT, - SF_CHANNEL_MAP_FRONT_CENTER, - SF_CHANNEL_MAP_REAR_CENTER, /* Apple calls this 'Center Surround', Msft calls this 'Back Center' */ - SF_CHANNEL_MAP_REAR_LEFT, /* Apple calls this 'Left Surround', Msft calls this 'Back Left' */ - SF_CHANNEL_MAP_REAR_RIGHT, /* Apple calls this 'Right Surround', Msft calls this 'Back Right' */ - SF_CHANNEL_MAP_LFE, /* Apple calls this 'LFEScreen', Msft calls this 'Low Frequency' */ - SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER, /* Apple calls this 'Left Center' */ - SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER, /* Apple calls this 'Right Center */ - SF_CHANNEL_MAP_SIDE_LEFT, /* Apple calls this 'Left Surround Direct' */ - SF_CHANNEL_MAP_SIDE_RIGHT, /* Apple calls this 'Right Surround Direct' */ - SF_CHANNEL_MAP_TOP_CENTER, /* Apple calls this 'Top Center Surround' */ - SF_CHANNEL_MAP_TOP_FRONT_LEFT, /* Apple calls this 'Vertical Height Left' */ - SF_CHANNEL_MAP_TOP_FRONT_RIGHT, /* Apple calls this 'Vertical Height Right' */ - SF_CHANNEL_MAP_TOP_FRONT_CENTER, /* Apple calls this 'Vertical Height Center' */ - SF_CHANNEL_MAP_TOP_REAR_LEFT, /* Apple and MS call this 'Top Back Left' */ - SF_CHANNEL_MAP_TOP_REAR_RIGHT, /* Apple and MS call this 'Top Back Right' */ - SF_CHANNEL_MAP_TOP_REAR_CENTER, /* Apple and MS call this 'Top Back Center' */ - - SF_CHANNEL_MAP_AMBISONIC_B_W, - SF_CHANNEL_MAP_AMBISONIC_B_X, - SF_CHANNEL_MAP_AMBISONIC_B_Y, - SF_CHANNEL_MAP_AMBISONIC_B_Z, - - SF_CHANNEL_MAP_MAX -} ; - - -/* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */ - -typedef struct SNDFILE_tag SNDFILE ; - -/* The following typedef is system specific and is defined when libsndfile is -** compiled. sf_count_t will be a 64 bit value when the underlying OS allows -** 64 bit file offsets. -** On windows, we need to allow the same header file to be compiler by both GCC -** and the Microsoft compiler. -*/ - -#if (defined (_MSCVER) || defined (_MSC_VER)) -typedef __int64 sf_count_t ; -#define SF_COUNT_MAX 0x7fffffffffffffffi64 -#else -typedef int64_t sf_count_t ; -#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL -#endif - - -/* A pointer to a SF_INFO structure is passed to sf_open () and filled in. -** On write, the SF_INFO structure is filled in by the user and passed into -** sf_open (). -*/ - -struct SF_INFO -{ sf_count_t frames ; /* Used to be called samples. Changed to avoid confusion. */ - int samplerate ; - int channels ; - int format ; - int sections ; - int seekable ; -} ; - -typedef struct SF_INFO SF_INFO ; - -/* The SF_FORMAT_INFO struct is used to retrieve information about the sound -** file formats libsndfile supports using the sf_command () interface. -** -** Using this interface will allow applications to support new file formats -** and encoding types when libsndfile is upgraded, without requiring -** re-compilation of the application. -** -** Please consult the libsndfile documentation (particularly the information -** on the sf_command () interface) for examples of its use. -*/ - -typedef struct -{ int format ; - const char *name ; - const char *extension ; -} SF_FORMAT_INFO ; - -/* -** Enums and typedefs for adding dither on read and write. -** See the html documentation for sf_command(), SFC_SET_DITHER_ON_WRITE -** and SFC_SET_DITHER_ON_READ. -*/ - -enum -{ SFD_DEFAULT_LEVEL = 0, - SFD_CUSTOM_LEVEL = 0x40000000, - - SFD_NO_DITHER = 500, - SFD_WHITE = 501, - SFD_TRIANGULAR_PDF = 502 -} ; - -typedef struct -{ int type ; - double level ; - const char *name ; -} SF_DITHER_INFO ; - -/* Struct used to retrieve information about a file embedded within a -** larger file. See SFC_GET_EMBED_FILE_INFO. -*/ - -typedef struct -{ sf_count_t offset ; - sf_count_t length ; -} SF_EMBED_FILE_INFO ; - -/* -** Structs used to retrieve music sample information from a file. -*/ - -enum -{ /* - ** The loop mode field in SF_INSTRUMENT will be one of the following. - */ - SF_LOOP_NONE = 800, - SF_LOOP_FORWARD, - SF_LOOP_BACKWARD, - SF_LOOP_ALTERNATING -} ; - -typedef struct -{ int gain ; - char basenote, detune ; - char velocity_lo, velocity_hi ; - char key_lo, key_hi ; - int loop_count ; - - struct - { int mode ; - unsigned int start ; - unsigned int end ; - unsigned int count ; - } loops [16] ; /* make variable in a sensible way */ -} SF_INSTRUMENT ; - - - -/* Struct used to retrieve loop information from a file.*/ -typedef struct -{ - short time_sig_num ; /* any positive integer > 0 */ - short time_sig_den ; /* any positive power of 2 > 0 */ - int loop_mode ; /* see SF_LOOP enum */ - - int num_beats ; /* this is NOT the amount of quarter notes !!!*/ - /* a full bar of 4/4 is 4 beats */ - /* a full bar of 7/8 is 7 beats */ - - float bpm ; /* suggestion, as it can be calculated using other fields:*/ - /* file's lenght, file's sampleRate and our time_sig_den*/ - /* -> bpms are always the amount of _quarter notes_ per minute */ - - int root_key ; /* MIDI note, or -1 for None */ - int future [6] ; -} SF_LOOP_INFO ; - - -/* Struct used to retrieve broadcast (EBU) information from a file. -** Strongly (!) based on EBU "bext" chunk format used in Broadcast WAVE. -*/ -#define SF_BROADCAST_INFO_VAR(coding_hist_size) \ - struct \ - { char description [256] ; \ - char originator [32] ; \ - char originator_reference [32] ; \ - char origination_date [10] ; \ - char origination_time [8] ; \ - unsigned int time_reference_low ; \ - unsigned int time_reference_high ; \ - short version ; \ - char umid [64] ; \ - char reserved [190] ; \ - unsigned int coding_history_size ; \ - char coding_history [coding_hist_size] ; \ - } - -/* SF_BROADCAST_INFO is the above struct with coding_history field of 256 bytes. */ -typedef SF_BROADCAST_INFO_VAR (256) SF_BROADCAST_INFO ; - - -/* Virtual I/O functionality. */ - -typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ; -typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ; -typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ; -typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ; -typedef sf_count_t (*sf_vio_tell) (void *user_data) ; - -struct SF_VIRTUAL_IO -{ sf_vio_get_filelen get_filelen ; - sf_vio_seek seek ; - sf_vio_read read ; - sf_vio_write write ; - sf_vio_tell tell ; -} ; - -typedef struct SF_VIRTUAL_IO SF_VIRTUAL_IO ; - - -/* Open the specified file for read, write or both. On error, this will -** return a NULL pointer. To find the error number, pass a NULL SNDFILE -** to sf_strerror (). -** All calls to sf_open() should be matched with a call to sf_close(). -*/ - -SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; - - -/* Use the existing file descriptor to create a SNDFILE object. If close_desc -** is TRUE, the file descriptor will be closed when sf_close() is called. If -** it is FALSE, the descritor will not be closed. -** When passed a descriptor like this, the library will assume that the start -** of file header is at the current file offset. This allows sound files within -** larger container files to be read and/or written. -** On error, this will return a NULL pointer. To find the error number, pass a -** NULL SNDFILE to sf_strerror (). -** All calls to sf_open_fd() should be matched with a call to sf_close(). - -*/ - -SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; - -SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ; - - -/* sf_error () returns a error number which can be translated to a text -** string using sf_error_number(). -*/ - -int sf_error (SNDFILE *sndfile) ; - - -/* sf_strerror () returns to the caller a pointer to the current error message for -** the given SNDFILE. -*/ - -const char* sf_strerror (SNDFILE *sndfile) ; - - -/* sf_error_number () allows the retrieval of the error string for each internal -** error number. -** -*/ - -const char* sf_error_number (int errnum) ; - - -/* The following two error functions are deprecated but they will remain in the -** library for the forseeable future. The function sf_strerror() should be used -** in their place. -*/ - -int sf_perror (SNDFILE *sndfile) ; -int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ; - - -/* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */ - -int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) ; - - -/* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */ - -int sf_format_check (const SF_INFO *info) ; - - -/* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses -** the same values for whence (SEEK_SET, SEEK_CUR and SEEK_END) as -** stdio.h function fseek (). -** An offset of zero with whence set to SEEK_SET will position the -** read / write pointer to the first data sample. -** On success sf_seek returns the current position in (multi-channel) -** samples from the start of the file. -** Please see the libsndfile documentation for moving the read pointer -** separately from the write pointer on files open in mode SFM_RDWR. -** On error all of these functions return -1. -*/ - -sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ; - - -/* Functions for retrieving and setting string data within sound files. -** Not all file types support this features; AIFF and WAV do. For both -** functions, the str_type parameter must be one of the SF_STR_* values -** defined above. -** On error, sf_set_string() returns non-zero while sf_get_string() -** returns NULL. -*/ - -int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ; - -const char* sf_get_string (SNDFILE *sndfile, int str_type) ; - - -/* Return the library version string. */ - -const char * sf_version_string (void) ; - - -/* Functions for reading/writing the waveform data of a sound file. -*/ - -sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; -sf_count_t sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t bytes) ; - - -/* Functions for reading and writing the data chunk in terms of frames. -** The number of items actually read/written = frames * number of channels. -** sf_xxxx_raw read/writes the raw data bytes from/to the file -** sf_xxxx_short passes data in the native short format -** sf_xxxx_int passes data in the native int format -** sf_xxxx_float passes data in the native float format -** sf_xxxx_double passes data in the native double format -** All of these read/write function return number of frames read/written. -*/ - -sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ; -sf_count_t sf_writef_short (SNDFILE *sndfile, const short *ptr, sf_count_t frames) ; - -sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ; -sf_count_t sf_writef_int (SNDFILE *sndfile, const int *ptr, sf_count_t frames) ; - -sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ; -sf_count_t sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frames) ; - -sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; -sf_count_t sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) ; - - -/* Functions for reading and writing the data chunk in terms of items. -** Otherwise similar to above. -** All of these read/write function return number of items read/written. -*/ - -sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ; -sf_count_t sf_write_short (SNDFILE *sndfile, const short *ptr, sf_count_t items) ; - -sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ; -sf_count_t sf_write_int (SNDFILE *sndfile, const int *ptr, sf_count_t items) ; - -sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ; -sf_count_t sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t items) ; - -sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; -sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t items) ; - - -/* Close the SNDFILE and clean up all memory allocations associated with this -** file. -** Returns 0 on success, or an error number. -*/ - -int sf_close (SNDFILE *sndfile) ; - - -/* If the file is opened SFM_WRITE or SFM_RDWR, call fsync() on the file -** to force the writing of data to disk. If the file is opened SFM_READ -** no action is taken. -*/ - -void sf_write_sync (SNDFILE *sndfile) ; - - - -/* The function sf_wchar_open() is Windows Only! -** Open a file passing in a Windows Unicode filename. Otherwise, this is -** the same as sf_open(). -** -** In order for this to work, you need to do the following: -** -** #include <windows.h> -** #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1 -** #including <sndfile.h> -*/ - -#if (defined (ENABLE_SNDFILE_WINDOWS_PROTOTYPES) && ENABLE_SNDFILE_WINDOWS_PROTOTYPES) -SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ; -#endif - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* SNDFILE_H */ - diff --git a/thirdparty/src/Lua/lapi.cpp b/thirdparty/src/Lua/lapi.cpp deleted file mode 100644 index 1207378ba..000000000 --- a/thirdparty/src/Lua/lapi.cpp +++ /dev/null @@ -1,1270 +0,0 @@ -/* -** $Id: lapi.c,v 2.244 2014/12/26 14:43:45 roberto Exp $ -** Lua API -** See Copyright Notice in lua.h -*/ - -#define lapi_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <stdarg.h> -#include <string.h> - -#include <Lua/lua.h> - -#include "lapi.h" -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lgc.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" -#include "lundump.h" -#include "lvm.h" - - - -const char lua_ident[] = - "$LuaVersion: " LUA_COPYRIGHT " $" - "$LuaAuthors: " LUA_AUTHORS " $"; - - -/* value at a non-valid index */ -#define NONVALIDVALUE cast(TValue *, luaO_nilobject) - -/* corresponding test */ -#define isvalid(o) ((o) != luaO_nilobject) - -/* test for pseudo index */ -#define ispseudo(i) ((i) <= LUA_REGISTRYINDEX) - -/* test for upvalue */ -#define isupvalue(i) ((i) < LUA_REGISTRYINDEX) - -/* test for valid but not pseudo index */ -#define isstackindex(i, o) (isvalid(o) && !ispseudo(i)) - -#define api_checkvalidindex(o) api_check(isvalid(o), "invalid index") - -#define api_checkstackindex(i, o) \ - api_check(isstackindex(i, o), "index not in the stack") - - -static TValue *index2addr (lua_State *L, int idx) { - CallInfo *ci = L->ci; - if (idx > 0) { - TValue *o = ci->func + idx; - api_check(idx <= ci->top - (ci->func + 1), "unacceptable index"); - if (o >= L->top) return NONVALIDVALUE; - else return o; - } - else if (!ispseudo(idx)) { /* negative index */ - api_check(idx != 0 && -idx <= L->top - (ci->func + 1), "invalid index"); - return L->top + idx; - } - else if (idx == LUA_REGISTRYINDEX) - return &G(L)->l_registry; - else { /* upvalues */ - idx = LUA_REGISTRYINDEX - idx; - api_check(idx <= MAXUPVAL + 1, "upvalue index too large"); - if (ttislcf(ci->func)) /* light C function? */ - return NONVALIDVALUE; /* it has no upvalues */ - else { - CClosure *func = clCvalue(ci->func); - return (idx <= func->nupvalues) ? &func->upvalue[idx-1] : NONVALIDVALUE; - } - } -} - - -/* -** to be called by 'lua_checkstack' in protected mode, to grow stack -** capturing memory errors -*/ -static void growstack (lua_State *L, void *ud) { - int size = *(int *)ud; - luaD_growstack(L, size); -} - - -LUA_API int lua_checkstack (lua_State *L, int n) { - int res; - CallInfo *ci = L->ci; - lua_lock(L); - api_check(n >= 0, "negative 'n'"); - if (L->stack_last - L->top > n) /* stack large enough? */ - res = 1; /* yes; check is OK */ - else { /* no; need to grow stack */ - int inuse = cast_int(L->top - L->stack) + EXTRA_STACK; - if (inuse > LUAI_MAXSTACK - n) /* can grow without overflow? */ - res = 0; /* no */ - else /* try to grow stack */ - res = (luaD_rawrunprotected(L, &growstack, &n) == LUA_OK); - } - if (res && ci->top < L->top + n) - ci->top = L->top + n; /* adjust frame top */ - lua_unlock(L); - return res; -} - - -LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { - int i; - if (from == to) return; - lua_lock(to); - api_checknelems(from, n); - api_check(G(from) == G(to), "moving among independent states"); - api_check(to->ci->top - to->top >= n, "not enough elements to move"); - from->top -= n; - for (i = 0; i < n; i++) { - setobj2s(to, to->top++, from->top + i); - } - lua_unlock(to); -} - - -LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { - lua_CFunction old; - lua_lock(L); - old = G(L)->panic; - G(L)->panic = panicf; - lua_unlock(L); - return old; -} - - -LUA_API const lua_Number *lua_version (lua_State *L) { - static const lua_Number version = LUA_VERSION_NUM; - if (L == NULL) return &version; - else return G(L)->version; -} - - - -/* -** basic stack manipulation -*/ - - -/* -** convert an acceptable stack index into an absolute index -*/ -LUA_API int lua_absindex (lua_State *L, int idx) { - return (idx > 0 || ispseudo(idx)) - ? idx - : cast_int(L->top - L->ci->func + idx); -} - - -LUA_API int lua_gettop (lua_State *L) { - return cast_int(L->top - (L->ci->func + 1)); -} - - -LUA_API void lua_settop (lua_State *L, int idx) { - StkId func = L->ci->func; - lua_lock(L); - if (idx >= 0) { - api_check(idx <= L->stack_last - (func + 1), "new top too large"); - while (L->top < (func + 1) + idx) - setnilvalue(L->top++); - L->top = (func + 1) + idx; - } - else { - api_check(-(idx+1) <= (L->top - (func + 1)), "invalid new top"); - L->top += idx+1; /* 'subtract' index (index is negative) */ - } - lua_unlock(L); -} - - -/* -** Reverse the stack segment from 'from' to 'to' -** (auxiliary to 'lua_rotate') -*/ -static void reverse (lua_State *L, StkId from, StkId to) { - for (; from < to; from++, to--) { - TValue temp; - setobj(L, &temp, from); - setobjs2s(L, from, to); - setobj2s(L, to, &temp); - } -} - - -/* -** Let x = AB, where A is a prefix of length 'n'. Then, -** rotate x n == BA. But BA == (A^r . B^r)^r. -*/ -LUA_API void lua_rotate (lua_State *L, int idx, int n) { - StkId p, t, m; - lua_lock(L); - t = L->top - 1; /* end of stack segment being rotated */ - p = index2addr(L, idx); /* start of segment */ - api_checkstackindex(idx, p); - api_check((n >= 0 ? n : -n) <= (t - p + 1), "invalid 'n'"); - m = (n >= 0 ? t - n : p - n - 1); /* end of prefix */ - reverse(L, p, m); /* reverse the prefix with length 'n' */ - reverse(L, m + 1, t); /* reverse the suffix */ - reverse(L, p, t); /* reverse the entire segment */ - lua_unlock(L); -} - - -LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) { - TValue *fr, *to; - lua_lock(L); - fr = index2addr(L, fromidx); - to = index2addr(L, toidx); - api_checkvalidindex(to); - setobj(L, to, fr); - if (isupvalue(toidx)) /* function upvalue? */ - luaC_barrier(L, clCvalue(L->ci->func), fr); - /* LUA_REGISTRYINDEX does not need gc barrier - (collector revisits it before finishing collection) */ - lua_unlock(L); -} - - -LUA_API void lua_pushvalue (lua_State *L, int idx) { - lua_lock(L); - setobj2s(L, L->top, index2addr(L, idx)); - api_incr_top(L); - lua_unlock(L); -} - - - -/* -** access functions (stack -> C) -*/ - - -LUA_API int lua_type (lua_State *L, int idx) { - StkId o = index2addr(L, idx); - return (isvalid(o) ? ttnov(o) : LUA_TNONE); -} - - -LUA_API const char *lua_typename (lua_State *L, int t) { - UNUSED(L); - api_check(LUA_TNONE <= t && t < LUA_NUMTAGS, "invalid tag"); - return ttypename(t); -} - - -LUA_API int lua_iscfunction (lua_State *L, int idx) { - StkId o = index2addr(L, idx); - return (ttislcf(o) || (ttisCclosure(o))); -} - - -LUA_API int lua_isinteger (lua_State *L, int idx) { - StkId o = index2addr(L, idx); - return ttisinteger(o); -} - - -LUA_API int lua_isnumber (lua_State *L, int idx) { - lua_Number n; - const TValue *o = index2addr(L, idx); - return tonumber(o, &n); -} - - -LUA_API int lua_isstring (lua_State *L, int idx) { - const TValue *o = index2addr(L, idx); - return (ttisstring(o) || cvt2str(o)); -} - - -LUA_API int lua_isuserdata (lua_State *L, int idx) { - const TValue *o = index2addr(L, idx); - return (ttisfulluserdata(o) || ttislightuserdata(o)); -} - - -LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { - StkId o1 = index2addr(L, index1); - StkId o2 = index2addr(L, index2); - return (isvalid(o1) && isvalid(o2)) ? luaV_rawequalobj(o1, o2) : 0; -} - - -LUA_API void lua_arith (lua_State *L, int op) { - lua_lock(L); - if (op != LUA_OPUNM && op != LUA_OPBNOT) - api_checknelems(L, 2); /* all other operations expect two operands */ - else { /* for unary operations, add fake 2nd operand */ - api_checknelems(L, 1); - setobjs2s(L, L->top, L->top - 1); - L->top++; - } - /* first operand at top - 2, second at top - 1; result go to top - 2 */ - luaO_arith(L, op, L->top - 2, L->top - 1, L->top - 2); - L->top--; /* remove second operand */ - lua_unlock(L); -} - - -LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) { - StkId o1, o2; - int i = 0; - lua_lock(L); /* may call tag method */ - o1 = index2addr(L, index1); - o2 = index2addr(L, index2); - if (isvalid(o1) && isvalid(o2)) { - switch (op) { - case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break; - case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break; - case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break; - default: api_check(0, "invalid option"); - } - } - lua_unlock(L); - return i; -} - - -LUA_API size_t lua_stringtonumber (lua_State *L, const char *s) { - size_t sz = luaO_str2num(s, L->top); - if (sz != 0) - api_incr_top(L); - return sz; -} - - -LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *pisnum) { - lua_Number n; - const TValue *o = index2addr(L, idx); - int isnum = tonumber(o, &n); - if (!isnum) - n = 0; /* call to 'tonumber' may change 'n' even if it fails */ - if (pisnum) *pisnum = isnum; - return n; -} - - -LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *pisnum) { - lua_Integer res; - const TValue *o = index2addr(L, idx); - int isnum = tointeger(o, &res); - if (!isnum) - res = 0; /* call to 'tointeger' may change 'n' even if it fails */ - if (pisnum) *pisnum = isnum; - return res; -} - - -LUA_API int lua_toboolean (lua_State *L, int idx) { - const TValue *o = index2addr(L, idx); - return !l_isfalse(o); -} - - -LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { - StkId o = index2addr(L, idx); - if (!ttisstring(o)) { - if (!cvt2str(o)) { /* not convertible? */ - if (len != NULL) *len = 0; - return NULL; - } - lua_lock(L); /* 'luaO_tostring' may create a new string */ - luaC_checkGC(L); - o = index2addr(L, idx); /* previous call may reallocate the stack */ - luaO_tostring(L, o); - lua_unlock(L); - } - if (len != NULL) *len = tsvalue(o)->len; - return svalue(o); -} - - -LUA_API size_t lua_rawlen (lua_State *L, int idx) { - StkId o = index2addr(L, idx); - switch (ttnov(o)) { - case LUA_TSTRING: return tsvalue(o)->len; - case LUA_TUSERDATA: return uvalue(o)->len; - case LUA_TTABLE: return luaH_getn(hvalue(o)); - default: return 0; - } -} - - -LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { - StkId o = index2addr(L, idx); - if (ttislcf(o)) return fvalue(o); - else if (ttisCclosure(o)) - return clCvalue(o)->f; - else return NULL; /* not a C function */ -} - - -LUA_API void *lua_touserdata (lua_State *L, int idx) { - StkId o = index2addr(L, idx); - switch (ttnov(o)) { - case LUA_TUSERDATA: return getudatamem(uvalue(o)); - case LUA_TLIGHTUSERDATA: return pvalue(o); - default: return NULL; - } -} - - -LUA_API lua_State *lua_tothread (lua_State *L, int idx) { - StkId o = index2addr(L, idx); - return (!ttisthread(o)) ? NULL : thvalue(o); -} - - -LUA_API const void *lua_topointer (lua_State *L, int idx) { - StkId o = index2addr(L, idx); - switch (ttype(o)) { - case LUA_TTABLE: return hvalue(o); - case LUA_TLCL: return clLvalue(o); - case LUA_TCCL: return clCvalue(o); - case LUA_TLCF: return cast(void *, cast(size_t, fvalue(o))); - case LUA_TTHREAD: return thvalue(o); - case LUA_TUSERDATA: - case LUA_TLIGHTUSERDATA: - return lua_touserdata(L, idx); - default: return NULL; - } -} - - - -/* -** push functions (C -> stack) -*/ - - -LUA_API void lua_pushnil (lua_State *L) { - lua_lock(L); - setnilvalue(L->top); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { - lua_lock(L); - setfltvalue(L->top, n); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { - lua_lock(L); - setivalue(L->top, n); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) { - TString *ts; - lua_lock(L); - luaC_checkGC(L); - ts = luaS_newlstr(L, s, len); - setsvalue2s(L, L->top, ts); - api_incr_top(L); - lua_unlock(L); - return getstr(ts); -} - - -LUA_API const char *lua_pushstring (lua_State *L, const char *s) { - if (s == NULL) { - lua_pushnil(L); - return NULL; - } - else { - TString *ts; - lua_lock(L); - luaC_checkGC(L); - ts = luaS_new(L, s); - setsvalue2s(L, L->top, ts); - api_incr_top(L); - lua_unlock(L); - return getstr(ts); - } -} - - -LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, - va_list argp) { - const char *ret; - lua_lock(L); - luaC_checkGC(L); - ret = luaO_pushvfstring(L, fmt, argp); - lua_unlock(L); - return ret; -} - - -LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { - const char *ret; - va_list argp; - lua_lock(L); - luaC_checkGC(L); - va_start(argp, fmt); - ret = luaO_pushvfstring(L, fmt, argp); - va_end(argp); - lua_unlock(L); - return ret; -} - - -LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { - lua_lock(L); - if (n == 0) { - setfvalue(L->top, fn); - } - else { - CClosure *cl; - api_checknelems(L, n); - api_check(n <= MAXUPVAL, "upvalue index too large"); - luaC_checkGC(L); - cl = luaF_newCclosure(L, n); - cl->f = fn; - L->top -= n; - while (n--) { - setobj2n(L, &cl->upvalue[n], L->top + n); - /* does not need barrier because closure is white */ - } - setclCvalue(L, L->top, cl); - } - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API void lua_pushboolean (lua_State *L, int b) { - lua_lock(L); - setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { - lua_lock(L); - setpvalue(L->top, p); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API int lua_pushthread (lua_State *L) { - lua_lock(L); - setthvalue(L, L->top, L); - api_incr_top(L); - lua_unlock(L); - return (G(L)->mainthread == L); -} - - - -/* -** get functions (Lua -> stack) -*/ - - -LUA_API int lua_getglobal (lua_State *L, const char *name) { - Table *reg = hvalue(&G(L)->l_registry); - const TValue *gt; /* global table */ - lua_lock(L); - gt = luaH_getint(reg, LUA_RIDX_GLOBALS); - setsvalue2s(L, L->top++, luaS_new(L, name)); - luaV_gettable(L, gt, L->top - 1, L->top - 1); - lua_unlock(L); - return ttnov(L->top - 1); -} - - -LUA_API int lua_gettable (lua_State *L, int idx) { - StkId t; - lua_lock(L); - t = index2addr(L, idx); - luaV_gettable(L, t, L->top - 1, L->top - 1); - lua_unlock(L); - return ttnov(L->top - 1); -} - - -LUA_API int lua_getfield (lua_State *L, int idx, const char *k) { - StkId t; - lua_lock(L); - t = index2addr(L, idx); - setsvalue2s(L, L->top, luaS_new(L, k)); - api_incr_top(L); - luaV_gettable(L, t, L->top - 1, L->top - 1); - lua_unlock(L); - return ttnov(L->top - 1); -} - - -LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) { - StkId t; - lua_lock(L); - t = index2addr(L, idx); - setivalue(L->top, n); - api_incr_top(L); - luaV_gettable(L, t, L->top - 1, L->top - 1); - lua_unlock(L); - return ttnov(L->top - 1); -} - - -LUA_API int lua_rawget (lua_State *L, int idx) { - StkId t; - lua_lock(L); - t = index2addr(L, idx); - api_check(ttistable(t), "table expected"); - setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); - lua_unlock(L); - return ttnov(L->top - 1); -} - - -LUA_API int lua_rawgeti (lua_State *L, int idx, lua_Integer n) { - StkId t; - lua_lock(L); - t = index2addr(L, idx); - api_check(ttistable(t), "table expected"); - setobj2s(L, L->top, luaH_getint(hvalue(t), n)); - api_incr_top(L); - lua_unlock(L); - return ttnov(L->top - 1); -} - - -LUA_API int lua_rawgetp (lua_State *L, int idx, const void *p) { - StkId t; - TValue k; - lua_lock(L); - t = index2addr(L, idx); - api_check(ttistable(t), "table expected"); - setpvalue(&k, cast(void *, p)); - setobj2s(L, L->top, luaH_get(hvalue(t), &k)); - api_incr_top(L); - lua_unlock(L); - return ttnov(L->top - 1); -} - - -LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { - Table *t; - lua_lock(L); - luaC_checkGC(L); - t = luaH_new(L); - sethvalue(L, L->top, t); - api_incr_top(L); - if (narray > 0 || nrec > 0) - luaH_resize(L, t, narray, nrec); - lua_unlock(L); -} - - -LUA_API int lua_getmetatable (lua_State *L, int objindex) { - const TValue *obj; - Table *mt; - int res = 0; - lua_lock(L); - obj = index2addr(L, objindex); - switch (ttnov(obj)) { - case LUA_TTABLE: - mt = hvalue(obj)->metatable; - break; - case LUA_TUSERDATA: - mt = uvalue(obj)->metatable; - break; - default: - mt = G(L)->mt[ttnov(obj)]; - break; - } - if (mt != NULL) { - sethvalue(L, L->top, mt); - api_incr_top(L); - res = 1; - } - lua_unlock(L); - return res; -} - - -LUA_API int lua_getuservalue (lua_State *L, int idx) { - StkId o; - lua_lock(L); - o = index2addr(L, idx); - api_check(ttisfulluserdata(o), "full userdata expected"); - getuservalue(L, uvalue(o), L->top); - api_incr_top(L); - lua_unlock(L); - return ttnov(L->top - 1); -} - - -/* -** set functions (stack -> Lua) -*/ - - -LUA_API void lua_setglobal (lua_State *L, const char *name) { - Table *reg = hvalue(&G(L)->l_registry); - const TValue *gt; /* global table */ - lua_lock(L); - api_checknelems(L, 1); - gt = luaH_getint(reg, LUA_RIDX_GLOBALS); - setsvalue2s(L, L->top++, luaS_new(L, name)); - luaV_settable(L, gt, L->top - 1, L->top - 2); - L->top -= 2; /* pop value and key */ - lua_unlock(L); -} - - -LUA_API void lua_settable (lua_State *L, int idx) { - StkId t; - lua_lock(L); - api_checknelems(L, 2); - t = index2addr(L, idx); - luaV_settable(L, t, L->top - 2, L->top - 1); - L->top -= 2; /* pop index and value */ - lua_unlock(L); -} - - -LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { - StkId t; - lua_lock(L); - api_checknelems(L, 1); - t = index2addr(L, idx); - setsvalue2s(L, L->top++, luaS_new(L, k)); - luaV_settable(L, t, L->top - 1, L->top - 2); - L->top -= 2; /* pop value and key */ - lua_unlock(L); -} - - -LUA_API void lua_seti (lua_State *L, int idx, lua_Integer n) { - StkId t; - lua_lock(L); - api_checknelems(L, 1); - t = index2addr(L, idx); - setivalue(L->top++, n); - luaV_settable(L, t, L->top - 1, L->top - 2); - L->top -= 2; /* pop value and key */ - lua_unlock(L); -} - - -LUA_API void lua_rawset (lua_State *L, int idx) { - StkId o; - Table *t; - lua_lock(L); - api_checknelems(L, 2); - o = index2addr(L, idx); - api_check(ttistable(o), "table expected"); - t = hvalue(o); - setobj2t(L, luaH_set(L, t, L->top-2), L->top-1); - invalidateTMcache(t); - luaC_barrierback(L, t, L->top-1); - L->top -= 2; - lua_unlock(L); -} - - -LUA_API void lua_rawseti (lua_State *L, int idx, lua_Integer n) { - StkId o; - Table *t; - lua_lock(L); - api_checknelems(L, 1); - o = index2addr(L, idx); - api_check(ttistable(o), "table expected"); - t = hvalue(o); - luaH_setint(L, t, n, L->top - 1); - luaC_barrierback(L, t, L->top-1); - L->top--; - lua_unlock(L); -} - - -LUA_API void lua_rawsetp (lua_State *L, int idx, const void *p) { - StkId o; - Table *t; - TValue k; - lua_lock(L); - api_checknelems(L, 1); - o = index2addr(L, idx); - api_check(ttistable(o), "table expected"); - t = hvalue(o); - setpvalue(&k, cast(void *, p)); - setobj2t(L, luaH_set(L, t, &k), L->top - 1); - luaC_barrierback(L, t, L->top - 1); - L->top--; - lua_unlock(L); -} - - -LUA_API int lua_setmetatable (lua_State *L, int objindex) { - TValue *obj; - Table *mt; - lua_lock(L); - api_checknelems(L, 1); - obj = index2addr(L, objindex); - if (ttisnil(L->top - 1)) - mt = NULL; - else { - api_check(ttistable(L->top - 1), "table expected"); - mt = hvalue(L->top - 1); - } - switch (ttnov(obj)) { - case LUA_TTABLE: { - hvalue(obj)->metatable = mt; - if (mt) { - luaC_objbarrier(L, gcvalue(obj), mt); - luaC_checkfinalizer(L, gcvalue(obj), mt); - } - break; - } - case LUA_TUSERDATA: { - uvalue(obj)->metatable = mt; - if (mt) { - luaC_objbarrier(L, uvalue(obj), mt); - luaC_checkfinalizer(L, gcvalue(obj), mt); - } - break; - } - default: { - G(L)->mt[ttnov(obj)] = mt; - break; - } - } - L->top--; - lua_unlock(L); - return 1; -} - - -LUA_API void lua_setuservalue (lua_State *L, int idx) { - StkId o; - lua_lock(L); - api_checknelems(L, 1); - o = index2addr(L, idx); - api_check(ttisfulluserdata(o), "full userdata expected"); - setuservalue(L, uvalue(o), L->top - 1); - luaC_barrier(L, gcvalue(o), L->top - 1); - L->top--; - lua_unlock(L); -} - - -/* -** 'load' and 'call' functions (run Lua code) -*/ - - -#define checkresults(L,na,nr) \ - api_check((nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)), \ - "results from function overflow current stack size") - - -LUA_API void lua_callk (lua_State *L, int nargs, int nresults, - lua_KContext ctx, lua_KFunction k) { - StkId func; - lua_lock(L); - api_check(k == NULL || !isLua(L->ci), - "cannot use continuations inside hooks"); - api_checknelems(L, nargs+1); - api_check(L->status == LUA_OK, "cannot do calls on non-normal thread"); - checkresults(L, nargs, nresults); - func = L->top - (nargs+1); - if (k != NULL && L->nny == 0) { /* need to prepare continuation? */ - L->ci->u.c.k = k; /* save continuation */ - L->ci->u.c.ctx = ctx; /* save context */ - luaD_call(L, func, nresults, 1); /* do the call */ - } - else /* no continuation or no yieldable */ - luaD_call(L, func, nresults, 0); /* just do the call */ - adjustresults(L, nresults); - lua_unlock(L); -} - - - -/* -** Execute a protected call. -*/ -struct CallS { /* data to 'f_call' */ - StkId func; - int nresults; -}; - - -static void f_call (lua_State *L, void *ud) { - struct CallS *c = cast(struct CallS *, ud); - luaD_call(L, c->func, c->nresults, 0); -} - - - -LUA_API int lua_pcallk (lua_State *L, int nargs, int nresults, int errfunc, - lua_KContext ctx, lua_KFunction k) { - struct CallS c; - int status; - ptrdiff_t func; - lua_lock(L); - api_check(k == NULL || !isLua(L->ci), - "cannot use continuations inside hooks"); - api_checknelems(L, nargs+1); - api_check(L->status == LUA_OK, "cannot do calls on non-normal thread"); - checkresults(L, nargs, nresults); - if (errfunc == 0) - func = 0; - else { - StkId o = index2addr(L, errfunc); - api_checkstackindex(errfunc, o); - func = savestack(L, o); - } - c.func = L->top - (nargs+1); /* function to be called */ - if (k == NULL || L->nny > 0) { /* no continuation or no yieldable? */ - c.nresults = nresults; /* do a 'conventional' protected call */ - status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); - } - else { /* prepare continuation (call is already protected by 'resume') */ - CallInfo *ci = L->ci; - ci->u.c.k = k; /* save continuation */ - ci->u.c.ctx = ctx; /* save context */ - /* save information for error recovery */ - ci->extra = savestack(L, c.func); - ci->u.c.old_errfunc = L->errfunc; - L->errfunc = func; - setoah(ci->callstatus, L->allowhook); /* save value of 'allowhook' */ - ci->callstatus |= CIST_YPCALL; /* function can do error recovery */ - luaD_call(L, c.func, nresults, 1); /* do the call */ - ci->callstatus &= ~CIST_YPCALL; - L->errfunc = ci->u.c.old_errfunc; - status = LUA_OK; /* if it is here, there were no errors */ - } - adjustresults(L, nresults); - lua_unlock(L); - return status; -} - - -LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, - const char *chunkname, const char *mode) { - ZIO z; - int status; - lua_lock(L); - if (!chunkname) chunkname = "?"; - luaZ_init(L, &z, reader, data); - status = luaD_protectedparser(L, &z, chunkname, mode); - if (status == LUA_OK) { /* no errors? */ - LClosure *f = clLvalue(L->top - 1); /* get newly created function */ - if (f->nupvalues >= 1) { /* does it have an upvalue? */ - /* get global table from registry */ - Table *reg = hvalue(&G(L)->l_registry); - const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS); - /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */ - setobj(L, f->upvals[0]->v, gt); - luaC_upvalbarrier(L, f->upvals[0]); - } - } - lua_unlock(L); - return status; -} - - -LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data, int strip) { - int status; - TValue *o; - lua_lock(L); - api_checknelems(L, 1); - o = L->top - 1; - if (isLfunction(o)) - status = luaU_dump(L, getproto(o), writer, data, strip); - else - status = 1; - lua_unlock(L); - return status; -} - - -LUA_API int lua_status (lua_State *L) { - return L->status; -} - - -/* -** Garbage-collection function -*/ - -LUA_API int lua_gc (lua_State *L, int what, int data) { - int res = 0; - global_State *g; - lua_lock(L); - g = G(L); - switch (what) { - case LUA_GCSTOP: { - g->gcrunning = 0; - break; - } - case LUA_GCRESTART: { - luaE_setdebt(g, 0); - g->gcrunning = 1; - break; - } - case LUA_GCCOLLECT: { - luaC_fullgc(L, 0); - break; - } - case LUA_GCCOUNT: { - /* GC values are expressed in Kbytes: #bytes/2^10 */ - res = cast_int(gettotalbytes(g) >> 10); - break; - } - case LUA_GCCOUNTB: { - res = cast_int(gettotalbytes(g) & 0x3ff); - break; - } - case LUA_GCSTEP: { - l_mem debt = 1; /* =1 to signal that it did an actual step */ - int oldrunning = g->gcrunning; - g->gcrunning = 1; /* allow GC to run */ - if (data == 0) { - luaE_setdebt(g, -GCSTEPSIZE); /* to do a "small" step */ - luaC_step(L); - } - else { /* add 'data' to total debt */ - debt = cast(l_mem, data) * 1024 + g->GCdebt; - luaE_setdebt(g, debt); - luaC_checkGC(L); - } - g->gcrunning = oldrunning; /* restore previous state */ - if (debt > 0 && g->gcstate == GCSpause) /* end of cycle? */ - res = 1; /* signal it */ - break; - } - case LUA_GCSETPAUSE: { - res = g->gcpause; - g->gcpause = data; - break; - } - case LUA_GCSETSTEPMUL: { - res = g->gcstepmul; - if (data < 40) data = 40; /* avoid ridiculous low values (and 0) */ - g->gcstepmul = data; - break; - } - case LUA_GCISRUNNING: { - res = g->gcrunning; - break; - } - default: res = -1; /* invalid option */ - } - lua_unlock(L); - return res; -} - - - -/* -** miscellaneous functions -*/ - - -LUA_API int lua_error (lua_State *L) { - lua_lock(L); - api_checknelems(L, 1); - luaG_errormsg(L); - /* code unreachable; will unlock when control actually leaves the kernel */ - return 0; /* to avoid warnings */ -} - - -LUA_API int lua_next (lua_State *L, int idx) { - StkId t; - int more; - lua_lock(L); - t = index2addr(L, idx); - api_check(ttistable(t), "table expected"); - more = luaH_next(L, hvalue(t), L->top - 1); - if (more) { - api_incr_top(L); - } - else /* no more elements */ - L->top -= 1; /* remove key */ - lua_unlock(L); - return more; -} - - -LUA_API void lua_concat (lua_State *L, int n) { - lua_lock(L); - api_checknelems(L, n); - if (n >= 2) { - luaC_checkGC(L); - luaV_concat(L, n); - } - else if (n == 0) { /* push empty string */ - setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); - api_incr_top(L); - } - /* else n == 1; nothing to do */ - lua_unlock(L); -} - - -LUA_API void lua_len (lua_State *L, int idx) { - StkId t; - lua_lock(L); - t = index2addr(L, idx); - luaV_objlen(L, L->top, t); - api_incr_top(L); - lua_unlock(L); -} - - -LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { - lua_Alloc f; - lua_lock(L); - if (ud) *ud = G(L)->ud; - f = G(L)->frealloc; - lua_unlock(L); - return f; -} - - -LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { - lua_lock(L); - G(L)->ud = ud; - G(L)->frealloc = f; - lua_unlock(L); -} - - -LUA_API void *lua_newuserdata (lua_State *L, size_t size) { - Udata *u; - lua_lock(L); - luaC_checkGC(L); - u = luaS_newudata(L, size); - setuvalue(L, L->top, u); - api_incr_top(L); - lua_unlock(L); - return getudatamem(u); -} - - - -static const char *aux_upvalue (StkId fi, int n, TValue **val, - CClosure **owner, UpVal **uv) { - switch (ttype(fi)) { - case LUA_TCCL: { /* C closure */ - CClosure *f = clCvalue(fi); - if (!(1 <= n && n <= f->nupvalues)) return NULL; - *val = &f->upvalue[n-1]; - if (owner) *owner = f; - return ""; - } - case LUA_TLCL: { /* Lua closure */ - LClosure *f = clLvalue(fi); - TString *name; - Proto *p = f->p; - if (!(1 <= n && n <= p->sizeupvalues)) return NULL; - *val = f->upvals[n-1]->v; - if (uv) *uv = f->upvals[n - 1]; - name = p->upvalues[n-1].name; - return (name == NULL) ? "(*no name)" : getstr(name); - } - default: return NULL; /* not a closure */ - } -} - - -LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { - const char *name; - TValue *val = NULL; /* to avoid warnings */ - lua_lock(L); - name = aux_upvalue(index2addr(L, funcindex), n, &val, NULL, NULL); - if (name) { - setobj2s(L, L->top, val); - api_incr_top(L); - } - lua_unlock(L); - return name; -} - - -LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { - const char *name; - TValue *val = NULL; /* to avoid warnings */ - CClosure *owner = NULL; - UpVal *uv = NULL; - StkId fi; - lua_lock(L); - fi = index2addr(L, funcindex); - api_checknelems(L, 1); - name = aux_upvalue(fi, n, &val, &owner, &uv); - if (name) { - L->top--; - setobj(L, val, L->top); - if (owner) { luaC_barrier(L, owner, L->top); } - else if (uv) { luaC_upvalbarrier(L, uv); } - } - lua_unlock(L); - return name; -} - - -static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) { - LClosure *f; - StkId fi = index2addr(L, fidx); - api_check(ttisLclosure(fi), "Lua function expected"); - f = clLvalue(fi); - api_check((1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index"); - if (pf) *pf = f; - return &f->upvals[n - 1]; /* get its upvalue pointer */ -} - - -LUA_API void *lua_upvalueid (lua_State *L, int fidx, int n) { - StkId fi = index2addr(L, fidx); - switch (ttype(fi)) { - case LUA_TLCL: { /* lua closure */ - return *getupvalref(L, fidx, n, NULL); - } - case LUA_TCCL: { /* C closure */ - CClosure *f = clCvalue(fi); - api_check(1 <= n && n <= f->nupvalues, "invalid upvalue index"); - return &f->upvalue[n - 1]; - } - default: { - api_check(0, "closure expected"); - return NULL; - } - } -} - - -LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1, - int fidx2, int n2) { - LClosure *f1; - UpVal **up1 = getupvalref(L, fidx1, n1, &f1); - UpVal **up2 = getupvalref(L, fidx2, n2, NULL); - luaC_upvdeccount(L, *up1); - *up1 = *up2; - (*up1)->refcount++; - if (upisopen(*up1)) (*up1)->u.open.touched = 1; - luaC_upvalbarrier(L, *up1); -} - - diff --git a/thirdparty/src/Lua/lapi.h b/thirdparty/src/Lua/lapi.h deleted file mode 100644 index 092f5e974..000000000 --- a/thirdparty/src/Lua/lapi.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -** $Id: lapi.h,v 2.8 2014/07/15 21:26:50 roberto Exp $ -** Auxiliary functions from Lua API -** See Copyright Notice in lua.h -*/ - -#ifndef lapi_h -#define lapi_h - - -#include "llimits.h" -#include "lstate.h" - -#define api_incr_top(L) {L->top++; api_check(L->top <= L->ci->top, \ - "stack overflow");} - -#define adjustresults(L,nres) \ - { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } - -#define api_checknelems(L,n) api_check((n) < (L->top - L->ci->func), \ - "not enough elements in the stack") - - -#endif diff --git a/thirdparty/src/Lua/lauxlib.cpp b/thirdparty/src/Lua/lauxlib.cpp deleted file mode 100644 index c61dbb04d..000000000 --- a/thirdparty/src/Lua/lauxlib.cpp +++ /dev/null @@ -1,972 +0,0 @@ -/* -** $Id: lauxlib.c,v 1.279 2014/12/14 18:32:26 roberto Exp $ -** Auxiliary functions for building Lua libraries -** See Copyright Notice in lua.h -*/ - -#define lauxlib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include <errno.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - - -/* This file uses only the official API of Lua. -** Any function declared here could be written as an application function. -*/ - -#include <Lua/lua.h> - -#include <Lua/lauxlib.h> - - -/* -** {====================================================== -** Traceback -** ======================================================= -*/ - - -#define LEVELS1 12 /* size of the first part of the stack */ -#define LEVELS2 10 /* size of the second part of the stack */ - - - -/* -** search for 'objidx' in table at index -1. -** return 1 + string at top if find a good name. -*/ -static int findfield (lua_State *L, int objidx, int level) { - if (level == 0 || !lua_istable(L, -1)) - return 0; /* not found */ - lua_pushnil(L); /* start 'next' loop */ - while (lua_next(L, -2)) { /* for each pair in table */ - if (lua_type(L, -2) == LUA_TSTRING) { /* ignore non-string keys */ - if (lua_rawequal(L, objidx, -1)) { /* found object? */ - lua_pop(L, 1); /* remove value (but keep name) */ - return 1; - } - else if (findfield(L, objidx, level - 1)) { /* try recursively */ - lua_remove(L, -2); /* remove table (but keep name) */ - lua_pushliteral(L, "."); - lua_insert(L, -2); /* place '.' between the two names */ - lua_concat(L, 3); - return 1; - } - } - lua_pop(L, 1); /* remove value */ - } - return 0; /* not found */ -} - - -/* -** Search for a name for a function in all loaded modules -** (registry._LOADED). -*/ -static int pushglobalfuncname (lua_State *L, lua_Debug *ar) { - int top = lua_gettop(L); - lua_getinfo(L, "f", ar); /* push function */ - lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); - if (findfield(L, top + 1, 2)) { - const char *name = lua_tostring(L, -1); - if (strncmp(name, "_G.", 3) == 0) { /* name start with '_G.'? */ - lua_pushstring(L, name + 3); /* push name without prefix */ - lua_remove(L, -2); /* remove original name */ - } - lua_copy(L, -1, top + 1); /* move name to proper place */ - lua_pop(L, 2); /* remove pushed values */ - return 1; - } - else { - lua_settop(L, top); /* remove function and global table */ - return 0; - } -} - - -static void pushfuncname (lua_State *L, lua_Debug *ar) { - if (pushglobalfuncname(L, ar)) { /* try first a global name */ - lua_pushfstring(L, "function '%s'", lua_tostring(L, -1)); - lua_remove(L, -2); /* remove name */ - } - else if (*ar->namewhat != '\0') /* is there a name from code? */ - lua_pushfstring(L, "%s '%s'", ar->namewhat, ar->name); /* use it */ - else if (*ar->what == 'm') /* main? */ - lua_pushliteral(L, "main chunk"); - else if (*ar->what != 'C') /* for Lua functions, use <file:line> */ - lua_pushfstring(L, "function <%s:%d>", ar->short_src, ar->linedefined); - else /* nothing left... */ - lua_pushliteral(L, "?"); -} - - -static int countlevels (lua_State *L) { - lua_Debug ar; - int li = 1, le = 1; - /* find an upper bound */ - while (lua_getstack(L, le, &ar)) { li = le; le *= 2; } - /* do a binary search */ - while (li < le) { - int m = (li + le)/2; - if (lua_getstack(L, m, &ar)) li = m + 1; - else le = m; - } - return le - 1; -} - - -LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, - const char *msg, int level) { - lua_Debug ar; - int top = lua_gettop(L); - int numlevels = countlevels(L1); - int mark = (numlevels > LEVELS1 + LEVELS2) ? LEVELS1 : 0; - if (msg) lua_pushfstring(L, "%s\n", msg); - lua_pushliteral(L, "stack traceback:"); - while (lua_getstack(L1, level++, &ar)) { - if (level == mark) { /* too many levels? */ - lua_pushliteral(L, "\n\t..."); /* add a '...' */ - level = numlevels - LEVELS2; /* and skip to last ones */ - } - else { - lua_getinfo(L1, "Slnt", &ar); - lua_pushfstring(L, "\n\t%s:", ar.short_src); - if (ar.currentline > 0) - lua_pushfstring(L, "%d:", ar.currentline); - lua_pushliteral(L, " in "); - pushfuncname(L, &ar); - if (ar.istailcall) - lua_pushliteral(L, "\n\t(...tail calls...)"); - lua_concat(L, lua_gettop(L) - top); - } - } - lua_concat(L, lua_gettop(L) - top); -} - -/* }====================================================== */ - - -/* -** {====================================================== -** Error-report functions -** ======================================================= -*/ - -LUALIB_API int luaL_argerror (lua_State *L, int arg, const char *extramsg) { - lua_Debug ar; - if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ - return luaL_error(L, "bad argument #%d (%s)", arg, extramsg); - lua_getinfo(L, "n", &ar); - if (strcmp(ar.namewhat, "method") == 0) { - arg--; /* do not count 'self' */ - if (arg == 0) /* error is in the self argument itself? */ - return luaL_error(L, "calling '%s' on bad self (%s)", - ar.name, extramsg); - } - if (ar.name == NULL) - ar.name = (pushglobalfuncname(L, &ar)) ? lua_tostring(L, -1) : "?"; - return luaL_error(L, "bad argument #%d to '%s' (%s)", - arg, ar.name, extramsg); -} - - -static int typeerror (lua_State *L, int arg, const char *tname) { - const char *msg; - const char *typearg; /* name for the type of the actual argument */ - if (luaL_getmetafield(L, arg, "__name") == LUA_TSTRING) - typearg = lua_tostring(L, -1); /* use the given type name */ - else if (lua_type(L, arg) == LUA_TLIGHTUSERDATA) - typearg = "light userdata"; /* special name for messages */ - else - typearg = luaL_typename(L, arg); /* standard name */ - msg = lua_pushfstring(L, "%s expected, got %s", tname, typearg); - return luaL_argerror(L, arg, msg); -} - - -static void tag_error (lua_State *L, int arg, int tag) { - typeerror(L, arg, lua_typename(L, tag)); -} - - -LUALIB_API void luaL_where (lua_State *L, int level) { - lua_Debug ar; - if (lua_getstack(L, level, &ar)) { /* check function at level */ - lua_getinfo(L, "Sl", &ar); /* get info about it */ - if (ar.currentline > 0) { /* is there info? */ - lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); - return; - } - } - lua_pushliteral(L, ""); /* else, no information available... */ -} - - -LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { - va_list argp; - va_start(argp, fmt); - luaL_where(L, 1); - lua_pushvfstring(L, fmt, argp); - va_end(argp); - lua_concat(L, 2); - return lua_error(L); -} - - -LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) { - int en = errno; /* calls to Lua API may change this value */ - if (stat) { - lua_pushboolean(L, 1); - return 1; - } - else { - lua_pushnil(L); - if (fname) - lua_pushfstring(L, "%s: %s", fname, strerror(en)); - else - lua_pushstring(L, strerror(en)); - lua_pushinteger(L, en); - return 3; - } -} - - -#if !defined(l_inspectstat) /* { */ - -#if defined(LUA_USE_POSIX) - -#include <sys/wait.h> - -/* -** use appropriate macros to interpret 'pclose' return status -*/ -#define l_inspectstat(stat,what) \ - if (WIFEXITED(stat)) { stat = WEXITSTATUS(stat); } \ - else if (WIFSIGNALED(stat)) { stat = WTERMSIG(stat); what = "signal"; } - -#else - -#define l_inspectstat(stat,what) /* no op */ - -#endif - -#endif /* } */ - - -LUALIB_API int luaL_execresult (lua_State *L, int stat) { - const char *what = "exit"; /* type of termination */ - if (stat == -1) /* error? */ - return luaL_fileresult(L, 0, NULL); - else { - l_inspectstat(stat, what); /* interpret result */ - if (*what == 'e' && stat == 0) /* successful termination? */ - lua_pushboolean(L, 1); - else - lua_pushnil(L); - lua_pushstring(L, what); - lua_pushinteger(L, stat); - return 3; /* return true/nil,what,code */ - } -} - -/* }====================================================== */ - - -/* -** {====================================================== -** Userdata's metatable manipulation -** ======================================================= -*/ - -LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { - if (luaL_getmetatable(L, tname)) /* name already in use? */ - return 0; /* leave previous value on top, but return 0 */ - lua_pop(L, 1); - lua_newtable(L); /* create metatable */ - lua_pushstring(L, tname); - lua_setfield(L, -2, "__name"); /* metatable.__name = tname */ - lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ - return 1; -} - - -LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) { - luaL_getmetatable(L, tname); - lua_setmetatable(L, -2); -} - - -LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) { - void *p = lua_touserdata(L, ud); - if (p != NULL) { /* value is a userdata? */ - if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ - luaL_getmetatable(L, tname); /* get correct metatable */ - if (!lua_rawequal(L, -1, -2)) /* not the same? */ - p = NULL; /* value is a userdata with wrong metatable */ - lua_pop(L, 2); /* remove both metatables */ - return p; - } - } - return NULL; /* value is not a userdata with a metatable */ -} - - -LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { - void *p = luaL_testudata(L, ud, tname); - if (p == NULL) typeerror(L, ud, tname); - return p; -} - -/* }====================================================== */ - - -/* -** {====================================================== -** Argument check functions -** ======================================================= -*/ - -LUALIB_API int luaL_checkoption (lua_State *L, int arg, const char *def, - const char *const lst[]) { - const char *name = (def) ? luaL_optstring(L, arg, def) : - luaL_checkstring(L, arg); - int i; - for (i=0; lst[i]; i++) - if (strcmp(lst[i], name) == 0) - return i; - return luaL_argerror(L, arg, - lua_pushfstring(L, "invalid option '%s'", name)); -} - - -LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) { - /* keep some extra space to run error routines, if needed */ - const int extra = LUA_MINSTACK; - if (!lua_checkstack(L, space + extra)) { - if (msg) - luaL_error(L, "stack overflow (%s)", msg); - else - luaL_error(L, "stack overflow"); - } -} - - -LUALIB_API void luaL_checktype (lua_State *L, int arg, int t) { - if (lua_type(L, arg) != t) - tag_error(L, arg, t); -} - - -LUALIB_API void luaL_checkany (lua_State *L, int arg) { - if (lua_type(L, arg) == LUA_TNONE) - luaL_argerror(L, arg, "value expected"); -} - - -LUALIB_API const char *luaL_checklstring (lua_State *L, int arg, size_t *len) { - const char *s = lua_tolstring(L, arg, len); - if (!s) tag_error(L, arg, LUA_TSTRING); - return s; -} - - -LUALIB_API const char *luaL_optlstring (lua_State *L, int arg, - const char *def, size_t *len) { - if (lua_isnoneornil(L, arg)) { - if (len) - *len = (def ? strlen(def) : 0); - return def; - } - else return luaL_checklstring(L, arg, len); -} - - -LUALIB_API lua_Number luaL_checknumber (lua_State *L, int arg) { - int isnum; - lua_Number d = lua_tonumberx(L, arg, &isnum); - if (!isnum) - tag_error(L, arg, LUA_TNUMBER); - return d; -} - - -LUALIB_API lua_Number luaL_optnumber (lua_State *L, int arg, lua_Number def) { - return luaL_opt(L, luaL_checknumber, arg, def); -} - - -static void interror (lua_State *L, int arg) { - if (lua_isnumber(L, arg)) - luaL_argerror(L, arg, "number has no integer representation"); - else - tag_error(L, arg, LUA_TNUMBER); -} - - -LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int arg) { - int isnum; - lua_Integer d = lua_tointegerx(L, arg, &isnum); - if (!isnum) { - interror(L, arg); - } - return d; -} - - -LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int arg, - lua_Integer def) { - return luaL_opt(L, luaL_checkinteger, arg, def); -} - -/* }====================================================== */ - - -/* -** {====================================================== -** Generic Buffer manipulation -** ======================================================= -*/ - -/* -** check whether buffer is using a userdata on the stack as a temporary -** buffer -*/ -#define buffonstack(B) ((B)->b != (B)->initb) - - -/* -** returns a pointer to a free area with at least 'sz' bytes -*/ -LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) { - lua_State *L = B->L; - if (B->size - B->n < sz) { /* not enough space? */ - char *newbuff; - size_t newsize = B->size * 2; /* double buffer size */ - if (newsize - B->n < sz) /* not big enough? */ - newsize = B->n + sz; - if (newsize < B->n || newsize - B->n < sz) - luaL_error(L, "buffer too large"); - /* create larger buffer */ - newbuff = (char *)lua_newuserdata(L, newsize * sizeof(char)); - /* move content to new buffer */ - memcpy(newbuff, B->b, B->n * sizeof(char)); - if (buffonstack(B)) - lua_remove(L, -2); /* remove old buffer */ - B->b = newbuff; - B->size = newsize; - } - return &B->b[B->n]; -} - - -LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { - char *b = luaL_prepbuffsize(B, l); - memcpy(b, s, l * sizeof(char)); - luaL_addsize(B, l); -} - - -LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { - luaL_addlstring(B, s, strlen(s)); -} - - -LUALIB_API void luaL_pushresult (luaL_Buffer *B) { - lua_State *L = B->L; - lua_pushlstring(L, B->b, B->n); - if (buffonstack(B)) - lua_remove(L, -2); /* remove old buffer */ -} - - -LUALIB_API void luaL_pushresultsize (luaL_Buffer *B, size_t sz) { - luaL_addsize(B, sz); - luaL_pushresult(B); -} - - -LUALIB_API void luaL_addvalue (luaL_Buffer *B) { - lua_State *L = B->L; - size_t l; - const char *s = lua_tolstring(L, -1, &l); - if (buffonstack(B)) - lua_insert(L, -2); /* put value below buffer */ - luaL_addlstring(B, s, l); - lua_remove(L, (buffonstack(B)) ? -2 : -1); /* remove value */ -} - - -LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { - B->L = L; - B->b = B->initb; - B->n = 0; - B->size = LUAL_BUFFERSIZE; -} - - -LUALIB_API char *luaL_buffinitsize (lua_State *L, luaL_Buffer *B, size_t sz) { - luaL_buffinit(L, B); - return luaL_prepbuffsize(B, sz); -} - -/* }====================================================== */ - - -/* -** {====================================================== -** Reference system -** ======================================================= -*/ - -/* index of free-list header */ -#define freelist 0 - - -LUALIB_API int luaL_ref (lua_State *L, int t) { - int ref; - if (lua_isnil(L, -1)) { - lua_pop(L, 1); /* remove from stack */ - return LUA_REFNIL; /* 'nil' has a unique fixed reference */ - } - t = lua_absindex(L, t); - lua_rawgeti(L, t, freelist); /* get first free element */ - ref = (int)lua_tointeger(L, -1); /* ref = t[freelist] */ - lua_pop(L, 1); /* remove it from stack */ - if (ref != 0) { /* any free element? */ - lua_rawgeti(L, t, ref); /* remove it from list */ - lua_rawseti(L, t, freelist); /* (t[freelist] = t[ref]) */ - } - else /* no free elements */ - ref = (int)lua_rawlen(L, t) + 1; /* get a new reference */ - lua_rawseti(L, t, ref); - return ref; -} - - -LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { - if (ref >= 0) { - t = lua_absindex(L, t); - lua_rawgeti(L, t, freelist); - lua_rawseti(L, t, ref); /* t[ref] = t[freelist] */ - lua_pushinteger(L, ref); - lua_rawseti(L, t, freelist); /* t[freelist] = ref */ - } -} - -/* }====================================================== */ - - -/* -** {====================================================== -** Load functions -** ======================================================= -*/ - -typedef struct LoadF { - int n; /* number of pre-read characters */ - FILE *f; /* file being read */ - char buff[BUFSIZ]; /* area for reading file */ -} LoadF; - - -static const char *getF (lua_State *L, void *ud, size_t *size) { - LoadF *lf = (LoadF *)ud; - (void)L; /* not used */ - if (lf->n > 0) { /* are there pre-read characters to be read? */ - *size = lf->n; /* return them (chars already in buffer) */ - lf->n = 0; /* no more pre-read characters */ - } - else { /* read a block from file */ - /* 'fread' can return > 0 *and* set the EOF flag. If next call to - 'getF' called 'fread', it might still wait for user input. - The next check avoids this problem. */ - if (feof(lf->f)) return NULL; - *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); /* read block */ - } - return lf->buff; -} - - -static int errfile (lua_State *L, const char *what, int fnameindex) { - const char *serr = strerror(errno); - const char *filename = lua_tostring(L, fnameindex) + 1; - lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); - lua_remove(L, fnameindex); - return LUA_ERRFILE; -} - - -static int skipBOM (LoadF *lf) { - const char *p = "\xEF\xBB\xBF"; /* Utf8 BOM mark */ - int c; - lf->n = 0; - do { - c = getc(lf->f); - if (c == EOF || c != *(const unsigned char *)p++) return c; - lf->buff[lf->n++] = c; /* to be read by the parser */ - } while (*p != '\0'); - lf->n = 0; /* prefix matched; discard it */ - return getc(lf->f); /* return next character */ -} - - -/* -** reads the first character of file 'f' and skips an optional BOM mark -** in its beginning plus its first line if it starts with '#'. Returns -** true if it skipped the first line. In any case, '*cp' has the -** first "valid" character of the file (after the optional BOM and -** a first-line comment). -*/ -static int skipcomment (LoadF *lf, int *cp) { - int c = *cp = skipBOM(lf); - if (c == '#') { /* first line is a comment (Unix exec. file)? */ - do { /* skip first line */ - c = getc(lf->f); - } while (c != EOF && c != '\n') ; - *cp = getc(lf->f); /* skip end-of-line, if present */ - return 1; /* there was a comment */ - } - else return 0; /* no comment */ -} - - -LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename, - const char *mode) { - LoadF lf; - int status, readstatus; - int c; - int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ - if (filename == NULL) { - lua_pushliteral(L, "=stdin"); - lf.f = stdin; - } - else { - lua_pushfstring(L, "@%s", filename); - lf.f = fopen(filename, "r"); - if (lf.f == NULL) return errfile(L, "open", fnameindex); - } - if (skipcomment(&lf, &c)) /* read initial portion */ - lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */ - if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ - lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ - if (lf.f == NULL) return errfile(L, "reopen", fnameindex); - skipcomment(&lf, &c); /* re-read initial portion */ - } - if (c != EOF) - lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */ - status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode); - readstatus = ferror(lf.f); - if (filename) fclose(lf.f); /* close file (even in case of errors) */ - if (readstatus) { - lua_settop(L, fnameindex); /* ignore results from 'lua_load' */ - return errfile(L, "read", fnameindex); - } - lua_remove(L, fnameindex); - return status; -} - - -typedef struct LoadS { - const char *s; - size_t size; -} LoadS; - - -static const char *getS (lua_State *L, void *ud, size_t *size) { - LoadS *ls = (LoadS *)ud; - (void)L; /* not used */ - if (ls->size == 0) return NULL; - *size = ls->size; - ls->size = 0; - return ls->s; -} - - -LUALIB_API int luaL_loadbufferx (lua_State *L, const char *buff, size_t size, - const char *name, const char *mode) { - LoadS ls; - ls.s = buff; - ls.size = size; - return lua_load(L, getS, &ls, name, mode); -} - - -LUALIB_API int luaL_loadstring (lua_State *L, const char *s) { - return luaL_loadbuffer(L, s, strlen(s), s); -} - -/* }====================================================== */ - - - -LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { - if (!lua_getmetatable(L, obj)) /* no metatable? */ - return LUA_TNIL; - else { - int tt; - lua_pushstring(L, event); - tt = lua_rawget(L, -2); - if (tt == LUA_TNIL) /* is metafield nil? */ - lua_pop(L, 2); /* remove metatable and metafield */ - else - lua_remove(L, -2); /* remove only metatable */ - return tt; /* return metafield type */ - } -} - - -LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { - obj = lua_absindex(L, obj); - if (luaL_getmetafield(L, obj, event) == LUA_TNIL) /* no metafield? */ - return 0; - lua_pushvalue(L, obj); - lua_call(L, 1, 1); - return 1; -} - - -LUALIB_API lua_Integer luaL_len (lua_State *L, int idx) { - lua_Integer l; - int isnum; - lua_len(L, idx); - l = lua_tointegerx(L, -1, &isnum); - if (!isnum) - luaL_error(L, "object length is not an integer"); - lua_pop(L, 1); /* remove object */ - return l; -} - - -LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) { - if (!luaL_callmeta(L, idx, "__tostring")) { /* no metafield? */ - switch (lua_type(L, idx)) { - case LUA_TNUMBER: { - if (lua_isinteger(L, idx)) - lua_pushfstring(L, "%I", lua_tointeger(L, idx)); - else - lua_pushfstring(L, "%f", lua_tonumber(L, idx)); - break; - } - case LUA_TSTRING: - lua_pushvalue(L, idx); - break; - case LUA_TBOOLEAN: - lua_pushstring(L, (lua_toboolean(L, idx) ? "true" : "false")); - break; - case LUA_TNIL: - lua_pushliteral(L, "nil"); - break; - default: - lua_pushfstring(L, "%s: %p", luaL_typename(L, idx), - lua_topointer(L, idx)); - break; - } - } - return lua_tolstring(L, -1, len); -} - - -/* -** {====================================================== -** Compatibility with 5.1 module functions -** ======================================================= -*/ -#if defined(LUA_COMPAT_MODULE) - -static const char *luaL_findtable (lua_State *L, int idx, - const char *fname, int szhint) { - const char *e; - if (idx) lua_pushvalue(L, idx); - do { - e = strchr(fname, '.'); - if (e == NULL) e = fname + strlen(fname); - lua_pushlstring(L, fname, e - fname); - if (lua_rawget(L, -2) == LUA_TNIL) { /* no such field? */ - lua_pop(L, 1); /* remove this nil */ - lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ - lua_pushlstring(L, fname, e - fname); - lua_pushvalue(L, -2); - lua_settable(L, -4); /* set new table into field */ - } - else if (!lua_istable(L, -1)) { /* field has a non-table value? */ - lua_pop(L, 2); /* remove table and value */ - return fname; /* return problematic part of the name */ - } - lua_remove(L, -2); /* remove previous table */ - fname = e + 1; - } while (*e == '.'); - return NULL; -} - - -/* -** Count number of elements in a luaL_Reg list. -*/ -static int libsize (const luaL_Reg *l) { - int size = 0; - for (; l && l->name; l++) size++; - return size; -} - - -/* -** Find or create a module table with a given name. The function -** first looks at the _LOADED table and, if that fails, try a -** global variable with that name. In any case, leaves on the stack -** the module table. -*/ -LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname, - int sizehint) { - luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); /* get _LOADED table */ - if (lua_getfield(L, -1, modname) != LUA_TTABLE) { /* no _LOADED[modname]? */ - lua_pop(L, 1); /* remove previous result */ - /* try global variable (and create one if it does not exist) */ - lua_pushglobaltable(L); - if (luaL_findtable(L, 0, modname, sizehint) != NULL) - luaL_error(L, "name conflict for module '%s'", modname); - lua_pushvalue(L, -1); - lua_setfield(L, -3, modname); /* _LOADED[modname] = new table */ - } - lua_remove(L, -2); /* remove _LOADED table */ -} - - -LUALIB_API void luaL_openlib (lua_State *L, const char *libname, - const luaL_Reg *l, int nup) { - luaL_checkversion(L); - if (libname) { - luaL_pushmodule(L, libname, libsize(l)); /* get/create library table */ - lua_insert(L, -(nup + 1)); /* move library table to below upvalues */ - } - if (l) - luaL_setfuncs(L, l, nup); - else - lua_pop(L, nup); /* remove upvalues */ -} - -#endif -/* }====================================================== */ - -/* -** set functions from list 'l' into table at top - 'nup'; each -** function gets the 'nup' elements at the top as upvalues. -** Returns with only the table at the stack. -*/ -LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { - luaL_checkstack(L, nup, "too many upvalues"); - for (; l->name != NULL; l++) { /* fill the table with given functions */ - int i; - for (i = 0; i < nup; i++) /* copy upvalues to the top */ - lua_pushvalue(L, -nup); - lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ - lua_setfield(L, -(nup + 2), l->name); - } - lua_pop(L, nup); /* remove upvalues */ -} - - -/* -** ensure that stack[idx][fname] has a table and push that table -** into the stack -*/ -LUALIB_API int luaL_getsubtable (lua_State *L, int idx, const char *fname) { - if (lua_getfield(L, idx, fname) == LUA_TTABLE) - return 1; /* table already there */ - else { - lua_pop(L, 1); /* remove previous result */ - idx = lua_absindex(L, idx); - lua_newtable(L); - lua_pushvalue(L, -1); /* copy to be left at top */ - lua_setfield(L, idx, fname); /* assign new table to field */ - return 0; /* false, because did not find table there */ - } -} - - -/* -** Stripped-down 'require': After checking "loaded" table, calls 'openf' -** to open a module, registers the result in 'package.loaded' table and, -** if 'glb' is true, also registers the result in the global table. -** Leaves resulting module on the top. -*/ -LUALIB_API void luaL_requiref (lua_State *L, const char *modname, - lua_CFunction openf, int glb) { - luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_getfield(L, -1, modname); /* _LOADED[modname] */ - if (!lua_toboolean(L, -1)) { /* package not already loaded? */ - lua_pop(L, 1); /* remove field */ - lua_pushcfunction(L, openf); - lua_pushstring(L, modname); /* argument to open function */ - lua_call(L, 1, 1); /* call 'openf' to open module */ - lua_pushvalue(L, -1); /* make copy of module (call result) */ - lua_setfield(L, -3, modname); /* _LOADED[modname] = module */ - } - lua_remove(L, -2); /* remove _LOADED table */ - if (glb) { - lua_pushvalue(L, -1); /* copy of module */ - lua_setglobal(L, modname); /* _G[modname] = module */ - } -} - - -LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, - const char *r) { - const char *wild; - size_t l = strlen(p); - luaL_Buffer b; - luaL_buffinit(L, &b); - while ((wild = strstr(s, p)) != NULL) { - luaL_addlstring(&b, s, wild - s); /* push prefix */ - luaL_addstring(&b, r); /* push replacement in place of pattern */ - s = wild + l; /* continue after 'p' */ - } - luaL_addstring(&b, s); /* push last suffix */ - luaL_pushresult(&b); - return lua_tostring(L, -1); -} - - -static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { - (void)ud; (void)osize; /* not used */ - if (nsize == 0) { - free(ptr); - return NULL; - } - else - return realloc(ptr, nsize); -} - - -static int panic (lua_State *L) { - lua_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n", - lua_tostring(L, -1)); - return 0; /* return to Lua to abort */ -} - - -LUALIB_API lua_State *luaL_newstate (void) { - lua_State *L = lua_newstate(l_alloc, NULL); - if (L) lua_atpanic(L, &panic); - return L; -} - - -LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver, size_t sz) { - const lua_Number *v = lua_version(L); - if (sz != LUAL_NUMSIZES) /* check numeric types */ - luaL_error(L, "core and library have incompatible numeric types"); - if (v != lua_version(NULL)) - luaL_error(L, "multiple Lua VMs detected"); - else if (*v != ver) - luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f", - ver, *v); -} - diff --git a/thirdparty/src/Lua/lbaselib.cpp b/thirdparty/src/Lua/lbaselib.cpp deleted file mode 100644 index c231782c6..000000000 --- a/thirdparty/src/Lua/lbaselib.cpp +++ /dev/null @@ -1,520 +0,0 @@ -/* -** $Id: lbaselib.c,v 1.309 2014/12/10 12:26:42 roberto Exp $ -** Basic library -** See Copyright Notice in lua.h -*/ - -#define lbaselib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <Lua/lua.h> - -#include <Lua/lauxlib.h> -#include <Lua/lualib.h> - - -static int luaB_print (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - int i; - lua_getglobal(L, "tostring"); - for (i=1; i<=n; i++) { - const char *s; - size_t l; - lua_pushvalue(L, -1); /* function to be called */ - lua_pushvalue(L, i); /* value to print */ - lua_call(L, 1, 1); - s = lua_tolstring(L, -1, &l); /* get result */ - if (s == NULL) - return luaL_error(L, "'tostring' must return a string to 'print'"); - if (i>1) lua_writestring("\t", 1); - lua_writestring(s, l); - lua_pop(L, 1); /* pop result */ - } - lua_writeline(); - return 0; -} - - -#define SPACECHARS " \f\n\r\t\v" - -static const char *b_str2int (const char *s, int base, lua_Integer *pn) { - lua_Unsigned n = 0; - int neg = 0; - s += strspn(s, SPACECHARS); /* skip initial spaces */ - if (*s == '-') { s++; neg = 1; } /* handle signal */ - else if (*s == '+') s++; - if (!isalnum((unsigned char)*s)) /* no digit? */ - return NULL; - do { - int digit = (isdigit((unsigned char)*s)) ? *s - '0' - : toupper((unsigned char)*s) - 'A' + 10; - if (digit >= base) return NULL; /* invalid numeral */ - n = n * base + digit; - s++; - } while (isalnum((unsigned char)*s)); - s += strspn(s, SPACECHARS); /* skip trailing spaces */ - *pn = (lua_Integer)((neg) ? (0u - n) : n); - return s; -} - - -static int luaB_tonumber (lua_State *L) { - if (lua_isnoneornil(L, 2)) { /* standard conversion? */ - luaL_checkany(L, 1); - if (lua_type(L, 1) == LUA_TNUMBER) { /* already a number? */ - lua_settop(L, 1); /* yes; return it */ - return 1; - } - else { - size_t l; - const char *s = lua_tolstring(L, 1, &l); - if (s != NULL && lua_stringtonumber(L, s) == l + 1) - return 1; /* successful conversion to number */ - /* else not a number */ - } - } - else { - size_t l; - const char *s; - lua_Integer n = 0; /* to avoid warnings */ - lua_Integer base = luaL_checkinteger(L, 2); - luaL_checktype(L, 1, LUA_TSTRING); /* before 'luaL_checklstring'! */ - s = luaL_checklstring(L, 1, &l); - luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); - if (b_str2int(s, (int)base, &n) == s + l) { - lua_pushinteger(L, n); - return 1; - } /* else not a number */ - } /* else not a number */ - lua_pushnil(L); /* not a number */ - return 1; -} - - -static int luaB_error (lua_State *L) { - int level = (int)luaL_optinteger(L, 2, 1); - lua_settop(L, 1); - if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ - luaL_where(L, level); - lua_pushvalue(L, 1); - lua_concat(L, 2); - } - return lua_error(L); -} - - -static int luaB_getmetatable (lua_State *L) { - luaL_checkany(L, 1); - if (!lua_getmetatable(L, 1)) { - lua_pushnil(L); - return 1; /* no metatable */ - } - luaL_getmetafield(L, 1, "__metatable"); - return 1; /* returns either __metatable field (if present) or metatable */ -} - - -static int luaB_setmetatable (lua_State *L) { - int t = lua_type(L, 2); - luaL_checktype(L, 1, LUA_TTABLE); - luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, - "nil or table expected"); - if (luaL_getmetafield(L, 1, "__metatable") != LUA_TNIL) - return luaL_error(L, "cannot change a protected metatable"); - lua_settop(L, 2); - lua_setmetatable(L, 1); - return 1; -} - - -static int luaB_rawequal (lua_State *L) { - luaL_checkany(L, 1); - luaL_checkany(L, 2); - lua_pushboolean(L, lua_rawequal(L, 1, 2)); - return 1; -} - - -static int luaB_rawlen (lua_State *L) { - int t = lua_type(L, 1); - luaL_argcheck(L, t == LUA_TTABLE || t == LUA_TSTRING, 1, - "table or string expected"); - lua_pushinteger(L, lua_rawlen(L, 1)); - return 1; -} - - -static int luaB_rawget (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checkany(L, 2); - lua_settop(L, 2); - lua_rawget(L, 1); - return 1; -} - -static int luaB_rawset (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - luaL_checkany(L, 2); - luaL_checkany(L, 3); - lua_settop(L, 3); - lua_rawset(L, 1); - return 1; -} - - -static int luaB_collectgarbage (lua_State *L) { - static const char *const opts[] = {"stop", "restart", "collect", - "count", "step", "setpause", "setstepmul", - "isrunning", NULL}; - static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, - LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, - LUA_GCISRUNNING}; - int o = optsnum[luaL_checkoption(L, 1, "collect", opts)]; - int ex = (int)luaL_optinteger(L, 2, 0); - int res = lua_gc(L, o, ex); - switch (o) { - case LUA_GCCOUNT: { - int b = lua_gc(L, LUA_GCCOUNTB, 0); - lua_pushnumber(L, (lua_Number)res + ((lua_Number)b/1024)); - return 1; - } - case LUA_GCSTEP: case LUA_GCISRUNNING: { - lua_pushboolean(L, res); - return 1; - } - default: { - lua_pushinteger(L, res); - return 1; - } - } -} - - -/* -** This function has all type names as upvalues, to maximize performance. -*/ -static int luaB_type (lua_State *L) { - luaL_checkany(L, 1); - lua_pushvalue(L, lua_upvalueindex(lua_type(L, 1) + 1)); - return 1; -} - - -static int pairsmeta (lua_State *L, const char *method, int iszero, - lua_CFunction iter) { - if (luaL_getmetafield(L, 1, method) == LUA_TNIL) { /* no metamethod? */ - luaL_checktype(L, 1, LUA_TTABLE); /* argument must be a table */ - lua_pushcfunction(L, iter); /* will return generator, */ - lua_pushvalue(L, 1); /* state, */ - if (iszero) lua_pushinteger(L, 0); /* and initial value */ - else lua_pushnil(L); - } - else { - lua_pushvalue(L, 1); /* argument 'self' to metamethod */ - lua_call(L, 1, 3); /* get 3 values from metamethod */ - } - return 3; -} - - -static int luaB_next (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - lua_settop(L, 2); /* create a 2nd argument if there isn't one */ - if (lua_next(L, 1)) - return 2; - else { - lua_pushnil(L); - return 1; - } -} - - -static int luaB_pairs (lua_State *L) { - return pairsmeta(L, "__pairs", 0, luaB_next); -} - - -/* -** Traversal function for 'ipairs' for raw tables -*/ -static int ipairsaux_raw (lua_State *L) { - lua_Integer i = luaL_checkinteger(L, 2) + 1; - luaL_checktype(L, 1, LUA_TTABLE); - lua_pushinteger(L, i); - return (lua_rawgeti(L, 1, i) == LUA_TNIL) ? 1 : 2; -} - - -/* -** Traversal function for 'ipairs' for tables with metamethods -*/ -static int ipairsaux (lua_State *L) { - lua_Integer i = luaL_checkinteger(L, 2) + 1; - lua_pushinteger(L, i); - return (lua_geti(L, 1, i) == LUA_TNIL) ? 1 : 2; -} - - -/* -** This function will use either 'ipairsaux' or 'ipairsaux_raw' to -** traverse a table, depending on whether the table has metamethods -** that can affect the traversal. -*/ -static int luaB_ipairs (lua_State *L) { - lua_CFunction iter = (luaL_getmetafield(L, 1, "__index") != LUA_TNIL) - ? ipairsaux : ipairsaux_raw; -#if defined(LUA_COMPAT_IPAIRS) - return pairsmeta(L, "__ipairs", 1, iter); -#else - luaL_checkany(L, 1); - lua_pushcfunction(L, iter); /* iteration function */ - lua_pushvalue(L, 1); /* state */ - lua_pushinteger(L, 0); /* initial value */ - return 3; -#endif -} - - -static int load_aux (lua_State *L, int status, int envidx) { - if (status == LUA_OK) { - if (envidx != 0) { /* 'env' parameter? */ - lua_pushvalue(L, envidx); /* environment for loaded function */ - if (!lua_setupvalue(L, -2, 1)) /* set it as 1st upvalue */ - lua_pop(L, 1); /* remove 'env' if not used by previous call */ - } - return 1; - } - else { /* error (message is on top of the stack) */ - lua_pushnil(L); - lua_insert(L, -2); /* put before error message */ - return 2; /* return nil plus error message */ - } -} - - -static int luaB_loadfile (lua_State *L) { - const char *fname = luaL_optstring(L, 1, NULL); - const char *mode = luaL_optstring(L, 2, NULL); - int env = (!lua_isnone(L, 3) ? 3 : 0); /* 'env' index or 0 if no 'env' */ - int status = luaL_loadfilex(L, fname, mode); - return load_aux(L, status, env); -} - - -/* -** {====================================================== -** Generic Read function -** ======================================================= -*/ - - -/* -** reserved slot, above all arguments, to hold a copy of the returned -** string to avoid it being collected while parsed. 'load' has four -** optional arguments (chunk, source name, mode, and environment). -*/ -#define RESERVEDSLOT 5 - - -/* -** Reader for generic 'load' function: 'lua_load' uses the -** stack for internal stuff, so the reader cannot change the -** stack top. Instead, it keeps its resulting string in a -** reserved slot inside the stack. -*/ -static const char *generic_reader (lua_State *L, void *ud, size_t *size) { - (void)(ud); /* not used */ - luaL_checkstack(L, 2, "too many nested functions"); - lua_pushvalue(L, 1); /* get function */ - lua_call(L, 0, 1); /* call it */ - if (lua_isnil(L, -1)) { - lua_pop(L, 1); /* pop result */ - *size = 0; - return NULL; - } - else if (!lua_isstring(L, -1)) - luaL_error(L, "reader function must return a string"); - lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ - return lua_tolstring(L, RESERVEDSLOT, size); -} - - -static int luaB_load (lua_State *L) { - int status; - size_t l; - const char *s = lua_tolstring(L, 1, &l); - const char *mode = luaL_optstring(L, 3, "bt"); - int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */ - if (s != NULL) { /* loading a string? */ - const char *chunkname = luaL_optstring(L, 2, s); - status = luaL_loadbufferx(L, s, l, chunkname, mode); - } - else { /* loading from a reader function */ - const char *chunkname = luaL_optstring(L, 2, "=(load)"); - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_settop(L, RESERVEDSLOT); /* create reserved slot */ - status = lua_load(L, generic_reader, NULL, chunkname, mode); - } - return load_aux(L, status, env); -} - -/* }====================================================== */ - - -static int dofilecont (lua_State *L, int d1, lua_KContext d2) { - (void)d1; (void)d2; /* only to match 'lua_Kfunction' prototype */ - return lua_gettop(L) - 1; -} - - -static int luaB_dofile (lua_State *L) { - const char *fname = luaL_optstring(L, 1, NULL); - lua_settop(L, 1); - if (luaL_loadfile(L, fname) != LUA_OK) - return lua_error(L); - lua_callk(L, 0, LUA_MULTRET, 0, dofilecont); - return dofilecont(L, 0, 0); -} - - -static int luaB_assert (lua_State *L) { - if (lua_toboolean(L, 1)) /* condition is true? */ - return lua_gettop(L); /* return all arguments */ - else { /* error */ - luaL_checkany(L, 1); /* there must be a condition */ - lua_remove(L, 1); /* remove it */ - lua_pushliteral(L, "assertion failed!"); /* default message */ - lua_settop(L, 1); /* leave only message (default if no other one) */ - return luaB_error(L); /* call 'error' */ - } -} - - -static int luaB_select (lua_State *L) { - int n = lua_gettop(L); - if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { - lua_pushinteger(L, n-1); - return 1; - } - else { - lua_Integer i = luaL_checkinteger(L, 1); - if (i < 0) i = n + i; - else if (i > n) i = n; - luaL_argcheck(L, 1 <= i, 1, "index out of range"); - return n - (int)i; - } -} - - -/* -** Continuation function for 'pcall' and 'xpcall'. Both functions -** already pushed a 'true' before doing the call, so in case of success -** 'finishpcall' only has to return everything in the stack minus -** 'extra' values (where 'extra' is exactly the number of items to be -** ignored). -*/ -static int finishpcall (lua_State *L, int status, lua_KContext extra) { - if (status != LUA_OK && status != LUA_YIELD) { /* error? */ - lua_pushboolean(L, 0); /* first result (false) */ - lua_pushvalue(L, -2); /* error message */ - return 2; /* return false, msg */ - } - else - return lua_gettop(L) - (int)extra; /* return all results */ -} - - -static int luaB_pcall (lua_State *L) { - int status; - luaL_checkany(L, 1); - lua_pushboolean(L, 1); /* first result if no errors */ - lua_insert(L, 1); /* put it in place */ - status = lua_pcallk(L, lua_gettop(L) - 2, LUA_MULTRET, 0, 0, finishpcall); - return finishpcall(L, status, 0); -} - - -/* -** Do a protected call with error handling. After 'lua_rotate', the -** stack will have <f, err, true, f, [args...]>; so, the function passes -** 2 to 'finishpcall' to skip the 2 first values when returning results. -*/ -static int luaB_xpcall (lua_State *L) { - int status; - int n = lua_gettop(L); - luaL_checktype(L, 2, LUA_TFUNCTION); /* check error function */ - lua_pushboolean(L, 1); /* first result */ - lua_pushvalue(L, 1); /* function */ - lua_rotate(L, 3, 2); /* move them below function's arguments */ - status = lua_pcallk(L, n - 2, LUA_MULTRET, 2, 2, finishpcall); - return finishpcall(L, status, 2); -} - - -static int luaB_tostring (lua_State *L) { - luaL_checkany(L, 1); - luaL_tolstring(L, 1, NULL); - return 1; -} - - -static const luaL_Reg base_funcs[] = { - {"assert", luaB_assert}, - {"collectgarbage", luaB_collectgarbage}, - {"dofile", luaB_dofile}, - {"error", luaB_error}, - {"getmetatable", luaB_getmetatable}, - {"ipairs", luaB_ipairs}, - {"loadfile", luaB_loadfile}, - {"load", luaB_load}, -#if defined(LUA_COMPAT_LOADSTRING) - {"loadstring", luaB_load}, -#endif - {"next", luaB_next}, - {"pairs", luaB_pairs}, - {"pcall", luaB_pcall}, - {"print", luaB_print}, - {"rawequal", luaB_rawequal}, - {"rawlen", luaB_rawlen}, - {"rawget", luaB_rawget}, - {"rawset", luaB_rawset}, - {"select", luaB_select}, - {"setmetatable", luaB_setmetatable}, - {"tonumber", luaB_tonumber}, - {"tostring", luaB_tostring}, - {"xpcall", luaB_xpcall}, - /* placeholders */ - {"type", NULL}, - {"_G", NULL}, - {"_VERSION", NULL}, - {NULL, NULL} -}; - - -LUAMOD_API int luaopen_base (lua_State *L) { - int i; - /* open lib into global table */ - lua_pushglobaltable(L); - luaL_setfuncs(L, base_funcs, 0); - /* set global _G */ - lua_pushvalue(L, -1); - lua_setfield(L, -2, "_G"); - /* set global _VERSION */ - lua_pushliteral(L, LUA_VERSION); - lua_setfield(L, -2, "_VERSION"); - /* set function 'type' with proper upvalues */ - for (i = 0; i < LUA_NUMTAGS; i++) /* push all type names as upvalues */ - lua_pushstring(L, lua_typename(L, i)); - lua_pushcclosure(L, luaB_type, LUA_NUMTAGS); - lua_setfield(L, -2, "type"); - return 1; -} - diff --git a/thirdparty/src/Lua/lbitlib.cpp b/thirdparty/src/Lua/lbitlib.cpp deleted file mode 100644 index dc5ebc8d7..000000000 --- a/thirdparty/src/Lua/lbitlib.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* -** $Id: lbitlib.c,v 1.28 2014/11/02 19:19:04 roberto Exp $ -** Standard library for bitwise operations -** See Copyright Notice in lua.h -*/ - -#define lbitlib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include <Lua/lua.h> - -#include <Lua/lauxlib.h> -#include <Lua/lualib.h> - - -#if defined(LUA_COMPAT_BITLIB) /* { */ - - -/* number of bits to consider in a number */ -#if !defined(LUA_NBITS) -#define LUA_NBITS 32 -#endif - - -/* -** a lua_Unsigned with its first LUA_NBITS bits equal to 1. (Shift must -** be made in two parts to avoid problems when LUA_NBITS is equal to the -** number of bits in a lua_Unsigned.) -*/ -#define ALLONES (~(((~(lua_Unsigned)0) << (LUA_NBITS - 1)) << 1)) - - -/* macro to trim extra bits */ -#define trim(x) ((x) & ALLONES) - - -/* builds a number with 'n' ones (1 <= n <= LUA_NBITS) */ -#define mask(n) (~((ALLONES << 1) << ((n) - 1))) - - - -static lua_Unsigned andaux (lua_State *L) { - int i, n = lua_gettop(L); - lua_Unsigned r = ~(lua_Unsigned)0; - for (i = 1; i <= n; i++) - r &= luaL_checkunsigned(L, i); - return trim(r); -} - - -static int b_and (lua_State *L) { - lua_Unsigned r = andaux(L); - lua_pushunsigned(L, r); - return 1; -} - - -static int b_test (lua_State *L) { - lua_Unsigned r = andaux(L); - lua_pushboolean(L, r != 0); - return 1; -} - - -static int b_or (lua_State *L) { - int i, n = lua_gettop(L); - lua_Unsigned r = 0; - for (i = 1; i <= n; i++) - r |= luaL_checkunsigned(L, i); - lua_pushunsigned(L, trim(r)); - return 1; -} - - -static int b_xor (lua_State *L) { - int i, n = lua_gettop(L); - lua_Unsigned r = 0; - for (i = 1; i <= n; i++) - r ^= luaL_checkunsigned(L, i); - lua_pushunsigned(L, trim(r)); - return 1; -} - - -static int b_not (lua_State *L) { - lua_Unsigned r = ~luaL_checkunsigned(L, 1); - lua_pushunsigned(L, trim(r)); - return 1; -} - - -static int b_shift (lua_State *L, lua_Unsigned r, lua_Integer i) { - if (i < 0) { /* shift right? */ - i = -i; - r = trim(r); - if (i >= LUA_NBITS) r = 0; - else r >>= i; - } - else { /* shift left */ - if (i >= LUA_NBITS) r = 0; - else r <<= i; - r = trim(r); - } - lua_pushunsigned(L, r); - return 1; -} - - -static int b_lshift (lua_State *L) { - return b_shift(L, luaL_checkunsigned(L, 1), luaL_checkinteger(L, 2)); -} - - -static int b_rshift (lua_State *L) { - return b_shift(L, luaL_checkunsigned(L, 1), -luaL_checkinteger(L, 2)); -} - - -static int b_arshift (lua_State *L) { - lua_Unsigned r = luaL_checkunsigned(L, 1); - lua_Integer i = luaL_checkinteger(L, 2); - if (i < 0 || !(r & ((lua_Unsigned)1 << (LUA_NBITS - 1)))) - return b_shift(L, r, -i); - else { /* arithmetic shift for 'negative' number */ - if (i >= LUA_NBITS) r = ALLONES; - else - r = trim((r >> i) | ~(trim(~(lua_Unsigned)0) >> i)); /* add signal bit */ - lua_pushunsigned(L, r); - return 1; - } -} - - -static int b_rot (lua_State *L, lua_Integer d) { - lua_Unsigned r = luaL_checkunsigned(L, 1); - int i = d & (LUA_NBITS - 1); /* i = d % NBITS */ - r = trim(r); - if (i != 0) /* avoid undefined shift of LUA_NBITS when i == 0 */ - r = (r << i) | (r >> (LUA_NBITS - i)); - lua_pushunsigned(L, trim(r)); - return 1; -} - - -static int b_lrot (lua_State *L) { - return b_rot(L, luaL_checkinteger(L, 2)); -} - - -static int b_rrot (lua_State *L) { - return b_rot(L, -luaL_checkinteger(L, 2)); -} - - -/* -** get field and width arguments for field-manipulation functions, -** checking whether they are valid. -** ('luaL_error' called without 'return' to avoid later warnings about -** 'width' being used uninitialized.) -*/ -static int fieldargs (lua_State *L, int farg, int *width) { - lua_Integer f = luaL_checkinteger(L, farg); - lua_Integer w = luaL_optinteger(L, farg + 1, 1); - luaL_argcheck(L, 0 <= f, farg, "field cannot be negative"); - luaL_argcheck(L, 0 < w, farg + 1, "width must be positive"); - if (f + w > LUA_NBITS) - luaL_error(L, "trying to access non-existent bits"); - *width = (int)w; - return (int)f; -} - - -static int b_extract (lua_State *L) { - int w; - lua_Unsigned r = trim(luaL_checkunsigned(L, 1)); - int f = fieldargs(L, 2, &w); - r = (r >> f) & mask(w); - lua_pushunsigned(L, r); - return 1; -} - - -static int b_replace (lua_State *L) { - int w; - lua_Unsigned r = trim(luaL_checkunsigned(L, 1)); - lua_Unsigned v = luaL_checkunsigned(L, 2); - int f = fieldargs(L, 3, &w); - int m = mask(w); - v &= m; /* erase bits outside given width */ - r = (r & ~(m << f)) | (v << f); - lua_pushunsigned(L, r); - return 1; -} - - -static const luaL_Reg bitlib[] = { - {"arshift", b_arshift}, - {"band", b_and}, - {"bnot", b_not}, - {"bor", b_or}, - {"bxor", b_xor}, - {"btest", b_test}, - {"extract", b_extract}, - {"lrotate", b_lrot}, - {"lshift", b_lshift}, - {"replace", b_replace}, - {"rrotate", b_rrot}, - {"rshift", b_rshift}, - {NULL, NULL} -}; - - - -LUAMOD_API int luaopen_bit32 (lua_State *L) { - luaL_newlib(L, bitlib); - return 1; -} - - -#else /* }{ */ - - -LUAMOD_API int luaopen_bit32 (lua_State *L) { - return luaL_error(L, "library 'bit32' has been deprecated"); -} - -#endif /* } */ diff --git a/thirdparty/src/Lua/lcode.cpp b/thirdparty/src/Lua/lcode.cpp deleted file mode 100644 index 0ce023a85..000000000 --- a/thirdparty/src/Lua/lcode.cpp +++ /dev/null @@ -1,954 +0,0 @@ -/* -** $Id: lcode.c,v 2.99 2014/12/29 16:49:25 roberto Exp $ -** Code generator for Lua -** See Copyright Notice in lua.h -*/ - -#define lcode_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <math.h> -#include <stdlib.h> - -#include <Lua/lua.h> - -#include "lcode.h" -#include "ldebug.h" -#include "ldo.h" -#include "lgc.h" -#include "llex.h" -#include "lmem.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lparser.h" -#include "lstring.h" -#include "ltable.h" -#include "lvm.h" - - -/* Maximum number of registers in a Lua function */ -#define MAXREGS 250 - - -#define hasjumps(e) ((e)->t != (e)->f) - - -static int tonumeral(expdesc *e, TValue *v) { - if (e->t != NO_JUMP || e->f != NO_JUMP) - return 0; /* not a numeral */ - switch (e->k) { - case VKINT: - if (v) setivalue(v, e->u.ival); - return 1; - case VKFLT: - if (v) setfltvalue(v, e->u.nval); - return 1; - default: return 0; - } -} - - -void luaK_nil (FuncState *fs, int from, int n) { - Instruction *previous; - int l = from + n - 1; /* last register to set nil */ - if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ - previous = &fs->f->code[fs->pc-1]; - if (GET_OPCODE(*previous) == OP_LOADNIL) { - int pfrom = GETARG_A(*previous); - int pl = pfrom + GETARG_B(*previous); - if ((pfrom <= from && from <= pl + 1) || - (from <= pfrom && pfrom <= l + 1)) { /* can connect both? */ - if (pfrom < from) from = pfrom; /* from = min(from, pfrom) */ - if (pl > l) l = pl; /* l = max(l, pl) */ - SETARG_A(*previous, from); - SETARG_B(*previous, l - from); - return; - } - } /* else go through */ - } - luaK_codeABC(fs, OP_LOADNIL, from, n - 1, 0); /* else no optimization */ -} - - -int luaK_jump (FuncState *fs) { - int jpc = fs->jpc; /* save list of jumps to here */ - int j; - fs->jpc = NO_JUMP; - j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); - luaK_concat(fs, &j, jpc); /* keep them on hold */ - return j; -} - - -void luaK_ret (FuncState *fs, int first, int nret) { - luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); -} - - -static int condjump (FuncState *fs, OpCode op, int A, int B, int C) { - luaK_codeABC(fs, op, A, B, C); - return luaK_jump(fs); -} - - -static void fixjump (FuncState *fs, int pc, int dest) { - Instruction *jmp = &fs->f->code[pc]; - int offset = dest-(pc+1); - lua_assert(dest != NO_JUMP); - if (abs(offset) > MAXARG_sBx) - luaX_syntaxerror(fs->ls, "control structure too long"); - SETARG_sBx(*jmp, offset); -} - - -/* -** returns current 'pc' and marks it as a jump target (to avoid wrong -** optimizations with consecutive instructions not in the same basic block). -*/ -int luaK_getlabel (FuncState *fs) { - fs->lasttarget = fs->pc; - return fs->pc; -} - - -static int getjump (FuncState *fs, int pc) { - int offset = GETARG_sBx(fs->f->code[pc]); - if (offset == NO_JUMP) /* point to itself represents end of list */ - return NO_JUMP; /* end of list */ - else - return (pc+1)+offset; /* turn offset into absolute position */ -} - - -static Instruction *getjumpcontrol (FuncState *fs, int pc) { - Instruction *pi = &fs->f->code[pc]; - if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) - return pi-1; - else - return pi; -} - - -/* -** check whether list has any jump that do not produce a value -** (or produce an inverted value) -*/ -static int need_value (FuncState *fs, int list) { - for (; list != NO_JUMP; list = getjump(fs, list)) { - Instruction i = *getjumpcontrol(fs, list); - if (GET_OPCODE(i) != OP_TESTSET) return 1; - } - return 0; /* not found */ -} - - -static int patchtestreg (FuncState *fs, int node, int reg) { - Instruction *i = getjumpcontrol(fs, node); - if (GET_OPCODE(*i) != OP_TESTSET) - return 0; /* cannot patch other instructions */ - if (reg != NO_REG && reg != GETARG_B(*i)) - SETARG_A(*i, reg); - else /* no register to put value or register already has the value */ - *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); - - return 1; -} - - -static void removevalues (FuncState *fs, int list) { - for (; list != NO_JUMP; list = getjump(fs, list)) - patchtestreg(fs, list, NO_REG); -} - - -static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, - int dtarget) { - while (list != NO_JUMP) { - int next = getjump(fs, list); - if (patchtestreg(fs, list, reg)) - fixjump(fs, list, vtarget); - else - fixjump(fs, list, dtarget); /* jump to default target */ - list = next; - } -} - - -static void dischargejpc (FuncState *fs) { - patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); - fs->jpc = NO_JUMP; -} - - -void luaK_patchlist (FuncState *fs, int list, int target) { - if (target == fs->pc) - luaK_patchtohere(fs, list); - else { - lua_assert(target < fs->pc); - patchlistaux(fs, list, target, NO_REG, target); - } -} - - -void luaK_patchclose (FuncState *fs, int list, int level) { - level++; /* argument is +1 to reserve 0 as non-op */ - while (list != NO_JUMP) { - int next = getjump(fs, list); - lua_assert(GET_OPCODE(fs->f->code[list]) == OP_JMP && - (GETARG_A(fs->f->code[list]) == 0 || - GETARG_A(fs->f->code[list]) >= level)); - SETARG_A(fs->f->code[list], level); - list = next; - } -} - - -void luaK_patchtohere (FuncState *fs, int list) { - luaK_getlabel(fs); - luaK_concat(fs, &fs->jpc, list); -} - - -void luaK_concat (FuncState *fs, int *l1, int l2) { - if (l2 == NO_JUMP) return; - else if (*l1 == NO_JUMP) - *l1 = l2; - else { - int list = *l1; - int next; - while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ - list = next; - fixjump(fs, list, l2); - } -} - - -static int luaK_code (FuncState *fs, Instruction i) { - Proto *f = fs->f; - dischargejpc(fs); /* 'pc' will change */ - /* put new instruction in code array */ - luaM_growvector(fs->ls->L, f->code, fs->pc, f->sizecode, Instruction, - MAX_INT, "opcodes"); - f->code[fs->pc] = i; - /* save corresponding line information */ - luaM_growvector(fs->ls->L, f->lineinfo, fs->pc, f->sizelineinfo, int, - MAX_INT, "opcodes"); - f->lineinfo[fs->pc] = fs->ls->lastline; - return fs->pc++; -} - - -int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { - lua_assert(getOpMode(o) == iABC); - lua_assert(getBMode(o) != OpArgN || b == 0); - lua_assert(getCMode(o) != OpArgN || c == 0); - lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C); - return luaK_code(fs, CREATE_ABC(o, a, b, c)); -} - - -int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { - lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); - lua_assert(getCMode(o) == OpArgN); - lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx); - return luaK_code(fs, CREATE_ABx(o, a, bc)); -} - - -static int codeextraarg (FuncState *fs, int a) { - lua_assert(a <= MAXARG_Ax); - return luaK_code(fs, CREATE_Ax(OP_EXTRAARG, a)); -} - - -int luaK_codek (FuncState *fs, int reg, int k) { - if (k <= MAXARG_Bx) - return luaK_codeABx(fs, OP_LOADK, reg, k); - else { - int p = luaK_codeABx(fs, OP_LOADKX, reg, 0); - codeextraarg(fs, k); - return p; - } -} - - -void luaK_checkstack (FuncState *fs, int n) { - int newstack = fs->freereg + n; - if (newstack > fs->f->maxstacksize) { - if (newstack >= MAXREGS) - luaX_syntaxerror(fs->ls, "function or expression too complex"); - fs->f->maxstacksize = cast_byte(newstack); - } -} - - -void luaK_reserveregs (FuncState *fs, int n) { - luaK_checkstack(fs, n); - fs->freereg += n; -} - - -static void freereg (FuncState *fs, int reg) { - if (!ISK(reg) && reg >= fs->nactvar) { - fs->freereg--; - lua_assert(reg == fs->freereg); - } -} - - -static void freeexp (FuncState *fs, expdesc *e) { - if (e->k == VNONRELOC) - freereg(fs, e->u.info); -} - - -/* -** Use scanner's table to cache position of constants in constant list -** and try to reuse constants -*/ -static int addk (FuncState *fs, TValue *key, TValue *v) { - lua_State *L = fs->ls->L; - Proto *f = fs->f; - TValue *idx = luaH_set(L, fs->ls->h, key); /* index scanner table */ - int k, oldsize; - if (ttisinteger(idx)) { /* is there an index there? */ - k = cast_int(ivalue(idx)); - /* correct value? (warning: must distinguish floats from integers!) */ - if (k < fs->nk && ttype(&f->k[k]) == ttype(v) && - luaV_rawequalobj(&f->k[k], v)) - return k; /* reuse index */ - } - /* constant not found; create a new entry */ - oldsize = f->sizek; - k = fs->nk; - /* numerical value does not need GC barrier; - table has no metatable, so it does not need to invalidate cache */ - setivalue(idx, k); - luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants"); - while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); - setobj(L, &f->k[k], v); - fs->nk++; - luaC_barrier(L, f, v); - return k; -} - - -int luaK_stringK (FuncState *fs, TString *s) { - TValue o; - setsvalue(fs->ls->L, &o, s); - return addk(fs, &o, &o); -} - - -/* -** Integers use userdata as keys to avoid collision with floats with same -** value; conversion to 'void*' used only for hashing, no "precision" -** problems -*/ -int luaK_intK (FuncState *fs, lua_Integer n) { - TValue k, o; - setpvalue(&k, cast(void*, cast(size_t, n))); - setivalue(&o, n); - return addk(fs, &k, &o); -} - - -static int luaK_numberK (FuncState *fs, lua_Number r) { - TValue o; - setfltvalue(&o, r); - return addk(fs, &o, &o); -} - - -static int boolK (FuncState *fs, int b) { - TValue o; - setbvalue(&o, b); - return addk(fs, &o, &o); -} - - -static int nilK (FuncState *fs) { - TValue k, v; - setnilvalue(&v); - /* cannot use nil as key; instead use table itself to represent nil */ - sethvalue(fs->ls->L, &k, fs->ls->h); - return addk(fs, &k, &v); -} - - -void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { - if (e->k == VCALL) { /* expression is an open function call? */ - SETARG_C(getcode(fs, e), nresults+1); - } - else if (e->k == VVARARG) { - SETARG_B(getcode(fs, e), nresults+1); - SETARG_A(getcode(fs, e), fs->freereg); - luaK_reserveregs(fs, 1); - } -} - - -void luaK_setoneret (FuncState *fs, expdesc *e) { - if (e->k == VCALL) { /* expression is an open function call? */ - e->k = VNONRELOC; - e->u.info = GETARG_A(getcode(fs, e)); - } - else if (e->k == VVARARG) { - SETARG_B(getcode(fs, e), 2); - e->k = VRELOCABLE; /* can relocate its simple result */ - } -} - - -void luaK_dischargevars (FuncState *fs, expdesc *e) { - switch (e->k) { - case VLOCAL: { - e->k = VNONRELOC; - break; - } - case VUPVAL: { - e->u.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0); - e->k = VRELOCABLE; - break; - } - case VINDEXED: { - OpCode op = OP_GETTABUP; /* assume 't' is in an upvalue */ - freereg(fs, e->u.ind.idx); - if (e->u.ind.vt == VLOCAL) { /* 't' is in a register? */ - freereg(fs, e->u.ind.t); - op = OP_GETTABLE; - } - e->u.info = luaK_codeABC(fs, op, 0, e->u.ind.t, e->u.ind.idx); - e->k = VRELOCABLE; - break; - } - case VVARARG: - case VCALL: { - luaK_setoneret(fs, e); - break; - } - default: break; /* there is one value available (somewhere) */ - } -} - - -static int code_label (FuncState *fs, int A, int b, int jump) { - luaK_getlabel(fs); /* those instructions may be jump targets */ - return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); -} - - -static void discharge2reg (FuncState *fs, expdesc *e, int reg) { - luaK_dischargevars(fs, e); - switch (e->k) { - case VNIL: { - luaK_nil(fs, reg, 1); - break; - } - case VFALSE: case VTRUE: { - luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); - break; - } - case VK: { - luaK_codek(fs, reg, e->u.info); - break; - } - case VKFLT: { - luaK_codek(fs, reg, luaK_numberK(fs, e->u.nval)); - break; - } - case VKINT: { - luaK_codek(fs, reg, luaK_intK(fs, e->u.ival)); - break; - } - case VRELOCABLE: { - Instruction *pc = &getcode(fs, e); - SETARG_A(*pc, reg); - break; - } - case VNONRELOC: { - if (reg != e->u.info) - luaK_codeABC(fs, OP_MOVE, reg, e->u.info, 0); - break; - } - default: { - lua_assert(e->k == VVOID || e->k == VJMP); - return; /* nothing to do... */ - } - } - e->u.info = reg; - e->k = VNONRELOC; -} - - -static void discharge2anyreg (FuncState *fs, expdesc *e) { - if (e->k != VNONRELOC) { - luaK_reserveregs(fs, 1); - discharge2reg(fs, e, fs->freereg-1); - } -} - - -static void exp2reg (FuncState *fs, expdesc *e, int reg) { - discharge2reg(fs, e, reg); - if (e->k == VJMP) - luaK_concat(fs, &e->t, e->u.info); /* put this jump in 't' list */ - if (hasjumps(e)) { - int final; /* position after whole expression */ - int p_f = NO_JUMP; /* position of an eventual LOAD false */ - int p_t = NO_JUMP; /* position of an eventual LOAD true */ - if (need_value(fs, e->t) || need_value(fs, e->f)) { - int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); - p_f = code_label(fs, reg, 0, 1); - p_t = code_label(fs, reg, 1, 0); - luaK_patchtohere(fs, fj); - } - final = luaK_getlabel(fs); - patchlistaux(fs, e->f, final, reg, p_f); - patchlistaux(fs, e->t, final, reg, p_t); - } - e->f = e->t = NO_JUMP; - e->u.info = reg; - e->k = VNONRELOC; -} - - -void luaK_exp2nextreg (FuncState *fs, expdesc *e) { - luaK_dischargevars(fs, e); - freeexp(fs, e); - luaK_reserveregs(fs, 1); - exp2reg(fs, e, fs->freereg - 1); -} - - -int luaK_exp2anyreg (FuncState *fs, expdesc *e) { - luaK_dischargevars(fs, e); - if (e->k == VNONRELOC) { - if (!hasjumps(e)) return e->u.info; /* exp is already in a register */ - if (e->u.info >= fs->nactvar) { /* reg. is not a local? */ - exp2reg(fs, e, e->u.info); /* put value on it */ - return e->u.info; - } - } - luaK_exp2nextreg(fs, e); /* default */ - return e->u.info; -} - - -void luaK_exp2anyregup (FuncState *fs, expdesc *e) { - if (e->k != VUPVAL || hasjumps(e)) - luaK_exp2anyreg(fs, e); -} - - -void luaK_exp2val (FuncState *fs, expdesc *e) { - if (hasjumps(e)) - luaK_exp2anyreg(fs, e); - else - luaK_dischargevars(fs, e); -} - - -int luaK_exp2RK (FuncState *fs, expdesc *e) { - luaK_exp2val(fs, e); - switch (e->k) { - case VTRUE: - case VFALSE: - case VNIL: { - if (fs->nk <= MAXINDEXRK) { /* constant fits in RK operand? */ - e->u.info = (e->k == VNIL) ? nilK(fs) : boolK(fs, (e->k == VTRUE)); - e->k = VK; - return RKASK(e->u.info); - } - else break; - } - case VKINT: { - e->u.info = luaK_intK(fs, e->u.ival); - e->k = VK; - goto vk; - } - case VKFLT: { - e->u.info = luaK_numberK(fs, e->u.nval); - e->k = VK; - /* go through */ - } - case VK: { - vk: - if (e->u.info <= MAXINDEXRK) /* constant fits in 'argC'? */ - return RKASK(e->u.info); - else break; - } - default: break; - } - /* not a constant in the right range: put it in a register */ - return luaK_exp2anyreg(fs, e); -} - - -void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { - switch (var->k) { - case VLOCAL: { - freeexp(fs, ex); - exp2reg(fs, ex, var->u.info); - return; - } - case VUPVAL: { - int e = luaK_exp2anyreg(fs, ex); - luaK_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0); - break; - } - case VINDEXED: { - OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE : OP_SETTABUP; - int e = luaK_exp2RK(fs, ex); - luaK_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e); - break; - } - default: { - lua_assert(0); /* invalid var kind to store */ - break; - } - } - freeexp(fs, ex); -} - - -void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { - int ereg; - luaK_exp2anyreg(fs, e); - ereg = e->u.info; /* register where 'e' was placed */ - freeexp(fs, e); - e->u.info = fs->freereg; /* base register for op_self */ - e->k = VNONRELOC; - luaK_reserveregs(fs, 2); /* function and 'self' produced by op_self */ - luaK_codeABC(fs, OP_SELF, e->u.info, ereg, luaK_exp2RK(fs, key)); - freeexp(fs, key); -} - - -static void invertjump (FuncState *fs, expdesc *e) { - Instruction *pc = getjumpcontrol(fs, e->u.info); - lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && - GET_OPCODE(*pc) != OP_TEST); - SETARG_A(*pc, !(GETARG_A(*pc))); -} - - -static int jumponcond (FuncState *fs, expdesc *e, int cond) { - if (e->k == VRELOCABLE) { - Instruction ie = getcode(fs, e); - if (GET_OPCODE(ie) == OP_NOT) { - fs->pc--; /* remove previous OP_NOT */ - return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond); - } - /* else go through */ - } - discharge2anyreg(fs, e); - freeexp(fs, e); - return condjump(fs, OP_TESTSET, NO_REG, e->u.info, cond); -} - - -void luaK_goiftrue (FuncState *fs, expdesc *e) { - int pc; /* pc of last jump */ - luaK_dischargevars(fs, e); - switch (e->k) { - case VJMP: { - invertjump(fs, e); - pc = e->u.info; - break; - } - case VK: case VKFLT: case VKINT: case VTRUE: { - pc = NO_JUMP; /* always true; do nothing */ - break; - } - default: { - pc = jumponcond(fs, e, 0); - break; - } - } - luaK_concat(fs, &e->f, pc); /* insert last jump in 'f' list */ - luaK_patchtohere(fs, e->t); - e->t = NO_JUMP; -} - - -void luaK_goiffalse (FuncState *fs, expdesc *e) { - int pc; /* pc of last jump */ - luaK_dischargevars(fs, e); - switch (e->k) { - case VJMP: { - pc = e->u.info; - break; - } - case VNIL: case VFALSE: { - pc = NO_JUMP; /* always false; do nothing */ - break; - } - default: { - pc = jumponcond(fs, e, 1); - break; - } - } - luaK_concat(fs, &e->t, pc); /* insert last jump in 't' list */ - luaK_patchtohere(fs, e->f); - e->f = NO_JUMP; -} - - -static void codenot (FuncState *fs, expdesc *e) { - luaK_dischargevars(fs, e); - switch (e->k) { - case VNIL: case VFALSE: { - e->k = VTRUE; - break; - } - case VK: case VKFLT: case VKINT: case VTRUE: { - e->k = VFALSE; - break; - } - case VJMP: { - invertjump(fs, e); - break; - } - case VRELOCABLE: - case VNONRELOC: { - discharge2anyreg(fs, e); - freeexp(fs, e); - e->u.info = luaK_codeABC(fs, OP_NOT, 0, e->u.info, 0); - e->k = VRELOCABLE; - break; - } - default: { - lua_assert(0); /* cannot happen */ - break; - } - } - /* interchange true and false lists */ - { int temp = e->f; e->f = e->t; e->t = temp; } - removevalues(fs, e->f); - removevalues(fs, e->t); -} - - -void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { - lua_assert(!hasjumps(t)); - t->u.ind.t = t->u.info; - t->u.ind.idx = luaK_exp2RK(fs, k); - t->u.ind.vt = (t->k == VUPVAL) ? VUPVAL - : check_exp(vkisinreg(t->k), VLOCAL); - t->k = VINDEXED; -} - - -/* -** return false if folding can raise an error -*/ -static int validop (int op, TValue *v1, TValue *v2) { - switch (op) { - case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: - case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ - lua_Integer i; - return (tointeger(v1, &i) && tointeger(v2, &i)); - } - case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ - return (nvalue(v2) != 0); - default: return 1; /* everything else is valid */ - } -} - - -/* -** Try to "constant-fold" an operation; return 1 iff successful -*/ -static int constfolding (FuncState *fs, int op, expdesc *e1, expdesc *e2) { - TValue v1, v2, res; - if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2)) - return 0; /* non-numeric operands or not safe to fold */ - luaO_arith(fs->ls->L, op, &v1, &v2, &res); /* does operation */ - if (ttisinteger(&res)) { - e1->k = VKINT; - e1->u.ival = ivalue(&res); - } - else { /* folds neither NaN nor 0.0 (to avoid collapsing with -0.0) */ - lua_Number n = fltvalue(&res); - if (luai_numisnan(n) || n == 0) - return 0; - e1->k = VKFLT; - e1->u.nval = n; - } - return 1; -} - - -/* -** Code for binary and unary expressions that "produce values" -** (arithmetic operations, bitwise operations, concat, length). First -** try to do constant folding (only for numeric [arithmetic and -** bitwise] operations, which is what 'lua_arith' accepts). -** Expression to produce final result will be encoded in 'e1'. -*/ -static void codeexpval (FuncState *fs, OpCode op, - expdesc *e1, expdesc *e2, int line) { - lua_assert(op >= OP_ADD); - if (op <= OP_BNOT && constfolding(fs, op - OP_ADD + LUA_OPADD, e1, e2)) - return; /* result has been folded */ - else { - int o1, o2; - /* move operands to registers (if needed) */ - if (op == OP_UNM || op == OP_BNOT || op == OP_LEN) { /* unary op? */ - o2 = 0; /* no second expression */ - o1 = luaK_exp2anyreg(fs, e1); /* cannot operate on constants */ - } - else { /* regular case (binary operators) */ - o2 = luaK_exp2RK(fs, e2); /* both operands are "RK" */ - o1 = luaK_exp2RK(fs, e1); - } - if (o1 > o2) { /* free registers in proper order */ - freeexp(fs, e1); - freeexp(fs, e2); - } - else { - freeexp(fs, e2); - freeexp(fs, e1); - } - e1->u.info = luaK_codeABC(fs, op, 0, o1, o2); /* generate opcode */ - e1->k = VRELOCABLE; /* all those operations are relocable */ - luaK_fixline(fs, line); - } -} - - -static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, - expdesc *e2) { - int o1 = luaK_exp2RK(fs, e1); - int o2 = luaK_exp2RK(fs, e2); - freeexp(fs, e2); - freeexp(fs, e1); - if (cond == 0 && op != OP_EQ) { - int temp; /* exchange args to replace by '<' or '<=' */ - temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ - cond = 1; - } - e1->u.info = condjump(fs, op, cond, o1, o2); - e1->k = VJMP; -} - - -void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) { - expdesc e2; - e2.t = e2.f = NO_JUMP; e2.k = VKINT; e2.u.ival = 0; - switch (op) { - case OPR_MINUS: case OPR_BNOT: case OPR_LEN: { - codeexpval(fs, cast(OpCode, (op - OPR_MINUS) + OP_UNM), e, &e2, line); - break; - } - case OPR_NOT: codenot(fs, e); break; - default: lua_assert(0); - } -} - - -void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { - switch (op) { - case OPR_AND: { - luaK_goiftrue(fs, v); - break; - } - case OPR_OR: { - luaK_goiffalse(fs, v); - break; - } - case OPR_CONCAT: { - luaK_exp2nextreg(fs, v); /* operand must be on the 'stack' */ - break; - } - case OPR_ADD: case OPR_SUB: - case OPR_MUL: case OPR_DIV: case OPR_IDIV: - case OPR_MOD: case OPR_POW: - case OPR_BAND: case OPR_BOR: case OPR_BXOR: - case OPR_SHL: case OPR_SHR: { - if (!tonumeral(v, NULL)) luaK_exp2RK(fs, v); - break; - } - default: { - luaK_exp2RK(fs, v); - break; - } - } -} - - -void luaK_posfix (FuncState *fs, BinOpr op, - expdesc *e1, expdesc *e2, int line) { - switch (op) { - case OPR_AND: { - lua_assert(e1->t == NO_JUMP); /* list must be closed */ - luaK_dischargevars(fs, e2); - luaK_concat(fs, &e2->f, e1->f); - *e1 = *e2; - break; - } - case OPR_OR: { - lua_assert(e1->f == NO_JUMP); /* list must be closed */ - luaK_dischargevars(fs, e2); - luaK_concat(fs, &e2->t, e1->t); - *e1 = *e2; - break; - } - case OPR_CONCAT: { - luaK_exp2val(fs, e2); - if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { - lua_assert(e1->u.info == GETARG_B(getcode(fs, e2))-1); - freeexp(fs, e1); - SETARG_B(getcode(fs, e2), e1->u.info); - e1->k = VRELOCABLE; e1->u.info = e2->u.info; - } - else { - luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ - codeexpval(fs, OP_CONCAT, e1, e2, line); - } - break; - } - case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: - case OPR_IDIV: case OPR_MOD: case OPR_POW: - case OPR_BAND: case OPR_BOR: case OPR_BXOR: - case OPR_SHL: case OPR_SHR: { - codeexpval(fs, cast(OpCode, (op - OPR_ADD) + OP_ADD), e1, e2, line); - break; - } - case OPR_EQ: case OPR_LT: case OPR_LE: { - codecomp(fs, cast(OpCode, op - OPR_EQ + OP_EQ), 1, e1, e2); - break; - } - case OPR_NE: case OPR_GT: case OPR_GE: { - codecomp(fs, cast(OpCode, op - OPR_NE + OP_EQ), 0, e1, e2); - break; - } - default: lua_assert(0); - } -} - - -void luaK_fixline (FuncState *fs, int line) { - fs->f->lineinfo[fs->pc - 1] = line; -} - - -void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { - int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; - int b = (tostore == LUA_MULTRET) ? 0 : tostore; - lua_assert(tostore != 0); - if (c <= MAXARG_C) - luaK_codeABC(fs, OP_SETLIST, base, b, c); - else if (c <= MAXARG_Ax) { - luaK_codeABC(fs, OP_SETLIST, base, b, 0); - codeextraarg(fs, c); - } - else - luaX_syntaxerror(fs->ls, "constructor too long"); - fs->freereg = base + 1; /* free registers with list values */ -} - diff --git a/thirdparty/src/Lua/lcode.h b/thirdparty/src/Lua/lcode.h deleted file mode 100644 index 43ab86db7..000000000 --- a/thirdparty/src/Lua/lcode.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -** $Id: lcode.h,v 1.63 2013/12/30 20:47:58 roberto Exp $ -** Code generator for Lua -** See Copyright Notice in lua.h -*/ - -#ifndef lcode_h -#define lcode_h - -#include "llex.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lparser.h" - - -/* -** Marks the end of a patch list. It is an invalid value both as an absolute -** address, and as a list link (would link an element to itself). -*/ -#define NO_JUMP (-1) - - -/* -** grep "ORDER OPR" if you change these enums (ORDER OP) -*/ -typedef enum BinOpr { - OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW, - OPR_DIV, - OPR_IDIV, - OPR_BAND, OPR_BOR, OPR_BXOR, - OPR_SHL, OPR_SHR, - OPR_CONCAT, - OPR_EQ, OPR_LT, OPR_LE, - OPR_NE, OPR_GT, OPR_GE, - OPR_AND, OPR_OR, - OPR_NOBINOPR -} BinOpr; - - -typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; - - -#define getcode(fs,e) ((fs)->f->code[(e)->u.info]) - -#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) - -#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) - -#define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) - -LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); -LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); -LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); -LUAI_FUNC void luaK_fixline (FuncState *fs, int line); -LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); -LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); -LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); -LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); -LUAI_FUNC int luaK_intK (FuncState *fs, lua_Integer n); -LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); -LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); -LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); -LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); -LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); -LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); -LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); -LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); -LUAI_FUNC int luaK_jump (FuncState *fs); -LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); -LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); -LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); -LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level); -LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); -LUAI_FUNC int luaK_getlabel (FuncState *fs); -LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); -LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); -LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, - expdesc *v2, int line); -LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); - - -#endif diff --git a/thirdparty/src/Lua/lcorolib.cpp b/thirdparty/src/Lua/lcorolib.cpp deleted file mode 100644 index 979b7385c..000000000 --- a/thirdparty/src/Lua/lcorolib.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* -** $Id: lcorolib.c,v 1.9 2014/11/02 19:19:04 roberto Exp $ -** Coroutine Library -** See Copyright Notice in lua.h -*/ - -#define lcorolib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include <stdlib.h> - -#include <Lua/lua.h> - -#include <Lua/lauxlib.h> -#include <Lua/lualib.h> - - -static lua_State *getco (lua_State *L) { - lua_State *co = lua_tothread(L, 1); - luaL_argcheck(L, co, 1, "thread expected"); - return co; -} - - -static int auxresume (lua_State *L, lua_State *co, int narg) { - int status; - if (!lua_checkstack(co, narg)) { - lua_pushliteral(L, "too many arguments to resume"); - return -1; /* error flag */ - } - if (lua_status(co) == LUA_OK && lua_gettop(co) == 0) { - lua_pushliteral(L, "cannot resume dead coroutine"); - return -1; /* error flag */ - } - lua_xmove(L, co, narg); - status = lua_resume(co, L, narg); - if (status == LUA_OK || status == LUA_YIELD) { - int nres = lua_gettop(co); - if (!lua_checkstack(L, nres + 1)) { - lua_pop(co, nres); /* remove results anyway */ - lua_pushliteral(L, "too many results to resume"); - return -1; /* error flag */ - } - lua_xmove(co, L, nres); /* move yielded values */ - return nres; - } - else { - lua_xmove(co, L, 1); /* move error message */ - return -1; /* error flag */ - } -} - - -static int luaB_coresume (lua_State *L) { - lua_State *co = getco(L); - int r; - r = auxresume(L, co, lua_gettop(L) - 1); - if (r < 0) { - lua_pushboolean(L, 0); - lua_insert(L, -2); - return 2; /* return false + error message */ - } - else { - lua_pushboolean(L, 1); - lua_insert(L, -(r + 1)); - return r + 1; /* return true + 'resume' returns */ - } -} - - -static int luaB_auxwrap (lua_State *L) { - lua_State *co = lua_tothread(L, lua_upvalueindex(1)); - int r = auxresume(L, co, lua_gettop(L)); - if (r < 0) { - if (lua_isstring(L, -1)) { /* error object is a string? */ - luaL_where(L, 1); /* add extra info */ - lua_insert(L, -2); - lua_concat(L, 2); - } - return lua_error(L); /* propagate error */ - } - return r; -} - - -static int luaB_cocreate (lua_State *L) { - lua_State *NL; - luaL_checktype(L, 1, LUA_TFUNCTION); - NL = lua_newthread(L); - lua_pushvalue(L, 1); /* move function to top */ - lua_xmove(L, NL, 1); /* move function from L to NL */ - return 1; -} - - -static int luaB_cowrap (lua_State *L) { - luaB_cocreate(L); - lua_pushcclosure(L, luaB_auxwrap, 1); - return 1; -} - - -static int luaB_yield (lua_State *L) { - return lua_yield(L, lua_gettop(L)); -} - - -static int luaB_costatus (lua_State *L) { - lua_State *co = getco(L); - if (L == co) lua_pushliteral(L, "running"); - else { - switch (lua_status(co)) { - case LUA_YIELD: - lua_pushliteral(L, "suspended"); - break; - case LUA_OK: { - lua_Debug ar; - if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ - lua_pushliteral(L, "normal"); /* it is running */ - else if (lua_gettop(co) == 0) - lua_pushliteral(L, "dead"); - else - lua_pushliteral(L, "suspended"); /* initial state */ - break; - } - default: /* some error occurred */ - lua_pushliteral(L, "dead"); - break; - } - } - return 1; -} - - -static int luaB_yieldable (lua_State *L) { - lua_pushboolean(L, lua_isyieldable(L)); - return 1; -} - - -static int luaB_corunning (lua_State *L) { - int ismain = lua_pushthread(L); - lua_pushboolean(L, ismain); - return 2; -} - - -static const luaL_Reg co_funcs[] = { - {"create", luaB_cocreate}, - {"resume", luaB_coresume}, - {"running", luaB_corunning}, - {"status", luaB_costatus}, - {"wrap", luaB_cowrap}, - {"yield", luaB_yield}, - {"isyieldable", luaB_yieldable}, - {NULL, NULL} -}; - - - -LUAMOD_API int luaopen_coroutine (lua_State *L) { - luaL_newlib(L, co_funcs); - return 1; -} - diff --git a/thirdparty/src/Lua/lctype.cpp b/thirdparty/src/Lua/lctype.cpp deleted file mode 100644 index ae9367e69..000000000 --- a/thirdparty/src/Lua/lctype.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* -** $Id: lctype.c,v 1.12 2014/11/02 19:19:04 roberto Exp $ -** 'ctype' functions for Lua -** See Copyright Notice in lua.h -*/ - -#define lctype_c -#define LUA_CORE - -#include "lprefix.h" - - -#include "lctype.h" - -#if !LUA_USE_CTYPE /* { */ - -#include <limits.h> - -LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { - 0x00, /* EOZ */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ - 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ - 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ - 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, - 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ - 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; - -#endif /* } */ diff --git a/thirdparty/src/Lua/lctype.h b/thirdparty/src/Lua/lctype.h deleted file mode 100644 index 1c8d563ef..000000000 --- a/thirdparty/src/Lua/lctype.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ -** 'ctype' functions for Lua -** See Copyright Notice in lua.h -*/ - -#ifndef lctype_h -#define lctype_h - -#include <Lua/lua.h> - - -/* -** WARNING: the functions defined here do not necessarily correspond -** to the similar functions in the standard C ctype.h. They are -** optimized for the specific needs of Lua -*/ - -#if !defined(LUA_USE_CTYPE) - -#if 'A' == 65 && '0' == 48 -/* ASCII case: can use its own tables; faster and fixed */ -#define LUA_USE_CTYPE 0 -#else -/* must use standard C ctype */ -#define LUA_USE_CTYPE 1 -#endif - -#endif - - -#if !LUA_USE_CTYPE /* { */ - -#include <limits.h> - -#include "llimits.h" - - -#define ALPHABIT 0 -#define DIGITBIT 1 -#define PRINTBIT 2 -#define SPACEBIT 3 -#define XDIGITBIT 4 - - -#define MASK(B) (1 << (B)) - - -/* -** add 1 to char to allow index -1 (EOZ) -*/ -#define testprop(c,p) (luai_ctype_[(c)+1] & (p)) - -/* -** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' -*/ -#define lislalpha(c) testprop(c, MASK(ALPHABIT)) -#define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) -#define lisdigit(c) testprop(c, MASK(DIGITBIT)) -#define lisspace(c) testprop(c, MASK(SPACEBIT)) -#define lisprint(c) testprop(c, MASK(PRINTBIT)) -#define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) - -/* -** this 'ltolower' only works for alphabetic characters -*/ -#define ltolower(c) ((c) | ('A' ^ 'a')) - - -/* two more entries for 0 and -1 (EOZ) */ -LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; - - -#else /* }{ */ - -/* -** use standard C ctypes -*/ - -#include <ctype.h> - - -#define lislalpha(c) (isalpha(c) || (c) == '_') -#define lislalnum(c) (isalnum(c) || (c) == '_') -#define lisdigit(c) (isdigit(c)) -#define lisspace(c) (isspace(c)) -#define lisprint(c) (isprint(c)) -#define lisxdigit(c) (isxdigit(c)) - -#define ltolower(c) (tolower(c)) - -#endif /* } */ - -#endif - diff --git a/thirdparty/src/Lua/ldblib.cpp b/thirdparty/src/Lua/ldblib.cpp deleted file mode 100644 index c33a5869a..000000000 --- a/thirdparty/src/Lua/ldblib.cpp +++ /dev/null @@ -1,437 +0,0 @@ -/* -** $Id: ldblib.c,v 1.148 2015/01/02 12:52:22 roberto Exp $ -** Interface from Lua to its debug API -** See Copyright Notice in lua.h -*/ - -#define ldblib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <Lua/lua.h> - -#include <Lua/lauxlib.h> -#include <Lua/lualib.h> - - -/* -** The hook table at registry[&HOOKKEY] maps threads to their current -** hook function. (We only need the unique address of 'HOOKKEY'.) -*/ -static const int HOOKKEY = 0; - - -static int db_getregistry (lua_State *L) { - lua_pushvalue(L, LUA_REGISTRYINDEX); - return 1; -} - - -static int db_getmetatable (lua_State *L) { - luaL_checkany(L, 1); - if (!lua_getmetatable(L, 1)) { - lua_pushnil(L); /* no metatable */ - } - return 1; -} - - -static int db_setmetatable (lua_State *L) { - int t = lua_type(L, 2); - luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, - "nil or table expected"); - lua_settop(L, 2); - lua_setmetatable(L, 1); - return 1; /* return 1st argument */ -} - - -static int db_getuservalue (lua_State *L) { - if (lua_type(L, 1) != LUA_TUSERDATA) - lua_pushnil(L); - else - lua_getuservalue(L, 1); - return 1; -} - - -static int db_setuservalue (lua_State *L) { - luaL_checktype(L, 1, LUA_TUSERDATA); - luaL_checkany(L, 2); - lua_settop(L, 2); - lua_setuservalue(L, 1); - return 1; -} - - -/* -** Auxiliary function used by several library functions: check for -** an optional thread as function's first argument and set 'arg' with -** 1 if this argument is present (so that functions can skip it to -** access their other arguments) -*/ -static lua_State *getthread (lua_State *L, int *arg) { - if (lua_isthread(L, 1)) { - *arg = 1; - return lua_tothread(L, 1); - } - else { - *arg = 0; - return L; /* function will operate over current thread */ - } -} - - -/* -** Variations of 'lua_settable', used by 'db_getinfo' to put results -** from 'lua_getinfo' into result table. Key is always a string; -** value can be a string, an int, or a boolean. -*/ -static void settabss (lua_State *L, const char *k, const char *v) { - lua_pushstring(L, v); - lua_setfield(L, -2, k); -} - -static void settabsi (lua_State *L, const char *k, int v) { - lua_pushinteger(L, v); - lua_setfield(L, -2, k); -} - -static void settabsb (lua_State *L, const char *k, int v) { - lua_pushboolean(L, v); - lua_setfield(L, -2, k); -} - - -/* -** In function 'db_getinfo', the call to 'lua_getinfo' may push -** results on the stack; later it creates the result table to put -** these objects. Function 'treatstackoption' puts the result from -** 'lua_getinfo' on top of the result table so that it can call -** 'lua_setfield'. -*/ -static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { - if (L == L1) - lua_rotate(L, -2, 1); /* exchange object and table */ - else - lua_xmove(L1, L, 1); /* move object to the "main" stack */ - lua_setfield(L, -2, fname); /* put object into table */ -} - - -/* -** Calls 'lua_getinfo' and collects all results in a new table. -*/ -static int db_getinfo (lua_State *L) { - lua_Debug ar; - int arg; - lua_State *L1 = getthread(L, &arg); - const char *options = luaL_optstring(L, arg+2, "flnStu"); - if (lua_isfunction(L, arg + 1)) { /* info about a function? */ - options = lua_pushfstring(L, ">%s", options); /* add '>' to 'options' */ - lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */ - lua_xmove(L, L1, 1); - } - else { /* stack level */ - if (!lua_getstack(L1, (int)luaL_checkinteger(L, arg + 1), &ar)) { - lua_pushnil(L); /* level out of range */ - return 1; - } - } - if (!lua_getinfo(L1, options, &ar)) - return luaL_argerror(L, arg+2, "invalid option"); - lua_newtable(L); /* table to collect results */ - if (strchr(options, 'S')) { - settabss(L, "source", ar.source); - settabss(L, "short_src", ar.short_src); - settabsi(L, "linedefined", ar.linedefined); - settabsi(L, "lastlinedefined", ar.lastlinedefined); - settabss(L, "what", ar.what); - } - if (strchr(options, 'l')) - settabsi(L, "currentline", ar.currentline); - if (strchr(options, 'u')) { - settabsi(L, "nups", ar.nups); - settabsi(L, "nparams", ar.nparams); - settabsb(L, "isvararg", ar.isvararg); - } - if (strchr(options, 'n')) { - settabss(L, "name", ar.name); - settabss(L, "namewhat", ar.namewhat); - } - if (strchr(options, 't')) - settabsb(L, "istailcall", ar.istailcall); - if (strchr(options, 'L')) - treatstackoption(L, L1, "activelines"); - if (strchr(options, 'f')) - treatstackoption(L, L1, "func"); - return 1; /* return table */ -} - - -static int db_getlocal (lua_State *L) { - int arg; - lua_State *L1 = getthread(L, &arg); - lua_Debug ar; - const char *name; - int nvar = (int)luaL_checkinteger(L, arg + 2); /* local-variable index */ - if (lua_isfunction(L, arg + 1)) { /* function argument? */ - lua_pushvalue(L, arg + 1); /* push function */ - lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */ - return 1; /* return only name (there is no value) */ - } - else { /* stack-level argument */ - int level = (int)luaL_checkinteger(L, arg + 1); - if (!lua_getstack(L1, level, &ar)) /* out of range? */ - return luaL_argerror(L, arg+1, "level out of range"); - name = lua_getlocal(L1, &ar, nvar); - if (name) { - lua_xmove(L1, L, 1); /* move local value */ - lua_pushstring(L, name); /* push name */ - lua_rotate(L, -2, 1); /* re-order */ - return 2; - } - else { - lua_pushnil(L); /* no name (nor value) */ - return 1; - } - } -} - - -static int db_setlocal (lua_State *L) { - int arg; - const char *name; - lua_State *L1 = getthread(L, &arg); - lua_Debug ar; - int level = (int)luaL_checkinteger(L, arg + 1); - int nvar = (int)luaL_checkinteger(L, arg + 2); - if (!lua_getstack(L1, level, &ar)) /* out of range? */ - return luaL_argerror(L, arg+1, "level out of range"); - luaL_checkany(L, arg+3); - lua_settop(L, arg+3); - lua_xmove(L, L1, 1); - name = lua_setlocal(L1, &ar, nvar); - if (name == NULL) - lua_pop(L1, 1); /* pop value (if not popped by 'lua_setlocal') */ - lua_pushstring(L, name); - return 1; -} - - -/* -** get (if 'get' is true) or set an upvalue from a closure -*/ -static int auxupvalue (lua_State *L, int get) { - const char *name; - int n = (int)luaL_checkinteger(L, 2); /* upvalue index */ - luaL_checktype(L, 1, LUA_TFUNCTION); /* closure */ - name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); - if (name == NULL) return 0; - lua_pushstring(L, name); - lua_insert(L, -(get+1)); /* no-op if get is false */ - return get + 1; -} - - -static int db_getupvalue (lua_State *L) { - return auxupvalue(L, 1); -} - - -static int db_setupvalue (lua_State *L) { - luaL_checkany(L, 3); - return auxupvalue(L, 0); -} - - -/* -** Check whether a given upvalue from a given closure exists and -** returns its index -*/ -static int checkupval (lua_State *L, int argf, int argnup) { - int nup = (int)luaL_checkinteger(L, argnup); /* upvalue index */ - luaL_checktype(L, argf, LUA_TFUNCTION); /* closure */ - luaL_argcheck(L, (lua_getupvalue(L, argf, nup) != NULL), argnup, - "invalid upvalue index"); - return nup; -} - - -static int db_upvalueid (lua_State *L) { - int n = checkupval(L, 1, 2); - lua_pushlightuserdata(L, lua_upvalueid(L, 1, n)); - return 1; -} - - -static int db_upvaluejoin (lua_State *L) { - int n1 = checkupval(L, 1, 2); - int n2 = checkupval(L, 3, 4); - luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected"); - luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected"); - lua_upvaluejoin(L, 1, n1, 3, n2); - return 0; -} - - -/* -** Call hook function registered at hook table for the current -** thread (if there is one) -*/ -static void hookf (lua_State *L, lua_Debug *ar) { - static const char *const hooknames[] = - {"call", "return", "line", "count", "tail call"}; - lua_rawgetp(L, LUA_REGISTRYINDEX, &HOOKKEY); - lua_pushthread(L); - if (lua_rawget(L, -2) == LUA_TFUNCTION) { /* is there a hook function? */ - lua_pushstring(L, hooknames[(int)ar->event]); /* push event name */ - if (ar->currentline >= 0) - lua_pushinteger(L, ar->currentline); /* push current line */ - else lua_pushnil(L); - lua_assert(lua_getinfo(L, "lS", ar)); - lua_call(L, 2, 0); /* call hook function */ - } -} - - -/* -** Convert a string mask (for 'sethook') into a bit mask -*/ -static int makemask (const char *smask, int count) { - int mask = 0; - if (strchr(smask, 'c')) mask |= LUA_MASKCALL; - if (strchr(smask, 'r')) mask |= LUA_MASKRET; - if (strchr(smask, 'l')) mask |= LUA_MASKLINE; - if (count > 0) mask |= LUA_MASKCOUNT; - return mask; -} - - -/* -** Convert a bit mask (for 'gethook') into a string mask -*/ -static char *unmakemask (int mask, char *smask) { - int i = 0; - if (mask & LUA_MASKCALL) smask[i++] = 'c'; - if (mask & LUA_MASKRET) smask[i++] = 'r'; - if (mask & LUA_MASKLINE) smask[i++] = 'l'; - smask[i] = '\0'; - return smask; -} - - -static int db_sethook (lua_State *L) { - int arg, mask, count; - lua_Hook func; - lua_State *L1 = getthread(L, &arg); - if (lua_isnoneornil(L, arg+1)) { /* no hook? */ - lua_settop(L, arg+1); - func = NULL; mask = 0; count = 0; /* turn off hooks */ - } - else { - const char *smask = luaL_checkstring(L, arg+2); - luaL_checktype(L, arg+1, LUA_TFUNCTION); - count = (int)luaL_optinteger(L, arg + 3, 0); - func = hookf; mask = makemask(smask, count); - } - if (lua_rawgetp(L, LUA_REGISTRYINDEX, &HOOKKEY) == LUA_TNIL) { - lua_createtable(L, 0, 2); /* create a hook table */ - lua_pushvalue(L, -1); - lua_rawsetp(L, LUA_REGISTRYINDEX, &HOOKKEY); /* set it in position */ - lua_pushstring(L, "k"); - lua_setfield(L, -2, "__mode"); /** hooktable.__mode = "k" */ - lua_pushvalue(L, -1); - lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */ - } - lua_pushthread(L1); lua_xmove(L1, L, 1); /* key (thread) */ - lua_pushvalue(L, arg + 1); /* value (hook function) */ - lua_rawset(L, -3); /* hooktable[L1] = new Lua hook */ - lua_sethook(L1, func, mask, count); - return 0; -} - - -static int db_gethook (lua_State *L) { - int arg; - lua_State *L1 = getthread(L, &arg); - char buff[5]; - int mask = lua_gethookmask(L1); - lua_Hook hook = lua_gethook(L1); - if (hook == NULL) /* no hook? */ - lua_pushnil(L); - else if (hook != hookf) /* external hook? */ - lua_pushliteral(L, "external hook"); - else { /* hook table must exist */ - lua_rawgetp(L, LUA_REGISTRYINDEX, &HOOKKEY); - lua_pushthread(L1); lua_xmove(L1, L, 1); - lua_rawget(L, -2); /* 1st result = hooktable[L1] */ - lua_remove(L, -2); /* remove hook table */ - } - lua_pushstring(L, unmakemask(mask, buff)); /* 2nd result = mask */ - lua_pushinteger(L, lua_gethookcount(L1)); /* 3rd result = count */ - return 3; -} - - -static int db_debug (lua_State *L) { - for (;;) { - char buffer[250]; - lua_writestringerror("%s", "lua_debug> "); - if (fgets(buffer, sizeof(buffer), stdin) == 0 || - strcmp(buffer, "cont\n") == 0) - return 0; - if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || - lua_pcall(L, 0, 0, 0)) - lua_writestringerror("%s\n", lua_tostring(L, -1)); - lua_settop(L, 0); /* remove eventual returns */ - } -} - - -static int db_traceback (lua_State *L) { - int arg; - lua_State *L1 = getthread(L, &arg); - const char *msg = lua_tostring(L, arg + 1); - if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */ - lua_pushvalue(L, arg + 1); /* return it untouched */ - else { - int level = (int)luaL_optinteger(L, arg + 2, (L == L1) ? 1 : 0); - luaL_traceback(L, L1, msg, level); - } - return 1; -} - - -static const luaL_Reg dblib[] = { - {"debug", db_debug}, - {"getuservalue", db_getuservalue}, - {"gethook", db_gethook}, - {"getinfo", db_getinfo}, - {"getlocal", db_getlocal}, - {"getregistry", db_getregistry}, - {"getmetatable", db_getmetatable}, - {"getupvalue", db_getupvalue}, - {"upvaluejoin", db_upvaluejoin}, - {"upvalueid", db_upvalueid}, - {"setuservalue", db_setuservalue}, - {"sethook", db_sethook}, - {"setlocal", db_setlocal}, - {"setmetatable", db_setmetatable}, - {"setupvalue", db_setupvalue}, - {"traceback", db_traceback}, - {NULL, NULL} -}; - - -LUAMOD_API int luaopen_debug (lua_State *L) { - luaL_newlib(L, dblib); - return 1; -} - diff --git a/thirdparty/src/Lua/ldebug.cpp b/thirdparty/src/Lua/ldebug.cpp deleted file mode 100644 index 46eb9bcf8..000000000 --- a/thirdparty/src/Lua/ldebug.cpp +++ /dev/null @@ -1,658 +0,0 @@ -/* -** $Id: ldebug.c,v 2.110 2015/01/02 12:52:22 roberto Exp $ -** Debug Interface -** See Copyright Notice in lua.h -*/ - -#define ldebug_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <stdarg.h> -#include <stddef.h> -#include <string.h> - -#include <Lua/lua.h> - -#include "lapi.h" -#include "lcode.h" -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" -#include "lvm.h" - - - -#define noLuaClosure(f) ((f) == NULL || (f)->c.tt == LUA_TCCL) - - -static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); - - -static int currentpc (CallInfo *ci) { - lua_assert(isLua(ci)); - return pcRel(ci->u.l.savedpc, ci_func(ci)->p); -} - - -static int currentline (CallInfo *ci) { - return getfuncline(ci_func(ci)->p, currentpc(ci)); -} - -static void swapextra (lua_State *L) { - if (L->status == LUA_YIELD) { - CallInfo *ci = L->ci; /* get function that yielded */ - StkId temp = ci->func; /* exchange its 'func' and 'extra' values */ - ci->func = restorestack(L, ci->extra); - ci->extra = savestack(L, temp); - } -} - -/* -** this function can be called asynchronous (e.g. during a signal) -*/ -LUA_API void lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { - if (func == NULL || mask == 0) { /* turn off hooks? */ - mask = 0; - func = NULL; - } - if (isLua(L->ci)) - L->oldpc = L->ci->u.l.savedpc; - L->hook = func; - L->basehookcount = count; - resethookcount(L); - L->hookmask = cast_byte(mask); -} - - -LUA_API lua_Hook lua_gethook (lua_State *L) { - return L->hook; -} - - -LUA_API int lua_gethookmask (lua_State *L) { - return L->hookmask; -} - - -LUA_API int lua_gethookcount (lua_State *L) { - return L->basehookcount; -} - - -LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { - int status; - CallInfo *ci; - if (level < 0) return 0; /* invalid (negative) level */ - lua_lock(L); - for (ci = L->ci; level > 0 && ci != &L->base_ci; ci = ci->previous) - level--; - if (level == 0 && ci != &L->base_ci) { /* level found? */ - status = 1; - ar->i_ci = ci; - } - else status = 0; /* no such level */ - lua_unlock(L); - return status; -} - - -static const char *upvalname (Proto *p, int uv) { - TString *s = check_exp(uv < p->sizeupvalues, p->upvalues[uv].name); - if (s == NULL) return "?"; - else return getstr(s); -} - - -static const char *findvararg (CallInfo *ci, int n, StkId *pos) { - int nparams = clLvalue(ci->func)->p->numparams; - if (n >= ci->u.l.base - ci->func - nparams) - return NULL; /* no such vararg */ - else { - *pos = ci->func + nparams + n; - return "(*vararg)"; /* generic name for any vararg */ - } -} - - -static const char *findlocal (lua_State *L, CallInfo *ci, int n, - StkId *pos) { - const char *name = NULL; - StkId base; - if (isLua(ci)) { - if (n < 0) /* access to vararg values? */ - return findvararg(ci, -n, pos); - else { - base = ci->u.l.base; - name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci)); - } - } - else - base = ci->func + 1; - if (name == NULL) { /* no 'standard' name? */ - StkId limit = (ci == L->ci) ? L->top : ci->next->func; - if (limit - base >= n && n > 0) /* is 'n' inside 'ci' stack? */ - name = "(*temporary)"; /* generic name for any valid slot */ - else - return NULL; /* no name */ - } - *pos = base + (n - 1); - return name; -} - - -LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { - const char *name; - lua_lock(L); - swapextra(L); - if (ar == NULL) { /* information about non-active function? */ - if (!isLfunction(L->top - 1)) /* not a Lua function? */ - name = NULL; - else /* consider live variables at function start (parameters) */ - name = luaF_getlocalname(clLvalue(L->top - 1)->p, n, 0); - } - else { /* active function; get information through 'ar' */ - StkId pos = 0; /* to avoid warnings */ - name = findlocal(L, ar->i_ci, n, &pos); - if (name) { - setobj2s(L, L->top, pos); - api_incr_top(L); - } - } - swapextra(L); - lua_unlock(L); - return name; -} - - -LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { - StkId pos = 0; /* to avoid warnings */ - const char *name; - lua_lock(L); - swapextra(L); - name = findlocal(L, ar->i_ci, n, &pos); - if (name) { - setobjs2s(L, pos, L->top - 1); - L->top--; /* pop value */ - } - swapextra(L); - lua_unlock(L); - return name; -} - - -static void funcinfo (lua_Debug *ar, Closure *cl) { - if (noLuaClosure(cl)) { - ar->source = "=[C]"; - ar->linedefined = -1; - ar->lastlinedefined = -1; - ar->what = "C"; - } - else { - Proto *p = cl->l.p; - ar->source = p->source ? getstr(p->source) : "=?"; - ar->linedefined = p->linedefined; - ar->lastlinedefined = p->lastlinedefined; - ar->what = (ar->linedefined == 0) ? "main" : "Lua"; - } - luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); -} - - -static void collectvalidlines (lua_State *L, Closure *f) { - if (noLuaClosure(f)) { - setnilvalue(L->top); - api_incr_top(L); - } - else { - int i; - TValue v; - int *lineinfo = f->l.p->lineinfo; - Table *t = luaH_new(L); /* new table to store active lines */ - sethvalue(L, L->top, t); /* push it on stack */ - api_incr_top(L); - setbvalue(&v, 1); /* boolean 'true' to be the value of all indices */ - for (i = 0; i < f->l.p->sizelineinfo; i++) /* for all lines with code */ - luaH_setint(L, t, lineinfo[i], &v); /* table[line] = true */ - } -} - - -static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, - Closure *f, CallInfo *ci) { - int status = 1; - for (; *what; what++) { - switch (*what) { - case 'S': { - funcinfo(ar, f); - break; - } - case 'l': { - ar->currentline = (ci && isLua(ci)) ? currentline(ci) : -1; - break; - } - case 'u': { - ar->nups = (f == NULL) ? 0 : f->c.nupvalues; - if (noLuaClosure(f)) { - ar->isvararg = 1; - ar->nparams = 0; - } - else { - ar->isvararg = f->l.p->is_vararg; - ar->nparams = f->l.p->numparams; - } - break; - } - case 't': { - ar->istailcall = (ci) ? ci->callstatus & CIST_TAIL : 0; - break; - } - case 'n': { - /* calling function is a known Lua function? */ - if (ci && !(ci->callstatus & CIST_TAIL) && isLua(ci->previous)) - ar->namewhat = getfuncname(L, ci->previous, &ar->name); - else - ar->namewhat = NULL; - if (ar->namewhat == NULL) { - ar->namewhat = ""; /* not found */ - ar->name = NULL; - } - break; - } - case 'L': - case 'f': /* handled by lua_getinfo */ - break; - default: status = 0; /* invalid option */ - } - } - return status; -} - - -LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { - int status; - Closure *cl; - CallInfo *ci; - StkId func; - lua_lock(L); - swapextra(L); - if (*what == '>') { - ci = NULL; - func = L->top - 1; - api_check(ttisfunction(func), "function expected"); - what++; /* skip the '>' */ - L->top--; /* pop function */ - } - else { - ci = ar->i_ci; - func = ci->func; - lua_assert(ttisfunction(ci->func)); - } - cl = ttisclosure(func) ? clvalue(func) : NULL; - status = auxgetinfo(L, what, ar, cl, ci); - if (strchr(what, 'f')) { - setobjs2s(L, L->top, func); - api_incr_top(L); - } - swapextra(L); - if (strchr(what, 'L')) - collectvalidlines(L, cl); - lua_unlock(L); - return status; -} - - -/* -** {====================================================== -** Symbolic Execution -** ======================================================= -*/ - -static const char *getobjname (Proto *p, int lastpc, int reg, - const char **name); - - -/* -** find a "name" for the RK value 'c' -*/ -static void kname (Proto *p, int pc, int c, const char **name) { - if (ISK(c)) { /* is 'c' a constant? */ - TValue *kvalue = &p->k[INDEXK(c)]; - if (ttisstring(kvalue)) { /* literal constant? */ - *name = svalue(kvalue); /* it is its own name */ - return; - } - /* else no reasonable name found */ - } - else { /* 'c' is a register */ - const char *what = getobjname(p, pc, c, name); /* search for 'c' */ - if (what && *what == 'c') { /* found a constant name? */ - return; /* 'name' already filled */ - } - /* else no reasonable name found */ - } - *name = "?"; /* no reasonable name found */ -} - - -static int filterpc (int pc, int jmptarget) { - if (pc < jmptarget) /* is code conditional (inside a jump)? */ - return -1; /* cannot know who sets that register */ - else return pc; /* current position sets that register */ -} - - -/* -** try to find last instruction before 'lastpc' that modified register 'reg' -*/ -static int findsetreg (Proto *p, int lastpc, int reg) { - int pc; - int setreg = -1; /* keep last instruction that changed 'reg' */ - int jmptarget = 0; /* any code before this address is conditional */ - for (pc = 0; pc < lastpc; pc++) { - Instruction i = p->code[pc]; - OpCode op = GET_OPCODE(i); - int a = GETARG_A(i); - switch (op) { - case OP_LOADNIL: { - int b = GETARG_B(i); - if (a <= reg && reg <= a + b) /* set registers from 'a' to 'a+b' */ - setreg = filterpc(pc, jmptarget); - break; - } - case OP_TFORCALL: { - if (reg >= a + 2) /* affect all regs above its base */ - setreg = filterpc(pc, jmptarget); - break; - } - case OP_CALL: - case OP_TAILCALL: { - if (reg >= a) /* affect all registers above base */ - setreg = filterpc(pc, jmptarget); - break; - } - case OP_JMP: { - int b = GETARG_sBx(i); - int dest = pc + 1 + b; - /* jump is forward and do not skip 'lastpc'? */ - if (pc < dest && dest <= lastpc) { - if (dest > jmptarget) - jmptarget = dest; /* update 'jmptarget' */ - } - break; - } - default: - if (testAMode(op) && reg == a) /* any instruction that set A */ - setreg = filterpc(pc, jmptarget); - break; - } - } - return setreg; -} - - -static const char *getobjname (Proto *p, int lastpc, int reg, - const char **name) { - int pc; - *name = luaF_getlocalname(p, reg + 1, lastpc); - if (*name) /* is a local? */ - return "local"; - /* else try symbolic execution */ - pc = findsetreg(p, lastpc, reg); - if (pc != -1) { /* could find instruction? */ - Instruction i = p->code[pc]; - OpCode op = GET_OPCODE(i); - switch (op) { - case OP_MOVE: { - int b = GETARG_B(i); /* move from 'b' to 'a' */ - if (b < GETARG_A(i)) - return getobjname(p, pc, b, name); /* get name for 'b' */ - break; - } - case OP_GETTABUP: - case OP_GETTABLE: { - int k = GETARG_C(i); /* key index */ - int t = GETARG_B(i); /* table index */ - const char *vn = (op == OP_GETTABLE) /* name of indexed variable */ - ? luaF_getlocalname(p, t + 1, pc) - : upvalname(p, t); - kname(p, pc, k, name); - return (vn && strcmp(vn, LUA_ENV) == 0) ? "global" : "field"; - } - case OP_GETUPVAL: { - *name = upvalname(p, GETARG_B(i)); - return "upvalue"; - } - case OP_LOADK: - case OP_LOADKX: { - int b = (op == OP_LOADK) ? GETARG_Bx(i) - : GETARG_Ax(p->code[pc + 1]); - if (ttisstring(&p->k[b])) { - *name = svalue(&p->k[b]); - return "constant"; - } - break; - } - case OP_SELF: { - int k = GETARG_C(i); /* key index */ - kname(p, pc, k, name); - return "method"; - } - default: break; /* go through to return NULL */ - } - } - return NULL; /* could not find reasonable name */ -} - - -static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { - TMS tm = (TMS)0; /* to avoid warnings */ - Proto *p = ci_func(ci)->p; /* calling function */ - int pc = currentpc(ci); /* calling instruction index */ - Instruction i = p->code[pc]; /* calling instruction */ - if (ci->callstatus & CIST_HOOKED) { /* was it called inside a hook? */ - *name = "?"; - return "hook"; - } - switch (GET_OPCODE(i)) { - case OP_CALL: - case OP_TAILCALL: /* get function name */ - return getobjname(p, pc, GETARG_A(i), name); - case OP_TFORCALL: { /* for iterator */ - *name = "for iterator"; - return "for iterator"; - } - /* all other instructions can call only through metamethods */ - case OP_SELF: case OP_GETTABUP: case OP_GETTABLE: - tm = TM_INDEX; - break; - case OP_SETTABUP: case OP_SETTABLE: - tm = TM_NEWINDEX; - break; - case OP_ADD: case OP_SUB: case OP_MUL: case OP_MOD: - case OP_POW: case OP_DIV: case OP_IDIV: case OP_BAND: - case OP_BOR: case OP_BXOR: case OP_SHL: case OP_SHR: { - int offset = cast_int(GET_OPCODE(i)) - cast_int(OP_ADD); /* ORDER OP */ - tm = cast(TMS, offset + cast_int(TM_ADD)); /* ORDER TM */ - break; - } - case OP_UNM: tm = TM_UNM; break; - case OP_BNOT: tm = TM_BNOT; break; - case OP_LEN: tm = TM_LEN; break; - case OP_CONCAT: tm = TM_CONCAT; break; - case OP_EQ: tm = TM_EQ; break; - case OP_LT: tm = TM_LT; break; - case OP_LE: tm = TM_LE; break; - default: lua_assert(0); /* other instructions cannot call a function */ - } - *name = getstr(G(L)->tmname[tm]); - return "metamethod"; -} - -/* }====================================================== */ - - - -/* -** The subtraction of two potentially unrelated pointers is -** not ISO C, but it should not crash a program; the subsequent -** checks are ISO C and ensure a correct result. -*/ -static int isinstack (CallInfo *ci, const TValue *o) { - ptrdiff_t i = o - ci->u.l.base; - return (0 <= i && i < (ci->top - ci->u.l.base) && ci->u.l.base + i == o); -} - - -/* -** Checks whether value 'o' came from an upvalue. (That can only happen -** with instructions OP_GETTABUP/OP_SETTABUP, which operate directly on -** upvalues.) -*/ -static const char *getupvalname (CallInfo *ci, const TValue *o, - const char **name) { - LClosure *c = ci_func(ci); - int i; - for (i = 0; i < c->nupvalues; i++) { - if (c->upvals[i]->v == o) { - *name = upvalname(c->p, i); - return "upvalue"; - } - } - return NULL; -} - - -static const char *varinfo (lua_State *L, const TValue *o) { - const char *name = NULL; /* to avoid warnings */ - CallInfo *ci = L->ci; - const char *kind = NULL; - if (isLua(ci)) { - kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ - if (!kind && isinstack(ci, o)) /* no? try a register */ - kind = getobjname(ci_func(ci)->p, currentpc(ci), - cast_int(o - ci->u.l.base), &name); - } - return (kind) ? luaO_pushfstring(L, " (%s '%s')", kind, name) : ""; -} - - -l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { - const char *t = objtypename(o); - luaG_runerror(L, "attempt to %s a %s value%s", op, t, varinfo(L, o)); -} - - -l_noret luaG_concaterror (lua_State *L, const TValue *p1, const TValue *p2) { - if (ttisstring(p1) || cvt2str(p1)) p1 = p2; - luaG_typeerror(L, p1, "concatenate"); -} - - -l_noret luaG_opinterror (lua_State *L, const TValue *p1, - const TValue *p2, const char *msg) { - lua_Number temp; - if (!tonumber(p1, &temp)) /* first operand is wrong? */ - p2 = p1; /* now second is wrong */ - luaG_typeerror(L, p2, msg); -} - - -/* -** Error when both values are convertible to numbers, but not to integers -*/ -l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2) { - lua_Integer temp; - if (!tointeger(p1, &temp)) - p2 = p1; - luaG_runerror(L, "number%s has no integer representation", varinfo(L, p2)); -} - - -l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { - const char *t1 = objtypename(p1); - const char *t2 = objtypename(p2); - if (t1 == t2) - luaG_runerror(L, "attempt to compare two %s values", t1); - else - luaG_runerror(L, "attempt to compare %s with %s", t1, t2); -} - - -static void addinfo (lua_State *L, const char *msg) { - CallInfo *ci = L->ci; - if (isLua(ci)) { /* is Lua code? */ - char buff[LUA_IDSIZE]; /* add file:line information */ - int line = currentline(ci); - TString *src = ci_func(ci)->p->source; - if (src) - luaO_chunkid(buff, getstr(src), LUA_IDSIZE); - else { /* no source available; use "?" instead */ - buff[0] = '?'; buff[1] = '\0'; - } - luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); - } -} - - -l_noret luaG_errormsg (lua_State *L) { - if (L->errfunc != 0) { /* is there an error handling function? */ - StkId errfunc = restorestack(L, L->errfunc); - setobjs2s(L, L->top, L->top - 1); /* move argument */ - setobjs2s(L, L->top - 1, errfunc); /* push function */ - L->top++; /* assume EXTRA_STACK */ - luaD_call(L, L->top - 2, 1, 0); /* call it */ - } - luaD_throw(L, LUA_ERRRUN); -} - - -l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { - va_list argp; - va_start(argp, fmt); - addinfo(L, luaO_pushvfstring(L, fmt, argp)); - va_end(argp); - luaG_errormsg(L); -} - - -void luaG_traceexec (lua_State *L) { - CallInfo *ci = L->ci; - lu_byte mask = L->hookmask; - int counthook = ((mask & LUA_MASKCOUNT) && L->hookcount == 0); - if (counthook) - resethookcount(L); /* reset count */ - if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */ - ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */ - return; /* do not call hook again (VM yielded, so it did not move) */ - } - if (counthook) - luaD_hook(L, LUA_HOOKCOUNT, -1); /* call count hook */ - if (mask & LUA_MASKLINE) { - Proto *p = ci_func(ci)->p; - int npc = pcRel(ci->u.l.savedpc, p); - int newline = getfuncline(p, npc); - if (npc == 0 || /* call linehook when enter a new function, */ - ci->u.l.savedpc <= L->oldpc || /* when jump back (loop), or when */ - newline != getfuncline(p, pcRel(L->oldpc, p))) /* enter a new line */ - luaD_hook(L, LUA_HOOKLINE, newline); /* call line hook */ - } - L->oldpc = ci->u.l.savedpc; - if (L->status == LUA_YIELD) { /* did hook yield? */ - if (counthook) - L->hookcount = 1; /* undo decrement to zero */ - ci->u.l.savedpc--; /* undo increment (resume will increment it again) */ - ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */ - ci->func = L->top - 1; /* protect stack below results */ - luaD_throw(L, LUA_YIELD); - } -} - diff --git a/thirdparty/src/Lua/ldebug.h b/thirdparty/src/Lua/ldebug.h deleted file mode 100644 index 0d8966ca9..000000000 --- a/thirdparty/src/Lua/ldebug.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -** $Id: ldebug.h,v 2.12 2014/11/10 14:46:05 roberto Exp $ -** Auxiliary functions from Debug Interface module -** See Copyright Notice in lua.h -*/ - -#ifndef ldebug_h -#define ldebug_h - - -#include "lstate.h" - - -#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) - -#define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) - -#define resethookcount(L) (L->hookcount = L->basehookcount) - -/* Active Lua function (given call info) */ -#define ci_func(ci) (clLvalue((ci)->func)) - - -LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, - const char *opname); -LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, - const TValue *p2); -LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, - const TValue *p2, - const char *msg); -LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, - const TValue *p2); -LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, - const TValue *p2); -LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); -LUAI_FUNC l_noret luaG_errormsg (lua_State *L); -LUAI_FUNC void luaG_traceexec (lua_State *L); - - -#endif diff --git a/thirdparty/src/Lua/ldo.cpp b/thirdparty/src/Lua/ldo.cpp deleted file mode 100644 index 039872df0..000000000 --- a/thirdparty/src/Lua/ldo.cpp +++ /dev/null @@ -1,717 +0,0 @@ -/* -** $Id: ldo.c,v 2.135 2014/11/11 17:13:39 roberto Exp $ -** Stack and Call structure of Lua -** See Copyright Notice in lua.h -*/ - -#define ldo_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <setjmp.h> -#include <stdlib.h> -#include <string.h> - -#include <Lua/lua.h> - -#include "lapi.h" -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lgc.h" -#include "lmem.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lparser.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" -#include "lundump.h" -#include "lvm.h" -#include "lzio.h" - - - -#define errorstatus(s) ((s) > LUA_YIELD) - - -/* -** {====================================================== -** Error-recovery functions -** ======================================================= -*/ - -/* -** LUAI_THROW/LUAI_TRY define how Lua does exception handling. By -** default, Lua handles errors with exceptions when compiling as -** C++ code, with _longjmp/_setjmp when asked to use them, and with -** longjmp/setjmp otherwise. -*/ -#if !defined(LUAI_THROW) /* { */ - -#if defined(__cplusplus) && !defined(LUA_USE_LONGJMP) /* { */ - -/* C++ exceptions */ -#define LUAI_THROW(L,c) throw(c) -#define LUAI_TRY(L,c,a) \ - try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; } -#define luai_jmpbuf int /* dummy variable */ - -#elif defined(LUA_USE_POSIX) /* }{ */ - -/* in POSIX, try _longjmp/_setjmp (more efficient) */ -#define LUAI_THROW(L,c) _longjmp((c)->b, 1) -#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } -#define luai_jmpbuf jmp_buf - -#else /* }{ */ - -/* ISO C handling with long jumps */ -#define LUAI_THROW(L,c) longjmp((c)->b, 1) -#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } -#define luai_jmpbuf jmp_buf - -#endif /* } */ - -#endif /* } */ - - - -/* chain list of long jump buffers */ -struct lua_longjmp { - struct lua_longjmp *previous; - luai_jmpbuf b; - volatile int status; /* error code */ -}; - - -static void seterrorobj (lua_State *L, int errcode, StkId oldtop) { - switch (errcode) { - case LUA_ERRMEM: { /* memory error? */ - setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */ - break; - } - case LUA_ERRERR: { - setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); - break; - } - default: { - setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ - break; - } - } - L->top = oldtop + 1; -} - - -l_noret luaD_throw (lua_State *L, int errcode) { - if (L->errorJmp) { /* thread has an error handler? */ - L->errorJmp->status = errcode; /* set status */ - LUAI_THROW(L, L->errorJmp); /* jump to it */ - } - else { /* thread has no error handler */ - global_State *g = G(L); - L->status = cast_byte(errcode); /* mark it as dead */ - if (g->mainthread->errorJmp) { /* main thread has a handler? */ - setobjs2s(L, g->mainthread->top++, L->top - 1); /* copy error obj. */ - luaD_throw(g->mainthread, errcode); /* re-throw in main thread */ - } - else { /* no handler at all; abort */ - if (g->panic) { /* panic function? */ - seterrorobj(L, errcode, L->top); /* assume EXTRA_STACK */ - if (L->ci->top < L->top) - L->ci->top = L->top; /* pushing msg. can break this invariant */ - lua_unlock(L); - g->panic(L); /* call panic function (last chance to jump out) */ - } - abort(); - } - } -} - - -int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { - unsigned short oldnCcalls = L->nCcalls; - struct lua_longjmp lj; - lj.status = LUA_OK; - lj.previous = L->errorJmp; /* chain new error handler */ - L->errorJmp = &lj; - LUAI_TRY(L, &lj, - (*f)(L, ud); - ); - L->errorJmp = lj.previous; /* restore old error handler */ - L->nCcalls = oldnCcalls; - return lj.status; -} - -/* }====================================================== */ - - -static void correctstack (lua_State *L, TValue *oldstack) { - CallInfo *ci; - UpVal *up; - L->top = (L->top - oldstack) + L->stack; - for (up = L->openupval; up != NULL; up = up->u.open.next) - up->v = (up->v - oldstack) + L->stack; - for (ci = L->ci; ci != NULL; ci = ci->previous) { - ci->top = (ci->top - oldstack) + L->stack; - ci->func = (ci->func - oldstack) + L->stack; - if (isLua(ci)) - ci->u.l.base = (ci->u.l.base - oldstack) + L->stack; - } -} - - -/* some space for error handling */ -#define ERRORSTACKSIZE (LUAI_MAXSTACK + 200) - - -void luaD_reallocstack (lua_State *L, int newsize) { - TValue *oldstack = L->stack; - int lim = L->stacksize; - lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE); - lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK); - luaM_reallocvector(L, L->stack, L->stacksize, newsize, TValue); - for (; lim < newsize; lim++) - setnilvalue(L->stack + lim); /* erase new segment */ - L->stacksize = newsize; - L->stack_last = L->stack + newsize - EXTRA_STACK; - correctstack(L, oldstack); -} - - -void luaD_growstack (lua_State *L, int n) { - int size = L->stacksize; - if (size > LUAI_MAXSTACK) /* error after extra size? */ - luaD_throw(L, LUA_ERRERR); - else { - int needed = cast_int(L->top - L->stack) + n + EXTRA_STACK; - int newsize = 2 * size; - if (newsize > LUAI_MAXSTACK) newsize = LUAI_MAXSTACK; - if (newsize < needed) newsize = needed; - if (newsize > LUAI_MAXSTACK) { /* stack overflow? */ - luaD_reallocstack(L, ERRORSTACKSIZE); - luaG_runerror(L, "stack overflow"); - } - else - luaD_reallocstack(L, newsize); - } -} - - -static int stackinuse (lua_State *L) { - CallInfo *ci; - StkId lim = L->top; - for (ci = L->ci; ci != NULL; ci = ci->previous) { - lua_assert(ci->top <= L->stack_last); - if (lim < ci->top) lim = ci->top; - } - return cast_int(lim - L->stack) + 1; /* part of stack in use */ -} - - -void luaD_shrinkstack (lua_State *L) { - int inuse = stackinuse(L); - int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK; - if (goodsize > LUAI_MAXSTACK) goodsize = LUAI_MAXSTACK; - if (L->stacksize > LUAI_MAXSTACK) /* was handling stack overflow? */ - luaE_freeCI(L); /* free all CIs (list grew because of an error) */ - else - luaE_shrinkCI(L); /* shrink list */ - if (inuse > LUAI_MAXSTACK || /* still handling stack overflow? */ - goodsize >= L->stacksize) /* would grow instead of shrink? */ - condmovestack(L); /* don't change stack (change only for debugging) */ - else - luaD_reallocstack(L, goodsize); /* shrink it */ -} - - -void luaD_hook (lua_State *L, int event, int line) { - lua_Hook hook = L->hook; - if (hook && L->allowhook) { - CallInfo *ci = L->ci; - ptrdiff_t top = savestack(L, L->top); - ptrdiff_t ci_top = savestack(L, ci->top); - lua_Debug ar; - ar.event = event; - ar.currentline = line; - ar.i_ci = ci; - luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ - ci->top = L->top + LUA_MINSTACK; - lua_assert(ci->top <= L->stack_last); - L->allowhook = 0; /* cannot call hooks inside a hook */ - ci->callstatus |= CIST_HOOKED; - lua_unlock(L); - (*hook)(L, &ar); - lua_lock(L); - lua_assert(!L->allowhook); - L->allowhook = 1; - ci->top = restorestack(L, ci_top); - L->top = restorestack(L, top); - ci->callstatus &= ~CIST_HOOKED; - } -} - - -static void callhook (lua_State *L, CallInfo *ci) { - int hook = LUA_HOOKCALL; - ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */ - if (isLua(ci->previous) && - GET_OPCODE(*(ci->previous->u.l.savedpc - 1)) == OP_TAILCALL) { - ci->callstatus |= CIST_TAIL; - hook = LUA_HOOKTAILCALL; - } - luaD_hook(L, hook, -1); - ci->u.l.savedpc--; /* correct 'pc' */ -} - - -static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { - int i; - int nfixargs = p->numparams; - StkId base, fixed; - lua_assert(actual >= nfixargs); - /* move fixed parameters to final position */ - luaD_checkstack(L, p->maxstacksize); /* check again for new 'base' */ - fixed = L->top - actual; /* first fixed argument */ - base = L->top; /* final position of first argument */ - for (i=0; i<nfixargs; i++) { - setobjs2s(L, L->top++, fixed + i); - setnilvalue(fixed + i); - } - return base; -} - - -/* -** Check whether __call metafield of 'func' is a function. If so, put -** it in stack below original 'func' so that 'luaD_precall' can call -** it. Raise an error if __call metafield is not a function. -*/ -static void tryfuncTM (lua_State *L, StkId func) { - const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); - StkId p; - if (!ttisfunction(tm)) - luaG_typeerror(L, func, "call"); - /* Open a hole inside the stack at 'func' */ - for (p = L->top; p > func; p--) - setobjs2s(L, p, p-1); - L->top++; /* slot ensured by caller */ - setobj2s(L, func, tm); /* tag method is the new function to be called */ -} - - - -#define next_ci(L) (L->ci = (L->ci->next ? L->ci->next : luaE_extendCI(L))) - - -/* -** returns true if function has been executed (C function) -*/ -int luaD_precall (lua_State *L, StkId func, int nresults) { - lua_CFunction f; - CallInfo *ci; - int n; /* number of arguments (Lua) or returns (C) */ - ptrdiff_t funcr = savestack(L, func); - switch (ttype(func)) { - case LUA_TLCF: /* light C function */ - f = fvalue(func); - goto Cfunc; - case LUA_TCCL: { /* C closure */ - f = clCvalue(func)->f; - Cfunc: - luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ - ci = next_ci(L); /* now 'enter' new function */ - ci->nresults = nresults; - ci->func = restorestack(L, funcr); - ci->top = L->top + LUA_MINSTACK; - lua_assert(ci->top <= L->stack_last); - ci->callstatus = 0; - luaC_checkGC(L); /* stack grow uses memory */ - if (L->hookmask & LUA_MASKCALL) - luaD_hook(L, LUA_HOOKCALL, -1); - lua_unlock(L); - n = (*f)(L); /* do the actual call */ - lua_lock(L); - api_checknelems(L, n); - luaD_poscall(L, L->top - n); - return 1; - } - case LUA_TLCL: { /* Lua function: prepare its call */ - StkId base; - Proto *p = clLvalue(func)->p; - n = cast_int(L->top - func) - 1; /* number of real arguments */ - luaD_checkstack(L, p->maxstacksize); - for (; n < p->numparams; n++) - setnilvalue(L->top++); /* complete missing arguments */ - if (!p->is_vararg) { - func = restorestack(L, funcr); - base = func + 1; - } - else { - base = adjust_varargs(L, p, n); - func = restorestack(L, funcr); /* previous call can change stack */ - } - ci = next_ci(L); /* now 'enter' new function */ - ci->nresults = nresults; - ci->func = func; - ci->u.l.base = base; - ci->top = base + p->maxstacksize; - lua_assert(ci->top <= L->stack_last); - ci->u.l.savedpc = p->code; /* starting point */ - ci->callstatus = CIST_LUA; - L->top = ci->top; - luaC_checkGC(L); /* stack grow uses memory */ - if (L->hookmask & LUA_MASKCALL) - callhook(L, ci); - return 0; - } - default: { /* not a function */ - luaD_checkstack(L, 1); /* ensure space for metamethod */ - func = restorestack(L, funcr); /* previous call may change stack */ - tryfuncTM(L, func); /* try to get '__call' metamethod */ - return luaD_precall(L, func, nresults); /* now it must be a function */ - } - } -} - - -int luaD_poscall (lua_State *L, StkId firstResult) { - StkId res; - int wanted, i; - CallInfo *ci = L->ci; - if (L->hookmask & (LUA_MASKRET | LUA_MASKLINE)) { - if (L->hookmask & LUA_MASKRET) { - ptrdiff_t fr = savestack(L, firstResult); /* hook may change stack */ - luaD_hook(L, LUA_HOOKRET, -1); - firstResult = restorestack(L, fr); - } - L->oldpc = ci->previous->u.l.savedpc; /* 'oldpc' for caller function */ - } - res = ci->func; /* res == final position of 1st result */ - wanted = ci->nresults; - L->ci = ci = ci->previous; /* back to caller */ - /* move results to correct place */ - for (i = wanted; i != 0 && firstResult < L->top; i--) - setobjs2s(L, res++, firstResult++); - while (i-- > 0) - setnilvalue(res++); - L->top = res; - return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */ -} - - -/* -** Call a function (C or Lua). The function to be called is at *func. -** The arguments are on the stack, right after the function. -** When returns, all the results are on the stack, starting at the original -** function position. -*/ -void luaD_call (lua_State *L, StkId func, int nResults, int allowyield) { - if (++L->nCcalls >= LUAI_MAXCCALLS) { - if (L->nCcalls == LUAI_MAXCCALLS) - luaG_runerror(L, "C stack overflow"); - else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) - luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ - } - if (!allowyield) L->nny++; - if (!luaD_precall(L, func, nResults)) /* is a Lua function? */ - luaV_execute(L); /* call it */ - if (!allowyield) L->nny--; - L->nCcalls--; -} - - -/* -** Completes the execution of an interrupted C function, calling its -** continuation function. -*/ -static void finishCcall (lua_State *L, int status) { - CallInfo *ci = L->ci; - int n; - /* must have a continuation and must be able to call it */ - lua_assert(ci->u.c.k != NULL && L->nny == 0); - /* error status can only happen in a protected call */ - lua_assert((ci->callstatus & CIST_YPCALL) || status == LUA_YIELD); - if (ci->callstatus & CIST_YPCALL) { /* was inside a pcall? */ - ci->callstatus &= ~CIST_YPCALL; /* finish 'lua_pcall' */ - L->errfunc = ci->u.c.old_errfunc; - } - /* finish 'lua_callk'/'lua_pcall'; CIST_YPCALL and 'errfunc' already - handled */ - adjustresults(L, ci->nresults); - /* call continuation function */ - lua_unlock(L); - n = (*ci->u.c.k)(L, status, ci->u.c.ctx); - lua_lock(L); - api_checknelems(L, n); - /* finish 'luaD_precall' */ - luaD_poscall(L, L->top - n); -} - - -/* -** Executes "full continuation" (everything in the stack) of a -** previously interrupted coroutine until the stack is empty (or another -** interruption long-jumps out of the loop). If the coroutine is -** recovering from an error, 'ud' points to the error status, which must -** be passed to the first continuation function (otherwise the default -** status is LUA_YIELD). -*/ -static void unroll (lua_State *L, void *ud) { - if (ud != NULL) /* error status? */ - finishCcall(L, *(int *)ud); /* finish 'lua_pcallk' callee */ - while (L->ci != &L->base_ci) { /* something in the stack */ - if (!isLua(L->ci)) /* C function? */ - finishCcall(L, LUA_YIELD); /* complete its execution */ - else { /* Lua function */ - luaV_finishOp(L); /* finish interrupted instruction */ - luaV_execute(L); /* execute down to higher C 'boundary' */ - } - } -} - - -/* -** Try to find a suspended protected call (a "recover point") for the -** given thread. -*/ -static CallInfo *findpcall (lua_State *L) { - CallInfo *ci; - for (ci = L->ci; ci != NULL; ci = ci->previous) { /* search for a pcall */ - if (ci->callstatus & CIST_YPCALL) - return ci; - } - return NULL; /* no pending pcall */ -} - - -/* -** Recovers from an error in a coroutine. Finds a recover point (if -** there is one) and completes the execution of the interrupted -** 'luaD_pcall'. If there is no recover point, returns zero. -*/ -static int recover (lua_State *L, int status) { - StkId oldtop; - CallInfo *ci = findpcall(L); - if (ci == NULL) return 0; /* no recovery point */ - /* "finish" luaD_pcall */ - oldtop = restorestack(L, ci->extra); - luaF_close(L, oldtop); - seterrorobj(L, status, oldtop); - L->ci = ci; - L->allowhook = getoah(ci->callstatus); /* restore original 'allowhook' */ - L->nny = 0; /* should be zero to be yieldable */ - luaD_shrinkstack(L); - L->errfunc = ci->u.c.old_errfunc; - return 1; /* continue running the coroutine */ -} - - -/* -** signal an error in the call to 'resume', not in the execution of the -** coroutine itself. (Such errors should not be handled by any coroutine -** error handler and should not kill the coroutine.) -*/ -static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) { - L->top = firstArg; /* remove args from the stack */ - setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */ - api_incr_top(L); - luaD_throw(L, -1); /* jump back to 'lua_resume' */ -} - - -/* -** Do the work for 'lua_resume' in protected mode. Most of the work -** depends on the status of the coroutine: initial state, suspended -** inside a hook, or regularly suspended (optionally with a continuation -** function), plus erroneous cases: non-suspended coroutine or dead -** coroutine. -*/ -static void resume (lua_State *L, void *ud) { - int nCcalls = L->nCcalls; - StkId firstArg = cast(StkId, ud); - CallInfo *ci = L->ci; - if (nCcalls >= LUAI_MAXCCALLS) - resume_error(L, "C stack overflow", firstArg); - if (L->status == LUA_OK) { /* may be starting a coroutine */ - if (ci != &L->base_ci) /* not in base level? */ - resume_error(L, "cannot resume non-suspended coroutine", firstArg); - /* coroutine is in base level; start running it */ - if (!luaD_precall(L, firstArg - 1, LUA_MULTRET)) /* Lua function? */ - luaV_execute(L); /* call it */ - } - else if (L->status != LUA_YIELD) - resume_error(L, "cannot resume dead coroutine", firstArg); - else { /* resuming from previous yield */ - L->status = LUA_OK; /* mark that it is running (again) */ - ci->func = restorestack(L, ci->extra); - if (isLua(ci)) /* yielded inside a hook? */ - luaV_execute(L); /* just continue running Lua code */ - else { /* 'common' yield */ - if (ci->u.c.k != NULL) { /* does it have a continuation function? */ - int n; - lua_unlock(L); - n = (*ci->u.c.k)(L, LUA_YIELD, ci->u.c.ctx); /* call continuation */ - lua_lock(L); - api_checknelems(L, n); - firstArg = L->top - n; /* yield results come from continuation */ - } - luaD_poscall(L, firstArg); /* finish 'luaD_precall' */ - } - unroll(L, NULL); /* run continuation */ - } - lua_assert(nCcalls == L->nCcalls); -} - - -LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs) { - int status; - int oldnny = L->nny; /* save "number of non-yieldable" calls */ - lua_lock(L); - luai_userstateresume(L, nargs); - L->nCcalls = (from) ? from->nCcalls + 1 : 1; - L->nny = 0; /* allow yields */ - api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs); - status = luaD_rawrunprotected(L, resume, L->top - nargs); - if (status == -1) /* error calling 'lua_resume'? */ - status = LUA_ERRRUN; - else { /* continue running after recoverable errors */ - while (errorstatus(status) && recover(L, status)) { - /* unroll continuation */ - status = luaD_rawrunprotected(L, unroll, &status); - } - if (errorstatus(status)) { /* unrecoverable error? */ - L->status = cast_byte(status); /* mark thread as 'dead' */ - seterrorobj(L, status, L->top); /* push error message */ - L->ci->top = L->top; - } - else lua_assert(status == L->status); /* normal end or yield */ - } - L->nny = oldnny; /* restore 'nny' */ - L->nCcalls--; - lua_assert(L->nCcalls == ((from) ? from->nCcalls : 0)); - lua_unlock(L); - return status; -} - - -LUA_API int lua_isyieldable (lua_State *L) { - return (L->nny == 0); -} - - -LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx, - lua_KFunction k) { - CallInfo *ci = L->ci; - luai_userstateyield(L, nresults); - lua_lock(L); - api_checknelems(L, nresults); - if (L->nny > 0) { - if (L != G(L)->mainthread) - luaG_runerror(L, "attempt to yield across a C-call boundary"); - else - luaG_runerror(L, "attempt to yield from outside a coroutine"); - } - L->status = LUA_YIELD; - ci->extra = savestack(L, ci->func); /* save current 'func' */ - if (isLua(ci)) { /* inside a hook? */ - api_check(k == NULL, "hooks cannot continue after yielding"); - } - else { - if ((ci->u.c.k = k) != NULL) /* is there a continuation? */ - ci->u.c.ctx = ctx; /* save context */ - ci->func = L->top - nresults - 1; /* protect stack below results */ - luaD_throw(L, LUA_YIELD); - } - lua_assert(ci->callstatus & CIST_HOOKED); /* must be inside a hook */ - lua_unlock(L); - return 0; /* return to 'luaD_hook' */ -} - - -int luaD_pcall (lua_State *L, Pfunc func, void *u, - ptrdiff_t old_top, ptrdiff_t ef) { - int status; - CallInfo *old_ci = L->ci; - lu_byte old_allowhooks = L->allowhook; - unsigned short old_nny = L->nny; - ptrdiff_t old_errfunc = L->errfunc; - L->errfunc = ef; - status = luaD_rawrunprotected(L, func, u); - if (status != LUA_OK) { /* an error occurred? */ - StkId oldtop = restorestack(L, old_top); - luaF_close(L, oldtop); /* close possible pending closures */ - seterrorobj(L, status, oldtop); - L->ci = old_ci; - L->allowhook = old_allowhooks; - L->nny = old_nny; - luaD_shrinkstack(L); - } - L->errfunc = old_errfunc; - return status; -} - - - -/* -** Execute a protected parser. -*/ -struct SParser { /* data to 'f_parser' */ - ZIO *z; - Mbuffer buff; /* dynamic structure used by the scanner */ - Dyndata dyd; /* dynamic structures used by the parser */ - const char *mode; - const char *name; -}; - - -static void checkmode (lua_State *L, const char *mode, const char *x) { - if (mode && strchr(mode, x[0]) == NULL) { - luaO_pushfstring(L, - "attempt to load a %s chunk (mode is '%s')", x, mode); - luaD_throw(L, LUA_ERRSYNTAX); - } -} - - -static void f_parser (lua_State *L, void *ud) { - LClosure *cl; - struct SParser *p = cast(struct SParser *, ud); - int c = zgetc(p->z); /* read first character */ - if (c == LUA_SIGNATURE[0]) { - checkmode(L, p->mode, "binary"); - cl = luaU_undump(L, p->z, &p->buff, p->name); - } - else { - checkmode(L, p->mode, "text"); - cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c); - } - lua_assert(cl->nupvalues == cl->p->sizeupvalues); - luaF_initupvals(L, cl); -} - - -int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, - const char *mode) { - struct SParser p; - int status; - L->nny++; /* cannot yield during parsing */ - p.z = z; p.name = name; p.mode = mode; - p.dyd.actvar.arr = NULL; p.dyd.actvar.size = 0; - p.dyd.gt.arr = NULL; p.dyd.gt.size = 0; - p.dyd.label.arr = NULL; p.dyd.label.size = 0; - luaZ_initbuffer(L, &p.buff); - status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); - luaZ_freebuffer(L, &p.buff); - luaM_freearray(L, p.dyd.actvar.arr, p.dyd.actvar.size); - luaM_freearray(L, p.dyd.gt.arr, p.dyd.gt.size); - luaM_freearray(L, p.dyd.label.arr, p.dyd.label.size); - L->nny--; - return status; -} - - diff --git a/thirdparty/src/Lua/ldo.h b/thirdparty/src/Lua/ldo.h deleted file mode 100644 index 05745c8ad..000000000 --- a/thirdparty/src/Lua/ldo.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -** $Id: ldo.h,v 2.21 2014/10/25 11:50:46 roberto Exp $ -** Stack and Call structure of Lua -** See Copyright Notice in lua.h -*/ - -#ifndef ldo_h -#define ldo_h - - -#include "lobject.h" -#include "lstate.h" -#include "lzio.h" - - -#define luaD_checkstack(L,n) if (L->stack_last - L->top <= (n)) \ - luaD_growstack(L, n); else condmovestack(L); - - -#define incr_top(L) {L->top++; luaD_checkstack(L,0);} - -#define savestack(L,p) ((char *)(p) - (char *)L->stack) -#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) - - -/* type of protected functions, to be ran by 'runprotected' */ -typedef void (*Pfunc) (lua_State *L, void *ud); - -LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, - const char *mode); -LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); -LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); -LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults, - int allowyield); -LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, - ptrdiff_t oldtop, ptrdiff_t ef); -LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); -LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); -LUAI_FUNC void luaD_growstack (lua_State *L, int n); -LUAI_FUNC void luaD_shrinkstack (lua_State *L); - -LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); -LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); - -#endif - diff --git a/thirdparty/src/Lua/ldump.cpp b/thirdparty/src/Lua/ldump.cpp deleted file mode 100644 index b857d7e47..000000000 --- a/thirdparty/src/Lua/ldump.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* -** $Id: ldump.c,v 2.34 2014/11/02 19:19:04 roberto Exp $ -** save precompiled Lua chunks -** See Copyright Notice in lua.h -*/ - -#define ldump_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <stddef.h> - -#include <Lua/lua.h> - -#include "lobject.h" -#include "lstate.h" -#include "lundump.h" - - -typedef struct { - lua_State *L; - lua_Writer writer; - void *data; - int strip; - int status; -} DumpState; - - -/* -** All high-level dumps go through DumpVector; you can change it to -** change the endianness of the result -*/ -#define DumpVector(v,n,D) DumpBlock(v,(n)*sizeof((v)[0]),D) - -#define DumpLiteral(s,D) DumpBlock(s, sizeof(s) - sizeof(char), D) - - -static void DumpBlock (const void *b, size_t size, DumpState *D) { - if (D->status == 0) { - lua_unlock(D->L); - D->status = (*D->writer)(D->L, b, size, D->data); - lua_lock(D->L); - } -} - - -#define DumpVar(x,D) DumpVector(&x,1,D) - - -static void DumpByte (int y, DumpState *D) { - lu_byte x = (lu_byte)y; - DumpVar(x, D); -} - - -static void DumpInt (int x, DumpState *D) { - DumpVar(x, D); -} - - -static void DumpNumber (lua_Number x, DumpState *D) { - DumpVar(x, D); -} - - -static void DumpInteger (lua_Integer x, DumpState *D) { - DumpVar(x, D); -} - - -static void DumpString (const TString *s, DumpState *D) { - if (s == NULL) - DumpByte(0, D); - else { - size_t size = s->len + 1; /* include trailing '\0' */ - if (size < 0xFF) - DumpByte(cast_int(size), D); - else { - DumpByte(0xFF, D); - DumpVar(size, D); - } - DumpVector(getstr(s), size - 1, D); /* no need to save '\0' */ - } -} - - -static void DumpCode (const Proto *f, DumpState *D) { - DumpInt(f->sizecode, D); - DumpVector(f->code, f->sizecode, D); -} - - -static void DumpFunction(const Proto *f, TString *psource, DumpState *D); - -static void DumpConstants (const Proto *f, DumpState *D) { - int i; - int n = f->sizek; - DumpInt(n, D); - for (i = 0; i < n; i++) { - const TValue *o = &f->k[i]; - DumpByte(ttype(o), D); - switch (ttype(o)) { - case LUA_TNIL: - break; - case LUA_TBOOLEAN: - DumpByte(bvalue(o), D); - break; - case LUA_TNUMFLT: - DumpNumber(fltvalue(o), D); - break; - case LUA_TNUMINT: - DumpInteger(ivalue(o), D); - break; - case LUA_TSHRSTR: - case LUA_TLNGSTR: - DumpString(tsvalue(o), D); - break; - default: - lua_assert(0); - } - } -} - - -static void DumpProtos (const Proto *f, DumpState *D) { - int i; - int n = f->sizep; - DumpInt(n, D); - for (i = 0; i < n; i++) - DumpFunction(f->p[i], f->source, D); -} - - -static void DumpUpvalues (const Proto *f, DumpState *D) { - int i, n = f->sizeupvalues; - DumpInt(n, D); - for (i = 0; i < n; i++) { - DumpByte(f->upvalues[i].instack, D); - DumpByte(f->upvalues[i].idx, D); - } -} - - -static void DumpDebug (const Proto *f, DumpState *D) { - int i, n; - n = (D->strip) ? 0 : f->sizelineinfo; - DumpInt(n, D); - DumpVector(f->lineinfo, n, D); - n = (D->strip) ? 0 : f->sizelocvars; - DumpInt(n, D); - for (i = 0; i < n; i++) { - DumpString(f->locvars[i].varname, D); - DumpInt(f->locvars[i].startpc, D); - DumpInt(f->locvars[i].endpc, D); - } - n = (D->strip) ? 0 : f->sizeupvalues; - DumpInt(n, D); - for (i = 0; i < n; i++) - DumpString(f->upvalues[i].name, D); -} - - -static void DumpFunction (const Proto *f, TString *psource, DumpState *D) { - if (D->strip || f->source == psource) - DumpString(NULL, D); /* no debug info or same source as its parent */ - else - DumpString(f->source, D); - DumpInt(f->linedefined, D); - DumpInt(f->lastlinedefined, D); - DumpByte(f->numparams, D); - DumpByte(f->is_vararg, D); - DumpByte(f->maxstacksize, D); - DumpCode(f, D); - DumpConstants(f, D); - DumpUpvalues(f, D); - DumpProtos(f, D); - DumpDebug(f, D); -} - - -static void DumpHeader (DumpState *D) { - DumpLiteral(LUA_SIGNATURE, D); - DumpByte(LUAC_VERSION, D); - DumpByte(LUAC_FORMAT, D); - DumpLiteral(LUAC_DATA, D); - DumpByte(sizeof(int), D); - DumpByte(sizeof(size_t), D); - DumpByte(sizeof(Instruction), D); - DumpByte(sizeof(lua_Integer), D); - DumpByte(sizeof(lua_Number), D); - DumpInteger(LUAC_INT, D); - DumpNumber(LUAC_NUM, D); -} - - -/* -** dump Lua function as precompiled chunk -*/ -int luaU_dump(lua_State *L, const Proto *f, lua_Writer w, void *data, - int strip) { - DumpState D; - D.L = L; - D.writer = w; - D.data = data; - D.strip = strip; - D.status = 0; - DumpHeader(&D); - DumpByte(f->sizeupvalues, &D); - DumpFunction(f, NULL, &D); - return D.status; -} - diff --git a/thirdparty/src/Lua/lfunc.cpp b/thirdparty/src/Lua/lfunc.cpp deleted file mode 100644 index ef7f80552..000000000 --- a/thirdparty/src/Lua/lfunc.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* -** $Id: lfunc.c,v 2.45 2014/11/02 19:19:04 roberto Exp $ -** Auxiliary functions to manipulate prototypes and closures -** See Copyright Notice in lua.h -*/ - -#define lfunc_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <stddef.h> - -#include <Lua/lua.h> - -#include "lfunc.h" -#include "lgc.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" - - - -CClosure *luaF_newCclosure (lua_State *L, int n) { - GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(n)); - CClosure *c = gco2ccl(o); - c->nupvalues = cast_byte(n); - return c; -} - - -LClosure *luaF_newLclosure (lua_State *L, int n) { - GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(n)); - LClosure *c = gco2lcl(o); - c->p = NULL; - c->nupvalues = cast_byte(n); - while (n--) c->upvals[n] = NULL; - return c; -} - -/* -** fill a closure with new closed upvalues -*/ -void luaF_initupvals (lua_State *L, LClosure *cl) { - int i; - for (i = 0; i < cl->nupvalues; i++) { - UpVal *uv = luaM_new(L, UpVal); - uv->refcount = 1; - uv->v = &uv->u.value; /* make it closed */ - setnilvalue(uv->v); - cl->upvals[i] = uv; - } -} - - -UpVal *luaF_findupval (lua_State *L, StkId level) { - UpVal **pp = &L->openupval; - UpVal *p; - UpVal *uv; - lua_assert(isintwups(L) || L->openupval == NULL); - while (*pp != NULL && (p = *pp)->v >= level) { - lua_assert(upisopen(p)); - if (p->v == level) /* found a corresponding upvalue? */ - return p; /* return it */ - pp = &p->u.open.next; - } - /* not found: create a new upvalue */ - uv = luaM_new(L, UpVal); - uv->refcount = 0; - uv->u.open.next = *pp; /* link it to list of open upvalues */ - uv->u.open.touched = 1; - *pp = uv; - uv->v = level; /* current value lives in the stack */ - if (!isintwups(L)) { /* thread not in list of threads with upvalues? */ - L->twups = G(L)->twups; /* link it to the list */ - G(L)->twups = L; - } - return uv; -} - - -void luaF_close (lua_State *L, StkId level) { - UpVal *uv; - while (L->openupval != NULL && (uv = L->openupval)->v >= level) { - lua_assert(upisopen(uv)); - L->openupval = uv->u.open.next; /* remove from 'open' list */ - if (uv->refcount == 0) /* no references? */ - luaM_free(L, uv); /* free upvalue */ - else { - setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */ - uv->v = &uv->u.value; /* now current value lives here */ - luaC_upvalbarrier(L, uv); - } - } -} - - -Proto *luaF_newproto (lua_State *L) { - GCObject *o = luaC_newobj(L, LUA_TPROTO, sizeof(Proto)); - Proto *f = gco2p(o); - f->k = NULL; - f->sizek = 0; - f->p = NULL; - f->sizep = 0; - f->code = NULL; - f->cache = NULL; - f->sizecode = 0; - f->lineinfo = NULL; - f->sizelineinfo = 0; - f->upvalues = NULL; - f->sizeupvalues = 0; - f->numparams = 0; - f->is_vararg = 0; - f->maxstacksize = 0; - f->locvars = NULL; - f->sizelocvars = 0; - f->linedefined = 0; - f->lastlinedefined = 0; - f->source = NULL; - return f; -} - - -void luaF_freeproto (lua_State *L, Proto *f) { - luaM_freearray(L, f->code, f->sizecode); - luaM_freearray(L, f->p, f->sizep); - luaM_freearray(L, f->k, f->sizek); - luaM_freearray(L, f->lineinfo, f->sizelineinfo); - luaM_freearray(L, f->locvars, f->sizelocvars); - luaM_freearray(L, f->upvalues, f->sizeupvalues); - luaM_free(L, f); -} - - -/* -** Look for n-th local variable at line 'line' in function 'func'. -** Returns NULL if not found. -*/ -const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { - int i; - for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) { - if (pc < f->locvars[i].endpc) { /* is variable active? */ - local_number--; - if (local_number == 0) - return getstr(f->locvars[i].varname); - } - } - return NULL; /* not found */ -} - diff --git a/thirdparty/src/Lua/lfunc.h b/thirdparty/src/Lua/lfunc.h deleted file mode 100644 index 256d3cf90..000000000 --- a/thirdparty/src/Lua/lfunc.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -** $Id: lfunc.h,v 2.14 2014/06/19 18:27:20 roberto Exp $ -** Auxiliary functions to manipulate prototypes and closures -** See Copyright Notice in lua.h -*/ - -#ifndef lfunc_h -#define lfunc_h - - -#include "lobject.h" - - -#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ - cast(int, sizeof(TValue)*((n)-1))) - -#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ - cast(int, sizeof(TValue *)*((n)-1))) - - -/* test whether thread is in 'twups' list */ -#define isintwups(L) (L->twups != L) - - -/* -** Upvalues for Lua closures -*/ -struct UpVal { - TValue *v; /* points to stack or to its own value */ - lu_mem refcount; /* reference counter */ - union { - struct { /* (when open) */ - UpVal *next; /* linked list */ - int touched; /* mark to avoid cycles with dead threads */ - } open; - TValue value; /* the value (when closed) */ - } u; -}; - -#define upisopen(up) ((up)->v != &(up)->u.value) - - -LUAI_FUNC Proto *luaF_newproto (lua_State *L); -LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); -LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); -LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); -LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); -LUAI_FUNC void luaF_close (lua_State *L, StkId level); -LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); -LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, - int pc); - - -#endif diff --git a/thirdparty/src/Lua/lgc.cpp b/thirdparty/src/Lua/lgc.cpp deleted file mode 100644 index e8965e5fb..000000000 --- a/thirdparty/src/Lua/lgc.cpp +++ /dev/null @@ -1,1159 +0,0 @@ -/* -** $Id: lgc.c,v 2.201 2014/12/20 13:58:15 roberto Exp $ -** Garbage Collector -** See Copyright Notice in lua.h -*/ - -#define lgc_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <string.h> - -#include <Lua/lua.h> - -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lgc.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" - - -/* -** internal state for collector while inside the atomic phase. The -** collector should never be in this state while running regular code. -*/ -#define GCSinsideatomic (GCSpause + 1) - -/* -** cost of sweeping one element (the size of a small object divided -** by some adjust for the sweep speed) -*/ -#define GCSWEEPCOST ((sizeof(TString) + 4) / 4) - -/* maximum number of elements to sweep in each single step */ -#define GCSWEEPMAX (cast_int((GCSTEPSIZE / GCSWEEPCOST) / 4)) - -/* cost of calling one finalizer */ -#define GCFINALIZECOST GCSWEEPCOST - - -/* -** macro to adjust 'stepmul': 'stepmul' is actually used like -** 'stepmul / STEPMULADJ' (value chosen by tests) -*/ -#define STEPMULADJ 200 - - -/* -** macro to adjust 'pause': 'pause' is actually used like -** 'pause / PAUSEADJ' (value chosen by tests) -*/ -#define PAUSEADJ 100 - - -/* -** 'makewhite' erases all color bits then sets only the current white -** bit -*/ -#define maskcolors (~(bitmask(BLACKBIT) | WHITEBITS)) -#define makewhite(g,x) \ - (x->marked = cast_byte((x->marked & maskcolors) | luaC_white(g))) - -#define white2gray(x) resetbits(x->marked, WHITEBITS) -#define black2gray(x) resetbit(x->marked, BLACKBIT) - - -#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) - -#define checkdeadkey(n) lua_assert(!ttisdeadkey(gkey(n)) || ttisnil(gval(n))) - - -#define checkconsistency(obj) \ - lua_longassert(!iscollectable(obj) || righttt(obj)) - - -#define markvalue(g,o) { checkconsistency(o); \ - if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); } - -#define markobject(g,t) \ - { if ((t) && iswhite(t)) reallymarkobject(g, obj2gco(t)); } - -static void reallymarkobject (global_State *g, GCObject *o); - - -/* -** {====================================================== -** Generic functions -** ======================================================= -*/ - - -/* -** one after last element in a hash array -*/ -#define gnodelast(h) gnode(h, cast(size_t, sizenode(h))) - - -/* -** link collectable object 'o' into list pointed by 'p' -*/ -#define linkgclist(o,p) ((o)->gclist = (p), (p) = obj2gco(o)) - - -/* -** if key is not marked, mark its entry as dead (therefore removing it -** from the table) -*/ -static void removeentry (Node *n) { - lua_assert(ttisnil(gval(n))); - if (valiswhite(gkey(n))) - setdeadvalue(wgkey(n)); /* unused and unmarked key; remove it */ -} - - -/* -** tells whether a key or value can be cleared from a weak -** table. Non-collectable objects are never removed from weak -** tables. Strings behave as 'values', so are never removed too. for -** other objects: if really collected, cannot keep them; for objects -** being finalized, keep them in keys, but not in values -*/ -static int iscleared (global_State *g, const TValue *o) { - if (!iscollectable(o)) return 0; - else if (ttisstring(o)) { - markobject(g, tsvalue(o)); /* strings are 'values', so are never weak */ - return 0; - } - else return iswhite(gcvalue(o)); -} - - -/* -** barrier that moves collector forward, that is, mark the white object -** being pointed by a black object. (If in sweep phase, clear the black -** object to white [sweep it] to avoid other barrier calls for this -** same object.) -*/ -void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) { - global_State *g = G(L); - lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); - if (keepinvariant(g)) /* must keep invariant? */ - reallymarkobject(g, v); /* restore invariant */ - else { /* sweep phase */ - lua_assert(issweepphase(g)); - makewhite(g, o); /* mark main obj. as white to avoid other barriers */ - } -} - - -/* -** barrier that moves collector backward, that is, mark the black object -** pointing to a white object as gray again. -*/ -void luaC_barrierback_ (lua_State *L, Table *t) { - global_State *g = G(L); - lua_assert(isblack(t) && !isdead(g, t)); - black2gray(t); /* make table gray (again) */ - linkgclist(t, g->grayagain); -} - - -/* -** barrier for assignments to closed upvalues. Because upvalues are -** shared among closures, it is impossible to know the color of all -** closures pointing to it. So, we assume that the object being assigned -** must be marked. -*/ -void luaC_upvalbarrier_ (lua_State *L, UpVal *uv) { - global_State *g = G(L); - GCObject *o = gcvalue(uv->v); - lua_assert(!upisopen(uv)); /* ensured by macro luaC_upvalbarrier */ - if (keepinvariant(g)) - markobject(g, o); -} - - -void luaC_fix (lua_State *L, GCObject *o) { - global_State *g = G(L); - lua_assert(g->allgc == o); /* object must be 1st in 'allgc' list! */ - white2gray(o); /* they will be gray forever */ - g->allgc = o->next; /* remove object from 'allgc' list */ - o->next = g->fixedgc; /* link it to 'fixedgc' list */ - g->fixedgc = o; -} - - -/* -** create a new collectable object (with given type and size) and link -** it to 'allgc' list. -*/ -GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { - global_State *g = G(L); - GCObject *o = cast(GCObject *, luaM_newobject(L, novariant(tt), sz)); - o->marked = luaC_white(g); - o->tt = tt; - o->next = g->allgc; - g->allgc = o; - return o; -} - -/* }====================================================== */ - - - -/* -** {====================================================== -** Mark functions -** ======================================================= -*/ - - -/* -** mark an object. Userdata, strings, and closed upvalues are visited -** and turned black here. Other objects are marked gray and added -** to appropriate list to be visited (and turned black) later. (Open -** upvalues are already linked in 'headuv' list.) -*/ -static void reallymarkobject (global_State *g, GCObject *o) { - reentry: - white2gray(o); - switch (o->tt) { - case LUA_TSHRSTR: - case LUA_TLNGSTR: { - gray2black(o); - g->GCmemtrav += sizestring(gco2ts(o)); - break; - } - case LUA_TUSERDATA: { - TValue uvalue; - markobject(g, gco2u(o)->metatable); /* mark its metatable */ - gray2black(o); - g->GCmemtrav += sizeudata(gco2u(o)); - getuservalue(g->mainthread, gco2u(o), &uvalue); - if (valiswhite(&uvalue)) { /* markvalue(g, &uvalue); */ - o = gcvalue(&uvalue); - goto reentry; - } - break; - } - case LUA_TLCL: { - linkgclist(gco2lcl(o), g->gray); - break; - } - case LUA_TCCL: { - linkgclist(gco2ccl(o), g->gray); - break; - } - case LUA_TTABLE: { - linkgclist(gco2t(o), g->gray); - break; - } - case LUA_TTHREAD: { - linkgclist(gco2th(o), g->gray); - break; - } - case LUA_TPROTO: { - linkgclist(gco2p(o), g->gray); - break; - } - default: lua_assert(0); break; - } -} - - -/* -** mark metamethods for basic types -*/ -static void markmt (global_State *g) { - int i; - for (i=0; i < LUA_NUMTAGS; i++) - markobject(g, g->mt[i]); -} - - -/* -** mark all objects in list of being-finalized -*/ -static void markbeingfnz (global_State *g) { - GCObject *o; - for (o = g->tobefnz; o != NULL; o = o->next) - markobject(g, o); -} - - -/* -** Mark all values stored in marked open upvalues from non-marked threads. -** (Values from marked threads were already marked when traversing the -** thread.) Remove from the list threads that no longer have upvalues and -** not-marked threads. -*/ -static void remarkupvals (global_State *g) { - lua_State *thread; - lua_State **p = &g->twups; - while ((thread = *p) != NULL) { - lua_assert(!isblack(thread)); /* threads are never black */ - if (isgray(thread) && thread->openupval != NULL) - p = &thread->twups; /* keep marked thread with upvalues in the list */ - else { /* thread is not marked or without upvalues */ - UpVal *uv; - *p = thread->twups; /* remove thread from the list */ - thread->twups = thread; /* mark that it is out of list */ - for (uv = thread->openupval; uv != NULL; uv = uv->u.open.next) { - if (uv->u.open.touched) { - markvalue(g, uv->v); /* remark upvalue's value */ - uv->u.open.touched = 0; - } - } - } - } -} - - -/* -** mark root set and reset all gray lists, to start a new collection -*/ -static void restartcollection (global_State *g) { - g->gray = g->grayagain = NULL; - g->weak = g->allweak = g->ephemeron = NULL; - markobject(g, g->mainthread); - markvalue(g, &g->l_registry); - markmt(g); - markbeingfnz(g); /* mark any finalizing object left from previous cycle */ -} - -/* }====================================================== */ - - -/* -** {====================================================== -** Traverse functions -** ======================================================= -*/ - -/* -** Traverse a table with weak values and link it to proper list. During -** propagate phase, keep it in 'grayagain' list, to be revisited in the -** atomic phase. In the atomic phase, if table has any white value, -** put it in 'weak' list, to be cleared. -*/ -static void traverseweakvalue (global_State *g, Table *h) { - Node *n, *limit = gnodelast(h); - /* if there is array part, assume it may have white values (it is not - worth traversing it now just to check) */ - int hasclears = (h->sizearray > 0); - for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */ - checkdeadkey(n); - if (ttisnil(gval(n))) /* entry is empty? */ - removeentry(n); /* remove it */ - else { - lua_assert(!ttisnil(gkey(n))); - markvalue(g, gkey(n)); /* mark key */ - if (!hasclears && iscleared(g, gval(n))) /* is there a white value? */ - hasclears = 1; /* table will have to be cleared */ - } - } - if (g->gcstate == GCSpropagate) - linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */ - else if (hasclears) - linkgclist(h, g->weak); /* has to be cleared later */ -} - - -/* -** Traverse an ephemeron table and link it to proper list. Returns true -** iff any object was marked during this traversal (which implies that -** convergence has to continue). During propagation phase, keep table -** in 'grayagain' list, to be visited again in the atomic phase. In -** the atomic phase, if table has any white->white entry, it has to -** be revisited during ephemeron convergence (as that key may turn -** black). Otherwise, if it has any white key, table has to be cleared -** (in the atomic phase). -*/ -static int traverseephemeron (global_State *g, Table *h) { - int marked = 0; /* true if an object is marked in this traversal */ - int hasclears = 0; /* true if table has white keys */ - int hasww = 0; /* true if table has entry "white-key -> white-value" */ - Node *n, *limit = gnodelast(h); - unsigned int i; - /* traverse array part */ - for (i = 0; i < h->sizearray; i++) { - if (valiswhite(&h->array[i])) { - marked = 1; - reallymarkobject(g, gcvalue(&h->array[i])); - } - } - /* traverse hash part */ - for (n = gnode(h, 0); n < limit; n++) { - checkdeadkey(n); - if (ttisnil(gval(n))) /* entry is empty? */ - removeentry(n); /* remove it */ - else if (iscleared(g, gkey(n))) { /* key is not marked (yet)? */ - hasclears = 1; /* table must be cleared */ - if (valiswhite(gval(n))) /* value not marked yet? */ - hasww = 1; /* white-white entry */ - } - else if (valiswhite(gval(n))) { /* value not marked yet? */ - marked = 1; - reallymarkobject(g, gcvalue(gval(n))); /* mark it now */ - } - } - /* link table into proper list */ - if (g->gcstate == GCSpropagate) - linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */ - else if (hasww) /* table has white->white entries? */ - linkgclist(h, g->ephemeron); /* have to propagate again */ - else if (hasclears) /* table has white keys? */ - linkgclist(h, g->allweak); /* may have to clean white keys */ - return marked; -} - - -static void traversestrongtable (global_State *g, Table *h) { - Node *n, *limit = gnodelast(h); - unsigned int i; - for (i = 0; i < h->sizearray; i++) /* traverse array part */ - markvalue(g, &h->array[i]); - for (n = gnode(h, 0); n < limit; n++) { /* traverse hash part */ - checkdeadkey(n); - if (ttisnil(gval(n))) /* entry is empty? */ - removeentry(n); /* remove it */ - else { - lua_assert(!ttisnil(gkey(n))); - markvalue(g, gkey(n)); /* mark key */ - markvalue(g, gval(n)); /* mark value */ - } - } -} - - -static lu_mem traversetable (global_State *g, Table *h) { - const char *weakkey, *weakvalue; - const TValue *mode = gfasttm(g, h->metatable, TM_MODE); - markobject(g, h->metatable); - if (mode && ttisstring(mode) && /* is there a weak mode? */ - ((weakkey = strchr(svalue(mode), 'k')), - (weakvalue = strchr(svalue(mode), 'v')), - (weakkey || weakvalue))) { /* is really weak? */ - black2gray(h); /* keep table gray */ - if (!weakkey) /* strong keys? */ - traverseweakvalue(g, h); - else if (!weakvalue) /* strong values? */ - traverseephemeron(g, h); - else /* all weak */ - linkgclist(h, g->allweak); /* nothing to traverse now */ - } - else /* not weak */ - traversestrongtable(g, h); - return sizeof(Table) + sizeof(TValue) * h->sizearray + - sizeof(Node) * cast(size_t, sizenode(h)); -} - - -static int traverseproto (global_State *g, Proto *f) { - int i; - if (f->cache && iswhite(f->cache)) - f->cache = NULL; /* allow cache to be collected */ - markobject(g, f->source); - for (i = 0; i < f->sizek; i++) /* mark literals */ - markvalue(g, &f->k[i]); - for (i = 0; i < f->sizeupvalues; i++) /* mark upvalue names */ - markobject(g, f->upvalues[i].name); - for (i = 0; i < f->sizep; i++) /* mark nested protos */ - markobject(g, f->p[i]); - for (i = 0; i < f->sizelocvars; i++) /* mark local-variable names */ - markobject(g, f->locvars[i].varname); - return sizeof(Proto) + sizeof(Instruction) * f->sizecode + - sizeof(Proto *) * f->sizep + - sizeof(TValue) * f->sizek + - sizeof(int) * f->sizelineinfo + - sizeof(LocVar) * f->sizelocvars + - sizeof(Upvaldesc) * f->sizeupvalues; -} - - -static lu_mem traverseCclosure (global_State *g, CClosure *cl) { - int i; - for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */ - markvalue(g, &cl->upvalue[i]); - return sizeCclosure(cl->nupvalues); -} - -/* -** open upvalues point to values in a thread, so those values should -** be marked when the thread is traversed except in the atomic phase -** (because then the value cannot be changed by the thread and the -** thread may not be traversed again) -*/ -static lu_mem traverseLclosure (global_State *g, LClosure *cl) { - int i; - markobject(g, cl->p); /* mark its prototype */ - for (i = 0; i < cl->nupvalues; i++) { /* mark its upvalues */ - UpVal *uv = cl->upvals[i]; - if (uv != NULL) { - if (upisopen(uv) && g->gcstate != GCSinsideatomic) - uv->u.open.touched = 1; /* can be marked in 'remarkupvals' */ - else - markvalue(g, uv->v); - } - } - return sizeLclosure(cl->nupvalues); -} - - -static lu_mem traversethread (global_State *g, lua_State *th) { - StkId o = th->stack; - if (o == NULL) - return 1; /* stack not completely built yet */ - lua_assert(g->gcstate == GCSinsideatomic || - th->openupval == NULL || isintwups(th)); - for (; o < th->top; o++) /* mark live elements in the stack */ - markvalue(g, o); - if (g->gcstate == GCSinsideatomic) { /* final traversal? */ - StkId lim = th->stack + th->stacksize; /* real end of stack */ - for (; o < lim; o++) /* clear not-marked stack slice */ - setnilvalue(o); - /* 'remarkupvals' may have removed thread from 'twups' list */ - if (!isintwups(th) && th->openupval != NULL) { - th->twups = g->twups; /* link it back to the list */ - g->twups = th; - } - } - else if (g->gckind != KGC_EMERGENCY) - luaD_shrinkstack(th); /* do not change stack in emergency cycle */ - return (sizeof(lua_State) + sizeof(TValue) * th->stacksize); -} - - -/* -** traverse one gray object, turning it to black (except for threads, -** which are always gray). -*/ -static void propagatemark (global_State *g) { - lu_mem size; - GCObject *o = g->gray; - lua_assert(isgray(o)); - gray2black(o); - switch (o->tt) { - case LUA_TTABLE: { - Table *h = gco2t(o); - g->gray = h->gclist; /* remove from 'gray' list */ - size = traversetable(g, h); - break; - } - case LUA_TLCL: { - LClosure *cl = gco2lcl(o); - g->gray = cl->gclist; /* remove from 'gray' list */ - size = traverseLclosure(g, cl); - break; - } - case LUA_TCCL: { - CClosure *cl = gco2ccl(o); - g->gray = cl->gclist; /* remove from 'gray' list */ - size = traverseCclosure(g, cl); - break; - } - case LUA_TTHREAD: { - lua_State *th = gco2th(o); - g->gray = th->gclist; /* remove from 'gray' list */ - linkgclist(th, g->grayagain); /* insert into 'grayagain' list */ - black2gray(o); - size = traversethread(g, th); - break; - } - case LUA_TPROTO: { - Proto *p = gco2p(o); - g->gray = p->gclist; /* remove from 'gray' list */ - size = traverseproto(g, p); - break; - } - default: lua_assert(0); return; - } - g->GCmemtrav += size; -} - - -static void propagateall (global_State *g) { - while (g->gray) propagatemark(g); -} - - -static void convergeephemerons (global_State *g) { - int changed; - do { - GCObject *w; - GCObject *next = g->ephemeron; /* get ephemeron list */ - g->ephemeron = NULL; /* tables may return to this list when traversed */ - changed = 0; - while ((w = next) != NULL) { - next = gco2t(w)->gclist; - if (traverseephemeron(g, gco2t(w))) { /* traverse marked some value? */ - propagateall(g); /* propagate changes */ - changed = 1; /* will have to revisit all ephemeron tables */ - } - } - } while (changed); -} - -/* }====================================================== */ - - -/* -** {====================================================== -** Sweep Functions -** ======================================================= -*/ - - -/* -** clear entries with unmarked keys from all weaktables in list 'l' up -** to element 'f' -*/ -static void clearkeys (global_State *g, GCObject *l, GCObject *f) { - for (; l != f; l = gco2t(l)->gclist) { - Table *h = gco2t(l); - Node *n, *limit = gnodelast(h); - for (n = gnode(h, 0); n < limit; n++) { - if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) { - setnilvalue(gval(n)); /* remove value ... */ - removeentry(n); /* and remove entry from table */ - } - } - } -} - - -/* -** clear entries with unmarked values from all weaktables in list 'l' up -** to element 'f' -*/ -static void clearvalues (global_State *g, GCObject *l, GCObject *f) { - for (; l != f; l = gco2t(l)->gclist) { - Table *h = gco2t(l); - Node *n, *limit = gnodelast(h); - unsigned int i; - for (i = 0; i < h->sizearray; i++) { - TValue *o = &h->array[i]; - if (iscleared(g, o)) /* value was collected? */ - setnilvalue(o); /* remove value */ - } - for (n = gnode(h, 0); n < limit; n++) { - if (!ttisnil(gval(n)) && iscleared(g, gval(n))) { - setnilvalue(gval(n)); /* remove value ... */ - removeentry(n); /* and remove entry from table */ - } - } - } -} - - -void luaC_upvdeccount (lua_State *L, UpVal *uv) { - lua_assert(uv->refcount > 0); - uv->refcount--; - if (uv->refcount == 0 && !upisopen(uv)) - luaM_free(L, uv); -} - - -static void freeLclosure (lua_State *L, LClosure *cl) { - int i; - for (i = 0; i < cl->nupvalues; i++) { - UpVal *uv = cl->upvals[i]; - if (uv) - luaC_upvdeccount(L, uv); - } - luaM_freemem(L, cl, sizeLclosure(cl->nupvalues)); -} - - -static void freeobj (lua_State *L, GCObject *o) { - switch (o->tt) { - case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; - case LUA_TLCL: { - freeLclosure(L, gco2lcl(o)); - break; - } - case LUA_TCCL: { - luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues)); - break; - } - case LUA_TTABLE: luaH_free(L, gco2t(o)); break; - case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break; - case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break; - case LUA_TSHRSTR: - luaS_remove(L, gco2ts(o)); /* remove it from hash table */ - /* go through */ - case LUA_TLNGSTR: { - luaM_freemem(L, o, sizestring(gco2ts(o))); - break; - } - default: lua_assert(0); - } -} - - -#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) -static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count); - - -/* -** sweep at most 'count' elements from a list of GCObjects erasing dead -** objects, where a dead object is one marked with the old (non current) -** white; change all non-dead objects back to white, preparing for next -** collection cycle. Return where to continue the traversal or NULL if -** list is finished. -*/ -static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { - global_State *g = G(L); - int ow = otherwhite(g); - int white = luaC_white(g); /* current white */ - while (*p != NULL && count-- > 0) { - GCObject *curr = *p; - int marked = curr->marked; - if (isdeadm(ow, marked)) { /* is 'curr' dead? */ - *p = curr->next; /* remove 'curr' from list */ - freeobj(L, curr); /* erase 'curr' */ - } - else { /* change mark to 'white' */ - curr->marked = cast_byte((marked & maskcolors) | white); - p = &curr->next; /* go to next element */ - } - } - return (*p == NULL) ? NULL : p; -} - - -/* -** sweep a list until a live object (or end of list) -*/ -static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) { - GCObject **old = p; - int i = 0; - do { - i++; - p = sweeplist(L, p, 1); - } while (p == old); - if (n) *n += i; - return p; -} - -/* }====================================================== */ - - -/* -** {====================================================== -** Finalization -** ======================================================= -*/ - -/* -** If possible, free concatenation buffer and shrink string table -*/ -static void checkSizes (lua_State *L, global_State *g) { - if (g->gckind != KGC_EMERGENCY) { - l_mem olddebt = g->GCdebt; - luaZ_freebuffer(L, &g->buff); /* free concatenation buffer */ - if (g->strt.nuse < g->strt.size / 4) /* string table too big? */ - luaS_resize(L, g->strt.size / 2); /* shrink it a little */ - g->GCestimate += g->GCdebt - olddebt; /* update estimate */ - } -} - - -static GCObject *udata2finalize (global_State *g) { - GCObject *o = g->tobefnz; /* get first element */ - lua_assert(tofinalize(o)); - g->tobefnz = o->next; /* remove it from 'tobefnz' list */ - o->next = g->allgc; /* return it to 'allgc' list */ - g->allgc = o; - resetbit(o->marked, FINALIZEDBIT); /* object is "normal" again */ - if (issweepphase(g)) - makewhite(g, o); /* "sweep" object */ - return o; -} - - -static void dothecall (lua_State *L, void *ud) { - UNUSED(ud); - luaD_call(L, L->top - 2, 0, 0); -} - - -static void GCTM (lua_State *L, int propagateerrors) { - global_State *g = G(L); - const TValue *tm; - TValue v; - setgcovalue(L, &v, udata2finalize(g)); - tm = luaT_gettmbyobj(L, &v, TM_GC); - if (tm != NULL && ttisfunction(tm)) { /* is there a finalizer? */ - int status; - lu_byte oldah = L->allowhook; - int running = g->gcrunning; - L->allowhook = 0; /* stop debug hooks during GC metamethod */ - g->gcrunning = 0; /* avoid GC steps */ - setobj2s(L, L->top, tm); /* push finalizer... */ - setobj2s(L, L->top + 1, &v); /* ... and its argument */ - L->top += 2; /* and (next line) call the finalizer */ - status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0); - L->allowhook = oldah; /* restore hooks */ - g->gcrunning = running; /* restore state */ - if (status != LUA_OK && propagateerrors) { /* error while running __gc? */ - if (status == LUA_ERRRUN) { /* is there an error object? */ - const char *msg = (ttisstring(L->top - 1)) - ? svalue(L->top - 1) - : "no message"; - luaO_pushfstring(L, "error in __gc metamethod (%s)", msg); - status = LUA_ERRGCMM; /* error in __gc metamethod */ - } - luaD_throw(L, status); /* re-throw error */ - } - } -} - - -/* -** call a few (up to 'g->gcfinnum') finalizers -*/ -static int runafewfinalizers (lua_State *L) { - global_State *g = G(L); - unsigned int i; - lua_assert(!g->tobefnz || g->gcfinnum > 0); - for (i = 0; g->tobefnz && i < g->gcfinnum; i++) - GCTM(L, 1); /* call one finalizer */ - g->gcfinnum = (!g->tobefnz) ? 0 /* nothing more to finalize? */ - : g->gcfinnum * 2; /* else call a few more next time */ - return i; -} - - -/* -** call all pending finalizers -*/ -static void callallpendingfinalizers (lua_State *L, int propagateerrors) { - global_State *g = G(L); - while (g->tobefnz) - GCTM(L, propagateerrors); -} - - -/* -** find last 'next' field in list 'p' list (to add elements in its end) -*/ -static GCObject **findlast (GCObject **p) { - while (*p != NULL) - p = &(*p)->next; - return p; -} - - -/* -** move all unreachable objects (or 'all' objects) that need -** finalization from list 'finobj' to list 'tobefnz' (to be finalized) -*/ -static void separatetobefnz (global_State *g, int all) { - GCObject *curr; - GCObject **p = &g->finobj; - GCObject **lastnext = findlast(&g->tobefnz); - while ((curr = *p) != NULL) { /* traverse all finalizable objects */ - lua_assert(tofinalize(curr)); - if (!(iswhite(curr) || all)) /* not being collected? */ - p = &curr->next; /* don't bother with it */ - else { - *p = curr->next; /* remove 'curr' from 'finobj' list */ - curr->next = *lastnext; /* link at the end of 'tobefnz' list */ - *lastnext = curr; - lastnext = &curr->next; - } - } -} - - -/* -** if object 'o' has a finalizer, remove it from 'allgc' list (must -** search the list to find it) and link it in 'finobj' list. -*/ -void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { - global_State *g = G(L); - if (tofinalize(o) || /* obj. is already marked... */ - gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */ - return; /* nothing to be done */ - else { /* move 'o' to 'finobj' list */ - GCObject **p; - if (issweepphase(g)) { - makewhite(g, o); /* "sweep" object 'o' */ - if (g->sweepgc == &o->next) /* should not remove 'sweepgc' object */ - g->sweepgc = sweeptolive(L, g->sweepgc, NULL); /* change 'sweepgc' */ - } - /* search for pointer pointing to 'o' */ - for (p = &g->allgc; *p != o; p = &(*p)->next) { /* empty */ } - *p = o->next; /* remove 'o' from 'allgc' list */ - o->next = g->finobj; /* link it in 'finobj' list */ - g->finobj = o; - l_setbit(o->marked, FINALIZEDBIT); /* mark it as such */ - } -} - -/* }====================================================== */ - - - -/* -** {====================================================== -** GC control -** ======================================================= -*/ - - -/* -** Set a reasonable "time" to wait before starting a new GC cycle; cycle -** will start when memory use hits threshold. (Division by 'estimate' -** should be OK: it cannot be zero (because Lua cannot even start with -** less than PAUSEADJ bytes). -*/ -static void setpause (global_State *g) { - l_mem threshold, debt; - l_mem estimate = g->GCestimate / PAUSEADJ; /* adjust 'estimate' */ - lua_assert(estimate > 0); - threshold = (g->gcpause < MAX_LMEM / estimate) /* overflow? */ - ? estimate * g->gcpause /* no overflow */ - : MAX_LMEM; /* overflow; truncate to maximum */ - debt = gettotalbytes(g) - threshold; - luaE_setdebt(g, debt); -} - - -/* -** Enter first sweep phase. -** The call to 'sweeptolive' makes pointer point to an object inside -** the list (instead of to the header), so that the real sweep do not -** need to skip objects created between "now" and the start of the real -** sweep. -** Returns how many objects it swept. -*/ -static int entersweep (lua_State *L) { - global_State *g = G(L); - int n = 0; - g->gcstate = GCSswpallgc; - lua_assert(g->sweepgc == NULL); - g->sweepgc = sweeptolive(L, &g->allgc, &n); - return n; -} - - -void luaC_freeallobjects (lua_State *L) { - global_State *g = G(L); - separatetobefnz(g, 1); /* separate all objects with finalizers */ - lua_assert(g->finobj == NULL); - callallpendingfinalizers(L, 0); - lua_assert(g->tobefnz == NULL); - g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */ - g->gckind = KGC_NORMAL; - sweepwholelist(L, &g->finobj); - sweepwholelist(L, &g->allgc); - sweepwholelist(L, &g->fixedgc); /* collect fixed objects */ - lua_assert(g->strt.nuse == 0); -} - - -static l_mem atomic (lua_State *L) { - global_State *g = G(L); - l_mem work; - GCObject *origweak, *origall; - GCObject *grayagain = g->grayagain; /* save original list */ - lua_assert(g->ephemeron == NULL && g->weak == NULL); - lua_assert(!iswhite(g->mainthread)); - g->gcstate = GCSinsideatomic; - g->GCmemtrav = 0; /* start counting work */ - markobject(g, L); /* mark running thread */ - /* registry and global metatables may be changed by API */ - markvalue(g, &g->l_registry); - markmt(g); /* mark global metatables */ - /* remark occasional upvalues of (maybe) dead threads */ - remarkupvals(g); - propagateall(g); /* propagate changes */ - work = g->GCmemtrav; /* stop counting (do not recount 'grayagain') */ - g->gray = grayagain; - propagateall(g); /* traverse 'grayagain' list */ - g->GCmemtrav = 0; /* restart counting */ - convergeephemerons(g); - /* at this point, all strongly accessible objects are marked. */ - /* Clear values from weak tables, before checking finalizers */ - clearvalues(g, g->weak, NULL); - clearvalues(g, g->allweak, NULL); - origweak = g->weak; origall = g->allweak; - work += g->GCmemtrav; /* stop counting (objects being finalized) */ - separatetobefnz(g, 0); /* separate objects to be finalized */ - g->gcfinnum = 1; /* there may be objects to be finalized */ - markbeingfnz(g); /* mark objects that will be finalized */ - propagateall(g); /* remark, to propagate 'resurrection' */ - g->GCmemtrav = 0; /* restart counting */ - convergeephemerons(g); - /* at this point, all resurrected objects are marked. */ - /* remove dead objects from weak tables */ - clearkeys(g, g->ephemeron, NULL); /* clear keys from all ephemeron tables */ - clearkeys(g, g->allweak, NULL); /* clear keys from all 'allweak' tables */ - /* clear values from resurrected weak tables */ - clearvalues(g, g->weak, origweak); - clearvalues(g, g->allweak, origall); - g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ - work += g->GCmemtrav; /* complete counting */ - return work; /* estimate of memory marked by 'atomic' */ -} - - -static lu_mem sweepstep (lua_State *L, global_State *g, - int nextstate, GCObject **nextlist) { - if (g->sweepgc) { - l_mem olddebt = g->GCdebt; - g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); - g->GCestimate += g->GCdebt - olddebt; /* update estimate */ - if (g->sweepgc) /* is there still something to sweep? */ - return (GCSWEEPMAX * GCSWEEPCOST); - } - /* else enter next state */ - g->gcstate = nextstate; - g->sweepgc = nextlist; - return 0; -} - - -static lu_mem singlestep (lua_State *L) { - global_State *g = G(L); - switch (g->gcstate) { - case GCSpause: { - g->GCmemtrav = g->strt.size * sizeof(GCObject*); - restartcollection(g); - g->gcstate = GCSpropagate; - return g->GCmemtrav; - } - case GCSpropagate: { - g->GCmemtrav = 0; - lua_assert(g->gray); - propagatemark(g); - if (g->gray == NULL) /* no more gray objects? */ - g->gcstate = GCSatomic; /* finish propagate phase */ - return g->GCmemtrav; /* memory traversed in this step */ - } - case GCSatomic: { - lu_mem work; - int sw; - propagateall(g); /* make sure gray list is empty */ - work = atomic(L); /* work is what was traversed by 'atomic' */ - sw = entersweep(L); - g->GCestimate = gettotalbytes(g); /* first estimate */; - return work + sw * GCSWEEPCOST; - } - case GCSswpallgc: { /* sweep "regular" objects */ - return sweepstep(L, g, GCSswpfinobj, &g->finobj); - } - case GCSswpfinobj: { /* sweep objects with finalizers */ - return sweepstep(L, g, GCSswptobefnz, &g->tobefnz); - } - case GCSswptobefnz: { /* sweep objects to be finalized */ - return sweepstep(L, g, GCSswpend, NULL); - } - case GCSswpend: { /* finish sweeps */ - makewhite(g, g->mainthread); /* sweep main thread */ - checkSizes(L, g); - g->gcstate = GCScallfin; - return 0; - } - case GCScallfin: { /* call remaining finalizers */ - if (g->tobefnz && g->gckind != KGC_EMERGENCY) { - int n = runafewfinalizers(L); - return (n * GCFINALIZECOST); - } - else { /* emergency mode or no more finalizers */ - g->gcstate = GCSpause; /* finish collection */ - return 0; - } - } - default: lua_assert(0); return 0; - } -} - - -/* -** advances the garbage collector until it reaches a state allowed -** by 'statemask' -*/ -void luaC_runtilstate (lua_State *L, int statesmask) { - global_State *g = G(L); - while (!testbit(statesmask, g->gcstate)) - singlestep(L); -} - - -/* -** get GC debt and convert it from Kb to 'work units' (avoid zero debt -** and overflows) -*/ -static l_mem getdebt (global_State *g) { - l_mem debt = g->GCdebt; - int stepmul = g->gcstepmul; - debt = (debt / STEPMULADJ) + 1; - debt = (debt < MAX_LMEM / stepmul) ? debt * stepmul : MAX_LMEM; - return debt; -} - -/* -** performs a basic GC step when collector is running -*/ -void luaC_step (lua_State *L) { - global_State *g = G(L); - l_mem debt = getdebt(g); /* GC deficit (be paid now) */ - if (!g->gcrunning) { /* not running? */ - luaE_setdebt(g, -GCSTEPSIZE * 10); /* avoid being called too often */ - return; - } - do { /* repeat until pause or enough "credit" (negative debt) */ - lu_mem work = singlestep(L); /* perform one single step */ - debt -= work; - } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause); - if (g->gcstate == GCSpause) - setpause(g); /* pause until next cycle */ - else { - debt = (debt / g->gcstepmul) * STEPMULADJ; /* convert 'work units' to Kb */ - luaE_setdebt(g, debt); - runafewfinalizers(L); - } -} - - -/* -** Performs a full GC cycle; if 'isemergency', set a flag to avoid -** some operations which could change the interpreter state in some -** unexpected ways (running finalizers and shrinking some structures). -** Before running the collection, check 'keepinvariant'; if it is true, -** there may be some objects marked as black, so the collector has -** to sweep all objects to turn them back to white (as white has not -** changed, nothing will be collected). -*/ -void luaC_fullgc (lua_State *L, int isemergency) { - global_State *g = G(L); - lua_assert(g->gckind == KGC_NORMAL); - if (isemergency) g->gckind = KGC_EMERGENCY; /* set flag */ - if (keepinvariant(g)) { /* black objects? */ - entersweep(L); /* sweep everything to turn them back to white */ - } - /* finish any pending sweep phase to start a new cycle */ - luaC_runtilstate(L, bitmask(GCSpause)); - luaC_runtilstate(L, ~bitmask(GCSpause)); /* start new collection */ - luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */ - /* estimate must be correct after a full GC cycle */ - lua_assert(g->GCestimate == gettotalbytes(g)); - luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ - g->gckind = KGC_NORMAL; - setpause(g); -} - -/* }====================================================== */ - - diff --git a/thirdparty/src/Lua/lgc.h b/thirdparty/src/Lua/lgc.h deleted file mode 100644 index 0eedf8420..000000000 --- a/thirdparty/src/Lua/lgc.h +++ /dev/null @@ -1,138 +0,0 @@ -/* -** $Id: lgc.h,v 2.86 2014/10/25 11:50:46 roberto Exp $ -** Garbage Collector -** See Copyright Notice in lua.h -*/ - -#ifndef lgc_h -#define lgc_h - - -#include "lobject.h" -#include "lstate.h" - -/* -** Collectable objects may have one of three colors: white, which -** means the object is not marked; gray, which means the -** object is marked, but its references may be not marked; and -** black, which means that the object and all its references are marked. -** The main invariant of the garbage collector, while marking objects, -** is that a black object can never point to a white one. Moreover, -** any gray object must be in a "gray list" (gray, grayagain, weak, -** allweak, ephemeron) so that it can be visited again before finishing -** the collection cycle. These lists have no meaning when the invariant -** is not being enforced (e.g., sweep phase). -*/ - - - -/* how much to allocate before next GC step */ -#if !defined(GCSTEPSIZE) -/* ~100 small strings */ -#define GCSTEPSIZE (cast_int(100 * sizeof(TString))) -#endif - - -/* -** Possible states of the Garbage Collector -*/ -#define GCSpropagate 0 -#define GCSatomic 1 -#define GCSswpallgc 2 -#define GCSswpfinobj 3 -#define GCSswptobefnz 4 -#define GCSswpend 5 -#define GCScallfin 6 -#define GCSpause 7 - - -#define issweepphase(g) \ - (GCSswpallgc <= (g)->gcstate && (g)->gcstate <= GCSswpend) - - -/* -** macro to tell when main invariant (white objects cannot point to black -** ones) must be kept. During a collection, the sweep -** phase may break the invariant, as objects turned white may point to -** still-black objects. The invariant is restored when sweep ends and -** all objects are white again. -*/ - -#define keepinvariant(g) ((g)->gcstate <= GCSatomic) - - -/* -** some useful bit tricks -*/ -#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) -#define setbits(x,m) ((x) |= (m)) -#define testbits(x,m) ((x) & (m)) -#define bitmask(b) (1<<(b)) -#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) -#define l_setbit(x,b) setbits(x, bitmask(b)) -#define resetbit(x,b) resetbits(x, bitmask(b)) -#define testbit(x,b) testbits(x, bitmask(b)) - - -/* Layout for bit use in 'marked' field: */ -#define WHITE0BIT 0 /* object is white (type 0) */ -#define WHITE1BIT 1 /* object is white (type 1) */ -#define BLACKBIT 2 /* object is black */ -#define FINALIZEDBIT 3 /* object has been marked for finalization */ -/* bit 7 is currently used by tests (luaL_checkmemory) */ - -#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) - - -#define iswhite(x) testbits((x)->marked, WHITEBITS) -#define isblack(x) testbit((x)->marked, BLACKBIT) -#define isgray(x) /* neither white nor black */ \ - (!testbits((x)->marked, WHITEBITS | bitmask(BLACKBIT))) - -#define tofinalize(x) testbit((x)->marked, FINALIZEDBIT) - -#define otherwhite(g) ((g)->currentwhite ^ WHITEBITS) -#define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow))) -#define isdead(g,v) isdeadm(otherwhite(g), (v)->marked) - -#define changewhite(x) ((x)->marked ^= WHITEBITS) -#define gray2black(x) l_setbit((x)->marked, BLACKBIT) - -#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) - - -#define luaC_condGC(L,c) \ - {if (G(L)->GCdebt > 0) {c;}; condchangemem(L);} -#define luaC_checkGC(L) luaC_condGC(L, luaC_step(L);) - - -#define luaC_barrier(L,p,v) { \ - if (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) \ - luaC_barrier_(L,obj2gco(p),gcvalue(v)); } - -#define luaC_barrierback(L,p,v) { \ - if (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) \ - luaC_barrierback_(L,p); } - -#define luaC_objbarrier(L,p,o) { \ - if (isblack(p) && iswhite(o)) \ - luaC_barrier_(L,obj2gco(p),obj2gco(o)); } - -#define luaC_upvalbarrier(L,uv) \ - { if (iscollectable((uv)->v) && !upisopen(uv)) \ - luaC_upvalbarrier_(L,uv); } - -LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o); -LUAI_FUNC void luaC_freeallobjects (lua_State *L); -LUAI_FUNC void luaC_step (lua_State *L); -LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask); -LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); -LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz); -LUAI_FUNC void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v); -LUAI_FUNC void luaC_barrierback_ (lua_State *L, Table *o); -LUAI_FUNC void luaC_upvalbarrier_ (lua_State *L, UpVal *uv); -LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt); -LUAI_FUNC void luaC_upvdeccount (lua_State *L, UpVal *uv); - - -#endif diff --git a/thirdparty/src/Lua/linit.cpp b/thirdparty/src/Lua/linit.cpp deleted file mode 100644 index f51ad1426..000000000 --- a/thirdparty/src/Lua/linit.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* -** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $ -** Initialization of libraries for lua.c and other clients -** See Copyright Notice in lua.h -*/ - - -#define linit_c -#define LUA_LIB - -/* -** If you embed Lua in your program and need to open the standard -** libraries, call luaL_openlibs in your program. If you need a -** different set of libraries, copy this file to your project and edit -** it to suit your needs. -** -** You can also *preload* libraries, so that a later 'require' can -** open the library, which is already linked to the application. -** For that, do the following code: -** -** luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); -** lua_pushcfunction(L, luaopen_modname); -** lua_setfield(L, -2, modname); -** lua_pop(L, 1); // remove _PRELOAD table -*/ - -#include "lprefix.h" - - -#include <stddef.h> - -#include <Lua/lua.h> - -#include <Lua/lualib.h> -#include <Lua/lauxlib.h> - - -/* -** these libs are loaded by lua.c and are readily available to any Lua -** program -*/ -static const luaL_Reg loadedlibs[] = { - {"_G", luaopen_base}, - {LUA_LOADLIBNAME, luaopen_package}, - {LUA_COLIBNAME, luaopen_coroutine}, - {LUA_TABLIBNAME, luaopen_table}, - {LUA_IOLIBNAME, luaopen_io}, - {LUA_OSLIBNAME, luaopen_os}, - {LUA_STRLIBNAME, luaopen_string}, - {LUA_MATHLIBNAME, luaopen_math}, - {LUA_UTF8LIBNAME, luaopen_utf8}, - {LUA_DBLIBNAME, luaopen_debug}, -#if defined(LUA_COMPAT_BITLIB) - {LUA_BITLIBNAME, luaopen_bit32}, -#endif - {NULL, NULL} -}; - - -LUALIB_API void luaL_openlibs (lua_State *L) { - const luaL_Reg *lib; - /* "require" functions from 'loadedlibs' and set results to global table */ - for (lib = loadedlibs; lib->func; lib++) { - luaL_requiref(L, lib->name, lib->func, 1); - lua_pop(L, 1); /* remove lib */ - } -} - diff --git a/thirdparty/src/Lua/liolib.cpp b/thirdparty/src/Lua/liolib.cpp deleted file mode 100644 index 65fc418d5..000000000 --- a/thirdparty/src/Lua/liolib.cpp +++ /dev/null @@ -1,757 +0,0 @@ -/* -** $Id: liolib.c,v 2.142 2015/01/02 12:50:28 roberto Exp $ -** Standard I/O (and system) library -** See Copyright Notice in lua.h -*/ - -#define liolib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include <ctype.h> -#include <errno.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <Lua/lua.h> - -#include <Lua/lauxlib.h> -#include <Lua/lualib.h> - - -#if !defined(l_checkmode) - -/* -** Check whether 'mode' matches '[rwa]%+?b?'. -** Change this macro to accept other modes for 'fopen' besides -** the standard ones. -*/ -#define l_checkmode(mode) \ - (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && \ - (*mode != '+' || ++mode) && /* skip if char is '+' */ \ - (*mode != 'b' || ++mode) && /* skip if char is 'b' */ \ - (*mode == '\0')) - -#endif - -/* -** {====================================================== -** l_popen spawns a new process connected to the current -** one through the file streams. -** ======================================================= -*/ - -#if !defined(l_popen) /* { */ - -#if defined(LUA_USE_POSIX) /* { */ - -#define l_popen(L,c,m) (fflush(NULL), popen(c,m)) -#define l_pclose(L,file) (pclose(file)) - -#elif defined(LUA_USE_WINDOWS) /* }{ */ - -#define l_popen(L,c,m) (_popen(c,m)) -#define l_pclose(L,file) (_pclose(file)) - -#else /* }{ */ - -/* ISO C definitions */ -#define l_popen(L,c,m) \ - ((void)((void)c, m), \ - luaL_error(L, "'popen' not supported"), \ - (FILE*)0) -#define l_pclose(L,file) ((void)L, (void)file, -1) - -#endif /* } */ - -#endif /* } */ - -/* }====================================================== */ - - -#if !defined(l_getc) /* { */ - -#if defined(LUA_USE_POSIX) -#define l_getc(f) getc_unlocked(f) -#define l_lockfile(f) flockfile(f) -#define l_unlockfile(f) funlockfile(f) -#else -#define l_getc(f) getc(f) -#define l_lockfile(f) ((void)0) -#define l_unlockfile(f) ((void)0) -#endif - -#endif /* } */ - - -/* -** {====================================================== -** l_fseek: configuration for longer offsets -** ======================================================= -*/ - -#if !defined(l_fseek) /* { */ - -#if defined(LUA_USE_POSIX) /* { */ - -#include <sys/types.h> - -#define l_fseek(f,o,w) fseeko(f,o,w) -#define l_ftell(f) ftello(f) -#define l_seeknum off_t - -#elif defined(LUA_USE_WINDOWS) && !defined(_CRTIMP_TYPEINFO) \ - && defined(_MSC_VER) && (_MSC_VER >= 1400) /* }{ */ - -/* Windows (but not DDK) and Visual C++ 2005 or higher */ -#define l_fseek(f,o,w) _fseeki64(f,o,w) -#define l_ftell(f) _ftelli64(f) -#define l_seeknum __int64 - -#else /* }{ */ - -/* ISO C definitions */ -#define l_fseek(f,o,w) fseek(f,o,w) -#define l_ftell(f) ftell(f) -#define l_seeknum long - -#endif /* } */ - -#endif /* } */ - -/* }====================================================== */ - - -#define IO_PREFIX "_IO_" -#define IOPREF_LEN (sizeof(IO_PREFIX)/sizeof(char) - 1) -#define IO_INPUT (IO_PREFIX "input") -#define IO_OUTPUT (IO_PREFIX "output") - - -typedef luaL_Stream LStream; - - -#define tolstream(L) ((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE)) - -#define isclosed(p) ((p)->closef == NULL) - - -static int io_type (lua_State *L) { - LStream *p; - luaL_checkany(L, 1); - p = (LStream *)luaL_testudata(L, 1, LUA_FILEHANDLE); - if (p == NULL) - lua_pushnil(L); /* not a file */ - else if (isclosed(p)) - lua_pushliteral(L, "closed file"); - else - lua_pushliteral(L, "file"); - return 1; -} - - -static int f_tostring (lua_State *L) { - LStream *p = tolstream(L); - if (isclosed(p)) - lua_pushliteral(L, "file (closed)"); - else - lua_pushfstring(L, "file (%p)", p->f); - return 1; -} - - -static FILE *tofile (lua_State *L) { - LStream *p = tolstream(L); - if (isclosed(p)) - luaL_error(L, "attempt to use a closed file"); - lua_assert(p->f); - return p->f; -} - - -/* -** When creating file handles, always creates a 'closed' file handle -** before opening the actual file; so, if there is a memory error, the -** file is not left opened. -*/ -static LStream *newprefile (lua_State *L) { - LStream *p = (LStream *)lua_newuserdata(L, sizeof(LStream)); - p->closef = NULL; /* mark file handle as 'closed' */ - luaL_setmetatable(L, LUA_FILEHANDLE); - return p; -} - - -/* -** Calls the 'close' function from a file handle. The 'volatile' avoids -** a bug in some versions of the Clang compiler (e.g., clang 3.0 for -** 32 bits). -*/ -static int aux_close (lua_State *L) { - LStream *p = tolstream(L); - volatile lua_CFunction cf = p->closef; - p->closef = NULL; /* mark stream as closed */ - return (*cf)(L); /* close it */ -} - - -static int io_close (lua_State *L) { - if (lua_isnone(L, 1)) /* no argument? */ - lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use standard output */ - tofile(L); /* make sure argument is an open stream */ - return aux_close(L); -} - - -static int f_gc (lua_State *L) { - LStream *p = tolstream(L); - if (!isclosed(p) && p->f != NULL) - aux_close(L); /* ignore closed and incompletely open files */ - return 0; -} - - -/* -** function to close regular files -*/ -static int io_fclose (lua_State *L) { - LStream *p = tolstream(L); - int res = fclose(p->f); - return luaL_fileresult(L, (res == 0), NULL); -} - - -static LStream *newfile (lua_State *L) { - LStream *p = newprefile(L); - p->f = NULL; - p->closef = &io_fclose; - return p; -} - - -static void opencheck (lua_State *L, const char *fname, const char *mode) { - LStream *p = newfile(L); - p->f = fopen(fname, mode); - if (p->f == NULL) - luaL_error(L, "cannot open file '%s' (%s)", fname, strerror(errno)); -} - - -static int io_open (lua_State *L) { - const char *filename = luaL_checkstring(L, 1); - const char *mode = luaL_optstring(L, 2, "r"); - LStream *p = newfile(L); - const char *md = mode; /* to traverse/check mode */ - luaL_argcheck(L, l_checkmode(md), 2, "invalid mode"); - p->f = fopen(filename, mode); - return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; -} - - -/* -** function to close 'popen' files -*/ -static int io_pclose (lua_State *L) { - LStream *p = tolstream(L); - return luaL_execresult(L, l_pclose(L, p->f)); -} - - -static int io_popen (lua_State *L) { - const char *filename = luaL_checkstring(L, 1); - const char *mode = luaL_optstring(L, 2, "r"); - LStream *p = newprefile(L); - p->f = l_popen(L, filename, mode); - p->closef = &io_pclose; - return (p->f == NULL) ? luaL_fileresult(L, 0, filename) : 1; -} - - -static int io_tmpfile (lua_State *L) { - LStream *p = newfile(L); - p->f = tmpfile(); - return (p->f == NULL) ? luaL_fileresult(L, 0, NULL) : 1; -} - - -static FILE *getiofile (lua_State *L, const char *findex) { - LStream *p; - lua_getfield(L, LUA_REGISTRYINDEX, findex); - p = (LStream *)lua_touserdata(L, -1); - if (isclosed(p)) - luaL_error(L, "standard %s file is closed", findex + IOPREF_LEN); - return p->f; -} - - -static int g_iofile (lua_State *L, const char *f, const char *mode) { - if (!lua_isnoneornil(L, 1)) { - const char *filename = lua_tostring(L, 1); - if (filename) - opencheck(L, filename, mode); - else { - tofile(L); /* check that it's a valid file handle */ - lua_pushvalue(L, 1); - } - lua_setfield(L, LUA_REGISTRYINDEX, f); - } - /* return current value */ - lua_getfield(L, LUA_REGISTRYINDEX, f); - return 1; -} - - -static int io_input (lua_State *L) { - return g_iofile(L, IO_INPUT, "r"); -} - - -static int io_output (lua_State *L) { - return g_iofile(L, IO_OUTPUT, "w"); -} - - -static int io_readline (lua_State *L); - - -static void aux_lines (lua_State *L, int toclose) { - int n = lua_gettop(L) - 1; /* number of arguments to read */ - lua_pushinteger(L, n); /* number of arguments to read */ - lua_pushboolean(L, toclose); /* close/not close file when finished */ - lua_rotate(L, 2, 2); /* move 'n' and 'toclose' to their positions */ - lua_pushcclosure(L, io_readline, 3 + n); -} - - -static int f_lines (lua_State *L) { - tofile(L); /* check that it's a valid file handle */ - aux_lines(L, 0); - return 1; -} - - -static int io_lines (lua_State *L) { - int toclose; - if (lua_isnone(L, 1)) lua_pushnil(L); /* at least one argument */ - if (lua_isnil(L, 1)) { /* no file name? */ - lua_getfield(L, LUA_REGISTRYINDEX, IO_INPUT); /* get default input */ - lua_replace(L, 1); /* put it at index 1 */ - tofile(L); /* check that it's a valid file handle */ - toclose = 0; /* do not close it after iteration */ - } - else { /* open a new file */ - const char *filename = luaL_checkstring(L, 1); - opencheck(L, filename, "r"); - lua_replace(L, 1); /* put file at index 1 */ - toclose = 1; /* close it after iteration */ - } - aux_lines(L, toclose); - return 1; -} - - -/* -** {====================================================== -** READ -** ======================================================= -*/ - - -/* maximum length of a numeral */ -#define MAXRN 200 - -/* auxiliary structure used by 'read_number' */ -typedef struct { - FILE *f; /* file being read */ - int c; /* current character (look ahead) */ - int n; /* number of elements in buffer 'buff' */ - char buff[MAXRN + 1]; /* +1 for ending '\0' */ -} RN; - - -/* -** Add current char to buffer (if not out of space) and read next one -*/ -static int nextc (RN *rn) { - if (rn->n >= MAXRN) { /* buffer overflow? */ - rn->buff[0] = '\0'; /* invalidate result */ - return 0; /* fail */ - } - else { - rn->buff[rn->n++] = rn->c; /* save current char */ - rn->c = l_getc(rn->f); /* read next one */ - return 1; - } -} - - -/* -** Accept current char if it is in 'set' (of size 1 or 2) -*/ -static int test2 (RN *rn, const char *set) { - if (rn->c == set[0] || (rn->c == set[1] && rn->c != '\0')) - return nextc(rn); - else return 0; -} - - -/* -** Read a sequence of (hex)digits -*/ -static int readdigits (RN *rn, int hex) { - int count = 0; - while ((hex ? isxdigit(rn->c) : isdigit(rn->c)) && nextc(rn)) - count++; - return count; -} - - -/* access to locale "radix character" (decimal point) */ -#if !defined(l_getlocaledecpoint) -#define l_getlocaledecpoint() (localeconv()->decimal_point[0]) -#endif - - -/* -** Read a number: first reads a valid prefix of a numeral into a buffer. -** Then it calls 'lua_stringtonumber' to check whether the format is -** correct and to convert it to a Lua number -*/ -static int read_number (lua_State *L, FILE *f) { - RN rn; - int count = 0; - int hex = 0; - char decp[2] = "."; - rn.f = f; rn.n = 0; - decp[0] = l_getlocaledecpoint(); /* get decimal point from locale */ - l_lockfile(rn.f); - do { rn.c = l_getc(rn.f); } while (isspace(rn.c)); /* skip spaces */ - test2(&rn, "-+"); /* optional signal */ - if (test2(&rn, "0")) { - if (test2(&rn, "xX")) hex = 1; /* numeral is hexadecimal */ - else count = 1; /* count initial '0' as a valid digit */ - } - count += readdigits(&rn, hex); /* integral part */ - if (test2(&rn, decp)) /* decimal point? */ - count += readdigits(&rn, hex); /* fractional part */ - if (count > 0 && test2(&rn, (hex ? "pP" : "eE"))) { /* exponent mark? */ - test2(&rn, "-+"); /* exponent signal */ - readdigits(&rn, 0); /* exponent digits */ - } - ungetc(rn.c, rn.f); /* unread look-ahead char */ - l_unlockfile(rn.f); - rn.buff[rn.n] = '\0'; /* finish string */ - if (lua_stringtonumber(L, rn.buff)) /* is this a valid number? */ - return 1; /* ok */ - else { /* invalid format */ - lua_pushnil(L); /* "result" to be removed */ - return 0; /* read fails */ - } -} - - -static int test_eof (lua_State *L, FILE *f) { - int c = getc(f); - ungetc(c, f); /* no-op when c == EOF */ - lua_pushlstring(L, NULL, 0); - return (c != EOF); -} - - -static int read_line (lua_State *L, FILE *f, int chop) { - luaL_Buffer b; - int c = '\0'; - luaL_buffinit(L, &b); - while (c != EOF && c != '\n') { /* repeat until end of line */ - char *buff = luaL_prepbuffer(&b); /* pre-allocate buffer */ - int i = 0; - l_lockfile(f); /* no memory errors can happen inside the lock */ - while (i < LUAL_BUFFERSIZE && (c = l_getc(f)) != EOF && c != '\n') - buff[i++] = c; - l_unlockfile(f); - luaL_addsize(&b, i); - } - if (!chop && c == '\n') /* want a newline and have one? */ - luaL_addchar(&b, c); /* add ending newline to result */ - luaL_pushresult(&b); /* close buffer */ - /* return ok if read something (either a newline or something else) */ - return (c == '\n' || lua_rawlen(L, -1) > 0); -} - - -static void read_all (lua_State *L, FILE *f) { - size_t nr; - luaL_Buffer b; - luaL_buffinit(L, &b); - do { /* read file in chunks of LUAL_BUFFERSIZE bytes */ - char *p = luaL_prepbuffsize(&b, LUAL_BUFFERSIZE); - nr = fread(p, sizeof(char), LUAL_BUFFERSIZE, f); - luaL_addsize(&b, nr); - } while (nr == LUAL_BUFFERSIZE); - luaL_pushresult(&b); /* close buffer */ -} - - -static int read_chars (lua_State *L, FILE *f, size_t n) { - size_t nr; /* number of chars actually read */ - char *p; - luaL_Buffer b; - luaL_buffinit(L, &b); - p = luaL_prepbuffsize(&b, n); /* prepare buffer to read whole block */ - nr = fread(p, sizeof(char), n, f); /* try to read 'n' chars */ - luaL_addsize(&b, nr); - luaL_pushresult(&b); /* close buffer */ - return (nr > 0); /* true iff read something */ -} - - -static int g_read (lua_State *L, FILE *f, int first) { - int nargs = lua_gettop(L) - 1; - int success; - int n; - clearerr(f); - if (nargs == 0) { /* no arguments? */ - success = read_line(L, f, 1); - n = first+1; /* to return 1 result */ - } - else { /* ensure stack space for all results and for auxlib's buffer */ - luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); - success = 1; - for (n = first; nargs-- && success; n++) { - if (lua_type(L, n) == LUA_TNUMBER) { - size_t l = (size_t)luaL_checkinteger(L, n); - success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); - } - else { - const char *p = luaL_checkstring(L, n); - if (*p == '*') p++; /* skip optional '*' (for compatibility) */ - switch (*p) { - case 'n': /* number */ - success = read_number(L, f); - break; - case 'l': /* line */ - success = read_line(L, f, 1); - break; - case 'L': /* line with end-of-line */ - success = read_line(L, f, 0); - break; - case 'a': /* file */ - read_all(L, f); /* read entire file */ - success = 1; /* always success */ - break; - default: - return luaL_argerror(L, n, "invalid format"); - } - } - } - } - if (ferror(f)) - return luaL_fileresult(L, 0, NULL); - if (!success) { - lua_pop(L, 1); /* remove last result */ - lua_pushnil(L); /* push nil instead */ - } - return n - first; -} - - -static int io_read (lua_State *L) { - return g_read(L, getiofile(L, IO_INPUT), 1); -} - - -static int f_read (lua_State *L) { - return g_read(L, tofile(L), 2); -} - - -static int io_readline (lua_State *L) { - LStream *p = (LStream *)lua_touserdata(L, lua_upvalueindex(1)); - int i; - int n = (int)lua_tointeger(L, lua_upvalueindex(2)); - if (isclosed(p)) /* file is already closed? */ - return luaL_error(L, "file is already closed"); - lua_settop(L , 1); - luaL_checkstack(L, n, "too many arguments"); - for (i = 1; i <= n; i++) /* push arguments to 'g_read' */ - lua_pushvalue(L, lua_upvalueindex(3 + i)); - n = g_read(L, p->f, 2); /* 'n' is number of results */ - lua_assert(n > 0); /* should return at least a nil */ - if (lua_toboolean(L, -n)) /* read at least one value? */ - return n; /* return them */ - else { /* first result is nil: EOF or error */ - if (n > 1) { /* is there error information? */ - /* 2nd result is error message */ - return luaL_error(L, "%s", lua_tostring(L, -n + 1)); - } - if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */ - lua_settop(L, 0); - lua_pushvalue(L, lua_upvalueindex(1)); - aux_close(L); /* close it */ - } - return 0; - } -} - -/* }====================================================== */ - - -static int g_write (lua_State *L, FILE *f, int arg) { - int nargs = lua_gettop(L) - arg; - int status = 1; - for (; nargs--; arg++) { - if (lua_type(L, arg) == LUA_TNUMBER) { - /* optimization: could be done exactly as for strings */ - int len = lua_isinteger(L, arg) - ? fprintf(f, LUA_INTEGER_FMT, lua_tointeger(L, arg)) - : fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)); - status = status && (len > 0); - } - else { - size_t l; - const char *s = luaL_checklstring(L, arg, &l); - status = status && (fwrite(s, sizeof(char), l, f) == l); - } - } - if (status) return 1; /* file handle already on stack top */ - else return luaL_fileresult(L, status, NULL); -} - - -static int io_write (lua_State *L) { - return g_write(L, getiofile(L, IO_OUTPUT), 1); -} - - -static int f_write (lua_State *L) { - FILE *f = tofile(L); - lua_pushvalue(L, 1); /* push file at the stack top (to be returned) */ - return g_write(L, f, 2); -} - - -static int f_seek (lua_State *L) { - static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; - static const char *const modenames[] = {"set", "cur", "end", NULL}; - FILE *f = tofile(L); - int op = luaL_checkoption(L, 2, "cur", modenames); - lua_Integer p3 = luaL_optinteger(L, 3, 0); - l_seeknum offset = (l_seeknum)p3; - luaL_argcheck(L, (lua_Integer)offset == p3, 3, - "not an integer in proper range"); - op = l_fseek(f, offset, mode[op]); - if (op) - return luaL_fileresult(L, 0, NULL); /* error */ - else { - lua_pushinteger(L, (lua_Integer)l_ftell(f)); - return 1; - } -} - - -static int f_setvbuf (lua_State *L) { - static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; - static const char *const modenames[] = {"no", "full", "line", NULL}; - FILE *f = tofile(L); - int op = luaL_checkoption(L, 2, NULL, modenames); - lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); - int res = setvbuf(f, NULL, mode[op], (size_t)sz); - return luaL_fileresult(L, res == 0, NULL); -} - - - -static int io_flush (lua_State *L) { - return luaL_fileresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); -} - - -static int f_flush (lua_State *L) { - return luaL_fileresult(L, fflush(tofile(L)) == 0, NULL); -} - - -/* -** functions for 'io' library -*/ -static const luaL_Reg iolib[] = { - {"close", io_close}, - {"flush", io_flush}, - {"input", io_input}, - {"lines", io_lines}, - {"open", io_open}, - {"output", io_output}, - {"popen", io_popen}, - {"read", io_read}, - {"tmpfile", io_tmpfile}, - {"type", io_type}, - {"write", io_write}, - {NULL, NULL} -}; - - -/* -** methods for file handles -*/ -static const luaL_Reg flib[] = { - {"close", io_close}, - {"flush", f_flush}, - {"lines", f_lines}, - {"read", f_read}, - {"seek", f_seek}, - {"setvbuf", f_setvbuf}, - {"write", f_write}, - {"__gc", f_gc}, - {"__tostring", f_tostring}, - {NULL, NULL} -}; - - -static void createmeta (lua_State *L) { - luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ - lua_pushvalue(L, -1); /* push metatable */ - lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ - luaL_setfuncs(L, flib, 0); /* add file methods to new metatable */ - lua_pop(L, 1); /* pop new metatable */ -} - - -/* -** function to (not) close the standard files stdin, stdout, and stderr -*/ -static int io_noclose (lua_State *L) { - LStream *p = tolstream(L); - p->closef = &io_noclose; /* keep file opened */ - lua_pushnil(L); - lua_pushliteral(L, "cannot close standard file"); - return 2; -} - - -static void createstdfile (lua_State *L, FILE *f, const char *k, - const char *fname) { - LStream *p = newprefile(L); - p->f = f; - p->closef = &io_noclose; - if (k != NULL) { - lua_pushvalue(L, -1); - lua_setfield(L, LUA_REGISTRYINDEX, k); /* add file to registry */ - } - lua_setfield(L, -2, fname); /* add file to module */ -} - - -LUAMOD_API int luaopen_io (lua_State *L) { - luaL_newlib(L, iolib); /* new module */ - createmeta(L); - /* create (and set) default files */ - createstdfile(L, stdin, IO_INPUT, "stdin"); - createstdfile(L, stdout, IO_OUTPUT, "stdout"); - createstdfile(L, stderr, NULL, "stderr"); - return 1; -} - diff --git a/thirdparty/src/Lua/llex.cpp b/thirdparty/src/Lua/llex.cpp deleted file mode 100644 index 4fe630dfb..000000000 --- a/thirdparty/src/Lua/llex.cpp +++ /dev/null @@ -1,630 +0,0 @@ -/* -** $Id: llex.c,v 2.89 2014/11/14 16:06:09 roberto Exp $ -** Lexical Analyzer -** See Copyright Notice in lua.h -*/ - -#define llex_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <locale.h> -#include <string.h> - -#include <Lua/lua.h> - -#include "lctype.h" -#include "ldo.h" -#include "lgc.h" -#include "llex.h" -#include "lobject.h" -#include "lparser.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "lzio.h" - - - -#define next(ls) (ls->current = zgetc(ls->z)) - - - -#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') - - -/* ORDER RESERVED */ -static const char *const luaX_tokens [] = { - "and", "break", "do", "else", "elseif", - "end", "false", "for", "function", "goto", "if", - "in", "local", "nil", "not", "or", "repeat", - "return", "then", "true", "until", "while", - "//", "..", "...", "==", ">=", "<=", "~=", - "<<", ">>", "::", "<eof>", -#ifdef LUA_CPPNEG - "!=", -#endif - "<number>", "<integer>", "<name>", "<string>" -}; - - -#define save_and_next(ls) (save(ls, ls->current), next(ls)) - - -static l_noret lexerror (LexState *ls, const char *msg, int token); - - -static void save (LexState *ls, int c) { - Mbuffer *b = ls->buff; - if (luaZ_bufflen(b) + 1 > luaZ_sizebuffer(b)) { - size_t newsize; - if (luaZ_sizebuffer(b) >= MAX_SIZE/2) - lexerror(ls, "lexical element too long", 0); - newsize = luaZ_sizebuffer(b) * 2; - luaZ_resizebuffer(ls->L, b, newsize); - } - b->buffer[luaZ_bufflen(b)++] = cast(char, c); -} - - -void luaX_init (lua_State *L) { - int i; - TString *e = luaS_new(L, LUA_ENV); /* create env name */ - luaC_fix(L, obj2gco(e)); /* never collect this name */ - for (i=0; i<NUM_RESERVED; i++) { - TString *ts = luaS_new(L, luaX_tokens[i]); - luaC_fix(L, obj2gco(ts)); /* reserved words are never collected */ - ts->extra = cast_byte(i+1); /* reserved word */ - } -} - - -const char *luaX_token2str (LexState *ls, int token) { - if (token < FIRST_RESERVED) { /* single-byte symbols? */ - lua_assert(token == cast_uchar(token)); - return luaO_pushfstring(ls->L, "'%c'", token); - } - else { - const char *s = luaX_tokens[token - FIRST_RESERVED]; - if (token < TK_EOS) /* fixed format (symbols and reserved words)? */ - return luaO_pushfstring(ls->L, "'%s'", s); - else /* names, strings, and numerals */ - return s; - } -} - - -static const char *txtToken (LexState *ls, int token) { - switch (token) { - case TK_NAME: case TK_STRING: - case TK_FLT: case TK_INT: - save(ls, '\0'); - return luaO_pushfstring(ls->L, "'%s'", luaZ_buffer(ls->buff)); - default: - return luaX_token2str(ls, token); - } -} - - -static l_noret lexerror (LexState *ls, const char *msg, int token) { - char buff[LUA_IDSIZE]; - luaO_chunkid(buff, getstr(ls->source), LUA_IDSIZE); - msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); - if (token) - luaO_pushfstring(ls->L, "%s near %s", msg, txtToken(ls, token)); - luaD_throw(ls->L, LUA_ERRSYNTAX); -} - - -l_noret luaX_syntaxerror (LexState *ls, const char *msg) { - lexerror(ls, msg, ls->t.token); -} - - -/* -** creates a new string and anchors it in scanner's table so that -** it will not be collected until the end of the compilation -** (by that time it should be anchored somewhere) -*/ -TString *luaX_newstring (LexState *ls, const char *str, size_t l) { - lua_State *L = ls->L; - TValue *o; /* entry for 'str' */ - TString *ts = luaS_newlstr(L, str, l); /* create new string */ - setsvalue2s(L, L->top++, ts); /* temporarily anchor it in stack */ - o = luaH_set(L, ls->h, L->top - 1); - if (ttisnil(o)) { /* not in use yet? */ - /* boolean value does not need GC barrier; - table has no metatable, so it does not need to invalidate cache */ - setbvalue(o, 1); /* t[string] = true */ - luaC_checkGC(L); - } - else { /* string already present */ - ts = tsvalue(keyfromval(o)); /* re-use value previously stored */ - } - L->top--; /* remove string from stack */ - return ts; -} - - -/* -** increment line number and skips newline sequence (any of -** \n, \r, \n\r, or \r\n) -*/ -static void inclinenumber (LexState *ls) { - int old = ls->current; - lua_assert(currIsNewline(ls)); - next(ls); /* skip '\n' or '\r' */ - if (currIsNewline(ls) && ls->current != old) - next(ls); /* skip '\n\r' or '\r\n' */ - if (++ls->linenumber >= MAX_INT) - lexerror(ls, "chunk has too many lines", 0); -} - - -void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source, - int firstchar) { - ls->t.token = 0; - ls->decpoint = '.'; - ls->L = L; - ls->current = firstchar; - ls->lookahead.token = TK_EOS; /* no look-ahead token */ - ls->z = z; - ls->fs = NULL; - ls->linenumber = 1; - ls->lastline = 1; - ls->source = source; - ls->envn = luaS_new(L, LUA_ENV); /* get env name */ - luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ -} - - - -/* -** ======================================================= -** LEXICAL ANALYZER -** ======================================================= -*/ - - -static int check_next1 (LexState *ls, int c) { - if (ls->current == c) { - next(ls); - return 1; - } - else return 0; -} - - -/* -** Check whether current char is in set 'set' (with two chars) and -** saves it -*/ -static int check_next2 (LexState *ls, const char *set) { - lua_assert(set[2] == '\0'); - if (ls->current == set[0] || ls->current == set[1]) { - save_and_next(ls); - return 1; - } - else return 0; -} - - -/* -** change all characters 'from' in buffer to 'to' -*/ -static void buffreplace (LexState *ls, char from, char to) { - if (from != to) { - size_t n = luaZ_bufflen(ls->buff); - char *p = luaZ_buffer(ls->buff); - while (n--) - if (p[n] == from) p[n] = to; - } -} - - -#if !defined(l_getlocaledecpoint) -#define l_getlocaledecpoint() (localeconv()->decimal_point[0]) -#endif - - -#define buff2num(b,o) (luaO_str2num(luaZ_buffer(b), o) != 0) - -/* -** in case of format error, try to change decimal point separator to -** the one defined in the current locale and check again -*/ -static void trydecpoint (LexState *ls, TValue *o) { - char old = ls->decpoint; - ls->decpoint = l_getlocaledecpoint(); - buffreplace(ls, old, ls->decpoint); /* try new decimal separator */ - if (!buff2num(ls->buff, o)) { - /* format error with correct decimal point: no more options */ - buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ - lexerror(ls, "malformed number", TK_FLT); - } -} - - -/* LUA_NUMBER */ -/* -** this function is quite liberal in what it accepts, as 'luaO_str2num' -** will reject ill-formed numerals. -*/ -static int read_numeral (LexState *ls, SemInfo *seminfo) { - TValue obj; - const char *expo = "Ee"; - int first = ls->current; - lua_assert(lisdigit(ls->current)); - save_and_next(ls); - if (first == '0' && check_next2(ls, "xX")) /* hexadecimal? */ - expo = "Pp"; - for (;;) { - if (check_next2(ls, expo)) /* exponent part? */ - check_next2(ls, "-+"); /* optional exponent sign */ - if (lisxdigit(ls->current)) - save_and_next(ls); - else if (ls->current == '.') - save_and_next(ls); - else break; - } - save(ls, '\0'); - buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ - if (!buff2num(ls->buff, &obj)) /* format error? */ - trydecpoint(ls, &obj); /* try to update decimal point separator */ - if (ttisinteger(&obj)) { - seminfo->i = ivalue(&obj); - return TK_INT; - } - else { - lua_assert(ttisfloat(&obj)); - seminfo->r = fltvalue(&obj); - return TK_FLT; - } -} - - -/* -** skip a sequence '[=*[' or ']=*]' and return its number of '='s or -** -1 if sequence is malformed -*/ -static int skip_sep (LexState *ls) { - int count = 0; - int s = ls->current; - lua_assert(s == '[' || s == ']'); - save_and_next(ls); - while (ls->current == '=') { - save_and_next(ls); - count++; - } - return (ls->current == s) ? count : (-count) - 1; -} - - -static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { - int line = ls->linenumber; /* initial line (for error message) */ - save_and_next(ls); /* skip 2nd '[' */ - if (currIsNewline(ls)) /* string starts with a newline? */ - inclinenumber(ls); /* skip it */ - for (;;) { - switch (ls->current) { - case EOZ: { /* error */ - const char *what = (seminfo ? "string" : "comment"); - const char *msg = luaO_pushfstring(ls->L, - "unfinished long %s (starting at line %d)", what, line); - lexerror(ls, msg, TK_EOS); - break; /* to avoid warnings */ - } - case ']': { - if (skip_sep(ls) == sep) { - save_and_next(ls); /* skip 2nd ']' */ - goto endloop; - } - break; - } - case '\n': case '\r': { - save(ls, '\n'); - inclinenumber(ls); - if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ - break; - } - default: { - if (seminfo) save_and_next(ls); - else next(ls); - } - } - } endloop: - if (seminfo) - seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), - luaZ_bufflen(ls->buff) - 2*(2 + sep)); -} - - -static void esccheck (LexState *ls, int c, const char *msg) { - if (!c) { - if (ls->current != EOZ) - save_and_next(ls); /* add current to buffer for error message */ - lexerror(ls, msg, TK_STRING); - } -} - - -static int gethexa (LexState *ls) { - save_and_next(ls); - esccheck (ls, lisxdigit(ls->current), "hexadecimal digit expected"); - return luaO_hexavalue(ls->current); -} - - -static int readhexaesc (LexState *ls) { - int r = gethexa(ls); - r = (r << 4) + gethexa(ls); - luaZ_buffremove(ls->buff, 2); /* remove saved chars from buffer */ - return r; -} - - -static unsigned long readutf8esc (LexState *ls) { - unsigned long r; - int i = 4; /* chars to be removed: '\', 'u', '{', and first digit */ - save_and_next(ls); /* skip 'u' */ - esccheck(ls, ls->current == '{', "missing '{'"); - r = gethexa(ls); /* must have at least one digit */ - while ((save_and_next(ls), lisxdigit(ls->current))) { - i++; - r = (r << 4) + luaO_hexavalue(ls->current); - esccheck(ls, r <= 0x10FFFF, "UTF-8 value too large"); - } - esccheck(ls, ls->current == '}', "missing '}'"); - next(ls); /* skip '}' */ - luaZ_buffremove(ls->buff, i); /* remove saved chars from buffer */ - return r; -} - - -static void utf8esc (LexState *ls) { - char buff[UTF8BUFFSZ]; - int n = luaO_utf8esc(buff, readutf8esc(ls)); - for (; n > 0; n--) /* add 'buff' to string */ - save(ls, buff[UTF8BUFFSZ - n]); -} - - -static int readdecesc (LexState *ls) { - int i; - int r = 0; /* result accumulator */ - for (i = 0; i < 3 && lisdigit(ls->current); i++) { /* read up to 3 digits */ - r = 10*r + ls->current - '0'; - save_and_next(ls); - } - esccheck(ls, r <= UCHAR_MAX, "decimal escape too large"); - luaZ_buffremove(ls->buff, i); /* remove read digits from buffer */ - return r; -} - - -static void read_string (LexState *ls, int del, SemInfo *seminfo) { - save_and_next(ls); /* keep delimiter (for error messages) */ - while (ls->current != del) { - switch (ls->current) { - case EOZ: - lexerror(ls, "unfinished string", TK_EOS); - break; /* to avoid warnings */ - case '\n': - case '\r': - lexerror(ls, "unfinished string", TK_STRING); - break; /* to avoid warnings */ - case '\\': { /* escape sequences */ - int c; /* final character to be saved */ - save_and_next(ls); /* keep '\\' for error messages */ - switch (ls->current) { - case 'a': c = '\a'; goto read_save; - case 'b': c = '\b'; goto read_save; - case 'f': c = '\f'; goto read_save; - case 'n': c = '\n'; goto read_save; - case 'r': c = '\r'; goto read_save; - case 't': c = '\t'; goto read_save; - case 'v': c = '\v'; goto read_save; - case 'x': c = readhexaesc(ls); goto read_save; - case 'u': utf8esc(ls); goto no_save; - case '\n': case '\r': - inclinenumber(ls); c = '\n'; goto only_save; - case '\\': case '\"': case '\'': - c = ls->current; goto read_save; - case EOZ: goto no_save; /* will raise an error next loop */ - case 'z': { /* zap following span of spaces */ - luaZ_buffremove(ls->buff, 1); /* remove '\\' */ - next(ls); /* skip the 'z' */ - while (lisspace(ls->current)) { - if (currIsNewline(ls)) inclinenumber(ls); - else next(ls); - } - goto no_save; - } - default: { - esccheck(ls, lisdigit(ls->current), "invalid escape sequence"); - c = readdecesc(ls); /* digital escape '\ddd' */ - goto only_save; - } - } - read_save: - next(ls); - /* go through */ - only_save: - luaZ_buffremove(ls->buff, 1); /* remove '\\' */ - save(ls, c); - /* go through */ - no_save: break; - } - default: - save_and_next(ls); - } - } - save_and_next(ls); /* skip delimiter */ - seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, - luaZ_bufflen(ls->buff) - 2); -} - - -static int llex (LexState *ls, SemInfo *seminfo) { -#if defined(LUA_CPPCOMT_LONG) - int last; -#endif - luaZ_resetbuffer(ls->buff); - for (;;) { - switch (ls->current) { - case '\n': case '\r': { /* line breaks */ - inclinenumber(ls); - break; - } - case ' ': case '\f': case '\t': case '\v': { /* spaces */ - next(ls); - break; - } - case '-': { /* '-' or '--' (comment) */ - next(ls); - if (ls->current != '-') return '-'; - /* else is a comment */ - next(ls); - if (ls->current == '[') { /* long comment? */ - int sep = skip_sep(ls); - luaZ_resetbuffer(ls->buff); /* 'skip_sep' may dirty the buffer */ - if (sep >= 0) { - read_long_string(ls, NULL, sep); /* skip long comment */ - luaZ_resetbuffer(ls->buff); /* previous call may dirty the buff. */ - break; - } - } - /* else short comment */ - while (!currIsNewline(ls) && ls->current != EOZ) - next(ls); /* skip until end of line (or end of file) */ - break; - } - case '[': { /* long string or simply '[' */ - int sep = skip_sep(ls); - if (sep >= 0) { - read_long_string(ls, seminfo, sep); - return TK_STRING; - } - else if (sep == -1) return '['; - else lexerror(ls, "invalid long string delimiter", TK_STRING); - } - case '=': { - next(ls); - if (check_next1(ls, '=')) return TK_EQ; - else return '='; - } - case '<': { - next(ls); - if (check_next1(ls, '=')) return TK_LE; - else if (check_next1(ls, '<')) return TK_SHL; - else return '<'; - } - case '>': { - next(ls); - if (check_next1(ls, '=')) return TK_GE; - else if (check_next1(ls, '>')) return TK_SHR; - else return '>'; - } - case '/': { - next(ls); - if (check_next1(ls, '/')) return TK_IDIV; -#if defined(LUA_CPPCOMT_LONG) - /* bn 01/2012: added C++-style comments */ - /* Lynix 02/2015: Fixed it for Lua 5.3.0 */ - else if (check_next1(ls, '*')) { - last = 0; - while (ls->current != EOZ) { - if (last == '*' && ls->current == '/') break; - last = ls->current; - next(ls); /* skip until closing marker (or end of file) */ - } - if (ls->current == EOZ) - lexerror(ls, "unfinished long comment", TK_EOS); - else next(ls); - } -#endif /* LUA_CPPCOMT_LONG */ - else return '/'; - } -#ifdef LUA_CPPNEG - case '!': { - next(ls); - if (check_next1(ls, '=')) return TK_NE; - else return '!'; - } -#endif - case '~': { - next(ls); - if (check_next1(ls, '=')) return TK_NE; - else return '~'; - } - case ':': { - next(ls); - if (check_next1(ls, ':')) return TK_DBCOLON; - else return ':'; - } - case '"': case '\'': { /* short literal strings */ - read_string(ls, ls->current, seminfo); - return TK_STRING; - } - case '.': { /* '.', '..', '...', or number */ - save_and_next(ls); - if (check_next1(ls, '.')) { - if (check_next1(ls, '.')) - return TK_DOTS; /* '...' */ - else return TK_CONCAT; /* '..' */ - } - else if (!lisdigit(ls->current)) return '.'; - else return read_numeral(ls, seminfo); - } - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': { - return read_numeral(ls, seminfo); - } - case EOZ: { - return TK_EOS; - } - default: { - if (lislalpha(ls->current)) { /* identifier or reserved word? */ - TString *ts; - do { - save_and_next(ls); - } while (lislalnum(ls->current)); - ts = luaX_newstring(ls, luaZ_buffer(ls->buff), - luaZ_bufflen(ls->buff)); - seminfo->ts = ts; - if (isreserved(ts)) /* reserved word? */ - return ts->extra - 1 + FIRST_RESERVED; - else { - return TK_NAME; - } - } - else { /* single-char tokens (+ - / ...) */ - int c = ls->current; - next(ls); - return c; - } - } - } - } -} - - -void luaX_next (LexState *ls) { - ls->lastline = ls->linenumber; - if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ - ls->t = ls->lookahead; /* use this one */ - ls->lookahead.token = TK_EOS; /* and discharge it */ - } - else - ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ -} - - -int luaX_lookahead (LexState *ls) { - lua_assert(ls->lookahead.token == TK_EOS); - ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); - return ls->lookahead.token; -} - diff --git a/thirdparty/src/Lua/llex.h b/thirdparty/src/Lua/llex.h deleted file mode 100644 index ac1df1720..000000000 --- a/thirdparty/src/Lua/llex.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -** $Id: llex.h,v 1.78 2014/10/29 15:38:24 roberto Exp $ -** Lexical Analyzer -** See Copyright Notice in lua.h -*/ - -#ifndef llex_h -#define llex_h - -#include "lobject.h" -#include "lzio.h" - - -#define FIRST_RESERVED 257 - - -#if !defined(LUA_ENV) -#define LUA_ENV "_ENV" -#endif - -/* bn 01/2012: added C++-style comments */ -#define LUA_CPPCOMT_LONG -/* end changes */ - -/* -* WARNING: if you change the order of this enumeration, -* grep "ORDER RESERVED" -*/ -enum RESERVED { - /* terminal symbols denoted by reserved words */ - TK_AND = FIRST_RESERVED, TK_BREAK, - TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, - TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, - TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, - /* other terminal symbols */ - TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, - TK_SHL, TK_SHR, - TK_DBCOLON, TK_EOS, -#ifdef LUA_CPPNEG - TK_CNE, -#endif - TK_FLT, TK_INT, TK_NAME, TK_STRING -}; - -/* number of reserved words */ -#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) - - -typedef union { - lua_Number r; - lua_Integer i; - TString *ts; -} SemInfo; /* semantics information */ - - -typedef struct Token { - int token; - SemInfo seminfo; -} Token; - - -/* state of the lexer plus state of the parser when shared by all - functions */ -typedef struct LexState { - int current; /* current character (charint) */ - int linenumber; /* input line counter */ - int lastline; /* line of last token 'consumed' */ - Token t; /* current token */ - Token lookahead; /* look ahead token */ - struct FuncState *fs; /* current function (parser) */ - struct lua_State *L; - ZIO *z; /* input stream */ - Mbuffer *buff; /* buffer for tokens */ - Table *h; /* to avoid collection/reuse strings */ - struct Dyndata *dyd; /* dynamic structures used by the parser */ - TString *source; /* current source name */ - TString *envn; /* environment variable name */ - char decpoint; /* locale decimal point */ -} LexState; - - -LUAI_FUNC void luaX_init (lua_State *L); -LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, - TString *source, int firstchar); -LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); -LUAI_FUNC void luaX_next (LexState *ls); -LUAI_FUNC int luaX_lookahead (LexState *ls); -LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); -LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); - - -#endif diff --git a/thirdparty/src/Lua/llimits.h b/thirdparty/src/Lua/llimits.h deleted file mode 100644 index 6347af542..000000000 --- a/thirdparty/src/Lua/llimits.h +++ /dev/null @@ -1,242 +0,0 @@ -/* -** $Id: llimits.h,v 1.125 2014/12/19 13:30:23 roberto Exp $ -** Limits, basic types, and some other 'installation-dependent' definitions -** See Copyright Notice in lua.h -*/ - -#ifndef llimits_h -#define llimits_h - - -#include <limits.h> -#include <stddef.h> - - -#include <Lua/lua.h> - -/* -** 'lu_mem' and 'l_mem' are unsigned/signed integers big enough to count -** the total memory used by Lua (in bytes). Usually, 'size_t' and -** 'ptrdiff_t' should work, but we use 'long' for 16-bit machines. -*/ -#if defined(LUAI_MEM) /* { external definitions? */ -typedef LUAI_UMEM lu_mem; -typedef LUAI_MEM l_mem; -#elif LUAI_BITSINT >= 32 /* }{ */ -typedef size_t lu_mem; -typedef ptrdiff_t l_mem; -#else /* 16-bit ints */ /* }{ */ -typedef unsigned long lu_mem; -typedef long l_mem; -#endif /* } */ - - -/* chars used as small naturals (so that 'char' is reserved for characters) */ -typedef unsigned char lu_byte; - - -/* maximum value for size_t */ -#define MAX_SIZET ((size_t)(~(size_t)0)) - -/* maximum size visible for Lua (must be representable in a lua_Integer */ -#define MAX_SIZE (sizeof(size_t) < sizeof(lua_Integer) ? MAX_SIZET \ - : (size_t)(LUA_MAXINTEGER)) - - -#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)) - -#define MAX_LMEM ((l_mem)(MAX_LUMEM >> 1)) - - -#define MAX_INT INT_MAX /* maximum value of an int */ - - -/* -** conversion of pointer to integer: -** this is for hashing only; there is no problem if the integer -** cannot hold the whole pointer value -*/ -#define point2int(p) ((unsigned int)((size_t)(p) & UINT_MAX)) - - - -/* type to ensure maximum alignment */ -#if defined(LUAI_USER_ALIGNMENT_T) -typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; -#else -typedef union { double u; void *s; lua_Integer i; long l; } L_Umaxalign; -#endif - - - -/* types of 'usual argument conversions' for lua_Number and lua_Integer */ -typedef LUAI_UACNUMBER l_uacNumber; -typedef LUAI_UACINT l_uacInt; - - -/* internal assertions for in-house debugging */ -#if defined(lua_assert) -#define check_exp(c,e) (lua_assert(c), (e)) -/* to avoid problems with conditions too long */ -#define lua_longassert(c) { if (!(c)) lua_assert(0); } -#else -#define lua_assert(c) ((void)0) -#define check_exp(c,e) (e) -#define lua_longassert(c) ((void)0) -#endif - -/* -** assertion for checking API calls -*/ -#if defined(LUA_USE_APICHECK) -#include <assert.h> -#define luai_apicheck(e) assert(e) -#else -#define luai_apicheck(e) lua_assert(e) -#endif - - -#define api_check(e,msg) luai_apicheck((e) && msg) - - -#if !defined(UNUSED) -#define UNUSED(x) ((void)(x)) /* to avoid warnings */ -#endif - - -#define cast(t, exp) ((t)(exp)) - -#define cast_void(i) cast(void, (i)) -#define cast_byte(i) cast(lu_byte, (i)) -#define cast_num(i) cast(lua_Number, (i)) -#define cast_int(i) cast(int, (i)) -#define cast_uchar(i) cast(unsigned char, (i)) - - -/* cast a signed lua_Integer to lua_Unsigned */ -#if !defined(l_castS2U) -#define l_castS2U(i) ((lua_Unsigned)(i)) -#endif - -/* -** cast a lua_Unsigned to a signed lua_Integer; this cast is -** not strict ISO C, but two-complement architectures should -** work fine. -*/ -#if !defined(l_castU2S) -#define l_castU2S(i) ((lua_Integer)(i)) -#endif - - -/* -** non-return type -*/ -#if defined(__GNUC__) -#define l_noret void __attribute__((noreturn)) -#elif defined(_MSC_VER) && _MSC_VER >= 1200 -#define l_noret void __declspec(noreturn) -#else -#define l_noret void -#endif - - - -/* -** maximum depth for nested C calls and syntactical nested non-terminals -** in a program. (Value must fit in an unsigned short int.) -*/ -#if !defined(LUAI_MAXCCALLS) -#define LUAI_MAXCCALLS 200 -#endif - -/* -** maximum number of upvalues in a closure (both C and Lua). (Value -** must fit in an unsigned char.) -*/ -#define MAXUPVAL UCHAR_MAX - - -/* -** type for virtual-machine instructions; -** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) -*/ -#if LUAI_BITSINT >= 32 -typedef unsigned int Instruction; -#else -typedef unsigned long Instruction; -#endif - - - - -/* minimum size for the string table (must be power of 2) */ -#if !defined(MINSTRTABSIZE) -#define MINSTRTABSIZE 64 /* minimum size for "predefined" strings */ -#endif - - -/* minimum size for string buffer */ -#if !defined(LUA_MINBUFFER) -#define LUA_MINBUFFER 32 -#endif - - -#if !defined(lua_lock) -#define lua_lock(L) ((void) 0) -#define lua_unlock(L) ((void) 0) -#endif - -#if !defined(luai_threadyield) -#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} -#endif - - -/* -** these macros allow user-specific actions on threads when you defined -** LUAI_EXTRASPACE and need to do something extra when a thread is -** created/deleted/resumed/yielded. -*/ -#if !defined(luai_userstateopen) -#define luai_userstateopen(L) ((void)L) -#endif - -#if !defined(luai_userstateclose) -#define luai_userstateclose(L) ((void)L) -#endif - -#if !defined(luai_userstatethread) -#define luai_userstatethread(L,L1) ((void)L) -#endif - -#if !defined(luai_userstatefree) -#define luai_userstatefree(L,L1) ((void)L) -#endif - -#if !defined(luai_userstateresume) -#define luai_userstateresume(L,n) ((void)L) -#endif - -#if !defined(luai_userstateyield) -#define luai_userstateyield(L,n) ((void)L) -#endif - - - -/* -** macro to control inclusion of some hard tests on stack reallocation -*/ -#if !defined(HARDSTACKTESTS) -#define condmovestack(L) ((void)0) -#else -/* realloc stack keeping its size */ -#define condmovestack(L) luaD_reallocstack((L), (L)->stacksize) -#endif - -#if !defined(HARDMEMTESTS) -#define condchangemem(L) condmovestack(L) -#else -#define condchangemem(L) \ - ((void)(!(G(L)->gcrunning) || (luaC_fullgc(L, 0), 1))) -#endif - -#endif diff --git a/thirdparty/src/Lua/lmathlib.cpp b/thirdparty/src/Lua/lmathlib.cpp deleted file mode 100644 index 638ded878..000000000 --- a/thirdparty/src/Lua/lmathlib.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/* -** $Id: lmathlib.c,v 1.114 2014/12/27 20:32:26 roberto Exp $ -** Standard mathematical library -** See Copyright Notice in lua.h -*/ - -#define lmathlib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include <stdlib.h> -#include <math.h> - -#include <Lua/lua.h> - -#include <Lua/lauxlib.h> -#include <Lua/lualib.h> - - -#undef PI -#define PI (l_mathop(3.141592653589793238462643383279502884)) - - -#if !defined(l_rand) /* { */ -#if defined(LUA_USE_POSIX) -#define l_rand() random() -#define l_srand(x) srandom(x) -#define L_RANDMAX 2147483647 /* (2^31 - 1), following POSIX */ -#else -#define l_rand() rand() -#define l_srand(x) srand(x) -#define L_RANDMAX RAND_MAX -#endif -#endif /* } */ - - -static int math_abs (lua_State *L) { - if (lua_isinteger(L, 1)) { - lua_Integer n = lua_tointeger(L, 1); - if (n < 0) n = (lua_Integer)(0u - n); - lua_pushinteger(L, n); - } - else - lua_pushnumber(L, l_mathop(fabs)(luaL_checknumber(L, 1))); - return 1; -} - -static int math_sin (lua_State *L) { - lua_pushnumber(L, l_mathop(sin)(luaL_checknumber(L, 1))); - return 1; -} - -static int math_cos (lua_State *L) { - lua_pushnumber(L, l_mathop(cos)(luaL_checknumber(L, 1))); - return 1; -} - -static int math_tan (lua_State *L) { - lua_pushnumber(L, l_mathop(tan)(luaL_checknumber(L, 1))); - return 1; -} - -static int math_asin (lua_State *L) { - lua_pushnumber(L, l_mathop(asin)(luaL_checknumber(L, 1))); - return 1; -} - -static int math_acos (lua_State *L) { - lua_pushnumber(L, l_mathop(acos)(luaL_checknumber(L, 1))); - return 1; -} - -static int math_atan (lua_State *L) { - lua_Number y = luaL_checknumber(L, 1); - lua_Number x = luaL_optnumber(L, 2, 1); - lua_pushnumber(L, l_mathop(atan2)(y, x)); - return 1; -} - - -static int math_toint (lua_State *L) { - int valid; - lua_Integer n = lua_tointegerx(L, 1, &valid); - if (valid) - lua_pushinteger(L, n); - else { - luaL_checkany(L, 1); - lua_pushnil(L); /* value is not convertible to integer */ - } - return 1; -} - - -static void pushnumint (lua_State *L, lua_Number d) { - lua_Integer n; - if (lua_numbertointeger(d, &n)) /* does 'd' fit in an integer? */ - lua_pushinteger(L, n); /* result is integer */ - else - lua_pushnumber(L, d); /* result is float */ -} - - -static int math_floor (lua_State *L) { - if (lua_isinteger(L, 1)) - lua_settop(L, 1); /* integer is its own floor */ - else { - lua_Number d = l_mathop(floor)(luaL_checknumber(L, 1)); - pushnumint(L, d); - } - return 1; -} - - -static int math_ceil (lua_State *L) { - if (lua_isinteger(L, 1)) - lua_settop(L, 1); /* integer is its own ceil */ - else { - lua_Number d = l_mathop(ceil)(luaL_checknumber(L, 1)); - pushnumint(L, d); - } - return 1; -} - - -static int math_fmod (lua_State *L) { - if (lua_isinteger(L, 1) && lua_isinteger(L, 2)) { - lua_Integer d = lua_tointeger(L, 2); - if ((lua_Unsigned)d + 1u <= 1u) { /* special cases: -1 or 0 */ - luaL_argcheck(L, d != 0, 2, "zero"); - lua_pushinteger(L, 0); /* avoid overflow with 0x80000... / -1 */ - } - else - lua_pushinteger(L, lua_tointeger(L, 1) % d); - } - else - lua_pushnumber(L, l_mathop(fmod)(luaL_checknumber(L, 1), - luaL_checknumber(L, 2))); - return 1; -} - - -/* -** next function does not use 'modf', avoiding problems with 'double*' -** (which is not compatible with 'float*') when lua_Number is not -** 'double'. -*/ -static int math_modf (lua_State *L) { - if (lua_isinteger(L ,1)) { - lua_settop(L, 1); /* number is its own integer part */ - lua_pushnumber(L, 0); /* no fractional part */ - } - else { - lua_Number n = luaL_checknumber(L, 1); - /* integer part (rounds toward zero) */ - lua_Number ip = (n < 0) ? l_mathop(ceil)(n) : l_mathop(floor)(n); - pushnumint(L, ip); - /* fractional part (test needed for inf/-inf) */ - lua_pushnumber(L, (n == ip) ? l_mathop(0.0) : (n - ip)); - } - return 2; -} - - -static int math_sqrt (lua_State *L) { - lua_pushnumber(L, l_mathop(sqrt)(luaL_checknumber(L, 1))); - return 1; -} - - -static int math_ult (lua_State *L) { - lua_Integer a = luaL_checkinteger(L, 1); - lua_Integer b = luaL_checkinteger(L, 2); - lua_pushboolean(L, (lua_Unsigned)a < (lua_Unsigned)b); - return 1; -} - -static int math_log (lua_State *L) { - lua_Number x = luaL_checknumber(L, 1); - lua_Number res; - if (lua_isnoneornil(L, 2)) - res = l_mathop(log)(x); - else { - lua_Number base = luaL_checknumber(L, 2); - if (base == 10.0) res = l_mathop(log10)(x); - else res = l_mathop(log)(x)/l_mathop(log)(base); - } - lua_pushnumber(L, res); - return 1; -} - -static int math_exp (lua_State *L) { - lua_pushnumber(L, l_mathop(exp)(luaL_checknumber(L, 1))); - return 1; -} - -static int math_deg (lua_State *L) { - lua_pushnumber(L, luaL_checknumber(L, 1) * (l_mathop(180.0) / PI)); - return 1; -} - -static int math_rad (lua_State *L) { - lua_pushnumber(L, luaL_checknumber(L, 1) * (PI / l_mathop(180.0))); - return 1; -} - - -static int math_min (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - int imin = 1; /* index of current minimum value */ - int i; - luaL_argcheck(L, n >= 1, 1, "value expected"); - for (i = 2; i <= n; i++) { - if (lua_compare(L, i, imin, LUA_OPLT)) - imin = i; - } - lua_pushvalue(L, imin); - return 1; -} - - -static int math_max (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - int imax = 1; /* index of current maximum value */ - int i; - luaL_argcheck(L, n >= 1, 1, "value expected"); - for (i = 2; i <= n; i++) { - if (lua_compare(L, imax, i, LUA_OPLT)) - imax = i; - } - lua_pushvalue(L, imax); - return 1; -} - -/* -** This function uses 'double' (instead of 'lua_Number') to ensure that -** all bits from 'l_rand' can be represented, and that 'RANDMAX + 1.0' -** will keep full precision (ensuring that 'r' is always less than 1.0.) -*/ -static int math_random (lua_State *L) { - lua_Integer low, up; - double r = (double)l_rand() * (1.0 / ((double)L_RANDMAX + 1.0)); - switch (lua_gettop(L)) { /* check number of arguments */ - case 0: { /* no arguments */ - lua_pushnumber(L, (lua_Number)r); /* Number between 0 and 1 */ - return 1; - } - case 1: { /* only upper limit */ - low = 1; - up = luaL_checkinteger(L, 1); - break; - } - case 2: { /* lower and upper limits */ - low = luaL_checkinteger(L, 1); - up = luaL_checkinteger(L, 2); - break; - } - default: return luaL_error(L, "wrong number of arguments"); - } - /* random integer in the interval [low, up] */ - luaL_argcheck(L, low <= up, 1, "interval is empty"); - luaL_argcheck(L, low >= 0 || up <= LUA_MAXINTEGER + low, 1, - "interval too large"); - r *= (double)(up - low) + 1.0; - lua_pushinteger(L, (lua_Integer)r + low); - return 1; -} - - -static int math_randomseed (lua_State *L) { - l_srand((unsigned int)(lua_Integer)luaL_checknumber(L, 1)); - (void)rand(); /* discard first value to avoid undesirable correlations */ - return 0; -} - - -static int math_type (lua_State *L) { - if (lua_type(L, 1) == LUA_TNUMBER) { - if (lua_isinteger(L, 1)) - lua_pushliteral(L, "integer"); - else - lua_pushliteral(L, "float"); - } - else { - luaL_checkany(L, 1); - lua_pushnil(L); - } - return 1; -} - - -/* -** {================================================================== -** Deprecated functions (for compatibility only) -** =================================================================== -*/ -#if defined(LUA_COMPAT_MATHLIB) - -static int math_cosh (lua_State *L) { - lua_pushnumber(L, l_mathop(cosh)(luaL_checknumber(L, 1))); - return 1; -} - -static int math_sinh (lua_State *L) { - lua_pushnumber(L, l_mathop(sinh)(luaL_checknumber(L, 1))); - return 1; -} - -static int math_tanh (lua_State *L) { - lua_pushnumber(L, l_mathop(tanh)(luaL_checknumber(L, 1))); - return 1; -} - -static int math_pow (lua_State *L) { - lua_Number x = luaL_checknumber(L, 1); - lua_Number y = luaL_checknumber(L, 2); - lua_pushnumber(L, l_mathop(pow)(x, y)); - return 1; -} - -static int math_frexp (lua_State *L) { - int e; - lua_pushnumber(L, l_mathop(frexp)(luaL_checknumber(L, 1), &e)); - lua_pushinteger(L, e); - return 2; -} - -static int math_ldexp (lua_State *L) { - lua_Number x = luaL_checknumber(L, 1); - int ep = (int)luaL_checkinteger(L, 2); - lua_pushnumber(L, l_mathop(ldexp)(x, ep)); - return 1; -} - -static int math_log10 (lua_State *L) { - lua_pushnumber(L, l_mathop(log10)(luaL_checknumber(L, 1))); - return 1; -} - -#endif -/* }================================================================== */ - - - -static const luaL_Reg mathlib[] = { - {"abs", math_abs}, - {"acos", math_acos}, - {"asin", math_asin}, - {"atan", math_atan}, - {"ceil", math_ceil}, - {"cos", math_cos}, - {"deg", math_deg}, - {"exp", math_exp}, - {"tointeger", math_toint}, - {"floor", math_floor}, - {"fmod", math_fmod}, - {"ult", math_ult}, - {"log", math_log}, - {"max", math_max}, - {"min", math_min}, - {"modf", math_modf}, - {"rad", math_rad}, - {"random", math_random}, - {"randomseed", math_randomseed}, - {"sin", math_sin}, - {"sqrt", math_sqrt}, - {"tan", math_tan}, - {"type", math_type}, -#if defined(LUA_COMPAT_MATHLIB) - {"atan2", math_atan}, - {"cosh", math_cosh}, - {"sinh", math_sinh}, - {"tanh", math_tanh}, - {"pow", math_pow}, - {"frexp", math_frexp}, - {"ldexp", math_ldexp}, - {"log10", math_log10}, -#endif - /* placeholders */ - {"pi", NULL}, - {"huge", NULL}, - {"maxinteger", NULL}, - {"mininteger", NULL}, - {NULL, NULL} -}; - - -/* -** Open math library -*/ -LUAMOD_API int luaopen_math (lua_State *L) { - luaL_newlib(L, mathlib); - lua_pushnumber(L, PI); - lua_setfield(L, -2, "pi"); - lua_pushnumber(L, (lua_Number)HUGE_VAL); - lua_setfield(L, -2, "huge"); - lua_pushinteger(L, LUA_MAXINTEGER); - lua_setfield(L, -2, "maxinteger"); - lua_pushinteger(L, LUA_MININTEGER); - lua_setfield(L, -2, "mininteger"); - return 1; -} - diff --git a/thirdparty/src/Lua/lmem.cpp b/thirdparty/src/Lua/lmem.cpp deleted file mode 100644 index 4e8892511..000000000 --- a/thirdparty/src/Lua/lmem.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* -** $Id: lmem.c,v 1.89 2014/11/02 19:33:33 roberto Exp $ -** Interface to Memory Manager -** See Copyright Notice in lua.h -*/ - -#define lmem_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <stddef.h> - -#include <Lua/lua.h> - -#include "ldebug.h" -#include "ldo.h" -#include "lgc.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" - - - -/* -** About the realloc function: -** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); -** ('osize' is the old size, 'nsize' is the new size) -** -** * frealloc(ud, NULL, x, s) creates a new block of size 's' (no -** matter 'x'). -** -** * frealloc(ud, p, x, 0) frees the block 'p' -** (in this specific case, frealloc must return NULL); -** particularly, frealloc(ud, NULL, 0, 0) does nothing -** (which is equivalent to free(NULL) in ISO C) -** -** frealloc returns NULL if it cannot create or reallocate the area -** (any reallocation to an equal or smaller size cannot fail!) -*/ - - - -#define MINSIZEARRAY 4 - - -void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, - int limit, const char *what) { - void *newblock; - int newsize; - if (*size >= limit/2) { /* cannot double it? */ - if (*size >= limit) /* cannot grow even a little? */ - luaG_runerror(L, "too many %s (limit is %d)", what, limit); - newsize = limit; /* still have at least one free place */ - } - else { - newsize = (*size)*2; - if (newsize < MINSIZEARRAY) - newsize = MINSIZEARRAY; /* minimum size */ - } - newblock = luaM_reallocv(L, block, *size, newsize, size_elems); - *size = newsize; /* update only when everything else is OK */ - return newblock; -} - - -l_noret luaM_toobig (lua_State *L) { - luaG_runerror(L, "memory allocation error: block too big"); -} - - - -/* -** generic allocation routine. -*/ -void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { - void *newblock; - global_State *g = G(L); - size_t realosize = (block) ? osize : 0; - lua_assert((realosize == 0) == (block == NULL)); -#if defined(HARDMEMTESTS) - if (nsize > realosize && g->gcrunning) - luaC_fullgc(L, 1); /* force a GC whenever possible */ -#endif - newblock = (*g->frealloc)(g->ud, block, osize, nsize); - if (newblock == NULL && nsize > 0) { - api_check( nsize > realosize, - "realloc cannot fail when shrinking a block"); - luaC_fullgc(L, 1); /* try to free some memory... */ - newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ - if (newblock == NULL) - luaD_throw(L, LUA_ERRMEM); - } - lua_assert((nsize == 0) == (newblock == NULL)); - g->GCdebt = (g->GCdebt + nsize) - realosize; - return newblock; -} - diff --git a/thirdparty/src/Lua/lmem.h b/thirdparty/src/Lua/lmem.h deleted file mode 100644 index e44f46380..000000000 --- a/thirdparty/src/Lua/lmem.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -** $Id: lmem.h,v 1.43 2014/12/19 17:26:14 roberto Exp $ -** Interface to Memory Manager -** See Copyright Notice in lua.h -*/ - -#ifndef lmem_h -#define lmem_h - - -#include <stddef.h> - -#include "llimits.h" -#include <Lua/lua.h> - - -/* -** This macro reallocs a vector 'b' from 'on' to 'n' elements, where -** each element has size 'e'. In case of arithmetic overflow of the -** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because -** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e). -** -** (The macro is somewhat complex to avoid warnings: The 'sizeof' -** comparison avoids a runtime comparison when overflow cannot occur. -** The compiler should be able to optimize the real test by itself, but -** when it does it, it may give a warning about "comparison is always -** false due to limited range of data type"; the +1 tricks the compiler, -** avoiding this warning but also this optimization.) -*/ -#define luaM_reallocv(L,b,on,n,e) \ - (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \ - ? luaM_toobig(L) : cast_void(0)) , \ - luaM_realloc_(L, (b), (on)*(e), (n)*(e))) - -/* -** Arrays of chars do not need any test -*/ -#define luaM_reallocvchar(L,b,on,n) \ - cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) - -#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) -#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) -#define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) - -#define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) -#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) -#define luaM_newvector(L,n,t) \ - cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) - -#define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) - -#define luaM_growvector(L,v,nelems,size,t,limit,e) \ - if ((nelems)+1 > (size)) \ - ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) - -#define luaM_reallocvector(L, v,oldn,n,t) \ - ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) - -LUAI_FUNC l_noret luaM_toobig (lua_State *L); - -/* not to be called directly */ -LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, - size_t size); -LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, - size_t size_elem, int limit, - const char *what); - -#endif - diff --git a/thirdparty/src/Lua/loadlib.cpp b/thirdparty/src/Lua/loadlib.cpp deleted file mode 100644 index f5319da42..000000000 --- a/thirdparty/src/Lua/loadlib.cpp +++ /dev/null @@ -1,788 +0,0 @@ -/* -** $Id: loadlib.c,v 1.124 2015/01/05 13:51:39 roberto Exp $ -** Dynamic library loader for Lua -** See Copyright Notice in lua.h -** -** This module contains an implementation of loadlib for Unix systems -** that have dlfcn, an implementation for Windows, and a stub for other -** systems. -*/ - -#define loadlib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include <stdlib.h> -#include <string.h> - -#include <Lua/lua.h> - -#include <Lua/lauxlib.h> -#include <Lua/lualib.h> - - -/* -** LUA_PATH_VAR and LUA_CPATH_VAR are the names of the environment -** variables that Lua check to set its paths. -*/ -#if !defined(LUA_PATH_VAR) -#define LUA_PATH_VAR "LUA_PATH" -#endif - -#if !defined(LUA_CPATH_VAR) -#define LUA_CPATH_VAR "LUA_CPATH" -#endif - -#define LUA_PATHSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR - -#define LUA_PATHVARVERSION LUA_PATH_VAR LUA_PATHSUFFIX -#define LUA_CPATHVARVERSION LUA_CPATH_VAR LUA_PATHSUFFIX - -/* -** LUA_PATH_SEP is the character that separates templates in a path. -** LUA_PATH_MARK is the string that marks the substitution points in a -** template. -** LUA_EXEC_DIR in a Windows path is replaced by the executable's -** directory. -** LUA_IGMARK is a mark to ignore all before it when building the -** luaopen_ function name. -*/ -#if !defined (LUA_PATH_SEP) -#define LUA_PATH_SEP ";" -#endif -#if !defined (LUA_PATH_MARK) -#define LUA_PATH_MARK "?" -#endif -#if !defined (LUA_EXEC_DIR) -#define LUA_EXEC_DIR "!" -#endif -#if !defined (LUA_IGMARK) -#define LUA_IGMARK "-" -#endif - - -/* -** LUA_CSUBSEP is the character that replaces dots in submodule names -** when searching for a C loader. -** LUA_LSUBSEP is the character that replaces dots in submodule names -** when searching for a Lua loader. -*/ -#if !defined(LUA_CSUBSEP) -#define LUA_CSUBSEP LUA_DIRSEP -#endif - -#if !defined(LUA_LSUBSEP) -#define LUA_LSUBSEP LUA_DIRSEP -#endif - - -/* prefix for open functions in C libraries */ -#define LUA_POF "luaopen_" - -/* separator for open functions in C libraries */ -#define LUA_OFSEP "_" - - -/* -** unique key for table in the registry that keeps handles -** for all loaded C libraries -*/ -static const int CLIBS = 0; - -#define LIB_FAIL "open" - -#define setprogdir(L) ((void)0) - - -/* -** system-dependent functions -*/ - -/* -** unload library 'lib' -*/ -static void lsys_unloadlib (void *lib); - -/* -** load C library in file 'path'. If 'seeglb', load with all names in -** the library global. -** Returns the library; in case of error, returns NULL plus an -** error string in the stack. -*/ -static void *lsys_load (lua_State *L, const char *path, int seeglb); - -/* -** Try to find a function named 'sym' in library 'lib'. -** Returns the function; in case of error, returns NULL plus an -** error string in the stack. -*/ -static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym); - - - - -#if defined(LUA_USE_DLOPEN) /* { */ -/* -** {======================================================================== -** This is an implementation of loadlib based on the dlfcn interface. -** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, -** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least -** as an emulation layer on top of native functions. -** ========================================================================= -*/ - -#include <dlfcn.h> - -/* -** Macro to covert pointer to void* to pointer to function. This cast -** is undefined according to ISO C, but POSIX assumes that it must work. -** (The '__extension__' in gnu compilers is only to avoid warnings.) -*/ -#if defined(__GNUC__) -#define cast_func(p) (__extension__ (lua_CFunction)(p)) -#else -#define cast_func(p) ((lua_CFunction)(p)) -#endif - - -static void lsys_unloadlib (void *lib) { - dlclose(lib); -} - - -static void *lsys_load (lua_State *L, const char *path, int seeglb) { - void *lib = dlopen(path, RTLD_NOW | (seeglb ? RTLD_GLOBAL : RTLD_LOCAL)); - if (lib == NULL) lua_pushstring(L, dlerror()); - return lib; -} - - -static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { - lua_CFunction f = cast_func(dlsym(lib, sym)); - if (f == NULL) lua_pushstring(L, dlerror()); - return f; -} - -/* }====================================================== */ - - - -#elif defined(LUA_DL_DLL) /* }{ */ -/* -** {====================================================================== -** This is an implementation of loadlib for Windows using native functions. -** ======================================================================= -*/ - -#define WIN32_LEAN_AND_MEAN - -#include <windows.h> - -#undef setprogdir - -/* -** optional flags for LoadLibraryEx -*/ -#if !defined(LUA_LLE_FLAGS) -#define LUA_LLE_FLAGS 0 -#endif - - -static void setprogdir (lua_State *L) { - char buff[MAX_PATH + 1]; - char *lb; - DWORD nsize = sizeof(buff)/sizeof(char); - DWORD n = GetModuleFileNameA(NULL, buff, nsize); - if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) - luaL_error(L, "unable to get ModuleFileName"); - else { - *lb = '\0'; - luaL_gsub(L, lua_tostring(L, -1), LUA_EXEC_DIR, buff); - lua_remove(L, -2); /* remove original string */ - } -} - - -static void pusherror (lua_State *L) { - int error = GetLastError(); - char buffer[128]; - if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, error, 0, buffer, sizeof(buffer)/sizeof(char), NULL)) - lua_pushstring(L, buffer); - else - lua_pushfstring(L, "system error %d\n", error); -} - -static void lsys_unloadlib (void *lib) { - FreeLibrary((HMODULE)lib); -} - - -static void *lsys_load (lua_State *L, const char *path, int seeglb) { - HMODULE lib = LoadLibraryExA(path, NULL, LUA_LLE_FLAGS); - (void)(seeglb); /* not used: symbols are 'global' by default */ - if (lib == NULL) pusherror(L); - return lib; -} - - -static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { - lua_CFunction f = (lua_CFunction)GetProcAddress((HMODULE)lib, sym); - if (f == NULL) pusherror(L); - return f; -} - -/* }====================================================== */ - - -#else /* }{ */ -/* -** {====================================================== -** Fallback for other systems -** ======================================================= -*/ - -#undef LIB_FAIL -#define LIB_FAIL "absent" - - -#define DLMSG "dynamic libraries not enabled; check your Lua installation" - - -static void lsys_unloadlib (void *lib) { - (void)(lib); /* not used */ -} - - -static void *lsys_load (lua_State *L, const char *path, int seeglb) { - (void)(path); (void)(seeglb); /* not used */ - lua_pushliteral(L, DLMSG); - return NULL; -} - - -static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym) { - (void)(lib); (void)(sym); /* not used */ - lua_pushliteral(L, DLMSG); - return NULL; -} - -/* }====================================================== */ -#endif /* } */ - - -/* -** return registry.CLIBS[path] -*/ -static void *checkclib (lua_State *L, const char *path) { - void *plib; - lua_rawgetp(L, LUA_REGISTRYINDEX, &CLIBS); - lua_getfield(L, -1, path); - plib = lua_touserdata(L, -1); /* plib = CLIBS[path] */ - lua_pop(L, 2); /* pop CLIBS table and 'plib' */ - return plib; -} - - -/* -** registry.CLIBS[path] = plib -- for queries -** registry.CLIBS[#CLIBS + 1] = plib -- also keep a list of all libraries -*/ -static void addtoclib (lua_State *L, const char *path, void *plib) { - lua_rawgetp(L, LUA_REGISTRYINDEX, &CLIBS); - lua_pushlightuserdata(L, plib); - lua_pushvalue(L, -1); - lua_setfield(L, -3, path); /* CLIBS[path] = plib */ - lua_rawseti(L, -2, luaL_len(L, -2) + 1); /* CLIBS[#CLIBS + 1] = plib */ - lua_pop(L, 1); /* pop CLIBS table */ -} - - -/* -** __gc tag method for CLIBS table: calls 'lsys_unloadlib' for all lib -** handles in list CLIBS -*/ -static int gctm (lua_State *L) { - lua_Integer n = luaL_len(L, 1); - for (; n >= 1; n--) { /* for each handle, in reverse order */ - lua_rawgeti(L, 1, n); /* get handle CLIBS[n] */ - lsys_unloadlib(lua_touserdata(L, -1)); - lua_pop(L, 1); /* pop handle */ - } - return 0; -} - - - -/* error codes for 'lookforfunc' */ -#define ERRLIB 1 -#define ERRFUNC 2 - -/* -** Look for a C function named 'sym' in a dynamically loaded library -** 'path'. -** First, check whether the library is already loaded; if not, try -** to load it. -** Then, if 'sym' is '*', return true (as library has been loaded). -** Otherwise, look for symbol 'sym' in the library and push a -** C function with that symbol. -** Return 0 and 'true' or a function in the stack; in case of -** errors, return an error code and an error message in the stack. -*/ -static int lookforfunc (lua_State *L, const char *path, const char *sym) { - void *reg = checkclib(L, path); /* check loaded C libraries */ - if (reg == NULL) { /* must load library? */ - reg = lsys_load(L, path, *sym == '*'); /* global symbols if 'sym'=='*' */ - if (reg == NULL) return ERRLIB; /* unable to load library */ - addtoclib(L, path, reg); - } - if (*sym == '*') { /* loading only library (no function)? */ - lua_pushboolean(L, 1); /* return 'true' */ - return 0; /* no errors */ - } - else { - lua_CFunction f = lsys_sym(L, reg, sym); - if (f == NULL) - return ERRFUNC; /* unable to find function */ - lua_pushcfunction(L, f); /* else create new function */ - return 0; /* no errors */ - } -} - - -static int ll_loadlib (lua_State *L) { - const char *path = luaL_checkstring(L, 1); - const char *init = luaL_checkstring(L, 2); - int stat = lookforfunc(L, path, init); - if (stat == 0) /* no errors? */ - return 1; /* return the loaded function */ - else { /* error; error message is on stack top */ - lua_pushnil(L); - lua_insert(L, -2); - lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); - return 3; /* return nil, error message, and where */ - } -} - - - -/* -** {====================================================== -** 'require' function -** ======================================================= -*/ - - -static int readable (const char *filename) { - FILE *f = fopen(filename, "r"); /* try to open file */ - if (f == NULL) return 0; /* open failed */ - fclose(f); - return 1; -} - - -static const char *pushnexttemplate (lua_State *L, const char *path) { - const char *l; - while (*path == *LUA_PATH_SEP) path++; /* skip separators */ - if (*path == '\0') return NULL; /* no more templates */ - l = strchr(path, *LUA_PATH_SEP); /* find next separator */ - if (l == NULL) l = path + strlen(path); - lua_pushlstring(L, path, l - path); /* template */ - return l; -} - - -static const char *searchpath (lua_State *L, const char *name, - const char *path, - const char *sep, - const char *dirsep) { - luaL_Buffer msg; /* to build error message */ - luaL_buffinit(L, &msg); - if (*sep != '\0') /* non-empty separator? */ - name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */ - while ((path = pushnexttemplate(L, path)) != NULL) { - const char *filename = luaL_gsub(L, lua_tostring(L, -1), - LUA_PATH_MARK, name); - lua_remove(L, -2); /* remove path template */ - if (readable(filename)) /* does file exist and is readable? */ - return filename; /* return that file name */ - lua_pushfstring(L, "\n\tno file '%s'", filename); - lua_remove(L, -2); /* remove file name */ - luaL_addvalue(&msg); /* concatenate error msg. entry */ - } - luaL_pushresult(&msg); /* create error message */ - return NULL; /* not found */ -} - - -static int ll_searchpath (lua_State *L) { - const char *f = searchpath(L, luaL_checkstring(L, 1), - luaL_checkstring(L, 2), - luaL_optstring(L, 3, "."), - luaL_optstring(L, 4, LUA_DIRSEP)); - if (f != NULL) return 1; - else { /* error message is on top of the stack */ - lua_pushnil(L); - lua_insert(L, -2); - return 2; /* return nil + error message */ - } -} - - -static const char *findfile (lua_State *L, const char *name, - const char *pname, - const char *dirsep) { - const char *path; - lua_getfield(L, lua_upvalueindex(1), pname); - path = lua_tostring(L, -1); - if (path == NULL) - luaL_error(L, "'package.%s' must be a string", pname); - return searchpath(L, name, path, ".", dirsep); -} - - -static int checkload (lua_State *L, int stat, const char *filename) { - if (stat) { /* module loaded successfully? */ - lua_pushstring(L, filename); /* will be 2nd argument to module */ - return 2; /* return open function and file name */ - } - else - return luaL_error(L, "error loading module '%s' from file '%s':\n\t%s", - lua_tostring(L, 1), filename, lua_tostring(L, -1)); -} - - -static int searcher_Lua (lua_State *L) { - const char *filename; - const char *name = luaL_checkstring(L, 1); - filename = findfile(L, name, "path", LUA_LSUBSEP); - if (filename == NULL) return 1; /* module not found in this path */ - return checkload(L, (luaL_loadfile(L, filename) == LUA_OK), filename); -} - - -/* -** Try to find a load function for module 'modname' at file 'filename'. -** First, change '.' to '_' in 'modname'; then, if 'modname' has -** the form X-Y (that is, it has an "ignore mark"), build a function -** name "luaopen_X" and look for it. (For compatibility, if that -** fails, it also tries "luaopen_Y".) If there is no ignore mark, -** look for a function named "luaopen_modname". -*/ -static int loadfunc (lua_State *L, const char *filename, const char *modname) { - const char *openfunc; - const char *mark; - modname = luaL_gsub(L, modname, ".", LUA_OFSEP); - mark = strchr(modname, *LUA_IGMARK); - if (mark) { - int stat; - openfunc = lua_pushlstring(L, modname, mark - modname); - openfunc = lua_pushfstring(L, LUA_POF"%s", openfunc); - stat = lookforfunc(L, filename, openfunc); - if (stat != ERRFUNC) return stat; - modname = mark + 1; /* else go ahead and try old-style name */ - } - openfunc = lua_pushfstring(L, LUA_POF"%s", modname); - return lookforfunc(L, filename, openfunc); -} - - -static int searcher_C (lua_State *L) { - const char *name = luaL_checkstring(L, 1); - const char *filename = findfile(L, name, "cpath", LUA_CSUBSEP); - if (filename == NULL) return 1; /* module not found in this path */ - return checkload(L, (loadfunc(L, filename, name) == 0), filename); -} - - -static int searcher_Croot (lua_State *L) { - const char *filename; - const char *name = luaL_checkstring(L, 1); - const char *p = strchr(name, '.'); - int stat; - if (p == NULL) return 0; /* is root */ - lua_pushlstring(L, name, p - name); - filename = findfile(L, lua_tostring(L, -1), "cpath", LUA_CSUBSEP); - if (filename == NULL) return 1; /* root not found */ - if ((stat = loadfunc(L, filename, name)) != 0) { - if (stat != ERRFUNC) - return checkload(L, 0, filename); /* real error */ - else { /* open function not found */ - lua_pushfstring(L, "\n\tno module '%s' in file '%s'", name, filename); - return 1; - } - } - lua_pushstring(L, filename); /* will be 2nd argument to module */ - return 2; -} - - -static int searcher_preload (lua_State *L) { - const char *name = luaL_checkstring(L, 1); - lua_getfield(L, LUA_REGISTRYINDEX, "_PRELOAD"); - if (lua_getfield(L, -1, name) == LUA_TNIL) /* not found? */ - lua_pushfstring(L, "\n\tno field package.preload['%s']", name); - return 1; -} - - -static void findloader (lua_State *L, const char *name) { - int i; - luaL_Buffer msg; /* to build error message */ - luaL_buffinit(L, &msg); - /* push 'package.searchers' to index 3 in the stack */ - if (lua_getfield(L, lua_upvalueindex(1), "searchers") != LUA_TTABLE) - luaL_error(L, "'package.searchers' must be a table"); - /* iterate over available searchers to find a loader */ - for (i = 1; ; i++) { - if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */ - lua_pop(L, 1); /* remove nil */ - luaL_pushresult(&msg); /* create error message */ - luaL_error(L, "module '%s' not found:%s", name, lua_tostring(L, -1)); - } - lua_pushstring(L, name); - lua_call(L, 1, 2); /* call it */ - if (lua_isfunction(L, -2)) /* did it find a loader? */ - return; /* module loader found */ - else if (lua_isstring(L, -2)) { /* searcher returned error message? */ - lua_pop(L, 1); /* remove extra return */ - luaL_addvalue(&msg); /* concatenate error message */ - } - else - lua_pop(L, 2); /* remove both returns */ - } -} - - -static int ll_require (lua_State *L) { - const char *name = luaL_checkstring(L, 1); - lua_settop(L, 1); /* _LOADED table will be at index 2 */ - lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_getfield(L, 2, name); /* _LOADED[name] */ - if (lua_toboolean(L, -1)) /* is it there? */ - return 1; /* package is already loaded */ - /* else must load package */ - lua_pop(L, 1); /* remove 'getfield' result */ - findloader(L, name); - lua_pushstring(L, name); /* pass name as argument to module loader */ - lua_insert(L, -2); /* name is 1st argument (before search data) */ - lua_call(L, 2, 1); /* run loader to load module */ - if (!lua_isnil(L, -1)) /* non-nil return? */ - lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ - if (lua_getfield(L, 2, name) == LUA_TNIL) { /* module set no value? */ - lua_pushboolean(L, 1); /* use true as result */ - lua_pushvalue(L, -1); /* extra copy to be returned */ - lua_setfield(L, 2, name); /* _LOADED[name] = true */ - } - return 1; -} - -/* }====================================================== */ - - - -/* -** {====================================================== -** 'module' function -** ======================================================= -*/ -#if defined(LUA_COMPAT_MODULE) - -/* -** changes the environment variable of calling function -*/ -static void set_env (lua_State *L) { - lua_Debug ar; - if (lua_getstack(L, 1, &ar) == 0 || - lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ - lua_iscfunction(L, -1)) - luaL_error(L, "'module' not called from a Lua function"); - lua_pushvalue(L, -2); /* copy new environment table to top */ - lua_setupvalue(L, -2, 1); - lua_pop(L, 1); /* remove function */ -} - - -static void dooptions (lua_State *L, int n) { - int i; - for (i = 2; i <= n; i++) { - if (lua_isfunction(L, i)) { /* avoid 'calling' extra info. */ - lua_pushvalue(L, i); /* get option (a function) */ - lua_pushvalue(L, -2); /* module */ - lua_call(L, 1, 0); - } - } -} - - -static void modinit (lua_State *L, const char *modname) { - const char *dot; - lua_pushvalue(L, -1); - lua_setfield(L, -2, "_M"); /* module._M = module */ - lua_pushstring(L, modname); - lua_setfield(L, -2, "_NAME"); - dot = strrchr(modname, '.'); /* look for last dot in module name */ - if (dot == NULL) dot = modname; - else dot++; - /* set _PACKAGE as package name (full module name minus last part) */ - lua_pushlstring(L, modname, dot - modname); - lua_setfield(L, -2, "_PACKAGE"); -} - - -static int ll_module (lua_State *L) { - const char *modname = luaL_checkstring(L, 1); - int lastarg = lua_gettop(L); /* last parameter */ - luaL_pushmodule(L, modname, 1); /* get/create module table */ - /* check whether table already has a _NAME field */ - if (lua_getfield(L, -1, "_NAME") != LUA_TNIL) - lua_pop(L, 1); /* table is an initialized module */ - else { /* no; initialize it */ - lua_pop(L, 1); - modinit(L, modname); - } - lua_pushvalue(L, -1); - set_env(L); - dooptions(L, lastarg); - return 1; -} - - -static int ll_seeall (lua_State *L) { - luaL_checktype(L, 1, LUA_TTABLE); - if (!lua_getmetatable(L, 1)) { - lua_createtable(L, 0, 1); /* create new metatable */ - lua_pushvalue(L, -1); - lua_setmetatable(L, 1); - } - lua_pushglobaltable(L); - lua_setfield(L, -2, "__index"); /* mt.__index = _G */ - return 0; -} - -#endif -/* }====================================================== */ - - - -/* auxiliary mark (for internal use) */ -#define AUXMARK "\1" - - -/* -** return registry.LUA_NOENV as a boolean -*/ -static int noenv (lua_State *L) { - int b; - lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); - b = lua_toboolean(L, -1); - lua_pop(L, 1); /* remove value */ - return b; -} - - -static void setpath (lua_State *L, const char *fieldname, const char *envname1, - const char *envname2, const char *def) { - const char *path = getenv(envname1); - if (path == NULL) /* no environment variable? */ - path = getenv(envname2); /* try alternative name */ - if (path == NULL || noenv(L)) /* no environment variable? */ - lua_pushstring(L, def); /* use default */ - else { - /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ - path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP, - LUA_PATH_SEP AUXMARK LUA_PATH_SEP); - luaL_gsub(L, path, AUXMARK, def); - lua_remove(L, -2); - } - setprogdir(L); - lua_setfield(L, -2, fieldname); -} - - -static const luaL_Reg pk_funcs[] = { - {"loadlib", ll_loadlib}, - {"searchpath", ll_searchpath}, -#if defined(LUA_COMPAT_MODULE) - {"seeall", ll_seeall}, -#endif - /* placeholders */ - {"preload", NULL}, - {"cpath", NULL}, - {"path", NULL}, - {"searchers", NULL}, - {"loaded", NULL}, - {NULL, NULL} -}; - - -static const luaL_Reg ll_funcs[] = { -#if defined(LUA_COMPAT_MODULE) - {"module", ll_module}, -#endif - {"require", ll_require}, - {NULL, NULL} -}; - - -static void createsearcherstable (lua_State *L) { - static const lua_CFunction searchers[] = - {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL}; - int i; - /* create 'searchers' table */ - lua_createtable(L, sizeof(searchers)/sizeof(searchers[0]) - 1, 0); - /* fill it with pre-defined searchers */ - for (i=0; searchers[i] != NULL; i++) { - lua_pushvalue(L, -2); /* set 'package' as upvalue for all searchers */ - lua_pushcclosure(L, searchers[i], 1); - lua_rawseti(L, -2, i+1); - } -#if defined(LUA_COMPAT_LOADERS) - lua_pushvalue(L, -1); /* make a copy of 'searchers' table */ - lua_setfield(L, -3, "loaders"); /* put it in field 'loaders' */ -#endif - lua_setfield(L, -2, "searchers"); /* put it in field 'searchers' */ -} - - -/* -** create table CLIBS to keep track of loaded C libraries, -** setting a finalizer to close all libraries when closing state. -*/ -static void createclibstable (lua_State *L) { - lua_newtable(L); /* create CLIBS table */ - lua_createtable(L, 0, 1); /* create metatable for CLIBS */ - lua_pushcfunction(L, gctm); - lua_setfield(L, -2, "__gc"); /* set finalizer for CLIBS table */ - lua_setmetatable(L, -2); - lua_rawsetp(L, LUA_REGISTRYINDEX, &CLIBS); /* set CLIBS table in registry */ -} - - -LUAMOD_API int luaopen_package (lua_State *L) { - createclibstable(L); - luaL_newlib(L, pk_funcs); /* create 'package' table */ - createsearcherstable(L); - /* set field 'path' */ - setpath(L, "path", LUA_PATHVARVERSION, LUA_PATH_VAR, LUA_PATH_DEFAULT); - /* set field 'cpath' */ - setpath(L, "cpath", LUA_CPATHVARVERSION, LUA_CPATH_VAR, LUA_CPATH_DEFAULT); - /* store config information */ - lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n" - LUA_EXEC_DIR "\n" LUA_IGMARK "\n"); - lua_setfield(L, -2, "config"); - /* set field 'loaded' */ - luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED"); - lua_setfield(L, -2, "loaded"); - /* set field 'preload' */ - luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); - lua_setfield(L, -2, "preload"); - lua_pushglobaltable(L); - lua_pushvalue(L, -2); /* set 'package' as upvalue for next lib */ - luaL_setfuncs(L, ll_funcs, 1); /* open lib into global table */ - lua_pop(L, 1); /* pop global table */ - return 1; /* return 'package' table */ -} - diff --git a/thirdparty/src/Lua/lobject.cpp b/thirdparty/src/Lua/lobject.cpp deleted file mode 100644 index f4f2ffd1e..000000000 --- a/thirdparty/src/Lua/lobject.cpp +++ /dev/null @@ -1,470 +0,0 @@ -/* -** $Id: lobject.c,v 2.101 2014/12/26 14:43:45 roberto Exp $ -** Some generic functions over Lua objects -** See Copyright Notice in lua.h -*/ - -#define lobject_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <Lua/lua.h> - -#include "lctype.h" -#include "ldebug.h" -#include "ldo.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" -#include "lstring.h" -#include "lvm.h" - - - -LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT}; - - -/* -** converts an integer to a "floating point byte", represented as -** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if -** eeeee != 0 and (xxx) otherwise. -*/ -int luaO_int2fb (unsigned int x) { - int e = 0; /* exponent */ - if (x < 8) return x; - while (x >= 0x10) { - x = (x+1) >> 1; - e++; - } - return ((e+1) << 3) | (cast_int(x) - 8); -} - - -/* converts back */ -int luaO_fb2int (int x) { - int e = (x >> 3) & 0x1f; - if (e == 0) return x; - else return ((x & 7) + 8) << (e - 1); -} - - -int luaO_ceillog2 (unsigned int x) { - static const lu_byte log_2[256] = { - 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 - }; - int l = 0; - x--; - while (x >= 256) { l += 8; x >>= 8; } - return l + log_2[x]; -} - - -static lua_Integer intarith (lua_State *L, int op, lua_Integer v1, - lua_Integer v2) { - switch (op) { - case LUA_OPADD: return intop(+, v1, v2); - case LUA_OPSUB:return intop(-, v1, v2); - case LUA_OPMUL:return intop(*, v1, v2); - case LUA_OPMOD: return luaV_mod(L, v1, v2); - case LUA_OPIDIV: return luaV_div(L, v1, v2); - case LUA_OPBAND: return intop(&, v1, v2); - case LUA_OPBOR: return intop(|, v1, v2); - case LUA_OPBXOR: return intop(^, v1, v2); - case LUA_OPSHL: return luaV_shiftl(v1, v2); - case LUA_OPSHR: return luaV_shiftl(v1, -v2); - case LUA_OPUNM: return intop(-, 0, v1); - case LUA_OPBNOT: return intop(^, ~l_castS2U(0), v1); - default: lua_assert(0); return 0; - } -} - - -static lua_Number numarith (lua_State *L, int op, lua_Number v1, - lua_Number v2) { - switch (op) { - case LUA_OPADD: return luai_numadd(L, v1, v2); - case LUA_OPSUB: return luai_numsub(L, v1, v2); - case LUA_OPMUL: return luai_nummul(L, v1, v2); - case LUA_OPDIV: return luai_numdiv(L, v1, v2); - case LUA_OPPOW: return luai_numpow(L, v1, v2); - case LUA_OPIDIV: return luai_numidiv(L, v1, v2); - case LUA_OPUNM: return luai_numunm(L, v1); - case LUA_OPMOD: { - lua_Number m; - luai_nummod(L, v1, v2, m); - return m; - } - default: lua_assert(0); return 0; - } -} - - -void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2, - TValue *res) { - switch (op) { - case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: - case LUA_OPSHL: case LUA_OPSHR: - case LUA_OPBNOT: { /* operate only on integers */ - lua_Integer i1; lua_Integer i2; - if (tointeger(p1, &i1) && tointeger(p2, &i2)) { - setivalue(res, intarith(L, op, i1, i2)); - return; - } - else break; /* go to the end */ - } - case LUA_OPDIV: case LUA_OPPOW: { /* operate only on floats */ - lua_Number n1; lua_Number n2; - if (tonumber(p1, &n1) && tonumber(p2, &n2)) { - setfltvalue(res, numarith(L, op, n1, n2)); - return; - } - else break; /* go to the end */ - } - default: { /* other operations */ - lua_Number n1; lua_Number n2; - if (ttisinteger(p1) && ttisinteger(p2)) { - setivalue(res, intarith(L, op, ivalue(p1), ivalue(p2))); - return; - } - else if (tonumber(p1, &n1) && tonumber(p2, &n2)) { - setfltvalue(res, numarith(L, op, n1, n2)); - return; - } - else break; /* go to the end */ - } - } - /* could not perform raw operation; try metamethod */ - lua_assert(L != NULL); /* should not fail when folding (compile time) */ - luaT_trybinTM(L, p1, p2, res, cast(TMS, op - LUA_OPADD + TM_ADD)); -} - - -int luaO_hexavalue (int c) { - if (lisdigit(c)) return c - '0'; - else return ltolower(c) - 'a' + 10; -} - - -static int isneg (const char **s) { - if (**s == '-') { (*s)++; return 1; } - else if (**s == '+') (*s)++; - return 0; -} - - - -/* -** {================================================================== -** Lua's implementation for 'lua_strx2number' -** =================================================================== -*/ -#if !defined(lua_strx2number) - -#include <math.h> - -/* maximum number of significant digits to read (to avoid overflows - even with single floats) */ -#define MAXSIGDIG 30 - -/* -** convert an hexadecimal numeric string to a number, following -** C99 specification for 'strtod' -*/ -static lua_Number lua_strx2number (const char *s, char **endptr) { - lua_Number r = 0.0; /* result (accumulator) */ - int sigdig = 0; /* number of significant digits */ - int nosigdig = 0; /* number of non-significant digits */ - int e = 0; /* exponent correction */ - int neg; /* 1 if number is negative */ - int dot = 0; /* true after seen a dot */ - *endptr = cast(char *, s); /* nothing is valid yet */ - while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ - neg = isneg(&s); /* check signal */ - if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */ - return 0.0; /* invalid format (no '0x') */ - for (s += 2; ; s++) { /* skip '0x' and read numeral */ - if (*s == '.') { - if (dot) break; /* second dot? stop loop */ - else dot = 1; - } - else if (lisxdigit(cast_uchar(*s))) { - if (sigdig == 0 && *s == '0') /* non-significant digit (zero)? */ - nosigdig++; - else if (++sigdig <= MAXSIGDIG) /* can read it without overflow? */ - r = (r * cast_num(16.0)) + luaO_hexavalue(*s); - else e++; /* too many digits; ignore, but still count for exponent */ - if (dot) e--; /* decimal digit? correct exponent */ - } - else break; /* neither a dot nor a digit */ - } - if (nosigdig + sigdig == 0) /* no digits? */ - return 0.0; /* invalid format */ - *endptr = cast(char *, s); /* valid up to here */ - e *= 4; /* each digit multiplies/divides value by 2^4 */ - if (*s == 'p' || *s == 'P') { /* exponent part? */ - int exp1 = 0; /* exponent value */ - int neg1; /* exponent signal */ - s++; /* skip 'p' */ - neg1 = isneg(&s); /* signal */ - if (!lisdigit(cast_uchar(*s))) - return 0.0; /* invalid; must have at least one digit */ - while (lisdigit(cast_uchar(*s))) /* read exponent */ - exp1 = exp1 * 10 + *(s++) - '0'; - if (neg1) exp1 = -exp1; - e += exp1; - *endptr = cast(char *, s); /* valid up to here */ - } - if (neg) r = -r; - return l_mathop(ldexp)(r, e); -} - -#endif -/* }====================================================== */ - - -static const char *l_str2d (const char *s, lua_Number *result) { - char *endptr; - if (strpbrk(s, "nN")) /* reject 'inf' and 'nan' */ - return NULL; - else if (strpbrk(s, "xX")) /* hex? */ - *result = lua_strx2number(s, &endptr); - else - *result = lua_str2number(s, &endptr); - if (endptr == s) return 0; /* nothing recognized */ - while (lisspace(cast_uchar(*endptr))) endptr++; - return (*endptr == '\0' ? endptr : NULL); /* OK if no trailing characters */ -} - - -static const char *l_str2int (const char *s, lua_Integer *result) { - lua_Unsigned a = 0; - int empty = 1; - int neg; - while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ - neg = isneg(&s); - if (s[0] == '0' && - (s[1] == 'x' || s[1] == 'X')) { /* hex? */ - s += 2; /* skip '0x' */ - for (; lisxdigit(cast_uchar(*s)); s++) { - a = a * 16 + luaO_hexavalue(*s); - empty = 0; - } - } - else { /* decimal */ - for (; lisdigit(cast_uchar(*s)); s++) { - a = a * 10 + *s - '0'; - empty = 0; - } - } - while (lisspace(cast_uchar(*s))) s++; /* skip trailing spaces */ - if (empty || *s != '\0') return NULL; /* something wrong in the numeral */ - else { - *result = l_castU2S((neg) ? 0u - a : a); - return s; - } -} - - -size_t luaO_str2num (const char *s, TValue *o) { - lua_Integer i; lua_Number n; - const char *e; - if ((e = l_str2int(s, &i)) != NULL) { /* try as an integer */ - setivalue(o, i); - } - else if ((e = l_str2d(s, &n)) != NULL) { /* else try as a float */ - setfltvalue(o, n); - } - else - return 0; /* conversion failed */ - return (e - s + 1); /* success; return string size */ -} - - -int luaO_utf8esc (char *buff, unsigned long x) { - int n = 1; /* number of bytes put in buffer (backwards) */ - lua_assert(x <= 0x10FFFF); - if (x < 0x80) /* ascii? */ - buff[UTF8BUFFSZ - 1] = cast(char, x); - else { /* need continuation bytes */ - unsigned int mfb = 0x3f; /* maximum that fits in first byte */ - do { /* add continuation bytes */ - buff[UTF8BUFFSZ - (n++)] = cast(char, 0x80 | (x & 0x3f)); - x >>= 6; /* remove added bits */ - mfb >>= 1; /* now there is one less bit available in first byte */ - } while (x > mfb); /* still needs continuation byte? */ - buff[UTF8BUFFSZ - n] = cast(char, (~mfb << 1) | x); /* add first byte */ - } - return n; -} - - -/* maximum length of the conversion of a number to a string */ -#define MAXNUMBER2STR 50 - - -/* -** Convert a number object to a string -*/ -void luaO_tostring (lua_State *L, StkId obj) { - char buff[MAXNUMBER2STR]; - size_t len; - lua_assert(ttisnumber(obj)); - if (ttisinteger(obj)) - len = lua_integer2str(buff, ivalue(obj)); - else { - len = lua_number2str(buff, fltvalue(obj)); -#if !defined(LUA_COMPAT_FLOATSTRING) - if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */ - buff[len++] = '.'; - buff[len++] = '0'; /* adds '.0' to result */ - } -#endif - } - setsvalue2s(L, obj, luaS_newlstr(L, buff, len)); -} - - -static void pushstr (lua_State *L, const char *str, size_t l) { - setsvalue2s(L, L->top++, luaS_newlstr(L, str, l)); -} - - -/* this function handles only '%d', '%c', '%f', '%p', and '%s' - conventional formats, plus Lua-specific '%I' and '%U' */ -const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { - int n = 0; - for (;;) { - const char *e = strchr(fmt, '%'); - if (e == NULL) break; - luaD_checkstack(L, 2); /* fmt + item */ - pushstr(L, fmt, e - fmt); - switch (*(e+1)) { - case 's': { - const char *s = va_arg(argp, char *); - if (s == NULL) s = "(null)"; - pushstr(L, s, strlen(s)); - break; - } - case 'c': { - char buff = cast(char, va_arg(argp, int)); - if (lisprint(cast_uchar(buff))) - pushstr(L, &buff, 1); - else /* non-printable character; print its code */ - luaO_pushfstring(L, "<\\%d>", cast_uchar(buff)); - break; - } - case 'd': { - setivalue(L->top++, va_arg(argp, int)); - luaO_tostring(L, L->top - 1); - break; - } - case 'I': { - setivalue(L->top++, cast(lua_Integer, va_arg(argp, l_uacInt))); - luaO_tostring(L, L->top - 1); - break; - } - case 'f': { - setfltvalue(L->top++, cast_num(va_arg(argp, l_uacNumber))); - luaO_tostring(L, L->top - 1); - break; - } - case 'p': { - char buff[4*sizeof(void *) + 8]; /* should be enough space for a '%p' */ - int l = sprintf(buff, "%p", va_arg(argp, void *)); - pushstr(L, buff, l); - break; - } - case 'U': { - char buff[UTF8BUFFSZ]; - int l = luaO_utf8esc(buff, cast(long, va_arg(argp, long))); - pushstr(L, buff + UTF8BUFFSZ - l, l); - break; - } - case '%': { - pushstr(L, "%", 1); - break; - } - default: { - luaG_runerror(L, "invalid option '%%%c' to 'lua_pushfstring'", - *(e + 1)); - } - } - n += 2; - fmt = e+2; - } - luaD_checkstack(L, 1); - pushstr(L, fmt, strlen(fmt)); - if (n > 0) luaV_concat(L, n + 1); - return svalue(L->top - 1); -} - - -const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { - const char *msg; - va_list argp; - va_start(argp, fmt); - msg = luaO_pushvfstring(L, fmt, argp); - va_end(argp); - return msg; -} - - -/* number of chars of a literal string without the ending \0 */ -#define LL(x) (sizeof(x)/sizeof(char) - 1) - -#define RETS "..." -#define PRE "[string \"" -#define POS "\"]" - -#define addstr(a,b,l) ( memcpy(a,b,(l) * sizeof(char)), a += (l) ) - -void luaO_chunkid (char *out, const char *source, size_t bufflen) { - size_t l = strlen(source); - if (*source == '=') { /* 'literal' source */ - if (l <= bufflen) /* small enough? */ - memcpy(out, source + 1, l * sizeof(char)); - else { /* truncate it */ - addstr(out, source + 1, bufflen - 1); - *out = '\0'; - } - } - else if (*source == '@') { /* file name */ - if (l <= bufflen) /* small enough? */ - memcpy(out, source + 1, l * sizeof(char)); - else { /* add '...' before rest of name */ - addstr(out, RETS, LL(RETS)); - bufflen -= LL(RETS); - memcpy(out, source + 1 + l - bufflen, bufflen * sizeof(char)); - } - } - else { /* string; format as [string "source"] */ - const char *nl = strchr(source, '\n'); /* find first new line (if any) */ - addstr(out, PRE, LL(PRE)); /* add prefix */ - bufflen -= LL(PRE RETS POS) + 1; /* save space for prefix+suffix+'\0' */ - if (l < bufflen && nl == NULL) { /* small one-line source? */ - addstr(out, source, l); /* keep it */ - } - else { - if (nl != NULL) l = nl - source; /* stop at first newline */ - if (l > bufflen) l = bufflen; - addstr(out, source, l); - addstr(out, RETS, LL(RETS)); - } - memcpy(out, POS, (LL(POS) + 1) * sizeof(char)); - } -} - diff --git a/thirdparty/src/Lua/lobject.h b/thirdparty/src/Lua/lobject.h deleted file mode 100644 index b4502a317..000000000 --- a/thirdparty/src/Lua/lobject.h +++ /dev/null @@ -1,540 +0,0 @@ -/* -** $Id: lobject.h,v 2.106 2015/01/05 13:52:37 roberto Exp $ -** Type definitions for Lua objects -** See Copyright Notice in lua.h -*/ - - -#ifndef lobject_h -#define lobject_h - - -#include <stdarg.h> - - -#include "llimits.h" -#include <Lua/lua.h> - - -/* -** Extra tags for non-values -*/ -#define LUA_TPROTO LUA_NUMTAGS -#define LUA_TDEADKEY (LUA_NUMTAGS+1) - -/* -** number of all possible tags (including LUA_TNONE but excluding DEADKEY) -*/ -#define LUA_TOTALTAGS (LUA_TPROTO + 2) - - -/* -** tags for Tagged Values have the following use of bits: -** bits 0-3: actual tag (a LUA_T* value) -** bits 4-5: variant bits -** bit 6: whether value is collectable -*/ - -#define VARBITS (3 << 4) - - -/* -** LUA_TFUNCTION variants: -** 0 - Lua function -** 1 - light C function -** 2 - regular C function (closure) -*/ - -/* Variant tags for functions */ -#define LUA_TLCL (LUA_TFUNCTION | (0 << 4)) /* Lua closure */ -#define LUA_TLCF (LUA_TFUNCTION | (1 << 4)) /* light C function */ -#define LUA_TCCL (LUA_TFUNCTION | (2 << 4)) /* C closure */ - - -/* Variant tags for strings */ -#define LUA_TSHRSTR (LUA_TSTRING | (0 << 4)) /* short strings */ -#define LUA_TLNGSTR (LUA_TSTRING | (1 << 4)) /* long strings */ - - -/* Variant tags for numbers */ -#define LUA_TNUMFLT (LUA_TNUMBER | (0 << 4)) /* float numbers */ -#define LUA_TNUMINT (LUA_TNUMBER | (1 << 4)) /* integer numbers */ - - -/* Bit mark for collectable types */ -#define BIT_ISCOLLECTABLE (1 << 6) - -/* mark a tag as collectable */ -#define ctb(t) ((t) | BIT_ISCOLLECTABLE) - - -/* -** Common type for all collectable objects -*/ -typedef struct GCObject GCObject; - - -/* -** Common Header for all collectable objects (in macro form, to be -** included in other objects) -*/ -#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked - - -/* -** Common type has only the common header -*/ -struct GCObject { - CommonHeader; -}; - - - -/* -** Union of all Lua values -*/ -typedef union Value Value; - - - - -/* -** Tagged Values. This is the basic representation of values in Lua, -** an actual value plus a tag with its type. -*/ - -#define TValuefields Value value_; int tt_ - -typedef struct lua_TValue TValue; - - -/* macro defining a nil value */ -#define NILCONSTANT {NULL}, LUA_TNIL - - -#define val_(o) ((o)->value_) - - -/* raw type tag of a TValue */ -#define rttype(o) ((o)->tt_) - -/* tag with no variants (bits 0-3) */ -#define novariant(x) ((x) & 0x0F) - -/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */ -#define ttype(o) (rttype(o) & 0x3F) - -/* type tag of a TValue with no variants (bits 0-3) */ -#define ttnov(o) (novariant(rttype(o))) - - -/* Macros to test type */ -#define checktag(o,t) (rttype(o) == (t)) -#define checktype(o,t) (ttnov(o) == (t)) -#define ttisnumber(o) checktype((o), LUA_TNUMBER) -#define ttisfloat(o) checktag((o), LUA_TNUMFLT) -#define ttisinteger(o) checktag((o), LUA_TNUMINT) -#define ttisnil(o) checktag((o), LUA_TNIL) -#define ttisboolean(o) checktag((o), LUA_TBOOLEAN) -#define ttislightuserdata(o) checktag((o), LUA_TLIGHTUSERDATA) -#define ttisstring(o) checktype((o), LUA_TSTRING) -#define ttisshrstring(o) checktag((o), ctb(LUA_TSHRSTR)) -#define ttislngstring(o) checktag((o), ctb(LUA_TLNGSTR)) -#define ttistable(o) checktag((o), ctb(LUA_TTABLE)) -#define ttisfunction(o) checktype(o, LUA_TFUNCTION) -#define ttisclosure(o) ((rttype(o) & 0x1F) == LUA_TFUNCTION) -#define ttisCclosure(o) checktag((o), ctb(LUA_TCCL)) -#define ttisLclosure(o) checktag((o), ctb(LUA_TLCL)) -#define ttislcf(o) checktag((o), LUA_TLCF) -#define ttisfulluserdata(o) checktag((o), ctb(LUA_TUSERDATA)) -#define ttisthread(o) checktag((o), ctb(LUA_TTHREAD)) -#define ttisdeadkey(o) checktag((o), LUA_TDEADKEY) - - -/* Macros to access values */ -#define ivalue(o) check_exp(ttisinteger(o), val_(o).i) -#define fltvalue(o) check_exp(ttisfloat(o), val_(o).n) -#define nvalue(o) check_exp(ttisnumber(o), \ - (ttisinteger(o) ? cast_num(ivalue(o)) : fltvalue(o))) -#define gcvalue(o) check_exp(iscollectable(o), val_(o).gc) -#define pvalue(o) check_exp(ttislightuserdata(o), val_(o).p) -#define tsvalue(o) check_exp(ttisstring(o), gco2ts(val_(o).gc)) -#define uvalue(o) check_exp(ttisfulluserdata(o), gco2u(val_(o).gc)) -#define clvalue(o) check_exp(ttisclosure(o), gco2cl(val_(o).gc)) -#define clLvalue(o) check_exp(ttisLclosure(o), gco2lcl(val_(o).gc)) -#define clCvalue(o) check_exp(ttisCclosure(o), gco2ccl(val_(o).gc)) -#define fvalue(o) check_exp(ttislcf(o), val_(o).f) -#define hvalue(o) check_exp(ttistable(o), gco2t(val_(o).gc)) -#define bvalue(o) check_exp(ttisboolean(o), val_(o).b) -#define thvalue(o) check_exp(ttisthread(o), gco2th(val_(o).gc)) -/* a dead value may get the 'gc' field, but cannot access its contents */ -#define deadvalue(o) check_exp(ttisdeadkey(o), cast(void *, val_(o).gc)) - -#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) - - -#define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE) - - -/* Macros for internal tests */ -#define righttt(obj) (ttype(obj) == gcvalue(obj)->tt) - -#define checkliveness(g,obj) \ - lua_longassert(!iscollectable(obj) || \ - (righttt(obj) && !isdead(g,gcvalue(obj)))) - - -/* Macros to set values */ -#define settt_(o,t) ((o)->tt_=(t)) - -#define setfltvalue(obj,x) \ - { TValue *io=(obj); val_(io).n=(x); settt_(io, LUA_TNUMFLT); } - -#define setivalue(obj,x) \ - { TValue *io=(obj); val_(io).i=(x); settt_(io, LUA_TNUMINT); } - -#define setnilvalue(obj) settt_(obj, LUA_TNIL) - -#define setfvalue(obj,x) \ - { TValue *io=(obj); val_(io).f=(x); settt_(io, LUA_TLCF); } - -#define setpvalue(obj,x) \ - { TValue *io=(obj); val_(io).p=(x); settt_(io, LUA_TLIGHTUSERDATA); } - -#define setbvalue(obj,x) \ - { TValue *io=(obj); val_(io).b=(x); settt_(io, LUA_TBOOLEAN); } - -#define setgcovalue(L,obj,x) \ - { TValue *io = (obj); GCObject *i_g=(x); \ - val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); } - -#define setsvalue(L,obj,x) \ - { TValue *io = (obj); TString *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(x_->tt)); \ - checkliveness(G(L),io); } - -#define setuvalue(L,obj,x) \ - { TValue *io = (obj); Udata *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TUSERDATA)); \ - checkliveness(G(L),io); } - -#define setthvalue(L,obj,x) \ - { TValue *io = (obj); lua_State *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTHREAD)); \ - checkliveness(G(L),io); } - -#define setclLvalue(L,obj,x) \ - { TValue *io = (obj); LClosure *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TLCL)); \ - checkliveness(G(L),io); } - -#define setclCvalue(L,obj,x) \ - { TValue *io = (obj); CClosure *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TCCL)); \ - checkliveness(G(L),io); } - -#define sethvalue(L,obj,x) \ - { TValue *io = (obj); Table *x_ = (x); \ - val_(io).gc = obj2gco(x_); settt_(io, ctb(LUA_TTABLE)); \ - checkliveness(G(L),io); } - -#define setdeadvalue(obj) settt_(obj, LUA_TDEADKEY) - - - -#define setobj(L,obj1,obj2) \ - { TValue *io1=(obj1); *io1 = *(obj2); \ - (void)L; checkliveness(G(L),io1); } - - -/* -** different types of assignments, according to destination -*/ - -/* from stack to (same) stack */ -#define setobjs2s setobj -/* to stack (not from same stack) */ -#define setobj2s setobj -#define setsvalue2s setsvalue -#define sethvalue2s sethvalue -#define setptvalue2s setptvalue -/* from table to same table */ -#define setobjt2t setobj -/* to table */ -#define setobj2t setobj -/* to new object */ -#define setobj2n setobj -#define setsvalue2n setsvalue - - - - -/* -** {====================================================== -** types and prototypes -** ======================================================= -*/ - - -union Value { - GCObject *gc; /* collectable objects */ - void *p; /* light userdata */ - int b; /* booleans */ - lua_CFunction f; /* light C functions */ - lua_Integer i; /* integer numbers */ - lua_Number n; /* float numbers */ -}; - - -struct lua_TValue { - TValuefields; -}; - - -typedef TValue *StkId; /* index to stack elements */ - - - - -/* -** Header for string value; string bytes follow the end of this structure -** (aligned according to 'UTString'; see next). -*/ -typedef struct TString { - CommonHeader; - lu_byte extra; /* reserved words for short strings; "has hash" for longs */ - unsigned int hash; - size_t len; /* number of characters in string */ - struct TString *hnext; /* linked list for hash table */ -} TString; - - -/* -** Ensures that address after this type is always fully aligned. -*/ -typedef union UTString { - L_Umaxalign dummy; /* ensures maximum alignment for strings */ - TString tsv; -} UTString; - - -/* -** Get the actual string (array of bytes) from a 'TString'. -** (Access to 'extra' ensures that value is really a 'TString'.) -*/ -#define getaddrstr(ts) (cast(char *, (ts)) + sizeof(UTString)) -#define getstr(ts) \ - check_exp(sizeof((ts)->extra), cast(const char*, getaddrstr(ts))) - -/* get the actual string (array of bytes) from a Lua value */ -#define svalue(o) getstr(tsvalue(o)) - - -/* -** Header for userdata; memory area follows the end of this structure -** (aligned according to 'UUdata'; see next). -*/ -typedef struct Udata { - CommonHeader; - lu_byte ttuv_; /* user value's tag */ - struct Table *metatable; - size_t len; /* number of bytes */ - union Value user_; /* user value */ -} Udata; - - -/* -** Ensures that address after this type is always fully aligned. -*/ -typedef union UUdata { - L_Umaxalign dummy; /* ensures maximum alignment for 'local' udata */ - Udata uv; -} UUdata; - - -/* -** Get the address of memory block inside 'Udata'. -** (Access to 'ttuv_' ensures that value is really a 'Udata'.) -*/ -#define getudatamem(u) \ - check_exp(sizeof((u)->ttuv_), (cast(char*, (u)) + sizeof(UUdata))) - -#define setuservalue(L,u,o) \ - { const TValue *io=(o); Udata *iu = (u); \ - iu->user_ = io->value_; iu->ttuv_ = io->tt_; \ - checkliveness(G(L),io); } - - -#define getuservalue(L,u,o) \ - { TValue *io=(o); const Udata *iu = (u); \ - io->value_ = iu->user_; io->tt_ = iu->ttuv_; \ - checkliveness(G(L),io); } - - -/* -** Description of an upvalue for function prototypes -*/ -typedef struct Upvaldesc { - TString *name; /* upvalue name (for debug information) */ - lu_byte instack; /* whether it is in stack */ - lu_byte idx; /* index of upvalue (in stack or in outer function's list) */ -} Upvaldesc; - - -/* -** Description of a local variable for function prototypes -** (used for debug information) -*/ -typedef struct LocVar { - TString *varname; - int startpc; /* first point where variable is active */ - int endpc; /* first point where variable is dead */ -} LocVar; - - -/* -** Function Prototypes -*/ -typedef struct Proto { - CommonHeader; - lu_byte numparams; /* number of fixed parameters */ - lu_byte is_vararg; - lu_byte maxstacksize; /* maximum stack used by this function */ - int sizeupvalues; /* size of 'upvalues' */ - int sizek; /* size of 'k' */ - int sizecode; - int sizelineinfo; - int sizep; /* size of 'p' */ - int sizelocvars; - int linedefined; - int lastlinedefined; - TValue *k; /* constants used by the function */ - Instruction *code; - struct Proto **p; /* functions defined inside the function */ - int *lineinfo; /* map from opcodes to source lines (debug information) */ - LocVar *locvars; /* information about local variables (debug information) */ - Upvaldesc *upvalues; /* upvalue information */ - struct LClosure *cache; /* last created closure with this prototype */ - TString *source; /* used for debug information */ - GCObject *gclist; -} Proto; - - - -/* -** Lua Upvalues -*/ -typedef struct UpVal UpVal; - - -/* -** Closures -*/ - -#define ClosureHeader \ - CommonHeader; lu_byte nupvalues; GCObject *gclist - -typedef struct CClosure { - ClosureHeader; - lua_CFunction f; - TValue upvalue[1]; /* list of upvalues */ -} CClosure; - - -typedef struct LClosure { - ClosureHeader; - struct Proto *p; - UpVal *upvals[1]; /* list of upvalues */ -} LClosure; - - -typedef union Closure { - CClosure c; - LClosure l; -} Closure; - - -#define isLfunction(o) ttisLclosure(o) - -#define getproto(o) (clLvalue(o)->p) - - -/* -** Tables -*/ - -typedef union TKey { - struct { - TValuefields; - int next; /* for chaining (offset for next node) */ - } nk; - TValue tvk; -} TKey; - - -/* copy a value into a key without messing up field 'next' */ -#define setnodekey(L,key,obj) \ - { TKey *k_=(key); const TValue *io_=(obj); \ - k_->nk.value_ = io_->value_; k_->nk.tt_ = io_->tt_; \ - (void)L; checkliveness(G(L),io_); } - - -typedef struct Node { - TValue i_val; - TKey i_key; -} Node; - - -typedef struct Table { - CommonHeader; - lu_byte flags; /* 1<<p means tagmethod(p) is not present */ - lu_byte lsizenode; /* log2 of size of 'node' array */ - unsigned int sizearray; /* size of 'array' array */ - TValue *array; /* array part */ - Node *node; - Node *lastfree; /* any free position is before this position */ - struct Table *metatable; - GCObject *gclist; -} Table; - - - -/* -** 'module' operation for hashing (size is always a power of 2) -*/ -#define lmod(s,size) \ - (check_exp((size&(size-1))==0, (cast(int, (s) & ((size)-1))))) - - -#define twoto(x) (1<<(x)) -#define sizenode(t) (twoto((t)->lsizenode)) - - -/* -** (address of) a fixed nil value -*/ -#define luaO_nilobject (&luaO_nilobject_) - - -LUAI_DDEC const TValue luaO_nilobject_; - -/* size of buffer for 'luaO_utf8esc' function */ -#define UTF8BUFFSZ 8 - -LUAI_FUNC int luaO_int2fb (unsigned int x); -LUAI_FUNC int luaO_fb2int (int x); -LUAI_FUNC int luaO_utf8esc (char *buff, unsigned long x); -LUAI_FUNC int luaO_ceillog2 (unsigned int x); -LUAI_FUNC void luaO_arith (lua_State *L, int op, const TValue *p1, - const TValue *p2, TValue *res); -LUAI_FUNC size_t luaO_str2num (const char *s, TValue *o); -LUAI_FUNC int luaO_hexavalue (int c); -LUAI_FUNC void luaO_tostring (lua_State *L, StkId obj); -LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, - va_list argp); -LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); -LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); - - -#endif - diff --git a/thirdparty/src/Lua/lopcodes.cpp b/thirdparty/src/Lua/lopcodes.cpp deleted file mode 100644 index a1cbef857..000000000 --- a/thirdparty/src/Lua/lopcodes.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* -** $Id: lopcodes.c,v 1.55 2015/01/05 13:48:33 roberto Exp $ -** Opcodes for Lua virtual machine -** See Copyright Notice in lua.h -*/ - -#define lopcodes_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <stddef.h> - -#include "lopcodes.h" - - -/* ORDER OP */ - -LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { - "MOVE", - "LOADK", - "LOADKX", - "LOADBOOL", - "LOADNIL", - "GETUPVAL", - "GETTABUP", - "GETTABLE", - "SETTABUP", - "SETUPVAL", - "SETTABLE", - "NEWTABLE", - "SELF", - "ADD", - "SUB", - "MUL", - "MOD", - "POW", - "DIV", - "IDIV", - "BAND", - "BOR", - "BXOR", - "SHL", - "SHR", - "UNM", - "BNOT", - "NOT", - "LEN", - "CONCAT", - "JMP", - "EQ", - "LT", - "LE", - "TEST", - "TESTSET", - "CALL", - "TAILCALL", - "RETURN", - "FORLOOP", - "FORPREP", - "TFORCALL", - "TFORLOOP", - "SETLIST", - "CLOSURE", - "VARARG", - "EXTRAARG", - NULL -}; - - -#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) - -LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { -/* T A B C mode opcode */ - opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ - ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ - ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */ - ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ - ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */ - ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ - ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */ - ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ - ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */ - ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ - ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ - ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ - ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BAND */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BOR */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BXOR */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHL */ - ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHR */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_BNOT */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ - ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ - ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ - ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ - ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ - ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ - ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ - ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */ - ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ - ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ - ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ - ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ - ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ - ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ - ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */ - ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ - ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ - ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ - ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ - ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ -}; - diff --git a/thirdparty/src/Lua/lopcodes.h b/thirdparty/src/Lua/lopcodes.h deleted file mode 100644 index 864b8e4bb..000000000 --- a/thirdparty/src/Lua/lopcodes.h +++ /dev/null @@ -1,295 +0,0 @@ -/* -** $Id: lopcodes.h,v 1.148 2014/10/25 11:50:46 roberto Exp $ -** Opcodes for Lua virtual machine -** See Copyright Notice in lua.h -*/ - -#ifndef lopcodes_h -#define lopcodes_h - -#include "llimits.h" - - -/*=========================================================================== - We assume that instructions are unsigned numbers. - All instructions have an opcode in the first 6 bits. - Instructions can have the following fields: - 'A' : 8 bits - 'B' : 9 bits - 'C' : 9 bits - 'Ax' : 26 bits ('A', 'B', and 'C' together) - 'Bx' : 18 bits ('B' and 'C' together) - 'sBx' : signed Bx - - A signed argument is represented in excess K; that is, the number - value is the unsigned value minus K. K is exactly the maximum value - for that argument (so that -max is represented by 0, and +max is - represented by 2*max), which is half the maximum for the corresponding - unsigned argument. -===========================================================================*/ - - -enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */ - - -/* -** size and position of opcode arguments. -*/ -#define SIZE_C 9 -#define SIZE_B 9 -#define SIZE_Bx (SIZE_C + SIZE_B) -#define SIZE_A 8 -#define SIZE_Ax (SIZE_C + SIZE_B + SIZE_A) - -#define SIZE_OP 6 - -#define POS_OP 0 -#define POS_A (POS_OP + SIZE_OP) -#define POS_C (POS_A + SIZE_A) -#define POS_B (POS_C + SIZE_C) -#define POS_Bx POS_C -#define POS_Ax POS_A - - -/* -** limits for opcode arguments. -** we use (signed) int to manipulate most arguments, -** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) -*/ -#if SIZE_Bx < LUAI_BITSINT-1 -#define MAXARG_Bx ((1<<SIZE_Bx)-1) -#define MAXARG_sBx (MAXARG_Bx>>1) /* 'sBx' is signed */ -#else -#define MAXARG_Bx MAX_INT -#define MAXARG_sBx MAX_INT -#endif - -#if SIZE_Ax < LUAI_BITSINT-1 -#define MAXARG_Ax ((1<<SIZE_Ax)-1) -#else -#define MAXARG_Ax MAX_INT -#endif - - -#define MAXARG_A ((1<<SIZE_A)-1) -#define MAXARG_B ((1<<SIZE_B)-1) -#define MAXARG_C ((1<<SIZE_C)-1) - - -/* creates a mask with 'n' 1 bits at position 'p' */ -#define MASK1(n,p) ((~((~(Instruction)0)<<(n)))<<(p)) - -/* creates a mask with 'n' 0 bits at position 'p' */ -#define MASK0(n,p) (~MASK1(n,p)) - -/* -** the following macros help to manipulate instructions -*/ - -#define GET_OPCODE(i) (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0))) -#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ - ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP)))) - -#define getarg(i,pos,size) (cast(int, ((i)>>pos) & MASK1(size,0))) -#define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \ - ((cast(Instruction, v)<<pos)&MASK1(size,pos)))) - -#define GETARG_A(i) getarg(i, POS_A, SIZE_A) -#define SETARG_A(i,v) setarg(i, v, POS_A, SIZE_A) - -#define GETARG_B(i) getarg(i, POS_B, SIZE_B) -#define SETARG_B(i,v) setarg(i, v, POS_B, SIZE_B) - -#define GETARG_C(i) getarg(i, POS_C, SIZE_C) -#define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C) - -#define GETARG_Bx(i) getarg(i, POS_Bx, SIZE_Bx) -#define SETARG_Bx(i,v) setarg(i, v, POS_Bx, SIZE_Bx) - -#define GETARG_Ax(i) getarg(i, POS_Ax, SIZE_Ax) -#define SETARG_Ax(i,v) setarg(i, v, POS_Ax, SIZE_Ax) - -#define GETARG_sBx(i) (GETARG_Bx(i)-MAXARG_sBx) -#define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx)) - - -#define CREATE_ABC(o,a,b,c) ((cast(Instruction, o)<<POS_OP) \ - | (cast(Instruction, a)<<POS_A) \ - | (cast(Instruction, b)<<POS_B) \ - | (cast(Instruction, c)<<POS_C)) - -#define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \ - | (cast(Instruction, a)<<POS_A) \ - | (cast(Instruction, bc)<<POS_Bx)) - -#define CREATE_Ax(o,a) ((cast(Instruction, o)<<POS_OP) \ - | (cast(Instruction, a)<<POS_Ax)) - - -/* -** Macros to operate RK indices -*/ - -/* this bit 1 means constant (0 means register) */ -#define BITRK (1 << (SIZE_B - 1)) - -/* test whether value is a constant */ -#define ISK(x) ((x) & BITRK) - -/* gets the index of the constant */ -#define INDEXK(r) ((int)(r) & ~BITRK) - -#define MAXINDEXRK (BITRK - 1) - -/* code a constant index as a RK value */ -#define RKASK(x) ((x) | BITRK) - - -/* -** invalid register that fits in 8 bits -*/ -#define NO_REG MAXARG_A - - -/* -** R(x) - register -** Kst(x) - constant (in constant table) -** RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x) -*/ - - -/* -** grep "ORDER OP" if you change these enums -*/ - -typedef enum { -/*---------------------------------------------------------------------- -name args description -------------------------------------------------------------------------*/ -OP_MOVE,/* A B R(A) := R(B) */ -OP_LOADK,/* A Bx R(A) := Kst(Bx) */ -OP_LOADKX,/* A R(A) := Kst(extra arg) */ -OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */ -OP_LOADNIL,/* A B R(A), R(A+1), ..., R(A+B) := nil */ -OP_GETUPVAL,/* A B R(A) := UpValue[B] */ - -OP_GETTABUP,/* A B C R(A) := UpValue[B][RK(C)] */ -OP_GETTABLE,/* A B C R(A) := R(B)[RK(C)] */ - -OP_SETTABUP,/* A B C UpValue[A][RK(B)] := RK(C) */ -OP_SETUPVAL,/* A B UpValue[B] := R(A) */ -OP_SETTABLE,/* A B C R(A)[RK(B)] := RK(C) */ - -OP_NEWTABLE,/* A B C R(A) := {} (size = B,C) */ - -OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */ - -OP_ADD,/* A B C R(A) := RK(B) + RK(C) */ -OP_SUB,/* A B C R(A) := RK(B) - RK(C) */ -OP_MUL,/* A B C R(A) := RK(B) * RK(C) */ -OP_MOD,/* A B C R(A) := RK(B) % RK(C) */ -OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */ -OP_DIV,/* A B C R(A) := RK(B) / RK(C) */ -OP_IDIV,/* A B C R(A) := RK(B) // RK(C) */ -OP_BAND,/* A B C R(A) := RK(B) & RK(C) */ -OP_BOR,/* A B C R(A) := RK(B) | RK(C) */ -OP_BXOR,/* A B C R(A) := RK(B) ~ RK(C) */ -OP_SHL,/* A B C R(A) := RK(B) << RK(C) */ -OP_SHR,/* A B C R(A) := RK(B) >> RK(C) */ -OP_UNM,/* A B R(A) := -R(B) */ -OP_BNOT,/* A B R(A) := ~R(B) */ -OP_NOT,/* A B R(A) := not R(B) */ -OP_LEN,/* A B R(A) := length of R(B) */ - -OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */ - -OP_JMP,/* A sBx pc+=sBx; if (A) close all upvalues >= R(A - 1) */ -OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */ -OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */ -OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */ - -OP_TEST,/* A C if not (R(A) <=> C) then pc++ */ -OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ - -OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ -OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ -OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ - -OP_FORLOOP,/* A sBx R(A)+=R(A+2); - if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/ -OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */ - -OP_TFORCALL,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); */ -OP_TFORLOOP,/* A sBx if R(A+1) ~= nil then { R(A)=R(A+1); pc += sBx }*/ - -OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */ - -OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */ - -OP_VARARG,/* A B R(A), R(A+1), ..., R(A+B-2) = vararg */ - -OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ -} OpCode; - - -#define NUM_OPCODES (cast(int, OP_EXTRAARG) + 1) - - - -/*=========================================================================== - Notes: - (*) In OP_CALL, if (B == 0) then B = top. If (C == 0), then 'top' is - set to last_result+1, so next open instruction (OP_CALL, OP_RETURN, - OP_SETLIST) may use 'top'. - - (*) In OP_VARARG, if (B == 0) then use actual number of varargs and - set top (like in OP_CALL with C == 0). - - (*) In OP_RETURN, if (B == 0) then return up to 'top'. - - (*) In OP_SETLIST, if (B == 0) then B = 'top'; if (C == 0) then next - 'instruction' is EXTRAARG(real C). - - (*) In OP_LOADKX, the next 'instruction' is always EXTRAARG. - - (*) For comparisons, A specifies what condition the test should accept - (true or false). - - (*) All 'skips' (pc++) assume that next instruction is a jump. - -===========================================================================*/ - - -/* -** masks for instruction properties. The format is: -** bits 0-1: op mode -** bits 2-3: C arg mode -** bits 4-5: B arg mode -** bit 6: instruction set register A -** bit 7: operator is a test (next instruction must be a jump) -*/ - -enum OpArgMask { - OpArgN, /* argument is not used */ - OpArgU, /* argument is used */ - OpArgR, /* argument is a register or a jump offset */ - OpArgK /* argument is a constant or register/constant */ -}; - -LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES]; - -#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) -#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) -#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) -#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) -#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) - - -LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ - - -/* number of list items to accumulate before a SETLIST instruction */ -#define LFIELDS_PER_FLUSH 50 - - -#endif diff --git a/thirdparty/src/Lua/loslib.cpp b/thirdparty/src/Lua/loslib.cpp deleted file mode 100644 index 439d5bef0..000000000 --- a/thirdparty/src/Lua/loslib.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/* -** $Id: loslib.c,v 1.54 2014/12/26 14:46:07 roberto Exp $ -** Standard Operating System library -** See Copyright Notice in lua.h -*/ - -#define loslib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include <errno.h> -#include <locale.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> - -#include <Lua/lua.h> - -#include <Lua/lauxlib.h> -#include <Lua/lualib.h> - - -#if !defined(LUA_STRFTIMEOPTIONS) /* { */ -/* -** list of valid conversion specifiers for the 'strftime' function -*/ - -#if defined(LUA_USE_C89) -#define LUA_STRFTIMEOPTIONS { "aAbBcdHIjmMpSUwWxXyYz%", "" } -#else /* C99 specification */ -#define LUA_STRFTIMEOPTIONS \ - { "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%", "", \ - "E", "cCxXyY", \ - "O", "deHImMSuUVwWy" } -#endif - -#endif /* } */ - - - -#if !defined(l_time_t) /* { */ -/* -** type to represent time_t in Lua -*/ -#define l_timet lua_Integer -#define l_pushtime(L,t) lua_pushinteger(L,(lua_Integer)(t)) -#define l_checktime(L,a) ((time_t)luaL_checkinteger(L,a)) - -#endif /* } */ - - - -#if !defined(lua_tmpnam) /* { */ -/* -** By default, Lua uses tmpnam except when POSIX is available, where it -** uses mkstemp. -*/ - -#if defined(LUA_USE_POSIX) /* { */ - -#include <unistd.h> - -#define LUA_TMPNAMBUFSIZE 32 - -#if !defined(LUA_TMPNAMTEMPLATE) -#define LUA_TMPNAMTEMPLATE "/tmp/lua_XXXXXX" -#endif - -#define lua_tmpnam(b,e) { \ - strcpy(b, LUA_TMPNAMTEMPLATE); \ - e = mkstemp(b); \ - if (e != -1) close(e); \ - e = (e == -1); } - -#else /* }{ */ - -/* ISO C definitions */ -#define LUA_TMPNAMBUFSIZE L_tmpnam -#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } - -#endif /* } */ - -#endif /* } */ - - - -#if !defined(l_gmtime) /* { */ -/* -** By default, Lua uses gmtime/localtime, except when POSIX is available, -** where it uses gmtime_r/localtime_r -*/ - -#if defined(LUA_USE_POSIX) /* { */ - -#define l_gmtime(t,r) gmtime_r(t,r) -#define l_localtime(t,r) localtime_r(t,r) - -#else /* }{ */ - -/* ISO C definitions */ -#define l_gmtime(t,r) ((void)(r)->tm_sec, gmtime(t)) -#define l_localtime(t,r) ((void)(r)->tm_sec, localtime(t)) - -#endif /* } */ - -#endif /* } */ - - - -static int os_execute (lua_State *L) { - const char *cmd = luaL_optstring(L, 1, NULL); - int stat = system(cmd); - if (cmd != NULL) - return luaL_execresult(L, stat); - else { - lua_pushboolean(L, stat); /* true if there is a shell */ - return 1; - } -} - - -static int os_remove (lua_State *L) { - const char *filename = luaL_checkstring(L, 1); - return luaL_fileresult(L, remove(filename) == 0, filename); -} - - -static int os_rename (lua_State *L) { - const char *fromname = luaL_checkstring(L, 1); - const char *toname = luaL_checkstring(L, 2); - return luaL_fileresult(L, rename(fromname, toname) == 0, NULL); -} - - -static int os_tmpname (lua_State *L) { - char buff[LUA_TMPNAMBUFSIZE]; - int err; - lua_tmpnam(buff, err); - if (err) - return luaL_error(L, "unable to generate a unique filename"); - lua_pushstring(L, buff); - return 1; -} - - -static int os_getenv (lua_State *L) { - lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ - return 1; -} - - -static int os_clock (lua_State *L) { - lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); - return 1; -} - - -/* -** {====================================================== -** Time/Date operations -** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, -** wday=%w+1, yday=%j, isdst=? } -** ======================================================= -*/ - -static void setfield (lua_State *L, const char *key, int value) { - lua_pushinteger(L, value); - lua_setfield(L, -2, key); -} - -static void setboolfield (lua_State *L, const char *key, int value) { - if (value < 0) /* undefined? */ - return; /* does not set field */ - lua_pushboolean(L, value); - lua_setfield(L, -2, key); -} - -static int getboolfield (lua_State *L, const char *key) { - int res; - res = (lua_getfield(L, -1, key) == LUA_TNIL) ? -1 : lua_toboolean(L, -1); - lua_pop(L, 1); - return res; -} - - -static int getfield (lua_State *L, const char *key, int d) { - int res, isnum; - lua_getfield(L, -1, key); - res = (int)lua_tointegerx(L, -1, &isnum); - if (!isnum) { - if (d < 0) - return luaL_error(L, "field '%s' missing in date table", key); - res = d; - } - lua_pop(L, 1); - return res; -} - - -static const char *checkoption (lua_State *L, const char *conv, char *buff) { - static const char *const options[] = LUA_STRFTIMEOPTIONS; - unsigned int i; - for (i = 0; i < sizeof(options)/sizeof(options[0]); i += 2) { - if (*conv != '\0' && strchr(options[i], *conv) != NULL) { - buff[1] = *conv; - if (*options[i + 1] == '\0') { /* one-char conversion specifier? */ - buff[2] = '\0'; /* end buffer */ - return conv + 1; - } - else if (*(conv + 1) != '\0' && - strchr(options[i + 1], *(conv + 1)) != NULL) { - buff[2] = *(conv + 1); /* valid two-char conversion specifier */ - buff[3] = '\0'; /* end buffer */ - return conv + 2; - } - } - } - luaL_argerror(L, 1, - lua_pushfstring(L, "invalid conversion specifier '%%%s'", conv)); - return conv; /* to avoid warnings */ -} - - -static int os_date (lua_State *L) { - const char *s = luaL_optstring(L, 1, "%c"); - time_t t = luaL_opt(L, l_checktime, 2, time(NULL)); - struct tm tmr, *stm; - if (*s == '!') { /* UTC? */ - stm = l_gmtime(&t, &tmr); - s++; /* skip '!' */ - } - else - stm = l_localtime(&t, &tmr); - if (stm == NULL) /* invalid date? */ - lua_pushnil(L); - else if (strcmp(s, "*t") == 0) { - lua_createtable(L, 0, 9); /* 9 = number of fields */ - setfield(L, "sec", stm->tm_sec); - setfield(L, "min", stm->tm_min); - setfield(L, "hour", stm->tm_hour); - setfield(L, "day", stm->tm_mday); - setfield(L, "month", stm->tm_mon+1); - setfield(L, "year", stm->tm_year+1900); - setfield(L, "wday", stm->tm_wday+1); - setfield(L, "yday", stm->tm_yday+1); - setboolfield(L, "isdst", stm->tm_isdst); - } - else { - char cc[4]; - luaL_Buffer b; - cc[0] = '%'; - luaL_buffinit(L, &b); - while (*s) { - if (*s != '%') /* no conversion specifier? */ - luaL_addchar(&b, *s++); - else { - size_t reslen; - char buff[200]; /* should be big enough for any conversion result */ - s = checkoption(L, s + 1, cc); - reslen = strftime(buff, sizeof(buff), cc, stm); - luaL_addlstring(&b, buff, reslen); - } - } - luaL_pushresult(&b); - } - return 1; -} - - -static int os_time (lua_State *L) { - time_t t; - if (lua_isnoneornil(L, 1)) /* called without args? */ - t = time(NULL); /* get current time */ - else { - struct tm ts; - luaL_checktype(L, 1, LUA_TTABLE); - lua_settop(L, 1); /* make sure table is at the top */ - ts.tm_sec = getfield(L, "sec", 0); - ts.tm_min = getfield(L, "min", 0); - ts.tm_hour = getfield(L, "hour", 12); - ts.tm_mday = getfield(L, "day", -1); - ts.tm_mon = getfield(L, "month", -1) - 1; - ts.tm_year = getfield(L, "year", -1) - 1900; - ts.tm_isdst = getboolfield(L, "isdst"); - t = mktime(&ts); - } - if (t != (time_t)(l_timet)t) - luaL_error(L, "time result cannot be represented in this Lua instalation"); - else if (t == (time_t)(-1)) - lua_pushnil(L); - else - l_pushtime(L, t); - return 1; -} - - -static int os_difftime (lua_State *L) { - double res = difftime((l_checktime(L, 1)), (l_checktime(L, 2))); - lua_pushnumber(L, (lua_Number)res); - return 1; -} - -/* }====================================================== */ - - -static int os_setlocale (lua_State *L) { - static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, - LC_NUMERIC, LC_TIME}; - static const char *const catnames[] = {"all", "collate", "ctype", "monetary", - "numeric", "time", NULL}; - const char *l = luaL_optstring(L, 1, NULL); - int op = luaL_checkoption(L, 2, "all", catnames); - lua_pushstring(L, setlocale(cat[op], l)); - return 1; -} - - -static int os_exit (lua_State *L) { - int status; - if (lua_isboolean(L, 1)) - status = (lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE); - else - status = (int)luaL_optinteger(L, 1, EXIT_SUCCESS); - if (lua_toboolean(L, 2)) - lua_close(L); - if (L) exit(status); /* 'if' to avoid warnings for unreachable 'return' */ - return 0; -} - - -static const luaL_Reg syslib[] = { - {"clock", os_clock}, - {"date", os_date}, - {"difftime", os_difftime}, - {"execute", os_execute}, - {"exit", os_exit}, - {"getenv", os_getenv}, - {"remove", os_remove}, - {"rename", os_rename}, - {"setlocale", os_setlocale}, - {"time", os_time}, - {"tmpname", os_tmpname}, - {NULL, NULL} -}; - -/* }====================================================== */ - - - -LUAMOD_API int luaopen_os (lua_State *L) { - luaL_newlib(L, syslib); - return 1; -} - diff --git a/thirdparty/src/Lua/lparser.cpp b/thirdparty/src/Lua/lparser.cpp deleted file mode 100644 index 826a22d17..000000000 --- a/thirdparty/src/Lua/lparser.cpp +++ /dev/null @@ -1,1647 +0,0 @@ -/* -** $Id: lparser.c,v 2.147 2014/12/27 20:31:43 roberto Exp $ -** Lua Parser -** See Copyright Notice in lua.h -*/ - -#define lparser_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <string.h> - -#include <Lua/lua.h> - -#include "lcode.h" -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "llex.h" -#include "lmem.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lparser.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" - - - -/* maximum number of local variables per function (must be smaller - than 250, due to the bytecode format) */ -#define MAXVARS 200 - - -#define hasmultret(k) ((k) == VCALL || (k) == VVARARG) - - -/* because all strings are unified by the scanner, the parser - can use pointer equality for string equality */ -#define eqstr(a,b) ((a) == (b)) - - -/* -** nodes for block list (list of active blocks) -*/ -typedef struct BlockCnt { - struct BlockCnt *previous; /* chain */ - int firstlabel; /* index of first label in this block */ - int firstgoto; /* index of first pending goto in this block */ - lu_byte nactvar; /* # active locals outside the block */ - lu_byte upval; /* true if some variable in the block is an upvalue */ - lu_byte isloop; /* true if 'block' is a loop */ -} BlockCnt; - - - -/* -** prototypes for recursive non-terminal functions -*/ -static void statement (LexState *ls); -static void expr (LexState *ls, expdesc *v); - - -/* semantic error */ -static l_noret semerror (LexState *ls, const char *msg) { - ls->t.token = 0; /* remove "near <token>" from final message */ - luaX_syntaxerror(ls, msg); -} - - -static l_noret error_expected (LexState *ls, int token) { - luaX_syntaxerror(ls, - luaO_pushfstring(ls->L, "%s expected", luaX_token2str(ls, token))); -} - - -static l_noret errorlimit (FuncState *fs, int limit, const char *what) { - lua_State *L = fs->ls->L; - const char *msg; - int line = fs->f->linedefined; - const char *where = (line == 0) - ? "main function" - : luaO_pushfstring(L, "function at line %d", line); - msg = luaO_pushfstring(L, "too many %s (limit is %d) in %s", - what, limit, where); - luaX_syntaxerror(fs->ls, msg); -} - - -static void checklimit (FuncState *fs, int v, int l, const char *what) { - if (v > l) errorlimit(fs, l, what); -} - - -static int testnext (LexState *ls, int c) { - if (ls->t.token == c) { - luaX_next(ls); - return 1; - } - else return 0; -} - - -static void check (LexState *ls, int c) { - if (ls->t.token != c) - error_expected(ls, c); -} - - -static void checknext (LexState *ls, int c) { - check(ls, c); - luaX_next(ls); -} - - -#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } - - - -static void check_match (LexState *ls, int what, int who, int where) { - if (!testnext(ls, what)) { - if (where == ls->linenumber) - error_expected(ls, what); - else { - luaX_syntaxerror(ls, luaO_pushfstring(ls->L, - "%s expected (to close %s at line %d)", - luaX_token2str(ls, what), luaX_token2str(ls, who), where)); - } - } -} - - -static TString *str_checkname (LexState *ls) { - TString *ts; - check(ls, TK_NAME); - ts = ls->t.seminfo.ts; - luaX_next(ls); - return ts; -} - - -static void init_exp (expdesc *e, expkind k, int i) { - e->f = e->t = NO_JUMP; - e->k = k; - e->u.info = i; -} - - -static void codestring (LexState *ls, expdesc *e, TString *s) { - init_exp(e, VK, luaK_stringK(ls->fs, s)); -} - - -static void checkname (LexState *ls, expdesc *e) { - codestring(ls, e, str_checkname(ls)); -} - - -static int registerlocalvar (LexState *ls, TString *varname) { - FuncState *fs = ls->fs; - Proto *f = fs->f; - int oldsize = f->sizelocvars; - luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, - LocVar, SHRT_MAX, "local variables"); - while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; - f->locvars[fs->nlocvars].varname = varname; - luaC_objbarrier(ls->L, f, varname); - return fs->nlocvars++; -} - - -static void new_localvar (LexState *ls, TString *name) { - FuncState *fs = ls->fs; - Dyndata *dyd = ls->dyd; - int reg = registerlocalvar(ls, name); - checklimit(fs, dyd->actvar.n + 1 - fs->firstlocal, - MAXVARS, "local variables"); - luaM_growvector(ls->L, dyd->actvar.arr, dyd->actvar.n + 1, - dyd->actvar.size, Vardesc, MAX_INT, "local variables"); - dyd->actvar.arr[dyd->actvar.n++].idx = cast(short, reg); -} - - -static void new_localvarliteral_ (LexState *ls, const char *name, size_t sz) { - new_localvar(ls, luaX_newstring(ls, name, sz)); -} - -#define new_localvarliteral(ls,v) \ - new_localvarliteral_(ls, "" v, (sizeof(v)/sizeof(char))-1) - - -static LocVar *getlocvar (FuncState *fs, int i) { - int idx = fs->ls->dyd->actvar.arr[fs->firstlocal + i].idx; - lua_assert(idx < fs->nlocvars); - return &fs->f->locvars[idx]; -} - - -static void adjustlocalvars (LexState *ls, int nvars) { - FuncState *fs = ls->fs; - fs->nactvar = cast_byte(fs->nactvar + nvars); - for (; nvars; nvars--) { - getlocvar(fs, fs->nactvar - nvars)->startpc = fs->pc; - } -} - - -static void removevars (FuncState *fs, int tolevel) { - fs->ls->dyd->actvar.n -= (fs->nactvar - tolevel); - while (fs->nactvar > tolevel) - getlocvar(fs, --fs->nactvar)->endpc = fs->pc; -} - - -static int searchupvalue (FuncState *fs, TString *name) { - int i; - Upvaldesc *up = fs->f->upvalues; - for (i = 0; i < fs->nups; i++) { - if (eqstr(up[i].name, name)) return i; - } - return -1; /* not found */ -} - - -static int newupvalue (FuncState *fs, TString *name, expdesc *v) { - Proto *f = fs->f; - int oldsize = f->sizeupvalues; - checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues"); - luaM_growvector(fs->ls->L, f->upvalues, fs->nups, f->sizeupvalues, - Upvaldesc, MAXUPVAL, "upvalues"); - while (oldsize < f->sizeupvalues) f->upvalues[oldsize++].name = NULL; - f->upvalues[fs->nups].instack = (v->k == VLOCAL); - f->upvalues[fs->nups].idx = cast_byte(v->u.info); - f->upvalues[fs->nups].name = name; - luaC_objbarrier(fs->ls->L, f, name); - return fs->nups++; -} - - -static int searchvar (FuncState *fs, TString *n) { - int i; - for (i = cast_int(fs->nactvar) - 1; i >= 0; i--) { - if (eqstr(n, getlocvar(fs, i)->varname)) - return i; - } - return -1; /* not found */ -} - - -/* - Mark block where variable at given level was defined - (to emit close instructions later). -*/ -static void markupval (FuncState *fs, int level) { - BlockCnt *bl = fs->bl; - while (bl->nactvar > level) bl = bl->previous; - bl->upval = 1; -} - - -/* - Find variable with given name 'n'. If it is an upvalue, add this - upvalue into all intermediate functions. -*/ -static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { - if (fs == NULL) /* no more levels? */ - return VVOID; /* default is global */ - else { - int v = searchvar(fs, n); /* look up locals at current level */ - if (v >= 0) { /* found? */ - init_exp(var, VLOCAL, v); /* variable is local */ - if (!base) - markupval(fs, v); /* local will be used as an upval */ - return VLOCAL; - } - else { /* not found as local at current level; try upvalues */ - int idx = searchupvalue(fs, n); /* try existing upvalues */ - if (idx < 0) { /* not found? */ - if (singlevaraux(fs->prev, n, var, 0) == VVOID) /* try upper levels */ - return VVOID; /* not found; is a global */ - /* else was LOCAL or UPVAL */ - idx = newupvalue(fs, n, var); /* will be a new upvalue */ - } - init_exp(var, VUPVAL, idx); - return VUPVAL; - } - } -} - - -static void singlevar (LexState *ls, expdesc *var) { - TString *varname = str_checkname(ls); - FuncState *fs = ls->fs; - if (singlevaraux(fs, varname, var, 1) == VVOID) { /* global name? */ - expdesc key; - singlevaraux(fs, ls->envn, var, 1); /* get environment variable */ - lua_assert(var->k == VLOCAL || var->k == VUPVAL); - codestring(ls, &key, varname); /* key is variable name */ - luaK_indexed(fs, var, &key); /* env[varname] */ - } -} - - -static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { - FuncState *fs = ls->fs; - int extra = nvars - nexps; - if (hasmultret(e->k)) { - extra++; /* includes call itself */ - if (extra < 0) extra = 0; - luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ - if (extra > 1) luaK_reserveregs(fs, extra-1); - } - else { - if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ - if (extra > 0) { - int reg = fs->freereg; - luaK_reserveregs(fs, extra); - luaK_nil(fs, reg, extra); - } - } -} - - -static void enterlevel (LexState *ls) { - lua_State *L = ls->L; - ++L->nCcalls; - checklimit(ls->fs, L->nCcalls, LUAI_MAXCCALLS, "C levels"); -} - - -#define leavelevel(ls) ((ls)->L->nCcalls--) - - -static void closegoto (LexState *ls, int g, Labeldesc *label) { - int i; - FuncState *fs = ls->fs; - Labellist *gl = &ls->dyd->gt; - Labeldesc *gt = &gl->arr[g]; - lua_assert(eqstr(gt->name, label->name)); - if (gt->nactvar < label->nactvar) { - TString *vname = getlocvar(fs, gt->nactvar)->varname; - const char *msg = luaO_pushfstring(ls->L, - "<goto %s> at line %d jumps into the scope of local '%s'", - getstr(gt->name), gt->line, getstr(vname)); - semerror(ls, msg); - } - luaK_patchlist(fs, gt->pc, label->pc); - /* remove goto from pending list */ - for (i = g; i < gl->n - 1; i++) - gl->arr[i] = gl->arr[i + 1]; - gl->n--; -} - - -/* -** try to close a goto with existing labels; this solves backward jumps -*/ -static int findlabel (LexState *ls, int g) { - int i; - BlockCnt *bl = ls->fs->bl; - Dyndata *dyd = ls->dyd; - Labeldesc *gt = &dyd->gt.arr[g]; - /* check labels in current block for a match */ - for (i = bl->firstlabel; i < dyd->label.n; i++) { - Labeldesc *lb = &dyd->label.arr[i]; - if (eqstr(lb->name, gt->name)) { /* correct label? */ - if (gt->nactvar > lb->nactvar && - (bl->upval || dyd->label.n > bl->firstlabel)) - luaK_patchclose(ls->fs, gt->pc, lb->nactvar); - closegoto(ls, g, lb); /* close it */ - return 1; - } - } - return 0; /* label not found; cannot close goto */ -} - - -static int newlabelentry (LexState *ls, Labellist *l, TString *name, - int line, int pc) { - int n = l->n; - luaM_growvector(ls->L, l->arr, n, l->size, - Labeldesc, SHRT_MAX, "labels/gotos"); - l->arr[n].name = name; - l->arr[n].line = line; - l->arr[n].nactvar = ls->fs->nactvar; - l->arr[n].pc = pc; - l->n = n + 1; - return n; -} - - -/* -** check whether new label 'lb' matches any pending gotos in current -** block; solves forward jumps -*/ -static void findgotos (LexState *ls, Labeldesc *lb) { - Labellist *gl = &ls->dyd->gt; - int i = ls->fs->bl->firstgoto; - while (i < gl->n) { - if (eqstr(gl->arr[i].name, lb->name)) - closegoto(ls, i, lb); - else - i++; - } -} - - -/* -** export pending gotos to outer level, to check them against -** outer labels; if the block being exited has upvalues, and -** the goto exits the scope of any variable (which can be the -** upvalue), close those variables being exited. -*/ -static void movegotosout (FuncState *fs, BlockCnt *bl) { - int i = bl->firstgoto; - Labellist *gl = &fs->ls->dyd->gt; - /* correct pending gotos to current block and try to close it - with visible labels */ - while (i < gl->n) { - Labeldesc *gt = &gl->arr[i]; - if (gt->nactvar > bl->nactvar) { - if (bl->upval) - luaK_patchclose(fs, gt->pc, bl->nactvar); - gt->nactvar = bl->nactvar; - } - if (!findlabel(fs->ls, i)) - i++; /* move to next one */ - } -} - - -static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isloop) { - bl->isloop = isloop; - bl->nactvar = fs->nactvar; - bl->firstlabel = fs->ls->dyd->label.n; - bl->firstgoto = fs->ls->dyd->gt.n; - bl->upval = 0; - bl->previous = fs->bl; - fs->bl = bl; - lua_assert(fs->freereg == fs->nactvar); -} - - -/* -** create a label named 'break' to resolve break statements -*/ -static void breaklabel (LexState *ls) { - TString *n = luaS_new(ls->L, "break"); - int l = newlabelentry(ls, &ls->dyd->label, n, 0, ls->fs->pc); - findgotos(ls, &ls->dyd->label.arr[l]); -} - -/* -** generates an error for an undefined 'goto'; choose appropriate -** message when label name is a reserved word (which can only be 'break') -*/ -static l_noret undefgoto (LexState *ls, Labeldesc *gt) { - const char *msg = isreserved(gt->name) - ? "<%s> at line %d not inside a loop" - : "no visible label '%s' for <goto> at line %d"; - msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line); - semerror(ls, msg); -} - - -static void leaveblock (FuncState *fs) { - BlockCnt *bl = fs->bl; - LexState *ls = fs->ls; - if (bl->previous && bl->upval) { - /* create a 'jump to here' to close upvalues */ - int j = luaK_jump(fs); - luaK_patchclose(fs, j, bl->nactvar); - luaK_patchtohere(fs, j); - } - if (bl->isloop) - breaklabel(ls); /* close pending breaks */ - fs->bl = bl->previous; - removevars(fs, bl->nactvar); - lua_assert(bl->nactvar == fs->nactvar); - fs->freereg = fs->nactvar; /* free registers */ - ls->dyd->label.n = bl->firstlabel; /* remove local labels */ - if (bl->previous) /* inner block? */ - movegotosout(fs, bl); /* update pending gotos to outer block */ - else if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */ - undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */ -} - - -/* -** adds a new prototype into list of prototypes -*/ -static Proto *addprototype (LexState *ls) { - Proto *clp; - lua_State *L = ls->L; - FuncState *fs = ls->fs; - Proto *f = fs->f; /* prototype of current function */ - if (fs->np >= f->sizep) { - int oldsize = f->sizep; - luaM_growvector(L, f->p, fs->np, f->sizep, Proto *, MAXARG_Bx, "functions"); - while (oldsize < f->sizep) f->p[oldsize++] = NULL; - } - f->p[fs->np++] = clp = luaF_newproto(L); - luaC_objbarrier(L, f, clp); - return clp; -} - - -/* -** codes instruction to create new closure in parent function. -** The OP_CLOSURE instruction must use the last available register, -** so that, if it invokes the GC, the GC knows which registers -** are in use at that time. -*/ -static void codeclosure (LexState *ls, expdesc *v) { - FuncState *fs = ls->fs->prev; - init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np - 1)); - luaK_exp2nextreg(fs, v); /* fix it at the last register */ -} - - -static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) { - Proto *f; - fs->prev = ls->fs; /* linked list of funcstates */ - fs->ls = ls; - ls->fs = fs; - fs->pc = 0; - fs->lasttarget = 0; - fs->jpc = NO_JUMP; - fs->freereg = 0; - fs->nk = 0; - fs->np = 0; - fs->nups = 0; - fs->nlocvars = 0; - fs->nactvar = 0; - fs->firstlocal = ls->dyd->actvar.n; - fs->bl = NULL; - f = fs->f; - f->source = ls->source; - f->maxstacksize = 2; /* registers 0/1 are always valid */ - enterblock(fs, bl, 0); -} - - -static void close_func (LexState *ls) { - lua_State *L = ls->L; - FuncState *fs = ls->fs; - Proto *f = fs->f; - luaK_ret(fs, 0, 0); /* final return */ - leaveblock(fs); - luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); - f->sizecode = fs->pc; - luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); - f->sizelineinfo = fs->pc; - luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); - f->sizek = fs->nk; - luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); - f->sizep = fs->np; - luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); - f->sizelocvars = fs->nlocvars; - luaM_reallocvector(L, f->upvalues, f->sizeupvalues, fs->nups, Upvaldesc); - f->sizeupvalues = fs->nups; - lua_assert(fs->bl == NULL); - ls->fs = fs->prev; - luaC_checkGC(L); -} - - - -/*============================================================*/ -/* GRAMMAR RULES */ -/*============================================================*/ - - -/* -** check whether current token is in the follow set of a block. -** 'until' closes syntactical blocks, but do not close scope, -** so it is handled in separate. -*/ -static int block_follow (LexState *ls, int withuntil) { - switch (ls->t.token) { - case TK_ELSE: case TK_ELSEIF: - case TK_END: case TK_EOS: - return 1; - case TK_UNTIL: return withuntil; - default: return 0; - } -} - - -static void statlist (LexState *ls) { - /* statlist -> { stat [';'] } */ - while (!block_follow(ls, 1)) { - if (ls->t.token == TK_RETURN) { - statement(ls); - return; /* 'return' must be last statement */ - } - statement(ls); - } -} - - -static void fieldsel (LexState *ls, expdesc *v) { - /* fieldsel -> ['.' | ':'] NAME */ - FuncState *fs = ls->fs; - expdesc key; - luaK_exp2anyregup(fs, v); - luaX_next(ls); /* skip the dot or colon */ - checkname(ls, &key); - luaK_indexed(fs, v, &key); -} - - -static void yindex (LexState *ls, expdesc *v) { - /* index -> '[' expr ']' */ - luaX_next(ls); /* skip the '[' */ - expr(ls, v); - luaK_exp2val(ls->fs, v); - checknext(ls, ']'); -} - - -/* -** {====================================================================== -** Rules for Constructors -** ======================================================================= -*/ - - -struct ConsControl { - expdesc v; /* last list item read */ - expdesc *t; /* table descriptor */ - int nh; /* total number of 'record' elements */ - int na; /* total number of array elements */ - int tostore; /* number of array elements pending to be stored */ -}; - - -static void recfield (LexState *ls, struct ConsControl *cc) { - /* recfield -> (NAME | '['exp1']') = exp1 */ - FuncState *fs = ls->fs; - int reg = ls->fs->freereg; - expdesc key, val; - int rkkey; - if (ls->t.token == TK_NAME) { - checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); - checkname(ls, &key); - } - else /* ls->t.token == '[' */ - yindex(ls, &key); - cc->nh++; - checknext(ls, '='); - rkkey = luaK_exp2RK(fs, &key); - expr(ls, &val); - luaK_codeABC(fs, OP_SETTABLE, cc->t->u.info, rkkey, luaK_exp2RK(fs, &val)); - fs->freereg = reg; /* free registers */ -} - - -static void closelistfield (FuncState *fs, struct ConsControl *cc) { - if (cc->v.k == VVOID) return; /* there is no list item */ - luaK_exp2nextreg(fs, &cc->v); - cc->v.k = VVOID; - if (cc->tostore == LFIELDS_PER_FLUSH) { - luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); /* flush */ - cc->tostore = 0; /* no more items pending */ - } -} - - -static void lastlistfield (FuncState *fs, struct ConsControl *cc) { - if (cc->tostore == 0) return; - if (hasmultret(cc->v.k)) { - luaK_setmultret(fs, &cc->v); - luaK_setlist(fs, cc->t->u.info, cc->na, LUA_MULTRET); - cc->na--; /* do not count last expression (unknown number of elements) */ - } - else { - if (cc->v.k != VVOID) - luaK_exp2nextreg(fs, &cc->v); - luaK_setlist(fs, cc->t->u.info, cc->na, cc->tostore); - } -} - - -static void listfield (LexState *ls, struct ConsControl *cc) { - /* listfield -> exp */ - expr(ls, &cc->v); - checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); - cc->na++; - cc->tostore++; -} - - -static void field (LexState *ls, struct ConsControl *cc) { - /* field -> listfield | recfield */ - switch(ls->t.token) { - case TK_NAME: { /* may be 'listfield' or 'recfield' */ - if (luaX_lookahead(ls) != '=') /* expression? */ - listfield(ls, cc); - else - recfield(ls, cc); - break; - } - case '[': { - recfield(ls, cc); - break; - } - default: { - listfield(ls, cc); - break; - } - } -} - - -static void constructor (LexState *ls, expdesc *t) { - /* constructor -> '{' [ field { sep field } [sep] ] '}' - sep -> ',' | ';' */ - FuncState *fs = ls->fs; - int line = ls->linenumber; - int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); - struct ConsControl cc; - cc.na = cc.nh = cc.tostore = 0; - cc.t = t; - init_exp(t, VRELOCABLE, pc); - init_exp(&cc.v, VVOID, 0); /* no value (yet) */ - luaK_exp2nextreg(ls->fs, t); /* fix it at stack top */ - checknext(ls, '{'); - do { - lua_assert(cc.v.k == VVOID || cc.tostore > 0); - if (ls->t.token == '}') break; - closelistfield(fs, &cc); - field(ls, &cc); - } while (testnext(ls, ',') || testnext(ls, ';')); - check_match(ls, '}', '{', line); - lastlistfield(fs, &cc); - SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ - SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ -} - -/* }====================================================================== */ - - - -static void parlist (LexState *ls) { - /* parlist -> [ param { ',' param } ] */ - FuncState *fs = ls->fs; - Proto *f = fs->f; - int nparams = 0; - f->is_vararg = 0; - if (ls->t.token != ')') { /* is 'parlist' not empty? */ - do { - switch (ls->t.token) { - case TK_NAME: { /* param -> NAME */ - new_localvar(ls, str_checkname(ls)); - nparams++; - break; - } - case TK_DOTS: { /* param -> '...' */ - luaX_next(ls); - f->is_vararg = 1; - break; - } - default: luaX_syntaxerror(ls, "<name> or '...' expected"); - } - } while (!f->is_vararg && testnext(ls, ',')); - } - adjustlocalvars(ls, nparams); - f->numparams = cast_byte(fs->nactvar); - luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ -} - - -static void body (LexState *ls, expdesc *e, int ismethod, int line) { - /* body -> '(' parlist ')' block END */ - FuncState new_fs; - BlockCnt bl; - new_fs.f = addprototype(ls); - new_fs.f->linedefined = line; - open_func(ls, &new_fs, &bl); - checknext(ls, '('); - if (ismethod) { - new_localvarliteral(ls, "self"); /* create 'self' parameter */ - adjustlocalvars(ls, 1); - } - parlist(ls); - checknext(ls, ')'); - statlist(ls); - new_fs.f->lastlinedefined = ls->linenumber; - check_match(ls, TK_END, TK_FUNCTION, line); - codeclosure(ls, e); - close_func(ls); -} - - -static int explist (LexState *ls, expdesc *v) { - /* explist -> expr { ',' expr } */ - int n = 1; /* at least one expression */ - expr(ls, v); - while (testnext(ls, ',')) { - luaK_exp2nextreg(ls->fs, v); - expr(ls, v); - n++; - } - return n; -} - - -static void funcargs (LexState *ls, expdesc *f, int line) { - FuncState *fs = ls->fs; - expdesc args; - int base, nparams; - switch (ls->t.token) { - case '(': { /* funcargs -> '(' [ explist ] ')' */ - luaX_next(ls); - if (ls->t.token == ')') /* arg list is empty? */ - args.k = VVOID; - else { - explist(ls, &args); - luaK_setmultret(fs, &args); - } - check_match(ls, ')', '(', line); - break; - } - case '{': { /* funcargs -> constructor */ - constructor(ls, &args); - break; - } - case TK_STRING: { /* funcargs -> STRING */ - codestring(ls, &args, ls->t.seminfo.ts); - luaX_next(ls); /* must use 'seminfo' before 'next' */ - break; - } - default: { - luaX_syntaxerror(ls, "function arguments expected"); - } - } - lua_assert(f->k == VNONRELOC); - base = f->u.info; /* base register for call */ - if (hasmultret(args.k)) - nparams = LUA_MULTRET; /* open call */ - else { - if (args.k != VVOID) - luaK_exp2nextreg(fs, &args); /* close last argument */ - nparams = fs->freereg - (base+1); - } - init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); - luaK_fixline(fs, line); - fs->freereg = base+1; /* call remove function and arguments and leaves - (unless changed) one result */ -} - - - - -/* -** {====================================================================== -** Expression parsing -** ======================================================================= -*/ - - -static void primaryexp (LexState *ls, expdesc *v) { - /* primaryexp -> NAME | '(' expr ')' */ - switch (ls->t.token) { - case '(': { - int line = ls->linenumber; - luaX_next(ls); - expr(ls, v); - check_match(ls, ')', '(', line); - luaK_dischargevars(ls->fs, v); - return; - } - case TK_NAME: { - singlevar(ls, v); - return; - } - default: { - luaX_syntaxerror(ls, "unexpected symbol"); - } - } -} - - -static void suffixedexp (LexState *ls, expdesc *v) { - /* suffixedexp -> - primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */ - FuncState *fs = ls->fs; - int line = ls->linenumber; - primaryexp(ls, v); - for (;;) { - switch (ls->t.token) { - case '.': { /* fieldsel */ - fieldsel(ls, v); - break; - } - case '[': { /* '[' exp1 ']' */ - expdesc key; - luaK_exp2anyregup(fs, v); - yindex(ls, &key); - luaK_indexed(fs, v, &key); - break; - } - case ':': { /* ':' NAME funcargs */ - expdesc key; - luaX_next(ls); - checkname(ls, &key); - luaK_self(fs, v, &key); - funcargs(ls, v, line); - break; - } - case '(': case TK_STRING: case '{': { /* funcargs */ - luaK_exp2nextreg(fs, v); - funcargs(ls, v, line); - break; - } - default: return; - } - } -} - - -static void simpleexp (LexState *ls, expdesc *v) { - /* simpleexp -> FLT | INT | STRING | NIL | TRUE | FALSE | ... | - constructor | FUNCTION body | suffixedexp */ - switch (ls->t.token) { - case TK_FLT: { - init_exp(v, VKFLT, 0); - v->u.nval = ls->t.seminfo.r; - break; - } - case TK_INT: { - init_exp(v, VKINT, 0); - v->u.ival = ls->t.seminfo.i; - break; - } - case TK_STRING: { - codestring(ls, v, ls->t.seminfo.ts); - break; - } - case TK_NIL: { - init_exp(v, VNIL, 0); - break; - } - case TK_TRUE: { - init_exp(v, VTRUE, 0); - break; - } - case TK_FALSE: { - init_exp(v, VFALSE, 0); - break; - } - case TK_DOTS: { /* vararg */ - FuncState *fs = ls->fs; - check_condition(ls, fs->f->is_vararg, - "cannot use '...' outside a vararg function"); - init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); - break; - } - case '{': { /* constructor */ - constructor(ls, v); - return; - } - case TK_FUNCTION: { - luaX_next(ls); - body(ls, v, 0, ls->linenumber); - return; - } - default: { - suffixedexp(ls, v); - return; - } - } - luaX_next(ls); -} - - -static UnOpr getunopr (int op) { - switch (op) { - case TK_NOT: return OPR_NOT; - case '-': return OPR_MINUS; - case '~': return OPR_BNOT; - case '#': return OPR_LEN; - default: return OPR_NOUNOPR; - } -} - - -static BinOpr getbinopr (int op) { - switch (op) { - case '+': return OPR_ADD; - case '-': return OPR_SUB; - case '*': return OPR_MUL; - case '%': return OPR_MOD; - case '^': return OPR_POW; - case '/': return OPR_DIV; - case TK_IDIV: return OPR_IDIV; - case '&': return OPR_BAND; - case '|': return OPR_BOR; - case '~': return OPR_BXOR; - case TK_SHL: return OPR_SHL; - case TK_SHR: return OPR_SHR; - case TK_CONCAT: return OPR_CONCAT; - case TK_NE: return OPR_NE; - case TK_EQ: return OPR_EQ; - case '<': return OPR_LT; - case TK_LE: return OPR_LE; - case '>': return OPR_GT; - case TK_GE: return OPR_GE; - case TK_AND: return OPR_AND; - case TK_OR: return OPR_OR; - default: return OPR_NOBINOPR; - } -} - - -static const struct { - lu_byte left; /* left priority for each binary operator */ - lu_byte right; /* right priority */ -} priority[] = { /* ORDER OPR */ - {10, 10}, {10, 10}, /* '+' '-' */ - {11, 11}, {11, 11}, /* '*' '%' */ - {14, 13}, /* '^' (right associative) */ - {11, 11}, {11, 11}, /* '/' '//' */ - {6, 6}, {4, 4}, {5, 5}, /* '&' '|' '~' */ - {7, 7}, {7, 7}, /* '<<' '>>' */ - {9, 8}, /* '..' (right associative) */ - {3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */ - {3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */ - {2, 2}, {1, 1} /* and, or */ -}; - -#define UNARY_PRIORITY 12 /* priority for unary operators */ - - -/* -** subexpr -> (simpleexp | unop subexpr) { binop subexpr } -** where 'binop' is any binary operator with a priority higher than 'limit' -*/ -static BinOpr subexpr (LexState *ls, expdesc *v, int limit) { - BinOpr op; - UnOpr uop; - enterlevel(ls); - uop = getunopr(ls->t.token); - if (uop != OPR_NOUNOPR) { - int line = ls->linenumber; - luaX_next(ls); - subexpr(ls, v, UNARY_PRIORITY); - luaK_prefix(ls->fs, uop, v, line); - } - else simpleexp(ls, v); - /* expand while operators have priorities higher than 'limit' */ - op = getbinopr(ls->t.token); - while (op != OPR_NOBINOPR && priority[op].left > limit) { - expdesc v2; - BinOpr nextop; - int line = ls->linenumber; - luaX_next(ls); - luaK_infix(ls->fs, op, v); - /* read sub-expression with higher priority */ - nextop = subexpr(ls, &v2, priority[op].right); - luaK_posfix(ls->fs, op, v, &v2, line); - op = nextop; - } - leavelevel(ls); - return op; /* return first untreated operator */ -} - - -static void expr (LexState *ls, expdesc *v) { - subexpr(ls, v, 0); -} - -/* }==================================================================== */ - - - -/* -** {====================================================================== -** Rules for Statements -** ======================================================================= -*/ - - -static void block (LexState *ls) { - /* block -> statlist */ - FuncState *fs = ls->fs; - BlockCnt bl; - enterblock(fs, &bl, 0); - statlist(ls); - leaveblock(fs); -} - - -/* -** structure to chain all variables in the left-hand side of an -** assignment -*/ -struct LHS_assign { - struct LHS_assign *prev; - expdesc v; /* variable (global, local, upvalue, or indexed) */ -}; - - -/* -** check whether, in an assignment to an upvalue/local variable, the -** upvalue/local variable is begin used in a previous assignment to a -** table. If so, save original upvalue/local value in a safe place and -** use this safe copy in the previous assignment. -*/ -static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { - FuncState *fs = ls->fs; - int extra = fs->freereg; /* eventual position to save local variable */ - int conflict = 0; - for (; lh; lh = lh->prev) { /* check all previous assignments */ - if (lh->v.k == VINDEXED) { /* assigning to a table? */ - /* table is the upvalue/local being assigned now? */ - if (lh->v.u.ind.vt == v->k && lh->v.u.ind.t == v->u.info) { - conflict = 1; - lh->v.u.ind.vt = VLOCAL; - lh->v.u.ind.t = extra; /* previous assignment will use safe copy */ - } - /* index is the local being assigned? (index cannot be upvalue) */ - if (v->k == VLOCAL && lh->v.u.ind.idx == v->u.info) { - conflict = 1; - lh->v.u.ind.idx = extra; /* previous assignment will use safe copy */ - } - } - } - if (conflict) { - /* copy upvalue/local value to a temporary (in position 'extra') */ - OpCode op = (v->k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; - luaK_codeABC(fs, op, extra, v->u.info, 0); - luaK_reserveregs(fs, 1); - } -} - - -static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { - expdesc e; - check_condition(ls, vkisvar(lh->v.k), "syntax error"); - if (testnext(ls, ',')) { /* assignment -> ',' suffixedexp assignment */ - struct LHS_assign nv; - nv.prev = lh; - suffixedexp(ls, &nv.v); - if (nv.v.k != VINDEXED) - check_conflict(ls, lh, &nv.v); - checklimit(ls->fs, nvars + ls->L->nCcalls, LUAI_MAXCCALLS, - "C levels"); - assignment(ls, &nv, nvars+1); - } - else { /* assignment -> '=' explist */ - int nexps; - checknext(ls, '='); - nexps = explist(ls, &e); - if (nexps != nvars) { - adjust_assign(ls, nvars, nexps, &e); - if (nexps > nvars) - ls->fs->freereg -= nexps - nvars; /* remove extra values */ - } - else { - luaK_setoneret(ls->fs, &e); /* close last expression */ - luaK_storevar(ls->fs, &lh->v, &e); - return; /* avoid default */ - } - } - init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ - luaK_storevar(ls->fs, &lh->v, &e); -} - - -static int cond (LexState *ls) { - /* cond -> exp */ - expdesc v; - expr(ls, &v); /* read condition */ - if (v.k == VNIL) v.k = VFALSE; /* 'falses' are all equal here */ - luaK_goiftrue(ls->fs, &v); - return v.f; -} - - -static void gotostat (LexState *ls, int pc) { - int line = ls->linenumber; - TString *label; - int g; - if (testnext(ls, TK_GOTO)) - label = str_checkname(ls); - else { - luaX_next(ls); /* skip break */ - label = luaS_new(ls->L, "break"); - } - g = newlabelentry(ls, &ls->dyd->gt, label, line, pc); - findlabel(ls, g); /* close it if label already defined */ -} - - -/* check for repeated labels on the same block */ -static void checkrepeated (FuncState *fs, Labellist *ll, TString *label) { - int i; - for (i = fs->bl->firstlabel; i < ll->n; i++) { - if (eqstr(label, ll->arr[i].name)) { - const char *msg = luaO_pushfstring(fs->ls->L, - "label '%s' already defined on line %d", - getstr(label), ll->arr[i].line); - semerror(fs->ls, msg); - } - } -} - - -/* skip no-op statements */ -static void skipnoopstat (LexState *ls) { - while (ls->t.token == ';' || ls->t.token == TK_DBCOLON) - statement(ls); -} - - -static void labelstat (LexState *ls, TString *label, int line) { - /* label -> '::' NAME '::' */ - FuncState *fs = ls->fs; - Labellist *ll = &ls->dyd->label; - int l; /* index of new label being created */ - checkrepeated(fs, ll, label); /* check for repeated labels */ - checknext(ls, TK_DBCOLON); /* skip double colon */ - /* create new entry for this label */ - l = newlabelentry(ls, ll, label, line, fs->pc); - skipnoopstat(ls); /* skip other no-op statements */ - if (block_follow(ls, 0)) { /* label is last no-op statement in the block? */ - /* assume that locals are already out of scope */ - ll->arr[l].nactvar = fs->bl->nactvar; - } - findgotos(ls, &ll->arr[l]); -} - - -static void whilestat (LexState *ls, int line) { - /* whilestat -> WHILE cond DO block END */ - FuncState *fs = ls->fs; - int whileinit; - int condexit; - BlockCnt bl; - luaX_next(ls); /* skip WHILE */ - whileinit = luaK_getlabel(fs); - condexit = cond(ls); - enterblock(fs, &bl, 1); - checknext(ls, TK_DO); - block(ls); - luaK_jumpto(fs, whileinit); - check_match(ls, TK_END, TK_WHILE, line); - leaveblock(fs); - luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ -} - - -static void repeatstat (LexState *ls, int line) { - /* repeatstat -> REPEAT block UNTIL cond */ - int condexit; - FuncState *fs = ls->fs; - int repeat_init = luaK_getlabel(fs); - BlockCnt bl1, bl2; - enterblock(fs, &bl1, 1); /* loop block */ - enterblock(fs, &bl2, 0); /* scope block */ - luaX_next(ls); /* skip REPEAT */ - statlist(ls); - check_match(ls, TK_UNTIL, TK_REPEAT, line); - condexit = cond(ls); /* read condition (inside scope block) */ - if (bl2.upval) /* upvalues? */ - luaK_patchclose(fs, condexit, bl2.nactvar); - leaveblock(fs); /* finish scope */ - luaK_patchlist(fs, condexit, repeat_init); /* close the loop */ - leaveblock(fs); /* finish loop */ -} - - -static int exp1 (LexState *ls) { - expdesc e; - int reg; - expr(ls, &e); - luaK_exp2nextreg(ls->fs, &e); - lua_assert(e.k == VNONRELOC); - reg = e.u.info; - return reg; -} - - -static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { - /* forbody -> DO block */ - BlockCnt bl; - FuncState *fs = ls->fs; - int prep, endfor; - adjustlocalvars(ls, 3); /* control variables */ - checknext(ls, TK_DO); - prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); - enterblock(fs, &bl, 0); /* scope for declared variables */ - adjustlocalvars(ls, nvars); - luaK_reserveregs(fs, nvars); - block(ls); - leaveblock(fs); /* end of scope for declared variables */ - luaK_patchtohere(fs, prep); - if (isnum) /* numeric for? */ - endfor = luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP); - else { /* generic for */ - luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars); - luaK_fixline(fs, line); - endfor = luaK_codeAsBx(fs, OP_TFORLOOP, base + 2, NO_JUMP); - } - luaK_patchlist(fs, endfor, prep + 1); - luaK_fixline(fs, line); -} - - -static void fornum (LexState *ls, TString *varname, int line) { - /* fornum -> NAME = exp1,exp1[,exp1] forbody */ - FuncState *fs = ls->fs; - int base = fs->freereg; - new_localvarliteral(ls, "(for index)"); - new_localvarliteral(ls, "(for limit)"); - new_localvarliteral(ls, "(for step)"); - new_localvar(ls, varname); - checknext(ls, '='); - exp1(ls); /* initial value */ - checknext(ls, ','); - exp1(ls); /* limit */ - if (testnext(ls, ',')) - exp1(ls); /* optional step */ - else { /* default step = 1 */ - luaK_codek(fs, fs->freereg, luaK_intK(fs, 1)); - luaK_reserveregs(fs, 1); - } - forbody(ls, base, line, 1, 1); -} - - -static void forlist (LexState *ls, TString *indexname) { - /* forlist -> NAME {,NAME} IN explist forbody */ - FuncState *fs = ls->fs; - expdesc e; - int nvars = 4; /* gen, state, control, plus at least one declared var */ - int line; - int base = fs->freereg; - /* create control variables */ - new_localvarliteral(ls, "(for generator)"); - new_localvarliteral(ls, "(for state)"); - new_localvarliteral(ls, "(for control)"); - /* create declared variables */ - new_localvar(ls, indexname); - while (testnext(ls, ',')) { - new_localvar(ls, str_checkname(ls)); - nvars++; - } - checknext(ls, TK_IN); - line = ls->linenumber; - adjust_assign(ls, 3, explist(ls, &e), &e); - luaK_checkstack(fs, 3); /* extra space to call generator */ - forbody(ls, base, line, nvars - 3, 0); -} - - -static void forstat (LexState *ls, int line) { - /* forstat -> FOR (fornum | forlist) END */ - FuncState *fs = ls->fs; - TString *varname; - BlockCnt bl; - enterblock(fs, &bl, 1); /* scope for loop and control variables */ - luaX_next(ls); /* skip 'for' */ - varname = str_checkname(ls); /* first variable name */ - switch (ls->t.token) { - case '=': fornum(ls, varname, line); break; - case ',': case TK_IN: forlist(ls, varname); break; - default: luaX_syntaxerror(ls, "'=' or 'in' expected"); - } - check_match(ls, TK_END, TK_FOR, line); - leaveblock(fs); /* loop scope ('break' jumps to this point) */ -} - - -static void test_then_block (LexState *ls, int *escapelist) { - /* test_then_block -> [IF | ELSEIF] cond THEN block */ - BlockCnt bl; - FuncState *fs = ls->fs; - expdesc v; - int jf; /* instruction to skip 'then' code (if condition is false) */ - luaX_next(ls); /* skip IF or ELSEIF */ - expr(ls, &v); /* read condition */ - checknext(ls, TK_THEN); - if (ls->t.token == TK_GOTO || ls->t.token == TK_BREAK) { - luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */ - enterblock(fs, &bl, 0); /* must enter block before 'goto' */ - gotostat(ls, v.t); /* handle goto/break */ - skipnoopstat(ls); /* skip other no-op statements */ - if (block_follow(ls, 0)) { /* 'goto' is the entire block? */ - leaveblock(fs); - return; /* and that is it */ - } - else /* must skip over 'then' part if condition is false */ - jf = luaK_jump(fs); - } - else { /* regular case (not goto/break) */ - luaK_goiftrue(ls->fs, &v); /* skip over block if condition is false */ - enterblock(fs, &bl, 0); - jf = v.f; - } - statlist(ls); /* 'then' part */ - leaveblock(fs); - if (ls->t.token == TK_ELSE || - ls->t.token == TK_ELSEIF) /* followed by 'else'/'elseif'? */ - luaK_concat(fs, escapelist, luaK_jump(fs)); /* must jump over it */ - luaK_patchtohere(fs, jf); -} - - -static void ifstat (LexState *ls, int line) { - /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ - FuncState *fs = ls->fs; - int escapelist = NO_JUMP; /* exit list for finished parts */ - test_then_block(ls, &escapelist); /* IF cond THEN block */ - while (ls->t.token == TK_ELSEIF) - test_then_block(ls, &escapelist); /* ELSEIF cond THEN block */ - if (testnext(ls, TK_ELSE)) - block(ls); /* 'else' part */ - check_match(ls, TK_END, TK_IF, line); - luaK_patchtohere(fs, escapelist); /* patch escape list to 'if' end */ -} - - -static void localfunc (LexState *ls) { - expdesc b; - FuncState *fs = ls->fs; - new_localvar(ls, str_checkname(ls)); /* new local variable */ - adjustlocalvars(ls, 1); /* enter its scope */ - body(ls, &b, 0, ls->linenumber); /* function created in next register */ - /* debug information will only see the variable after this point! */ - getlocvar(fs, b.u.info)->startpc = fs->pc; -} - - -static void localstat (LexState *ls) { - /* stat -> LOCAL NAME {',' NAME} ['=' explist] */ - int nvars = 0; - int nexps; - expdesc e; - do { - new_localvar(ls, str_checkname(ls)); - nvars++; - } while (testnext(ls, ',')); - if (testnext(ls, '=')) - nexps = explist(ls, &e); - else { - e.k = VVOID; - nexps = 0; - } - adjust_assign(ls, nvars, nexps, &e); - adjustlocalvars(ls, nvars); -} - - -static int funcname (LexState *ls, expdesc *v) { - /* funcname -> NAME {fieldsel} [':' NAME] */ - int ismethod = 0; - singlevar(ls, v); - while (ls->t.token == '.') - fieldsel(ls, v); - if (ls->t.token == ':') { - ismethod = 1; - fieldsel(ls, v); - } - return ismethod; -} - - -static void funcstat (LexState *ls, int line) { - /* funcstat -> FUNCTION funcname body */ - int ismethod; - expdesc v, b; - luaX_next(ls); /* skip FUNCTION */ - ismethod = funcname(ls, &v); - body(ls, &b, ismethod, line); - luaK_storevar(ls->fs, &v, &b); - luaK_fixline(ls->fs, line); /* definition "happens" in the first line */ -} - - -static void exprstat (LexState *ls) { - /* stat -> func | assignment */ - FuncState *fs = ls->fs; - struct LHS_assign v; - suffixedexp(ls, &v.v); - if (ls->t.token == '=' || ls->t.token == ',') { /* stat -> assignment ? */ - v.prev = NULL; - assignment(ls, &v, 1); - } - else { /* stat -> func */ - check_condition(ls, v.v.k == VCALL, "syntax error"); - SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ - } -} - - -static void retstat (LexState *ls) { - /* stat -> RETURN [explist] [';'] */ - FuncState *fs = ls->fs; - expdesc e; - int first, nret; /* registers with returned values */ - if (block_follow(ls, 1) || ls->t.token == ';') - first = nret = 0; /* return no values */ - else { - nret = explist(ls, &e); /* optional return values */ - if (hasmultret(e.k)) { - luaK_setmultret(fs, &e); - if (e.k == VCALL && nret == 1) { /* tail call? */ - SET_OPCODE(getcode(fs,&e), OP_TAILCALL); - lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); - } - first = fs->nactvar; - nret = LUA_MULTRET; /* return all values */ - } - else { - if (nret == 1) /* only one single value? */ - first = luaK_exp2anyreg(fs, &e); - else { - luaK_exp2nextreg(fs, &e); /* values must go to the stack */ - first = fs->nactvar; /* return all active values */ - lua_assert(nret == fs->freereg - first); - } - } - } - luaK_ret(fs, first, nret); - testnext(ls, ';'); /* skip optional semicolon */ -} - - -static void statement (LexState *ls) { - int line = ls->linenumber; /* may be needed for error messages */ - enterlevel(ls); - switch (ls->t.token) { - case ';': { /* stat -> ';' (empty statement) */ - luaX_next(ls); /* skip ';' */ - break; - } - case TK_IF: { /* stat -> ifstat */ - ifstat(ls, line); - break; - } - case TK_WHILE: { /* stat -> whilestat */ - whilestat(ls, line); - break; - } - case TK_DO: { /* stat -> DO block END */ - luaX_next(ls); /* skip DO */ - block(ls); - check_match(ls, TK_END, TK_DO, line); - break; - } - case TK_FOR: { /* stat -> forstat */ - forstat(ls, line); - break; - } - case TK_REPEAT: { /* stat -> repeatstat */ - repeatstat(ls, line); - break; - } - case TK_FUNCTION: { /* stat -> funcstat */ - funcstat(ls, line); - break; - } - case TK_LOCAL: { /* stat -> localstat */ - luaX_next(ls); /* skip LOCAL */ - if (testnext(ls, TK_FUNCTION)) /* local function? */ - localfunc(ls); - else - localstat(ls); - break; - } - case TK_DBCOLON: { /* stat -> label */ - luaX_next(ls); /* skip double colon */ - labelstat(ls, str_checkname(ls), line); - break; - } - case TK_RETURN: { /* stat -> retstat */ - luaX_next(ls); /* skip RETURN */ - retstat(ls); - break; - } - case TK_BREAK: /* stat -> breakstat */ - case TK_GOTO: { /* stat -> 'goto' NAME */ - gotostat(ls, luaK_jump(ls->fs)); - break; - } - default: { /* stat -> func | assignment */ - exprstat(ls); - break; - } - } - lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && - ls->fs->freereg >= ls->fs->nactvar); - ls->fs->freereg = ls->fs->nactvar; /* free registers */ - leavelevel(ls); -} - -/* }====================================================================== */ - - -/* -** compiles the main function, which is a regular vararg function with an -** upvalue named LUA_ENV -*/ -static void mainfunc (LexState *ls, FuncState *fs) { - BlockCnt bl; - expdesc v; - open_func(ls, fs, &bl); - fs->f->is_vararg = 1; /* main function is always vararg */ - init_exp(&v, VLOCAL, 0); /* create and... */ - newupvalue(fs, ls->envn, &v); /* ...set environment upvalue */ - luaX_next(ls); /* read first token */ - statlist(ls); /* parse main body */ - check(ls, TK_EOS); - close_func(ls); -} - - -LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, - Dyndata *dyd, const char *name, int firstchar) { - LexState lexstate; - FuncState funcstate; - LClosure *cl = luaF_newLclosure(L, 1); /* create main closure */ - setclLvalue(L, L->top, cl); /* anchor it (to avoid being collected) */ - incr_top(L); - lexstate.h = luaH_new(L); /* create table for scanner */ - sethvalue(L, L->top, lexstate.h); /* anchor it */ - incr_top(L); - funcstate.f = cl->p = luaF_newproto(L); - funcstate.f->source = luaS_new(L, name); /* create and anchor TString */ - lua_assert(iswhite(funcstate.f)); /* do not need barrier here */ - lexstate.buff = buff; - lexstate.dyd = dyd; - dyd->actvar.n = dyd->gt.n = dyd->label.n = 0; - luaX_setinput(L, &lexstate, z, funcstate.f->source, firstchar); - mainfunc(&lexstate, &funcstate); - lua_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs); - /* all scopes should be correctly finished */ - lua_assert(dyd->actvar.n == 0 && dyd->gt.n == 0 && dyd->label.n == 0); - L->top--; /* remove scanner's table */ - return cl; /* closure is on the stack, too */ -} - diff --git a/thirdparty/src/Lua/lparser.h b/thirdparty/src/Lua/lparser.h deleted file mode 100644 index 62c50cac7..000000000 --- a/thirdparty/src/Lua/lparser.h +++ /dev/null @@ -1,120 +0,0 @@ -/* -** $Id: lparser.h,v 1.74 2014/10/25 11:50:46 roberto Exp $ -** Lua Parser -** See Copyright Notice in lua.h -*/ - -#ifndef lparser_h -#define lparser_h - -#include "llimits.h" -#include "lobject.h" -#include "lzio.h" - - -/* -** Expression descriptor -*/ - -typedef enum { - VVOID, /* no value */ - VNIL, - VTRUE, - VFALSE, - VK, /* info = index of constant in 'k' */ - VKFLT, /* nval = numerical float value */ - VKINT, /* nval = numerical integer value */ - VNONRELOC, /* info = result register */ - VLOCAL, /* info = local register */ - VUPVAL, /* info = index of upvalue in 'upvalues' */ - VINDEXED, /* t = table register/upvalue; idx = index R/K */ - VJMP, /* info = instruction pc */ - VRELOCABLE, /* info = instruction pc */ - VCALL, /* info = instruction pc */ - VVARARG /* info = instruction pc */ -} expkind; - - -#define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED) -#define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL) - -typedef struct expdesc { - expkind k; - union { - struct { /* for indexed variables (VINDEXED) */ - short idx; /* index (R/K) */ - lu_byte t; /* table (register or upvalue) */ - lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */ - } ind; - int info; /* for generic use */ - lua_Number nval; /* for VKFLT */ - lua_Integer ival; /* for VKINT */ - } u; - int t; /* patch list of 'exit when true' */ - int f; /* patch list of 'exit when false' */ -} expdesc; - - -/* description of active local variable */ -typedef struct Vardesc { - short idx; /* variable index in stack */ -} Vardesc; - - -/* description of pending goto statements and label statements */ -typedef struct Labeldesc { - TString *name; /* label identifier */ - int pc; /* position in code */ - int line; /* line where it appeared */ - lu_byte nactvar; /* local level where it appears in current block */ -} Labeldesc; - - -/* list of labels or gotos */ -typedef struct Labellist { - Labeldesc *arr; /* array */ - int n; /* number of entries in use */ - int size; /* array size */ -} Labellist; - - -/* dynamic structures used by the parser */ -typedef struct Dyndata { - struct { /* list of active local variables */ - Vardesc *arr; - int n; - int size; - } actvar; - Labellist gt; /* list of pending gotos */ - Labellist label; /* list of active labels */ -} Dyndata; - - -/* control of blocks */ -struct BlockCnt; /* defined in lparser.c */ - - -/* state needed to generate code for a given function */ -typedef struct FuncState { - Proto *f; /* current function header */ - struct FuncState *prev; /* enclosing function */ - struct LexState *ls; /* lexical state */ - struct BlockCnt *bl; /* chain of current blocks */ - int pc; /* next position to code (equivalent to 'ncode') */ - int lasttarget; /* 'label' of last 'jump label' */ - int jpc; /* list of pending jumps to 'pc' */ - int nk; /* number of elements in 'k' */ - int np; /* number of elements in 'p' */ - int firstlocal; /* index of first local var (in Dyndata array) */ - short nlocvars; /* number of elements in 'f->locvars' */ - lu_byte nactvar; /* number of active local variables */ - lu_byte nups; /* number of upvalues */ - lu_byte freereg; /* first free register */ -} FuncState; - - -LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, - Dyndata *dyd, const char *name, int firstchar); - - -#endif diff --git a/thirdparty/src/Lua/lprefix.h b/thirdparty/src/Lua/lprefix.h deleted file mode 100644 index 02daa837f..000000000 --- a/thirdparty/src/Lua/lprefix.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ -** Definitions for Lua code that must come before any other header file -** See Copyright Notice in lua.h -*/ - -#ifndef lprefix_h -#define lprefix_h - - -/* -** Allows POSIX/XSI stuff -*/ -#if !defined(LUA_USE_C89) /* { */ - -#if !defined(_XOPEN_SOURCE) -#define _XOPEN_SOURCE 600 -#elif _XOPEN_SOURCE == 0 -#undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ -#endif - -/* -** Allows manipulation of large files in gcc and some other compilers -*/ -#if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) -#define _LARGEFILE_SOURCE 1 -#define _FILE_OFFSET_BITS 64 -#endif - -#endif /* } */ - - -/* -** Windows stuff -*/ -#if defined(_WIN32) /* { */ - -#if !defined(_CRT_SECURE_NO_WARNINGS) -#define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ -#endif - -#endif /* } */ - -#endif - diff --git a/thirdparty/src/Lua/lstate.cpp b/thirdparty/src/Lua/lstate.cpp deleted file mode 100644 index 8d28a28e3..000000000 --- a/thirdparty/src/Lua/lstate.cpp +++ /dev/null @@ -1,346 +0,0 @@ -/* -** $Id: lstate.c,v 2.127 2014/11/02 19:33:33 roberto Exp $ -** Global State -** See Copyright Notice in lua.h -*/ - -#define lstate_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <stddef.h> -#include <string.h> - -#include <Lua/lua.h> - -#include "lapi.h" -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lgc.h" -#include "llex.h" -#include "lmem.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" - - -#if !defined(LUAI_GCPAUSE) -#define LUAI_GCPAUSE 200 /* 200% */ -#endif - -#if !defined(LUAI_GCMUL) -#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ -#endif - - -#define MEMERRMSG "not enough memory" - - -/* -** a macro to help the creation of a unique random seed when a state is -** created; the seed is used to randomize hashes. -*/ -#if !defined(luai_makeseed) -#include <time.h> -#define luai_makeseed() cast(unsigned int, time(NULL)) -#endif - - - -/* -** thread state + extra space -*/ -typedef struct LX { - lu_byte extra_[LUA_EXTRASPACE]; - lua_State l; -} LX; - - -/* -** Main thread combines a thread state and the global state -*/ -typedef struct LG { - LX l; - global_State g; -} LG; - - - -#define fromstate(L) (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l))) - - -/* -** Compute an initial seed as random as possible. Rely on Address Space -** Layout Randomization (if present) to increase randomness.. -*/ -#define addbuff(b,p,e) \ - { size_t t = cast(size_t, e); \ - memcpy(buff + p, &t, sizeof(t)); p += sizeof(t); } - -static unsigned int makeseed (lua_State *L) { - char buff[4 * sizeof(size_t)]; - unsigned int h = luai_makeseed(); - int p = 0; - addbuff(buff, p, L); /* heap variable */ - addbuff(buff, p, &h); /* local variable */ - addbuff(buff, p, luaO_nilobject); /* global variable */ - addbuff(buff, p, &lua_newstate); /* public function */ - lua_assert(p == sizeof(buff)); - return luaS_hash(buff, p, h); -} - - -/* -** set GCdebt to a new value keeping the value (totalbytes + GCdebt) -** invariant -*/ -void luaE_setdebt (global_State *g, l_mem debt) { - g->totalbytes -= (debt - g->GCdebt); - g->GCdebt = debt; -} - - -CallInfo *luaE_extendCI (lua_State *L) { - CallInfo *ci = luaM_new(L, CallInfo); - lua_assert(L->ci->next == NULL); - L->ci->next = ci; - ci->previous = L->ci; - ci->next = NULL; - return ci; -} - - -/* -** free all CallInfo structures not in use by a thread -*/ -void luaE_freeCI (lua_State *L) { - CallInfo *ci = L->ci; - CallInfo *next = ci->next; - ci->next = NULL; - while ((ci = next) != NULL) { - next = ci->next; - luaM_free(L, ci); - } -} - - -/* -** free half of the CallInfo structures not in use by a thread -*/ -void luaE_shrinkCI (lua_State *L) { - CallInfo *ci = L->ci; - while (ci->next != NULL) { /* while there is 'next' */ - CallInfo *next2 = ci->next->next; /* next's next */ - if (next2 == NULL) break; - luaM_free(L, ci->next); /* remove next */ - ci->next = next2; /* remove 'next' from the list */ - next2->previous = ci; - ci = next2; - } -} - - -static void stack_init (lua_State *L1, lua_State *L) { - int i; CallInfo *ci; - /* initialize stack array */ - L1->stack = luaM_newvector(L, BASIC_STACK_SIZE, TValue); - L1->stacksize = BASIC_STACK_SIZE; - for (i = 0; i < BASIC_STACK_SIZE; i++) - setnilvalue(L1->stack + i); /* erase new stack */ - L1->top = L1->stack; - L1->stack_last = L1->stack + L1->stacksize - EXTRA_STACK; - /* initialize first ci */ - ci = &L1->base_ci; - ci->next = ci->previous = NULL; - ci->callstatus = 0; - ci->func = L1->top; - setnilvalue(L1->top++); /* 'function' entry for this 'ci' */ - ci->top = L1->top + LUA_MINSTACK; - L1->ci = ci; -} - - -static void freestack (lua_State *L) { - if (L->stack == NULL) - return; /* stack not completely built yet */ - L->ci = &L->base_ci; /* free the entire 'ci' list */ - luaE_freeCI(L); - luaM_freearray(L, L->stack, L->stacksize); /* free stack array */ -} - - -/* -** Create registry table and its predefined values -*/ -static void init_registry (lua_State *L, global_State *g) { - TValue temp; - /* create registry */ - Table *registry = luaH_new(L); - sethvalue(L, &g->l_registry, registry); - luaH_resize(L, registry, LUA_RIDX_LAST, 0); - /* registry[LUA_RIDX_MAINTHREAD] = L */ - setthvalue(L, &temp, L); /* temp = L */ - luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &temp); - /* registry[LUA_RIDX_GLOBALS] = table of globals */ - sethvalue(L, &temp, luaH_new(L)); /* temp = new table (global table) */ - luaH_setint(L, registry, LUA_RIDX_GLOBALS, &temp); -} - - -/* -** open parts of the state that may cause memory-allocation errors. -** ('g->version' != NULL flags that the state was completely build) -*/ -static void f_luaopen (lua_State *L, void *ud) { - global_State *g = G(L); - UNUSED(ud); - stack_init(L, L); /* init stack */ - init_registry(L, g); - luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ - luaT_init(L); - luaX_init(L); - /* pre-create memory-error message */ - g->memerrmsg = luaS_newliteral(L, MEMERRMSG); - luaC_fix(L, obj2gco(g->memerrmsg)); /* it should never be collected */ - g->gcrunning = 1; /* allow gc */ - g->version = lua_version(NULL); - luai_userstateopen(L); -} - - -/* -** preinitialize a thread with consistent values without allocating -** any memory (to avoid errors) -*/ -static void preinit_thread (lua_State *L, global_State *g) { - G(L) = g; - L->stack = NULL; - L->ci = NULL; - L->stacksize = 0; - L->twups = L; /* thread has no upvalues */ - L->errorJmp = NULL; - L->nCcalls = 0; - L->hook = NULL; - L->hookmask = 0; - L->basehookcount = 0; - L->allowhook = 1; - resethookcount(L); - L->openupval = NULL; - L->nny = 1; - L->status = LUA_OK; - L->errfunc = 0; -} - - -static void close_state (lua_State *L) { - global_State *g = G(L); - luaF_close(L, L->stack); /* close all upvalues for this thread */ - luaC_freeallobjects(L); /* collect all objects */ - if (g->version) /* closing a fully built state? */ - luai_userstateclose(L); - luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); - luaZ_freebuffer(L, &g->buff); - freestack(L); - lua_assert(gettotalbytes(g) == sizeof(LG)); - (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); /* free main block */ -} - - -LUA_API lua_State *lua_newthread (lua_State *L) { - global_State *g = G(L); - lua_State *L1; - lua_lock(L); - luaC_checkGC(L); - /* create new thread */ - L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; - L1->marked = luaC_white(g); - L1->tt = LUA_TTHREAD; - /* link it on list 'allgc' */ - L1->next = g->allgc; - g->allgc = obj2gco(L1); - /* anchor it on L stack */ - setthvalue(L, L->top, L1); - api_incr_top(L); - preinit_thread(L1, g); - L1->hookmask = L->hookmask; - L1->basehookcount = L->basehookcount; - L1->hook = L->hook; - resethookcount(L1); - /* initialize L1 extra space */ - memcpy(lua_getextraspace(L1), lua_getextraspace(g->mainthread), - LUA_EXTRASPACE); - luai_userstatethread(L, L1); - stack_init(L1, L); /* init stack */ - lua_unlock(L); - return L1; -} - - -void luaE_freethread (lua_State *L, lua_State *L1) { - LX *l = fromstate(L1); - luaF_close(L1, L1->stack); /* close all upvalues for this thread */ - lua_assert(L1->openupval == NULL); - luai_userstatefree(L, L1); - freestack(L1); - luaM_free(L, l); -} - - -LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { - int i; - lua_State *L; - global_State *g; - LG *l = cast(LG *, (*f)(ud, NULL, LUA_TTHREAD, sizeof(LG))); - if (l == NULL) return NULL; - L = &l->l.l; - g = &l->g; - L->next = NULL; - L->tt = LUA_TTHREAD; - g->currentwhite = bitmask(WHITE0BIT); - L->marked = luaC_white(g); - preinit_thread(L, g); - g->frealloc = f; - g->ud = ud; - g->mainthread = L; - g->seed = makeseed(L); - g->gcrunning = 0; /* no GC while building state */ - g->GCestimate = 0; - g->strt.size = g->strt.nuse = 0; - g->strt.hash = NULL; - setnilvalue(&g->l_registry); - luaZ_initbuffer(L, &g->buff); - g->panic = NULL; - g->version = NULL; - g->gcstate = GCSpause; - g->gckind = KGC_NORMAL; - g->allgc = g->finobj = g->tobefnz = g->fixedgc = NULL; - g->sweepgc = NULL; - g->gray = g->grayagain = NULL; - g->weak = g->ephemeron = g->allweak = NULL; - g->twups = NULL; - g->totalbytes = sizeof(LG); - g->GCdebt = 0; - g->gcfinnum = 0; - g->gcpause = LUAI_GCPAUSE; - g->gcstepmul = LUAI_GCMUL; - for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL; - if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) { - /* memory allocation error: free partial state */ - close_state(L); - L = NULL; - } - return L; -} - - -LUA_API void lua_close (lua_State *L) { - L = G(L)->mainthread; /* only the main thread can be closed */ - lua_lock(L); - close_state(L); -} - - diff --git a/thirdparty/src/Lua/lstate.h b/thirdparty/src/Lua/lstate.h deleted file mode 100644 index 2ec3d5d41..000000000 --- a/thirdparty/src/Lua/lstate.h +++ /dev/null @@ -1,223 +0,0 @@ -/* -** $Id: lstate.h,v 2.119 2014/10/30 18:53:28 roberto Exp $ -** Global State -** See Copyright Notice in lua.h -*/ - -#ifndef lstate_h -#define lstate_h - -#include <Lua/lua.h> - -#include "lobject.h" -#include "ltm.h" -#include "lzio.h" - - -/* - -** Some notes about garbage-collected objects: All objects in Lua must -** be kept somehow accessible until being freed, so all objects always -** belong to one (and only one) of these lists, using field 'next' of -** the 'CommonHeader' for the link: -** -** 'allgc': all objects not marked for finalization; -** 'finobj': all objects marked for finalization; -** 'tobefnz': all objects ready to be finalized; -** 'fixedgc': all objects that are not to be collected (currently -** only small strings, such as reserved words). - -*/ - - -struct lua_longjmp; /* defined in ldo.c */ - - - -/* extra stack space to handle TM calls and some other extras */ -#define EXTRA_STACK 5 - - -#define BASIC_STACK_SIZE (2*LUA_MINSTACK) - - -/* kinds of Garbage Collection */ -#define KGC_NORMAL 0 -#define KGC_EMERGENCY 1 /* gc was forced by an allocation failure */ - - -typedef struct stringtable { - TString **hash; - int nuse; /* number of elements */ - int size; -} stringtable; - - -/* -** Information about a call. -** When a thread yields, 'func' is adjusted to pretend that the -** top function has only the yielded values in its stack; in that -** case, the actual 'func' value is saved in field 'extra'. -** When a function calls another with a continuation, 'extra' keeps -** the function index so that, in case of errors, the continuation -** function can be called with the correct top. -*/ -typedef struct CallInfo { - StkId func; /* function index in the stack */ - StkId top; /* top for this function */ - struct CallInfo *previous, *next; /* dynamic call link */ - union { - struct { /* only for Lua functions */ - StkId base; /* base for this function */ - const Instruction *savedpc; - } l; - struct { /* only for C functions */ - lua_KFunction k; /* continuation in case of yields */ - ptrdiff_t old_errfunc; - lua_KContext ctx; /* context info. in case of yields */ - } c; - } u; - ptrdiff_t extra; - short nresults; /* expected number of results from this function */ - lu_byte callstatus; -} CallInfo; - - -/* -** Bits in CallInfo status -*/ -#define CIST_OAH (1<<0) /* original value of 'allowhook' */ -#define CIST_LUA (1<<1) /* call is running a Lua function */ -#define CIST_HOOKED (1<<2) /* call is running a debug hook */ -#define CIST_REENTRY (1<<3) /* call is running on same invocation of - luaV_execute of previous call */ -#define CIST_YPCALL (1<<4) /* call is a yieldable protected call */ -#define CIST_TAIL (1<<5) /* call was tail called */ -#define CIST_HOOKYIELD (1<<6) /* last hook called yielded */ - -#define isLua(ci) ((ci)->callstatus & CIST_LUA) - -/* assume that CIST_OAH has offset 0 and that 'v' is strictly 0/1 */ -#define setoah(st,v) ((st) = ((st) & ~CIST_OAH) | (v)) -#define getoah(st) ((st) & CIST_OAH) - - -/* -** 'global state', shared by all threads of this state -*/ -typedef struct global_State { - lua_Alloc frealloc; /* function to reallocate memory */ - void *ud; /* auxiliary data to 'frealloc' */ - lu_mem totalbytes; /* number of bytes currently allocated - GCdebt */ - l_mem GCdebt; /* bytes allocated not yet compensated by the collector */ - lu_mem GCmemtrav; /* memory traversed by the GC */ - lu_mem GCestimate; /* an estimate of the non-garbage memory in use */ - stringtable strt; /* hash table for strings */ - TValue l_registry; - unsigned int seed; /* randomized seed for hashes */ - lu_byte currentwhite; - lu_byte gcstate; /* state of garbage collector */ - lu_byte gckind; /* kind of GC running */ - lu_byte gcrunning; /* true if GC is running */ - GCObject *allgc; /* list of all collectable objects */ - GCObject **sweepgc; /* current position of sweep in list */ - GCObject *finobj; /* list of collectable objects with finalizers */ - GCObject *gray; /* list of gray objects */ - GCObject *grayagain; /* list of objects to be traversed atomically */ - GCObject *weak; /* list of tables with weak values */ - GCObject *ephemeron; /* list of ephemeron tables (weak keys) */ - GCObject *allweak; /* list of all-weak tables */ - GCObject *tobefnz; /* list of userdata to be GC */ - GCObject *fixedgc; /* list of objects not to be collected */ - struct lua_State *twups; /* list of threads with open upvalues */ - Mbuffer buff; /* temporary buffer for string concatenation */ - unsigned int gcfinnum; /* number of finalizers to call in each GC step */ - int gcpause; /* size of pause between successive GCs */ - int gcstepmul; /* GC 'granularity' */ - lua_CFunction panic; /* to be called in unprotected errors */ - struct lua_State *mainthread; - const lua_Number *version; /* pointer to version number */ - TString *memerrmsg; /* memory-error message */ - TString *tmname[TM_N]; /* array with tag-method names */ - struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */ -} global_State; - - -/* -** 'per thread' state -*/ -struct lua_State { - CommonHeader; - lu_byte status; - StkId top; /* first free slot in the stack */ - global_State *l_G; - CallInfo *ci; /* call info for current function */ - const Instruction *oldpc; /* last pc traced */ - StkId stack_last; /* last free slot in the stack */ - StkId stack; /* stack base */ - UpVal *openupval; /* list of open upvalues in this stack */ - GCObject *gclist; - struct lua_State *twups; /* list of threads with open upvalues */ - struct lua_longjmp *errorJmp; /* current error recover point */ - CallInfo base_ci; /* CallInfo for first level (C calling Lua) */ - lua_Hook hook; - ptrdiff_t errfunc; /* current error handling function (stack index) */ - int stacksize; - int basehookcount; - int hookcount; - unsigned short nny; /* number of non-yieldable calls in stack */ - unsigned short nCcalls; /* number of nested C calls */ - lu_byte hookmask; - lu_byte allowhook; -}; - - -#define G(L) (L->l_G) - - -/* -** Union of all collectable objects (only for conversions) -*/ -union GCUnion { - GCObject gc; /* common header */ - struct TString ts; - struct Udata u; - union Closure cl; - struct Table h; - struct Proto p; - struct lua_State th; /* thread */ -}; - - -#define cast_u(o) cast(union GCUnion *, (o)) - -/* macros to convert a GCObject into a specific value */ -#define gco2ts(o) \ - check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts)) -#define gco2u(o) check_exp((o)->tt == LUA_TUSERDATA, &((cast_u(o))->u)) -#define gco2lcl(o) check_exp((o)->tt == LUA_TLCL, &((cast_u(o))->cl.l)) -#define gco2ccl(o) check_exp((o)->tt == LUA_TCCL, &((cast_u(o))->cl.c)) -#define gco2cl(o) \ - check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl)) -#define gco2t(o) check_exp((o)->tt == LUA_TTABLE, &((cast_u(o))->h)) -#define gco2p(o) check_exp((o)->tt == LUA_TPROTO, &((cast_u(o))->p)) -#define gco2th(o) check_exp((o)->tt == LUA_TTHREAD, &((cast_u(o))->th)) - - -/* macro to convert a Lua object into a GCObject */ -#define obj2gco(v) \ - check_exp(novariant((v)->tt) < LUA_TDEADKEY, (&(cast_u(v)->gc))) - - -/* actual number of total bytes allocated */ -#define gettotalbytes(g) ((g)->totalbytes + (g)->GCdebt) - -LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); -LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); -LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L); -LUAI_FUNC void luaE_freeCI (lua_State *L); -LUAI_FUNC void luaE_shrinkCI (lua_State *L); - - -#endif - diff --git a/thirdparty/src/Lua/lstring.cpp b/thirdparty/src/Lua/lstring.cpp deleted file mode 100644 index 178b62b3b..000000000 --- a/thirdparty/src/Lua/lstring.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* -** $Id: lstring.c,v 2.45 2014/11/02 19:19:04 roberto Exp $ -** String table (keeps all strings handled by Lua) -** See Copyright Notice in lua.h -*/ - -#define lstring_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <string.h> - -#include <Lua/lua.h> - -#include "ldebug.h" -#include "ldo.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" -#include "lstring.h" - - - -/* -** Lua will use at most ~(2^LUAI_HASHLIMIT) bytes from a string to -** compute its hash -*/ -#if !defined(LUAI_HASHLIMIT) -#define LUAI_HASHLIMIT 5 -#endif - - -/* -** equality for long strings -*/ -int luaS_eqlngstr (TString *a, TString *b) { - size_t len = a->len; - lua_assert(a->tt == LUA_TLNGSTR && b->tt == LUA_TLNGSTR); - return (a == b) || /* same instance or... */ - ((len == b->len) && /* equal length and ... */ - (memcmp(getstr(a), getstr(b), len) == 0)); /* equal contents */ -} - - -unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { - unsigned int h = seed ^ cast(unsigned int, l); - size_t l1; - size_t step = (l >> LUAI_HASHLIMIT) + 1; - for (l1 = l; l1 >= step; l1 -= step) - h = h ^ ((h<<5) + (h>>2) + cast_byte(str[l1 - 1])); - return h; -} - - -/* -** resizes the string table -*/ -void luaS_resize (lua_State *L, int newsize) { - int i; - stringtable *tb = &G(L)->strt; - if (newsize > tb->size) { /* grow table if needed */ - luaM_reallocvector(L, tb->hash, tb->size, newsize, TString *); - for (i = tb->size; i < newsize; i++) - tb->hash[i] = NULL; - } - for (i = 0; i < tb->size; i++) { /* rehash */ - TString *p = tb->hash[i]; - tb->hash[i] = NULL; - while (p) { /* for each node in the list */ - TString *hnext = p->hnext; /* save next */ - unsigned int h = lmod(p->hash, newsize); /* new position */ - p->hnext = tb->hash[h]; /* chain it */ - tb->hash[h] = p; - p = hnext; - } - } - if (newsize < tb->size) { /* shrink table if needed */ - /* vanishing slice should be empty */ - lua_assert(tb->hash[newsize] == NULL && tb->hash[tb->size - 1] == NULL); - luaM_reallocvector(L, tb->hash, tb->size, newsize, TString *); - } - tb->size = newsize; -} - - - -/* -** creates a new string object -*/ -static TString *createstrobj (lua_State *L, const char *str, size_t l, - int tag, unsigned int h) { - TString *ts; - GCObject *o; - size_t totalsize; /* total size of TString object */ - totalsize = sizelstring(l); - o = luaC_newobj(L, tag, totalsize); - ts = gco2ts(o); - ts->len = l; - ts->hash = h; - ts->extra = 0; - memcpy(getaddrstr(ts), str, l * sizeof(char)); - getaddrstr(ts)[l] = '\0'; /* ending 0 */ - return ts; -} - - -void luaS_remove (lua_State *L, TString *ts) { - stringtable *tb = &G(L)->strt; - TString **p = &tb->hash[lmod(ts->hash, tb->size)]; - while (*p != ts) /* find previous element */ - p = &(*p)->hnext; - *p = (*p)->hnext; /* remove element from its list */ - tb->nuse--; -} - - -/* -** checks whether short string exists and reuses it or creates a new one -*/ -static TString *internshrstr (lua_State *L, const char *str, size_t l) { - TString *ts; - global_State *g = G(L); - unsigned int h = luaS_hash(str, l, g->seed); - TString **list = &g->strt.hash[lmod(h, g->strt.size)]; - for (ts = *list; ts != NULL; ts = ts->hnext) { - if (l == ts->len && - (memcmp(str, getstr(ts), l * sizeof(char)) == 0)) { - /* found! */ - if (isdead(g, ts)) /* dead (but not collected yet)? */ - changewhite(ts); /* resurrect it */ - return ts; - } - } - if (g->strt.nuse >= g->strt.size && g->strt.size <= MAX_INT/2) { - luaS_resize(L, g->strt.size * 2); - list = &g->strt.hash[lmod(h, g->strt.size)]; /* recompute with new size */ - } - ts = createstrobj(L, str, l, LUA_TSHRSTR, h); - ts->hnext = *list; - *list = ts; - g->strt.nuse++; - return ts; -} - - -/* -** new string (with explicit length) -*/ -TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { - if (l <= LUAI_MAXSHORTLEN) /* short string? */ - return internshrstr(L, str, l); - else { - if (l + 1 > (MAX_SIZE - sizeof(TString))/sizeof(char)) - luaM_toobig(L); - return createstrobj(L, str, l, LUA_TLNGSTR, G(L)->seed); - } -} - - -/* -** new zero-terminated string -*/ -TString *luaS_new (lua_State *L, const char *str) { - return luaS_newlstr(L, str, strlen(str)); -} - - -Udata *luaS_newudata (lua_State *L, size_t s) { - Udata *u; - GCObject *o; - if (s > MAX_SIZE - sizeof(Udata)) - luaM_toobig(L); - o = luaC_newobj(L, LUA_TUSERDATA, sizeludata(s)); - u = gco2u(o); - u->len = s; - u->metatable = NULL; - setuservalue(L, u, luaO_nilobject); - return u; -} - diff --git a/thirdparty/src/Lua/lstring.h b/thirdparty/src/Lua/lstring.h deleted file mode 100644 index d3f04caf7..000000000 --- a/thirdparty/src/Lua/lstring.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -** $Id: lstring.h,v 1.56 2014/07/18 14:46:47 roberto Exp $ -** String table (keep all strings handled by Lua) -** See Copyright Notice in lua.h -*/ - -#ifndef lstring_h -#define lstring_h - -#include "lgc.h" -#include "lobject.h" -#include "lstate.h" - - -#define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) -#define sizestring(s) sizelstring((s)->len) - -#define sizeludata(l) (sizeof(union UUdata) + (l)) -#define sizeudata(u) sizeludata((u)->len) - -#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ - (sizeof(s)/sizeof(char))-1)) - - -/* -** test whether a string is a reserved word -*/ -#define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) - - -/* -** equality for short strings, which are always internalized -*/ -#define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) - - -LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); -LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); -LUAI_FUNC void luaS_resize (lua_State *L, int newsize); -LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); -LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); -LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); -LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); - - -#endif diff --git a/thirdparty/src/Lua/lstrlib.cpp b/thirdparty/src/Lua/lstrlib.cpp deleted file mode 100644 index b22729ad2..000000000 --- a/thirdparty/src/Lua/lstrlib.cpp +++ /dev/null @@ -1,1431 +0,0 @@ -/* -** $Id: lstrlib.c,v 1.221 2014/12/11 14:03:07 roberto Exp $ -** Standard library for string operations and pattern-matching -** See Copyright Notice in lua.h -*/ - -#define lstrlib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include <ctype.h> -#include <limits.h> -#include <stddef.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <Lua/lua.h> - -#include <Lua/lauxlib.h> -#include <Lua/lualib.h> - - -/* -** maximum number of captures that a pattern can do during -** pattern-matching. This limit is arbitrary. -*/ -#if !defined(LUA_MAXCAPTURES) -#define LUA_MAXCAPTURES 32 -#endif - - -/* macro to 'unsign' a character */ -#define uchar(c) ((unsigned char)(c)) - - -/* -** Some sizes are better limited to fit in 'int', but must also fit in -** 'size_t'. (We assume that 'lua_Integer' cannot be smaller than 'int'.) -*/ -#define MAXSIZE \ - (sizeof(size_t) < sizeof(int) ? (~(size_t)0) : (size_t)(INT_MAX)) - - - - -static int str_len (lua_State *L) { - size_t l; - luaL_checklstring(L, 1, &l); - lua_pushinteger(L, (lua_Integer)l); - return 1; -} - - -/* translate a relative string position: negative means back from end */ -static lua_Integer posrelat (lua_Integer pos, size_t len) { - if (pos >= 0) return pos; - else if (0u - (size_t)pos > len) return 0; - else return (lua_Integer)len + pos + 1; -} - - -static int str_sub (lua_State *L) { - size_t l; - const char *s = luaL_checklstring(L, 1, &l); - lua_Integer start = posrelat(luaL_checkinteger(L, 2), l); - lua_Integer end = posrelat(luaL_optinteger(L, 3, -1), l); - if (start < 1) start = 1; - if (end > (lua_Integer)l) end = l; - if (start <= end) - lua_pushlstring(L, s + start - 1, (size_t)(end - start + 1)); - else lua_pushliteral(L, ""); - return 1; -} - - -static int str_reverse (lua_State *L) { - size_t l, i; - luaL_Buffer b; - const char *s = luaL_checklstring(L, 1, &l); - char *p = luaL_buffinitsize(L, &b, l); - for (i = 0; i < l; i++) - p[i] = s[l - i - 1]; - luaL_pushresultsize(&b, l); - return 1; -} - - -static int str_lower (lua_State *L) { - size_t l; - size_t i; - luaL_Buffer b; - const char *s = luaL_checklstring(L, 1, &l); - char *p = luaL_buffinitsize(L, &b, l); - for (i=0; i<l; i++) - p[i] = tolower(uchar(s[i])); - luaL_pushresultsize(&b, l); - return 1; -} - - -static int str_upper (lua_State *L) { - size_t l; - size_t i; - luaL_Buffer b; - const char *s = luaL_checklstring(L, 1, &l); - char *p = luaL_buffinitsize(L, &b, l); - for (i=0; i<l; i++) - p[i] = toupper(uchar(s[i])); - luaL_pushresultsize(&b, l); - return 1; -} - - -static int str_rep (lua_State *L) { - size_t l, lsep; - const char *s = luaL_checklstring(L, 1, &l); - lua_Integer n = luaL_checkinteger(L, 2); - const char *sep = luaL_optlstring(L, 3, "", &lsep); - if (n <= 0) lua_pushliteral(L, ""); - else if (l + lsep < l || l + lsep > MAXSIZE / n) /* may overflow? */ - return luaL_error(L, "resulting string too large"); - else { - size_t totallen = (size_t)n * l + (size_t)(n - 1) * lsep; - luaL_Buffer b; - char *p = luaL_buffinitsize(L, &b, totallen); - while (n-- > 1) { /* first n-1 copies (followed by separator) */ - memcpy(p, s, l * sizeof(char)); p += l; - if (lsep > 0) { /* empty 'memcpy' is not that cheap */ - memcpy(p, sep, lsep * sizeof(char)); - p += lsep; - } - } - memcpy(p, s, l * sizeof(char)); /* last copy (not followed by separator) */ - luaL_pushresultsize(&b, totallen); - } - return 1; -} - - -static int str_byte (lua_State *L) { - size_t l; - const char *s = luaL_checklstring(L, 1, &l); - lua_Integer posi = posrelat(luaL_optinteger(L, 2, 1), l); - lua_Integer pose = posrelat(luaL_optinteger(L, 3, posi), l); - int n, i; - if (posi < 1) posi = 1; - if (pose > (lua_Integer)l) pose = l; - if (posi > pose) return 0; /* empty interval; return no values */ - n = (int)(pose - posi + 1); - if (posi + n <= pose) /* arithmetic overflow? */ - return luaL_error(L, "string slice too long"); - luaL_checkstack(L, n, "string slice too long"); - for (i=0; i<n; i++) - lua_pushinteger(L, uchar(s[posi+i-1])); - return n; -} - - -static int str_char (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - int i; - luaL_Buffer b; - char *p = luaL_buffinitsize(L, &b, n); - for (i=1; i<=n; i++) { - lua_Integer c = luaL_checkinteger(L, i); - luaL_argcheck(L, uchar(c) == c, i, "value out of range"); - p[i - 1] = uchar(c); - } - luaL_pushresultsize(&b, n); - return 1; -} - - -static int writer (lua_State *L, const void *b, size_t size, void *B) { - (void)L; - luaL_addlstring((luaL_Buffer *) B, (const char *)b, size); - return 0; -} - - -static int str_dump (lua_State *L) { - luaL_Buffer b; - int strip = lua_toboolean(L, 2); - luaL_checktype(L, 1, LUA_TFUNCTION); - lua_settop(L, 1); - luaL_buffinit(L,&b); - if (lua_dump(L, writer, &b, strip) != 0) - return luaL_error(L, "unable to dump given function"); - luaL_pushresult(&b); - return 1; -} - - - -/* -** {====================================================== -** PATTERN MATCHING -** ======================================================= -*/ - - -#define CAP_UNFINISHED (-1) -#define CAP_POSITION (-2) - - -typedef struct MatchState { - int matchdepth; /* control for recursive depth (to avoid C stack overflow) */ - const char *src_init; /* init of source string */ - const char *src_end; /* end ('\0') of source string */ - const char *p_end; /* end ('\0') of pattern */ - lua_State *L; - int level; /* total number of captures (finished or unfinished) */ - struct { - const char *init; - ptrdiff_t len; - } capture[LUA_MAXCAPTURES]; -} MatchState; - - -/* recursive function */ -static const char *match (MatchState *ms, const char *s, const char *p); - - -/* maximum recursion depth for 'match' */ -#if !defined(MAXCCALLS) -#define MAXCCALLS 200 -#endif - - -#define L_ESC '%' -#define SPECIALS "^$*+?.([%-" - - -static int check_capture (MatchState *ms, int l) { - l -= '1'; - if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED) - return luaL_error(ms->L, "invalid capture index %%%d", l + 1); - return l; -} - - -static int capture_to_close (MatchState *ms) { - int level = ms->level; - for (level--; level>=0; level--) - if (ms->capture[level].len == CAP_UNFINISHED) return level; - return luaL_error(ms->L, "invalid pattern capture"); -} - - -static const char *classend (MatchState *ms, const char *p) { - switch (*p++) { - case L_ESC: { - if (p == ms->p_end) - luaL_error(ms->L, "malformed pattern (ends with '%%')"); - return p+1; - } - case '[': { - if (*p == '^') p++; - do { /* look for a ']' */ - if (p == ms->p_end) - luaL_error(ms->L, "malformed pattern (missing ']')"); - if (*(p++) == L_ESC && p < ms->p_end) - p++; /* skip escapes (e.g. '%]') */ - } while (*p != ']'); - return p+1; - } - default: { - return p; - } - } -} - - -static int match_class (int c, int cl) { - int res; - switch (tolower(cl)) { - case 'a' : res = isalpha(c); break; - case 'c' : res = iscntrl(c); break; - case 'd' : res = isdigit(c); break; - case 'g' : res = isgraph(c); break; - case 'l' : res = islower(c); break; - case 'p' : res = ispunct(c); break; - case 's' : res = isspace(c); break; - case 'u' : res = isupper(c); break; - case 'w' : res = isalnum(c); break; - case 'x' : res = isxdigit(c); break; - case 'z' : res = (c == 0); break; /* deprecated option */ - default: return (cl == c); - } - return (islower(cl) ? res : !res); -} - - -static int matchbracketclass (int c, const char *p, const char *ec) { - int sig = 1; - if (*(p+1) == '^') { - sig = 0; - p++; /* skip the '^' */ - } - while (++p < ec) { - if (*p == L_ESC) { - p++; - if (match_class(c, uchar(*p))) - return sig; - } - else if ((*(p+1) == '-') && (p+2 < ec)) { - p+=2; - if (uchar(*(p-2)) <= c && c <= uchar(*p)) - return sig; - } - else if (uchar(*p) == c) return sig; - } - return !sig; -} - - -static int singlematch (MatchState *ms, const char *s, const char *p, - const char *ep) { - if (s >= ms->src_end) - return 0; - else { - int c = uchar(*s); - switch (*p) { - case '.': return 1; /* matches any char */ - case L_ESC: return match_class(c, uchar(*(p+1))); - case '[': return matchbracketclass(c, p, ep-1); - default: return (uchar(*p) == c); - } - } -} - - -static const char *matchbalance (MatchState *ms, const char *s, - const char *p) { - if (p >= ms->p_end - 1) - luaL_error(ms->L, "malformed pattern (missing arguments to '%%b')"); - if (*s != *p) return NULL; - else { - int b = *p; - int e = *(p+1); - int cont = 1; - while (++s < ms->src_end) { - if (*s == e) { - if (--cont == 0) return s+1; - } - else if (*s == b) cont++; - } - } - return NULL; /* string ends out of balance */ -} - - -static const char *max_expand (MatchState *ms, const char *s, - const char *p, const char *ep) { - ptrdiff_t i = 0; /* counts maximum expand for item */ - while (singlematch(ms, s + i, p, ep)) - i++; - /* keeps trying to match with the maximum repetitions */ - while (i>=0) { - const char *res = match(ms, (s+i), ep+1); - if (res) return res; - i--; /* else didn't match; reduce 1 repetition to try again */ - } - return NULL; -} - - -static const char *min_expand (MatchState *ms, const char *s, - const char *p, const char *ep) { - for (;;) { - const char *res = match(ms, s, ep+1); - if (res != NULL) - return res; - else if (singlematch(ms, s, p, ep)) - s++; /* try with one more repetition */ - else return NULL; - } -} - - -static const char *start_capture (MatchState *ms, const char *s, - const char *p, int what) { - const char *res; - int level = ms->level; - if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); - ms->capture[level].init = s; - ms->capture[level].len = what; - ms->level = level+1; - if ((res=match(ms, s, p)) == NULL) /* match failed? */ - ms->level--; /* undo capture */ - return res; -} - - -static const char *end_capture (MatchState *ms, const char *s, - const char *p) { - int l = capture_to_close(ms); - const char *res; - ms->capture[l].len = s - ms->capture[l].init; /* close capture */ - if ((res = match(ms, s, p)) == NULL) /* match failed? */ - ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ - return res; -} - - -static const char *match_capture (MatchState *ms, const char *s, int l) { - size_t len; - l = check_capture(ms, l); - len = ms->capture[l].len; - if ((size_t)(ms->src_end-s) >= len && - memcmp(ms->capture[l].init, s, len) == 0) - return s+len; - else return NULL; -} - - -static const char *match (MatchState *ms, const char *s, const char *p) { - if (ms->matchdepth-- == 0) - luaL_error(ms->L, "pattern too complex"); - init: /* using goto's to optimize tail recursion */ - if (p != ms->p_end) { /* end of pattern? */ - switch (*p) { - case '(': { /* start capture */ - if (*(p + 1) == ')') /* position capture? */ - s = start_capture(ms, s, p + 2, CAP_POSITION); - else - s = start_capture(ms, s, p + 1, CAP_UNFINISHED); - break; - } - case ')': { /* end capture */ - s = end_capture(ms, s, p + 1); - break; - } - case '$': { - if ((p + 1) != ms->p_end) /* is the '$' the last char in pattern? */ - goto dflt; /* no; go to default */ - s = (s == ms->src_end) ? s : NULL; /* check end of string */ - break; - } - case L_ESC: { /* escaped sequences not in the format class[*+?-]? */ - switch (*(p + 1)) { - case 'b': { /* balanced string? */ - s = matchbalance(ms, s, p + 2); - if (s != NULL) { - p += 4; goto init; /* return match(ms, s, p + 4); */ - } /* else fail (s == NULL) */ - break; - } - case 'f': { /* frontier? */ - const char *ep; char previous; - p += 2; - if (*p != '[') - luaL_error(ms->L, "missing '[' after '%%f' in pattern"); - ep = classend(ms, p); /* points to what is next */ - previous = (s == ms->src_init) ? '\0' : *(s - 1); - if (!matchbracketclass(uchar(previous), p, ep - 1) && - matchbracketclass(uchar(*s), p, ep - 1)) { - p = ep; goto init; /* return match(ms, s, ep); */ - } - s = NULL; /* match failed */ - break; - } - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': { /* capture results (%0-%9)? */ - s = match_capture(ms, s, uchar(*(p + 1))); - if (s != NULL) { - p += 2; goto init; /* return match(ms, s, p + 2) */ - } - break; - } - default: goto dflt; - } - break; - } - default: dflt: { /* pattern class plus optional suffix */ - const char *ep = classend(ms, p); /* points to optional suffix */ - /* does not match at least once? */ - if (!singlematch(ms, s, p, ep)) { - if (*ep == '*' || *ep == '?' || *ep == '-') { /* accept empty? */ - p = ep + 1; goto init; /* return match(ms, s, ep + 1); */ - } - else /* '+' or no suffix */ - s = NULL; /* fail */ - } - else { /* matched once */ - switch (*ep) { /* handle optional suffix */ - case '?': { /* optional */ - const char *res; - if ((res = match(ms, s + 1, ep + 1)) != NULL) - s = res; - else { - p = ep + 1; goto init; /* else return match(ms, s, ep + 1); */ - } - break; - } - case '+': /* 1 or more repetitions */ - s++; /* 1 match already done */ - /* go through */ - case '*': /* 0 or more repetitions */ - s = max_expand(ms, s, p, ep); - break; - case '-': /* 0 or more repetitions (minimum) */ - s = min_expand(ms, s, p, ep); - break; - default: /* no suffix */ - s++; p = ep; goto init; /* return match(ms, s + 1, ep); */ - } - } - break; - } - } - } - ms->matchdepth++; - return s; -} - - - -static const char *lmemfind (const char *s1, size_t l1, - const char *s2, size_t l2) { - if (l2 == 0) return s1; /* empty strings are everywhere */ - else if (l2 > l1) return NULL; /* avoids a negative 'l1' */ - else { - const char *init; /* to search for a '*s2' inside 's1' */ - l2--; /* 1st char will be checked by 'memchr' */ - l1 = l1-l2; /* 's2' cannot be found after that */ - while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { - init++; /* 1st char is already checked */ - if (memcmp(init, s2+1, l2) == 0) - return init-1; - else { /* correct 'l1' and 's1' to try again */ - l1 -= init-s1; - s1 = init; - } - } - return NULL; /* not found */ - } -} - - -static void push_onecapture (MatchState *ms, int i, const char *s, - const char *e) { - if (i >= ms->level) { - if (i == 0) /* ms->level == 0, too */ - lua_pushlstring(ms->L, s, e - s); /* add whole match */ - else - luaL_error(ms->L, "invalid capture index %%%d", i + 1); - } - else { - ptrdiff_t l = ms->capture[i].len; - if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); - if (l == CAP_POSITION) - lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); - else - lua_pushlstring(ms->L, ms->capture[i].init, l); - } -} - - -static int push_captures (MatchState *ms, const char *s, const char *e) { - int i; - int nlevels = (ms->level == 0 && s) ? 1 : ms->level; - luaL_checkstack(ms->L, nlevels, "too many captures"); - for (i = 0; i < nlevels; i++) - push_onecapture(ms, i, s, e); - return nlevels; /* number of strings pushed */ -} - - -/* check whether pattern has no special characters */ -static int nospecials (const char *p, size_t l) { - size_t upto = 0; - do { - if (strpbrk(p + upto, SPECIALS)) - return 0; /* pattern has a special character */ - upto += strlen(p + upto) + 1; /* may have more after \0 */ - } while (upto <= l); - return 1; /* no special chars found */ -} - - -static int str_find_aux (lua_State *L, int find) { - size_t ls, lp; - const char *s = luaL_checklstring(L, 1, &ls); - const char *p = luaL_checklstring(L, 2, &lp); - lua_Integer init = posrelat(luaL_optinteger(L, 3, 1), ls); - if (init < 1) init = 1; - else if (init > (lua_Integer)ls + 1) { /* start after string's end? */ - lua_pushnil(L); /* cannot find anything */ - return 1; - } - /* explicit request or no special characters? */ - if (find && (lua_toboolean(L, 4) || nospecials(p, lp))) { - /* do a plain search */ - const char *s2 = lmemfind(s + init - 1, ls - (size_t)init + 1, p, lp); - if (s2) { - lua_pushinteger(L, s2 - s + 1); - lua_pushinteger(L, s2 - s + lp); - return 2; - } - } - else { - MatchState ms; - const char *s1 = s + init - 1; - int anchor = (*p == '^'); - if (anchor) { - p++; lp--; /* skip anchor character */ - } - ms.L = L; - ms.matchdepth = MAXCCALLS; - ms.src_init = s; - ms.src_end = s + ls; - ms.p_end = p + lp; - do { - const char *res; - ms.level = 0; - lua_assert(ms.matchdepth == MAXCCALLS); - if ((res=match(&ms, s1, p)) != NULL) { - if (find) { - lua_pushinteger(L, s1 - s + 1); /* start */ - lua_pushinteger(L, res - s); /* end */ - return push_captures(&ms, NULL, 0) + 2; - } - else - return push_captures(&ms, s1, res); - } - } while (s1++ < ms.src_end && !anchor); - } - lua_pushnil(L); /* not found */ - return 1; -} - - -static int str_find (lua_State *L) { - return str_find_aux(L, 1); -} - - -static int str_match (lua_State *L) { - return str_find_aux(L, 0); -} - - -static int gmatch_aux (lua_State *L) { - MatchState ms; - size_t ls, lp; - const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); - const char *p = lua_tolstring(L, lua_upvalueindex(2), &lp); - const char *src; - ms.L = L; - ms.matchdepth = MAXCCALLS; - ms.src_init = s; - ms.src_end = s+ls; - ms.p_end = p + lp; - for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); - src <= ms.src_end; - src++) { - const char *e; - ms.level = 0; - lua_assert(ms.matchdepth == MAXCCALLS); - if ((e = match(&ms, src, p)) != NULL) { - lua_Integer newstart = e-s; - if (e == src) newstart++; /* empty match? go at least one position */ - lua_pushinteger(L, newstart); - lua_replace(L, lua_upvalueindex(3)); - return push_captures(&ms, src, e); - } - } - return 0; /* not found */ -} - - -static int gmatch (lua_State *L) { - luaL_checkstring(L, 1); - luaL_checkstring(L, 2); - lua_settop(L, 2); - lua_pushinteger(L, 0); - lua_pushcclosure(L, gmatch_aux, 3); - return 1; -} - - -static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, - const char *e) { - size_t l, i; - lua_State *L = ms->L; - const char *news = lua_tolstring(L, 3, &l); - for (i = 0; i < l; i++) { - if (news[i] != L_ESC) - luaL_addchar(b, news[i]); - else { - i++; /* skip ESC */ - if (!isdigit(uchar(news[i]))) { - if (news[i] != L_ESC) - luaL_error(L, "invalid use of '%c' in replacement string", L_ESC); - luaL_addchar(b, news[i]); - } - else if (news[i] == '0') - luaL_addlstring(b, s, e - s); - else { - push_onecapture(ms, news[i] - '1', s, e); - luaL_tolstring(L, -1, NULL); /* if number, convert it to string */ - lua_remove(L, -2); /* remove original value */ - luaL_addvalue(b); /* add capture to accumulated result */ - } - } - } -} - - -static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, - const char *e, int tr) { - lua_State *L = ms->L; - switch (tr) { - case LUA_TFUNCTION: { - int n; - lua_pushvalue(L, 3); - n = push_captures(ms, s, e); - lua_call(L, n, 1); - break; - } - case LUA_TTABLE: { - push_onecapture(ms, 0, s, e); - lua_gettable(L, 3); - break; - } - default: { /* LUA_TNUMBER or LUA_TSTRING */ - add_s(ms, b, s, e); - return; - } - } - if (!lua_toboolean(L, -1)) { /* nil or false? */ - lua_pop(L, 1); - lua_pushlstring(L, s, e - s); /* keep original text */ - } - else if (!lua_isstring(L, -1)) - luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); - luaL_addvalue(b); /* add result to accumulator */ -} - - -static int str_gsub (lua_State *L) { - size_t srcl, lp; - const char *src = luaL_checklstring(L, 1, &srcl); - const char *p = luaL_checklstring(L, 2, &lp); - int tr = lua_type(L, 3); - lua_Integer max_s = luaL_optinteger(L, 4, srcl + 1); - int anchor = (*p == '^'); - lua_Integer n = 0; - MatchState ms; - luaL_Buffer b; - luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || - tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, - "string/function/table expected"); - luaL_buffinit(L, &b); - if (anchor) { - p++; lp--; /* skip anchor character */ - } - ms.L = L; - ms.matchdepth = MAXCCALLS; - ms.src_init = src; - ms.src_end = src+srcl; - ms.p_end = p + lp; - while (n < max_s) { - const char *e; - ms.level = 0; - lua_assert(ms.matchdepth == MAXCCALLS); - e = match(&ms, src, p); - if (e) { - n++; - add_value(&ms, &b, src, e, tr); - } - if (e && e>src) /* non empty match? */ - src = e; /* skip it */ - else if (src < ms.src_end) - luaL_addchar(&b, *src++); - else break; - if (anchor) break; - } - luaL_addlstring(&b, src, ms.src_end-src); - luaL_pushresult(&b); - lua_pushinteger(L, n); /* number of substitutions */ - return 2; -} - -/* }====================================================== */ - - - -/* -** {====================================================== -** STRING FORMAT -** ======================================================= -*/ - -/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ -#define MAX_ITEM \ -(sizeof(lua_Number) <= 4 ? 150 : sizeof(lua_Number) <= 8 ? 450 : 5050) - -/* valid flags in a format specification */ -#define FLAGS "-+ #0" - -/* -** maximum size of each format specification (such as "%-099.99d") -** (+2 for length modifiers; +10 accounts for %99.99x plus margin of error) -*/ -#define MAX_FORMAT (sizeof(FLAGS) + 2 + 10) - - -static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { - size_t l; - const char *s = luaL_checklstring(L, arg, &l); - luaL_addchar(b, '"'); - while (l--) { - if (*s == '"' || *s == '\\' || *s == '\n') { - luaL_addchar(b, '\\'); - luaL_addchar(b, *s); - } - else if (*s == '\0' || iscntrl(uchar(*s))) { - char buff[10]; - if (!isdigit(uchar(*(s+1)))) - sprintf(buff, "\\%d", (int)uchar(*s)); - else - sprintf(buff, "\\%03d", (int)uchar(*s)); - luaL_addstring(b, buff); - } - else - luaL_addchar(b, *s); - s++; - } - luaL_addchar(b, '"'); -} - -static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { - const char *p = strfrmt; - while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ - if ((size_t)(p - strfrmt) >= sizeof(FLAGS)/sizeof(char)) - luaL_error(L, "invalid format (repeated flags)"); - if (isdigit(uchar(*p))) p++; /* skip width */ - if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ - if (*p == '.') { - p++; - if (isdigit(uchar(*p))) p++; /* skip precision */ - if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ - } - if (isdigit(uchar(*p))) - luaL_error(L, "invalid format (width or precision too long)"); - *(form++) = '%'; - memcpy(form, strfrmt, (p - strfrmt + 1) * sizeof(char)); - form += p - strfrmt + 1; - *form = '\0'; - return p; -} - - -/* -** add length modifier into formats -*/ -static void addlenmod (char *form, const char *lenmod) { - size_t l = strlen(form); - size_t lm = strlen(lenmod); - char spec = form[l - 1]; - strcpy(form + l - 1, lenmod); - form[l + lm - 1] = spec; - form[l + lm] = '\0'; -} - - -static int str_format (lua_State *L) { - int top = lua_gettop(L); - int arg = 1; - size_t sfl; - const char *strfrmt = luaL_checklstring(L, arg, &sfl); - const char *strfrmt_end = strfrmt+sfl; - luaL_Buffer b; - luaL_buffinit(L, &b); - while (strfrmt < strfrmt_end) { - if (*strfrmt != L_ESC) - luaL_addchar(&b, *strfrmt++); - else if (*++strfrmt == L_ESC) - luaL_addchar(&b, *strfrmt++); /* %% */ - else { /* format item */ - char form[MAX_FORMAT]; /* to store the format ('%...') */ - char *buff = luaL_prepbuffsize(&b, MAX_ITEM); /* to put formatted item */ - int nb = 0; /* number of bytes in added item */ - if (++arg > top) - luaL_argerror(L, arg, "no value"); - strfrmt = scanformat(L, strfrmt, form); - switch (*strfrmt++) { - case 'c': { - nb = sprintf(buff, form, (int)luaL_checkinteger(L, arg)); - break; - } - case 'd': case 'i': - case 'o': case 'u': case 'x': case 'X': { - lua_Integer n = luaL_checkinteger(L, arg); - addlenmod(form, LUA_INTEGER_FRMLEN); - nb = sprintf(buff, form, n); - break; - } -#if defined(LUA_USE_AFORMAT) - case 'a': case 'A': -#endif - case 'e': case 'E': case 'f': - case 'g': case 'G': { - addlenmod(form, LUA_NUMBER_FRMLEN); - nb = sprintf(buff, form, luaL_checknumber(L, arg)); - break; - } - case 'q': { - addquoted(L, &b, arg); - break; - } - case 's': { - size_t l; - const char *s = luaL_tolstring(L, arg, &l); - if (!strchr(form, '.') && l >= 100) { - /* no precision and string is too long to be formatted; - keep original string */ - luaL_addvalue(&b); - break; - } - else { - nb = sprintf(buff, form, s); - lua_pop(L, 1); /* remove result from 'luaL_tolstring' */ - break; - } - } - default: { /* also treat cases 'pnLlh' */ - return luaL_error(L, "invalid option '%%%c' to 'format'", - *(strfrmt - 1)); - } - } - luaL_addsize(&b, nb); - } - } - luaL_pushresult(&b); - return 1; -} - -/* }====================================================== */ - - -/* -** {====================================================== -** PACK/UNPACK -** ======================================================= -*/ - - -/* value used for padding */ -#if !defined(LUA_PACKPADBYTE) -#define LUA_PACKPADBYTE 0x00 -#endif - -/* maximum size for the binary representation of an integer */ -#define MAXINTSIZE 16 - -/* number of bits in a character */ -#define NB CHAR_BIT - -/* mask for one character (NB 1's) */ -#define MC ((1 << NB) - 1) - -/* size of a lua_Integer */ -#define SZINT ((int)sizeof(lua_Integer)) - - -/* dummy union to get native endianness */ -static const union { - int dummy; - char little; /* true iff machine is little endian */ -} nativeendian = {1}; - - -/* dummy structure to get native alignment requirements */ -struct cD { - char c; - union { double d; void *p; lua_Integer i; lua_Number n; } u; -}; - -#define MAXALIGN (offsetof(struct cD, u)) - - -/* -** Union for serializing floats -*/ -typedef union Ftypes { - float f; - double d; - lua_Number n; - char buff[5 * sizeof(lua_Number)]; /* enough for any float type */ -} Ftypes; - - -/* -** information to pack/unpack stuff -*/ -typedef struct Header { - lua_State *L; - int islittle; - int maxalign; -} Header; - - -/* -** options for pack/unpack -*/ -typedef enum KOption { - Kint, /* signed integers */ - Kuint, /* unsigned integers */ - Kfloat, /* floating-point numbers */ - Kchar, /* fixed-length strings */ - Kstring, /* strings with prefixed length */ - Kzstr, /* zero-terminated strings */ - Kpadding, /* padding */ - Kpaddalign, /* padding for alignment */ - Knop /* no-op (configuration or spaces) */ -} KOption; - - -/* -** Read an integer numeral from string 'fmt' or return 'df' if -** there is no numeral -*/ -static int digit (int c) { return '0' <= c && c <= '9'; } - -static int getnum (const char **fmt, int df) { - if (!digit(**fmt)) /* no number? */ - return df; /* return default value */ - else { - int a = 0; - do { - a = a*10 + (*((*fmt)++) - '0'); - } while (digit(**fmt) && a <= ((int)MAXSIZE - 9)/10); - return a; - } -} - - -/* -** Read an integer numeral and raises an error if it is larger -** than the maximum size for integers. -*/ -static int getnumlimit (Header *h, const char **fmt, int df) { - int sz = getnum(fmt, df); - if (sz > MAXINTSIZE || sz <= 0) - luaL_error(h->L, "integral size (%d) out of limits [1,%d]", - sz, MAXINTSIZE); - return sz; -} - - -/* -** Initialize Header -*/ -static void initheader (lua_State *L, Header *h) { - h->L = L; - h->islittle = nativeendian.little; - h->maxalign = 1; -} - - -/* -** Read and classify next option. 'size' is filled with option's size. -*/ -static KOption getoption (Header *h, const char **fmt, int *size) { - int opt = *((*fmt)++); - *size = 0; /* default */ - switch (opt) { - case 'b': *size = sizeof(char); return Kint; - case 'B': *size = sizeof(char); return Kuint; - case 'h': *size = sizeof(short); return Kint; - case 'H': *size = sizeof(short); return Kuint; - case 'l': *size = sizeof(long); return Kint; - case 'L': *size = sizeof(long); return Kuint; - case 'j': *size = sizeof(lua_Integer); return Kint; - case 'J': *size = sizeof(lua_Integer); return Kuint; - case 'T': *size = sizeof(size_t); return Kuint; - case 'f': *size = sizeof(float); return Kfloat; - case 'd': *size = sizeof(double); return Kfloat; - case 'n': *size = sizeof(lua_Number); return Kfloat; - case 'i': *size = getnumlimit(h, fmt, sizeof(int)); return Kint; - case 'I': *size = getnumlimit(h, fmt, sizeof(int)); return Kuint; - case 's': *size = getnumlimit(h, fmt, sizeof(size_t)); return Kstring; - case 'c': - *size = getnum(fmt, -1); - if (*size == -1) - luaL_error(h->L, "missing size for format option 'c'"); - return Kchar; - case 'z': return Kzstr; - case 'x': *size = 1; return Kpadding; - case 'X': return Kpaddalign; - case ' ': break; - case '<': h->islittle = 1; break; - case '>': h->islittle = 0; break; - case '=': h->islittle = nativeendian.little; break; - case '!': h->maxalign = getnumlimit(h, fmt, MAXALIGN); break; - default: luaL_error(h->L, "invalid format option '%c'", opt); - } - return Knop; -} - - -/* -** Read, classify, and fill other details about the next option. -** 'psize' is filled with option's size, 'notoalign' with its -** alignment requirements. -** Local variable 'size' gets the size to be aligned. (Kpadal option -** always gets its full alignment, other options are limited by -** the maximum alignment ('maxalign'). Kchar option needs no alignment -** despite its size. -*/ -static KOption getdetails (Header *h, size_t totalsize, - const char **fmt, int *psize, int *ntoalign) { - KOption opt = getoption(h, fmt, psize); - int align = *psize; /* usually, alignment follows size */ - if (opt == Kpaddalign) { /* 'X' gets alignment from following option */ - if (**fmt == '\0' || getoption(h, fmt, &align) == Kchar || align == 0) - luaL_argerror(h->L, 1, "invalid next option for option 'X'"); - } - if (align <= 1 || opt == Kchar) /* need no alignment? */ - *ntoalign = 0; - else { - if (align > h->maxalign) /* enforce maximum alignment */ - align = h->maxalign; - if ((align & (align - 1)) != 0) /* is 'align' not a power of 2? */ - luaL_argerror(h->L, 1, "format asks for alignment not power of 2"); - *ntoalign = (align - (int)(totalsize & (align - 1))) & (align - 1); - } - return opt; -} - - -/* -** Pack integer 'n' with 'size' bytes and 'islittle' endianness. -** The final 'if' handles the case when 'size' is larger than -** the size of a Lua integer, correcting the extra sign-extension -** bytes if necessary (by default they would be zeros). -*/ -static void packint (luaL_Buffer *b, lua_Unsigned n, - int islittle, int size, int neg) { - char *buff = luaL_prepbuffsize(b, size); - int i; - buff[islittle ? 0 : size - 1] = (char)(n & MC); /* first byte */ - for (i = 1; i < size; i++) { - n >>= NB; - buff[islittle ? i : size - 1 - i] = (char)(n & MC); - } - if (neg && size > SZINT) { /* negative number need sign extension? */ - for (i = SZINT; i < size; i++) /* correct extra bytes */ - buff[islittle ? i : size - 1 - i] = (char)MC; - } - luaL_addsize(b, size); /* add result to buffer */ -} - - -/* -** Copy 'size' bytes from 'src' to 'dest', correcting endianness if -** given 'islittle' is different from native endianness. -*/ -static void copywithendian (volatile char *dest, volatile const char *src, - int size, int islittle) { - if (islittle == nativeendian.little) { - while (size-- != 0) - *(dest++) = *(src++); - } - else { - dest += size - 1; - while (size-- != 0) - *(dest--) = *(src++); - } -} - - -static int str_pack (lua_State *L) { - luaL_Buffer b; - Header h; - const char *fmt = luaL_checkstring(L, 1); /* format string */ - int arg = 1; /* current argument to pack */ - size_t totalsize = 0; /* accumulate total size of result */ - initheader(L, &h); - lua_pushnil(L); /* mark to separate arguments from string buffer */ - luaL_buffinit(L, &b); - while (*fmt != '\0') { - int size, ntoalign; - KOption opt = getdetails(&h, totalsize, &fmt, &size, &ntoalign); - totalsize += ntoalign + size; - while (ntoalign-- > 0) - luaL_addchar(&b, LUA_PACKPADBYTE); /* fill alignment */ - arg++; - switch (opt) { - case Kint: { /* signed integers */ - lua_Integer n = luaL_checkinteger(L, arg); - if (size < SZINT) { /* need overflow check? */ - lua_Integer lim = (lua_Integer)1 << ((size * NB) - 1); - luaL_argcheck(L, -lim <= n && n < lim, arg, "integer overflow"); - } - packint(&b, (lua_Unsigned)n, h.islittle, size, (n < 0)); - break; - } - case Kuint: { /* unsigned integers */ - lua_Integer n = luaL_checkinteger(L, arg); - if (size < SZINT) /* need overflow check? */ - luaL_argcheck(L, (lua_Unsigned)n < ((lua_Unsigned)1 << (size * NB)), - arg, "unsigned overflow"); - packint(&b, (lua_Unsigned)n, h.islittle, size, 0); - break; - } - case Kfloat: { /* floating-point options */ - volatile Ftypes u; - char *buff = luaL_prepbuffsize(&b, size); - lua_Number n = luaL_checknumber(L, arg); /* get argument */ - if (size == sizeof(u.f)) u.f = (float)n; /* copy it into 'u' */ - else if (size == sizeof(u.d)) u.d = (double)n; - else u.n = n; - /* move 'u' to final result, correcting endianness if needed */ - copywithendian(buff, u.buff, size, h.islittle); - luaL_addsize(&b, size); - break; - } - case Kchar: { /* fixed-size string */ - size_t len; - const char *s = luaL_checklstring(L, arg, &len); - luaL_argcheck(L, len == (size_t)size, arg, "wrong length"); - luaL_addlstring(&b, s, size); - break; - } - case Kstring: { /* strings with length count */ - size_t len; - const char *s = luaL_checklstring(L, arg, &len); - luaL_argcheck(L, size >= (int)sizeof(size_t) || - len < ((size_t)1 << (size * NB)), - arg, "string length does not fit in given size"); - packint(&b, (lua_Unsigned)len, h.islittle, size, 0); /* pack length */ - luaL_addlstring(&b, s, len); - totalsize += len; - break; - } - case Kzstr: { /* zero-terminated string */ - size_t len; - const char *s = luaL_checklstring(L, arg, &len); - luaL_argcheck(L, strlen(s) == len, arg, "string contains zeros"); - luaL_addlstring(&b, s, len); - luaL_addchar(&b, '\0'); /* add zero at the end */ - totalsize += len + 1; - break; - } - case Kpadding: luaL_addchar(&b, LUA_PACKPADBYTE); /* go through */ - case Kpaddalign: case Knop: - arg--; /* undo increment */ - break; - } - } - luaL_pushresult(&b); - return 1; -} - - -static int str_packsize (lua_State *L) { - Header h; - const char *fmt = luaL_checkstring(L, 1); /* format string */ - size_t totalsize = 0; /* accumulate total size of result */ - initheader(L, &h); - while (*fmt != '\0') { - int size, ntoalign; - KOption opt = getdetails(&h, totalsize, &fmt, &size, &ntoalign); - size += ntoalign; /* total space used by option */ - luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, - "format result too large"); - totalsize += size; - switch (opt) { - case Kstring: /* strings with length count */ - case Kzstr: /* zero-terminated string */ - luaL_argerror(L, 1, "variable-length format"); - break; - default: break; - } - } - lua_pushinteger(L, (lua_Integer)totalsize); - return 1; -} - - -/* -** Unpack an integer with 'size' bytes and 'islittle' endianness. -** If size is smaller than the size of a Lua integer and integer -** is signed, must do sign extension (propagating the sign to the -** higher bits); if size is larger than the size of a Lua integer, -** it must check the unread bytes to see whether they do not cause an -** overflow. -*/ -static lua_Integer unpackint (lua_State *L, const char *str, - int islittle, int size, int issigned) { - lua_Unsigned res = 0; - int i; - int limit = (size <= SZINT) ? size : SZINT; - for (i = limit - 1; i >= 0; i--) { - res <<= NB; - res |= (lua_Unsigned)(unsigned char)str[islittle ? i : size - 1 - i]; - } - if (size < SZINT) { /* real size smaller than lua_Integer? */ - if (issigned) { /* needs sign extension? */ - lua_Unsigned mask = (lua_Unsigned)1 << (size*NB - 1); - res = ((res ^ mask) - mask); /* do sign extension */ - } - } - else if (size > SZINT) { /* must check unread bytes */ - int mask = (!issigned || (lua_Integer)res >= 0) ? 0 : MC; - for (i = limit; i < size; i++) { - if ((unsigned char)str[islittle ? i : size - 1 - i] != mask) - luaL_error(L, "%d-byte integer does not fit into Lua Integer", size); - } - } - return (lua_Integer)res; -} - - -static int str_unpack (lua_State *L) { - Header h; - const char *fmt = luaL_checkstring(L, 1); - size_t ld; - const char *data = luaL_checklstring(L, 2, &ld); - size_t pos = (size_t)posrelat(luaL_optinteger(L, 3, 1), ld) - 1; - int n = 0; /* number of results */ - luaL_argcheck(L, pos <= ld, 3, "initial position out of string"); - initheader(L, &h); - while (*fmt != '\0') { - int size, ntoalign; - KOption opt = getdetails(&h, pos, &fmt, &size, &ntoalign); - if ((size_t)ntoalign + size > ~pos || pos + ntoalign + size > ld) - luaL_argerror(L, 2, "data string too short"); - pos += ntoalign; /* skip alignment */ - /* stack space for item + next position */ - luaL_checkstack(L, 2, "too many results"); - n++; - switch (opt) { - case Kint: - case Kuint: { - lua_Integer res = unpackint(L, data + pos, h.islittle, size, - (opt == Kint)); - lua_pushinteger(L, res); - break; - } - case Kfloat: { - volatile Ftypes u; - lua_Number num; - copywithendian(u.buff, data + pos, size, h.islittle); - if (size == sizeof(u.f)) num = (lua_Number)u.f; - else if (size == sizeof(u.d)) num = (lua_Number)u.d; - else num = u.n; - lua_pushnumber(L, num); - break; - } - case Kchar: { - lua_pushlstring(L, data + pos, size); - break; - } - case Kstring: { - size_t len = (size_t)unpackint(L, data + pos, h.islittle, size, 0); - luaL_argcheck(L, pos + len + size <= ld, 2, "data string too short"); - lua_pushlstring(L, data + pos + size, len); - pos += len; /* skip string */ - break; - } - case Kzstr: { - size_t len = (int)strlen(data + pos); - lua_pushlstring(L, data + pos, len); - pos += len + 1; /* skip string plus final '\0' */ - break; - } - case Kpaddalign: case Kpadding: case Knop: - n--; /* undo increment */ - break; - } - pos += size; - } - lua_pushinteger(L, pos + 1); /* next position */ - return n + 1; -} - -/* }====================================================== */ - - -static const luaL_Reg strlib[] = { - {"byte", str_byte}, - {"char", str_char}, - {"dump", str_dump}, - {"find", str_find}, - {"format", str_format}, - {"gmatch", gmatch}, - {"gsub", str_gsub}, - {"len", str_len}, - {"lower", str_lower}, - {"match", str_match}, - {"rep", str_rep}, - {"reverse", str_reverse}, - {"sub", str_sub}, - {"upper", str_upper}, - {"pack", str_pack}, - {"packsize", str_packsize}, - {"unpack", str_unpack}, - {NULL, NULL} -}; - - -static void createmetatable (lua_State *L) { - lua_createtable(L, 0, 1); /* table to be metatable for strings */ - lua_pushliteral(L, ""); /* dummy string */ - lua_pushvalue(L, -2); /* copy table */ - lua_setmetatable(L, -2); /* set table as metatable for strings */ - lua_pop(L, 1); /* pop dummy string */ - lua_pushvalue(L, -2); /* get string library */ - lua_setfield(L, -2, "__index"); /* metatable.__index = string */ - lua_pop(L, 1); /* pop metatable */ -} - - -/* -** Open string library -*/ -LUAMOD_API int luaopen_string (lua_State *L) { - luaL_newlib(L, strlib); - createmetatable(L); - return 1; -} - diff --git a/thirdparty/src/Lua/ltable.cpp b/thirdparty/src/Lua/ltable.cpp deleted file mode 100644 index a126bf939..000000000 --- a/thirdparty/src/Lua/ltable.cpp +++ /dev/null @@ -1,650 +0,0 @@ -/* -** $Id: ltable.c,v 2.100 2015/01/05 13:52:37 roberto Exp $ -** Lua tables (hash) -** See Copyright Notice in lua.h -*/ - -#define ltable_c -#define LUA_CORE - -#include "lprefix.h" - - -/* -** Implementation of tables (aka arrays, objects, or hash tables). -** Tables keep its elements in two parts: an array part and a hash part. -** Non-negative integer keys are all candidates to be kept in the array -** part. The actual size of the array is the largest 'n' such that at -** least half the slots between 0 and n are in use. -** Hash uses a mix of chained scatter table with Brent's variation. -** A main invariant of these tables is that, if an element is not -** in its main position (i.e. the 'original' position that its hash gives -** to it), then the colliding element is in its own main position. -** Hence even when the load factor reaches 100%, performance remains good. -*/ - -#include <float.h> -#include <math.h> -#include <string.h> -#include <limits.h> - -#include <Lua/lua.h> - -#include "ldebug.h" -#include "ldo.h" -#include "lgc.h" -#include "lmem.h" -#include "lobject.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "lvm.h" - - -/* -** Maximum size of array part (MAXASIZE) is 2^MAXABITS. MAXABITS is -** the largest integer such that MAXASIZE fits in an unsigned int. -*/ -#define MAXABITS cast_int(sizeof(int) * CHAR_BIT - 1) -#define MAXASIZE (1u << MAXABITS) - -/* -** Maximum size of hash part is 2^MAXHBITS. MAXHBITS is the largest -** integer such that 2^MAXHBITS fits in a signed int. (Note that the -** maximum number of elements in a table, 2^MAXABITS + 2^MAXHBITS, still -** fits comfortably in an unsigned int.) -*/ -#define MAXHBITS (MAXABITS - 1) - - -#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) - -#define hashstr(t,str) hashpow2(t, (str)->hash) -#define hashboolean(t,p) hashpow2(t, p) -#define hashint(t,i) hashpow2(t, i) - - -/* -** for some types, it is better to avoid modulus by power of 2, as -** they tend to have many 2 factors. -*/ -#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) - - -#define hashpointer(t,p) hashmod(t, point2int(p)) - - -#define dummynode (&dummynode_) - -#define isdummy(n) ((n) == dummynode) - -static const Node dummynode_ = { - {NILCONSTANT}, /* value */ - {{NILCONSTANT, 0}} /* key */ -}; - - -/* -** Checks whether a float has a value representable as a lua_Integer -** (and does the conversion if so) -*/ -static int numisinteger (lua_Number x, lua_Integer *p) { - if ((x) == l_floor(x)) /* integral value? */ - return lua_numbertointeger(x, p); /* try as an integer */ - else return 0; -} - - -/* -** hash for floating-point numbers -*/ -static Node *hashfloat (const Table *t, lua_Number n) { - int i; - n = l_mathop(frexp)(n, &i) * cast_num(INT_MAX - DBL_MAX_EXP); - i += cast_int(n); - if (i < 0) { - if (cast(unsigned int, i) == 0u - i) /* use unsigned to avoid overflows */ - i = 0; /* handle INT_MIN */ - i = -i; /* must be a positive value */ - } - return hashmod(t, i); -} - - - -/* -** returns the 'main' position of an element in a table (that is, the index -** of its hash value) -*/ -static Node *mainposition (const Table *t, const TValue *key) { - switch (ttype(key)) { - case LUA_TNUMINT: - return hashint(t, ivalue(key)); - case LUA_TNUMFLT: - return hashfloat(t, fltvalue(key)); - case LUA_TSHRSTR: - return hashstr(t, tsvalue(key)); - case LUA_TLNGSTR: { - TString *s = tsvalue(key); - if (s->extra == 0) { /* no hash? */ - s->hash = luaS_hash(getstr(s), s->len, s->hash); - s->extra = 1; /* now it has its hash */ - } - return hashstr(t, tsvalue(key)); - } - case LUA_TBOOLEAN: - return hashboolean(t, bvalue(key)); - case LUA_TLIGHTUSERDATA: - return hashpointer(t, pvalue(key)); - case LUA_TLCF: - return hashpointer(t, fvalue(key)); - default: - return hashpointer(t, gcvalue(key)); - } -} - - -/* -** returns the index for 'key' if 'key' is an appropriate key to live in -** the array part of the table, 0 otherwise. -*/ -static unsigned int arrayindex (const TValue *key) { - if (ttisinteger(key)) { - lua_Integer k = ivalue(key); - if (0 < k && (lua_Unsigned)k <= MAXASIZE) - return cast(unsigned int, k); /* 'key' is an appropriate array index */ - } - return 0; /* 'key' did not match some condition */ -} - - -/* -** returns the index of a 'key' for table traversals. First goes all -** elements in the array part, then elements in the hash part. The -** beginning of a traversal is signaled by 0. -*/ -static unsigned int findindex (lua_State *L, Table *t, StkId key) { - unsigned int i; - if (ttisnil(key)) return 0; /* first iteration */ - i = arrayindex(key); - if (i != 0 && i <= t->sizearray) /* is 'key' inside array part? */ - return i; /* yes; that's the index */ - else { - int nx; - Node *n = mainposition(t, key); - for (;;) { /* check whether 'key' is somewhere in the chain */ - /* key may be dead already, but it is ok to use it in 'next' */ - if (luaV_rawequalobj(gkey(n), key) || - (ttisdeadkey(gkey(n)) && iscollectable(key) && - deadvalue(gkey(n)) == gcvalue(key))) { - i = cast_int(n - gnode(t, 0)); /* key index in hash table */ - /* hash elements are numbered after array ones */ - return (i + 1) + t->sizearray; - } - nx = gnext(n); - if (nx == 0) - luaG_runerror(L, "invalid key to 'next'"); /* key not found */ - else n += nx; - } - } -} - - -int luaH_next (lua_State *L, Table *t, StkId key) { - unsigned int i = findindex(L, t, key); /* find original element */ - for (; i < t->sizearray; i++) { /* try first array part */ - if (!ttisnil(&t->array[i])) { /* a non-nil value? */ - setivalue(key, i + 1); - setobj2s(L, key+1, &t->array[i]); - return 1; - } - } - for (i -= t->sizearray; cast_int(i) < sizenode(t); i++) { /* hash part */ - if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ - setobj2s(L, key, gkey(gnode(t, i))); - setobj2s(L, key+1, gval(gnode(t, i))); - return 1; - } - } - return 0; /* no more elements */ -} - - -/* -** {============================================================= -** Rehash -** ============================================================== -*/ - -/* -** Compute the optimal size for the array part of table 't'. 'nums' is a -** "count array" where 'nums[i]' is the number of integers in the table -** between 2^(i - 1) + 1 and 2^i. Put in '*narray' the optimal size, and -** return the number of elements that will go to that part. -*/ -static unsigned int computesizes (unsigned int nums[], unsigned int *narray) { - int i; - unsigned int twotoi; /* 2^i */ - unsigned int a = 0; /* number of elements smaller than 2^i */ - unsigned int na = 0; /* number of elements to go to array part */ - unsigned int n = 0; /* optimal size for array part */ - for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) { - if (nums[i] > 0) { - a += nums[i]; - if (a > twotoi/2) { /* more than half elements present? */ - n = twotoi; /* optimal size (till now) */ - na = a; /* all elements up to 'n' will go to array part */ - } - } - if (a == *narray) break; /* all elements already counted */ - } - *narray = n; - lua_assert(*narray/2 <= na && na <= *narray); - return na; -} - - -static int countint (const TValue *key, unsigned int *nums) { - unsigned int k = arrayindex(key); - if (k != 0) { /* is 'key' an appropriate array index? */ - nums[luaO_ceillog2(k)]++; /* count as such */ - return 1; - } - else - return 0; -} - - -static unsigned int numusearray (const Table *t, unsigned int *nums) { - int lg; - unsigned int ttlg; /* 2^lg */ - unsigned int ause = 0; /* summation of 'nums' */ - unsigned int i = 1; /* count to traverse all array keys */ - /* traverse each slice */ - for (lg = 0, ttlg = 1; lg <= MAXABITS; lg++, ttlg *= 2) { - unsigned int lc = 0; /* counter */ - unsigned int lim = ttlg; - if (lim > t->sizearray) { - lim = t->sizearray; /* adjust upper limit */ - if (i > lim) - break; /* no more elements to count */ - } - /* count elements in range (2^(lg - 1), 2^lg] */ - for (; i <= lim; i++) { - if (!ttisnil(&t->array[i-1])) - lc++; - } - nums[lg] += lc; - ause += lc; - } - return ause; -} - - -static int numusehash (const Table *t, unsigned int *nums, - unsigned int *pnasize) { - int totaluse = 0; /* total number of elements */ - int ause = 0; /* elements added to 'nums' (can go to array part) */ - int i = sizenode(t); - while (i--) { - Node *n = &t->node[i]; - if (!ttisnil(gval(n))) { - ause += countint(gkey(n), nums); - totaluse++; - } - } - *pnasize += ause; - return totaluse; -} - - -static void setarrayvector (lua_State *L, Table *t, unsigned int size) { - unsigned int i; - luaM_reallocvector(L, t->array, t->sizearray, size, TValue); - for (i=t->sizearray; i<size; i++) - setnilvalue(&t->array[i]); - t->sizearray = size; -} - - -static void setnodevector (lua_State *L, Table *t, unsigned int size) { - int lsize; - if (size == 0) { /* no elements to hash part? */ - t->node = cast(Node *, dummynode); /* use common 'dummynode' */ - lsize = 0; - } - else { - int i; - lsize = luaO_ceillog2(size); - if (lsize > MAXHBITS) - luaG_runerror(L, "table overflow"); - size = twoto(lsize); - t->node = luaM_newvector(L, size, Node); - for (i = 0; i < (int)size; i++) { - Node *n = gnode(t, i); - gnext(n) = 0; - setnilvalue(wgkey(n)); - setnilvalue(gval(n)); - } - } - t->lsizenode = cast_byte(lsize); - t->lastfree = gnode(t, size); /* all positions are free */ -} - - -void luaH_resize (lua_State *L, Table *t, unsigned int nasize, - unsigned int nhsize) { - unsigned int i; - int j; - unsigned int oldasize = t->sizearray; - int oldhsize = t->lsizenode; - Node *nold = t->node; /* save old hash ... */ - if (nasize > oldasize) /* array part must grow? */ - setarrayvector(L, t, nasize); - /* create new hash part with appropriate size */ - setnodevector(L, t, nhsize); - if (nasize < oldasize) { /* array part must shrink? */ - t->sizearray = nasize; - /* re-insert elements from vanishing slice */ - for (i=nasize; i<oldasize; i++) { - if (!ttisnil(&t->array[i])) - luaH_setint(L, t, i + 1, &t->array[i]); - } - /* shrink array */ - luaM_reallocvector(L, t->array, oldasize, nasize, TValue); - } - /* re-insert elements from hash part */ - for (j = twoto(oldhsize) - 1; j >= 0; j--) { - Node *old = nold + j; - if (!ttisnil(gval(old))) { - /* doesn't need barrier/invalidate cache, as entry was - already present in the table */ - setobjt2t(L, luaH_set(L, t, gkey(old)), gval(old)); - } - } - if (!isdummy(nold)) - luaM_freearray(L, nold, cast(size_t, twoto(oldhsize))); /* free old array */ -} - - -void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize) { - int nsize = isdummy(t->node) ? 0 : sizenode(t); - luaH_resize(L, t, nasize, nsize); -} - -/* -** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i -*/ -static void rehash (lua_State *L, Table *t, const TValue *ek) { - unsigned int nasize, na; - unsigned int nums[MAXABITS + 1]; - int i; - int totaluse; - for (i = 0; i <= MAXABITS; i++) nums[i] = 0; /* reset counts */ - nasize = numusearray(t, nums); /* count keys in array part */ - totaluse = nasize; /* all those keys are integer keys */ - totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */ - /* count extra key */ - nasize += countint(ek, nums); - totaluse++; - /* compute new size for array part */ - na = computesizes(nums, &nasize); - /* resize the table to new computed sizes */ - luaH_resize(L, t, nasize, totaluse - na); -} - - - -/* -** }============================================================= -*/ - - -Table *luaH_new (lua_State *L) { - GCObject *o = luaC_newobj(L, LUA_TTABLE, sizeof(Table)); - Table *t = gco2t(o); - t->metatable = NULL; - t->flags = cast_byte(~0); - t->array = NULL; - t->sizearray = 0; - setnodevector(L, t, 0); - return t; -} - - -void luaH_free (lua_State *L, Table *t) { - if (!isdummy(t->node)) - luaM_freearray(L, t->node, cast(size_t, sizenode(t))); - luaM_freearray(L, t->array, t->sizearray); - luaM_free(L, t); -} - - -static Node *getfreepos (Table *t) { - while (t->lastfree > t->node) { - t->lastfree--; - if (ttisnil(gkey(t->lastfree))) - return t->lastfree; - } - return NULL; /* could not find a free place */ -} - - - -/* -** inserts a new key into a hash table; first, check whether key's main -** position is free. If not, check whether colliding node is in its main -** position or not: if it is not, move colliding node to an empty place and -** put new key in its main position; otherwise (colliding node is in its main -** position), new key goes to an empty position. -*/ -TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { - Node *mp; - TValue aux; - if (ttisnil(key)) luaG_runerror(L, "table index is nil"); - else if (ttisfloat(key)) { - lua_Number n = fltvalue(key); - lua_Integer k; - if (luai_numisnan(n)) - luaG_runerror(L, "table index is NaN"); - if (numisinteger(n, &k)) { /* index is int? */ - setivalue(&aux, k); - key = &aux; /* insert it as an integer */ - } - } - mp = mainposition(t, key); - if (!ttisnil(gval(mp)) || isdummy(mp)) { /* main position is taken? */ - Node *othern; - Node *f = getfreepos(t); /* get a free place */ - if (f == NULL) { /* cannot find a free place? */ - rehash(L, t, key); /* grow table */ - /* whatever called 'newkey' takes care of TM cache and GC barrier */ - return luaH_set(L, t, key); /* insert key into grown table */ - } - lua_assert(!isdummy(f)); - othern = mainposition(t, gkey(mp)); - if (othern != mp) { /* is colliding node out of its main position? */ - /* yes; move colliding node into free position */ - while (othern + gnext(othern) != mp) /* find previous */ - othern += gnext(othern); - gnext(othern) = cast_int(f - othern); /* rechain to point to 'f' */ - *f = *mp; /* copy colliding node into free pos. (mp->next also goes) */ - if (gnext(mp) != 0) { - gnext(f) += cast_int(mp - f); /* correct 'next' */ - gnext(mp) = 0; /* now 'mp' is free */ - } - setnilvalue(gval(mp)); - } - else { /* colliding node is in its own main position */ - /* new node will go into free position */ - if (gnext(mp) != 0) - gnext(f) = cast_int((mp + gnext(mp)) - f); /* chain new position */ - else lua_assert(gnext(f) == 0); - gnext(mp) = cast_int(f - mp); - mp = f; - } - } - setnodekey(L, &mp->i_key, key); - luaC_barrierback(L, t, key); - lua_assert(ttisnil(gval(mp))); - return gval(mp); -} - - -/* -** search function for integers -*/ -const TValue *luaH_getint (Table *t, lua_Integer key) { - /* (1 <= key && key <= t->sizearray) */ - if (l_castS2U(key - 1) < t->sizearray) - return &t->array[key - 1]; - else { - Node *n = hashint(t, key); - for (;;) { /* check whether 'key' is somewhere in the chain */ - if (ttisinteger(gkey(n)) && ivalue(gkey(n)) == key) - return gval(n); /* that's it */ - else { - int nx = gnext(n); - if (nx == 0) break; - n += nx; - } - }; - return luaO_nilobject; - } -} - - -/* -** search function for short strings -*/ -const TValue *luaH_getstr (Table *t, TString *key) { - Node *n = hashstr(t, key); - lua_assert(key->tt == LUA_TSHRSTR); - for (;;) { /* check whether 'key' is somewhere in the chain */ - const TValue *k = gkey(n); - if (ttisshrstring(k) && eqshrstr(tsvalue(k), key)) - return gval(n); /* that's it */ - else { - int nx = gnext(n); - if (nx == 0) break; - n += nx; - } - }; - return luaO_nilobject; -} - - -/* -** main search function -*/ -const TValue *luaH_get (Table *t, const TValue *key) { - switch (ttype(key)) { - case LUA_TSHRSTR: return luaH_getstr(t, tsvalue(key)); - case LUA_TNUMINT: return luaH_getint(t, ivalue(key)); - case LUA_TNIL: return luaO_nilobject; - case LUA_TNUMFLT: { - lua_Integer k; - if (numisinteger(fltvalue(key), &k)) /* index is int? */ - return luaH_getint(t, k); /* use specialized version */ - /* else go through */ - } - default: { - Node *n = mainposition(t, key); - for (;;) { /* check whether 'key' is somewhere in the chain */ - if (luaV_rawequalobj(gkey(n), key)) - return gval(n); /* that's it */ - else { - int nx = gnext(n); - if (nx == 0) break; - n += nx; - } - }; - return luaO_nilobject; - } - } -} - - -/* -** beware: when using this function you probably need to check a GC -** barrier and invalidate the TM cache. -*/ -TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { - const TValue *p = luaH_get(t, key); - if (p != luaO_nilobject) - return cast(TValue *, p); - else return luaH_newkey(L, t, key); -} - - -void luaH_setint (lua_State *L, Table *t, lua_Integer key, TValue *value) { - const TValue *p = luaH_getint(t, key); - TValue *cell; - if (p != luaO_nilobject) - cell = cast(TValue *, p); - else { - TValue k; - setivalue(&k, key); - cell = luaH_newkey(L, t, &k); - } - setobj2t(L, cell, value); -} - - -static int unbound_search (Table *t, unsigned int j) { - unsigned int i = j; /* i is zero or a present index */ - j++; - /* find 'i' and 'j' such that i is present and j is not */ - while (!ttisnil(luaH_getint(t, j))) { - i = j; - if (j > cast(unsigned int, MAX_INT)/2) { /* overflow? */ - /* table was built with bad purposes: resort to linear search */ - i = 1; - while (!ttisnil(luaH_getint(t, i))) i++; - return i - 1; - } - j *= 2; - } - /* now do a binary search between them */ - while (j - i > 1) { - unsigned int m = (i+j)/2; - if (ttisnil(luaH_getint(t, m))) j = m; - else i = m; - } - return i; -} - - -/* -** Try to find a boundary in table 't'. A 'boundary' is an integer index -** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). -*/ -int luaH_getn (Table *t) { - unsigned int j = t->sizearray; - if (j > 0 && ttisnil(&t->array[j - 1])) { - /* there is a boundary in the array part: (binary) search for it */ - unsigned int i = 0; - while (j - i > 1) { - unsigned int m = (i+j)/2; - if (ttisnil(&t->array[m - 1])) j = m; - else i = m; - } - return i; - } - /* else must find a boundary in hash part */ - else if (isdummy(t->node)) /* hash part is empty? */ - return j; /* that is easy... */ - else return unbound_search(t, j); -} - - - -#if defined(LUA_DEBUG) - -Node *luaH_mainposition (const Table *t, const TValue *key) { - return mainposition(t, key); -} - -int luaH_isdummy (Node *n) { return isdummy(n); } - -#endif diff --git a/thirdparty/src/Lua/ltable.h b/thirdparty/src/Lua/ltable.h deleted file mode 100644 index 53d25511a..000000000 --- a/thirdparty/src/Lua/ltable.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -** $Id: ltable.h,v 2.20 2014/09/04 18:15:29 roberto Exp $ -** Lua tables (hash) -** See Copyright Notice in lua.h -*/ - -#ifndef ltable_h -#define ltable_h - -#include "lobject.h" - - -#define gnode(t,i) (&(t)->node[i]) -#define gval(n) (&(n)->i_val) -#define gnext(n) ((n)->i_key.nk.next) - - -/* 'const' to avoid wrong writings that can mess up field 'next' */ -#define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) - -#define wgkey(n) (&(n)->i_key.nk) - -#define invalidateTMcache(t) ((t)->flags = 0) - - -/* returns the key, given the value of a table entry */ -#define keyfromval(v) \ - (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) - - -LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); -LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, - TValue *value); -LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); -LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); -LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); -LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); -LUAI_FUNC Table *luaH_new (lua_State *L); -LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, - unsigned int nhsize); -LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); -LUAI_FUNC void luaH_free (lua_State *L, Table *t); -LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); -LUAI_FUNC int luaH_getn (Table *t); - - -#if defined(LUA_DEBUG) -LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); -LUAI_FUNC int luaH_isdummy (Node *n); -#endif - - -#endif diff --git a/thirdparty/src/Lua/ltablib.cpp b/thirdparty/src/Lua/ltablib.cpp deleted file mode 100644 index 845d6ab53..000000000 --- a/thirdparty/src/Lua/ltablib.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/* -** $Id: ltablib.c,v 1.79 2014/11/02 19:19:04 roberto Exp $ -** Library for Table Manipulation -** See Copyright Notice in lua.h -*/ - -#define ltablib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include <limits.h> -#include <stddef.h> - -#include <Lua/lua.h> - -#include <Lua/lauxlib.h> -#include <Lua/lualib.h> - - - -/* -** Structure with table-access functions -*/ -typedef struct { - int (*geti) (lua_State *L, int idx, lua_Integer n); - void (*seti) (lua_State *L, int idx, lua_Integer n); -} TabA; - - -/* -** Check that 'arg' has a table and set access functions in 'ta' to raw -** or non-raw according to the presence of corresponding metamethods. -*/ -static void checktab (lua_State *L, int arg, TabA *ta) { - ta->geti = NULL; ta->seti = NULL; - if (lua_getmetatable(L, arg)) { - lua_pushliteral(L, "__index"); /* 'index' metamethod */ - if (lua_rawget(L, -2) != LUA_TNIL) - ta->geti = lua_geti; - lua_pushliteral(L, "__newindex"); /* 'newindex' metamethod */ - if (lua_rawget(L, -3) != LUA_TNIL) - ta->seti = lua_seti; - lua_pop(L, 3); /* pop metatable plus both metamethods */ - } - if (ta->geti == NULL || ta->seti == NULL) { - luaL_checktype(L, arg, LUA_TTABLE); /* must be table for raw methods */ - if (ta->geti == NULL) ta->geti = lua_rawgeti; - if (ta->seti == NULL) ta->seti = lua_rawseti; - } -} - - -#define aux_getn(L,n,ta) (checktab(L, n, ta), luaL_len(L, n)) - - -#if defined(LUA_COMPAT_MAXN) -static int maxn (lua_State *L) { - lua_Number max = 0; - luaL_checktype(L, 1, LUA_TTABLE); - lua_pushnil(L); /* first key */ - while (lua_next(L, 1)) { - lua_pop(L, 1); /* remove value */ - if (lua_type(L, -1) == LUA_TNUMBER) { - lua_Number v = lua_tonumber(L, -1); - if (v > max) max = v; - } - } - lua_pushnumber(L, max); - return 1; -} -#endif - - -static int tinsert (lua_State *L) { - TabA ta; - lua_Integer e = aux_getn(L, 1, &ta) + 1; /* first empty element */ - lua_Integer pos; /* where to insert new element */ - switch (lua_gettop(L)) { - case 2: { /* called with only 2 arguments */ - pos = e; /* insert new element at the end */ - break; - } - case 3: { - lua_Integer i; - pos = luaL_checkinteger(L, 2); /* 2nd argument is the position */ - luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds"); - for (i = e; i > pos; i--) { /* move up elements */ - (*ta.geti)(L, 1, i - 1); - (*ta.seti)(L, 1, i); /* t[i] = t[i - 1] */ - } - break; - } - default: { - return luaL_error(L, "wrong number of arguments to 'insert'"); - } - } - (*ta.seti)(L, 1, pos); /* t[pos] = v */ - return 0; -} - - -static int tremove (lua_State *L) { - TabA ta; - lua_Integer size = aux_getn(L, 1, &ta); - lua_Integer pos = luaL_optinteger(L, 2, size); - if (pos != size) /* validate 'pos' if given */ - luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds"); - (*ta.geti)(L, 1, pos); /* result = t[pos] */ - for ( ; pos < size; pos++) { - (*ta.geti)(L, 1, pos + 1); - (*ta.seti)(L, 1, pos); /* t[pos] = t[pos + 1] */ - } - lua_pushnil(L); - (*ta.seti)(L, 1, pos); /* t[pos] = nil */ - return 1; -} - - -static int tmove (lua_State *L) { - TabA ta; - lua_Integer f = luaL_checkinteger(L, 2); - lua_Integer e = luaL_checkinteger(L, 3); - lua_Integer t = luaL_checkinteger(L, 4); - int tt = !lua_isnoneornil(L, 5) ? 5 : 1; /* destination table */ - /* the following restriction avoids several problems with overflows */ - luaL_argcheck(L, f > 0, 2, "initial position must be positive"); - if (e >= f) { /* otherwise, nothing to move */ - lua_Integer n, i; - ta.geti = (luaL_getmetafield(L, 1, "__index") == LUA_TNIL) - ? (luaL_checktype(L, 1, LUA_TTABLE), lua_rawgeti) - : lua_geti; - ta.seti = (luaL_getmetafield(L, tt, "__newindex") == LUA_TNIL) - ? (luaL_checktype(L, tt, LUA_TTABLE), lua_rawseti) - : lua_seti; - n = e - f + 1; /* number of elements to move */ - if (t > f) { - for (i = n - 1; i >= 0; i--) { - (*ta.geti)(L, 1, f + i); - (*ta.seti)(L, tt, t + i); - } - } - else { - for (i = 0; i < n; i++) { - (*ta.geti)(L, 1, f + i); - (*ta.seti)(L, tt, t + i); - } - } - } - lua_pushvalue(L, tt); /* return "to table" */ - return 1; -} - - -static void addfield (lua_State *L, luaL_Buffer *b, TabA *ta, lua_Integer i) { - (*ta->geti)(L, 1, i); - if (!lua_isstring(L, -1)) - luaL_error(L, "invalid value (%s) at index %d in table for 'concat'", - luaL_typename(L, -1), i); - luaL_addvalue(b); -} - - -static int tconcat (lua_State *L) { - TabA ta; - luaL_Buffer b; - size_t lsep; - lua_Integer i, last; - const char *sep = luaL_optlstring(L, 2, "", &lsep); - checktab(L, 1, &ta); - i = luaL_optinteger(L, 3, 1); - last = luaL_opt(L, luaL_checkinteger, 4, luaL_len(L, 1)); - luaL_buffinit(L, &b); - for (; i < last; i++) { - addfield(L, &b, &ta, i); - luaL_addlstring(&b, sep, lsep); - } - if (i == last) /* add last value (if interval was not empty) */ - addfield(L, &b, &ta, i); - luaL_pushresult(&b); - return 1; -} - - -/* -** {====================================================== -** Pack/unpack -** ======================================================= -*/ - -static int pack (lua_State *L) { - int i; - int n = lua_gettop(L); /* number of elements to pack */ - lua_createtable(L, n, 1); /* create result table */ - lua_insert(L, 1); /* put it at index 1 */ - for (i = n; i >= 1; i--) /* assign elements */ - lua_rawseti(L, 1, i); - lua_pushinteger(L, n); - lua_setfield(L, 1, "n"); /* t.n = number of elements */ - return 1; /* return table */ -} - - -static int unpack (lua_State *L) { - TabA ta; - lua_Integer i, e; - lua_Unsigned n; - checktab(L, 1, &ta); - i = luaL_optinteger(L, 2, 1); - e = luaL_opt(L, luaL_checkinteger, 3, luaL_len(L, 1)); - if (i > e) return 0; /* empty range */ - n = (lua_Unsigned)e - i; /* number of elements minus 1 (avoid overflows) */ - if (n >= (unsigned int)INT_MAX || !lua_checkstack(L, (int)(++n))) - return luaL_error(L, "too many results to unpack"); - do { /* must have at least one element */ - (*ta.geti)(L, 1, i); /* push arg[i..e] */ - } while (i++ < e); - - return (int)n; -} - -/* }====================================================== */ - - - -/* -** {====================================================== -** Quicksort -** (based on 'Algorithms in MODULA-3', Robert Sedgewick; -** Addison-Wesley, 1993.) -** ======================================================= -*/ - - -static void set2 (lua_State *L, TabA *ta, int i, int j) { - (*ta->seti)(L, 1, i); - (*ta->seti)(L, 1, j); -} - -static int sort_comp (lua_State *L, int a, int b) { - if (!lua_isnil(L, 2)) { /* function? */ - int res; - lua_pushvalue(L, 2); - lua_pushvalue(L, a-1); /* -1 to compensate function */ - lua_pushvalue(L, b-2); /* -2 to compensate function and 'a' */ - lua_call(L, 2, 1); - res = lua_toboolean(L, -1); - lua_pop(L, 1); - return res; - } - else /* a < b? */ - return lua_compare(L, a, b, LUA_OPLT); -} - -static void auxsort (lua_State *L, TabA *ta, int l, int u) { - while (l < u) { /* for tail recursion */ - int i, j; - /* sort elements a[l], a[(l+u)/2] and a[u] */ - (*ta->geti)(L, 1, l); - (*ta->geti)(L, 1, u); - if (sort_comp(L, -1, -2)) /* a[u] < a[l]? */ - set2(L, ta, l, u); /* swap a[l] - a[u] */ - else - lua_pop(L, 2); - if (u-l == 1) break; /* only 2 elements */ - i = (l+u)/2; - (*ta->geti)(L, 1, i); - (*ta->geti)(L, 1, l); - if (sort_comp(L, -2, -1)) /* a[i]<a[l]? */ - set2(L, ta, i, l); - else { - lua_pop(L, 1); /* remove a[l] */ - (*ta->geti)(L, 1, u); - if (sort_comp(L, -1, -2)) /* a[u]<a[i]? */ - set2(L, ta, i, u); - else - lua_pop(L, 2); - } - if (u-l == 2) break; /* only 3 elements */ - (*ta->geti)(L, 1, i); /* Pivot */ - lua_pushvalue(L, -1); - (*ta->geti)(L, 1, u-1); - set2(L, ta, i, u-1); - /* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */ - i = l; j = u-1; - for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */ - /* repeat ++i until a[i] >= P */ - while ((*ta->geti)(L, 1, ++i), sort_comp(L, -1, -2)) { - if (i>=u) luaL_error(L, "invalid order function for sorting"); - lua_pop(L, 1); /* remove a[i] */ - } - /* repeat --j until a[j] <= P */ - while ((*ta->geti)(L, 1, --j), sort_comp(L, -3, -1)) { - if (j<=l) luaL_error(L, "invalid order function for sorting"); - lua_pop(L, 1); /* remove a[j] */ - } - if (j<i) { - lua_pop(L, 3); /* pop pivot, a[i], a[j] */ - break; - } - set2(L, ta, i, j); - } - (*ta->geti)(L, 1, u-1); - (*ta->geti)(L, 1, i); - set2(L, ta, u-1, i); /* swap pivot (a[u-1]) with a[i] */ - /* a[l..i-1] <= a[i] == P <= a[i+1..u] */ - /* adjust so that smaller half is in [j..i] and larger one in [l..u] */ - if (i-l < u-i) { - j=l; i=i-1; l=i+2; - } - else { - j=i+1; i=u; u=j-2; - } - auxsort(L, ta, j, i); /* call recursively the smaller one */ - } /* repeat the routine for the larger one */ -} - -static int sort (lua_State *L) { - TabA ta; - int n = (int)aux_getn(L, 1, &ta); - luaL_checkstack(L, 50, ""); /* assume array is smaller than 2^50 */ - if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ - luaL_checktype(L, 2, LUA_TFUNCTION); - lua_settop(L, 2); /* make sure there are two arguments */ - auxsort(L, &ta, 1, n); - return 0; -} - -/* }====================================================== */ - - -static const luaL_Reg tab_funcs[] = { - {"concat", tconcat}, -#if defined(LUA_COMPAT_MAXN) - {"maxn", maxn}, -#endif - {"insert", tinsert}, - {"pack", pack}, - {"unpack", unpack}, - {"remove", tremove}, - {"move", tmove}, - {"sort", sort}, - {NULL, NULL} -}; - - -LUAMOD_API int luaopen_table (lua_State *L) { - luaL_newlib(L, tab_funcs); -#if defined(LUA_COMPAT_UNPACK) - /* _G.unpack = table.unpack */ - lua_getfield(L, -1, "unpack"); - lua_setglobal(L, "unpack"); -#endif - return 1; -} - diff --git a/thirdparty/src/Lua/ltm.cpp b/thirdparty/src/Lua/ltm.cpp deleted file mode 100644 index 4f0d4e0e6..000000000 --- a/thirdparty/src/Lua/ltm.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* -** $Id: ltm.c,v 2.33 2014/11/21 12:15:57 roberto Exp $ -** Tag methods -** See Copyright Notice in lua.h -*/ - -#define ltm_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <string.h> - -#include <Lua/lua.h> - -#include "ldebug.h" -#include "ldo.h" -#include "lobject.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" -#include "lvm.h" - - -static const char udatatypename[] = "userdata"; - -LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = { - "no value", - "nil", "boolean", udatatypename, "number", - "string", "table", "function", udatatypename, "thread", - "proto" /* this last case is used for tests only */ -}; - - -void luaT_init (lua_State *L) { - static const char *const luaT_eventname[] = { /* ORDER TM */ - "__index", "__newindex", - "__gc", "__mode", "__len", "__eq", - "__add", "__sub", "__mul", "__mod", "__pow", - "__div", "__idiv", - "__band", "__bor", "__bxor", "__shl", "__shr", - "__unm", "__bnot", "__lt", "__le", - "__concat", "__call" - }; - int i; - for (i=0; i<TM_N; i++) { - G(L)->tmname[i] = luaS_new(L, luaT_eventname[i]); - luaC_fix(L, obj2gco(G(L)->tmname[i])); /* never collect these names */ - } -} - - -/* -** function to be used with macro "fasttm": optimized for absence of -** tag methods -*/ -const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { - const TValue *tm = luaH_getstr(events, ename); - lua_assert(event <= TM_EQ); - if (ttisnil(tm)) { /* no tag method? */ - events->flags |= cast_byte(1u<<event); /* cache this fact */ - return NULL; - } - else return tm; -} - - -const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) { - Table *mt; - switch (ttnov(o)) { - case LUA_TTABLE: - mt = hvalue(o)->metatable; - break; - case LUA_TUSERDATA: - mt = uvalue(o)->metatable; - break; - default: - mt = G(L)->mt[ttnov(o)]; - } - return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); -} - - -void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, - const TValue *p2, TValue *p3, int hasres) { - ptrdiff_t result = savestack(L, p3); - setobj2s(L, L->top++, f); /* push function (assume EXTRA_STACK) */ - setobj2s(L, L->top++, p1); /* 1st argument */ - setobj2s(L, L->top++, p2); /* 2nd argument */ - if (!hasres) /* no result? 'p3' is third argument */ - setobj2s(L, L->top++, p3); /* 3rd argument */ - /* metamethod may yield only when called from Lua code */ - luaD_call(L, L->top - (4 - hasres), hasres, isLua(L->ci)); - if (hasres) { /* if has result, move it to its place */ - p3 = restorestack(L, result); - setobjs2s(L, p3, --L->top); - } -} - - -int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, - StkId res, TMS event) { - const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ - if (ttisnil(tm)) - tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ - if (ttisnil(tm)) return 0; - luaT_callTM(L, tm, p1, p2, res, 1); - return 1; -} - - -void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, - StkId res, TMS event) { - if (!luaT_callbinTM(L, p1, p2, res, event)) { - switch (event) { - case TM_CONCAT: - luaG_concaterror(L, p1, p2); - case TM_BAND: case TM_BOR: case TM_BXOR: - case TM_SHL: case TM_SHR: case TM_BNOT: { - lua_Number dummy; - if (tonumber(p1, &dummy) && tonumber(p2, &dummy)) - luaG_tointerror(L, p1, p2); - else - luaG_opinterror(L, p1, p2, "perform bitwise operation on"); - /* else go through */ - } - default: - luaG_opinterror(L, p1, p2, "perform arithmetic on"); - } - } -} - - -int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, - TMS event) { - if (!luaT_callbinTM(L, p1, p2, L->top, event)) - return -1; /* no metamethod */ - else - return !l_isfalse(L->top); -} - diff --git a/thirdparty/src/Lua/ltm.h b/thirdparty/src/Lua/ltm.h deleted file mode 100644 index 180179ce0..000000000 --- a/thirdparty/src/Lua/ltm.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -** $Id: ltm.h,v 2.21 2014/10/25 11:50:46 roberto Exp $ -** Tag methods -** See Copyright Notice in lua.h -*/ - -#ifndef ltm_h -#define ltm_h - - -#include "lobject.h" - - -/* -* WARNING: if you change the order of this enumeration, -* grep "ORDER TM" and "ORDER OP" -*/ -typedef enum { - TM_INDEX, - TM_NEWINDEX, - TM_GC, - TM_MODE, - TM_LEN, - TM_EQ, /* last tag method with fast access */ - TM_ADD, - TM_SUB, - TM_MUL, - TM_MOD, - TM_POW, - TM_DIV, - TM_IDIV, - TM_BAND, - TM_BOR, - TM_BXOR, - TM_SHL, - TM_SHR, - TM_UNM, - TM_BNOT, - TM_LT, - TM_LE, - TM_CONCAT, - TM_CALL, - TM_N /* number of elements in the enum */ -} TMS; - - - -#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ - ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) - -#define fasttm(l,et,e) gfasttm(G(l), et, e) - -#define ttypename(x) luaT_typenames_[(x) + 1] -#define objtypename(x) ttypename(ttnov(x)) - -LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; - - -LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); -LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, - TMS event); -LUAI_FUNC void luaT_init (lua_State *L); - -LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, - const TValue *p2, TValue *p3, int hasres); -LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, - StkId res, TMS event); -LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, - StkId res, TMS event); -LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, - const TValue *p2, TMS event); - - - -#endif diff --git a/thirdparty/src/Lua/lundump.cpp b/thirdparty/src/Lua/lundump.cpp deleted file mode 100644 index d9839f3a9..000000000 --- a/thirdparty/src/Lua/lundump.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/* -** $Id: lundump.c,v 2.41 2014/11/02 19:19:04 roberto Exp $ -** load precompiled Lua chunks -** See Copyright Notice in lua.h -*/ - -#define lundump_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <string.h> - -#include <Lua/lua.h> - -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lmem.h" -#include "lobject.h" -#include "lstring.h" -#include "lundump.h" -#include "lzio.h" - - -#if !defined(luai_verifycode) -#define luai_verifycode(L,b,f) /* empty */ -#endif - - -typedef struct { - lua_State *L; - ZIO *Z; - Mbuffer *b; - const char *name; -} LoadState; - - -static l_noret error(LoadState *S, const char *why) { - luaO_pushfstring(S->L, "%s: %s precompiled chunk", S->name, why); - luaD_throw(S->L, LUA_ERRSYNTAX); -} - - -/* -** All high-level loads go through LoadVector; you can change it to -** adapt to the endianness of the input -*/ -#define LoadVector(S,b,n) LoadBlock(S,b,(n)*sizeof((b)[0])) - -static void LoadBlock (LoadState *S, void *b, size_t size) { - if (luaZ_read(S->Z, b, size) != 0) - error(S, "truncated"); -} - - -#define LoadVar(S,x) LoadVector(S,&x,1) - - -static lu_byte LoadByte (LoadState *S) { - lu_byte x; - LoadVar(S, x); - return x; -} - - -static int LoadInt (LoadState *S) { - int x; - LoadVar(S, x); - return x; -} - - -static lua_Number LoadNumber (LoadState *S) { - lua_Number x; - LoadVar(S, x); - return x; -} - - -static lua_Integer LoadInteger (LoadState *S) { - lua_Integer x; - LoadVar(S, x); - return x; -} - - -static TString *LoadString (LoadState *S) { - size_t size = LoadByte(S); - if (size == 0xFF) - LoadVar(S, size); - if (size == 0) - return NULL; - else { - char *s = luaZ_openspace(S->L, S->b, --size); - LoadVector(S, s, size); - return luaS_newlstr(S->L, s, size); - } -} - - -static void LoadCode (LoadState *S, Proto *f) { - int n = LoadInt(S); - f->code = luaM_newvector(S->L, n, Instruction); - f->sizecode = n; - LoadVector(S, f->code, n); -} - - -static void LoadFunction(LoadState *S, Proto *f, TString *psource); - - -static void LoadConstants (LoadState *S, Proto *f) { - int i; - int n = LoadInt(S); - f->k = luaM_newvector(S->L, n, TValue); - f->sizek = n; - for (i = 0; i < n; i++) - setnilvalue(&f->k[i]); - for (i = 0; i < n; i++) { - TValue *o = &f->k[i]; - int t = LoadByte(S); - switch (t) { - case LUA_TNIL: - setnilvalue(o); - break; - case LUA_TBOOLEAN: - setbvalue(o, LoadByte(S)); - break; - case LUA_TNUMFLT: - setfltvalue(o, LoadNumber(S)); - break; - case LUA_TNUMINT: - setivalue(o, LoadInteger(S)); - break; - case LUA_TSHRSTR: - case LUA_TLNGSTR: - setsvalue2n(S->L, o, LoadString(S)); - break; - default: - lua_assert(0); - } - } -} - - -static void LoadProtos (LoadState *S, Proto *f) { - int i; - int n = LoadInt(S); - f->p = luaM_newvector(S->L, n, Proto *); - f->sizep = n; - for (i = 0; i < n; i++) - f->p[i] = NULL; - for (i = 0; i < n; i++) { - f->p[i] = luaF_newproto(S->L); - LoadFunction(S, f->p[i], f->source); - } -} - - -static void LoadUpvalues (LoadState *S, Proto *f) { - int i, n; - n = LoadInt(S); - f->upvalues = luaM_newvector(S->L, n, Upvaldesc); - f->sizeupvalues = n; - for (i = 0; i < n; i++) - f->upvalues[i].name = NULL; - for (i = 0; i < n; i++) { - f->upvalues[i].instack = LoadByte(S); - f->upvalues[i].idx = LoadByte(S); - } -} - - -static void LoadDebug (LoadState *S, Proto *f) { - int i, n; - n = LoadInt(S); - f->lineinfo = luaM_newvector(S->L, n, int); - f->sizelineinfo = n; - LoadVector(S, f->lineinfo, n); - n = LoadInt(S); - f->locvars = luaM_newvector(S->L, n, LocVar); - f->sizelocvars = n; - for (i = 0; i < n; i++) - f->locvars[i].varname = NULL; - for (i = 0; i < n; i++) { - f->locvars[i].varname = LoadString(S); - f->locvars[i].startpc = LoadInt(S); - f->locvars[i].endpc = LoadInt(S); - } - n = LoadInt(S); - for (i = 0; i < n; i++) - f->upvalues[i].name = LoadString(S); -} - - -static void LoadFunction (LoadState *S, Proto *f, TString *psource) { - f->source = LoadString(S); - if (f->source == NULL) /* no source in dump? */ - f->source = psource; /* reuse parent's source */ - f->linedefined = LoadInt(S); - f->lastlinedefined = LoadInt(S); - f->numparams = LoadByte(S); - f->is_vararg = LoadByte(S); - f->maxstacksize = LoadByte(S); - LoadCode(S, f); - LoadConstants(S, f); - LoadUpvalues(S, f); - LoadProtos(S, f); - LoadDebug(S, f); -} - - -static void checkliteral (LoadState *S, const char *s, const char *msg) { - char buff[sizeof(LUA_SIGNATURE) + sizeof(LUAC_DATA)]; /* larger than both */ - size_t len = strlen(s); - LoadVector(S, buff, len); - if (memcmp(s, buff, len) != 0) - error(S, msg); -} - - -static void fchecksize (LoadState *S, size_t size, const char *tname) { - if (LoadByte(S) != size) - error(S, luaO_pushfstring(S->L, "%s size mismatch in", tname)); -} - - -#define checksize(S,t) fchecksize(S,sizeof(t),#t) - -static void checkHeader (LoadState *S) { - checkliteral(S, LUA_SIGNATURE + 1, "not a"); /* 1st char already checked */ - if (LoadByte(S) != LUAC_VERSION) - error(S, "version mismatch in"); - if (LoadByte(S) != LUAC_FORMAT) - error(S, "format mismatch in"); - checkliteral(S, LUAC_DATA, "corrupted"); - checksize(S, int); - checksize(S, size_t); - checksize(S, Instruction); - checksize(S, lua_Integer); - checksize(S, lua_Number); - if (LoadInteger(S) != LUAC_INT) - error(S, "endianness mismatch in"); - if (LoadNumber(S) != LUAC_NUM) - error(S, "float format mismatch in"); -} - - -/* -** load precompiled chunk -*/ -LClosure *luaU_undump(lua_State *L, ZIO *Z, Mbuffer *buff, - const char *name) { - LoadState S; - LClosure *cl; - if (*name == '@' || *name == '=') - S.name = name + 1; - else if (*name == LUA_SIGNATURE[0]) - S.name = "binary string"; - else - S.name = name; - S.L = L; - S.Z = Z; - S.b = buff; - checkHeader(&S); - cl = luaF_newLclosure(L, LoadByte(&S)); - setclLvalue(L, L->top, cl); - incr_top(L); - cl->p = luaF_newproto(L); - LoadFunction(&S, cl->p, NULL); - lua_assert(cl->nupvalues == cl->p->sizeupvalues); - luai_verifycode(L, buff, cl->p); - return cl; -} - diff --git a/thirdparty/src/Lua/lundump.h b/thirdparty/src/Lua/lundump.h deleted file mode 100644 index ef43d5126..000000000 --- a/thirdparty/src/Lua/lundump.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -** $Id: lundump.h,v 1.44 2014/06/19 18:27:20 roberto Exp $ -** load precompiled Lua chunks -** See Copyright Notice in lua.h -*/ - -#ifndef lundump_h -#define lundump_h - -#include "llimits.h" -#include "lobject.h" -#include "lzio.h" - - -/* data to catch conversion errors */ -#define LUAC_DATA "\x19\x93\r\n\x1a\n" - -#define LUAC_INT 0x5678 -#define LUAC_NUM cast_num(370.5) - -#define MYINT(s) (s[0]-'0') -#define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) -#define LUAC_FORMAT 0 /* this is the official format */ - -/* load one chunk; from lundump.c */ -LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, - const char* name); - -/* dump one chunk; from ldump.c */ -LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, - void* data, int strip); - -#endif diff --git a/thirdparty/src/Lua/lutf8lib.cpp b/thirdparty/src/Lua/lutf8lib.cpp deleted file mode 100644 index eebe8030e..000000000 --- a/thirdparty/src/Lua/lutf8lib.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/* -** $Id: lutf8lib.c,v 1.13 2014/11/02 19:19:04 roberto Exp $ -** Standard library for UTF-8 manipulation -** See Copyright Notice in lua.h -*/ - -#define lutf8lib_c -#define LUA_LIB - -#include "lprefix.h" - - -#include <assert.h> -#include <stdlib.h> -#include <string.h> - -#include <Lua/lua.h> - -#include <Lua/lauxlib.h> -#include <Lua/lualib.h> - -#define MAXUNICODE 0x10FFFF - -#define iscont(p) ((*(p) & 0xC0) == 0x80) - - -/* from strlib */ -/* translate a relative string position: negative means back from end */ -static lua_Integer u_posrelat (lua_Integer pos, size_t len) { - if (pos >= 0) return pos; - else if (0u - (size_t)pos > len) return 0; - else return (lua_Integer)len + pos + 1; -} - - -/* -** Decode one UTF-8 sequence, returning NULL if byte sequence is invalid. -*/ -static const char *utf8_decode (const char *o, int *val) { - static unsigned int limits[] = {0xFF, 0x7F, 0x7FF, 0xFFFF}; - const unsigned char *s = (const unsigned char *)o; - unsigned int c = s[0]; - unsigned int res = 0; /* final result */ - if (c < 0x80) /* ascii? */ - res = c; - else { - int count = 0; /* to count number of continuation bytes */ - while (c & 0x40) { /* still have continuation bytes? */ - int cc = s[++count]; /* read next byte */ - if ((cc & 0xC0) != 0x80) /* not a continuation byte? */ - return NULL; /* invalid byte sequence */ - res = (res << 6) | (cc & 0x3F); /* add lower 6 bits from cont. byte */ - c <<= 1; /* to test next bit */ - } - res |= ((c & 0x7F) << (count * 5)); /* add first byte */ - if (count > 3 || res > MAXUNICODE || res <= limits[count]) - return NULL; /* invalid byte sequence */ - s += count; /* skip continuation bytes read */ - } - if (val) *val = res; - return (const char *)s + 1; /* +1 to include first byte */ -} - - -/* -** utf8len(s [, i [, j]]) --> number of characters that start in the -** range [i,j], or nil + current position if 's' is not well formed in -** that interval -*/ -static int utflen (lua_State *L) { - int n = 0; - size_t len; - const char *s = luaL_checklstring(L, 1, &len); - lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), len); - lua_Integer posj = u_posrelat(luaL_optinteger(L, 3, -1), len); - luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 2, - "initial position out of string"); - luaL_argcheck(L, --posj < (lua_Integer)len, 3, - "final position out of string"); - while (posi <= posj) { - const char *s1 = utf8_decode(s + posi, NULL); - if (s1 == NULL) { /* conversion error? */ - lua_pushnil(L); /* return nil ... */ - lua_pushinteger(L, posi + 1); /* ... and current position */ - return 2; - } - posi = s1 - s; - n++; - } - lua_pushinteger(L, n); - return 1; -} - - -/* -** codepoint(s, [i, [j]]) -> returns codepoints for all characters -** that start in the range [i,j] -*/ -static int codepoint (lua_State *L) { - size_t len; - const char *s = luaL_checklstring(L, 1, &len); - lua_Integer posi = u_posrelat(luaL_optinteger(L, 2, 1), len); - lua_Integer pose = u_posrelat(luaL_optinteger(L, 3, posi), len); - int n; - const char *se; - luaL_argcheck(L, posi >= 1, 2, "out of range"); - luaL_argcheck(L, pose <= (lua_Integer)len, 3, "out of range"); - if (posi > pose) return 0; /* empty interval; return no values */ - n = (int)(pose - posi + 1); - if (posi + n <= pose) /* (lua_Integer -> int) overflow? */ - return luaL_error(L, "string slice too long"); - luaL_checkstack(L, n, "string slice too long"); - n = 0; - se = s + pose; - for (s += posi - 1; s < se;) { - int code; - s = utf8_decode(s, &code); - if (s == NULL) - return luaL_error(L, "invalid UTF-8 code"); - lua_pushinteger(L, code); - n++; - } - return n; -} - - -static void pushutfchar (lua_State *L, int arg) { - lua_Integer code = luaL_checkinteger(L, arg); - luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, "value out of range"); - lua_pushfstring(L, "%U", (long)code); -} - - -/* -** utfchar(n1, n2, ...) -> char(n1)..char(n2)... -*/ -static int utfchar (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - if (n == 1) /* optimize common case of single char */ - pushutfchar(L, 1); - else { - int i; - luaL_Buffer b; - luaL_buffinit(L, &b); - for (i = 1; i <= n; i++) { - pushutfchar(L, i); - luaL_addvalue(&b); - } - luaL_pushresult(&b); - } - return 1; -} - - -/* -** offset(s, n, [i]) -> index where n-th character counting from -** position 'i' starts; 0 means character at 'i'. -*/ -static int byteoffset (lua_State *L) { - size_t len; - const char *s = luaL_checklstring(L, 1, &len); - lua_Integer n = luaL_checkinteger(L, 2); - lua_Integer posi = (n >= 0) ? 1 : len + 1; - posi = u_posrelat(luaL_optinteger(L, 3, posi), len); - luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 3, - "position out of range"); - if (n == 0) { - /* find beginning of current byte sequence */ - while (posi > 0 && iscont(s + posi)) posi--; - } - else { - if (iscont(s + posi)) - luaL_error(L, "initial position is a continuation byte"); - if (n < 0) { - while (n < 0 && posi > 0) { /* move back */ - do { /* find beginning of previous character */ - posi--; - } while (posi > 0 && iscont(s + posi)); - n++; - } - } - else { - n--; /* do not move for 1st character */ - while (n > 0 && posi < (lua_Integer)len) { - do { /* find beginning of next character */ - posi++; - } while (iscont(s + posi)); /* (cannot pass final '\0') */ - n--; - } - } - } - if (n == 0) /* did it find given character? */ - lua_pushinteger(L, posi + 1); - else /* no such character */ - lua_pushnil(L); - return 1; -} - - -static int iter_aux (lua_State *L) { - size_t len; - const char *s = luaL_checklstring(L, 1, &len); - lua_Integer n = lua_tointeger(L, 2) - 1; - if (n < 0) /* first iteration? */ - n = 0; /* start from here */ - else if (n < (lua_Integer)len) { - n++; /* skip current byte */ - while (iscont(s + n)) n++; /* and its continuations */ - } - if (n >= (lua_Integer)len) - return 0; /* no more codepoints */ - else { - int code; - const char *next = utf8_decode(s + n, &code); - if (next == NULL || iscont(next)) - return luaL_error(L, "invalid UTF-8 code"); - lua_pushinteger(L, n + 1); - lua_pushinteger(L, code); - return 2; - } -} - - -static int iter_codes (lua_State *L) { - luaL_checkstring(L, 1); - lua_pushcfunction(L, iter_aux); - lua_pushvalue(L, 1); - lua_pushinteger(L, 0); - return 3; -} - - -/* pattern to match a single UTF-8 character */ -#define UTF8PATT "[\0-\x7F\xC2-\xF4][\x80-\xBF]*" - - -static struct luaL_Reg funcs[] = { - {"offset", byteoffset}, - {"codepoint", codepoint}, - {"char", utfchar}, - {"len", utflen}, - {"codes", iter_codes}, - /* placeholders */ - {"charpattern", NULL}, - {NULL, NULL} -}; - - -LUAMOD_API int luaopen_utf8 (lua_State *L) { - luaL_newlib(L, funcs); - lua_pushliteral(L, UTF8PATT); - lua_setfield(L, -2, "charpattern"); - return 1; -} - diff --git a/thirdparty/src/Lua/lvm.cpp b/thirdparty/src/Lua/lvm.cpp deleted file mode 100644 index 6e3de2556..000000000 --- a/thirdparty/src/Lua/lvm.cpp +++ /dev/null @@ -1,1182 +0,0 @@ -/* -** $Id: lvm.c,v 2.232 2014/12/27 20:30:38 roberto Exp $ -** Lua virtual machine -** See Copyright Notice in lua.h -*/ - -#define lvm_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <limits.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <Lua/lua.h> - -#include "ldebug.h" -#include "ldo.h" -#include "lfunc.h" -#include "lgc.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lstate.h" -#include "lstring.h" -#include "ltable.h" -#include "ltm.h" -#include "lvm.h" - - -/* -** You can define LUA_FLOORN2I if you want to convert floats to integers -** by flooring them (instead of raising an error if they are not -** integral values) -*/ -#if !defined(LUA_FLOORN2I) -#define LUA_FLOORN2I 0 -#endif - - -/* limit for table tag-method chains (to avoid loops) */ -#define MAXTAGLOOP 2000 - - -/* -** Similar to 'tonumber', but does not attempt to convert strings and -** ensure correct precision (no extra bits). Used in comparisons. -*/ -static int tofloat (const TValue *obj, lua_Number *n) { - if (ttisfloat(obj)) *n = fltvalue(obj); - else if (ttisinteger(obj)) { - volatile lua_Number x = cast_num(ivalue(obj)); /* avoid extra precision */ - *n = x; - } - else { - *n = 0; /* to avoid warnings */ - return 0; - } - return 1; -} - - -/* -** Try to convert a value to a float. The float case is already handled -** by the macro 'tonumber'. -*/ -int luaV_tonumber_ (const TValue *obj, lua_Number *n) { - TValue v; - if (ttisinteger(obj)) { - *n = cast_num(ivalue(obj)); - return 1; - } - else if (cvt2num(obj) && /* string convertible to number? */ - luaO_str2num(svalue(obj), &v) == tsvalue(obj)->len + 1) { - *n = nvalue(&v); /* convert result of 'luaO_str2num' to a float */ - return 1; - } - else - return 0; /* conversion failed */ -} - - -/* -** try to convert a value to an integer, rounding according to 'mode': -** mode == 0: accepts only integral values -** mode == 1: takes the floor of the number -** mode == 2: takes the ceil of the number -*/ -static int tointeger_aux (const TValue *obj, lua_Integer *p, int mode) { - TValue v; - again: - if (ttisfloat(obj)) { - lua_Number n = fltvalue(obj); - lua_Number f = l_floor(n); - if (n != f) { /* not an integral value? */ - if (mode == 0) return 0; /* fails if mode demands integral value */ - else if (mode > 1) /* needs ceil? */ - f += 1; /* convert floor to ceil (remember: n != f) */ - } - return lua_numbertointeger(f, p); - } - else if (ttisinteger(obj)) { - *p = ivalue(obj); - return 1; - } - else if (cvt2num(obj) && - luaO_str2num(svalue(obj), &v) == tsvalue(obj)->len + 1) { - obj = &v; - goto again; /* convert result from 'luaO_str2num' to an integer */ - } - return 0; /* conversion failed */ -} - - -/* -** try to convert a value to an integer -*/ -int luaV_tointeger_ (const TValue *obj, lua_Integer *p) { - return tointeger_aux(obj, p, LUA_FLOORN2I); -} - - -/* -** Try to convert a 'for' limit to an integer, preserving the -** semantics of the loop. -** (The following explanation assumes a non-negative step; it is valid -** for negative steps mutatis mutandis.) -** If the limit can be converted to an integer, rounding down, that is -** it. -** Otherwise, check whether the limit can be converted to a number. If -** the number is too large, it is OK to set the limit as LUA_MAXINTEGER, -** which means no limit. If the number is too negative, the loop -** should not run, because any initial integer value is larger than the -** limit. So, it sets the limit to LUA_MININTEGER. 'stopnow' corrects -** the extreme case when the initial value is LUA_MININTEGER, in which -** case the LUA_MININTEGER limit would still run the loop once. -*/ -static int forlimit (const TValue *obj, lua_Integer *p, lua_Integer step, - int *stopnow) { - *stopnow = 0; /* usually, let loops run */ - if (!tointeger_aux(obj, p, (step < 0 ? 2 : 1))) { /* not fit in integer? */ - lua_Number n; /* try to convert to float */ - if (!tonumber(obj, &n)) /* cannot convert to float? */ - return 0; /* not a number */ - if (n > 0) { /* if true, float is larger than max integer */ - *p = LUA_MAXINTEGER; - if (step < 0) *stopnow = 1; - } - else { /* float is smaller than min integer */ - *p = LUA_MININTEGER; - if (step >= 0) *stopnow = 1; - } - } - return 1; -} - - -/* -** Main function for table access (invoking metamethods if needed). -** Compute 'val = t[key]' -*/ -void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { - int loop; /* counter to avoid infinite loops */ - for (loop = 0; loop < MAXTAGLOOP; loop++) { - const TValue *tm; - if (ttistable(t)) { /* 't' is a table? */ - Table *h = hvalue(t); - const TValue *res = luaH_get(h, key); /* do a primitive get */ - if (!ttisnil(res) || /* result is not nil? */ - (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ - setobj2s(L, val, res); /* result is the raw get */ - return; - } - /* else will try metamethod */ - } - else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) - luaG_typeerror(L, t, "index"); /* no metamethod */ - if (ttisfunction(tm)) { /* metamethod is a function */ - luaT_callTM(L, tm, t, key, val, 1); - return; - } - t = tm; /* else repeat access over 'tm' */ - } - luaG_runerror(L, "gettable chain too long; possible loop"); -} - - -/* -** Main function for table assignment (invoking metamethods if needed). -** Compute 't[key] = val' -*/ -void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { - int loop; /* counter to avoid infinite loops */ - for (loop = 0; loop < MAXTAGLOOP; loop++) { - const TValue *tm; - if (ttistable(t)) { /* 't' is a table? */ - Table *h = hvalue(t); - TValue *oldval = cast(TValue *, luaH_get(h, key)); - /* if previous value is not nil, there must be a previous entry - in the table; a metamethod has no relevance */ - if (!ttisnil(oldval) || - /* previous value is nil; must check the metamethod */ - ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL && - /* no metamethod; is there a previous entry in the table? */ - (oldval != luaO_nilobject || - /* no previous entry; must create one. (The next test is - always true; we only need the assignment.) */ - (oldval = luaH_newkey(L, h, key), 1)))) { - /* no metamethod and (now) there is an entry with given key */ - setobj2t(L, oldval, val); /* assign new value to that entry */ - invalidateTMcache(h); - luaC_barrierback(L, h, val); - return; - } - /* else will try the metamethod */ - } - else /* not a table; check metamethod */ - if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) - luaG_typeerror(L, t, "index"); - /* try the metamethod */ - if (ttisfunction(tm)) { - luaT_callTM(L, tm, t, key, val, 0); - return; - } - t = tm; /* else repeat assignment over 'tm' */ - } - luaG_runerror(L, "settable chain too long; possible loop"); -} - - -/* -** Compare two strings 'ls' x 'rs', returning an integer smaller-equal- -** -larger than zero if 'ls' is smaller-equal-larger than 'rs'. -** The code is a little tricky because it allows '\0' in the strings -** and it uses 'strcoll' (to respect locales) for each segments -** of the strings. -*/ -static int l_strcmp (const TString *ls, const TString *rs) { - const char *l = getstr(ls); - size_t ll = ls->len; - const char *r = getstr(rs); - size_t lr = rs->len; - for (;;) { /* for each segment */ - int temp = strcoll(l, r); - if (temp != 0) /* not equal? */ - return temp; /* done */ - else { /* strings are equal up to a '\0' */ - size_t len = strlen(l); /* index of first '\0' in both strings */ - if (len == lr) /* 'rs' is finished? */ - return (len == ll) ? 0 : 1; /* check 'ls' */ - else if (len == ll) /* 'ls' is finished? */ - return -1; /* 'ls' is smaller than 'rs' ('rs' is not finished) */ - /* both strings longer than 'len'; go on comparing after the '\0' */ - len++; - l += len; ll -= len; r += len; lr -= len; - } - } -} - - -/* -** Main operation less than; return 'l < r'. -*/ -int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { - int res; - lua_Number nl, nr; - if (ttisinteger(l) && ttisinteger(r)) /* both operands are integers? */ - return (ivalue(l) < ivalue(r)); - else if (tofloat(l, &nl) && tofloat(r, &nr)) /* both are numbers? */ - return luai_numlt(nl, nr); - else if (ttisstring(l) && ttisstring(r)) /* both are strings? */ - return l_strcmp(tsvalue(l), tsvalue(r)) < 0; - else if ((res = luaT_callorderTM(L, l, r, TM_LT)) < 0) /* no metamethod? */ - luaG_ordererror(L, l, r); /* error */ - return res; -} - - -/* -** Main operation less than or equal to; return 'l <= r'. -*/ -int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) { - int res; - lua_Number nl, nr; - if (ttisinteger(l) && ttisinteger(r)) /* both operands are integers? */ - return (ivalue(l) <= ivalue(r)); - else if (tofloat(l, &nl) && tofloat(r, &nr)) /* both are numbers? */ - return luai_numle(nl, nr); - else if (ttisstring(l) && ttisstring(r)) /* both are strings? */ - return l_strcmp(tsvalue(l), tsvalue(r)) <= 0; - else if ((res = luaT_callorderTM(L, l, r, TM_LE)) >= 0) /* first try 'le' */ - return res; - else if ((res = luaT_callorderTM(L, r, l, TM_LT)) < 0) /* else try 'lt' */ - luaG_ordererror(L, l, r); - return !res; -} - - -/* -** Main operation for equality of Lua values; return 't1 == t2'. -** L == NULL means raw equality (no metamethods) -*/ -int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) { - const TValue *tm; - if (ttype(t1) != ttype(t2)) { /* not the same variant? */ - if (ttnov(t1) != ttnov(t2) || ttnov(t1) != LUA_TNUMBER) - return 0; /* only numbers can be equal with different variants */ - else { /* two numbers with different variants */ - lua_Number n1, n2; /* compare them as floats */ - lua_assert(ttisnumber(t1) && ttisnumber(t2)); - cast_void(tofloat(t1, &n1)); cast_void(tofloat(t2, &n2)); - return luai_numeq(n1, n2); - } - } - /* values have same type and same variant */ - switch (ttype(t1)) { - case LUA_TNIL: return 1; - case LUA_TNUMINT: return (ivalue(t1) == ivalue(t2)); - case LUA_TNUMFLT: return luai_numeq(fltvalue(t1), fltvalue(t2)); - case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ - case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); - case LUA_TLCF: return fvalue(t1) == fvalue(t2); - case LUA_TSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2)); - case LUA_TLNGSTR: return luaS_eqlngstr(tsvalue(t1), tsvalue(t2)); - case LUA_TUSERDATA: { - if (uvalue(t1) == uvalue(t2)) return 1; - else if (L == NULL) return 0; - tm = fasttm(L, uvalue(t1)->metatable, TM_EQ); - if (tm == NULL) - tm = fasttm(L, uvalue(t2)->metatable, TM_EQ); - break; /* will try TM */ - } - case LUA_TTABLE: { - if (hvalue(t1) == hvalue(t2)) return 1; - else if (L == NULL) return 0; - tm = fasttm(L, hvalue(t1)->metatable, TM_EQ); - if (tm == NULL) - tm = fasttm(L, hvalue(t2)->metatable, TM_EQ); - break; /* will try TM */ - } - default: - return gcvalue(t1) == gcvalue(t2); - } - if (tm == NULL) /* no TM? */ - return 0; /* objects are different */ - luaT_callTM(L, tm, t1, t2, L->top, 1); /* call TM */ - return !l_isfalse(L->top); -} - - -/* macro used by 'luaV_concat' to ensure that element at 'o' is a string */ -#define tostring(L,o) \ - (ttisstring(o) || (cvt2str(o) && (luaO_tostring(L, o), 1))) - -/* -** Main operation for concatenation: concat 'total' values in the stack, -** from 'L->top - total' up to 'L->top - 1'. -*/ -void luaV_concat (lua_State *L, int total) { - lua_assert(total >= 2); - do { - StkId top = L->top; - int n = 2; /* number of elements handled in this pass (at least 2) */ - if (!(ttisstring(top-2) || cvt2str(top-2)) || !tostring(L, top-1)) - luaT_trybinTM(L, top-2, top-1, top-2, TM_CONCAT); - else if (tsvalue(top-1)->len == 0) /* second operand is empty? */ - cast_void(tostring(L, top - 2)); /* result is first operand */ - else if (ttisstring(top-2) && tsvalue(top-2)->len == 0) { - setobjs2s(L, top - 2, top - 1); /* result is second op. */ - } - else { - /* at least two non-empty string values; get as many as possible */ - size_t tl = tsvalue(top-1)->len; - char *buffer; - int i; - /* collect total length */ - for (i = 1; i < total && tostring(L, top-i-1); i++) { - size_t l = tsvalue(top-i-1)->len; - if (l >= (MAX_SIZE/sizeof(char)) - tl) - luaG_runerror(L, "string length overflow"); - tl += l; - } - buffer = luaZ_openspace(L, &G(L)->buff, tl); - tl = 0; - n = i; - do { /* copy all strings to buffer */ - size_t l = tsvalue(top-i)->len; - memcpy(buffer+tl, svalue(top-i), l * sizeof(char)); - tl += l; - } while (--i > 0); - setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); /* create result */ - } - total -= n-1; /* got 'n' strings to create 1 new */ - L->top -= n-1; /* popped 'n' strings and pushed one */ - } while (total > 1); /* repeat until only 1 result left */ -} - - -/* -** Main operation 'ra' = #rb'. -*/ -void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { - const TValue *tm; - switch (ttnov(rb)) { - case LUA_TTABLE: { - Table *h = hvalue(rb); - tm = fasttm(L, h->metatable, TM_LEN); - if (tm) break; /* metamethod? break switch to call it */ - setivalue(ra, luaH_getn(h)); /* else primitive len */ - return; - } - case LUA_TSTRING: { - setivalue(ra, tsvalue(rb)->len); - return; - } - default: { /* try metamethod */ - tm = luaT_gettmbyobj(L, rb, TM_LEN); - if (ttisnil(tm)) /* no metamethod? */ - luaG_typeerror(L, rb, "get length of"); - break; - } - } - luaT_callTM(L, tm, rb, rb, ra, 1); -} - - -/* -** Integer division; return 'm // n', that is, floor(m/n). -** C division truncates its result (rounds towards zero). -** 'floor(q) == trunc(q)' when 'q >= 0' or when 'q' is integer, -** otherwise 'floor(q) == trunc(q) - 1'. -*/ -lua_Integer luaV_div (lua_State *L, lua_Integer m, lua_Integer n) { - if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */ - if (n == 0) - luaG_runerror(L, "attempt to divide by zero"); - return intop(-, 0, m); /* n==-1; avoid overflow with 0x80000...//-1 */ - } - else { - lua_Integer q = m / n; /* perform C division */ - if ((m ^ n) < 0 && m % n != 0) /* 'm/n' would be negative non-integer? */ - q -= 1; /* correct result for different rounding */ - return q; - } -} - - -/* -** Integer modulus; return 'm % n'. (Assume that C '%' with -** negative operands follows C99 behavior. See previous comment -** about luaV_div.) -*/ -lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) { - if (l_castS2U(n) + 1u <= 1u) { /* special cases: -1 or 0 */ - if (n == 0) - luaG_runerror(L, "attempt to perform 'n%%0'"); - return 0; /* m % -1 == 0; avoid overflow with 0x80000...%-1 */ - } - else { - lua_Integer r = m % n; - if (r != 0 && (m ^ n) < 0) /* 'm/n' would be non-integer negative? */ - r += n; /* correct result for different rounding */ - return r; - } -} - - -/* number of bits in an integer */ -#define NBITS cast_int(sizeof(lua_Integer) * CHAR_BIT) - -/* -** Shift left operation. (Shift right just negates 'y'.) -*/ -lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) { - if (y < 0) { /* shift right? */ - if (y <= -NBITS) return 0; - else return intop(>>, x, -y); - } - else { /* shift left */ - if (y >= NBITS) return 0; - else return intop(<<, x, y); - } -} - - -/* -** check whether cached closure in prototype 'p' may be reused, that is, -** whether there is a cached closure with the same upvalues needed by -** new closure to be created. -*/ -static LClosure *getcached (Proto *p, UpVal **encup, StkId base) { - LClosure *c = p->cache; - if (c != NULL) { /* is there a cached closure? */ - int nup = p->sizeupvalues; - Upvaldesc *uv = p->upvalues; - int i; - for (i = 0; i < nup; i++) { /* check whether it has right upvalues */ - TValue *v = uv[i].instack ? base + uv[i].idx : encup[uv[i].idx]->v; - if (c->upvals[i]->v != v) - return NULL; /* wrong upvalue; cannot reuse closure */ - } - } - return c; /* return cached closure (or NULL if no cached closure) */ -} - - -/* -** create a new Lua closure, push it in the stack, and initialize -** its upvalues. Note that the closure is not cached if prototype is -** already black (which means that 'cache' was already cleared by the -** GC). -*/ -static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, - StkId ra) { - int nup = p->sizeupvalues; - Upvaldesc *uv = p->upvalues; - int i; - LClosure *ncl = luaF_newLclosure(L, nup); - ncl->p = p; - setclLvalue(L, ra, ncl); /* anchor new closure in stack */ - for (i = 0; i < nup; i++) { /* fill in its upvalues */ - if (uv[i].instack) /* upvalue refers to local variable? */ - ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx); - else /* get upvalue from enclosing function */ - ncl->upvals[i] = encup[uv[i].idx]; - ncl->upvals[i]->refcount++; - /* new closure is white, so we do not need a barrier here */ - } - if (!isblack(p)) /* cache will not break GC invariant? */ - p->cache = ncl; /* save it on cache for reuse */ -} - - -/* -** finish execution of an opcode interrupted by an yield -*/ -void luaV_finishOp (lua_State *L) { - CallInfo *ci = L->ci; - StkId base = ci->u.l.base; - Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */ - OpCode op = GET_OPCODE(inst); - switch (op) { /* finish its execution */ - case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV: case OP_IDIV: - case OP_BAND: case OP_BOR: case OP_BXOR: case OP_SHL: case OP_SHR: - case OP_MOD: case OP_POW: - case OP_UNM: case OP_BNOT: case OP_LEN: - case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: { - setobjs2s(L, base + GETARG_A(inst), --L->top); - break; - } - case OP_LE: case OP_LT: case OP_EQ: { - int res = !l_isfalse(L->top - 1); - L->top--; - /* metamethod should not be called when operand is K */ - lua_assert(!ISK(GETARG_B(inst))); - if (op == OP_LE && /* "<=" using "<" instead? */ - ttisnil(luaT_gettmbyobj(L, base + GETARG_B(inst), TM_LE))) - res = !res; /* invert result */ - lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP); - if (res != GETARG_A(inst)) /* condition failed? */ - ci->u.l.savedpc++; /* skip jump instruction */ - break; - } - case OP_CONCAT: { - StkId top = L->top - 1; /* top when 'luaT_trybinTM' was called */ - int b = GETARG_B(inst); /* first element to concatenate */ - int total = cast_int(top - 1 - (base + b)); /* yet to concatenate */ - setobj2s(L, top - 2, top); /* put TM result in proper position */ - if (total > 1) { /* are there elements to concat? */ - L->top = top - 1; /* top is one after last element (at top-2) */ - luaV_concat(L, total); /* concat them (may yield again) */ - } - /* move final result to final position */ - setobj2s(L, ci->u.l.base + GETARG_A(inst), L->top - 1); - L->top = ci->top; /* restore top */ - break; - } - case OP_TFORCALL: { - lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_TFORLOOP); - L->top = ci->top; /* correct top */ - break; - } - case OP_CALL: { - if (GETARG_C(inst) - 1 >= 0) /* nresults >= 0? */ - L->top = ci->top; /* adjust results */ - break; - } - case OP_TAILCALL: case OP_SETTABUP: case OP_SETTABLE: - break; - default: lua_assert(0); - } -} - - - - -/* -** {================================================================== -** Function 'luaV_execute': main interpreter loop -** =================================================================== -*/ - - -/* -** some macros for common tasks in 'luaV_execute' -*/ - -#if !defined luai_runtimecheck -#define luai_runtimecheck(L, c) /* void */ -#endif - - -#define RA(i) (base+GETARG_A(i)) -/* to be used after possible stack reallocation */ -#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i)) -#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i)) -#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \ - ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) -#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ - ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) -#define KBx(i) \ - (k + (GETARG_Bx(i) != 0 ? GETARG_Bx(i) - 1 : GETARG_Ax(*ci->u.l.savedpc++))) - - -/* execute a jump instruction */ -#define dojump(ci,i,e) \ - { int a = GETARG_A(i); \ - if (a > 0) luaF_close(L, ci->u.l.base + a - 1); \ - ci->u.l.savedpc += GETARG_sBx(i) + e; } - -/* for test instructions, execute the jump instruction that follows it */ -#define donextjump(ci) { i = *ci->u.l.savedpc; dojump(ci, i, 1); } - - -#define Protect(x) { {x;}; base = ci->u.l.base; } - -#define checkGC(L,c) \ - Protect( luaC_condGC(L,{L->top = (c); /* limit of live values */ \ - luaC_step(L); \ - L->top = ci->top;}) /* restore top */ \ - luai_threadyield(L); ) - - -#define vmdispatch(o) switch(o) -#define vmcase(l) case l: -#define vmbreak break - -void luaV_execute (lua_State *L) { - CallInfo *ci = L->ci; - LClosure *cl; - TValue *k; - StkId base; - newframe: /* reentry point when frame changes (call/return) */ - lua_assert(ci == L->ci); - cl = clLvalue(ci->func); - k = cl->p->k; - base = ci->u.l.base; - /* main loop of interpreter */ - for (;;) { - Instruction i = *(ci->u.l.savedpc++); - StkId ra; - if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && - (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { - Protect(luaG_traceexec(L)); - } - /* WARNING: several calls may realloc the stack and invalidate 'ra' */ - ra = RA(i); - lua_assert(base == ci->u.l.base); - lua_assert(base <= L->top && L->top < L->stack + L->stacksize); - vmdispatch (GET_OPCODE(i)) { - vmcase(OP_MOVE) { - setobjs2s(L, ra, RB(i)); - vmbreak; - } - vmcase(OP_LOADK) { - TValue *rb = k + GETARG_Bx(i); - setobj2s(L, ra, rb); - vmbreak; - } - vmcase(OP_LOADKX) { - TValue *rb; - lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); - rb = k + GETARG_Ax(*ci->u.l.savedpc++); - setobj2s(L, ra, rb); - vmbreak; - } - vmcase(OP_LOADBOOL) { - setbvalue(ra, GETARG_B(i)); - if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */ - vmbreak; - } - vmcase(OP_LOADNIL) { - int b = GETARG_B(i); - do { - setnilvalue(ra++); - } while (b--); - vmbreak; - } - vmcase(OP_GETUPVAL) { - int b = GETARG_B(i); - setobj2s(L, ra, cl->upvals[b]->v); - vmbreak; - } - vmcase(OP_GETTABUP) { - int b = GETARG_B(i); - Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra)); - vmbreak; - } - vmcase(OP_GETTABLE) { - Protect(luaV_gettable(L, RB(i), RKC(i), ra)); - vmbreak; - } - vmcase(OP_SETTABUP) { - int a = GETARG_A(i); - Protect(luaV_settable(L, cl->upvals[a]->v, RKB(i), RKC(i))); - vmbreak; - } - vmcase(OP_SETUPVAL) { - UpVal *uv = cl->upvals[GETARG_B(i)]; - setobj(L, uv->v, ra); - luaC_upvalbarrier(L, uv); - vmbreak; - } - vmcase(OP_SETTABLE) { - Protect(luaV_settable(L, ra, RKB(i), RKC(i))); - vmbreak; - } - vmcase(OP_NEWTABLE) { - int b = GETARG_B(i); - int c = GETARG_C(i); - Table *t = luaH_new(L); - sethvalue(L, ra, t); - if (b != 0 || c != 0) - luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); - checkGC(L, ra + 1); - vmbreak; - } - vmcase(OP_SELF) { - StkId rb = RB(i); - setobjs2s(L, ra+1, rb); - Protect(luaV_gettable(L, rb, RKC(i), ra)); - vmbreak; - } - vmcase(OP_ADD) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (ttisinteger(rb) && ttisinteger(rc)) { - lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); - setivalue(ra, intop(+, ib, ic)); - } - else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - setfltvalue(ra, luai_numadd(L, nb, nc)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); } - vmbreak; - } - vmcase(OP_SUB) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (ttisinteger(rb) && ttisinteger(rc)) { - lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); - setivalue(ra, intop(-, ib, ic)); - } - else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - setfltvalue(ra, luai_numsub(L, nb, nc)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SUB)); } - vmbreak; - } - vmcase(OP_MUL) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (ttisinteger(rb) && ttisinteger(rc)) { - lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); - setivalue(ra, intop(*, ib, ic)); - } - else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - setfltvalue(ra, luai_nummul(L, nb, nc)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MUL)); } - vmbreak; - } - vmcase(OP_DIV) { /* float division (always with floats) */ - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - setfltvalue(ra, luai_numdiv(L, nb, nc)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); } - vmbreak; - } - vmcase(OP_BAND) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Integer ib; lua_Integer ic; - if (tointeger(rb, &ib) && tointeger(rc, &ic)) { - setivalue(ra, intop(&, ib, ic)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BAND)); } - vmbreak; - } - vmcase(OP_BOR) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Integer ib; lua_Integer ic; - if (tointeger(rb, &ib) && tointeger(rc, &ic)) { - setivalue(ra, intop(|, ib, ic)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BOR)); } - vmbreak; - } - vmcase(OP_BXOR) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Integer ib; lua_Integer ic; - if (tointeger(rb, &ib) && tointeger(rc, &ic)) { - setivalue(ra, intop(^, ib, ic)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BXOR)); } - vmbreak; - } - vmcase(OP_SHL) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Integer ib; lua_Integer ic; - if (tointeger(rb, &ib) && tointeger(rc, &ic)) { - setivalue(ra, luaV_shiftl(ib, ic)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHL)); } - vmbreak; - } - vmcase(OP_SHR) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Integer ib; lua_Integer ic; - if (tointeger(rb, &ib) && tointeger(rc, &ic)) { - setivalue(ra, luaV_shiftl(ib, -ic)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHR)); } - vmbreak; - } - vmcase(OP_MOD) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (ttisinteger(rb) && ttisinteger(rc)) { - lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); - setivalue(ra, luaV_mod(L, ib, ic)); - } - else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - lua_Number m; - luai_nummod(L, nb, nc, m); - setfltvalue(ra, m); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MOD)); } - vmbreak; - } - vmcase(OP_IDIV) { /* floor division */ - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (ttisinteger(rb) && ttisinteger(rc)) { - lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); - setivalue(ra, luaV_div(L, ib, ic)); - } - else if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - setfltvalue(ra, luai_numidiv(L, nb, nc)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_IDIV)); } - vmbreak; - } - vmcase(OP_POW) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - lua_Number nb; lua_Number nc; - if (tonumber(rb, &nb) && tonumber(rc, &nc)) { - setfltvalue(ra, luai_numpow(L, nb, nc)); - } - else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_POW)); } - vmbreak; - } - vmcase(OP_UNM) { - TValue *rb = RB(i); - lua_Number nb; - if (ttisinteger(rb)) { - lua_Integer ib = ivalue(rb); - setivalue(ra, intop(-, 0, ib)); - } - else if (tonumber(rb, &nb)) { - setfltvalue(ra, luai_numunm(L, nb)); - } - else { - Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM)); - } - vmbreak; - } - vmcase(OP_BNOT) { - TValue *rb = RB(i); - lua_Integer ib; - if (tointeger(rb, &ib)) { - setivalue(ra, intop(^, ~l_castS2U(0), ib)); - } - else { - Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT)); - } - vmbreak; - } - vmcase(OP_NOT) { - TValue *rb = RB(i); - int res = l_isfalse(rb); /* next assignment may change this value */ - setbvalue(ra, res); - vmbreak; - } - vmcase(OP_LEN) { - Protect(luaV_objlen(L, ra, RB(i))); - vmbreak; - } - vmcase(OP_CONCAT) { - int b = GETARG_B(i); - int c = GETARG_C(i); - StkId rb; - L->top = base + c + 1; /* mark the end of concat operands */ - Protect(luaV_concat(L, c - b + 1)); - ra = RA(i); /* 'luav_concat' may invoke TMs and move the stack */ - rb = b + base; - setobjs2s(L, ra, rb); - checkGC(L, (ra >= rb ? ra + 1 : rb)); - L->top = ci->top; /* restore top */ - vmbreak; - } - vmcase(OP_JMP) { - dojump(ci, i, 0); - vmbreak; - } - vmcase(OP_EQ) { - TValue *rb = RKB(i); - TValue *rc = RKC(i); - Protect( - if (cast_int(luaV_equalobj(L, rb, rc)) != GETARG_A(i)) - ci->u.l.savedpc++; - else - donextjump(ci); - ) - vmbreak; - } - vmcase(OP_LT) { - Protect( - if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i)) - ci->u.l.savedpc++; - else - donextjump(ci); - ) - vmbreak; - } - vmcase(OP_LE) { - Protect( - if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i)) - ci->u.l.savedpc++; - else - donextjump(ci); - ) - vmbreak; - } - vmcase(OP_TEST) { - if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra)) - ci->u.l.savedpc++; - else - donextjump(ci); - vmbreak; - } - vmcase(OP_TESTSET) { - TValue *rb = RB(i); - if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb)) - ci->u.l.savedpc++; - else { - setobjs2s(L, ra, rb); - donextjump(ci); - } - vmbreak; - } - vmcase(OP_CALL) { - int b = GETARG_B(i); - int nresults = GETARG_C(i) - 1; - if (b != 0) L->top = ra+b; /* else previous instruction set top */ - if (luaD_precall(L, ra, nresults)) { /* C function? */ - if (nresults >= 0) L->top = ci->top; /* adjust results */ - base = ci->u.l.base; - } - else { /* Lua function */ - ci = L->ci; - ci->callstatus |= CIST_REENTRY; - goto newframe; /* restart luaV_execute over new Lua function */ - } - vmbreak; - } - vmcase(OP_TAILCALL) { - int b = GETARG_B(i); - if (b != 0) L->top = ra+b; /* else previous instruction set top */ - lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); - if (luaD_precall(L, ra, LUA_MULTRET)) /* C function? */ - base = ci->u.l.base; - else { - /* tail call: put called frame (n) in place of caller one (o) */ - CallInfo *nci = L->ci; /* called frame */ - CallInfo *oci = nci->previous; /* caller frame */ - StkId nfunc = nci->func; /* called function */ - StkId ofunc = oci->func; /* caller function */ - /* last stack slot filled by 'precall' */ - StkId lim = nci->u.l.base + getproto(nfunc)->numparams; - int aux; - /* close all upvalues from previous call */ - if (cl->p->sizep > 0) luaF_close(L, oci->u.l.base); - /* move new frame into old one */ - for (aux = 0; nfunc + aux < lim; aux++) - setobjs2s(L, ofunc + aux, nfunc + aux); - oci->u.l.base = ofunc + (nci->u.l.base - nfunc); /* correct base */ - oci->top = L->top = ofunc + (L->top - nfunc); /* correct top */ - oci->u.l.savedpc = nci->u.l.savedpc; - oci->callstatus |= CIST_TAIL; /* function was tail called */ - ci = L->ci = oci; /* remove new frame */ - lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize); - goto newframe; /* restart luaV_execute over new Lua function */ - } - vmbreak; - } - vmcase(OP_RETURN) { - int b = GETARG_B(i); - if (b != 0) L->top = ra+b-1; - if (cl->p->sizep > 0) luaF_close(L, base); - b = luaD_poscall(L, ra); - if (!(ci->callstatus & CIST_REENTRY)) /* 'ci' still the called one */ - return; /* external invocation: return */ - else { /* invocation via reentry: continue execution */ - ci = L->ci; - if (b) L->top = ci->top; - lua_assert(isLua(ci)); - lua_assert(GET_OPCODE(*((ci)->u.l.savedpc - 1)) == OP_CALL); - goto newframe; /* restart luaV_execute over new Lua function */ - } - } - vmcase(OP_FORLOOP) { - if (ttisinteger(ra)) { /* integer loop? */ - lua_Integer step = ivalue(ra + 2); - lua_Integer idx = ivalue(ra) + step; /* increment index */ - lua_Integer limit = ivalue(ra + 1); - if ((0 < step) ? (idx <= limit) : (limit <= idx)) { - ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ - setivalue(ra, idx); /* update internal index... */ - setivalue(ra + 3, idx); /* ...and external index */ - } - } - else { /* floating loop */ - lua_Number step = fltvalue(ra + 2); - lua_Number idx = luai_numadd(L, fltvalue(ra), step); /* inc. index */ - lua_Number limit = fltvalue(ra + 1); - if (luai_numlt(0, step) ? luai_numle(idx, limit) - : luai_numle(limit, idx)) { - ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ - setfltvalue(ra, idx); /* update internal index... */ - setfltvalue(ra + 3, idx); /* ...and external index */ - } - } - vmbreak; - } - vmcase(OP_FORPREP) { - TValue *init = ra; - TValue *plimit = ra + 1; - TValue *pstep = ra + 2; - lua_Integer ilimit; - int stopnow; - if (ttisinteger(init) && ttisinteger(pstep) && - forlimit(plimit, &ilimit, ivalue(pstep), &stopnow)) { - /* all values are integer */ - lua_Integer initv = (stopnow ? 0 : ivalue(init)); - setivalue(plimit, ilimit); - setivalue(init, initv - ivalue(pstep)); - } - else { /* try making all values floats */ - lua_Number ninit; lua_Number nlimit; lua_Number nstep; - if (!tonumber(plimit, &nlimit)) - luaG_runerror(L, "'for' limit must be a number"); - setfltvalue(plimit, nlimit); - if (!tonumber(pstep, &nstep)) - luaG_runerror(L, "'for' step must be a number"); - setfltvalue(pstep, nstep); - if (!tonumber(init, &ninit)) - luaG_runerror(L, "'for' initial value must be a number"); - setfltvalue(init, luai_numsub(L, ninit, nstep)); - } - ci->u.l.savedpc += GETARG_sBx(i); - vmbreak; - } - vmcase(OP_TFORCALL) { - StkId cb = ra + 3; /* call base */ - setobjs2s(L, cb+2, ra+2); - setobjs2s(L, cb+1, ra+1); - setobjs2s(L, cb, ra); - L->top = cb + 3; /* func. + 2 args (state and index) */ - Protect(luaD_call(L, cb, GETARG_C(i), 1)); - L->top = ci->top; - i = *(ci->u.l.savedpc++); /* go to next instruction */ - ra = RA(i); - lua_assert(GET_OPCODE(i) == OP_TFORLOOP); - goto l_tforloop; - } - vmcase(OP_TFORLOOP) { - l_tforloop: - if (!ttisnil(ra + 1)) { /* continue loop? */ - setobjs2s(L, ra, ra + 1); /* save control variable */ - ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ - } - vmbreak; - } - vmcase(OP_SETLIST) { - int n = GETARG_B(i); - int c = GETARG_C(i); - unsigned int last; - Table *h; - if (n == 0) n = cast_int(L->top - ra) - 1; - if (c == 0) { - lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); - c = GETARG_Ax(*ci->u.l.savedpc++); - } - luai_runtimecheck(L, ttistable(ra)); - h = hvalue(ra); - last = ((c-1)*LFIELDS_PER_FLUSH) + n; - if (last > h->sizearray) /* needs more space? */ - luaH_resizearray(L, h, last); /* pre-allocate it at once */ - for (; n > 0; n--) { - TValue *val = ra+n; - luaH_setint(L, h, last--, val); - luaC_barrierback(L, h, val); - } - L->top = ci->top; /* correct top (in case of previous open call) */ - vmbreak; - } - vmcase(OP_CLOSURE) { - Proto *p = cl->p->p[GETARG_Bx(i)]; - LClosure *ncl = getcached(p, cl->upvals, base); /* cached closure */ - if (ncl == NULL) /* no match? */ - pushclosure(L, p, cl->upvals, base, ra); /* create a new one */ - else - setclLvalue(L, ra, ncl); /* push cashed closure */ - checkGC(L, ra + 1); - vmbreak; - } - vmcase(OP_VARARG) { - int b = GETARG_B(i) - 1; - int j; - int n = cast_int(base - ci->func) - cl->p->numparams - 1; - if (b < 0) { /* B == 0? */ - b = n; /* get all var. arguments */ - Protect(luaD_checkstack(L, n)); - ra = RA(i); /* previous call may change the stack */ - L->top = ra + n; - } - for (j = 0; j < b; j++) { - if (j < n) { - setobjs2s(L, ra + j, base - n + j); - } - else { - setnilvalue(ra + j); - } - } - vmbreak; - } - vmcase(OP_EXTRAARG) { - lua_assert(0); - vmbreak; - } - } - } -} - -/* }================================================================== */ - diff --git a/thirdparty/src/Lua/lvm.h b/thirdparty/src/Lua/lvm.h deleted file mode 100644 index 5c5e18c3a..000000000 --- a/thirdparty/src/Lua/lvm.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -** $Id: lvm.h,v 2.34 2014/08/01 17:24:02 roberto Exp $ -** Lua virtual machine -** See Copyright Notice in lua.h -*/ - -#ifndef lvm_h -#define lvm_h - - -#include "ldo.h" -#include "lobject.h" -#include "ltm.h" - - -#if !defined(LUA_NOCVTN2S) -#define cvt2str(o) ttisnumber(o) -#else -#define cvt2str(o) 0 /* no conversion from numbers to strings */ -#endif - - -#if !defined(LUA_NOCVTS2N) -#define cvt2num(o) ttisstring(o) -#else -#define cvt2num(o) 0 /* no conversion from strings to numbers */ -#endif - - -#define tonumber(o,n) \ - (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) - -#define tointeger(o,i) \ - (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger_(o,i)) - -#define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) - -#define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) - - -LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); -LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); -LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); -LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); -LUAI_FUNC int luaV_tointeger_ (const TValue *obj, lua_Integer *p); -LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, - StkId val); -LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, - StkId val); -LUAI_FUNC void luaV_finishOp (lua_State *L); -LUAI_FUNC void luaV_execute (lua_State *L); -LUAI_FUNC void luaV_concat (lua_State *L, int total); -LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y); -LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); -LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y); -LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); - -#endif diff --git a/thirdparty/src/Lua/lzio.cpp b/thirdparty/src/Lua/lzio.cpp deleted file mode 100644 index ad44ac40e..000000000 --- a/thirdparty/src/Lua/lzio.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* -** $Id: lzio.c,v 1.36 2014/11/02 19:19:04 roberto Exp $ -** Buffered streams -** See Copyright Notice in lua.h -*/ - -#define lzio_c -#define LUA_CORE - -#include "lprefix.h" - - -#include <string.h> - -#include <Lua/lua.h> - -#include "llimits.h" -#include "lmem.h" -#include "lstate.h" -#include "lzio.h" - - -int luaZ_fill (ZIO *z) { - size_t size; - lua_State *L = z->L; - const char *buff; - lua_unlock(L); - buff = z->reader(L, z->data, &size); - lua_lock(L); - if (buff == NULL || size == 0) - return EOZ; - z->n = size - 1; /* discount char being returned */ - z->p = buff; - return cast_uchar(*(z->p++)); -} - - -void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { - z->L = L; - z->reader = reader; - z->data = data; - z->n = 0; - z->p = NULL; -} - - -/* --------------------------------------------------------------- read --- */ -size_t luaZ_read (ZIO *z, void *b, size_t n) { - while (n) { - size_t m; - if (z->n == 0) { /* no bytes in buffer? */ - if (luaZ_fill(z) == EOZ) /* try to read more */ - return n; /* no more input; return number of missing bytes */ - else { - z->n++; /* luaZ_fill consumed first byte; put it back */ - z->p--; - } - } - m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ - memcpy(b, z->p, m); - z->n -= m; - z->p += m; - b = (char *)b + m; - n -= m; - } - return 0; -} - -/* ------------------------------------------------------------------------ */ -char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { - if (n > buff->buffsize) { - if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; - luaZ_resizebuffer(L, buff, n); - } - return buff->buffer; -} - - diff --git a/thirdparty/src/Lua/lzio.h b/thirdparty/src/Lua/lzio.h deleted file mode 100644 index e94f9e87a..000000000 --- a/thirdparty/src/Lua/lzio.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -** $Id: lzio.h,v 1.30 2014/12/19 17:26:14 roberto Exp $ -** Buffered streams -** See Copyright Notice in lua.h -*/ - - -#ifndef lzio_h -#define lzio_h - -#include <Lua/lua.h> - -#include "lmem.h" - - -#define EOZ (-1) /* end of stream */ - -typedef struct Zio ZIO; - -#define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) - - -typedef struct Mbuffer { - char *buffer; - size_t n; - size_t buffsize; -} Mbuffer; - -#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) - -#define luaZ_buffer(buff) ((buff)->buffer) -#define luaZ_sizebuffer(buff) ((buff)->buffsize) -#define luaZ_bufflen(buff) ((buff)->n) - -#define luaZ_buffremove(buff,i) ((buff)->n -= (i)) -#define luaZ_resetbuffer(buff) ((buff)->n = 0) - - -#define luaZ_resizebuffer(L, buff, size) \ - ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ - (buff)->buffsize, size), \ - (buff)->buffsize = size) - -#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) - - -LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); -LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, - void *data); -LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ - - - -/* --------- Private Part ------------------ */ - -struct Zio { - size_t n; /* bytes still unread */ - const char *p; /* current position in buffer */ - lua_Reader reader; /* reader function */ - void *data; /* additional data */ - lua_State *L; /* Lua state (for reader) */ -}; - - -LUAI_FUNC int luaZ_fill (ZIO *z); - -#endif diff --git a/thirdparty/src/chipmunk/chipmunk.c b/thirdparty/src/chipmunk/chipmunk.c deleted file mode 100644 index a6cc9d6d4..000000000 --- a/thirdparty/src/chipmunk/chipmunk.c +++ /dev/null @@ -1,331 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <stdio.h> -#include <string.h> -#include <stdarg.h> -#if defined(ANDROID) -# include <android/log.h> -#endif - -#include "chipmunk/chipmunk_private.h" - -void -cpMessage(const char *condition, const char *file, int line, int isError, int isHardError, const char *message, ...) -{ - fprintf(stderr, (isError ? "Aborting due to Chipmunk error: " : "Chipmunk warning: ")); - - va_list vargs; - va_start(vargs, message); { -#if defined(ANDROID) - __android_log_print( ANDROID_LOG_INFO, "Chipmunk", "%s(%d)", file, line ); - __android_log_print( ANDROID_LOG_INFO, "Chipmunk", message, vargs ); -#else - vfprintf(stderr, message, vargs); - fprintf(stderr, "\n"); -#endif - } va_end(vargs); - -#if defined(ANDROID) - __android_log_print(ANDROID_LOG_INFO, "Chipmunk", "\tFailed condition: %s\n", condition); - __android_log_print(ANDROID_LOG_INFO, "Chipmunk", "\tSource:%s:%d\n", file, line); -#else - fprintf(stderr, "\tFailed condition: %s\n", condition); - fprintf(stderr, "\tSource:%s:%d\n", file, line); -#endif -} - -#define STR(s) #s -#define XSTR(s) STR(s) - -const char *cpVersionString = XSTR(CP_VERSION_MAJOR) "." XSTR(CP_VERSION_MINOR) "." XSTR(CP_VERSION_RELEASE); - -//MARK: Misc Functions - -cpFloat -cpMomentForCircle(cpFloat m, cpFloat r1, cpFloat r2, cpVect offset) -{ - return m*(0.5f*(r1*r1 + r2*r2) + cpvlengthsq(offset)); -} - -cpFloat -cpAreaForCircle(cpFloat r1, cpFloat r2) -{ - return (cpFloat)CP_PI*cpfabs(r1*r1 - r2*r2); -} - -cpFloat -cpMomentForSegment(cpFloat m, cpVect a, cpVect b, cpFloat r) -{ - cpVect offset = cpvlerp(a, b, 0.5f); - - // This approximates the shape as a box for rounded segments, but it's quite close. - cpFloat length = cpvdist(b, a) + 2.0f*r; - return m*((length*length + 4.0f*r*r)/12.0f + cpvlengthsq(offset)); -} - -cpFloat -cpAreaForSegment(cpVect a, cpVect b, cpFloat r) -{ - return r*((cpFloat)CP_PI*r + 2.0f*cpvdist(a, b)); -} - -cpFloat -cpMomentForPoly(cpFloat m, int count, const cpVect *verts, cpVect offset, cpFloat r) -{ - // TODO account for radius. - if(count == 2) return cpMomentForSegment(m, verts[0], verts[1], 0.0f); - - cpFloat sum1 = 0.0f; - cpFloat sum2 = 0.0f; - for(int i=0; i<count; i++){ - cpVect v1 = cpvadd(verts[i], offset); - cpVect v2 = cpvadd(verts[(i+1)%count], offset); - - cpFloat a = cpvcross(v2, v1); - cpFloat b = cpvdot(v1, v1) + cpvdot(v1, v2) + cpvdot(v2, v2); - - sum1 += a*b; - sum2 += a; - } - - return (m*sum1)/(6.0f*sum2); -} - -cpFloat -cpAreaForPoly(const int count, const cpVect *verts, cpFloat r) -{ - cpFloat area = 0.0f; - cpFloat perimeter = 0.0f; - for(int i=0; i<count; i++){ - cpVect v1 = verts[i]; - cpVect v2 = verts[(i+1)%count]; - - area += cpvcross(v1, v2); - perimeter += cpvdist(v1, v2); - } - - return r*(CP_PI*cpfabs(r) + perimeter) + area/2.0f; -} - -cpVect -cpCentroidForPoly(const int count, const cpVect *verts) -{ - cpFloat sum = 0.0f; - cpVect vsum = cpvzero; - - for(int i=0; i<count; i++){ - cpVect v1 = verts[i]; - cpVect v2 = verts[(i+1)%count]; - cpFloat cross = cpvcross(v1, v2); - - sum += cross; - vsum = cpvadd(vsum, cpvmult(cpvadd(v1, v2), cross)); - } - - return cpvmult(vsum, 1.0f/(3.0f*sum)); -} - -//void -//cpRecenterPoly(const int count, cpVect *verts){ -// cpVect centroid = cpCentroidForPoly(count, verts); -// -// for(int i=0; i<count; i++){ -// verts[i] = cpvsub(verts[i], centroid); -// } -//} - -cpFloat -cpMomentForBox(cpFloat m, cpFloat width, cpFloat height) -{ - return m*(width*width + height*height)/12.0f; -} - -cpFloat -cpMomentForBox2(cpFloat m, cpBB box) -{ - cpFloat width = box.r - box.l; - cpFloat height = box.t - box.b; - cpVect offset = cpvmult(cpv(box.l + box.r, box.b + box.t), 0.5f); - - // TODO: NaN when offset is 0 and m is INFINITY - return cpMomentForBox(m, width, height) + m*cpvlengthsq(offset); -} - -//MARK: Quick Hull - -void -cpLoopIndexes(const cpVect *verts, int count, int *start, int *end) -{ - (*start) = (*end) = 0; - cpVect min = verts[0]; - cpVect max = min; - - for(int i=1; i<count; i++){ - cpVect v = verts[i]; - - if(v.x < min.x || (v.x == min.x && v.y < min.y)){ - min = v; - (*start) = i; - } else if(v.x > max.x || (v.x == max.x && v.y > max.y)){ - max = v; - (*end) = i; - } - } -} - -#define SWAP(__A__, __B__) {cpVect __TMP__ = __A__; __A__ = __B__; __B__ = __TMP__;} - -static int -QHullPartition(cpVect *verts, int count, cpVect a, cpVect b, cpFloat tol) -{ - if(count == 0) return 0; - - cpFloat max = 0; - int pivot = 0; - - cpVect delta = cpvsub(b, a); - cpFloat valueTol = tol*cpvlength(delta); - - int head = 0; - for(int tail = count-1; head <= tail;){ - cpFloat value = cpvcross(cpvsub(verts[head], a), delta); - if(value > valueTol){ - if(value > max){ - max = value; - pivot = head; - } - - head++; - } else { - SWAP(verts[head], verts[tail]); - tail--; - } - } - - // move the new pivot to the front if it's not already there. - if(pivot != 0) SWAP(verts[0], verts[pivot]); - return head; -} - -static int -QHullReduce(cpFloat tol, cpVect *verts, int count, cpVect a, cpVect pivot, cpVect b, cpVect *result) -{ - if(count < 0){ - return 0; - } else if(count == 0) { - result[0] = pivot; - return 1; - } else { - int left_count = QHullPartition(verts, count, a, pivot, tol); - int index = QHullReduce(tol, verts + 1, left_count - 1, a, verts[0], pivot, result); - - result[index++] = pivot; - - int right_count = QHullPartition(verts + left_count, count - left_count, pivot, b, tol); - return index + QHullReduce(tol, verts + left_count + 1, right_count - 1, pivot, verts[left_count], b, result + index); - } -} - -// QuickHull seemed like a neat algorithm, and efficient-ish for large input sets. -// My implementation performs an in place reduction using the result array as scratch space. -int -cpConvexHull(int count, const cpVect *verts, cpVect *result, int *first, cpFloat tol) -{ - if(verts != result){ - // Copy the line vertexes into the empty part of the result polyline to use as a scratch buffer. - memcpy(result, verts, count*sizeof(cpVect)); - } - - // Degenerate case, all points are the same. - int start, end; - cpLoopIndexes(verts, count, &start, &end); - if(start == end){ - if(first) (*first) = 0; - return 1; - } - - SWAP(result[0], result[start]); - SWAP(result[1], result[end == 0 ? start : end]); - - cpVect a = result[0]; - cpVect b = result[1]; - - if(first) (*first) = start; - return QHullReduce(tol, result + 2, count - 2, a, b, a, result + 1) + 1; -} - -//MARK: Alternate Block Iterators - -#if defined(__has_extension) -#if __has_extension(blocks) - -static void IteratorFunc(void *ptr, void (^block)(void *ptr)){block(ptr);} - -void cpSpaceEachBody_b(cpSpace *space, void (^block)(cpBody *body)){ - cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)IteratorFunc, block); -} - -void cpSpaceEachShape_b(cpSpace *space, void (^block)(cpShape *shape)){ - cpSpaceEachShape(space, (cpSpaceShapeIteratorFunc)IteratorFunc, block); -} - -void cpSpaceEachConstraint_b(cpSpace *space, void (^block)(cpConstraint *constraint)){ - cpSpaceEachConstraint(space, (cpSpaceConstraintIteratorFunc)IteratorFunc, block); -} - -static void BodyIteratorFunc(cpBody *body, void *ptr, void (^block)(void *ptr)){block(ptr);} - -void cpBodyEachShape_b(cpBody *body, void (^block)(cpShape *shape)){ - cpBodyEachShape(body, (cpBodyShapeIteratorFunc)BodyIteratorFunc, block); -} - -void cpBodyEachConstraint_b(cpBody *body, void (^block)(cpConstraint *constraint)){ - cpBodyEachConstraint(body, (cpBodyConstraintIteratorFunc)BodyIteratorFunc, block); -} - -void cpBodyEachArbiter_b(cpBody *body, void (^block)(cpArbiter *arbiter)){ - cpBodyEachArbiter(body, (cpBodyArbiterIteratorFunc)BodyIteratorFunc, block); -} - -static void PointQueryIteratorFunc(cpShape *shape, cpVect p, cpFloat d, cpVect g, cpSpacePointQueryBlock block){block(shape, p, d, g);} -void cpSpacePointQuery_b(cpSpace *space, cpVect point, cpFloat maxDistance, cpShapeFilter filter, cpSpacePointQueryBlock block){ - cpSpacePointQuery(space, point, maxDistance, filter, (cpSpacePointQueryFunc)PointQueryIteratorFunc, block); -} - -static void SegmentQueryIteratorFunc(cpShape *shape, cpVect p, cpVect n, cpFloat t, cpSpaceSegmentQueryBlock block){block(shape, p, n, t);} -void cpSpaceSegmentQuery_b(cpSpace *space, cpVect start, cpVect end, cpFloat radius, cpShapeFilter filter, cpSpaceSegmentQueryBlock block){ - cpSpaceSegmentQuery(space, start, end, radius, filter, (cpSpaceSegmentQueryFunc)SegmentQueryIteratorFunc, block); -} - -void cpSpaceBBQuery_b(cpSpace *space, cpBB bb, cpShapeFilter filter, cpSpaceBBQueryBlock block){ - cpSpaceBBQuery(space, bb, filter, (cpSpaceBBQueryFunc)IteratorFunc, block); -} - -static void ShapeQueryIteratorFunc(cpShape *shape, cpContactPointSet *points, cpSpaceShapeQueryBlock block){block(shape, points);} -cpBool cpSpaceShapeQuery_b(cpSpace *space, cpShape *shape, cpSpaceShapeQueryBlock block){ - return cpSpaceShapeQuery(space, shape, (cpSpaceShapeQueryFunc)ShapeQueryIteratorFunc, block); -} - -#endif -#endif - -#include "chipmunk/chipmunk_ffi.h" diff --git a/thirdparty/src/chipmunk/cpArbiter.c b/thirdparty/src/chipmunk/cpArbiter.c deleted file mode 100644 index 6c52ceea0..000000000 --- a/thirdparty/src/chipmunk/cpArbiter.c +++ /dev/null @@ -1,496 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -// TODO: make this generic so I can reuse it for constraints also. -static inline void -unthreadHelper(cpArbiter *arb, cpBody *body) -{ - struct cpArbiterThread *thread = cpArbiterThreadForBody(arb, body); - cpArbiter *prev = thread->prev; - cpArbiter *next = thread->next; - - if(prev){ - cpArbiterThreadForBody(prev, body)->next = next; - } else if(body->arbiterList == arb) { - // IFF prev is NULL and body->arbiterList == arb, is arb at the head of the list. - // This function may be called for an arbiter that was never in a list. - // In that case, we need to protect it from wiping out the body->arbiterList pointer. - body->arbiterList = next; - } - - if(next) cpArbiterThreadForBody(next, body)->prev = prev; - - thread->prev = NULL; - thread->next = NULL; -} - -void -cpArbiterUnthread(cpArbiter *arb) -{ - unthreadHelper(arb, arb->body_a); - unthreadHelper(arb, arb->body_b); -} - -cpBool cpArbiterIsFirstContact(const cpArbiter *arb) -{ - return arb->state == CP_ARBITER_STATE_FIRST_COLLISION; -} - -cpBool cpArbiterIsRemoval(const cpArbiter *arb) -{ - return arb->state == CP_ARBITER_STATE_INVALIDATED; -} - -int cpArbiterGetCount(const cpArbiter *arb) -{ - // Return 0 contacts if we are in a separate callback. - return (arb->state < CP_ARBITER_STATE_CACHED ? arb->count : 0); -} - -cpVect -cpArbiterGetNormal(const cpArbiter *arb) -{ - return cpvmult(arb->n, arb->swapped ? -1.0f : 1.0); -} - -cpVect -cpArbiterGetPointA(const cpArbiter *arb, int i) -{ - cpAssertHard(0 <= i && i < cpArbiterGetCount(arb), "Index error: The specified contact index is invalid for this arbiter"); - return cpvadd(arb->body_a->p, arb->contacts[i].r1); -} - -cpVect -cpArbiterGetPointB(const cpArbiter *arb, int i) -{ - cpAssertHard(0 <= i && i < cpArbiterGetCount(arb), "Index error: The specified contact index is invalid for this arbiter"); - return cpvadd(arb->body_b->p, arb->contacts[i].r2); -} - -cpFloat -cpArbiterGetDepth(const cpArbiter *arb, int i) -{ - cpAssertHard(0 <= i && i < cpArbiterGetCount(arb), "Index error: The specified contact index is invalid for this arbiter"); - - struct cpContact *con = &arb->contacts[i]; - return cpvdot(cpvadd(cpvsub(con->r2, con->r1), cpvsub(arb->body_b->p, arb->body_a->p)), arb->n); -} - -cpContactPointSet -cpArbiterGetContactPointSet(const cpArbiter *arb) -{ - cpContactPointSet set; - set.count = cpArbiterGetCount(arb); - - cpBool swapped = arb->swapped; - cpVect n = arb->n; - set.normal = (swapped ? cpvneg(n) : n); - - for(int i=0; i<set.count; i++){ - // Contact points are relative to body CoGs; - cpVect p1 = cpvadd(arb->body_a->p, arb->contacts[i].r1); - cpVect p2 = cpvadd(arb->body_b->p, arb->contacts[i].r2); - - set.points[i].pointA = (swapped ? p2 : p1); - set.points[i].pointB = (swapped ? p1 : p2); - set.points[i].distance = cpvdot(cpvsub(p2, p1), n); - } - - return set; -} - -void -cpArbiterSetContactPointSet(cpArbiter *arb, cpContactPointSet *set) -{ - int count = set->count; - cpAssertHard(count == arb->count, "The number of contact points cannot be changed."); - - cpBool swapped = arb->swapped; - arb->n = (swapped ? cpvneg(set->normal) : set->normal); - - for(int i=0; i<count; i++){ - // Convert back to CoG relative offsets. - cpVect p1 = set->points[i].pointA; - cpVect p2 = set->points[i].pointB; - - arb->contacts[i].r1 = cpvsub(swapped ? p2 : p1, arb->body_a->p); - arb->contacts[i].r2 = cpvsub(swapped ? p1 : p2, arb->body_b->p); - } -} - -cpVect -cpArbiterTotalImpulse(const cpArbiter *arb) -{ - struct cpContact *contacts = arb->contacts; - cpVect n = arb->n; - cpVect sum = cpvzero; - - for(int i=0, count=cpArbiterGetCount(arb); i<count; i++){ - struct cpContact *con = &contacts[i]; - sum = cpvadd(sum, cpvrotate(n, cpv(con->jnAcc, con->jtAcc))); - } - - return (arb->swapped ? sum : cpvneg(sum)); - return cpvzero; -} - -cpFloat -cpArbiterTotalKE(const cpArbiter *arb) -{ - cpFloat eCoef = (1 - arb->e)/(1 + arb->e); - cpFloat sum = 0.0; - - struct cpContact *contacts = arb->contacts; - for(int i=0, count=cpArbiterGetCount(arb); i<count; i++){ - struct cpContact *con = &contacts[i]; - cpFloat jnAcc = con->jnAcc; - cpFloat jtAcc = con->jtAcc; - - sum += eCoef*jnAcc*jnAcc/con->nMass + jtAcc*jtAcc/con->tMass; - } - - return sum; -} - -cpBool -cpArbiterIgnore(cpArbiter *arb) -{ - arb->state = CP_ARBITER_STATE_IGNORE; - return cpFalse; -} - -cpFloat -cpArbiterGetRestitution(const cpArbiter *arb) -{ - return arb->e; -} - -void -cpArbiterSetRestitution(cpArbiter *arb, cpFloat restitution) -{ - arb->e = restitution; -} - -cpFloat -cpArbiterGetFriction(const cpArbiter *arb) -{ - return arb->u; -} - -void -cpArbiterSetFriction(cpArbiter *arb, cpFloat friction) -{ - arb->u = friction; -} - -cpVect -cpArbiterGetSurfaceVelocity(cpArbiter *arb) -{ - return cpvmult(arb->surface_vr, arb->swapped ? -1.0f : 1.0); -} - -void -cpArbiterSetSurfaceVelocity(cpArbiter *arb, cpVect vr) -{ - arb->surface_vr = cpvmult(vr, arb->swapped ? -1.0f : 1.0); -} - -cpDataPointer -cpArbiterGetUserData(const cpArbiter *arb) -{ - return arb->data; -} - -void -cpArbiterSetUserData(cpArbiter *arb, cpDataPointer userData) -{ - arb->data = userData; -} - -void -cpArbiterGetShapes(const cpArbiter *arb, cpShape **a, cpShape **b) -{ - if(arb->swapped){ - (*a) = (cpShape *)arb->b, (*b) = (cpShape *)arb->a; - } else { - (*a) = (cpShape *)arb->a, (*b) = (cpShape *)arb->b; - } -} - -void cpArbiterGetBodies(const cpArbiter *arb, cpBody **a, cpBody **b) -{ - CP_ARBITER_GET_SHAPES(arb, shape_a, shape_b); - (*a) = shape_a->body; - (*b) = shape_b->body; -} - -cpBool -cpArbiterCallWildcardBeginA(cpArbiter *arb, cpSpace *space) -{ - cpCollisionHandler *handler = arb->handlerA; - return handler->beginFunc(arb, space, handler->userData); -} - -cpBool -cpArbiterCallWildcardBeginB(cpArbiter *arb, cpSpace *space) -{ - cpCollisionHandler *handler = arb->handlerB; - arb->swapped = !arb->swapped; - cpBool retval = handler->beginFunc(arb, space, handler->userData); - arb->swapped = !arb->swapped; - return retval; -} - -cpBool -cpArbiterCallWildcardPreSolveA(cpArbiter *arb, cpSpace *space) -{ - cpCollisionHandler *handler = arb->handlerA; - return handler->preSolveFunc(arb, space, handler->userData); -} - -cpBool -cpArbiterCallWildcardPreSolveB(cpArbiter *arb, cpSpace *space) -{ - cpCollisionHandler *handler = arb->handlerB; - arb->swapped = !arb->swapped; - cpBool retval = handler->preSolveFunc(arb, space, handler->userData); - arb->swapped = !arb->swapped; - return retval; -} - -void -cpArbiterCallWildcardPostSolveA(cpArbiter *arb, cpSpace *space) -{ - cpCollisionHandler *handler = arb->handlerA; - handler->postSolveFunc(arb, space, handler->userData); -} - -void -cpArbiterCallWildcardPostSolveB(cpArbiter *arb, cpSpace *space) -{ - cpCollisionHandler *handler = arb->handlerB; - arb->swapped = !arb->swapped; - handler->postSolveFunc(arb, space, handler->userData); - arb->swapped = !arb->swapped; -} - -void -cpArbiterCallWildcardSeparateA(cpArbiter *arb, cpSpace *space) -{ - cpCollisionHandler *handler = arb->handlerA; - handler->separateFunc(arb, space, handler->userData); -} - -void -cpArbiterCallWildcardSeparateB(cpArbiter *arb, cpSpace *space) -{ - cpCollisionHandler *handler = arb->handlerB; - arb->swapped = !arb->swapped; - handler->separateFunc(arb, space, handler->userData); - arb->swapped = !arb->swapped; -} - -cpArbiter* -cpArbiterInit(cpArbiter *arb, cpShape *a, cpShape *b) -{ - arb->handler = NULL; - arb->swapped = cpFalse; - - arb->handler = NULL; - arb->handlerA = NULL; - arb->handlerB = NULL; - - arb->e = 0.0f; - arb->u = 0.0f; - arb->surface_vr = cpvzero; - - arb->count = 0; - arb->contacts = NULL; - - arb->a = a; arb->body_a = a->body; - arb->b = b; arb->body_b = b->body; - - arb->thread_a.next = NULL; - arb->thread_b.next = NULL; - arb->thread_a.prev = NULL; - arb->thread_b.prev = NULL; - - arb->stamp = 0; - arb->state = CP_ARBITER_STATE_FIRST_COLLISION; - - arb->data = NULL; - - return arb; -} - -static inline cpCollisionHandler * -cpSpaceLookupHandler(cpSpace *space, cpCollisionType a, cpCollisionType b, cpCollisionHandler *defaultValue) -{ - cpCollisionType types[] = {a, b}; - cpCollisionHandler *handler = (cpCollisionHandler *)cpHashSetFind(space->collisionHandlers, CP_HASH_PAIR(a, b), types); - return (handler ? handler : defaultValue); -} - -void -cpArbiterUpdate(cpArbiter *arb, struct cpCollisionInfo *info, cpSpace *space) -{ - const cpShape *a = info->a, *b = info->b; - - // For collisions between two similar primitive types, the order could have been swapped since the last frame. - arb->a = a; arb->body_a = a->body; - arb->b = b; arb->body_b = b->body; - - // Iterate over the possible pairs to look for hash value matches. - for(int i=0; i<info->count; i++){ - struct cpContact *con = &info->arr[i]; - - // r1 and r2 store absolute offsets at init time. - // Need to convert them to relative offsets. - con->r1 = cpvsub(con->r1, a->body->p); - con->r2 = cpvsub(con->r2, b->body->p); - - // Cached impulses are not zeroed at init time. - con->jnAcc = con->jtAcc = 0.0f; - - for(int j=0; j<arb->count; j++){ - struct cpContact *old = &arb->contacts[j]; - - // This could trigger false positives, but is fairly unlikely nor serious if it does. - if(con->hash == old->hash){ - // Copy the persistant contact information. - con->jnAcc = old->jnAcc; - con->jtAcc = old->jtAcc; - } - } - } - - arb->contacts = info->arr; - arb->count = info->count; - arb->n = info->n; - - arb->e = a->e * b->e; - arb->u = a->u * b->u; - - cpVect surface_vr = cpvsub(b->surfaceV, a->surfaceV); - arb->surface_vr = cpvsub(surface_vr, cpvmult(info->n, cpvdot(surface_vr, info->n))); - - cpCollisionType typeA = info->a->type, typeB = info->b->type; - cpCollisionHandler *defaultHandler = &space->defaultHandler; - cpCollisionHandler *handler = arb->handler = cpSpaceLookupHandler(space, typeA, typeB, defaultHandler); - - // Check if the types match, but don't swap for a default handler which use the wildcard for type A. - cpBool swapped = arb->swapped = (typeA != handler->typeA && handler->typeA != CP_WILDCARD_COLLISION_TYPE); - - if(handler != defaultHandler || space->usesWildcards){ - // The order of the main handler swaps the wildcard handlers too. Uffda. - arb->handlerA = cpSpaceLookupHandler(space, (swapped ? typeB : typeA), CP_WILDCARD_COLLISION_TYPE, &cpCollisionHandlerDoNothing); - arb->handlerB = cpSpaceLookupHandler(space, (swapped ? typeA : typeB), CP_WILDCARD_COLLISION_TYPE, &cpCollisionHandlerDoNothing); - } - - // mark it as new if it's been cached - if(arb->state == CP_ARBITER_STATE_CACHED) arb->state = CP_ARBITER_STATE_FIRST_COLLISION; -} - -void -cpArbiterPreStep(cpArbiter *arb, cpFloat dt, cpFloat slop, cpFloat bias) -{ - cpBody *a = arb->body_a; - cpBody *b = arb->body_b; - cpVect n = arb->n; - cpVect body_delta = cpvsub(b->p, a->p); - - for(int i=0; i<arb->count; i++){ - struct cpContact *con = &arb->contacts[i]; - - // Calculate the mass normal and mass tangent. - con->nMass = 1.0f/k_scalar(a, b, con->r1, con->r2, n); - con->tMass = 1.0f/k_scalar(a, b, con->r1, con->r2, cpvperp(n)); - - // Calculate the target bias velocity. - cpFloat dist = cpvdot(cpvadd(cpvsub(con->r2, con->r1), body_delta), n); - con->bias = -bias*cpfmin(0.0f, dist + slop)/dt; - con->jBias = 0.0f; - - // Calculate the target bounce velocity. - con->bounce = normal_relative_velocity(a, b, con->r1, con->r2, n)*arb->e; - } -} - -void -cpArbiterApplyCachedImpulse(cpArbiter *arb, cpFloat dt_coef) -{ - if(cpArbiterIsFirstContact(arb)) return; - - cpBody *a = arb->body_a; - cpBody *b = arb->body_b; - cpVect n = arb->n; - - for(int i=0; i<arb->count; i++){ - struct cpContact *con = &arb->contacts[i]; - cpVect j = cpvrotate(n, cpv(con->jnAcc, con->jtAcc)); - apply_impulses(a, b, con->r1, con->r2, cpvmult(j, dt_coef)); - } -} - -// TODO: is it worth splitting velocity/position correction? - -void -cpArbiterApplyImpulse(cpArbiter *arb) -{ - cpBody *a = arb->body_a; - cpBody *b = arb->body_b; - cpVect n = arb->n; - cpVect surface_vr = arb->surface_vr; - cpFloat friction = arb->u; - - for(int i=0; i<arb->count; i++){ - struct cpContact *con = &arb->contacts[i]; - cpFloat nMass = con->nMass; - cpVect r1 = con->r1; - cpVect r2 = con->r2; - - cpVect vb1 = cpvadd(a->v_bias, cpvmult(cpvperp(r1), a->w_bias)); - cpVect vb2 = cpvadd(b->v_bias, cpvmult(cpvperp(r2), b->w_bias)); - cpVect vr = cpvadd(relative_velocity(a, b, r1, r2), surface_vr); - - cpFloat vbn = cpvdot(cpvsub(vb2, vb1), n); - cpFloat vrn = cpvdot(vr, n); - cpFloat vrt = cpvdot(vr, cpvperp(n)); - - cpFloat jbn = (con->bias - vbn)*nMass; - cpFloat jbnOld = con->jBias; - con->jBias = cpfmax(jbnOld + jbn, 0.0f); - - cpFloat jn = -(con->bounce + vrn)*nMass; - cpFloat jnOld = con->jnAcc; - con->jnAcc = cpfmax(jnOld + jn, 0.0f); - - cpFloat jtMax = friction*con->jnAcc; - cpFloat jt = -vrt*con->tMass; - cpFloat jtOld = con->jtAcc; - con->jtAcc = cpfclamp(jtOld + jt, -jtMax, jtMax); - - apply_bias_impulses(a, b, r1, r2, cpvmult(n, con->jBias - jbnOld)); - apply_impulses(a, b, r1, r2, cpvrotate(n, cpv(con->jnAcc - jnOld, con->jtAcc - jtOld))); - } -} diff --git a/thirdparty/src/chipmunk/cpArray.c b/thirdparty/src/chipmunk/cpArray.c deleted file mode 100644 index a1f8df526..000000000 --- a/thirdparty/src/chipmunk/cpArray.c +++ /dev/null @@ -1,101 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <string.h> - -#include "chipmunk/chipmunk_private.h" - - -cpArray * -cpArrayNew(int size) -{ - cpArray *arr = (cpArray *)cpcalloc(1, sizeof(cpArray)); - - arr->num = 0; - arr->max = (size ? size : 4); - arr->arr = (void **)cpcalloc(arr->max, sizeof(void*)); - - return arr; -} - -void -cpArrayFree(cpArray *arr) -{ - if(arr){ - cpfree(arr->arr); - arr->arr = NULL; - - cpfree(arr); - } -} - -void -cpArrayPush(cpArray *arr, void *object) -{ - if(arr->num == arr->max){ - arr->max = 3*(arr->max + 1)/2; - arr->arr = (void **)cprealloc(arr->arr, arr->max*sizeof(void*)); - } - - arr->arr[arr->num] = object; - arr->num++; -} - -void * -cpArrayPop(cpArray *arr) -{ - arr->num--; - - void *value = arr->arr[arr->num]; - arr->arr[arr->num] = NULL; - - return value; -} - -void -cpArrayDeleteObj(cpArray *arr, void *obj) -{ - for(int i=0; i<arr->num; i++){ - if(arr->arr[i] == obj){ - arr->num--; - - arr->arr[i] = arr->arr[arr->num]; - arr->arr[arr->num] = NULL; - - return; - } - } -} - -void -cpArrayFreeEach(cpArray *arr, void (freeFunc)(void*)) -{ - for(int i=0; i<arr->num; i++) freeFunc(arr->arr[i]); -} - -cpBool -cpArrayContains(cpArray *arr, void *ptr) -{ - for(int i=0; i<arr->num; i++) - if(arr->arr[i] == ptr) return cpTrue; - - return cpFalse; -} diff --git a/thirdparty/src/chipmunk/cpBBTree.c b/thirdparty/src/chipmunk/cpBBTree.c deleted file mode 100644 index eb2944bad..000000000 --- a/thirdparty/src/chipmunk/cpBBTree.c +++ /dev/null @@ -1,896 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "stdlib.h" -#include "stdio.h" - -#include "chipmunk/chipmunk_private.h" - -static inline cpSpatialIndexClass *Klass(); - -typedef struct Node Node; -typedef struct Pair Pair; - -struct cpBBTree { - cpSpatialIndex spatialIndex; - cpBBTreeVelocityFunc velocityFunc; - - cpHashSet *leaves; - Node *root; - - Node *pooledNodes; - Pair *pooledPairs; - cpArray *allocatedBuffers; - - cpTimestamp stamp; -}; - -struct Node { - void *obj; - cpBB bb; - Node *parent; - - union { - // Internal nodes - struct { Node *a, *b; } children; - - // Leaves - struct { - cpTimestamp stamp; - Pair *pairs; - } leaf; - } node; -}; - -// Can't use anonymous unions and still get good x-compiler compatability -#define A node.children.a -#define B node.children.b -#define STAMP node.leaf.stamp -#define PAIRS node.leaf.pairs - -typedef struct Thread { - Pair *prev; - Node *leaf; - Pair *next; -} Thread; - -struct Pair { - Thread a, b; - cpCollisionID id; -}; - -//MARK: Misc Functions - -static inline cpBB -GetBB(cpBBTree *tree, void *obj) -{ - cpBB bb = tree->spatialIndex.bbfunc(obj); - - cpBBTreeVelocityFunc velocityFunc = tree->velocityFunc; - if(velocityFunc){ - cpFloat coef = 0.1f; - cpFloat x = (bb.r - bb.l)*coef; - cpFloat y = (bb.t - bb.b)*coef; - - cpVect v = cpvmult(velocityFunc(obj), 0.1f); - return cpBBNew(bb.l + cpfmin(-x, v.x), bb.b + cpfmin(-y, v.y), bb.r + cpfmax(x, v.x), bb.t + cpfmax(y, v.y)); - } else { - return bb; - } -} - -static inline cpBBTree * -GetTree(cpSpatialIndex *index) -{ - return (index && index->klass == Klass() ? (cpBBTree *)index : NULL); -} - -static inline Node * -GetRootIfTree(cpSpatialIndex *index){ - return (index && index->klass == Klass() ? ((cpBBTree *)index)->root : NULL); -} - -static inline cpBBTree * -GetMasterTree(cpBBTree *tree) -{ - cpBBTree *dynamicTree = GetTree(tree->spatialIndex.dynamicIndex); - return (dynamicTree ? dynamicTree : tree); -} - -static inline void -IncrementStamp(cpBBTree *tree) -{ - cpBBTree *dynamicTree = GetTree(tree->spatialIndex.dynamicIndex); - if(dynamicTree){ - dynamicTree->stamp++; - } else { - tree->stamp++; - } -} - -//MARK: Pair/Thread Functions - -static void -PairRecycle(cpBBTree *tree, Pair *pair) -{ - // Share the pool of the master tree. - // TODO: would be lovely to move the pairs stuff into an external data structure. - tree = GetMasterTree(tree); - - pair->a.next = tree->pooledPairs; - tree->pooledPairs = pair; -} - -static Pair * -PairFromPool(cpBBTree *tree) -{ - // Share the pool of the master tree. - // TODO: would be lovely to move the pairs stuff into an external data structure. - tree = GetMasterTree(tree); - - Pair *pair = tree->pooledPairs; - - if(pair){ - tree->pooledPairs = pair->a.next; - return pair; - } else { - // Pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(Pair); - cpAssertHard(count, "Internal Error: Buffer size is too small."); - - Pair *buffer = (Pair *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(tree->allocatedBuffers, buffer); - - // push all but the first one, return the first instead - for(int i=1; i<count; i++) PairRecycle(tree, buffer + i); - return buffer; - } -} - -static inline void -ThreadUnlink(Thread thread) -{ - Pair *next = thread.next; - Pair *prev = thread.prev; - - if(next){ - if(next->a.leaf == thread.leaf) next->a.prev = prev; else next->b.prev = prev; - } - - if(prev){ - if(prev->a.leaf == thread.leaf) prev->a.next = next; else prev->b.next = next; - } else { - thread.leaf->PAIRS = next; - } -} - -static void -PairsClear(Node *leaf, cpBBTree *tree) -{ - Pair *pair = leaf->PAIRS; - leaf->PAIRS = NULL; - - while(pair){ - if(pair->a.leaf == leaf){ - Pair *next = pair->a.next; - ThreadUnlink(pair->b); - PairRecycle(tree, pair); - pair = next; - } else { - Pair *next = pair->b.next; - ThreadUnlink(pair->a); - PairRecycle(tree, pair); - pair = next; - } - } -} - -static void -PairInsert(Node *a, Node *b, cpBBTree *tree) -{ - Pair *nextA = a->PAIRS, *nextB = b->PAIRS; - Pair *pair = PairFromPool(tree); - Pair temp = {{NULL, a, nextA},{NULL, b, nextB}, 0}; - - a->PAIRS = b->PAIRS = pair; - *pair = temp; - - if(nextA){ - if(nextA->a.leaf == a) nextA->a.prev = pair; else nextA->b.prev = pair; - } - - if(nextB){ - if(nextB->a.leaf == b) nextB->a.prev = pair; else nextB->b.prev = pair; - } -} - - -//MARK: Node Functions - -static void -NodeRecycle(cpBBTree *tree, Node *node) -{ - node->parent = tree->pooledNodes; - tree->pooledNodes = node; -} - -static Node * -NodeFromPool(cpBBTree *tree) -{ - Node *node = tree->pooledNodes; - - if(node){ - tree->pooledNodes = node->parent; - return node; - } else { - // Pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(Node); - cpAssertHard(count, "Internal Error: Buffer size is too small."); - - Node *buffer = (Node *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(tree->allocatedBuffers, buffer); - - // push all but the first one, return the first instead - for(int i=1; i<count; i++) NodeRecycle(tree, buffer + i); - return buffer; - } -} - -static inline void -NodeSetA(Node *node, Node *value) -{ - node->A = value; - value->parent = node; -} - -static inline void -NodeSetB(Node *node, Node *value) -{ - node->B = value; - value->parent = node; -} - -static Node * -NodeNew(cpBBTree *tree, Node *a, Node *b) -{ - Node *node = NodeFromPool(tree); - - node->obj = NULL; - node->bb = cpBBMerge(a->bb, b->bb); - node->parent = NULL; - - NodeSetA(node, a); - NodeSetB(node, b); - - return node; -} - -static inline cpBool -NodeIsLeaf(Node *node) -{ - return (node->obj != NULL); -} - -static inline Node * -NodeOther(Node *node, Node *child) -{ - return (node->A == child ? node->B : node->A); -} - -static inline void -NodeReplaceChild(Node *parent, Node *child, Node *value, cpBBTree *tree) -{ - cpAssertSoft(!NodeIsLeaf(parent), "Internal Error: Cannot replace child of a leaf."); - cpAssertSoft(child == parent->A || child == parent->B, "Internal Error: Node is not a child of parent."); - - if(parent->A == child){ - NodeRecycle(tree, parent->A); - NodeSetA(parent, value); - } else { - NodeRecycle(tree, parent->B); - NodeSetB(parent, value); - } - - for(Node *node=parent; node; node = node->parent){ - node->bb = cpBBMerge(node->A->bb, node->B->bb); - } -} - -//MARK: Subtree Functions - -static inline cpFloat -cpBBProximity(cpBB a, cpBB b) -{ - return cpfabs(a.l + a.r - b.l - b.r) + cpfabs(a.b + a.t - b.b - b.t); -} - -static Node * -SubtreeInsert(Node *subtree, Node *leaf, cpBBTree *tree) -{ - if(subtree == NULL){ - return leaf; - } else if(NodeIsLeaf(subtree)){ - return NodeNew(tree, leaf, subtree); - } else { - cpFloat cost_a = cpBBArea(subtree->B->bb) + cpBBMergedArea(subtree->A->bb, leaf->bb); - cpFloat cost_b = cpBBArea(subtree->A->bb) + cpBBMergedArea(subtree->B->bb, leaf->bb); - - if(cost_a == cost_b){ - cost_a = cpBBProximity(subtree->A->bb, leaf->bb); - cost_b = cpBBProximity(subtree->B->bb, leaf->bb); - } - - if(cost_b < cost_a){ - NodeSetB(subtree, SubtreeInsert(subtree->B, leaf, tree)); - } else { - NodeSetA(subtree, SubtreeInsert(subtree->A, leaf, tree)); - } - - subtree->bb = cpBBMerge(subtree->bb, leaf->bb); - return subtree; - } -} - -static void -SubtreeQuery(Node *subtree, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data) -{ - if(cpBBIntersects(subtree->bb, bb)){ - if(NodeIsLeaf(subtree)){ - func(obj, subtree->obj, 0, data); - } else { - SubtreeQuery(subtree->A, obj, bb, func, data); - SubtreeQuery(subtree->B, obj, bb, func, data); - } - } -} - - -static cpFloat -SubtreeSegmentQuery(Node *subtree, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data) -{ - if(NodeIsLeaf(subtree)){ - return func(obj, subtree->obj, data); - } else { - cpFloat t_a = cpBBSegmentQuery(subtree->A->bb, a, b); - cpFloat t_b = cpBBSegmentQuery(subtree->B->bb, a, b); - - if(t_a < t_b){ - if(t_a < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->A, obj, a, b, t_exit, func, data)); - if(t_b < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->B, obj, a, b, t_exit, func, data)); - } else { - if(t_b < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->B, obj, a, b, t_exit, func, data)); - if(t_a < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->A, obj, a, b, t_exit, func, data)); - } - - return t_exit; - } -} - -static void -SubtreeRecycle(cpBBTree *tree, Node *node) -{ - if(!NodeIsLeaf(node)){ - SubtreeRecycle(tree, node->A); - SubtreeRecycle(tree, node->B); - NodeRecycle(tree, node); - } -} - -static inline Node * -SubtreeRemove(Node *subtree, Node *leaf, cpBBTree *tree) -{ - if(leaf == subtree){ - return NULL; - } else { - Node *parent = leaf->parent; - if(parent == subtree){ - Node *other = NodeOther(subtree, leaf); - other->parent = subtree->parent; - NodeRecycle(tree, subtree); - return other; - } else { - NodeReplaceChild(parent->parent, parent, NodeOther(parent, leaf), tree); - return subtree; - } - } -} - -//MARK: Marking Functions - -typedef struct MarkContext { - cpBBTree *tree; - Node *staticRoot; - cpSpatialIndexQueryFunc func; - void *data; -} MarkContext; - -static void -MarkLeafQuery(Node *subtree, Node *leaf, cpBool left, MarkContext *context) -{ - if(cpBBIntersects(leaf->bb, subtree->bb)){ - if(NodeIsLeaf(subtree)){ - if(left){ - PairInsert(leaf, subtree, context->tree); - } else { - if(subtree->STAMP < leaf->STAMP) PairInsert(subtree, leaf, context->tree); - context->func(leaf->obj, subtree->obj, 0, context->data); - } - } else { - MarkLeafQuery(subtree->A, leaf, left, context); - MarkLeafQuery(subtree->B, leaf, left, context); - } - } -} - -static void -MarkLeaf(Node *leaf, MarkContext *context) -{ - cpBBTree *tree = context->tree; - if(leaf->STAMP == GetMasterTree(tree)->stamp){ - Node *staticRoot = context->staticRoot; - if(staticRoot) MarkLeafQuery(staticRoot, leaf, cpFalse, context); - - for(Node *node = leaf; node->parent; node = node->parent){ - if(node == node->parent->A){ - MarkLeafQuery(node->parent->B, leaf, cpTrue, context); - } else { - MarkLeafQuery(node->parent->A, leaf, cpFalse, context); - } - } - } else { - Pair *pair = leaf->PAIRS; - while(pair){ - if(leaf == pair->b.leaf){ - pair->id = context->func(pair->a.leaf->obj, leaf->obj, pair->id, context->data); - pair = pair->b.next; - } else { - pair = pair->a.next; - } - } - } -} - -static void -MarkSubtree(Node *subtree, MarkContext *context) -{ - if(NodeIsLeaf(subtree)){ - MarkLeaf(subtree, context); - } else { - MarkSubtree(subtree->A, context); - MarkSubtree(subtree->B, context); // TODO: Force TCO here? - } -} - -//MARK: Leaf Functions - -static Node * -LeafNew(cpBBTree *tree, void *obj, cpBB bb) -{ - Node *node = NodeFromPool(tree); - node->obj = obj; - node->bb = GetBB(tree, obj); - - node->parent = NULL; - node->STAMP = 0; - node->PAIRS = NULL; - - return node; -} - -static cpBool -LeafUpdate(Node *leaf, cpBBTree *tree) -{ - Node *root = tree->root; - cpBB bb = tree->spatialIndex.bbfunc(leaf->obj); - - if(!cpBBContainsBB(leaf->bb, bb)){ - leaf->bb = GetBB(tree, leaf->obj); - - root = SubtreeRemove(root, leaf, tree); - tree->root = SubtreeInsert(root, leaf, tree); - - PairsClear(leaf, tree); - leaf->STAMP = GetMasterTree(tree)->stamp; - - return cpTrue; - } else { - return cpFalse; - } -} - -static cpCollisionID VoidQueryFunc(void *obj1, void *obj2, cpCollisionID id, void *data){return id;} - -static void -LeafAddPairs(Node *leaf, cpBBTree *tree) -{ - cpSpatialIndex *dynamicIndex = tree->spatialIndex.dynamicIndex; - if(dynamicIndex){ - Node *dynamicRoot = GetRootIfTree(dynamicIndex); - if(dynamicRoot){ - cpBBTree *dynamicTree = GetTree(dynamicIndex); - MarkContext context = {dynamicTree, NULL, NULL, NULL}; - MarkLeafQuery(dynamicRoot, leaf, cpTrue, &context); - } - } else { - Node *staticRoot = GetRootIfTree(tree->spatialIndex.staticIndex); - MarkContext context = {tree, staticRoot, VoidQueryFunc, NULL}; - MarkLeaf(leaf, &context); - } -} - -//MARK: Memory Management Functions - -cpBBTree * -cpBBTreeAlloc(void) -{ - return (cpBBTree *)cpcalloc(1, sizeof(cpBBTree)); -} - -static int -leafSetEql(void *obj, Node *node) -{ - return (obj == node->obj); -} - -static void * -leafSetTrans(void *obj, cpBBTree *tree) -{ - return LeafNew(tree, obj, tree->spatialIndex.bbfunc(obj)); -} - -cpSpatialIndex * -cpBBTreeInit(cpBBTree *tree, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) -{ - cpSpatialIndexInit((cpSpatialIndex *)tree, Klass(), bbfunc, staticIndex); - - tree->velocityFunc = NULL; - - tree->leaves = cpHashSetNew(0, (cpHashSetEqlFunc)leafSetEql); - tree->root = NULL; - - tree->pooledNodes = NULL; - tree->allocatedBuffers = cpArrayNew(0); - - tree->stamp = 0; - - return (cpSpatialIndex *)tree; -} - -void -cpBBTreeSetVelocityFunc(cpSpatialIndex *index, cpBBTreeVelocityFunc func) -{ - if(index->klass != Klass()){ - cpAssertWarn(cpFalse, "Ignoring cpBBTreeSetVelocityFunc() call to non-tree spatial index."); - return; - } - - ((cpBBTree *)index)->velocityFunc = func; -} - -cpSpatialIndex * -cpBBTreeNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) -{ - return cpBBTreeInit(cpBBTreeAlloc(), bbfunc, staticIndex); -} - -static void -cpBBTreeDestroy(cpBBTree *tree) -{ - cpHashSetFree(tree->leaves); - - if(tree->allocatedBuffers) cpArrayFreeEach(tree->allocatedBuffers, cpfree); - cpArrayFree(tree->allocatedBuffers); -} - -//MARK: Insert/Remove - -static void -cpBBTreeInsert(cpBBTree *tree, void *obj, cpHashValue hashid) -{ - Node *leaf = (Node *)cpHashSetInsert(tree->leaves, hashid, obj, (cpHashSetTransFunc)leafSetTrans, tree); - - Node *root = tree->root; - tree->root = SubtreeInsert(root, leaf, tree); - - leaf->STAMP = GetMasterTree(tree)->stamp; - LeafAddPairs(leaf, tree); - IncrementStamp(tree); -} - -static void -cpBBTreeRemove(cpBBTree *tree, void *obj, cpHashValue hashid) -{ - Node *leaf = (Node *)cpHashSetRemove(tree->leaves, hashid, obj); - - tree->root = SubtreeRemove(tree->root, leaf, tree); - PairsClear(leaf, tree); - NodeRecycle(tree, leaf); -} - -static cpBool -cpBBTreeContains(cpBBTree *tree, void *obj, cpHashValue hashid) -{ - return (cpHashSetFind(tree->leaves, hashid, obj) != NULL); -} - -//MARK: Reindex - -static void LeafUpdateWrap(Node *leaf, cpBBTree *tree) {LeafUpdate(leaf, tree);} - -static void -cpBBTreeReindexQuery(cpBBTree *tree, cpSpatialIndexQueryFunc func, void *data) -{ - if(!tree->root) return; - - // LeafUpdate() may modify tree->root. Don't cache it. - cpHashSetEach(tree->leaves, (cpHashSetIteratorFunc)LeafUpdateWrap, tree); - - cpSpatialIndex *staticIndex = tree->spatialIndex.staticIndex; - Node *staticRoot = (staticIndex && staticIndex->klass == Klass() ? ((cpBBTree *)staticIndex)->root : NULL); - - MarkContext context = {tree, staticRoot, func, data}; - MarkSubtree(tree->root, &context); - if(staticIndex && !staticRoot) cpSpatialIndexCollideStatic((cpSpatialIndex *)tree, staticIndex, func, data); - - IncrementStamp(tree); -} - -static void -cpBBTreeReindex(cpBBTree *tree) -{ - cpBBTreeReindexQuery(tree, VoidQueryFunc, NULL); -} - -static void -cpBBTreeReindexObject(cpBBTree *tree, void *obj, cpHashValue hashid) -{ - Node *leaf = (Node *)cpHashSetFind(tree->leaves, hashid, obj); - if(leaf){ - if(LeafUpdate(leaf, tree)) LeafAddPairs(leaf, tree); - IncrementStamp(tree); - } -} - -//MARK: Query - -static void -cpBBTreeSegmentQuery(cpBBTree *tree, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data) -{ - Node *root = tree->root; - if(root) SubtreeSegmentQuery(root, obj, a, b, t_exit, func, data); -} - -static void -cpBBTreeQuery(cpBBTree *tree, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data) -{ - if(tree->root) SubtreeQuery(tree->root, obj, bb, func, data); -} - -//MARK: Misc - -static int -cpBBTreeCount(cpBBTree *tree) -{ - return cpHashSetCount(tree->leaves); -} - -typedef struct eachContext { - cpSpatialIndexIteratorFunc func; - void *data; -} eachContext; - -static void each_helper(Node *node, eachContext *context){context->func(node->obj, context->data);} - -static void -cpBBTreeEach(cpBBTree *tree, cpSpatialIndexIteratorFunc func, void *data) -{ - eachContext context = {func, data}; - cpHashSetEach(tree->leaves, (cpHashSetIteratorFunc)each_helper, &context); -} - -static cpSpatialIndexClass klass = { - (cpSpatialIndexDestroyImpl)cpBBTreeDestroy, - - (cpSpatialIndexCountImpl)cpBBTreeCount, - (cpSpatialIndexEachImpl)cpBBTreeEach, - - (cpSpatialIndexContainsImpl)cpBBTreeContains, - (cpSpatialIndexInsertImpl)cpBBTreeInsert, - (cpSpatialIndexRemoveImpl)cpBBTreeRemove, - - (cpSpatialIndexReindexImpl)cpBBTreeReindex, - (cpSpatialIndexReindexObjectImpl)cpBBTreeReindexObject, - (cpSpatialIndexReindexQueryImpl)cpBBTreeReindexQuery, - - (cpSpatialIndexQueryImpl)cpBBTreeQuery, - (cpSpatialIndexSegmentQueryImpl)cpBBTreeSegmentQuery, -}; - -static inline cpSpatialIndexClass *Klass(){return &klass;} - - -//MARK: Tree Optimization - -static int -cpfcompare(const cpFloat *a, const cpFloat *b){ - return (*a < *b ? -1 : (*b < *a ? 1 : 0)); -} - -static void -fillNodeArray(Node *node, Node ***cursor){ - (**cursor) = node; - (*cursor)++; -} - -static Node * -partitionNodes(cpBBTree *tree, Node **nodes, int count) -{ - if(count == 1){ - return nodes[0]; - } else if(count == 2) { - return NodeNew(tree, nodes[0], nodes[1]); - } - - // Find the AABB for these nodes - cpBB bb = nodes[0]->bb; - for(int i=1; i<count; i++) bb = cpBBMerge(bb, nodes[i]->bb); - - // Split it on it's longest axis - cpBool splitWidth = (bb.r - bb.l > bb.t - bb.b); - - // Sort the bounds and use the median as the splitting point - cpFloat *bounds = (cpFloat *)cpcalloc(count*2, sizeof(cpFloat)); - if(splitWidth){ - for(int i=0; i<count; i++){ - bounds[2*i + 0] = nodes[i]->bb.l; - bounds[2*i + 1] = nodes[i]->bb.r; - } - } else { - for(int i=0; i<count; i++){ - bounds[2*i + 0] = nodes[i]->bb.b; - bounds[2*i + 1] = nodes[i]->bb.t; - } - } - - qsort(bounds, count*2, sizeof(cpFloat), (int (*)(const void *, const void *))cpfcompare); - cpFloat split = (bounds[count - 1] + bounds[count])*0.5f; // use the medain as the split - cpfree(bounds); - - // Generate the child BBs - cpBB a = bb, b = bb; - if(splitWidth) a.r = b.l = split; else a.t = b.b = split; - - // Partition the nodes - int right = count; - for(int left=0; left < right;){ - Node *node = nodes[left]; - if(cpBBMergedArea(node->bb, b) < cpBBMergedArea(node->bb, a)){ -// if(cpBBProximity(node->bb, b) < cpBBProximity(node->bb, a)){ - right--; - nodes[left] = nodes[right]; - nodes[right] = node; - } else { - left++; - } - } - - if(right == count){ - Node *node = NULL; - for(int i=0; i<count; i++) node = SubtreeInsert(node, nodes[i], tree); - return node; - } - - // Recurse and build the node! - return NodeNew(tree, - partitionNodes(tree, nodes, right), - partitionNodes(tree, nodes + right, count - right) - ); -} - -//static void -//cpBBTreeOptimizeIncremental(cpBBTree *tree, int passes) -//{ -// for(int i=0; i<passes; i++){ -// Node *root = tree->root; -// Node *node = root; -// int bit = 0; -// unsigned int path = tree->opath; -// -// while(!NodeIsLeaf(node)){ -// node = (path&(1<<bit) ? node->a : node->b); -// bit = (bit + 1)&(sizeof(unsigned int)*8 - 1); -// } -// -// root = subtreeRemove(root, node, tree); -// tree->root = subtreeInsert(root, node, tree); -// } -//} - -void -cpBBTreeOptimize(cpSpatialIndex *index) -{ - if(index->klass != &klass){ - cpAssertWarn(cpFalse, "Ignoring cpBBTreeOptimize() call to non-tree spatial index."); - return; - } - - cpBBTree *tree = (cpBBTree *)index; - Node *root = tree->root; - if(!root) return; - - int count = cpBBTreeCount(tree); - Node **nodes = (Node **)cpcalloc(count, sizeof(Node *)); - Node **cursor = nodes; - - cpHashSetEach(tree->leaves, (cpHashSetIteratorFunc)fillNodeArray, &cursor); - - SubtreeRecycle(tree, root); - tree->root = partitionNodes(tree, nodes, count); - cpfree(nodes); -} - -//MARK: Debug Draw - -//#define CP_BBTREE_DEBUG_DRAW -#ifdef CP_BBTREE_DEBUG_DRAW -#include "OpenGL/gl.h" -#include "OpenGL/glu.h" -#include <GLUT/glut.h> - -static void -NodeRender(Node *node, int depth) -{ - if(!NodeIsLeaf(node) && depth <= 10){ - NodeRender(node->a, depth + 1); - NodeRender(node->b, depth + 1); - } - - cpBB bb = node->bb; - -// GLfloat v = depth/2.0f; -// glColor3f(1.0f - v, v, 0.0f); - glLineWidth(cpfmax(5.0f - depth, 1.0f)); - glBegin(GL_LINES); { - glVertex2f(bb.l, bb.b); - glVertex2f(bb.l, bb.t); - - glVertex2f(bb.l, bb.t); - glVertex2f(bb.r, bb.t); - - glVertex2f(bb.r, bb.t); - glVertex2f(bb.r, bb.b); - - glVertex2f(bb.r, bb.b); - glVertex2f(bb.l, bb.b); - }; glEnd(); -} - -void -cpBBTreeRenderDebug(cpSpatialIndex *index){ - if(index->klass != &klass){ - cpAssertWarn(cpFalse, "Ignoring cpBBTreeRenderDebug() call to non-tree spatial index."); - return; - } - - cpBBTree *tree = (cpBBTree *)index; - if(tree->root) NodeRender(tree->root, 0); -} -#endif diff --git a/thirdparty/src/chipmunk/cpBody.c b/thirdparty/src/chipmunk/cpBody.c deleted file mode 100644 index a8e079725..000000000 --- a/thirdparty/src/chipmunk/cpBody.c +++ /dev/null @@ -1,626 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <float.h> -#include <stdarg.h> - -#include "chipmunk/chipmunk_private.h" - -cpBody* -cpBodyAlloc(void) -{ - return (cpBody *)cpcalloc(1, sizeof(cpBody)); -} - -cpBody * -cpBodyInit(cpBody *body, cpFloat mass, cpFloat moment) -{ - body->space = NULL; - body->shapeList = NULL; - body->arbiterList = NULL; - body->constraintList = NULL; - - body->velocity_func = cpBodyUpdateVelocity; - body->position_func = cpBodyUpdatePosition; - - body->sleeping.root = NULL; - body->sleeping.next = NULL; - body->sleeping.idleTime = 0.0f; - - body->p = cpvzero; - body->v = cpvzero; - body->f = cpvzero; - - body->w = 0.0f; - body->t = 0.0f; - - body->v_bias = cpvzero; - body->w_bias = 0.0f; - - body->userData = NULL; - - // Setters must be called after full initialization so the sanity checks don't assert on garbage data. - cpBodySetMass(body, mass); - cpBodySetMoment(body, moment); - cpBodySetAngle(body, 0.0f); - - return body; -} - -cpBody* -cpBodyNew(cpFloat mass, cpFloat moment) -{ - return cpBodyInit(cpBodyAlloc(), mass, moment); -} - -cpBody* -cpBodyNewKinematic() -{ - cpBody *body = cpBodyNew(0.0f, 0.0f); - cpBodySetType(body, CP_BODY_TYPE_KINEMATIC); - - return body; -} - -cpBody* -cpBodyNewStatic() -{ - cpBody *body = cpBodyNew(0.0f, 0.0f); - cpBodySetType(body, CP_BODY_TYPE_STATIC); - - return body; -} - -void cpBodyDestroy(cpBody *body){} - -void -cpBodyFree(cpBody *body) -{ - if(body){ - cpBodyDestroy(body); - cpfree(body); - } -} - -#ifdef NDEBUG - #define cpAssertSaneBody(body) -#else - static void cpv_assert_nan(cpVect v, char *message){cpAssertHard(v.x == v.x && v.y == v.y, message);} - static void cpv_assert_infinite(cpVect v, char *message){cpAssertHard(cpfabs(v.x) != INFINITY && cpfabs(v.y) != INFINITY, message);} - static void cpv_assert_sane(cpVect v, char *message){cpv_assert_nan(v, message); cpv_assert_infinite(v, message);} - - static void - cpBodySanityCheck(const cpBody *body) - { - cpAssertHard(body->m == body->m && body->m_inv == body->m_inv, "Body's mass is NaN."); - cpAssertHard(body->i == body->i && body->i_inv == body->i_inv, "Body's moment is NaN."); - cpAssertHard(body->m >= 0.0f, "Body's mass is negative."); - cpAssertHard(body->i >= 0.0f, "Body's moment is negative."); - - cpv_assert_sane(body->p, "Body's position is invalid."); - cpv_assert_sane(body->v, "Body's velocity is invalid."); - cpv_assert_sane(body->f, "Body's force is invalid."); - - cpAssertHard(body->a == body->a && cpfabs(body->a) != INFINITY, "Body's angle is invalid."); - cpAssertHard(body->w == body->w && cpfabs(body->w) != INFINITY, "Body's angular velocity is invalid."); - cpAssertHard(body->t == body->t && cpfabs(body->t) != INFINITY, "Body's torque is invalid."); - } - - #define cpAssertSaneBody(body) cpBodySanityCheck(body) -#endif - -cpBool -cpBodyIsSleeping(const cpBody *body) -{ - return (body->sleeping.root != ((cpBody*)0)); -} - -cpBodyType -cpBodyGetType(cpBody *body) -{ - if(body->sleeping.idleTime == INFINITY){ - return CP_BODY_TYPE_STATIC; - } else if(body->m == INFINITY){ - return CP_BODY_TYPE_KINEMATIC; - } else { - return CP_BODY_TYPE_DYNAMIC; - } -} - -void -cpBodySetType(cpBody *body, cpBodyType type) -{ - cpBodyType oldType = cpBodyGetType(body); - if(oldType == type) return; - - // Static bodies have their idle timers set to infinity. - // Non-static bodies should have their idle timer reset. - body->sleeping.idleTime = (type == CP_BODY_TYPE_STATIC ? INFINITY : 0.0f); - - if(type == CP_BODY_TYPE_DYNAMIC){ - body->m = body->i = 0.0f; - body->m_inv = body->i_inv = INFINITY; - - cpBodyAccumulateMassFromShapes(body); - } else { - body->m = body->i = INFINITY; - body->m_inv = body->i_inv = 0.0f; - - body->v = cpvzero; - body->w = 0.0f; - } - - // If the body is added to a space already, we'll need to update some space data structures. - cpSpace *space = cpBodyGetSpace(body); - if(space != NULL){ - cpAssertSpaceUnlocked(space); - - if(oldType == CP_BODY_TYPE_STATIC){ - // TODO This is probably not necessary -// cpBodyActivateStatic(body, NULL); - } else { - cpBodyActivate(body); - } - - // Move the bodies to the correct array. - cpArray *fromArray = cpSpaceArrayForBodyType(space, oldType); - cpArray *toArray = cpSpaceArrayForBodyType(space, type); - if(fromArray != toArray){ - cpArrayDeleteObj(fromArray, body); - cpArrayPush(toArray, body); - } - - // Move the body's shapes to the correct spatial index. - cpSpatialIndex *fromIndex = (oldType == CP_BODY_TYPE_STATIC ? space->staticShapes : space->dynamicShapes); - cpSpatialIndex *toIndex = (type == CP_BODY_TYPE_STATIC ? space->staticShapes : space->dynamicShapes); - if(fromIndex != toIndex){ - CP_BODY_FOREACH_SHAPE(body, shape){ - cpSpatialIndexRemove(fromIndex, shape, shape->hashid); - cpSpatialIndexInsert(toIndex, shape, shape->hashid); - } - } - } -} - - - -// Should *only* be called when shapes with mass info are modified, added or removed. -void -cpBodyAccumulateMassFromShapes(cpBody *body) -{ - if(body == NULL || cpBodyGetType(body) != CP_BODY_TYPE_DYNAMIC) return; - - // Reset the body's mass data. - body->m = body->i = 0.0f; - body->cog = cpvzero; - - // Cache the position to realign it at the end. - cpVect pos = cpBodyGetPosition(body); - - // Accumulate mass from shapes. - CP_BODY_FOREACH_SHAPE(body, shape){ - struct cpShapeMassInfo *info = &shape->massInfo; - cpFloat m = info->m; - - if(m > 0.0f){ - cpFloat msum = body->m + m; - - body->i += m*info->i + cpvdistsq(body->cog, info->cog)*(m*body->m)/msum; - body->cog = cpvlerp(body->cog, info->cog, m/msum); - body->m = msum; - } - } - - // Recalculate the inverses. - body->m_inv = 1.0f/body->m; - body->i_inv = 1.0f/body->i; - - // Realign the body since the CoG has probably moved. - cpBodySetPosition(body, pos); - cpAssertSaneBody(body); -} - -cpSpace * -cpBodyGetSpace(const cpBody *body) -{ - return body->space; -} - -cpFloat -cpBodyGetMass(const cpBody *body) -{ - return body->m; -} - -void -cpBodySetMass(cpBody *body, cpFloat mass) -{ - cpAssertHard(cpBodyGetType(body) == CP_BODY_TYPE_DYNAMIC, "You cannot set the mass of kinematic or static bodies."); - cpAssertHard(0.0f <= mass && mass < INFINITY, "Mass must be positive and finite."); - - cpBodyActivate(body); - body->m = mass; - body->m_inv = 1.0f/mass; - cpAssertSaneBody(body); -} - -cpFloat -cpBodyGetMoment(const cpBody *body) -{ - return body->i; -} - -void -cpBodySetMoment(cpBody *body, cpFloat moment) -{ - cpAssertHard(moment >= 0.0f, "Moment of Inertia must be positive."); - - cpBodyActivate(body); - body->i = moment; - body->i_inv = 1.0f/moment; - cpAssertSaneBody(body); -} - -cpVect -cpBodyGetRotation(const cpBody *body) -{ - return cpv(body->transform.a, body->transform.b); -} - -void -cpBodyAddShape(cpBody *body, cpShape *shape) -{ - cpShape *next = body->shapeList; - if(next) next->prev = shape; - - shape->next = next; - body->shapeList = shape; - - if(shape->massInfo.m > 0.0f){ - cpBodyAccumulateMassFromShapes(body); - } -} - -void -cpBodyRemoveShape(cpBody *body, cpShape *shape) -{ - cpShape *prev = shape->prev; - cpShape *next = shape->next; - - if(prev){ - prev->next = next; - } else { - body->shapeList = next; - } - - if(next){ - next->prev = prev; - } - - shape->prev = NULL; - shape->next = NULL; - - if(cpBodyGetType(body) == CP_BODY_TYPE_DYNAMIC && shape->massInfo.m > 0.0f){ - cpBodyAccumulateMassFromShapes(body); - } -} - -static cpConstraint * -filterConstraints(cpConstraint *node, cpBody *body, cpConstraint *filter) -{ - if(node == filter){ - return cpConstraintNext(node, body); - } else if(node->a == body){ - node->next_a = filterConstraints(node->next_a, body, filter); - } else { - node->next_b = filterConstraints(node->next_b, body, filter); - } - - return node; -} - -void -cpBodyRemoveConstraint(cpBody *body, cpConstraint *constraint) -{ - body->constraintList = filterConstraints(body->constraintList, body, constraint); -} - -// 'p' is the position of the CoG -static void -SetTransform(cpBody *body, cpVect p, cpFloat a) -{ - cpVect rot = cpvforangle(a); - cpVect c = body->cog; - - body->transform = cpTransformNewTranspose( - rot.x, -rot.y, p.x - (c.x*rot.x - c.y*rot.y), - rot.y, rot.x, p.y - (c.x*rot.y + c.y*rot.x) - ); -} - -static inline cpFloat -SetAngle(cpBody *body, cpFloat a) -{ - body->a = a; - cpAssertSaneBody(body); - - return a; -} - -cpVect -cpBodyGetPosition(const cpBody *body) -{ - return cpTransformPoint(body->transform, cpvzero); -} - -void -cpBodySetPosition(cpBody *body, cpVect position) -{ - cpBodyActivate(body); - cpVect p = body->p = cpvadd(cpTransformVect(body->transform, body->cog), position); - cpAssertSaneBody(body); - - SetTransform(body, p, body->a); -} - -cpVect -cpBodyGetCenterOfGravity(const cpBody *body) -{ - return body->cog; -} - -void -cpBodySetCenterOfGravity(cpBody *body, cpVect cog) -{ - cpBodyActivate(body); - body->cog = cog; - cpAssertSaneBody(body); -} - -cpVect -cpBodyGetVelocity(const cpBody *body) -{ - return body->v; -} - -void -cpBodySetVelocity(cpBody *body, cpVect velocity) -{ - cpBodyActivate(body); - body->v = velocity; - cpAssertSaneBody(body); -} - -cpVect -cpBodyGetForce(const cpBody *body) -{ - return body->f; -} - -void -cpBodySetForce(cpBody *body, cpVect force) -{ - cpBodyActivate(body); - body->f = force; - cpAssertSaneBody(body); -} - -cpFloat -cpBodyGetAngle(const cpBody *body) -{ - return body->a; -} - -void -cpBodySetAngle(cpBody *body, cpFloat angle) -{ - cpBodyActivate(body); - SetAngle(body, angle); - - SetTransform(body, body->p, angle); -} - -cpFloat -cpBodyGetAngularVelocity(const cpBody *body) -{ - return body->w; -} - -void -cpBodySetAngularVelocity(cpBody *body, cpFloat angularVelocity) -{ - cpBodyActivate(body); - body->w = angularVelocity; - cpAssertSaneBody(body); -} - -cpFloat -cpBodyGetTorque(const cpBody *body) -{ - return body->t; -} - -void -cpBodySetTorque(cpBody *body, cpFloat torque) -{ - cpBodyActivate(body); - body->t = torque; - cpAssertSaneBody(body); -} - -cpDataPointer -cpBodyGetUserData(const cpBody *body) -{ - return body->userData; -} - -void -cpBodySetUserData(cpBody *body, cpDataPointer userData) -{ - body->userData = userData; -} - -void -cpBodySetVelocityUpdateFunc(cpBody *body, cpBodyVelocityFunc velocityFunc) -{ - body->velocity_func = velocityFunc; -} - -void -cpBodySetPositionUpdateFunc(cpBody *body, cpBodyPositionFunc positionFunc) -{ - body->position_func = positionFunc; -} - -void -cpBodyUpdateVelocity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt) -{ - // Skip kinematic bodies. - if(cpBodyGetType(body) == CP_BODY_TYPE_KINEMATIC) return; - - cpAssertSoft(body->m > 0.0f && body->i > 0.0f, "Body's mass and moment must be positive to simulate. (Mass: %f Moment: %f)", body->m, body->i); - - body->v = cpvadd(cpvmult(body->v, damping), cpvmult(cpvadd(gravity, cpvmult(body->f, body->m_inv)), dt)); - body->w = body->w*damping + body->t*body->i_inv*dt; - - // Reset forces. - body->f = cpvzero; - body->t = 0.0f; - - cpAssertSaneBody(body); -} - -void -cpBodyUpdatePosition(cpBody *body, cpFloat dt) -{ - cpVect p = body->p = cpvadd(body->p, cpvmult(cpvadd(body->v, body->v_bias), dt)); - cpFloat a = SetAngle(body, body->a + (body->w + body->w_bias)*dt); - SetTransform(body, p, a); - - body->v_bias = cpvzero; - body->w_bias = 0.0f; - - cpAssertSaneBody(body); -} - -cpVect -cpBodyLocalToWorld(const cpBody *body, const cpVect point) -{ - return cpTransformPoint(body->transform, point); -} - -cpVect -cpBodyWorldToLocal(const cpBody *body, const cpVect point) -{ - return cpTransformPoint(cpTransformRigidInverse(body->transform), point); -} - -void -cpBodyApplyForceAtWorldPoint(cpBody *body, cpVect force, cpVect point) -{ - cpBodyActivate(body); - body->f = cpvadd(body->f, force); - - cpVect r = cpvsub(point, cpTransformPoint(body->transform, body->cog)); - body->t += cpvcross(r, force); -} - -void -cpBodyApplyForceAtLocalPoint(cpBody *body, cpVect force, cpVect point) -{ - cpBodyApplyForceAtWorldPoint(body, cpTransformVect(body->transform, force), cpTransformPoint(body->transform, point)); -} - -void -cpBodyApplyImpulseAtWorldPoint(cpBody *body, cpVect impulse, cpVect point) -{ - cpBodyActivate(body); - - cpVect r = cpvsub(point, cpTransformPoint(body->transform, body->cog)); - apply_impulse(body, impulse, r); -} - -void -cpBodyApplyImpulseAtLocalPoint(cpBody *body, cpVect impulse, cpVect point) -{ - cpBodyApplyImpulseAtWorldPoint(body, cpTransformVect(body->transform, impulse), cpTransformPoint(body->transform, point)); -} - -cpVect -cpBodyGetVelocityAtLocalPoint(const cpBody *body, cpVect point) -{ - cpVect r = cpTransformVect(body->transform, cpvsub(point, body->cog)); - return cpvadd(body->v, cpvmult(cpvperp(r), body->w)); -} - -cpVect -cpBodyGetVelocityAtWorldPoint(const cpBody *body, cpVect point) -{ - cpVect r = cpvsub(point, cpTransformPoint(body->transform, body->cog)); - return cpvadd(body->v, cpvmult(cpvperp(r), body->w)); -} - -cpFloat -cpBodyKineticEnergy(const cpBody *body) -{ - // Need to do some fudging to avoid NaNs - cpFloat vsq = cpvdot(body->v, body->v); - cpFloat wsq = body->w*body->w; - return (vsq ? vsq*body->m : 0.0f) + (wsq ? wsq*body->i : 0.0f); -} - -void -cpBodyEachShape(cpBody *body, cpBodyShapeIteratorFunc func, void *data) -{ - cpShape *shape = body->shapeList; - while(shape){ - cpShape *next = shape->next; - func(body, shape, data); - shape = next; - } -} - -void -cpBodyEachConstraint(cpBody *body, cpBodyConstraintIteratorFunc func, void *data) -{ - cpConstraint *constraint = body->constraintList; - while(constraint){ - cpConstraint *next = cpConstraintNext(constraint, body); - func(body, constraint, data); - constraint = next; - } -} - -void -cpBodyEachArbiter(cpBody *body, cpBodyArbiterIteratorFunc func, void *data) -{ - cpArbiter *arb = body->arbiterList; - while(arb){ - cpArbiter *next = cpArbiterNext(arb, body); - - cpBool swapped = arb->swapped; { - arb->swapped = (body == arb->body_b); - func(body, arb, data); - } arb->swapped = swapped; - - arb = next; - } -} diff --git a/thirdparty/src/chipmunk/cpCollision.c b/thirdparty/src/chipmunk/cpCollision.c deleted file mode 100644 index 0d3147335..000000000 --- a/thirdparty/src/chipmunk/cpCollision.c +++ /dev/null @@ -1,726 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <stdio.h> -#include <string.h> - -#include "chipmunk/chipmunk_private.h" -#include "chipmunk/cpRobust.h" - -#if DEBUG && 0 -#include "ChipmunkDemo.h" -#define DRAW_ALL 0 -#define DRAW_GJK (0 || DRAW_ALL) -#define DRAW_EPA (0 || DRAW_ALL) -#define DRAW_CLOSEST (0 || DRAW_ALL) -#define DRAW_CLIP (0 || DRAW_ALL) - -#define PRINT_LOG 0 -#endif - -#define MAX_GJK_ITERATIONS 30 -#define MAX_EPA_ITERATIONS 30 -#define WARN_GJK_ITERATIONS 20 -#define WARN_EPA_ITERATIONS 20 - -static inline void -cpCollisionInfoPushContact(struct cpCollisionInfo *info, cpVect p1, cpVect p2, cpHashValue hash) -{ - cpAssertSoft(info->count <= CP_MAX_CONTACTS_PER_ARBITER, "Internal error: Tried to push too many contacts."); - - struct cpContact *con = &info->arr[info->count]; - con->r1 = p1; - con->r2 = p2; - con->hash = hash; - - info->count++; -} - -//MARK: Support Points and Edges: - -// Support points are the maximal points on a shape's perimeter along a certain axis. -// The GJK and EPA algorithms use support points to iteratively sample the surface of the two shapes' minkowski difference. - -static inline int -PolySupportPointIndex(const int count, const struct cpSplittingPlane *planes, const cpVect n) -{ - cpFloat max = -INFINITY; - int index = 0; - - for(int i=0; i<count; i++){ - cpVect v = planes[i].v0; - cpFloat d = cpvdot(v, n); - if(d > max){ - max = d; - index = i; - } - } - - return index; -} - -struct SupportPoint { - cpVect p; - // Save an index of the point so it can be cheaply looked up as a starting point for the next frame. - cpCollisionID index; -}; - -static inline struct SupportPoint -SupportPointNew(cpVect p, cpCollisionID index) -{ - struct SupportPoint point = {p, index}; - return point; -} - -typedef struct SupportPoint (*SupportPointFunc)(const cpShape *shape, const cpVect n); - -static inline struct SupportPoint -CircleSupportPoint(const cpCircleShape *circle, const cpVect n) -{ - return SupportPointNew(circle->tc, 0); -} - -static inline struct SupportPoint -SegmentSupportPoint(const cpSegmentShape *seg, const cpVect n) -{ - if(cpvdot(seg->ta, n) > cpvdot(seg->tb, n)){ - return SupportPointNew(seg->ta, 0); - } else { - return SupportPointNew(seg->tb, 1); - } -} - -static inline struct SupportPoint -PolySupportPoint(const cpPolyShape *poly, const cpVect n) -{ - const struct cpSplittingPlane *planes = poly->planes; - int i = PolySupportPointIndex(poly->count, planes, n); - return SupportPointNew(planes[i].v0, i); -} - -// A point on the surface of two shape's minkowski difference. -struct MinkowskiPoint { - // Cache the two original support points. - cpVect a, b; - // b - a - cpVect ab; - // Concatenate the two support point indexes. - cpCollisionID id; -}; - -static inline struct MinkowskiPoint -MinkowskiPointNew(const struct SupportPoint a, const struct SupportPoint b) -{ - struct MinkowskiPoint point = {a.p, b.p, cpvsub(b.p, a.p), (a.index & 0xFF)<<8 | (b.index & 0xFF)}; - return point; -} - -struct SupportContext { - const cpShape *shape1, *shape2; - SupportPointFunc func1, func2; -}; - -// Calculate the maximal point on the minkowski difference of two shapes along a particular axis. -static inline struct MinkowskiPoint -Support(const struct SupportContext *ctx, const cpVect n) -{ - struct SupportPoint a = ctx->func1(ctx->shape1, cpvneg(n)); - struct SupportPoint b = ctx->func2(ctx->shape2, n); - return MinkowskiPointNew(a, b); -} - -struct EdgePoint { - cpVect p; - // Keep a hash value for Chipmunk's collision hashing mechanism. - cpHashValue hash; -}; - -// Support edges are the edges of a polygon or segment shape that are in contact. -struct Edge { - struct EdgePoint a, b; - cpFloat r; - cpVect n; -}; - -static struct Edge -SupportEdgeForPoly(const cpPolyShape *poly, const cpVect n) -{ - int count = poly->count; - int i1 = PolySupportPointIndex(poly->count, poly->planes, n); - - // TODO: get rid of mod eventually, very expensive on ARM - int i0 = (i1 - 1 + count)%count; - int i2 = (i1 + 1)%count; - - const struct cpSplittingPlane *planes = poly->planes; - cpHashValue hashid = poly->shape.hashid; - if(cpvdot(n, planes[i1].n) > cpvdot(n, planes[i2].n)){ - struct Edge edge = {{planes[i0].v0, CP_HASH_PAIR(hashid, i0)}, {planes[i1].v0, CP_HASH_PAIR(hashid, i1)}, poly->r, planes[i1].n}; - return edge; - } else { - struct Edge edge = {{planes[i1].v0, CP_HASH_PAIR(hashid, i1)}, {planes[i2].v0, CP_HASH_PAIR(hashid, i2)}, poly->r, planes[i2].n}; - return edge; - } -} - -static struct Edge -SupportEdgeForSegment(const cpSegmentShape *seg, const cpVect n) -{ - cpHashValue hashid = seg->shape.hashid; - if(cpvdot(seg->tn, n) > 0.0){ - struct Edge edge = {{seg->ta, CP_HASH_PAIR(hashid, 0)}, {seg->tb, CP_HASH_PAIR(hashid, 1)}, seg->r, seg->tn}; - return edge; - } else { - struct Edge edge = {{seg->tb, CP_HASH_PAIR(hashid, 1)}, {seg->ta, CP_HASH_PAIR(hashid, 0)}, seg->r, cpvneg(seg->tn)}; - return edge; - } -} - -// Find the closest p(t) to (0, 0) where p(t) = a*(1-t)/2 + b*(1+t)/2 -// The range for t is [-1, 1] to avoid floating point issues if the parameters are swapped. -static inline cpFloat -ClosestT(const cpVect a, const cpVect b) -{ - cpVect delta = cpvsub(b, a); - return -cpfclamp(cpvdot(delta, cpvadd(a, b))/cpvlengthsq(delta), -1.0f, 1.0f); -} - -// Basically the same as cpvlerp(), except t = [-1, 1] -static inline cpVect -LerpT(const cpVect a, const cpVect b, const cpFloat t) -{ - cpFloat ht = 0.5f*t; - return cpvadd(cpvmult(a, 0.5f - ht), cpvmult(b, 0.5f + ht)); -} - -// Closest points on the surface of two shapes. -struct ClosestPoints { - // Surface points in absolute coordinates. - cpVect a, b; - // Minimum separating axis of the two shapes. - cpVect n; - // Signed distance between the points. - cpFloat d; - // Concatenation of the id's of the minkoski points. - cpCollisionID id; -}; - -// Calculate the closest points on two shapes given the closest edge on their minkowski difference to (0, 0) -static inline struct ClosestPoints -ClosestPointsNew(const struct MinkowskiPoint v0, const struct MinkowskiPoint v1) -{ - // Find the closest p(t) on the minkowski difference to (0, 0) - cpFloat t = ClosestT(v0.ab, v1.ab); - cpVect p = LerpT(v0.ab, v1.ab, t); - - // Interpolate the original support points using the same 't' value as above. - // This gives you the closest surface points in absolute coordinates. NEAT! - cpVect pa = LerpT(v0.a, v1.a, t); - cpVect pb = LerpT(v0.b, v1.b, t); - cpCollisionID id = (v0.id & 0xFFFF)<<16 | (v1.id & 0xFFFF); - - // First try calculating the MSA from the minkowski difference edge. - // This gives us a nice, accurate MSA when the surfaces are close together. - cpVect delta = cpvsub(v1.ab, v0.ab); - cpVect n = cpvnormalize(cpvrperp(delta)); - cpFloat d = cpvdot(n, p); - - if(d <= 0.0f || (-1.0f < t && t < 1.0f)){ - // If the shapes are overlapping, or we have a regular vertex/edge collision, we are done. - struct ClosestPoints points = {pa, pb, n, d, id}; - return points; - } else { - // Vertex/vertex collisions need special treatment since the MSA won't be shared with an axis of the minkowski difference. - cpFloat d2 = cpvlength(p); - cpVect n2 = cpvmult(p, 1.0f/(d2 + CPFLOAT_MIN)); - - struct ClosestPoints points = {pa, pb, n2, d2, id}; - return points; - } -} - -//MARK: EPA Functions - -static inline cpFloat -ClosestDist(const cpVect v0,const cpVect v1) -{ - return cpvlengthsq(LerpT(v0, v1, ClosestT(v0, v1))); -} - -// Recursive implementation of the EPA loop. -// Each recursion adds a point to the convex hull until it's known that we have the closest point on the surface. -static struct ClosestPoints -EPARecurse(const struct SupportContext *ctx, const int count, const struct MinkowskiPoint *hull, const int iteration) -{ - int mini = 0; - cpFloat minDist = INFINITY; - - // TODO: precalculate this when building the hull and save a step. - // Find the closest segment hull[i] and hull[i + 1] to (0, 0) - for(int j=0, i=count-1; j<count; i=j, j++){ - cpFloat d = ClosestDist(hull[i].ab, hull[j].ab); - if(d < minDist){ - minDist = d; - mini = i; - } - } - - struct MinkowskiPoint v0 = hull[mini]; - struct MinkowskiPoint v1 = hull[(mini + 1)%count]; - cpAssertSoft(!cpveql(v0.ab, v1.ab), "Internal Error: EPA vertexes are the same (%d and %d)", mini, (mini + 1)%count); - - // Check if there is a point on the minkowski difference beyond this edge. - struct MinkowskiPoint p = Support(ctx, cpvperp(cpvsub(v1.ab, v0.ab))); - -#if DRAW_EPA - cpVect verts[count]; - for(int i=0; i<count; i++) verts[i] = hull[i].ab; - - ChipmunkDebugDrawPolygon(count, verts, 0.0, RGBAColor(1, 1, 0, 1), RGBAColor(1, 1, 0, 0.25)); - ChipmunkDebugDrawSegment(v0.ab, v1.ab, RGBAColor(1, 0, 0, 1)); - - ChipmunkDebugDrawDot(5, p.ab, LAColor(1, 1)); -#endif - - // The usual exit condition is a duplicated vertex. - // Much faster to check the ids than to check the signed area. - cpBool duplicate = (p.id == v0.id || p.id == v1.id); - - if(!duplicate && cpCheckPointGreater(v0.ab, v1.ab, p.ab) && iteration < MAX_EPA_ITERATIONS){ - // Rebuild the convex hull by inserting p. - struct MinkowskiPoint *hull2 = (struct MinkowskiPoint *)alloca((count + 1)*sizeof(struct MinkowskiPoint)); - int count2 = 1; - hull2[0] = p; - - for(int i=0; i<count; i++){ - int index = (mini + 1 + i)%count; - - cpVect h0 = hull2[count2 - 1].ab; - cpVect h1 = hull[index].ab; - cpVect h2 = (i + 1 < count ? hull[(index + 1)%count] : p).ab; - - if(cpCheckPointGreater(h0, h2, h1)){ - hull2[count2] = hull[index]; - count2++; - } - } - - return EPARecurse(ctx, count2, hull2, iteration + 1); - } else { - // Could not find a new point to insert, so we have found the closest edge of the minkowski difference. - cpAssertWarn(iteration < WARN_EPA_ITERATIONS, "High EPA iterations: %d", iteration); - return ClosestPointsNew(v0, v1); - } -} - -// Find the closest points on the surface of two overlapping shapes using the EPA algorithm. -// EPA is called from GJK when two shapes overlap. -// This is a moderately expensive step! Avoid it by adding radii to your shapes so their inner polygons won't overlap. -static struct ClosestPoints -EPA(const struct SupportContext *ctx, const struct MinkowskiPoint v0, const struct MinkowskiPoint v1, const struct MinkowskiPoint v2) -{ - // TODO: allocate a NxM array here and do an in place convex hull reduction in EPARecurse? - struct MinkowskiPoint hull[3] = {v0, v1, v2}; - return EPARecurse(ctx, 3, hull, 1); -} - -//MARK: GJK Functions. - -// Recursive implementation of the GJK loop. -static inline struct ClosestPoints -GJKRecurse(const struct SupportContext *ctx, const struct MinkowskiPoint v0, const struct MinkowskiPoint v1, const int iteration) -{ - if(iteration > MAX_GJK_ITERATIONS){ - cpAssertWarn(iteration < WARN_GJK_ITERATIONS, "High GJK iterations: %d", iteration); - return ClosestPointsNew(v0, v1); - } - - if(cpCheckPointGreater(v1.ab, v0.ab, cpvzero)){ - // Origin is behind axis. Flip and try again. - return GJKRecurse(ctx, v1, v0, iteration); - } else { - cpFloat t = ClosestT(v0.ab, v1.ab); - cpVect n = (-1.0f < t && t < 1.0f ? cpvperp(cpvsub(v1.ab, v0.ab)) : cpvneg(LerpT(v0.ab, v1.ab, t))); - struct MinkowskiPoint p = Support(ctx, n); - -#if DRAW_GJK - ChipmunkDebugDrawSegment(v0.ab, v1.ab, RGBAColor(1, 1, 1, 1)); - cpVect c = cpvlerp(v0.ab, v1.ab, 0.5); - ChipmunkDebugDrawSegment(c, cpvadd(c, cpvmult(cpvnormalize(n), 5.0)), RGBAColor(1, 0, 0, 1)); - - ChipmunkDebugDrawDot(5.0, p.ab, LAColor(1, 1)); -#endif - - if(cpCheckPointGreater(p.ab, v0.ab, cpvzero) && cpCheckPointGreater(v1.ab, p.ab, cpvzero)){ - // The triangle v0, p, v1 contains the origin. Use EPA to find the MSA. - cpAssertWarn(iteration < WARN_GJK_ITERATIONS, "High GJK->EPA iterations: %d", iteration); - return EPA(ctx, v0, p, v1); - } else { - if(cpCheckAxis(v0.ab, v1.ab, p.ab, n)){ - // The edge v0, v1 that we already have is the closest to (0, 0) since p was not closer. - cpAssertWarn(iteration < WARN_GJK_ITERATIONS, "High GJK iterations: %d", iteration); - return ClosestPointsNew(v0, v1); - } else { - // p was closer to the origin than our existing edge. - // Need to figure out which existing point to drop. - if(ClosestDist(v0.ab, p.ab) < ClosestDist(p.ab, v1.ab)){ - return GJKRecurse(ctx, v0, p, iteration + 1); - } else { - return GJKRecurse(ctx, p, v1, iteration + 1); - } - } - } - } -} - -// Get a SupportPoint from a cached shape and index. -static struct SupportPoint -ShapePoint(const cpShape *shape, const int i) -{ - switch(shape->klass->type){ - case CP_CIRCLE_SHAPE: { - return SupportPointNew(((cpCircleShape *)shape)->tc, 0); - } case CP_SEGMENT_SHAPE: { - cpSegmentShape *seg = (cpSegmentShape *)shape; - return SupportPointNew(i == 0 ? seg->ta : seg->tb, i); - } case CP_POLY_SHAPE: { - cpPolyShape *poly = (cpPolyShape *)shape; - // Poly shapes may change vertex count. - int index = (i < poly->count ? i : 0); - return SupportPointNew(poly->planes[index].v0, index); - } default: { - return SupportPointNew(cpvzero, 0); - } - } -} - -// Find the closest points between two shapes using the GJK algorithm. -static struct ClosestPoints -GJK(const struct SupportContext *ctx, cpCollisionID *id) -{ -#if DRAW_GJK || DRAW_EPA - int count1 = 1; - int count2 = 1; - - switch(ctx->shape1->klass->type){ - case CP_SEGMENT_SHAPE: count1 = 2; break; - case CP_POLY_SHAPE: count1 = ((cpPolyShape *)ctx->shape1)->count; break; - default: break; - } - - switch(ctx->shape2->klass->type){ - case CP_SEGMENT_SHAPE: count1 = 2; break; - case CP_POLY_SHAPE: count2 = ((cpPolyShape *)ctx->shape2)->count; break; - default: break; - } - - - // draw the minkowski difference origin - cpVect origin = cpvzero; - ChipmunkDebugDrawDot(5.0, origin, RGBAColor(1,0,0,1)); - - int mdiffCount = count1*count2; - cpVect *mdiffVerts = alloca(mdiffCount*sizeof(cpVect)); - - for(int i=0; i<count1; i++){ - for(int j=0; j<count2; j++){ - cpVect v = cpvsub(ShapePoint(ctx->shape2, j).p, ShapePoint(ctx->shape1, i).p); - mdiffVerts[i*count2 + j] = v; - ChipmunkDebugDrawDot(2.0, v, RGBAColor(1, 0, 0, 1)); - } - } - - cpVect *hullVerts = alloca(mdiffCount*sizeof(cpVect)); - int hullCount = cpConvexHull(mdiffCount, mdiffVerts, hullVerts, NULL, 0.0); - - ChipmunkDebugDrawPolygon(hullCount, hullVerts, 0.0, RGBAColor(1, 0, 0, 1), RGBAColor(1, 0, 0, 0.25)); -#endif - - struct MinkowskiPoint v0, v1; - if(*id){ - // Use the minkowski points from the last frame as a starting point using the cached indexes. - v0 = MinkowskiPointNew(ShapePoint(ctx->shape1, (*id>>24)&0xFF), ShapePoint(ctx->shape2, (*id>>16)&0xFF)); - v1 = MinkowskiPointNew(ShapePoint(ctx->shape1, (*id>> 8)&0xFF), ShapePoint(ctx->shape2, (*id )&0xFF)); - } else { - // No cached indexes, use the shapes' bounding box centers as a guess for a starting axis. - cpVect axis = cpvperp(cpvsub(cpBBCenter(ctx->shape1->bb), cpBBCenter(ctx->shape2->bb))); - v0 = Support(ctx, axis); - v1 = Support(ctx, cpvneg(axis)); - } - - struct ClosestPoints points = GJKRecurse(ctx, v0, v1, 1); - *id = points.id; - return points; -} - -//MARK: Contact Clipping - -// Given two support edges, find contact point pairs on their surfaces. -static inline void -ContactPoints(const struct Edge e1, const struct Edge e2, const struct ClosestPoints points, struct cpCollisionInfo *info) -{ - cpFloat mindist = e1.r + e2.r; - if(points.d <= mindist){ -#ifdef DRAW_CLIP - ChipmunkDebugDrawFatSegment(e1.a.p, e1.b.p, e1.r, RGBAColor(0, 1, 0, 1), LAColor(0, 0)); - ChipmunkDebugDrawFatSegment(e2.a.p, e2.b.p, e2.r, RGBAColor(1, 0, 0, 1), LAColor(0, 0)); -#endif - cpVect n = info->n = points.n; - - // Distances along the axis parallel to n - cpFloat d_e1_a = cpvcross(e1.a.p, n); - cpFloat d_e1_b = cpvcross(e1.b.p, n); - cpFloat d_e2_a = cpvcross(e2.a.p, n); - cpFloat d_e2_b = cpvcross(e2.b.p, n); - - // TODO + min isn't a complete fix. - cpFloat e1_denom = 1.0f/(d_e1_b - d_e1_a + CPFLOAT_MIN); - cpFloat e2_denom = 1.0f/(d_e2_b - d_e2_a + CPFLOAT_MIN); - - // Project the endpoints of the two edges onto the opposing edge, clamping them as necessary. - // Compare the projected points to the collision normal to see if the shapes overlap there. - { - cpVect p1 = cpvadd(cpvmult(n, e1.r), cpvlerp(e1.a.p, e1.b.p, cpfclamp01((d_e2_b - d_e1_a)*e1_denom))); - cpVect p2 = cpvadd(cpvmult(n, -e2.r), cpvlerp(e2.a.p, e2.b.p, cpfclamp01((d_e1_a - d_e2_a)*e2_denom))); - cpFloat dist = cpvdot(cpvsub(p2, p1), n); - if(dist <= 0.0f){ - cpHashValue hash_1a2b = CP_HASH_PAIR(e1.a.hash, e2.b.hash); - cpCollisionInfoPushContact(info, p1, p2, hash_1a2b); - } - }{ - cpVect p1 = cpvadd(cpvmult(n, e1.r), cpvlerp(e1.a.p, e1.b.p, cpfclamp01((d_e2_a - d_e1_a)*e1_denom))); - cpVect p2 = cpvadd(cpvmult(n, -e2.r), cpvlerp(e2.a.p, e2.b.p, cpfclamp01((d_e1_b - d_e2_a)*e2_denom))); - cpFloat dist = cpvdot(cpvsub(p2, p1), n); - if(dist <= 0.0f){ - cpHashValue hash_1b2a = CP_HASH_PAIR(e1.b.hash, e2.a.hash); - cpCollisionInfoPushContact(info, p1, p2, hash_1b2a); - } - } - } -} - -//MARK: Collision Functions - -typedef void (*CollisionFunc)(const cpShape *a, const cpShape *b, struct cpCollisionInfo *info); - -// Collide circle shapes. -static void -CircleToCircle(const cpCircleShape *c1, const cpCircleShape *c2, struct cpCollisionInfo *info) -{ - cpFloat mindist = c1->r + c2->r; - cpVect delta = cpvsub(c2->tc, c1->tc); - cpFloat distsq = cpvlengthsq(delta); - - if(distsq < mindist*mindist){ - cpFloat dist = cpfsqrt(distsq); - cpVect n = info->n = (dist ? cpvmult(delta, 1.0f/dist) : cpv(1.0f, 0.0f)); - cpCollisionInfoPushContact(info, cpvadd(c1->tc, cpvmult(n, c1->r)), cpvadd(c2->tc, cpvmult(n, -c2->r)), 0); - } -} - -static void -CircleToSegment(const cpCircleShape *circle, const cpSegmentShape *segment, struct cpCollisionInfo *info) -{ - cpVect seg_a = segment->ta; - cpVect seg_b = segment->tb; - cpVect center = circle->tc; - - // Find the closest point on the segment to the circle. - cpVect seg_delta = cpvsub(seg_b, seg_a); - cpFloat closest_t = cpfclamp01(cpvdot(seg_delta, cpvsub(center, seg_a))/cpvlengthsq(seg_delta)); - cpVect closest = cpvadd(seg_a, cpvmult(seg_delta, closest_t)); - - // Compare the radii of the two shapes to see if they are colliding. - cpFloat mindist = circle->r + segment->r; - cpVect delta = cpvsub(closest, center); - cpFloat distsq = cpvlengthsq(delta); - if(distsq < mindist*mindist){ - cpFloat dist = cpfsqrt(distsq); - // Handle coincident shapes as gracefully as possible. - cpVect n = info->n = (dist ? cpvmult(delta, 1.0f/dist) : segment->tn); - - // Reject endcap collisions if tangents are provided. - cpVect rot = cpBodyGetRotation(segment->shape.body); - if( - (closest_t != 0.0f || cpvdot(n, cpvrotate(segment->a_tangent, rot)) >= 0.0) && - (closest_t != 1.0f || cpvdot(n, cpvrotate(segment->b_tangent, rot)) >= 0.0) - ){ - cpCollisionInfoPushContact(info, cpvadd(center, cpvmult(n, circle->r)), cpvadd(closest, cpvmult(n, -segment->r)), 0); - } - } -} - -static void -SegmentToSegment(const cpSegmentShape *seg1, const cpSegmentShape *seg2, struct cpCollisionInfo *info) -{ - struct SupportContext context = {(cpShape *)seg1, (cpShape *)seg2, (SupportPointFunc)SegmentSupportPoint, (SupportPointFunc)SegmentSupportPoint}; - struct ClosestPoints points = GJK(&context, &info->id); - -#if DRAW_CLOSEST -#if PRINT_LOG -// ChipmunkDemoPrintString("Distance: %.2f\n", points.d); -#endif - - ChipmunkDebugDrawDot(6.0, points.a, RGBAColor(1, 1, 1, 1)); - ChipmunkDebugDrawDot(6.0, points.b, RGBAColor(1, 1, 1, 1)); - ChipmunkDebugDrawSegment(points.a, points.b, RGBAColor(1, 1, 1, 1)); - ChipmunkDebugDrawSegment(points.a, cpvadd(points.a, cpvmult(points.n, 10.0)), RGBAColor(1, 0, 0, 1)); -#endif - - cpVect n = points.n; - cpVect rot1 = cpBodyGetRotation(seg1->shape.body); - cpVect rot2 = cpBodyGetRotation(seg2->shape.body); - - // If the closest points are nearer than the sum of the radii... - if( - points.d <= (seg1->r + seg2->r) && ( - // Reject endcap collisions if tangents are provided. - (!cpveql(points.a, seg1->ta) || cpvdot(n, cpvrotate(seg1->a_tangent, rot1)) <= 0.0) && - (!cpveql(points.a, seg1->tb) || cpvdot(n, cpvrotate(seg1->b_tangent, rot1)) <= 0.0) && - (!cpveql(points.b, seg2->ta) || cpvdot(n, cpvrotate(seg2->a_tangent, rot2)) >= 0.0) && - (!cpveql(points.b, seg2->tb) || cpvdot(n, cpvrotate(seg2->b_tangent, rot2)) >= 0.0) - ) - ){ - ContactPoints(SupportEdgeForSegment(seg1, n), SupportEdgeForSegment(seg2, cpvneg(n)), points, info); - } -} - -static void -PolyToPoly(const cpPolyShape *poly1, const cpPolyShape *poly2, struct cpCollisionInfo *info) -{ - struct SupportContext context = {(cpShape *)poly1, (cpShape *)poly2, (SupportPointFunc)PolySupportPoint, (SupportPointFunc)PolySupportPoint}; - struct ClosestPoints points = GJK(&context, &info->id); - -#if DRAW_CLOSEST -#if PRINT_LOG -// ChipmunkDemoPrintString("Distance: %.2f\n", points.d); -#endif - - ChipmunkDebugDrawDot(3.0, points.a, RGBAColor(1, 1, 1, 1)); - ChipmunkDebugDrawDot(3.0, points.b, RGBAColor(1, 1, 1, 1)); - ChipmunkDebugDrawSegment(points.a, points.b, RGBAColor(1, 1, 1, 1)); - ChipmunkDebugDrawSegment(points.a, cpvadd(points.a, cpvmult(points.n, 10.0)), RGBAColor(1, 0, 0, 1)); -#endif - - // If the closest points are nearer than the sum of the radii... - if(points.d - poly1->r - poly2->r <= 0.0){ - ContactPoints(SupportEdgeForPoly(poly1, points.n), SupportEdgeForPoly(poly2, cpvneg(points.n)), points, info); - } -} - -static void -SegmentToPoly(const cpSegmentShape *seg, const cpPolyShape *poly, struct cpCollisionInfo *info) -{ - struct SupportContext context = {(cpShape *)seg, (cpShape *)poly, (SupportPointFunc)SegmentSupportPoint, (SupportPointFunc)PolySupportPoint}; - struct ClosestPoints points = GJK(&context, &info->id); - -#if DRAW_CLOSEST -#if PRINT_LOG -// ChipmunkDemoPrintString("Distance: %.2f\n", points.d); -#endif - - ChipmunkDebugDrawDot(3.0, points.a, RGBAColor(1, 1, 1, 1)); - ChipmunkDebugDrawDot(3.0, points.b, RGBAColor(1, 1, 1, 1)); - ChipmunkDebugDrawSegment(points.a, points.b, RGBAColor(1, 1, 1, 1)); - ChipmunkDebugDrawSegment(points.a, cpvadd(points.a, cpvmult(points.n, 10.0)), RGBAColor(1, 0, 0, 1)); -#endif - - cpVect n = points.n; - cpVect rot = cpBodyGetRotation(seg->shape.body); - - if( - // If the closest points are nearer than the sum of the radii... - points.d - seg->r - poly->r <= 0.0 && ( - // Reject endcap collisions if tangents are provided. - (!cpveql(points.a, seg->ta) || cpvdot(n, cpvrotate(seg->a_tangent, rot)) <= 0.0) && - (!cpveql(points.a, seg->tb) || cpvdot(n, cpvrotate(seg->b_tangent, rot)) <= 0.0) - ) - ){ - ContactPoints(SupportEdgeForSegment(seg, n), SupportEdgeForPoly(poly, cpvneg(n)), points, info); - } -} - -static void -CircleToPoly(const cpCircleShape *circle, const cpPolyShape *poly, struct cpCollisionInfo *info) -{ - struct SupportContext context = {(cpShape *)circle, (cpShape *)poly, (SupportPointFunc)CircleSupportPoint, (SupportPointFunc)PolySupportPoint}; - struct ClosestPoints points = GJK(&context, &info->id); - -#if DRAW_CLOSEST - ChipmunkDebugDrawDot(3.0, points.a, RGBAColor(1, 1, 1, 1)); - ChipmunkDebugDrawDot(3.0, points.b, RGBAColor(1, 1, 1, 1)); - ChipmunkDebugDrawSegment(points.a, points.b, RGBAColor(1, 1, 1, 1)); - ChipmunkDebugDrawSegment(points.a, cpvadd(points.a, cpvmult(points.n, 10.0)), RGBAColor(1, 0, 0, 1)); -#endif - - // If the closest points are nearer than the sum of the radii... - if(points.d <= circle->r + poly->r){ - cpVect n = info->n = points.n; - cpCollisionInfoPushContact(info, cpvadd(points.a, cpvmult(n, circle->r)), cpvadd(points.b, cpvmult(n, poly->r)), 0); - } -} - -static void -CollisionError(const cpShape *circle, const cpShape *poly, struct cpCollisionInfo *info) -{ - cpAssertHard(cpFalse, "Internal Error: Shape types are not sorted."); -} - - -static const CollisionFunc BuiltinCollisionFuncs[9] = { - (CollisionFunc)CircleToCircle, - CollisionError, - CollisionError, - (CollisionFunc)CircleToSegment, - (CollisionFunc)SegmentToSegment, - CollisionError, - (CollisionFunc)CircleToPoly, - (CollisionFunc)SegmentToPoly, - (CollisionFunc)PolyToPoly, -}; -static const CollisionFunc *CollisionFuncs = BuiltinCollisionFuncs; - -struct cpCollisionInfo -cpCollide(const cpShape *a, const cpShape *b, cpCollisionID id, struct cpContact *contacts) -{ - struct cpCollisionInfo info = {a, b, id, cpvzero, 0, contacts}; - - // Make sure the shape types are in order. - if(a->klass->type > b->klass->type){ - info.a = b; - info.b = a; - } - - CollisionFuncs[info.a->klass->type + info.b->klass->type*CP_NUM_SHAPES](info.a, info.b, &info); - -// if(0){ -// for(int i=0; i<info.count; i++){ -// cpVect r1 = info.arr[i].r1; -// cpVect r2 = info.arr[i].r2; -// cpVect mid = cpvlerp(r1, r2, 0.5f); -// -// ChipmunkDebugDrawSegment(r1, mid, RGBAColor(1, 0, 0, 1)); -// ChipmunkDebugDrawSegment(r2, mid, RGBAColor(0, 0, 1, 1)); -// } -// } - - return info; -} diff --git a/thirdparty/src/chipmunk/cpConstraint.c b/thirdparty/src/chipmunk/cpConstraint.c deleted file mode 100644 index 7952ea188..000000000 --- a/thirdparty/src/chipmunk/cpConstraint.c +++ /dev/null @@ -1,173 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -// TODO: Comment me! - -void cpConstraintDestroy(cpConstraint *constraint){} - -void -cpConstraintFree(cpConstraint *constraint) -{ - if(constraint){ - cpConstraintDestroy(constraint); - cpfree(constraint); - } -} - -void -cpConstraintInit(cpConstraint *constraint, const cpConstraintClass *klass, cpBody *a, cpBody *b) -{ - constraint->klass = klass; - - constraint->a = a; - constraint->b = b; - constraint->space = NULL; - - constraint->next_a = NULL; - constraint->next_b = NULL; - - constraint->maxForce = (cpFloat)INFINITY; - constraint->errorBias = cpfpow(1.0f - 0.1f, 60.0f); - constraint->maxBias = (cpFloat)INFINITY; - - constraint->collideBodies = cpTrue; - - constraint->preSolve = NULL; - constraint->postSolve = NULL; -} - -cpSpace * -cpConstraintGetSpace(const cpConstraint *constraint) -{ - return constraint->space; -} - -cpBody * -cpConstraintGetBodyA(const cpConstraint *constraint) -{ - return constraint->a; -} - -cpBody * -cpConstraintGetBodyB(const cpConstraint *constraint) -{ - return constraint->b; -} - -cpFloat -cpConstraintGetMaxForce(const cpConstraint *constraint) -{ - return constraint->maxForce; -} - -void -cpConstraintSetMaxForce(cpConstraint *constraint, cpFloat maxForce) -{ - cpAssertHard(maxForce >= 0.0f, "maxForce must be positive."); - cpConstraintActivateBodies(constraint); - constraint->maxForce = maxForce; -} - -cpFloat -cpConstraintGetErrorBias(const cpConstraint *constraint) -{ - return constraint->errorBias; -} - -void -cpConstraintSetErrorBias(cpConstraint *constraint, cpFloat errorBias) -{ - cpAssertHard(errorBias >= 0.0f, "errorBias must be positive."); - cpConstraintActivateBodies(constraint); - constraint->errorBias = errorBias; -} - -cpFloat -cpConstraintGetMaxBias(const cpConstraint *constraint) -{ - return constraint->maxBias; -} - -void -cpConstraintSetMaxBias(cpConstraint *constraint, cpFloat maxBias) -{ - cpAssertHard(maxBias >= 0.0f, "maxBias must be positive."); - cpConstraintActivateBodies(constraint); - constraint->maxBias = maxBias; -} - -cpBool -cpConstraintGetCollideBodies(const cpConstraint *constraint) -{ - return constraint->collideBodies; -} - -void -cpConstraintSetCollideBodies(cpConstraint *constraint, cpBool collideBodies) -{ - cpConstraintActivateBodies(constraint); - constraint->collideBodies = collideBodies; -} - -cpConstraintPreSolveFunc -cpConstraintGetPreSolveFunc(const cpConstraint *constraint) -{ - return constraint->preSolve; -} - -void -cpConstraintSetPreSolveFunc(cpConstraint *constraint, cpConstraintPreSolveFunc preSolveFunc) -{ - constraint->preSolve = preSolveFunc; -} - -cpConstraintPostSolveFunc -cpConstraintGetPostSolveFunc(const cpConstraint *constraint) -{ - return constraint->postSolve; -} - -void -cpConstraintSetPostSolveFunc(cpConstraint *constraint, cpConstraintPostSolveFunc postSolveFunc) -{ - constraint->postSolve = postSolveFunc; -} - -cpDataPointer -cpConstraintGetUserData(const cpConstraint *constraint) -{ - return constraint->userData; -} - -void -cpConstraintSetUserData(cpConstraint *constraint, cpDataPointer userData) -{ - constraint->userData = userData; -} - - -cpFloat -cpConstraintGetImpulse(cpConstraint *constraint) -{ - return constraint->klass->getImpulse(constraint); -} diff --git a/thirdparty/src/chipmunk/cpDampedRotarySpring.c b/thirdparty/src/chipmunk/cpDampedRotarySpring.c deleted file mode 100644 index 8d38a545e..000000000 --- a/thirdparty/src/chipmunk/cpDampedRotarySpring.c +++ /dev/null @@ -1,178 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -static cpFloat -defaultSpringTorque(cpDampedRotarySpring *spring, cpFloat relativeAngle){ - return (relativeAngle - spring->restAngle)*spring->stiffness; -} - -static void -preStep(cpDampedRotarySpring *spring, cpFloat dt) -{ - cpBody *a = spring->constraint.a; - cpBody *b = spring->constraint.b; - - cpFloat moment = a->i_inv + b->i_inv; - cpAssertSoft(moment != 0.0, "Unsolvable spring."); - spring->iSum = 1.0f/moment; - - spring->w_coef = 1.0f - cpfexp(-spring->damping*dt*moment); - spring->target_wrn = 0.0f; - - // apply spring torque - cpFloat j_spring = spring->springTorqueFunc((cpConstraint *)spring, a->a - b->a)*dt; - spring->jAcc = j_spring; - - a->w -= j_spring*a->i_inv; - b->w += j_spring*b->i_inv; -} - -static void applyCachedImpulse(cpDampedRotarySpring *spring, cpFloat dt_coef){} - -static void -applyImpulse(cpDampedRotarySpring *spring, cpFloat dt) -{ - cpBody *a = spring->constraint.a; - cpBody *b = spring->constraint.b; - - // compute relative velocity - cpFloat wrn = a->w - b->w;//normal_relative_velocity(a, b, r1, r2, n) - spring->target_vrn; - - // compute velocity loss from drag - // not 100% certain this is derived correctly, though it makes sense - cpFloat w_damp = (spring->target_wrn - wrn)*spring->w_coef; - spring->target_wrn = wrn + w_damp; - - //apply_impulses(a, b, spring->r1, spring->r2, cpvmult(spring->n, v_damp*spring->nMass)); - cpFloat j_damp = w_damp*spring->iSum; - spring->jAcc += j_damp; - - a->w += j_damp*a->i_inv; - b->w -= j_damp*b->i_inv; -} - -static cpFloat -getImpulse(cpDampedRotarySpring *spring) -{ - return spring->jAcc; -} - -static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, -}; - -cpDampedRotarySpring * -cpDampedRotarySpringAlloc(void) -{ - return (cpDampedRotarySpring *)cpcalloc(1, sizeof(cpDampedRotarySpring)); -} - -cpDampedRotarySpring * -cpDampedRotarySpringInit(cpDampedRotarySpring *spring, cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping) -{ - cpConstraintInit((cpConstraint *)spring, &klass, a, b); - - spring->restAngle = restAngle; - spring->stiffness = stiffness; - spring->damping = damping; - spring->springTorqueFunc = (cpDampedRotarySpringTorqueFunc)defaultSpringTorque; - - spring->jAcc = 0.0f; - - return spring; -} - -cpConstraint * -cpDampedRotarySpringNew(cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping) -{ - return (cpConstraint *)cpDampedRotarySpringInit(cpDampedRotarySpringAlloc(), a, b, restAngle, stiffness, damping); -} - -cpBool -cpConstraintIsDampedRotarySpring(const cpConstraint *constraint) -{ - return (constraint->klass == &klass); -} - -cpFloat -cpDampedRotarySpringGetRestAngle(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsDampedRotarySpring(constraint), "Constraint is not a damped rotary spring."); - return ((cpDampedRotarySpring *)constraint)->restAngle; -} - -void -cpDampedRotarySpringSetRestAngle(cpConstraint *constraint, cpFloat restAngle) -{ - cpAssertHard(cpConstraintIsDampedRotarySpring(constraint), "Constraint is not a damped rotary spring."); - cpConstraintActivateBodies(constraint); - ((cpDampedRotarySpring *)constraint)->restAngle = restAngle; -} - -cpFloat -cpDampedRotarySpringGetStiffness(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsDampedRotarySpring(constraint), "Constraint is not a damped rotary spring."); - return ((cpDampedRotarySpring *)constraint)->stiffness; -} - -void -cpDampedRotarySpringSetStiffness(cpConstraint *constraint, cpFloat stiffness) -{ - cpAssertHard(cpConstraintIsDampedRotarySpring(constraint), "Constraint is not a damped rotary spring."); - cpConstraintActivateBodies(constraint); - ((cpDampedRotarySpring *)constraint)->stiffness = stiffness; -} - -cpFloat -cpDampedRotarySpringGetDamping(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsDampedRotarySpring(constraint), "Constraint is not a damped rotary spring."); - return ((cpDampedRotarySpring *)constraint)->damping; -} - -void -cpDampedRotarySpringSetDamping(cpConstraint *constraint, cpFloat damping) -{ - cpAssertHard(cpConstraintIsDampedRotarySpring(constraint), "Constraint is not a damped rotary spring."); - cpConstraintActivateBodies(constraint); - ((cpDampedRotarySpring *)constraint)->damping = damping; -} - -cpDampedRotarySpringTorqueFunc -cpDampedRotarySpringGetSpringTorqueFunc(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsDampedRotarySpring(constraint), "Constraint is not a damped rotary spring."); - return ((cpDampedRotarySpring *)constraint)->springTorqueFunc; -} - -void -cpDampedRotarySpringSetSpringTorqueFunc(cpConstraint *constraint, cpDampedRotarySpringTorqueFunc springTorqueFunc) -{ - cpAssertHard(cpConstraintIsDampedRotarySpring(constraint), "Constraint is not a damped rotary spring."); - cpConstraintActivateBodies(constraint); - ((cpDampedRotarySpring *)constraint)->springTorqueFunc = springTorqueFunc; -} diff --git a/thirdparty/src/chipmunk/cpDampedSpring.c b/thirdparty/src/chipmunk/cpDampedSpring.c deleted file mode 100644 index e4d019e9a..000000000 --- a/thirdparty/src/chipmunk/cpDampedSpring.c +++ /dev/null @@ -1,216 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -static cpFloat -defaultSpringForce(cpDampedSpring *spring, cpFloat dist){ - return (spring->restLength - dist)*spring->stiffness; -} - -static void -preStep(cpDampedSpring *spring, cpFloat dt) -{ - cpBody *a = spring->constraint.a; - cpBody *b = spring->constraint.b; - - spring->r1 = cpTransformVect(a->transform, cpvsub(spring->anchorA, a->cog)); - spring->r2 = cpTransformVect(b->transform, cpvsub(spring->anchorB, b->cog)); - - cpVect delta = cpvsub(cpvadd(b->p, spring->r2), cpvadd(a->p, spring->r1)); - cpFloat dist = cpvlength(delta); - spring->n = cpvmult(delta, 1.0f/(dist ? dist : INFINITY)); - - cpFloat k = k_scalar(a, b, spring->r1, spring->r2, spring->n); - cpAssertSoft(k != 0.0, "Unsolvable spring."); - spring->nMass = 1.0f/k; - - spring->target_vrn = 0.0f; - spring->v_coef = 1.0f - cpfexp(-spring->damping*dt*k); - - // apply spring force - cpFloat f_spring = spring->springForceFunc((cpConstraint *)spring, dist); - cpFloat j_spring = spring->jAcc = f_spring*dt; - apply_impulses(a, b, spring->r1, spring->r2, cpvmult(spring->n, j_spring)); -} - -static void applyCachedImpulse(cpDampedSpring *spring, cpFloat dt_coef){} - -static void -applyImpulse(cpDampedSpring *spring, cpFloat dt) -{ - cpBody *a = spring->constraint.a; - cpBody *b = spring->constraint.b; - - cpVect n = spring->n; - cpVect r1 = spring->r1; - cpVect r2 = spring->r2; - - // compute relative velocity - cpFloat vrn = normal_relative_velocity(a, b, r1, r2, n); - - // compute velocity loss from drag - cpFloat v_damp = (spring->target_vrn - vrn)*spring->v_coef; - spring->target_vrn = vrn + v_damp; - - cpFloat j_damp = v_damp*spring->nMass; - spring->jAcc += j_damp; - apply_impulses(a, b, spring->r1, spring->r2, cpvmult(spring->n, j_damp)); -} - -static cpFloat -getImpulse(cpDampedSpring *spring) -{ - return spring->jAcc; -} - -static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, -}; - -cpDampedSpring * -cpDampedSpringAlloc(void) -{ - return (cpDampedSpring *)cpcalloc(1, sizeof(cpDampedSpring)); -} - -cpDampedSpring * -cpDampedSpringInit(cpDampedSpring *spring, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat restLength, cpFloat stiffness, cpFloat damping) -{ - cpConstraintInit((cpConstraint *)spring, &klass, a, b); - - spring->anchorA = anchorA; - spring->anchorB = anchorB; - - spring->restLength = restLength; - spring->stiffness = stiffness; - spring->damping = damping; - spring->springForceFunc = (cpDampedSpringForceFunc)defaultSpringForce; - - spring->jAcc = 0.0f; - - return spring; -} - -cpConstraint * -cpDampedSpringNew(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat restLength, cpFloat stiffness, cpFloat damping) -{ - return (cpConstraint *)cpDampedSpringInit(cpDampedSpringAlloc(), a, b, anchorA, anchorB, restLength, stiffness, damping); -} - -cpBool -cpConstraintIsDampedSpring(const cpConstraint *constraint) -{ - return (constraint->klass == &klass); -} - -cpVect -cpDampedSpringGetAnchorA(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsDampedSpring(constraint), "Constraint is not a damped spring."); - return ((cpDampedSpring *)constraint)->anchorA; -} - -void -cpDampedSpringSetAnchorA(cpConstraint *constraint, cpVect anchorA) -{ - cpAssertHard(cpConstraintIsDampedSpring(constraint), "Constraint is not a damped spring."); - cpConstraintActivateBodies(constraint); - ((cpDampedSpring *)constraint)->anchorA = anchorA; -} - -cpVect -cpDampedSpringGetAnchorB(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsDampedSpring(constraint), "Constraint is not a damped spring."); - return ((cpDampedSpring *)constraint)->anchorB; -} - -void -cpDampedSpringSetAnchorB(cpConstraint *constraint, cpVect anchorB) -{ - cpAssertHard(cpConstraintIsDampedSpring(constraint), "Constraint is not a damped spring."); - cpConstraintActivateBodies(constraint); - ((cpDampedSpring *)constraint)->anchorB = anchorB; -} - -cpFloat -cpDampedSpringGetRestLength(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsDampedSpring(constraint), "Constraint is not a damped spring."); - return ((cpDampedSpring *)constraint)->restLength; -} - -void -cpDampedSpringSetRestLength(cpConstraint *constraint, cpFloat restLength) -{ - cpAssertHard(cpConstraintIsDampedSpring(constraint), "Constraint is not a damped spring."); - cpConstraintActivateBodies(constraint); - ((cpDampedSpring *)constraint)->restLength = restLength; -} - -cpFloat -cpDampedSpringGetStiffness(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsDampedSpring(constraint), "Constraint is not a damped spring."); - return ((cpDampedSpring *)constraint)->stiffness; -} - -void -cpDampedSpringSetStiffness(cpConstraint *constraint, cpFloat stiffness) -{ - cpAssertHard(cpConstraintIsDampedSpring(constraint), "Constraint is not a damped spring."); - cpConstraintActivateBodies(constraint); - ((cpDampedSpring *)constraint)->stiffness = stiffness; -} - -cpFloat -cpDampedSpringGetDamping(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsDampedSpring(constraint), "Constraint is not a damped spring."); - return ((cpDampedSpring *)constraint)->damping; -} - -void -cpDampedSpringSetDamping(cpConstraint *constraint, cpFloat damping) -{ - cpAssertHard(cpConstraintIsDampedSpring(constraint), "Constraint is not a damped spring."); - cpConstraintActivateBodies(constraint); - ((cpDampedSpring *)constraint)->damping = damping; -} - -cpDampedSpringForceFunc -cpDampedSpringGetSpringForceFunc(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsDampedSpring(constraint), "Constraint is not a damped spring."); - return ((cpDampedSpring *)constraint)->springForceFunc; -} - -void -cpDampedSpringSetSpringForceFunc(cpConstraint *constraint, cpDampedSpringForceFunc springForceFunc) -{ - cpAssertHard(cpConstraintIsDampedSpring(constraint), "Constraint is not a damped spring."); - cpConstraintActivateBodies(constraint); - ((cpDampedSpring *)constraint)->springForceFunc = springForceFunc; -} diff --git a/thirdparty/src/chipmunk/cpGearJoint.c b/thirdparty/src/chipmunk/cpGearJoint.c deleted file mode 100644 index 3670173b3..000000000 --- a/thirdparty/src/chipmunk/cpGearJoint.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -static void -preStep(cpGearJoint *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // calculate moment of inertia coefficient. - joint->iSum = 1.0f/(a->i_inv*joint->ratio_inv + joint->ratio*b->i_inv); - - // calculate bias velocity - cpFloat maxBias = joint->constraint.maxBias; - joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*(b->a*joint->ratio - a->a - joint->phase)/dt, -maxBias, maxBias); -} - -static void -applyCachedImpulse(cpGearJoint *joint, cpFloat dt_coef) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpFloat j = joint->jAcc*dt_coef; - a->w -= j*a->i_inv*joint->ratio_inv; - b->w += j*b->i_inv; -} - -static void -applyImpulse(cpGearJoint *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // compute relative rotational velocity - cpFloat wr = b->w*joint->ratio - a->w; - - cpFloat jMax = joint->constraint.maxForce*dt; - - // compute normal impulse - cpFloat j = (joint->bias - wr)*joint->iSum; - cpFloat jOld = joint->jAcc; - joint->jAcc = cpfclamp(jOld + j, -jMax, jMax); - j = joint->jAcc - jOld; - - // apply impulse - a->w -= j*a->i_inv*joint->ratio_inv; - b->w += j*b->i_inv; -} - -static cpFloat -getImpulse(cpGearJoint *joint) -{ - return cpfabs(joint->jAcc); -} - -static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, -}; - -cpGearJoint * -cpGearJointAlloc(void) -{ - return (cpGearJoint *)cpcalloc(1, sizeof(cpGearJoint)); -} - -cpGearJoint * -cpGearJointInit(cpGearJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio) -{ - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->phase = phase; - joint->ratio = ratio; - joint->ratio_inv = 1.0f/ratio; - - joint->jAcc = 0.0f; - - return joint; -} - -cpConstraint * -cpGearJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio) -{ - return (cpConstraint *)cpGearJointInit(cpGearJointAlloc(), a, b, phase, ratio); -} - -cpBool -cpConstraintIsGearJoint(const cpConstraint *constraint) -{ - return (constraint->klass == &klass); -} - -cpFloat -cpGearJointGetPhase(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsGearJoint(constraint), "Constraint is not a ratchet joint."); - return ((cpGearJoint *)constraint)->phase; -} - -void -cpGearJointSetPhase(cpConstraint *constraint, cpFloat phase) -{ - cpAssertHard(cpConstraintIsGearJoint(constraint), "Constraint is not a ratchet joint."); - cpConstraintActivateBodies(constraint); - ((cpGearJoint *)constraint)->phase = phase; -} - -cpFloat -cpGearJointGetRatio(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsGearJoint(constraint), "Constraint is not a ratchet joint."); - return ((cpGearJoint *)constraint)->ratio; -} - -void -cpGearJointSetRatio(cpConstraint *constraint, cpFloat ratio) -{ - cpAssertHard(cpConstraintIsGearJoint(constraint), "Constraint is not a ratchet joint."); - cpConstraintActivateBodies(constraint); - ((cpGearJoint *)constraint)->ratio = ratio; - ((cpGearJoint *)constraint)->ratio_inv = 1.0f/ratio; -} diff --git a/thirdparty/src/chipmunk/cpGrooveJoint.c b/thirdparty/src/chipmunk/cpGrooveJoint.c deleted file mode 100644 index 50d1857d4..000000000 --- a/thirdparty/src/chipmunk/cpGrooveJoint.c +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -static void -preStep(cpGrooveJoint *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // calculate endpoints in worldspace - cpVect ta = cpTransformPoint(a->transform, joint->grv_a); - cpVect tb = cpTransformPoint(a->transform, joint->grv_b); - - // calculate axis - cpVect n = cpTransformVect(a->transform, joint->grv_n); - cpFloat d = cpvdot(ta, n); - - joint->grv_tn = n; - joint->r2 = cpTransformVect(b->transform, cpvsub(joint->anchorB, b->cog)); - - // calculate tangential distance along the axis of r2 - cpFloat td = cpvcross(cpvadd(b->p, joint->r2), n); - // calculate clamping factor and r2 - if(td <= cpvcross(ta, n)){ - joint->clamp = 1.0f; - joint->r1 = cpvsub(ta, a->p); - } else if(td >= cpvcross(tb, n)){ - joint->clamp = -1.0f; - joint->r1 = cpvsub(tb, a->p); - } else { - joint->clamp = 0.0f; - joint->r1 = cpvsub(cpvadd(cpvmult(cpvperp(n), -td), cpvmult(n, d)), a->p); - } - - // Calculate mass tensor - joint->k = k_tensor(a, b, joint->r1, joint->r2); - - // calculate bias velocity - cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1)); - joint->bias = cpvclamp(cpvmult(delta, -bias_coef(joint->constraint.errorBias, dt)/dt), joint->constraint.maxBias); -} - -static void -applyCachedImpulse(cpGrooveJoint *joint, cpFloat dt_coef) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - apply_impulses(a, b, joint->r1, joint->r2, cpvmult(joint->jAcc, dt_coef)); -} - -static inline cpVect -grooveConstrain(cpGrooveJoint *joint, cpVect j, cpFloat dt){ - cpVect n = joint->grv_tn; - cpVect jClamp = (joint->clamp*cpvcross(j, n) > 0.0f) ? j : cpvproject(j, n); - return cpvclamp(jClamp, joint->constraint.maxForce*dt); -} - -static void -applyImpulse(cpGrooveJoint *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpVect r1 = joint->r1; - cpVect r2 = joint->r2; - - // compute impulse - cpVect vr = relative_velocity(a, b, r1, r2); - - cpVect j = cpMat2x2Transform(joint->k, cpvsub(joint->bias, vr)); - cpVect jOld = joint->jAcc; - joint->jAcc = grooveConstrain(joint, cpvadd(jOld, j), dt); - j = cpvsub(joint->jAcc, jOld); - - // apply impulse - apply_impulses(a, b, joint->r1, joint->r2, j); -} - -static cpFloat -getImpulse(cpGrooveJoint *joint) -{ - return cpvlength(joint->jAcc); -} - -static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, -}; - -cpGrooveJoint * -cpGrooveJointAlloc(void) -{ - return (cpGrooveJoint *)cpcalloc(1, sizeof(cpGrooveJoint)); -} - -cpGrooveJoint * -cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchorB) -{ - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->grv_a = groove_a; - joint->grv_b = groove_b; - joint->grv_n = cpvperp(cpvnormalize(cpvsub(groove_b, groove_a))); - joint->anchorB = anchorB; - - joint->jAcc = cpvzero; - - return joint; -} - -cpConstraint * -cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchorB) -{ - return (cpConstraint *)cpGrooveJointInit(cpGrooveJointAlloc(), a, b, groove_a, groove_b, anchorB); -} - -cpBool -cpConstraintIsGrooveJoint(const cpConstraint *constraint) -{ - return (constraint->klass == &klass); -} - -cpVect -cpGrooveJointGetGrooveA(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsGrooveJoint(constraint), "Constraint is not a groove joint."); - return ((cpGrooveJoint *)constraint)->grv_a; -} - -void -cpGrooveJointSetGrooveA(cpConstraint *constraint, cpVect value) -{ - cpAssertHard(cpConstraintIsGrooveJoint(constraint), "Constraint is not a groove joint."); - cpGrooveJoint *g = (cpGrooveJoint *)constraint; - - g->grv_a = value; - g->grv_n = cpvperp(cpvnormalize(cpvsub(g->grv_b, value))); - - cpConstraintActivateBodies(constraint); -} - -cpVect -cpGrooveJointGetGrooveB(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsGrooveJoint(constraint), "Constraint is not a groove joint."); - return ((cpGrooveJoint *)constraint)->grv_b; -} - -void -cpGrooveJointSetGrooveB(cpConstraint *constraint, cpVect value) -{ - cpAssertHard(cpConstraintIsGrooveJoint(constraint), "Constraint is not a groove joint."); - cpGrooveJoint *g = (cpGrooveJoint *)constraint; - - g->grv_b = value; - g->grv_n = cpvperp(cpvnormalize(cpvsub(value, g->grv_a))); - - cpConstraintActivateBodies(constraint); -} - -cpVect -cpGrooveJointGetAnchorB(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsGrooveJoint(constraint), "Constraint is not a groove joint."); - return ((cpGrooveJoint *)constraint)->anchorB; -} - -void -cpGrooveJointSetAnchorB(cpConstraint *constraint, cpVect anchorB) -{ - cpAssertHard(cpConstraintIsGrooveJoint(constraint), "Constraint is not a groove joint."); - cpConstraintActivateBodies(constraint); - ((cpGrooveJoint *)constraint)->anchorB = anchorB; -} diff --git a/thirdparty/src/chipmunk/cpHashSet.c b/thirdparty/src/chipmunk/cpHashSet.c deleted file mode 100644 index e098b4247..000000000 --- a/thirdparty/src/chipmunk/cpHashSet.c +++ /dev/null @@ -1,253 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" -#include "prime.h" - -typedef struct cpHashSetBin { - void *elt; - cpHashValue hash; - struct cpHashSetBin *next; -} cpHashSetBin; - -struct cpHashSet { - unsigned int entries, size; - - cpHashSetEqlFunc eql; - void *default_value; - - cpHashSetBin **table; - cpHashSetBin *pooledBins; - - cpArray *allocatedBuffers; -}; - -void -cpHashSetFree(cpHashSet *set) -{ - if(set){ - cpfree(set->table); - - cpArrayFreeEach(set->allocatedBuffers, cpfree); - cpArrayFree(set->allocatedBuffers); - - cpfree(set); - } -} - -cpHashSet * -cpHashSetNew(int size, cpHashSetEqlFunc eqlFunc) -{ - cpHashSet *set = (cpHashSet *)cpcalloc(1, sizeof(cpHashSet)); - - set->size = next_prime(size); - set->entries = 0; - - set->eql = eqlFunc; - set->default_value = NULL; - - set->table = (cpHashSetBin **)cpcalloc(set->size, sizeof(cpHashSetBin *)); - set->pooledBins = NULL; - - set->allocatedBuffers = cpArrayNew(0); - - return set; -} - -void -cpHashSetSetDefaultValue(cpHashSet *set, void *default_value) -{ - set->default_value = default_value; -} - -static int -setIsFull(cpHashSet *set) -{ - return (set->entries >= set->size); -} - -static void -cpHashSetResize(cpHashSet *set) -{ - // Get the next approximate doubled prime. - unsigned int newSize = next_prime(set->size + 1); - // Allocate a new table. - cpHashSetBin **newTable = (cpHashSetBin **)cpcalloc(newSize, sizeof(cpHashSetBin *)); - - // Iterate over the chains. - for(unsigned int i=0; i<set->size; i++){ - // Rehash the bins into the new table. - cpHashSetBin *bin = set->table[i]; - while(bin){ - cpHashSetBin *next = bin->next; - - cpHashValue idx = bin->hash%newSize; - bin->next = newTable[idx]; - newTable[idx] = bin; - - bin = next; - } - } - - cpfree(set->table); - - set->table = newTable; - set->size = newSize; -} - -static inline void -recycleBin(cpHashSet *set, cpHashSetBin *bin) -{ - bin->next = set->pooledBins; - set->pooledBins = bin; - bin->elt = NULL; -} - -static cpHashSetBin * -getUnusedBin(cpHashSet *set) -{ - cpHashSetBin *bin = set->pooledBins; - - if(bin){ - set->pooledBins = bin->next; - return bin; - } else { - // Pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(cpHashSetBin); - cpAssertHard(count, "Internal Error: Buffer size is too small."); - - cpHashSetBin *buffer = (cpHashSetBin *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(set->allocatedBuffers, buffer); - - // push all but the first one, return it instead - for(int i=1; i<count; i++) recycleBin(set, buffer + i); - return buffer; - } -} - -int -cpHashSetCount(cpHashSet *set) -{ - return set->entries; -} - -void * -cpHashSetInsert(cpHashSet *set, cpHashValue hash, void *ptr, cpHashSetTransFunc trans, void *data) -{ - cpHashValue idx = hash%set->size; - - // Find the bin with the matching element. - cpHashSetBin *bin = set->table[idx]; - while(bin && !set->eql(ptr, bin->elt)) - bin = bin->next; - - // Create it if necessary. - if(!bin){ - bin = getUnusedBin(set); - bin->hash = hash; - bin->elt = (trans ? trans(ptr, data) : data); - - bin->next = set->table[idx]; - set->table[idx] = bin; - - set->entries++; - if(setIsFull(set)) cpHashSetResize(set); - } - - return bin->elt; -} - -void * -cpHashSetRemove(cpHashSet *set, cpHashValue hash, void *ptr) -{ - cpHashValue idx = hash%set->size; - - cpHashSetBin **prev_ptr = &set->table[idx]; - cpHashSetBin *bin = set->table[idx]; - - // Find the bin - while(bin && !set->eql(ptr, bin->elt)){ - prev_ptr = &bin->next; - bin = bin->next; - } - - // Remove it if it exists. - if(bin){ - // Update the previous linked list pointer - (*prev_ptr) = bin->next; - set->entries--; - - void *elt = bin->elt; - recycleBin(set, bin); - - return elt; - } - - return NULL; -} - -void * -cpHashSetFind(cpHashSet *set, cpHashValue hash, void *ptr) -{ - cpHashValue idx = hash%set->size; - cpHashSetBin *bin = set->table[idx]; - while(bin && !set->eql(ptr, bin->elt)) - bin = bin->next; - - return (bin ? bin->elt : set->default_value); -} - -void -cpHashSetEach(cpHashSet *set, cpHashSetIteratorFunc func, void *data) -{ - for(unsigned int i=0; i<set->size; i++){ - cpHashSetBin *bin = set->table[i]; - while(bin){ - cpHashSetBin *next = bin->next; - func(bin->elt, data); - bin = next; - } - } -} - -void -cpHashSetFilter(cpHashSet *set, cpHashSetFilterFunc func, void *data) -{ - for(unsigned int i=0; i<set->size; i++){ - // The rest works similarly to cpHashSetRemove() above. - cpHashSetBin **prev_ptr = &set->table[i]; - cpHashSetBin *bin = set->table[i]; - while(bin){ - cpHashSetBin *next = bin->next; - - if(func(bin->elt, data)){ - prev_ptr = &bin->next; - } else { - (*prev_ptr) = next; - - set->entries--; - recycleBin(set, bin); - } - - bin = next; - } - } -} diff --git a/thirdparty/src/chipmunk/cpHastySpace.c b/thirdparty/src/chipmunk/cpHastySpace.c deleted file mode 100644 index 7093bfc48..000000000 --- a/thirdparty/src/chipmunk/cpHastySpace.c +++ /dev/null @@ -1,700 +0,0 @@ -// Copyright 2013 Howling Moon Software. All rights reserved. -// See http://chipmunk2d.net/legal.php for more information. - -#include <stdlib.h> -#include <stdio.h> - -//TODO: Move all the thread stuff to another file - -//#include <sys/param.h > -#ifndef _WIN32 -#include <sys/sysctl.h> -#include <pthread.h> -#else -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#ifndef NOMINMAX -#define NOMINMAX -#endif - -#include <process.h> // _beginthreadex -#include <windows.h> - -#ifndef ETIMEDOUT -#define ETIMEDOUT 1 -#endif - -// Simple pthread implementation for Windows -// Made from scratch to avoid the LGPL licence from pthread-win32 -enum { - SIGNAL = 0, - BROADCAST = 1, - MAX_EVENTS = 2 -}; - -typedef HANDLE pthread_t; -typedef struct -{ - // Based on http://www.cs.wustl.edu/~schmidt/win32-cv-1.html since Windows has no condition variable until NT6 - UINT waiters_count; - // Count of the number of waiters. - - CRITICAL_SECTION waiters_count_lock; - // Serialize access to <waiters_count_>. - - HANDLE events[MAX_EVENTS]; -} pthread_cond_t; -typedef CRITICAL_SECTION pthread_mutex_t; - -typedef struct { - int dummy; -} pthread_condattr_t; // Dummy; - -int pthread_cond_destroy(pthread_cond_t* cv) -{ - CloseHandle(cv->events[BROADCAST]); - CloseHandle(cv->events[SIGNAL]); - - DeleteCriticalSection(&cv->waiters_count_lock); - - return 0; -} - -int pthread_cond_init(pthread_cond_t* cv, const pthread_condattr_t* attr) -{ - // Initialize the count to 0. - cv->waiters_count = 0; - - // Create an auto-reset event. - cv->events[SIGNAL] = CreateEvent(NULL, // no security - FALSE, // auto-reset event - FALSE, // non-signaled initially - NULL); // unnamed - - // Create a manual-reset event. - cv->events[BROADCAST] = CreateEvent(NULL, // no security - TRUE, // manual-reset - FALSE, // non-signaled initially - NULL); // unnamed - - InitializeCriticalSection(&cv->waiters_count_lock); - - return 0; -} - -int pthread_cond_broadcast(pthread_cond_t *cv) -{ - // Avoid race conditions. - EnterCriticalSection(&cv->waiters_count_lock); - int have_waiters = cv->waiters_count > 0; - LeaveCriticalSection(&cv->waiters_count_lock); - - if (have_waiters) - SetEvent(cv->events[BROADCAST]); - - return 0; -} - -int pthread_cond_signal(pthread_cond_t* cv) -{ - // Avoid race conditions. - EnterCriticalSection(&cv->waiters_count_lock); - int have_waiters = cv->waiters_count > 0; - LeaveCriticalSection(&cv->waiters_count_lock); - - if (have_waiters) - SetEvent(cv->events[SIGNAL]); - - return 0; -} - -int pthread_cond_wait(pthread_cond_t* cv, pthread_mutex_t* external_mutex) -{ - // Avoid race conditions. - EnterCriticalSection(&cv->waiters_count_lock); - cv->waiters_count++; - LeaveCriticalSection(&cv->waiters_count_lock); - - // It's ok to release the <external_mutex> here since Win32 - // manual-reset events maintain state when used with - // <SetEvent>. This avoids the "lost wakeup" bug... - LeaveCriticalSection(external_mutex); - - // Wait for either event to become signaled due to <pthread_cond_signal> - // being called or <pthread_cond_broadcast> being called. - int result = WaitForMultipleObjects(2, cv->events, FALSE, INFINITE); - - EnterCriticalSection(&cv->waiters_count_lock); - cv->waiters_count--; - int last_waiter = - result == WAIT_OBJECT_0 + BROADCAST - && cv->waiters_count == 0; - LeaveCriticalSection(&cv->waiters_count_lock); - - // Some thread called <pthread_cond_broadcast>. - if (last_waiter) - // We're the last waiter to be notified or to stop waiting, so - // reset the manual event. - ResetEvent(cv->events[BROADCAST]); - - // Reacquire the <external_mutex>. - EnterCriticalSection(external_mutex); - - return result == WAIT_TIMEOUT ? ETIMEDOUT : 0; -} - -typedef struct { - int dummy; -} pthread_mutexattr_t; //< Dummy - -int pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attr) -{ - InitializeCriticalSection(mutex); - return 0; -} - -int pthread_mutex_destroy(pthread_mutex_t* mutex) -{ - DeleteCriticalSection(mutex); - return 0; -} - -int pthread_mutex_lock(pthread_mutex_t* mutex) -{ - EnterCriticalSection(mutex); - return 0; -} - -int pthread_mutex_unlock(pthread_mutex_t* mutex) -{ - LeaveCriticalSection(mutex); - return 0; -} - -typedef struct { - int dummy; -} pthread_attr_t; - -typedef struct -{ - void *(*start_routine) (void *); - void* arg; -} pthread_internal_thread; - -unsigned int __stdcall ThreadProc(void* userdata) -{ - pthread_internal_thread* ud = (pthread_internal_thread*) userdata; - ud->start_routine(ud->arg); - - free(ud); - - return 0; -} - -int pthread_create(pthread_t* thread, const pthread_attr_t* attr, void *(*start_routine) (void *), void *arg) -{ - pthread_internal_thread* ud = (pthread_internal_thread*) malloc(sizeof(pthread_internal_thread)); - ud->start_routine = start_routine; - ud->arg = arg; - - *thread = (HANDLE) (_beginthreadex(NULL, 0, &ThreadProc, ud, 0, NULL)); - if (!*thread) - return 1; - - return 0; -} - -int pthread_join(pthread_t thread, void **value_ptr) -{ - WaitForSingleObject(thread, INFINITE); - CloseHandle(thread); - - return 0; -} - -#endif - -#include "chipmunk/chipmunk_private.h" -#include "chipmunk/cpHastySpace.h" - - -//MARK: ARM NEON Solver - -#if __ARM_NEON__ -#include <arm_neon.h> - -// Tested and known to work fine with Clang 3.0 and GCC 4.2 -// Doesn't work with Clang 1.6, and I have no idea why. -#if defined(__clang_major__) && __clang_major__ < 3 - #error Compiler not supported. -#endif - -#if CP_USE_DOUBLES - #if !__arm64 - #error Cannot use CP_USE_DOUBLES on 32 bit ARM. - #endif - - typedef float64_t cpFloat_t; - typedef float64x2_t cpFloatx2_t; - #define vld vld1q_f64 - #define vdup_n vdupq_n_f64 - #define vst vst1q_f64 - #define vst_lane vst1q_lane_f64 - #define vadd vaddq_f64 - #define vsub vsubq_f64 - #define vpadd vpaddq_f64 - #define vmul vmulq_f64 - #define vmul_n vmulq_n_f64 - #define vneg vnegq_f64 - #define vget_lane vgetq_lane_f64 - #define vset_lane vsetq_lane_f64 - #define vmin vminq_f64 - #define vmax vmaxq_f64 - #define vrev(__a) __builtin_shufflevector(__a, __a, 1, 0) -#else - typedef float32_t cpFloat_t; - typedef float32x2_t cpFloatx2_t; - #define vld vld1_f32 - #define vdup_n vdup_n_f32 - #define vst vst1_f32 - #define vst_lane vst1_lane_f32 - #define vadd vadd_f32 - #define vsub vsub_f32 - #define vpadd vpadd_f32 - #define vmul vmul_f32 - #define vmul_n vmul_n_f32 - #define vneg vneg_f32 - #define vget_lane vget_lane_f32 - #define vset_lane vset_lane_f32 - #define vmin vmin_f32 - #define vmax vmax_f32 - #define vrev vrev64_f32 -#endif - -// TODO could probably do better here, maybe using vcreate? -// especially for the constants -// Maybe use the {} notation for GCC/Clang? -static inline cpFloatx2_t -vmake(cpFloat_t x, cpFloat_t y) -{ -// cpFloatx2_t v = {}; -// v = vset_lane(x, v, 0); -// v = vset_lane(y, v, 1); -// -// return v; - - // This might not be super compatible, but all the NEON headers use it... - return (cpFloatx2_t){x, y}; -} - -static void -cpArbiterApplyImpulse_NEON(cpArbiter *arb) -{ - cpBody *a = arb->body_a; - cpBody *b = arb->body_b; - cpFloatx2_t surface_vr = vld((cpFloat_t *)&arb->surface_vr); - cpFloatx2_t n = vld((cpFloat_t *)&arb->n); - cpFloat_t friction = arb->u; - - int numContacts = arb->count; - struct cpContact *contacts = arb->contacts; - for(int i=0; i<numContacts; i++){ - struct cpContact *con = contacts + i; - cpFloatx2_t r1 = vld((cpFloat_t *)&con->r1); - cpFloatx2_t r2 = vld((cpFloat_t *)&con->r2); - - cpFloatx2_t perp = vmake(-1.0, 1.0); - cpFloatx2_t r1p = vmul(vrev(r1), perp); - cpFloatx2_t r2p = vmul(vrev(r2), perp); - - cpFloatx2_t vBias_a = vld((cpFloat_t *)&a->v_bias); - cpFloatx2_t vBias_b = vld((cpFloat_t *)&b->v_bias); - cpFloatx2_t wBias = vmake(a->w_bias, b->w_bias); - - cpFloatx2_t vb1 = vadd(vBias_a, vmul_n(r1p, vget_lane(wBias, 0))); - cpFloatx2_t vb2 = vadd(vBias_b, vmul_n(r2p, vget_lane(wBias, 1))); - cpFloatx2_t vbr = vsub(vb2, vb1); - - cpFloatx2_t v_a = vld((cpFloat_t *)&a->v); - cpFloatx2_t v_b = vld((cpFloat_t *)&b->v); - cpFloatx2_t w = vmake(a->w, b->w); - cpFloatx2_t v1 = vadd(v_a, vmul_n(r1p, vget_lane(w, 0))); - cpFloatx2_t v2 = vadd(v_b, vmul_n(r2p, vget_lane(w, 1))); - cpFloatx2_t vr = vsub(v2, v1); - - cpFloatx2_t vbn_vrn = vpadd(vmul(vbr, n), vmul(vr, n)); - - cpFloatx2_t v_offset = vmake(con->bias, -con->bounce); - cpFloatx2_t jOld = vmake(con->jBias, con->jnAcc); - cpFloatx2_t jbn_jn = vmul_n(vsub(v_offset, vbn_vrn), con->nMass); - jbn_jn = vmax(vadd(jOld, jbn_jn), vdup_n(0.0)); - cpFloatx2_t jApply = vsub(jbn_jn, jOld); - - cpFloatx2_t t = vmul(vrev(n), perp); - cpFloatx2_t vrt_tmp = vmul(vadd(vr, surface_vr), t); - cpFloatx2_t vrt = vpadd(vrt_tmp, vrt_tmp); - - cpFloatx2_t jtOld = {}; jtOld = vset_lane(con->jtAcc, jtOld, 0); - cpFloatx2_t jtMax = vrev(vmul_n(jbn_jn, friction)); - cpFloatx2_t jt = vmul_n(vrt, -con->tMass); - jt = vmax(vneg(jtMax), vmin(vadd(jtOld, jt), jtMax)); - cpFloatx2_t jtApply = vsub(jt, jtOld); - - cpFloatx2_t i_inv = vmake(-a->i_inv, b->i_inv); - cpFloatx2_t nperp = vmake(1.0, -1.0); - - cpFloatx2_t jBias = vmul_n(n, vget_lane(jApply, 0)); - cpFloatx2_t jBiasCross = vmul(vrev(jBias), nperp); - cpFloatx2_t biasCrosses = vpadd(vmul(r1, jBiasCross), vmul(r2, jBiasCross)); - wBias = vadd(wBias, vmul(i_inv, biasCrosses)); - - vBias_a = vsub(vBias_a, vmul_n(jBias, a->m_inv)); - vBias_b = vadd(vBias_b, vmul_n(jBias, b->m_inv)); - - cpFloatx2_t j = vadd(vmul_n(n, vget_lane(jApply, 1)), vmul_n(t, vget_lane(jtApply, 0))); - cpFloatx2_t jCross = vmul(vrev(j), nperp); - cpFloatx2_t crosses = vpadd(vmul(r1, jCross), vmul(r2, jCross)); - w = vadd(w, vmul(i_inv, crosses)); - - v_a = vsub(v_a, vmul_n(j, a->m_inv)); - v_b = vadd(v_b, vmul_n(j, b->m_inv)); - - // TODO would moving these earlier help pipeline them better? - vst((cpFloat_t *)&a->v_bias, vBias_a); - vst((cpFloat_t *)&b->v_bias, vBias_b); - vst_lane((cpFloat_t *)&a->w_bias, wBias, 0); - vst_lane((cpFloat_t *)&b->w_bias, wBias, 1); - - vst((cpFloat_t *)&a->v, v_a); - vst((cpFloat_t *)&b->v, v_b); - vst_lane((cpFloat_t *)&a->w, w, 0); - vst_lane((cpFloat_t *)&b->w, w, 1); - - vst_lane((cpFloat_t *)&con->jBias, jbn_jn, 0); - vst_lane((cpFloat_t *)&con->jnAcc, jbn_jn, 1); - vst_lane((cpFloat_t *)&con->jtAcc, jt, 0); - } -} - -#endif - -//MARK: PThreads - -// Right now using more than 2 threads probably wont help your performance any. -// If you are using a ridiculous number of iterations it could help though. -#define MAX_THREADS 2 - -struct ThreadContext { - pthread_t thread; - cpHastySpace *space; - unsigned long thread_num; -}; - -typedef void (*cpHastySpaceWorkFunction)(cpSpace *space, unsigned long worker, unsigned long worker_count); - -struct cpHastySpace { - cpSpace space; - - // Number of worker threads (including the main thread) - unsigned long num_threads; - - // Number of worker threads currently executing. (also including the main thread) - unsigned long num_working; - - // Number of constraints (plus contacts) that must exist per step to start the worker threads. - unsigned long constraint_count_threshold; - - pthread_mutex_t mutex; - pthread_cond_t cond_work, cond_resume; - - // Work function to invoke. - cpHastySpaceWorkFunction work; - - struct ThreadContext workers[MAX_THREADS - 1]; -}; - -static void * -WorkerThreadLoop(struct ThreadContext *context) -{ - cpHastySpace *hasty = context->space; - - unsigned long thread = context->thread_num; - unsigned long num_threads = hasty->num_threads; - - for(;;){ - pthread_mutex_lock(&hasty->mutex); { - if(--hasty->num_working == 0){ - pthread_cond_signal(&hasty->cond_resume); - } - - pthread_cond_wait(&hasty->cond_work, &hasty->mutex); - } pthread_mutex_unlock(&hasty->mutex); - - cpHastySpaceWorkFunction func = hasty->work; - if(func){ - hasty->work(&hasty->space, thread, num_threads); - } else { - break; - } - } - - return NULL; -} - -static void -RunWorkers(cpHastySpace *hasty, cpHastySpaceWorkFunction func) -{ - hasty->num_working = hasty->num_threads - 1; - hasty->work = func; - - if(hasty->num_working > 0){ - pthread_mutex_lock(&hasty->mutex); { - pthread_cond_broadcast(&hasty->cond_work); - } pthread_mutex_unlock(&hasty->mutex); - - func((cpSpace *)hasty, 0, hasty->num_threads); - - pthread_mutex_lock(&hasty->mutex); { - if(hasty->num_working > 0){ - pthread_cond_wait(&hasty->cond_resume, &hasty->mutex); - } - } pthread_mutex_unlock(&hasty->mutex); - } else { - func((cpSpace *)hasty, 0, hasty->num_threads); - } - - hasty->work = NULL; -} - -static void -Solver(cpSpace *space, unsigned long worker, unsigned long worker_count) -{ - cpArray *constraints = space->constraints; - cpArray *arbiters = space->arbiters; - - cpFloat dt = space->curr_dt; - unsigned long iterations = (space->iterations + worker_count - 1)/worker_count; - - for(unsigned long i=0; i<iterations; i++){ - for(int j=0; j<arbiters->num; j++){ - cpArbiter *arb = (cpArbiter *)arbiters->arr[j]; - #ifdef __ARM_NEON__ - cpArbiterApplyImpulse_NEON(arb); - #else - cpArbiterApplyImpulse(arb); - #endif - } - - for(int j=0; j<constraints->num; j++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[j]; - constraint->klass->applyImpulse(constraint, dt); - } - } -} - -//MARK: Thread Management Functions - -static void -HaltThreads(cpHastySpace *hasty) -{ - pthread_mutex_t *mutex = &hasty->mutex; - pthread_mutex_lock(mutex); { - hasty->work = NULL; // NULL work function means break and exit - pthread_cond_broadcast(&hasty->cond_work); - } pthread_mutex_unlock(mutex); - - for(unsigned long i=0; i<(hasty->num_threads-1); i++){ - pthread_join(hasty->workers[i].thread, NULL); - } -} - -void -cpHastySpaceSetThreads(cpSpace *space, unsigned long threads) -{ -#if TARGET_IPHONE_SIMULATOR == 1 - // Individual values appear to be written non-atomically when compiled as debug for the simulator. - // No idea why, so threads are disabled. - threads = 1; -#endif - - cpHastySpace *hasty = (cpHastySpace *)space; - HaltThreads(hasty); - -#ifdef __APPLE__ - if(threads == 0){ - size_t size = sizeof(threads); - sysctlbyname("hw.ncpu", &threads, &size, NULL, 0); - } -#else - if(threads == 0) threads = 1; -#endif - - hasty->num_threads = (threads < MAX_THREADS ? threads : MAX_THREADS); - hasty->num_working = hasty->num_threads - 1; - - // Create the worker threads and wait for them to signal ready. - if(hasty->num_working > 0){ - pthread_mutex_lock(&hasty->mutex); - for(unsigned long i=0; i<(hasty->num_threads-1); i++){ - hasty->workers[i].space = hasty; - hasty->workers[i].thread_num = i + 1; - - pthread_create(&hasty->workers[i].thread, NULL, (void*(*)(void*))WorkerThreadLoop, &hasty->workers[i]); - } - - pthread_cond_wait(&hasty->cond_resume, &hasty->mutex); - pthread_mutex_unlock(&hasty->mutex); - } -} - -unsigned long -cpHastySpaceGetThreads(cpSpace *space) -{ - return ((cpHastySpace *)space)->num_threads; -} - -//MARK: Overriden cpSpace Functions. - -cpSpace * -cpHastySpaceNew(void) -{ - cpHastySpace *hasty = (cpHastySpace *)cpcalloc(1, sizeof(cpHastySpace)); - cpSpaceInit((cpSpace *)hasty); - - pthread_mutex_init(&hasty->mutex, NULL); - pthread_cond_init(&hasty->cond_work, NULL); - pthread_cond_init(&hasty->cond_resume, NULL); - - // TODO magic number, should test this more thoroughly. - hasty->constraint_count_threshold = 50; - - // Default to 1 thread for determinism. - hasty->num_threads = 1; - cpHastySpaceSetThreads((cpSpace *)hasty, 1); - - return (cpSpace *)hasty; -} - -void -cpHastySpaceFree(cpSpace *space) -{ - cpHastySpace *hasty = (cpHastySpace *)space; - - HaltThreads(hasty); - - pthread_mutex_destroy(&hasty->mutex); - pthread_cond_destroy(&hasty->cond_work); - pthread_cond_destroy(&hasty->cond_resume); - - cpSpaceFree(space); -} - -void -cpHastySpaceStep(cpSpace *space, cpFloat dt) -{ - // don't step if the timestep is 0! - if(dt == 0.0f) return; - - space->stamp++; - - cpFloat prev_dt = space->curr_dt; - space->curr_dt = dt; - - cpArray *bodies = space->dynamicBodies; - cpArray *constraints = space->constraints; - cpArray *arbiters = space->arbiters; - - // Reset and empty the arbiter list. - for(int i=0; i<arbiters->num; i++){ - cpArbiter *arb = (cpArbiter *)arbiters->arr[i]; - arb->state = CP_ARBITER_STATE_NORMAL; - - // If both bodies are awake, unthread the arbiter from the contact graph. - if(!cpBodyIsSleeping(arb->body_a) && !cpBodyIsSleeping(arb->body_b)){ - cpArbiterUnthread(arb); - } - } - arbiters->num = 0; - - cpSpaceLock(space); { - // Integrate positions - for(int i=0; i<bodies->num; i++){ - cpBody *body = (cpBody *)bodies->arr[i]; - body->position_func(body, dt); - } - - // Find colliding pairs. - cpSpacePushFreshContactBuffer(space); - cpSpatialIndexEach(space->dynamicShapes, (cpSpatialIndexIteratorFunc)cpShapeUpdateFunc, NULL); - cpSpatialIndexReindexQuery(space->dynamicShapes, (cpSpatialIndexQueryFunc)cpSpaceCollideShapes, space); - } cpSpaceUnlock(space, cpFalse); - - // Rebuild the contact graph (and detect sleeping components if sleeping is enabled) - cpSpaceProcessComponents(space, dt); - - cpSpaceLock(space); { - // Clear out old cached arbiters and call separate callbacks - cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)cpSpaceArbiterSetFilter, space); - - // Prestep the arbiters and constraints. - cpFloat slop = space->collisionSlop; - cpFloat biasCoef = 1.0f - cpfpow(space->collisionBias, dt); - for(int i=0; i<arbiters->num; i++){ - cpArbiterPreStep((cpArbiter *)arbiters->arr[i], dt, slop, biasCoef); - } - - for(int i=0; i<constraints->num; i++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; - - cpConstraintPreSolveFunc preSolve = constraint->preSolve; - if(preSolve) preSolve(constraint, space); - - constraint->klass->preStep(constraint, dt); - } - - // Integrate velocities. - cpFloat damping = cpfpow(space->damping, dt); - cpVect gravity = space->gravity; - for(int i=0; i<bodies->num; i++){ - cpBody *body = (cpBody *)bodies->arr[i]; - body->velocity_func(body, gravity, damping, dt); - } - - // Apply cached impulses - cpFloat dt_coef = (prev_dt == 0.0f ? 0.0f : dt/prev_dt); - for(int i=0; i<arbiters->num; i++){ - cpArbiterApplyCachedImpulse((cpArbiter *)arbiters->arr[i], dt_coef); - } - - for(int i=0; i<constraints->num; i++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; - constraint->klass->applyCachedImpulse(constraint, dt_coef); - } - - // Run the impulse solver. - cpHastySpace *hasty = (cpHastySpace *)space; - if((unsigned long)(arbiters->num + constraints->num) > hasty->constraint_count_threshold){ - RunWorkers(hasty, Solver); - } else { - Solver(space, 0, 1); - } - - // Run the constraint post-solve callbacks - for(int i=0; i<constraints->num; i++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; - - cpConstraintPostSolveFunc postSolve = constraint->postSolve; - if(postSolve) postSolve(constraint, space); - } - - // run the post-solve callbacks - for(int i=0; i<arbiters->num; i++){ - cpArbiter *arb = (cpArbiter *) arbiters->arr[i]; - - cpCollisionHandler *handler = arb->handler; - handler->postSolveFunc(arb, space, handler->userData); - } - } cpSpaceUnlock(space, cpTrue); -} diff --git a/thirdparty/src/chipmunk/cpMarch.c b/thirdparty/src/chipmunk/cpMarch.c deleted file mode 100644 index c666bd2e6..000000000 --- a/thirdparty/src/chipmunk/cpMarch.c +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2013 Howling Moon Software. All rights reserved. -// See http://chipmunk2d.net/legal.php for more information. - -#include <stdlib.h> -#include <stdio.h> -#include <math.h> - -#include "chipmunk/chipmunk.h" -#include "chipmunk/cpMarch.h" - - -typedef void (*cpMarchCellFunc)( - cpFloat t, cpFloat a, cpFloat b, cpFloat c, cpFloat d, - cpFloat x0, cpFloat x1, cpFloat y0, cpFloat y1, - cpMarchSegmentFunc segment, void *segment_data -); - -// The looping and sample caching code is shared between cpMarchHard() and cpMarchSoft(). -static void -cpMarchCells( - cpBB bb, unsigned long x_samples, unsigned long y_samples, cpFloat t, - cpMarchSegmentFunc segment, void *segment_data, - cpMarchSampleFunc sample, void *sample_data, - cpMarchCellFunc cell -){ - cpFloat x_denom = 1.0/(cpFloat)(x_samples - 1); - cpFloat y_denom = 1.0/(cpFloat)(y_samples - 1); - - // TODO range assertions and short circuit for 0 sized windows. - - // Keep a copy of the previous row to avoid double lookups. - cpFloat *buffer = (cpFloat *)cpcalloc(x_samples, sizeof(cpFloat)); - for(unsigned long i=0; i<x_samples; i++) buffer[i] = sample(cpv(cpflerp(bb.l, bb.r, i*x_denom), bb.b), sample_data); - - for(unsigned long j=0; j<y_samples-1; j++){ - cpFloat y0 = cpflerp(bb.b, bb.t, (j+0)*y_denom); - cpFloat y1 = cpflerp(bb.b, bb.t, (j+1)*y_denom); - - cpFloat a, b = buffer[0]; - cpFloat c, d = sample(cpv(bb.l, y1), sample_data); - buffer[0] = d; - - for(unsigned long i=0; i<x_samples-1; i++){ - cpFloat x0 = cpflerp(bb.l, bb.r, (i+0)*x_denom); - cpFloat x1 = cpflerp(bb.l, bb.r, (i+1)*x_denom); - - a = b, b = buffer[i + 1]; - c = d, d = sample(cpv(x1, y1), sample_data); - buffer[i + 1] = d; - - cell(t, a, b, c, d, x0, x1, y0, y1, segment, segment_data); - } - } - - cpfree(buffer); -} - - -// TODO should flip this around eventually. -static inline void -seg(cpVect v0, cpVect v1, cpMarchSegmentFunc f, void *data) -{ - if(!cpveql(v0, v1)) f(v1, v0, data); -} - -// Lerps between two positions based on their sample values. -static inline cpFloat -midlerp(cpFloat x0, cpFloat x1, cpFloat s0, cpFloat s1, cpFloat t) -{ - return cpflerp(x0, x1, (t - s0)/(s1 - s0)); -} - -static void -cpMarchCellSoft( - cpFloat t, cpFloat a, cpFloat b, cpFloat c, cpFloat d, - cpFloat x0, cpFloat x1, cpFloat y0, cpFloat y1, - cpMarchSegmentFunc segment, void *segment_data -){ - // TODO this switch part is super expensive, can it be NEONized? - switch((a>t)<<0 | (b>t)<<1 | (c>t)<<2 | (d>t)<<3){ - case 0x1: seg(cpv(x0, midlerp(y0,y1,a,c,t)), cpv(midlerp(x0,x1,a,b,t), y0), segment, segment_data); break; - case 0x2: seg(cpv(midlerp(x0,x1,a,b,t), y0), cpv(x1, midlerp(y0,y1,b,d,t)), segment, segment_data); break; - case 0x3: seg(cpv(x0, midlerp(y0,y1,a,c,t)), cpv(x1, midlerp(y0,y1,b,d,t)), segment, segment_data); break; - case 0x4: seg(cpv(midlerp(x0,x1,c,d,t), y1), cpv(x0, midlerp(y0,y1,a,c,t)), segment, segment_data); break; - case 0x5: seg(cpv(midlerp(x0,x1,c,d,t), y1), cpv(midlerp(x0,x1,a,b,t), y0), segment, segment_data); break; - case 0x6: seg(cpv(midlerp(x0,x1,a,b,t), y0), cpv(x1, midlerp(y0,y1,b,d,t)), segment, segment_data); - seg(cpv(midlerp(x0,x1,c,d,t), y1), cpv(x0, midlerp(y0,y1,a,c,t)), segment, segment_data); break; - case 0x7: seg(cpv(midlerp(x0,x1,c,d,t), y1), cpv(x1, midlerp(y0,y1,b,d,t)), segment, segment_data); break; - case 0x8: seg(cpv(x1, midlerp(y0,y1,b,d,t)), cpv(midlerp(x0,x1,c,d,t), y1), segment, segment_data); break; - case 0x9: seg(cpv(x0, midlerp(y0,y1,a,c,t)), cpv(midlerp(x0,x1,a,b,t), y0), segment, segment_data); - seg(cpv(x1, midlerp(y0,y1,b,d,t)), cpv(midlerp(x0,x1,c,d,t), y1), segment, segment_data); break; - case 0xA: seg(cpv(midlerp(x0,x1,a,b,t), y0), cpv(midlerp(x0,x1,c,d,t), y1), segment, segment_data); break; - case 0xB: seg(cpv(x0, midlerp(y0,y1,a,c,t)), cpv(midlerp(x0,x1,c,d,t), y1), segment, segment_data); break; - case 0xC: seg(cpv(x1, midlerp(y0,y1,b,d,t)), cpv(x0, midlerp(y0,y1,a,c,t)), segment, segment_data); break; - case 0xD: seg(cpv(x1, midlerp(y0,y1,b,d,t)), cpv(midlerp(x0,x1,a,b,t), y0), segment, segment_data); break; - case 0xE: seg(cpv(midlerp(x0,x1,a,b,t), y0), cpv(x0, midlerp(y0,y1,a,c,t)), segment, segment_data); break; - default: break; // 0x0 and 0xF - } -} - -void -cpMarchSoft( - cpBB bb, unsigned long x_samples, unsigned long y_samples, cpFloat t, - cpMarchSegmentFunc segment, void *segment_data, - cpMarchSampleFunc sample, void *sample_data -){ - cpMarchCells(bb, x_samples, y_samples, t, segment, segment_data, sample, sample_data, cpMarchCellSoft); -} - - -// TODO should flip this around eventually. -static inline void -segs(cpVect a, cpVect b, cpVect c, cpMarchSegmentFunc f, void *data) -{ - seg(b, c, f, data); - seg(a, b, f, data); -} - -static void -cpMarchCellHard( - cpFloat t, cpFloat a, cpFloat b, cpFloat c, cpFloat d, - cpFloat x0, cpFloat x1, cpFloat y0, cpFloat y1, - cpMarchSegmentFunc segment, void *segment_data -){ - // midpoints - cpFloat xm = cpflerp(x0, x1, 0.5f); - cpFloat ym = cpflerp(y0, y1, 0.5f); - - switch((a>t)<<0 | (b>t)<<1 | (c>t)<<2 | (d>t)<<3){ - case 0x1: segs(cpv(x0, ym), cpv(xm, ym), cpv(xm, y0), segment, segment_data); break; - case 0x2: segs(cpv(xm, y0), cpv(xm, ym), cpv(x1, ym), segment, segment_data); break; - case 0x3: seg(cpv(x0, ym), cpv(x1, ym), segment, segment_data); break; - case 0x4: segs(cpv(xm, y1), cpv(xm, ym), cpv(x0, ym), segment, segment_data); break; - case 0x5: seg(cpv(xm, y1), cpv(xm, y0), segment, segment_data); break; - case 0x6: segs(cpv(xm, y0), cpv(xm, ym), cpv(x0, ym), segment, segment_data); - segs(cpv(xm, y1), cpv(xm, ym), cpv(x1, ym), segment, segment_data); break; - case 0x7: segs(cpv(xm, y1), cpv(xm, ym), cpv(x1, ym), segment, segment_data); break; - case 0x8: segs(cpv(x1, ym), cpv(xm, ym), cpv(xm, y1), segment, segment_data); break; - case 0x9: segs(cpv(x1, ym), cpv(xm, ym), cpv(xm, y0), segment, segment_data); - segs(cpv(x0, ym), cpv(xm, ym), cpv(xm, y1), segment, segment_data); break; - case 0xA: seg(cpv(xm, y0), cpv(xm, y1), segment, segment_data); break; - case 0xB: segs(cpv(x0, ym), cpv(xm, ym), cpv(xm, y1), segment, segment_data); break; - case 0xC: seg(cpv(x1, ym), cpv(x0, ym), segment, segment_data); break; - case 0xD: segs(cpv(x1, ym), cpv(xm, ym), cpv(xm, y0), segment, segment_data); break; - case 0xE: segs(cpv(xm, y0), cpv(xm, ym), cpv(x0, ym), segment, segment_data); break; - default: break; // 0x0 and 0xF - } -} - -void -cpMarchHard( - cpBB bb, unsigned long x_samples, unsigned long y_samples, cpFloat t, - cpMarchSegmentFunc segment, void *segment_data, - cpMarchSampleFunc sample, void *sample_data -){ - cpMarchCells(bb, x_samples, y_samples, t, segment, segment_data, sample, sample_data, cpMarchCellHard); -} diff --git a/thirdparty/src/chipmunk/cpPinJoint.c b/thirdparty/src/chipmunk/cpPinJoint.c deleted file mode 100644 index 545e78bf8..000000000 --- a/thirdparty/src/chipmunk/cpPinJoint.c +++ /dev/null @@ -1,172 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -static void -preStep(cpPinJoint *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - joint->r1 = cpTransformVect(a->transform, cpvsub(joint->anchorA, a->cog)); - joint->r2 = cpTransformVect(b->transform, cpvsub(joint->anchorB, b->cog)); - - cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1)); - cpFloat dist = cpvlength(delta); - joint->n = cpvmult(delta, 1.0f/(dist ? dist : (cpFloat)INFINITY)); - - // calculate mass normal - joint->nMass = 1.0f/k_scalar(a, b, joint->r1, joint->r2, joint->n); - - // calculate bias velocity - cpFloat maxBias = joint->constraint.maxBias; - joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*(dist - joint->dist)/dt, -maxBias, maxBias); -} - -static void -applyCachedImpulse(cpPinJoint *joint, cpFloat dt_coef) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpVect j = cpvmult(joint->n, joint->jnAcc*dt_coef); - apply_impulses(a, b, joint->r1, joint->r2, j); -} - -static void -applyImpulse(cpPinJoint *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - cpVect n = joint->n; - - // compute relative velocity - cpFloat vrn = normal_relative_velocity(a, b, joint->r1, joint->r2, n); - - cpFloat jnMax = joint->constraint.maxForce*dt; - - // compute normal impulse - cpFloat jn = (joint->bias - vrn)*joint->nMass; - cpFloat jnOld = joint->jnAcc; - joint->jnAcc = cpfclamp(jnOld + jn, -jnMax, jnMax); - jn = joint->jnAcc - jnOld; - - // apply impulse - apply_impulses(a, b, joint->r1, joint->r2, cpvmult(n, jn)); -} - -static cpFloat -getImpulse(cpPinJoint *joint) -{ - return cpfabs(joint->jnAcc); -} - -static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, -}; - - -cpPinJoint * -cpPinJointAlloc(void) -{ - return (cpPinJoint *)cpcalloc(1, sizeof(cpPinJoint)); -} - -cpPinJoint * -cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB) -{ - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->anchorA = anchorA; - joint->anchorB = anchorB; - - // STATIC_BODY_CHECK - cpVect p1 = (a ? cpTransformPoint(a->transform, anchorA) : anchorA); - cpVect p2 = (b ? cpTransformPoint(b->transform, anchorB) : anchorB); - joint->dist = cpvlength(cpvsub(p2, p1)); - - cpAssertWarn(joint->dist > 0.0, "You created a 0 length pin joint. A pivot joint will be much more stable."); - - joint->jnAcc = 0.0f; - - return joint; -} - -cpConstraint * -cpPinJointNew(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB) -{ - return (cpConstraint *)cpPinJointInit(cpPinJointAlloc(), a, b, anchorA, anchorB); -} - -cpBool -cpConstraintIsPinJoint(const cpConstraint *constraint) -{ - return (constraint->klass == &klass); -} - -cpVect -cpPinJointGetAnchorA(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsPinJoint(constraint), "Constraint is not a pin joint."); - return ((cpPinJoint *)constraint)->anchorA; -} - -void -cpPinJointSetAnchorA(cpConstraint *constraint, cpVect anchorA) -{ - cpAssertHard(cpConstraintIsPinJoint(constraint), "Constraint is not a pin joint."); - cpConstraintActivateBodies(constraint); - ((cpPinJoint *)constraint)->anchorA = anchorA; -} - -cpVect -cpPinJointGetAnchorB(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsPinJoint(constraint), "Constraint is not a pin joint."); - return ((cpPinJoint *)constraint)->anchorB; -} - -void -cpPinJointSetAnchorB(cpConstraint *constraint, cpVect anchorB) -{ - cpAssertHard(cpConstraintIsPinJoint(constraint), "Constraint is not a pin joint."); - cpConstraintActivateBodies(constraint); - ((cpPinJoint *)constraint)->anchorB = anchorB; -} - -cpFloat -cpPinJointGetDist(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsPinJoint(constraint), "Constraint is not a pin joint."); - return ((cpPinJoint *)constraint)->dist; -} - -void -cpPinJointSetDist(cpConstraint *constraint, cpFloat dist) -{ - cpAssertHard(cpConstraintIsPinJoint(constraint), "Constraint is not a pin joint."); - cpConstraintActivateBodies(constraint); - ((cpPinJoint *)constraint)->dist = dist; -} diff --git a/thirdparty/src/chipmunk/cpPivotJoint.c b/thirdparty/src/chipmunk/cpPivotJoint.c deleted file mode 100644 index e45ba072b..000000000 --- a/thirdparty/src/chipmunk/cpPivotJoint.c +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -static void -preStep(cpPivotJoint *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - joint->r1 = cpTransformVect(a->transform, cpvsub(joint->anchorA, a->cog)); - joint->r2 = cpTransformVect(b->transform, cpvsub(joint->anchorB, b->cog)); - - // Calculate mass tensor - joint-> k = k_tensor(a, b, joint->r1, joint->r2); - - // calculate bias velocity - cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1)); - joint->bias = cpvclamp(cpvmult(delta, -bias_coef(joint->constraint.errorBias, dt)/dt), joint->constraint.maxBias); -} - -static void -applyCachedImpulse(cpPivotJoint *joint, cpFloat dt_coef) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - apply_impulses(a, b, joint->r1, joint->r2, cpvmult(joint->jAcc, dt_coef)); -} - -static void -applyImpulse(cpPivotJoint *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpVect r1 = joint->r1; - cpVect r2 = joint->r2; - - // compute relative velocity - cpVect vr = relative_velocity(a, b, r1, r2); - - // compute normal impulse - cpVect j = cpMat2x2Transform(joint->k, cpvsub(joint->bias, vr)); - cpVect jOld = joint->jAcc; - joint->jAcc = cpvclamp(cpvadd(joint->jAcc, j), joint->constraint.maxForce*dt); - j = cpvsub(joint->jAcc, jOld); - - // apply impulse - apply_impulses(a, b, joint->r1, joint->r2, j); -} - -static cpFloat -getImpulse(cpConstraint *joint) -{ - return cpvlength(((cpPivotJoint *)joint)->jAcc); -} - -static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, -}; - -cpPivotJoint * -cpPivotJointAlloc(void) -{ - return (cpPivotJoint *)cpcalloc(1, sizeof(cpPivotJoint)); -} - -cpPivotJoint * -cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB) -{ - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->anchorA = anchorA; - joint->anchorB = anchorB; - - joint->jAcc = cpvzero; - - return joint; -} - -cpConstraint * -cpPivotJointNew2(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB) -{ - return (cpConstraint *)cpPivotJointInit(cpPivotJointAlloc(), a, b, anchorA, anchorB); -} - -cpConstraint * -cpPivotJointNew(cpBody *a, cpBody *b, cpVect pivot) -{ - cpVect anchorA = (a ? cpBodyWorldToLocal(a, pivot) : pivot); - cpVect anchorB = (b ? cpBodyWorldToLocal(b, pivot) : pivot); - return cpPivotJointNew2(a, b, anchorA, anchorB); -} - -cpBool -cpConstraintIsPivotJoint(const cpConstraint *constraint) -{ - return (constraint->klass == &klass); -} - -cpVect -cpPivotJointGetAnchorA(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsPivotJoint(constraint), "Constraint is not a pivot joint."); - return ((cpPivotJoint *)constraint)->anchorA; -} - -void -cpPivotJointSetAnchorA(cpConstraint *constraint, cpVect anchorA) -{ - cpAssertHard(cpConstraintIsPivotJoint(constraint), "Constraint is not a pivot joint."); - cpConstraintActivateBodies(constraint); - ((cpPivotJoint *)constraint)->anchorA = anchorA; -} - -cpVect -cpPivotJointGetAnchorB(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsPivotJoint(constraint), "Constraint is not a pivot joint."); - return ((cpPivotJoint *)constraint)->anchorB; -} - -void -cpPivotJointSetAnchorB(cpConstraint *constraint, cpVect anchorB) -{ - cpAssertHard(cpConstraintIsPivotJoint(constraint), "Constraint is not a pivot joint."); - cpConstraintActivateBodies(constraint); - ((cpPivotJoint *)constraint)->anchorB = anchorB; -} diff --git a/thirdparty/src/chipmunk/cpPolyShape.c b/thirdparty/src/chipmunk/cpPolyShape.c deleted file mode 100644 index db68cdc3a..000000000 --- a/thirdparty/src/chipmunk/cpPolyShape.c +++ /dev/null @@ -1,323 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" -#include "chipmunk/chipmunk_unsafe.h" - -cpPolyShape * -cpPolyShapeAlloc(void) -{ - return (cpPolyShape *)cpcalloc(1, sizeof(cpPolyShape)); -} - -static void -cpPolyShapeDestroy(cpPolyShape *poly) -{ - if(poly->count > CP_POLY_SHAPE_INLINE_ALLOC){ - cpfree(poly->planes); - } -} - -static cpBB -cpPolyShapeCacheData(cpPolyShape *poly, cpTransform transform) -{ - int count = poly->count; - struct cpSplittingPlane *dst = poly->planes; - struct cpSplittingPlane *src = dst + count; - - cpFloat l = (cpFloat)INFINITY, r = -(cpFloat)INFINITY; - cpFloat b = (cpFloat)INFINITY, t = -(cpFloat)INFINITY; - - for(int i=0; i<count; i++){ - cpVect v = cpTransformPoint(transform, src[i].v0); - cpVect n = cpTransformVect(transform, src[i].n); - - dst[i].v0 = v; - dst[i].n = n; - - l = cpfmin(l, v.x); - r = cpfmax(r, v.x); - b = cpfmin(b, v.y); - t = cpfmax(t, v.y); - } - - cpFloat radius = poly->r; - return (poly->shape.bb = cpBBNew(l - radius, b - radius, r + radius, t + radius)); -} - -static void -cpPolyShapePointQuery(cpPolyShape *poly, cpVect p, cpPointQueryInfo *info){ - int count = poly->count; - struct cpSplittingPlane *planes = poly->planes; - cpFloat r = poly->r; - - cpVect v0 = planes[count - 1].v0; - cpFloat minDist = INFINITY; - cpVect closestPoint = cpvzero; - cpVect closestNormal = cpvzero; - cpBool outside = cpFalse; - - for(int i=0; i<count; i++){ - cpVect v1 = planes[i].v0; - outside = outside || (cpvdot(planes[i].n, cpvsub(p,v1)) > 0.0f); - - cpVect closest = cpClosetPointOnSegment(p, v0, v1); - - cpFloat dist = cpvdist(p, closest); - if(dist < minDist){ - minDist = dist; - closestPoint = closest; - closestNormal = planes[i].n; - } - - v0 = v1; - } - - cpFloat dist = (outside ? minDist : -minDist); - cpVect g = cpvmult(cpvsub(p, closestPoint), 1.0f/dist); - - info->shape = (cpShape *)poly; - info->point = cpvadd(closestPoint, cpvmult(g, r)); - info->distance = dist - r; - - // Use the normal of the closest segment if the distance is small. - info->gradient = (minDist > MAGIC_EPSILON ? g : closestNormal); -} - -static void -cpPolyShapeSegmentQuery(cpPolyShape *poly, cpVect a, cpVect b, cpFloat r2, cpSegmentQueryInfo *info) -{ - struct cpSplittingPlane *planes = poly->planes; - int count = poly->count; - cpFloat r = poly->r; - cpFloat rsum = r + r2; - - for(int i=0; i<count; i++){ - cpVect n = planes[i].n; - cpFloat an = cpvdot(a, n); - cpFloat d = an - cpvdot(planes[i].v0, n) - rsum; - if(d < 0.0f) continue; - - cpFloat bn = cpvdot(b, n); - cpFloat t = d/(an - bn); - if(t < 0.0f || 1.0f < t) continue; - - cpVect point = cpvlerp(a, b, t); - cpFloat dt = cpvcross(n, point); - cpFloat dtMin = cpvcross(n, planes[(i - 1 + count)%count].v0); - cpFloat dtMax = cpvcross(n, planes[i].v0); - - if(dtMin <= dt && dt <= dtMax){ - info->shape = (cpShape *)poly; - info->point = cpvsub(cpvlerp(a, b, t), cpvmult(n, r2)); - info->normal = n; - info->alpha = t; - } - } - - // Also check against the beveled vertexes. - if(rsum > 0.0f){ - for(int i=0; i<count; i++){ - cpSegmentQueryInfo circle_info = {NULL, b, cpvzero, 1.0f}; - CircleSegmentQuery(&poly->shape, planes[i].v0, r, a, b, r2, &circle_info); - if(circle_info.alpha < info->alpha) (*info) = circle_info; - } - } -} - -static void -SetVerts(cpPolyShape *poly, int count, const cpVect *verts) -{ - poly->count = count; - if(count <= CP_POLY_SHAPE_INLINE_ALLOC){ - poly->planes = poly->_planes; - } else { - poly->planes = (struct cpSplittingPlane *)cpcalloc(2*count, sizeof(struct cpSplittingPlane)); - } - - for(int i=0; i<count; i++){ - cpVect a = verts[(i - 1 + count)%count]; - cpVect b = verts[i]; - cpVect n = cpvnormalize(cpvrperp(cpvsub(b, a))); - - poly->planes[i + count].v0 = b; - poly->planes[i + count].n = n; - } -} - -static struct cpShapeMassInfo -cpPolyShapeMassInfo(cpFloat mass, int count, const cpVect *verts, cpFloat radius) -{ - // TODO moment is approximate due to radius. - - cpVect centroid = cpCentroidForPoly(count, verts); - struct cpShapeMassInfo info = { - mass, cpMomentForPoly(1.0f, count, verts, cpvneg(centroid), radius), - centroid, - cpAreaForPoly(count, verts, radius), - }; - - return info; -} - -static const cpShapeClass polyClass = { - CP_POLY_SHAPE, - (cpShapeCacheDataImpl)cpPolyShapeCacheData, - (cpShapeDestroyImpl)cpPolyShapeDestroy, - (cpShapePointQueryImpl)cpPolyShapePointQuery, - (cpShapeSegmentQueryImpl)cpPolyShapeSegmentQuery, -}; - -cpPolyShape * -cpPolyShapeInit(cpPolyShape *poly, cpBody *body, int count, const cpVect *verts, cpTransform transform, cpFloat radius) -{ - cpVect *hullVerts = (cpVect *)alloca(count*sizeof(cpVect)); - - // Transform the verts before building the hull in case of a negative scale. - for(int i=0; i<count; i++) hullVerts[i] = cpTransformPoint(transform, verts[i]); - - unsigned int hullCount = cpConvexHull(count, hullVerts, hullVerts, NULL, 0.0); - return cpPolyShapeInitRaw(poly, body, hullCount, hullVerts, radius); -} - -cpPolyShape * -cpPolyShapeInitRaw(cpPolyShape *poly, cpBody *body, int count, const cpVect *verts, cpFloat radius) -{ - cpShapeInit((cpShape *)poly, &polyClass, body, cpPolyShapeMassInfo(0.0f, count, verts, radius)); - - SetVerts(poly, count, verts); - poly->r = radius; - - return poly; -} - -cpShape * -cpPolyShapeNew(cpBody *body, int count, const cpVect *verts, cpTransform transform, cpFloat radius) -{ - return (cpShape *)cpPolyShapeInit(cpPolyShapeAlloc(), body, count, verts, transform, radius); -} - -cpShape * -cpPolyShapeNewRaw(cpBody *body, int count, const cpVect *verts, cpFloat radius) -{ - return (cpShape *)cpPolyShapeInitRaw(cpPolyShapeAlloc(), body, count, verts, radius); -} - -cpPolyShape * -cpBoxShapeInit(cpPolyShape *poly, cpBody *body, cpFloat width, cpFloat height, cpFloat radius) -{ - cpFloat hw = width/2.0f; - cpFloat hh = height/2.0f; - - return cpBoxShapeInit2(poly, body, cpBBNew(-hw, -hh, hw, hh), radius); -} - -cpPolyShape * -cpBoxShapeInit2(cpPolyShape *poly, cpBody *body, cpBB box, cpFloat radius) -{ - cpVect verts[] = { - cpv(box.r, box.b), - cpv(box.r, box.t), - cpv(box.l, box.t), - cpv(box.l, box.b), - }; - - return cpPolyShapeInitRaw(poly, body, 4, verts, radius); -} - -cpShape * -cpBoxShapeNew(cpBody *body, cpFloat width, cpFloat height, cpFloat radius) -{ - return (cpShape *)cpBoxShapeInit(cpPolyShapeAlloc(), body, width, height, radius); -} - -cpShape * -cpBoxShapeNew2(cpBody *body, cpBB box, cpFloat radius) -{ - return (cpShape *)cpBoxShapeInit2(cpPolyShapeAlloc(), body, box, radius); -} - -int -cpPolyShapeGetCount(const cpShape *shape) -{ - cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape."); - return ((cpPolyShape *)shape)->count; -} - -cpVect -cpPolyShapeGetVert(const cpShape *shape, int i) -{ - cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape."); - - int count = cpPolyShapeGetCount(shape); - cpAssertHard(0 <= i && i < count, "Index out of range."); - - return ((cpPolyShape *)shape)->planes[i + count].v0; -} - -cpFloat -cpPolyShapeGetRadius(const cpShape *shape) -{ - cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape."); - return ((cpPolyShape *)shape)->r; -} - -// Unsafe API (chipmunk_unsafe.h) - -void -cpPolyShapeSetVerts(cpShape *shape, int count, cpVect *verts, cpTransform transform) -{ - cpVect *hullVerts = (cpVect *)alloca(count*sizeof(cpVect)); - - // Transform the verts before building the hull in case of a negative scale. - for(int i=0; i<count; i++) hullVerts[i] = cpTransformPoint(transform, verts[i]); - - unsigned int hullCount = cpConvexHull(count, hullVerts, hullVerts, NULL, 0.0); - cpPolyShapeSetVertsRaw(shape, hullCount, hullVerts); -} - -void -cpPolyShapeSetVertsRaw(cpShape *shape, int count, cpVect *verts) -{ - cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape."); - cpPolyShape *poly = (cpPolyShape *)shape; - cpPolyShapeDestroy(poly); - - SetVerts(poly, count, verts); - - cpFloat mass = shape->massInfo.m; - shape->massInfo = cpPolyShapeMassInfo(shape->massInfo.m, count, verts, poly->r); - if(mass > 0.0f) cpBodyAccumulateMassFromShapes(shape->body); -} - -void -cpPolyShapeSetRadius(cpShape *shape, cpFloat radius) -{ - cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape."); - cpPolyShape *poly = (cpPolyShape *)shape; - poly->r = radius; - - - // TODO radius is not handled by moment/area -// cpFloat mass = shape->massInfo.m; -// shape->massInfo = cpPolyShapeMassInfo(shape->massInfo.m, poly->count, poly->verts, poly->r); -// if(mass > 0.0f) cpBodyAccumulateMassFromShapes(shape->body); -} diff --git a/thirdparty/src/chipmunk/cpPolyline.c b/thirdparty/src/chipmunk/cpPolyline.c deleted file mode 100644 index 47b8be97e..000000000 --- a/thirdparty/src/chipmunk/cpPolyline.c +++ /dev/null @@ -1,652 +0,0 @@ -// Copyright 2013 Howling Moon Software. All rights reserved. -// See http://chipmunk2d.net/legal.php for more information. - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <math.h> - -#include "chipmunk/chipmunk_private.h" -#include "chipmunk/cpPolyline.h" - - -static inline int Next(int i, int count){return (i+1)%count;} - -//MARK: Polylines - -#define DEFAULT_POLYLINE_CAPACITY 16 - -static int -cpPolylineSizeForCapacity(int capacity) -{ - return sizeof(cpPolyline) + capacity*sizeof(cpVect); -} - -static cpPolyline * -cpPolylineMake(int capacity) -{ - capacity = (capacity > DEFAULT_POLYLINE_CAPACITY ? capacity : DEFAULT_POLYLINE_CAPACITY); - - cpPolyline *line = (cpPolyline *)cpcalloc(1, cpPolylineSizeForCapacity(capacity)); - line->count = 0; - line->capacity = capacity; - - return line; -} - -static cpPolyline * -cpPolylineMake2(int capacity, cpVect a, cpVect b) -{ - cpPolyline *line = cpPolylineMake(capacity); - line->count = 2; - line->verts[0] = a; - line->verts[1] = b; - - return line; -} - -static cpPolyline * -cpPolylineShrink(cpPolyline *line) -{ - line->capacity = line->count; - return (cpPolyline*) cprealloc(line, cpPolylineSizeForCapacity(line->count)); -} - -void -cpPolylineFree(cpPolyline *line) -{ - cpfree(line); -} - -// Grow the allocated memory for a polyline. -static cpPolyline * -cpPolylineGrow(cpPolyline *line, int count) -{ - line->count += count; - - int capacity = line->capacity; - while(line->count > capacity) capacity *= 2; - - if(line->capacity < capacity){ - line->capacity = capacity; - line = (cpPolyline*) cprealloc(line, cpPolylineSizeForCapacity(capacity)); - } - - return line; -} - -// Push v onto the end of line. -static cpPolyline * -cpPolylinePush(cpPolyline *line, cpVect v) -{ - int count = line->count; - line = cpPolylineGrow(line, 1); - line->verts[count] = v; - - return line; -} - -// Push v onto the beginning of line. -static cpPolyline * -cpPolylineEnqueue(cpPolyline *line, cpVect v) -{ - // TODO could optimize this to grow in both directions. - // Probably doesn't matter though. - int count = line->count; - line = cpPolylineGrow(line, 1); - memmove(line->verts + 1, line->verts, count*sizeof(cpVect)); - line->verts[0] = v; - - return line; -} - -// Returns true if the polyline starts and ends with the same vertex. -cpBool -cpPolylineIsClosed(cpPolyline *line) -{ - return (line->count > 1 && cpveql(line->verts[0], line->verts[line->count-1])); -} - -// Check if a cpPolyline is longer than a certain length -// Takes a range which can wrap around if the polyline is looped. -static cpBool -cpPolylineIsShort(cpVect *points, int count, int start, int end, cpFloat min) -{ - cpFloat length = 0.0f; - for(int i=start; i!=end; i=Next(i, count)){ - length += cpvdist(points[i], points[Next(i, count)]); - if(length > min) return cpFalse; - } - - return cpTrue; -} - -//MARK: Polyline Simplification - -static inline cpFloat -Sharpness(cpVect a, cpVect b, cpVect c) -{ - // TODO could speed this up by caching the normals instead of calculating each twice. - return cpvdot(cpvnormalize(cpvsub(a, b)), cpvnormalize(cpvsub(c, b))); -} - -// Join similar adjacent line segments together. Works well for hard edged shapes. -// 'tol' is the minimum anglular difference in radians of a vertex. -cpPolyline * -cpPolylineSimplifyVertexes(cpPolyline *line, cpFloat tol) -{ - cpPolyline *reduced = cpPolylineMake2(0, line->verts[0], line->verts[1]); - - cpFloat minSharp = -cpfcos(tol); - - for(int i=2; i<line->count; i++){ - cpVect vert = line->verts[i]; - cpFloat sharp = Sharpness(reduced->verts[reduced->count - 2], reduced->verts[reduced->count - 1], vert); - - if(sharp <= minSharp){ - reduced->verts[reduced->count - 1] = vert; - } else { - reduced = cpPolylinePush(reduced, vert); - } - } - - if( - cpPolylineIsClosed(line) && - Sharpness(reduced->verts[reduced->count - 2], reduced->verts[0], reduced->verts[1]) < minSharp - ){ - reduced->verts[0] = reduced->verts[reduced->count - 2]; - reduced->count--; - } - - // TODO shrink - return reduced; -} - -// Recursive function used by cpPolylineSimplifyCurves(). -static cpPolyline * -DouglasPeucker( - cpVect *verts, cpPolyline *reduced, - int length, int start, int end, - cpFloat min, cpFloat tol -){ - // Early exit if the points are adjacent - if((end - start + length)%length < 2) return reduced; - - cpVect a = verts[start]; - cpVect b = verts[end]; - - // Check if the length is below the threshold - if(cpvnear(a, b, min) && cpPolylineIsShort(verts, length, start, end, min)) return reduced; - - // Find the maximal vertex to split and recurse on - cpFloat max = 0.0; - int maxi = start; - - cpVect n = cpvnormalize(cpvperp(cpvsub(b, a))); - cpFloat d = cpvdot(n, a); - - for(int i=Next(start, length); i!=end; i=Next(i, length)){ - cpFloat dist = fabs(cpvdot(n, verts[i]) - d); - - if(dist > max){ - max = dist; - maxi = i; - } - } - - if(max > tol){ - reduced = DouglasPeucker(verts, reduced, length, start, maxi, min, tol); - reduced = cpPolylinePush(reduced, verts[maxi]); - reduced = DouglasPeucker(verts, reduced, length, maxi, end, min, tol); - } - - return reduced; -} - -// Recursively reduce the vertex count on a polyline. Works best for smooth shapes. -// 'tol' is the maximum error for the reduction. -// The reduced polyline will never be farther than this distance from the original polyline. -cpPolyline * -cpPolylineSimplifyCurves(cpPolyline *line, cpFloat tol) -{ - cpPolyline *reduced = cpPolylineMake(line->count); - - cpFloat min = tol/2.0f; - - if(cpPolylineIsClosed(line)){ - int start, end; - cpLoopIndexes(line->verts, line->count - 1, &start, &end); - - reduced = cpPolylinePush(reduced, line->verts[start]); - reduced = DouglasPeucker(line->verts, reduced, line->count - 1, start, end, min, tol); - reduced = cpPolylinePush(reduced, line->verts[end]); - reduced = DouglasPeucker(line->verts, reduced, line->count - 1, end, start, min, tol); - reduced = cpPolylinePush(reduced, line->verts[start]); - } else { - reduced = cpPolylinePush(reduced, line->verts[0]); - reduced = DouglasPeucker(line->verts, reduced, line->count, 0, line->count - 1, min, tol); - reduced = cpPolylinePush(reduced, line->verts[line->count - 1]); - } - - return cpPolylineShrink(reduced); -} - -//MARK: Polyline Sets - -cpPolylineSet * -cpPolylineSetAlloc(void) -{ - return (cpPolylineSet *)cpcalloc(1, sizeof(cpPolylineSet)); -} - -cpPolylineSet * -cpPolylineSetInit(cpPolylineSet *set) -{ - set->count = 0; - set->capacity = 8; - set->lines = (cpPolyline**) cpcalloc(set->capacity, sizeof(cpPolyline)); - - return set; -} - - -cpPolylineSet * -cpPolylineSetNew(void) -{ - return cpPolylineSetInit(cpPolylineSetAlloc()); -} - -void -cpPolylineSetDestroy(cpPolylineSet *set, cpBool freePolylines) -{ - if(freePolylines){ - for(int i=0; i<set->count; i++){ - cpPolylineFree(set->lines[i]); - } - } - - cpfree(set->lines); -} - - -void -cpPolylineSetFree(cpPolylineSet *set, cpBool freePolylines) -{ - if(set){ - cpPolylineSetDestroy(set, freePolylines); - cpfree(set); - } -} - -// Find the polyline that ends with v. -static int -cpPolylineSetFindEnds(cpPolylineSet *set, cpVect v){ - int count = set->count; - cpPolyline **lines = set->lines; - - for(int i=0; i<count; i++){ - cpPolyline *line = lines[i]; - if(cpveql(line->verts[line->count - 1], v)) return i; - } - - return -1; -} - -// Find the polyline that starts with v. -static int -cpPolylineSetFindStarts(cpPolylineSet *set, cpVect v){ - int count = set->count; - cpPolyline **lines = set->lines; - - for(int i=0; i<count; i++){ - if(cpveql(lines[i]->verts[0], v)) return i; - } - - return -1; -} - -// Add a new polyline to a polyline set. -static void -cpPolylineSetPush(cpPolylineSet *set, cpPolyline *line) -{ - // grow set - set->count++; - if(set->count > set->capacity){ - set->capacity *= 2; - set->lines = (cpPolyline**) cprealloc(set->lines, set->capacity*sizeof(cpPolyline)); - } - - set->lines[set->count - 1] = line; -} - -// Add a new polyline to a polyline set. -static void -cpPolylineSetAdd(cpPolylineSet *set, cpVect v0, cpVect v1) -{ - cpPolylineSetPush(set, cpPolylineMake2(DEFAULT_POLYLINE_CAPACITY, v0, v1)); -} - -// Join two cpPolylines in a polyline set together. -static void -cpPolylineSetJoin(cpPolylineSet *set, int before, int after) -{ - cpPolyline *lbefore = set->lines[before]; - cpPolyline *lafter = set->lines[after]; - - // append - int count = lbefore->count; - lbefore = cpPolylineGrow(lbefore, lafter->count); - memmove(lbefore->verts + count, lafter->verts, lafter->count*sizeof(cpVect)); - set->lines[before] = lbefore; - - // delete lafter - set->count--; - cpPolylineFree(set->lines[after]); - set->lines[after] = set->lines[set->count]; -} - -// Add a segment to a polyline set. -// A segment will either start a new polyline, join two others, or add to or loop an existing polyline. -void -cpPolylineSetCollectSegment(cpVect v0, cpVect v1, cpPolylineSet *lines) -{ - int before = cpPolylineSetFindEnds(lines, v0); - int after = cpPolylineSetFindStarts(lines, v1); - - if(before >= 0 && after >= 0){ - if(before == after){ - // loop by pushing v1 onto before - lines->lines[before] = cpPolylinePush(lines->lines[before], v1); - } else { - // join before and after - cpPolylineSetJoin(lines, before, after); - } - } else if(before >= 0){ - // push v1 onto before - lines->lines[before] = cpPolylinePush(lines->lines[before], v1); - } else if(after >= 0){ - // enqueue v0 onto after - lines->lines[after] = cpPolylineEnqueue(lines->lines[after], v0); - } else { - // create new line from v0 and v1 - cpPolylineSetAdd(lines, v0, v1); - } -} - -//MARK: Convex Hull Functions - -cpPolyline * -cpPolylineToConvexHull(cpPolyline *line, cpFloat tol) -{ - cpPolyline *hull = cpPolylineMake(line->count + 1); - hull->count = cpConvexHull(line->count, line->verts, hull->verts, NULL, tol); - hull = cpPolylinePush(hull, hull->verts[0]); - - return cpPolylineShrink(hull); -} - -//MARK: Approximate Concave Decompostition - -struct Notch { - int i; - cpFloat d; - cpVect v; - cpVect n; -}; - -static cpFloat -FindSteiner(int count, cpVect *verts, struct Notch notch) -{ - cpFloat min = INFINITY; - cpFloat feature = -1.0; - - for(int i=1; i<count-1; i++){ - int index = (notch.i + i)%count; - - cpVect seg_a = verts[index]; - cpVect seg_b = verts[Next(index, count)]; - - cpFloat thing_a = cpvcross(notch.n, cpvsub(seg_a, notch.v)); - cpFloat thing_b = cpvcross(notch.n, cpvsub(seg_b, notch.v)); - if(thing_a*thing_b <= 0.0){ - cpFloat t = thing_a/(thing_a - thing_b); - cpFloat dist = cpvdot(notch.n, cpvsub(cpvlerp(seg_a, seg_b, t), notch.v)); - - if(dist >= 0.0 && dist <= min){ - min = dist; - feature = index + t; - } - } - } - - return feature; -} - -//static cpFloat -//FindSteiner2(cpVect *verts, int count, struct Notch notch) -//{ -// cpVect a = verts[(notch.i + count - 1)%count]; -// cpVect b = verts[(notch.i + 1)%count]; -// cpVect n = cpvnormalize(cpvadd(cpvnormalize(cpvsub(notch.v, a)), cpvnormalize(cpvsub(notch.v, b)))); -// -// cpFloat min = INFINITY; -// cpFloat feature = -1.0; -// -// for(int i=1; i<count-1; i++){ -// int index = (notch.i + i)%count; -// -// cpVect seg_a = verts[index]; -// cpVect seg_b = verts[Next(index, count)]; -// -// cpFloat thing_a = cpvcross(n, cpvsub(seg_a, notch.v)); -// cpFloat thing_b = cpvcross(n, cpvsub(seg_b, notch.v)); -// if(thing_a*thing_b <= 0.0){ -// cpFloat t = thing_a/(thing_a - thing_b); -// cpFloat dist = cpvdot(n, cpvsub(cpvlerp(seg_a, seg_b, t), notch.v)); -// -// if(dist >= 0.0 && dist <= min){ -// min = dist; -// feature = index + t; -// } -// } -// } -// -// cpAssertSoft(feature >= 0.0, "No closest features detected. This is likely due to a self intersecting polygon."); -// return feature; -//} - -//struct Range {cpFloat min, max;}; -//static inline struct Range -//clip_range(cpVect delta_a, cpVect delta_b, cpVect clip) -//{ -// cpFloat da = cpvcross(delta_a, clip); -// cpFloat db = cpvcross(delta_b, clip); -// cpFloat clamp = da/(da - db); -// if(da > db){ -// return (struct Range){-INFINITY, clamp}; -// } else if(da < db){ -// return (struct Range){clamp, INFINITY}; -// } else { -// return (struct Range){-INFINITY, INFINITY}; -// } -//} -// -//static cpFloat -//FindSteiner3(cpVect *verts, int count, struct Notch notch) -//{ -// cpFloat min = INFINITY; -// cpFloat feature = -1.0; -// -// cpVect support_a = verts[(notch.i - 1 + count)%count]; -// cpVect support_b = verts[(notch.i + 1)%count]; -// -// cpVect clip_a = cpvlerp(support_a, support_b, 0.1); -// cpVect clip_b = cpvlerp(support_b, support_b, 0.9); -// -// for(int i=1; i<count - 1; i++){ -// int index = (notch.i + i)%count; -// cpVect seg_a = verts[index]; -// cpVect seg_b = verts[Next(index, count)]; -// -// cpVect delta_a = cpvsub(seg_a, notch.v); -// cpVect delta_b = cpvsub(seg_b, notch.v); -// -// // Ignore if the segment faces away from the point. -// if(cpvcross(delta_b, delta_a) > 0.0){ -// struct Range range1 = clip_range(delta_a, delta_b, cpvsub(notch.v, clip_a)); -// struct Range range2 = clip_range(delta_a, delta_b, cpvsub(clip_b, notch.v)); -// -// cpFloat min_t = cpfmax(0.0, cpfmax(range1.min, range2.min)); -// cpFloat max_t = cpfmin(1.0, cpfmin(range1.max, range2.max)); -// -// // Ignore if the segment has been completely clipped away. -// if(min_t < max_t){ -// cpVect seg_delta = cpvsub(seg_b, seg_a); -// cpFloat closest_t = cpfclamp(cpvdot(seg_delta, cpvsub(notch.v, seg_a))/cpvlengthsq(seg_delta), min_t, max_t); -// cpVect closest = cpvlerp(seg_a, seg_b, closest_t); -// -// cpFloat dist = cpvdistsq(notch.v, closest); -// if(dist < min){ -// min = dist; -// feature = index + closest_t; -// } -// } -// } -// } -// -// cpAssertWarn(feature >= 0.0, "Internal Error: No closest features detected."); -// return feature; -//} - -//static cpBool -//VertexUnobscured(int count, cpVect *verts, int index, int notch_i) -//{ -// cpVect v = verts[notch_i]; -// cpVect n = cpvnormalize(cpvsub(verts[index], v)); -// -// for(int i=0; i<count; i++){ -// if(i == index || i == Next(i, count) || i == notch_i || i == Next(notch_i, count)) continue; -// -// cpVect seg_a = verts[i]; -// cpVect seg_b = verts[Next(i, count)]; -// -// cpFloat thing_a = cpvcross(n, cpvsub(seg_a, v)); -// cpFloat thing_b = cpvcross(n, cpvsub(seg_b, v)); -// if(thing_a*thing_b <= 0.0) return cpTrue; -// } -// -// return cpFalse; -//} -// -//static cpFloat -//FindSteiner4(int count, cpVect *verts, struct Notch notch, cpFloat *convexity) -//{ -// cpFloat min = INFINITY; -// cpFloat feature = -1.0; -// -// for(int i=Next(notch.b, count); i!=notch.a; i=Next(i, count)){ -// cpVect v = verts[i]; -// cpFloat weight = (1.0 + 0.1*convexity[i])/(1.0*cpvdist(notch.v, v)); -// -// if(weight <= min && VertexUnobscured(count, verts, i, notch.i)){ -// min = weight; -// feature = i; -// } -// } -// -// cpAssertSoft(feature >= 0.0, "No closest features detected. This is likely due to a self intersecting polygon."); -// return feature; -//} - -static struct Notch -DeepestNotch(int count, cpVect *verts, int hullCount, cpVect *hullVerts, int first, cpFloat tol) -{ - struct Notch notch = {0}; - int j = Next(first, count); - - for(int i=0; i<hullCount; i++){ - cpVect a = hullVerts[i]; - cpVect b = hullVerts[Next(i, hullCount)]; - - // TODO use a cross check instead? - cpVect n = cpvnormalize(cpvrperp(cpvsub(a, b))); - cpFloat d = cpvdot(n, a); - - cpVect v = verts[j]; - while(!cpveql(v, b)){ - cpFloat depth = cpvdot(n, v) - d; - - if(depth > notch.d){ - notch.d = depth; - notch.i = j; - notch.v = v; - notch.n = n; - } - - j = Next(j, count); - v = verts[j]; - } - - j = Next(j, count); - } - - return notch; -} - -static inline int IMAX(int a, int b){return (a > b ? a : b);} - -static void -ApproximateConcaveDecomposition(cpVect *verts, int count, cpFloat tol, cpPolylineSet *set) -{ - int first; - cpVect *hullVerts = (cpVect*) alloca(count*sizeof(cpVect)); - int hullCount = cpConvexHull(count, verts, hullVerts, &first, 0.0); - - if(hullCount != count){ - struct Notch notch = DeepestNotch(count, verts, hullCount, hullVerts, first, tol); - - if(notch.d > tol){ - cpFloat steiner_it = FindSteiner(count, verts, notch); - - if(steiner_it >= 0.0){ - int steiner_i = (int)steiner_it; - cpVect steiner = cpvlerp(verts[steiner_i], verts[Next(steiner_i, count)], steiner_it - steiner_i); - - // Vertex counts NOT including the steiner point. - int sub1_count = (steiner_i - notch.i + count)%count + 1; - int sub2_count = count - (steiner_i - notch.i + count)%count; - cpVect *scratch = (cpVect*) alloca((IMAX(sub1_count, sub2_count) + 1)*sizeof(cpVect)); - - for(int i=0; i<sub1_count; i++) scratch[i] = verts[(notch.i + i)%count]; - scratch[sub1_count] = steiner; - ApproximateConcaveDecomposition(scratch, sub1_count + 1, tol, set); - - for(int i=0; i<sub2_count; i++) scratch[i] = verts[(steiner_i + 1 + i)%count]; - scratch[sub2_count] = steiner; - ApproximateConcaveDecomposition(scratch, sub2_count + 1, tol, set); - - return; - } - } - } - - cpPolyline *hull = cpPolylineMake(hullCount + 1); - - memcpy(hull->verts, hullVerts, hullCount*sizeof(cpVect)); - hull->verts[hullCount] = hullVerts[0]; - hull->count = hullCount + 1; - - cpPolylineSetPush(set, hull); -} - -cpPolylineSet * -cpPolylineConvexDecomposition_BETA(cpPolyline *line, cpFloat tol) -{ - cpAssertSoft(cpPolylineIsClosed(line), "Cannot decompose an open polygon."); - cpAssertSoft(cpAreaForPoly(line->count, line->verts, 0.0) >= 0.0, "Winding is backwards. (Are you passing a hole?)"); - - cpPolylineSet *set = cpPolylineSetNew(); - ApproximateConcaveDecomposition(line->verts, line->count - 1, tol, set); - - return set; -} diff --git a/thirdparty/src/chipmunk/cpRatchetJoint.c b/thirdparty/src/chipmunk/cpRatchetJoint.c deleted file mode 100644 index b3c9687e3..000000000 --- a/thirdparty/src/chipmunk/cpRatchetJoint.c +++ /dev/null @@ -1,179 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -static void -preStep(cpRatchetJoint *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpFloat angle = joint->angle; - cpFloat phase = joint->phase; - cpFloat ratchet = joint->ratchet; - - cpFloat delta = b->a - a->a; - cpFloat diff = angle - delta; - cpFloat pdist = 0.0f; - - if(diff*ratchet > 0.0f){ - pdist = diff; - } else { - joint->angle = cpffloor((delta - phase)/ratchet)*ratchet + phase; - } - - // calculate moment of inertia coefficient. - joint->iSum = 1.0f/(a->i_inv + b->i_inv); - - // calculate bias velocity - cpFloat maxBias = joint->constraint.maxBias; - joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*pdist/dt, -maxBias, maxBias); - - // If the bias is 0, the joint is not at a limit. Reset the impulse. - if(!joint->bias) joint->jAcc = 0.0f; -} - -static void -applyCachedImpulse(cpRatchetJoint *joint, cpFloat dt_coef) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpFloat j = joint->jAcc*dt_coef; - a->w -= j*a->i_inv; - b->w += j*b->i_inv; -} - -static void -applyImpulse(cpRatchetJoint *joint, cpFloat dt) -{ - if(!joint->bias) return; // early exit - - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // compute relative rotational velocity - cpFloat wr = b->w - a->w; - cpFloat ratchet = joint->ratchet; - - cpFloat jMax = joint->constraint.maxForce*dt; - - // compute normal impulse - cpFloat j = -(joint->bias + wr)*joint->iSum; - cpFloat jOld = joint->jAcc; - joint->jAcc = cpfclamp((jOld + j)*ratchet, 0.0f, jMax*cpfabs(ratchet))/ratchet; - j = joint->jAcc - jOld; - - // apply impulse - a->w -= j*a->i_inv; - b->w += j*b->i_inv; -} - -static cpFloat -getImpulse(cpRatchetJoint *joint) -{ - return cpfabs(joint->jAcc); -} - -static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, -}; - -cpRatchetJoint * -cpRatchetJointAlloc(void) -{ - return (cpRatchetJoint *)cpcalloc(1, sizeof(cpRatchetJoint)); -} - -cpRatchetJoint * -cpRatchetJointInit(cpRatchetJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet) -{ - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->angle = 0.0f; - joint->phase = phase; - joint->ratchet = ratchet; - - // STATIC_BODY_CHECK - joint->angle = (b ? b->a : 0.0f) - (a ? a->a : 0.0f); - - return joint; -} - -cpConstraint * -cpRatchetJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet) -{ - return (cpConstraint *)cpRatchetJointInit(cpRatchetJointAlloc(), a, b, phase, ratchet); -} - -cpBool -cpConstraintIsRatchetJoint(const cpConstraint *constraint) -{ - return (constraint->klass == &klass); -} - -cpFloat -cpRatchetJointGetAngle(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsRatchetJoint(constraint), "Constraint is not a ratchet joint."); - return ((cpRatchetJoint *)constraint)->angle; -} - -void -cpRatchetJointSetAngle(cpConstraint *constraint, cpFloat angle) -{ - cpAssertHard(cpConstraintIsRatchetJoint(constraint), "Constraint is not a ratchet joint."); - cpConstraintActivateBodies(constraint); - ((cpRatchetJoint *)constraint)->angle = angle; -} - -cpFloat -cpRatchetJointGetPhase(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsRatchetJoint(constraint), "Constraint is not a ratchet joint."); - return ((cpRatchetJoint *)constraint)->phase; -} - -void -cpRatchetJointSetPhase(cpConstraint *constraint, cpFloat phase) -{ - cpAssertHard(cpConstraintIsRatchetJoint(constraint), "Constraint is not a ratchet joint."); - cpConstraintActivateBodies(constraint); - ((cpRatchetJoint *)constraint)->phase = phase; -} -cpFloat -cpRatchetJointGetRatchet(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsRatchetJoint(constraint), "Constraint is not a ratchet joint."); - return ((cpRatchetJoint *)constraint)->ratchet; -} - -void -cpRatchetJointSetRatchet(cpConstraint *constraint, cpFloat ratchet) -{ - cpAssertHard(cpConstraintIsRatchetJoint(constraint), "Constraint is not a ratchet joint."); - cpConstraintActivateBodies(constraint); - ((cpRatchetJoint *)constraint)->ratchet = ratchet; -} diff --git a/thirdparty/src/chipmunk/cpRobust.c b/thirdparty/src/chipmunk/cpRobust.c deleted file mode 100644 index 57507d14e..000000000 --- a/thirdparty/src/chipmunk/cpRobust.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "chipmunk/cpRobust.h" - - -cpBool -cpCheckPointGreater(const cpVect a, const cpVect b, const cpVect c) -{ - return (b.y - a.y)*(a.x + b.x - 2*c.x) > (b.x - a.x)*(a.y + b.y - 2*c.y); -} - -cpBool -cpCheckAxis(cpVect v0, cpVect v1, cpVect p, cpVect n){ - return cpvdot(p, n) <= cpfmax(cpvdot(v0, n), cpvdot(v1, n)); -} diff --git a/thirdparty/src/chipmunk/cpRotaryLimitJoint.c b/thirdparty/src/chipmunk/cpRotaryLimitJoint.c deleted file mode 100644 index 548adbebf..000000000 --- a/thirdparty/src/chipmunk/cpRotaryLimitJoint.c +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -static void -preStep(cpRotaryLimitJoint *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpFloat dist = b->a - a->a; - cpFloat pdist = 0.0f; - if(dist > joint->max) { - pdist = joint->max - dist; - } else if(dist < joint->min) { - pdist = joint->min - dist; - } - - // calculate moment of inertia coefficient. - joint->iSum = 1.0f/(a->i_inv + b->i_inv); - - // calculate bias velocity - cpFloat maxBias = joint->constraint.maxBias; - joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*pdist/dt, -maxBias, maxBias); - - // If the bias is 0, the joint is not at a limit. Reset the impulse. - if(!joint->bias) joint->jAcc = 0.0f; -} - -static void -applyCachedImpulse(cpRotaryLimitJoint *joint, cpFloat dt_coef) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpFloat j = joint->jAcc*dt_coef; - a->w -= j*a->i_inv; - b->w += j*b->i_inv; -} - -static void -applyImpulse(cpRotaryLimitJoint *joint, cpFloat dt) -{ - if(!joint->bias) return; // early exit - - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // compute relative rotational velocity - cpFloat wr = b->w - a->w; - - cpFloat jMax = joint->constraint.maxForce*dt; - - // compute normal impulse - cpFloat j = -(joint->bias + wr)*joint->iSum; - cpFloat jOld = joint->jAcc; - if(joint->bias < 0.0f){ - joint->jAcc = cpfclamp(jOld + j, 0.0f, jMax); - } else { - joint->jAcc = cpfclamp(jOld + j, -jMax, 0.0f); - } - j = joint->jAcc - jOld; - - // apply impulse - a->w -= j*a->i_inv; - b->w += j*b->i_inv; -} - -static cpFloat -getImpulse(cpRotaryLimitJoint *joint) -{ - return cpfabs(joint->jAcc); -} - -static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, -}; - -cpRotaryLimitJoint * -cpRotaryLimitJointAlloc(void) -{ - return (cpRotaryLimitJoint *)cpcalloc(1, sizeof(cpRotaryLimitJoint)); -} - -cpRotaryLimitJoint * -cpRotaryLimitJointInit(cpRotaryLimitJoint *joint, cpBody *a, cpBody *b, cpFloat min, cpFloat max) -{ - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->min = min; - joint->max = max; - - joint->jAcc = 0.0f; - - return joint; -} - -cpConstraint * -cpRotaryLimitJointNew(cpBody *a, cpBody *b, cpFloat min, cpFloat max) -{ - return (cpConstraint *)cpRotaryLimitJointInit(cpRotaryLimitJointAlloc(), a, b, min, max); -} - -cpBool -cpConstraintIsRotaryLimitJoint(const cpConstraint *constraint) -{ - return (constraint->klass == &klass); -} - -cpFloat -cpRotaryLimitJointGetMin(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsRotaryLimitJoint(constraint), "Constraint is not a rotary limit joint."); - return ((cpRotaryLimitJoint *)constraint)->min; -} - -void -cpRotaryLimitJointSetMin(cpConstraint *constraint, cpFloat min) -{ - cpAssertHard(cpConstraintIsRotaryLimitJoint(constraint), "Constraint is not a rotary limit joint."); - cpConstraintActivateBodies(constraint); - ((cpRotaryLimitJoint *)constraint)->min = min; -} - -cpFloat -cpRotaryLimitJointGetMax(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsRotaryLimitJoint(constraint), "Constraint is not a rotary limit joint."); - return ((cpRotaryLimitJoint *)constraint)->max; -} - -void -cpRotaryLimitJointSetMax(cpConstraint *constraint, cpFloat max) -{ - cpAssertHard(cpConstraintIsRotaryLimitJoint(constraint), "Constraint is not a rotary limit joint."); - cpConstraintActivateBodies(constraint); - ((cpRotaryLimitJoint *)constraint)->max = max; -} diff --git a/thirdparty/src/chipmunk/cpShape.c b/thirdparty/src/chipmunk/cpShape.c deleted file mode 100644 index 10f5afa7c..000000000 --- a/thirdparty/src/chipmunk/cpShape.c +++ /dev/null @@ -1,603 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" -#include "chipmunk/chipmunk_unsafe.h" - -#define CP_DefineShapeGetter(struct, type, member, name) \ -CP_DeclareShapeGetter(struct, type, name){ \ - cpAssertHard(shape->klass == &struct##Class, "shape is not a "#struct); \ - return ((struct *)shape)->member; \ -} - -cpShape * -cpShapeInit(cpShape *shape, const cpShapeClass *klass, cpBody *body, struct cpShapeMassInfo massInfo) -{ - shape->klass = klass; - - shape->body = body; - shape->massInfo = massInfo; - - shape->sensor = 0; - - shape->e = 0.0f; - shape->u = 0.0f; - shape->surfaceV = cpvzero; - - shape->type = 0; - shape->filter.group = CP_NO_GROUP; - shape->filter.categories = CP_ALL_CATEGORIES; - shape->filter.mask = CP_ALL_CATEGORIES; - - shape->userData = NULL; - - shape->space = NULL; - - shape->next = NULL; - shape->prev = NULL; - - return shape; -} - -void -cpShapeDestroy(cpShape *shape) -{ - if(shape->klass && shape->klass->destroy) shape->klass->destroy(shape); -} - -void -cpShapeFree(cpShape *shape) -{ - if(shape){ - cpShapeDestroy(shape); - cpfree(shape); - } -} - -cpSpace * -cpShapeGetSpace(const cpShape *shape) -{ - return shape->space; -} - -cpBody * -cpShapeGetBody(const cpShape *shape) -{ - return shape->body; -} - -void -cpShapeSetBody(cpShape *shape, cpBody *body) -{ - cpAssertHard(!cpShapeActive(shape), "You cannot change the body on an active shape. You must remove the shape from the space before changing the body."); - shape->body = body; -} - -cpFloat cpShapeGetMass(cpShape *shape){ return shape->massInfo.m; } - -void -cpShapeSetMass(cpShape *shape, cpFloat mass){ - cpBody *body = shape->body; - cpBodyActivate(body); - - shape->massInfo.m = mass; - cpBodyAccumulateMassFromShapes(body); -} - -cpFloat cpShapeGetDensity(cpShape *shape){ return shape->massInfo.m/shape->massInfo.area; } -void cpShapeSetDensity(cpShape *shape, cpFloat density){ cpShapeSetMass(shape, density*shape->massInfo.area); } - -cpFloat cpShapeGetMoment(cpShape *shape){ return shape->massInfo.m*shape->massInfo.i; } -cpFloat cpShapeGetArea(cpShape *shape){ return shape->massInfo.area; } -cpVect cpShapeGetCenterOfGravity(cpShape *shape) { return shape->massInfo.cog; } - -cpBB -cpShapeGetBB(const cpShape *shape) -{ - return shape->bb; -} - -cpBool -cpShapeGetSensor(const cpShape *shape) -{ - return shape->sensor; -} - -void -cpShapeSetSensor(cpShape *shape, cpBool sensor) -{ - cpBodyActivate(shape->body); - shape->sensor = sensor; -} - -cpFloat -cpShapeGetElasticity(const cpShape *shape) -{ - return shape->e; -} - -void -cpShapeSetElasticity(cpShape *shape, cpFloat elasticity) -{ - cpAssertHard(elasticity >= 0.0f, "Elasticity must be positive."); - cpBodyActivate(shape->body); - shape->e = elasticity; -} - -cpFloat -cpShapeGetFriction(const cpShape *shape) -{ - return shape->u; -} - -void -cpShapeSetFriction(cpShape *shape, cpFloat friction) -{ - cpAssertHard(friction >= 0.0f, "Friction must be postive."); - cpBodyActivate(shape->body); - shape->u = friction; -} - -cpVect -cpShapeGetSurfaceVelocity(const cpShape *shape) -{ - return shape->surfaceV; -} - -void -cpShapeSetSurfaceVelocity(cpShape *shape, cpVect surfaceVelocity) -{ - cpBodyActivate(shape->body); - shape->surfaceV = surfaceVelocity; -} - -cpDataPointer -cpShapeGetUserData(const cpShape *shape) -{ - return shape->userData; -} - -void -cpShapeSetUserData(cpShape *shape, cpDataPointer userData) -{ - shape->userData = userData; -} - -cpCollisionType -cpShapeGetCollisionType(const cpShape *shape) -{ - return shape->type; -} - -void -cpShapeSetCollisionType(cpShape *shape, cpCollisionType collisionType) -{ - cpBodyActivate(shape->body); - shape->type = collisionType; -} - -cpShapeFilter -cpShapeGetFilter(const cpShape *shape) -{ - return shape->filter; -} - -void -cpShapeSetFilter(cpShape *shape, cpShapeFilter filter) -{ - cpBodyActivate(shape->body); - shape->filter = filter; -} - -cpBB -cpShapeCacheBB(cpShape *shape) -{ - return cpShapeUpdate(shape, shape->body->transform); -} - -cpBB -cpShapeUpdate(cpShape *shape, cpTransform transform) -{ - return (shape->bb = shape->klass->cacheData(shape, transform)); -} - -cpFloat -cpShapePointQuery(const cpShape *shape, cpVect p, cpPointQueryInfo *info) -{ - cpPointQueryInfo blank = {NULL, cpvzero, INFINITY, cpvzero}; - if(info){ - (*info) = blank; - } else { - info = ␣ - } - - shape->klass->pointQuery(shape, p, info); - return info->distance; -} - - -cpBool -cpShapeSegmentQuery(const cpShape *shape, cpVect a, cpVect b, cpFloat radius, cpSegmentQueryInfo *info){ - cpSegmentQueryInfo blank = {NULL, b, cpvzero, 1.0f}; - if(info){ - (*info) = blank; - } else { - info = ␣ - } - - cpPointQueryInfo nearest; - shape->klass->pointQuery(shape, a, &nearest); - if(nearest.distance <= radius){ - info->shape = shape; - info->alpha = 0.0; - info->normal = cpvnormalize(cpvsub(a, nearest.point)); - } else { - shape->klass->segmentQuery(shape, a, b, radius, info); - } - - return (info->shape != NULL); -} - -cpContactPointSet -cpShapesCollide(const cpShape *a, const cpShape *b) -{ - struct cpContact contacts[CP_MAX_CONTACTS_PER_ARBITER]; - struct cpCollisionInfo info = cpCollide(a, b, 0, contacts); - - cpContactPointSet set; - set.count = info.count; - - // cpCollideShapes() may have swapped the contact order. Flip the normal. - cpBool swapped = (a != info.a); - set.normal = (swapped ? cpvneg(info.n) : info.n); - - for(int i=0; i<info.count; i++){ - // cpCollideShapesInfo() returns contacts with absolute positions. - cpVect p1 = contacts[i].r1; - cpVect p2 = contacts[i].r2; - - set.points[i].pointA = (swapped ? p2 : p1); - set.points[i].pointB = (swapped ? p1 : p2); - set.points[i].distance = cpvdot(cpvsub(p2, p1), set.normal); - } - - return set; -} - -cpCircleShape * -cpCircleShapeAlloc(void) -{ - return (cpCircleShape *)cpcalloc(1, sizeof(cpCircleShape)); -} - -static cpBB -cpCircleShapeCacheData(cpCircleShape *circle, cpTransform transform) -{ - cpVect c = circle->tc = cpTransformPoint(transform, circle->c); - return cpBBNewForCircle(c, circle->r); -} - -static void -cpCircleShapePointQuery(cpCircleShape *circle, cpVect p, cpPointQueryInfo *info) -{ - cpVect delta = cpvsub(p, circle->tc); - cpFloat d = cpvlength(delta); - cpFloat r = circle->r; - - info->shape = (cpShape *)circle; - info->point = cpvadd(circle->tc, cpvmult(delta, r/d)); // TODO: div/0 - info->distance = d - r; - - // Use up for the gradient if the distance is very small. - info->gradient = (d > MAGIC_EPSILON ? cpvmult(delta, 1.0f/d) : cpv(0.0f, 1.0f)); -} - -static void -cpCircleShapeSegmentQuery(cpCircleShape *circle, cpVect a, cpVect b, cpFloat radius, cpSegmentQueryInfo *info) -{ - CircleSegmentQuery((cpShape *)circle, circle->tc, circle->r, a, b, radius, info); -} - -static struct cpShapeMassInfo -cpCircleShapeMassInfo(cpFloat mass, cpFloat radius, cpVect center) -{ - struct cpShapeMassInfo info = { - mass, cpMomentForCircle(1.0f, 0.0f, radius, cpvzero), - center, - cpAreaForCircle(0.0f, radius), - }; - - return info; -} - -static const cpShapeClass cpCircleShapeClass = { - CP_CIRCLE_SHAPE, - (cpShapeCacheDataImpl)cpCircleShapeCacheData, - NULL, - (cpShapePointQueryImpl)cpCircleShapePointQuery, - (cpShapeSegmentQueryImpl)cpCircleShapeSegmentQuery, -}; - -cpCircleShape * -cpCircleShapeInit(cpCircleShape *circle, cpBody *body, cpFloat radius, cpVect offset) -{ - circle->c = offset; - circle->r = radius; - - cpShapeInit((cpShape *)circle, &cpCircleShapeClass, body, cpCircleShapeMassInfo(0.0f, radius, offset)); - - return circle; -} - -cpShape * -cpCircleShapeNew(cpBody *body, cpFloat radius, cpVect offset) -{ - return (cpShape *)cpCircleShapeInit(cpCircleShapeAlloc(), body, radius, offset); -} - -cpVect -cpCircleShapeGetOffset(const cpShape *shape) -{ - cpAssertHard(shape->klass == &cpCircleShapeClass, "Shape is not a circle shape."); - return ((cpCircleShape *)shape)->c; -} - -cpFloat -cpCircleShapeGetRadius(const cpShape *shape) -{ - cpAssertHard(shape->klass == &cpCircleShapeClass, "Shape is not a circle shape."); - return ((cpCircleShape *)shape)->r; -} - - -cpSegmentShape * -cpSegmentShapeAlloc(void) -{ - return (cpSegmentShape *)cpcalloc(1, sizeof(cpSegmentShape)); -} - -static cpBB -cpSegmentShapeCacheData(cpSegmentShape *seg, cpTransform transform) -{ - seg->ta = cpTransformPoint(transform, seg->a); - seg->tb = cpTransformPoint(transform, seg->b); - seg->tn = cpTransformVect(transform, seg->n); - - cpFloat l,r,b,t; - - if(seg->ta.x < seg->tb.x){ - l = seg->ta.x; - r = seg->tb.x; - } else { - l = seg->tb.x; - r = seg->ta.x; - } - - if(seg->ta.y < seg->tb.y){ - b = seg->ta.y; - t = seg->tb.y; - } else { - b = seg->tb.y; - t = seg->ta.y; - } - - cpFloat rad = seg->r; - return cpBBNew(l - rad, b - rad, r + rad, t + rad); -} - -static void -cpSegmentShapePointQuery(cpSegmentShape *seg, cpVect p, cpPointQueryInfo *info) -{ - cpVect closest = cpClosetPointOnSegment(p, seg->ta, seg->tb); - - cpVect delta = cpvsub(p, closest); - cpFloat d = cpvlength(delta); - cpFloat r = seg->r; - cpVect g = cpvmult(delta, 1.0f/d); - - info->shape = (cpShape *)seg; - info->point = (d ? cpvadd(closest, cpvmult(g, r)) : closest); - info->distance = d - r; - - // Use the segment's normal if the distance is very small. - info->gradient = (d > MAGIC_EPSILON ? g : seg->n); -} - -static void -cpSegmentShapeSegmentQuery(cpSegmentShape *seg, cpVect a, cpVect b, cpFloat r2, cpSegmentQueryInfo *info) -{ - cpVect n = seg->tn; - cpFloat d = cpvdot(cpvsub(seg->ta, a), n); - cpFloat r = seg->r + r2; - - cpVect flipped_n = (d > 0.0f ? cpvneg(n) : n); - cpVect seg_offset = cpvsub(cpvmult(flipped_n, r), a); - - // Make the endpoints relative to 'a' and move them by the thickness of the segment. - cpVect seg_a = cpvadd(seg->ta, seg_offset); - cpVect seg_b = cpvadd(seg->tb, seg_offset); - cpVect delta = cpvsub(b, a); - - if(cpvcross(delta, seg_a)*cpvcross(delta, seg_b) <= 0.0f){ - cpFloat d_offset = d + (d > 0.0f ? -r : r); - cpFloat ad = -d_offset; - cpFloat bd = cpvdot(delta, n) - d_offset; - - if(ad*bd < 0.0f){ - cpFloat t = ad/(ad - bd); - - info->shape = (cpShape *)seg; - info->point = cpvsub(cpvlerp(a, b, t), cpvmult(flipped_n, r2)); - info->normal = flipped_n; - info->alpha = t; - } - } else if(r != 0.0f){ - cpSegmentQueryInfo info1 = {NULL, b, cpvzero, 1.0f}; - cpSegmentQueryInfo info2 = {NULL, b, cpvzero, 1.0f}; - CircleSegmentQuery((cpShape *)seg, seg->ta, seg->r, a, b, r2, &info1); - CircleSegmentQuery((cpShape *)seg, seg->tb, seg->r, a, b, r2, &info2); - - if(info1.alpha < info2.alpha){ - (*info) = info1; - } else { - (*info) = info2; - } - } -} - -static struct cpShapeMassInfo -cpSegmentShapeMassInfo(cpFloat mass, cpVect a, cpVect b, cpFloat r) -{ - struct cpShapeMassInfo info = { - mass, cpMomentForBox(1.0f, cpvdist(a, b) + 2.0f*r, 2.0f*r), // TODO is an approximation. - cpvlerp(a, b, 0.5f), - cpAreaForSegment(a, b, r), - }; - - return info; -} - -static const cpShapeClass cpSegmentShapeClass = { - CP_SEGMENT_SHAPE, - (cpShapeCacheDataImpl)cpSegmentShapeCacheData, - NULL, - (cpShapePointQueryImpl)cpSegmentShapePointQuery, - (cpShapeSegmentQueryImpl)cpSegmentShapeSegmentQuery, -}; - -cpSegmentShape * -cpSegmentShapeInit(cpSegmentShape *seg, cpBody *body, cpVect a, cpVect b, cpFloat r) -{ - seg->a = a; - seg->b = b; - seg->n = cpvrperp(cpvnormalize(cpvsub(b, a))); - - seg->r = r; - - seg->a_tangent = cpvzero; - seg->b_tangent = cpvzero; - - cpShapeInit((cpShape *)seg, &cpSegmentShapeClass, body, cpSegmentShapeMassInfo(0.0f, a, b, r)); - - return seg; -} - -cpShape* -cpSegmentShapeNew(cpBody *body, cpVect a, cpVect b, cpFloat r) -{ - return (cpShape *)cpSegmentShapeInit(cpSegmentShapeAlloc(), body, a, b, r); -} - -cpVect -cpSegmentShapeGetA(const cpShape *shape) -{ - cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); - return ((cpSegmentShape *)shape)->a; -} - -cpVect -cpSegmentShapeGetB(const cpShape *shape) -{ - cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); - return ((cpSegmentShape *)shape)->b; -} - -cpVect -cpSegmentShapeGetNormal(const cpShape *shape) -{ - cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); - return ((cpSegmentShape *)shape)->n; -} - -cpFloat -cpSegmentShapeGetRadius(const cpShape *shape) -{ - cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); - return ((cpSegmentShape *)shape)->r; -} - -void -cpSegmentShapeSetNeighbors(cpShape *shape, cpVect prev, cpVect next) -{ - cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); - cpSegmentShape *seg = (cpSegmentShape *)shape; - - seg->a_tangent = cpvsub(prev, seg->a); - seg->b_tangent = cpvsub(next, seg->b); -} - -// Unsafe API (chipmunk_unsafe.h) - -// TODO setters should wake the shape up? - -void -cpCircleShapeSetRadius(cpShape *shape, cpFloat radius) -{ - cpAssertHard(shape->klass == &cpCircleShapeClass, "Shape is not a circle shape."); - cpCircleShape *circle = (cpCircleShape *)shape; - - circle->r = radius; - - cpFloat mass = shape->massInfo.m; - shape->massInfo = cpCircleShapeMassInfo(mass, circle->r, circle->c); - if(mass > 0.0f) cpBodyAccumulateMassFromShapes(shape->body); -} - -void -cpCircleShapeSetOffset(cpShape *shape, cpVect offset) -{ - cpAssertHard(shape->klass == &cpCircleShapeClass, "Shape is not a circle shape."); - cpCircleShape *circle = (cpCircleShape *)shape; - - circle->c = offset; - - cpFloat mass = shape->massInfo.m; - shape->massInfo = cpCircleShapeMassInfo(shape->massInfo.m, circle->r, circle->c); - if(mass > 0.0f) cpBodyAccumulateMassFromShapes(shape->body); -} - -void -cpSegmentShapeSetEndpoints(cpShape *shape, cpVect a, cpVect b) -{ - cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); - cpSegmentShape *seg = (cpSegmentShape *)shape; - - seg->a = a; - seg->b = b; - seg->n = cpvperp(cpvnormalize(cpvsub(b, a))); - - cpFloat mass = shape->massInfo.m; - shape->massInfo = cpSegmentShapeMassInfo(shape->massInfo.m, seg->a, seg->b, seg->r); - if(mass > 0.0f) cpBodyAccumulateMassFromShapes(shape->body); -} - -void -cpSegmentShapeSetRadius(cpShape *shape, cpFloat radius) -{ - cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); - cpSegmentShape *seg = (cpSegmentShape *)shape; - - seg->r = radius; - - cpFloat mass = shape->massInfo.m; - shape->massInfo = cpSegmentShapeMassInfo(shape->massInfo.m, seg->a, seg->b, seg->r); - if(mass > 0.0f) cpBodyAccumulateMassFromShapes(shape->body); -} diff --git a/thirdparty/src/chipmunk/cpSimpleMotor.c b/thirdparty/src/chipmunk/cpSimpleMotor.c deleted file mode 100644 index 6d83f80aa..000000000 --- a/thirdparty/src/chipmunk/cpSimpleMotor.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -static void -preStep(cpSimpleMotor *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // calculate moment of inertia coefficient. - joint->iSum = 1.0f/(a->i_inv + b->i_inv); -} - -static void -applyCachedImpulse(cpSimpleMotor *joint, cpFloat dt_coef) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpFloat j = joint->jAcc*dt_coef; - a->w -= j*a->i_inv; - b->w += j*b->i_inv; -} - -static void -applyImpulse(cpSimpleMotor *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // compute relative rotational velocity - cpFloat wr = b->w - a->w + joint->rate; - - cpFloat jMax = joint->constraint.maxForce*dt; - - // compute normal impulse - cpFloat j = -wr*joint->iSum; - cpFloat jOld = joint->jAcc; - joint->jAcc = cpfclamp(jOld + j, -jMax, jMax); - j = joint->jAcc - jOld; - - // apply impulse - a->w -= j*a->i_inv; - b->w += j*b->i_inv; -} - -static cpFloat -getImpulse(cpSimpleMotor *joint) -{ - return cpfabs(joint->jAcc); -} - -static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, -}; - -cpSimpleMotor * -cpSimpleMotorAlloc(void) -{ - return (cpSimpleMotor *)cpcalloc(1, sizeof(cpSimpleMotor)); -} - -cpSimpleMotor * -cpSimpleMotorInit(cpSimpleMotor *joint, cpBody *a, cpBody *b, cpFloat rate) -{ - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->rate = rate; - - joint->jAcc = 0.0f; - - return joint; -} - -cpConstraint * -cpSimpleMotorNew(cpBody *a, cpBody *b, cpFloat rate) -{ - return (cpConstraint *)cpSimpleMotorInit(cpSimpleMotorAlloc(), a, b, rate); -} - -cpBool -cpConstraintIsSimpleMotor(const cpConstraint *constraint) -{ - return (constraint->klass == &klass); -} - -cpFloat -cpSimpleMotorGetRate(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsSimpleMotor(constraint), "Constraint is not a pin joint."); - return ((cpSimpleMotor *)constraint)->rate; -} - -void -cpSimpleMotorSetRate(cpConstraint *constraint, cpFloat rate) -{ - cpAssertHard(cpConstraintIsSimpleMotor(constraint), "Constraint is not a pin joint."); - cpConstraintActivateBodies(constraint); - ((cpSimpleMotor *)constraint)->rate = rate; -} diff --git a/thirdparty/src/chipmunk/cpSlideJoint.c b/thirdparty/src/chipmunk/cpSlideJoint.c deleted file mode 100644 index 61afe33e4..000000000 --- a/thirdparty/src/chipmunk/cpSlideJoint.c +++ /dev/null @@ -1,195 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -static void -preStep(cpSlideJoint *joint, cpFloat dt) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - joint->r1 = cpTransformVect(a->transform, cpvsub(joint->anchorA, a->cog)); - joint->r2 = cpTransformVect(b->transform, cpvsub(joint->anchorB, b->cog)); - - cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1)); - cpFloat dist = cpvlength(delta); - cpFloat pdist = 0.0f; - if(dist > joint->max) { - pdist = dist - joint->max; - joint->n = cpvnormalize(delta); - } else if(dist < joint->min) { - pdist = joint->min - dist; - joint->n = cpvneg(cpvnormalize(delta)); - } else { - joint->n = cpvzero; - joint->jnAcc = 0.0f; - } - - // calculate mass normal - joint->nMass = 1.0f/k_scalar(a, b, joint->r1, joint->r2, joint->n); - - // calculate bias velocity - cpFloat maxBias = joint->constraint.maxBias; - joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*pdist/dt, -maxBias, maxBias); -} - -static void -applyCachedImpulse(cpSlideJoint *joint, cpFloat dt_coef) -{ - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpVect j = cpvmult(joint->n, joint->jnAcc*dt_coef); - apply_impulses(a, b, joint->r1, joint->r2, j); -} - -static void -applyImpulse(cpSlideJoint *joint, cpFloat dt) -{ - if(cpveql(joint->n, cpvzero)) return; // early exit - - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpVect n = joint->n; - cpVect r1 = joint->r1; - cpVect r2 = joint->r2; - - // compute relative velocity - cpVect vr = relative_velocity(a, b, r1, r2); - cpFloat vrn = cpvdot(vr, n); - - // compute normal impulse - cpFloat jn = (joint->bias - vrn)*joint->nMass; - cpFloat jnOld = joint->jnAcc; - joint->jnAcc = cpfclamp(jnOld + jn, -joint->constraint.maxForce*dt, 0.0f); - jn = joint->jnAcc - jnOld; - - // apply impulse - apply_impulses(a, b, joint->r1, joint->r2, cpvmult(n, jn)); -} - -static cpFloat -getImpulse(cpConstraint *joint) -{ - return cpfabs(((cpSlideJoint *)joint)->jnAcc); -} - -static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, -}; - -cpSlideJoint * -cpSlideJointAlloc(void) -{ - return (cpSlideJoint *)cpcalloc(1, sizeof(cpSlideJoint)); -} - -cpSlideJoint * -cpSlideJointInit(cpSlideJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat min, cpFloat max) -{ - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->anchorA = anchorA; - joint->anchorB = anchorB; - joint->min = min; - joint->max = max; - - joint->jnAcc = 0.0f; - - return joint; -} - -cpConstraint * -cpSlideJointNew(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat min, cpFloat max) -{ - return (cpConstraint *)cpSlideJointInit(cpSlideJointAlloc(), a, b, anchorA, anchorB, min, max); -} - -cpBool -cpConstraintIsSlideJoint(const cpConstraint *constraint) -{ - return (constraint->klass == &klass); -} - -cpVect -cpSlideJointGetAnchorA(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsSlideJoint(constraint), "Constraint is not a slide joint."); - return ((cpSlideJoint *)constraint)->anchorA; -} - -void -cpSlideJointSetAnchorA(cpConstraint *constraint, cpVect anchorA) -{ - cpAssertHard(cpConstraintIsSlideJoint(constraint), "Constraint is not a slide joint."); - cpConstraintActivateBodies(constraint); - ((cpSlideJoint *)constraint)->anchorA = anchorA; -} - -cpVect -cpSlideJointGetAnchorB(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsSlideJoint(constraint), "Constraint is not a slide joint."); - return ((cpSlideJoint *)constraint)->anchorB; -} - -void -cpSlideJointSetAnchorB(cpConstraint *constraint, cpVect anchorB) -{ - cpAssertHard(cpConstraintIsSlideJoint(constraint), "Constraint is not a slide joint."); - cpConstraintActivateBodies(constraint); - ((cpSlideJoint *)constraint)->anchorB = anchorB; -} - -cpFloat -cpSlideJointGetMin(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsSlideJoint(constraint), "Constraint is not a slide joint."); - return ((cpSlideJoint *)constraint)->min; -} - -void -cpSlideJointSetMin(cpConstraint *constraint, cpFloat min) -{ - cpAssertHard(cpConstraintIsSlideJoint(constraint), "Constraint is not a slide joint."); - cpConstraintActivateBodies(constraint); - ((cpSlideJoint *)constraint)->min = min; -} - -cpFloat -cpSlideJointGetMax(const cpConstraint *constraint) -{ - cpAssertHard(cpConstraintIsSlideJoint(constraint), "Constraint is not a slide joint."); - return ((cpSlideJoint *)constraint)->max; -} - -void -cpSlideJointSetMax(cpConstraint *constraint, cpFloat max) -{ - cpAssertHard(cpConstraintIsSlideJoint(constraint), "Constraint is not a slide joint."); - cpConstraintActivateBodies(constraint); - ((cpSlideJoint *)constraint)->max = max; -} diff --git a/thirdparty/src/chipmunk/cpSpace.c b/thirdparty/src/chipmunk/cpSpace.c deleted file mode 100644 index 079752d2a..000000000 --- a/thirdparty/src/chipmunk/cpSpace.c +++ /dev/null @@ -1,700 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <stdio.h> -#include <string.h> - -#include "chipmunk/chipmunk_private.h" - -//MARK: Contact Set Helpers - -// Equal function for arbiterSet. -static cpBool -arbiterSetEql(cpShape **shapes, cpArbiter *arb) -{ - cpShape *a = shapes[0]; - cpShape *b = shapes[1]; - - return ((a == arb->a && b == arb->b) || (b == arb->a && a == arb->b)); -} - -//MARK: Collision Handler Set HelperFunctions - -// Equals function for collisionHandlers. -static cpBool -handlerSetEql(cpCollisionHandler *check, cpCollisionHandler *pair) -{ - return ( - (check->typeA == pair->typeA && check->typeB == pair->typeB) || - (check->typeB == pair->typeA && check->typeA == pair->typeB) - ); -} - -// Transformation function for collisionHandlers. -static void * -handlerSetTrans(cpCollisionHandler *handler, void *unused) -{ - cpCollisionHandler *copy = (cpCollisionHandler *)cpcalloc(1, sizeof(cpCollisionHandler)); - memcpy(copy, handler, sizeof(cpCollisionHandler)); - - return copy; -} - -//MARK: Misc Helper Funcs - -// Default collision functions. - -static cpBool -DefaultBegin(cpArbiter *arb, cpSpace *space, void *data){ - cpBool retA = cpArbiterCallWildcardBeginA(arb, space); - cpBool retB = cpArbiterCallWildcardBeginB(arb, space); - return retA && retB; -} - -static cpBool -DefaultPreSolve(cpArbiter *arb, cpSpace *space, void *data){ - cpBool retA = cpArbiterCallWildcardPreSolveA(arb, space); - cpBool retB = cpArbiterCallWildcardPreSolveB(arb, space); - return retA && retB; -} - -static void -DefaultPostSolve(cpArbiter *arb, cpSpace *space, void *data){ - cpArbiterCallWildcardPostSolveA(arb, space); - cpArbiterCallWildcardPostSolveB(arb, space); -} - -static void -DefaultSeparate(cpArbiter *arb, cpSpace *space, void *data){ - cpArbiterCallWildcardSeparateA(arb, space); - cpArbiterCallWildcardSeparateB(arb, space); -} - -// Use the wildcard identifier since the default handler should never match any type pair. -static cpCollisionHandler cpCollisionHandlerDefault = { - CP_WILDCARD_COLLISION_TYPE, CP_WILDCARD_COLLISION_TYPE, - DefaultBegin, DefaultPreSolve, DefaultPostSolve, DefaultSeparate, NULL -}; - -static cpBool AlwaysCollide(cpArbiter *arb, cpSpace *space, void *data){return cpTrue;} -static void DoNothing(cpArbiter *arb, cpSpace *space, void *data){} - -cpCollisionHandler cpCollisionHandlerDoNothing = { - CP_WILDCARD_COLLISION_TYPE, CP_WILDCARD_COLLISION_TYPE, - AlwaysCollide, AlwaysCollide, DoNothing, DoNothing, NULL -}; - -// function to get the estimated velocity of a shape for the cpBBTree. -static cpVect ShapeVelocityFunc(cpShape *shape){return shape->body->v;} - -// Used for disposing of collision handlers. -static void FreeWrap(void *ptr, void *unused){cpfree(ptr);} - -//MARK: Memory Management Functions - -cpSpace * -cpSpaceAlloc(void) -{ - return (cpSpace *)cpcalloc(1, sizeof(cpSpace)); -} - -cpSpace* -cpSpaceInit(cpSpace *space) -{ -#ifndef NDEBUG - static cpBool done = cpFalse; - if(!done){ - printf("Initializing cpSpace - Chipmunk v%s (Debug Enabled)\n", cpVersionString); - printf("Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks\n"); - done = cpTrue; - } -#endif - - space->iterations = 10; - - space->gravity = cpvzero; - space->damping = 1.0f; - - space->collisionSlop = 0.1f; - space->collisionBias = cpfpow(1.0f - 0.1f, 60.0f); - space->collisionPersistence = 3; - - space->locked = 0; - space->stamp = 0; - - space->shapeIDCounter = 0; - space->staticShapes = cpBBTreeNew((cpSpatialIndexBBFunc)cpShapeGetBB, NULL); - space->dynamicShapes = cpBBTreeNew((cpSpatialIndexBBFunc)cpShapeGetBB, space->staticShapes); - cpBBTreeSetVelocityFunc(space->dynamicShapes, (cpBBTreeVelocityFunc)ShapeVelocityFunc); - - space->allocatedBuffers = cpArrayNew(0); - - space->dynamicBodies = cpArrayNew(0); - space->staticBodies = cpArrayNew(0); - space->sleepingComponents = cpArrayNew(0); - space->rousedBodies = cpArrayNew(0); - - space->sleepTimeThreshold = INFINITY; - space->idleSpeedThreshold = 0.0f; - - space->arbiters = cpArrayNew(0); - space->pooledArbiters = cpArrayNew(0); - - space->contactBuffersHead = NULL; - space->cachedArbiters = cpHashSetNew(0, (cpHashSetEqlFunc)arbiterSetEql); - - space->constraints = cpArrayNew(0); - - space->usesWildcards = cpFalse; - memcpy(&space->defaultHandler, &cpCollisionHandlerDoNothing, sizeof(cpCollisionHandler)); - space->collisionHandlers = cpHashSetNew(0, (cpHashSetEqlFunc)handlerSetEql); - - space->postStepCallbacks = cpArrayNew(0); - space->skipPostStep = cpFalse; - - cpBody *staticBody = cpBodyInit(&space->_staticBody, 0.0f, 0.0f); - cpBodySetType(staticBody, CP_BODY_TYPE_STATIC); - cpSpaceSetStaticBody(space, staticBody); - - return space; -} - -cpSpace* -cpSpaceNew(void) -{ - return cpSpaceInit(cpSpaceAlloc()); -} - -static void cpBodyActivateWrap(cpBody *body, void *unused){cpBodyActivate(body);} - -void -cpSpaceDestroy(cpSpace *space) -{ - cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)cpBodyActivateWrap, NULL); - - cpSpatialIndexFree(space->staticShapes); - cpSpatialIndexFree(space->dynamicShapes); - - cpArrayFree(space->dynamicBodies); - cpArrayFree(space->staticBodies); - cpArrayFree(space->sleepingComponents); - cpArrayFree(space->rousedBodies); - - cpArrayFree(space->constraints); - - cpHashSetFree(space->cachedArbiters); - - cpArrayFree(space->arbiters); - cpArrayFree(space->pooledArbiters); - - if(space->allocatedBuffers){ - cpArrayFreeEach(space->allocatedBuffers, cpfree); - cpArrayFree(space->allocatedBuffers); - } - - if(space->postStepCallbacks){ - cpArrayFreeEach(space->postStepCallbacks, cpfree); - cpArrayFree(space->postStepCallbacks); - } - - if(space->collisionHandlers) cpHashSetEach(space->collisionHandlers, FreeWrap, NULL); - cpHashSetFree(space->collisionHandlers); -} - -void -cpSpaceFree(cpSpace *space) -{ - if(space){ - cpSpaceDestroy(space); - cpfree(space); - } -} - - -//MARK: Basic properties: - -int -cpSpaceGetIterations(const cpSpace *space) -{ - return space->iterations; -} - -void -cpSpaceSetIterations(cpSpace *space, int iterations) -{ - cpAssertHard(iterations > 0, "Iterations must be positive and non-zero."); - space->iterations = iterations; -} - -cpVect -cpSpaceGetGravity(const cpSpace *space) -{ - return space->gravity; -} - -void -cpSpaceSetGravity(cpSpace *space, cpVect gravity) -{ - space->gravity = gravity; - - // Wake up all of the bodies since the gravity changed. - cpArray *components = space->sleepingComponents; - for(int i=0; i<components->num; i++){ - cpBodyActivate((cpBody *)components->arr[i]); - } -} - -cpFloat -cpSpaceGetDamping(const cpSpace *space) -{ - return space->damping; -} - -void -cpSpaceSetDamping(cpSpace *space, cpFloat damping) -{ - cpAssertHard(damping >= 0.0, "Damping must be positive."); - space->damping = damping; -} - -cpFloat -cpSpaceGetIdleSpeedThreshold(const cpSpace *space) -{ - return space->idleSpeedThreshold; -} - -void -cpSpaceSetIdleSpeedThreshold(cpSpace *space, cpFloat idleSpeedThreshold) -{ - space->idleSpeedThreshold = idleSpeedThreshold; -} - -cpFloat -cpSpaceGetSleepTimeThreshold(const cpSpace *space) -{ - return space->sleepTimeThreshold; -} - -void -cpSpaceSetSleepTimeThreshold(cpSpace *space, cpFloat sleepTimeThreshold) -{ - space->sleepTimeThreshold = sleepTimeThreshold; -} - -cpFloat -cpSpaceGetCollisionSlop(const cpSpace *space) -{ - return space->collisionSlop; -} - -void -cpSpaceSetCollisionSlop(cpSpace *space, cpFloat collisionSlop) -{ - space->collisionSlop = collisionSlop; -} - -cpFloat -cpSpaceGetCollisionBias(const cpSpace *space) -{ - return space->collisionBias; -} - -void -cpSpaceSetCollisionBias(cpSpace *space, cpFloat collisionBias) -{ - space->collisionBias = collisionBias; -} - -cpTimestamp -cpSpaceGetCollisionPersistence(const cpSpace *space) -{ - return space->collisionPersistence; -} - -void -cpSpaceSetCollisionPersistence(cpSpace *space, cpTimestamp collisionPersistence) -{ - space->collisionPersistence = collisionPersistence; -} - -cpDataPointer -cpSpaceGetUserData(const cpSpace *space) -{ - return space->userData; -} - -void -cpSpaceSetUserData(cpSpace *space, cpDataPointer userData) -{ - space->userData = userData; -} - -cpBody * -cpSpaceGetStaticBody(const cpSpace *space) -{ - return space->staticBody; -} - -cpFloat -cpSpaceGetCurrentTimeStep(const cpSpace *space) -{ - return space->curr_dt; -} - -void -cpSpaceSetStaticBody(cpSpace *space, cpBody *body) -{ - if(space->staticBody != NULL){ - cpAssertHard(space->staticBody->shapeList == NULL, "Internal Error: Changing the designated static body while the old one still had shapes attached."); - space->staticBody->space = NULL; - } - - space->staticBody = body; - body->space = space; -} - -cpBool -cpSpaceIsLocked(cpSpace *space) -{ - return (space->locked > 0); -} - -//MARK: Collision Handler Function Management - -static void -cpSpaceUseWildcardDefaultHandler(cpSpace *space) -{ - // Spaces default to using the slightly faster "do nothing" default handler until wildcards are potentially needed. - if(!space->usesWildcards){ - space->usesWildcards = cpTrue; - memcpy(&space->defaultHandler, &cpCollisionHandlerDefault, sizeof(cpCollisionHandler)); - } -} - -cpCollisionHandler *cpSpaceAddDefaultCollisionHandler(cpSpace *space) -{ - cpSpaceUseWildcardDefaultHandler(space); - return &space->defaultHandler; -} - -cpCollisionHandler *cpSpaceAddCollisionHandler(cpSpace *space, cpCollisionType a, cpCollisionType b) -{ - cpHashValue hash = CP_HASH_PAIR(a, b); - cpCollisionHandler handler = {a, b, DefaultBegin, DefaultPreSolve, DefaultPostSolve, DefaultSeparate, NULL}; - return (cpCollisionHandler*)cpHashSetInsert(space->collisionHandlers, hash, &handler, (cpHashSetTransFunc)handlerSetTrans, NULL); -} - -cpCollisionHandler * -cpSpaceAddWildcardHandler(cpSpace *space, cpCollisionType type) -{ - cpSpaceUseWildcardDefaultHandler(space); - - cpHashValue hash = CP_HASH_PAIR(type, CP_WILDCARD_COLLISION_TYPE); - cpCollisionHandler handler = {type, CP_WILDCARD_COLLISION_TYPE, AlwaysCollide, AlwaysCollide, DoNothing, DoNothing, NULL}; - return (cpCollisionHandler*)cpHashSetInsert(space->collisionHandlers, hash, &handler, (cpHashSetTransFunc)handlerSetTrans, NULL); -} - - -//MARK: Body, Shape, and Joint Management -cpShape * -cpSpaceAddShape(cpSpace *space, cpShape *shape) -{ - cpBody *body = shape->body; - - cpAssertHard(shape->space != space, "You have already added this shape to this space. You must not add it a second time."); - cpAssertHard(!shape->space, "You have already added this shape to another space. You cannot add it to a second."); -// cpAssertHard(body->space == space, "The shape's body must be added to the space before the shape."); - cpAssertSpaceUnlocked(space); - - cpBool isStatic = (cpBodyGetType(body) == CP_BODY_TYPE_STATIC); - if(!isStatic) cpBodyActivate(body); - cpBodyAddShape(body, shape); - - shape->hashid = space->shapeIDCounter++; - cpShapeUpdate(shape, body->transform); - cpSpatialIndexInsert(isStatic ? space->staticShapes : space->dynamicShapes, shape, shape->hashid); - shape->space = space; - - return shape; -} - -cpBody * -cpSpaceAddBody(cpSpace *space, cpBody *body) -{ - cpAssertHard(body->space != space, "You have already added this body to this space. You must not add it a second time."); - cpAssertHard(!body->space, "You have already added this body to another space. You cannot add it to a second."); - cpAssertSpaceUnlocked(space); - - cpArrayPush(cpSpaceArrayForBodyType(space, cpBodyGetType(body)), body); - body->space = space; - - return body; -} - -cpConstraint * -cpSpaceAddConstraint(cpSpace *space, cpConstraint *constraint) -{ - cpAssertHard(constraint->space != space, "You have already added this constraint to this space. You must not add it a second time."); - cpAssertHard(!constraint->space, "You have already added this constraint to another space. You cannot add it to a second."); - cpAssertSpaceUnlocked(space); - - cpBody *a = constraint->a, *b = constraint->b; - cpAssertHard(a != NULL && b != NULL, "Constraint is attached to a NULL body."); -// cpAssertHard(a->space == space && b->space == space, "The constraint's bodies must be added to the space before the constraint."); - - cpBodyActivate(a); - cpBodyActivate(b); - cpArrayPush(space->constraints, constraint); - - // Push onto the heads of the bodies' constraint lists - constraint->next_a = a->constraintList; a->constraintList = constraint; - constraint->next_b = b->constraintList; b->constraintList = constraint; - constraint->space = space; - - return constraint; -} - -struct arbiterFilterContext { - cpSpace *space; - cpBody *body; - cpShape *shape; -}; - -static cpBool -cachedArbitersFilter(cpArbiter *arb, struct arbiterFilterContext *context) -{ - cpShape *shape = context->shape; - cpBody *body = context->body; - - - // Match on the filter shape, or if it's NULL the filter body - if( - (body == arb->body_a && (shape == arb->a || shape == NULL)) || - (body == arb->body_b && (shape == arb->b || shape == NULL)) - ){ - // Call separate when removing shapes. - if(shape && arb->state != CP_ARBITER_STATE_CACHED){ - // Invalidate the arbiter since one of the shapes was removed. - arb->state = CP_ARBITER_STATE_INVALIDATED; - - cpCollisionHandler *handler = arb->handler; - handler->separateFunc(arb, context->space, handler->userData); - } - - cpArbiterUnthread(arb); - cpArrayDeleteObj(context->space->arbiters, arb); - cpArrayPush(context->space->pooledArbiters, arb); - - return cpFalse; - } - - return cpTrue; -} - -void -cpSpaceFilterArbiters(cpSpace *space, cpBody *body, cpShape *filter) -{ - cpSpaceLock(space); { - struct arbiterFilterContext context = {space, body, filter}; - cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)cachedArbitersFilter, &context); - } cpSpaceUnlock(space, cpTrue); -} - -void -cpSpaceRemoveShape(cpSpace *space, cpShape *shape) -{ - cpBody *body = shape->body; - cpAssertHard(cpSpaceContainsShape(space, shape), "Cannot remove a shape that was not added to the space. (Removed twice maybe?)"); - cpAssertSpaceUnlocked(space); - - cpBool isStatic = (cpBodyGetType(body) == CP_BODY_TYPE_STATIC); - if(isStatic){ - cpBodyActivateStatic(body, shape); - } else { - cpBodyActivate(body); - } - - cpBodyRemoveShape(body, shape); - cpSpaceFilterArbiters(space, body, shape); - cpSpatialIndexRemove(isStatic ? space->staticShapes : space->dynamicShapes, shape, shape->hashid); - shape->space = NULL; - shape->hashid = 0; -} - -void -cpSpaceRemoveBody(cpSpace *space, cpBody *body) -{ - cpAssertHard(body != cpSpaceGetStaticBody(space), "Cannot remove the designated static body for the space."); - cpAssertHard(cpSpaceContainsBody(space, body), "Cannot remove a body that was not added to the space. (Removed twice maybe?)"); -// cpAssertHard(body->shapeList == NULL, "Cannot remove a body from the space before removing the bodies attached to it."); -// cpAssertHard(body->constraintList == NULL, "Cannot remove a body from the space before removing the constraints attached to it."); - cpAssertSpaceUnlocked(space); - - cpBodyActivate(body); -// cpSpaceFilterArbiters(space, body, NULL); - cpArrayDeleteObj(cpSpaceArrayForBodyType(space, cpBodyGetType(body)), body); - body->space = NULL; -} - -void -cpSpaceRemoveConstraint(cpSpace *space, cpConstraint *constraint) -{ - cpAssertHard(cpSpaceContainsConstraint(space, constraint), "Cannot remove a constraint that was not added to the space. (Removed twice maybe?)"); - cpAssertSpaceUnlocked(space); - - cpBodyActivate(constraint->a); - cpBodyActivate(constraint->b); - cpArrayDeleteObj(space->constraints, constraint); - - cpBodyRemoveConstraint(constraint->a, constraint); - cpBodyRemoveConstraint(constraint->b, constraint); - constraint->space = NULL; -} - -cpBool cpSpaceContainsShape(cpSpace *space, cpShape *shape) -{ - return (shape->space == space); -} - -cpBool cpSpaceContainsBody(cpSpace *space, cpBody *body) -{ - return (body->space == space); -} - -cpBool cpSpaceContainsConstraint(cpSpace *space, cpConstraint *constraint) -{ - return (constraint->space == space); -} - -//MARK: Iteration - -void -cpSpaceEachBody(cpSpace *space, cpSpaceBodyIteratorFunc func, void *data) -{ - cpSpaceLock(space); { - cpArray *bodies = space->dynamicBodies; - for(int i=0; i<bodies->num; i++){ - func((cpBody *)bodies->arr[i], data); - } - - cpArray *otherBodies = space->staticBodies; - for(int i=0; i<otherBodies->num; i++){ - func((cpBody *)otherBodies->arr[i], data); - } - - cpArray *components = space->sleepingComponents; - for(int i=0; i<components->num; i++){ - cpBody *root = (cpBody *)components->arr[i]; - - cpBody *body = root; - while(body){ - cpBody *next = body->sleeping.next; - func(body, data); - body = next; - } - } - } cpSpaceUnlock(space, cpTrue); -} - -typedef struct spaceShapeContext { - cpSpaceShapeIteratorFunc func; - void *data; -} spaceShapeContext; - -static void -spaceEachShapeIterator(cpShape *shape, spaceShapeContext *context) -{ - context->func(shape, context->data); -} - -void -cpSpaceEachShape(cpSpace *space, cpSpaceShapeIteratorFunc func, void *data) -{ - cpSpaceLock(space); { - spaceShapeContext context = {func, data}; - cpSpatialIndexEach(space->dynamicShapes, (cpSpatialIndexIteratorFunc)spaceEachShapeIterator, &context); - cpSpatialIndexEach(space->staticShapes, (cpSpatialIndexIteratorFunc)spaceEachShapeIterator, &context); - } cpSpaceUnlock(space, cpTrue); -} - -void -cpSpaceEachConstraint(cpSpace *space, cpSpaceConstraintIteratorFunc func, void *data) -{ - cpSpaceLock(space); { - cpArray *constraints = space->constraints; - - for(int i=0; i<constraints->num; i++){ - func((cpConstraint *)constraints->arr[i], data); - } - } cpSpaceUnlock(space, cpTrue); -} - -//MARK: Spatial Index Management - -void -cpSpaceReindexStatic(cpSpace *space) -{ - cpAssertHard(!space->locked, "You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete."); - - cpSpatialIndexEach(space->staticShapes, (cpSpatialIndexIteratorFunc)&cpShapeUpdateFunc, NULL); - cpSpatialIndexReindex(space->staticShapes); -} - -void -cpSpaceReindexShape(cpSpace *space, cpShape *shape) -{ - cpAssertHard(!space->locked, "You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete."); - - cpShapeCacheBB(shape); - - // attempt to rehash the shape in both hashes - cpSpatialIndexReindexObject(space->dynamicShapes, shape, shape->hashid); - cpSpatialIndexReindexObject(space->staticShapes, shape, shape->hashid); -} - -void -cpSpaceReindexShapesForBody(cpSpace *space, cpBody *body) -{ - CP_BODY_FOREACH_SHAPE(body, shape) cpSpaceReindexShape(space, shape); -} - - -static void -copyShapes(cpShape *shape, cpSpatialIndex *index) -{ - cpSpatialIndexInsert(index, shape, shape->hashid); -} - -void -cpSpaceUseSpatialHash(cpSpace *space, cpFloat dim, int count) -{ - cpSpatialIndex *staticShapes = cpSpaceHashNew(dim, count, (cpSpatialIndexBBFunc)cpShapeGetBB, NULL); - cpSpatialIndex *dynamicShapes = cpSpaceHashNew(dim, count, (cpSpatialIndexBBFunc)cpShapeGetBB, staticShapes); - - cpSpatialIndexEach(space->staticShapes, (cpSpatialIndexIteratorFunc)copyShapes, staticShapes); - cpSpatialIndexEach(space->dynamicShapes, (cpSpatialIndexIteratorFunc)copyShapes, dynamicShapes); - - cpSpatialIndexFree(space->staticShapes); - cpSpatialIndexFree(space->dynamicShapes); - - space->staticShapes = staticShapes; - space->dynamicShapes = dynamicShapes; -} diff --git a/thirdparty/src/chipmunk/cpSpaceComponent.c b/thirdparty/src/chipmunk/cpSpaceComponent.c deleted file mode 100644 index 7b2d60699..000000000 --- a/thirdparty/src/chipmunk/cpSpaceComponent.c +++ /dev/null @@ -1,349 +0,0 @@ -/* Copyright (c) 2007 Scott Lembcke - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include <string.h> - -#include "chipmunk/chipmunk_private.h" - -//MARK: Sleeping Functions - -void -cpSpaceActivateBody(cpSpace *space, cpBody *body) -{ - cpAssertHard(cpBodyGetType(body) == CP_BODY_TYPE_DYNAMIC, "Internal error: Attempting to activate a non-dynamic body."); - - if(space->locked){ - // cpSpaceActivateBody() is called again once the space is unlocked - if(!cpArrayContains(space->rousedBodies, body)) cpArrayPush(space->rousedBodies, body); - } else { - cpAssertSoft(body->sleeping.root == NULL && body->sleeping.next == NULL, "Internal error: Activating body non-NULL node pointers."); - cpArrayPush(space->dynamicBodies, body); - - CP_BODY_FOREACH_SHAPE(body, shape){ - cpSpatialIndexRemove(space->staticShapes, shape, shape->hashid); - cpSpatialIndexInsert(space->dynamicShapes, shape, shape->hashid); - } - - CP_BODY_FOREACH_ARBITER(body, arb){ - cpBody *bodyA = arb->body_a; - - // Arbiters are shared between two bodies that are always woken up together. - // You only want to restore the arbiter once, so bodyA is arbitrarily chosen to own the arbiter. - // The edge case is when static bodies are involved as the static bodies never actually sleep. - // If the static body is bodyB then all is good. If the static body is bodyA, that can easily be checked. - if(body == bodyA || cpBodyGetType(bodyA) == CP_BODY_TYPE_STATIC){ - int numContacts = arb->count; - struct cpContact *contacts = arb->contacts; - - // Restore contact values back to the space's contact buffer memory - arb->contacts = cpContactBufferGetArray(space); - memcpy(arb->contacts, contacts, numContacts*sizeof(struct cpContact)); - cpSpacePushContacts(space, numContacts); - - // Reinsert the arbiter into the arbiter cache - const cpShape *a = arb->a, *b = arb->b; - const cpShape *shape_pair[] = {a, b}; - cpHashValue arbHashID = CP_HASH_PAIR((cpHashValue)a, (cpHashValue)b); - cpHashSetInsert(space->cachedArbiters, arbHashID, shape_pair, NULL, arb); - - // Update the arbiter's state - arb->stamp = space->stamp; - cpArrayPush(space->arbiters, arb); - - cpfree(contacts); - } - } - - CP_BODY_FOREACH_CONSTRAINT(body, constraint){ - cpBody *bodyA = constraint->a; - if(body == bodyA || cpBodyGetType(bodyA) == CP_BODY_TYPE_STATIC) cpArrayPush(space->constraints, constraint); - } - } -} - -static void -cpSpaceDeactivateBody(cpSpace *space, cpBody *body) -{ - cpAssertHard(cpBodyGetType(body) == CP_BODY_TYPE_DYNAMIC, "Internal error: Attempting to deactivate a non-dynamic body."); - - cpArrayDeleteObj(space->dynamicBodies, body); - - CP_BODY_FOREACH_SHAPE(body, shape){ - cpSpatialIndexRemove(space->dynamicShapes, shape, shape->hashid); - cpSpatialIndexInsert(space->staticShapes, shape, shape->hashid); - } - - CP_BODY_FOREACH_ARBITER(body, arb){ - cpBody *bodyA = arb->body_a; - if(body == bodyA || cpBodyGetType(bodyA) == CP_BODY_TYPE_STATIC){ - cpSpaceUncacheArbiter(space, arb); - - // Save contact values to a new block of memory so they won't time out - size_t bytes = arb->count*sizeof(struct cpContact); - struct cpContact *contacts = (struct cpContact *)cpcalloc(1, bytes); - memcpy(contacts, arb->contacts, bytes); - arb->contacts = contacts; - } - } - - CP_BODY_FOREACH_CONSTRAINT(body, constraint){ - cpBody *bodyA = constraint->a; - if(body == bodyA || cpBodyGetType(bodyA) == CP_BODY_TYPE_STATIC) cpArrayDeleteObj(space->constraints, constraint); - } -} - -static inline cpBody * -ComponentRoot(cpBody *body) -{ - return (body ? body->sleeping.root : NULL); -} - -void -cpBodyActivate(cpBody *body) -{ - if(body != NULL && cpBodyGetType(body) == CP_BODY_TYPE_DYNAMIC){ - body->sleeping.idleTime = 0.0f; - - cpBody *root = ComponentRoot(body); - if(root && cpBodyIsSleeping(root)){ - // TODO should cpBodyIsSleeping(root) be an assertion? - cpAssertSoft(cpBodyGetType(root) == CP_BODY_TYPE_DYNAMIC, "Internal Error: Non-dynamic body component root detected."); - - cpSpace *space = root->space; - cpBody *body = root; - while(body){ - cpBody *next = body->sleeping.next; - - body->sleeping.idleTime = 0.0f; - body->sleeping.root = NULL; - body->sleeping.next = NULL; - cpSpaceActivateBody(space, body); - - body = next; - } - - cpArrayDeleteObj(space->sleepingComponents, root); - } - - CP_BODY_FOREACH_ARBITER(body, arb){ - // Reset the idle timer of things the body is touching as well. - // That way things don't get left hanging in the air. - cpBody *other = (arb->body_a == body ? arb->body_b : arb->body_a); - if(cpBodyGetType(other) != CP_BODY_TYPE_STATIC) other->sleeping.idleTime = 0.0f; - } - } -} - -void -cpBodyActivateStatic(cpBody *body, cpShape *filter) -{ - cpAssertHard(cpBodyGetType(body) == CP_BODY_TYPE_STATIC, "cpBodyActivateStatic() called on a non-static body."); - - CP_BODY_FOREACH_ARBITER(body, arb){ - if(!filter || filter == arb->a || filter == arb->b){ - cpBodyActivate(arb->body_a == body ? arb->body_b : arb->body_a); - } - } - - // TODO: should also activate joints? -} - -static inline void -cpBodyPushArbiter(cpBody *body, cpArbiter *arb) -{ - cpAssertSoft(cpArbiterThreadForBody(arb, body)->next == NULL, "Internal Error: Dangling contact graph pointers detected. (A)"); - cpAssertSoft(cpArbiterThreadForBody(arb, body)->prev == NULL, "Internal Error: Dangling contact graph pointers detected. (B)"); - - cpArbiter *next = body->arbiterList; - cpAssertSoft(next == NULL || cpArbiterThreadForBody(next, body)->prev == NULL, "Internal Error: Dangling contact graph pointers detected. (C)"); - cpArbiterThreadForBody(arb, body)->next = next; - - if(next) cpArbiterThreadForBody(next, body)->prev = arb; - body->arbiterList = arb; -} - -static inline void -ComponentAdd(cpBody *root, cpBody *body){ - body->sleeping.root = root; - - if(body != root){ - body->sleeping.next = root->sleeping.next; - root->sleeping.next = body; - } -} - -static inline void -FloodFillComponent(cpBody *root, cpBody *body) -{ - // Kinematic bodies cannot be put to sleep and prevent bodies they are touching from sleeping. - // Static bodies are effectively sleeping all the time. - if(cpBodyGetType(body) == CP_BODY_TYPE_DYNAMIC){ - cpBody *other_root = ComponentRoot(body); - if(other_root == NULL){ - ComponentAdd(root, body); - CP_BODY_FOREACH_ARBITER(body, arb) FloodFillComponent(root, (body == arb->body_a ? arb->body_b : arb->body_a)); - CP_BODY_FOREACH_CONSTRAINT(body, constraint) FloodFillComponent(root, (body == constraint->a ? constraint->b : constraint->a)); - } else { - cpAssertSoft(other_root == root, "Internal Error: Inconsistency dectected in the contact graph."); - } - } -} - -static inline cpBool -ComponentActive(cpBody *root, cpFloat threshold) -{ - CP_BODY_FOREACH_COMPONENT(root, body){ - if(body->sleeping.idleTime < threshold) return cpTrue; - } - - return cpFalse; -} - -void -cpSpaceProcessComponents(cpSpace *space, cpFloat dt) -{ - cpBool sleep = (space->sleepTimeThreshold != INFINITY); - cpArray *bodies = space->dynamicBodies; - -#ifndef NDEBUG - for(int i=0; i<bodies->num; i++){ - cpBody *body = (cpBody*)bodies->arr[i]; - - cpAssertSoft(body->sleeping.next == NULL, "Internal Error: Dangling next pointer detected in contact graph."); - cpAssertSoft(body->sleeping.root == NULL, "Internal Error: Dangling root pointer detected in contact graph."); - } -#endif - - // Calculate the kinetic energy of all the bodies. - if(sleep){ - cpFloat dv = space->idleSpeedThreshold; - cpFloat dvsq = (dv ? dv*dv : cpvlengthsq(space->gravity)*dt*dt); - - // update idling and reset component nodes - for(int i=0; i<bodies->num; i++){ - cpBody *body = (cpBody*)bodies->arr[i]; - - // TODO should make a separate array for kinematic bodies. - if(cpBodyGetType(body) != CP_BODY_TYPE_DYNAMIC) continue; - - // Need to deal with infinite mass objects - cpFloat keThreshold = (dvsq ? body->m*dvsq : 0.0f); - body->sleeping.idleTime = (cpBodyKineticEnergy(body) > keThreshold ? 0.0f : body->sleeping.idleTime + dt); - } - } - - // Awaken any sleeping bodies found and then push arbiters to the bodies' lists. - cpArray *arbiters = space->arbiters; - for(int i=0, count=arbiters->num; i<count; i++){ - cpArbiter *arb = (cpArbiter*)arbiters->arr[i]; - cpBody *a = arb->body_a, *b = arb->body_b; - - if(sleep){ - // TODO checking cpBodyIsSleepin() redundant? - if(cpBodyGetType(b) == CP_BODY_TYPE_KINEMATIC || cpBodyIsSleeping(a)) cpBodyActivate(a); - if(cpBodyGetType(a) == CP_BODY_TYPE_KINEMATIC || cpBodyIsSleeping(b)) cpBodyActivate(b); - } - - cpBodyPushArbiter(a, arb); - cpBodyPushArbiter(b, arb); - } - - if(sleep){ - // Bodies should be held active if connected by a joint to a kinematic. - cpArray *constraints = space->constraints; - for(int i=0; i<constraints->num; i++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; - cpBody *a = constraint->a, *b = constraint->b; - - if(cpBodyGetType(b) == CP_BODY_TYPE_KINEMATIC) cpBodyActivate(a); - if(cpBodyGetType(a) == CP_BODY_TYPE_KINEMATIC) cpBodyActivate(b); - } - - // Generate components and deactivate sleeping ones - for(int i=0; i<bodies->num;){ - cpBody *body = (cpBody*)bodies->arr[i]; - - if(ComponentRoot(body) == NULL){ - // Body not in a component yet. Perform a DFS to flood fill mark - // the component in the contact graph using this body as the root. - FloodFillComponent(body, body); - - // Check if the component should be put to sleep. - if(!ComponentActive(body, space->sleepTimeThreshold)){ - cpArrayPush(space->sleepingComponents, body); - CP_BODY_FOREACH_COMPONENT(body, other) cpSpaceDeactivateBody(space, other); - - // cpSpaceDeactivateBody() removed the current body from the list. - // Skip incrementing the index counter. - continue; - } - } - - i++; - - // Only sleeping bodies retain their component node pointers. - body->sleeping.root = NULL; - body->sleeping.next = NULL; - } - } -} - -void -cpBodySleep(cpBody *body) -{ - cpBodySleepWithGroup(body, NULL); -} - -void -cpBodySleepWithGroup(cpBody *body, cpBody *group){ - cpAssertHard(cpBodyGetType(body) == CP_BODY_TYPE_DYNAMIC, "Non-dynamic bodies cannot be put to sleep."); - - cpSpace *space = body->space; - cpAssertHard(!cpSpaceIsLocked(space), "Bodies cannot be put to sleep during a query or a call to cpSpaceStep(). Put these calls into a post-step callback."); - cpAssertHard(cpSpaceGetSleepTimeThreshold(space) < INFINITY, "Sleeping is not enabled on the space. You cannot sleep a body without setting a sleep time threshold on the space."); - cpAssertHard(group == NULL || cpBodyIsSleeping(group), "Cannot use a non-sleeping body as a group identifier."); - - if(cpBodyIsSleeping(body)){ - cpAssertHard(ComponentRoot(body) == ComponentRoot(group), "The body is already sleeping and it's group cannot be reassigned."); - return; - } - - CP_BODY_FOREACH_SHAPE(body, shape) cpShapeCacheBB(shape); - cpSpaceDeactivateBody(space, body); - - if(group){ - cpBody *root = ComponentRoot(group); - - body->sleeping.root = root; - body->sleeping.next = root->sleeping.next; - body->sleeping.idleTime = 0.0f; - - root->sleeping.next = body; - } else { - body->sleeping.root = body; - body->sleeping.next = NULL; - body->sleeping.idleTime = 0.0f; - - cpArrayPush(space->sleepingComponents, body); - } - - cpArrayDeleteObj(space->dynamicBodies, body); -} diff --git a/thirdparty/src/chipmunk/cpSpaceDebug.c b/thirdparty/src/chipmunk/cpSpaceDebug.c deleted file mode 100644 index 4711ac518..000000000 --- a/thirdparty/src/chipmunk/cpSpaceDebug.c +++ /dev/null @@ -1,189 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -#ifndef CP_SPACE_DISABLE_DEBUG_API - -static void -cpSpaceDebugDrawShape(cpShape *shape, cpSpaceDebugDrawOptions *options) -{ - cpBody *body = shape->body; - cpDataPointer data = options->data; - - cpSpaceDebugColor outline_color = options->shapeOutlineColor; - cpSpaceDebugColor fill_color = options->colorForShape(shape, data); - - switch(shape->klass->type){ - case CP_CIRCLE_SHAPE: { - cpCircleShape *circle = (cpCircleShape *)shape; - options->drawCircle(circle->tc, body->a, circle->r, outline_color, fill_color, data); - break; - } - case CP_SEGMENT_SHAPE: { - cpSegmentShape *seg = (cpSegmentShape *)shape; - options->drawFatSegment(seg->ta, seg->tb, seg->r, outline_color, fill_color, data); - break; - } - case CP_POLY_SHAPE: { - cpPolyShape *poly = (cpPolyShape *)shape; - - int count = poly->count; - struct cpSplittingPlane *planes = poly->planes; - cpVect *verts = (cpVect *)alloca(count*sizeof(cpVect)); - - for(int i=0; i<count; i++) verts[i] = planes[i].v0; - options->drawPolygon(count, verts, poly->r, outline_color, fill_color, data); - break; - } - default: break; - } -} - -static const cpVect spring_verts[] = { - {0.00f, 0.0f}, - {0.20f, 0.0f}, - {0.25f, 3.0f}, - {0.30f,-6.0f}, - {0.35f, 6.0f}, - {0.40f,-6.0f}, - {0.45f, 6.0f}, - {0.50f,-6.0f}, - {0.55f, 6.0f}, - {0.60f,-6.0f}, - {0.65f, 6.0f}, - {0.70f,-3.0f}, - {0.75f, 6.0f}, - {0.80f, 0.0f}, - {1.00f, 0.0f}, -}; -static const int spring_count = sizeof(spring_verts)/sizeof(cpVect); - -static void -cpSpaceDebugDrawConstraint(cpConstraint *constraint, cpSpaceDebugDrawOptions *options) -{ - cpDataPointer data = options->data; - cpSpaceDebugColor color = options->constraintColor; - - cpBody *body_a = constraint->a; - cpBody *body_b = constraint->b; - - if(cpConstraintIsPinJoint(constraint)){ - cpPinJoint *joint = (cpPinJoint *)constraint; - - cpVect a = cpTransformPoint(body_a->transform, joint->anchorA); - cpVect b = cpTransformPoint(body_b->transform, joint->anchorB); - - options->drawDot(5, a, color, data); - options->drawDot(5, b, color, data); - options->drawSegment(a, b, color, data); - } else if(cpConstraintIsSlideJoint(constraint)){ - cpSlideJoint *joint = (cpSlideJoint *)constraint; - - cpVect a = cpTransformPoint(body_a->transform, joint->anchorA); - cpVect b = cpTransformPoint(body_b->transform, joint->anchorB); - - options->drawDot(5, a, color, data); - options->drawDot(5, b, color, data); - options->drawSegment(a, b, color, data); - } else if(cpConstraintIsPivotJoint(constraint)){ - cpPivotJoint *joint = (cpPivotJoint *)constraint; - - cpVect a = cpTransformPoint(body_a->transform, joint->anchorA); - cpVect b = cpTransformPoint(body_b->transform, joint->anchorB); - - options->drawDot(5, a, color, data); - options->drawDot(5, b, color, data); - } else if(cpConstraintIsGrooveJoint(constraint)){ - cpGrooveJoint *joint = (cpGrooveJoint *)constraint; - - cpVect a = cpTransformPoint(body_a->transform, joint->grv_a); - cpVect b = cpTransformPoint(body_a->transform, joint->grv_b); - cpVect c = cpTransformPoint(body_b->transform, joint->anchorB); - - options->drawDot(5, c, color, data); - options->drawSegment(a, b, color, data); - } else if(cpConstraintIsDampedSpring(constraint)){ - cpDampedSpring *spring = (cpDampedSpring *)constraint; - cpDataPointer data = options->data; - cpSpaceDebugColor color = options->constraintColor; - - cpVect a = cpTransformPoint(body_a->transform, spring->anchorA); - cpVect b = cpTransformPoint(body_b->transform, spring->anchorB); - - options->drawDot(5, a, color, data); - options->drawDot(5, b, color, data); - - cpVect delta = cpvsub(b, a); - cpFloat cos = delta.x; - cpFloat sin = delta.y; - cpFloat s = 1.0f/cpvlength(delta); - - cpVect r1 = cpv(cos, -sin*s); - cpVect r2 = cpv(sin, cos*s); - - cpVect *verts = (cpVect *)alloca(spring_count*sizeof(cpVect)); - for(int i=0; i<spring_count; i++){ - cpVect v = spring_verts[i]; - verts[i] = cpv(cpvdot(v, r1) + a.x, cpvdot(v, r2) + a.y); - } - - for(int i=0; i<spring_count-1; i++){ - options->drawSegment(verts[i], verts[i + 1], color, data); - } - } -} - -void -cpSpaceDebugDraw(cpSpace *space, cpSpaceDebugDrawOptions *options) -{ - if(options->flags & CP_SPACE_DEBUG_DRAW_SHAPES){ - cpSpaceEachShape(space, (cpSpaceShapeIteratorFunc)cpSpaceDebugDrawShape, options); - } - - if(options->flags & CP_SPACE_DEBUG_DRAW_CONSTRAINTS){ - cpSpaceEachConstraint(space, (cpSpaceConstraintIteratorFunc)cpSpaceDebugDrawConstraint, options); - } - - if(options->flags & CP_SPACE_DEBUG_DRAW_COLLISION_POINTS){ - cpArray *arbiters = space->arbiters; - cpSpaceDebugColor color = options->collisionPointColor; - cpSpaceDebugDrawSegmentImpl draw_seg = options->drawSegment; - cpDataPointer data = options->data; - - for(int i=0; i<arbiters->num; i++){ - cpArbiter *arb = (cpArbiter*)arbiters->arr[i]; - cpVect n = arb->n; - - for(int j=0; j<arb->count; j++){ - cpVect p1 = cpvadd(arb->body_a->p, arb->contacts[j].r1); - cpVect p2 = cpvadd(arb->body_b->p, arb->contacts[j].r2); - - cpFloat d = 2.0f; - cpVect a = cpvadd(p1, cpvmult(n, -d)); - cpVect b = cpvadd(p2, cpvmult(n, d)); - draw_seg(a, b, color, data); - } - } - } -} - -#endif diff --git a/thirdparty/src/chipmunk/cpSpaceHash.c b/thirdparty/src/chipmunk/cpSpaceHash.c deleted file mode 100644 index 656c3bd6f..000000000 --- a/thirdparty/src/chipmunk/cpSpaceHash.c +++ /dev/null @@ -1,634 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" -#include "prime.h" - -typedef struct cpSpaceHashBin cpSpaceHashBin; -typedef struct cpHandle cpHandle; - -struct cpSpaceHash { - cpSpatialIndex spatialIndex; - - int numcells; - cpFloat celldim; - - cpSpaceHashBin **table; - cpHashSet *handleSet; - - cpSpaceHashBin *pooledBins; - cpArray *pooledHandles; - cpArray *allocatedBuffers; - - cpTimestamp stamp; -}; - - -//MARK: Handle Functions - -struct cpHandle { - void *obj; - int retain; - cpTimestamp stamp; -}; - -static cpHandle* -cpHandleInit(cpHandle *hand, void *obj) -{ - hand->obj = obj; - hand->retain = 0; - hand->stamp = 0; - - return hand; -} - -static inline void cpHandleRetain(cpHandle *hand){hand->retain++;} - -static inline void -cpHandleRelease(cpHandle *hand, cpArray *pooledHandles) -{ - hand->retain--; - if(hand->retain == 0) cpArrayPush(pooledHandles, hand); -} - -static int handleSetEql(void *obj, cpHandle *hand){return (obj == hand->obj);} - -static void * -handleSetTrans(void *obj, cpSpaceHash *hash) -{ - if(hash->pooledHandles->num == 0){ - // handle pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(cpHandle); - cpAssertHard(count, "Internal Error: Buffer size is too small."); - - cpHandle *buffer = (cpHandle *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(hash->allocatedBuffers, buffer); - - for(int i=0; i<count; i++) cpArrayPush(hash->pooledHandles, buffer + i); - } - - cpHandle *hand = cpHandleInit((cpHandle *)cpArrayPop(hash->pooledHandles), obj); - cpHandleRetain(hand); - - return hand; -} - -//MARK: Bin Functions - -struct cpSpaceHashBin { - cpHandle *handle; - cpSpaceHashBin *next; -}; - -static inline void -recycleBin(cpSpaceHash *hash, cpSpaceHashBin *bin) -{ - bin->next = hash->pooledBins; - hash->pooledBins = bin; -} - -static inline void -clearTableCell(cpSpaceHash *hash, int idx) -{ - cpSpaceHashBin *bin = hash->table[idx]; - while(bin){ - cpSpaceHashBin *next = bin->next; - - cpHandleRelease(bin->handle, hash->pooledHandles); - recycleBin(hash, bin); - - bin = next; - } - - hash->table[idx] = NULL; -} - -static void -clearTable(cpSpaceHash *hash) -{ - for(int i=0; i<hash->numcells; i++) clearTableCell(hash, i); -} - -// Get a recycled or new bin. -static inline cpSpaceHashBin * -getEmptyBin(cpSpaceHash *hash) -{ - cpSpaceHashBin *bin = hash->pooledBins; - - if(bin){ - hash->pooledBins = bin->next; - return bin; - } else { - // Pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(cpSpaceHashBin); - cpAssertHard(count, "Internal Error: Buffer size is too small."); - - cpSpaceHashBin *buffer = (cpSpaceHashBin *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(hash->allocatedBuffers, buffer); - - // push all but the first one, return the first instead - for(int i=1; i<count; i++) recycleBin(hash, buffer + i); - return buffer; - } -} - -//MARK: Memory Management Functions - -cpSpaceHash * -cpSpaceHashAlloc(void) -{ - return (cpSpaceHash *)cpcalloc(1, sizeof(cpSpaceHash)); -} - -// Frees the old table, and allocate a new one. -static void -cpSpaceHashAllocTable(cpSpaceHash *hash, int numcells) -{ - cpfree(hash->table); - - hash->numcells = numcells; - hash->table = (cpSpaceHashBin **)cpcalloc(numcells, sizeof(cpSpaceHashBin *)); -} - -static inline cpSpatialIndexClass *Klass(); - -cpSpatialIndex * -cpSpaceHashInit(cpSpaceHash *hash, cpFloat celldim, int numcells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) -{ - cpSpatialIndexInit((cpSpatialIndex *)hash, Klass(), bbfunc, staticIndex); - - cpSpaceHashAllocTable(hash, next_prime(numcells)); - hash->celldim = celldim; - - hash->handleSet = cpHashSetNew(0, (cpHashSetEqlFunc)handleSetEql); - - hash->pooledHandles = cpArrayNew(0); - - hash->pooledBins = NULL; - hash->allocatedBuffers = cpArrayNew(0); - - hash->stamp = 1; - - return (cpSpatialIndex *)hash; -} - -cpSpatialIndex * -cpSpaceHashNew(cpFloat celldim, int cells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) -{ - return cpSpaceHashInit(cpSpaceHashAlloc(), celldim, cells, bbfunc, staticIndex); -} - -static void -cpSpaceHashDestroy(cpSpaceHash *hash) -{ - if(hash->table) clearTable(hash); - cpfree(hash->table); - - cpHashSetFree(hash->handleSet); - - cpArrayFreeEach(hash->allocatedBuffers, cpfree); - cpArrayFree(hash->allocatedBuffers); - cpArrayFree(hash->pooledHandles); -} - -//MARK: Helper Functions - -static inline cpBool -containsHandle(cpSpaceHashBin *bin, cpHandle *hand) -{ - while(bin){ - if(bin->handle == hand) return cpTrue; - bin = bin->next; - } - - return cpFalse; -} - -// The hash function itself. -static inline cpHashValue -hash_func(cpHashValue x, cpHashValue y, cpHashValue n) -{ - return (x*1640531513ul ^ y*2654435789ul) % n; -} - -// Much faster than (int)floor(f) -// Profiling showed floor() to be a sizable performance hog -static inline int -floor_int(cpFloat f) -{ - int i = (int)f; - return (f < 0.0f && f != i ? i - 1 : i); -} - -static inline void -hashHandle(cpSpaceHash *hash, cpHandle *hand, cpBB bb) -{ - // Find the dimensions in cell coordinates. - cpFloat dim = hash->celldim; - int l = floor_int(bb.l/dim); // Fix by ShiftZ - int r = floor_int(bb.r/dim); - int b = floor_int(bb.b/dim); - int t = floor_int(bb.t/dim); - - int n = hash->numcells; - for(int i=l; i<=r; i++){ - for(int j=b; j<=t; j++){ - cpHashValue idx = hash_func(i,j,n); - cpSpaceHashBin *bin = hash->table[idx]; - - // Don't add an object twice to the same cell. - if(containsHandle(bin, hand)) continue; - - cpHandleRetain(hand); - // Insert a new bin for the handle in this cell. - cpSpaceHashBin *newBin = getEmptyBin(hash); - newBin->handle = hand; - newBin->next = bin; - hash->table[idx] = newBin; - } - } -} - -//MARK: Basic Operations - -static void -cpSpaceHashInsert(cpSpaceHash *hash, void *obj, cpHashValue hashid) -{ - cpHandle *hand = (cpHandle *)cpHashSetInsert(hash->handleSet, hashid, obj, (cpHashSetTransFunc)handleSetTrans, hash); - hashHandle(hash, hand, hash->spatialIndex.bbfunc(obj)); -} - -static void -cpSpaceHashRehashObject(cpSpaceHash *hash, void *obj, cpHashValue hashid) -{ - cpHandle *hand = (cpHandle *)cpHashSetRemove(hash->handleSet, hashid, obj); - - if(hand){ - hand->obj = NULL; - cpHandleRelease(hand, hash->pooledHandles); - - cpSpaceHashInsert(hash, obj, hashid); - } -} - -static void -rehash_helper(cpHandle *hand, cpSpaceHash *hash) -{ - hashHandle(hash, hand, hash->spatialIndex.bbfunc(hand->obj)); -} - -static void -cpSpaceHashRehash(cpSpaceHash *hash) -{ - clearTable(hash); - cpHashSetEach(hash->handleSet, (cpHashSetIteratorFunc)rehash_helper, hash); -} - -static void -cpSpaceHashRemove(cpSpaceHash *hash, void *obj, cpHashValue hashid) -{ - cpHandle *hand = (cpHandle *)cpHashSetRemove(hash->handleSet, hashid, obj); - - if(hand){ - hand->obj = NULL; - cpHandleRelease(hand, hash->pooledHandles); - } -} - -typedef struct eachContext { - cpSpatialIndexIteratorFunc func; - void *data; -} eachContext; - -static void eachHelper(cpHandle *hand, eachContext *context){context->func(hand->obj, context->data);} - -static void -cpSpaceHashEach(cpSpaceHash *hash, cpSpatialIndexIteratorFunc func, void *data) -{ - eachContext context = {func, data}; - cpHashSetEach(hash->handleSet, (cpHashSetIteratorFunc)eachHelper, &context); -} - -static void -remove_orphaned_handles(cpSpaceHash *hash, cpSpaceHashBin **bin_ptr) -{ - cpSpaceHashBin *bin = *bin_ptr; - while(bin){ - cpHandle *hand = bin->handle; - cpSpaceHashBin *next = bin->next; - - if(!hand->obj){ - // orphaned handle, unlink and recycle the bin - (*bin_ptr) = bin->next; - recycleBin(hash, bin); - - cpHandleRelease(hand, hash->pooledHandles); - } else { - bin_ptr = &bin->next; - } - - bin = next; - } -} - -//MARK: Query Functions - -static inline void -query_helper(cpSpaceHash *hash, cpSpaceHashBin **bin_ptr, void *obj, cpSpatialIndexQueryFunc func, void *data) -{ - restart: - for(cpSpaceHashBin *bin = *bin_ptr; bin; bin = bin->next){ - cpHandle *hand = bin->handle; - void *other = hand->obj; - - if(hand->stamp == hash->stamp || obj == other){ - continue; - } else if(other){ - func(obj, other, 0, data); - hand->stamp = hash->stamp; - } else { - // The object for this handle has been removed - // cleanup this cell and restart the query - remove_orphaned_handles(hash, bin_ptr); - goto restart; // GCC not smart enough/able to tail call an inlined function. - } - } -} - -static void -cpSpaceHashQuery(cpSpaceHash *hash, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data) -{ - // Get the dimensions in cell coordinates. - cpFloat dim = hash->celldim; - int l = floor_int(bb.l/dim); // Fix by ShiftZ - int r = floor_int(bb.r/dim); - int b = floor_int(bb.b/dim); - int t = floor_int(bb.t/dim); - - int n = hash->numcells; - cpSpaceHashBin **table = hash->table; - - // Iterate over the cells and query them. - for(int i=l; i<=r; i++){ - for(int j=b; j<=t; j++){ - query_helper(hash, &table[hash_func(i,j,n)], obj, func, data); - } - } - - hash->stamp++; -} - -// Similar to struct eachPair above. -typedef struct queryRehashContext { - cpSpaceHash *hash; - cpSpatialIndexQueryFunc func; - void *data; -} queryRehashContext; - -// Hashset iterator func used with cpSpaceHashQueryRehash(). -static void -queryRehash_helper(cpHandle *hand, queryRehashContext *context) -{ - cpSpaceHash *hash = context->hash; - cpSpatialIndexQueryFunc func = context->func; - void *data = context->data; - - cpFloat dim = hash->celldim; - int n = hash->numcells; - - void *obj = hand->obj; - cpBB bb = hash->spatialIndex.bbfunc(obj); - - int l = floor_int(bb.l/dim); - int r = floor_int(bb.r/dim); - int b = floor_int(bb.b/dim); - int t = floor_int(bb.t/dim); - - cpSpaceHashBin **table = hash->table; - - for(int i=l; i<=r; i++){ - for(int j=b; j<=t; j++){ - cpHashValue idx = hash_func(i,j,n); - cpSpaceHashBin *bin = table[idx]; - - if(containsHandle(bin, hand)) continue; - - cpHandleRetain(hand); // this MUST be done first in case the object is removed in func() - query_helper(hash, &bin, obj, func, data); - - cpSpaceHashBin *newBin = getEmptyBin(hash); - newBin->handle = hand; - newBin->next = bin; - table[idx] = newBin; - } - } - - // Increment the stamp for each object hashed. - hash->stamp++; -} - -static void -cpSpaceHashReindexQuery(cpSpaceHash *hash, cpSpatialIndexQueryFunc func, void *data) -{ - clearTable(hash); - - queryRehashContext context = {hash, func, data}; - cpHashSetEach(hash->handleSet, (cpHashSetIteratorFunc)queryRehash_helper, &context); - - cpSpatialIndexCollideStatic((cpSpatialIndex *)hash, hash->spatialIndex.staticIndex, func, data); -} - -static inline cpFloat -segmentQuery_helper(cpSpaceHash *hash, cpSpaceHashBin **bin_ptr, void *obj, cpSpatialIndexSegmentQueryFunc func, void *data) -{ - cpFloat t = 1.0f; - - restart: - for(cpSpaceHashBin *bin = *bin_ptr; bin; bin = bin->next){ - cpHandle *hand = bin->handle; - void *other = hand->obj; - - // Skip over certain conditions - if(hand->stamp == hash->stamp){ - continue; - } else if(other){ - t = cpfmin(t, func(obj, other, data)); - hand->stamp = hash->stamp; - } else { - // The object for this handle has been removed - // cleanup this cell and restart the query - remove_orphaned_handles(hash, bin_ptr); - goto restart; // GCC not smart enough/able to tail call an inlined function. - } - } - - return t; -} - -// modified from http://playtechs.blogspot.com/2007/03/raytracing-on-grid.html -static void -cpSpaceHashSegmentQuery(cpSpaceHash *hash, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data) -{ - a = cpvmult(a, 1.0f/hash->celldim); - b = cpvmult(b, 1.0f/hash->celldim); - - int cell_x = floor_int(a.x), cell_y = floor_int(a.y); - - cpFloat t = 0; - - int x_inc, y_inc; - cpFloat temp_v, temp_h; - - if (b.x > a.x){ - x_inc = 1; - temp_h = (cpffloor(a.x + 1.0f) - a.x); - } else { - x_inc = -1; - temp_h = (a.x - cpffloor(a.x)); - } - - if (b.y > a.y){ - y_inc = 1; - temp_v = (cpffloor(a.y + 1.0f) - a.y); - } else { - y_inc = -1; - temp_v = (a.y - cpffloor(a.y)); - } - - // Division by zero is *very* slow on ARM - cpFloat dx = cpfabs(b.x - a.x), dy = cpfabs(b.y - a.y); - cpFloat dt_dx = (dx ? 1.0f/dx : INFINITY), dt_dy = (dy ? 1.0f/dy : INFINITY); - - // fix NANs in horizontal directions - cpFloat next_h = (temp_h ? temp_h*dt_dx : dt_dx); - cpFloat next_v = (temp_v ? temp_v*dt_dy : dt_dy); - - int n = hash->numcells; - cpSpaceHashBin **table = hash->table; - - while(t < t_exit){ - cpHashValue idx = hash_func(cell_x, cell_y, n); - t_exit = cpfmin(t_exit, segmentQuery_helper(hash, &table[idx], obj, func, data)); - - if (next_v < next_h){ - cell_y += y_inc; - t = next_v; - next_v += dt_dy; - } else { - cell_x += x_inc; - t = next_h; - next_h += dt_dx; - } - } - - hash->stamp++; -} - -//MARK: Misc - -void -cpSpaceHashResize(cpSpaceHash *hash, cpFloat celldim, int numcells) -{ - if(hash->spatialIndex.klass != Klass()){ - cpAssertWarn(cpFalse, "Ignoring cpSpaceHashResize() call to non-cpSpaceHash spatial index."); - return; - } - - clearTable(hash); - - hash->celldim = celldim; - cpSpaceHashAllocTable(hash, next_prime(numcells)); -} - -static int -cpSpaceHashCount(cpSpaceHash *hash) -{ - return cpHashSetCount(hash->handleSet); -} - -static int -cpSpaceHashContains(cpSpaceHash *hash, void *obj, cpHashValue hashid) -{ - return cpHashSetFind(hash->handleSet, hashid, obj) != NULL; -} - -static cpSpatialIndexClass klass = { - (cpSpatialIndexDestroyImpl)cpSpaceHashDestroy, - - (cpSpatialIndexCountImpl)cpSpaceHashCount, - (cpSpatialIndexEachImpl)cpSpaceHashEach, - (cpSpatialIndexContainsImpl)cpSpaceHashContains, - - (cpSpatialIndexInsertImpl)cpSpaceHashInsert, - (cpSpatialIndexRemoveImpl)cpSpaceHashRemove, - - (cpSpatialIndexReindexImpl)cpSpaceHashRehash, - (cpSpatialIndexReindexObjectImpl)cpSpaceHashRehashObject, - (cpSpatialIndexReindexQueryImpl)cpSpaceHashReindexQuery, - - (cpSpatialIndexQueryImpl)cpSpaceHashQuery, - (cpSpatialIndexSegmentQueryImpl)cpSpaceHashSegmentQuery, -}; - -static inline cpSpatialIndexClass *Klass(){return &klass;} - -//MARK: Debug Drawing - -//#define CP_BBTREE_DEBUG_DRAW -#ifdef CP_BBTREE_DEBUG_DRAW -#include "OpenGL/gl.h" -#include "OpenGL/glu.h" -#include <GLUT/glut.h> - -void -cpSpaceHashRenderDebug(cpSpatialIndex *index) -{ - if(index->klass != &klass){ - cpAssertWarn(cpFalse, "Ignoring cpSpaceHashRenderDebug() call to non-spatial hash spatial index."); - return; - } - - cpSpaceHash *hash = (cpSpaceHash *)index; - cpBB bb = cpBBNew(-320, -240, 320, 240); - - cpFloat dim = hash->celldim; - int n = hash->numcells; - - int l = (int)floor(bb.l/dim); - int r = (int)floor(bb.r/dim); - int b = (int)floor(bb.b/dim); - int t = (int)floor(bb.t/dim); - - for(int i=l; i<=r; i++){ - for(int j=b; j<=t; j++){ - int cell_count = 0; - - int index = hash_func(i,j,n); - for(cpSpaceHashBin *bin = hash->table[index]; bin; bin = bin->next) - cell_count++; - - GLfloat v = 1.0f - (GLfloat)cell_count/10.0f; - glColor3f(v,v,v); - glRectf(i*dim, j*dim, (i + 1)*dim, (j + 1)*dim); - } - } -} -#endif diff --git a/thirdparty/src/chipmunk/cpSpaceQuery.c b/thirdparty/src/chipmunk/cpSpaceQuery.c deleted file mode 100644 index 1ce4a10c1..000000000 --- a/thirdparty/src/chipmunk/cpSpaceQuery.c +++ /dev/null @@ -1,246 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -//MARK: Nearest Point Query Functions - -struct PointQueryContext { - cpVect point; - cpFloat maxDistance; - cpShapeFilter filter; - cpSpacePointQueryFunc func; -}; - -static cpCollisionID -NearestPointQuery(struct PointQueryContext *context, cpShape *shape, cpCollisionID id, void *data) -{ - if( - !cpShapeFilterReject(shape->filter, context->filter) - ){ - cpPointQueryInfo info; - cpShapePointQuery(shape, context->point, &info); - - if(info.shape && info.distance < context->maxDistance) context->func(shape, info.point, info.distance, info.gradient, data); - } - - return id; -} - -void -cpSpacePointQuery(cpSpace *space, cpVect point, cpFloat maxDistance, cpShapeFilter filter, cpSpacePointQueryFunc func, void *data) -{ - struct PointQueryContext context = {point, maxDistance, filter, func}; - cpBB bb = cpBBNewForCircle(point, cpfmax(maxDistance, 0.0f)); - - cpSpaceLock(space); { - cpSpatialIndexQuery(space->dynamicShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQuery, data); - cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQuery, data); - } cpSpaceUnlock(space, cpTrue); -} - -static cpCollisionID -NearestPointQueryNearest(struct PointQueryContext *context, cpShape *shape, cpCollisionID id, cpPointQueryInfo *out) -{ - if( - !cpShapeFilterReject(shape->filter, context->filter) && !shape->sensor - ){ - cpPointQueryInfo info; - cpShapePointQuery(shape, context->point, &info); - - if(info.distance < out->distance) (*out) = info; - } - - return id; -} - -cpShape * -cpSpacePointQueryNearest(cpSpace *space, cpVect point, cpFloat maxDistance, cpShapeFilter filter, cpPointQueryInfo *out) -{ - cpPointQueryInfo info = {NULL, cpvzero, maxDistance, cpvzero}; - if(out){ - (*out) = info; - } else { - out = &info; - } - - struct PointQueryContext context = { - point, maxDistance, - filter, - NULL - }; - - cpBB bb = cpBBNewForCircle(point, cpfmax(maxDistance, 0.0f)); - cpSpatialIndexQuery(space->dynamicShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQueryNearest, out); - cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQueryNearest, out); - - return (cpShape *)out->shape; -} - - -//MARK: Segment Query Functions - -struct SegmentQueryContext { - cpVect start, end; - cpFloat radius; - cpShapeFilter filter; - cpSpaceSegmentQueryFunc func; -}; - -static cpFloat -SegmentQuery(struct SegmentQueryContext *context, cpShape *shape, void *data) -{ - cpSegmentQueryInfo info; - - if( - !cpShapeFilterReject(shape->filter, context->filter) && - cpShapeSegmentQuery(shape, context->start, context->end, context->radius, &info) - ){ - context->func(shape, info.point, info.normal, info.alpha, data); - } - - return 1.0f; -} - -void -cpSpaceSegmentQuery(cpSpace *space, cpVect start, cpVect end, cpFloat radius, cpShapeFilter filter, cpSpaceSegmentQueryFunc func, void *data) -{ - struct SegmentQueryContext context = { - start, end, - radius, - filter, - func, - }; - - cpSpaceLock(space); { - cpSpatialIndexSegmentQuery(space->staticShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)SegmentQuery, data); - cpSpatialIndexSegmentQuery(space->dynamicShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)SegmentQuery, data); - } cpSpaceUnlock(space, cpTrue); -} - -static cpFloat -SegmentQueryFirst(struct SegmentQueryContext *context, cpShape *shape, cpSegmentQueryInfo *out) -{ - cpSegmentQueryInfo info; - - if( - !cpShapeFilterReject(shape->filter, context->filter) && !shape->sensor && - cpShapeSegmentQuery(shape, context->start, context->end, context->radius, &info) && - info.alpha < out->alpha - ){ - (*out) = info; - } - - return out->alpha; -} - -cpShape * -cpSpaceSegmentQueryFirst(cpSpace *space, cpVect start, cpVect end, cpFloat radius, cpShapeFilter filter, cpSegmentQueryInfo *out) -{ - cpSegmentQueryInfo info = {NULL, end, cpvzero, 1.0f}; - if(out){ - (*out) = info; - } else { - out = &info; - } - - struct SegmentQueryContext context = { - start, end, - radius, - filter, - NULL - }; - - cpSpatialIndexSegmentQuery(space->staticShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)SegmentQueryFirst, out); - cpSpatialIndexSegmentQuery(space->dynamicShapes, &context, start, end, out->alpha, (cpSpatialIndexSegmentQueryFunc)SegmentQueryFirst, out); - - return (cpShape *)out->shape; -} - -//MARK: BB Query Functions - -struct BBQueryContext { - cpBB bb; - cpShapeFilter filter; - cpSpaceBBQueryFunc func; -}; - -static cpCollisionID -BBQuery(struct BBQueryContext *context, cpShape *shape, cpCollisionID id, void *data) -{ - if( - !cpShapeFilterReject(shape->filter, context->filter) && - cpBBIntersects(context->bb, shape->bb) - ){ - context->func(shape, data); - } - - return id; -} - -void -cpSpaceBBQuery(cpSpace *space, cpBB bb, cpShapeFilter filter, cpSpaceBBQueryFunc func, void *data) -{ - struct BBQueryContext context = {bb, filter, func}; - - cpSpaceLock(space); { - cpSpatialIndexQuery(space->dynamicShapes, &context, bb, (cpSpatialIndexQueryFunc)BBQuery, data); - cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)BBQuery, data); - } cpSpaceUnlock(space, cpTrue); -} - -//MARK: Shape Query Functions - -struct ShapeQueryContext { - cpSpaceShapeQueryFunc func; - void *data; - cpBool anyCollision; -}; - -// Callback from the spatial hash. -static cpCollisionID -ShapeQuery(cpShape *a, cpShape *b, cpCollisionID id, struct ShapeQueryContext *context) -{ - if(cpShapeFilterReject(a->filter, b->filter) || a == b) return id; - - cpContactPointSet set = cpShapesCollide(a, b); - if(set.count){ - if(context->func) context->func(b, &set, context->data); - context->anyCollision = !(a->sensor || b->sensor); - } - - return id; -} - -cpBool -cpSpaceShapeQuery(cpSpace *space, cpShape *shape, cpSpaceShapeQueryFunc func, void *data) -{ - cpBody *body = shape->body; - cpBB bb = (body ? cpShapeUpdate(shape, body->transform) : shape->bb); - struct ShapeQueryContext context = {func, data, cpFalse}; - - cpSpaceLock(space); { - cpSpatialIndexQuery(space->dynamicShapes, shape, bb, (cpSpatialIndexQueryFunc)ShapeQuery, &context); - cpSpatialIndexQuery(space->staticShapes, shape, bb, (cpSpatialIndexQueryFunc)ShapeQuery, &context); - } cpSpaceUnlock(space, cpTrue); - - return context.anyCollision; -} diff --git a/thirdparty/src/chipmunk/cpSpaceStep.c b/thirdparty/src/chipmunk/cpSpaceStep.c deleted file mode 100644 index 85cbb3d0c..000000000 --- a/thirdparty/src/chipmunk/cpSpaceStep.c +++ /dev/null @@ -1,445 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -//MARK: Post Step Callback Functions - -cpPostStepCallback * -cpSpaceGetPostStepCallback(cpSpace *space, void *key) -{ - cpArray *arr = space->postStepCallbacks; - for(int i=0; i<arr->num; i++){ - cpPostStepCallback *callback = (cpPostStepCallback *)arr->arr[i]; - if(callback && callback->key == key) return callback; - } - - return NULL; -} - -static void PostStepDoNothing(cpSpace *space, void *obj, void *data){} - -cpBool -cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *key, void *data) -{ - cpAssertWarn(space->locked, - "Adding a post-step callback when the space is not locked is unnecessary. " - "Post-step callbacks will not called until the end of the next call to cpSpaceStep() or the next query."); - - if(!cpSpaceGetPostStepCallback(space, key)){ - cpPostStepCallback *callback = (cpPostStepCallback *)cpcalloc(1, sizeof(cpPostStepCallback)); - callback->func = (func ? func : PostStepDoNothing); - callback->key = key; - callback->data = data; - - cpArrayPush(space->postStepCallbacks, callback); - return cpTrue; - } else { - return cpFalse; - } -} - -//MARK: Locking Functions - -void -cpSpaceLock(cpSpace *space) -{ - space->locked++; -} - -void -cpSpaceUnlock(cpSpace *space, cpBool runPostStep) -{ - space->locked--; - cpAssertHard(space->locked >= 0, "Internal Error: Space lock underflow."); - - if(space->locked == 0){ - cpArray *waking = space->rousedBodies; - - for(int i=0, count=waking->num; i<count; i++){ - cpSpaceActivateBody(space, (cpBody *)waking->arr[i]); - waking->arr[i] = NULL; - } - - waking->num = 0; - - if(space->locked == 0 && runPostStep && !space->skipPostStep){ - space->skipPostStep = cpTrue; - - cpArray *arr = space->postStepCallbacks; - for(int i=0; i<arr->num; i++){ - cpPostStepCallback *callback = (cpPostStepCallback *)arr->arr[i]; - cpPostStepFunc func = callback->func; - - // Mark the func as NULL in case calling it calls cpSpaceRunPostStepCallbacks() again. - // TODO: need more tests around this case I think. - callback->func = NULL; - if(func) func(space, callback->key, callback->data); - - arr->arr[i] = NULL; - cpfree(callback); - } - - arr->num = 0; - space->skipPostStep = cpFalse; - } - } -} - -//MARK: Contact Buffer Functions - -struct cpContactBufferHeader { - cpTimestamp stamp; - cpContactBufferHeader *next; - unsigned int numContacts; -}; - -#define CP_CONTACTS_BUFFER_SIZE ((CP_BUFFER_BYTES - sizeof(cpContactBufferHeader))/sizeof(struct cpContact)) -typedef struct cpContactBuffer { - cpContactBufferHeader header; - struct cpContact contacts[CP_CONTACTS_BUFFER_SIZE]; -} cpContactBuffer; - -static cpContactBufferHeader * -cpSpaceAllocContactBuffer(cpSpace *space) -{ - cpContactBuffer *buffer = (cpContactBuffer *)cpcalloc(1, sizeof(cpContactBuffer)); - cpArrayPush(space->allocatedBuffers, buffer); - return (cpContactBufferHeader *)buffer; -} - -static cpContactBufferHeader * -cpContactBufferHeaderInit(cpContactBufferHeader *header, cpTimestamp stamp, cpContactBufferHeader *splice) -{ - header->stamp = stamp; - header->next = (splice ? splice->next : header); - header->numContacts = 0; - - return header; -} - -void -cpSpacePushFreshContactBuffer(cpSpace *space) -{ - cpTimestamp stamp = space->stamp; - - cpContactBufferHeader *head = space->contactBuffersHead; - - if(!head){ - // No buffers have been allocated, make one - space->contactBuffersHead = cpContactBufferHeaderInit(cpSpaceAllocContactBuffer(space), stamp, NULL); - } else if(stamp - head->next->stamp > space->collisionPersistence){ - // The tail buffer is available, rotate the ring - cpContactBufferHeader *tail = head->next; - space->contactBuffersHead = cpContactBufferHeaderInit(tail, stamp, tail); - } else { - // Allocate a new buffer and push it into the ring - cpContactBufferHeader *buffer = cpContactBufferHeaderInit(cpSpaceAllocContactBuffer(space), stamp, head); - space->contactBuffersHead = head->next = buffer; - } -} - - -struct cpContact * -cpContactBufferGetArray(cpSpace *space) -{ - if(space->contactBuffersHead->numContacts + CP_MAX_CONTACTS_PER_ARBITER > CP_CONTACTS_BUFFER_SIZE){ - // contact buffer could overflow on the next collision, push a fresh one. - cpSpacePushFreshContactBuffer(space); - } - - cpContactBufferHeader *head = space->contactBuffersHead; - return ((cpContactBuffer *)head)->contacts + head->numContacts; -} - -void -cpSpacePushContacts(cpSpace *space, int count) -{ - cpAssertHard(count <= CP_MAX_CONTACTS_PER_ARBITER, "Internal Error: Contact buffer overflow!"); - space->contactBuffersHead->numContacts += count; -} - -static void -cpSpacePopContacts(cpSpace *space, int count){ - space->contactBuffersHead->numContacts -= count; -} - -//MARK: Collision Detection Functions - -static void * -cpSpaceArbiterSetTrans(cpShape **shapes, cpSpace *space) -{ - if(space->pooledArbiters->num == 0){ - // arbiter pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(cpArbiter); - cpAssertHard(count, "Internal Error: Buffer size too small."); - - cpArbiter *buffer = (cpArbiter *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(space->allocatedBuffers, buffer); - - for(int i=0; i<count; i++) cpArrayPush(space->pooledArbiters, buffer + i); - } - - return cpArbiterInit((cpArbiter *)cpArrayPop(space->pooledArbiters), shapes[0], shapes[1]); -} - -static inline cpBool -QueryRejectConstraint(cpBody *a, cpBody *b) -{ - CP_BODY_FOREACH_CONSTRAINT(a, constraint){ - if( - !constraint->collideBodies && ( - (constraint->a == a && constraint->b == b) || - (constraint->a == b && constraint->b == a) - ) - ) return cpTrue; - } - - return cpFalse; -} - -static inline cpBool -QueryReject(cpShape *a, cpShape *b) -{ - return ( - // BBoxes must overlap - !cpBBIntersects(a->bb, b->bb) - // Don't collide shapes attached to the same body. - || a->body == b->body - // Don't collide shapes that are filtered. - || cpShapeFilterReject(a->filter, b->filter) - // Don't collide bodies if they have a constraint with collideBodies == cpFalse. - || QueryRejectConstraint(a->body, b->body) - ); -} - -// Callback from the spatial hash. -cpCollisionID -cpSpaceCollideShapes(cpShape *a, cpShape *b, cpCollisionID id, cpSpace *space) -{ - // Reject any of the simple cases - if(QueryReject(a,b)) return id; - - // Narrow-phase collision detection. - struct cpCollisionInfo info = cpCollide(a, b, id, cpContactBufferGetArray(space)); - - if(info.count == 0) return info.id; // Shapes are not colliding. - cpSpacePushContacts(space, info.count); - - // Get an arbiter from space->arbiterSet for the two shapes. - // This is where the persistant contact magic comes from. - const cpShape *shape_pair[] = {info.a, info.b}; - cpHashValue arbHashID = CP_HASH_PAIR((cpHashValue)info.a, (cpHashValue)info.b); - cpArbiter *arb = (cpArbiter *)cpHashSetInsert(space->cachedArbiters, arbHashID, shape_pair, (cpHashSetTransFunc)cpSpaceArbiterSetTrans, space); - cpArbiterUpdate(arb, &info, space); - - cpCollisionHandler *handler = arb->handler; - - // Call the begin function first if it's the first step - if(arb->state == CP_ARBITER_STATE_FIRST_COLLISION && !handler->beginFunc(arb, space, handler->userData)){ - cpArbiterIgnore(arb); // permanently ignore the collision until separation - } - - if( - // Ignore the arbiter if it has been flagged - (arb->state != CP_ARBITER_STATE_IGNORE) && - // Call preSolve - handler->preSolveFunc(arb, space, handler->userData) && - // Check (again) in case the pre-solve() callback called cpArbiterIgnored(). - arb->state != CP_ARBITER_STATE_IGNORE && - // Process, but don't add collisions for sensors. - !(a->sensor || b->sensor) && - // Don't process collisions between two infinite mass bodies. - // This includes collisions between two kinematic bodies, or a kinematic body and a static body. - !(a->body->m == INFINITY && b->body->m == INFINITY) - ){ - cpArrayPush(space->arbiters, arb); - } else { - cpSpacePopContacts(space, info.count); - - arb->contacts = NULL; - arb->count = 0; - - // Normally arbiters are set as used after calling the post-solve callback. - // However, post-solve() callbacks are not called for sensors or arbiters rejected from pre-solve. - if(arb->state != CP_ARBITER_STATE_IGNORE) arb->state = CP_ARBITER_STATE_NORMAL; - } - - // Time stamp the arbiter so we know it was used recently. - arb->stamp = space->stamp; - return info.id; -} - -// Hashset filter func to throw away old arbiters. -cpBool -cpSpaceArbiterSetFilter(cpArbiter *arb, cpSpace *space) -{ - cpTimestamp ticks = space->stamp - arb->stamp; - - cpBody *a = arb->body_a, *b = arb->body_b; - - // TODO: should make an arbiter state for this so it doesn't require filtering arbiters for dangling body pointers on body removal. - // Preserve arbiters on sensors and rejected arbiters for sleeping objects. - // This prevents errant separate callbacks from happenening. - if( - (cpBodyGetType(a) == CP_BODY_TYPE_STATIC || cpBodyIsSleeping(a)) && - (cpBodyGetType(b) == CP_BODY_TYPE_STATIC || cpBodyIsSleeping(b)) - ){ - return cpTrue; - } - - // Arbiter was used last frame, but not this one - if(ticks >= 1 && arb->state != CP_ARBITER_STATE_CACHED){ - arb->state = CP_ARBITER_STATE_CACHED; - cpCollisionHandler *handler = arb->handler; - handler->separateFunc(arb, space, handler->userData); - } - - if(ticks >= space->collisionPersistence){ - arb->contacts = NULL; - arb->count = 0; - - cpArrayPush(space->pooledArbiters, arb); - return cpFalse; - } - - return cpTrue; -} - -//MARK: All Important cpSpaceStep() Function - - void -cpShapeUpdateFunc(cpShape *shape, void *unused) -{ - cpShapeCacheBB(shape); -} - -void -cpSpaceStep(cpSpace *space, cpFloat dt) -{ - // don't step if the timestep is 0! - if(dt == 0.0f) return; - - space->stamp++; - - cpFloat prev_dt = space->curr_dt; - space->curr_dt = dt; - - cpArray *bodies = space->dynamicBodies; - cpArray *constraints = space->constraints; - cpArray *arbiters = space->arbiters; - - // Reset and empty the arbiter lists. - for(int i=0; i<arbiters->num; i++){ - cpArbiter *arb = (cpArbiter *)arbiters->arr[i]; - arb->state = CP_ARBITER_STATE_NORMAL; - - // If both bodies are awake, unthread the arbiter from the contact graph. - if(!cpBodyIsSleeping(arb->body_a) && !cpBodyIsSleeping(arb->body_b)){ - cpArbiterUnthread(arb); - } - } - arbiters->num = 0; - - cpSpaceLock(space); { - // Integrate positions - for(int i=0; i<bodies->num; i++){ - cpBody *body = (cpBody *)bodies->arr[i]; - body->position_func(body, dt); - } - - // Find colliding pairs. - cpSpacePushFreshContactBuffer(space); - cpSpatialIndexEach(space->dynamicShapes, (cpSpatialIndexIteratorFunc)cpShapeUpdateFunc, NULL); - cpSpatialIndexReindexQuery(space->dynamicShapes, (cpSpatialIndexQueryFunc)cpSpaceCollideShapes, space); - } cpSpaceUnlock(space, cpFalse); - - // Rebuild the contact graph (and detect sleeping components if sleeping is enabled) - cpSpaceProcessComponents(space, dt); - - cpSpaceLock(space); { - // Clear out old cached arbiters and call separate callbacks - cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)cpSpaceArbiterSetFilter, space); - - // Prestep the arbiters and constraints. - cpFloat slop = space->collisionSlop; - cpFloat biasCoef = 1.0f - cpfpow(space->collisionBias, dt); - for(int i=0; i<arbiters->num; i++){ - cpArbiterPreStep((cpArbiter *)arbiters->arr[i], dt, slop, biasCoef); - } - - for(int i=0; i<constraints->num; i++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; - - cpConstraintPreSolveFunc preSolve = constraint->preSolve; - if(preSolve) preSolve(constraint, space); - - constraint->klass->preStep(constraint, dt); - } - - // Integrate velocities. - cpFloat damping = cpfpow(space->damping, dt); - cpVect gravity = space->gravity; - for(int i=0; i<bodies->num; i++){ - cpBody *body = (cpBody *)bodies->arr[i]; - body->velocity_func(body, gravity, damping, dt); - } - - // Apply cached impulses - cpFloat dt_coef = (prev_dt == 0.0f ? 0.0f : dt/prev_dt); - for(int i=0; i<arbiters->num; i++){ - cpArbiterApplyCachedImpulse((cpArbiter *)arbiters->arr[i], dt_coef); - } - - for(int i=0; i<constraints->num; i++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; - constraint->klass->applyCachedImpulse(constraint, dt_coef); - } - - // Run the impulse solver. - for(int i=0; i<space->iterations; i++){ - for(int j=0; j<arbiters->num; j++){ - cpArbiterApplyImpulse((cpArbiter *)arbiters->arr[j]); - } - - for(int j=0; j<constraints->num; j++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[j]; - constraint->klass->applyImpulse(constraint, dt); - } - } - - // Run the constraint post-solve callbacks - for(int i=0; i<constraints->num; i++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; - - cpConstraintPostSolveFunc postSolve = constraint->postSolve; - if(postSolve) postSolve(constraint, space); - } - - // run the post-solve callbacks - for(int i=0; i<arbiters->num; i++){ - cpArbiter *arb = (cpArbiter *) arbiters->arr[i]; - - cpCollisionHandler *handler = arb->handler; - handler->postSolveFunc(arb, space, handler->userData); - } - } cpSpaceUnlock(space, cpTrue); -} diff --git a/thirdparty/src/chipmunk/cpSpatialIndex.c b/thirdparty/src/chipmunk/cpSpatialIndex.c deleted file mode 100644 index 3fb7cb5d9..000000000 --- a/thirdparty/src/chipmunk/cpSpatialIndex.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -void -cpSpatialIndexFree(cpSpatialIndex *index) -{ - if(index){ - cpSpatialIndexDestroy(index); - cpfree(index); - } -} - -cpSpatialIndex * -cpSpatialIndexInit(cpSpatialIndex *index, cpSpatialIndexClass *klass, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) -{ - index->klass = klass; - index->bbfunc = bbfunc; - index->staticIndex = staticIndex; - - if(staticIndex){ - cpAssertHard(!staticIndex->dynamicIndex, "This static index is already associated with a dynamic index."); - staticIndex->dynamicIndex = index; - } - - return index; -} - -typedef struct dynamicToStaticContext { - cpSpatialIndexBBFunc bbfunc; - cpSpatialIndex *staticIndex; - cpSpatialIndexQueryFunc queryFunc; - void *data; -} dynamicToStaticContext; - -static void -dynamicToStaticIter(void *obj, dynamicToStaticContext *context) -{ - cpSpatialIndexQuery(context->staticIndex, obj, context->bbfunc(obj), context->queryFunc, context->data); -} - -void -cpSpatialIndexCollideStatic(cpSpatialIndex *dynamicIndex, cpSpatialIndex *staticIndex, cpSpatialIndexQueryFunc func, void *data) -{ - if(staticIndex && cpSpatialIndexCount(staticIndex) > 0){ - dynamicToStaticContext context = {dynamicIndex->bbfunc, staticIndex, func, data}; - cpSpatialIndexEach(dynamicIndex, (cpSpatialIndexIteratorFunc)dynamicToStaticIter, &context); - } -} - diff --git a/thirdparty/src/chipmunk/cpSweep1D.c b/thirdparty/src/chipmunk/cpSweep1D.c deleted file mode 100644 index e200cf92b..000000000 --- a/thirdparty/src/chipmunk/cpSweep1D.c +++ /dev/null @@ -1,254 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "chipmunk/chipmunk_private.h" - -static inline cpSpatialIndexClass *Klass(); - -//MARK: Basic Structures - -typedef struct Bounds { - cpFloat min, max; -} Bounds; - -typedef struct TableCell { - void *obj; - Bounds bounds; -} TableCell; - -struct cpSweep1D -{ - cpSpatialIndex spatialIndex; - - int num; - int max; - TableCell *table; -}; - -static inline cpBool -BoundsOverlap(Bounds a, Bounds b) -{ - return (a.min <= b.max && b.min <= a.max); -} - -static inline Bounds -BBToBounds(cpSweep1D *sweep, cpBB bb) -{ - Bounds bounds = {bb.l, bb.r}; - return bounds; -} - -static inline TableCell -MakeTableCell(cpSweep1D *sweep, void *obj) -{ - TableCell cell = {obj, BBToBounds(sweep, sweep->spatialIndex.bbfunc(obj))}; - return cell; -} - -//MARK: Memory Management Functions - -cpSweep1D * -cpSweep1DAlloc(void) -{ - return (cpSweep1D *)cpcalloc(1, sizeof(cpSweep1D)); -} - -static void -ResizeTable(cpSweep1D *sweep, int size) -{ - sweep->max = size; - sweep->table = (TableCell *)cprealloc(sweep->table, size*sizeof(TableCell)); -} - -cpSpatialIndex * -cpSweep1DInit(cpSweep1D *sweep, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) -{ - cpSpatialIndexInit((cpSpatialIndex *)sweep, Klass(), bbfunc, staticIndex); - - sweep->num = 0; - ResizeTable(sweep, 32); - - return (cpSpatialIndex *)sweep; -} - -cpSpatialIndex * -cpSweep1DNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) -{ - return cpSweep1DInit(cpSweep1DAlloc(), bbfunc, staticIndex); -} - -static void -cpSweep1DDestroy(cpSweep1D *sweep) -{ - cpfree(sweep->table); - sweep->table = NULL; -} - -//MARK: Misc - -static int -cpSweep1DCount(cpSweep1D *sweep) -{ - return sweep->num; -} - -static void -cpSweep1DEach(cpSweep1D *sweep, cpSpatialIndexIteratorFunc func, void *data) -{ - TableCell *table = sweep->table; - for(int i=0, count=sweep->num; i<count; i++) func(table[i].obj, data); -} - -static int -cpSweep1DContains(cpSweep1D *sweep, void *obj, cpHashValue hashid) -{ - TableCell *table = sweep->table; - for(int i=0, count=sweep->num; i<count; i++){ - if(table[i].obj == obj) return cpTrue; - } - - return cpFalse; -} - -//MARK: Basic Operations - -static void -cpSweep1DInsert(cpSweep1D *sweep, void *obj, cpHashValue hashid) -{ - if(sweep->num == sweep->max) ResizeTable(sweep, sweep->max*2); - - sweep->table[sweep->num] = MakeTableCell(sweep, obj); - sweep->num++; -} - -static void -cpSweep1DRemove(cpSweep1D *sweep, void *obj, cpHashValue hashid) -{ - TableCell *table = sweep->table; - for(int i=0, count=sweep->num; i<count; i++){ - if(table[i].obj == obj){ - int num = --sweep->num; - - table[i] = table[num]; - table[num].obj = NULL; - - return; - } - } -} - -//MARK: Reindexing Functions - -static void -cpSweep1DReindexObject(cpSweep1D *sweep, void *obj, cpHashValue hashid) -{ - // Nothing to do here -} - -static void -cpSweep1DReindex(cpSweep1D *sweep) -{ - // Nothing to do here - // Could perform a sort, but queries are not accelerated anyway. -} - -//MARK: Query Functions - -static void -cpSweep1DQuery(cpSweep1D *sweep, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data) -{ - // Implementing binary search here would allow you to find an upper limit - // but not a lower limit. Probably not worth the hassle. - - Bounds bounds = BBToBounds(sweep, bb); - - TableCell *table = sweep->table; - for(int i=0, count=sweep->num; i<count; i++){ - TableCell cell = table[i]; - if(BoundsOverlap(bounds, cell.bounds) && obj != cell.obj) func(obj, cell.obj, 0, data); - } -} - -static void -cpSweep1DSegmentQuery(cpSweep1D *sweep, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data) -{ - cpBB bb = cpBBExpand(cpBBNew(a.x, a.y, a.x, a.y), b); - Bounds bounds = BBToBounds(sweep, bb); - - TableCell *table = sweep->table; - for(int i=0, count=sweep->num; i<count; i++){ - TableCell cell = table[i]; - if(BoundsOverlap(bounds, cell.bounds)) func(obj, cell.obj, data); - } -} - -//MARK: Reindex/Query - -static int -TableSort(TableCell *a, TableCell *b) -{ - return (a->bounds.min < b->bounds.min ? -1 : (a->bounds.min > b->bounds.min ? 1 : 0)); -} - -static void -cpSweep1DReindexQuery(cpSweep1D *sweep, cpSpatialIndexQueryFunc func, void *data) -{ - TableCell *table = sweep->table; - int count = sweep->num; - - // Update bounds and sort - for(int i=0; i<count; i++) table[i] = MakeTableCell(sweep, table[i].obj); - qsort(table, count, sizeof(TableCell), (int (*)(const void *, const void *))TableSort); // TODO: use insertion sort instead - - for(int i=0; i<count; i++){ - TableCell cell = table[i]; - cpFloat max = cell.bounds.max; - - for(int j=i+1; table[j].bounds.min < max && j<count; j++){ - func(cell.obj, table[j].obj, 0, data); - } - } - - // Reindex query is also responsible for colliding against the static index. - // Fortunately there is a helper function for that. - cpSpatialIndexCollideStatic((cpSpatialIndex *)sweep, sweep->spatialIndex.staticIndex, func, data); -} - -static cpSpatialIndexClass klass = { - (cpSpatialIndexDestroyImpl)cpSweep1DDestroy, - - (cpSpatialIndexCountImpl)cpSweep1DCount, - (cpSpatialIndexEachImpl)cpSweep1DEach, - (cpSpatialIndexContainsImpl)cpSweep1DContains, - - (cpSpatialIndexInsertImpl)cpSweep1DInsert, - (cpSpatialIndexRemoveImpl)cpSweep1DRemove, - - (cpSpatialIndexReindexImpl)cpSweep1DReindex, - (cpSpatialIndexReindexObjectImpl)cpSweep1DReindexObject, - (cpSpatialIndexReindexQueryImpl)cpSweep1DReindexQuery, - - (cpSpatialIndexQueryImpl)cpSweep1DQuery, - (cpSpatialIndexSegmentQueryImpl)cpSweep1DSegmentQuery, -}; - -static inline cpSpatialIndexClass *Klass(){return &klass;} - diff --git a/thirdparty/src/chipmunk/prime.h b/thirdparty/src/chipmunk/prime.h deleted file mode 100644 index d470c2cdd..000000000 --- a/thirdparty/src/chipmunk/prime.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// Used for resizing hash tables. -// Values approximately double. -// http://planetmath.org/encyclopedia/GoodHashTablePrimes.html -static int primes[] = { - 5, - 13, - 23, - 47, - 97, - 193, - 389, - 769, - 1543, - 3079, - 6151, - 12289, - 24593, - 49157, - 98317, - 196613, - 393241, - 786433, - 1572869, - 3145739, - 6291469, - 12582917, - 25165843, - 50331653, - 100663319, - 201326611, - 402653189, - 805306457, - 1610612741, - 0, -}; - -static inline int -next_prime(int n) -{ - int i = 0; - while(n > primes[i]){ - i++; - cpAssertHard(primes[i], "Tried to resize a hash table to a size greater than 1610612741 O_o"); // realistically this should never happen - } - - return primes[i]; -} diff --git a/thirdparty/src/newton/dContainers/CMakeLists.txt b/thirdparty/src/newton/dContainers/CMakeLists.txt deleted file mode 100644 index 24b86806d..000000000 --- a/thirdparty/src/newton/dContainers/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (c) <2014-2017> <Newton Game Dynamics> -# -# 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. - -cmake_minimum_required(VERSION 3.4.0) - -set (projectName "dContainers") -message (${projectName}) - -#source and header files -file(GLOB CPP_SOURCE *.h *.cpp) -file(GLOB HEADERS *.h) - -source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/" FILES ${CPP_SOURCE}) - -if(NEWTON_BUILD_SHARED_LIBS) - if(MSVC OR MINGW) - add_definitions(-D_DCONTAINERS_DLL) - add_definitions(-D_DCONTAINERS_EXPORT) - endif() - add_library(${projectName} SHARED ${CPP_SOURCE}) -else(NEWTON_BUILD_SHARED_LIBS) - if (MSVC OR MINGW) - add_definitions(-D_NEWTON_STATIC_LIB) - endif() - - add_library(${projectName} STATIC ${CPP_SOURCE}) -endif(NEWTON_BUILD_SHARED_LIBS) - -target_include_directories(${projectName} PUBLIC . ../dMath ../dgCore) -if (NEWTON_BUILD_PROFILER) - target_link_libraries (${projectName} dProfiler) -endif() - -if (MSVC) - if(CMAKE_VS_MSBUILD_COMMAND OR CMAKE_VS_DEVENV_COMMAND) - set_target_properties(${projectName} PROPERTIES COMPILE_FLAGS "/YudContainersStdAfx.h") - set_source_files_properties(dContainersStdAfx.cpp PROPERTIES COMPILE_FLAGS "/YcdContainersStdAfx.h") - endif() - - if (NEWTON_BUILD_SANDBOX_DEMOS) - add_custom_command( - TARGET ${projectName} POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy $<TARGET_FILE:${projectName}> ${PROJECT_BINARY_DIR}/applications/demosSandbox/${CMAKE_CFG_INTDIR}/$<TARGET_FILE_NAME:${projectName}>) - endif () -endif(MSVC) - -install(TARGETS ${projectName} - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin) - -install(FILES ${HEADERS} DESTINATION include/${projectName}) - diff --git a/thirdparty/src/newton/dContainers/dArray.h b/thirdparty/src/newton/dContainers/dArray.h deleted file mode 100644 index 007b05482..000000000 --- a/thirdparty/src/newton/dContainers/dArray.h +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#ifndef __D_ARRAY__ -#define __D_ARRAY__ - -#include "dContainersAlloc.h" - -template<class T> -class dArray: public dContainersAlloc -{ - public: - dArray(); - dArray(int size); - ~dArray(); - - T& operator[] (int i); - const T& operator[] (int i) const; - - int GetSize() const; - void Resize(int size) const; - - protected: - mutable int m_capacity; - mutable T* m_data; -}; - -template<class T> -dArray<T>::dArray() - :m_capacity(0) - ,m_data(NULL) -{ -} - -template<class T> -dArray<T>::dArray(int size) - :dContainersAlloc() - ,m_capacity(0) - ,m_data(NULL) -{ - Resize(size); -} - - -template<class T> -dArray<T>::~dArray() -{ - if (m_data) { - delete[] m_data; - } -} - - -template<class T> -T& dArray<T>::operator[] (int i) -{ - dAssert(i >= 0); - while (i >= m_capacity) { - Resize(dMax (i * 2, 1)); - } - return m_data[i]; -} - -template<class T> -const T& dArray<T>::operator[] (int i) const -{ - dAssert(i >= 0); - while (i >= m_capacity) { - Resize(dMax (i * 2, 1)); - } - return m_data[i]; -} - -template<class T> -int dArray <T>::GetSize() const -{ - return m_capacity; -} - -template<class T> -void dArray <T>::Resize(int size) const -{ - if (size >= m_capacity) { - T* const newArray = new T[size]; - if (m_data) { - for (int i = 0; i < m_capacity; i++) { - newArray[i] = m_data[i]; - } - delete[] m_data; - } - m_data = newArray; - m_capacity = size; - } else if (size < m_capacity) { - T* const newArray = new T[size]; - if (m_data) { - for (int i = 0; i < size; i++) { - newArray[i] = m_data[i]; - } - delete[] m_data; - } - m_data = newArray; - m_capacity = size; - } -} - -#endif diff --git a/thirdparty/src/newton/dContainers/dBaseHierarchy.cpp b/thirdparty/src/newton/dContainers/dBaseHierarchy.cpp deleted file mode 100644 index 710500985..000000000 --- a/thirdparty/src/newton/dContainers/dBaseHierarchy.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dContainersStdAfx.h" -#include "dBaseHierarchy.h" - - -dBaseHierarchy::dBaseHierarchy (const dBaseHierarchy &clone) -{ - Clear (); - SetNameID (clone.m_name.GetStr()); - for (dBaseHierarchy* obj = clone.m_child; obj; obj = obj->m_sibling) { - dBaseHierarchy* const newObj = obj->CreateClone (); - newObj->Attach (this); - } -} - - -dBaseHierarchy::~dBaseHierarchy () -{ - Detach(); - while (m_child) { - delete m_child; - } -} - - - -void dBaseHierarchy::Attach (dBaseHierarchy* const parentArg, bool addFirst) -{ - m_parent = parentArg; - if (m_parent->m_child) { - if (addFirst) { - m_sibling = m_parent->m_child; - m_parent->m_child = this; - } else { - dBaseHierarchy* obj = m_parent->m_child; - for (; obj->m_sibling; obj = obj->m_sibling); - obj->m_sibling = this; - } - } else { - m_parent->m_child = this; - } -} - - -void dBaseHierarchy::Detach () -{ - if (m_parent) { - if (m_parent->m_child == this) { - m_parent->m_child = m_sibling; - } else { - dBaseHierarchy* ptr = m_parent->m_child; - for (; ptr->m_sibling != this; ptr = ptr->m_sibling); - ptr->m_sibling = m_sibling; - } - m_parent = NULL; - m_sibling = NULL; - } -} - - -dBaseHierarchy* dBaseHierarchy::GetRoot() const -{ - const dBaseHierarchy* root = this; - for (; root->m_parent; root = root->m_parent); - return (dBaseHierarchy*)root; -} - - -dBaseHierarchy* dBaseHierarchy::GetFirst() const -{ - dBaseHierarchy* ptr = (dBaseHierarchy*) this; - for (; ptr->m_child; ptr = ptr->m_child); - return ptr; -} - -dBaseHierarchy* dBaseHierarchy::GetNext() const -{ - if (m_sibling) { - return m_sibling->GetFirst(); - } - - dBaseHierarchy* ptr = m_parent; - dBaseHierarchy* x = (dBaseHierarchy *)this; - for (; ptr && (x == ptr->m_sibling); ptr = ptr->m_parent) { - x = ptr; - } - return ptr; -} - - - -dBaseHierarchy* dBaseHierarchy::GetLast() const -{ - dBaseHierarchy* ptr = (dBaseHierarchy*) this; - for (; ptr->m_sibling; ptr = ptr->m_sibling); - return ptr; -} - - -dBaseHierarchy* dBaseHierarchy::GetPrev() const -{ - - if (m_child) { - return m_child->GetNext(); - } - - dBaseHierarchy* ptr = m_parent; - dBaseHierarchy* x = (dBaseHierarchy *)this; - for (; ptr && (x == ptr->m_child); ptr = ptr->m_child) { - x = ptr; - } - return ptr; -} - - -dBaseHierarchy* dBaseHierarchy::Find (dCRCTYPE nameCRC) const -{ - if (nameCRC == GetNameID()) { - return (dBaseHierarchy*)this; - } else { - for (dBaseHierarchy* ptr = GetFirst(); ptr && (ptr != this); ptr = ptr->GetNext()) { - if (nameCRC == ptr->GetNameID()) { - return ptr; - } - } - } - - return NULL; -} - - - - - - - - - diff --git a/thirdparty/src/newton/dContainers/dBaseHierarchy.h b/thirdparty/src/newton/dContainers/dBaseHierarchy.h deleted file mode 100644 index 06e5d6a96..000000000 --- a/thirdparty/src/newton/dContainers/dBaseHierarchy.h +++ /dev/null @@ -1,256 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - - -#ifndef __Hierarchy__ -#define __Hierarchy__ - -#include "dCRC.h" -#include "dString.h" -#include "dContainersAlloc.h" - - - -class dBaseHierarchy: public dContainersAlloc -{ - public: - DCONTAINERS_API dBaseHierarchy* GetChild () const; - DCONTAINERS_API dBaseHierarchy* GetParent () const; - DCONTAINERS_API dBaseHierarchy* GetSibling () const; - - DCONTAINERS_API void Detach (); - DCONTAINERS_API void Attach (dBaseHierarchy* const parent, bool addFirst = false); - - DCONTAINERS_API dBaseHierarchy* GetRoot () const; - DCONTAINERS_API dBaseHierarchy* GetFirst() const; - DCONTAINERS_API dBaseHierarchy* GetLast() const; - DCONTAINERS_API dBaseHierarchy* GetNext() const; - DCONTAINERS_API dBaseHierarchy* GetPrev() const; - - DCONTAINERS_API dBaseHierarchy* Find (dCRCTYPE nameCRC) const; - DCONTAINERS_API dBaseHierarchy* Find (const char* const name) const; - - DCONTAINERS_API long long GetNameID() const; - DCONTAINERS_API const dString& GetName() const; - void SetNameID(const char* const name); - - protected: - DCONTAINERS_API dBaseHierarchy (); - DCONTAINERS_API dBaseHierarchy (const char* const name); - DCONTAINERS_API dBaseHierarchy (const dBaseHierarchy &clone); - virtual DCONTAINERS_API ~dBaseHierarchy (); - - virtual DCONTAINERS_API dBaseHierarchy* CreateClone () const = 0; - - private: - inline void Clear(); - - dString m_name; - long long m_nameID; - dBaseHierarchy* m_parent; - dBaseHierarchy* m_child; - dBaseHierarchy* m_sibling; -}; - -template<class T> -class dHierarchy: public dBaseHierarchy -{ - public: - dHierarchy (); - dHierarchy (const char* const name); - void Attach (T* const parent, bool addFirst = false); - void Detach (); - T* GetChild () const; - T* GetParent () const; - T* GetSibling () const; - T* GetRoot () const; - T* GetFirst() const; - T* GetLast() const; - T* GetNext() const; - T* GetPrev() const; - T* Find (long long nameCRC) const; - T* Find (const char* const name) const; - - protected: - dHierarchy (const T &clone); - virtual ~dHierarchy (); -}; - - -inline dBaseHierarchy::dBaseHierarchy () -{ - Clear (); -} - -inline dBaseHierarchy::dBaseHierarchy (const char* const name) -{ - Clear (); - SetNameID (name); -} - - -inline void dBaseHierarchy::Clear() -{ - m_child = NULL; - m_parent = NULL; - m_sibling = NULL; - m_nameID = 0; - m_name = (char*)NULL; -} - - -inline dBaseHierarchy* dBaseHierarchy::GetChild () const -{ - return m_child; -} - -inline dBaseHierarchy* dBaseHierarchy::GetSibling () const -{ - return m_sibling; -} - -inline dBaseHierarchy* dBaseHierarchy::GetParent () const -{ - return m_parent; -} - - -inline dBaseHierarchy* dBaseHierarchy::Find (const char* const name) const -{ - return Find (dCRC64 (name)); -} - -inline void dBaseHierarchy::SetNameID(const char* const name) -{ - m_nameID = dCRC64 (name); - m_name = name; -} - -inline long long dBaseHierarchy::GetNameID() const -{ - return m_nameID; -} - -inline const dString& dBaseHierarchy::GetName() const -{ - return m_name; -} - - -template<class T> -dHierarchy<T>::dHierarchy () - :dBaseHierarchy () -{ -} - -template<class T> -dHierarchy<T>::dHierarchy (const T &clone) - :dBaseHierarchy (clone) -{ -} - -template<class T> -dHierarchy<T>::dHierarchy (const char* const name) - :dBaseHierarchy (name) -{ -} - -template<class T> -dHierarchy<T>::~dHierarchy () -{ -} - - -//template<class T> -//dBaseHierarchy* dHierarchy<T>::CreateClone () const -//{ -// return new T (*(T*)this); -//} - -template<class T> -void dHierarchy<T>::Attach (T* const parent, bool addFirst) -{ - dBaseHierarchy::Attach(parent, addFirst); -} - -template<class T> -void dHierarchy<T>::Detach () -{ - dBaseHierarchy::Detach (); -} - -template<class T> -T* dHierarchy<T>::GetChild () const -{ - return (T*) dBaseHierarchy::GetChild(); -} - -template<class T> -T* dHierarchy<T>::GetSibling () const -{ - return (T*) dBaseHierarchy::GetSibling (); -} - -template<class T> -T* dHierarchy<T>::GetParent () const -{ - return (T*) dBaseHierarchy::GetParent (); -} - - -template<class T> -T* dHierarchy<T>::GetRoot () const -{ - return (T*) dBaseHierarchy::GetRoot (); -} - - -template<class T> -T* dHierarchy<T>::GetFirst() const -{ - return (T*) dBaseHierarchy::GetFirst (); -} - -template<class T> -T* dHierarchy<T>::GetLast() const -{ - return (T*) dBaseHierarchy::GetLast (); -} - - -template<class T> -T* dHierarchy<T>::GetNext() const -{ - return (T*) dBaseHierarchy::GetNext (); -} - -template<class T> -T* dHierarchy<T>::GetPrev() const -{ - return (T*) dBaseHierarchy::GetPrev (); -} - - -template<class T> -T* dHierarchy<T>::Find (dCRCTYPE nameCRC) const -{ - return (T*) dBaseHierarchy::Find (nameCRC); -} - -template<class T> -T* dHierarchy<T>::Find (const char* const name) const -{ - return (T*) dBaseHierarchy::Find (name); -} - - -#endif - diff --git a/thirdparty/src/newton/dContainers/dBezierSpline.cpp b/thirdparty/src/newton/dContainers/dBezierSpline.cpp deleted file mode 100644 index 6b90aecd8..000000000 --- a/thirdparty/src/newton/dContainers/dBezierSpline.cpp +++ /dev/null @@ -1,641 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dContainersStdAfx.h" -#include "dBezierSpline.h" - -dBezierSpline::dBezierSpline () - :dContainersAlloc() - ,m_knotVector(16) - ,m_controlPoints(16) - ,m_degree(0) - ,m_knotsCount(0) - ,m_controlPointsCount(0) -{ -} - -dBezierSpline::dBezierSpline (const dBezierSpline& src) - :m_knotVector(src.m_knotsCount) - ,m_controlPoints(src.m_controlPointsCount) - ,m_degree(0) - ,m_knotsCount(0) - ,m_controlPointsCount(0) -{ - if (src.m_knotsCount) { - CreateFromKnotVectorAndControlPoints (src.m_degree, src.m_knotsCount - 2 * src.m_degree, &src.m_knotVector[src.m_degree], &src.m_controlPoints[0]); - } -} - -dBezierSpline::~dBezierSpline () -{ - Clear(); -} - -void dBezierSpline::Clear() -{ - m_degree = 0; - m_knotsCount = 0; - m_controlPointsCount = 0; -} - -dBezierSpline& dBezierSpline::operator = (const dBezierSpline ©) -{ - Clear(); - if (copy.m_knotsCount) { - CreateFromKnotVectorAndControlPoints (copy.m_degree, copy.m_knotsCount - 2 * copy.m_degree, ©.m_knotVector[copy.m_degree], ©.m_controlPoints[0]); - } - return *this; -} - -int dBezierSpline::GetDegree () const -{ - return m_degree; -} - -void dBezierSpline::CreateFromKnotVectorAndControlPoints (int degree, int knotCount, const dFloat64* const knotVector, const dBigVector* const controlPoints) -{ - Clear(); - dAssert (knotCount); - dAssert (knotVector[0] == 0.0f); - dAssert (knotVector[knotCount - 1] == 1.0f); - - m_degree = degree; - m_knotsCount = knotCount + 2 * degree; - m_controlPointsCount = knotCount + m_degree - 1; - - for (int i = 0; i < m_controlPointsCount; i++) { - m_controlPoints[i] = controlPoints[i]; - } - - for (int i = 0; i < m_degree; i ++) { - m_knotVector[i] = dFloat64(0.0f); - m_knotVector[i + m_knotsCount - m_degree] = dFloat64(1.0f); - } - - for (int i = 0; i < knotCount; i ++) { - m_knotVector[i + m_degree] = knotVector[i]; - dAssert (m_knotVector[i + m_degree] >= m_knotVector[i + m_degree - 1]); - } -} - -int dBezierSpline::GetKnotCount() const -{ - return m_knotsCount; -} - -dArray<dFloat64>& dBezierSpline::GetKnotArray() -{ - return m_knotVector; -} - -const dArray<dFloat64>& dBezierSpline::GetKnotArray() const -{ - return m_knotVector; -} - -dFloat64 dBezierSpline::GetKnot(int i) const -{ - return m_knotVector[i]; -} - -int dBezierSpline::GetControlPointCount() const -{ - return m_controlPointsCount; -} - -dBigVector dBezierSpline::GetControlPoint(int i) const -{ - return m_controlPoints[i]; -} - -void dBezierSpline::SetControlPoint(int i, const dBigVector& point) -{ - m_controlPoints[i] = point; -} - -dArray<dBigVector>& dBezierSpline::GetControlPointArray() -{ - return m_controlPoints; -} - -const dArray<dBigVector>& dBezierSpline::GetControlPointArray() const -{ - return m_controlPoints; -} - -int dBezierSpline::GetSpan(dFloat64 u) const -{ - int low = m_degree; - int high = m_knotsCount - m_degree - 1; - - dAssert (u >= 0.0f); - dAssert (u <= 1.0f); - while ((high - low) >= 4) { - int mid = (low + high) >> 1; - if (u > m_knotVector[mid]) { - low = mid; - } else { - high = mid; - } - } - - dAssert (m_knotVector[low] <= u); - for (int i = low; i < m_degree + m_knotsCount + 1; i ++) { - if (m_knotVector[i + 1] >= u) { - return i; - } - } - dAssert (0); - return 0; -} - -void dBezierSpline::BasicsFunctions (dFloat64 u, int span, dFloat64* const BasicFunctionsOut) const -{ - BasicFunctionsOut[0] = 1.0f; - - dFloat64* const left = dAlloca(dFloat64, m_knotsCount + 32); - dFloat64* const right = dAlloca(dFloat64, m_knotsCount + 32); - - for (int j = 1; j <= m_degree; j ++) { - left[j] = u - m_knotVector[span + 1 - j]; - right[j] = m_knotVector[span + j] - u; - - dFloat64 saved = 0.0f; - for (int r = 0; r < j; r ++) { - dFloat64 temp = BasicFunctionsOut[r] / (right[r + 1] + left[j - r]); - BasicFunctionsOut[r] = saved + temp * right[r + 1]; - saved = temp * left[j - r]; - } - BasicFunctionsOut[j] = saved; - } -} - -void dBezierSpline::BasicsFunctionsDerivatives (dFloat64 u, int span, dFloat64* const derivativesOut) const -{ - dFloat64* const a = dAlloca(dFloat64, m_knotsCount + 32); - dFloat64* const ndu = dAlloca(dFloat64, m_knotsCount + 32); - dFloat64* const left = dAlloca(dFloat64, m_knotsCount + 32); - dFloat64* const right = dAlloca(dFloat64, m_knotsCount + 32); - - const int width = m_degree + 1; - ndu[0] = 1.0f; - for (int j = 1; j <= m_degree; j ++) { - left[j] = u - m_knotVector[span + 1 - j]; - right[j] = m_knotVector[span + j] - u; - dFloat64 saved = 0.0f; - for (int r = 0; r < j; r ++) { - ndu[j * width + r] = right[r + 1] + left[j - r]; - - dFloat64 temp = ndu[r * width + j - 1] / ndu[j * width + r]; - ndu[r * width + j] = saved + temp * right[r + 1]; - saved = temp * left[j - r]; - } - ndu[j * width + j] = saved; - } - - - for (int j = 0; j <= m_degree; j ++) { - derivativesOut[width * 0 + j] = ndu [width * j + m_degree]; - } - - for (int r = 0; r <= m_degree; r ++) { - int s1 = 0; - int s2 = 1; - a[0] = 1.0f; - for (int k = 1; k <= m_degree; k ++) { - dFloat64 d = 0.0f; - int rk = r - k; - int pk = m_degree - k; - if (r >= k) { - a[width * s2 + 0] = a[width * s1 + 0] / ndu[width * (pk + 1) + rk]; - d = a[width * s2 + 0] * ndu[width * rk + pk]; - } - int j1 = 0; - int j2 = 0; - if (rk >= -1) { - j1 = 1; - } else { - j1 = -rk; - } - - if ((r - 1) <= pk) { - j2 = k-1; - } else { - j2 = m_degree-r; - } - for (int j = j1; j <= j2; j ++) { - a[width * s2 + j] = (a[width * s1 + j] - a[width * s1 + j - 1]) / ndu[width * (pk + 1) + rk + j]; - d += a[width * s2 + j] * ndu[width * (rk + j) + pk]; - } - if (r <= pk) { - a[width * s2 + k] = -a[width * s1 + k - 1] / ndu[width * (pk + 1) + r]; - d += a[width * s2 + k] * ndu[width * r + pk]; - } - derivativesOut[width * k + r] = d; - dSwap(s1, s2); - } - } - - int s = m_degree; - for (int k = 1; k <= m_degree; k ++) { - for (int j = 0; j <= m_degree; j ++) { - derivativesOut[width * k + j] *= s; - } - s *= (m_degree - k); - } -} - -dBigVector dBezierSpline::CurvePoint (dFloat64 u, int span) const -{ - dBigVector point (0.0f); - dFloat64* const basicFunctions = dAlloca(dFloat64, m_knotsCount + 32); - BasicsFunctions (u, span, basicFunctions); - for (int i = 0; i <= m_degree; i ++) { - point += m_controlPoints[span - m_degree + i].Scale (basicFunctions[i]); - } - return point; -} - -dBigVector dBezierSpline::CurvePoint (dFloat64 u) const -{ - u = dClamp (u, dFloat64 (0.0f), dFloat64 (1.0f)); - int span = GetSpan(u); - return CurvePoint (u, span); -} - -dBigVector dBezierSpline::CurveDerivative (dFloat64 u, int index) const -{ - u = dClamp (u, dFloat64 (0.0f), dFloat64 (1.0f)); - dAssert (index <= m_degree); - - dFloat64* const basicsFuncDerivatives = dAlloca(dFloat64, m_knotsCount + 32); - int span = GetSpan(u); - BasicsFunctionsDerivatives (u, span, basicsFuncDerivatives); - - const int with = m_degree + 1; - dBigVector point (0.0f); - for (int i = 0; i <= m_degree; i ++) { - point += m_controlPoints[span - m_degree + i].Scale (basicsFuncDerivatives[with * index + i]); - } - return point; -} - -int dBezierSpline::CurveAllDerivatives (dFloat64 u, dBigVector* const derivatives) const -{ - u = dMod (u, dFloat64(1.0f)); - dFloat64* const basicsFuncDerivatives = dAlloca(dFloat64, m_knotsCount + 32); - int span = GetSpan(u); - BasicsFunctionsDerivatives (u, span, basicsFuncDerivatives); - - const int with = m_degree + 1; - dBigVector point (0.0f); - for (int j = 0; j <= m_degree; j ++) { - dBigVector ck (0.0f); - for (int i = 0; i <= m_degree; i ++) { - ck += m_controlPoints[span - m_degree + i].Scale (basicsFuncDerivatives[with * j + i]); - } - derivatives[j] = ck; - } - - return m_degree + 1; -} - -void dBezierSpline::GlobalCubicInterpolation (int count, const dBigVector* const points, const dBigVector& firstTangent, const dBigVector& lastTangent) -{ - CreateCubicKnotVector (count, points); - CreateCubicControlPoints (count, points, firstTangent, lastTangent); -} - -void dBezierSpline::CreateCubicKnotVector(int count, const dBigVector* const points) -{ - dFloat64 d = dFloat64(0.0f); - dAssert (count >= 2); - - dFloat64* const u = dAlloca(dFloat64, m_knotsCount + 32); - u[0] = dFloat64(0.0f); - for (int i = 1; i < count; i ++) { - dBigVector step (points[i] - points[i - 1]); - dFloat64 len = dSqrt (step.DotProduct3(step)); - u[i] = dSqrt (len); - d += u[i]; - } - - for (int i = 1; i < count; i ++) { - u[i] = u[i-1] + u[i] / d; - } - u[0] = dFloat64 (0.0f); - u[count - 1] = dFloat64(1.0f); - - m_degree = 3; - m_knotsCount = count + 2 * m_degree; - - for (int i = 0; i < (m_degree + 1); i ++) { - m_knotVector[i] = dFloat64(0.0f); - m_knotVector[i + m_knotsCount - m_degree - 1] = dFloat64(1.0f); - } - - for (int i = 1; i < (count - 1); i ++) { - dFloat64 acc = dFloat64 (0.0f); - for (int j = 0; j < m_degree; j ++) { - acc += u[j + i - 1]; - } - m_knotVector[m_degree + i] = acc / dFloat64 (3.0f); - } -} - -void dBezierSpline::CreateCubicControlPoints(int count, const dBigVector* const points, const dBigVector& firstTangent, const dBigVector& lastTangent) -{ - dFloat64 abc[4]; - if ((m_knotsCount - 2 * (m_degree - 1)) != m_controlPointsCount) { - m_controlPointsCount = m_knotsCount - 2 * (m_degree - 1); - } - - m_controlPoints[0] = points[0]; - m_controlPoints[m_controlPointsCount - 1] = points[count - 1]; - - m_controlPoints[1] = m_controlPoints[0] + firstTangent.Scale (m_knotVector[m_degree + 1] / 3.0f); - m_controlPoints[m_controlPointsCount - 2] = m_controlPoints[m_controlPointsCount - 1] - lastTangent.Scale ((1.0f - m_knotVector[m_knotsCount - m_degree - 2]) / 3.0f); - if (count == 3) { - BasicsFunctions (m_knotVector[m_degree + 1], m_degree + 1, abc); - m_controlPoints[2] = points[1] - m_controlPoints[1].Scale (abc[0]) - m_controlPoints[3].Scale (abc[2]); - m_controlPoints[2] = m_controlPoints[2].Scale (1.0f / abc[1]); - } else { - dFloat64* const dd = dAlloca(dFloat64, m_knotsCount + 32); - BasicsFunctions (m_knotVector[m_degree + 1], m_degree + 1, abc); - dFloat64 den = abc[1]; - m_controlPoints[2] = (points[1] - m_controlPoints[1].Scale (abc[0])).Scale (1.0f / den); - for (int i = 3; i < (count - 1); i ++) { - dd[i + 1] = abc[2] / den; - BasicsFunctions (m_knotVector[i + 2], i + 2, abc); - den = abc[1] - abc[0] * dd[i + 1]; - m_controlPoints[i] = (points[i - 1] - m_controlPoints[i - 1].Scale (abc[0])).Scale (1.0f / den); - } - - dd[count] = abc[2] / den; - BasicsFunctions (m_knotVector[count + 1], count + 1, abc); - den = abc[1] - abc[0] * dd[count]; - m_controlPoints[count - 1] = (points[count - 2] - m_controlPoints[count].Scale (abc[2]) - m_controlPoints[count - 2].Scale (abc[0])).Scale (1.0f / den); - - for (int i = count - 2; i >= 2; i --) { - m_controlPoints[i] -= m_controlPoints[i + 1].Scale (dd[i + 2]); - } - } -} - -dFloat64 dBezierSpline::CalculateLength (dFloat64 tol) const -{ - dBigVector stackPool[32][3]; - int stack = 0; - - dFloat64 length = 0.0f; - dFloat64 tol2 = tol * tol; - dFloat64 u0 = m_knotVector[m_degree]; - dBigVector p0 (CurvePoint (u0)); - - for (int i = m_degree; i < (m_knotsCount - m_degree - 1); i ++) { - dFloat64 u1 = m_knotVector[i + 1]; - dBigVector p1 (CurvePoint (u1)); - stackPool[stack][0] = p0; - stackPool[stack][1] = p1; - stackPool[stack][2] = dBigVector (u0, u1, dFloat64(0.0f), dFloat64(0.0f)); - stack ++; - while (stack) { - stack --; - dBigVector q0 (stackPool[stack][0]); - dBigVector q1 (stackPool[stack][1]); - dFloat64 t0 = stackPool[stack][2][0]; - dFloat64 t1 = stackPool[stack][2][1]; - dFloat64 t01 = (t1 + t0) * 0.5f; - - dBigVector p01 ((q1 + q0).Scale (0.5f)); - dBigVector q01 (CurvePoint (t01)); - dBigVector err (q01 - p01); - - dFloat64 err2 = err.DotProduct3(err); - if (err2 < tol2) { - dBigVector step (q1 - q0); - length += dSqrt (step.DotProduct3(step)); - } else { - stackPool[stack][0] = q01; - stackPool[stack][1] = q1; - stackPool[stack][2] = dBigVector (t01, t1, dFloat64(0.0f), dFloat64(0.0f)); - stack ++; - - stackPool[stack][0] = q0; - stackPool[stack][1] = q01; - stackPool[stack][2] = dBigVector (t0, t01, dFloat64(0.0f), dFloat64(0.0f)); - stack ++; - } - } - u0 = u1; - p0 = p1; - } - - return length; -} - -void dBezierSpline::InsertKnot (dFloat64 u) -{ - const int k = GetSpan(u); - int multiplicity = 0; - for (int i = 0; i < m_degree; i ++) { - multiplicity += (dAbs (m_knotVector[k + i + 1] - u) < dFloat64 (1.0e-5f)) ? 1 : 0; - } - if (multiplicity == m_degree) { - return; - } - - for (int i = m_knotsCount; i > (k + 1); i --) { - m_knotVector[i] = m_knotVector[i - 1]; - } - m_knotVector[k + 1] = u; - - dBigVector Rw[16]; - for (int i = 0; i <= m_degree; i ++) { - Rw[i] = m_controlPoints[k - m_degree + i]; - } - - const int m = k - m_degree + 1; - dAssert(m >= 0); - dAssert((k + 1 - 1 - 0) >= 0); - dAssert((m_degree - 1 - 0) >= 0); - - for (int i = 0; i <= (m_degree - 1); i ++) { - dFloat64 alpha = (u - m_knotVector[m + i]) / (m_knotVector[i + k + 1] - m_knotVector[m + i]); - Rw[i] = Rw[i + 1].Scale (alpha) + Rw[i].Scale (dFloat64 (1.0f) - alpha); - } - - for (int i = m_controlPointsCount; i > k; i--) { - m_controlPoints[i] = m_controlPoints[i - 1]; - } - m_controlPoints[m] = Rw[0]; - m_controlPoints[k + 1 - 1 - 0] = Rw[m_degree - 1 - 0]; - for (int i = m + 1; i < k; i++) { - dAssert((i - m) >= 0); - m_controlPoints[i] = Rw[i - m]; - } - - m_knotsCount ++; - m_controlPointsCount ++; -} - -bool dBezierSpline::RemoveKnot (dFloat64 u, dFloat64 tol) -{ - int r = GetSpan(u) + 1; - dAssert (m_knotVector[r - 1] < u); - if (dAbs (m_knotVector[r] - u) > 1.0e-5f) { - return false; - } - - int s = 1; - int last = r - s; - int first = r - m_degree; - int ord = m_degree + 1; - dBigVector temp[16]; - - bool removableFlag = false; - int t = 0; - for ( ; t < m_degree; t ++) { - int off = first - 1; - temp[0] = m_controlPoints[off]; - temp[last + 1 - off] = m_controlPoints[last + 1]; - int i = first; - int j = last; - int ii = 1; - int jj = last - off; - - while ((j - i) > t) { - dFloat64 alpha_i = (u - m_knotVector[i]) / (m_knotVector[i + ord + t] - m_knotVector[i]); - dFloat64 alpha_j = (u - m_knotVector[j - t]) / (m_knotVector[j + ord] - m_knotVector[j - t]); - temp[ii] = (m_controlPoints[i] - temp[ii - 1].Scale (dFloat64 (1.0f) - alpha_i)).Scale (dFloat64 (1.0f) / alpha_i); - temp[jj] = (m_controlPoints[j] - temp[jj + 1].Scale (alpha_j)).Scale (dFloat64 (1.0f) / (dFloat64 (1.0f) - alpha_j)); - i ++; - j --; - ii ++; - jj --; - } - if ((j - i) < t) { - dBigVector diff (temp[ii - 1] - temp[jj + 1]); - removableFlag = diff.DotProduct3(diff) < (tol * tol); - } else { - dFloat64 alpha_i = (u - m_knotVector[i]) / (m_knotVector[i + ord + t] - m_knotVector[i]); - dBigVector p (temp[ii + t + 1].Scale (alpha_i) + temp[ii - 1].Scale (dFloat64 (1.0f) - alpha_i)); - dBigVector diff (m_controlPoints[i] - p); - removableFlag = diff.DotProduct3(diff) < (tol * tol); - } - if (!removableFlag) { - break; - } - - i = first; - j = last; - while ((j - 1) > t) { - m_controlPoints[i] = temp[i - off]; - m_controlPoints[j] = temp[j - off]; - i ++; - j --; - } - first --; - last ++; - } - - if (t) { - for (int k = r + t; k < m_knotsCount; k ++) { - m_knotVector[k - t] = m_knotVector[k]; - } - - int fOut = (2 * r - s - m_degree) / 2; - int j = fOut; - int i = j; - for (int k = 1; k < t; k ++) { - if ((k % 2) == 1) { - i ++; - } else { - j = j - 1; - } - } - for (int k = i + 1; k < m_controlPointsCount; k ++) { - m_controlPoints[j] = m_controlPoints[k]; - j ++; - } - - m_knotsCount -= t; - m_controlPointsCount -= t; - } - - - return removableFlag; -} - -dFloat64 dBezierSpline::FindClosestKnot(dBigVector& closestPoint, const dBigVector& point, int subdivitionSteps) const -{ - int startSpan = m_degree; - dFloat64 bestU = 0.0f; - dFloat64 distance2 = 1.0e10f; - dBigVector closestControlPoint(m_controlPoints[0]); - subdivitionSteps = dMax(subdivitionSteps, 1); - dFloat64 scale = 1.0f / subdivitionSteps; - for (int span = m_degree; span < (m_knotsCount - m_degree - 1); span++) { - dFloat64 param = 0.0f; - for (int i = 0; i < subdivitionSteps; i++) { - dFloat64 u = m_knotVector[span] + (m_knotVector[span + 1] - m_knotVector[span]) * param; - param += scale; - dBigVector p(CurvePoint(u, span)); - dBigVector dp(p - point); - dFloat64 dist2 = dp.DotProduct3(dp); - if (dist2 < distance2) { - bestU = u; - startSpan = span; - distance2 = dist2; - closestControlPoint = p; - } - } - } - - dBigVector p(CurvePoint(0.999f)); - dBigVector dp(p - point); - dFloat64 dist2 = dp.DotProduct3(dp); - if (dist2 < distance2) { - bestU = dFloat64(0.999f); - startSpan = m_knotsCount - m_degree - 2; - closestControlPoint = p; - } - - dBigVector derivatives[32]; - dFloat64 u0 = bestU; - - bool stop = false; - for (int i = 0; (i < 20) && !stop; i++) { - CurveAllDerivatives(u0, derivatives); - - dBigVector dist(closestControlPoint - point); - dFloat64 num = derivatives[1].DotProduct3(dist); - dFloat64 den = derivatives[2].DotProduct3(dist) + derivatives[1].DotProduct3(derivatives[1]); - dFloat64 u1 = dClamp(u0 - num / den, dFloat64(0.0), dFloat64(1.0)); - if (u1 < m_knotVector[startSpan]) { - startSpan--; - dAssert(startSpan >= 0); - } else if (u1 >= m_knotVector[startSpan + 1]) { - startSpan++; - dAssert(startSpan < (m_knotsCount - m_degree)); - } - - dAssert(startSpan >= m_degree); - dAssert(startSpan <= (m_knotsCount - m_degree - 1)); - closestControlPoint = CurvePoint(u1, startSpan); - - stop |= (dAbs(u1 - u0) < 1.0e-10) || (num * num < ((dist.DotProduct3(dist)) * (derivatives[1].DotProduct3(derivatives[1])) * 1.0e-10)); - u0 = u1; - } - - closestPoint = closestControlPoint; - return u0; -} diff --git a/thirdparty/src/newton/dContainers/dBezierSpline.h b/thirdparty/src/newton/dContainers/dBezierSpline.h deleted file mode 100644 index 346b32248..000000000 --- a/thirdparty/src/newton/dContainers/dBezierSpline.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dContainersStdAfx.h" -#include "dArray.h" -#include "dContainersAlloc.h" - -#ifndef __D_BEZIER_SPLINE_H__ -#define __D_BEZIER_SPLINE_H__ - -class dBezierSpline: public dContainersAlloc -{ - public: - - // empty spline - DCONTAINERS_API dBezierSpline (); - DCONTAINERS_API dBezierSpline (const dBezierSpline& src); - - // create from knot vector and control points - DCONTAINERS_API virtual ~dBezierSpline (); - - DCONTAINERS_API dBezierSpline& operator = (const dBezierSpline ©) ; - - DCONTAINERS_API int GetDegree () const; - - DCONTAINERS_API dBigVector CurvePoint (dFloat64 u) const; - DCONTAINERS_API dBigVector CurveDerivative (dFloat64 u, int index = 1) const; - DCONTAINERS_API int CurveAllDerivatives (dFloat64 u, dBigVector* const defivatives) const; - - DCONTAINERS_API dFloat64 CalculateLength (dFloat64 tol) const; - - DCONTAINERS_API void GlobalCubicInterpolation (int count, const dBigVector* const points, const dBigVector& firstTangent, const dBigVector& lastTangent); - DCONTAINERS_API void CreateFromKnotVectorAndControlPoints (int degree, int knotCount, const dFloat64* const knotVector, const dBigVector* const controlPoints); - - DCONTAINERS_API void InsertKnot (dFloat64 u); - DCONTAINERS_API bool RemoveKnot (dFloat64 u, dFloat64 tol); - - DCONTAINERS_API int GetControlPointCount() const; - DCONTAINERS_API dArray<dBigVector>& GetControlPointArray(); - DCONTAINERS_API const dArray<dBigVector>& GetControlPointArray() const; - - DCONTAINERS_API dBigVector GetControlPoint(int i) const; - DCONTAINERS_API void SetControlPoint(int i, const dBigVector& point); - - DCONTAINERS_API int GetKnotCount() const; - DCONTAINERS_API dArray<dFloat64>& GetKnotArray(); - DCONTAINERS_API const dArray<dFloat64>& GetKnotArray() const; - - DCONTAINERS_API dFloat64 GetKnot(int i) const; - DCONTAINERS_API dFloat64 FindClosestKnot (dBigVector& closestPointOnCurve, const dBigVector& point, int subdivitionSteps = 2) const; - - private: - void Clear(); - int GetSpan(dFloat64 u) const; - - dBigVector CurvePoint (dFloat64 u, int span) const; - void CreateCubicKnotVector(int count, const dBigVector* const points); - void CreateCubicControlPoints(int count, const dBigVector* const points, const dBigVector& firstTangent, const dBigVector& lastTangent); - - void BasicsFunctions (dFloat64 u, int span, dFloat64* const functionOut) const; - void BasicsFunctionsDerivatives (dFloat64 u, int span, dFloat64* const derivatyivesOut) const; - - dArray<dFloat64> m_knotVector; - dArray<dBigVector> m_controlPoints; - - int m_degree; - int m_knotsCount; - int m_controlPointsCount; -}; -#endif - diff --git a/thirdparty/src/newton/dContainers/dCRC.cpp b/thirdparty/src/newton/dContainers/dCRC.cpp deleted file mode 100644 index bbf3887b7..000000000 --- a/thirdparty/src/newton/dContainers/dCRC.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dContainersStdAfx.h" -#include "dCRC.h" - - -static dCRCTYPE randBits0[] = -{ - static_cast<long long>(7266447313870364031ULL), static_cast<long long>(4946485549665804864ULL), static_cast<long long>(16945909448695747420ULL), static_cast<long long>(16394063075524226720ULL), - static_cast<long long>(4873882236456199058ULL), static_cast<long long>(14877448043947020171ULL), static_cast<long long>(6740343660852211943ULL), static_cast<long long>(13857871200353263164ULL), - static_cast<long long>(5249110015610582907ULL), static_cast<long long>(10205081126064480383ULL), static_cast<long long>(1235879089597390050ULL), static_cast<long long>(17320312680810499042ULL), - static_cast<long long>(16489141110565194782ULL), static_cast<long long>(8942268601720066061ULL), static_cast<long long>(13520575722002588570ULL), static_cast<long long>(14226945236717732373ULL), - - static_cast<long long>(9383926873555417063ULL), static_cast<long long>(15690281668532552105ULL), static_cast<long long>(11510704754157191257ULL), static_cast<long long>(15864264574919463609ULL), - static_cast<long long>(6489677788245343319ULL), static_cast<long long>(5112602299894754389ULL), static_cast<long long>(10828930062652518694ULL), static_cast<long long>(15942305434158995996ULL), - static_cast<long long>(15445717675088218264ULL), static_cast<long long>(4764500002345775851ULL), static_cast<long long>(14673753115101942098ULL), static_cast<long long>(236502320419669032ULL), - static_cast<long long>(13670483975188204088ULL), static_cast<long long>(14931360615268175698ULL), static_cast<long long>(8904234204977263924ULL), static_cast<long long>(12836915408046564963ULL), - - static_cast<long long>(12120302420213647524ULL), static_cast<long long>(15755110976537356441ULL), static_cast<long long>(5405758943702519480ULL), static_cast<long long>(10951858968426898805ULL), - static_cast<long long>(17251681303478610375ULL), static_cast<long long>(4144140664012008120ULL), static_cast<long long>(18286145806977825275ULL), static_cast<long long>(13075804672185204371ULL), - static_cast<long long>(10831805955733617705ULL), static_cast<long long>(6172975950399619139ULL), static_cast<long long>(12837097014497293886ULL), static_cast<long long>(12903857913610213846ULL), - static_cast<long long>(560691676108914154ULL), static_cast<long long>(1074659097419704618ULL), static_cast<long long>(14266121283820281686ULL), static_cast<long long>(11696403736022963346ULL), - - static_cast<long long>(13383246710985227247ULL), static_cast<long long>(7132746073714321322ULL), static_cast<long long>(10608108217231874211ULL), static_cast<long long>(9027884570906061560ULL), - static_cast<long long>(12893913769120703138ULL), static_cast<long long>(15675160838921962454ULL), static_cast<long long>(2511068401785704737ULL), static_cast<long long>(14483183001716371453ULL), - static_cast<long long>(3774730664208216065ULL), static_cast<long long>(5083371700846102796ULL), static_cast<long long>(9583498264570933637ULL), static_cast<long long>(17119870085051257224ULL), - static_cast<long long>(5217910858257235075ULL), static_cast<long long>(10612176809475689857ULL), static_cast<long long>(1924700483125896976ULL), static_cast<long long>(7171619684536160599ULL), - - - static_cast<long long>(10949279256701751503ULL), static_cast<long long>(15596196964072664893ULL), static_cast<long long>(14097948002655599357ULL), static_cast<long long>(615821766635933047ULL), - static_cast<long long>(5636498760852923045ULL), static_cast<long long>(17618792803942051220ULL), static_cast<long long>(580805356741162327ULL), static_cast<long long>(425267967796817241ULL), - static_cast<long long>(8381470634608387938ULL), static_cast<long long>(13212228678420887626ULL), static_cast<long long>(16993060308636741960ULL), static_cast<long long>(957923366004347591ULL), - static_cast<long long>(6210242862396777185ULL), static_cast<long long>(1012818702180800310ULL), static_cast<long long>(15299383925974515757ULL), static_cast<long long>(17501832009465945633ULL), - - static_cast<long long>(17453794942891241229ULL), static_cast<long long>(15807805462076484491ULL), static_cast<long long>(8407189590930420827ULL), static_cast<long long>(974125122787311712ULL), - static_cast<long long>(1861591264068118966ULL), static_cast<long long>(997568339582634050ULL), static_cast<long long>(18046771844467391493ULL), static_cast<long long>(17981867688435687790ULL), - static_cast<long long>(3809841506498447207ULL), static_cast<long long>(9460108917638135678ULL), static_cast<long long>(16172980638639374310ULL), static_cast<long long>(958022432077424298ULL), - static_cast<long long>(4393365126459778813ULL), static_cast<long long>(13408683141069553686ULL), static_cast<long long>(13900005529547645957ULL), static_cast<long long>(15773550354402817866ULL), - - static_cast<long long>(16475327524349230602ULL), static_cast<long long>(6260298154874769264ULL), static_cast<long long>(12224576659776460914ULL), static_cast<long long>(6405294864092763507ULL), - static_cast<long long>(7585484664713203306ULL), static_cast<long long>(5187641382818981381ULL), static_cast<long long>(12435998400285353380ULL), static_cast<long long>(13554353441017344755ULL), - static_cast<long long>(646091557254529188ULL), static_cast<long long>(11393747116974949255ULL), static_cast<long long>(16797249248413342857ULL), static_cast<long long>(15713519023537495495ULL), - static_cast<long long>(12823504709579858843ULL), static_cast<long long>(4738086532119935073ULL), static_cast<long long>(4429068783387643752ULL), static_cast<long long>(585582692562183870ULL), - - static_cast<long long>(1048280754023674130ULL), static_cast<long long>(6788940719869959076ULL), static_cast<long long>(11670856244972073775ULL), static_cast<long long>(2488756775360218862ULL), - static_cast<long long>(2061695363573180185ULL), static_cast<long long>(6884655301895085032ULL), static_cast<long long>(3566345954323888697ULL), static_cast<long long>(12784319933059041817ULL), - static_cast<long long>(4772468691551857254ULL), static_cast<long long>(6864898938209826895ULL), static_cast<long long>(7198730565322227090ULL), static_cast<long long>(2452224231472687253ULL), - static_cast<long long>(13424792606032445807ULL), static_cast<long long>(10827695224855383989ULL), static_cast<long long>(11016608897122070904ULL), static_cast<long long>(14683280565151378358ULL), - - static_cast<long long>(7077866519618824360ULL), static_cast<long long>(17487079941198422333ULL), static_cast<long long>(3956319990205097495ULL), static_cast<long long>(5804870313319323478ULL), - static_cast<long long>(8017203611194497730ULL), static_cast<long long>(3310931575584983808ULL), static_cast<long long>(5009341981771541845ULL), static_cast<long long>(11772020174577005930ULL), - static_cast<long long>(3537640779967351792ULL), static_cast<long long>(6801855569284252424ULL), static_cast<long long>(17687268231192623388ULL), static_cast<long long>(12968358613633237218ULL), - static_cast<long long>(1429775571144180123ULL), static_cast<long long>(10427377732172208413ULL), static_cast<long long>(12155566091986788996ULL), static_cast<long long>(16465954421598296115ULL), - - static_cast<long long>(12710429690464359999ULL), static_cast<long long>(9547226351541565595ULL), static_cast<long long>(12156624891403410342ULL), static_cast<long long>(2985938688676214686ULL), - static_cast<long long>(18066917785985010959ULL), static_cast<long long>(5975570403614438776ULL), static_cast<long long>(11541343163022500560ULL), static_cast<long long>(11115388652389704592ULL), - static_cast<long long>(9499328389494710074ULL), static_cast<long long>(9247163036769651820ULL), static_cast<long long>(3688303938005101774ULL), static_cast<long long>(2210483654336887556ULL), - static_cast<long long>(15458161910089693228ULL), static_cast<long long>(6558785204455557683ULL), static_cast<long long>(1288373156735958118ULL), static_cast<long long>(18433986059948829624ULL), - - static_cast<long long>(3435082195390932486ULL), static_cast<long long>(16822351800343061990ULL), static_cast<long long>(3120532877336962310ULL), static_cast<long long>(16681785111062885568ULL), - static_cast<long long>(7835551710041302304ULL), static_cast<long long>(2612798015018627203ULL), static_cast<long long>(15083279177152657491ULL), static_cast<long long>(6591467229462292195ULL), - static_cast<long long>(10592706450534565444ULL), static_cast<long long>(7438147750787157163ULL), static_cast<long long>(323186165595851698ULL), static_cast<long long>(7444710627467609883ULL), - static_cast<long long>(8473714411329896576ULL), static_cast<long long>(2782675857700189492ULL), static_cast<long long>(3383567662400128329ULL), static_cast<long long>(3200233909833521327ULL), - - static_cast<long long>(12897601280285604448ULL), static_cast<long long>(3612068790453735040ULL), static_cast<long long>(8324209243736219497ULL), static_cast<long long>(15789570356497723463ULL), - static_cast<long long>(1083312926512215996ULL), static_cast<long long>(4797349136059339390ULL), static_cast<long long>(5556729349871544986ULL), static_cast<long long>(18266943104929747076ULL), - static_cast<long long>(1620389818516182276ULL), static_cast<long long>(172225355691600141ULL), static_cast<long long>(3034352936522087096ULL), static_cast<long long>(1266779576738385285ULL), - static_cast<long long>(3906668377244742888ULL), static_cast<long long>(6961783143042492788ULL), static_cast<long long>(17159706887321247572ULL), static_cast<long long>(4676208075243319061ULL), - - static_cast<long long>(10315634697142985816ULL), static_cast<long long>(13435140047933251189ULL), static_cast<long long>(716076639492622016ULL), static_cast<long long>(13847954035438697558ULL), - static_cast<long long>(7195811275139178570ULL), static_cast<long long>(10815312636510328870ULL), static_cast<long long>(6214164734784158515ULL), static_cast<long long>(16412194511839921544ULL), - static_cast<long long>(3862249798930641332ULL), static_cast<long long>(1005482699535576005ULL), static_cast<long long>(4644542796609371301ULL), static_cast<long long>(17600091057367987283ULL), - static_cast<long long>(4209958422564632034ULL), static_cast<long long>(5419285945389823940ULL), static_cast<long long>(11453701547564354601ULL), static_cast<long long>(9951588026679380114ULL), - - static_cast<long long>(7425168333159839689ULL), static_cast<long long>(8436306210125134906ULL), static_cast<long long>(11216615872596820107ULL), static_cast<long long>(3681345096403933680ULL), - static_cast<long long>(5770016989916553752ULL), static_cast<long long>(11102855936150871733ULL), static_cast<long long>(11187980892339693935ULL), static_cast<long long>(396336430216428875ULL), - static_cast<long long>(6384853777489155236ULL), static_cast<long long>(7551613839184151117ULL), static_cast<long long>(16527062023276943109ULL), static_cast<long long>(13429850429024956898ULL), - static_cast<long long>(9901753960477271766ULL), static_cast<long long>(9731501992702612259ULL), static_cast<long long>(5217575797614661659ULL), static_cast<long long>(10311708346636548706ULL), - - static_cast<long long>(15111747519735330483ULL), static_cast<long long>(4353415295139137513ULL), static_cast<long long>(1845293119018433391ULL), static_cast<long long>(11952006873430493561ULL), - static_cast<long long>(3531972641585683893ULL), static_cast<long long>(16852246477648409827ULL), static_cast<long long>(15956854822143321380ULL), static_cast<long long>(12314609993579474774ULL), - static_cast<long long>(16763911684844598963ULL), static_cast<long long>(16392145690385382634ULL), static_cast<long long>(1545507136970403756ULL), static_cast<long long>(17771199061862790062ULL), - static_cast<long long>(12121348462972638971ULL), static_cast<long long>(12613068545148305776ULL), static_cast<long long>(954203144844315208ULL), static_cast<long long>(1257976447679270605ULL), - - static_cast<long long>(3664184785462160180ULL), static_cast<long long>(2747964788443845091ULL), static_cast<long long>(15895917007470512307ULL), static_cast<long long>(15552935765724302120ULL), - static_cast<long long>(16366915862261682626ULL), static_cast<long long>(8385468783684865323ULL), static_cast<long long>(10745343827145102946ULL), static_cast<long long>(2485742734157099909ULL), - static_cast<long long>(916246281077683950ULL), static_cast<long long>(15214206653637466707ULL), static_cast<long long>(12895483149474345798ULL), static_cast<long long>(1079510114301747843ULL), - static_cast<long long>(10718876134480663664ULL), static_cast<long long>(1259990987526807294ULL), static_cast<long long>(8326303777037206221ULL), static_cast<long long>(14104661172014248293ULL), -}; - -dCRCTYPE dCombineCRC (dCRCTYPE a, dCRCTYPE b) -{ - return (a << 8) ^ b; -} - -// calculate a 32 bit crc of a string -dCRCTYPE dCRC64 (const char* const name, dCRCTYPE crcAcc) -{ - if (name) { - const int bitshift = (sizeof (dCRCTYPE)<<3) - 8; - for (int i = 0; name[i]; i ++) { - char c = name[i]; - dCRCTYPE val = randBits0[((crcAcc >> bitshift) ^ c) & 0xff]; - crcAcc = (crcAcc << 8) ^ val; - } - } - return crcAcc; -} - - -dCRCTYPE dCRC64 (const void* const buffer, int size, dCRCTYPE crcAcc) -{ - const unsigned char* const ptr = (unsigned char*)buffer; - - const int bitshift = (sizeof (dCRCTYPE)<<3) - 8; - for (int i = 0; i < size; i ++) { - char c = ptr[i]; - dCRCTYPE val = randBits0[((crcAcc >> bitshift) ^ c) & 0xff]; - crcAcc = (crcAcc << 8) ^ val; - } - return crcAcc; -} - - - - diff --git a/thirdparty/src/newton/dContainers/dCRC.h b/thirdparty/src/newton/dContainers/dCRC.h deleted file mode 100644 index f12b59766..000000000 --- a/thirdparty/src/newton/dContainers/dCRC.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#ifndef __dCRC__ -#define __dCRC__ - -#include "dContainersAlloc.h" - -#define dCRCTYPE long long - -DCONTAINERS_API dCRCTYPE dCRC64 (const char* const string, dCRCTYPE crcAcc = 0); -DCONTAINERS_API dCRCTYPE dCRC64 (const void* const buffer, int size, dCRCTYPE crcAcc); - -DCONTAINERS_API dCRCTYPE dCombineCRC (dCRCTYPE a, dCRCTYPE b); - -#endif - diff --git a/thirdparty/src/newton/dContainers/dClassInfo.cpp b/thirdparty/src/newton/dContainers/dClassInfo.cpp deleted file mode 100644 index 588d8e6d6..000000000 --- a/thirdparty/src/newton/dContainers/dClassInfo.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - - -#include "dContainersStdAfx.h" -#include "dClassInfo.h" - -//dRtti dClassInfo::m_rtti ("dClassInfo"); -dRttiRootClassSupportImplement(dClassInfo); diff --git a/thirdparty/src/newton/dContainers/dClassInfo.h b/thirdparty/src/newton/dContainers/dClassInfo.h deleted file mode 100644 index 0aebf9c1e..000000000 --- a/thirdparty/src/newton/dContainers/dClassInfo.h +++ /dev/null @@ -1,32 +0,0 @@ - -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#ifndef __DCLASS_INFO_H__ -#define __DCLASS_INFO_H__ - -#include "dRtti.h" -#include "dRefCounter.h" - -class dClassInfo: public dRefCounter -{ - public: - dClassInfo(void) - { - } - virtual ~dClassInfo() - { - } - - dRttiRootClassSupportDeclare(dClassInfo,DCONTAINERS_API); -}; - -#endif diff --git a/thirdparty/src/newton/dContainers/dContainersAlloc.cpp b/thirdparty/src/newton/dContainers/dContainersAlloc.cpp deleted file mode 100644 index fbc25eec2..000000000 --- a/thirdparty/src/newton/dContainers/dContainersAlloc.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dContainersStdAfx.h" -#include "dContainersAlloc.h" - - -#pragma warning (disable: 4100) //warning C4100: 'lpReserved' : unreferenced formal parameter - -#ifdef _DCONTAINERS_DLL - void* operator new (size_t size) - { - void* const ptr = malloc (size); - dAssert (ptr); - return ptr; - } - - void operator delete (void* ptr) - { - free (ptr); - } - - BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) - { - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - // check for memory leaks - #if defined(_DEBUG) && defined(_MSC_VER) - // Track all memory leaks at the operating system level. - // make sure no Newton tool or utility leaves leaks behind. - _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF)); - #endif - - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; - } -#endif - - -void* dContainersAlloc::operator new (size_t size) -{ - //return ::new char[size]; - return Alloc (size); -} - -void dContainersAlloc::operator delete (void* ptr) -{ -// delete[] (char*) ptr; - Free(ptr); -} - -void* dContainersAlloc::Alloc (size_t size) -{ - char* const ptr = ::new char[size]; - return ptr; -} - -void dContainersAlloc::Free(void* const ptr) -{ - delete[] (char*) ptr; -} - - - - -dContainerFixSizeAllocator::dContainerFixSizeAllocator(int size, int poolSize) - :m_freeListNode(NULL) - ,m_size(size) - ,m_poolSize(poolSize) -{ - Prefetch (); -} - - -dContainerFixSizeAllocator::~dContainerFixSizeAllocator() -{ - Flush(); -} - - -dContainerFixSizeAllocator* dContainerFixSizeAllocator::Create (int size, int poolSize) -{ - class AllocatorsFactory - { - public: - AllocatorsFactory() - :m_count(0) - ,m_maxSize(0) - ,m_pool (NULL) - { - m_maxSize = 1; - m_pool = new dContainerFixSizeAllocator*[1]; - } - - ~AllocatorsFactory() - { - for (int i = 0; i < m_count; i ++) { - delete m_pool[i]; - } - delete[] m_pool; - } - - dContainerFixSizeAllocator* FindCreate (int size, int poolSize) - { - int i0 = 0; - int i2 = m_count -1; - while ((i2 - i0) > 4) { - int i1 = (i0 + i2) >> 1; - if (size < m_pool[i1]->m_size) { - i2 = i1; - } else { - i0 = i1; - } - } - - for (int i = i0; (i < m_count) && (m_pool[i]->m_size <= size); i ++) { - if (m_pool[i]->m_size == size) { - return m_pool[i]; - } - } - - if (m_count == m_maxSize) { - m_maxSize *= 2; - dContainerFixSizeAllocator** pool = new dContainerFixSizeAllocator*[m_maxSize]; - memcpy (pool, m_pool, m_count * sizeof (dContainerFixSizeAllocator*)); - delete[] m_pool; - m_pool = pool; - } - - dContainerFixSizeAllocator* const allocator = new dContainerFixSizeAllocator(size, poolSize); - - int entry = m_count; - for (; entry && (m_pool[entry - 1]->m_size > size); entry --) { - m_pool[entry] = m_pool[entry - 1]; - } - m_pool[entry] = allocator; - m_count ++; - return allocator; - } - - int m_count; - int m_maxSize; - dContainerFixSizeAllocator** m_pool; - }; - - static AllocatorsFactory factories; - return factories.FindCreate(size, poolSize); -} - - -void dContainerFixSizeAllocator::Prefetch () -{ - for (int i = 0; i < m_poolSize; i ++) { - dFreeListNode* const data = (dFreeListNode*) dContainersAlloc::Alloc (m_size); - data->m_count = i + 1; - data->m_next = m_freeListNode; - m_freeListNode = data; - } -} - - -void dContainerFixSizeAllocator::Flush () -{ - for (int i = 0; m_freeListNode && (i < m_poolSize); i ++) { - dFreeListNode* const ptr = m_freeListNode; - m_freeListNode = m_freeListNode->m_next; - dContainersAlloc::Free (ptr); - } -} - - -void* dContainerFixSizeAllocator::Alloc() -{ - if (!m_freeListNode) { - Prefetch (); - } - dFreeListNode* const data = m_freeListNode; - m_freeListNode = m_freeListNode->m_next; - return data; -} - - -void dContainerFixSizeAllocator::Free(void* const ptr) -{ - dFreeListNode* const data = (dFreeListNode*) ptr; - data->m_count = m_freeListNode ? m_freeListNode->m_count + 1 : 1; - data->m_next = m_freeListNode; - m_freeListNode = data; - if (data->m_count >= 2 * m_poolSize) { - Flush(); - } -} diff --git a/thirdparty/src/newton/dContainers/dContainersAlloc.h b/thirdparty/src/newton/dContainers/dContainersAlloc.h deleted file mode 100644 index a0163fc56..000000000 --- a/thirdparty/src/newton/dContainers/dContainersAlloc.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _D_CONTAINERS_ALLOC_H_ -#define _D_CONTAINERS_ALLOC_H_ -#include "dContainersStdAfx.h" - -#define D_MAX_ENTRIES_IN_FREELIST 32 - -class dContainersAlloc -{ - public: - DCONTAINERS_API void *operator new (size_t size); - DCONTAINERS_API void operator delete (void* ptr); - - dContainersAlloc() - { - } - - virtual ~dContainersAlloc() - { - } - - static DCONTAINERS_API void* Alloc (size_t size); - static DCONTAINERS_API void Free (void* const ptr); -}; - - -class dContainerFixSizeAllocator -{ - public: - static DCONTAINERS_API dContainerFixSizeAllocator* Create (int size, int poolSize); - DCONTAINERS_API ~dContainerFixSizeAllocator(); - DCONTAINERS_API void* Alloc(); - DCONTAINERS_API void Free(void* const ptr); -// DCONTAINERS_API bool IsAlive() const; - DCONTAINERS_API void Flush (); - - private: - DCONTAINERS_API dContainerFixSizeAllocator(int size, int poolSize); - - class dFreeListNode - { - public: - int m_count; - dFreeListNode* m_next; - }; - - DCONTAINERS_API void Prefetch (); - - dFreeListNode* m_freeListNode; - int m_size; - int m_poolSize; -}; - - -#endif diff --git a/thirdparty/src/newton/dContainers/dContainersStdAfx.cpp b/thirdparty/src/newton/dContainers/dContainersStdAfx.cpp deleted file mode 100644 index 7f10bf6a3..000000000 --- a/thirdparty/src/newton/dContainers/dContainersStdAfx.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -// stdafx.cpp : source file that includes just the standard includes -// containers.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "dContainersStdAfx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file - - diff --git a/thirdparty/src/newton/dContainers/dContainersStdAfx.h b/thirdparty/src/newton/dContainers/dContainersStdAfx.h deleted file mode 100644 index 0f9816eb2..000000000 --- a/thirdparty/src/newton/dContainers/dContainersStdAfx.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#ifndef __D_CONTAINERS_STDAFX__ -#define __D_CONTAINERS_STDAFX__ - -#include <new> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <assert.h> -#include <dMathDefines.h> -#include <dVector.h> -#include <dMatrix.h> - -#include <dgTypes.h> - -#ifdef _DCONTAINERS_DLL - #ifdef _DCONTAINERS_EXPORT - #define DCONTAINERS_API DG_LIBRARY_EXPORT - #else - #define DCONTAINERS_API DG_LIBRARY_IMPORT - #endif -#else - #define DCONTAINERS_API DG_LIBRARY_STATIC -#endif - - -#ifdef _WIN32 - #include <windows.h> - #include <crtdbg.h> -#endif - -#ifdef _MACOSX_VER - #include <unistd.h> - #include <libkern/OSAtomic.h> - #include <sys/sysctl.h> -#endif - -#include <dMathDefines.h> - -#endif diff --git a/thirdparty/src/newton/dContainers/dHeap.h b/thirdparty/src/newton/dContainers/dHeap.h deleted file mode 100644 index c32daef17..000000000 --- a/thirdparty/src/newton/dContainers/dHeap.h +++ /dev/null @@ -1,421 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dHeapBase__ -#define __dHeapBase__ - - -#include "dContainersStdAfx.h" -#include "dContainersAlloc.h" - -//#define D_CHECK_HEAP - - -template <class OBJECT, class KEY> -class dHeapBase: public dContainersAlloc -{ - protected: - struct dHeapRecord - { - dHeapRecord () - :m_key(), m_obj() - { - } - - dHeapRecord (KEY key, const OBJECT& obj) - :m_key(key), m_obj(obj) - { - } - - ~dHeapRecord () - { - } - - KEY m_key; - OBJECT m_obj; - }; - - dHeapBase (int maxElements); - virtual ~dHeapBase (); - - public: - void Flush (); - KEY MaxValue() const; - KEY Value(int i = 0) const; - int GetCount() const; - int GetMaxCount() const; - const OBJECT& operator[] (int i) const; - int Find (OBJECT &obj); - int Find (KEY key); - - int m_curCount; - int m_maxCount; - bool m_allocated; - dHeapRecord* m_pool; -}; - -template <class OBJECT, class KEY> -class dDownHeap: public dHeapBase<OBJECT, KEY> -{ - public: - dDownHeap (int maxElements); - - void Pop () {Remove (0);} - void Push (OBJECT &obj, KEY key); - void Sort (); - void Remove (int Index); - bool SanityCheck(); -}; - -template <class OBJECT, class KEY> -class dUpHeap: public dHeapBase<OBJECT, KEY> -{ - public: - dUpHeap (int maxElements); - - void Pop () {Remove (0);} - void Push (OBJECT &obj, KEY key); - void Sort (); - void Remove (int Index); - bool SanityCheck(); -}; - -template <class OBJECT, class KEY> -dHeapBase<OBJECT,KEY>::dHeapBase (int maxElements) - :m_curCount(0) - ,m_maxCount(maxElements) - ,m_allocated(true) - ,m_pool(new dHeapRecord[maxElements]) -{ - Flush(); -} - - -template <class OBJECT, class KEY> -dHeapBase<OBJECT,KEY>::~dHeapBase () -{ - if (m_allocated == true) { - delete[] m_pool; - } -} - - -template <class OBJECT, class KEY> -KEY dHeapBase<OBJECT,KEY>::Value(int i) const -{ - return m_pool[i].m_key; -} - - -template <class OBJECT, class KEY> -int dHeapBase<OBJECT,KEY>::GetCount() const -{ - return m_curCount; -} - - -template <class OBJECT, class KEY> -void dHeapBase<OBJECT,KEY>::Flush () -{ - m_curCount = 0; - - #ifdef _DEBUG -// dHeapBase<OBJECT,KEY>::m_pool[dHeapBase<OBJECT,KEY>::m_curCount].m_key = KEY (0); - #endif -} - - -template <class OBJECT, class KEY> -KEY dHeapBase<OBJECT,KEY>::MaxValue() const -{ - return m_pool[0].m_key; -} - - -template <class OBJECT, class KEY> -int dHeapBase<OBJECT,KEY>::GetMaxCount() const -{ - return m_maxCount; -} - - -template <class OBJECT, class KEY> -int dHeapBase<OBJECT,KEY>::Find (OBJECT &obj) -{ - // For now let perform a linear search - // this is efficient if the size of the heap is small - // ex: m_curCount < 32 - // this will be change to a binary search in the heap should the - // the size of the heap get larger than 32 - // dAssert (m_curCount <= 32); - for (int i = 0; i < m_curCount; i ++) { - if (m_pool[i].obj == obj) { - return i; - } - } - return - 1; -} - -template <class OBJECT, class KEY> -int dHeapBase<OBJECT,KEY>::Find (KEY key) -{ - // ex: m_curCount < 32 - // this will be change to a binary search in the heap shoud the - // the size of the heap get larger than 32 - dAssert (m_curCount <= 32); - for (int i = 0; i < m_curCount; i ++) { - if (m_pool[i].m_key == key) { - return i; - } - } - return - 1; -} - - -template <class OBJECT, class KEY> -const OBJECT& dHeapBase<OBJECT,KEY>::operator[] (int i) const -{ - dAssert (i<= m_curCount); - return m_pool[i].m_obj; -} - - -// ************************************************************************** -// -// down Heap -// -// ************************************************************************** -template <class OBJECT, class KEY> -dDownHeap<OBJECT,KEY>::dDownHeap (int maxElements) - :dHeapBase<OBJECT, KEY> (maxElements) -{ -} - -template <class OBJECT, class KEY> -void dDownHeap<OBJECT,KEY>::Push (OBJECT &obj, KEY key) -{ - dAssert ((dHeapBase<OBJECT,KEY>::m_curCount < dHeapBase<OBJECT,KEY>::m_maxCount)); - dHeapBase<OBJECT,KEY>::m_curCount ++; - - int j; - int i = dHeapBase<OBJECT,KEY>::m_curCount; - for (; i; i = j) { - j = i >> 1; - if (!j || (dHeapBase<OBJECT,KEY>::m_pool[j - 1].m_key > key)) { - break; - } - dHeapBase<OBJECT,KEY>::m_pool[i - 1] = dHeapBase<OBJECT,KEY>::m_pool[j - 1]; - } - dAssert (i); - dHeapBase<OBJECT,KEY>::m_pool[i - 1].m_key = key; - dHeapBase<OBJECT,KEY>::m_pool[i - 1].m_obj = obj; - dAssert (SanityCheck()); -} - -template <class OBJECT, class KEY> -void dDownHeap<OBJECT,KEY>::Remove (int index) -{ - dHeapBase<OBJECT, KEY>::m_curCount--; - dHeapBase<OBJECT, KEY>::m_pool[index] = dHeapBase<OBJECT, KEY>::m_pool[dHeapBase<OBJECT, KEY>::m_curCount]; - while (index && dHeapBase<OBJECT, KEY>::m_pool[(index - 1) >> 1].m_key < dHeapBase<OBJECT, KEY>::m_pool[index].m_key) { - dSwap(dHeapBase<OBJECT, KEY>::m_pool[(index - 1) >> 1], dHeapBase<OBJECT, KEY>::m_pool[index]); - index = (index - 1) >> 1; - } - - while ((2 * index + 1) < dHeapBase<OBJECT, KEY>::m_curCount) { - int i0 = 2 * index + 1; - int i1 = 2 * index + 2; - if (i1 < dHeapBase<OBJECT, KEY>::m_curCount) { - i0 = (dHeapBase<OBJECT, KEY>::m_pool[i0].m_key > dHeapBase<OBJECT, KEY>::m_pool[i1].m_key) ? i0 : i1; - if (dHeapBase<OBJECT, KEY>::m_pool[i0].m_key <= dHeapBase<OBJECT, KEY>::m_pool[index].m_key) { - break; - } - dSwap(dHeapBase<OBJECT, KEY>::m_pool[i0], dHeapBase<OBJECT, KEY>::m_pool[index]); - index = i0; - } else { - if (dHeapBase<OBJECT, KEY>::m_pool[i0].m_key > dHeapBase<OBJECT, KEY>::m_pool[index].m_key) { - dSwap(dHeapBase<OBJECT, KEY>::m_pool[i0], dHeapBase<OBJECT, KEY>::m_pool[index]); - } - index = i0; - } - } - dAssert(SanityCheck()); -} - -template <class OBJECT, class KEY> -void dDownHeap<OBJECT,KEY>::Sort () -{ - int count = dHeapBase<OBJECT,KEY>::m_curCount; - for (int i = 1; i < count; i ++) { - KEY key (dHeapBase<OBJECT,KEY>::m_pool[0].m_key); - OBJECT obj (dHeapBase<OBJECT,KEY>::m_pool[0].m_obj); - - Pop(); - - dHeapBase<OBJECT,KEY>::m_pool[dHeapBase<OBJECT,KEY>::m_curCount].m_key = key; - dHeapBase<OBJECT,KEY>::m_pool[dHeapBase<OBJECT,KEY>::m_curCount].m_obj = obj; - } - - dHeapBase<OBJECT,KEY>::m_curCount = count; - for (int i = 0; i < count / 2; i ++) { - KEY key (dHeapBase<OBJECT,KEY>::m_pool[i].m_key); - OBJECT obj (dHeapBase<OBJECT,KEY>::m_pool[i].m_obj); - - dHeapBase<OBJECT,KEY>::m_pool[i].m_key = dHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_key; - dHeapBase<OBJECT,KEY>::m_pool[i].m_obj = dHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_obj; - - dHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_key = key; - dHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_obj = obj; - } - dAssert (SanityCheck()); -} - -template <class OBJECT, class KEY> -bool dDownHeap<OBJECT, KEY>::SanityCheck() -{ -#ifdef D_CHECK_HEAP - for (int i = 0; i < this->m_curCount; i++) { - int i1 = 2 * i + 1; - int i2 = 2 * i + 2; - if ((i1 < this->m_curCount) && (dHeapBase<OBJECT, KEY>::m_pool[i].m_key < dHeapBase<OBJECT, KEY>::m_pool[i1].m_key)) { - return false; - } - if ((i2 < this->m_curCount) && (dHeapBase<OBJECT, KEY>::m_pool[i].m_key < dHeapBase<OBJECT, KEY>::m_pool[i2].m_key)) { - return false; - } - } -#endif - return true; -} - - -// ************************************************************************** -// -// Up Heap -// -// ************************************************************************** -template <class OBJECT, class KEY> -dUpHeap<OBJECT,KEY>::dUpHeap (int maxElements) - :dHeapBase<OBJECT, KEY> (maxElements) -{ -} - -template <class OBJECT, class KEY> -void dUpHeap<OBJECT,KEY>::Push (OBJECT &obj, KEY key) -{ - dAssert ((dHeapBase<OBJECT,KEY>::m_curCount < dHeapBase<OBJECT,KEY>::m_maxCount)); - dHeapBase<OBJECT,KEY>::m_curCount ++; - - int j; - int i = dHeapBase<OBJECT,KEY>::m_curCount; - for (; i; i = j) { - j = i >> 1; - if (!j || (dHeapBase<OBJECT,KEY>::m_pool[j - 1].m_key < key)) { - break; - } - dHeapBase<OBJECT,KEY>::m_pool[i - 1] = dHeapBase<OBJECT,KEY>::m_pool[j - 1]; - } - dAssert (i); - dHeapBase<OBJECT,KEY>::m_pool[i - 1].m_key = key; - dHeapBase<OBJECT,KEY>::m_pool[i - 1].m_obj = obj; - dAssert (SanityCheck()); -} - - -template <class OBJECT, class KEY> -void dUpHeap<OBJECT,KEY>::Sort () -{ - int count = dHeapBase<OBJECT,KEY>::m_curCount; - for (int i = 1; i < count; i ++) { - KEY key (dHeapBase<OBJECT,KEY>::m_pool[0].m_key); - OBJECT obj (dHeapBase<OBJECT,KEY>::m_pool[0].m_obj); - - Pop(); - - dHeapBase<OBJECT,KEY>::m_pool[dHeapBase<OBJECT,KEY>::m_curCount].m_key = key; - dHeapBase<OBJECT,KEY>::m_pool[dHeapBase<OBJECT,KEY>::m_curCount].m_obj = obj; - } - - dHeapBase<OBJECT,KEY>::m_curCount = count; - for (int i = 0; i < count / 2; i ++) { - KEY key (dHeapBase<OBJECT,KEY>::m_pool[i].m_key); - OBJECT obj (dHeapBase<OBJECT,KEY>::m_pool[i].m_obj); - - dHeapBase<OBJECT,KEY>::m_pool[i].m_key = dHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_key; - dHeapBase<OBJECT,KEY>::m_pool[i].m_obj = dHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_obj; - - dHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_key = key; - dHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_obj = obj; - } - dAssert (SanityCheck()); -} - -template <class OBJECT, class KEY> -void dUpHeap<OBJECT,KEY>::Remove (int index) -{ - dHeapBase<OBJECT, KEY>::m_curCount--; - dHeapBase<OBJECT, KEY>::m_pool[index] = dHeapBase<OBJECT, KEY>::m_pool[dHeapBase<OBJECT, KEY>::m_curCount]; - while (index && dHeapBase<OBJECT, KEY>::m_pool[(index - 1) >> 1].m_key > dHeapBase<OBJECT, KEY>::m_pool[index].m_key) { - dSwap(dHeapBase<OBJECT, KEY>::m_pool[(index - 1) >> 1], dHeapBase<OBJECT, KEY>::m_pool[index]); - index = (index - 1) >> 1; - } - - while ((2 * index + 1) < dHeapBase<OBJECT, KEY>::m_curCount) { - int i0 = 2 * index + 1; - int i1 = 2 * index + 2; - if (i1 < dHeapBase<OBJECT, KEY>::m_curCount) { - i0 = (dHeapBase<OBJECT, KEY>::m_pool[i0].m_key < dHeapBase<OBJECT, KEY>::m_pool[i1].m_key) ? i0 : i1; - if (dHeapBase<OBJECT, KEY>::m_pool[i0].m_key >= dHeapBase<OBJECT, KEY>::m_pool[index].m_key) { - break; - } - dSwap(dHeapBase<OBJECT, KEY>::m_pool[i0], dHeapBase<OBJECT, KEY>::m_pool[index]); - index = i0; - } else { - if (dHeapBase<OBJECT, KEY>::m_pool[i0].m_key < dHeapBase<OBJECT, KEY>::m_pool[index].m_key) { - dSwap(dHeapBase<OBJECT, KEY>::m_pool[i0], dHeapBase<OBJECT, KEY>::m_pool[index]); - } - index = i0; - } - } - dAssert (SanityCheck()); -} - -template <class OBJECT, class KEY> -bool dUpHeap<OBJECT, KEY>::SanityCheck() -{ -#ifdef D_CHECK_HEAP - for (int i = 0; i < this->m_curCount; i++) { - int i1 = 2 * i + 1; - int i2 = 2 * i + 2; - if ((i1 < this->m_curCount) && (dHeapBase<OBJECT, KEY>::m_pool[i].m_key > dHeapBase<OBJECT, KEY>::m_pool[i1].m_key)) { - return false; - } - if ((i2 < this->m_curCount) && (dHeapBase<OBJECT, KEY>::m_pool[i].m_key > dHeapBase<OBJECT, KEY>::m_pool[i2].m_key)) { - return false; - } - } -#endif - return true; -} - - -#endif - diff --git a/thirdparty/src/newton/dContainers/dList.h b/thirdparty/src/newton/dContainers/dList.h deleted file mode 100644 index cb5373e9b..000000000 --- a/thirdparty/src/newton/dContainers/dList.h +++ /dev/null @@ -1,483 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - - -#ifndef __dList__ -#define __dList__ - -#include "dContainersStdAfx.h" -#include "dContainersAlloc.h" - - -// a small double link list container similar to STL, -template<class T, int poolSize = D_MAX_ENTRIES_IN_FREELIST> -class dList: public dContainersAlloc -{ - public: - class dListNode - { - dListNode (dListNode* const prev, dListNode* const next) - :m_info () - { - m_prev = prev; - m_next = next; - if (m_prev) { - m_prev->m_next = this; - } - if (m_next) { - m_next->m_prev = this; - } - } - - dListNode (const T &info, dListNode* prev, dListNode* next) - :m_info (info) - { - m_prev = prev; - m_next = next; - if (m_prev) { - m_prev->m_next = this; - } - if (m_next) { - m_next->m_prev = this; - } - } - - virtual ~dListNode() - { - } - - void Unlink () - { - if (m_prev) { - m_prev->m_next = m_next; - } - - if (m_next) { - m_next->m_prev = m_prev; - } - m_prev = NULL; - m_next = NULL; - } - - void Remove() - { - Unlink(); - this->~dListNode(); - } - - void AddLast(dListNode* const node) - { - m_next = node; - node->m_prev = this; - } - - void AddFirst(dListNode* const node) - { - m_prev = node; - node->m_next = this; - } - - public: - T& GetInfo() - { - return m_info; - } - - const T& GetInfo() const - { - return m_info; - } - - - dListNode* GetNext() const - { - return m_next; - } - - dListNode* GetPrev() const - { - return m_prev; - } - - private: - T m_info; - dListNode* m_next; - dListNode* m_prev; - friend class dList<T, poolSize>; - }; - - class Iterator - { - public: - Iterator (const dList<T, poolSize> &me) - { - m_ptr = NULL; - m_list = (dList *)&me; - } - - ~Iterator () - { - } - - operator int() const - { - return m_ptr != NULL; - } - - bool operator== (const Iterator &target) const - { - return (m_ptr == target.m_ptr) && (m_list == target.m_list); - } - - void Begin() - { - m_ptr = m_list->GetFirst(); - } - - void End() - { - m_ptr = m_list->GetLast(); - } - - void Set (dListNode* const node) - { - m_ptr = node; - } - - void operator++ () - { - m_ptr = m_ptr->m_next(); - } - - void operator++ (int) - { - m_ptr = m_ptr->GetNext(); - } - - void operator-- () - { - m_ptr = m_ptr->GetPrev(); - } - - void operator-- (int) - { - m_ptr = m_ptr->GetPrev(); - } - - T &operator* () const - { - return m_ptr->GetInfo(); - } - - dListNode* GetNode() const - { - return m_ptr; - } - - private: - dList *m_list; - dListNode* m_ptr; - }; - - // *********************************************************** - // member functions - // *********************************************************** - public: - dList (); - virtual ~dList (); - - operator int() const; - int GetCount() const; - dListNode* GetLast() const; - dListNode* GetFirst() const; - dListNode* Append (); - dListNode* Append (const T &element); - dListNode* Addtop (); - dListNode* Addtop (const T &element); - dListNode* AppendAfter (dListNode* const node); - - void RotateToEnd (dListNode* const node); - void RotateToBegin (dListNode* const node); - void InsertAfter (dListNode* const root, dListNode* const node); - - dListNode* Find (const T &element) const; - dListNode* GetNodeFromInfo (T &m_info) const; - void Remove (dListNode* const node); - void Remove (const T &element); - void RemoveAll (); - - // special routines - // move the data to the target list and set to zero m_count, m_first and m_last - void TranferDataToTarget (dList& target); - - // *********************************************************** - // member variables - // *********************************************************** - private: -/* - bool Sanity() const - { - int count = 0; - for (dListNode* ptr = GetFirst(); ptr; ptr = ptr->GetNext()) - count ++; - return count == m_count; - } -*/ - bool Sanity() const {return true;} - dContainerFixSizeAllocator& GetAllocator() - { - static dContainerFixSizeAllocator* allocator = NULL; - if (!allocator) { - allocator = dContainerFixSizeAllocator::Create (sizeof (dList<T, poolSize>::dListNode), poolSize); - } - return *allocator; - } - - int m_count; - dListNode* m_first; - dListNode* m_last; - friend class dListNode; -}; - - -template<class T, int poolSize> -dList<T, poolSize>::dList () -{ - m_count = 0; - m_first = NULL; - m_last = NULL; - GetAllocator(); -} - - -template<class T, int poolSize> -dList<T, poolSize>::~dList () -{ - RemoveAll (); -} - - -template<class T, int poolSize> -int dList<T, poolSize>::GetCount() const -{ - return m_count; -} - -template<class T, int poolSize> -dList<T, poolSize>::operator int() const -{ - return m_first != NULL; -} - -template<class T, int poolSize> -typename dList<T, poolSize>::dListNode* dList<T, poolSize>::GetFirst() const -{ - return m_first; -} - -template<class T, int poolSize> -typename dList<T, poolSize>::dListNode* dList<T, poolSize>::GetLast() const -{ - return m_last; -} - -template<class T, int poolSize> -typename dList<T, poolSize>::dListNode* dList<T, poolSize>::Append () -{ - m_count ++; - if (m_first == NULL) { - m_first = new (GetAllocator().Alloc()) dListNode(NULL, NULL); - m_last = m_first; - } else { - m_last = new (GetAllocator().Alloc()) dListNode(m_last, NULL); - } - dAssert (Sanity()); - return m_last; -} - -template<class T, int poolSize> -typename dList<T, poolSize>::dListNode* dList<T, poolSize>::AppendAfter (dListNode* const node) -{ - dListNode* const ptr = Append (); - InsertAfter (node, ptr); - return ptr; -} - -template<class T, int poolSize> -typename dList<T, poolSize>::dListNode* dList<T, poolSize>::Append (const T &element) -{ - m_count ++; - if (m_first == NULL) { - m_first = new (GetAllocator().Alloc()) dListNode(element, NULL, NULL); - m_last = m_first; - } else { - m_last = new (GetAllocator().Alloc()) dListNode(element, m_last, NULL); - } - dAssert (Sanity()); - return m_last; -} - -template<class T, int poolSize> -typename dList<T, poolSize>::dListNode* dList<T, poolSize>::Addtop () -{ - m_count ++; - if (m_last == NULL) { - m_last = new (GetAllocator().Alloc()) dListNode(NULL, NULL); - m_first = m_last; - } else { - m_first = new (GetAllocator().Alloc()) dListNode(NULL, m_first); - } - dAssert (Sanity()); - return m_first; -} - - -template<class T, int poolSize> -typename dList<T, poolSize>::dListNode* dList<T, poolSize>::Addtop (const T &element) -{ - m_count ++; - if (m_last == NULL) { - m_last = new (GetAllocator().Alloc()) dListNode(element, NULL, NULL); - m_first = m_last; - } else { - m_first = new (GetAllocator().Alloc()) dListNode(element, NULL, m_first); - } - dAssert (Sanity()); - return m_first; -} - -template<class T, int poolSize> -void dList<T, poolSize>::InsertAfter (dListNode* const root, dListNode* const node) -{ - dAssert (root != node); - if (node == m_last) { - m_last = m_last->GetPrev(); - } - node->Unlink(); - - node->m_prev = root; - node->m_next = root->m_next; - if (root->m_next) { - root->m_next->m_prev = node; - } - root->m_next = node; - - if (root == m_last) { - m_last = node; - } - - dAssert (Sanity()); -} - -template<class T, int poolSize> -void dList<T, poolSize>::RotateToEnd (dListNode* const node) -{ - if (node != m_last) { - if (m_last != m_first) { - if (node == m_first) { - m_first = m_first->GetNext(); - } - node->Unlink(); - m_last->AddLast(node); - m_last = node; - } - } -} - -template<class T, int poolSize> -void dList<T, poolSize>::RotateToBegin (dListNode* const node) -{ - if (node != m_first) { - if (m_last != m_first) { - if (node == m_last) { - m_last = m_last->GetPrev(); - } - node->Unlink(); - m_first->AddFirst(node); - m_first = node; - } - } -} - - -template<class T, int poolSize> -typename dList<T, poolSize>::dListNode* dList<T, poolSize>::Find (const T &element) const -{ - dListNode* node; - for (node = m_first; node; node = node->GetNext()) { - if (element == node->m_info) { - break; - } - } - return node; -} - - -template<class T, int poolSize> -typename dList<T, poolSize>::dListNode* dList<T, poolSize>::GetNodeFromInfo (T &info) const -{ - dListNode* const node = (dListNode*) &info; - long long offset = ((char*) &node->m_info) - ((char*)node); - dListNode* const retnode = (dListNode*) (((char *) node) - offset); - dAssert (&retnode->GetInfo () == &info); - return retnode; -} - - -template<class T, int poolSize> -void dList<T, poolSize>::Remove (const T &element) -{ - dListNode* const node = Find (element); - if (node) { - Remove (node); - } -} - -template<class T, int poolSize> -void dList<T, poolSize>::Remove (dListNode* const node) -{ - m_count --; - if (node == m_first) { - m_first = m_first->GetNext(); - } - if (node == m_last) { - m_last = m_last->GetPrev(); - } - node->Remove(); - GetAllocator().Free (node); - dAssert (Sanity()); -} - -template<class T, int poolSize> -void dList<T, poolSize>::RemoveAll () -{ - while (m_first) { - Remove(m_first); - } - dAssert (!m_count); -} - -template<class T, int poolSize> -void dList<T, poolSize>::TranferDataToTarget (dList& target) -{ - dAssert (target.m_count == 0); - target.m_count = m_count; - target.m_first = m_first; - target.m_last = m_last; - - m_count = 0; - m_first = NULL; - m_last = NULL; -} - -#endif - - diff --git a/thirdparty/src/newton/dContainers/dMap.h b/thirdparty/src/newton/dContainers/dMap.h deleted file mode 100644 index 4e4ef6f97..000000000 --- a/thirdparty/src/newton/dContainers/dMap.h +++ /dev/null @@ -1,1049 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - - -#ifndef __D_MAP__ -#define __D_MAP__ - -template<class OBJECT, class KEY> -class dMap -{ - public: - class dTreeNode - { - enum REDBLACK_COLOR - { - RED = true, - BLACK = false - }; - - dTreeNode (const KEY &key, dTreeNode* parentNode) - :m_info() - ,m_key(key) - ,m_left(nullptr) - ,m_right(nullptr) - ,m_parent(parentNode) - ,m_color(false) - ,m_inTree(false) - { - SetColor(RED); - SetInTreeFlag(true); - } - - dTreeNode (const OBJECT &info, const KEY &key, dTreeNode* parentNode) - :m_info(info) - ,m_key(key) - ,m_left(nullptr) - ,m_right(nullptr) - ,m_parent(parentNode) - ,m_color(false) - ,m_inTree(false) - { - SetColor(RED); - SetInTreeFlag(true); - } - - virtual ~dTreeNode () - { - } - - void SetInTreeFlag(bool flag) - { - m_inTree = flag; - } - - bool GetColor() const - { - return m_color; - } - - void SetColor(bool color) - { - m_color = color; - } - - dTreeNode& operator= (dTreeNode& src) - { - dAssert (0); - return* this; - } - - dTreeNode* GetLeft () const - { - return m_left; - } - - dTreeNode* GetRight () const - { - return m_right; - } - - dTreeNode* GetParent () - { - return m_parent; - } - - void SetLeft (dTreeNode* const node) - { - m_left = node; - } - - void SetRight (dTreeNode* const node) - { - m_right = node; - } - - void SetParent (dTreeNode* const node) - { - m_parent = node; - } - - public: - const KEY& GetKey() const - { - return m_key; - } - - OBJECT& GetInfo() - { - return m_info; - } - - dTreeNode* Minimum() const - { - dTreeNode* ptr = (dTreeNode*)this; - for (; ptr->m_left; ptr = ptr->m_left); - return ptr; - } - - dTreeNode* Next() const - { - if (m_right) { - return m_right->Minimum(); - } - - dTreeNode* node = (dTreeNode*)this; - dTreeNode* ptr = m_parent; - for (; ptr && node == ptr->m_right; ptr = ptr->m_parent) { - node = ptr; - } - return ptr; - } - - void Unlink(dTreeNode** const head) - { - dTreeNode* const node = this; - node->SetInTreeFlag(false); - - if (!node->m_left || !node->m_right) { - // y has a nullptr node as a child - dTreeNode* const endNode = node; - - // x is y's only child - dTreeNode* child = endNode->m_right; - if (endNode->m_left) { - child = endNode->m_left; - } - - // remove y from the parent chain - if (child) { - child->m_parent = endNode->m_parent; - } - - if (endNode->m_parent) { - if (endNode == endNode->m_parent->m_left) { - endNode->m_parent->m_left = child; - } else { - endNode->m_parent->m_right = child; - } - } else { - *head = child; - } - - if (endNode->GetColor() == BLACK) { - endNode->m_parent->RemoveFixup(child, head); - } - } else { - - // find tree successor with a nullptr node as a child - dTreeNode* endNode = node->m_right; - while (endNode->m_left != nullptr) { - endNode = endNode->m_left; - } - - // x is y's only child - dTreeNode* const child = endNode->m_right; - - endNode->m_left = node->m_left; - node->m_left->m_parent = endNode; - - dTreeNode* endNodeParent = endNode; - if (endNode != node->m_right) { - if (child) { - child->m_parent = endNode->m_parent; - } - endNode->m_parent->m_left = child; - endNode->m_right = node->m_right; - node->m_right->m_parent = endNode; - endNodeParent = endNode->m_parent; - } - - - if (node == *head) { - *head = endNode; - } else if (node == node->m_parent->m_left) { - node->m_parent->m_left = endNode; - } else { - node->m_parent->m_right = endNode; - } - endNode->m_parent = node->m_parent; - - bool oldColor = endNode->GetColor(); - endNode->SetColor(node->GetColor()); - node->SetColor(oldColor); - - if (oldColor == BLACK) { - endNodeParent->RemoveFixup(child, head); - } - } - } - - void RotateLeft(dTreeNode** const head) - { - dTreeNode* const me = this; - dTreeNode* const child = me->m_right; - - //dAssert(child); - me->m_right = child->m_left; - if (child->m_left != nullptr) { - child->m_left->m_parent = me; - } - - if (child != nullptr) { - child->m_parent = me->m_parent; - } - if (me->m_parent) { - if (me == me->m_parent->m_left) { - me->m_parent->m_left = child; - } else { - me->m_parent->m_right = child; - } - } else { - *head = child; - } - - // link child and me - child->m_left = me; - if (me != nullptr) { - me->m_parent = child; - } - } - - // rotate node me to right * - void RotateRight(dTreeNode** const head) - { - dTreeNode* const me = this; - dTreeNode* const child = me->m_left; - - //dAssert(child); - me->m_left = child->m_right; - if (child->m_right != nullptr) { - child->m_right->m_parent = me; - } - - // establish child->m_parent link - if (child != nullptr) { - child->m_parent = me->m_parent; - } - if (me->m_parent) { - if (me == me->m_parent->m_right) { - me->m_parent->m_right = child; - } else { - me->m_parent->m_left = child; - } - } else { - *head = child; - } - - // link me and child - child->m_right = me; - if (me != nullptr) { - me->m_parent = child; - } - } - - void RemoveFixup(dTreeNode* const me, dTreeNode** const head) - { - dTreeNode* ptr = this; - dTreeNode* node = me; - while ((node != *head) && (!node || node->GetColor() == BLACK)) { - if (node == ptr->m_left) { - if (!ptr) { - return; - } - dTreeNode* tmp = ptr->m_right; - if (!tmp) { - return; - } - if (tmp->GetColor() == RED) { - tmp->SetColor(BLACK); - ptr->SetColor(RED); - ptr->RotateLeft(head); - tmp = ptr->m_right; - if (!tmp) { - return; - } - } - if ((!tmp->m_left || (tmp->m_left->GetColor() == BLACK)) && - (!tmp->m_right || (tmp->m_right->GetColor() == BLACK))) { - tmp->SetColor(RED); - node = ptr; - ptr = ptr->m_parent; - continue; - } else if (!tmp->m_right || (tmp->m_right->GetColor() == BLACK)) { - tmp->m_left->SetColor(BLACK); - tmp->SetColor(RED); - tmp->RotateRight(head); - tmp = ptr->m_right; - //if (!ptr || !tmp) { - if (!tmp) { - return; - } - } - tmp->SetColor(ptr->GetColor()); - if (tmp->m_right) { - tmp->m_right->SetColor(BLACK); - } - if (ptr) { - ptr->SetColor(BLACK); - ptr->RotateLeft(head); - } - node = *head; - - } else { - if (!ptr) { - return; - } - dTreeNode* tmp = ptr->m_left; - if (!tmp) { - return; - } - if (tmp->GetColor() == RED) { - tmp->SetColor(BLACK); - ptr->SetColor(RED); - ptr->RotateRight(head); - tmp = ptr->m_left; - if (!tmp) { - return; - } - } - - if ((!tmp->m_right || (tmp->m_right->GetColor() == BLACK)) && - (!tmp->m_left || (tmp->m_left->GetColor() == BLACK))) { - tmp->SetColor(RED); - node = ptr; - ptr = ptr->m_parent; - continue; - } else if (!tmp->m_left || (tmp->m_left->GetColor() == BLACK)) { - tmp->m_right->SetColor(BLACK); - tmp->SetColor(RED); - tmp->RotateLeft(head); - tmp = ptr->m_left; - //if (!ptr || !tmp) { - if (!tmp) { - return; - } - } - tmp->SetColor(ptr->GetColor()); - if (tmp->m_left) { - tmp->m_left->SetColor(BLACK); - } - if (ptr) { - ptr->SetColor(BLACK); - ptr->RotateRight(head); - } - node = *head; - } - } - if (node) { - node->SetColor(BLACK); - } - } - - void InsertFixup(dTreeNode** const head) - { - dTreeNode* ptr = this; - // check Red-Black properties - //dAssert((ptr == *head) || ptr->m_parent); - while ((ptr != *head) && (ptr->m_parent->GetColor() == RED)) { - // we have a violation - //dAssert(ptr->m_parent); - //dAssert(ptr->m_parent->m_parent); - if (ptr->m_parent == ptr->m_parent->m_parent->m_left) { - dTreeNode* const tmp = ptr->m_parent->m_parent->m_right; - if (tmp && (tmp->GetColor() == RED)) { - // uncle is RED - ptr->m_parent->SetColor(BLACK); - tmp->SetColor(BLACK); - ptr->m_parent->m_parent->SetColor(RED); - ptr = ptr->m_parent->m_parent; - } else { - // uncle is BLACK - if (ptr == ptr->m_parent->m_right) { - // make ptr a left child - ptr = ptr->m_parent; - ptr->RotateLeft(head); - } - - ptr->m_parent->SetColor(BLACK); - if (ptr->m_parent->m_parent) { - ptr->m_parent->m_parent->SetColor(RED); - ptr->m_parent->m_parent->RotateRight(head); - } - } - } else { - //dAssert (ptr->m_parent == ptr->m_parent->m_parent->m_right); - // mirror image of above code - dTreeNode* const tmp = ptr->m_parent->m_parent->m_left; - if (tmp && (tmp->GetColor() == RED)) { - //uncle is RED - ptr->m_parent->SetColor(BLACK); - tmp->SetColor(BLACK); - ptr->m_parent->m_parent->SetColor(RED); - ptr = ptr->m_parent->m_parent; - } else { - // uncle is BLACK - if (ptr == ptr->m_parent->m_left) { - ptr = ptr->m_parent; - ptr->RotateRight(head); - } - ptr->m_parent->SetColor(BLACK); - if (ptr->m_parent->m_parent->GetColor() == BLACK) { - ptr->m_parent->m_parent->SetColor(RED); - ptr->m_parent->m_parent->RotateLeft(head); - } - } - } - } - (*head)->SetColor(BLACK); - } - - - private: - OBJECT m_info; - KEY m_key; - dTreeNode* m_left; - dTreeNode* m_right; - dTreeNode* m_parent; - bool m_color; - bool m_inTree; - friend class dMap<OBJECT, KEY>; - }; - - class Iterator - { - public: - Iterator(const dMap<OBJECT,KEY> &me) - { - m_ptr = nullptr; - m_tree = &me; - } - - ~Iterator() - { - } - - void Begin() - { - m_ptr = m_tree->Minimum(); - } - - void End() - { - m_ptr = m_tree->Maximum(); - } - - void Set (dTreeNode* const node) - { - m_ptr = node; - } - - operator int() const - { - return m_ptr != nullptr; - } - - void operator++ () - { - //dAssert (m_ptr); - m_ptr = m_ptr->Next(); - } - - void operator++ (int) - { - //dAssert (m_ptr); - m_ptr = m_ptr->Next(); - } - - void operator-- () - { - //dAssert (m_ptr); - m_ptr = m_ptr->Prev(); - } - - void operator-- (int) - { - //dAssert (m_ptr); - m_ptr = m_ptr->Prev(); - } - - OBJECT &operator* () const - { - return ((dTreeNode*)m_ptr)->GetInfo(); - } - - dTreeNode* GetNode() const - { - return (dTreeNode*)m_ptr; - } - - KEY GetKey () const - { - dTreeNode* const tmp = (dTreeNode*)m_ptr; - return tmp ? tmp->GetKey() : KEY(0); - } - - private: - dTreeNode* m_ptr; - const dMap* m_tree; - }; - - - // *********************************************************** - // member functions - // *********************************************************** - public: - dMap (); - virtual ~dMap (); - - operator int() const; - int GetCount() const; - - dTreeNode* GetRoot () const; - dTreeNode* Minimum () const; - dTreeNode* Maximum () const; - - dTreeNode* Find (KEY key) const; - dTreeNode* FindGreater (KEY key) const; - dTreeNode* FindGreaterEqual (KEY key) const; - dTreeNode* FindLessEqual (KEY key) const; - - dTreeNode* GetNodeFromInfo (OBJECT &info) const; - - dTreeNode* Insert (KEY key); - dTreeNode* Insert (const OBJECT &element, KEY key); - dTreeNode* Insert (const OBJECT &element, KEY key, bool& elementWasInTree); - dTreeNode* Insert (dTreeNode* const node, KEY key); - - dTreeNode* Replace (OBJECT &element, KEY key); - dTreeNode* ReplaceKey (KEY oldKey, KEY newKey); - dTreeNode* ReplaceKey (dTreeNode* const node, KEY key); - - void Unlink (dTreeNode* const node); - - void Remove (KEY key); - void Remove (dTreeNode* const node); - void RemoveAll (); - - bool SanityCheck () const; - - - // *********************************************************** - // member variables - // *********************************************************** - private: - void RemoveAllLow (dTreeNode* const root); - int CompareKeys (const KEY &key0, const KEY &key1) const; - bool SanityCheck (dTreeNode* const ptr, int height) const; - - int m_count; - dTreeNode* m_head; - friend class dTreeNode; -}; - -template<class OBJECT, class KEY> -dMap<OBJECT, KEY>::dMap () -{ - m_count = 0; - m_head = nullptr; -} - -template<class OBJECT, class KEY> -dMap<OBJECT, KEY>::~dMap () -{ - RemoveAll(); -} - - -template<class OBJECT, class KEY> -dMap<OBJECT, KEY>::operator int() const -{ - return m_head != nullptr; -} - -template<class OBJECT, class KEY> -int dMap<OBJECT, KEY>::GetCount() const -{ - return m_count; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::Minimum () const -{ - return m_head ? (dTreeNode*) m_head->Minimum() : nullptr; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::Maximum () const -{ - return m_head ? (dTreeNode*) m_head->Maximum() : nullptr; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::GetRoot () const -{ - return m_head; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::Find (KEY key) const -{ - if (m_head == nullptr) { - return nullptr; - } - - dTreeNode* ptr = m_head; - while (ptr != nullptr) { - int val = CompareKeys (ptr->m_key, key); - if (!val) { - break; - } - if (val < 0) { - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - return ptr; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::GetNodeFromInfo (OBJECT &info) const -{ - dTreeNode* node = (dTreeNode*) &info; - int offset = ((char*) &node->m_info) - ((char *) node); - node = (dTreeNode*) (((char *) node) - offset); - -// dAssert (node->IsInTree ()); - dAssert (&node->GetInfo () == &info); - return (node->IsInTree ()) ? node : nullptr; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::FindGreater (KEY key) const -{ - if (m_head == nullptr) { - return nullptr; - } - - dTreeNode* prev = nullptr; - dTreeNode* ptr = m_head; - int val = 0; - while (ptr != nullptr) { - val = CompareKeys (ptr->m_key, key); - if (!val) { - return (dTreeNode*) ptr->Next(); - } - prev = ptr; - if (val < 0) { - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - - if (val > 0) { - while (prev->m_parent && (prev->m_parent->m_right == prev)) { - prev = prev->GetParent(); - } - prev = prev->GetParent(); - } - return (dTreeNode*) prev; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::FindGreaterEqual (KEY key) const -{ - if (m_head == nullptr) { - return nullptr; - } - - dTreeNode* prev = nullptr; - dTreeNode* ptr = m_head; - int val = 0; - while (ptr != nullptr) { - val = CompareKeys (ptr->m_key, key); - if (!val) { - return ptr; - } - prev = ptr; - if (val < 0) { - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - - if (val > 0) { - while (prev->m_parent && (prev->m_parent->m_right == prev)) { - prev = prev->GetParent(); - } - prev = prev->GetParent(); - } - return (dTreeNode*) prev; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::FindLessEqual (KEY key) const -{ - if (m_head == nullptr) { - return nullptr; - } - - dTreeNode* prev = nullptr; - dTreeNode* ptr = m_head; - int val = 0; - while (ptr != nullptr) { - val = CompareKeys (ptr->m_key, key); - if (!val) { - return ptr; - } - prev = ptr; - if (val < 0) { - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - - if (val < 0) { - while (prev->m_parent && (prev->m_parent->m_left == prev)) { - prev = prev->GetParent(); - } - prev = prev->GetParent(); - } - return (dTreeNode*) prev; -} - - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::Insert (KEY key) -{ - dTreeNode* parent = nullptr; - dTreeNode* ptr = m_head; - int val = 0; - while (ptr != nullptr) { - parent = ptr; - val = CompareKeys (ptr->m_key, key); - - if (val < 0) { - ptr = ptr->GetLeft(); - } else if (val > 0) { - ptr = ptr->GetRight(); - } else { - return ptr; - } - } - m_count ++; - - ptr = new dTreeNode (key, parent); - if (!parent) { - m_head = ptr; - } else { - if (val < 0) { - parent->m_left = ptr; - } else { - parent->m_right = ptr; - } - } - ptr->InsertFixup ((dTreeNode**)&m_head); - return ptr; -} - - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::Insert (const OBJECT &element, KEY key, bool& elementWasInTree) -{ - dTreeNode* parent = nullptr; - dTreeNode* ptr = m_head; - int val = 0; - elementWasInTree = false; - while (ptr != nullptr) { - parent = ptr; - val = CompareKeys (ptr->m_key, key); - - if (val < 0) { - ptr = ptr->GetLeft(); - } else if (val > 0) { - ptr = ptr->GetRight(); - } else { - elementWasInTree = true; - return ptr; - } - } - m_count ++; - - ptr = new dTreeNode (element, key, parent); - if (!parent) { - m_head = ptr; - } else { - if (val < 0) { - parent->m_left = ptr; - } else { - parent->m_right = ptr; - } - } - ptr->InsertFixup ((dTreeNode**)&m_head); - return ptr; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::Insert (const OBJECT &element, KEY key) -{ - bool foundState; - dTreeNode* node = Insert (element, key, foundState); - if (foundState) { - node = nullptr; - } - return node; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::Insert (typename dMap<OBJECT, KEY>::dTreeNode* const node, KEY key) -{ - int val = 0; - dTreeNode* ptr = m_head; - dTreeNode* parent = nullptr; - while (ptr != nullptr) { - parent = ptr; - val = CompareKeys (ptr->m_key, key); - - if (val < 0) { - ptr = ptr->GetLeft(); - } else if (val > 0) { - ptr = ptr->GetRight(); - } else { - return nullptr; - } - } - - m_count ++; - - ptr = node; - ptr->m_key = key; - ptr->Initdata (parent); - - if (!parent) { - m_head = ptr; - } else { - if (val < 0) { - parent->m_left = ptr; - } else { - parent->m_right = ptr; - } - } - ptr->InsertFixup ((dTreeNode**)&m_head); - return ptr; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::Replace (OBJECT &element, KEY key) -{ - dTreeNode* parent = nullptr; - dTreeNode* ptr = m_head; - int val = 0; - while (ptr != nullptr) { - parent = ptr; - val = CompareKeys (ptr->m_key, key); - if (val == 0) { - ptr->m_info = element; - return ptr; - } - if (val < 0) { - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - - ptr = new dTreeNode (element, key, parent); - if (!parent) { - m_head = ptr; - } else { - if (val < 0) { - parent->m_left = ptr; - } else { - parent->m_right = ptr; - } - } - ptr->InsertFixup ((dTreeNode**)&m_head); - return ptr; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::ReplaceKey (typename dMap<OBJECT, KEY>::dTreeNode* node, KEY key) -{ - Unlink(node); - dTreeNode* const ptr = Insert (node, key); - - dAssert (ptr); - return ptr; -} - -template<class OBJECT, class KEY> -typename dMap<OBJECT, KEY>::dTreeNode* dMap<OBJECT, KEY>::ReplaceKey (KEY oldKey, KEY newKey) -{ - dTreeNode* const node = Find (oldKey); - return node ? ReplaceKey (node, newKey) : nullptr; -} - -template<class OBJECT, class KEY> -void dMap<OBJECT, KEY>::Unlink (typename dMap<OBJECT, KEY>::dTreeNode* const node) -{ - m_count --; - node->Unlink((dTreeNode** )&m_head); -} - -template<class OBJECT, class KEY> -void dMap<OBJECT, KEY>::Remove (typename dMap<OBJECT, KEY>::dTreeNode* const node) -{ - m_count --; - node->Unlink ((dTreeNode** )&m_head); - delete node; -} - -template<class OBJECT, class KEY> -void dMap<OBJECT, KEY>::Remove (KEY key) -{ - // find node in tree - dTreeNode* const node = Find (key); - if (node) { - Remove (node); - } -} - - -template<class OBJECT, class KEY> -void dMap<OBJECT, KEY>::RemoveAllLow (dTreeNode* const root) -{ - if (root->m_left) { - RemoveAllLow((dTreeNode*)root->m_left); - } - if (root->m_right) { - RemoveAllLow ((dTreeNode*)root->m_right); - } - root->SetInTreeFlag(false); - delete root; -} - - -template<class OBJECT, class KEY> -void dMap<OBJECT, KEY>::RemoveAll () -{ - if (m_head) { - m_count = 0; - dTreeNode* root; - for (root = m_head; root->m_parent; root = (dTreeNode*)root->m_parent); - RemoveAllLow(root); - m_head = nullptr; - } -} - -template<class OBJECT, class KEY> -bool dMap<OBJECT, KEY>::SanityCheck () const -{ - return SanityCheck (m_head, 0); -} - - -template<class OBJECT, class KEY> -bool dMap<OBJECT, KEY>::SanityCheck (typename dMap<OBJECT, KEY>::dTreeNode* ptr, int height) const -{ - if (!ptr) { - return true; - } - - if (ptr->m_left) { - if (CompareKeys (ptr->m_key, ptr->GetLeft()->m_key) > 0) { - return false; - } - } - - if (ptr->m_right) { - if (CompareKeys (ptr->m_key, ptr->GetRight()->m_key) < 0) { - return false; - } - } - - if (ptr->GetColor() == dTreeNode::BLACK) { - height ++; - } else if (!((!ptr->m_left || (ptr->m_left->GetColor() == dTreeNode::BLACK)) && - (!ptr->m_right || (ptr->m_right->GetColor() == dTreeNode::BLACK)))) { - return false; - } - - if (!ptr->m_left && !ptr->m_right) { - int bh = 0; - for (dTreeNode* x = ptr; x; x = x->GetParent()) { - if (x->GetColor() == dTreeNode::BLACK) { - bh ++; - } - } - if (bh != height) { - return false; - } - } - - if (ptr->m_left && !SanityCheck (ptr->GetLeft(), height)) { - return false; - } - - if (ptr->m_right && !SanityCheck (ptr->GetRight(), height)) { - return false; - } - return true; -} - -template<class OBJECT, class KEY> -int dMap<OBJECT, KEY>::CompareKeys (const KEY &key0, const KEY &key1) const -{ - if (key1 < key0) { - return - 1; - } - if (key1 > key0) { - return 1; - } - return 0; -} - -#endif - - diff --git a/thirdparty/src/newton/dContainers/dPointer.h b/thirdparty/src/newton/dContainers/dPointer.h deleted file mode 100644 index d0ef2eb1d..000000000 --- a/thirdparty/src/newton/dContainers/dPointer.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - - -#ifndef __D_POINTER_H__ -#define __D_POINTER_H__ - - -template <typename T> -class dPointer -{ - public: - dPointer(); - dPointer(T* const data); - ~dPointer(); - T& operator* (); - T* operator-> (); - - T* GetData() const; - void SetData(T* const data); - - private: - T* m_data; -}; - -template<class T> -dPointer<T>::dPointer() - :m_data(NULL) -{ -} - - -template<class T> -dPointer<T>::dPointer(T* const data) - :m_data(data) -{ -} - -template<class T> -dPointer<T>::~dPointer() -{ - if (m_data) { - delete m_data; - } -} - -template<class T> -T& dPointer<T>::operator* () -{ - return *m_data; -} - -template<class T> -T* dPointer<T>::operator-> () -{ - return m_data; -} - -template<class T> -T* dPointer<T>::GetData() const -{ - return m_data; -} - -template<class T> -void dPointer<T>::SetData(T* const data) -{ - m_data = data; -} - -#endif \ No newline at end of file diff --git a/thirdparty/src/newton/dContainers/dRefCounter.cpp b/thirdparty/src/newton/dContainers/dRefCounter.cpp deleted file mode 100644 index 13977dcff..000000000 --- a/thirdparty/src/newton/dContainers/dRefCounter.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dContainersStdAfx.h" -#include "dRefCounter.h" - -dRefCounter::dRefCounter(void) - :dContainersAlloc() -{ - m_refCount = 1; -} - -dRefCounter::~dRefCounter(void) -{ -} - - -int dRefCounter::GetRef() const -{ - return m_refCount; -} - -int dRefCounter::Release() -{ - m_refCount --; - dAssert (m_refCount >= 0); - if (!m_refCount) { - delete this; - return 0; - } - return m_refCount; -} - -void dRefCounter::AddRef() const -{ - m_refCount ++; -} - diff --git a/thirdparty/src/newton/dContainers/dRefCounter.h b/thirdparty/src/newton/dContainers/dRefCounter.h deleted file mode 100644 index a78270d2b..000000000 --- a/thirdparty/src/newton/dContainers/dRefCounter.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - - -#ifndef __DREF_COUNTER_H__ -#define __DREF_COUNTER_H__ - -#include "dContainersAlloc.h" - - -class dRefCounter: public dContainersAlloc -{ - public: - DCONTAINERS_API dRefCounter(void); - DCONTAINERS_API int GetRef() const; - DCONTAINERS_API int Release(); - DCONTAINERS_API void AddRef() const; - - protected: - DCONTAINERS_API virtual ~dRefCounter(void); - - private: - mutable int m_refCount; -}; - -#endif \ No newline at end of file diff --git a/thirdparty/src/newton/dContainers/dRtti.h b/thirdparty/src/newton/dContainers/dRtti.h deleted file mode 100644 index c3949bf5d..000000000 --- a/thirdparty/src/newton/dContainers/dRtti.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#ifndef __DRTTI_H__ -#define __DRTTI_H__ - -#include "dCRC.h" -#include "dContainersAlloc.h" - -#define dRttiCommon(className,exportType) \ - private: \ - exportType static dCRCTYPE m_rtti; \ - public: \ - static dCRCTYPE GetRttiType() \ - { \ - return m_rtti; \ - } \ - virtual dCRCTYPE GetTypeId () const \ - { \ - return m_rtti; \ - } \ - - - -// add these macros only to the root base class that you want to have rtti -#define dRttiRootClassSupportDeclare(className,exportType) \ - dRttiCommon(className,exportType) \ - virtual bool IsType (dCRCTYPE typeId) const \ - { \ - return typeId == m_rtti; \ - } - -#define dRttiRootClassSupportImplement(className) \ - dCRCTYPE className::m_rtti = dCRC64 (#className); - - - -// add these macros to every derived class -#define dAddRtti(baseClass,exportType) \ - dRttiCommon(baseClass,exportType) \ - virtual bool IsType (dCRCTYPE typeId) const \ - { \ - if (typeId == m_rtti) { \ - return true; \ - } \ - return baseClass::IsType (typeId); \ - } - - -#define dInitRtti(className) \ - dRttiRootClassSupportImplement(className) - - -#endif diff --git a/thirdparty/src/newton/dContainers/dString.cpp b/thirdparty/src/newton/dContainers/dString.cpp deleted file mode 100644 index fc96de4a8..000000000 --- a/thirdparty/src/newton/dContainers/dString.cpp +++ /dev/null @@ -1,571 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dContainersStdAfx.h" -#include "dString.h" - - -#define D_USE_POOL_BUKECT_ALLOCATOR -#define D_STRING_MEM_GRANULARITY 16 -#define D_STRING_MEM_MAX_BUCKET_SIZE 256 -#define D_STRING_MEM_BUCKETS (D_STRING_MEM_MAX_BUCKET_SIZE / D_STRING_MEM_GRANULARITY) -#define D_DSTRING_ENTRIES_IN_FREELIST 32 - - - - -class dString::dStringAllocator -{ - public: - #ifdef D_USE_POOL_BUKECT_ALLOCATOR - class dMemBucket - { - public: - - class dDataChunk - { - public: - int m_size; - int m_count; - dDataChunk* m_next; - - }; - - dMemBucket() - :m_freeListDataChunk(NULL) - { - } - ~dMemBucket() - { - } - - void Prefetch (int chunckSize) - { - for (int i = 0; i < D_DSTRING_ENTRIES_IN_FREELIST; i ++) { - //dDataChunk* const data = (dDataChunk*) new char[chunckSize + sizeof (int)]; - dDataChunk* const data = (dDataChunk*) dContainersAlloc::Alloc (chunckSize + sizeof (int)); - data->m_count = i + 1; - data->m_size = chunckSize; - data->m_next = m_freeListDataChunk; - m_freeListDataChunk = data; - } - } - - void Flush () - { - for (int i = 0; m_freeListDataChunk && (i < D_DSTRING_ENTRIES_IN_FREELIST); i ++) { - dDataChunk* const ptr = m_freeListDataChunk; - m_freeListDataChunk = m_freeListDataChunk->m_next; - //delete[] (char*) ptr; - dContainersAlloc::Free (ptr); - } - } - - char* Alloc(int size) - { - dAssert (size < 1024 * 4); - if (!m_freeListDataChunk) { - Prefetch (size); - } - dDataChunk* const data = m_freeListDataChunk; - dAssert (size == data->m_size); - m_freeListDataChunk = m_freeListDataChunk->m_next; - return ((char*)data) + sizeof (int); - } - - void Free(char * const ptr) - { - char* const realPtr = ptr - sizeof (int); - dMemBucket::dDataChunk* const dataChunck = (dMemBucket::dDataChunk*) (realPtr); - - dataChunck->m_count = m_freeListDataChunk ? m_freeListDataChunk->m_count + 1 : 1; - dataChunck->m_next = m_freeListDataChunk; - m_freeListDataChunk = dataChunck; - if (dataChunck->m_count >= 2 * D_DSTRING_ENTRIES_IN_FREELIST) { - Flush(); - } - } - - dDataChunk* m_freeListDataChunk; - }; - - - dStringAllocator() - { - for (int i = 0; i < int (sizeof (m_buckects) / sizeof (m_buckects[0])); i ++) { - m_buckects[i].Prefetch ((i + 1)* D_STRING_MEM_GRANULARITY); - } - } - ~dStringAllocator() - { - for (int i = 0; i < int (sizeof (m_buckects) / sizeof (m_buckects[0])); i ++) { - m_buckects[i].Flush(); - } - } - - char* Alloc(int size) - { - dAssert (size >= 1); - if (size <= D_STRING_MEM_MAX_BUCKET_SIZE) { - int buckectEntry = (size - 1) / D_STRING_MEM_GRANULARITY; - int buckectSize = (buckectEntry + 1) * D_STRING_MEM_GRANULARITY; - return m_buckects[buckectEntry].Alloc(buckectSize); - } - dMemBucket::dDataChunk* const ptr = (dMemBucket::dDataChunk*) dContainersAlloc::Alloc (size + sizeof (int)); - ptr->m_size = size; - return ((char*)ptr) + sizeof (int); - } - - void Free(char* const ptr) - { - char* const realPtr = ptr-sizeof (int); - dMemBucket::dDataChunk* const dataChunck = (dMemBucket::dDataChunk*) (realPtr); - if (dataChunck->m_size <= D_STRING_MEM_MAX_BUCKET_SIZE) { - int buckectEntry = dataChunck->m_size / D_STRING_MEM_GRANULARITY - 1; - m_buckects[buckectEntry].Free(ptr); - } else { - void* const ptr1 = ((char*)ptr) - sizeof (int); - dContainersAlloc::Free (ptr1); - } - } - - dMemBucket m_buckects [D_STRING_MEM_BUCKETS]; - - #else - char* Alloc(int size) - { - //return new char[size]; - return (char*) dContainersAlloc::Alloc (size); - } - - void Free(char* const ptr) - { - //delete[] ptr; - dContainersAlloc::Free (ptr); - } - #endif -}; - -//dString::dStringAllocator dString::m_allocator; - -dString::dString () - :m_string(NULL) - ,m_size(0) - ,m_capacity(0) -{ -} - -dString::dString (const dString& src) - :m_string(NULL) - ,m_size(0) - ,m_capacity(0) -{ - if (src.m_string) { - m_size = src.m_size; - m_capacity = m_size + 1; - - m_string = AllocMem (src.m_size + 1); - CopyData (m_string, src.m_string, src.m_size + 1); - m_string[m_size] = 0; - } -} - -dString::dString (const char* const data) - :m_string(NULL) - ,m_size(0) - ,m_capacity(0) -{ - if (data) { - m_size = CalculateSize (data); - m_capacity = m_size + 1; - - m_string = AllocMem (m_size + 1); - CopyData (m_string, data, m_size + 1); - m_string[m_size] = 0; - } -} - -dString::dString (const char* const data, int maxSize) - :m_string(NULL) - ,m_size(0) - ,m_capacity(0) -{ - if (data) { - m_size = dMin (CalculateSize (data), maxSize); - m_capacity = m_size + 1; - m_string = AllocMem (m_size + 1); - CopyData (m_string, data, m_size + 1); - m_string[m_size] = 0; - } -} - -dString::dString (const dString& src, const char* const concatenate, int concatenateSize) - :m_string(NULL) - ,m_size(0) - ,m_capacity(0) -{ - m_string = AllocMem (src.m_size + concatenateSize + 1); - memcpy (m_string, src.m_string, src.m_size); - memcpy (&m_string[src.m_size], concatenate, concatenateSize); - m_size = src.m_size + concatenateSize; - m_string[m_size] = 0; - m_capacity = m_size + 1; -} - - - -dString::dString (char chr) - :m_string(NULL) - ,m_size(0) - ,m_capacity(0) -{ - m_string = AllocMem (2); - m_string[0] = chr; - m_string[1] = 0; - m_size = 1; - m_capacity = m_size + 1; -} - -dString::dString (int val) - :m_string(NULL) - ,m_size(0) - ,m_capacity(0) -{ - char tmp[256]; - - int count = 0; - unsigned mag = abs (val); - do { - unsigned digit = mag % 10; - mag /= 10; - tmp[count] = '0' + char(digit); - count ++; - } while (mag > 0); - - int offset = (val >= 0) ? 0: 1; - m_string = AllocMem (count + offset + 1); - if (offset) { - m_string[0] = '-'; - } - for (int i = 0; i < count; i ++) { - m_string[i + offset] = tmp[count - i - 1]; - } - - m_string[count + offset] = 0; - m_size = count + offset; - m_capacity = m_size + 1; -} - -dString::dString (long long val) - :m_string(NULL) - ,m_size(0) - ,m_capacity(0) -{ - char tmp[256]; - - int count = 0; - unsigned long long mag = (val > 0ll) ? val : -val; - do { - unsigned long long digit = mag % 10ll; - mag /= 10ll; - tmp[count] = '0' + char(digit); - count ++; - } while (mag > 0); - - int offset = (val >= 0ll) ? 0: 1; - m_string = AllocMem (count + offset + 1); - if (offset) { - m_string[0] = '-'; - } - for (int i = 0; i < count; i ++) { - m_string[i + offset] = tmp[count - i - 1]; - } - - m_string[count + offset] = 0; - m_size = count + offset; - m_capacity = m_size + 1; -} - - -dString::~dString () -{ - Empty(); -} - -void dString::Empty() -{ - if (m_capacity && m_string) { - FreeMem (m_string); - } - m_size = 0; - m_capacity = 0; - m_string = NULL; -} - -void dString::LoadFile (FILE* const file) -{ - Empty(); -// fseek (file, 0, SEEK_END); -// int size = ftell (file); - int size = 0; - fseek (file, 0, SEEK_SET); - for (;!feof(file); size ++) { - fgetc (file); - } - fseek (file, 0, SEEK_SET); - Expand (size); - size_t ret = fread (m_string, 1, size, file); - ret = 0; - m_string[size-1] = 0; - m_size = size-1; - m_capacity = m_size + 1; -} - - - -void dString::operator+= (const char* const src) -{ - char* const oldData = m_string; - int size = CalculateSize (src); - m_string = AllocMem (m_size + size + 1); - memcpy (m_string, oldData, m_size); - memcpy (&m_string[m_size], src, size); - m_size = m_size + size; - m_string[m_size] = 0; - m_capacity = m_size + 1; - FreeMem(oldData); -} - - -int dString::ToInteger() const -{ - int value = 0; - if (m_size) { - int base = (m_string[0] == '-') ? 1 : 0; - for (int i = base; i < m_size; i ++) { - char ch = m_string[i]; - if ((ch >= '0') && (ch <= '9')) { - value = value * 10 + ch - '0'; - } else { - break; - } - } - value *= base ? -1 : 1; - } - return value; -} - - -long long dString::ToInteger64() const -{ - long long value = 0; - if (m_size) { - int base = (m_string[0] == '-') ? 1 : 0; - for (int i = base; i < m_size; i ++) { - char ch = m_string[i]; - if ((ch >= '0') && (ch <= '9')) { - value = value * 10ll + ch - '0'; - } else { - break; - } - } - value *= base ? -1 : 1; - } - return value; -} - - -double dString::ToFloat() const -{ - double value = 0.0; - double power = 1.0; - double decimalBase = 1.0; - if (m_size) { - int base = (m_string[0] == '-') ? 1 : 0; - for (int i = base; i < m_size; i ++) { - char ch = m_string[i]; - if ((ch >= '0') && (ch <= '9')) { - value = value * 10ll + ch - '0'; - power *= decimalBase; - } else if (ch == '.') { - decimalBase = 10.0; - } else { - break; - } - } - value *= base ? -1 : 1; - } - value /= power; - - return value; -} - -dString& dString::operator= (const dString& src) -{ - if (m_capacity && m_string) { - FreeMem (m_string); - } - m_string = NULL; - m_capacity = 0; - m_size = src.m_size; - if (src.m_string) { - m_capacity = src.m_size + 1; - m_string = AllocMem (src.m_size + 1); - CopyData (m_string, src.m_string, src.m_size + 1); - } - return *this; -} - -int dString::CalculateSize (const char* const data) const -{ - int size = 0; - if (data) { - for (int i = 0; data[i]; i ++) { - size ++; - } - } - return size; -} - -void dString::ToUpper() -{ - if (m_string) { - for (char * cp = m_string; *cp; ++cp) { - if ((*cp >= 'a') && (*cp <= 'z') ) - *cp += 'A' - 'a'; - } - } -} - -void dString::ToLower() -{ - if (m_string) { - for (char * cp = m_string; *cp; ++cp) { - if ((*cp >= 'A') && (*cp <= 'Z') ) - *cp += 'a' - 'A'; - } - } -} - -int dString::Find (char ch, int from) const -{ - for (int i = from; i < m_size; i ++) { - if (m_string[i] == ch) { - return i; - } - } - return -1; -} - -//int dString::Find (const dString& subStream, int from) const -int dString::Find (const char* const subString, int subStringLength, int from, int lenght) const -{ - dAssert (from >= 0); - //dAssert (subStream.m_size >= 0); - dAssert (subStringLength >= 1); - - int location = -1; - if (m_size) { - const int str2Size = dMin (subStringLength, lenght); - if (str2Size == 1) { - char ch = subString[0]; - const char* const ptr1 = m_string; - for (int i = 0; i < m_size; i ++) { - if (ch == ptr1[i]) { - return i; - } - } - } else if ((str2Size < 4) || (m_size < 64)) { - const int size = m_size - str2Size; - for (int j = from; j <= size; j ++) { - const char* const ptr1 = &m_string[j]; - int i = 0; - while (subString[i] && (ptr1[i] == subString[i])) { - i ++; - } - if (!subString[i]) { - return j; - } - } - } else { - // for large strings smart search - short frequency[256]; - memset (frequency, -1, sizeof (frequency)); - for (int i = 0; i < str2Size; i ++) { - frequency[int (subString[i])] = short(i); - } - - int j = from; - const int size = m_size - str2Size; - while (j <= size) { - const char* const ptr1 = &m_string[j]; - int i = str2Size - 1; - while ((i >= 0) && (ptr1[i] == subString[i])) { - i --; - } - if (i < 0) { - return j; - - } - j += dMax(i - frequency[int (ptr1[i])], 1); - } - } - } - return location; -} - - -void dString::Replace (int start, int size, const char* const str, int strSize) -{ - char* const oldData = m_string; - m_string = AllocMem (m_size - size + strSize + 1); - memcpy (m_string, oldData, start); - memcpy (&m_string[start], str, strSize); - memcpy (&m_string[start + strSize], &oldData[start + size], m_size - (start + size)); - m_size = m_size - size + strSize; - m_capacity = m_size - size + strSize + 1; - m_string[m_size] = 0; - FreeMem(oldData); -} - - -void dString::Expand (int size) -{ - char* const oldData = m_string; - m_string = AllocMem (m_size + size + 1); - - if (m_capacity) { - memcpy (m_string, oldData, m_size); - FreeMem(oldData); - } - m_string[m_size] = 0; - m_capacity = m_size + size + 1; -} - - -dString::dStringAllocator& dString::GetAllocator() const -{ - static dStringAllocator allocator; - return allocator; -} - - -char* dString::AllocMem(int size) -{ - return GetAllocator().Alloc(size); -} - -void dString::FreeMem (char* const ptr) -{ - if (ptr) { - GetAllocator().Free(ptr); - } -} diff --git a/thirdparty/src/newton/dContainers/dString.h b/thirdparty/src/newton/dContainers/dString.h deleted file mode 100644 index 1a4e998c2..000000000 --- a/thirdparty/src/newton/dContainers/dString.h +++ /dev/null @@ -1,214 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - - -#ifndef __DSTRING_H_ -#define __DSTRING_H_ - -#include "dContainersStdAfx.h" -#include "dContainersAlloc.h" - - -class dString: public dContainersAlloc -{ - class dStringAllocator; - public: - DCONTAINERS_API dString (); - DCONTAINERS_API dString (char chr); - DCONTAINERS_API dString (const dString& src); - DCONTAINERS_API dString (const char* const data); - DCONTAINERS_API dString (const char* const data, int maxSize); - DCONTAINERS_API dString (int val); - DCONTAINERS_API dString (long long val); - DCONTAINERS_API ~dString (); - - char& operator[] (int index); - char operator[] (int index) const; - - DCONTAINERS_API dString& operator= (const dString& src); - bool operator== (const dString& src) const; - bool operator!= (const dString& src) const; - bool operator< (const dString& src) const; - bool operator> (const dString& src) const; - bool operator<= (const dString& src) const; - bool operator>= (const dString& src) const; - - DCONTAINERS_API void operator+= (const char* const src); - void operator+= (const dString& src); - - dString operator+ (const char* const src) const; - dString operator+ (const dString& src) const; - - DCONTAINERS_API int Find (char ch, int from = 0) const; - int Find (const dString& subString, int from = 0) const; - DCONTAINERS_API int Find (const char* const subString, int from = 0, int lenght = 0x7ffffff) const; - - DCONTAINERS_API void Replace (int start, int size, const char* const str, int strSize); - void Replace (int start, int size, const dString& str); - void Empty(); - - DCONTAINERS_API void ToUpper(); - DCONTAINERS_API void ToLower(); - DCONTAINERS_API int ToInteger() const; - DCONTAINERS_API double ToFloat() const; - DCONTAINERS_API long long ToInteger64() const; - - int Size() const; - int Capacity() const; - DCONTAINERS_API void Expand (int size); - - DCONTAINERS_API void LoadFile (FILE* const file); - dString SubString(int start = 0, int size = 0x7fffffff) const; - - const char* GetStr () const; - - private: - DCONTAINERS_API int CalculateSize (const char* const data) const; - int Compare (const char* const str0, const char* const str1) const; - void CopyData (char* const dst, const char* const src, int size) const; - - DCONTAINERS_API int Find (const char* const subString, int stringSize, int from, int lenght) const; - - - protected: - char* AllocMem(int size); - void FreeMem (char* const ptr); - DCONTAINERS_API dString (const dString& src, const char* const concatenate, int maxSize); - - char* m_string; - int m_size; - int m_capacity; - - private: - dStringAllocator& GetAllocator() const; -}; - - -inline char& dString::operator[] (int index) -{ - dAssert (m_string); - dAssert (index >= 0); - dAssert (index < m_size); - return m_string[index]; -} - -inline char dString::operator[] (int index) const -{ - dAssert (m_string); - dAssert (index >= 0); - dAssert (index < m_size); - return m_string[index]; -} - -inline const char* dString::GetStr () const -{ - return m_string; -} - -inline int dString::Size() const -{ - return m_size; -} - - -inline int dString::Find (const char* const subString, int from, int lenght) const -{ - return Find (subString, CalculateSize(subString), from, lenght); -} - -inline int dString::Find (const dString& subStream, int from) const -{ - dAssert (subStream.m_string); - return Find (subStream.m_string, subStream.m_size, from, subStream.m_size); -} - -inline void dString::Replace (int start, int size, const dString& str) -{ - Replace(start, size, str.m_string, str.m_size); -} - -inline void dString::operator+= (const dString& src) -{ - *this += src.m_string; -} - -inline dString dString::operator+ (const dString& src) const -{ - return dString (*this, src.m_string, src.m_size); -} - -inline dString dString::operator+ (const char* const copy) const -{ - return dString (*this, copy, CalculateSize (copy)); -} - - -inline int dString::Capacity() const -{ - return m_capacity; -} - -inline void dString::CopyData (char* const dst, const char* const src, int size) const -{ - dAssert (dst); - dAssert (src); - memcpy (dst, src, size); -} - -inline int dString::Compare (const char* const str0, const char* const str1) const -{ - dAssert (str0); - dAssert (str1); - return strcmp (str0, str1); -} - - -inline bool dString::operator== (const dString& src) const -{ - return Compare (m_string, src.m_string) == 0; -} - -inline bool dString::operator!= (const dString& src) const -{ - return Compare (m_string, src.m_string) != 0; -} - - -inline bool dString::operator< (const dString& src) const -{ - return Compare (m_string, src.m_string) < 0; -} - -inline bool dString::operator> (const dString& src) const -{ - return Compare (m_string, src.m_string) > 0; -} - -inline bool dString::operator<= (const dString& src) const -{ - return Compare (m_string, src.m_string) <= 0; -} - -inline bool dString::operator>= (const dString& src) const -{ - return Compare (m_string, src.m_string) >= 0; -} - -inline dString dString::SubString(int start, int size) const -{ - dAssert (m_string); - return dString (&m_string[start], size); -} - - -#endif - - diff --git a/thirdparty/src/newton/dContainers/dTree.cpp b/thirdparty/src/newton/dContainers/dTree.cpp deleted file mode 100644 index 04896f19f..000000000 --- a/thirdparty/src/newton/dContainers/dTree.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dContainersStdAfx.h" -#include "dTree.h" - - -dRedBackNode* dRedBackNode::Minimum () const -{ - dRedBackNode* ptr = (dRedBackNode*) this; - for (; ptr->m_left; ptr = ptr->m_left); - return ptr; -} - -dRedBackNode* dRedBackNode::Maximum () const -{ - dRedBackNode* ptr = (dRedBackNode*) this; - for (; ptr->m_right; ptr = ptr->m_right); - return ptr; -} - - -dRedBackNode* dRedBackNode::Prev () const -{ - if (m_left) { - return m_left->Maximum (); - } - - dRedBackNode* me = (dRedBackNode*) this; - dRedBackNode* ptr = m_parent; - for (; ptr && me == ptr->m_left; ptr = ptr->m_parent) { - me = ptr; - } - return ptr; - -} - -dRedBackNode* dRedBackNode::Next () const -{ - if (m_right) { - return m_right->Minimum (); - } - - dRedBackNode* node = (dRedBackNode*) this; - dRedBackNode* ptr = m_parent; - for (; ptr && node == ptr->m_right; ptr = ptr->m_parent) { - node = ptr; - } - return ptr; -} - -// rotate node me to left -void dRedBackNode::RotateLeft(dRedBackNode** const head) -{ - dRedBackNode* const me = this; - dRedBackNode* const child = me->m_right; - - dAssert (child); - //establish me->m_right link - me->m_right = child->m_left; - if (child->m_left != NULL) { - child->m_left->m_parent = me; - } - - // establish child->m_parent link - if (child != NULL) { - child->m_parent = me->m_parent; - } - if (me->m_parent) { - if (me == me->m_parent->m_left) { - me->m_parent->m_left = child; - } else { - me->m_parent->m_right = child; - } - } else { - *head = child; - } - - // link child and me - child->m_left = me; - if (me != NULL) { - me->m_parent = child; - } -} - - -// rotate node me to right * -void dRedBackNode::RotateRight(dRedBackNode** const head) -{ - dRedBackNode* const me = this; - dRedBackNode* const child = me->m_left; - - dAssert (child); - // establish me->m_left link - me->m_left = child->m_right; - if (child->m_right != NULL) { - child->m_right->m_parent = me; - } - - // establish child->m_parent link - if (child != NULL) { - child->m_parent = me->m_parent; - } - if (me->m_parent) { - if (me == me->m_parent->m_right) { - me->m_parent->m_right = child; - } else { - me->m_parent->m_left = child; - } - } else { - *head = child; - } - - // link me and child - child->m_right = me; - if (me != NULL) { - me->m_parent = child; - } -} - - -// maintain Red-Black tree balance after inserting node ptr -void dRedBackNode::InsertFixup(dRedBackNode** const head) -{ - dRedBackNode* ptr = this; - // check Red-Black properties - dAssert ((ptr == *head) || ptr->m_parent); - while ((ptr != *head) && (ptr->m_parent->GetColor() == RED)) { - // we have a violation - dAssert (ptr->m_parent); - dAssert (ptr->m_parent->m_parent); - if (ptr->m_parent == ptr->m_parent->m_parent->m_left) { - dRedBackNode* const tmp = ptr->m_parent->m_parent->m_right; - if (tmp && (tmp->GetColor() == RED)) { - // uncle is RED - ptr->m_parent->SetColor(BLACK); - tmp->SetColor(BLACK) ; - ptr->m_parent->m_parent->SetColor(RED) ; - ptr = ptr->m_parent->m_parent; - } else { - // uncle is BLACK - if (ptr == ptr->m_parent->m_right) { - // make ptr a left child - ptr = ptr->m_parent; - ptr->RotateLeft(head); - } - - ptr->m_parent->SetColor(BLACK); - if (ptr->m_parent->m_parent) { - ptr->m_parent->m_parent->SetColor(RED); - ptr->m_parent->m_parent->RotateRight(head); - } - } - } else { - //dAssert (ptr->m_parent == ptr->m_parent->m_parent->m_right); - // mirror image of above code - dRedBackNode* const tmp = ptr->m_parent->m_parent->m_left; - if (tmp && (tmp->GetColor() == RED)) { - //uncle is RED - ptr->m_parent->SetColor(BLACK); - tmp->SetColor(BLACK) ; - ptr->m_parent->m_parent->SetColor(RED) ; - ptr = ptr->m_parent->m_parent; - } else { - // uncle is BLACK - if (ptr == ptr->m_parent->m_left) { - ptr = ptr->m_parent; - ptr->RotateRight(head); - } - ptr->m_parent->SetColor(BLACK); - if (ptr->m_parent->m_parent->GetColor() == BLACK) { - ptr->m_parent->m_parent->SetColor(RED) ; - ptr->m_parent->m_parent->RotateLeft (head); - } - } - } - } - (*head)->SetColor(BLACK); -} - - -//maintain Red-Black tree balance after deleting node x -void dRedBackNode::RemoveFixup (dRedBackNode* const me, dRedBackNode** const head) -{ - dRedBackNode* ptr = this; - dRedBackNode* node = me; - while ((node != *head) && (!node || node->GetColor() == BLACK)) { - if (node == ptr->m_left) { - if (!ptr) { - return; - } - dRedBackNode* tmp = ptr->m_right; - if (!tmp) { - return; - } - if (tmp->GetColor() == RED) { - tmp->SetColor(BLACK) ; - ptr->SetColor(RED) ; - ptr->RotateLeft (head); - tmp = ptr->m_right; - //if (!ptr || !tmp) { - if (!tmp) { - return; - } - } - if ((!tmp->m_left || (tmp->m_left->GetColor() == BLACK)) && - (!tmp->m_right || (tmp->m_right->GetColor() == BLACK))) { - tmp->SetColor(RED); - node = ptr; - ptr = ptr->m_parent; - continue; - } else if (!tmp->m_right || (tmp->m_right->GetColor() == BLACK)) { - tmp->m_left->SetColor(BLACK); - tmp->SetColor(RED); - tmp->RotateRight (head); - tmp = ptr->m_right; - //if (!ptr || !tmp) { - if (!tmp) { - return; - } - } - tmp->SetColor (ptr->GetColor()); - if (tmp->m_right) { - tmp->m_right->SetColor(BLACK) ; - } - if (ptr) { - ptr->SetColor(BLACK) ; - ptr->RotateLeft (head); - } - node = *head; - - } else { - if (!ptr) { - return; - } - dRedBackNode* tmp = ptr->m_left; - if (!tmp) { - return; - } - if (tmp->GetColor() == RED) { - tmp->SetColor(BLACK) ; - ptr->SetColor(RED) ; - ptr->RotateRight (head); - tmp = ptr->m_left; - //if (!ptr || !tmp) { - if (!tmp) { - return; - } - } - - if ((!tmp->m_right || (tmp->m_right->GetColor() == BLACK)) && - (!tmp->m_left || (tmp->m_left->GetColor() == BLACK))) { - tmp->SetColor(RED) ; - node = ptr; - ptr = ptr->m_parent; - continue; - } else if (!tmp->m_left || (tmp->m_left->GetColor() == BLACK)) { - tmp->m_right->SetColor(BLACK) ; - tmp->SetColor(RED) ; - tmp->RotateLeft (head); - tmp = ptr->m_left; - //if (!ptr || !tmp) { - if (!tmp) { - return; - } - } - tmp->SetColor (ptr->GetColor()); - if (tmp->m_left) { - tmp->m_left->SetColor(BLACK); - } - if (ptr) { - ptr->SetColor(BLACK) ; - ptr->RotateRight (head); - } - node = *head; - } - } - if (node) { - node->SetColor(BLACK); - } -} - -void dRedBackNode::Unlink (dRedBackNode** const head) -{ - dRedBackNode* const node = this; - node->SetInTreeFlag(false); - - if (!node->m_left || !node->m_right) { - // y has a NULL node as a child - dRedBackNode* const endNode = node; - - // x is y's only child - dRedBackNode* child = endNode->m_right; - if (endNode->m_left) { - child = endNode->m_left; - } - - // remove y from the parent chain - if (child) { - child->m_parent = endNode->m_parent; - } - - if (endNode->m_parent) { - if (endNode == endNode->m_parent->m_left) { - endNode->m_parent->m_left = child; - } else { - endNode->m_parent->m_right = child; - } - } else { - *head = child; - } - - if (endNode->GetColor() == BLACK) { - endNode->m_parent->RemoveFixup (child, head); - } - } else { - - // find tree successor with a NULL node as a child - dRedBackNode* endNode = node->m_right; - while (endNode->m_left != NULL) { - endNode = endNode->m_left; - } - - // x is y's only child - dRedBackNode* const child = endNode->m_right; - - endNode->m_left = node->m_left; - node->m_left->m_parent = endNode; - - dRedBackNode* endNodeParent = endNode; - if (endNode != node->m_right) { - if (child) { - child->m_parent = endNode->m_parent; - } - endNode->m_parent->m_left = child; - endNode->m_right = node->m_right; - node->m_right->m_parent = endNode; - endNodeParent = endNode->m_parent; - } - - - if (node == *head) { - *head = endNode; - } else if (node == node->m_parent->m_left) { - node->m_parent->m_left = endNode; - } else { - node->m_parent->m_right = endNode; - } - endNode->m_parent = node->m_parent; - - bool oldColor = endNode->GetColor(); - endNode->SetColor (node->GetColor()); - node->SetColor (oldColor); - - if (oldColor == BLACK) { - endNodeParent->RemoveFixup (child, head); - } - } -} - - diff --git a/thirdparty/src/newton/dContainers/dTree.h b/thirdparty/src/newton/dContainers/dTree.h deleted file mode 100644 index 1f2f2238d..000000000 --- a/thirdparty/src/newton/dContainers/dTree.h +++ /dev/null @@ -1,796 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - - -#ifndef __dTree__ -#define __dTree__ - -#include "dContainersStdAfx.h" -#include "dContainersAlloc.h" - - -// Note: this is a low level class for dTree use only -// unpredictable result will happen if you attempt to manipulate -// any member of this class -class dRedBackNode -{ - public: - enum REDBLACK_COLOR - { - RED = true, - BLACK = false - }; - - public: - dRedBackNode* GetLeft() const; - dRedBackNode* GetRight() const; - dRedBackNode* GetParent() const; - dRedBackNode (dRedBackNode* const parent); - DCONTAINERS_API dRedBackNode* Prev() const; - DCONTAINERS_API dRedBackNode* Next() const; - DCONTAINERS_API dRedBackNode* Minimum() const; - DCONTAINERS_API dRedBackNode* Maximum() const; - - protected: - virtual ~dRedBackNode () - { - } - - void Initdata (dRedBackNode* const parent); - void SetColor (bool color); - bool GetColor () const; - bool IsInTree () const; - void SetInTreeFlag (bool flag); - DCONTAINERS_API void RotateLeft(dRedBackNode** const head); - DCONTAINERS_API void RotateRight(dRedBackNode** const head); - DCONTAINERS_API void RemoveFixup (dRedBackNode* const node, dRedBackNode** const head); - DCONTAINERS_API void Unlink (dRedBackNode** const head); - DCONTAINERS_API void InsertFixup(dRedBackNode** const head); - - bool m_color; - bool m_inTree; - dRedBackNode* m_left; - dRedBackNode* m_right; - dRedBackNode* m_parent; -}; - - - -template<class OBJECT, class KEY, int poolSize = D_MAX_ENTRIES_IN_FREELIST> -class dTree: public dContainersAlloc -{ - public: - class dTreeNode: public dRedBackNode - { - dTreeNode ( - const KEY &key, - dTreeNode* parentNode) - :dRedBackNode(parentNode), m_info (), m_key (key) - { - } - - dTreeNode ( - const OBJECT &info, - const KEY &key, - dTreeNode* parentNode) - :dRedBackNode(parentNode), m_info (info), m_key (key) - { - } - - virtual ~dTreeNode () - { - } - - dTreeNode& operator= (dTreeNode& src) - { - dAssert (0); - return* this; - } - - dTreeNode* GetLeft () const - { - return (dTreeNode*) dRedBackNode::m_left; - } - - dTreeNode* GetRight () const - { - return (dTreeNode*) dRedBackNode::m_right; - } - - dTreeNode* GetParent () - { - return (dTreeNode*) dRedBackNode::m_parent; - } - - void SetLeft (dTreeNode* const node) - { - dRedBackNode::m_left = node; - } - - void SetRight (dTreeNode* const node) - { - dRedBackNode::m_right = node; - } - - void SetParent (dTreeNode* const node) - { - dRedBackNode::m_parent = node; - } - - public: - const KEY& GetKey() const - { - return m_key; - } - - OBJECT& GetInfo() - { - return m_info; - } - - private: - OBJECT m_info; - KEY m_key; - friend class dTree<OBJECT, KEY>; - }; - - class Iterator - { - public: - Iterator(const dTree<OBJECT,KEY> &me) - { - m_ptr = NULL; - m_tree = &me; - } - - ~Iterator() - { - } - - void Begin() - { - m_ptr = m_tree->Minimum(); - } - - void End() - { - m_ptr = m_tree->Maximum(); - } - - void Set (dTreeNode* const node) - { - m_ptr = node; - } - - operator int() const - { - return m_ptr != NULL; - } - - void operator++ () - { - //dAssert (m_ptr); - m_ptr = m_ptr->Next(); - } - - void operator++ (int) - { - //dAssert (m_ptr); - m_ptr = m_ptr->Next(); - } - - void operator-- () - { - //dAssert (m_ptr); - m_ptr = m_ptr->Prev(); - } - - void operator-- (int) - { - //dAssert (m_ptr); - m_ptr = m_ptr->Prev(); - } - - OBJECT &operator* () const - { - return ((dTreeNode*)m_ptr)->GetInfo(); - } - - dTreeNode* GetNode() const - { - return (dTreeNode*)m_ptr; - } - - KEY GetKey () const - { - dTreeNode* const tmp = (dTreeNode*)m_ptr; - return tmp ? tmp->GetKey() : KEY(0); - } - - private: - dRedBackNode* m_ptr; - const dTree* m_tree; - }; - - - // *********************************************************** - // member functions - // *********************************************************** - public: - dTree (); - virtual ~dTree (); - - operator int() const; - int GetCount() const; - - dTreeNode* GetRoot () const; - dTreeNode* Minimum () const; - dTreeNode* Maximum () const; - - dTreeNode* Find (KEY key) const; - dTreeNode* FindGreater (KEY key) const; - dTreeNode* FindGreaterEqual (KEY key) const; - dTreeNode* FindLessEqual (KEY key) const; - - dTreeNode* GetNodeFromInfo (OBJECT &info) const; - - dTreeNode* Insert (KEY key); - dTreeNode* Insert (const OBJECT &element, KEY key); - dTreeNode* Insert (const OBJECT &element, KEY key, bool& elementWasInTree); - dTreeNode* Insert (dTreeNode* const node, KEY key); - - dTreeNode* Replace (OBJECT &element, KEY key); - dTreeNode* ReplaceKey (KEY oldKey, KEY newKey); - dTreeNode* ReplaceKey (dTreeNode* const node, KEY key); - - void Unlink (dTreeNode* const node); - - void Remove (KEY key); - void Remove (dTreeNode* const node); - void RemoveAll (); - - bool SanityCheck () const; - - - // *********************************************************** - // member variables - // *********************************************************** - private: - dContainerFixSizeAllocator& GetAllocator() - { - static dContainerFixSizeAllocator* allocator = NULL; - if (!allocator) { - allocator = dContainerFixSizeAllocator::Create (sizeof (dTree<OBJECT, KEY, poolSize>::dTreeNode), poolSize); - } - return *allocator; - } - - - void RemoveAllLow (dTreeNode* const root); - int CompareKeys (const KEY &key0, const KEY &key1) const; - bool SanityCheck (dTreeNode* const ptr, int height) const; - - int m_count; - dTreeNode* m_head; - friend class dTreeNode; -}; - - -inline dRedBackNode::dRedBackNode (dRedBackNode* const parent) -{ - Initdata (parent); -} - -inline void dRedBackNode::Initdata (dRedBackNode* const parent) -{ - SetColor (RED); - SetInTreeFlag (true); - m_left = NULL; - m_right = NULL; - m_parent = parent; -} - -inline void dRedBackNode::SetColor (bool color) -{ - m_color = color; -} - -inline bool dRedBackNode::GetColor () const -{ - return m_color; -} - -inline bool dRedBackNode::IsInTree () const -{ - return m_inTree; -} - -inline void dRedBackNode::SetInTreeFlag (bool flag) -{ - m_inTree = flag; -} - - - -template<class OBJECT, class KEY, int poolSize> -dTree<OBJECT, KEY, poolSize>::dTree () -{ - m_count = 0; - m_head = NULL; - GetAllocator(); -} - - -template<class OBJECT, class KEY, int poolSize> -dTree<OBJECT, KEY, poolSize>::~dTree () -{ - RemoveAll(); -} - - -template<class OBJECT, class KEY, int poolSize> -dTree<OBJECT, KEY, poolSize>::operator int() const -{ - return m_head != NULL; -} - -template<class OBJECT, class KEY, int poolSize> -int dTree<OBJECT, KEY, poolSize>::GetCount() const -{ - return m_count; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::Minimum () const -{ - return m_head ? (dTreeNode*) m_head->Minimum() : NULL; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::Maximum () const -{ - return m_head ? (dTreeNode*) m_head->Maximum() : NULL; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::GetRoot () const -{ - return m_head; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::Find (KEY key) const -{ - if (m_head == NULL) { - return NULL; - } - - dTreeNode* ptr = m_head; - while (ptr != NULL) { - int val = CompareKeys (ptr->m_key, key); - if (!val) { - break; - } - if (val < 0) { - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - return ptr; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::GetNodeFromInfo (OBJECT &info) const -{ - dTreeNode* node = (dTreeNode*) &info; - int offset = ((char*) &node->m_info) - ((char *) node); - node = (dTreeNode*) (((char *) node) - offset); - -// dAssert (node->IsInTree ()); - dAssert (&node->GetInfo () == &info); - return (node->IsInTree ()) ? node : NULL; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::FindGreater (KEY key) const -{ - if (m_head == NULL) { - return NULL; - } - - dTreeNode* prev = NULL; - dTreeNode* ptr = m_head; - int val = 0; - while (ptr != NULL) { - val = CompareKeys (ptr->m_key, key); - if (!val) { - return (dTreeNode*) ptr->Next(); - } - prev = ptr; - if (val < 0) { - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - - if (val > 0) { - while (prev->m_parent && (prev->m_parent->m_right == prev)) { - prev = prev->GetParent(); - } - prev = prev->GetParent(); - } - return (dTreeNode*) prev; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::FindGreaterEqual (KEY key) const -{ - if (m_head == NULL) { - return NULL; - } - - dTreeNode* prev = NULL; - dTreeNode* ptr = m_head; - int val = 0; - while (ptr != NULL) { - val = CompareKeys (ptr->m_key, key); - if (!val) { - return ptr; - } - prev = ptr; - if (val < 0) { - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - - if (val > 0) { - while (prev->m_parent && (prev->m_parent->m_right == prev)) { - prev = prev->GetParent(); - } - prev = prev->GetParent(); - } - return (dTreeNode*) prev; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::FindLessEqual (KEY key) const -{ - if (m_head == NULL) { - return NULL; - } - - dTreeNode* prev = NULL; - dTreeNode* ptr = m_head; - int val = 0; - while (ptr != NULL) { - val = CompareKeys (ptr->m_key, key); - if (!val) { - return ptr; - } - prev = ptr; - if (val < 0) { - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - - if (val < 0) { - while (prev->m_parent && (prev->m_parent->m_left == prev)) { - prev = prev->GetParent(); - } - prev = prev->GetParent(); - } - return (dTreeNode*) prev; -} - - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::Insert (KEY key) -{ - dTreeNode* parent = NULL; - dTreeNode* ptr = m_head; - int val = 0; - while (ptr != NULL) { - parent = ptr; - val = CompareKeys (ptr->m_key, key); - - if (val < 0) { - ptr = ptr->GetLeft(); - } else if (val > 0) { - ptr = ptr->GetRight(); - } else { - return ptr; - } - } - m_count ++; - - ptr = new (GetAllocator().Alloc()) dTreeNode (key, parent); - if (!parent) { - m_head = ptr; - } else { - if (val < 0) { - parent->m_left = ptr; - } else { - parent->m_right = ptr; - } - } - ptr->InsertFixup ((dRedBackNode**)&m_head); - return ptr; -} - - - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::Insert (const OBJECT &element, KEY key, bool& elementWasInTree) -{ - dTreeNode* parent = NULL; - dTreeNode* ptr = m_head; - int val = 0; - elementWasInTree = false; - while (ptr != NULL) { - parent = ptr; - val = CompareKeys (ptr->m_key, key); - - if (val < 0) { - ptr = ptr->GetLeft(); - } else if (val > 0) { - ptr = ptr->GetRight(); - } else { - elementWasInTree = true; - return ptr; - } - } - m_count ++; - - ptr = new (GetAllocator().Alloc()) dTreeNode (element, key, parent); - if (!parent) { - m_head = ptr; - } else { - if (val < 0) { - parent->m_left = ptr; - } else { - parent->m_right = ptr; - } - } - ptr->InsertFixup ((dRedBackNode**)&m_head); - return ptr; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::Insert (const OBJECT &element, KEY key) -{ - bool foundState; - dTreeNode* node = Insert (element, key, foundState); - if (foundState) { - node = NULL; - } - return node; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::Insert (typename dTree<OBJECT, KEY, poolSize>::dTreeNode* const node, KEY key) -{ - int val = 0; - dTreeNode* ptr = m_head; - dTreeNode* parent = NULL; - while (ptr != NULL) { - parent = ptr; - val = CompareKeys (ptr->m_key, key); - - if (val < 0) { - ptr = ptr->GetLeft(); - } else if (val > 0) { - ptr = ptr->GetRight(); - } else { - return NULL; - } - } - - m_count ++; - - ptr = node; - ptr->m_key = key; - ptr->Initdata (parent); - - if (!parent) { - m_head = ptr; - } else { - if (val < 0) { - parent->m_left = ptr; - } else { - parent->m_right = ptr; - } - } - ptr->InsertFixup ((dRedBackNode**)&m_head); - return ptr; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::Replace (OBJECT &element, KEY key) -{ - dTreeNode* parent = NULL; - dTreeNode* ptr = m_head; - int val = 0; - while (ptr != NULL) { - parent = ptr; - val = CompareKeys (ptr->m_key, key); - if (val == 0) { - ptr->m_info = element; - return ptr; - } - if (val < 0) { - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - - ptr = new (GetAllocator().Alloc()) dTreeNode (element, key, parent); - if (!parent) { - m_head = ptr; - } else { - if (val < 0) { - parent->m_left = ptr; - } else { - parent->m_right = ptr; - } - } - ptr->InsertFixup ((dRedBackNode**)&m_head); - return ptr; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::ReplaceKey (typename dTree<OBJECT, KEY, poolSize>::dTreeNode* node, KEY key) -{ - Unlink(node); - dTreeNode* const ptr = Insert (node, key); - - dAssert (ptr); - return ptr; -} - -template<class OBJECT, class KEY, int poolSize> -typename dTree<OBJECT, KEY, poolSize>::dTreeNode* dTree<OBJECT, KEY, poolSize>::ReplaceKey (KEY oldKey, KEY newKey) -{ - dTreeNode* const node = Find (oldKey); - return node ? ReplaceKey (node, newKey) : NULL; -} - -template<class OBJECT, class KEY, int poolSize> -void dTree<OBJECT, KEY, poolSize>::Unlink (typename dTree<OBJECT, KEY, poolSize>::dTreeNode* const node) -{ - m_count --; - node->Unlink((dRedBackNode** )&m_head); -} - - -template<class OBJECT, class KEY, int poolSize> -void dTree<OBJECT, KEY, poolSize>::Remove (typename dTree<OBJECT, KEY, poolSize>::dTreeNode* const node) -{ - m_count --; - node->Unlink ((dRedBackNode** )&m_head); - node->~dTreeNode(); - GetAllocator().Free (node); -} - -template<class OBJECT, class KEY, int poolSize> -void dTree<OBJECT, KEY, poolSize>::Remove (KEY key) -{ - // find node in tree - dTreeNode* const node = Find (key); - if (node) { - Remove (node); - } -} - - -template<class OBJECT, class KEY, int poolSize> -void dTree<OBJECT, KEY, poolSize>::RemoveAllLow (dTreeNode* const root) -{ - if (root->m_left) { - RemoveAllLow((dTreeNode*)root->m_left); - } - if (root->m_right) { - RemoveAllLow ((dTreeNode*)root->m_right); - } - root->SetInTreeFlag(false); - root->~dTreeNode(); - GetAllocator().Free (root); -} - - -template<class OBJECT, class KEY, int poolSize> -void dTree<OBJECT, KEY, poolSize>::RemoveAll () -{ - if (m_head) { - m_count = 0; - dTreeNode* root; - for (root = m_head; root->m_parent; root = (dTreeNode*)root->m_parent); - RemoveAllLow(root); - m_head = NULL; - } -} - -template<class OBJECT, class KEY, int poolSize> -bool dTree<OBJECT, KEY, poolSize>::SanityCheck () const -{ - return SanityCheck (m_head, 0); -} - - -template<class OBJECT, class KEY, int poolSize> -bool dTree<OBJECT, KEY, poolSize>::SanityCheck (typename dTree<OBJECT, KEY, poolSize>::dTreeNode* ptr, int height) const -{ - if (!ptr) { - return true; - } - - if (ptr->m_left) { - if (CompareKeys (ptr->m_key, ptr->GetLeft()->m_key) > 0) { - return false; - } - } - - if (ptr->m_right) { - if (CompareKeys (ptr->m_key, ptr->GetRight()->m_key) < 0) { - return false; - } - } - - if (ptr->GetColor() == dTreeNode::BLACK) { - height ++; - } else if (!((!ptr->m_left || (ptr->m_left->GetColor() == dTreeNode::BLACK)) && - (!ptr->m_right || (ptr->m_right->GetColor() == dTreeNode::BLACK)))) { - return false; - } - - if (!ptr->m_left && !ptr->m_right) { - int bh = 0; - for (dTreeNode* x = ptr; x; x = x->GetParent()) { - if (x->GetColor() == dTreeNode::BLACK) { - bh ++; - } - } - if (bh != height) { - return false; - } - } - - if (ptr->m_left && !SanityCheck (ptr->GetLeft(), height)) { - return false; - } - - if (ptr->m_right && !SanityCheck (ptr->GetRight(), height)) { - return false; - } - return true; -} - -template<class OBJECT, class KEY, int poolSize> -int dTree<OBJECT, KEY, poolSize>::CompareKeys (const KEY &key0, const KEY &key1) const -{ - if (key1 < key0) { - return - 1; - } - if (key1 > key0) { - return 1; - } - return 0; -} - -#endif - - diff --git a/thirdparty/src/newton/dMath/CMakeLists.txt b/thirdparty/src/newton/dMath/CMakeLists.txt deleted file mode 100644 index e9cc1fb8f..000000000 --- a/thirdparty/src/newton/dMath/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (c) <2014-2017> <Newton Game Dynamics> -# -# 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. - -cmake_minimum_required(VERSION 3.4.0) - -set (projectName "dMath") -message (${projectName}) - -# low level core -file(GLOB CPP_SOURCE *.h *.cpp) -file(GLOB HEADERS *.h) - -if (UNIX OR MINGW) - if(NEWTON_BUILD_SHARED_LIBS) - add_library(${projectName} SHARED ${CPP_SOURCE}) - else(NEWTON_BUILD_SHARED_LIBS) - add_library(${projectName} STATIC ${CPP_SOURCE}) - endif(NEWTON_BUILD_SHARED_LIBS) -endif (UNIX OR MINGW) - -if (MSVC) - add_library(${projectName} STATIC ${CPP_SOURCE}) - - if(CMAKE_VS_MSBUILD_COMMAND OR CMAKE_VS_DEVENV_COMMAND) - set_target_properties(${projectName} PROPERTIES COMPILE_FLAGS "/YudStdAfxMath.h") - set_source_files_properties(dStdAfxMath.cpp PROPERTIES COMPILE_FLAGS "/YcdStdAfxMath.h") - endif() -endif(MSVC) - -target_include_directories(${projectName} PUBLIC .) - -if (NEWTON_BUILD_PROFILER) - target_link_libraries (${projectName} dProfiler) -endif() - -install(TARGETS ${projectName} - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin) - -install(FILES ${HEADERS} DESTINATION include/${projectName}) diff --git a/thirdparty/src/newton/dMath/dLinearAlgebra.cpp b/thirdparty/src/newton/dMath/dLinearAlgebra.cpp deleted file mode 100644 index f1c20748f..000000000 --- a/thirdparty/src/newton/dMath/dLinearAlgebra.cpp +++ /dev/null @@ -1,948 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dStdAfxMath.h" -#include "dMathDefines.h" -#include "dLinearAlgebra.h" - -#define COMPLEMENTARITY_VEL_DAMP dFloat(100.0f) -#define COMPLEMENTARITY_POS_DAMP dFloat(1500.0f) -#define COMPLEMENTARITY_PSD_DAMP_TOL dFloat(1.0e-4f) -#define COMPLEMENTARITY_STACK_ENTRIES 64 - - -void dSymmetricBiconjugateGradientSolve::ScaleAdd (int size, dFloat64* const a, const dFloat64* const b, dFloat64 scale, const dFloat64* const c) const -{ - for (int i = 0; i < size; i ++) { - a[i] = b[i] + scale * c[i]; - } -} - -void dSymmetricBiconjugateGradientSolve::Sub (int size, dFloat64* const a, const dFloat64* const b, const dFloat64* const c) const -{ - for (int i = 0; i < size; i ++) { - a[i] = b[i] - c[i]; - } -} - -dFloat64 dSymmetricBiconjugateGradientSolve::DotProduct (int size, const dFloat64* const b, const dFloat64* const c) const -{ - dFloat64 product = dFloat64 (0.0f); - for (int i = 0; i < size; i ++) { - product += b[i] * c[i]; - } - return product; -} - -dFloat64 dSymmetricBiconjugateGradientSolve::Solve (int size, dFloat64 tolerance, dFloat64* const x, const dFloat64* const b) const -{ - dFloat64* const r0 = new dFloat64 [size]; - dFloat64* const p0 = new dFloat64 [size]; - dFloat64* const MinvR0 = new dFloat64 [size]; - dFloat64* const matrixP0 = new dFloat64 [size]; - - MatrixTimeVector (matrixP0, x); - Sub(size, r0, b, matrixP0); - bool continueExecution = InversePrecoditionerTimeVector (p0, r0); - - int iter = 0; - dFloat64 num = DotProduct (size, r0, p0); - dFloat64 error2 = num; - for (int j = 0; (j < size) && (error2 > tolerance) && continueExecution; j ++) { - - MatrixTimeVector (matrixP0, p0); - dFloat64 den = DotProduct (size, p0, matrixP0); - - dAssert (fabs(den) > dFloat64 (0.0f)); - dFloat64 alpha = num / den; - - ScaleAdd (size, x, x, alpha, p0); - if ((j % 50) != 49) { - ScaleAdd (size, r0, r0, -alpha, matrixP0); - } else { - MatrixTimeVector (matrixP0, x); - Sub(size, r0, b, matrixP0); - } - - continueExecution = InversePrecoditionerTimeVector (MinvR0, r0); - - dFloat64 num1 = DotProduct (size, r0, MinvR0); - dFloat64 beta = num1 / num; - ScaleAdd (size, p0, MinvR0, beta, p0); - num = DotProduct (size, r0, MinvR0); - iter ++; - error2 = num; - if (j > 10) { - error2 = dFloat64 (0.0f); - for (int i = 0; i < size; i ++) { - error2 = dMax (error2, r0[i] * r0[i]); - } - } - } - - delete[] matrixP0; - delete[] MinvR0; - delete[] p0; - delete[] r0; - - dAssert (iter <= size); - return num; -} - - -dComplementaritySolver::dBodyState::dBodyState() - :m_matrix(dGetIdentityMatrix()) - ,m_localFrame(dGetIdentityMatrix()) - ,m_inertia(dGetZeroMatrix()) - ,m_invInertia(dGetZeroMatrix()) - ,m_localInertia (0.0f) - ,m_localInvInertia(0.0f) - ,m_veloc(0.0f) - ,m_omega(0.0f) - ,m_externalForce(0.0f) - ,m_externalTorque(0.0f) - ,m_globalCentreOfMass(0.0f) - ,m_mass(0.0f) - ,m_invMass(0.0f) - ,m_myIndex(0) -{ -} - -const dVector& dComplementaritySolver::dBodyState::GetOmega() const -{ - return m_omega; -} - -const dVector& dComplementaritySolver::dBodyState::GetVelocity() const -{ - return m_veloc; -} - -dVector dComplementaritySolver::dBodyState::CalculatePointVelocity (const dVector& point) const -{ - return m_veloc + m_omega.CrossProduct(point - m_globalCentreOfMass); -} - -dFloat dComplementaritySolver::dBodyState::GetMass () const -{ - return m_mass; -} - -dFloat dComplementaritySolver::dBodyState::GetInvMass () const -{ - return m_invMass; -} - -void dComplementaritySolver::dBodyState::SetMass (dFloat mass) -{ - m_mass = mass; - m_invMass = mass > (1.0e-3f) ? 1.0f / mass : 0.0f; -} - -void dComplementaritySolver::dBodyState::SetInertia (dFloat Ixx, dFloat Iyy, dFloat Izz) -{ - m_localInertia[0] = Ixx; - m_localInertia[1] = Iyy; - m_localInertia[2] = Izz; - m_localInvInertia[0] = Ixx ? 1.0f / Ixx : 0.0f; - m_localInvInertia[1] = Iyy ? 1.0f / Iyy : 0.0f; - m_localInvInertia[2] = Izz ? 1.0f / Izz : 0.0f; -} - -void dComplementaritySolver::dBodyState::GetInertia (dFloat& Ixx, dFloat& Iyy, dFloat& Izz) const -{ - Ixx = m_localInertia[0]; - Iyy = m_localInertia[1]; - Izz = m_localInertia[2]; -} - -const dMatrix& dComplementaritySolver::dBodyState::GetInertia() const -{ - return m_inertia; -} - -const dMatrix& dComplementaritySolver::dBodyState::GetInvInertia() const -{ - return m_invInertia; -} - -void dComplementaritySolver::dBodyState::SetMatrix (const dMatrix& matrix) -{ - m_matrix = matrix; - m_globalCentreOfMass = m_matrix.TransformVector(m_localFrame.m_posit); -} - -const dMatrix& dComplementaritySolver::dBodyState::GetMatrix () const -{ - return m_matrix; -} - -void dComplementaritySolver::dBodyState::SetLocalMatrix (const dMatrix& matrix) -{ - m_localFrame = matrix; - m_globalCentreOfMass = m_matrix.TransformVector(m_localFrame.m_posit); -} - -const dMatrix& dComplementaritySolver::dBodyState::GetLocalMatrix () const -{ - return m_localFrame; -} - -const dVector& dComplementaritySolver::dBodyState::GetCOM () const -{ - return m_localFrame.m_posit; -} - -void dComplementaritySolver::dBodyState::SetVeloc (const dVector& veloc) -{ - m_veloc = veloc; -} - -void dComplementaritySolver::dBodyState::SetOmega (const dVector& omega) -{ - m_omega = omega; -} - -void dComplementaritySolver::dBodyState::SetForce (const dVector& force) -{ - m_externalForce = force; -} - -void dComplementaritySolver::dBodyState::SetTorque (const dVector& torque) -{ - m_externalTorque = torque; -} - -const dVector& dComplementaritySolver::dBodyState::GetForce () const -{ - return m_externalForce; -} - -const dVector& dComplementaritySolver::dBodyState::GetTorque () const -{ - return m_externalTorque; -} - -void dComplementaritySolver::dBodyState::UpdateInertia() -{ - dMatrix tmpMatrix (dGetZeroMatrix()); - - tmpMatrix[0] = m_localInertia * dVector (m_matrix[0][0], m_matrix[1][0], m_matrix[2][0], dFloat(0.0f)); - tmpMatrix[1] = m_localInertia * dVector (m_matrix[0][1], m_matrix[1][1], m_matrix[2][1], dFloat(0.0f)); - tmpMatrix[2] = m_localInertia * dVector (m_matrix[0][2], m_matrix[1][2], m_matrix[2][2], dFloat(0.0f)); - m_inertia = tmpMatrix * m_matrix; - - tmpMatrix[0] = m_localInvInertia * dVector (m_matrix[0][0], m_matrix[1][0], m_matrix[2][0], dFloat(0.0f)); - tmpMatrix[1] = m_localInvInertia * dVector (m_matrix[0][1], m_matrix[1][1], m_matrix[2][1], dFloat(0.0f)); - tmpMatrix[2] = m_localInvInertia * dVector (m_matrix[0][2], m_matrix[1][2], m_matrix[2][2], dFloat(0.0f)); - m_invInertia = tmpMatrix * m_matrix; -} - -void dComplementaritySolver::dBodyState::IntegrateForce (dFloat timestep, const dVector& force, const dVector& torque) -{ - dVector accel (force.Scale (m_invMass)); - dVector alpha (m_invInertia.RotateVector(torque)); - m_veloc += accel.Scale (timestep); - m_omega += alpha.Scale (timestep); -} - -void dComplementaritySolver::dBodyState::IntegrateVelocity (dFloat timestep) -{ - // this is the fucking bug cause the vehicle malfunction - const dFloat D_MAX_ANGLE_STEP = dFloat (90.0f * dDegreeToRad); - while ((m_omega.DotProduct3(m_omega) * timestep * timestep) > (D_MAX_ANGLE_STEP * D_MAX_ANGLE_STEP)) { - dAssert (0); - m_omega = m_omega.Scale (dFloat (0.8f)); - } - - // this is correct - const dFloat D_ANGULAR_TOL = dFloat (0.0125f * dDegreeToRad); - m_globalCentreOfMass += m_veloc.Scale (timestep); - dFloat omegaMag2 = m_omega.DotProduct3(m_omega); - if (omegaMag2 > (D_ANGULAR_TOL * D_ANGULAR_TOL)) { - dFloat invOmegaMag = 1.0f / dSqrt (omegaMag2); - dVector omegaAxis (m_omega.Scale (invOmegaMag)); - dFloat omegaAngle = invOmegaMag * omegaMag2 * timestep; - dQuaternion rotation (omegaAxis, omegaAngle); - dQuaternion rotMatrix (m_matrix); - rotMatrix = rotMatrix * rotation; - rotMatrix.Scale( 1.0f / dSqrt (rotMatrix.DotProduct (rotMatrix))); - m_matrix = dMatrix (rotMatrix, m_matrix.m_posit); - } - - m_matrix.m_posit = m_globalCentreOfMass - m_matrix.RotateVector(m_localFrame.m_posit); - -#ifdef _DEBUG - int j0 = 1; - int j1 = 2; - for (int i = 0; i < 3; i ++) { - dAssert (m_matrix[i][3] == 0.0f); - dFloat val = m_matrix[i].DotProduct3(m_matrix[i]); - dAssert (dAbs (val - 1.0f) < 1.0e-5f); - dVector tmp (m_matrix[j0].CrossProduct(m_matrix[j1])); - val = tmp.DotProduct3(m_matrix[i]); - dAssert (dAbs (val - 1.0f) < 1.0e-5f); - j0 = j1; - j1 = i; - } -#endif -} - -void dComplementaritySolver::dBodyState::ApplyNetForceAndTorque (dFloat invTimestep, const dVector& veloc, const dVector& omega) -{ - dVector accel = (m_veloc - veloc).Scale(invTimestep); - dVector alpha = (m_omega - omega).Scale(invTimestep); - - m_externalForce = accel.Scale(m_mass); - alpha = m_matrix.UnrotateVector(alpha); - m_externalTorque = m_matrix.RotateVector(alpha * m_localInertia); -} - -void dComplementaritySolver::dBilateralJoint::Init(dBodyState* const state0, dBodyState* const state1) -{ - m_start = 0; - m_count = 0; - memset (m_rowIsMotor, 0, sizeof (m_rowIsMotor)); - memset (m_motorAcceleration, 0, sizeof (m_motorAcceleration)); - //memset (m_jointFeebackForce, 0, sizeof (m_jointFeebackForce)); - - m_state0 = state0; - m_state1 = state1; -} - -void dComplementaritySolver::dBilateralJoint::AddContactRowJacobian (dParamInfo* const constraintParams, const dVector& pivot, const dVector& dir, dFloat restitution) -{ - dVector r0 (pivot - m_state0->m_globalCentreOfMass); - dVector r1 (pivot - m_state1->m_globalCentreOfMass); - - int index = constraintParams->m_count; - - dAssert(dir.m_w == 0.0f); - dJacobian &jacobian0 = constraintParams->m_jacobians[index].m_jacobian_J01; - dJacobian &jacobian1 = constraintParams->m_jacobians[index].m_jacobian_J10; - - jacobian0.m_linear = dir; - jacobian0.m_angular = r0.CrossProduct(jacobian0.m_linear); - - jacobian1.m_linear = dir.Scale(-1.0f); - jacobian1.m_angular = r1.CrossProduct(jacobian1.m_linear); - - const dVector& omega0 = m_state0->m_omega; - const dVector& omega1 = m_state1->m_omega; - const dVector& veloc0 = m_state0->m_veloc; - const dVector& veloc1 = m_state1->m_veloc; - - const dVector veloc(jacobian0.m_linear * veloc0 + jacobian0.m_angular * omega0 + jacobian1.m_linear * veloc1 + jacobian1.m_angular * omega1); - const dVector relAccel(veloc.Scale(constraintParams->m_timestepInv * (1.0f + restitution))); - - dAssert(relAccel.m_w == 0.0f); - constraintParams->m_frictionCallback[index] = NULL; - constraintParams->m_diagonalRegularizer[index] = 0.0f; - constraintParams->m_jointAccel[index] = -(relAccel.m_x + relAccel.m_y + relAccel.m_z); - constraintParams->m_jointLowFrictionCoef[index] = D_COMPLEMENTARITY_MIN_FRICTION_BOUND; - constraintParams->m_jointHighFrictionCoef[index] = D_COMPLEMENTARITY_MAX_FRICTION_BOUND; - constraintParams->m_count = index + 1; -} - - -void dComplementaritySolver::dBilateralJoint::AddLinearRowJacobian(dParamInfo* const constraintParams, const dVector& pivot, const dVector& dir) -{ - dVector r0 (pivot - m_state0->m_globalCentreOfMass); - dVector r1 (pivot - m_state1->m_globalCentreOfMass); - - int index = constraintParams->m_count; - - dAssert(dir.m_w == 0.0f); - dJacobian &jacobian0 = constraintParams->m_jacobians[index].m_jacobian_J01; - dJacobian &jacobian1 = constraintParams->m_jacobians[index].m_jacobian_J10; - - jacobian0.m_linear = dir; - jacobian0.m_angular = r0.CrossProduct(jacobian0.m_linear); - - jacobian1.m_linear = dir.Scale(-1.0f); - jacobian1.m_angular = r1.CrossProduct(jacobian1.m_linear); - - const dVector& omega0 = m_state0->m_omega; - const dVector& omega1 = m_state1->m_omega; - const dVector& veloc0 = m_state0->m_veloc; - const dVector& veloc1 = m_state1->m_veloc; - - dVector centripetal0(omega0.CrossProduct(omega0.CrossProduct(r0))); - dVector centripetal1(omega1.CrossProduct(omega1.CrossProduct(r1))); - const dVector accel(jacobian0.m_linear * centripetal0 + jacobian1.m_linear * centripetal1); - const dVector veloc(jacobian0.m_linear * veloc0 + jacobian0.m_angular * omega0 + jacobian1.m_linear * veloc1 + jacobian1.m_angular * omega1); - const dVector relAccel(accel + veloc.Scale(constraintParams->m_timestepInv)); - - dAssert(relAccel.m_w == 0.0f); - constraintParams->m_frictionCallback[index] = NULL; - constraintParams->m_diagonalRegularizer[index] = 0.0f; - constraintParams->m_jointAccel[index] = -(relAccel.m_x + relAccel.m_y + relAccel.m_z); - constraintParams->m_jointLowFrictionCoef[index] = D_COMPLEMENTARITY_MIN_FRICTION_BOUND; - constraintParams->m_jointHighFrictionCoef[index] = D_COMPLEMENTARITY_MAX_FRICTION_BOUND; - constraintParams->m_count = index + 1; -} - -void dComplementaritySolver::dBilateralJoint::AddAngularRowJacobian (dParamInfo* const constraintParams, const dVector& dir, dFloat jointAngle) -{ - int index = constraintParams->m_count; - dAssert(dir.m_w == 0.0f); - - dJacobian &jacobian0 = constraintParams->m_jacobians[index].m_jacobian_J01; - dJacobian &jacobian1 = constraintParams->m_jacobians[index].m_jacobian_J10; - - jacobian0.m_linear = dVector(0.0f); - jacobian1.m_linear = dVector(0.0f); - - jacobian0.m_angular = dir; - jacobian1.m_angular = dir.Scale (-1.0f); - - const dVector& omega0 = m_state0->m_omega; - const dVector& omega1 = m_state1->m_omega; - const dVector omega (omega0 * jacobian0.m_angular + omega1 * jacobian1.m_angular); - const dVector alpha (omega.Scale (constraintParams->m_timestepInv)); - - constraintParams->m_frictionCallback[index] = NULL; - constraintParams->m_diagonalRegularizer[index] = 0.0f; - constraintParams->m_jointAccel[index] = -(alpha.m_x + alpha.m_y + alpha.m_z); - constraintParams->m_jointLowFrictionCoef[index] = D_COMPLEMENTARITY_MIN_FRICTION_BOUND; - constraintParams->m_jointHighFrictionCoef[index] = D_COMPLEMENTARITY_MAX_FRICTION_BOUND; - constraintParams->m_count = index + 1; -} - -dFloat dComplementaritySolver::dBilateralJoint::GetRowAccelaration(dParamInfo* const constraintParams) const -{ - dAssert(constraintParams->m_count > 0); - return constraintParams->m_jointAccel[constraintParams->m_count - 1]; -} - -void dComplementaritySolver::dBilateralJoint::SetRowAccelaration(dParamInfo* const constraintParams, dFloat accel) -{ - dAssert(constraintParams->m_count > 0); - constraintParams->m_jointAccel[constraintParams->m_count - 1] = accel; -} - -dFloat dComplementaritySolver::dBilateralJoint::CalculateMassMatrixDiagonal(dParamInfo* const constraintParams) const -{ -/* - dAssert(constraintParams->m_count > 0); - const int index = constraintParams->m_count - 1; - const dJacobian &jacobian0 = constraintParams->m_jacobians[index].m_jacobian_J01; - const dJacobian &jacobian1 = constraintParams->m_jacobians[index].m_jacobian_J10; - - const dMatrix& invInertia0 = m_state0->m_invInertia; - const dMatrix& invInertia1 = m_state1->m_invInertia; - - const dFloat invMass0 = m_state0->m_invMass; - const dFloat invMass1 = m_state1->m_invMass; - - const dVector JMinvIM0linear(jacobian0.m_linear.Scale(invMass0)); - const dVector JMinvIM1linear(jacobian1.m_linear.Scale(invMass1)); - const dVector JMinvIM0angular = invInertia0.UnrotateVector(jacobian0.m_angular); - const dVector JMinvIM1angular = invInertia1.UnrotateVector(jacobian1.m_angular); - const dVector tmpDiag(JMinvIM0linear * jacobian0.m_linear + JMinvIM0angular * jacobian0.m_angular + - JMinvIM1linear * jacobian1.m_linear + JMinvIM1angular * jacobian1.m_angular); - - dFloat invEffectiveMass = (tmpDiag[0] + tmpDiag[1] + tmpDiag[2]); - springConst *= invEffectiveMass; - damperConst *= invEffectiveMass; - -springConst *= 2.0f; -damperConst *= 0.5f; - - const dFloat timestep = constraintParams->m_timestep; - - //at = [- ks (x2 - x1) - kd * (v2 - v1) - dt * ks * (v2 - v1)] / [1 + dt * kd + dt * dt * ks] - dFloat accel = springConst * posit + damperConst * speed + timestep * springConst * speed; - // yes I know this is the correct implicit term, but made the behavior too soft, so I am fudging it - //dFloat den = dFloat(1.0f) + timestep * kd + timestep * ksd; - //dFloat den = timestep * damperConst + timestep * ksd; - dFloat den = 0.25f * timestep * (timestep * springConst + damperConst); - - constraintParams->m_jointAccel[index] = - accel; - constraintParams->m_diagonalRegularizer[index] = den; -*/ - - dAssert(constraintParams->m_count > 0); - const int index = constraintParams->m_count - 1; - const dJacobian &jacobian0 = constraintParams->m_jacobians[index].m_jacobian_J01; - const dJacobian &jacobian1 = constraintParams->m_jacobians[index].m_jacobian_J10; - - const dMatrix& invInertia0 = m_state0->m_invInertia; - const dMatrix& invInertia1 = m_state1->m_invInertia; - - const dFloat invMass0 = m_state0->m_invMass; - const dFloat invMass1 = m_state1->m_invMass; - - const dVector JMinvIM0linear(jacobian0.m_linear.Scale(invMass0)); - const dVector JMinvIM1linear(jacobian1.m_linear.Scale(invMass1)); - const dVector JMinvIM0angular = invInertia0.UnrotateVector(jacobian0.m_angular); - const dVector JMinvIM1angular = invInertia1.UnrotateVector(jacobian1.m_angular); - const dVector tmpDiag(JMinvIM0linear * jacobian0.m_linear + JMinvIM0angular * jacobian0.m_angular + - JMinvIM1linear * jacobian1.m_linear + JMinvIM1angular * jacobian1.m_angular); - - return tmpDiag[0] + tmpDiag[1] + tmpDiag[2]; -} - -/* -dFloat dComplementaritySolver::dBilateralJoint::CalculateRowZeroAccelaration (dParamInfo* const constraintParams) const -{ - const int i = constraintParams->m_count - 1; - dAssert (i >= 0); - - const dVector& omega0 = m_state0->GetOmega(); - const dVector& omega1 = m_state1->GetOmega(); - const dVector& veloc0 = m_state0->GetVelocity(); - const dVector& veloc1 = m_state1->GetVelocity(); - dVector accel(constraintParams->m_jacobians[i].m_jacobian_J01.m_linear * veloc0 + - constraintParams->m_jacobians[i].m_jacobian_J01.m_angular * omega0 + - constraintParams->m_jacobians[i].m_jacobian_J10.m_linear * veloc1 + - constraintParams->m_jacobians[i].m_jacobian_J10.m_angular * omega1); - return -(accel.m_x + accel.m_y + accel.m_z) * constraintParams->m_timestepInv; -} -*/ - -dFloat dComplementaritySolver::dBilateralJoint::CalculateAngle (const dVector& planeDir, const dVector& cosDir, const dVector& sinDir) const -{ - dFloat cosAngle = planeDir.DotProduct3(cosDir); - dFloat sinAngle = sinDir.DotProduct3(planeDir.CrossProduct(cosDir)); - return dAtan2(sinAngle, cosAngle); -} - -/* -void dComplementaritySolver::dBilateralJoint::AddAngularRowJacobian (dParamInfo* const constraintParams, const dVector& dir0, const dVector& dir1, dFloat accelerationRatio) -{ - int index = constraintParams->m_count; - dJacobian &jacobian0 = constraintParams->m_jacobians[index].m_jacobian_IM0; - - jacobian0.m_linear[0] = 0.0f; - jacobian0.m_linear[1] = 0.0f; - jacobian0.m_linear[2] = 0.0f; - jacobian0.m_linear[3] = 0.0f; - jacobian0.m_angular[0] = dir0.m_x; - jacobian0.m_angular[1] = dir0.m_y; - jacobian0.m_angular[2] = dir0.m_z; - jacobian0.m_angular[3] = 0.0f; - - dJacobian &jacobian1 = constraintParams->m_jacobians[index].m_jacobian_IM1; - jacobian1.m_linear[0] = 0.0f; - jacobian1.m_linear[1] = 0.0f; - jacobian1.m_linear[2] = 0.0f; - jacobian1.m_linear[3] = 0.0f; - jacobian1.m_angular[0] = dir1.m_x; - jacobian1.m_angular[1] = dir1.m_y; - jacobian1.m_angular[2] = dir1.m_z; - jacobian1.m_angular[3] = 0.0f; - - m_rowIsMotor[index] = true; - m_motorAcceleration[index] = accelerationRatio; - constraintParams->m_jointAccel[index] = 0.0f; - constraintParams->m_jointLowFriction[index] = D_COMPLEMENTARITY_MIN_FRICTION_BOUND; - constraintParams->m_jointHighFriction[index] = D_COMPLEMENTARITY_MAX_FRICTION_BOUND; - constraintParams->m_count = index + 1; -} -*/ - -void dComplementaritySolver::dBilateralJoint::JointAccelerations (dJointAccelerationDecriptor* const params) -{ - dJacobianColum* const jacobianColElements = params->m_colMatrix; - dJacobianPair* const jacobianRowElements = params->m_rowMatrix; - - const dVector& bodyVeloc0 = m_state0->m_veloc; - const dVector& bodyOmega0 = m_state0->m_omega; - const dVector& bodyVeloc1 = m_state1->m_veloc; - const dVector& bodyOmega1 = m_state1->m_omega; - - dFloat timestep = params->m_timeStep; - dFloat kd = COMPLEMENTARITY_VEL_DAMP * dFloat (4.0f); - dFloat ks = COMPLEMENTARITY_POS_DAMP * dFloat (0.25f); - for (int k = 0; k < params->m_rowsCount; k ++) { - if (m_rowIsMotor[k]) { - jacobianColElements[k].m_coordenateAccel = m_motorAcceleration[k] + jacobianColElements[k].m_deltaAccel; - } else { - const dJacobianPair& Jt = jacobianRowElements[k]; - dVector relVeloc (Jt.m_jacobian_J01.m_linear * bodyVeloc0 + - Jt.m_jacobian_J01.m_angular * bodyOmega0 + - Jt.m_jacobian_J10.m_linear * bodyVeloc1 + - Jt.m_jacobian_J10.m_angular * bodyOmega1); - - dFloat vRel = relVeloc.m_x + relVeloc.m_y + relVeloc.m_z; - dFloat aRel = jacobianColElements[k].m_deltaAccel; - dFloat ksd = timestep * ks; - dFloat relPosit = 0.0f - vRel * timestep * params->m_firstPassCoefFlag; - - dFloat num = ks * relPosit - kd * vRel - ksd * vRel; - dFloat den = dFloat (1.0f) + timestep * kd + timestep * ksd; - dFloat aRelErr = num / den; - jacobianColElements[k].m_coordenateAccel = aRelErr + aRel; - } - } -} - -int dComplementaritySolver::dFrictionLessContactJoint::CompareContact (const dContact* const contactA, const dContact* const contactB, void* dommy) -{ - if (contactA->m_point[0] < contactB->m_point[0]) { - return -1; - } else if (contactA->m_point[0] > contactB->m_point[0]) { - return 1; - } else { - return 0; - } -} - -int dComplementaritySolver::dFrictionLessContactJoint::ReduceContacts (int count, dContact* const contacts, dFloat tol) -{ - int mask[D_MAX_PLACEMENT_CONTACTS]; - int index = 0; - int packContacts = 0; - dFloat window = tol; - dFloat window2 = window * window; - memset (mask, 0, size_t (count)); - dSort (contacts, count, CompareContact, NULL); - dAssert (count <= D_MAX_PLACEMENT_CONTACTS); - for (int i = 0; i < count; i ++) { - if (!mask[i]) { - dFloat val = contacts[i].m_point[index] + window; - for (int j = i + 1; (j < count) && (contacts[j].m_point[index] < val) ; j ++) { - if (!mask[j]) { - dVector dp (contacts[j].m_point - contacts[i].m_point); - dFloat dist2 = dp.DotProduct3(dp); - if (dist2 < window2) { - mask[j] = 1; - packContacts = 1; - } - } - } - } - } - - if (packContacts) { - int j = 0; - for (int i = 0; i < count; i ++) { - dAssert (i < D_MAX_PLACEMENT_CONTACTS); - if (!mask[i]) { - contacts[j] = contacts[i]; - j ++; - } - } - count = j; - } - return count; -} - -void dComplementaritySolver::dFrictionLessContactJoint::SetContacts (int count, dContact* const contacts, dFloat restitution) -{ - dFloat tol = 5.0e-3f; - count = ReduceContacts(count, contacts, tol); - while (count > D_MAX_PRAM_INFO_SIZE) { - tol *= 2.0f; - count = ReduceContacts(count, contacts, tol); - } - - m_count = count; - m_restitution = restitution; - memcpy (m_contacts, contacts, count * sizeof (dContact)); -} - -void dComplementaritySolver::dFrictionLessContactJoint::JacobianDerivative (dParamInfo* const constraintParams) -{ - for (int i = 0; i < m_count; i ++) { - AddLinearRowJacobian(constraintParams, m_contacts[i].m_point, m_contacts[i].m_point); - dAssert(0); -/* - dVector velocError (pointData.m_veloc1 - pointData.m_veloc0); - //dFloat restitution = 0.05f; - dFloat relVelocErr = velocError.DotProduct3(m_contacts[i].m_normal); - dFloat penetration = 0.0f; - dFloat penetrationStiffness = 0.0f; - dFloat penetrationVeloc = penetration * penetrationStiffness; - - if (relVelocErr > dFloat(1.0e-3f)) { - relVelocErr *= (m_restitution + dFloat (1.0f)); - } - - constraintParams->m_normalIndex[i] = 0; - constraintParams->m_frictionCallback[index] = NULL; - constraintParams->m_jointLowFrictionCoef[i] = dFloat (0.0f); - constraintParams->m_jointAccel[i] = dMax (dFloat (-4.0f), relVelocErr + penetrationVeloc) * constraintParams->m_timestepInv; -*/ - } -} - -void dComplementaritySolver::dFrictionLessContactJoint::JointAccelerations (dJointAccelerationDecriptor* const params) -{ - dJacobianPair* const rowMatrix = params->m_rowMatrix; - dJacobianColum* const jacobianColElements = params->m_colMatrix; - - const dVector& bodyVeloc0 = m_state0->GetVelocity(); - const dVector& bodyOmega0 = m_state0->GetOmega(); - const dVector& bodyVeloc1 = m_state1->GetVelocity(); - const dVector& bodyOmega1 = m_state1->GetOmega(); - - int count = params->m_rowsCount; - - dAssert (params->m_timeStep > dFloat (0.0f)); - for (int k = 0; k < count; k ++) { - const dJacobianPair& Jt = rowMatrix[k]; - dJacobianColum& element = jacobianColElements[k]; - - dVector relVeloc (Jt.m_jacobian_J01.m_linear * bodyVeloc0 + Jt.m_jacobian_J01.m_angular * bodyOmega0 + Jt.m_jacobian_J10.m_linear * bodyVeloc1 + Jt.m_jacobian_J10.m_angular * bodyOmega1); - - dFloat vRel = relVeloc.m_x + relVeloc.m_y + relVeloc.m_z; - dFloat aRel = element.m_deltaAccel; - //dFloat restitution = (vRel <= 0.0f) ? 1.05f : 1.0f; - dFloat restitution = (vRel <= 0.0f) ? (dFloat (1.0f) + m_restitution) : dFloat(1.0f); - - vRel *= restitution; - vRel = dMin (dFloat (4.0f), vRel); - element.m_coordenateAccel = (aRel - vRel * params->m_invTimeStep); - } -} - -int dComplementaritySolver::BuildJacobianMatrix (int jointCount, dBilateralJoint** const jointArray, dFloat timestep, dJacobianPair* const jacobianArray, dJacobianColum* const jacobianColumnArray, int maxRowCount) -{ - int rowCount = 0; - - dParamInfo constraintParams; - constraintParams.m_timestep = timestep; - constraintParams.m_timestepInv = 1.0f / timestep; - - // calculate Jacobian derivative for each active joint - for (int j = 0; j < jointCount; j ++) { - dBilateralJoint* const joint = jointArray[j]; - constraintParams.m_count = 0; - joint->JacobianDerivative (&constraintParams); - - int dofCount = constraintParams.m_count; - joint->m_count = dofCount; - joint->m_start = rowCount; - - // complete the derivative matrix for this joint - int index = joint->m_start; - dBodyState* const state0 = joint->m_state0; - dBodyState* const state1 = joint->m_state1; - - const dMatrix& invInertia0 = state0->m_invInertia; - const dMatrix& invInertia1 = state1->m_invInertia; - - dFloat invMass0 = state0->m_invMass; - dFloat invMass1 = state1->m_invMass; - dFloat weight = 0.9f; - - for (int i = 0; i < dofCount; i ++) { - dJacobianPair* const row = &jacobianArray[index]; - dJacobianColum* const col = &jacobianColumnArray[index]; - jacobianArray[rowCount] = constraintParams.m_jacobians[i]; - - dVector JMinvIM0linear (row->m_jacobian_J01.m_linear.Scale (invMass0)); - dVector JMinvIM1linear (row->m_jacobian_J10.m_linear.Scale (invMass1)); - dVector JMinvIM0angular = invInertia0.UnrotateVector(row->m_jacobian_J01.m_angular); - dVector JMinvIM1angular = invInertia1.UnrotateVector(row->m_jacobian_J10.m_angular); - - dVector tmpDiag (JMinvIM0linear * row->m_jacobian_J01.m_linear + JMinvIM0angular * row->m_jacobian_J01.m_angular + JMinvIM1linear * row->m_jacobian_J10.m_linear + JMinvIM1angular * row->m_jacobian_J10.m_angular); - dVector tmpAccel (JMinvIM0linear * state0->m_externalForce + JMinvIM0angular * state0->m_externalTorque + JMinvIM1linear * state1->m_externalForce + JMinvIM1angular * state1->m_externalTorque); - dFloat extenalAcceleration = -(tmpAccel[0] + tmpAccel[1] + tmpAccel[2]); - - col->m_diagDamp = 1.0f; - col->m_coordenateAccel = constraintParams.m_jointAccel[i]; - col->m_normalIndex = constraintParams.m_normalIndex[i]; - col->m_frictionCallback = constraintParams.m_frictionCallback[i]; - col->m_jointLowFriction = constraintParams.m_jointLowFrictionCoef[i]; - col->m_jointHighFriction = constraintParams.m_jointHighFrictionCoef[i]; - - col->m_deltaAccel = extenalAcceleration; - col->m_coordenateAccel += extenalAcceleration; - - col->m_force = joint->m_jointFeebackForce[i] * weight; - - dFloat stiffness = COMPLEMENTARITY_PSD_DAMP_TOL * col->m_diagDamp; - dFloat diag = (tmpDiag[0] + tmpDiag[1] + tmpDiag[2]); - dAssert (diag > dFloat (0.0f)); - col->m_diagDamp = diag * stiffness; - - diag *= (dFloat(1.0f) + stiffness); - col->m_invDJMinvJt = dFloat(1.0f) / diag; - index ++; - rowCount ++; - dAssert (rowCount < maxRowCount); - } - } - return rowCount; -} - -void dComplementaritySolver::CalculateReactionsForces (int bodyCount, dBodyState** const bodyArray, int jointCount, dBilateralJoint** const jointArray, dFloat timestepSrc, dJacobianPair* const jacobianArray, dJacobianColum* const jacobianColumnArray) -{ - dJacobian stateVeloc[COMPLEMENTARITY_STACK_ENTRIES]; - dJacobian internalForces [COMPLEMENTARITY_STACK_ENTRIES]; - - int stateIndex = 0; - dVector zero(dFloat (0.0f)); - for (int i = 0; i < bodyCount; i ++) { - dBodyState* const state = bodyArray[i]; - stateVeloc[stateIndex].m_linear = state->m_veloc; - stateVeloc[stateIndex].m_angular = state->m_omega; - - internalForces[stateIndex].m_linear = zero; - internalForces[stateIndex].m_angular = zero; - - state->m_myIndex = stateIndex; - stateIndex ++; - dAssert (stateIndex < int (sizeof (stateVeloc)/sizeof (stateVeloc[0]))); - } - - for (int i = 0; i < jointCount; i ++) { - dJacobian y0; - dJacobian y1; - y0.m_linear = zero; - y0.m_angular = zero; - y1.m_linear = zero; - y1.m_angular = zero; - dBilateralJoint* const constraint = jointArray[i]; - int first = constraint->m_start; - int count = constraint->m_count; - for (int j = 0; j < count; j ++) { - dJacobianPair* const row = &jacobianArray[j + first]; - const dJacobianColum* const col = &jacobianColumnArray[j + first]; - dFloat val = col->m_force; - y0.m_linear += row->m_jacobian_J01.m_linear.Scale(val); - y0.m_angular += row->m_jacobian_J01.m_angular.Scale(val); - y1.m_linear += row->m_jacobian_J10.m_linear.Scale(val); - y1.m_angular += row->m_jacobian_J10.m_angular.Scale(val); - } - int m0 = constraint->m_state0->m_myIndex; - int m1 = constraint->m_state1->m_myIndex; - internalForces[m0].m_linear += y0.m_linear; - internalForces[m0].m_angular += y0.m_angular; - internalForces[m1].m_linear += y1.m_linear; - internalForces[m1].m_angular += y1.m_angular; - } - - - dFloat invTimestepSrc = dFloat (1.0f) / timestepSrc; - dFloat invStep = dFloat (0.25f); - dFloat timestep = timestepSrc * invStep; - dFloat invTimestep = invTimestepSrc * dFloat (4.0f); - - int maxPasses = 5; - dFloat firstPassCoef = dFloat (0.0f); - dFloat maxAccNorm = dFloat (1.0e-2f); - - for (int step = 0; step < 4; step ++) { - dJointAccelerationDecriptor joindDesc; - joindDesc.m_timeStep = timestep; - joindDesc.m_invTimeStep = invTimestep; - joindDesc.m_firstPassCoefFlag = firstPassCoef; - - for (int i = 0; i < jointCount; i ++) { - dBilateralJoint* const constraint = jointArray[i]; - joindDesc.m_rowsCount = constraint->m_count; - joindDesc.m_rowMatrix = &jacobianArray[constraint->m_start]; - joindDesc.m_colMatrix = &jacobianColumnArray[constraint->m_start]; - constraint->JointAccelerations (&joindDesc); - } - firstPassCoef = dFloat (1.0f); - - dFloat accNorm = dFloat (1.0e10f); - for (int passes = 0; (passes < maxPasses) && (accNorm > maxAccNorm); passes ++) { - accNorm = dFloat (0.0f); - for (int i = 0; i < jointCount; i ++) { - - dBilateralJoint* const constraint = jointArray[i]; - int index = constraint->m_start; - int rowsCount = constraint->m_count; - int m0 = constraint->m_state0->m_myIndex; - int m1 = constraint->m_state1->m_myIndex; - - dVector linearM0 (internalForces[m0].m_linear); - dVector angularM0 (internalForces[m0].m_angular); - dVector linearM1 (internalForces[m1].m_linear); - dVector angularM1 (internalForces[m1].m_angular); - - dBodyState* const state0 = constraint->m_state0; - dBodyState* const state1 = constraint->m_state1; - const dMatrix& invInertia0 = state0->m_invInertia; - const dMatrix& invInertia1 = state1->m_invInertia; - dFloat invMass0 = state0->m_invMass; - dFloat invMass1 = state1->m_invMass; - - for (int k = 0; k < rowsCount; k ++) { - dJacobianPair* const row = &jacobianArray[index]; - dJacobianColum* const col = &jacobianColumnArray[index]; - - dVector JMinvIM0linear (row->m_jacobian_J01.m_linear.Scale (invMass0)); - dVector JMinvIM1linear (row->m_jacobian_J10.m_linear.Scale (invMass1)); - dVector JMinvIM0angular = invInertia0.UnrotateVector(row->m_jacobian_J01.m_angular); - dVector JMinvIM1angular = invInertia1.UnrotateVector(row->m_jacobian_J10.m_angular); - dVector acc (JMinvIM0linear * linearM0 + JMinvIM0angular * angularM0 + JMinvIM1linear * linearM1 + JMinvIM1angular * angularM1); - - dFloat a = col->m_coordenateAccel - acc.m_x - acc.m_y - acc.m_z - col->m_force * col->m_diagDamp; - dFloat f = col->m_force + col->m_invDJMinvJt * a; - - dFloat lowerFrictionForce = col->m_jointLowFriction; - dFloat upperFrictionForce = col->m_jointHighFriction; - - if (f > upperFrictionForce) { - a = dFloat (0.0f); - f = upperFrictionForce; - } else if (f < lowerFrictionForce) { - a = dFloat (0.0f); - f = lowerFrictionForce; - } - - accNorm = dMax (accNorm, dAbs (a)); - dFloat prevValue = f - col->m_force; - col->m_force = f; - - linearM0 += row->m_jacobian_J01.m_linear.Scale (prevValue); - angularM0 += row->m_jacobian_J01.m_angular.Scale (prevValue); - linearM1 += row->m_jacobian_J10.m_linear.Scale (prevValue); - angularM1 += row->m_jacobian_J10.m_angular.Scale (prevValue); - index ++; - } - internalForces[m0].m_linear = linearM0; - internalForces[m0].m_angular = angularM0; - internalForces[m1].m_linear = linearM1; - internalForces[m1].m_angular = angularM1; - } - } - - for (int i = 0; i < bodyCount; i ++) { - dBodyState* const state = bodyArray[i]; - //int index = state->m_myIndex; - dAssert (state->m_myIndex == i); - dVector force (state->m_externalForce + internalForces[i].m_linear); - dVector torque (state->m_externalTorque + internalForces[i].m_angular); - state->IntegrateForce(timestep, force, torque); - } - } - - for (int i = 0; i < jointCount; i ++) { - dBilateralJoint* const constraint = jointArray[i]; - int first = constraint->m_start; - int count = constraint->m_count; - for (int j = 0; j < count; j ++) { - const dJacobianColum* const col = &jacobianColumnArray[j + first]; - dFloat val = col->m_force; - constraint->m_jointFeebackForce[j] = val; - } - } - - for (int i = 0; i < jointCount; i ++) { - dBilateralJoint* const constraint = jointArray[i]; - constraint->UpdateSolverForces (jacobianArray); - } - - for (int i = 0; i < bodyCount; i ++) { - dBodyState* const state = bodyArray[i]; - dAssert (state->m_myIndex == i); - state->ApplyNetForceAndTorque (invTimestepSrc, stateVeloc[i].m_linear, stateVeloc[i].m_angular); - } -} - diff --git a/thirdparty/src/newton/dMath/dLinearAlgebra.h b/thirdparty/src/newton/dMath/dLinearAlgebra.h deleted file mode 100644 index 827d26c81..000000000 --- a/thirdparty/src/newton/dMath/dLinearAlgebra.h +++ /dev/null @@ -1,294 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dStdAfxMath.h" -#include "dMathDefines.h" -#include "dVector.h" -#include "dMatrix.h" -#include "dQuaternion.h" - - -#ifndef __D_LINEAR_ALGEBRA_H__ -#define __D_LINEAR_ALGEBRA_H__ - -#ifdef _MSC_VER - #pragma warning (disable: 4100) //unreferenced formal parameter -#endif - - -#define D_MAX_PRAM_INFO_SIZE 16 -#define D_MAX_PLACEMENT_CONTACTS 128 -#define D_COMPLEMENTARITY_MAX_FRICTION_BOUND dFloat(1.0e15f) -#define D_COMPLEMENTARITY_MIN_FRICTION_BOUND (-D_COMPLEMENTARITY_MAX_FRICTION_BOUND) - - -class dSymmetricBiconjugateGradientSolve -{ - public: - dSymmetricBiconjugateGradientSolve () {} - virtual ~dSymmetricBiconjugateGradientSolve () {} - - virtual dFloat64 Solve (int size, dFloat64 tolerance, dFloat64* const x, const dFloat64* const b) const; - - protected: - virtual void MatrixTimeVector (dFloat64* const out, const dFloat64* const v) const = 0; - virtual bool InversePrecoditionerTimeVector (dFloat64* const out, const dFloat64* const v) const = 0; - - private: - dFloat64 DotProduct (int size, const dFloat64* const b, const dFloat64* const c) const; - void ScaleAdd (int size, dFloat64* const a, const dFloat64* const b, dFloat64 scale, const dFloat64* const c) const; - void Sub (int size, dFloat64* const a, const dFloat64* const b, const dFloat64* const c) const; -}; - -class dComplementaritySolver -{ - public: - class dBodyState; - class dBilateralJoint; - - class dContact - { - public: - dContact() - :m_point(0.0f) - ,m_normal(0.0f) - { - } - - dVector m_point; - dVector m_normal; - }; - - class dJacobian - { - public: - dJacobian () - :m_linear(0.0f) - ,m_angular(0.0f) - { - } - - dJacobian (const dVector& linear, const dVector& angular) - :m_linear(linear) - ,m_angular(angular) - { - } - - dVector m_linear; - dVector m_angular; - }; - - class dJacobianPair - { - public: - dJacobian m_jacobian_J01; - dJacobian m_jacobian_J10; - }; - - class dJacobianColum - { - public: - dFloat m_force; - dFloat m_diagDamp; - dFloat m_deltaAccel; - dFloat m_invDJMinvJt; - dFloat m_coordenateAccel; - dFloat m_jointLowFriction; - dFloat m_jointHighFriction; - dBilateralJoint* m_frictionCallback; - int m_normalIndex; - }; - - class dParamInfo - { - public: - dJacobianPair m_jacobians[D_MAX_PRAM_INFO_SIZE]; - dFloat m_jointAccel[D_MAX_PRAM_INFO_SIZE]; - dFloat m_jointLowFrictionCoef[D_MAX_PRAM_INFO_SIZE]; - dFloat m_jointHighFrictionCoef[D_MAX_PRAM_INFO_SIZE]; - dFloat m_diagonalRegularizer[D_MAX_PRAM_INFO_SIZE]; - int m_normalIndex[D_MAX_PRAM_INFO_SIZE]; - dBilateralJoint* m_frictionCallback[D_MAX_PRAM_INFO_SIZE]; - dFloat m_timestep; - dFloat m_timestepInv; - int m_count; - }; - - class dJointAccelerationDecriptor - { - public: - int m_rowsCount; - dFloat m_timeStep; - dFloat m_invTimeStep; - dFloat m_firstPassCoefFlag; - dJacobianPair* m_rowMatrix; - dJacobianColum* m_colMatrix; - }; - - class dBilateralJoint - { - public: - dBilateralJoint() - :m_state0(NULL) - ,m_state1(NULL) - ,m_ordinals(0x050403020100ll) - ,m_start(0) - ,m_count(0) - ,m_dof(0) - { - memset(m_rowIsMotor, 0, sizeof (m_rowIsMotor)); - memset(m_motorAcceleration, 0, sizeof (m_motorAcceleration)); - memset(m_jointFeebackForce, 0, sizeof (m_jointFeebackForce)); - } - - virtual ~dBilateralJoint(){} - - virtual void Init (dBodyState* const state0, dBodyState* const state1); - virtual void JacobianDerivative (dParamInfo* const constraintParams) = 0; - virtual void UpdateSolverForces (const dJacobianPair* const jacobians) const = 0; - virtual void JointAccelerations (dJointAccelerationDecriptor* const accelParam); - virtual void SpecialSolverFrictionCallback(const dFloat* const force, dFloat* const lowFriction, dFloat* const highFriction) const {} - - void AddAngularRowJacobian (dParamInfo* const constraintParams, const dVector& dir, dFloat jointAngle); - void AddLinearRowJacobian (dParamInfo* const constraintParams, const dVector& pivot, const dVector& dir); - void AddContactRowJacobian (dParamInfo* const constraintParams, const dVector& pivot, const dVector& dir, dFloat restitution); - - dFloat GetRowAccelaration(dParamInfo* const constraintParams) const; - void SetRowAccelaration(dParamInfo* const constraintParams, dFloat accel); - - dFloat CalculateMassMatrixDiagonal(dParamInfo* const constraintParams) const; - dFloat CalculateAngle (const dVector& planeDir, const dVector& cosDir, const dVector& sinDir) const; - - dFloat m_motorAcceleration[D_MAX_PRAM_INFO_SIZE]; - dFloat m_jointFeebackForce[D_MAX_PRAM_INFO_SIZE]; - int m_rowIsMotor[D_MAX_PRAM_INFO_SIZE]; - dBodyState* m_state0; - dBodyState* m_state1; - union - { - long long m_ordinals; - char m_sourceJacobianIndex[8]; - }; - int m_start; - int m_count; - int m_dof; - - friend class dBodyState; - friend class dComplementaritySolver; - }; - - class dFrictionLessContactJoint: public dBilateralJoint - { - public: - dFrictionLessContactJoint() - :dBilateralJoint() - ,m_restitution(0.0f) - ,m_count (0) - {} - virtual ~dFrictionLessContactJoint(){} - - void SetContacts (int count, dContact* const contacts, dFloat restitution); - - protected: - void UpdateSolverForces (const dJacobianPair* const jacobians) const {} - - static inline int CompareContact (const dContact* const contactA, const dContact* const contactB, void* dommy); - int ReduceContacts (int count, dContact* const contacts, dFloat tol); - void JacobianDerivative (dParamInfo* const constraintParams); - void JointAccelerations (dJointAccelerationDecriptor* const params); - - dContact m_contacts[D_MAX_PRAM_INFO_SIZE]; - dFloat m_restitution; - int m_count; - }; - - class dBodyState - { - public: - dBodyState(); - virtual ~dBodyState() {} - - dFloat GetMass () const; - void SetMass (dFloat mass); - - dFloat GetInvMass () const; - - void SetInertia (dFloat Ixx, dFloat Iyy, dFloat Izz); - void GetInertia (dFloat& Ixx, dFloat& Iyy, dFloat& Izz) const; - - const dMatrix& GetInertia() const; - const dMatrix& GetInvInertia() const; - - void SetVeloc (const dVector& veloc); - void SetOmega (const dVector& omega); - const dVector& GetOmega() const; - const dVector& GetVelocity() const; - dVector CalculatePointVelocity (const dVector& point) const; - - void UpdateInertia(); - - void SetMatrix (const dMatrix& matrix); - const dMatrix& GetMatrix () const; - - void SetLocalMatrix (const dMatrix& matrix); - const dMatrix& GetLocalMatrix () const; - - void SetForce (const dVector& force); - void SetTorque (const dVector& torque); - const dVector& GetForce () const; - const dVector& GetTorque () const; - - const dVector& GetCOM () const; - - void IntegrateVelocity (dFloat timestep); - void IntegrateForce (dFloat timestep, const dVector& force, const dVector& torque); - - protected: - virtual void ApplyNetForceAndTorque (dFloat invTimestep, const dVector& veloc, const dVector& omega); - - dMatrix m_matrix; - dMatrix m_localFrame; - dMatrix m_inertia; - dMatrix m_invInertia; - - dVector m_localInertia; - dVector m_localInvInertia; - - dVector m_veloc; - dVector m_omega; - dVector m_externalForce; - dVector m_externalTorque; - dVector m_globalCentreOfMass; - - dFloat m_mass; - dFloat m_invMass; - int m_myIndex; - - friend class dBilateralJoint; - friend class dComplementaritySolver; - }; - - public: - dComplementaritySolver() {}; - virtual ~dComplementaritySolver() {}; - - virtual int GetActiveJoints (dBilateralJoint** const jointArray, int bufferSize) - { - return 0; - } - - virtual int BuildJacobianMatrix (int jointCount, dBilateralJoint** const jointArray, dFloat timestep, dJacobianPair* const jacobianArray, dJacobianColum* const jacobianColumnArray, int maxRowCount); - virtual void CalculateReactionsForces (int bodyCount, dBodyState** const bodyArray, int jointCount, dBilateralJoint** const jointArray, dFloat timestep, dJacobianPair* const jacobianArray, dJacobianColum* const jacobianColumnArray); -}; - - -#endif - diff --git a/thirdparty/src/newton/dMath/dMathDefines.cpp b/thirdparty/src/newton/dMath/dMathDefines.cpp deleted file mode 100644 index 5a32e6788..000000000 --- a/thirdparty/src/newton/dMath/dMathDefines.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dStdAfxMath.h" -#include "dMathDefines.h" - - diff --git a/thirdparty/src/newton/dMath/dMathDefines.h b/thirdparty/src/newton/dMath/dMathDefines.h deleted file mode 100644 index 1b6b8a693..000000000 --- a/thirdparty/src/newton/dMath/dMathDefines.h +++ /dev/null @@ -1,925 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - - -#ifndef __dMathDefined__ -#define __dMathDefined__ - -#include <math.h> -#include <float.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <assert.h> - -#ifdef _MSC_VER - #include <malloc.h> - #include <windows.h> - #ifdef _DEBUG - #include <stdarg.h> - inline void dExpandTraceMessage (const char* const fmt, ...) - { - va_list v_args; - char text[4096]; - - text[0] = 0; - va_start (v_args, fmt); - vsprintf_s(text, fmt, v_args); - va_end (v_args); - - OutputDebugStringA (text); - } - - #define dTrace(x) \ - { \ - dExpandTraceMessage x; \ - } - #else - #define dTrace(x) - #endif -#else - #define dTrace(x) -#endif - -#if ( defined (_MSC_VER) || defined (__MINGW32__) || defined (__MINGW64__) ) - #include <crtdbg.h> - #define dAssert(x) _ASSERTE(x) -#else - #define dAssert(x) assert(x) -#endif - - - -#ifndef dFloat - #ifdef _NEWTON_USE_DOUBLE - typedef double dFloat; - #else - typedef float dFloat; - #endif -#endif - -#ifndef dFloat64 - typedef double dFloat64; -#endif - -// some constants -#define dPi dFloat (3.141592f) -#define dRadToDegree (dFloat (180.0f) / dPi) -#define dDegreeToRad (dFloat (1.0f) / dRadToDegree) - -// transcendental functions -#define dSqrt(x) dFloat (sqrt (dFloat(x))) -#define dCiel(x) dFloat (ceil (dFloat(x))) -#define dFloor(x) dFloat (floor (dFloat(x))) -#define dLog(x) dFloat (log (dFloat(x))) -#define dPow(x,y) dFloat (pow (dFloat(x), dFloat(y))) - -#define dSin(x) dFloat (sin (dFloat(x))) -#define dCos(x) dFloat (cos (dFloat(x))) -#define dTan(x) dFloat (tan (dFloat(x))) -#define dAsin(x) dFloat (asin (dFloat(x))) -#define dAcos(x) dFloat (acos (dFloat(x))) -#define dAtan(x) dFloat (atan (dFloat(x))) -#define dAtan2(x,y) dFloat (atan2 (dFloat(x), dFloat(y))) - - - -#ifdef D_PROFILER - #include <dProfiler.h> - - #define D_TRACKTIME() dProfilerZoneScoped(__FUNCTION__) - #define D_SET_TRACK_NAME(trackName) dProfilerSetTrackName(trackName) -#else - #define D_TRACKTIME() - #define D_SET_TRACK_NAME(trackName) -#endif - - -#define D_MSC_VECTOR_ALIGNMENT - -enum dEulerAngleOrder -{ - m_pitchYawRoll, - m_pitchRollYaw, - PYR = (0 << 8) + (1 << 4) + (2 << 0), - PRY = (0 << 8) + (2 << 4) + (1 << 0), - YPR = (1 << 8) + (0 << 4) + (2 << 0), - YRP = (1 << 8) + (2 << 4) + (0 << 0), - RYP = (2 << 8) + (1 << 4) + (0 << 0), - RPY = (2 << 8) + (0 << 4) + (1 << 0), -}; - -#define dAlloca(type,size) (type*) alloca ((size) * sizeof (type)) - -template <class T> -T dAbs(T A) -{ - // this is far faster than the standard function (does not mess with cpu rounding mode) - return (A >= T(0.0f)) ? A : -A; -} - -template <class T> -T dSign (T A) -{ - return (A >= T(0)) ? T(1) : T(-1); -} - -template <class T> -void dSwap(T& A, T& B) -{ - T tmp (A); - A = B; - B = tmp; -} - -template <class T> -T dMax(T A, T B) -{ - return (A > B) ? A : B; -} - -template <class T> -T dMin(T A, T B) -{ - return (A < B) ? A : B; -} - -template <class T> -T dClamp(T val, T min, T max) -{ - return dMax (min, dMin (max, val)); -} - -template <class T> -T dMod(T val, T mod) -{ - return T (fmod (T(val), T(mod))); -} - -template <class T> -void dSort (T* const array, int elements, int (*compare) (const T* const A, const T* const B, void* const context), void* const context = NULL) -{ - int stride = 8; - int stack[1024][2]; - - stack[0][0] = 0; - stack[0][1] = elements - 1; - int stackIndex = 1; - while (stackIndex) { - stackIndex --; - int lo = stack[stackIndex][0]; - int hi = stack[stackIndex][1]; - if ((hi - lo) > stride) { - int i = lo; - int j = hi; - T val (array[(lo + hi) >> 1]); - do { - while (compare (&array[i], &val, context) < 0) i ++; - while (compare (&array[j], &val, context) > 0) j --; - - if (i <= j) { - dSwap(array[i], array[j]); - i++; - j--; - } - } while (i <= j); - - if (i < hi) { - stack[stackIndex][0] = i; - stack[stackIndex][1] = hi; - stackIndex ++; - } - if (lo < j) { - stack[stackIndex][0] = lo; - stack[stackIndex][1] = j; - stackIndex ++; - } - dAssert (stackIndex < int (sizeof (stack) / (2 * sizeof (stack[0][0])))); - } - } - - stride = stride * 2; - if (elements < stride) { - stride = elements; - } - for (int i = 1; i < stride; i ++) { - if (compare (&array[0], &array[i], context) > 0) { - dSwap(array[0], array[i]); - } - } - - for (int i = 1; i < elements; i ++) { - int j = i; - T tmp (array[i]); - for (; compare (&array[j - 1], &tmp, context) > 0; j --) { - dAssert (j > 0); - array[j] = array[j - 1]; - } - array[j] = tmp; - } - -#ifdef _DEBUG - for (int i = 0; i < (elements - 1); i ++) { - dAssert (compare (&array[i], &array[i + 1], context) <= 0); - } -#endif -} - -// return dot product -template<class T> -T dDotProduct(int size, const T* const A, const T* const B) -{ - T val(0.0f); - for (int i = 0; i < size; i++) { - val = val + A[i] * B[i]; - } - return val; -} - -template<class T> -void dMatrixTimeVector(int size, const T* const matrix, const T* const v, T* const out) -{ - int stride = 0; - for (int i = 0; i < size; i++) { - out[i] = dDotProduct(size, &matrix[stride], v); - stride += size; - } -} - -template<class T> -bool dSolveGaussian(int size, T* const matrix, T* const b) -{ - for (int i = 0; i < size - 1; i++) { - const T* const rowI = &matrix[i * size]; - int m = i; - T maxVal(dAbs(rowI[i])); - for (int j = i + 1; j < size - 1; j++) { - T val(dAbs(matrix[size * j + i])); - if (val > maxVal) { - m = j; - maxVal = val; - } - } - - if (maxVal < T(1.0e-12f)) { - return false; - } - - if (m != i) { - T* const rowK = &matrix[m * size]; - T* const rowJ = &matrix[i * size]; - for (int j = 0; j < size; j++) { - dSwap(rowK[j], rowJ[j]); - } - dSwap(b[i], b[m]); - } - - T den = T(1.0f) / rowI[i]; - for (int k = i + 1; k < size; k++) { - T* const rowK = &matrix[size * k]; - T factor(-rowK[i] * den); - for (int j = i + 1; j < size; j++) { - rowK[j] += rowI[j] * factor; - } - rowK[i] = T(0.0f); - b[k] += b[i] * factor; - } - } - - for (int i = size - 1; i >= 0; i--) { - T acc(0); - T* const rowI = &matrix[i * size]; - for (int j = i + 1; j < size; j++) { - acc = acc + rowI[j] * b[j]; - } - b[i] = (b[i] - acc) / rowI[i]; - } - return true; -} - - -template<class T> -void dCholeskySolve(int size, int stride, const T* const choleskyMatrix, T* const x) -{ - int rowStart = 0; - for (int i = 0; i < size; i++) { - T acc(0.0f); - const T* const row = &choleskyMatrix[rowStart]; - for (int j = 0; j < i; j++) { - acc = acc + row[j] * x[j]; - } - x[i] = (x[i] - acc) / row[i]; - rowStart += stride; - } - - for (int i = size - 1; i >= 0; i--) { - T acc = 0.0f; - for (int j = i + 1; j < size; j++) { - acc = acc + choleskyMatrix[stride * j + i] * x[j]; - } - x[i] = (x[i] - acc) / choleskyMatrix[stride * i + i]; - } -} - -template<class T> -bool dCholeskyFactorization(int size, int stride, T* const matrix) -{ - T* const invDiagonal = dAlloca(T, size); - for (int i = 0; i < size; i++) { - T* const rowN = &matrix[stride * i]; - - int rowStart = 0; - for (int j = 0; j <= i; j++) { - T s(0.0f); - T* const rowJ = &matrix[rowStart]; - for (int k = 0; k < j; k++) { - s += rowN[k] * rowJ[k]; - } - - if (i == j) { - T diag = rowN[i] - s; - if (diag < T(1.0e-8f)) { - return false; - } - rowN[i] = T(sqrt(diag)); - invDiagonal[i] = T (1.0f) / rowN[i]; - } else { - //rowN[j] = ((T(1.0f) / rowJ[j]) * (rowN[j] - s)); - rowN[j] = invDiagonal[j] * (rowN[j] - s); - } - rowStart += stride; - } - } - return true; -} - -template<class T> -bool dTestPSDmatrix(int size, int stride, const T* const matrix) -{ - T* const copy = dAlloca(T, size * size); - int row = 0; - for (int i = 0; i < size; i ++) - { - memcpy (©[i * size], &matrix[row], size * sizeof (T)); - row += stride; - } - return dCholeskyFactorization(size, size, copy); -} - -template<class T> -void dPermuteRows(int size, int i, int j, T* const matrix, T* const choleskyMatrix, T* const x, T* const r, T* const low, T* const high, int* const permute) -{ - if (i != j) { - T* const matrixRowA = &matrix[size * i]; - T* const matrixRowB = &matrix[size * j]; - T* const choleskyRowA = &choleskyMatrix[size * i]; - T* const choleskyRowB = &choleskyMatrix[size * j]; - for (int k = 0; k < size; k++) { - dSwap(matrixRowA[k], matrixRowB[k]); - dSwap(choleskyRowA[k], choleskyRowB[k]); - } - - int stride = 0; - for (int k = 0; k < size; k++) { - dSwap(matrix[stride + i], matrix[stride + j]); - stride += size; - } - - dSwap(x[i], x[j]); - dSwap(r[i], r[j]); - dSwap(low[i], low[j]); - dSwap(high[i], high[j]); - dSwap(permute[i], permute[j]); - } -} - -template<class T> -void dCholeskyUpdate(int size, int row, int colum, T* const choleskyMatrix, T* const tmp, T* const reflexion) -{ - if (row != colum) { - dAssert(row < colum); - - for (int i = row; i < size; i++) { - T* const rowI = &choleskyMatrix[size * i]; - T mag(T(dFloat(0.0f))); - for (int j = i + 1; j < size; j++) { - mag += rowI[j] * rowI[j]; - reflexion[j] = rowI[j]; - } - if (mag > T(dFloat(1.0e-9f))) { - reflexion[i] = rowI[i] - T(sqrt(mag + rowI[i] * rowI[i])); - - T vMag2(mag + reflexion[i] * reflexion[i]); - T den(dFloat(1.0f) / T(sqrt(vMag2))); - for (int j = i; j < size; j++) { - reflexion[j] *= den; - } - - for (int j = i; j < size; j++) { - T acc(0.0f); - T* const rowJ = &choleskyMatrix[size * j]; - for (int k = i; k < size; k++) { - acc += rowJ[k] * reflexion[k]; - } - tmp[j] = acc * T(dFloat(2.0f)); - } - - for (int j = i + 1; j < size; j++) { - T* const rowJ = &choleskyMatrix[size * j]; - for (int k = i; k < size; k++) { - rowJ[k] -= tmp[j] * reflexion[k]; - } - } - rowI[i] -= tmp[i] * reflexion[i]; - } - - for (int k = i + 1; k < size; k++) { - rowI[k] = T(dFloat(0.0f)); - } - - if (rowI[i] < T(dFloat(0.0f))) { - for (int k = i; k < size; k++) { - choleskyMatrix[size * k + i] = -choleskyMatrix[size * k + i]; - } - } - } - for (int i = row; i < size; i++) { - choleskyMatrix[size * i + i] = dMax(choleskyMatrix[size * i + i], T(dFloat(1.0e-6f))); - } - } -} - -template<class T> -void dCalculateDelta_x(int size, T dir, int n, const T* const matrix, const T* const choleskyMatrix, T* const delta_x) -{ - const T* const row = &matrix[size * n]; - for (int i = 0; i < n; i++) { - delta_x[i] = -row[i] * dir; - } - dCholeskySolve(size, n, choleskyMatrix, delta_x); - delta_x[n] = dir; -} - -// calculate delta_r = A * delta_x -template<class T> -void dCalculateDelta_r(int size, int n, const T* const matrix, const T* const delta_x, T* const delta_r) -{ - int stride = n * size; - for (int i = n; i < size; i++) { - delta_r[i] = dDotProduct(size, &matrix[stride], delta_x); - stride += size; - } -} - - -// solve a general Linear complementary program (LCP) -// A * x = b + r -// subjected to constraints -// x(i) = low(i), if r(i) >= 0 -// x(i) = high(i), if r(i) <= 0 -// low(i) <= x(i) <= high(i), if r(i) == 0 -// -// return true is the system has a solution. -// in return -// x is the solution, -// r is return in vector b -// note: although the system is called LCP, the solve is far more general than a strict LCP -// to solve a strict LCP set the following -// low(i) = 0 -// high(i) = infinity. -// this the same as enforcing the constrain: x(i) * r(i) = 0 -template <class T> -bool dSolveDantzigLCP(int size, T* const matrix, T* const x, T* const b, T* const low, T* const high, T regularizer = T(1.e-4f)) -{ - T* const choleskyMatrix = dAlloca(T, size * size); - T* const x0 = dAlloca(T, size); - T* const r0 = dAlloca(T, size); - T* const delta_r = dAlloca(T, size); - T* const delta_x = dAlloca(T, size); - T* const tmp0 = dAlloca(T, size); - T* const tmp1 = dAlloca(T, size); - int* const permute = dAlloca(int, size); - - memcpy(choleskyMatrix, matrix, sizeof(T) * size * size); - bool pass = dCholeskyFactorization(size, choleskyMatrix); - while (!pass) { - int stride = 0; - for (int i = 0; i < size; i ++) { - matrix[stride] += matrix[stride] * regularizer; - stride += size + 1; - } - memcpy(choleskyMatrix, matrix, sizeof(T) * size * size); - pass = dCholeskyFactorization(size, choleskyMatrix); - } - - for (int i = 0; i < size; i++) { - T* const row = &choleskyMatrix[i * size]; - for (int j = i + 1; j < size; j++) { - row[j] = T(0.0f); - } - } - - int index = 0; - int count = size; - int clampedIndex = size; - for (int i = 0; i < size; i++) { - permute[i] = short(i); - r0[i] = -b[i]; - x0[i] = dFloat(0.0f); - delta_x[i] = T(dFloat(0.0f)); - delta_r[i] = T(dFloat(0.0f)); - } - - bool findInitialGuess = size >= 6; - if (findInitialGuess) { - int initialGuessCount = size; - for (int j = 0; (j < 5) && findInitialGuess; j++) { - - findInitialGuess = false; - for (int i = 0; i < initialGuessCount; i++) { - x0[i] = -r0[i]; - } - dCholeskySolve(size, initialGuessCount, choleskyMatrix, x0); - int permuteStart = initialGuessCount; - for (int i = 0; i < initialGuessCount; i++) { - T f = x0[i]; - if ((f < low[i]) || (f > high[i])) { - findInitialGuess = true; - x0[i] = T(dFloat(0.0f)); - dPermuteRows(size, i, initialGuessCount - 1, matrix, choleskyMatrix, x0, r0, low, high, permute); - permuteStart = dMin(permuteStart, i); - i--; - initialGuessCount--; - } - } - if (findInitialGuess) { - dCholeskyUpdate(size, permuteStart, size - 1, choleskyMatrix, tmp0, tmp1); - } - } - - if (initialGuessCount == size) { - for (int i = 0; i < size; i++) { - x[i] = x0[i]; - b[i] = T(dFloat(0.0f)); - } - return true; - } else { - if (!findInitialGuess) { - for (int i = 0; i < initialGuessCount; i++) { - r0[i] = T(dFloat(0.0f)); - } - for (int i = initialGuessCount; i < size; i++) { - r0[i] += dDotProduct(size, &matrix[i * size], x0); - } - index = initialGuessCount; - count = size - initialGuessCount; - } else { - //dAssert(0); - for (int i = 0; i < size; i++) { - x0[i] = dFloat(0.0f); - } - } - } - } - - while (count) { - bool loop = true; - bool calculateDelta_x = true; - - while (loop) { - loop = false; - T clamp_x(0.0f); - int swapIndex = -1; - - if (dAbs(r0[index]) > T(1.0e-12f)) { - if (calculateDelta_x) { - T dir(dFloat(1.0f)); - dCalculateDelta_x(size, dir, index, matrix, choleskyMatrix, delta_x); - } - - calculateDelta_x = true; - dCalculateDelta_r(size, index, matrix, delta_x, delta_r); - dAssert(delta_r[index] != T(dFloat(0.0f))); - dAssert(dAbs(delta_x[index]) == T(1.0f)); - delta_r[index] = (delta_r[index] == T(dFloat(0.0f))) ? T(dFloat(1.0e-12f)) : delta_r[index]; - - T s = -r0[index] / delta_r[index]; - dAssert(dAbs(s) >= T(dFloat(0.0f))); - - for (int i = 0; i <= index; i++) { - T x1 = x0[i] + s * delta_x[i]; - if (x1 > high[i]) { - swapIndex = i; - clamp_x = high[i]; - s = (high[i] - x0[i]) / delta_x[i]; - } else if (x1 < low[i]) { - swapIndex = i; - clamp_x = low[i]; - s = (low[i] - x0[i]) / delta_x[i]; - } - } - dAssert(dAbs(s) >= T(dFloat(0.0f))); - - for (int i = clampedIndex; (i < size) && (s > T(1.0e-12f)); i++) { - T r1 = r0[i] + s * delta_r[i]; - if ((r1 * r0[i]) < T(dFloat(0.0f))) { - dAssert(dAbs(delta_r[i]) > T(dFloat(0.0f))); - T s1 = -r0[i] / delta_r[i]; - dAssert(dAbs(s1) >= T(dFloat(0.0f))); - dAssert(dAbs(s1) <= dAbs(s)); - if (dAbs(s1) < dAbs(s)) { - s = s1; - swapIndex = i; - } - } - } - - for (int i = 0; i < size; i++) { - dAssert((x0[i] + dAbs(x0[i]) * T(dFloat(1.0e-4f))) >= low[i]); - dAssert((x0[i] - dAbs(x0[i]) * T(dFloat(1.0e-4f))) <= high[i]); - - x0[i] += s * delta_x[i]; - r0[i] += s * delta_r[i]; - - dAssert((x0[i] + dFloat(1.0f)) >= low[i]); - dAssert((x0[i] - dFloat(1.0f)) <= high[i]); - } - } - - if (swapIndex == -1) { - r0[index] = T(dFloat(0.0f)); - delta_r[index] = T(dFloat(0.0f)); - index++; - count--; - loop = false; - } else if (swapIndex == index) { - count--; - clampedIndex--; - x0[index] = clamp_x; - dPermuteRows(size, index, clampedIndex, matrix, choleskyMatrix, x0, r0, low, high, permute); - dCholeskyUpdate(size, index, clampedIndex, choleskyMatrix, tmp0, tmp1); - - loop = count ? true : false; - } else if (swapIndex > index) { - loop = true; - r0[swapIndex] = T(dFloat(0.0f)); - dAssert(swapIndex < size); - dAssert(clampedIndex <= size); - if (swapIndex < clampedIndex) { - count--; - clampedIndex--; - dPermuteRows(size, clampedIndex, swapIndex, matrix, choleskyMatrix, x0, r0, low, high, permute); - dCholeskyUpdate(size, swapIndex, clampedIndex, choleskyMatrix, tmp0, tmp1); - dAssert(clampedIndex >= index); - } else { - count++; - dAssert(clampedIndex < size); - dPermuteRows(size, clampedIndex, swapIndex, matrix, choleskyMatrix, x0, r0, low, high, permute); - dCholeskyUpdate(size, clampedIndex, swapIndex, choleskyMatrix, tmp0, tmp1); - clampedIndex++; - dAssert(clampedIndex <= size); - dAssert(clampedIndex >= index); - } - calculateDelta_x = false; - } else { - dAssert(index > 0); - x0[swapIndex] = clamp_x; - delta_x[index] = T(dFloat(0.0f)); - - dAssert(swapIndex < index); - dPermuteRows(size, swapIndex, index - 1, matrix, choleskyMatrix, x0, r0, low, high, permute); - dPermuteRows(size, index - 1, index, matrix, choleskyMatrix, x0, r0, low, high, permute); - dPermuteRows(size, clampedIndex - 1, index, matrix, choleskyMatrix, x0, r0, low, high, permute); - dCholeskyUpdate(size, swapIndex, clampedIndex - 1, choleskyMatrix, tmp0, tmp1); - - clampedIndex--; - index--; - loop = true; - } - } - } - - for (int i = 0; i < size; i++) { - int j = permute[i]; - x[j] = x0[i]; - b[j] = r0[i]; - } - return true; -} - - -template <class T> -bool dCholeskyWithRegularizer(int size, int block, T* const matrix, T regularizer) -{ - T* const copy = dAlloca(T, size * size); - memcpy(copy, matrix, size * size * sizeof (T)); - bool pass = dCholeskyFactorization(size, block, matrix); - - int count = 0; - while (!pass && (count < 10)) { - int stride = 0; - for (int i = 0; i < block; i++) { - copy[stride] += copy[stride] * regularizer; - stride += size + 1; - } - memcpy(matrix, copy, sizeof(T)* size * size); - pass = dCholeskyFactorization(size, block, matrix); - } - return pass; -} - - -// solve a general Linear complementary program (LCP) -// A * x = b + r -// subjected to constraints -// x(i) = low(i), if r(i) >= 0 -// x(i) = high(i), if r(i) <= 0 -// low(i) <= x(i) <= high(i), if r(i) == 0 -// -// return true is the system has a solution. -// in return -// x is the solution, -// b is zero -// note: although the system is called LCP, the solver is far more general than a strict LCP -// to solve a strict LCP, set the following -// low(i) = 0 -// high(i) = infinity. -// this is the same as enforcing the constraint: x(i) * r(i) = 0 -template <class T> -bool dSolvePartitionDantzigLCP(int size, T* const symmetricMatrixPSD, T* const x, T* const b, T* const low, T* const high, int unboundedSize, T regularizer = T(1.e-4f)) -{ - bool ret = false; - if (unboundedSize > 0) { - - ret = dCholeskyWithRegularizer(size, unboundedSize, symmetricMatrixPSD, regularizer); - if (ret) { - memcpy (x, b, unboundedSize * sizeof (T)); - dCholeskySolve(size, unboundedSize, symmetricMatrixPSD, x); - int base = unboundedSize * size; - for (int i = unboundedSize; i < size; i++) { - b[i] -= dDotProduct(unboundedSize, &symmetricMatrixPSD[base], x); - base += size; - } - - const int boundedSize = size - unboundedSize; - T* const l = dAlloca(T, boundedSize); - T* const h = dAlloca(T, boundedSize); - T* const c = dAlloca(T, boundedSize); - T* const u = dAlloca(T, boundedSize); - T* const a11 = dAlloca(T, boundedSize * boundedSize); - T* const a10 = dAlloca(T, boundedSize * unboundedSize); - - for (int i = 0; i < boundedSize; i++) { - T* const g = &a10[i * unboundedSize]; - const T* const row = &symmetricMatrixPSD[(unboundedSize + i) * size]; - for (int j = 0; j < unboundedSize; j++) { - g[j] = -row[j]; - } - dCholeskySolve(size, unboundedSize, symmetricMatrixPSD, g); - - T* const arow = &a11[i * boundedSize]; - const T* const row2 = &symmetricMatrixPSD[(unboundedSize + i) * size]; - arow[i] = row2[unboundedSize + i] + dDotProduct(unboundedSize, g, row2); - for (int j = i + 1; j < boundedSize; j++) { - const T* const row1 = &symmetricMatrixPSD[(unboundedSize + j) * size]; - T elem = row1[unboundedSize + i] + dDotProduct(unboundedSize, g, row1); - arow[j] = elem; - a11[j * boundedSize + i] = elem; - } - u[i] = T(0.0f); - c[i] = b[i + unboundedSize]; - l[i] = low[i + unboundedSize]; - h[i] = high[i + unboundedSize]; - } - - if (dSolveDantzigLCP(boundedSize, a11, u, c, l, h, regularizer)) { - for (int i = 0; i < boundedSize; i++) { - const T s = u[i]; - x[unboundedSize + i] = s; - const T* const g = &a10[i * unboundedSize]; - for (int j = 0; j < unboundedSize; j++) { - x[j] += g[j] * s; - } - } - ret = true; - } - } - } else { - ret = dSolveDantzigLCP(size, symmetricMatrixPSD, x, b, low, high, regularizer); - } - - return ret; -} - - -// solve a general Linear complementary program (LCP) -// A * x = b + r -// subjected to constraints -// x(i) = low(i), if r(i) >= 0 -// x(i) = high(i), if r(i) <= 0 -// low(i) <= x(i) <= high(i), if r(i) == 0 -// -// return true is the system has a solution. -// in return -// x is the solution, -// r is return in vector b -// note: although the system is called LCP, the solver is far more general than a strict LCP -// to solve a strict LCP, set the following -// low(i) = 0 -// high(i) = infinity. -// this the same as enforcing the constraint: x(i) * r(i) = 0 -template <class T> -void dGaussSeidelLcpSor(const int size, const int stride, const T* const matrix, T* const x, const T* const b, const int* const normalIndex, const T* const low, const T* const high, T tol2, int maxIterCount, T sor) -{ - const T* const me = matrix; - T* const invDiag1 = dAlloca(T, size); - T* const u = dAlloca(T, size + 1); - int* const index = dAlloca(int, size); - - u[size] = T(1.0f); - int rowStart = 0; - for (int j = 0; j < size; j++) { - u[j] = x[j]; - index[j] = normalIndex[j] ? j + normalIndex[j] : size; - } - - for (int j = 0; j < size; j++) { - const T val = u[index[j]]; - const T l = low[j] * val; - const T h = high[j] * val; - u[j] = dClamp(u[j], l, h); - invDiag1[j] = T(1.0f) / me[rowStart + j]; - rowStart += stride; - } - - T tolerance(tol2 * 2.0f); - const T* const invDiag = invDiag1; - const int maxCount = dMax (8, size); - for (int i = 0; (i < maxCount) && (tolerance > tol2); i++) { - int base = 0; - tolerance = T(0.0f); - for (int j = 0; j < size; j++) { - const T* const row = &me[base]; - T r(b[j] - dDotProduct(size, row, u)); - T f((r + row[j] * u[j]) * invDiag[j]); - - const T val = u[index[j]]; - const T l = low[j] * val; - const T h = high[j] * val; - if (f > h) { - u[j] = h; - } else if (f < l) { - u[j] = l; - } else { - tolerance += r * r; - u[j] = f; - } - base += stride; - } - } - -#ifdef _DEBUG - int passes = 0; -#endif - for (int i = 0; (i < maxIterCount) && (tolerance > tol2); i++) { - int base = 0; - tolerance = T(0.0f); -#ifdef _DEBUG - passes++; -#endif - for (int j = 0; j < size; j++) { - const T* const row = &me[base]; - T r(b[j] - dDotProduct(size, row, u)); - T f((r + row[j] * u[j]) * invDiag[j]); - f = u[j] + (f - u[j]) * sor; - - const T val = u[index[j]]; - const T l = low[j] * val; - const T h = high[j] * val; - if (f > h) { - u[j] = h; - } else if (f < l) { - u[j] = l; - } else { - tolerance += r * r; - u[j] = f; - } - base += stride; - } - } - - for (int j = 0; j < size; j++) { - x[j] = u[j]; - } -} - -#endif - diff --git a/thirdparty/src/newton/dMath/dMatrix.cpp b/thirdparty/src/newton/dMath/dMatrix.cpp deleted file mode 100644 index 57dfb6ca4..000000000 --- a/thirdparty/src/newton/dMath/dMatrix.cpp +++ /dev/null @@ -1,1036 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dStdAfxMath.h" -#include "dMathDefines.h" -#include "dVector.h" -#include "dMatrix.h" -#include "dQuaternion.h" - -// calculate an orthonormal matrix with the front vector pointing on the -// dir direction, and the up and right are determined by using the GramSchidth procedure - -dMatrix dGetIdentityMatrix() -{ - return dMatrix (dVector (dFloat (1.0f), dFloat (0.0f), dFloat (0.0f), dFloat (0.0f)), - dVector (dFloat (0.0f), dFloat (1.0f), dFloat (0.0f), dFloat (0.0f)), - dVector (dFloat (0.0f), dFloat (0.0f), dFloat (1.0f), dFloat (0.0f)), - dVector (dFloat (0.0f), dFloat (0.0f), dFloat (0.0f), dFloat (1.0f))); -} - -dMatrix dGetZeroMatrix () -{ - return dMatrix (dVector (dFloat (0.0f), dFloat (0.0f), dFloat (0.0f), dFloat (0.0f)), - dVector (dFloat (0.0f), dFloat (0.0f), dFloat (0.0f), dFloat (0.0f)), - dVector (dFloat (0.0f), dFloat (0.0f), dFloat (0.0f), dFloat (0.0f)), - dVector (dFloat (0.0f), dFloat (0.0f), dFloat (0.0f), dFloat (0.0f))); -} - -dMatrix dGrammSchmidt(const dVector& dir) -{ - dVector up(dFloat (0.0f)); - dVector right(dFloat (0.0f)); - dVector front (dir); - - front = front.Scale(1.0f / dSqrt (front.DotProduct3(front))); - if (dAbs (front.m_z) > 0.577f) { - right = front.CrossProduct(dVector (-front.m_y, front.m_z, dFloat (0.0f))); - } else { - right = front.CrossProduct(dVector (-front.m_y, front.m_x, dFloat (0.0f))); - } - right = right.Scale (1.0f / dSqrt (right.DotProduct3(right))); - up = right.CrossProduct(front); - - front.m_w = dFloat (0.0f); - up.m_w = dFloat (0.0f); - right.m_w = dFloat (0.0f); - return dMatrix (front, up, right, dVector (dFloat(0.0f), dFloat (0.0f), dFloat (0.0f), dFloat (1.0f))); -} - -dMatrix dPitchMatrix(dFloat ang) -{ - dFloat cosAng; - dFloat sinAng; - sinAng = dSin (ang); - cosAng = dCos (ang); - return dMatrix (dVector (dFloat (1.0f), dFloat (0.0f), dFloat (0.0f), dFloat (0.0f)), - dVector (dFloat (0.0f), cosAng, sinAng, dFloat (0.0f)), - dVector (dFloat (0.0f), -sinAng, cosAng, dFloat (0.0f)), - dVector (dFloat (0.0f), dFloat (0.0f), dFloat (0.0f), dFloat (1.0f))); - -} - -dMatrix dYawMatrix(dFloat ang) -{ - dFloat cosAng; - dFloat sinAng; - sinAng = dSin (ang); - cosAng = dCos (ang); - return dMatrix (dVector (cosAng, dFloat (0.0f), -sinAng, dFloat (0.0f)), - dVector (dFloat(0.0f), 1.0f, 0.0f, dFloat (0.0f)), - dVector (sinAng, dFloat (0.0f), cosAng, dFloat (0.0f)), - dVector (dFloat(0.0f), dFloat (0.0f), dFloat (0.0f), dFloat (1.0f))); -} - -dMatrix dRollMatrix(dFloat ang) -{ - dFloat cosAng; - dFloat sinAng; - sinAng = dSin (ang); - cosAng = dCos (ang); - return dMatrix (dVector ( cosAng, sinAng, dFloat (0.0f), dFloat (0.0f)), - dVector (-sinAng, cosAng, dFloat (0.0f), dFloat (0.0f)), - dVector ((dFloat (0.0f)), dFloat (0.0f), dFloat (1.0f), dFloat (0.0f)), - dVector ((dFloat (0.0f)), dFloat (0.0f), dFloat (0.0f), dFloat (1.0f))); -} - -dMatrix::dMatrix (const dQuaternion &rotation, const dVector &position) - :m_front(dFloat (0.0f)) - ,m_up(dFloat (0.0f)) - ,m_right(dFloat (0.0f)) - ,m_posit(dFloat (0.0f)) -{ - dFloat x2 = dFloat (2.0f) * rotation.m_x * rotation.m_x; - dFloat y2 = dFloat (2.0f) * rotation.m_y * rotation.m_y; - dFloat z2 = dFloat (2.0f) * rotation.m_z * rotation.m_z; -#ifdef _DEBUG - dFloat w2 = dFloat (2.0f) * rotation.m_w * rotation.m_w; - dAssert (dAbs (w2 + x2 + y2 + z2 - dFloat(2.0f)) < dFloat (1.e-2f)); -#endif - - dFloat xy = dFloat (2.0f) * rotation.m_x * rotation.m_y; - dFloat xz = dFloat (2.0f) * rotation.m_x * rotation.m_z; - dFloat xw = dFloat (2.0f) * rotation.m_x * rotation.m_w; - dFloat yz = dFloat (2.0f) * rotation.m_y * rotation.m_z; - dFloat yw = dFloat (2.0f) * rotation.m_y * rotation.m_w; - dFloat zw = dFloat (2.0f) * rotation.m_z * rotation.m_w; - - m_front = dVector (dFloat (1.0f) - y2 - z2, xy + zw , xz - yw , dFloat (0.0f)); - m_up = dVector (xy - zw , dFloat (1.0f) - x2 - z2, yz + xw , dFloat (0.0f)); - m_right = dVector (xz + yw , yz - xw , dFloat (1.0f) - x2 - y2 , dFloat (0.0f)); - - m_posit.m_x = position.m_x; - m_posit.m_y = position.m_y; - m_posit.m_z = position.m_z; - m_posit.m_w = dFloat (1.0f); -} - -dMatrix::dMatrix (dFloat pitch, dFloat yaw, dFloat roll, const dVector& location) -{ - dMatrix& me = *this; - me = dPitchMatrix(pitch) * dYawMatrix(yaw) * dRollMatrix(roll); - me.m_posit = location; - me.m_posit.m_w = dFloat (1.0f); -} - -bool dMatrix::TestIdentity() const -{ - const dMatrix& matrix = *this; - const dMatrix& identity = dGetIdentityMatrix(); - - bool isIdentity = true; - for (int i = 0; isIdentity && (i < 3); i ++) { - isIdentity &= dAbs (matrix[3][i]) < 1.0e-4f; - for (int j = i; isIdentity && (j < 3); j ++) { - isIdentity &= dAbs (matrix[i][j]-identity[i][j]) < 1.0e-4f; - } - } - return isIdentity; -} - -bool dMatrix::TestOrthogonal() const -{ - dVector n (m_front.CrossProduct(m_up)); - dFloat a = m_right.DotProduct3(m_right); - dFloat b = m_up.DotProduct3(m_up); - dFloat c = m_front.DotProduct3(m_front); - dFloat d = n.DotProduct3(m_right); - - return (m_front[3] == dFloat (dFloat (0.0f))) & - (m_up[3] == dFloat (dFloat (0.0f))) & - (m_right[3] == dFloat (dFloat (0.0f))) & - (m_posit[3] == dFloat (1.0f)) & - (dAbs(a - dFloat (1.0f)) < dFloat (1.0e-4f)) & - (dAbs(b - dFloat (1.0f)) < dFloat (1.0e-4f)) & - (dAbs(c - dFloat (1.0f)) < dFloat (1.0e-4f)) & - (dAbs(d - dFloat (1.0f)) < dFloat (1.0e-4f)); -} - -void dMatrix::GetEulerAngles(dVector& euler0, dVector& euler1, dEulerAngleOrder order) const -{ - // Assuming the angles are in radians. -#ifdef _NEWTON_USE_DOUBLE - const dFloat tol = 0.99999995f; -#else - const dFloat tol = 0.99995f; -#endif - - switch (order) - { - case m_pitchYawRoll: - { - const dMatrix& matrix = *this; - if (matrix[0][2] > tol) { - dFloat picth0 = dFloat (0.0f); - dFloat yaw0 = -dPi * 0.5f; - dFloat roll0 = -dAtan2(matrix[2][1], matrix[1][1]); - euler0[0] = picth0; - euler0[1] = yaw0; - euler0[2] = roll0; - - euler1[0] = picth0; - euler1[1] = yaw0; - euler1[2] = roll0; - - } else if (matrix[0][2] < -tol) { - dFloat picth0 = dFloat (0.0f); - dFloat yaw0 = dPi * 0.5f; - dFloat roll0 = dAtan2(matrix[2][1], matrix[1][1]); - euler0[0] = picth0; - euler0[1] = yaw0; - euler0[2] = roll0; - - euler1[0] = picth0; - euler1[1] = yaw0; - euler1[2] = roll0; - } else { - dFloat yaw0 = -dAsin(matrix[0][2]); - dFloat yaw1 = dPi - yaw0; - - dFloat picth0 = dAtan2( matrix[1][2], matrix[2][2]); - dFloat picth1 = dAtan2(-matrix[1][2], -matrix[2][2]); - - dFloat roll0 = dAtan2( matrix[0][1], matrix[0][0]); - dFloat roll1 = dAtan2(-matrix[0][1], -matrix[0][0]); - - if (yaw1 > dPi) { - yaw1 -= 2.0f * dPi; - } - - euler0[0] = picth0; - euler0[1] = yaw0; - euler0[2] = roll0; - - euler1[0] = picth1; - euler1[1] = yaw1; - euler1[2] = roll1; - } - -#ifdef _DEBUG - dMatrix m0(dPitchMatrix(euler0[0]) * dYawMatrix(euler0[1]) * dRollMatrix(euler0[2])); - dMatrix m1(dPitchMatrix(euler1[0]) * dYawMatrix(euler1[1]) * dRollMatrix(euler1[2])); - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - dFloat error = dAbs(m0[i][j] - matrix[i][j]); - dAssert(error < dFloat(5.0e-2f)); - error = dAbs(m1[i][j] - matrix[i][j]); - dAssert(error < dFloat(5.0e-2f)); - } - } -#endif - break; - } - - case m_pitchRollYaw: - { - const dMatrix& matrix = *this; - //dMatrix matrix(dPitchMatrix(30.0f * dDegreeToRad) * dRollMatrix(-90.0f * dDegreeToRad) * dYawMatrix(50.0f * dDegreeToRad)); - if (matrix[0][1] > tol) { - - dFloat picth0 = dFloat (0.0f); - dFloat roll0 = dFloat (dPi * 0.5f); - dFloat yaw0 = dAtan2(matrix[1][2], matrix[2][2]); - - euler0[0] = picth0; - euler0[1] = yaw0; - euler0[2] = roll0; - - euler1[0] = picth0; - euler1[1] = yaw0; - euler1[2] = roll0; - - } else if (matrix[0][1] < -tol) { - - dFloat picth0 = dFloat (0.0f); - dFloat roll0 = dFloat(-dPi * 0.5f); - dFloat yaw0 = dAtan2(-matrix[1][2], matrix[2][2]); - - euler0[0] = picth0; - euler0[1] = yaw0; - euler0[2] = roll0; - - euler1[0] = picth0; - euler1[1] = yaw0; - euler1[2] = roll0; - - } else { - dFloat roll0 = dAsin(matrix[0][1]); - dFloat roll1 = dPi - roll0; - - dFloat yaw0 = dAtan2(-matrix[0][2], matrix[0][0]); - dFloat yaw1 = dAtan2( matrix[0][2], -matrix[0][0]); - - dFloat picth0 = dAtan2(-matrix[2][1], matrix[1][1]); - dFloat picth1 = dAtan2( matrix[2][1], -matrix[1][1]); - - if (roll1 > dFloat (dPi)) { - roll1 -= dFloat (2.0f * dPi); - } - - euler0[0] = picth0; - euler0[1] = yaw0; - euler0[2] = roll0; - - euler1[0] = picth1; - euler1[1] = yaw1; - euler1[2] = roll1; - } - -#ifdef _DEBUG - dMatrix m0(dPitchMatrix(euler0[0]) * dRollMatrix(euler0[2]) * dYawMatrix(euler0[1])); - dMatrix m1(dPitchMatrix(euler1[0]) * dRollMatrix(euler1[2]) * dYawMatrix(euler1[1])); - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - dFloat error = dAbs(m0[i][j] - matrix[i][j]); - dAssert(error < dFloat(5.0e-2f)); - error = dAbs(m1[i][j] - matrix[i][j]); - dAssert(error < dFloat(5.0e-2f)); - } - } -#endif - break; - } - - default: - { - int a0 = (order >> 8) & 3; - int a1 = (order >> 4) & 3; - int a2 = (order >> 0) & 3; - const dMatrix& matrix = *this; - - // Assuming the angles are in radians. - if (matrix[a0][a2] > tol) { - dFloat picth0 = dFloat (0.0f); - dFloat yaw0 = dFloat(-3.141592f * 0.5f); - dFloat roll0 = -dAtan2(matrix[a2][a1], matrix[a1][a1]); - euler0[a0] = picth0; - euler0[a1] = yaw0; - euler0[a2] = roll0; - - euler1[a0] = picth0; - euler1[a1] = yaw0; - euler1[a2] = roll0; - - } else if (matrix[a0][a2] < -tol) { - dFloat picth0 = dFloat (0.0f); - dFloat yaw0 = dFloat(3.141592f * 0.5f); - dFloat roll0 = dAtan2(matrix[a2][a1], matrix[a1][a1]); - euler0[a0] = picth0; - euler0[a1] = yaw0; - euler0[a2] = roll0; - - euler1[a0] = picth0; - euler1[a1] = yaw0; - euler1[a2] = roll0; - } else { - //euler[a0] = -dAtan2(-matrix[a1][a2], matrix[a2][a2]); - //euler[a1] = -dAsin ( matrix[a0][a2]); - //euler[a2] = -dAtan2(-matrix[a0][a1], matrix[a0][a0]); - - dFloat yaw0 = -dAsin(matrix[a0][a2]); - dFloat yaw1 = 3.141592f - yaw0; - dFloat sign0 = dSign(dCos(yaw0)); - dFloat sign1 = dSign(dCos(yaw1)); - - dFloat picth0 = dAtan2(matrix[a1][a2] * sign0, matrix[a2][a2] * sign0); - dFloat picth1 = dAtan2(matrix[a1][a2] * sign1, matrix[a2][a2] * sign1); - - dFloat roll0 = dAtan2(matrix[a0][a1] * sign0, matrix[a0][a0] * sign0); - dFloat roll1 = dAtan2(matrix[a0][a1] * sign1, matrix[a0][a0] * sign1); - - if (yaw1 > 3.141592f) { - yaw1 -= 2.0f * 3.141592f; - } - - euler0[a0] = picth0; - euler0[a1] = yaw0; - euler0[a2] = roll0; - - euler1[a0] = picth1; - euler1[a1] = yaw1; - euler1[a2] = roll1; - } - } - } - - euler0[3] = dFloat (0.0f); - euler1[3] = dFloat (0.0f); -} - -dMatrix dMatrix::Inverse () const -{ - return dMatrix (dVector (m_front.m_x, m_up.m_x, m_right.m_x, dFloat (0.0f)), - dVector (m_front.m_y, m_up.m_y, m_right.m_y, dFloat (0.0f)), - dVector (m_front.m_z, m_up.m_z, m_right.m_z, dFloat (0.0f)), - dVector (- m_posit.DotProduct3(m_front), - m_posit.DotProduct3(m_up), - m_posit.DotProduct3(m_right), dFloat (1.0f))); -} - -dMatrix dMatrix::Transpose () const -{ - return dMatrix (dVector (m_front.m_x, m_up.m_x, m_right.m_x, dFloat (0.0f)), - dVector (m_front.m_y, m_up.m_y, m_right.m_y, dFloat (0.0f)), - dVector (m_front.m_z, m_up.m_z, m_right.m_z, dFloat (0.0f)), - dVector (dFloat(0.0f), dFloat (0.0f), dFloat (0.0f), dFloat (1.0f))); -} - -dMatrix dMatrix::Transpose4X4 () const -{ - return dMatrix (dVector (m_front.m_x, m_up.m_x, m_right.m_x, m_posit.m_x), - dVector (m_front.m_y, m_up.m_y, m_right.m_y, m_posit.m_y), - dVector (m_front.m_z, m_up.m_z, m_right.m_z, m_posit.m_z), - dVector (m_front.m_w, m_up.m_w, m_right.m_w, m_posit.m_w)); - -} - -dVector dMatrix::RotateVector (const dVector &v) const -{ - return dVector (v.m_x * m_front.m_x + v.m_y * m_up.m_x + v.m_z * m_right.m_x, - v.m_x * m_front.m_y + v.m_y * m_up.m_y + v.m_z * m_right.m_y, - v.m_x * m_front.m_z + v.m_y * m_up.m_z + v.m_z * m_right.m_z, dFloat (0.0f)); -} - -dVector dMatrix::UnrotateVector (const dVector &v) const -{ - return dVector (v.DotProduct3(m_front), v.DotProduct3(m_up), v.DotProduct3(m_right), dFloat (0.0f)); -} - -dVector dMatrix::RotateVector4x4 (const dVector &v) const -{ - return dVector (v.m_x * m_front.m_x + v.m_y * m_up.m_x + v.m_z * m_right.m_x + v.m_w * m_posit.m_x, - v.m_x * m_front.m_y + v.m_y * m_up.m_y + v.m_z * m_right.m_y + v.m_w * m_posit.m_y, - v.m_x * m_front.m_z + v.m_y * m_up.m_z + v.m_z * m_right.m_z + v.m_w * m_posit.m_z, - v.m_x * m_front.m_w + v.m_y * m_up.m_w + v.m_z * m_right.m_w + v.m_w * m_posit.m_w); -} - - -dVector dMatrix::TransformVector (const dVector &v) const -{ - return m_posit + RotateVector(v); -} - -dVector dMatrix::UntransformVector (const dVector &v) const -{ - dVector rot (UnrotateVector(v - m_posit)); - rot.m_w = dFloat (1.0f); - return rot; -} - - -void dMatrix::TransformTriplex (dFloat* const dst, int dstStrideInBytes, const dFloat* const src, int srcStrideInBytes, int count) const -{ - dstStrideInBytes /= sizeof (dFloat); - srcStrideInBytes /= sizeof (dFloat); - for (int i = 0 ; i < count; i ++ ) { - dFloat x = src[srcStrideInBytes * i + 0]; - dFloat y = src[srcStrideInBytes * i + 1]; - dFloat z = src[srcStrideInBytes * i + 2]; - dst[dstStrideInBytes * i + 0] = x * m_front.m_x + y * m_up.m_x + z * m_right.m_x + m_posit.m_x; - dst[dstStrideInBytes * i + 1] = x * m_front.m_y + y * m_up.m_y + z * m_right.m_y + m_posit.m_y; - dst[dstStrideInBytes * i + 2] = x * m_front.m_z + y * m_up.m_z + z * m_right.m_z + m_posit.m_z; - } -} - -#ifndef _NEWTON_USE_DOUBLE -void dMatrix::TransformTriplex (dFloat64* const dst, int dstStrideInBytes, const dFloat64* const src, int srcStrideInBytes, int count) const -{ - dstStrideInBytes /= sizeof (dFloat64); - srcStrideInBytes /= sizeof (dFloat64); - for (int i = 0 ; i < count; i ++ ) { - dFloat64 x = src[srcStrideInBytes * i + 0]; - dFloat64 y = src[srcStrideInBytes * i + 1]; - dFloat64 z = src[srcStrideInBytes * i + 2]; - dst[dstStrideInBytes * i + 0] = x * m_front.m_x + y * m_up.m_x + z * m_right.m_x + m_posit.m_x; - dst[dstStrideInBytes * i + 1] = x * m_front.m_y + y * m_up.m_y + z * m_right.m_y + m_posit.m_y; - dst[dstStrideInBytes * i + 2] = x * m_front.m_z + y * m_up.m_z + z * m_right.m_z + m_posit.m_z; - } -} -#endif - -dMatrix dMatrix::operator* (const dMatrix &B) const -{ - const dMatrix& A = *this; - return dMatrix (dVector (A[0][0] * B[0][0] + A[0][1] * B[1][0] + A[0][2] * B[2][0] + A[0][3] * B[3][0], - A[0][0] * B[0][1] + A[0][1] * B[1][1] + A[0][2] * B[2][1] + A[0][3] * B[3][1], - A[0][0] * B[0][2] + A[0][1] * B[1][2] + A[0][2] * B[2][2] + A[0][3] * B[3][2], - A[0][0] * B[0][3] + A[0][1] * B[1][3] + A[0][2] * B[2][3] + A[0][3] * B[3][3]), - dVector (A[1][0] * B[0][0] + A[1][1] * B[1][0] + A[1][2] * B[2][0] + A[1][3] * B[3][0], - A[1][0] * B[0][1] + A[1][1] * B[1][1] + A[1][2] * B[2][1] + A[1][3] * B[3][1], - A[1][0] * B[0][2] + A[1][1] * B[1][2] + A[1][2] * B[2][2] + A[1][3] * B[3][2], - A[1][0] * B[0][3] + A[1][1] * B[1][3] + A[1][2] * B[2][3] + A[1][3] * B[3][3]), - dVector (A[2][0] * B[0][0] + A[2][1] * B[1][0] + A[2][2] * B[2][0] + A[2][3] * B[3][0], - A[2][0] * B[0][1] + A[2][1] * B[1][1] + A[2][2] * B[2][1] + A[2][3] * B[3][1], - A[2][0] * B[0][2] + A[2][1] * B[1][2] + A[2][2] * B[2][2] + A[2][3] * B[3][2], - A[2][0] * B[0][3] + A[2][1] * B[1][3] + A[2][2] * B[2][3] + A[2][3] * B[3][3]), - dVector (A[3][0] * B[0][0] + A[3][1] * B[1][0] + A[3][2] * B[2][0] + A[3][3] * B[3][0], - A[3][0] * B[0][1] + A[3][1] * B[1][1] + A[3][2] * B[2][1] + A[3][3] * B[3][1], - A[3][0] * B[0][2] + A[3][1] * B[1][2] + A[3][2] * B[2][2] + A[3][3] * B[3][2], - A[3][0] * B[0][3] + A[3][1] * B[1][3] + A[3][2] * B[2][3] + A[3][3] * B[3][3])); -} - -dVector dMatrix::TransformPlane (const dVector &localPlane) const -{ - dVector tmp (RotateVector (localPlane)); - tmp.m_w = localPlane.m_w - (localPlane.DotProduct3(UnrotateVector (m_posit))); - return tmp; -} - -dVector dMatrix::UntransformPlane (const dVector &globalPlane) const -{ - dVector tmp (UnrotateVector (globalPlane)); - tmp.m_w = globalPlane.DotProduct3(m_posit) + globalPlane.m_w; - return tmp; -} - -bool dMatrix::SanityCheck() const -{ - dVector right (m_front.CrossProduct(m_up)); - if (dAbs (right.DotProduct3(m_right)) < 0.9999f) { - return false; - } - if (dAbs (m_right.m_w) > 0.0f) { - return false; - } - if (dAbs (m_up.m_w) > 0.0f) { - return false; - } - if (dAbs (m_right.m_w) > 0.0f) { - return false; - } - - if (dAbs (m_posit.m_w) != dFloat (1.0f)) { - return false; - } - - return true; -} - -dMatrix dMatrix::Inverse4x4 () const -{ - dMatrix tmp (*this); - dMatrix inv (dGetIdentityMatrix()); - for (int i = 0; i < 4; i ++) { - dFloat pivot = dAbs(tmp[i][i]); - if (pivot < 0.01f) { - int permute = i; - for (int j = i + 1; j < 4; j++) { - dFloat pivot1 = dAbs(tmp[j][i]); - if (pivot1 > pivot) { - permute = j; - pivot = pivot1; - } - } - dAssert(pivot > 1.0e-6f); - if (permute != i) { - for (int j = 0; j < 4; j++) { - dSwap(inv[i][j], inv[permute][j]); - dSwap(tmp[i][j], tmp[permute][j]); - } - } - } - - for (int j = i + 1; j < 4; j++) { - dFloat scale = tmp[j][i] / tmp[i][i]; - for (int k = 0; k < 4; k++) { - tmp[j][k] -= scale * tmp[i][k]; - inv[j][k] -= scale * inv[i][k]; - } - tmp[j][i] = dFloat (0.0f); - } - } - - dVector zero(dFloat (0.0f)); - for (int i = 3; i >= 0; i--) { - dVector acc (zero); - for (int j = i + 1; j < 4; j++) { - dFloat pivot = tmp[i][j]; - for (int k = 0; k < 4; k++) { - acc[k] += pivot * inv[j][k]; - } - } - dFloat den = dFloat (1.0f) / tmp[i][i]; - for (int k = 0; k < 4; k++) { - inv[i][k] = den * (inv[i][k] - acc[k]); - } - } - -#ifdef _DEBUG - tmp = *this * inv; - for (int i = 0; i < 4; i++) { - dAssert(dAbs(tmp[i][i] - dFloat (1.0f)) < dFloat(1.0e-4f)); - for (int j = i + 1; j < 4; j++) { - dAssert(dAbs(tmp[i][j]) < dFloat(1.0e-3f)); - dAssert(dAbs(tmp[j][i]) < dFloat(1.0e-3f)); - } - } -#endif - - return inv; -} - -/* -static inline void ROT(dMatrix &a, int i, int j, int k, int l, dFloat s, dFloat tau) -{ - dFloat g; - dFloat h; - g = a[i][j]; - h = a[k][l]; - a[i][j] = g - s * (h + g * tau); - a[k][l] = h + s * (g - h * tau); -} -*/ -// from numerical recipes in c -// Jacobian method for computing the eigenvectors of a symmetric matrix -dMatrix dMatrix::JacobiDiagonalization (dVector &eigenValues, const dMatrix& initialMatrix) const -{ -/* - dMatrix mat(*this); - dMatrix eigenVectors(initialMatrix); - dFloat thresh; - dFloat b[3]; - dFloat z[3]; - dFloat d[3]; - const dFloat EPSILON = 1.0e-5f; - - b[0] = mat[0][0]; - b[1] = mat[1][1]; - b[2] = mat[2][2]; - - d[0] = mat[0][0]; - d[1] = mat[1][1]; - d[2] = mat[2][2]; - - z[0] = dFloat (0.0f); - z[1] = dFloat (0.0f); - z[2] = dFloat (0.0f); - - int nrot = 0; - for (int i = 0; i < 50; i++) { - dFloat sm = dAbs(mat[0][1]) + dAbs(mat[0][2]) + dAbs(mat[1][2]); - - if (sm < (EPSILON * 1.0e-4f)) { - dAssert (dAbs((eigenVectors.m_front.DotProduct3(eigenVectors.m_front)) - 1.0f) < EPSILON); - dAssert (dAbs((eigenVectors.m_up.DotProduct3(eigenVectors.m_up)) - 1.0f) < EPSILON); - dAssert (dAbs((eigenVectors.m_right.DotProduct3(eigenVectors.m_right)) - 1.0f) < EPSILON); - eigenValues = dVector (d[0], d[1], d[2], dFloat (dFloat (0.0f))); - return eigenVectors.Inverse(); - } - - if (i < 3) { - thresh = (dFloat)(0.2f / 9.0f) * sm; - } else { - thresh = 0.0; - } - - - // First row - dFloat g = 100.0f * dAbs(mat[0][1]); - if ((i > 3) && (dAbs(d[0]) + g == dAbs(d[0])) && (dAbs(d[1]) + g == dAbs(d[1]))) { - mat[0][1] = dFloat (0.0f); - } else if (dAbs(mat[0][1]) > thresh) { - dFloat t; - dFloat h = d[1] - d[0]; - if (dAbs(h) + g == dAbs(h)) { - t = mat[0][1] / h; - } else { - dFloat theta = dFloat (0.5f) * h / mat[0][1]; - t = dFloat (1.0f) / (dAbs(theta) + dSqrt(dFloat (1.0f) + theta * theta)); - if (theta < 0.0f) { - t = -t; - } - } - dFloat c = dFloat (1.0f) / dSqrt (1.0f + t * t); - dFloat s = t * c; - dFloat tau = s / (dFloat (1.0f) + c); - h = t * mat[0][1]; - z[0] -= h; - z[1] += h; - d[0] -= h; - d[1] += h; - mat[0][1] = dFloat (0.0f); - ROT (mat, 0, 2, 1, 2, s, tau); - ROT (eigenVectors, 0, 0, 0, 1, s, tau); - ROT (eigenVectors, 1, 0, 1, 1, s, tau); - ROT (eigenVectors, 2, 0, 2, 1, s, tau); - - nrot++; - } - - - // second row - g = 100.0f * dAbs(mat[0][2]); - if ((i > 3) && (dAbs(d[0]) + g == dAbs(d[0])) && (dAbs(d[2]) + g == dAbs(d[2]))) { - mat[0][2] = dFloat (0.0f); - } else if (dAbs(mat[0][2]) > thresh) { - dFloat t; - dFloat h = d[2] - d[0]; - if (dAbs(h) + g == dAbs(h)) { - t = (mat[0][2]) / h; - } else { - dFloat theta = dFloat (0.5f) * h / mat[0][2]; - t = dFloat (1.0f) / (dAbs(theta) + dSqrt(dFloat (1.0f) + theta * theta)); - if (theta < 0.0f) { - t = -t; - } - } - dFloat c = dFloat (1.0f) / dSqrt(1 + t * t); - dFloat s = t * c; - dFloat tau = s / (dFloat (1.0f) + c); - h = t * mat[0][2]; - z[0] -= h; - z[2] += h; - d[0] -= h; - d[2] += h; - mat[0][2]=0.0; - ROT (mat, 0, 1, 1, 2, s, tau); - ROT (eigenVectors, 0, 0, 0, 2, s, tau); - ROT (eigenVectors, 1, 0, 1, 2, s, tau); - ROT (eigenVectors, 2, 0, 2, 2, s, tau); - } - - // trird row - g = 100.0f * dAbs(mat[1][2]); - if ((i > 3) && (dAbs(d[1]) + g == dAbs(d[1])) && (dAbs(d[2]) + g == dAbs(d[2]))) { - mat[1][2] = dFloat (0.0f); - } else if (dAbs(mat[1][2]) > thresh) { - dFloat t; - dFloat h = d[2] - d[1]; - if (dAbs(h) + g == dAbs(h)) { - t = mat[1][2] / h; - } else { - dFloat theta = dFloat (0.5f) * h / mat[1][2]; - t = dFloat (1.0f) / (dAbs(theta) + dSqrt(dFloat (1.0f) + theta * theta)); - if (theta < 0.0f) { - t = -t; - } - } - dFloat c = dFloat (1.0f) / dSqrt(1 + t*t); - dFloat s = t * c; - dFloat tau = s / (dFloat (1.0f) + c); - - h = t * mat[1][2]; - z[1] -= h; - z[2] += h; - d[1] -= h; - d[2] += h; - mat[1][2] = dFloat (0.0f); - ROT (mat, 0, 1, 0, 2, s, tau); - ROT (eigenVectors, 0, 1, 0, 2, s, tau); - ROT (eigenVectors, 1, 1, 1, 2, s, tau); - ROT (eigenVectors, 2, 1, 2, 2, s, tau); - nrot++; - } - - b[0] += z[0]; d[0] = b[0]; z[0] = dFloat (0.0f); - b[1] += z[1]; d[1] = b[1]; z[1] = dFloat (0.0f); - b[2] += z[2]; d[2] = b[2]; z[2] = dFloat (0.0f); - } - - dAssert (0); - eigenValues = dVector (d[0], d[1], d[2], dFloat (dFloat (0.0f))); - return dGetIdentityMatrix(); -*/ - - dMatrix mat(*this); - dMatrix eigenVectors(initialMatrix.Transpose()); - - // QR algorithm is really bad at converging matrices with very different eigenvalue. - // the solution is to use RD with double shift which I do not feel like implementing. - // using Jacobi diagonalize instead - dVector d(mat[0][0], mat[1][1], mat[2][2], dFloat(0.0f)); - dVector b(d); - for (int i = 0; i < 50; i++) { - dFloat sm = mat[0][1] * mat[0][1] + mat[0][2] * mat[0][2] + mat[1][2] * mat[1][2]; - if (sm < dFloat(1.0e-12f)) { - // make sure the the eigen vectors are orthonormal - //dVector tmp (eigenVectors.m_front.CrossProduct(eigenVectors.m_up)); - //if (tmp.DotProduct(eigenVectors.m_right).GetScalar() < dFloat(0.0f)) { - // eigenVectors.m_right = eigenVectors.m_right * dVector::m_negOne; - //} - dAssert(eigenVectors[0].DotProduct3(eigenVectors[1].CrossProduct(eigenVectors[2])) > dFloat(0.0f)); - break; - } - - dFloat thresh = dFloat(0.0f); - if (i < 3) { - thresh = (dFloat)(0.2f / 9.0f) * sm; - } - - dVector z(0.0f); - for (int ip = 0; ip < 2; ip++) { - for (int iq = ip + 1; iq < 3; iq++) { - dFloat g = dFloat(100.0f) * dAbs(mat[ip][iq]); - if ((i > 3) && ((dAbs(d[ip]) + g) == dAbs(d[ip])) && ((dAbs(d[iq]) + g) == dAbs(d[iq]))) { - mat[ip][iq] = dFloat(0.0f); - } - else if (dAbs(mat[ip][iq]) > thresh) { - - dFloat t; - dFloat h = d[iq] - d[ip]; - if (dAbs(h) + g == dAbs(h)) { - t = mat[ip][iq] / h; - } else { - dFloat theta = dFloat(0.5f) * h / mat[ip][iq]; - t = dFloat(1.0f) / (dAbs(theta) + dSqrt(dFloat(1.0f) + theta * theta)); - if (theta < dFloat(0.0f)) { - t = -t; - } - } - dFloat c = dFloat(1.0f) / dSqrt(dFloat(1.0f) + t * t); - dFloat s = t * c; - dFloat tau = s / (dFloat(1.0f) + c); - h = t * mat[ip][iq]; - z[ip] -= h; - z[iq] += h; - d[ip] -= h; - d[iq] += h; - mat[ip][iq] = dFloat(0.0f); - - for (int j = 0; j <= ip - 1; j++) { - dFloat g0 = mat[j][ip]; - dFloat h0 = mat[j][iq]; - mat[j][ip] = g0 - s * (h0 + g0 * tau); - mat[j][iq] = h0 + s * (g0 - h0 * tau); - } - for (int j = ip + 1; j <= iq - 1; j++) { - dFloat g0 = mat[ip][j]; - dFloat h0 = mat[j][iq]; - mat[ip][j] = g0 - s * (h0 + g0 * tau); - mat[j][iq] = h0 + s * (g0 - h0 * tau); - } - for (int j = iq + 1; j < 3; j++) { - dFloat g0 = mat[ip][j]; - dFloat h0 = mat[iq][j]; - mat[ip][j] = g0 - s * (h0 + g0 * tau); - mat[iq][j] = h0 + s * (g0 - h0 * tau); - } - - dVector sv(s); - dVector tauv(tau); - dVector gv(eigenVectors[ip]); - dVector hv(eigenVectors[iq]); - eigenVectors[ip] -= sv * (hv + gv * tauv); - eigenVectors[iq] += sv * (gv - hv * tauv); - } - } - } - - b += z; - d = b; - } - - #ifdef _DEBUG - dMatrix diag(dGetIdentityMatrix()); - diag[0][0] = d[0]; - diag[1][1] = d[1]; - diag[2][2] = d[2]; - dMatrix E(eigenVectors.Transpose()); - dMatrix matrix(E * diag * E.Transpose()); - for (int j = 0; j < 3; j++) { - for (int k = 0; k < 3; k++) { - dFloat error = (*this)[j][k] - matrix[j][k]; - dAssert((error * error) < dFloat(1.0e-4f)); - } - } - #endif - - eigenValues = d; - return eigenVectors.Transpose(); -} - -//void dMatrix::PolarDecomposition (dMatrix& orthogonal, dMatrix& symetric) const -void dMatrix::PolarDecomposition (dMatrix& transformMatrix, dVector& scale, dMatrix& stretchAxis, const dMatrix& initialStretchAxis) const -{ - // a polar decomposition decompose matrix A = O * S - // where S = sqrt (transpose (L) * L) - - // calculate transpose (L) * L - dMatrix LL ((*this) * Transpose()); - - // check is this si a pure uniformScale * rotation * translation - dFloat det2 = (LL[0][0] + LL[1][1] + LL[2][2]) * (1.0f / 3.0f); - - dFloat invdet2 = dFloat (1.0f) / det2; - - dMatrix pureRotation (LL); - pureRotation[0] = pureRotation[0].Scale (invdet2); - pureRotation[1] = pureRotation[1].Scale (invdet2); - pureRotation[2] = pureRotation[2].Scale (invdet2); - - const dMatrix& me = *this; - dFloat sign = me[2].DotProduct3 (me[0].CrossProduct(me[1])) > 0.0f ? 1.0f : -1.0f; - dFloat det = pureRotation[2].DotProduct3 (pureRotation[0].CrossProduct(pureRotation[1])); - if (dAbs (det - 1.0f) < 1.e-5f){ - // this is a pure scale * rotation * translation - det = sign * dSqrt (det2); - scale[0] = det; - scale[1] = det; - scale[2] = det; - scale[3] = dFloat (1.0f); - det = dFloat (1.0f)/ det; - transformMatrix.m_front = m_front.Scale (det); - transformMatrix.m_up = m_up.Scale (det); - transformMatrix.m_right = m_right.Scale (det); - transformMatrix[0][3] = dFloat (0.0f); - transformMatrix[1][3] = dFloat (0.0f); - transformMatrix[2][3] = dFloat (0.0f); - transformMatrix.m_posit = m_posit; - stretchAxis = dGetIdentityMatrix(); - - } else { - stretchAxis = LL.JacobiDiagonalization(scale, initialStretchAxis); - - // I need to deal with buy seeing of some of the Scale are duplicated - // do this later (maybe by a given rotation around the non uniform axis but I do not know if it will work) - // for now just us the matrix - - scale[0] = sign * dSqrt (scale[0]); - scale[1] = sign * dSqrt (scale[1]); - scale[2] = sign * dSqrt (scale[2]); - scale[3] = dFloat (1.0f); - - dMatrix scaledAxis; - scaledAxis[0] = stretchAxis[0].Scale (1.0f / scale[0]); - scaledAxis[1] = stretchAxis[1].Scale (1.0f / scale[1]); - scaledAxis[2] = stretchAxis[2].Scale (1.0f / scale[2]); - scaledAxis[3] = stretchAxis[3]; - dMatrix symetricInv (stretchAxis.Transpose() * scaledAxis); - - transformMatrix = symetricInv * (*this); - transformMatrix.m_posit = m_posit; - } -} - -dMatrix::dMatrix (const dMatrix& transformMatrix, const dVector& scale, const dMatrix& stretchAxis) - :m_front(dFloat (0.0f)) - ,m_up(dFloat (0.0f)) - ,m_right(dFloat (0.0f)) - ,m_posit(dFloat (0.0f)) -{ - dMatrix scaledAxis; - scaledAxis[0] = stretchAxis[0].Scale (scale[0]); - scaledAxis[1] = stretchAxis[1].Scale (scale[1]); - scaledAxis[2] = stretchAxis[2].Scale (scale[2]); - scaledAxis[3] = stretchAxis[3]; - - *this = stretchAxis.Transpose() * scaledAxis * transformMatrix; -} - -dSpatialMatrix dSpatialMatrix::Inverse(int rows) const -{ - dSpatialMatrix tmp(*this); - dSpatialMatrix inv(dFloat (0.0f)); - for (int i = 0; i < rows; i++) { - inv[i][i] = dFloat (1.0f); - } - -#if 0 - for (int i = 0; i < rows; i++) { - dFloat val = tmp[i][i]; - dAssert(dAbs(val) > 1.0e-12f); - dFloat den = dFloat (1.0f) / val; - - tmp[i] = tmp[i].Scale(den); - tmp[i][i] = dFloat (1.0f); - inv[i] = inv[i].Scale(den); - - for (int j = 0; j < i; j++) { - dFloat pivot = -tmp[j][i]; - tmp[j] = tmp[j] + tmp[i].Scale(pivot); - inv[j] = inv[j] + inv[i].Scale(pivot); - } - - for (int j = i + 1; j < rows; j++) { - dFloat pivot = -tmp[j][i]; - tmp[j] = tmp[j] + tmp[i].Scale(pivot); - inv[j] = inv[j] + inv[i].Scale(pivot); - } - } - -#else - - for (int i = 0; i < rows; i++) { - dFloat pivot = dAbs(tmp[i][i]); - dAssert(pivot >= 0.01f); - if (pivot <= 0.01f) { - int permute = i; - for (int j = i + 1; j < rows; j++) { - dFloat pivot1 = dAbs(tmp[j][i]); - if (pivot1 > pivot) { - permute = j; - pivot = pivot1; - } - } - dAssert(pivot > dFloat(1.0e-6f)); - if (permute != i) { - for (int j = 0; j < rows; j++) { - dSwap(tmp[i][j], tmp[permute][j]); - dSwap(tmp[i][j], tmp[permute][j]); - } - } - } - - for (int j = i + 1; j < rows; j++) { - dFloat scale = tmp[j][i] / tmp[i][i]; - tmp[j][i] = dFloat (0.0f); - for (int k = i + 1; k < rows; k++) { - tmp[j][k] -= scale * tmp[i][k]; - } - for (int k = 0; k <= i; k++) { - inv[j][k] -= scale * inv[i][k]; - } - } - } - - for (int i = rows - 1; i >= 0; i--) { - dSpatialVector acc(dFloat (0.0f)); - for (int j = i + 1; j < rows; j++) { - dFloat pivot = tmp[i][j]; - for (int k = 0; k < rows; k++) { - acc[k] += pivot * inv[j][k]; - } - } - dFloat den = dFloat (1.0f) / tmp[i][i]; - for (int k = 0; k < rows; k++) { - inv[i][k] = den * (inv[i][k] - acc[k]); - } - } -#endif - -#ifdef _DEBUG - for (int i = 0; i < rows; i++) { - for (int j = 0; j < rows; j++) { - tmp[i][j] = m_rows[j][i]; - } - } - for (int i = 0; i < rows; i++) { - dSpatialVector v(inv.VectorTimeMatrix (tmp[i], rows)); - dAssert (dAbs (v[i] - dFloat (1.0f)) < dFloat(1.0e-5f)); - for (int j = 0; j < rows; j++) { - if (j != i) { - dAssert (dAbs (v[j]) < dFloat(1.0e-5f)); - } - } - } -#endif - - return inv; -} - diff --git a/thirdparty/src/newton/dMath/dMatrix.h b/thirdparty/src/newton/dMath/dMatrix.h deleted file mode 100644 index f499f5014..000000000 --- a/thirdparty/src/newton/dMath/dMatrix.h +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - - -#ifndef __dMatrix__ -#define __dMatrix__ - -#include "dVector.h" - -class dMatrix; -class dQuaternion; -class dQuaternion; - -dMatrix dGetZeroMatrix (); -dMatrix dGetIdentityMatrix(); - -class dMatrix -{ - public: - dMatrix (); - dMatrix (const dFloat* const array); -#ifndef _NEWTON_USE_DOUBLE - dMatrix (const dFloat64* const array); -#endif - dMatrix (const dVector &front, const dVector &up, const dVector &right, const dVector &posit); - dMatrix (const dQuaternion &rotation, const dVector &position); - dMatrix (dFloat pitch, dFloat yaw, dFloat roll, const dVector& location); - - dVector& operator[] (int i); - const dVector& operator[] (int i) const; - - dMatrix Inverse () const; - dMatrix Transpose () const; - dMatrix Transpose4X4 () const; - - dVector RotateVector (const dVector &v) const; - dVector UnrotateVector (const dVector &v) const; - dVector TransformVector (const dVector &v) const; - dVector UntransformVector (const dVector &v) const; - dVector TransformPlane (const dVector &localPlane) const; - dVector UntransformPlane (const dVector &globalPlane) const; - void GetEulerAngles(dVector& euler1, dVector& euler2, dEulerAngleOrder order = m_pitchYawRoll) const; - - bool TestIdentity() const; - bool TestOrthogonal() const; - dMatrix Inverse4x4() const; - dVector RotateVector4x4 (const dVector &v) const; - dMatrix JacobiDiagonalization (dVector& eigenValues, const dMatrix& initialMatrix = dGetIdentityMatrix()) const; - - // decompose this matrix into [this = transpose(stretchAxis) * matrix(scale) * stretchAxis * transformMatrix]; - void PolarDecomposition (dMatrix& transformMatrix, dVector& scale, dMatrix& stretchAxis, const dMatrix& initialStretchAxis = dGetIdentityMatrix()) const; - - // constructor for polar composition - dMatrix (const dMatrix& transformMatrix, const dVector& scale, const dMatrix& stretchAxis); - - void TransformTriplex (dFloat* const dst, int dstStrideInBytes, const dFloat* const src, int srcStrideInBytes, int count) const; -#ifndef _NEWTON_USE_DOUBLE - void TransformTriplex (dFloat64* const dst, int dstStrideInBytes, const dFloat64* const src, int srcStrideInBytes, int count) const; -#endif - - dMatrix operator* (const dMatrix & B) const; - - void Trace () const - { - dTrace (("(%ff, %ff, %ff, %ff)\n", m_front.m_x, m_front.m_y, m_front.m_z, m_front.m_w)); - dTrace (("(%ff, %ff, %ff, %ff)\n", m_up.m_x, m_up.m_y, m_up.m_z, m_up.m_w)); - dTrace (("(%ff, %ff, %ff, %ff)\n", m_right.m_x, m_right.m_y, m_right.m_z, m_right.m_w)); - dTrace (("(%ff, %ff, %ff, %ff)\n", m_posit.m_x, m_posit.m_y, m_posit.m_z, m_posit.m_w)); - } - - - bool SanityCheck() const; - - dVector m_front; - dVector m_up; - dVector m_right; - dVector m_posit; -}; - -inline dMatrix::dMatrix () -{ -} - -inline dMatrix::dMatrix (const dVector &front, const dVector &up, const dVector &right, const dVector &posit) - :m_front (front), m_up(up), m_right(right), m_posit(posit) -{ -} - -inline dMatrix::dMatrix (const dFloat* const array) -{ - memcpy (&(*this)[0][0], array, sizeof (dMatrix)); -} - -#ifndef _NEWTON_USE_DOUBLE -inline dMatrix::dMatrix (const dFloat64* const array) -{ - dFloat* const ptr = &(*this)[0][0]; - for (int i = 0; i < 16; i ++) { - ptr[i] = dFloat (array[i]); - } -} -#endif - -inline dVector& dMatrix::operator[] (int i) -{ - return (&m_front)[i]; -} - -inline const dVector& dMatrix::operator[] (int i) const -{ - return (&m_front)[i]; -} - -dMatrix dRollMatrix(dFloat ang); -dMatrix dYawMatrix(dFloat ang); -dMatrix dPitchMatrix(dFloat ang); -dMatrix dGrammSchmidt(const dVector& dir); - - -class dSpatialMatrix -{ - public: - inline dSpatialMatrix() - { - } - - inline dSpatialMatrix(dFloat val) - { - for (int i = 0; i < 6; i++) { - m_rows[i] = dSpatialVector(val); - } - } - - inline dSpatialVector& operator[] (int i) - { - dAssert(i < 6); - dAssert(i >= 0); - return m_rows[i]; - } - - inline const dSpatialVector& operator[] (int i) const - { - dAssert(i < 6); - dAssert(i >= 0); - return m_rows[i]; - } - - dSpatialMatrix Inverse(int rows) const; - - inline dSpatialVector VectorTimeMatrix(const dSpatialVector& jacobian) const - { - dSpatialVector tmp(m_rows[0].Scale(jacobian[0])); - for (int i = 1; i < 6; i++) { - tmp = tmp + m_rows[i].Scale(jacobian[i]); - } - return tmp; - } - - inline dSpatialVector VectorTimeMatrix(const dSpatialVector& jacobian, int dof) const - { - dSpatialVector tmp(0.0f); - for (int i = 0; i < dof; i++) { - tmp = tmp + m_rows[i].Scale(jacobian[i]); - } - return tmp; - } - - dSpatialVector m_rows[6]; -}; - - -#endif - diff --git a/thirdparty/src/newton/dMath/dQuaternion.cpp b/thirdparty/src/newton/dMath/dQuaternion.cpp deleted file mode 100644 index 2bfca38d8..000000000 --- a/thirdparty/src/newton/dMath/dQuaternion.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dStdAfxMath.h" -#include "dMathDefines.h" -#include "dVector.h" -#include "dMatrix.h" -#include "dQuaternion.h" - -enum QUAT_INDEX -{ - X_INDEX = 0, - Y_INDEX = 1, - Z_INDEX = 2 -}; -static QUAT_INDEX QIndex[] = { Y_INDEX, Z_INDEX, X_INDEX }; - -dQuaternion::dQuaternion (const dMatrix &matrix) -{ - dFloat trace = matrix[0][0] + matrix[1][1] + matrix[2][2]; - dAssert (matrix[2].DotProduct3(matrix[0].CrossProduct(matrix[1])) > 0.0f); - - if (trace > dFloat(0.0f)) { - trace = dSqrt (trace + dFloat(1.0f)); - m_w = dFloat (0.5f) * trace; - trace = dFloat (0.5f) / trace; - m_x = (matrix[1][2] - matrix[2][1]) * trace; - m_y = (matrix[2][0] - matrix[0][2]) * trace; - m_z = (matrix[0][1] - matrix[1][0]) * trace; - - } else { - - QUAT_INDEX i = X_INDEX; - if (matrix[Y_INDEX][Y_INDEX] > matrix[X_INDEX][X_INDEX]) { - i = Y_INDEX; - } - if (matrix[Z_INDEX][Z_INDEX] > matrix[i][i]) { - i = Z_INDEX; - } - QUAT_INDEX j = QIndex [i]; - QUAT_INDEX k = QIndex [j]; - - trace = dFloat(1.0f) + matrix[i][i] - matrix[j][j] - matrix[k][k]; - trace = dSqrt (trace); - - dFloat* const ptr = &m_x; - ptr[i] = dFloat (0.5f) * trace; - trace = dFloat (0.5f) / trace; - m_w = (matrix[j][k] - matrix[k][j]) * trace; - ptr[j] = (matrix[i][j] + matrix[j][i]) * trace; - ptr[k] = (matrix[i][k] + matrix[k][i]) * trace; - } - -#if _DEBUG - - dMatrix tmp (*this, matrix.m_posit); - dMatrix unitMatrix (tmp * matrix.Inverse()); - for (int i = 0; i < 4; i ++) { - dFloat err = dAbs (unitMatrix[i][i] - dFloat(1.0f)); - dAssert (err < dFloat (1.0e-3f)); - } - - dFloat err = dAbs (DotProduct(*this) - dFloat(1.0f)); - dAssert (err < dFloat(1.0e-3f)); -#endif - -} - -dQuaternion::dQuaternion (const dVector &unitAxis, dFloat angle) -{ - angle *= dFloat (0.5f); - m_w = dCos (angle); - dFloat sinAng = dSin (angle); - -#ifdef _DEBUG - if (dAbs (angle) > dFloat(1.0e-6f)) { - dAssert (dAbs (dFloat(1.0f) - unitAxis.DotProduct3(unitAxis)) < dFloat(1.0e-3f)); - } -#endif - m_x = unitAxis.m_x * sinAng; - m_y = unitAxis.m_y * sinAng; - m_z = unitAxis.m_z * sinAng; -} - -dVector dQuaternion::CalcAverageOmega (const dQuaternion &q1, dFloat invdt) const -{ - dQuaternion q0 (*this); - if (q0.DotProduct (q1) < 0.0f) { - q0.Scale(-1.0f); - } - dQuaternion dq (q0.Inverse() * q1); - dVector omegaDir (dq.m_x, dq.m_y, dq.m_z); - - dFloat dirMag2 = omegaDir.DotProduct3(omegaDir); - if (dirMag2 < dFloat(dFloat (1.0e-5f) * dFloat (1.0e-5f))) { - return dVector (dFloat(0.0f)); - } - - dFloat dirMagInv = dFloat (1.0f) / dSqrt (dirMag2); - dFloat dirMag = dirMag2 * dirMagInv; - - dFloat omegaMag = dFloat(2.0f) * dAtan2 (dirMag, dq.m_w) * invdt; - return omegaDir.Scale (dirMagInv * omegaMag); -} - -dQuaternion dQuaternion::Slerp (const dQuaternion &q1, dFloat t) const -{ - dQuaternion q; - - dFloat dot = DotProduct (q1); - dAssert (dot >= 0.0f); - - if ((dot + dFloat(1.0f)) > dFloat(1.0e-5f)) { - dFloat Sclp; - dFloat Sclq; - if (dot < dFloat(0.995f)) { - - dFloat ang = dAcos (dot); - dFloat sinAng = dSin (ang); - - dFloat den = dFloat(1.0f) / sinAng; - - Sclp = dSin ((dFloat(1.0f) - t ) * ang) * den; - Sclq = dSin (t * ang) * den; - - } else { - Sclp = dFloat(1.0f) - t; - Sclq = t; - } - - q.m_w = m_w * Sclp + q1.m_w * Sclq; - q.m_x = m_x * Sclp + q1.m_x * Sclq; - q.m_y = m_y * Sclp + q1.m_y * Sclq; - q.m_z = m_z * Sclp + q1.m_z * Sclq; - - } else { - q.m_w = m_z; - q.m_x = -m_y; - q.m_y = m_x; - q.m_z = m_w; - - dFloat Sclp = dSin ((dFloat(1.0f) - t) * dFloat (dPi *0.5f)); - dFloat Sclq = dSin (t * dFloat (dPi * 0.5f)); - - q.m_w = m_w * Sclp + q.m_w * Sclq; - q.m_x = m_x * Sclp + q.m_x * Sclq; - q.m_y = m_y * Sclp + q.m_y * Sclq; - q.m_z = m_z * Sclp + q.m_z * Sclq; - } - - dot = q.DotProduct (q); - if ((dot) < (1.0f - 1.0e-4f) ) { - dot = dFloat(1.0f) / dSqrt (dot); - //dot = dgRsqrt (dot); - q.m_w *= dot; - q.m_x *= dot; - q.m_y *= dot; - q.m_z *= dot; - } - return q; -} - -dVector dQuaternion::RotateVector (const dVector& point) const -{ - dMatrix matrix (*this, dVector (0.0f, 0.0f, 0.0f, 1.0f)); - return matrix.RotateVector(point); -} - -dVector dQuaternion::UnrotateVector (const dVector& point) const -{ - dMatrix matrix (*this, dVector (0.0f, 0.0f, 0.0f, 1.0f)); - return matrix.UnrotateVector(point); -} - -void dQuaternion::GetEulerAngles(dVector& euler1, dVector& euler2, dEulerAngleOrder order) const -{ - dMatrix matrix (*this, dVector (0.0f,0.0f,0.0f,1.0f)); - //return matrix.GetEulerAngles (order); - matrix.GetEulerAngles (euler1, euler2, order); -} - -dQuaternion dQuaternion::IntegrateOmega (const dVector& omega, dFloat timestep) const -{ - // this is correct - dQuaternion rotation (*this); - dFloat omegaMag2 = omega.DotProduct3(omega); - const dFloat errAngle = 0.0125f * dDegreeToRad; - const dFloat errAngle2 = errAngle * errAngle; - if (omegaMag2 > errAngle2) { - dFloat invOmegaMag = 1.0f / dSqrt (omegaMag2); - dVector omegaAxis (omega.Scale (invOmegaMag)); - dFloat omegaAngle = invOmegaMag * omegaMag2 * timestep; - dQuaternion deltaRotation (omegaAxis, omegaAngle); - rotation = rotation * deltaRotation; - rotation.Scale(1.0f / dSqrt (rotation.DotProduct (rotation))); - } - return rotation; -} diff --git a/thirdparty/src/newton/dMath/dQuaternion.h b/thirdparty/src/newton/dMath/dQuaternion.h deleted file mode 100644 index 4daee1f20..000000000 --- a/thirdparty/src/newton/dMath/dQuaternion.h +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#ifndef __dQuaternion__ -#define __dQuaternion__ - -#include "dVector.h" -class dMatrix; - -D_MSC_VECTOR_ALIGNMENT -class dQuaternion -{ - public: - dQuaternion (); - dQuaternion (const dMatrix& matrix); - //dQuaternion (dFloat w, dFloat x, dFloat y, dFloat z); - dQuaternion (dFloat x, dFloat y, dFloat z, dFloat w); - dQuaternion (const dVector& unit_Axis, dFloat Angle = 0.0f); - - void Scale (dFloat scale); - void Normalize (); - inline dFloat DotProduct (const dQuaternion& q) const; - dQuaternion Inverse () const; - - dVector RotateVector (const dVector& point) const; - dVector UnrotateVector (const dVector& point) const; - - void GetEulerAngles(dVector& euler1, dVector& euler2, dEulerAngleOrder order = m_pitchYawRoll) const; - dVector CalcAverageOmega (const dQuaternion &q1, dFloat invdt) const; - dQuaternion Slerp (const dQuaternion &q1, dFloat t) const; - dQuaternion IntegrateOmega (const dVector& omega, dFloat timestep) const; - - dQuaternion operator* (const dQuaternion &q) const; - dQuaternion operator+ (const dQuaternion &q) const; - dQuaternion operator- (const dQuaternion &q) const; - - dFloat m_x; - dFloat m_y; - dFloat m_z; - dFloat m_w; -}; - -inline dQuaternion::dQuaternion () - :m_x(0.0f) - ,m_y(0.0f) - ,m_z(0.0f) - ,m_w(1.0f) -{ -} - -inline dQuaternion::dQuaternion (dFloat x, dFloat y, dFloat z, dFloat w) - :m_x(x) - ,m_y(y) - ,m_z(z) - ,m_w(w) -{ -} - -inline void dQuaternion::Scale (dFloat scale) -{ - m_w *= scale; - m_x *= scale; - m_y *= scale; - m_z *= scale; -} - -inline void dQuaternion::Normalize () -{ - Scale (1.0f / dSqrt (DotProduct (*this))); -} - -inline dFloat dQuaternion::DotProduct (const dQuaternion &q1) const -{ - return m_w * q1.m_w + m_x * q1.m_x + m_y * q1.m_y + m_z * q1.m_z; -} - -inline dQuaternion dQuaternion::Inverse () const -{ - return dQuaternion (-m_x, -m_y, -m_z, m_w); -} - -inline dQuaternion dQuaternion::operator+ (const dQuaternion &q) const -{ - return dQuaternion (m_x + q.m_x, m_y + q.m_y, m_z + q.m_z, m_w + q.m_w); -} - -inline dQuaternion dQuaternion::operator- (const dQuaternion &B) const -{ - return dQuaternion (m_x - B.m_x, m_y - B.m_y, m_z - B.m_z, m_w - B.m_w); -} - -inline dQuaternion dQuaternion::operator* (const dQuaternion &q) const -{ - return dQuaternion (q.m_x * m_w + q.m_w * m_x - q.m_z * m_y + q.m_y * m_z, - q.m_y * m_w + q.m_z * m_x + q.m_w * m_y - q.m_x * m_z, - q.m_z * m_w - q.m_y * m_x + q.m_x * m_y + q.m_w * m_z, - q.m_w * m_w - q.m_x * m_x - q.m_y * m_y - q.m_z * m_z); -} - -#endif - diff --git a/thirdparty/src/newton/dMath/dStdAfxMath.cpp b/thirdparty/src/newton/dMath/dStdAfxMath.cpp deleted file mode 100644 index 70c490abd..000000000 --- a/thirdparty/src/newton/dMath/dStdAfxMath.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -// stdafx.cpp : source file that includes just the standard includes -// MinimalMath.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "dStdAfxMath.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file - diff --git a/thirdparty/src/newton/dMath/dStdAfxMath.h b/thirdparty/src/newton/dMath/dStdAfxMath.h deleted file mode 100644 index eb3a39ca5..000000000 --- a/thirdparty/src/newton/dMath/dStdAfxMath.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#ifndef __STDAFXMATH_H__ -#define __STDAFXMATH_H__ - - -#ifdef _MSC_VER - #ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - #endif - #include <windows.h> - #include <crtdbg.h> -#endif - -#if ( defined (__MINGW32__) || defined (__MINGW64__) ) - #include <crtdbg.h> -#endif - -#include <stdio.h> -#include <assert.h> -#endif - diff --git a/thirdparty/src/newton/dMath/dVector.cpp b/thirdparty/src/newton/dMath/dVector.cpp deleted file mode 100644 index a6c0e6ecd..000000000 --- a/thirdparty/src/newton/dMath/dVector.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#include "dStdAfxMath.h" - diff --git a/thirdparty/src/newton/dMath/dVector.h b/thirdparty/src/newton/dMath/dVector.h deleted file mode 100644 index a7f4f2892..000000000 --- a/thirdparty/src/newton/dMath/dVector.h +++ /dev/null @@ -1,328 +0,0 @@ -/* Copyright (c) <2003-2019> <Newton Game Dynamics> -* -* 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 -*/ - -#ifndef __dVector__ -#define __dVector__ - - -#include "dMathDefines.h" - - -// small but very effective 4 dimensional template vector class - -template<class T> -class TemplateVector -{ - public: - TemplateVector (); - TemplateVector (const T val); - TemplateVector (const T* const ptr); - TemplateVector (T m_x, T m_y, T m_z, T m_w = T(1.0f)); - TemplateVector Scale (T s) const; - - T& operator[] (int i); - const T& operator[] (int i) const; - - TemplateVector operator+ (const TemplateVector &A) const; - TemplateVector operator- (const TemplateVector &A) const; - TemplateVector operator* (const TemplateVector &A) const; - TemplateVector& operator+= (const TemplateVector &A); - TemplateVector& operator-= (const TemplateVector &A); - TemplateVector& operator*= (const TemplateVector &A); - - TemplateVector Abs() const; - TemplateVector Min(const TemplateVector &A) const; - TemplateVector Max(const TemplateVector &A) const; - - T DotProduct3 (const TemplateVector &A) const; - TemplateVector Normalize () const; - TemplateVector CrossProduct (const TemplateVector &A) const; - - T m_x; - T m_y; - T m_z; - T m_w; -}; - -class dVector: public TemplateVector<dFloat> -{ - public: - dVector() - :TemplateVector<dFloat>() - { - } - - dVector(dFloat val) - :TemplateVector<dFloat>(val) - { - } - - dVector (const TemplateVector<dFloat>& v) - :TemplateVector<dFloat>(v) - { - } - - dVector (const dFloat* const ptr) - :TemplateVector<dFloat>(ptr) - { - } - - dVector (dFloat x, dFloat y, dFloat z, dFloat w = 1.0f) - :TemplateVector<dFloat>(x, y, z, w) - { - } - -#ifndef _NEWTON_USE_DOUBLE - dVector (const TemplateVector<dFloat64>& v) - :TemplateVector<dFloat>(dFloat(v.m_x), dFloat(v.m_y), dFloat(v.m_z), dFloat(v.m_w)) - { - } -#endif -}; - - -class dBigVector: public TemplateVector<dFloat64> -{ - public: - dBigVector(){}; - dBigVector(dFloat64 val) - :TemplateVector<dFloat64> (val) - { - } - - dBigVector (const dFloat64* const ptr) - :TemplateVector<dFloat64> (ptr) - { - } - - dBigVector (const TemplateVector<dFloat64>& v) - :TemplateVector<dFloat64> (v.m_x, v.m_y, v.m_z, v.m_w) - { - } - - dBigVector(const dVector& v) - :TemplateVector<dFloat64>(v.m_x, v.m_y, v.m_z, v.m_w) - { - } - - dBigVector (dFloat64 x, dFloat64 y, dFloat64 z, dFloat64 w = dFloat(1.0f)) - :TemplateVector<dFloat64> (x, y, z, w) - { - } -}; - - -template<class T> -TemplateVector<T>::TemplateVector() -{ -} - -template<class T> -TemplateVector<T>::TemplateVector(const T val) - :m_x (val), m_y(val), m_z(val), m_w(val) -{ -} - -template<class T> -TemplateVector<T>::TemplateVector(const T *ptr) - :m_x (ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w(0.0f) -{ -} - -template<class T> -TemplateVector<T>::TemplateVector(T x, T y, T z, T w) - :m_x (x), m_y(y), m_z(z), m_w(w) -{ -} - -template<class T> -T& TemplateVector<T>::operator[] (int i) -{ - return (&m_x)[i]; -} - -template<class T> -const T& TemplateVector<T>::operator[] (int i) const -{ - return (&m_x)[i]; -} - -template<class T> -TemplateVector<T> TemplateVector<T>::Scale (T scale) const -{ - return TemplateVector<T> (m_x * scale, m_y * scale, m_z * scale, m_w); -} - -template<class T> -TemplateVector<T> TemplateVector<T>::operator+ (const TemplateVector<T>& B) const -{ - return TemplateVector<T> (m_x + B.m_x, m_y + B.m_y, m_z + B.m_z, m_w); -} - -template<class T> -TemplateVector<T> TemplateVector<T>::operator* (const TemplateVector<T>& B) const -{ - return TemplateVector<T>(m_x * B.m_x, m_y * B.m_y, m_z * B.m_z, m_w); -} - - -template<class T> -TemplateVector<T>& TemplateVector<T>::operator+= (const TemplateVector<T>& A) -{ - m_x += A.m_x; - m_y += A.m_y; - m_z += A.m_z; - return *this; -} - -template<class T> -TemplateVector<T> TemplateVector<T>::operator- (const TemplateVector<T>& A) const -{ - return TemplateVector<T> (m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w); -} - -template<class T> -TemplateVector<T>& TemplateVector<T>::operator-= (const TemplateVector<T>& A) -{ - m_x -= A.m_x; - m_y -= A.m_y; - m_z -= A.m_z; - return *this; -} - -template<class T> -TemplateVector<T>& TemplateVector<T>::operator*= (const TemplateVector<T>& A) -{ - m_x *= A.m_x; - m_y *= A.m_y; - m_z *= A.m_z; - //m_w *= A.m_w; - return *this; -} - -template<class T> -TemplateVector<T> TemplateVector<T>::Abs() const -{ - return dVector(dAbs(m_x), dAbs(m_y), dAbs(m_z), dAbs(m_w)); -} - -template<class T> -TemplateVector<T> TemplateVector<T>::Min(const TemplateVector &A) const -{ - return dVector (dMin (m_x, A.m_x), dMin (m_y, A.m_y), dMin (m_z, A.m_z), dMin (m_w, A.m_w)); -} - -template<class T> -TemplateVector<T> TemplateVector<T>::Max(const TemplateVector &A) const -{ - return dVector (dMax (m_x, A.m_x), dMax (m_y, A.m_y), dMax (m_z, A.m_z), dMax (m_w, A.m_w)); -} - - -template<class T> -T TemplateVector<T>::DotProduct3 (const TemplateVector<T>& A) const -{ - return m_x * A.m_x + m_y * A.m_y + m_z * A.m_z; -} - -template<class T> -TemplateVector<T> TemplateVector<T>::Normalize () const -{ - T mag (DotProduct3(*this)); - return Scale (1.0f / T(sqrt (mag))); -} - -template<class T> -TemplateVector<T> TemplateVector<T>::CrossProduct (const TemplateVector<T>& A) const -{ - return TemplateVector<T> (m_y * A.m_z - m_z * A.m_y, m_z * A.m_x - m_x * A.m_z, m_x * A.m_y - m_y * A.m_x, m_w); -} - - -class dSpatialVector -{ - public: - inline dSpatialVector() - { - } - - inline dSpatialVector(const dFloat a) - { - for (int i = 0; i < 6; i++) { - m_d[i] = a; - } - } - - inline dSpatialVector(const dVector& low, const dVector& high) - { - m_d[0] = low[0]; - m_d[1] = low[1]; - m_d[2] = low[2]; - m_d[3] = high[0]; - m_d[4] = high[1]; - m_d[5] = high[2]; - } - - inline dFloat& operator[] (int i) - { - dAssert(i < 6); - dAssert(i >= 0); - return m_d[i]; - } - - inline const dFloat& operator[] (int i) const - { - dAssert(i < 6); - dAssert(i >= 0); - return m_d[i]; - } - - inline dSpatialVector operator+ (const dSpatialVector& A) const - { - dSpatialVector tmp; - for (int i = 0; i < 6; i++) { - tmp[i] = m_d[i] + A.m_d[i]; - } - return tmp; - } - - inline dSpatialVector operator* (const dSpatialVector& A) const - { - dSpatialVector tmp; - for (int i = 0; i < 6; i++) { - tmp[i] = m_d[i] * A.m_d[i]; - } - return tmp; - } - - inline dFloat DotProduct(const dSpatialVector& v) const - { - dFloat acc = dFloat (0.0f); - for (int i = 0; i < 6; i++) { - acc += m_d[i] * v.m_d[i]; - } - return acc; - } - - inline dSpatialVector Scale(dFloat s) const - { - dSpatialVector tmp; - for (int i = 0; i < 6; i++) { - tmp[i] = m_d[i] * s; - } - return tmp; - } - - dFloat m_d[6]; -}; - -#endif - diff --git a/thirdparty/src/newton/dgCore/dg.cpp b/thirdparty/src/newton/dgCore/dg.cpp deleted file mode 100644 index 7b95b7001..000000000 --- a/thirdparty/src/newton/dgCore/dg.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" - - - - - diff --git a/thirdparty/src/newton/dgCore/dg.h b/thirdparty/src/newton/dgCore/dg.h deleted file mode 100644 index 39fc05afa..000000000 --- a/thirdparty/src/newton/dgCore/dg.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -#if !defined(AFX_DG_H__FGRTY_5GR39H_98TQ_H) -#define AFX_DG_H__FGRTY_5GR39H_98TQ_H - -#include "dgTypes.h" - -#include "dgRef.h" -#include "dgCRC.h" -#include "dgObb.h" -#include "dgRtti.h" -#include "dgList.h" -#include "dgTree.h" -#include "dgNode.h" -#include "dgHeap.h" -#include "dgSort.h" -#include "dgArray.h" -#include "dgStack.h" -#include "dgDebug.h" -#include "dgGraph.h" -#include "dgPlane.h" -#include "dgGoogol.h" -#include "dgVector.h" -#include "dgMatrix.h" -#include "dgMemory.h" -#include "dgRandom.h" -#include "dgThread.h" -#include "dgProfiler.h" -#include "dgFastQueue.h" -#include "dgPolyhedra.h" -#include "dgThreadHive.h" -#include "dgPathFinder.h" -#include "dgRefCounter.h" -#include "dgQuaternion.h" -#include "dgMutexThread.h" -#include "dgConvexHull3d.h" -#include "dgConvexHull4d.h" -#include "dgIntersections.h" -#include "dgGeneralVector.h" -#include "dgGeneralMatrix.h" -#include "dgAABBPolygonSoup.h" -#include "dgSmallDeterminant.h" -#include "dgPolygonSoupBuilder.h" -#include "dgPolygonSoupDatabase.h" -#include "dgPolyhedraMassProperties.h" -#include "dgDelaunayTetrahedralization.h" - -#endif diff --git a/thirdparty/src/newton/dgCore/dgAABBPolygonSoup.cpp b/thirdparty/src/newton/dgCore/dgAABBPolygonSoup.cpp deleted file mode 100644 index 9b5166c1c..000000000 --- a/thirdparty/src/newton/dgCore/dgAABBPolygonSoup.cpp +++ /dev/null @@ -1,1390 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgHeap.h" -#include "dgStack.h" -#include "dgList.h" -#include "dgMatrix.h" -#include "dgAABBPolygonSoup.h" -#include "dgPolygonSoupBuilder.h" - - -#define DG_STACK_DEPTH 512 - - -DG_MSC_VECTOR_ALIGNMENT -class dgAABBPolygonSoup::dgNodeBuilder: public dgAABBPolygonSoup::dgNode -{ - public: - dgNodeBuilder (const dgVector& p0, const dgVector& p1) - :dgNode() - ,m_left (NULL) - ,m_right (NULL) - ,m_parent (NULL) - ,m_indexBox0(0) - ,m_indexBox1(0) - ,m_enumeration(-1) - ,m_faceIndex(0) - ,m_indexCount(0) - ,m_faceIndices(NULL) - { - SetBox (p0, p1); - } - - dgNodeBuilder (const dgVector* const vertexArray, dgInt32 faceIndex, dgInt32 indexCount, const dgInt32* const indexArray) - :dgNode() - ,m_left (NULL) - ,m_right (NULL) - ,m_parent (NULL) - ,m_indexBox0(0) - ,m_indexBox1(0) - ,m_enumeration(-1) - ,m_faceIndex(faceIndex) - ,m_indexCount(indexCount) - ,m_faceIndices(indexArray) - { - dgVector minP ( dgFloat32 (1.0e15f)); - dgVector maxP (-dgFloat32 (1.0e15f)); - for (dgInt32 i = 0; i < indexCount; i ++) { - dgInt32 index = indexArray[i]; - const dgVector& p (vertexArray[index]); - minP = p.GetMin(minP); - maxP = p.GetMax(maxP); - } - minP -= dgVector (dgFloat32 (1.0e-3f)); - maxP += dgVector (dgFloat32 (1.0e-3f)); - minP = minP & dgVector::m_triplexMask; - maxP = maxP & dgVector::m_triplexMask; - SetBox (minP, maxP); - } - - dgNodeBuilder (dgNodeBuilder* const left, dgNodeBuilder* const right) - :dgNode() - ,m_left(left) - ,m_right(right) - ,m_parent(NULL) - ,m_indexBox0(0) - ,m_indexBox1(0) - ,m_enumeration(-1) - ,m_faceIndex(0) - ,m_indexCount(0) - ,m_faceIndices(NULL) - { - m_left->m_parent = this; - m_right->m_parent = this; - - dgVector p0 (left->m_p0.GetMin(right->m_p0)); - dgVector p1 (left->m_p1.GetMax(right->m_p1)); - SetBox(p0, p1); - } - - void SetBox (const dgVector& p0, const dgVector& p1) - { - m_p0 = p0; - m_p1 = p1; - m_size = m_p1 - m_p0; - m_origin = (m_p1 + m_p0) * dgVector::m_half; - m_area = m_size.DotProduct(m_size.ShiftTripleRight()).m_x; - } - - DG_INLINE static dgFloat32 CalculateSurfaceArea (dgNodeBuilder* const node0, dgNodeBuilder* const node1, dgVector& minBox, dgVector& maxBox) - { - minBox = node0->m_p0.GetMin(node1->m_p0); - maxBox = node0->m_p1.GetMax(node1->m_p1); - - dgVector side0 ((maxBox - minBox) * dgVector::m_half); - //dgVector side1 (side0.m_y, side0.m_z, side0.m_x, dgFloat32 (0.0f)); - dgVector side1 (side0.ShiftTripleLeft()); - return side0.DotProduct(side1).GetScalar(); - } - - dgVector m_p0; - dgVector m_p1; - dgVector m_size; - dgVector m_origin; - dgFloat32 m_area; - - dgNodeBuilder* m_left; - dgNodeBuilder* m_right; - dgNodeBuilder* m_parent; - dgInt32 m_indexBox0; - dgInt32 m_indexBox1; - dgInt32 m_enumeration; - dgInt32 m_faceIndex; - dgInt32 m_indexCount; - const dgInt32* m_faceIndices; -} DG_GCC_VECTOR_ALIGNMENT; - - - -class dgAABBPolygonSoup::dgSpliteInfo -{ - public: - dgSpliteInfo (dgNodeBuilder* const boxArray, dgInt32 boxCount) - { - dgVector minP ( dgFloat32 (1.0e15f)); - dgVector maxP (-dgFloat32 (1.0e15f)); - - if (boxCount == 2) { - m_axis = 1; - for (dgInt32 i = 0; i < boxCount; i ++) { - const dgNodeBuilder& box = boxArray[i]; - const dgVector& p0 = box.m_p0; - const dgVector& p1 = box.m_p1; - minP = minP.GetMin (p0); - maxP = maxP.GetMax (p1); - } - - } else { - dgVector median (dgFloat32 (0.0f)); - dgVector varian (dgFloat32 (0.0f)); - for (dgInt32 i = 0; i < boxCount; i ++) { - const dgNodeBuilder& box = boxArray[i]; - - const dgVector& p0 = box.m_p0; - const dgVector& p1 = box.m_p1; - - minP = minP.GetMin (p0); - maxP = maxP.GetMax (p1); - dgVector p (dgVector::m_half * (p0 + p1)); - - median += p; - varian += p * p; - } - - varian = varian.Scale (dgFloat32 (boxCount)) - median * median; - - dgInt32 index = 0; - dgFloat32 maxVarian = dgFloat32 (-1.0e10f); - for (dgInt32 i = 0; i < 3; i ++) { - if (varian[i] > maxVarian) { - index = i; - maxVarian = varian[i]; - } - } - - dgVector center = median.Scale (dgFloat32 (1.0f) / dgFloat32 (boxCount)); - dgFloat32 test = center[index]; - dgInt32 i0 = 0; - dgInt32 i1 = boxCount - 1; - do { - for (; i0 <= i1; i0 ++) { - const dgNodeBuilder& box = boxArray[i0]; - dgFloat32 val = (box.m_p0[index] + box.m_p1[index]) * dgFloat32 (0.5f); - if (val > test) { - break; - } - } - - for (; i1 >= i0; i1 --) { - const dgNodeBuilder& box = boxArray[i1]; - dgFloat32 val = (box.m_p0[index] + box.m_p1[index]) * dgFloat32 (0.5f); - if (val < test) { - break; - } - } - - if (i0 < i1) { - dgSwap(boxArray[i0], boxArray[i1]); - i0++; - i1--; - } - } while (i0 <= i1); - - if (i0 > 0){ - i0 --; - } - if ((i0 + 1) >= boxCount) { - i0 = boxCount - 2; - } - - m_axis = i0 + 1; - } - - dgAssert (maxP.m_x - minP.m_x >= dgFloat32 (0.0f)); - dgAssert (maxP.m_y - minP.m_y >= dgFloat32 (0.0f)); - dgAssert (maxP.m_z - minP.m_z >= dgFloat32 (0.0f)); - m_p0 = minP; - m_p1 = maxP; - } - - dgInt32 m_axis; - dgVector m_p0; - dgVector m_p1; -}; - - - -dgAABBPolygonSoup::dgAABBPolygonSoup () - :dgPolygonSoupDatabase() - ,m_nodesCount(0) - ,m_indexCount(0) - ,m_aabb(NULL) - ,m_indices(NULL) -{ -} - -dgAABBPolygonSoup::~dgAABBPolygonSoup () -{ - if (m_aabb) { - dgFreeStack (m_aabb); - dgFreeStack (m_indices); - } -} - - -void dgAABBPolygonSoup::ImproveNodeFitness (dgNodeBuilder* const node) const -{ - dgAssert (node->m_left); - dgAssert (node->m_right); - - if (node->m_parent) { - dgAssert(node->m_parent->m_p0.m_w == dgFloat32(0.0f)); - dgAssert(node->m_parent->m_p1.m_w == dgFloat32(0.0f)); - - if (node->m_parent->m_left == node) { - dgFloat32 cost0 = node->m_area; - - dgVector cost1P0; - dgVector cost1P1; - dgFloat32 cost1 = dgNodeBuilder::CalculateSurfaceArea (node->m_right, node->m_parent->m_right, cost1P0, cost1P1); - - dgVector cost2P0; - dgVector cost2P1; - dgFloat32 cost2 = dgNodeBuilder::CalculateSurfaceArea (node->m_left, node->m_parent->m_right, cost2P0, cost2P1); - - if ((cost1 <= cost0) && (cost1 <= cost2)) { - dgNodeBuilder* const parent = node->m_parent; - node->m_p0 = parent->m_p0; - node->m_p1 = parent->m_p1; - node->m_area = parent->m_area; - node->m_size = parent->m_size; - node->m_origin = parent->m_origin; - - if (parent->m_parent) { - if (parent->m_parent->m_left == parent) { - parent->m_parent->m_left = node; - } else { - dgAssert (parent->m_parent->m_right == parent); - parent->m_parent->m_right = node; - } - } - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_right->m_parent = parent; - parent->m_left = node->m_right; - node->m_right = parent; - parent->m_p0 = cost1P0; - parent->m_p1 = cost1P1; - parent->m_area = cost1; - parent->m_size = (parent->m_p1 - parent->m_p0) * dgVector::m_half; - parent->m_origin = (parent->m_p1 + parent->m_p0) * dgVector::m_half; - - } else if ((cost2 <= cost0) && (cost2 <= cost1)) { - dgNodeBuilder* const parent = node->m_parent; - node->m_p0 = parent->m_p0; - node->m_p1 = parent->m_p1; - node->m_area = parent->m_area; - node->m_size = parent->m_size; - node->m_origin = parent->m_origin; - - if (parent->m_parent) { - if (parent->m_parent->m_left == parent) { - parent->m_parent->m_left = node; - } else { - dgAssert (parent->m_parent->m_right == parent); - parent->m_parent->m_right = node; - } - } - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_left->m_parent = parent; - parent->m_left = node->m_left; - node->m_left = parent; - - parent->m_p0 = cost2P0; - parent->m_p1 = cost2P1; - parent->m_area = cost2; - parent->m_size = (parent->m_p1 - parent->m_p0) * dgVector::m_half; - parent->m_origin = (parent->m_p1 + parent->m_p0) * dgVector::m_half; - } - } else { - dgFloat32 cost0 = node->m_area; - - dgVector cost1P0; - dgVector cost1P1; - dgFloat32 cost1 = dgNodeBuilder::CalculateSurfaceArea (node->m_left, node->m_parent->m_left, cost1P0, cost1P1); - - dgVector cost2P0; - dgVector cost2P1; - dgFloat32 cost2 = dgNodeBuilder::CalculateSurfaceArea (node->m_right, node->m_parent->m_left, cost2P0, cost2P1); - - if ((cost1 <= cost0) && (cost1 <= cost2)) { - dgNodeBuilder* const parent = node->m_parent; - node->m_p0 = parent->m_p0; - node->m_p1 = parent->m_p1; - node->m_area = parent->m_area; - node->m_size = parent->m_size; - node->m_origin = parent->m_origin; - - if (parent->m_parent) { - if (parent->m_parent->m_left == parent) { - parent->m_parent->m_left = node; - } else { - dgAssert (parent->m_parent->m_right == parent); - parent->m_parent->m_right = node; - } - } - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_left->m_parent = parent; - parent->m_right = node->m_left; - node->m_left = parent; - - parent->m_p0 = cost1P0; - parent->m_p1 = cost1P1; - parent->m_area = cost1; - parent->m_size = (parent->m_p1 - parent->m_p0) * dgVector::m_half; - parent->m_origin = (parent->m_p1 + parent->m_p0) * dgVector::m_half; - - } else if ((cost2 <= cost0) && (cost2 <= cost1)) { - dgNodeBuilder* const parent = node->m_parent; - node->m_p0 = parent->m_p0; - node->m_p1 = parent->m_p1; - node->m_area = parent->m_area; - node->m_size = parent->m_size; - node->m_origin = parent->m_origin; - - if (parent->m_parent) { - if (parent->m_parent->m_left == parent) { - parent->m_parent->m_left = node; - } else { - dgAssert (parent->m_parent->m_right == parent); - parent->m_parent->m_right = node; - } - } - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_right->m_parent = parent; - parent->m_right = node->m_right; - node->m_right = parent; - - parent->m_p0 = cost2P0; - parent->m_p1 = cost2P1; - parent->m_area = cost2; - parent->m_size = (parent->m_p1 - parent->m_p0) * dgVector::m_half; - parent->m_origin = (parent->m_p1 + parent->m_p0) * dgVector::m_half; - } - } - } else { - // in the future I can handle this but it is too much work for little payoff - } -} - -dgFloat32 dgAABBPolygonSoup::CalculateFaceMaxSize (const dgVector* const vertex, dgInt32 indexCount, const dgInt32* const indexArray) const -{ - dgFloat32 maxSize = dgFloat32 (0.0f); - dgInt32 index = indexArray[indexCount - 1]; - dgVector p0 (vertex[index]); - for (dgInt32 i = 0; i < indexCount; i ++) { - dgInt32 index1 = indexArray[i]; - dgVector p1 (vertex[index1]); - - dgVector dir (p1 - p0); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dir = dir.Normalize(); - - dgFloat32 maxVal = dgFloat32 (-1.0e10f); - dgFloat32 minVal = dgFloat32 ( 1.0e10f); - for (dgInt32 j = 0; j < indexCount; j ++) { - dgInt32 index2 = indexArray[j]; - dgVector q (vertex[index2]); - dgFloat32 val = dir.DotProduct(q).GetScalar(); - minVal = dgMin(minVal, val); - maxVal = dgMax(maxVal, val); - } - - dgFloat32 size = maxVal - minVal; - maxSize = dgMax(maxSize, size); - p0 = p1; - } - - return dgFloor (maxSize + dgFloat32 (1.0f)); -} - -void dgAABBPolygonSoup::GetAABB (dgVector& p0, dgVector& p1) const -{ - if (m_aabb) { - GetNodeAABB (m_aabb, p0, p1); - } else { - p0 = dgVector::m_zero; - p1 = dgVector::m_zero; - } -} - -void dgAABBPolygonSoup::CalculateAdjacendy () -{ - dgVector p0; - dgVector p1; - GetAABB (p0, p1); - dgFastAABBInfo box (p0, p1); - ForAllSectors (box, dgVector (dgFloat32 (0.0f)), dgFloat32 (1.0f), CalculateAllFaceEdgeNormals, this); - - dgStack<dgTriplex> pool ((m_indexCount / 2) - 1); - const dgTriplex* const vertexArray = (dgTriplex*)GetLocalVertexPool(); - dgInt32 normalCount = 0; - for (dgInt32 i = 0; i < m_nodesCount; i ++) { - const dgNode* const node = &m_aabb[i]; - if (node->m_left.IsLeaf()) { - dgInt32 vCount = dgInt32 (node->m_left.GetCount()); - if (vCount) { - dgInt32 index = dgInt32 (node->m_left.GetIndex()); - dgInt32* const face = &m_indices[index]; - - dgInt32 j0 = 2 * (vCount + 1) - 1; - dgVector normal (&vertexArray[face[vCount + 1]].m_x); - normal = normal & dgVector::m_triplexMask; - dgAssert (dgAbs (normal.DotProduct(normal).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-6f)); - dgVector q0 (&vertexArray[face[vCount - 1]].m_x); - q0 = q0 & dgVector::m_triplexMask; - for (dgInt32 j = 0; j < vCount; j ++) { - dgInt32 j1 = vCount + 2 + j; - dgVector q1 (&vertexArray[face[j]].m_x); - q1 = q1 & dgVector::m_triplexMask; - if (face[j0] == -1) { - dgVector e (q1 - q0); - dgVector n (e.CrossProduct(normal)); - n = n.Scale(dgFloat32 (1.0f) / dgSqrt (n.DotProduct(n).GetScalar())); - dgAssert (dgAbs (n.DotProduct(n).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-6f)); - pool[normalCount].m_x = n.m_x; - pool[normalCount].m_y = n.m_y; - pool[normalCount].m_z = n.m_z; - face[j0] = -normalCount - 1; - normalCount ++; - } - q0 = q1; - j0 = j1; - } - } - } - - if (node->m_right.IsLeaf()) { - dgInt32 vCount = dgInt32 (node->m_right.GetCount()); - if (vCount) { - dgInt32 index = dgInt32 (node->m_right.GetIndex()); - dgInt32* const face = &m_indices[index]; - - dgInt32 j0 = 2 * (vCount + 1) - 1; - dgVector normal (&vertexArray[face[vCount + 1]].m_x); - normal = normal & dgVector::m_triplexMask; - dgAssert (dgAbs (normal.DotProduct(normal).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-6f)); - dgVector q0 (&vertexArray[face[vCount - 1]].m_x); - q0 = q0 & dgVector::m_triplexMask; - for (dgInt32 j = 0; j < vCount; j ++) { - dgInt32 j1 = vCount + 2 + j; - dgVector q1 (&vertexArray[face[j]].m_x); - q1 = q1 & dgVector::m_triplexMask; - if (face[j0] == -1) { - dgVector e (q1 - q0); - dgVector n (e.CrossProduct(normal)); - n = n.Scale(dgFloat32 (1.0f) / dgSqrt (n.DotProduct(n).GetScalar())); - dgAssert (dgAbs (n.DotProduct(n).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-6f)); - pool[normalCount].m_x = n.m_x; - pool[normalCount].m_y = n.m_y; - pool[normalCount].m_z = n.m_z; - face[j0] = -normalCount - 1; - normalCount ++; - } - q0 = q1; - j0 = j1; - } - } - } - } - - if (normalCount) { - dgStack<dgInt32> indexArray (normalCount); - dgInt32 newNormalCount = dgVertexListToIndexList (&pool[0].m_x, sizeof (dgTriplex), sizeof (dgTriplex), 0, normalCount, &indexArray[0], dgFloat32 (1.0e-6f)); - - dgInt32 oldCount = GetVertexCount(); - dgTriplex* const vertexArray1 = (dgTriplex*) dgMallocStack (sizeof (dgTriplex) * (oldCount + newNormalCount)); - memcpy (vertexArray1, GetLocalVertexPool(), sizeof (dgTriplex) * oldCount); - memcpy (&vertexArray1[oldCount], &pool[0].m_x, sizeof (dgTriplex) * newNormalCount); - dgFreeStack(GetLocalVertexPool()); - - m_localVertex = &vertexArray1[0].m_x; - m_vertexCount = oldCount + newNormalCount; - - for (dgInt32 i = 0; i < m_nodesCount; i ++) { - const dgNode* const node = &m_aabb[i]; - if (node->m_left.IsLeaf()) { - dgInt32 vCount = dgInt32 (node->m_left.GetCount()); - dgInt32 index = dgInt32 (node->m_left.GetIndex()); - dgInt32* const face = &m_indices[index]; - for (dgInt32 j = 0; j < vCount; j ++) { - if (face[vCount + 2 + j] < 0) { - dgInt32 k = -1 - face[vCount + 2 + j]; - face[vCount + 2 + j] = indexArray[k] + oldCount; - } - #ifdef _DEBUG - dgVector normal (&vertexArray1[face[vCount + 2 + j]].m_x); - normal = normal & dgVector::m_triplexMask; - dgAssert (dgAbs (normal.DotProduct(normal).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-6f)); - #endif - } - } - - if (node->m_right.IsLeaf()) { - dgInt32 vCount = dgInt32 (node->m_right.GetCount()); - dgInt32 index = dgInt32 (node->m_right.GetIndex()); - dgInt32* const face = &m_indices[index]; - for (dgInt32 j = 0; j < vCount; j ++) { - if (face[vCount + 2 + j] < 0) { - dgInt32 k = -1 - face[vCount + 2 + j]; - face[vCount + 2 + j] = indexArray[k] + oldCount; - } - - #ifdef _DEBUG - dgVector normal (&vertexArray1[face[vCount + 2 + j]].m_x); - normal = normal & dgVector::m_triplexMask; - dgAssert (dgAbs (normal.DotProduct(normal).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-6f)); - #endif - } - } - } - } -} - -dgIntersectStatus dgAABBPolygonSoup::CalculateAllFaceEdgeNormals (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance) -{ - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat32)); - - AdjacentdFace adjacentFaces; - adjacentFaces.m_count = indexCount; - adjacentFaces.m_index = (dgInt32*) indexArray; - - dgVector n (&polygon[indexArray[indexCount + 1] * stride]); - dgVector p (&polygon[indexArray[0] * stride]); - n = n & dgVector::m_triplexMask; - p = p & dgVector::m_triplexMask; - adjacentFaces.m_normal = dgPlane (n, - n.DotProduct(p).GetScalar()); - - dgAssert (indexCount < dgInt32 (sizeof (adjacentFaces.m_edgeMap) / sizeof (adjacentFaces.m_edgeMap[0]))); - - dgInt32 edgeIndex = indexCount - 1; - dgInt32 i0 = indexArray[indexCount - 1]; - dgVector p0 ( dgFloat32 (1.0e15f), dgFloat32 (1.0e15f), dgFloat32 (1.0e15f), dgFloat32 (0.0f)); - dgVector p1 (-dgFloat32 (1.0e15f), -dgFloat32 (1.0e15f), -dgFloat32 (1.0e15f), dgFloat32 (0.0f)); - for (dgInt32 i = 0; i < indexCount; i ++) { - dgInt32 i1 = indexArray[i]; - dgInt32 index = i1 * stride; - dgVector point (&polygon[index]); - point = point & dgVector::m_triplexMask; - p0 = p0.GetMin(point); - p1 = p1.GetMax(point); - adjacentFaces.m_edgeMap[edgeIndex] = (dgInt64 (i1) << 32) + i0; - edgeIndex = i; - i0 = i1; - } - - dgFloat32 padding = dgFloat32 (1.0f/16.0f); - p0.m_x -= padding; - p0.m_y -= padding; - p0.m_z -= padding; - p1.m_x += padding; - p1.m_y += padding; - p1.m_z += padding; - - dgAABBPolygonSoup* const me = (dgAABBPolygonSoup*) context; - dgFastAABBInfo box (p0, p1); - me->ForAllSectors (box, dgVector (dgFloat32 (0.0f)), dgFloat32 (1.0f), CalculateDisjointedFaceEdgeNormals, &adjacentFaces); - return t_ContinueSearh; -} - - -dgIntersectStatus dgAABBPolygonSoup::CalculateDisjointedFaceEdgeNormals (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance) -{ - #define DG_WELDING_TOL (1.0e-2f) - #define DG_WELDING_TOL2 (DG_WELDING_TOL * DG_WELDING_TOL) - - const AdjacentdFace& adjacentFace = *((AdjacentdFace*)context); - - if (adjacentFace.m_index != indexArray) { - dgInt32 adjacentCount = adjacentFace.m_count; - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat32)); - - dgInt32 j0 = adjacentCount - 1; - dgInt32 indexJ0 = adjacentFace.m_index[adjacentCount - 1]; - for (dgInt32 j = 0; j < adjacentCount; j ++) { - dgInt32 indexJ1 = adjacentFace.m_index[j]; - dgBigVector q0 (dgVector(&polygon[indexJ1 * stride]) & dgVector::m_triplexMask); - dgBigVector q1 (dgVector(&polygon[indexJ0 * stride]) & dgVector::m_triplexMask); - dgBigVector q1q0 (q1 - q0); - dgFloat64 q1q0Mag2 = q1q0.DotProduct(q1q0).GetScalar(); - - dgInt32 indexI0 = indexArray[indexCount - 1]; - for (dgInt32 i = 0; i < indexCount; i ++) { - dgInt32 indexI1 = indexArray[i]; - dgBigVector p0 (dgVector(&polygon[indexI0 * stride]) & dgVector::m_triplexMask); - dgBigVector p1 (dgVector(&polygon[indexI1 * stride]) & dgVector::m_triplexMask); - dgBigVector p1p0 (p1 - p0); - dgFloat64 dot = p1p0.DotProduct(q1q0).GetScalar(); - if (dot > 0.0f) { - dgFloat64 q1p0Mag2 = p1p0.DotProduct(p1p0).GetScalar(); - if ((dot * dot) >= (q1p0Mag2 * q1q0Mag2 * dgFloat64(0.99995f))) { - dgFloat64 x0 = q0.DotProduct(q1q0).GetScalar(); - dgFloat64 x1 = q1.DotProduct(q1q0).GetScalar(); - dgFloat64 y0 = p0.DotProduct(q1q0).GetScalar(); - dgFloat64 y1 = p1.DotProduct(q1q0).GetScalar(); - dgAssert (x1 > x0); - dgAssert (y1 > y0); - if (!((y0 >= x1) || (y1 <= x0))) { - dgFloat64 t = q1q0.DotProduct(p0 - q0).GetScalar() / q1q0Mag2; - dgAssert (q1q0.m_w == dgFloat32 (0.0f)); - dgBigVector q (q0 + q1q0.Scale(t)); - dgBigVector dist (p0 - q); - dgAssert (dist.m_w == dgFloat32 (0.0f)); - dgFloat64 err2 = dist.DotProduct(dist).GetScalar(); - if (err2 < DG_WELDING_TOL2) { - dgFloat32 maxDist = dgFloat32 (0.0f); - for (dgInt32 k = 0; k < indexCount; k ++) { - dgVector r (&polygon[indexArray[k] * stride]); - r = r & dgVector::m_triplexMask; - dgFloat32 dist1 = adjacentFace.m_normal.Evalue(r); - if (dgAbs (dist1) > dgAbs (maxDist)) { - maxDist = dist1; - } - } - - if (adjacentFace.m_index[j0 + adjacentCount + 2] == -1) { - if (maxDist < -dgFloat32 (1.0e-3f)) { - adjacentFace.m_index[j0 + adjacentCount + 2] = indexArray[indexCount + 1]; - } else { - adjacentFace.m_index[j0 + adjacentCount + 2] = adjacentFace.m_index[adjacentCount + 1]; - } - } else { - if (maxDist < -dgFloat32 (1.0e-3f)) { - dgBigVector n0 (adjacentFace.m_normal[0], adjacentFace.m_normal[1], adjacentFace.m_normal[2], dgFloat64(0.0f)); - dgBigVector n1 (dgVector(&polygon[adjacentFace.m_index[j0 + adjacentCount + 2] * stride]) & dgVector::m_triplexMask); - dgBigVector n2 (dgVector(&polygon[indexArray[indexCount + 1] * stride]) & dgVector::m_triplexMask); - - dgBigVector tilt0 (n0.CrossProduct(n1)); - dgBigVector tilt1 (n0.CrossProduct(n2)); - dgFloat64 dist0 (q1q0.DotProduct(tilt0).GetScalar()); - dgFloat64 dist1 (q1q0.DotProduct(tilt1).GetScalar()); - if (dist0 < dist1) { - adjacentFace.m_index[j0 + adjacentCount + 2] = indexArray[indexCount + 1]; - } - } else { - adjacentFace.m_index[j0 + adjacentCount + 2] = adjacentFace.m_index[adjacentCount + 1]; - } - } - break; - } - } - } - } - indexI0 = indexI1; - } - j0 = j; - indexJ0 = indexJ1; - } - } - return t_ContinueSearh; -} - - - -dgAABBPolygonSoup::dgNodeBuilder* dgAABBPolygonSoup::BuildTopDown (dgNodeBuilder* const leafArray, dgInt32 firstBox, dgInt32 lastBox, dgNodeBuilder** const allocator) const -{ - dgAssert (firstBox >= 0); - dgAssert (lastBox >= 0); - - if (lastBox == firstBox) { - return &leafArray[firstBox]; - } else { - dgSpliteInfo info (&leafArray[firstBox], lastBox - firstBox + 1); - - dgNodeBuilder* const parent = new (*allocator) dgNodeBuilder (info.m_p0, info.m_p1); - *allocator = *allocator + 1; - - dgAssert (parent); - parent->m_right = BuildTopDown (leafArray, firstBox + info.m_axis, lastBox, allocator); - parent->m_right->m_parent = parent; - - parent->m_left = BuildTopDown (leafArray, firstBox, firstBox + info.m_axis - 1, allocator); - parent->m_left->m_parent = parent; - return parent; - } -} - -void dgAABBPolygonSoup::Create (const dgPolygonSoupDatabaseBuilder& builder, bool optimizedBuild) -{ - if (builder.m_faceCount == 0) { - return; - } - dgAssert (builder.m_faceCount >= 1); - m_strideInBytes = sizeof (dgTriplex); - m_nodesCount = ((builder.m_faceCount - 1) < 1) ? 1 : builder.m_faceCount - 1; - m_aabb = (dgNode*) dgMallocStack (sizeof (dgNode) * m_nodesCount); - m_indexCount = builder.m_indexCount * 2 + builder.m_faceCount; - if (builder.m_faceCount == 1) { - m_indexCount *= 2; - } - m_indices = (dgInt32*) dgMallocStack (sizeof (dgInt32) * m_indexCount); - dgStack<dgVector> tmpVertexArrayCont(builder.m_vertexCount + builder.m_normalCount + builder.m_faceCount * 2 + 4); - - dgVector* const tmpVertexArray = &tmpVertexArrayCont[0]; - for (dgInt32 i = 0; i < builder.m_vertexCount; i ++) { - tmpVertexArray[i] = builder.m_vertexPoints[i]; - } - - for (dgInt32 i = 0; i < builder.m_normalCount; i ++) { - tmpVertexArray[i + builder.m_vertexCount] = builder.m_normalPoints[i]; - } - - const dgInt32* const indices = &builder.m_vertexIndex[0]; - dgStack<dgNodeBuilder> constructor (builder.m_faceCount * 2 + 16); - - dgInt32 polygonIndex = 0; - dgInt32 allocatorIndex = 0; - if (builder.m_faceCount == 1) { - dgInt32 indexCount = builder.m_faceVertexCount[0] - 1; - new (&constructor[allocatorIndex]) dgNodeBuilder (&tmpVertexArray[0], 0, indexCount, &indices[0]); - allocatorIndex ++; - } - for (dgInt32 i = 0; i < builder.m_faceCount; i ++) { - dgInt32 indexCount = builder.m_faceVertexCount[i] - 1; - new (&constructor[allocatorIndex]) dgNodeBuilder (&tmpVertexArray[0], i, indexCount, &indices[polygonIndex]); - allocatorIndex ++; - polygonIndex += (indexCount + 1); - } - - dgNodeBuilder* contructorAllocator = &constructor[allocatorIndex]; - dgNodeBuilder* root = BuildTopDown (&constructor[0], 0, allocatorIndex - 1, &contructorAllocator); - - dgAssert (root); - if (root->m_left) { - - dgAssert (root->m_right); - dgList<dgNodeBuilder*> list (builder.m_allocator); - dgList<dgNodeBuilder*> stack (builder.m_allocator); - stack.Append(root); - while (stack.GetCount()) { - dgList<dgNodeBuilder*>::dgListNode* const stackNode = stack.GetLast(); - dgNodeBuilder* const node = stackNode->GetInfo(); - stack.Remove(stackNode); - - if (node->m_left) { - dgAssert (node->m_right); - list.Append(node); - stack.Append(node->m_right); - stack.Append(node->m_left); - } - } - - dgFloat64 newCost = dgFloat32 (1.0e20f); - dgFloat64 prevCost = newCost; - do { - prevCost = newCost; - for (dgList<dgNodeBuilder*>::dgListNode* listNode = list.GetFirst(); listNode; listNode = listNode->GetNext()) { - dgNodeBuilder* const node = listNode->GetInfo(); - ImproveNodeFitness (node); - } - - newCost = dgFloat32 (0.0f); - for (dgList<dgNodeBuilder*>::dgListNode* listNode = list.GetFirst(); listNode; listNode = listNode->GetNext()) { - dgNodeBuilder* const node = listNode->GetInfo(); - newCost += node->m_area; - } - } while (newCost < (prevCost * dgFloat32 (0.9999f))); - - root = list.GetLast()->GetInfo(); - while (root->m_parent) { - root = root->m_parent; - } - } - - dgList<dgNodeBuilder*> list (builder.m_allocator); - - list.Append(root); - dgInt32 nodeIndex = 0; - while (list.GetCount()) { - dgNodeBuilder* const node = list.GetFirst()->GetInfo(); - list.Remove(list.GetFirst()); - - if (node->m_left) { - node->m_enumeration = nodeIndex; - nodeIndex ++; - dgAssert (node->m_right); - list.Append(node->m_left); - list.Append(node->m_right); - } - } - dgAssert(!list.GetCount()); - - dgInt32 aabbBase = builder.m_vertexCount + builder.m_normalCount; - - - dgVector* const aabbPoints = &tmpVertexArray[aabbBase]; - - - dgInt32 vertexIndex = 0; - dgInt32 aabbNodeIndex = 0; - list.Append(root); - dgInt32 indexMap = 0; - while (list.GetCount()) { - - dgNodeBuilder* const node = list.GetFirst()->GetInfo(); - list.Remove(list.GetFirst()); - - if (node->m_enumeration >= 0) { - dgAssert (node->m_left); - dgAssert (node->m_right); - dgNode& aabbNode = m_aabb[aabbNodeIndex]; - aabbNodeIndex ++; - dgAssert (aabbNodeIndex <= m_nodesCount); - - if (node->m_parent) { - if (node->m_parent->m_left == node) { - m_aabb[node->m_parent->m_enumeration].m_left = dgNode::dgLeafNodePtr (dgUnsigned32 (&m_aabb[node->m_enumeration] - m_aabb)); - } else { - dgAssert (node->m_parent->m_right == node); - m_aabb[node->m_parent->m_enumeration].m_right = dgNode::dgLeafNodePtr (dgUnsigned32 (&m_aabb[node->m_enumeration] - m_aabb)); - } - } - - aabbPoints[vertexIndex + 0] = node->m_p0; - aabbPoints[vertexIndex + 1] = node->m_p1; - - aabbNode.m_indexBox0 = aabbBase + vertexIndex; - aabbNode.m_indexBox1 = aabbBase + vertexIndex + 1; - - vertexIndex += 2; - - } else { - dgAssert (!node->m_left); - dgAssert (!node->m_right); - - if (node->m_parent) { - if (node->m_parent->m_left == node) { - m_aabb[node->m_parent->m_enumeration].m_left = dgNode::dgLeafNodePtr (dgUnsigned32(node->m_indexCount), dgUnsigned32(indexMap)); - } else { - dgAssert (node->m_parent->m_right == node); - m_aabb[node->m_parent->m_enumeration].m_right = dgNode::dgLeafNodePtr (dgUnsigned32(node->m_indexCount), dgUnsigned32(indexMap)); - } - } - - // index format i0, i1, i2, ... , id, normal, e0Normal, e1Normal, e2Normal, ..., faceSize - for (dgInt32 j = 0; j < node->m_indexCount; j ++) { - m_indices[indexMap + j] = node->m_faceIndices[j]; - m_indices[indexMap + j + node->m_indexCount + 2] = -1; - } - - // face attribute - m_indices[indexMap + node->m_indexCount] = node->m_faceIndices[node->m_indexCount]; - // face normal - m_indices[indexMap + node->m_indexCount + 1] = builder.m_vertexCount + builder.m_normalIndex[node->m_faceIndex]; - // face size - m_indices[indexMap + node->m_indexCount * 2 + 2] = dgInt32 (CalculateFaceMaxSize (&tmpVertexArray[0], node->m_indexCount, node->m_faceIndices)); - - indexMap += node->m_indexCount * 2 + 3; - } - - if (node->m_left) { - dgAssert (node->m_right); - list.Append(node->m_left); - list.Append(node->m_right); - } - } - - dgStack<dgInt32> indexArray (vertexIndex); - dgInt32 aabbPointCount = dgVertexListToIndexList (&aabbPoints[0].m_x, sizeof (dgVector), sizeof (dgTriplex), 0, vertexIndex, &indexArray[0], dgFloat32 (1.0e-6f)); - - m_vertexCount = aabbBase + aabbPointCount; - m_localVertex = (dgFloat32*) dgMallocStack (sizeof (dgTriplex) * m_vertexCount); - - dgTriplex* const dstPoints = (dgTriplex*)m_localVertex; - for (dgInt32 i = 0; i < m_vertexCount; i ++) { - dstPoints[i].m_x = tmpVertexArray[i].m_x; - dstPoints[i].m_y = tmpVertexArray[i].m_y; - dstPoints[i].m_z = tmpVertexArray[i].m_z; - } - - for (dgInt32 i = 0; i < m_nodesCount; i ++) { - dgNode& box = m_aabb[i]; - - dgInt32 j = box.m_indexBox0 - aabbBase; - box.m_indexBox0 = indexArray[j] + aabbBase; - - j = box.m_indexBox1 - aabbBase; - box.m_indexBox1 = indexArray[j] + aabbBase; - } - - if (builder.m_faceCount == 1) { - m_aabb[0].m_right = dgNode::dgLeafNodePtr (0, 0); - } -// CalculateAdjacendy(); -} - -void dgAABBPolygonSoup::Serialize (dgSerialize callback, void* const userData) const -{ - callback (userData, &m_vertexCount, sizeof (dgInt32)); - callback (userData, &m_indexCount, sizeof (dgInt32)); - callback (userData, &m_nodesCount, sizeof (dgInt32)); - callback (userData, &m_nodesCount, sizeof (dgInt32)); - if (m_aabb) { - callback (userData, m_localVertex, dgInt32 (sizeof (dgTriplex) * m_vertexCount)); - callback (userData, m_indices, dgInt32 (sizeof (dgInt32) * m_indexCount)); - callback (userData, m_aabb, dgInt32 (sizeof (dgNode) * m_nodesCount)); - } -} - -void dgAABBPolygonSoup::Deserialize (dgDeserialize callback, void* const userData, dgInt32 revisionNumber) -{ - m_strideInBytes = sizeof (dgTriplex); - callback (userData, &m_vertexCount, sizeof (dgInt32)); - callback (userData, &m_indexCount, sizeof (dgInt32)); - callback (userData, &m_nodesCount, sizeof (dgInt32)); - callback (userData, &m_nodesCount, sizeof (dgInt32)); - - if (m_vertexCount) { - m_localVertex = (dgFloat32*) dgMallocStack (sizeof (dgTriplex) * m_vertexCount); - m_indices = (dgInt32*) dgMallocStack (sizeof (dgInt32) * m_indexCount); - m_aabb = (dgNode*) dgMallocStack (sizeof (dgNode) * m_nodesCount); - - callback (userData, m_localVertex, dgInt32 (sizeof (dgTriplex) * m_vertexCount)); - callback (userData, m_indices, dgInt32 (sizeof (dgInt32) * m_indexCount)); - callback (userData, m_aabb, dgInt32 (sizeof (dgNode) * m_nodesCount)); - } else { - m_localVertex = NULL; - m_indices = NULL; - m_aabb = NULL; - } -} - - -dgVector dgAABBPolygonSoup::ForAllSectorsSupportVectex (const dgVector& dir) const -{ - dgVector supportVertex (dgFloat32 (0.0f)); - if (m_aabb) { - dgFloat32 aabbProjection[DG_STACK_DEPTH]; - const dgNode *stackPool[DG_STACK_DEPTH]; - - dgInt32 stack = 1; - stackPool[0] = m_aabb; - aabbProjection[0] = dgFloat32 (1.0e10f); - const dgTriplex* const boxArray = (dgTriplex*)m_localVertex; - - - dgFloat32 maxProj = dgFloat32 (-1.0e20f); - dgInt32 ix = (dir[0] > dgFloat32 (0.0f)) ? 1 : 0; - dgInt32 iy = (dir[1] > dgFloat32 (0.0f)) ? 1 : 0; - dgInt32 iz = (dir[2] > dgFloat32 (0.0f)) ? 1 : 0; - - while (stack) { - dgFloat32 boxSupportValue; - - stack--; - boxSupportValue = aabbProjection[stack]; - if (boxSupportValue > maxProj) { - dgFloat32 backSupportDist = dgFloat32 (0.0f); - dgFloat32 frontSupportDist = dgFloat32 (0.0f); - const dgNode* const me = stackPool[stack]; - if (me->m_left.IsLeaf()) { - backSupportDist = dgFloat32 (-1.0e20f); - dgInt32 index = dgInt32 (me->m_left.GetIndex()); - dgInt32 vCount = dgInt32 (me->m_left.GetCount()); - dgVector vertex (dgFloat32 (0.0f)); - for (dgInt32 j = 0; j < vCount; j ++) { - dgInt32 i0 = m_indices[index + j] * dgInt32 (sizeof (dgTriplex) / sizeof (dgFloat32)); - dgVector p (&boxArray[i0].m_x); - p = p & dgVector::m_triplexMask; - dgFloat32 dist = p.DotProduct(dir).GetScalar(); - if (dist > backSupportDist) { - backSupportDist = dist; - vertex = p; - } - } - - if (backSupportDist > maxProj) { - maxProj = backSupportDist; - supportVertex = vertex; - } - - } else { - dgVector box[2]; - const dgNode* const node = me->m_left.GetNode(m_aabb); - box[0].m_x = boxArray[node->m_indexBox0].m_x; - box[0].m_y = boxArray[node->m_indexBox0].m_y; - box[0].m_z = boxArray[node->m_indexBox0].m_z; - box[1].m_x = boxArray[node->m_indexBox1].m_x; - box[1].m_y = boxArray[node->m_indexBox1].m_y; - box[1].m_z = boxArray[node->m_indexBox1].m_z; - - dgVector supportPoint (box[ix].m_x, box[iy].m_y, box[iz].m_z, dgFloat32 (0.0)); - backSupportDist = supportPoint.DotProduct(dir).GetScalar(); - } - - if (me->m_right.IsLeaf()) { - frontSupportDist = dgFloat32 (-1.0e20f); - dgInt32 index = dgInt32 (me->m_right.GetIndex()); - dgInt32 vCount = dgInt32 (me->m_right.GetCount()); - dgVector vertex (dgFloat32 (0.0f)); - for (dgInt32 j = 0; j < vCount; j ++) { - dgInt32 i0 = m_indices[index + j] * dgInt32 (sizeof (dgTriplex) / sizeof (dgFloat32)); - dgVector p (&boxArray[i0].m_x); - p = p & dgVector::m_triplexMask; - dgFloat32 dist = p.DotProduct(dir).GetScalar(); - if (dist > frontSupportDist) { - frontSupportDist = dist; - vertex = p; - } - } - if (frontSupportDist > maxProj) { - maxProj = frontSupportDist; - supportVertex = vertex; - } - - } else { - dgVector box[2]; - const dgNode* const node = me->m_right.GetNode(m_aabb); - box[0].m_x = boxArray[node->m_indexBox0].m_x; - box[0].m_y = boxArray[node->m_indexBox0].m_y; - box[0].m_z = boxArray[node->m_indexBox0].m_z; - box[1].m_x = boxArray[node->m_indexBox1].m_x; - box[1].m_y = boxArray[node->m_indexBox1].m_y; - box[1].m_z = boxArray[node->m_indexBox1].m_z; - - dgVector supportPoint (box[ix].m_x, box[iy].m_y, box[iz].m_z, dgFloat32 (0.0f)); - frontSupportDist = supportPoint.DotProduct(dir).GetScalar(); - } - - if (frontSupportDist >= backSupportDist) { - if (!me->m_left.IsLeaf()) { - aabbProjection[stack] = backSupportDist; - stackPool[stack] = me->m_left.GetNode(m_aabb); - stack++; - } - - if (!me->m_right.IsLeaf()) { - aabbProjection[stack] = frontSupportDist; - stackPool[stack] = me->m_right.GetNode(m_aabb); - stack++; - } - - } else { - - if (!me->m_right.IsLeaf()) { - aabbProjection[stack] = frontSupportDist; - stackPool[stack] = me->m_right.GetNode(m_aabb); - stack++; - } - - if (!me->m_left.IsLeaf()) { - aabbProjection[stack] = backSupportDist; - stackPool[stack] = me->m_left.GetNode(m_aabb); - stack++; - } - } - } - } - } - return supportVertex; -} - - -void dgAABBPolygonSoup::ForAllSectorsRayHit (const dgFastRayTest& raySrc, dgFloat32 maxParam, dgRayIntersectCallback callback, void* const context) const -{ - const dgNode *stackPool[DG_STACK_DEPTH]; - dgFloat32 distance[DG_STACK_DEPTH]; - dgFastRayTest ray (raySrc); - - dgInt32 stack = 1; - const dgTriplex* const vertexArray = (dgTriplex*) m_localVertex; - - stackPool[0] = m_aabb; - distance[0] = m_aabb->RayDistance(ray, vertexArray); - while (stack) { - stack --; - dgFloat32 dist = distance[stack]; - if (dist > maxParam) { - break; - } else { - const dgNode *const me = stackPool[stack]; - if (me->m_left.IsLeaf()) { - dgInt32 vCount = dgInt32 (me->m_left.GetCount()); - if (vCount > 0) { - dgInt32 index = dgInt32 (me->m_left.GetIndex()); - dgFloat32 param = callback(context, &vertexArray[0].m_x, sizeof (dgTriplex), &m_indices[index], vCount); - dgAssert (param >= dgFloat32 (0.0f)); - if (param < maxParam) { - maxParam = param; - if (maxParam == dgFloat32 (0.0f)) { - break; - } - } - } - - } else { - const dgNode* const node = me->m_left.GetNode(m_aabb); - dgFloat32 dist1 = node->RayDistance(ray, vertexArray); - if (dist1 < maxParam) { - dgInt32 j = stack; - for ( ; j && (dist1 > distance[j - 1]); j --) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - dgAssert (stack < DG_STACK_DEPTH); - stackPool[j] = node; - distance[j] = dist1; - stack++; - } - } - - if (me->m_right.IsLeaf()) { - dgInt32 vCount = dgInt32 (me->m_right.GetCount()); - if (vCount > 0) { - dgInt32 index = dgInt32 (me->m_right.GetIndex()); - dgFloat32 param = callback(context, &vertexArray[0].m_x, sizeof (dgTriplex), &m_indices[index], vCount); - dgAssert (param >= dgFloat32 (0.0f)); - if (param < maxParam) { - maxParam = param; - if (maxParam == dgFloat32 (0.0f)) { - break; - } - } - } - - } else { - const dgNode* const node = me->m_right.GetNode(m_aabb); - dgFloat32 dist1 = node->RayDistance(ray, vertexArray); - if (dist1 < maxParam) { - dgInt32 j = stack; - for ( ; j && (dist1 > distance[j - 1]); j --) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - dgAssert (stack < DG_STACK_DEPTH); - stackPool[j] = node; - distance[j] = dist1; - stack++; - } - } - } - } -} - -void dgAABBPolygonSoup::ForAllSectors (const dgFastAABBInfo& obbAabbInfo, const dgVector& boxDistanceTravel, dgFloat32 m_maxT, dgAABBIntersectCallback callback, void* const context) const -{ - dgAssert (dgAbs(dgAbs(obbAabbInfo[0][0]) - obbAabbInfo.m_absDir[0][0]) < dgFloat32 (1.0e-4f)); - dgAssert (dgAbs(dgAbs(obbAabbInfo[1][1]) - obbAabbInfo.m_absDir[1][1]) < dgFloat32 (1.0e-4f)); - dgAssert (dgAbs(dgAbs(obbAabbInfo[2][2]) - obbAabbInfo.m_absDir[2][2]) < dgFloat32 (1.0e-4f)); - - dgAssert (dgAbs(dgAbs(obbAabbInfo[0][1]) - obbAabbInfo.m_absDir[1][0]) < dgFloat32 (1.0e-4f)); - dgAssert (dgAbs(dgAbs(obbAabbInfo[0][2]) - obbAabbInfo.m_absDir[2][0]) < dgFloat32 (1.0e-4f)); - dgAssert (dgAbs(dgAbs(obbAabbInfo[1][2]) - obbAabbInfo.m_absDir[2][1]) < dgFloat32 (1.0e-4f)); - - if (m_aabb) { - dgFloat32 distance[DG_STACK_DEPTH]; - const dgNode* stackPool[DG_STACK_DEPTH]; - - const dgInt32 stride = sizeof (dgTriplex) / sizeof (dgFloat32); - const dgTriplex* const vertexArray = (dgTriplex*) m_localVertex; - - dgAssert (boxDistanceTravel.m_w == dgFloat32 (0.0f)); - if (boxDistanceTravel.DotProduct(boxDistanceTravel).GetScalar() < dgFloat32 (1.0e-8f)) { - - dgInt32 stack = 1; - stackPool[0] = m_aabb; - distance[0] = m_aabb->BoxPenetration(obbAabbInfo, vertexArray); - if (distance[0] <= dgFloat32(0.0f)) { - obbAabbInfo.m_separationDistance = dgMin(obbAabbInfo.m_separationDistance[0], -distance[0]); - } - while (stack) { - stack --; - dgFloat32 dist = distance[stack]; - if (dist > dgFloat32 (0.0f)) { - const dgNode* const me = stackPool[stack]; - if (me->m_left.IsLeaf()) { - dgInt32 index = dgInt32 (me->m_left.GetIndex()); - dgInt32 vCount = dgInt32 (me->m_left.GetCount()); - if (vCount > 0) { - const dgInt32* const indices = &m_indices[index]; - dgInt32 normalIndex = indices[vCount + 1]; - dgVector faceNormal (&vertexArray[normalIndex].m_x); - faceNormal = faceNormal & dgVector::m_triplexMask; - dgFloat32 dist1 = obbAabbInfo.PolygonBoxDistance (faceNormal, vCount, indices, stride, &vertexArray[0].m_x); - if (dist1 > dgFloat32 (0.0f)) { - obbAabbInfo.m_separationDistance = dgFloat32(0.0f); - dgAssert (vCount >= 3); - if (callback(context, &vertexArray[0].m_x, sizeof (dgTriplex), indices, vCount, dist1) == t_StopSearh) { - return; - } - } else { - obbAabbInfo.m_separationDistance = dgMin(obbAabbInfo.m_separationDistance[0], -dist1); - } - } - - } else { - const dgNode* const node = me->m_left.GetNode(m_aabb); - dgFloat32 dist1 = node->BoxPenetration(obbAabbInfo, vertexArray); - if (dist1 > dgFloat32 (0.0f)) { - dgInt32 j = stack; - for ( ; j && (dist1 > distance[j - 1]); j --) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - dgAssert (stack < DG_STACK_DEPTH); - stackPool[j] = node; - distance[j] = dist1; - stack++; - } else { - obbAabbInfo.m_separationDistance = dgMin(obbAabbInfo.m_separationDistance[0], -dist1); - } - } - - if (me->m_right.IsLeaf()) { - dgInt32 index = dgInt32 (me->m_right.GetIndex()); - dgInt32 vCount = dgInt32 (me->m_right.GetCount()); - if (vCount > 0) { - const dgInt32* const indices = &m_indices[index]; - dgInt32 normalIndex = indices[vCount + 1]; - dgVector faceNormal (&vertexArray[normalIndex].m_x); - faceNormal = faceNormal & dgVector::m_triplexMask; - dgFloat32 dist1 = obbAabbInfo.PolygonBoxDistance (faceNormal, vCount, indices, stride, &vertexArray[0].m_x); - if (dist1 > dgFloat32 (0.0f)) { - dgAssert (vCount >= 3); - obbAabbInfo.m_separationDistance = dgFloat32(0.0f); - if (callback(context, &vertexArray[0].m_x, sizeof (dgTriplex), indices, vCount, dist1) == t_StopSearh) { - return; - } - } else { - obbAabbInfo.m_separationDistance = dgMin(obbAabbInfo.m_separationDistance[0], -dist1); - } - } - - } else { - const dgNode* const node = me->m_right.GetNode(m_aabb); - dgFloat32 dist1 = node->BoxPenetration(obbAabbInfo, vertexArray); - if (dist1 > dgFloat32 (0.0f)) { - dgInt32 j = stack; - for ( ; j && (dist1 > distance[j - 1]); j --) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - dgAssert (stack < DG_STACK_DEPTH); - stackPool[j] = node; - distance[j] = dist1; - stack++; - } else { - obbAabbInfo.m_separationDistance = dgMin(obbAabbInfo.m_separationDistance[0], -dist1); - } - } - } - } - - } else { - dgFastRayTest ray (dgVector (dgFloat32 (0.0f)), boxDistanceTravel); - dgFastRayTest obbRay (dgVector (dgFloat32 (0.0f)), obbAabbInfo.UnrotateVector(boxDistanceTravel)); - dgInt32 stack = 1; - stackPool[0] = m_aabb; - distance [0] = m_aabb->BoxIntersect (ray, obbRay, obbAabbInfo, vertexArray); - - while (stack) { - stack --; - const dgFloat32 dist = distance[stack]; - const dgNode* const me = stackPool[stack]; - if (dist < dgFloat32 (1.0f)) { - - if (me->m_left.IsLeaf()) { - dgInt32 index = dgInt32 (me->m_left.GetIndex()); - dgInt32 vCount = dgInt32 (me->m_left.GetCount()); - if (vCount > 0) { - const dgInt32* const indices = &m_indices[index]; - dgInt32 normalIndex = indices[vCount + 1]; - dgVector faceNormal (&vertexArray[normalIndex].m_x); - faceNormal = faceNormal & dgVector::m_triplexMask; - dgFloat32 hitDistance = obbAabbInfo.PolygonBoxRayDistance (faceNormal, vCount, indices, stride, &vertexArray[0].m_x, ray); - if (hitDistance < dgFloat32 (1.0f)) { - dgAssert (vCount >= 3); - if (callback(context, &vertexArray[0].m_x, sizeof (dgTriplex), indices, vCount, hitDistance) == t_StopSearh) { - return; - } - } - } - - } else { - const dgNode* const node = me->m_left.GetNode(m_aabb); - dgFloat32 dist1 = node->BoxIntersect (ray, obbRay, obbAabbInfo, vertexArray); - if (dist1 < dgFloat32 (1.0f)) { - dgInt32 j = stack; - for ( ; j && (dist1 > distance[j - 1]); j --) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - dgAssert (stack < DG_STACK_DEPTH); - stackPool[j] = node; - distance[j] = dist1; - stack++; - } - } - - if (me->m_right.IsLeaf()) { - dgInt32 index = dgInt32 (me->m_right.GetIndex()); - dgInt32 vCount = dgInt32 (me->m_right.GetCount()); - if (vCount > 0) { - const dgInt32* const indices = &m_indices[index]; - dgInt32 normalIndex = indices[vCount + 1]; - dgVector faceNormal (&vertexArray[normalIndex].m_x); - faceNormal = faceNormal & dgVector::m_triplexMask; - dgFloat32 hitDistance = obbAabbInfo.PolygonBoxRayDistance (faceNormal, vCount, indices, stride, &vertexArray[0].m_x, ray); - if (hitDistance < dgFloat32 (1.0f)) { - dgAssert (vCount >= 3); - if (callback(context, &vertexArray[0].m_x, sizeof (dgTriplex), indices, vCount, hitDistance) == t_StopSearh) { - return; - } - } - } - - } else { - const dgNode* const node = me->m_right.GetNode(m_aabb); - dgFloat32 dist1 = node->BoxIntersect (ray, obbRay, obbAabbInfo, vertexArray); - if (dist1 < dgFloat32 (1.0f)) { - dgInt32 j = stack; - for ( ; j && (dist1 > distance[j - 1]); j --) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - dgAssert (stack < DG_STACK_DEPTH); - stackPool[j] = node; - distance[j] = dist1; - stack ++; - } - } - } - } - } - } -} - - diff --git a/thirdparty/src/newton/dgCore/dgAABBPolygonSoup.h b/thirdparty/src/newton/dgCore/dgAABBPolygonSoup.h deleted file mode 100644 index 19beaa062..000000000 --- a/thirdparty/src/newton/dgCore/dgAABBPolygonSoup.h +++ /dev/null @@ -1,251 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DG_AABB_POLYGON_SOUP_H_ -#define __DG_AABB_POLYGON_SOUP_H_ - -#include "dgStdafx.h" -#include "dgIntersections.h" -#include "dgPolygonSoupDatabase.h" - - -class dgPolygonSoupDatabaseBuilder; - - -class dgAABBPolygonSoup: public dgPolygonSoupDatabase -{ - public: - class dgNode - { - public: - enum dgNodeType - { - m_binary = 0, - m_leaf, - }; - - class dgLeafNodePtr - { - #define DG_INDEX_COUNT_BITS 6 - - public: - DG_INLINE dgLeafNodePtr () - { - dgAssert (0); - } - - DG_INLINE dgLeafNodePtr (dgUnsigned32 node) - { - m_node = node; - dgAssert (!IsLeaf()); - } - - DG_INLINE dgUnsigned32 IsLeaf () const - { - return m_node & 0x80000000; - } - - DG_INLINE dgUnsigned32 GetCount() const - { - dgAssert (IsLeaf()); - return (m_node & (~0x80000000)) >> (32 - DG_INDEX_COUNT_BITS - 1); - } - - DG_INLINE dgUnsigned32 GetIndex() const - { - dgAssert (IsLeaf()); - return m_node & (~(-(1 << (32 - DG_INDEX_COUNT_BITS - 1)))); - } - - - DG_INLINE dgLeafNodePtr (dgUnsigned32 faceIndexCount, dgUnsigned32 faceIndexStart) - { - dgAssert (faceIndexCount < (1<<DG_INDEX_COUNT_BITS)); - m_node = 0x80000000 | (faceIndexCount << (32 - DG_INDEX_COUNT_BITS - 1)) | faceIndexStart; - } - - DG_INLINE dgNode* GetNode (const void* const root) const - { - return ((dgNode*) root) + m_node; - } - - union { - dgUnsigned32 m_node; - }; - }; - - - dgNode () - :m_indexBox0(0) - ,m_indexBox1(0) - ,m_left(0) - ,m_right(0) - { - } - - DG_INLINE dgFloat32 RayDistance (const dgFastRayTest& ray, const dgTriplex* const vertexArray) const - { - dgVector minBox (&vertexArray[m_indexBox0].m_x); - dgVector maxBox (&vertexArray[m_indexBox1].m_x); - minBox = minBox & dgVector::m_triplexMask; - maxBox = maxBox & dgVector::m_triplexMask; - return ray.BoxIntersect(minBox, maxBox); - } - - DG_INLINE dgFloat32 BoxPenetration (const dgFastAABBInfo& obb, const dgTriplex* const vertexArray) const - { - dgVector p0 (&vertexArray[m_indexBox0].m_x); - dgVector p1 (&vertexArray[m_indexBox1].m_x); - p0 = p0 & dgVector::m_triplexMask; - p1 = p1 & dgVector::m_triplexMask; - dgVector minBox (p0 - obb.m_p1); - dgVector maxBox (p1 - obb.m_p0); - dgAssert(maxBox.m_x >= minBox.m_x); - dgAssert(maxBox.m_y >= minBox.m_y); - dgAssert(maxBox.m_z >= minBox.m_z); - - dgVector mask ((minBox * maxBox) < dgVector::m_zero); - dgVector dist (maxBox.GetMin (minBox.Abs()) & mask); - dist = dist.GetMin(dist.ShiftTripleRight()); - dist = dist.GetMin(dist.ShiftTripleRight()); - - if (dist.GetScalar() > dgFloat32 (0.0f)) { - dgVector origin (dgVector::m_half * (p1 + p0)); - dgVector size (dgVector::m_half * (p1 - p0)); - - origin = obb.UntransformVector(origin); - size = obb.m_absDir.RotateVector(size); - dgVector q0 (origin - size); - dgVector q1 (origin + size); - dgVector minBox1 (q0 - obb.m_size); - dgVector maxBox1 (q1 + obb.m_size); - dgAssert(maxBox1.m_x >= minBox1.m_x); - dgAssert(maxBox1.m_y >= minBox1.m_y); - dgAssert(maxBox1.m_z >= minBox1.m_z); - dgVector mask1 ((minBox1 * maxBox1) < dgVector::m_zero); - dgVector dist1 (maxBox1.GetMin (minBox1.Abs()) & mask1); - dist1 = dist1.GetMin(dist1.ShiftTripleRight()); - dist1 = dist1.GetMin(dist1.ShiftTripleRight()); - dist = dist.GetMin(dist1); - } else { - dgVector p1p0((minBox.Abs()).GetMin(maxBox.Abs()).AndNot(mask)); - dist = p1p0.DotProduct(p1p0); - dist = dist.Sqrt() * dgVector::m_negOne; - } - return dist.GetScalar(); - } - - DG_INLINE dgFloat32 BoxIntersect (const dgFastRayTest& ray, const dgFastRayTest& obbRay, const dgFastAABBInfo& obb, const dgTriplex* const vertexArray) const - { - dgVector p0 (&vertexArray[m_indexBox0].m_x); - dgVector p1 (&vertexArray[m_indexBox1].m_x); - p0 = p0 & dgVector::m_triplexMask; - p1 = p1 & dgVector::m_triplexMask; - - dgVector minBox (p0 - obb.m_p1); - dgVector maxBox (p1 - obb.m_p0); - dgFloat32 dist = ray.BoxIntersect(minBox, maxBox); - if (dist < dgFloat32 (1.0f)) { - dgVector origin (dgVector::m_half * (p1 + p0)); - dgVector size (dgVector::m_half * (p1 - p0)); - - origin = obb.UntransformVector(origin); - size = obb.m_absDir.RotateVector(size); - dgVector q0 (origin - size); - dgVector q1 (origin + size); - - dgVector minBox1 (q0 - obb.m_size); - dgVector maxBox1 (q1 + obb.m_size); - dgFloat32 dist1 = obbRay.BoxIntersect(minBox1, maxBox1); - dist = (dist1 > dgFloat32 (1.0f)) ? dist1 : dgMax (dist1, dist); - } - return dist; - } - - dgInt32 m_indexBox0; - dgInt32 m_indexBox1; - dgLeafNodePtr m_left; - dgLeafNodePtr m_right; - }; - - class dgSpliteInfo; - class dgNodeBuilder; - - virtual void GetAABB (dgVector& p0, dgVector& p1) const; - virtual void Serialize (dgSerialize callback, void* const userData) const; - virtual void Deserialize (dgDeserialize callback, void* const userData, dgInt32 revisionNumber); - - protected: - dgAABBPolygonSoup (); - virtual ~dgAABBPolygonSoup (); - - void Create (const dgPolygonSoupDatabaseBuilder& builder, bool optimizedBuild); - void CalculateAdjacendy (); - virtual void ForAllSectorsRayHit (const dgFastRayTest& ray, dgFloat32 maxT, dgRayIntersectCallback callback, void* const context) const; - virtual void ForAllSectors (const dgFastAABBInfo& obbAabb, const dgVector& boxDistanceTravel, dgFloat32 m_maxT, dgAABBIntersectCallback callback, void* const context) const; - - - DG_INLINE void* GetRootNode() const - { - return m_aabb; - } - - DG_INLINE void* GetBackNode(const void* const root) const - { - dgNode* const node = (dgNode*) root; - return node->m_left.IsLeaf() ? NULL : node->m_left.GetNode(m_aabb); - } - - DG_INLINE void* GetFrontNode(const void* const root) const - { - dgNode* const node = (dgNode*) root; - return node->m_right.IsLeaf() ? NULL : node->m_right.GetNode(m_aabb); - } - - DG_INLINE void GetNodeAABB(const void* const root, dgVector& p0, dgVector& p1) const - { - const dgNode* const node = (dgNode*)root; - p0 = dgVector (&((dgTriplex*)m_localVertex)[node->m_indexBox0].m_x); - p1 = dgVector (&((dgTriplex*)m_localVertex)[node->m_indexBox1].m_x); - p0 = p0 & dgVector::m_triplexMask; - p1 = p1 & dgVector::m_triplexMask; - } - - virtual dgVector ForAllSectorsSupportVectex (const dgVector& dir) const; - - private: - dgNodeBuilder* BuildTopDown (dgNodeBuilder* const leafArray, dgInt32 firstBox, dgInt32 lastBox, dgNodeBuilder** const allocator) const; - dgFloat32 CalculateFaceMaxSize (const dgVector* const vertex, dgInt32 indexCount, const dgInt32* const indexArray) const; -// static dgIntersectStatus CalculateManifoldFaceEdgeNormals (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount); - static dgIntersectStatus CalculateDisjointedFaceEdgeNormals (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance); - static dgIntersectStatus CalculateAllFaceEdgeNormals (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance); - void ImproveNodeFitness (dgNodeBuilder* const node) const; - - dgInt32 m_nodesCount; - dgInt32 m_indexCount; - dgNode* m_aabb; - dgInt32* m_indices; -}; - - -#endif - - diff --git a/thirdparty/src/newton/dgCore/dgArray.h b/thirdparty/src/newton/dgCore/dgArray.h deleted file mode 100644 index 14160c091..000000000 --- a/thirdparty/src/newton/dgCore/dgArray.h +++ /dev/null @@ -1,227 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -/**************************************************************************** -* -* Visual C++ 6.0 created by: Julio Jerez -* -****************************************************************************/ -#ifndef __dgArray__ -#define __dgArray__ - -#include "dgStdafx.h" - -template<class T> -class dgArray -{ - public: - dgArray (); - dgArray (dgMemoryAllocator* const allocator, dgInt32 aligmentInBytes = DG_MEMORY_GRANULARITY); - dgArray (const dgArray& source, dgInt32 itemsToCopy); - dgArray(const dgArray& source); - ~dgArray (); - DG_CLASS_ALLOCATOR(allocator) - - DG_INLINE T& operator[] (dgInt32 i); - DG_INLINE const T& operator[] (dgInt32 i) const; - - void Clear () const; - void Resize (dgInt32 size) const; - DG_INLINE void ResizeIfNecessary (dgInt32 index) const; - - dgInt32 GetElementSize() const; - dgInt32 GetBytesCapacity () const; - dgInt32 GetElementsCapacity () const; - dgMemoryAllocator* GetAllocator() const; - void SetAllocator(dgMemoryAllocator* const allocator); - - protected: - mutable T *m_array; - private: - mutable dgInt32 m_maxSize; - dgInt32 m_aligmentInBytes; - dgMemoryAllocator* m_allocator; -}; - -template<class T> -dgArray<T>::dgArray() - :m_array(NULL) - ,m_maxSize(0) - ,m_aligmentInBytes(DG_MEMORY_GRANULARITY) - ,m_allocator(NULL) -{ - m_aligmentInBytes = 1 << dgExp2(m_aligmentInBytes); -} - -template<class T> -dgArray<T>::dgArray (dgMemoryAllocator* const allocator, dgInt32 aligmentInBytes) - :m_array(NULL) - ,m_maxSize(0) - ,m_aligmentInBytes(aligmentInBytes) - ,m_allocator(allocator) -{ - if (m_aligmentInBytes <= 0) { - m_aligmentInBytes = DG_MEMORY_GRANULARITY; - } - m_aligmentInBytes = 1 << dgExp2(m_aligmentInBytes); -} - -template<class T> -dgArray<T>::dgArray (const dgArray& source, dgInt32 itemsToCopy) - :m_array(NULL) - ,m_maxSize(itemsToCopy) - ,m_aligmentInBytes(source.m_aligmentInBytes) - ,m_allocator(source.m_allocator) -{ - if (source.m_array) { - m_array = (T*) m_allocator->MallocLow (sizeof (T) * itemsToCopy, m_aligmentInBytes); - for (dgInt32 i = 0; i < itemsToCopy; i++) { - m_array[i] = source.m_array[i]; - } - } -} -template<class T> -dgArray<T>::dgArray(const dgArray& source) - :m_array(NULL) - ,m_maxSize(source.m_maxSize) - ,m_aligmentInBytes(source.m_aligmentInBytes) - ,m_allocator(source.m_allocator) -{ - dgAssert(0); - // use dgArray<T>::dgArray(const dgArray& source, dgInt32 itemsToCopy) - if (source.m_array) { - m_array = (T*)m_allocator->MallocLow(sizeof(T) * m_maxSize, m_aligmentInBytes); - for (dgInt32 i = 0; i < m_maxSize; i++) { - m_array[i] = source.m_array[i]; - } - } -} - -template<class T> -dgArray<T>::~dgArray () -{ - if (m_array) { - m_allocator->FreeLow (m_array); - } -} - -template<class T> -DG_INLINE const T& dgArray<T>::operator[] (dgInt32 i) const -{ - dgAssert (i >= 0); - while (i >= m_maxSize) { - Resize (i * 2); - } - return m_array[i]; -} - -template<class T> -DG_INLINE T& dgArray<T>::operator[] (dgInt32 i) -{ - dgAssert (i >= 0); - while (i >= m_maxSize) { - Resize (i * 2); - } - return m_array[i]; -} - -template<class T> -dgInt32 dgArray<T>::GetElementSize() const -{ - return sizeof (T); -} - -template<class T> -dgInt32 dgArray<T>::GetElementsCapacity () const -{ - return m_maxSize; -} - -template<class T> -dgInt32 dgArray<T>::GetBytesCapacity () const -{ - return m_maxSize * GetElementSize(); -} - -template<class T> -void dgArray<T>::Clear () const -{ - if (m_array) { - m_allocator->FreeLow (m_array); - m_array = NULL; - } - m_maxSize = 0; -} - -template<class T> -dgMemoryAllocator* dgArray<T>::GetAllocator() const -{ - return m_allocator; -} - -template<class T> -void dgArray<T>::SetAllocator(dgMemoryAllocator* const allocator) -{ - dgAssert (!m_allocator); - m_allocator = allocator; -} - -template<class T> -void dgArray<T>::Resize (dgInt32 size) const -{ - if (size >= m_maxSize) { - size = dgMax (size, 16); - T* const newArray = (T*) m_allocator->MallocLow (dgInt32 (sizeof (T) * size), m_aligmentInBytes); - if (m_array) { - for (dgInt32 i = 0; i < m_maxSize; i ++) { - newArray[i] = m_array[i]; - } - m_allocator->FreeLow (m_array); - } - m_array = newArray; - m_maxSize = size; - } else if (size < m_maxSize) { - size = dgMax (size, 16); - T* const newArray = (T*) m_allocator->MallocLow (dgInt32 (sizeof (T) * size), m_aligmentInBytes); - if (m_array) { - for (dgInt32 i = 0; i < size; i ++) { - newArray[i] = m_array[i]; - } - m_allocator->FreeLow (m_array); - } - m_array = newArray; - m_maxSize = size; - } -} - -template<class T> -DG_INLINE void dgArray<T>::ResizeIfNecessary (dgInt32 size) const -{ - while (size >= m_maxSize) { - Resize (m_maxSize * 2); - } -} - -#endif - - - - diff --git a/thirdparty/src/newton/dgCore/dgCRC.cpp b/thirdparty/src/newton/dgCore/dgCRC.cpp deleted file mode 100644 index a508acb00..000000000 --- a/thirdparty/src/newton/dgCore/dgCRC.cpp +++ /dev/null @@ -1,390 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgCRC.h" -#include "dgList.h" -#include "dgTree.h" -#include "dgDebug.h" -#include "dgRandom.h" - -namespace InternalCRC -{ - const dgInt32 STRING_POOL_SIZE = 1024 * 8 - 256; - - static dgUnsigned32 randBits[] = { - 0x00000001, 0x2C11F801, 0xDFD8F60E, 0x6C8FA2B7, - 0xB573754C, 0x1522DCDD, 0x21615D3A, 0xE1B307F3, - 0x12AFA158, 0x53D18179, 0x70950126, 0x941702EF, - 0x756FE824, 0x694801D5, 0x36DF4DD2, 0x63D80FAB, - 0xB8AE95B0, 0x902439F1, 0x090C6F3E, 0x2B7C6A27, - 0x8344B5FC, 0x67D3C5CD, 0x22F5516A, 0x2FB00E63, - 0xFC761508, 0x87B00169, 0x27EBA056, 0x8CC0B85F, - 0xE33D3ED4, 0x95DA08C5, 0x13E5C802, 0x9DD9E41B, - 0xD4577F60, 0x3DD6B7E1, 0x096AF46E, 0x1A00CD97, - 0x4B10E2AC, 0x22EAAABD, 0x683F119A, 0x62D070D3, - 0xA8D034B8, 0xAA363D59, 0x58CECB86, 0x40F589CF, - 0x4F630184, 0x38918BB5, 0xB85B8E32, 0x0A6A948B, - 0x9A099510, 0x402871D1, 0x11E7859E, 0xEE73CD07, - 0x4142FB5C, 0x39D68BAD, 0x0FE19DCA, 0xE35B2F43, - 0x75590068, 0x66433549, 0x929182B6, 0x71EC773F, - 0xBBAC3034, 0xF2BD8AA5, 0x5743A062, 0x5AB120FB, - 0x5ABFD6C0, 0xDDD867C1, 0xDC3522CE, 0xD0EC6877, - 0xE106000C, 0xB7C6689D, 0xED3FF5FA, 0xC75749B3, - 0x126B7818, 0x1A75E939, 0x0546C5E6, 0x8A9C80AF, - 0x48A3CAE4, 0x756D0595, 0x7060FE92, 0xA594896B, - 0x12354470, 0x896599B1, 0xDAC6CBFE, 0xCB419FE7, - 0x9C44F0BC, 0xAFA9418D, 0xB87D1A2A, 0x428BC023, - 0x33229BC8, 0xC92D5929, 0xB1C19516, 0x0FBCA61F, - 0xE594D194, 0x716EFC85, 0x0036A8C2, 0xD7BBCDDB, - 0x16E4DE20, 0xD10F07A1, 0x68CF812E, 0x390A7357, - 0x8BAACD6C, 0x2C2E167D, 0x3E7C0A5A, 0x167F9293, - 0x3D596B78, 0x08888519, 0x9994F046, 0x0FC3E78F, - 0x008A4444, 0x87526F75, 0xB0079EF2, 0x238DEE4B, - 0xCA09A3D0, 0x4ED3B191, 0xFA42425E, 0x379DE2C7, - 0x1EA2961C, 0x1FC3E76D, 0x90DFC68A, 0x0279C103, - 0xF9AAE728, 0xF2666D09, 0xEF13D776, 0x92E944FF, - 0x364F22F4, 0x37665E65, 0x05D6E122, 0x7131EABB, - 0x479E9580, 0x98729781, 0x4BD20F8E, 0x1612EE37, - 0xCB574ACC, 0x5499B45D, 0x360B4EBA, 0x33814B73, - 0x43720ED8, 0x146610F9, 0x45514AA6, 0x0B23BE6F, - 0x026E6DA4, 0xD1B9C955, 0x94676F52, 0xCE8EC32B, - 0x165EB330, 0x2F6AB971, 0x92F1E8BE, 0xC54095A7, - 0xBEB3EB7C, 0x5C9E7D4D, 0x5921A2EA, 0xB45D31E3, - 0xB8C9E288, 0x5FE670E9, 0xC02049D6, 0xC42A53DF, - 0x6F332454, 0x661BB045, 0x2B3C4982, 0xDF4B779B, - 0xD7C4FCE0, 0x70FB1761, 0xADD4CDEE, 0x47BDD917, - 0x8C63782C, 0x8181423D, 0xFA05C31A, 0xDD947453, - 0x6A8D6238, 0x1A068CD9, 0x4413D506, 0x5374054F, - 0xC5A84704, 0xB41B1335, 0x06986FB2, 0x4CCF080B, - 0xF80C7290, 0x8622B151, 0x536DBF1E, 0x21E1B887, - 0xDED0F0DC, 0xB4B1032D, 0x1D5AAF4A, 0xC56E12C3, - 0x8C578DE8, 0xCBA564C9, 0xA67EEC36, 0x0837D2BF, - 0x3D98D5B4, 0x1B06F225, 0xFF7EE1E2, 0x3640747B, - 0x5E301440, 0x53A08741, 0x436FBC4E, 0xC9C333F7, - 0x2727558C, 0x7F5CC01D, 0xFC83677A, 0xAFF10D33, - 0x24836598, 0x3161F8B9, 0xDD748F66, 0x5B6CBC2F, - 0xAD8FD064, 0x89EE4D15, 0xBBB2A012, 0xA086BCEB, - 0x1BEAE1F0, 0x69F39931, 0x764DC57E, 0x17394B67, - 0x4D51A63C, 0xF273790D, 0x35A2EBAA, 0x7EE463A3, - 0xBC2BE948, 0x2B9B48A9, 0x2FC7BE96, 0x5FC9C19F, - 0x3AD83714, 0x6FA02405, 0xDDB6AA42, 0xE648E15B, - 0x1DB7DBA0, 0xF55AE721, 0x4D3ADAAE, 0xB3DAFED7, - 0x5FFAE2EC, 0x96A42DFD, 0xFB9C3BDA, 0x21CF1613, - 0x0F2C18F8, 0xAE705499, 0x650B79C6, 0x31C5E30F, - 0x097D09C4, 0xAAAB76F5, 0x34CE0072, 0x27EDE1CB, - 0xDAD20150, 0xADD57111, 0xC229FBDE, 0x8AFF4E47, - 0x448E0B9C, 0x5C5DDEED, 0x4612580A, 0x05F82483, - 0xBC1EF4A8, 0xB1C01C89, 0xF592C0F6, 0x6798207F, - 0xEC494874, 0x795F45E5, 0xECFBA2A2, 0xBB9CBE3B, - 0xF567104f, 0x47289407, 0x25683fa6, 0x2fde5836, - }; - - struct StringPool - { - char buff[STRING_POOL_SIZE]; - - StringPool () - { - } - - StringPool (const StringPool &arg) - { - } - }; - -/* - class CRCStringLookup: public dgTree<char *, dgUnsigned32>, public dgList<StringPool> - { - - dgInt32 size; - char *ptr; - - void AddContainer () - { - StringPool tmp; - dgListNode *node; - -// Addtop (tmp); -// node = GetFirst(); - node = Addtop (tmp); - - ptr = node->GetInfo().buff; - size = STRING_POOL_SIZE; - } - - public: - - CRCStringLookup () - :dgTree<char *, dgUnsigned32>(NULL), dgList<StringPool>() - { - AddContainer(); - } - - ~CRCStringLookup () - { - } - - - void AddString (dgUnsigned32 crc, const char *string) - { - dgInt32 length; - - if (dgTree<char *, dgUnsigned32>::Find(crc)) { - return; - } - - length = dgInt32 (strlen (string)) + 1; - if (size < length) { - AddContainer(); - } - - strcpy (ptr, string); - Insert (ptr, crc); - - ptr += length; - size -= length; - } - - const char* FindString (dgUnsigned32 crc) const - { - dgTreeNode *node; - - node = dgTree<char *, dgUnsigned32>::Find(crc); -// return node ? node->GetInfo() : NULL; - return node ? node->GetInfo() : NULL; - } - }; - - static CRCStringLookup& GetDatabase () - { - static CRCStringLookup database; - return database; - } -*/ - - - - /* - dgUnsigned32 RSHash(char* str, dgUnsigned32 len) - { - dgUnsigned32 b = 378551; - dgUnsigned32 a = 63689; - dgUnsigned32 hash = 0; - dgUnsigned32 i = 0; - - for(i = 0; i < len; str++, i++) { - hash = hash * a + (*str); - a = a * b; - } - - return (hash & 0x7FFFFFFF); - } - // End Of RS Hash Function - - - dgUnsigned32 JSHash(char* str, dgUnsigned32 len) - { - dgUnsigned32 hash = 1315423911; - dgUnsigned32 i = 0; - - for(i = 0; i < len; str++, i++) - { - hash ^= ((hash << 5) + (*str) + (hash >> 2)); - } - - return (hash & 0x7FFFFFFF); - } - // End Of JS Hash Function - - - dgUnsigned32 PJWHash(char* str, dgUnsigned32 len) - { - dgUnsigned32 BitsInUnsignedInt = (dgUnsigned32)(sizeof(dgUnsigned32) * 8); - dgUnsigned32 ThreeQuarters = (dgUnsigned32)((BitsInUnsignedInt * 3) / 4); - dgUnsigned32 OneEighth = (dgUnsigned32)(BitsInUnsignedInt / 8); - dgUnsigned32 HighBits = (dgUnsigned32)(0xFFFFFFFF) << (BitsInUnsignedInt - OneEighth); - dgUnsigned32 hash = 0; - dgUnsigned32 test = 0; - dgUnsigned32 i = 0; - - for(i = 0; i < len; str++, i++) - { - hash = (hash << OneEighth) + (*str); - - if((test = hash & HighBits) != 0) - { - hash = (( hash ^ (test >> ThreeQuarters)) & (~HighBits)); - } - } - - return (hash & 0x7FFFFFFF); - } - // End Of P. J. Weinberger Hash Function - - - dgUnsigned32 ELFHash(char* str, dgUnsigned32 len) - { - dgUnsigned32 hash = 0; - dgUnsigned32 x = 0; - dgUnsigned32 i = 0; - - for(i = 0; i < len; str++, i++) - { - hash = (hash << 4) + (*str); - if((x = hash & 0xF0000000L) != 0) - { - hash ^= (x >> 24); - hash &= ~x; - } - } - - return (hash & 0x7FFFFFFF); - } - // End Of ELF Hash Function - - - dgUnsigned32 BKDRHash(char* str, dgUnsigned32 len) - { - dgUnsigned32 seed = 131; // 31 131 1313 13131 131313 etc.. - dgUnsigned32 hash = 0; - dgUnsigned32 i = 0; - - for(i = 0; i < len; str++, i++) - { - hash = (hash * seed) + (*str); - } - - return (hash & 0x7FFFFFFF); - } - // End Of BKDR Hash Function - - - dgUnsigned32 SDBMHash(char* str, dgUnsigned32 len) - { - dgUnsigned32 hash = 0; - dgUnsigned32 i = 0; - - for(i = 0; i < len; str++, i++) - { - hash = (*str) + (hash << 6) + (hash << 16) - hash; - } - - return (hash & 0x7FFFFFFF); - } - // End Of SDBM Hash Function - - - dgUnsigned32 DEKHash(char* str, dgUnsigned32 len) - { - dgUnsigned32 hash = len; - dgUnsigned32 i = 0; - - for(i = 0; i < len; str++, i++) - { - hash = ((hash << 5) ^ (hash >> 27)) ^ (*str); - } - return (hash & 0x7FFFFFFF); - } - // End Of DEK Hash Function - - - dgUnsigned32 APHash(char* str, dgUnsigned32 len) - { - dgUnsigned32 hash = 0; - dgUnsigned32 i = 0; - - for(i = 0; i < len; str++, i++) - { - hash ^= ((i & 1) == 0) ? ( (hash << 7) ^ (*str) ^ (hash >> 3)) : - (~((hash << 11) ^ (*str) ^ (hash >> 5))); - } - - return (hash & 0x7FFFFFFF); - } - */ - - // End Of DJB Hash Function - dgUnsigned32 DJBHash(const char* const str, dgInt32 len) - { - dgUnsigned32 hash = 5381; - for(dgInt32 i = 0; i < len; i++) - { - //hash = ((hash << 5) + hash) + (*str); - hash = ((hash << 5) + hash) + str[i]; - } - - return (hash & 0x7FFFFFFF); - } -} - - -dgUnsigned32 dgApi dgCRC (const char* const name) -{ -// dgUnsigned32 c; -// dgUnsigned32 crc; -// unsigned char *ptr; -// dgUnsigned32 val; - if (!name) { - return 0; - } - - dgUnsigned32 crc = 0; - //for (ptr = (unsigned char*)name; *ptr; ptr ++) { - for (dgInt32 i = 0; name[i]; i ++) { - char c = name[i]; - dgUnsigned32 val = InternalCRC::randBits[((crc >> 24) ^ c) & 0xff]; - crc = (crc << 8) ^ val; - } - - dgAssert (0); -// InternalCRC::GetDatabase().AddString (crc, name); - return crc; -} - - - -dgUnsigned32 dgApi dgCRC (const void* const buffer, dgInt32 size, dgUnsigned32 crcAcc) -{ - dgAssert (buffer); - unsigned char* const ptr = (unsigned char*)buffer; - for (dgInt32 i = 0; i < size; i ++) { - dgUnsigned32 c = ptr[i]; - dgUnsigned32 val = InternalCRC::randBits[((crcAcc >> 24) ^ c) & 0xff]; - crcAcc = (crcAcc << 8) ^ val; - } - return crcAcc; -} - - -const char* dgApi dgInverseCRC (dgUnsigned32 crc) -{ - dgAssert (0); - return NULL; -// return InternalCRC::GetDatabase().FindString (crc); -} - - - -dgUnsigned32 dgApi dgHash (const void* const string, int size) -{ - return InternalCRC::DJBHash ((char*)string, size); -} diff --git a/thirdparty/src/newton/dgCore/dgCRC.h b/thirdparty/src/newton/dgCore/dgCRC.h deleted file mode 100644 index 2b6a4b409..000000000 --- a/thirdparty/src/newton/dgCore/dgCRC.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgCRC__ -#define __dgCRC__ - -#include "dgStdafx.h" - - -dgUnsigned32 dgApi dgCRC (const char* const string); -dgUnsigned32 dgApi dgCRC (const void* const buffer, dgInt32 size, dgUnsigned32 crcAcc = 0); -const char* dgApi dgInverseCRC (dgUnsigned32 CRC); - -dgUnsigned32 dgApi dgHash (const void* const string, dgInt32 size); - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgConvexHull3d.cpp b/thirdparty/src/newton/dgCore/dgConvexHull3d.cpp deleted file mode 100644 index 33b5b6323..000000000 --- a/thirdparty/src/newton/dgCore/dgConvexHull3d.cpp +++ /dev/null @@ -1,1100 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgSort.h" -#include "dgTree.h" -#include "dgStack.h" -#include "dgGoogol.h" -#include "dgConvexHull3d.h" -#include "dgSmallDeterminant.h" - - -#define DG_CONVEXHULL_3D_VERTEX_CLUSTER_SIZE 8 - -#ifdef DG_OLD_CONVEXHULL_3D -class dgConvexHull3d::dgNormalMap -{ - public: - dgNormalMap() - :m_count(sizeof(m_normal) / sizeof(m_normal[0])) - { - dgVector p0(dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p1(dgFloat32(-1.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p2(dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p3(dgFloat32(0.0f), dgFloat32(-1.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p4(dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f)); - dgVector p5(dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(-1.0f), dgFloat32(0.0f)); - - dgInt32 count = 0; - dgInt32 subdivitions = 2; - TessellateTriangle(subdivitions, p4, p0, p2, count); - TessellateTriangle(subdivitions, p0, p5, p2, count); - TessellateTriangle(subdivitions, p5, p1, p2, count); - TessellateTriangle(subdivitions, p1, p4, p2, count); - TessellateTriangle(subdivitions, p0, p4, p3, count); - TessellateTriangle(subdivitions, p5, p0, p3, count); - TessellateTriangle(subdivitions, p1, p5, p3, count); - TessellateTriangle(subdivitions, p4, p1, p3, count); - } - - static const dgNormalMap& GetNormaMap() - { - static dgNormalMap normalMap; - return normalMap; - } - - void TessellateTriangle(dgInt32 level, const dgVector& p0, const dgVector& p1, const dgVector& p2, dgInt32& count) - { - if (level) { - dgAssert(dgAbs(p0.DotProduct(p0).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p1.DotProduct(p1).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p2.DotProduct(p2).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgVector p01(p0 + p1); - dgVector p12(p1 + p2); - dgVector p20(p2 + p0); - - p01 = p01.Scale(dgRsqrt(p01.DotProduct(p01).GetScalar())); - p12 = p12.Scale(dgRsqrt(p12.DotProduct(p12).GetScalar())); - p20 = p20.Scale(dgRsqrt(p20.DotProduct(p20).GetScalar())); - - dgAssert(dgAbs(p01.DotProduct(p01).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p12.DotProduct(p12).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p20.DotProduct(p20).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - - TessellateTriangle(level - 1, p0, p01, p20, count); - TessellateTriangle(level - 1, p1, p12, p01, count); - TessellateTriangle(level - 1, p2, p20, p12, count); - TessellateTriangle(level - 1, p01, p12, p20, count); - } else { - dgBigPlane n(p0, p1, p2); - n = n.Scale(dgFloat64(1.0f) / sqrt(n.DotProduct(n).GetScalar())); - n.m_w = dgFloat64(0.0f); - dgInt32 index = dgBitReversal(count, sizeof(m_normal) / sizeof(m_normal[0])); - m_normal[index] = n; - count++; - dgAssert(count <= sizeof(m_normal) / sizeof(m_normal[0])); - } - } - - dgBigVector m_normal[128]; - dgInt32 m_count; -}; -#endif - -class dgConvexHull3DVertex: public dgBigVector -{ - public: - dgInt32 m_mark; -}; - -class dgConvexHull3dAABBTreeNode -{ - public: - dgBigVector m_box[2]; - dgConvexHull3dAABBTreeNode* m_left; - dgConvexHull3dAABBTreeNode* m_right; - dgConvexHull3dAABBTreeNode* m_parent; -}; - -class dgConvexHull3dPointCluster: public dgConvexHull3dAABBTreeNode -{ - public: - dgInt32 m_count; - dgInt32 m_indices[DG_CONVEXHULL_3D_VERTEX_CLUSTER_SIZE]; -}; - - -dgConvexHull3DFace::dgConvexHull3DFace() -{ - m_mark = 0; - m_twin[0] = NULL; - m_twin[1] = NULL; - m_twin[2] = NULL; -} - -dgFloat64 dgConvexHull3DFace::Evalue (const dgBigVector* const pointArray, const dgBigVector& point) const -{ - const dgBigVector& p0 = pointArray[m_index[0]]; - const dgBigVector& p1 = pointArray[m_index[1]]; - const dgBigVector& p2 = pointArray[m_index[2]]; - - dgFloat64 matrix[3][3]; - for (dgInt32 i = 0; i < 3; i ++) { - matrix[0][i] = p2[i] - p0[i]; - matrix[1][i] = p1[i] - p0[i]; - matrix[2][i] = point[i] - p0[i]; - } - - dgFloat64 error; - dgFloat64 det = Determinant3x3 (matrix, &error); - - // the code use double, however the threshold for accuracy test is the machine precision of a float. - // by changing this to a smaller number, the code should run faster since many small test will be considered valid - // the precision must be a power of two no smaller than the machine precision of a double, (1<<48) - // float64(1<<30) can be a good value - - // dgFloat64 precision = dgFloat64 (1.0f) / dgFloat64 (1<<30); - dgFloat64 precision = dgFloat64 (1.0f) / dgFloat64 (1<<24); - dgFloat64 errbound = error * precision; - if (fabs(det) > errbound) { - return det; - } - - dgGoogol exactMatrix[3][3]; - for (dgInt32 i = 0; i < 3; i ++) { - exactMatrix[0][i] = dgGoogol(p2[i]) - dgGoogol(p0[i]); - exactMatrix[1][i] = dgGoogol(p1[i]) - dgGoogol(p0[i]); - exactMatrix[2][i] = dgGoogol(point[i]) - dgGoogol(p0[i]); - } - return Determinant3x3(exactMatrix); -} - -dgBigPlane dgConvexHull3DFace::GetPlaneEquation (const dgBigVector* const pointArray) const -{ - const dgBigVector& p0 = pointArray[m_index[0]]; - const dgBigVector& p1 = pointArray[m_index[1]]; - const dgBigVector& p2 = pointArray[m_index[2]]; - dgBigPlane plane (p0, p1, p2); - plane = plane.Scale (1.0f / sqrt (plane.DotProduct(plane & dgBigVector::m_triplexMask).GetScalar())); - return plane; -} - - -dgConvexHull3d::dgConvexHull3d (dgMemoryAllocator* const allocator) - :dgList<dgConvexHull3DFace>(allocator) - ,m_count (0) - ,m_diag() - ,m_aabbP0(dgBigVector (dgFloat64 (0.0f))) - ,m_aabbP1(dgBigVector (dgFloat64 (0.0f))) - ,m_points(allocator) -{ -} - -dgConvexHull3d::dgConvexHull3d(const dgConvexHull3d& source) - :dgList<dgConvexHull3DFace>(source.GetAllocator()) - ,m_count (source.m_count) - ,m_diag(source.m_diag) - ,m_aabbP0 (source.m_aabbP0) - ,m_aabbP1 (source.m_aabbP1) - ,m_points(source.GetAllocator(), source.m_count) -{ - m_points[m_count-1].m_w = dgFloat64 (0.0f); - for (int i = 0; i < m_count; i ++) { - m_points[i] = source.m_points[i]; - } - dgTree<dgListNode*, dgListNode*> map (GetAllocator()); - for(dgListNode* sourceNode = source.GetFirst(); sourceNode; sourceNode = sourceNode->GetNext() ) { - dgListNode* const node = Append(); - map.Insert(node, sourceNode); - } - - for(dgListNode* sourceNode = source.GetFirst(); sourceNode; sourceNode = sourceNode->GetNext() ) { - dgListNode* const node = map.Find(sourceNode)->GetInfo(); - - dgConvexHull3DFace& face = node->GetInfo(); - dgConvexHull3DFace& srcFace = sourceNode->GetInfo(); - - face.m_mark = 0; - for (dgInt32 i = 0; i < 3; i ++) { - face.m_index[i] = srcFace.m_index[i]; - face.m_twin[i] = map.Find (srcFace.m_twin[i])->GetInfo(); - } - } -} - -dgConvexHull3d::dgConvexHull3d(dgMemoryAllocator* const allocator, const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, dgFloat64 distTol, dgInt32 maxVertexCount) - :dgList<dgConvexHull3DFace>(allocator) - ,m_count (0) - ,m_diag() - ,m_aabbP0 (dgBigVector (dgFloat64 (0.0), dgFloat64 (0.0), dgFloat64 (0.0), dgFloat64 (0.0))) - ,m_aabbP1 (dgBigVector (dgFloat64 (0.0), dgFloat64 (0.0), dgFloat64 (0.0), dgFloat64 (0.0))) - ,m_points(allocator) -{ - BuildHull (vertexCloud, strideInBytes, count, distTol, maxVertexCount); -} - -dgConvexHull3d::~dgConvexHull3d(void) -{ -} - - -void dgConvexHull3d::BuildHull (const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, dgFloat64 distTol, dgInt32 maxVertexCount) -{ - dgSetPrecisionDouble precision; - - dgInt32 treeCount = count / (DG_CONVEXHULL_3D_VERTEX_CLUSTER_SIZE>>1); - if (treeCount < 4) { - treeCount = 4; - } - treeCount *= 2; - - dgStack<dgConvexHull3DVertex> points (count); - dgStack<dgConvexHull3dPointCluster> treePool (treeCount + 256); - count = InitVertexArray(&points[0], vertexCloud, strideInBytes, count, &treePool[0], treePool.GetSizeInBytes()); - -#ifdef DG_OLD_CONVEXHULL_3D - if (m_count >= 4) { - CalculateConvexHull3d (&treePool[0], &points[0], count, distTol, maxVertexCount); - } -#else - if (m_count >= 3) { - if (CheckFlatSurface(&treePool[0], &points[0], count, distTol, maxVertexCount)) { - CalculateConvexHull2d(&treePool[0], &points[0], count, distTol, maxVertexCount); - } else { - dgAssert(m_count == 4); - CalculateConvexHull3d(&treePool[0], &points[0], count, distTol, maxVertexCount); - } - } -#endif -} - -dgInt32 dgConvexHull3d::ConvexCompareVertex(const dgConvexHull3DVertex* const A, const dgConvexHull3DVertex* const B, void* const context) -{ - for (dgInt32 i = 0; i < 3; i ++) { - if ((*A)[i] < (*B)[i]) { - return -1; - } else if ((*A)[i] > (*B)[i]) { - return 1; - } - } - return 0; -} - -dgConvexHull3dAABBTreeNode* dgConvexHull3d::BuildTree (dgConvexHull3dAABBTreeNode* const parent, dgConvexHull3DVertex* const points, dgInt32 count, dgInt32 baseIndex, dgInt8** memoryPool, dgInt32& maxMemSize) const -{ - dgConvexHull3dAABBTreeNode* tree = NULL; - - dgAssert (count); - dgBigVector minP ( dgFloat32 (1.0e15f)); - dgBigVector maxP (-dgFloat32 (1.0e15f)); - if (count <= DG_CONVEXHULL_3D_VERTEX_CLUSTER_SIZE) { - - dgConvexHull3dPointCluster* const clump = new (*memoryPool) dgConvexHull3dPointCluster; - *memoryPool += sizeof (dgConvexHull3dPointCluster); - maxMemSize -= sizeof (dgConvexHull3dPointCluster); - dgAssert (maxMemSize >= 0); - - dgAssert (clump); - clump->m_count = count; - for (dgInt32 i = 0; i < count; i ++) { - clump->m_indices[i] = i + baseIndex; - - const dgBigVector& p = points[i]; - dgAssert(p.m_w == dgFloat32(0.0f)); - minP = minP.GetMin(p); - maxP = maxP.GetMax(p); - } - - clump->m_left = NULL; - clump->m_right = NULL; - tree = clump; - - } else { - dgBigVector median (dgFloat32 (0.0f)); - dgBigVector varian (dgFloat32 (0.0f)); - for (dgInt32 i = 0; i < count; i ++) { - - const dgBigVector& p = points[i]; - dgAssert(p.m_w == dgFloat32(0.0f)); - minP = minP.GetMin(p); - maxP = maxP.GetMax(p); - median += p; - varian += p * p; - } - - varian = varian.Scale(dgFloat32(count)) - median * median; - dgInt32 index = 0; - dgFloat64 maxVarian = dgFloat64 (-1.0e10f); - for (dgInt32 i = 0; i < 3; i ++) { - if (varian[i] > maxVarian) { - index = i; - maxVarian = varian[i]; - } - } - dgBigVector center (median.Scale (dgFloat64 (1.0f) / dgFloat64 (count))); - - dgFloat64 test = center[index]; - - dgInt32 i0 = 0; - dgInt32 i1 = count - 1; - do { - for (; i0 <= i1; i0 ++) { - dgFloat64 val = points[i0][index]; - if (val > test) { - break; - } - } - - for (; i1 >= i0; i1 --) { - dgFloat64 val = points[i1][index]; - if (val < test) { - break; - } - } - - if (i0 < i1) { - dgSwap(points[i0], points[i1]); - i0++; - i1--; - } - } while (i0 <= i1); - - if (i0 == 0){ - i0 = count / 2; - } - if (i0 >= (count - 1)){ - i0 = count / 2; - } - - tree = new (*memoryPool) dgConvexHull3dAABBTreeNode; - *memoryPool += sizeof (dgConvexHull3dAABBTreeNode); - maxMemSize -= sizeof (dgConvexHull3dAABBTreeNode); - dgAssert (maxMemSize >= 0); - - dgAssert (i0); - dgAssert (count - i0); - - tree->m_left = BuildTree (tree, points, i0, baseIndex, memoryPool, maxMemSize); - tree->m_right = BuildTree (tree, &points[i0], count - i0, i0 + baseIndex, memoryPool, maxMemSize); - } - - dgAssert (tree); - tree->m_parent = parent; - tree->m_box[0] = (minP - dgBigVector (dgFloat64 (1.0e-3f))) & dgBigVector::m_triplexMask; - tree->m_box[1] = (maxP + dgBigVector (dgFloat64 (1.0e-3f))) & dgBigVector::m_triplexMask; - return tree; -} - -dgInt32 dgConvexHull3d::GetUniquePoints(dgConvexHull3DVertex* const points, const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, void* const memoryPool, dgInt32 maxMemSize) -{ - dgInt32 stride = dgInt32(strideInBytes / sizeof(dgFloat64)); - if (stride >= 4) { - for (dgInt32 i = 0; i < count; i++) { - dgInt32 index = i * stride; - dgBigVector& vertex = points[i]; - vertex = dgBigVector(vertexCloud[index], vertexCloud[index + 1], vertexCloud[index + 2], vertexCloud[index + 3]); - dgAssert(dgCheckVector(vertex)); - points[i].m_mark = 0; - } - } else { - for (dgInt32 i = 0; i < count; i++) { - dgInt32 index = i * stride; - dgBigVector& vertex = points[i]; - vertex = dgBigVector(vertexCloud[index], vertexCloud[index + 1], vertexCloud[index + 2], dgFloat64(0.0f)); - dgAssert(dgCheckVector(vertex)); - points[i].m_mark = 0; - } - } - - dgSort(points, count, ConvexCompareVertex); - - dgInt32 indexCount = 0; - for (int i = 1; i < count; i++) { - for (; i < count; i++) { - if (ConvexCompareVertex(&points[indexCount], &points[i], NULL)) { - indexCount++; - points[indexCount] = points[i]; - break; - } - } - } - count = indexCount + 1; - return count; -} - -dgInt32 dgConvexHull3d::InitVertexArray(dgConvexHull3DVertex* const points, const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, void* const memoryPool, dgInt32 maxMemSize) -{ - count = GetUniquePoints(points, vertexCloud, strideInBytes, count, memoryPool, maxMemSize); - if (count < 4) { - m_count = 0; - return count; - } - dgConvexHull3dAABBTreeNode* tree = BuildTree (NULL, points, count, 0, (dgInt8**) &memoryPool, maxMemSize); - - m_aabbP0 = tree->m_box[0]; - m_aabbP1 = tree->m_box[1]; - - dgBigVector boxSize (tree->m_box[1] - tree->m_box[0]); - dgAssert (boxSize.m_w == dgFloat32 (0.0f)); - m_diag = dgFloat32 (sqrt (boxSize.DotProduct(boxSize).GetScalar())); - -#ifdef DG_OLD_CONVEXHULL_3D - const dgNormalMap& normalMap = dgNormalMap::GetNormaMap(); - - dgInt32 index0 = SupportVertex (&tree, points, normalMap.m_normal[0]); - m_points[0] = points[index0]; - points[index0].m_mark = 1; - - bool validTetrahedrum = false; - dgBigVector e1 (dgFloat64 (0.0f), dgFloat64 (0.0f), dgFloat64 (0.0f), dgFloat64 (0.0f)) ; - for (dgInt32 i = 1; i < normalMap.m_count; i ++) { - dgInt32 index = SupportVertex (&tree, points, normalMap.m_normal[i]); - dgAssert (index >= 0); - - e1 = points[index] - m_points[0]; - dgAssert (e1.m_w == dgFloat32 (0.0f)); - dgFloat64 error2 = e1.DotProduct(e1).GetScalar(); - if (error2 > (dgFloat32 (1.0e-4f) * m_diag * m_diag)) { - m_points[1] = points[index]; - points[index].m_mark = 1; - validTetrahedrum = true; - break; - } - } - if (!validTetrahedrum) { - m_count = 0; - dgAssert (0); - return count; - } - - validTetrahedrum = false; - dgBigVector e2(dgFloat32 (0.0f)); - dgBigVector normal (dgFloat32 (0.0f)); - for (dgInt32 i = 2; i < normalMap.m_count; i ++) { - dgInt32 index = SupportVertex (&tree, points, normalMap.m_normal[i]); - dgAssert (index >= 0); - e2 = points[index] - m_points[0]; - normal = e1.CrossProduct(e2); - dgAssert (e2.m_w == dgFloat32 (0.0f)); - dgAssert (normal.m_w == dgFloat32 (0.0f)); - dgFloat64 error2 = sqrt (normal.DotProduct(normal).GetScalar()); - if (error2 > (dgFloat32 (1.0e-4f) * m_diag * m_diag)) { - m_points[2] = points[index]; - points[index].m_mark = 1; - validTetrahedrum = true; - break; - } - } - - dgAssert(normal.m_w == dgFloat32(0.0f)); - if (!validTetrahedrum) { - m_count = 0; - dgAssert (0); - return count; - } - - // find the largest possible tetrahedron - validTetrahedrum = false; - dgBigVector e3(dgFloat32 (0.0f)); - - index0 = SupportVertex (&tree, points, normal); - e3 = points[index0] - m_points[0]; - dgAssert (e3.m_w == dgFloat32 (0.0f)); - dgFloat64 err2 = normal.DotProduct(e3).GetScalar(); - if (fabs (err2) > (dgFloat64 (1.0e-6f) * m_diag * m_diag)) { - // we found a valid tetrahedral, about and start build the hull by adding the rest of the points - m_points[3] = points[index0]; - points[index0].m_mark = 1; - validTetrahedrum = true; - } - if (!validTetrahedrum) { - dgVector n (normal.Scale(dgFloat64 (-1.0f))); - dgInt32 index = SupportVertex (&tree, points, n); - e3 = points[index] - m_points[0]; - dgAssert (e3.m_w == dgFloat32 (0.0f)); - dgFloat64 error2 = normal.DotProduct(e3).GetScalar(); - if (fabs (error2) > (dgFloat64 (1.0e-6f) * m_diag * m_diag)) { - // we found a valid tetrahedral, about and start build the hull by adding the rest of the points - m_points[3] = points[index]; - points[index].m_mark = 1; - validTetrahedrum = true; - } - } - if (!validTetrahedrum) { - for (dgInt32 i = 3; i < normalMap.m_count; i ++) { - dgInt32 index = SupportVertex (&tree, points, normalMap.m_normal[i]); - dgAssert (index >= 0); - - //make sure the volume of the fist tetrahedral is no negative - e3 = points[index] - m_points[0]; - dgAssert (e3.m_w == dgFloat32 (0.0f)); - dgFloat64 error2 = normal.DotProduct(e3).GetScalar(); - if (fabs (error2) > (dgFloat64 (1.0e-6f) * m_diag * m_diag)) { - // we found a valid tetrahedral, about and start build the hull by adding the rest of the points - m_points[3] = points[index]; - points[index].m_mark = 1; - validTetrahedrum = true; - break; - } - } - } - if (!validTetrahedrum) { - // the points do not form a convex hull - m_count = 0; - //dgAssert (0); - return count; - } - - - m_count = 4; - dgFloat64 volume = TetrahedrumVolume (m_points[0], m_points[1], m_points[2], m_points[3]); - if (volume > dgFloat64 (0.0f)) { - dgSwap(m_points[2], m_points[3]); - } - dgAssert (TetrahedrumVolume(m_points[0], m_points[1], m_points[2], m_points[3]) < dgFloat64(0.0f)); - - return count; -#else - - dgBigVector origin((m_aabbP1 + m_aabbP0).Scale (0.5f)); - - dgBigVector dir(m_aabbP1 - m_aabbP0); - dgAssert(dir.DotProduct3(dir) > dgFloat32(1.0e-4f)); - dir = dir.Normalize(); - dgInt32 index0 = SupportVertex(&tree, points, dir); - m_points[0] = points[index0]; - points[index0].m_mark = 1; - - dir = origin - m_points[0]; - dgAssert(dir.DotProduct3(dir) > dgFloat32(1.0e-4f)); - dir = dir.Normalize(); - dgInt32 index1 = SupportVertex(&tree, points, dir); - m_points[1] = points[index1]; - points[index1].m_mark = 1; - - dgBigVector e0(m_points[1] - m_points[0]); - dgAssert(e0.DotProduct3(e0) > dgFloat32(1.0e-4f)); - dgFloat64 t = -e0.DotProduct3(origin - m_points[0]) / e0.DotProduct3(e0); - dir = m_points[0] + e0.Scale(t) - origin; - - dgAssert(dir.DotProduct3(dir) > dgFloat32(1.0e-4f)); - dir = dir.Normalize(); - dgInt32 index2 = SupportVertex(&tree, points, dir); - m_points[2] = points[index2]; - points[index2].m_mark = 1; - - dgBigVector e1 (m_points[2] - m_points[0]); - dgBigVector normal (e1.CrossProduct(e0)); - dgFloat64 error2 = sqrt(normal.DotProduct3(normal)); - if (error2 < (dgFloat32(1.0e-4f) * m_diag * m_diag)) { - dgAssert(0); -// m_points[2] = points[index]; -// points[index].m_mark = 1; -// validTetrahedrum = true; -// break; - } - - m_count = 3; - return count; -#endif -} - -dgFloat64 dgConvexHull3d::TetrahedrumVolume (const dgBigVector& p0, const dgBigVector& p1, const dgBigVector& p2, const dgBigVector& p3) const -{ - dgBigVector p1p0 (p1 - p0); - dgBigVector p2p0 (p2 - p0); - dgBigVector p3p0 (p3 - p0); - dgAssert (p1p0.m_w == dgFloat32 (0.0f)); - dgAssert (p2p0.m_w == dgFloat32 (0.0f)); - dgAssert (p3p0.m_w == dgFloat32 (0.0f)); - return p3p0.DotProduct(p1p0.CrossProduct(p2p0)).GetScalar(); -} - -dgInt32 dgConvexHull3d::SupportVertex (dgConvexHull3dAABBTreeNode** const treePointer, const dgConvexHull3DVertex* const points, const dgBigVector& dirPlane, const bool removeEntry) const -{ - #define DG_STACK_DEPTH_3D 64 - dgFloat64 aabbProjection[DG_STACK_DEPTH_3D]; - const dgConvexHull3dAABBTreeNode *stackPool[DG_STACK_DEPTH_3D]; - - dgBigVector dir(dirPlane & dgBigPlane::m_triplexMask); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - - dgInt32 index = -1; - dgInt32 stack = 1; - stackPool[0] = *treePointer; - aabbProjection[0] = dgFloat32 (1.0e20f); - dgFloat64 maxProj = dgFloat64 (-1.0e20f); - dgInt32 ix = (dir[0] > dgFloat64 (0.0f)) ? 1 : 0; - dgInt32 iy = (dir[1] > dgFloat64 (0.0f)) ? 1 : 0; - dgInt32 iz = (dir[2] > dgFloat64 (0.0f)) ? 1 : 0; - while (stack) { - stack--; - dgFloat64 boxSupportValue = aabbProjection[stack]; - if (boxSupportValue > maxProj) { - const dgConvexHull3dAABBTreeNode* const me = stackPool[stack]; - - if (me->m_left && me->m_right) { - dgBigVector leftSupportPoint (me->m_left->m_box[ix].m_x, me->m_left->m_box[iy].m_y, me->m_left->m_box[iz].m_z, dgFloat32 (0.0f)); - dgFloat64 leftSupportDist = leftSupportPoint.DotProduct(dir).GetScalar(); - - dgBigVector rightSupportPoint (me->m_right->m_box[ix].m_x, me->m_right->m_box[iy].m_y, me->m_right->m_box[iz].m_z, dgFloat32 (0.0f)); - dgFloat64 rightSupportDist = rightSupportPoint.DotProduct(dir).GetScalar(); - - if (rightSupportDist >= leftSupportDist) { - aabbProjection[stack] = leftSupportDist; - stackPool[stack] = me->m_left; - stack++; - dgAssert (stack < DG_STACK_DEPTH_3D); - aabbProjection[stack] = rightSupportDist; - stackPool[stack] = me->m_right; - stack++; - dgAssert (stack < DG_STACK_DEPTH_3D); - } else { - aabbProjection[stack] = rightSupportDist; - stackPool[stack] = me->m_right; - stack++; - dgAssert (stack < DG_STACK_DEPTH_3D); - aabbProjection[stack] = leftSupportDist; - stackPool[stack] = me->m_left; - stack++; - dgAssert (stack < DG_STACK_DEPTH_3D); - } - - } else { - dgConvexHull3dPointCluster* const cluster = (dgConvexHull3dPointCluster*) me; - for (dgInt32 i = 0; i < cluster->m_count; i ++) { - const dgConvexHull3DVertex& p = points[cluster->m_indices[i]]; - dgAssert (p.m_x >= cluster->m_box[0].m_x); - dgAssert (p.m_x <= cluster->m_box[1].m_x); - dgAssert (p.m_y >= cluster->m_box[0].m_y); - dgAssert (p.m_y <= cluster->m_box[1].m_y); - dgAssert (p.m_z >= cluster->m_box[0].m_z); - dgAssert (p.m_z <= cluster->m_box[1].m_z); - if (!p.m_mark) { - dgAssert (p.m_w == dgFloat32 (0.0f)); - dgFloat64 dist = p.DotProduct(dir).GetScalar(); - if (dist > maxProj) { - maxProj = dist; - index = cluster->m_indices[i]; - } - } else if (removeEntry) { - cluster->m_indices[i] = cluster->m_indices[cluster->m_count - 1]; - cluster->m_count = cluster->m_count - 1; - i --; - } - } - - if (cluster->m_count == 0) { - dgConvexHull3dAABBTreeNode* const parent = cluster->m_parent; - if (parent) { - dgConvexHull3dAABBTreeNode* const sibling = (parent->m_left != cluster) ? parent->m_left : parent->m_right; - dgAssert (sibling != cluster); - dgConvexHull3dAABBTreeNode* const grandParent = parent->m_parent; - if (grandParent) { - sibling->m_parent = grandParent; - if (grandParent->m_right == parent) { - grandParent->m_right = sibling; - } else { - grandParent->m_left = sibling; - } - } else { - sibling->m_parent = NULL; - *treePointer = sibling; - } - } - } - } - } - } - - dgAssert (index != -1); - return index; -} - -dgConvexHull3d::dgListNode* dgConvexHull3d::AddFace (dgInt32 i0, dgInt32 i1, dgInt32 i2) -{ - dgListNode* const node = Append(); - dgConvexHull3DFace& face = node->GetInfo(); - - face.m_index[0] = i0; - face.m_index[1] = i1; - face.m_index[2] = i2; - return node; -} - -void dgConvexHull3d::DeleteFace (dgListNode* const node) -{ - Remove (node); -} - -bool dgConvexHull3d::Sanity() const -{ -/* - for (dgListNode* node = GetFirst(); node; node = node->GetNext()) { - dgConvexHull3DFace* const face = &node->GetInfo(); - for (dgInt32 i = 0; i < 3; i ++) { - dgListNode* const twinNode = face->m_twin[i]; - if (!twinNode) { - return false; - } - - dgInt32 count = 0; - dgListNode* me = NULL; - dgConvexHull3DFace* const twinFace = &twinNode->GetInfo(); - for (dgInt32 j = 0; j < 3; j ++) { - if (twinFace->m_twin[j] == node) { - count ++; - me = twinFace->m_twin[j]; - } - } - if (count != 1) { - return false; - } - if (me != node) { - return false; - } - } - } -*/ - return true; -} - -bool dgConvexHull3d::CheckFlatSurface(dgConvexHull3dAABBTreeNode* tree, dgConvexHull3DVertex* const points, dgInt32 count, dgFloat64 distTol, dgInt32 maxVertexCount) -{ - dgBigVector e0(m_points[1] - m_points[0]); - dgBigVector e1(m_points[2] - m_points[0]); - dgAssert(e0.m_w == dgFloat32(0.0f)); - dgAssert(e1.m_w == dgFloat32(0.0f)); - dgAssert(e0.DotProduct(e0).GetScalar() > dgFloat32(1.0e-4f)); - dgAssert(e1.DotProduct(e1).GetScalar() > dgFloat32(1.0e-4f)); - dgBigVector normal(e1.CrossProduct(e0)); - dgAssert(normal.m_w == dgFloat32(0.0f)); - dgAssert(normal.DotProduct(normal).GetScalar() > dgFloat32(1.0e-6f)); - normal = normal.Normalize(); - - dgInt32 index = SupportVertex(&tree, points, normal); - m_points[3] = points[index]; - - dgFloat64 volume = TetrahedrumVolume(m_points[0], m_points[1], m_points[2], m_points[3]); - if (dgAbs(volume) < dgFloat32(1.0e-9f)) { - normal = normal.Scale(dgFloat32(-1.0f)); - index = SupportVertex(&tree, points, normal); - m_points[3] = points[index]; - volume = TetrahedrumVolume(m_points[0], m_points[1], m_points[2], m_points[3]); - if (dgAbs(volume) < dgFloat32(1.0e-9f)) { - return true; - } - } - points[index].m_mark = 1; - if (volume > dgFloat64(0.0f)) { - dgSwap(m_points[2], m_points[3]); - } - dgAssert(TetrahedrumVolume(m_points[0], m_points[1], m_points[2], m_points[3]) < dgFloat64(0.0f)); - m_count = 4; - return false; -} - - -void dgConvexHull3d::CalculateConvexHull2d(dgConvexHull3dAABBTreeNode* tree, dgConvexHull3DVertex* const points, dgInt32 count, dgFloat64 distTol, dgInt32 maxVertexCount) -{ - -} - -void dgConvexHull3d::CalculateConvexHull3d (dgConvexHull3dAABBTreeNode* vertexTree, dgConvexHull3DVertex* const points, dgInt32 count, dgFloat64 distTol, dgInt32 maxVertexCount) -{ - distTol = dgAbs (distTol) * m_diag; - dgListNode* const f0Node = AddFace (0, 1, 2); - dgListNode* const f1Node = AddFace (0, 2, 3); - dgListNode* const f2Node = AddFace (2, 1, 3); - dgListNode* const f3Node = AddFace (1, 0, 3); - - dgConvexHull3DFace* const f0 = &f0Node->GetInfo(); - dgConvexHull3DFace* const f1 = &f1Node->GetInfo(); - dgConvexHull3DFace* const f2 = &f2Node->GetInfo(); - dgConvexHull3DFace* const f3 = &f3Node->GetInfo(); - - f0->m_twin[0] = (dgList<dgConvexHull3DFace>::dgListNode*)f3Node; - f0->m_twin[1] = (dgList<dgConvexHull3DFace>::dgListNode*)f2Node; - f0->m_twin[2] = (dgList<dgConvexHull3DFace>::dgListNode*)f1Node; - - f1->m_twin[0] = (dgList<dgConvexHull3DFace>::dgListNode*)f0Node; - f1->m_twin[1] = (dgList<dgConvexHull3DFace>::dgListNode*)f2Node; - f1->m_twin[2] = (dgList<dgConvexHull3DFace>::dgListNode*)f3Node; - - f2->m_twin[0] = (dgList<dgConvexHull3DFace>::dgListNode*)f0Node; - f2->m_twin[1] = (dgList<dgConvexHull3DFace>::dgListNode*)f3Node; - f2->m_twin[2] = (dgList<dgConvexHull3DFace>::dgListNode*)f1Node; - - f3->m_twin[0] = (dgList<dgConvexHull3DFace>::dgListNode*)f0Node; - f3->m_twin[1] = (dgList<dgConvexHull3DFace>::dgListNode*)f1Node; - f3->m_twin[2] = (dgList<dgConvexHull3DFace>::dgListNode*)f2Node; - - dgList<dgListNode*> boundaryFaces(GetAllocator()); - - boundaryFaces.Append(f0Node); - boundaryFaces.Append(f1Node); - boundaryFaces.Append(f2Node); - boundaryFaces.Append(f3Node); - count -= 4; - maxVertexCount -= 4; - dgInt32 currentIndex = 4; - - - dgStack<dgListNode*> stackPool(1024 + m_count); - dgStack<dgListNode*> coneListPool(1024 + m_count); - dgStack<dgListNode*> deleteListPool(1024 + m_count); - - dgListNode** const stack = &stackPool[0]; - dgListNode** const coneList = &stackPool[0]; - dgListNode** const deleteList = &deleteListPool[0]; - - while (boundaryFaces.GetCount() && count && (maxVertexCount > 0)) { - // my definition of the optimal convex hull of a given vertex count, - // is the convex hull formed by a subset of the input vertex that minimizes the volume difference - // between the perfect hull formed from all input vertex and the hull of the sub set of vertex. - // When using a priority heap this algorithms will generate the an optimal of a fix vertex count. - // Since all Newton's tools do not have a limit on the point count of a convex hull, I can use either a stack or a queue. - // a stack maximize construction speed, a Queue tend to maximize the volume of the generated Hull approaching a perfect Hull. - // For now we use a queue. - // For general hulls it does not make a difference if we use a stack, queue, or a priority heap. - // perfect optimal hull only apply for when build hull of a limited vertex count. - // - // Also when building Hulls of a limited vertex count, this function runs in constant time. - // yes that is correct, it does not makes a difference if you build a N point hull from 100 vertex - // or from 100000 vertex input array. - - #if 0 - // using stack (faster) - dgListNode* const faceNode = boundaryFaces.GetFirst()->GetInfo(); - #else - // using a queue (some what slower by better hull when reduced vertex count is desired) - dgListNode* const faceNode = boundaryFaces.GetLast()->GetInfo(); - #endif - - dgConvexHull3DFace* const face = &faceNode->GetInfo(); - dgBigPlane planeEquation (face->GetPlaneEquation (&m_points[0])); - - dgInt32 index = SupportVertex (&vertexTree, points, planeEquation); - const dgBigVector& p = points[index]; - dgFloat64 dist = planeEquation.Evalue(p); - - if ((dist >= distTol) && (face->Evalue(&m_points[0], p) > dgFloat64(0.0f))) { - dgAssert (Sanity()); - - dgAssert (faceNode); - stack[0] = faceNode; - - dgInt32 stackIndex = 1; - dgInt32 deletedCount = 0; - - while (stackIndex) { - stackIndex --; - dgListNode* const node1 = stack[stackIndex]; - dgConvexHull3DFace* const face1 = &node1->GetInfo(); - - if (!face1->m_mark && (face1->Evalue(&m_points[0], p) > dgFloat64(0.0f))) { - #ifdef _DEBUG - for (dgInt32 i = 0; i < deletedCount; i ++) { - dgAssert (deleteList[i] != node1); - } - #endif - - deleteList[deletedCount] = node1; - deletedCount ++; - dgAssert (deletedCount < dgInt32 (deleteListPool.GetElementsCount())); - face1->m_mark = 1; - for (dgInt32 i = 0; i < 3; i ++) { - dgListNode* const twinNode = (dgListNode*)face1->m_twin[i]; - dgAssert (twinNode); - dgConvexHull3DFace* const twinFace = &twinNode->GetInfo(); - if (!twinFace->m_mark) { - stack[stackIndex] = twinNode; - stackIndex ++; - dgAssert (stackIndex < dgInt32 (stackPool.GetElementsCount())); - } - } - } - } - - m_points[currentIndex] = points[index]; - points[index].m_mark = 1; - - dgInt32 newCount = 0; - for (dgInt32 i = 0; i < deletedCount; i ++) { - dgListNode* const node1 = deleteList[i]; - dgConvexHull3DFace* const face1 = &node1->GetInfo(); - dgAssert (face1->m_mark == 1); - for (dgInt32 j0 = 0; j0 < 3; j0 ++) { - dgListNode* const twinNode = face1->m_twin[j0]; - dgConvexHull3DFace* const twinFace = &twinNode->GetInfo(); - if (!twinFace->m_mark) { - dgInt32 j1 = (j0 == 2) ? 0 : j0 + 1; - dgListNode* const newNode = AddFace (currentIndex, face1->m_index[j0], face1->m_index[j1]); - boundaryFaces.Addtop(newNode); - - dgConvexHull3DFace* const newFace = &newNode->GetInfo(); - newFace->m_twin[1] = twinNode; - for (dgInt32 k = 0; k < 3; k ++) { - if (twinFace->m_twin[k] == node1) { - twinFace->m_twin[k] = newNode; - } - } - coneList[newCount] = newNode; - newCount ++; - dgAssert (newCount < dgInt32 (coneListPool.GetElementsCount())); - } - } - } - - for (dgInt32 i = 0; i < newCount - 1; i ++) { - dgListNode* const nodeA = coneList[i]; - dgConvexHull3DFace* const faceA = &nodeA->GetInfo(); - dgAssert (faceA->m_mark == 0); - for (dgInt32 j = i + 1; j < newCount; j ++) { - dgListNode* const nodeB = coneList[j]; - dgConvexHull3DFace* const faceB = &nodeB->GetInfo(); - dgAssert (faceB->m_mark == 0); - if (faceA->m_index[2] == faceB->m_index[1]) { - faceA->m_twin[2] = nodeB; - faceB->m_twin[0] = nodeA; - break; - } - } - - for (dgInt32 j = i + 1; j < newCount; j ++) { - dgListNode* const nodeB = coneList[j]; - dgConvexHull3DFace* const faceB = &nodeB->GetInfo(); - dgAssert (faceB->m_mark == 0); - if (faceA->m_index[1] == faceB->m_index[2]) { - faceA->m_twin[0] = nodeB; - faceB->m_twin[2] = nodeA; - break; - } - } - } - - for (dgInt32 i = 0; i < deletedCount; i ++) { - dgListNode* const node = deleteList[i]; - boundaryFaces.Remove (node); - DeleteFace (node); - } - - maxVertexCount --; - currentIndex ++; - count --; - } else { - boundaryFaces.Remove (faceNode); - } - } - m_count = currentIndex; -} - - -void dgConvexHull3d::CalculateVolumeAndSurfaceArea (dgFloat64& volume, dgFloat64& surfaceArea) const -{ - dgFloat64 areaAcc = dgFloat32 (0.0f); - dgFloat64 volumeAcc = dgFloat32 (0.0f); - for (dgListNode* node = GetFirst(); node; node = node->GetNext()) { - const dgConvexHull3DFace* const face = &node->GetInfo(); - dgInt32 i0 = face->m_index[0]; - dgInt32 i1 = face->m_index[1]; - dgInt32 i2 = face->m_index[2]; - const dgBigVector& p0 = m_points[i0]; - const dgBigVector& p1 = m_points[i1]; - const dgBigVector& p2 = m_points[i2]; - dgAssert(p0.m_w == dgFloat32(0.0f)); - dgAssert(p1.m_w == dgFloat32(0.0f)); - dgAssert(p2.m_w == dgFloat32(0.0f)); - dgBigVector normal ((p1 - p0).CrossProduct(p2 - p0)); - dgAssert(normal.m_w == dgFloat32(0.0f)); - dgFloat64 area = sqrt (normal.DotProduct(normal).GetScalar()); - areaAcc += area; - volumeAcc += p2.DotProduct(p0.CrossProduct(p1)).GetScalar(); - } - dgAssert (volumeAcc >= dgFloat64 (0.0f)); - volume = volumeAcc * dgFloat64 (1.0f/6.0f); - surfaceArea = areaAcc * dgFloat64 (0.5f); -} - -// this code has linear time complexity on the number of faces -dgFloat64 dgConvexHull3d::RayCast (const dgBigVector& localP0, const dgBigVector& localP1) const -{ - dgFloat64 interset = dgFloat32 (1.2f); - dgFloat64 tE = dgFloat64 (0.0f); // for the maximum entering segment parameter; - dgFloat64 tL = dgFloat64 (1.0f); // for the minimum leaving segment parameter; - dgBigVector dS (localP1 - localP0); // is the segment direction vector; - - dgAssert(dS.m_w == dgFloat32(0.0f)); - dgInt32 hasHit = 0; - - for (dgListNode* node = GetFirst(); node; node = node->GetNext()) { - const dgConvexHull3DFace* const face = &node->GetInfo(); - - dgInt32 i0 = face->m_index[0]; - dgInt32 i1 = face->m_index[1]; - dgInt32 i2 = face->m_index[2]; - - const dgBigVector& p0 = m_points[i0]; - dgAssert(p0.m_w == dgFloat32(0.0f)); - dgBigVector normal ((m_points[i1] - p0).CrossProduct(m_points[i2] - p0)); - - dgAssert(normal.m_w == dgFloat32(0.0f)); - dgAssert(localP0.m_w == dgFloat32(0.0f)); - - //dgFloat64 N = -((localP0 - p0) % normal); - dgFloat64 D = normal.DotProduct(dS).GetScalar(); - dgFloat64 N = -normal.DotProduct(localP0 - p0).GetScalar(); - - if (fabs(D) < dgFloat64 (1.0e-12f)) { // - if (N < dgFloat64 (0.0f)) { - return dgFloat64 (1.2f); - } else { - continue; - } - } - - dgFloat64 t = N / D; - if (D < dgFloat64 (0.0f)) { - if (t > tE) { - tE = t; - hasHit = 1; - } - if (tE > tL) { - return dgFloat64 (1.2f); - } - } else { - dgAssert (D >= dgFloat64 (0.0f)); - tL = dgMin (tL, t); - if (tL < tE) { - return dgFloat64 (1.2f); - } - } - } - - if (hasHit) { - interset = tE; - } - - return interset; -} - -void dgConvexHull3d::Save (const char* const filename) const -{ - FILE* const file = fopen(filename, "wb"); - int index = 0; -// fprintf(file, "final\n"); - for (dgListNode* nodePtr = GetFirst(); nodePtr; nodePtr = nodePtr->GetNext()) { - fprintf(file, "triangle %d\n", index); - index++; - const dgConvexHull3DFace& face = nodePtr->GetInfo(); - const dgBigVector& p0 = m_points[face.m_index[0]]; - const dgBigVector& p1 = m_points[face.m_index[1]]; - const dgBigVector& p2 = m_points[face.m_index[2]]; - - fprintf(file, "p0(%f %f %f)\n", p0[0], p0[1], p0[2]); - fprintf(file, "p1(%f %f %f)\n", p1[0], p1[1], p1[2]); - fprintf(file, "p2(%f %f %f)\n", p2[0], p2[1], p2[2]); - } - fprintf(file, "\n"); - - fclose(file); -} \ No newline at end of file diff --git a/thirdparty/src/newton/dgCore/dgConvexHull3d.h b/thirdparty/src/newton/dgCore/dgConvexHull3d.h deleted file mode 100644 index 6c2138ed0..000000000 --- a/thirdparty/src/newton/dgCore/dgConvexHull3d.h +++ /dev/null @@ -1,136 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DG_CONVEXHULL_3D__ -#define __DG_CONVEXHULL_3D__ - -#include "dgStdafx.h" -#include "dgList.h" -#include "dgArray.h" -#include "dgPlane.h" -#include "dgVector.h" -#include "dgMatrix.h" -#include "dgQuaternion.h" - -#define DG_OLD_CONVEXHULL_3D - -class dgMemoryAllocator; -class dgConvexHull3DVertex; -class dgConvexHull3dAABBTreeNode; - -class dgConvexHull3DFace -{ - public: - dgConvexHull3DFace(); - - void SetMark(dgInt32 mark) {m_mark = mark;} - dgInt32 GetMark() const {return m_mark;} - dgList<dgConvexHull3DFace>::dgListNode* GetTwin(dgInt32 index) const { return m_twin[index];} - - private: - dgFloat64 Evalue (const dgBigVector* const pointArray, const dgBigVector& point) const; - dgBigPlane GetPlaneEquation (const dgBigVector* const pointArray) const; - - public: - dgInt32 m_index[3]; - private: - dgInt32 m_mark; - dgList<dgConvexHull3DFace>::dgListNode* m_twin[3]; - friend class dgConvexHull3d; -}; - -class dgConvexHull3d: public dgList<dgConvexHull3DFace> -{ -#ifdef DG_OLD_CONVEXHULL_3D - class dgNormalMap; -#endif - - public: - dgConvexHull3d(const dgConvexHull3d& source); - dgConvexHull3d(dgMemoryAllocator* const allocator, const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, dgFloat64 distTol, dgInt32 maxVertexCount = 0x7fffffff); - virtual ~dgConvexHull3d(); - - dgInt32 GetVertexCount() const; - const dgBigVector* GetVertexPool() const; - const dgBigVector& GetVertex(dgInt32 i) const; - - dgFloat64 GetDiagonal() const; - void GetAABB (dgBigVector& boxP0, dgBigVector& boxP1) const; - dgFloat64 RayCast (const dgBigVector& localP0, const dgBigVector& localP1) const; - void CalculateVolumeAndSurfaceArea (dgFloat64& volume, dgFloat64& surcafeArea) const; - - protected: - dgConvexHull3d(dgMemoryAllocator* const allocator); - void BuildHull (const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, dgFloat64 distTol, dgInt32 maxVertexCount); - - virtual dgListNode* AddFace (dgInt32 i0, dgInt32 i1, dgInt32 i2); - virtual void DeleteFace (dgListNode* const node) ; - virtual dgInt32 InitVertexArray(dgConvexHull3DVertex* const points, const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, void* const memoryPool, dgInt32 maxMemSize); - - bool CheckFlatSurface(dgConvexHull3dAABBTreeNode* vertexTree, dgConvexHull3DVertex* const points, dgInt32 count, dgFloat64 distTol, dgInt32 maxVertexCount); - void CalculateConvexHull2d (dgConvexHull3dAABBTreeNode* vertexTree, dgConvexHull3DVertex* const points, dgInt32 count, dgFloat64 distTol, dgInt32 maxVertexCount); - void CalculateConvexHull3d (dgConvexHull3dAABBTreeNode* vertexTree, dgConvexHull3DVertex* const points, dgInt32 count, dgFloat64 distTol, dgInt32 maxVertexCount); - - dgInt32 SupportVertex (dgConvexHull3dAABBTreeNode** const tree, const dgConvexHull3DVertex* const points, const dgBigVector& dir, const bool removeEntry = true) const; - dgFloat64 TetrahedrumVolume (const dgBigVector& p0, const dgBigVector& p1, const dgBigVector& p2, const dgBigVector& p3) const; - - dgInt32 GetUniquePoints(dgConvexHull3DVertex* const points, const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, void* const memoryPool, dgInt32 maxMemSize); - dgConvexHull3dAABBTreeNode* BuildTree (dgConvexHull3dAABBTreeNode* const parent, dgConvexHull3DVertex* const points, dgInt32 count, dgInt32 baseIndex, dgInt8** const memoryPool, dgInt32& maxMemSize) const; - static dgInt32 ConvexCompareVertex(const dgConvexHull3DVertex* const A, const dgConvexHull3DVertex* const B, void* const context); - bool Sanity() const; - void Save (const char* const filename) const; - - dgInt32 m_count; - dgFloat64 m_diag; - dgBigVector m_aabbP0; - dgBigVector m_aabbP1; - dgArray<dgBigVector> m_points; -}; - - -inline dgInt32 dgConvexHull3d::GetVertexCount() const -{ - return m_count; -} - -inline const dgBigVector* dgConvexHull3d::GetVertexPool() const -{ - return &m_points[0]; -} - -inline const dgBigVector& dgConvexHull3d::GetVertex(dgInt32 index) const -{ - return m_points[index]; -} - -inline dgFloat64 dgConvexHull3d::GetDiagonal() const -{ - return m_diag; -} - - -inline void dgConvexHull3d::GetAABB (dgBigVector& boxP0, dgBigVector& boxP1) const -{ - boxP0 = m_aabbP0; - boxP1 = m_aabbP1; -} - -#endif diff --git a/thirdparty/src/newton/dgCore/dgConvexHull4d.cpp b/thirdparty/src/newton/dgCore/dgConvexHull4d.cpp deleted file mode 100644 index ca4a38d02..000000000 --- a/thirdparty/src/newton/dgCore/dgConvexHull4d.cpp +++ /dev/null @@ -1,1056 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgSort.h" -#include "dgTree.h" -#include "dgHeap.h" -#include "dgStack.h" -#include "dgGoogol.h" -#include "dgConvexHull4d.h" -#include "dgSmallDeterminant.h" - -#define DG_VERTEX_CLUMP_SIZE_4D 8 - - -dgConvexHull4d::dgNormalMap::dgNormalMap() - :m_count(sizeof (m_normal) / sizeof (m_normal[0])) -{ - dgVector p0(dgFloat32( 1.0f), dgFloat32( 0.0f), dgFloat32( 0.0f), dgFloat32(0.0f)); - dgVector p1(dgFloat32(-1.0f), dgFloat32( 0.0f), dgFloat32( 0.0f), dgFloat32(0.0f)); - dgVector p2(dgFloat32( 0.0f), dgFloat32( 1.0f), dgFloat32( 0.0f), dgFloat32(0.0f)); - dgVector p3(dgFloat32( 0.0f), dgFloat32(-1.0f), dgFloat32( 0.0f), dgFloat32(0.0f)); - dgVector p4(dgFloat32( 0.0f), dgFloat32( 0.0f), dgFloat32( 1.0f), dgFloat32(0.0f)); - dgVector p5(dgFloat32( 0.0f), dgFloat32( 0.0f), dgFloat32(-1.0f), dgFloat32(0.0f)); - - dgInt32 count = 0; - dgInt32 subdivitions = 2; - - dgBigVector tmp[128]; - TessellateTriangle(subdivitions, p4, p0, p2, tmp, count); - TessellateTriangle(subdivitions, p0, p5, p2, tmp, count); - TessellateTriangle(subdivitions, p5, p1, p2, tmp, count); - TessellateTriangle(subdivitions, p1, p4, p2, tmp, count); - TessellateTriangle(subdivitions, p0, p4, p3, tmp, count); - TessellateTriangle(subdivitions, p5, p0, p3, tmp, count); - TessellateTriangle(subdivitions, p1, p5, p3, tmp, count); - TessellateTriangle(subdivitions, p4, p1, p3, tmp, count); - - count = 0; - for (dgInt32 j = 0; j < 8; j++) { - dgFloat64 beta = (j - 4) * dgFloat64 (22.5f * dgDegreeToRad) + dgFloat64 (10.5f * dgDegreeToRad); - dgFloat64 sinBeta = sin(beta); - dgFloat64 cosBeta = cos(beta); - - dgFloat64 w = sinBeta; - for (dgInt32 i = 0; i < 128; i ++) { - dgFloat64 z = cosBeta * tmp[i].m_z; - dgFloat64 y = cosBeta * tmp[i].m_y; - dgFloat64 x = cosBeta * tmp[i].m_x; - dgInt32 index = dgBitReversal(count, sizeof (m_normal) / sizeof (m_normal[0])); - dgAssert (index < sizeof (m_normal) / sizeof (m_normal[0])); - dgAssert (count < sizeof (m_normal) / sizeof (m_normal[0])); - m_normal[index] = dgBigVector (x, y, z, w); - count ++; - } - } -} - -void dgConvexHull4d::dgNormalMap::TessellateTriangle(dgInt32 level, const dgVector& p0, const dgVector& p1, const dgVector& p2, dgBigVector* const buffer, dgInt32& count) -{ - dgAssert(p0.m_w == dgFloat32(0.0f)); - dgAssert(p1.m_w == dgFloat32(0.0f)); - dgAssert(p2.m_w == dgFloat32(0.0f)); - if (level) { - dgAssert(dgAbs(p0.DotProduct(p0).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p1.DotProduct(p1).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p2.DotProduct(p2).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgVector p01(p0 + p1); - dgVector p12(p1 + p2); - dgVector p20(p2 + p0); - - dgAssert (p01.m_w == dgFloat32 (0.0f)); - dgAssert (p12.m_w == dgFloat32 (0.0f)); - dgAssert (p20.m_w == dgFloat32 (0.0f)); - p01 = p01.Scale(dgRsqrt(p01.DotProduct(p01).GetScalar())); - p12 = p12.Scale(dgRsqrt(p12.DotProduct(p12).GetScalar())); - p20 = p20.Scale(dgRsqrt(p20.DotProduct(p20).GetScalar())); - - dgAssert(dgAbs(p01.DotProduct(p01).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p12.DotProduct(p12).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p20.DotProduct(p20).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - - TessellateTriangle(level - 1, p0, p01, p20, buffer, count); - TessellateTriangle(level - 1, p1, p12, p01, buffer, count); - TessellateTriangle(level - 1, p2, p20, p12, buffer, count); - TessellateTriangle(level - 1, p01, p12, p20, buffer, count); - } else { - dgBigPlane n(p0, p1, p2); - n = n.Scale(dgFloat64(1.0f) / sqrt(n.DotProduct(n).GetScalar())); - n.m_w = dgFloat64(0.0f); - dgInt32 index = dgBitReversal(count, 128); - buffer[index] = n; - dgAssert(count < 128); - count++; - } -} - - -class dgConvexHull4dAABBTreeNode -{ - public: - #ifdef _DEBUG - dgConvexHull4dAABBTreeNode() - { - static dgInt32 id = 0; - m_id = id; - id ++; - } - dgInt32 m_id; - #endif - - dgBigVector m_box[2]; - dgConvexHull4dAABBTreeNode* m_left; - dgConvexHull4dAABBTreeNode* m_right; - dgConvexHull4dAABBTreeNode* m_parent; -}; - -class dgConvexHull4dPointCluster: public dgConvexHull4dAABBTreeNode -{ - public: - dgInt32 m_count; - dgInt32 m_indices[DG_VERTEX_CLUMP_SIZE_4D]; -}; - - -dgConvexHull4dTetraherum::dgTetrahedrumPlane::dgTetrahedrumPlane (const dgBigVector& p0, const dgBigVector& p1, const dgBigVector& p2, const dgBigVector& p3) - :dgBigVector ((p1 - p0).CrossProduct (p2 - p0, p3 - p0)) -{ - dgBigVector& me = *this; - dgFloat64 invMag2 = dgFloat32 (0.0f); - dgFloat64 val = me.DotProduct(me).m_x; - if (val > dgFloat64 (1.0e-38)) { - invMag2 = dgFloat64 (1.0f) / sqrt (val); - } else { - invMag2 = dgFloat32 (0.0f); - } - - me.m_x *= invMag2; - me.m_y *= invMag2; - me.m_z *= invMag2; - me.m_w *= invMag2; - m_dist = - me.DotProduct(p0).m_x; -} - -dgFloat64 dgConvexHull4dTetraherum::dgTetrahedrumPlane::Evalue (const dgBigVector& point) const -{ - const dgBigVector& me = *this; - return me.DotProduct(point).m_x + m_dist; -} - - -dgConvexHull4dTetraherum::dgConvexHull4dTetraherum() -{ -#ifdef _DEBUG - static dgInt32 debugID; - m_debugID = debugID; - debugID ++; -#endif - static dgInt32 m_monotonicID; - - m_uniqueID = m_monotonicID; - m_monotonicID ++; -} - -void dgConvexHull4dTetraherum::Init (const dgConvexHull4dVector* const points, dgInt32 v0, dgInt32 v1, dgInt32 v2, dgInt32 v3) -{ - m_faces[0].m_index[0] = v0; - m_faces[0].m_index[1] = v1; - m_faces[0].m_index[2] = v2; - m_faces[0].m_index[3] = v3; - - m_faces[1].m_index[0] = v3; - m_faces[1].m_index[1] = v0; - m_faces[1].m_index[2] = v2; - m_faces[1].m_index[3] = v1; - - m_faces[2].m_index[0] = v3; - m_faces[2].m_index[1] = v2; - m_faces[2].m_index[2] = v1; - m_faces[2].m_index[3] = v0; - - m_faces[3].m_index[0] = v3; - m_faces[3].m_index[1] = v1; - m_faces[3].m_index[2] = v0; - m_faces[3].m_index[3] = v2; - - SetMark (0); - for (dgInt32 i = 0; i < 4; i ++) { - m_faces[i].m_twin = NULL; - } - -#ifdef _DEBUG - dgBigVector p1p0 (points[v1] - points[v0]); - dgBigVector p2p0 (points[v2] - points[v0]); - dgBigVector p3p0 (points[v3] - points[v0]); - dgBigVector normal (p1p0.CrossProduct(p2p0, p3p0)); - dgFloat64 volume = normal.DotProduct(normal).m_x; - dgAssert (volume > dgFloat64 (0.0f)); -#endif -} - - -dgFloat64 dgConvexHull4dTetraherum::Evalue (const dgConvexHull4dVector* const pointArray, const dgBigVector& point) const -{ - const dgBigVector &p0 = pointArray[m_faces[0].m_index[0]]; - const dgBigVector &p1 = pointArray[m_faces[0].m_index[1]]; - const dgBigVector &p2 = pointArray[m_faces[0].m_index[2]]; - const dgBigVector &p3 = pointArray[m_faces[0].m_index[3]]; - - dgFloat64 matrix[4][4]; - for (dgInt32 i = 0; i < 4; i ++) { - matrix[0][i] = p1[i] - p0[i]; - matrix[1][i] = p2[i] - p0[i]; - matrix[2][i] = p3[i] - p0[i]; - matrix[3][i] = point[i] - p0[i]; - } - - dgFloat64 error; - dgFloat64 det = Determinant4x4 (matrix, &error); - dgFloat64 precision = dgFloat64 (1.0f) / dgFloat64 (1<<24); - dgFloat64 errbound = error * precision; - if (fabs(det) > errbound) { - return det; - } - - dgGoogol exactMatrix[4][4]; - for (dgInt32 i = 0; i < 4; i ++) { - exactMatrix[0][i] = dgGoogol(p1[i]) - dgGoogol(p0[i]); - exactMatrix[1][i] = dgGoogol(p2[i]) - dgGoogol(p0[i]); - exactMatrix[2][i] = dgGoogol(p3[i]) - dgGoogol(p0[i]); - exactMatrix[3][i] = dgGoogol(point[i]) - dgGoogol(p0[i]); - } - return Determinant4x4(exactMatrix); -} - -dgFloat64 dgConvexHull4dTetraherum::GetTetraVolume(const dgConvexHull4dVector* const points) const -{ - const dgBigVector &p0 = points[m_faces[0].m_index[0]]; - const dgBigVector &p1 = points[m_faces[0].m_index[1]]; - const dgBigVector &p2 = points[m_faces[0].m_index[2]]; - const dgBigVector &p3 = points[m_faces[0].m_index[3]]; - - dgFloat64 matrix[3][3]; - for (dgInt32 i = 0; i < 3; i++) { - matrix[0][i] = p2[i] - p0[i]; - matrix[1][i] = p1[i] - p0[i]; - matrix[2][i] = p3[i] - p0[i]; - } - - dgFloat64 error; - dgFloat64 det = Determinant3x3(matrix, &error); - - - dgFloat64 precision = dgFloat64(1.0f) / dgFloat64(1 << 24); - dgFloat64 errbound = error * precision; - if (fabs(det) > errbound) { - return det; - } - - dgGoogol exactMatrix[3][3]; - for (dgInt32 i = 0; i < 3; i++) { - exactMatrix[0][i] = dgGoogol(p2[i]) - dgGoogol(p0[i]); - exactMatrix[1][i] = dgGoogol(p1[i]) - dgGoogol(p0[i]); - exactMatrix[2][i] = dgGoogol(p3[i]) - dgGoogol(p0[i]); - } - return Determinant3x3(exactMatrix); -} - - -dgBigVector dgConvexHull4dTetraherum::CircumSphereCenter (const dgConvexHull4dVector* const pointArray) const -{ - dgGoogol matrix[4][4]; - - dgBigVector points[4]; - points[0] = pointArray[m_faces[0].m_index[0]]; - points[1] = pointArray[m_faces[0].m_index[1]]; - points[2] = pointArray[m_faces[0].m_index[2]]; - points[3] = pointArray[m_faces[0].m_index[3]]; - - for (dgInt32 i = 0; i < 4; i ++) { - for (dgInt32 j = 0; j < 3; j ++) { - matrix[i][j] = dgGoogol (points[i][j]); - } - matrix[i][3] = dgGoogol (1.0f); - } - dgGoogol det (Determinant4x4(matrix)); - dgFloat64 invDen = dgFloat64 (1.0f) / (dgFloat64(det) * dgFloat64 (2.0f)); - - dgBigVector centerOut; - dgFloat64 sign = dgFloat64 (1.0f); - for (dgInt32 k = 0; k < 3; k ++) { - for (dgInt32 i = 0; i < 4; i ++) { - matrix[i][0] = dgGoogol (points[i][3]); - for (dgInt32 j = 0; j < 2; j ++) { - dgInt32 j1 = (j < k) ? j : j + 1; - matrix[i][j + 1] = dgGoogol (points[i][j1]); - } - matrix[i][3] = dgGoogol (1.0f); - } - dgGoogol det1 (Determinant4x4(matrix)); - dgFloat64 val = dgFloat64 (det1) * sign; - sign *= dgFloat64 (-1.0f); - centerOut[k] = val * invDen; - } - centerOut[3] = dgFloat32 (0.0f); - return centerOut; -} - -dgConvexHull4dTetraherum::dgTetrahedrumPlane dgConvexHull4dTetraherum::GetPlaneEquation (const dgConvexHull4dVector* const points) const -{ - const dgBigVector &p0 = points[m_faces[0].m_index[0]]; - const dgBigVector &p1 = points[m_faces[0].m_index[1]]; - const dgBigVector &p2 = points[m_faces[0].m_index[2]]; - const dgBigVector &p3 = points[m_faces[0].m_index[3]]; - return dgTetrahedrumPlane (p0, p1, p2, p3); -} - -dgConvexHull4d::dgConvexHull4d (dgMemoryAllocator* const allocator) - :dgList<dgConvexHull4dTetraherum>(allocator), m_mark(0), m_count (0), m_diag(), m_points(allocator) -{ -} - - -dgConvexHull4d::dgConvexHull4d (dgMemoryAllocator* const allocator, const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, dgFloat64 distTol) - :dgList<dgConvexHull4dTetraherum>(allocator), m_mark(0), m_count (0), m_diag(), m_points(allocator) -{ - BuildHull (allocator, vertexCloud, strideInBytes, count, distTol); -} - - -dgConvexHull4d::~dgConvexHull4d(void) -{ -} - -const dgConvexHull4d::dgNormalMap& dgConvexHull4d::GetNormaMap() -{ - static dgNormalMap normalMap; - return normalMap; -} - - -void dgConvexHull4d::Save (const char* const filename) const -{ - FILE* const file = fopen (filename, "wb"); - int index = 0; -// fprintf (file, "final\n"); - for (dgListNode* nodePtr = GetFirst(); nodePtr; nodePtr = nodePtr->GetNext()) { - fprintf (file, "tetra %d\n", index); - index ++; - const dgConvexHull4dTetraherum& face = nodePtr->GetInfo(); - const dgBigVector& p0 = m_points[face.m_faces[0].m_index[0]]; - const dgBigVector& p1 = m_points[face.m_faces[0].m_index[1]]; - const dgBigVector& p2 = m_points[face.m_faces[0].m_index[2]]; - const dgBigVector& p3 = m_points[face.m_faces[0].m_index[3]]; - fprintf (file, "p0(%f %f %f %f)\n", p0[0], p0[1], p0[2], p0[3]); - fprintf (file, "p1(%f %f %f %f)\n", p1[0], p1[1], p1[2], p1[3]); - fprintf (file, "p2(%f %f %f %f)\n", p2[0], p2[1], p2[2], p2[3]); - fprintf (file, "p3(%f %f %f %f)\n", p3[0], p3[1], p3[2], p3[3]); - } - fprintf (file, "\n"); - - fclose (file); -} - - -dgInt32 dgConvexHull4d::SupportVertex (dgConvexHull4dAABBTreeNode** const treePointer, const dgConvexHull4dVector* const points, const dgBigVector& dir, const bool removeEntry) const -{ - #define DG_STACK_DEPTH_4D 64 - dgFloat64 aabbProjection[DG_STACK_DEPTH_4D]; - const dgConvexHull4dAABBTreeNode *stackPool[DG_STACK_DEPTH_4D]; - - dgInt32 index = -1; - dgInt32 stack = 1; - stackPool[0] = *treePointer; - aabbProjection[0] = dgFloat32 (1.0e20f); - dgFloat64 maxProj = dgFloat64 (-1.0e20f); - dgInt32 ix = (dir[0] > dgFloat64 (0.0f)) ? 1 : 0; - dgInt32 iy = (dir[1] > dgFloat64 (0.0f)) ? 1 : 0; - dgInt32 iz = (dir[2] > dgFloat64 (0.0f)) ? 1 : 0; - dgInt32 iw = (dir[3] > dgFloat64 (0.0f)) ? 1 : 0; - while (stack) { - stack--; - dgFloat64 boxSupportValue = aabbProjection[stack]; - if (boxSupportValue > maxProj) { - const dgConvexHull4dAABBTreeNode* const me = stackPool[stack]; - - if (me->m_left && me->m_right) { - dgBigVector leftSupportPoint (me->m_left->m_box[ix].m_x, me->m_left->m_box[iy].m_y, me->m_left->m_box[iz].m_z, me->m_left->m_box[iw].m_w); - dgFloat64 leftSupportDist = leftSupportPoint.DotProduct(dir).m_x; - - dgBigVector rightSupportPoint (me->m_right->m_box[ix].m_x, me->m_right->m_box[iy].m_y, me->m_right->m_box[iz].m_z, me->m_right->m_box[iw].m_w); - dgFloat64 rightSupportDist = rightSupportPoint.DotProduct(dir).m_x; - - if (rightSupportDist >= leftSupportDist) { - aabbProjection[stack] = leftSupportDist; - stackPool[stack] = me->m_left; - stack++; - dgAssert (stack < DG_STACK_DEPTH_4D); - aabbProjection[stack] = rightSupportDist; - stackPool[stack] = me->m_right; - stack++; - dgAssert (stack < DG_STACK_DEPTH_4D); - } else { - aabbProjection[stack] = rightSupportDist; - stackPool[stack] = me->m_right; - stack++; - dgAssert (stack < DG_STACK_DEPTH_4D); - aabbProjection[stack] = leftSupportDist; - stackPool[stack] = me->m_left; - stack++; - dgAssert (stack < DG_STACK_DEPTH_4D); - } - - } else { - dgConvexHull4dPointCluster* const cluster = (dgConvexHull4dPointCluster*) me; - for (dgInt32 i = 0; i < cluster->m_count; i ++) { - const dgConvexHull4dVector& p = points[cluster->m_indices[i]]; - dgAssert (p.m_x >= cluster->m_box[0].m_x); - dgAssert (p.m_x <= cluster->m_box[1].m_x); - dgAssert (p.m_y >= cluster->m_box[0].m_y); - dgAssert (p.m_y <= cluster->m_box[1].m_y); - dgAssert (p.m_z >= cluster->m_box[0].m_z); - dgAssert (p.m_z <= cluster->m_box[1].m_z); - dgAssert (p.m_w >= cluster->m_box[0].m_w); - dgAssert (p.m_w <= cluster->m_box[1].m_w); - if (!p.m_mark) { - dgFloat64 dist = p.DotProduct(dir).m_x; - if (dist > maxProj) { - maxProj = dist; - index = cluster->m_indices[i]; - } - } else if (removeEntry) { - cluster->m_indices[i] = cluster->m_indices[cluster->m_count - 1]; - cluster->m_count = cluster->m_count - 1; - i --; - } - } - - if (cluster->m_count == 0) { - dgConvexHull4dAABBTreeNode* const parent = cluster->m_parent; - if (parent) { - dgConvexHull4dAABBTreeNode* const sibling = (parent->m_left != cluster) ? parent->m_left : parent->m_right; - dgAssert (sibling != cluster); - dgConvexHull4dAABBTreeNode* const grandParent = parent->m_parent; - if (grandParent) { - sibling->m_parent = grandParent; - if (grandParent->m_right == parent) { - grandParent->m_right = sibling; - } else { - grandParent->m_left = sibling; - } - } else { - sibling->m_parent = NULL; - *treePointer = sibling; - } - } - } - } - } - } - - dgAssert (index != -1); - return index; -} - - -dgInt32 dgConvexHull4d::ConvexCompareVertex(const dgConvexHull4dVector* const A, const dgConvexHull4dVector* const B, void* const context) -{ - for (dgInt32 i = 0; i < 4; i ++) { - if ((*A)[i] < (*B)[i]) { - return -1; - } else if ((*A)[i] > (*B)[i]) { - return 1; - } - } - return 0; -} - - -dgConvexHull4dAABBTreeNode* dgConvexHull4d::BuildTree (dgConvexHull4dAABBTreeNode* const parent, dgConvexHull4dVector* const points, dgInt32 count, dgInt32 baseIndex, dgInt8** memoryPool, dgInt32& maxMemSize) const -{ - dgConvexHull4dAABBTreeNode* tree = NULL; - - dgAssert (count); - dgBigVector minP ( dgFloat32 (1.0e15f)); - dgBigVector maxP (-dgFloat32 (1.0e15f)); - if (count <= DG_VERTEX_CLUMP_SIZE_4D) { - - dgConvexHull4dPointCluster* const clump = new (*memoryPool) dgConvexHull4dPointCluster; - *memoryPool += sizeof (dgConvexHull4dPointCluster); - maxMemSize -= sizeof (dgConvexHull4dPointCluster); - dgAssert (maxMemSize >= 0); - - dgAssert (clump); - clump->m_count = count; - for (dgInt32 i = 0; i < count; i ++) { - clump->m_indices[i] = i + baseIndex; - - const dgBigVector& p = points[i]; - minP.m_x = dgMin (p.m_x, minP.m_x); - minP.m_y = dgMin (p.m_y, minP.m_y); - minP.m_z = dgMin (p.m_z, minP.m_z); - minP.m_w = dgMin (p.m_w, minP.m_w); - - maxP.m_x = dgMax (p.m_x, maxP.m_x); - maxP.m_y = dgMax (p.m_y, maxP.m_y); - maxP.m_z = dgMax (p.m_z, maxP.m_z); - maxP.m_w = dgMax (p.m_w, maxP.m_w); - } - - clump->m_left = NULL; - clump->m_right = NULL; - tree = clump; - - } else { - dgBigVector median (dgFloat32 (0.0f)); - dgBigVector varian (dgFloat32 (0.0f)); - for (dgInt32 i = 0; i < count; i ++) { - - const dgBigVector& p = points[i]; - minP.m_x = dgMin (p.m_x, minP.m_x); - minP.m_y = dgMin (p.m_y, minP.m_y); - minP.m_z = dgMin (p.m_z, minP.m_z); - minP.m_w = dgMin (p.m_w, minP.m_w); - - maxP.m_x = dgMax (p.m_x, maxP.m_x); - maxP.m_y = dgMax (p.m_y, maxP.m_y); - maxP.m_z = dgMax (p.m_z, maxP.m_z); - maxP.m_w = dgMax (p.m_w, maxP.m_w); - - median = median + p; - varian = varian + p * p; - } - - varian = varian.Scale (dgFloat32 (count)) - median * median; - - dgInt32 index = 0; - dgFloat64 maxVarian = dgFloat64 (-1.0e10f); - for (dgInt32 i = 0; i < 4; i ++) { - if (varian[i] > maxVarian) { - index = i; - maxVarian = varian[i]; - } - } - dgBigVector center = median.Scale (dgFloat64 (1.0f) / dgFloat64 (count)); - - dgFloat64 test = center[index]; - - dgInt32 i0 = 0; - dgInt32 i1 = count - 1; - do { - for (; i0 <= i1; i0 ++) { - dgFloat64 val = points[i0][index]; - if (val > test) { - break; - } - } - - for (; i1 >= i0; i1 --) { - dgFloat64 val = points[i1][index]; - if (val < test) { - break; - } - } - - if (i0 < i1) { - dgSwap(points[i0], points[i1]); - i0++; - i1--; - } - } while (i0 <= i1); - - if (i0 == 0){ - i0 = count / 2; - } - if (i0 >= (count - 1)){ - i0 = count / 2; - } - - tree = new (*memoryPool) dgConvexHull4dAABBTreeNode; - *memoryPool += sizeof (dgConvexHull4dAABBTreeNode); - maxMemSize -= sizeof (dgConvexHull4dAABBTreeNode); - dgAssert (maxMemSize >= 0); - - dgAssert (i0); - dgAssert (count - i0); - - tree->m_left = BuildTree (tree, points, i0, baseIndex, memoryPool, maxMemSize); - tree->m_right = BuildTree (tree, &points[i0], count - i0, i0 + baseIndex, memoryPool, maxMemSize); - } - - dgAssert (tree); - tree->m_parent = parent; - tree->m_box[0] = minP - dgBigVector (dgFloat64 (1.0e-3f)); - tree->m_box[1] = maxP + dgBigVector (dgFloat64 (1.0e-3f)); - return tree; -} - -dgInt32 dgConvexHull4d::InitVertexArray(dgConvexHull4dVector* const points, const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, void* const memoryPool, dgInt32 maxMemSize) -{ - dgInt32 stride = dgInt32(strideInBytes / sizeof (dgFloat64)); - for (dgInt32 i = 0; i < count; i ++) { - points[i] = dgBigVector (vertexCloud[i * stride + 0], vertexCloud[i * stride + 1], vertexCloud[i * stride + 2], vertexCloud[i * stride + 3]); - points[i].m_index = i; - points[i].m_mark = 0; - } - - dgSort(points, count, ConvexCompareVertex); - dgInt32 indexCount = 0; - for (int i = 1; i < count; i ++) { - for (; i < count; i ++) { - if (ConvexCompareVertex (&points[indexCount], &points[i], NULL)) { - indexCount ++; - points[indexCount] = points[i]; - break; - } - } - } - count = indexCount + 1; - if (count < 4) { - m_count = 0; - return count; - } - - dgConvexHull4dAABBTreeNode* tree = BuildTree (NULL, points, count, 0, (dgInt8**) &memoryPool, maxMemSize); - - dgBigVector boxSize (tree->m_box[1] - tree->m_box[0]); - m_diag = dgFloat32 (sqrt (boxSize.DotProduct(boxSize).m_x)); - - dgInt32 marks[4]; - m_points.Resize(count); - bool validTetrahedrum = false; - dgConvexHull4dVector* const convexPoints = &m_points[0]; - const dgFloat64 testVol = dgFloat32 (1.0e-6f) * m_diag * m_diag * m_diag; - - const dgNormalMap& normalMap = GetNormaMap(); - for (dgInt32 i = 0; !validTetrahedrum && (i < normalMap.m_count); i++) { - dgInt32 index = SupportVertex(&tree, points, normalMap.m_normal[i], false); - convexPoints[0] = points[index]; - marks[0] = index; - for (dgInt32 j = i + 1; !validTetrahedrum && (j < normalMap.m_count); j++) { - dgInt32 index1 = SupportVertex(&tree, points, normalMap.m_normal[j], false); - convexPoints[1] = points[index1]; - dgBigVector p10(convexPoints[1] - convexPoints[0]); - if (p10.DotProduct(p10).GetScalar() >(dgFloat32(1.0e-3f) * m_diag)) { - marks[1] = index1; - for (dgInt32 k = j + 1; !validTetrahedrum && (k < normalMap.m_count); k++) { - dgInt32 index2 = SupportVertex(&tree, points, normalMap.m_normal[k], false); - convexPoints[2] = points[index2]; - dgBigVector p20(convexPoints[2] - convexPoints[0]); - dgBigVector p21(convexPoints[2] - convexPoints[1]); - bool test = p20.DotProduct(p20).GetScalar() > (dgFloat32(1.0e-3f) * m_diag); - test = test && (p21.DotProduct(p21).GetScalar() > (dgFloat32(1.0e-3f) * m_diag)); - if (test) { - marks[2] = index2; - for (dgInt32 l = k + 1; !validTetrahedrum && (l < normalMap.m_count); l++) { - dgInt32 index3 = SupportVertex(&tree, points, normalMap.m_normal[l], false); - convexPoints[3] = points[index3]; - dgBigVector p30(convexPoints[3] - convexPoints[0]); - dgBigVector plane(p10.CrossProduct(p20, p30)); - dgFloat64 volume = plane.DotProduct(plane).GetScalar(); - if (volume > testVol) { - validTetrahedrum = true; - marks[3] = index3; - } - } - } - } - } - } - } - - m_count = 4; - if (!validTetrahedrum) { - m_count = 0; - } - - if (validTetrahedrum) { - for (dgInt32 i = 0; i < 4; i ++) { - points[marks[i]].m_mark = 1; - } - } - - return count; -} - - -dgConvexHull4d::dgListNode* dgConvexHull4d::AddFace (dgInt32 i0, dgInt32 i1, dgInt32 i2, dgInt32 i3) -{ - dgListNode* const node = Append(); - dgConvexHull4dTetraherum& face = node->GetInfo(); - face.Init (&m_points[0], i0, i1, i2, i3); - return node; -} - - -void dgConvexHull4d::DeleteFace (dgListNode* const node) -{ - Remove (node); -} - - -bool dgConvexHull4d::Sanity() const -{ - for (dgListNode* node = GetFirst(); node; node = node->GetNext()) { - dgConvexHull4dTetraherum* const tetra = &node->GetInfo(); - - for (dgInt32 i = 0; i < 4; i ++) { - dgConvexHull4dTetraherum::dgTetrahedrumFace* const face = &tetra->m_faces[i]; - dgListNode* const twinNode = face->m_twin; - if (!twinNode) { - return false; - } - } - } - -/* - dgList<dgListNode*> tetraList(GetAllocator()); - const dgHullVector* const points = &m_points[0]; - for (dgListNode* node = GetFirst(); node; node = node->GetNext()) { - dgConvexHull4dTetraherum* const tetra = &node->GetInfo(); - const dgBigVector &p0 = points[tetra->m_faces[0].m_index[0]]; - const dgBigVector &p1 = points[tetra->m_faces[0].m_index[1]]; - const dgBigVector &p2 = points[tetra->m_faces[0].m_index[2]]; - const dgBigVector &p3 = points[tetra->m_faces[0].m_index[3]]; - - dgBigVector p1p0 (p1.Sub4(p0)); - dgBigVector p2p0 (p2.Sub4(p0)); - dgBigVector p3p0 (p3.Sub4(p0)); - dgBigVector normal (p1p0.CrossProduct (p2p0, p3p0)); - - if (normal.m_w < dgFloat64 (0.0f)) { - tetraList.Append(node); - } - } - - for (dgList<dgListNode*>::dgListNode* node0 = tetraList.GetFirst(); node0; node0 = node0->GetNext()) { - dgListNode* const tetraNode0 = node0->GetInfo(); - dgConvexHull4dTetraherum* const tetra0 = &tetraNode0->GetInfo(); - - dgInt32 index0[4]; - index0[0] = tetra0->m_faces[0].m_index[0]; - index0[1] = tetra0->m_faces[0].m_index[1]; - index0[2] = tetra0->m_faces[0].m_index[2]; - index0[3] = tetra0->m_faces[0].m_index[3]; - - const dgBigVector &p0 = points[index0[0]]; - const dgBigVector &p1 = points[index0[1]]; - const dgBigVector &p2 = points[index0[2]]; - const dgBigVector &p3 = points[index0[3]]; - for (dgList<dgListNode*>::dgListNode* node1 = node0->GetNext(); node1; node1 = node1->GetNext()) { - dgListNode* const tetraNode1 = node1->GetInfo(); - dgConvexHull4dTetraherum* const tetra1 = &tetraNode1->GetInfo(); - - dgInt32 index1[4]; - index1[0] = tetra1->m_faces[0].m_index[0]; - index1[1] = tetra1->m_faces[0].m_index[1]; - index1[2] = tetra1->m_faces[0].m_index[2]; - index1[3] = tetra1->m_faces[0].m_index[3]; - - for (dgInt32 i = 0; i < 4; i ++) { - dgInt32 count = 0; - dgInt32 k = index1[i]; - for (dgInt32 j = 0; j < 4; j ++) { - count += (k == index0[j]); - } - if (!count){ -// const dgBigVector &p = points[k]; -// dgFloat64 size = -insphere(&p0.m_x, &p1.m_x, &p2.m_x, &p3.m_x, &p.m_x); -// if (size < dgFloat64 (0.0f)) { -// return false; -// } - } - } - } - } -*/ - - return true; -} - - -void dgConvexHull4d::LinkSibling (dgListNode* node0, dgListNode* node1) const -{ - dgConvexHull4dTetraherum* const tetra0 = &node0->GetInfo(); - dgConvexHull4dTetraherum* const tetra1 = &node1->GetInfo(); - for (int i = 0; i < 4; i ++) { - dgConvexHull4dTetraherum::dgTetrahedrumFace* const face0 = &tetra0->m_faces[i]; - if (!face0->m_twin) { - dgInt32 i0 = face0->m_index[0]; - dgInt32 i1 = face0->m_index[1]; - dgInt32 i2 = face0->m_index[2]; - for (int j = 0; j < 4; j ++) { - dgConvexHull4dTetraherum::dgTetrahedrumFace* const face1 = &tetra1->m_faces[j]; - if (!face1->m_twin) { - dgInt32 j2 = face1->m_index[0]; - dgInt32 j1 = face1->m_index[1]; - dgInt32 j0 = face1->m_index[2]; - - if (((i0 == j0) && (i1 == j1) && (i2 == j2)) || ((i1 == j0) && (i2 == j1) && (i0 == j2)) || ((i2 == j0) && (i0 == j1) && (i1 == j2))) { - face0->m_twin = node1; - face1->m_twin = node0; - return; - } - } - } - } - } -} - - -void dgConvexHull4d::InsertNewVertex(dgInt32 vertexIndex, dgListNode* const frontFace, dgList<dgListNode*>& deletedFaces, dgList<dgListNode*>& newFaces) -{ - dgAssert (Sanity()); - dgList<dgListNode*> stack(GetAllocator()); - - dgInt32 mark = IncMark(); - stack.Append(frontFace); - dgConvexHull4dVector* const hullVertexArray = &m_points[0]; - const dgBigVector& p = hullVertexArray[vertexIndex]; - while (stack.GetCount()) { - dgList<dgListNode*>::dgListNode* const stackNode = stack.GetLast(); - dgListNode* const node = stackNode->GetInfo(); - stack.Remove(stackNode); - dgConvexHull4dTetraherum* const face = &node->GetInfo(); - if ((face->GetMark() != mark) && (face->Evalue(hullVertexArray, p) > dgFloat64(0.0f))) { -#ifdef _DEBUG - for (dgList<dgListNode*>::dgListNode* deleteNode = deletedFaces.GetFirst(); deleteNode; deleteNode = deleteNode->GetNext()) { - dgAssert (deleteNode->GetInfo() != node); - } -#endif - deletedFaces.Append(node); - - face->SetMark(mark); - for (dgInt32 i = 0; i < 4; i ++) { - dgListNode* const twinNode = (dgListNode*)face->m_faces[i].m_twin; - dgAssert (twinNode); - dgConvexHull4dTetraherum* const twinFace = &twinNode->GetInfo(); - - if (twinFace->GetMark() != mark) { - stack.Append(twinNode); - } - } - } - } - - dgTree<dgListNode*, dgInt32> perimeter(GetAllocator()); - for (dgList<dgListNode*>::dgListNode* deleteNode = deletedFaces.GetFirst(); deleteNode; deleteNode = deleteNode->GetNext()) { - dgListNode* const deleteTetraNode = deleteNode->GetInfo(); - dgConvexHull4dTetraherum* const deletedTetra = &deleteTetraNode->GetInfo(); - dgAssert (deletedTetra->GetMark() == mark); - for (dgInt32 i = 0; i < 4; i ++) { - dgListNode* const twinNode = deletedTetra->m_faces[i].m_twin; - dgConvexHull4dTetraherum* const twinTetra = &twinNode->GetInfo(); - - if (twinTetra->GetMark() != mark) { - if (!perimeter.Find(twinTetra->m_uniqueID)) { - perimeter.Insert(twinNode, twinTetra->m_uniqueID); - } - } - deletedTetra->m_faces[i].m_twin = NULL; - } - } - - dgList<dgListNode*> coneList(GetAllocator()); - dgTree<dgListNode*, dgInt32>::Iterator iter (perimeter); - for (iter.Begin(); iter; iter ++) { - dgListNode* const perimeterNode = iter.GetNode()->GetInfo(); - dgConvexHull4dTetraherum* const perimeterTetra = &perimeterNode->GetInfo(); - for (dgInt32 i = 0; i < 4; i ++) { - dgConvexHull4dTetraherum::dgTetrahedrumFace* const perimeterFace = &perimeterTetra->m_faces[i]; - - if (perimeterFace->m_twin->GetInfo().GetMark() == mark) { - dgListNode* const newNode = AddFace (vertexIndex, perimeterFace->m_index[0], perimeterFace->m_index[1], perimeterFace->m_index[2]); - newFaces.Addtop(newNode); - - dgConvexHull4dTetraherum* const newTetra = &newNode->GetInfo(); - newTetra->m_faces[2].m_twin = perimeterNode; - perimeterFace->m_twin = newNode; - coneList.Append (newNode); - } - } - } - - for (dgList<dgListNode*>::dgListNode* coneNode = coneList.GetFirst(); coneNode->GetNext(); coneNode = coneNode->GetNext()) { - dgListNode* const coneNodeA = coneNode->GetInfo(); - for (dgList<dgListNode*>::dgListNode* nextConeNode = coneNode->GetNext(); nextConeNode; nextConeNode = nextConeNode->GetNext()) { - dgListNode* const coneNodeB = nextConeNode->GetInfo(); - LinkSibling (coneNodeA, coneNodeB); - } - } -} - -dgConvexHull4d::dgListNode* dgConvexHull4d::FindFacingNode(const dgBigVector& vertex) -{ - const dgConvexHull4dVector* const hullVertexArray = &m_points[0]; - - dgListNode* bestNode = GetFirst(); - dgConvexHull4dTetraherum* const tetra = &bestNode->GetInfo(); - dgConvexHull4dTetraherum::dgTetrahedrumPlane plane (tetra->GetPlaneEquation (hullVertexArray)); - dgFloat64 dist = plane.Evalue(vertex); - dgInt32 mark = IncMark(); - tetra->SetMark(mark); - - dgInt8 buffer[1024 * 2 * sizeof (dgFloat64)]; - dgDownHeap<dgListNode*, dgFloat64> heap (buffer, sizeof (buffer)); - - heap.Push(bestNode, dist); - dgInt32 maxCount = heap.GetMaxCount() - 1; - dgInt32 releafCount = maxCount >> 3; - while (heap.GetCount()) { - dgListNode* const node1 = heap[0]; - dgFloat64 dist1 = heap.Value(); - if (dist1 > dgFloat64 (1.0e-5f)) { - return node1; - } - heap.Pop(); - dgConvexHull4dTetraherum* const tetra1 = &node1->GetInfo(); - for (dgInt32 i = 0; i < 4; i ++) { - dgListNode* neigborghNode = tetra1->m_faces[i].m_twin; - dgConvexHull4dTetraherum* const neighborgh = &neigborghNode->GetInfo(); - if (neighborgh->GetMark() != mark) { - neighborgh->SetMark(mark); - if (heap.GetCount() >= maxCount) { - for (dgInt32 j = 0; j < releafCount; j ++) { - heap.Remove(heap.GetCount() - 1); - } - } - dgConvexHull4dTetraherum::dgTetrahedrumPlane plane1 (neighborgh->GetPlaneEquation (hullVertexArray)); - heap.Push(neigborghNode, plane1.Evalue(vertex)); - } - } - } - - for (dgListNode* node1 = GetFirst(); node1; node1 = node1->GetNext()) { - dgConvexHull4dTetraherum* const tetra1 = &node1->GetInfo(); - dgFloat64 dist1 = tetra1->Evalue(hullVertexArray, vertex); - if (dist1 > dgFloat64(0.0f)) { - return node1; - } - } - - - return NULL; -} - -dgInt32 dgConvexHull4d::AddVertex (const dgBigVector& vertex) -{ - dgSetPrecisionDouble precision; - dgInt32 index = -1; - dgListNode* const faceNode = FindFacingNode(vertex); - if (faceNode) { - index = m_count; - m_points[index] = vertex; - m_points[index].m_index = index; - m_count ++; - - dgList<dgListNode*> newFaces(GetAllocator()); - dgList<dgListNode*> deleteList(GetAllocator()); - - InsertNewVertex(index, faceNode, deleteList, newFaces); - for (dgList<dgListNode*>::dgListNode* deleteNode = deleteList.GetFirst(); deleteNode; deleteNode = deleteNode->GetNext()) { - dgListNode* const node = deleteNode->GetInfo(); - DeleteFace (node); - } - } - return index; -} - - -void dgConvexHull4d::BuildHull (dgMemoryAllocator* const allocator, const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, dgFloat64 distTol) -{ - dgInt32 treeCount = count / (DG_VERTEX_CLUMP_SIZE_4D>>1); - if (treeCount < 4) { - treeCount = 4; - } - treeCount *= 2; - - dgStack<dgConvexHull4dVector> points (count); - dgStack<dgConvexHull4dPointCluster> treePool (treeCount + 256); - - count = InitVertexArray(&points[0], vertexCloud, strideInBytes, count, &treePool[0], treePool.GetSizeInBytes()); - if (m_count >= 4) { - CalculateConvexHull (&treePool[0], &points[0], count, distTol); - } -} - - -void dgConvexHull4d::CalculateConvexHull (dgConvexHull4dAABBTreeNode* vertexTree, dgConvexHull4dVector* const points, dgInt32 count, dgFloat64 distTol) -{ - distTol = fabs (distTol) * m_diag; - dgListNode* const nodes0 = AddFace (0, 1, 2, 3); - dgListNode* const nodes1 = AddFace (0, 1, 3, 2); - - dgList<dgListNode*> boundaryFaces(GetAllocator()); - boundaryFaces.Append(nodes0); - boundaryFaces.Append(nodes1); - - LinkSibling (nodes0, nodes1); - LinkSibling (nodes0, nodes1); - LinkSibling (nodes0, nodes1); - LinkSibling (nodes0, nodes1); - - IncMark(); - count -= 4; - dgInt32 currentIndex = 4; - while (boundaryFaces.GetCount() && count) { - dgConvexHull4dVector* const hullVertexArray = &m_points[0]; - dgListNode* const faceNode = boundaryFaces.GetFirst()->GetInfo(); - dgConvexHull4dTetraherum* const face = &faceNode->GetInfo(); - dgConvexHull4dTetraherum::dgTetrahedrumPlane planeEquation (face->GetPlaneEquation (hullVertexArray)); - - dgInt32 index = SupportVertex (&vertexTree, points, planeEquation); - - const dgConvexHull4dVector& p = points[index]; - dgFloat64 dist = planeEquation.Evalue(p); - if ((dist > distTol) && (face->Evalue(hullVertexArray, p) > dgFloat64(0.0f))) { - - m_points[currentIndex] = p; - points[index].m_mark = 1; - - dgList<dgListNode*> deleteList(GetAllocator()); - InsertNewVertex(currentIndex, faceNode, deleteList, boundaryFaces); - - for (dgList<dgListNode*>::dgListNode* deleteNode = deleteList.GetFirst(); deleteNode; deleteNode = deleteNode->GetNext()) { - dgListNode* const node = deleteNode->GetInfo(); - boundaryFaces.Remove (node); - DeleteFace (node); - } - - currentIndex ++; - count --; - } else { - boundaryFaces.Remove (faceNode); - } - } - m_count = currentIndex; -} diff --git a/thirdparty/src/newton/dgCore/dgConvexHull4d.h b/thirdparty/src/newton/dgCore/dgConvexHull4d.h deleted file mode 100644 index e6d6b19ca..000000000 --- a/thirdparty/src/newton/dgCore/dgConvexHull4d.h +++ /dev/null @@ -1,193 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DG_CONVEXHULL_4D__ -#define __DG_CONVEXHULL_4D__ - -#include "dgStdafx.h" -#include "dgList.h" -#include "dgArray.h" -#include "dgPlane.h" -#include "dgVector.h" -#include "dgMatrix.h" -#include "dgQuaternion.h" - -class dgMemoryAllocator; -class dgConvexHull4dAABBTreeNode; - -class dgConvexHull4dVector: public dgBigVector -{ - public: - void operator = (const dgBigVector& a) - { - m_x = a.m_x; - m_y = a.m_y; - m_z = a.m_z; - m_w = a.m_w; - m_index = 0; - m_mark = 0; - } - - dgInt32 m_index; - dgInt32 m_mark; -}; - - -class dgConvexHull4dTetraherum -{ - public: - class dgTetrahedrumFace - { - public: - dgInt32 m_index[4]; - dgList<dgConvexHull4dTetraherum>::dgListNode* m_twin; - }; - - - class dgTetrahedrumPlane: public dgBigVector - { - public: - dgTetrahedrumPlane (const dgBigVector& p0, const dgBigVector& p1, const dgBigVector& p2, const dgBigVector& p3); - dgFloat64 Evalue (const dgBigVector& point) const; - dgFloat64 m_dist; - }; - - dgConvexHull4dTetraherum(); - dgTetrahedrumPlane GetPlaneEquation (const dgConvexHull4dVector* const points) const; - dgFloat64 GetTetraVolume (const dgConvexHull4dVector* const pointArray) const; - dgBigVector CircumSphereCenter (const dgConvexHull4dVector* const pointArray) const; - dgFloat64 Evalue (const dgConvexHull4dVector* const pointArray, const dgBigVector& point) const; - - dgInt32 GetMark() const { return m_mark; } - void SetMark(dgInt32 mark) { m_mark = mark; } - - private: - void Init (const dgConvexHull4dVector* const points, dgInt32 v0, dgInt32 v1, dgInt32 v2, dgInt32 v3); - - public: - dgTetrahedrumFace m_faces[4]; - dgInt32 m_mark; - dgInt32 m_uniqueID; - -#ifdef _DEBUG - dgInt32 m_debugID; -#endif - friend class dgConvexHull4d; - friend class dgDelaunayTetrahedralization; -}; - - -class dgConvexHull4d: public dgList<dgConvexHull4dTetraherum> -{ - public: - dgConvexHull4d(dgMemoryAllocator* const allocator, const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, dgFloat64 distTol); - virtual ~dgConvexHull4d(); - - dgInt32 GetVertexCount() const; - dgInt32 GetVertexIndex(dgInt32 i) const; - const dgBigVector& GetVertex(dgInt32 i) const; - - const dgConvexHull4dVector* GetHullVertexArray() const; - dgFloat64 GetTetraVolume (const dgConvexHull4dTetraherum* const tetra) const; - - dgInt32 IncMark (); - void Save (const char* const filename) const; - - protected: - dgConvexHull4d(dgMemoryAllocator* const allocator); - - void BuildHull (dgMemoryAllocator* const allocator, const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, dgFloat64 distTol); - - virtual dgInt32 AddVertex (const dgBigVector& vertex); - virtual dgInt32 InitVertexArray(dgConvexHull4dVector* const points, const dgFloat64* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, void* const memoryPool, dgInt32 maxMemSize); - - virtual dgListNode* AddFace (dgInt32 i0, dgInt32 i1, dgInt32 i2, dgInt32 i3); - virtual void DeleteFace (dgListNode* const node); - - dgListNode* FindFacingNode(const dgBigVector& vertex); - - void InsertNewVertex(dgInt32 vertexIndex, dgListNode* const frontFace, dgList<dgListNode*>& deletedFaces, dgList<dgListNode*>& newFaces); - dgInt32 SupportVertex (dgConvexHull4dAABBTreeNode** const tree, const dgConvexHull4dVector* const points, const dgBigVector& dir, const bool removeEntry = true) const; - - void CalculateConvexHull (dgConvexHull4dAABBTreeNode* vertexTree, dgConvexHull4dVector* const points, dgInt32 count, dgFloat64 distTol); - void LinkSibling (dgListNode* node0, dgListNode* node1) const; - bool Sanity() const; - dgConvexHull4dAABBTreeNode* BuildTree (dgConvexHull4dAABBTreeNode* const parent, dgConvexHull4dVector* const points, dgInt32 count, dgInt32 baseIndex, dgInt8** const memoryPool, dgInt32& maxMemSize) const; - - static dgInt32 ConvexCompareVertex(const dgConvexHull4dVector* const A, const dgConvexHull4dVector* const B, void* const context); - - class dgNormalMap - { - public: - dgNormalMap(); - private: - void TessellateTriangle(dgInt32 level, const dgVector& p0, const dgVector& p1, const dgVector& p2, dgBigVector* const buffer, dgInt32& count); - - dgBigVector m_normal[1024]; - dgInt32 m_count; - friend class dgConvexHull4d; - }; - static const dgNormalMap& GetNormaMap(); - - dgInt32 m_mark; - dgInt32 m_count; - dgFloat64 m_diag; - dgArray<dgConvexHull4dVector> m_points; -}; - - -inline dgInt32 dgConvexHull4d::IncMark () -{ - m_mark ++; - return m_mark; -} - -inline dgInt32 dgConvexHull4d::GetVertexCount() const -{ - return m_count; -} - -inline dgInt32 dgConvexHull4d::GetVertexIndex(dgInt32 index) const -{ - dgAssert (index >= 0); - dgAssert (index < m_count); - return m_points[index].m_index; -} - - -inline const dgBigVector& dgConvexHull4d::GetVertex(dgInt32 index) const -{ - dgAssert (index >= 0); - dgAssert (index < m_count); - return m_points[index]; -} - -inline const dgConvexHull4dVector* dgConvexHull4d::GetHullVertexArray() const -{ - return &m_points[0]; -} - -inline dgFloat64 dgConvexHull4d::GetTetraVolume (const dgConvexHull4dTetraherum* const tetra) const -{ - return tetra->GetTetraVolume (&m_points[0]); -} - -#endif diff --git a/thirdparty/src/newton/dgCore/dgDebug.cpp b/thirdparty/src/newton/dgCore/dgDebug.cpp deleted file mode 100644 index 17bfaadac..000000000 --- a/thirdparty/src/newton/dgCore/dgDebug.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgDebug.h" - - - diff --git a/thirdparty/src/newton/dgCore/dgDebug.h b/thirdparty/src/newton/dgCore/dgDebug.h deleted file mode 100644 index 92228e688..000000000 --- a/thirdparty/src/newton/dgCore/dgDebug.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgDebug__ -#define __dgDebug__ - -#include "dgStdafx.h" - - - inline void dgApi dgExpandTraceMessage(const char *fmt, ...) - { - va_list v_args; - char text[4096]; - - text[0] = 0; - va_start(v_args, fmt); - vsprintf(text, fmt, v_args); - va_end(v_args); - - #if defined (_WIN_32_VER) || defined (_WIN_64_VER) - OutputDebugStringA(text); - #else - printf("%s\n", text); - #endif - } - -#ifdef _MSC_VER - #ifdef _DEBUG - #define DG_TRACE - #endif -#endif - - -#ifdef DG_TRACE - #define dgTrace(x) dgExpandTraceMessage x; -#else - #define dgTrace(x); -#endif - - -#ifdef _DEBUG - inline void TraceFuntionName (const char *name) - { - // static int trace; - // dgTrace (("%d %s\n", trace, name)); - dgTrace (("%s\n", name)); - } - - //#define TRACE_FUNCTION(name) TraceFuntionName (name) - #define TRACE_FUNCTION(name) -#else - #define TRACE_FUNCTION(name) -#endif - - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgDelaunayTetrahedralization.cpp b/thirdparty/src/newton/dgCore/dgDelaunayTetrahedralization.cpp deleted file mode 100644 index a722d5161..000000000 --- a/thirdparty/src/newton/dgCore/dgDelaunayTetrahedralization.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgSort.h" -#include "dgStack.h" -#include "dgGoogol.h" -#include "dgSmallDeterminant.h" -#include "dgDelaunayTetrahedralization.h" - -dgDelaunayTetrahedralization::dgDelaunayTetrahedralization(dgMemoryAllocator* const allocator, const dgFloat64* const vertexCloud, dgInt32 count, dgInt32 strideInByte, dgFloat64 distTol) - :dgConvexHull4d(allocator) -{ - dgSetPrecisionDouble precision; - dgStack<dgBigVector> pool(count + 2); - - dgBigVector* const points = &pool[0]; - dgInt32 stride = dgInt32 (strideInByte / sizeof (dgFloat64)); - for (dgInt32 i = 0; i < count; i ++) { - dgFloat64 x = dgRoundToFloat (vertexCloud[i * stride + 0]); - dgFloat64 y = dgRoundToFloat (vertexCloud[i * stride + 1]); - dgFloat64 z = dgRoundToFloat (vertexCloud[i * stride + 2]); - points[i] = dgBigVector (x, y, z, x * x + y * y + z * z); - } - - dgInt32 oldCount = count; - BuildHull (allocator, &pool[0].m_x, sizeof (dgBigVector), count, distTol); - if (oldCount > m_count) { - // the mesh is convex, need to add two steiners point to make tractable - dgBigVector origin (dgFloat64 (0.0f)); - dgFloat64 maxW = dgFloat64 (-1.0e20f); - for (dgInt32 i = 0; i < count; i++) { - dgFloat64 x = dgRoundToFloat(vertexCloud[i * stride + 0]); - dgFloat64 y = dgRoundToFloat(vertexCloud[i * stride + 1]); - dgFloat64 z = dgRoundToFloat(vertexCloud[i * stride + 2]); - points[i] = dgBigVector(x, y, z, x * x + y * y + z * z); - origin += points[i]; - maxW = dgMax (points[i].m_w, maxW); - } - origin = origin.Scale (dgFloat64 (1.0f) / count); - points[count + 0] = origin; - points[count + 1] = origin; - points[count + 0].m_w += dgFloat64 (1.0f); - points[count + 1].m_w -= dgFloat64 (1.0f); - BuildHull (allocator, &pool[0].m_x, sizeof (dgBigVector), count + 2, distTol); - } - if (oldCount > m_count) { - // this is probably a regular convex solid, which will have a zero volume hull - // add the rest of the points by incremental insertion with small perturbation - dgInt32 hullCount = m_count; - - for (dgInt32 i = 0; i < count; i ++) { - bool inHull = false; - const dgConvexHull4dVector* const hullPoints = &m_points[0]; - for (dgInt32 j = 0; j < hullCount; j ++) { - if (hullPoints[j].m_index == i) { - inHull = true; - break; - } - } - if (!inHull) { - dgBigVector q (points[i]); - dgInt32 index = AddVertex(q); - if (index == -1) { - q.m_x += dgFloat64 (1.0e-3f); - q.m_y += dgFloat64 (1.0e-3f); - q.m_z += dgFloat64 (1.0e-3f); - index = AddVertex(q); - dgAssert (index != -1); - } - dgAssert (index != -1); - m_points[index].m_index = i; - } - } - } - - SortVertexArray (); -} - -dgDelaunayTetrahedralization::~dgDelaunayTetrahedralization() -{ -} - -dgInt32 dgDelaunayTetrahedralization::AddVertex (const dgBigVector& vertex) -{ - dgSetPrecisionDouble precision; - - dgBigVector p (vertex); - dgAssert(p.m_w == dgFloat32(0.0f)); - p.m_w = p.DotProduct(p).GetScalar(); - dgInt32 index = dgConvexHull4d::AddVertex(p); - - return index; -} - -dgInt32 dgDelaunayTetrahedralization::CompareVertexByIndex(const dgConvexHull4dVector* const A, const dgConvexHull4dVector* const B, void* const context) -{ - if (A->m_index < B ->m_index) { - return -1; - } else if (A->m_index > B->m_index) { - return 1; - } - return 0; -} - -void dgDelaunayTetrahedralization::SortVertexArray () -{ - dgConvexHull4dVector* const points = &m_points[0]; - for (dgListNode* node = GetFirst(); node; node = node->GetNext()) { - dgConvexHull4dTetraherum* const tetra = &node->GetInfo(); - for (dgInt32 i = 0; i < 4; i ++) { - dgConvexHull4dTetraherum::dgTetrahedrumFace& face = tetra->m_faces[i]; - for (dgInt32 j = 0; j < 4; j ++) { - dgInt32 index = face.m_index[j]; - face.m_index[j] = points[index].m_index; - } - } - } - - dgSort(points, m_count, CompareVertexByIndex); -} - -void dgDelaunayTetrahedralization::RemoveUpperHull () -{ - dgSetPrecisionDouble precision; - - dgListNode* nextNode = NULL; - for (dgListNode* node = GetFirst(); node; node = nextNode) { - nextNode = node->GetNext(); - - dgConvexHull4dTetraherum* const tetra = &node->GetInfo(); - tetra->SetMark(0); - dgFloat64 w = GetTetraVolume (tetra); - if (w >= dgFloat64 (0.0f)) { - DeleteFace(node); - } - } -} - -void dgDelaunayTetrahedralization::DeleteFace (dgListNode* const node) -{ - dgConvexHull4dTetraherum* const tetra = &node->GetInfo(); - for (dgInt32 i = 0; i < 4; i ++) { - dgListNode* const twinNode = tetra->m_faces[i].m_twin; - if (twinNode) { - dgConvexHull4dTetraherum* const twinTetra = &twinNode->GetInfo(); - for (dgInt32 j = 0; j < 4; j ++) { - if (twinTetra->m_faces[j].m_twin == node) { - twinTetra->m_faces[j].m_twin = NULL; - break; - } - } - } - } - dgConvexHull4d::DeleteFace (node); -} - - - - diff --git a/thirdparty/src/newton/dgCore/dgDelaunayTetrahedralization.h b/thirdparty/src/newton/dgCore/dgDelaunayTetrahedralization.h deleted file mode 100644 index 70e72b503..000000000 --- a/thirdparty/src/newton/dgCore/dgDelaunayTetrahedralization.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DG_DEALUNAY_TETRAHEDRALIZAION_4D__ -#define __DG_DEALUNAY_TETRAHEDRALIZAION_4D__ - -#include "dgStdafx.h" -#include "dgConvexHull4d.h" - -class dgDelaunayTetrahedralization: public dgConvexHull4d -{ - public: - dgDelaunayTetrahedralization(dgMemoryAllocator* const allocator, const dgFloat64* const vertexCloud, dgInt32 count, dgInt32 strideInByte, dgFloat64 distTol); - virtual ~dgDelaunayTetrahedralization(); - void RemoveUpperHull (); - - dgInt32 AddVertex (const dgBigVector& vertex); - - protected: - virtual void DeleteFace (dgListNode* const node) ; - - void SortVertexArray (); - static dgInt32 CompareVertexByIndex(const dgConvexHull4dVector* const A, const dgConvexHull4dVector* const B, void* const context); - -}; - -#endif diff --git a/thirdparty/src/newton/dgCore/dgFastQueue.h b/thirdparty/src/newton/dgCore/dgFastQueue.h deleted file mode 100644 index dc85b2af6..000000000 --- a/thirdparty/src/newton/dgCore/dgFastQueue.h +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -/**************************************************************************** -* -* Visual C++ 6.0 created by: Julio Jerez -* -****************************************************************************/ -#ifndef __dgFastQueue__ -#define __dgFastQueue__ - -#include "dgStdafx.h" - -template<class T, dgInt32 sizeInPowerOfTwo> -class dgFastQueue -{ - public: - DG_CLASS_ALLOCATOR_NEW(allocator) - - dgFastQueue (dgMemoryAllocator* const allocator); - ~dgFastQueue (); - - bool IsEmpty() const; - bool IsFull() const; - const T& GetHead() const; - void Pop(); - void Push(T& object); - - private: - T* m_pool; - dgMemoryAllocator* m_allocator; - dgInt32 m_head; - dgInt32 m_tail; -}; - - - -template<class T, dgInt32 sizeInPowerOfTwo> -dgFastQueue<T, sizeInPowerOfTwo>::dgFastQueue (dgMemoryAllocator* const allocator) - :m_allocator(allocator) - ,m_head(0) - ,m_tail(0) -{ - dgAssert (((sizeInPowerOfTwo -1) & (-sizeInPowerOfTwo)) == 0); - m_pool = (T*) m_allocator->MallocLow(sizeInPowerOfTwo * sizeof (T)); -} - - -template<class T, dgInt32 sizeInPowerOfTwo> -dgFastQueue<T, sizeInPowerOfTwo>::~dgFastQueue () -{ - m_allocator->FreeLow(m_pool); -} - -template<class T, dgInt32 sizeInPowerOfTwo> -bool dgFastQueue<T, sizeInPowerOfTwo>::IsEmpty() const -{ - return (m_head == m_tail); -} - -template<class T, dgInt32 sizeInPowerOfTwo> -bool dgFastQueue<T, sizeInPowerOfTwo>::IsFull() const -{ - return (((m_tail + 1) & (sizeInPowerOfTwo - 1)) == m_head); -} - -template<class T, dgInt32 sizeInPowerOfTwo> -const T& dgFastQueue<T, sizeInPowerOfTwo>::GetHead() const -{ - dgAssert (!IsEmpty()); - return m_pool[m_head]; -} - -template<class T, dgInt32 sizeInPowerOfTwo> -void dgFastQueue<T, sizeInPowerOfTwo>::Pop() -{ - dgAssert (!IsEmpty()); - m_head = (m_head + 1) & (sizeInPowerOfTwo - 1); -} - -template<class T, dgInt32 sizeInPowerOfTwo> -void dgFastQueue<T, sizeInPowerOfTwo>::Push(T& object) -{ - dgAssert (!IsFull()); - m_pool[m_tail] = object; - m_tail = (m_tail + 1) & (sizeInPowerOfTwo - 1); -} - - - -#endif - - - - diff --git a/thirdparty/src/newton/dgCore/dgGeneralMatrix.cpp b/thirdparty/src/newton/dgCore/dgGeneralMatrix.cpp deleted file mode 100644 index baf5a1b90..000000000 --- a/thirdparty/src/newton/dgCore/dgGeneralMatrix.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgGeneralMatrix.h" -#include "dgStack.h" -#include "dgMemory.h" - -/* -DG_INLINE bool dgCholeskyFactorizationAddRow(dgInt32 size, dgInt32 n, dgFloat32* const matrix, dgInt32 rowStride) -{ - dgFloat32* const rowN = &matrix[rowStride * n]; - - dgInt32 stride = 0; - for (dgInt32 j = 0; j <= n; j++) { - dgFloat32 s = dgFloat32(0.0f); - dgFloat32* const rowJ = &matrix[stride]; - for (dgInt32 k = 0; k < j; k++) { - s += rowN[k] * rowJ[k]; - } - - if (n == j) { - dgFloat32 diag = rowN[n] - s; - if (diag < dgFloat32(dgFloat32(1.0e-6f))) { - return false; - } - - rowN[n] = dgFloat32(sqrt(diag)); - } else { - rowN[j] = (rowN[j] - s) / rowJ[j]; - } - - stride += rowStride; - } - - return true; -} - - -bool dgCholeskyFactorization(dgInt32 size, dgFloat32* const psdMatrix, dgInt32 rowStride) -{ - bool state = true; - for (dgInt32 i = 0; (i < size) && state; i++) { - state = state && dgCholeskyFactorizationAddRow(size, i, psdMatrix, rowStride); - } - return state; -} -*/ \ No newline at end of file diff --git a/thirdparty/src/newton/dgCore/dgGeneralMatrix.h b/thirdparty/src/newton/dgCore/dgGeneralMatrix.h deleted file mode 100644 index 275709195..000000000 --- a/thirdparty/src/newton/dgCore/dgGeneralMatrix.h +++ /dev/null @@ -1,1337 +0,0 @@ - -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgGeneralMatrix__ -#define __dgGeneralMatrix__ - -#include "dgStdafx.h" -#include "dgDebug.h" -#include "dgVector.h" -#include "dgGeneralVector.h" - -#define DG_LCP_MAX_VALUE dgFloat32 (1.0e10f) - - -template<dgInt32 maxRows> -class dgOldSolverNetwon_1_5 -{ - public: - dgOldSolverNetwon_1_5() - { - } - - void SetSize(dgInt32 size) - { - m_size = size; - } - - dgInt32 GetSize() const - { - return m_size; - } - - dgFloat32* GetX() - { - return m_x; - } - - dgFloat32* GetB() - { - return m_b; - } - - dgFloat32* GetLow() - { - return m_low; - } - - dgFloat32* GetHigh() - { - return m_high; - } - - dgInt32* GetFrictionIndex() - { - return m_frictionIndex; - } - - dgFloat32* GetInvDiag() - { - return m_invDiag; - } - - dgFloat32* GetMatrixRow(dgInt32 i) - { - return &m_matrix[i * m_size]; - } - - dgFloat32 Solve() - { - dgInt32 stride = 0; - m_x[m_size] = dgFloat32(1.0f); - dgFloat32 accelNorm = dgFloat32(0.0f); - for (dgInt32 i = 0; i < m_size; i++) { - dgVector error(m_b[i]); - dgVector x(m_x[i]); - const dgInt32 frictionIndex = m_frictionIndex[i]; - const dgVector low(m_low[i] * m_x[frictionIndex]); - const dgVector high(m_high[i] * m_x[frictionIndex]); - error = error & (x < high) & (x > low); - accelNorm += error.GetScalar() * error.GetScalar(); - stride += m_size; - } - - const dgFloat32 tol2 = dgFloat32(1.0e-5f); - if (accelNorm > tol2) { - dgFloat32 accelNorm0 = accelNorm; - for (dgInt32 i = 0; (i < 5) && (accelNorm0 > tol2); i++) { - stride = 0; - accelNorm0 = dgFloat32(0.0f); - for (dgInt32 j = 0; j < m_size; j++) { - const dgFloat32* const row = &m_matrix[stride]; - dgFloat32 r = m_b[j]; - for (dgInt32 k = 0; k < m_size; k++) { - r = r - row[k] * m_x[k]; - } - const dgInt32 frictionIndex = m_frictionIndex[j]; - const dgVector low(m_low[j] * m_x[frictionIndex]); - const dgVector high(m_high[j] * m_x[frictionIndex]); - dgVector x((r + row[j] * m_x[j]) * m_invDiag[j]); - - dgVector a(r); - a = a & (x < high) & (x > low); - x = x.GetMax(low).GetMin(high); - m_x[j] = x.GetScalar(); - - accelNorm0 += a.GetScalar() * a.GetScalar(); - stride += m_size; - } - } - - if (accelNorm0 > tol2) { - stride = 0; - dgFloat32 mask[maxRows]; - for (dgInt32 i = 0; i < m_size; i++) { - dgFloat32 r = dgFloat32(0.0f); - const dgFloat32* const row = &m_matrix[stride]; - for (dgInt32 j = 0; j < m_size; j++) { - r += row[j] * m_x[j]; - } - m_b[i] -= r; - m_delta_x[i] = m_b[i]; - mask[i] = dgFloat32(1.0f); - const dgInt32 frictionIndex = m_frictionIndex[i]; - m_low[i] *= m_x[frictionIndex]; - m_high[i] *= m_x[frictionIndex]; - stride += m_size; - } - - dgFloat32 beta = dgFloat32(1.0f); - for (dgInt32 k = 0; (k < 20) && (beta > tol2); k++) { - stride = 0; - dgFloat32 num = dgFloat32(0.0f); - dgFloat32 den = dgFloat32(0.0f); - for (dgInt32 i = 0; i < m_size; i++) { - const dgFloat32* const row = &m_matrix[stride]; - dgFloat32 r = dgFloat32(0.0f); - for (dgInt32 j = 0; j < m_size; j++) { - r += row[j] * m_delta_x[j]; - } - stride += m_size; - m_delta_r[i] = r; - den += m_delta_x[i] * r; - num += m_b[i] * m_b[i] * mask[i]; - } - - dgInt32 index = -1; - dgFloat32 alpha = num / den; - dgAssert(alpha > dgFloat32(0.0f)); - - for (dgInt32 i = 0; (i < m_size) && (alpha > dgFloat32(0.0f)); i++) { - - if (m_delta_x[i]) { - dgFloat32 x = m_x[i] + alpha * m_delta_x[i]; - if (x < m_low[i]) { - index = i; - alpha = (m_low[i] - m_x[i]) / m_delta_x[i]; - } else if (x > m_high[i]) { - index = i; - alpha = (m_high[i] - m_x[i]) / m_delta_x[i]; - } - dgAssert(alpha >= dgFloat32(-1.0e-4f)); - if (alpha < dgFloat32(1.0e-6f)) { - alpha = dgFloat32(0.0f); - } - } - } - - beta = dgFloat32(0.0f); - for (dgInt32 i = 0; i < m_size; i++) { - m_x[i] += alpha * m_delta_x[i]; - m_b[i] -= alpha * m_delta_r[i]; - beta += m_b[i] * m_b[i] * mask[i]; - } - - if (index >= 0) { - beta = dgFloat32(0.0f); - mask[index] = dgFloat32(0.0f); - for (dgInt32 i = 0; i < m_size; i++) { - m_delta_x[i] = m_b[i] * mask[i]; - beta += m_b[i] * m_b[i] * mask[i]; - stride += m_size; - } - } else { - alpha = beta / num; - for (dgInt32 i = 0; i < m_size; i++) { - m_delta_x[i] = m_b[i] * mask[i] + alpha * m_delta_x[i]; - } - } - } - } - } - - return accelNorm; - } - - private: - dgFloat32 m_x[maxRows + 4]; - dgFloat32 m_b[maxRows]; - dgFloat32 m_low[maxRows]; - dgFloat32 m_high[maxRows]; - dgFloat32 m_invDiag[maxRows]; - dgFloat32 m_delta_x[maxRows]; - dgFloat32 m_delta_r[maxRows]; - dgFloat32 m_matrix[maxRows * maxRows]; - dgInt32 m_frictionIndex[maxRows]; - dgInt32 m_size; -}; - - -template<class T> -class dgSymmetricConjugateGradientSolver -{ - public: - dgSymmetricConjugateGradientSolver(); - dgSymmetricConjugateGradientSolver(T* const r0, T* const z0, T* const p0, T* const q0); - ~dgSymmetricConjugateGradientSolver(); - - void SetBuffers(T* const r0, T* const z0, T* const p0, T* const q0); - T Solve(dgInt32 size, T tolerance, T* const x, const T* const b); - - protected: - virtual void MatrixTimeVector(T* const out, const T* const v) const = 0; - virtual void InversePrecoditionerTimeVector(T* const out, const T* const v) const = 0; - - private: - T SolveInternal(dgInt32 size, T tolerance, T* const x, const T* const b) const; - //T DotProduct(dgInt32 size, const T* const b, const T* const c) const; - //void Sub(dgInt32 size, T* const a, const T* const b, const T* const c) const; - //void ScaleAdd(dgInt32 size, T* const a, const T* const b, T scale, const T* const c) const; - - T* m_r0; - T* m_z0; - T* m_p0; - T* m_q0; -}; - - -template<class T> -dgSymmetricConjugateGradientSolver<T>::dgSymmetricConjugateGradientSolver() -{ - SetBuffers(NULL, NULL, NULL, NULL); -} - -template<class T> -dgSymmetricConjugateGradientSolver<T>::dgSymmetricConjugateGradientSolver(T* const r0, T* const z0, T* const p0, T* const q0) -{ - SetBuffers(r0, z0, p0, q0); -} - -template<class T> -dgSymmetricConjugateGradientSolver<T>::~dgSymmetricConjugateGradientSolver() -{ -} - -template<class T> -void dgSymmetricConjugateGradientSolver<T>::SetBuffers(T* const r0, T* const z0, T* const p0, T* const q0) -{ - m_r0 = r0; - m_z0 = z0; - m_p0 = p0; - m_q0 = q0; -} - -template<class T> -T dgSymmetricConjugateGradientSolver<T>::Solve(dgInt32 size, T tolerance, T* const x, const T* const b) -{ - if (m_r0) { - return SolveInternal(size, tolerance, x, b); - } else { - T* const r0 = dgAlloca(T, size); - T* const z0 = dgAlloca(T, size); - T* const p0 = dgAlloca(T, size); - T* const q0 = dgAlloca(T, size); - SetBuffers(r0, z0, p0, q0); - T error = SolveInternal(size, tolerance, x, b); - SetBuffers(NULL, NULL, NULL, NULL); - return error; - } -} - -template<class T> -T dgSymmetricConjugateGradientSolver<T>::SolveInternal(dgInt32 size, T tolerance, T* const x, const T* const b) const -{ - MatrixTimeVector(m_z0, x); - dgSub(size, m_r0, b, m_z0); - InversePrecoditionerTimeVector(m_p0, m_r0); - - dgInt32 iter = 0; - T num = dgDotProduct(size, m_r0, m_p0); - T error2 = num; - for (dgInt32 j = 0; (j < size) && (error2 > tolerance); j++) { - - MatrixTimeVector(m_z0, m_p0); - T den = dgDotProduct(size, m_p0, m_z0); - - dgAssert(fabs(den) > T(0.0f)); - T alpha = num / den; - - dgMulAdd(size, x, x, m_p0, alpha); - if ((j % 50) != 49) { - dgMulAdd(size, m_r0, m_r0, m_z0, -alpha); - } else { - MatrixTimeVector(m_z0, x); - dgSub(size, m_r0, b, m_z0); - } - - InversePrecoditionerTimeVector(m_q0, m_r0); - - T num1 = dgDotProduct(size, m_r0, m_q0); - T beta = num1 / num; - dgMulAdd(size, m_p0, m_q0, m_p0, beta); - num = dgDotProduct(size, m_r0, m_q0); - iter++; - error2 = num; - if (j > 10) { - error2 = T(0.0f); - for (dgInt32 i = 0; i < size; i++) { - error2 = dgMax(error2, m_r0[i] * m_r0[i]); - } - } - } - dgAssert(iter <= size); - return num; -} - - -//************************************************************* -// -// generic linear algebra functions -// -//************************************************************* -template<class T> -void dgMatrixTimeVector(dgInt32 size, const T* const matrix, const T* const v, T* const out) -{ - dgInt32 stride = 0; - for (dgInt32 i = 0; i < size; i++) { - const T* const row = &matrix[stride]; - out[i] = dgDotProduct(size, row, v); - stride += size; - } -} - -template<class T> -void dgMatrixTimeMatrix(dgInt32 size, const T* const matrixA, const T* const matrixB, T* const out) -{ - for (dgInt32 i = 0; i < size; i++) { - const T* const rowA = &matrixA[i * size]; - T* const rowOut = &out[i * size]; - for (dgInt32 j = 0; j < size; j++) { - T acc = T(0.0f); - for (dgInt32 k = 0; k < size; k++) { - acc += rowA[k] * matrixB[k * size + j]; - } - rowOut[j] = acc; - } - } -} - -template<class T> -void dgCovarianceMatrix(dgInt32 size, T* const matrix, const T* const vectorA, const T* const vectorB) -{ - dgInt32 stride = 0; - for (dgInt32 i = 0; i < size; i++) { - T* const row = &matrix[stride]; - T scale (vectorA[i]); - for (dgInt32 j = 0; j < size; j++) { - row[j] = scale * vectorA[j]; - } - stride += size; - } -} - -template<class T> -DG_INLINE bool dgCholeskyFactorizationAddRow(dgInt32 size, dgInt32 stride, dgInt32 n, T* const matrix, T* const invDiagonalOut) -{ - T* const rowN = &matrix[stride * n]; - - dgInt32 base = 0; - for (dgInt32 j = 0; j <= n; j++) { - T s(0.0f); - T* const rowJ = &matrix[base]; - for (dgInt32 k = 0; k < j; k++) { - s += rowN[k] * rowJ[k]; - } - - if (n == j) { - T diag = rowN[n] - s; - if (diag < T(1.0e-6f)) { - return false; - } - - rowN[n] = T(sqrt(diag)); - invDiagonalOut[n] = T(1.0f) / rowN[n]; - } else { - rowJ[n] = T(0.0f); - //rowN[j] = (rowN[j] - s) / rowJ[j]; - rowN[j] = invDiagonalOut[j] * (rowN[j] - s); - } - - base += stride; - } - - return true; -} - -template<class T> -bool dgCholeskyFactorization(dgInt32 size, dgInt32 stride, T* const psdMatrix) -{ - bool state = true; - T* const invDiagonal = dgAlloca(T, size); - for (dgInt32 i = 0; (i < size) && state; i++) { - state = state && dgCholeskyFactorizationAddRow(size, stride, i, psdMatrix, invDiagonal); - } - return state; -} - -template<class T> -bool dgTestPSDmatrix(dgInt32 size, dgInt32 stride, T* const matrix) -{ - T* const copy = dgAlloca(T, size * size); - int row = 0; - for (int i = 0; i < size; i++) { - memcpy(©[i * size], &matrix[row], size * sizeof (T)); - row += stride; - } - return dgCholeskyFactorization(size, size, copy); -} - -template<class T> -void dgCholeskyApplyRegularizer (dgInt32 size, dgInt32 stride, T* const psdMatrix, T* const regularizer) -{ - bool isPsdMatrix = false; - dgFloat32* const lowerTriangule = dgAlloca(dgFloat32, stride * stride); - do { - memcpy(lowerTriangule, psdMatrix, sizeof(dgFloat32) * stride * stride); - isPsdMatrix = dgCholeskyFactorization(size, stride, lowerTriangule); - if (!isPsdMatrix) { - for (dgInt32 i = 0; i < size; i++) { - regularizer[i] *= dgFloat32(4.0f); - psdMatrix[i * stride + i] += regularizer[i]; - } - } - } while (!isPsdMatrix); -} - -template<class T> -DG_INLINE void dgSolveCholesky(dgInt32 size, dgInt32 stride, const T* const choleskyMatrix, T* const x, const T* const b) -{ - dgInt32 rowStart = 0; - for (dgInt32 i = 0; i < size; i++) { - T acc(0.0f); - const T* const row = &choleskyMatrix[rowStart]; - for (dgInt32 j = 0; j < i; j++) { - acc = acc + row[j] * x[j]; - } - x[i] = (b[i] - acc) / row[i]; - rowStart += stride; - } - - for (dgInt32 i = size - 1; i >= 0; i--) { - T acc = 0.0f; - for (dgInt32 j = i + 1; j < size; j++) { - acc = acc + choleskyMatrix[stride * j + i] * x[j]; - } - x[i] = (x[i] - acc) / choleskyMatrix[stride * i + i]; - } -} - -template<class T> -void dgSolveCholesky(dgInt32 size, T* const choleskyMatrix, T* const x) -{ - dgSolveCholesky(size, size, choleskyMatrix, x); -} - -template<class T> -bool dgSolveGaussian(dgInt32 size, T* const matrix, T* const b) -{ - for (dgInt32 i = 0; i < size - 1; i++) { - const T* const rowI = &matrix[i * size]; - dgInt32 m = i; - T maxVal (dgAbs(rowI[i])); - for (dgInt32 j = i + 1; j < size - 1; j++) { - T val (dgAbs(matrix[size * j + i])); - if (val > maxVal) { - m = j; - maxVal = val; - } - } - - if (maxVal < T(1.0e-12f)) { - return false; - } - - if (m != i) { - T* const rowK = &matrix[m * size]; - T* const rowJ = &matrix[i * size]; - for (dgInt32 j = 0; j < size; j++) { - dgSwap(rowK[j], rowJ[j]); - } - dgSwap(b[i], b[m]); - } - - T den = T(1.0f) / rowI[i]; - for (dgInt32 k = i + 1; k < size; k++) { - T* const rowK = &matrix[size * k]; - T factor(-rowK[i] * den); - for (dgInt32 j = i + 1; j < size; j++) { - rowK[j] += rowI[j] * factor; - } - rowK[i] = T(0.0f); - b[k] += b[i] * factor; - } - } - - for (dgInt32 i = size - 1; i >= 0; i--) { - T acc(0); - T* const rowI = &matrix[i * size]; - for (dgInt32 j = i + 1; j < size; j++) { - acc = acc + rowI[j] * b[j]; - } - b[i] = (b[i] - acc) / rowI[i]; - } - return true; -} - -template <class T> -void dgEigenValues(const dgInt32 size, const dgInt32 stride, const T* const symmetricMatrix, T* const eigenValues) -{ - T* const offDiag = dgAlloca(T, size); - T* const matrix = dgAlloca(T, size * stride); - - memcpy(matrix, symmetricMatrix, sizeof(T) * size * stride); - for (dgInt32 i = size - 1; i > 0; i--) { - T h(0.0f); - T* const rowI = &matrix[i * stride]; - - if (i > 1) { - T scale(0.0f); - for (dgInt32 k = 0; k < i; k++) { - scale += dgAbs(rowI[k]); - } - - if (scale == T(0.0f)) { - offDiag[i] = rowI[i - 1]; - } else { - for (dgInt32 k = 0; k < i; k++) { - rowI[k] /= scale; - h += rowI[k] * rowI[k]; - } - - T f(rowI[i - 1]); - T g((f >= T(0.0f) ? -T(sqrt(h)) : T(sqrt(h)))); - offDiag[i] = scale * g; - h -= f * g; - rowI[i - 1] = f - g; - f = T(0.0f); - - for (dgInt32 j = 0; j < i; j++) { - g = T(0.0f); - const T* const rowJ = &matrix[j * stride]; - for (dgInt32 k = 0; k <= j; k++) { - g += rowJ[k] * rowI[k]; - } - for (dgInt32 k = j + 1; k < i; k++) { - g += matrix[k * stride + j] * rowI[k]; - } - offDiag[j] = g / h; - f += offDiag[j] * rowI[j]; - } - - T hh(f / (h + h)); - for (dgInt32 j = 0; j < i; j++) { - T f1 (rowI[j]); - T g1(offDiag[j] - hh * f1); - offDiag[j] = g1; - T* const rowJ = &matrix[j * stride]; - for (dgInt32 k = 0; k <= j; k++) { - rowJ[k] -= (f1 * offDiag[k] + g1 * rowI[k]); - } - } - } - } else { - offDiag[i] = rowI[i - 1]; - } - eigenValues[i] = h; - } - - dgInt32 index = stride; - eigenValues[0] = matrix[0]; - for (dgInt32 i = 1; i < size; i++) { - eigenValues[i] = matrix[index + i]; - offDiag[i - 1] = offDiag[i]; - index += stride; - } - - for (dgInt32 i = 0; i < size; i++) { - dgInt32 j; - dgInt32 iter = 0; - do { - for (j = i; j < size - 1; j++) { - T dd(dgAbs(eigenValues[j]) + dgAbs(eigenValues[j + 1])); - if (dgAbs(offDiag[j]) <= (T(1.e-6f) * dd)) { - break; - } - } - - if (j != i) { - iter++; - if (iter == 10) { - dgAssert(0); - return; - } - - T g((eigenValues[i + 1] - eigenValues[i]) / (T(2.0f) * offDiag[i])); - T r(dgPythag(g, T(1.0f))); - g = eigenValues[j] - eigenValues[i] + offDiag[i] / (g + dgSign(r, g)); - T s(1.0f); - T c(1.0f); - T p(0.0f); - - dgInt32 k; - for (k = j - 1; k >= i; k--) { - T f(s * offDiag[k]); - T b(c * offDiag[k]); - T d(dgPythag(f, g)); - offDiag[k + 1] = d; - if (d == T(0.0f)) { - eigenValues[k + 1] -= p; - offDiag[j] = T(0.0f); - break; - } - s = f / d; - c = g / d; - g = eigenValues[k + 1] - p; - d = (eigenValues[k] - g) * s + T(2.0f) * c * b; - p = s * d; - eigenValues[k + 1] = g + p; - g = c * d - b; - } - - if (r == T(0.0f) && k >= i) { - continue; - } - eigenValues[i] -= p; - offDiag[i] = g; - offDiag[j] = T(0.0f); - } - } while (j != i); - } -} - -template <class T> -T dgConditionNumber(const dgInt32 size, const dgInt32 stride, const T* const choleskyMatrix) -{ - T* const eigenValues = dgAlloca(T, size); - dgEigenValues(size, stride, choleskyMatrix, eigenValues); - - T minVal = T(1.0e20f); - T maxVal = T(-1.0e20f); - for (int i = 0; i < size; i++) { - minVal = dgMin(minVal, eigenValues[i]); - maxVal = dgMax(maxVal, eigenValues[i]); - } - T condition = T(dgAbs(maxVal) / dgAbs(minVal)); - return condition; -} - - -// solve a general Linear complementary program (LCP) -// A * x = b + r -// subjected to constraints -// x(i) = low(i), if r(i) >= 0 -// x(i) = high(i), if r(i) <= 0 -// low(i) <= x(i) <= high(i), if r(i) == 0 -// -// return true is the system has a solution. -// in return -// x is the solution, -// r is return in vector b -// note: although the system is called LCP, the solver is far more general than a strict LCP -// to solve a strict LCP, set the following -// low(i) = 0 -// high(i) = infinity. -// this the same as enforcing the constraint: x(i) * r(i) = 0 -template <class T> -void dgGaussSeidelLcpSor(const dgInt32 size, const T* const matrix, T* const x, const T* const b, const T* const low, const T* const high, T tol2, dgInt32 maxIterCount, dgInt16* const clipped, T sor) -{ - const T* const me = matrix; - T* const invDiag1 = dgAlloca(T, size); - - dgInt32 stride = 0; - for (dgInt32 i = 0; i < size; i++) { - x[i] = dgClamp(T(0.0f), low[i], high[i]); - invDiag1[i] = T(1.0f) / me[stride + i]; - stride += size; - } - - T tolerance(tol2 * 2.0f); - const T* const invDiag = invDiag1; -#ifdef _DEBUG - dgInt32 passes = 0; -#endif - for (dgInt32 i = 0; (i < maxIterCount) && (tolerance > tol2); i++) { - dgInt32 base = 0; - tolerance = T(0.0f); -#ifdef _DEBUG - passes++; -#endif - for (dgInt32 j = 0; j < size; j++) { - const T* const row = &me[base]; - T r(b[j] - dgDotProduct(size, row, x)); - T f((r + row[j] * x[j]) * invDiag[j]); - if (f > high[j]) { - x[j] = high[j]; - clipped[j] = 1; - } else if (f < low[j]) { - x[j] = low[j]; - clipped[j] = 1; - } else { - clipped[j] = 0; - tolerance += r * r; - x[j] = x[j] + (f - x[j]) * sor; - } - base += size; - } - } -} - - -// solve a general Linear complementary program (LCP) -// A * x = b + r -// subjected to constraints -// x(i) = low(i), if r(i) >= 0 -// x(i) = high(i), if r(i) <= 0 -// low(i) <= x(i) <= high(i), if r(i) == 0 -// -// return true is the system has a solution. -// in return -// x is the solution, -// r is return in vector b -// note: although the system is called LCP, the solver is far more general than a strict LCP -// to solve a strict LCP, set the following -// low(i) = 0 -// high(i) = infinity. -// this the same as enforcing the constraint: x(i) * r(i) = 0 -template <class T> -void dgGaussSeidelLCP(const dgInt32 size, const T* const matrix, T* const x, const T* const b, const T* const low, const T* const high, T sor = T(1.2f)) -{ - dgInt16* const clipped = dgAlloca(dgInt16, size); - dgGaussSeidelLcpSor(size, matrix, x, b, low, high, T(1.0e-3f), size * size, clipped, sor); -} - -template<class T> -void dgPermuteRows(dgInt32 size, dgInt32 i, dgInt32 j, T* const matrix, T* const choleskyMatrix, T* const x, T* const r, T* const low, T* const high, dgInt16* const permute) -{ - if (i != j) { - T* const A = &matrix[size * i]; - T* const B = &matrix[size * j]; - T* const invA = &choleskyMatrix[size * i]; - T* const invB = &choleskyMatrix[size * j]; - for (dgInt32 k = 0; k < size; k++) { - dgSwap(A[k], B[k]); - dgSwap(invA[k], invB[k]); - } - - dgInt32 stride = 0; - for (dgInt32 k = 0; k < size; k++) { - dgSwap(matrix[stride + i], matrix[stride + j]); - stride += size; - } - - dgSwap(x[i], x[j]); - dgSwap(r[i], r[j]); - dgSwap(low[i], low[j]); - dgSwap(high[i], high[j]); - dgSwap(permute[i], permute[j]); - } -} - -template<class T> -DG_INLINE void dgCalculateDelta_x(dgInt32 size, dgInt32 n, const T* const matrix, const T* const choleskyMatrix, T* const delta_x) -{ - const T* const row = &matrix[size * n]; - for (dgInt32 i = 0; i < n; i++) { - delta_x[i] = -row[i]; - } - dgSolveCholesky(size, n, choleskyMatrix, delta_x, delta_x); - delta_x[n] = T(1.0f); -} - -// calculate delta_r = A * delta_x -template<class T> -DG_INLINE void dgCalculateDelta_r(dgInt32 size, dgInt32 n, const T* const matrix, const T* const delta_x, T* const delta_r) -{ - dgInt32 stride = n * size; - const dgInt32 size1 = n + 1; - for (dgInt32 i = n; i < size; i++) { - delta_r[i] = dgDotProduct(size1, &matrix[stride], delta_x); - stride += size; - } -} - -template<class T> -DG_INLINE void dgHouseholderReflection(dgInt32 size, dgInt32 row, dgInt32 colum, T* const choleskyMatrix, T* const tmp, T* const reflection) -{ - dgAssert(row <= colum); - if (row < colum) { - for (dgInt32 i = row; i <= colum; i++) { - T* const rowI = &choleskyMatrix[size * i]; - T mag2(0.0f); - for (dgInt32 j = i + 1; j <= colum; j++) { - mag2 += rowI[j] * rowI[j]; - reflection[j] = rowI[j]; - } - if (mag2 > T(1.0e-14f)) { - reflection[i] = rowI[i] + dgSign(rowI[i]) * T(sqrt(mag2 + rowI[i] * rowI[i])); - - const T vMag2(mag2 + reflection[i] * reflection[i]); - const T den = T(2.0f) / vMag2; - for (dgInt32 j = i; j < size; j++) { - T acc(0.0f); - T* const rowJ = &choleskyMatrix[size * j]; - for (dgInt32 k = i; k <= colum; k++) { - acc += rowJ[k] * reflection[k]; - } - tmp[j] = acc; - } - - for (dgInt32 j = i + 1; j < size; j++) { - rowI[j] = T(0.0f); - T* const rowJ = &choleskyMatrix[size * j]; - const T a = tmp[j] * den; - for (dgInt32 k = i; k <= colum; k++) { - rowJ[k] -= a * reflection[k]; - } - } - rowI[i] -= tmp[i] * reflection[i] * den; - } - - if (rowI[i] < T(0.0f)) { - for (dgInt32 k = i; k < size; k++) { - choleskyMatrix[size * k + i] = -choleskyMatrix[size * k + i]; - } - } - } - - for (dgInt32 i = row; i < size; i++) { - choleskyMatrix[size * i + i] = dgMax(choleskyMatrix[size * i + i], T(1.0e-6f)); - } - } -} - -template<class T> -void dgCholeskyUpdate(dgInt32 size, dgInt32 row, dgInt32 colum, T* const choleskyMatrix, T* const tmp, T* const reflexion, const T* const psdMatrix) -{ - const dgInt32 n0 = colum - row; - const dgInt32 n1 = n0 + 1; - const dgInt32 choleskyCost = size * size * size / 3; - const dgInt32 householdCost = n0 * (n0 + 1) / 2 + n1 * (n1 + 1) * (2 * (2 * n1 + 1) - 3 + 3 * (size - colum - 1)) / 6 - 1; - - if (householdCost < choleskyCost) { - dgHouseholderReflection(size, row, colum, choleskyMatrix, tmp, reflexion); - } else { - memcpy (choleskyMatrix, psdMatrix, sizeof (T) * size * size); - dgCholeskyFactorization(size, choleskyMatrix); - } - -//#if _DEBUG -#if 0 - T* const psdMatrixCopy = dgAlloca(T, size * size); - memcpy(psdMatrixCopy, psdMatrix, sizeof(T) * size * size); - dgCholeskyFactorization(size, psdMatrixCopy); - - for (int i = 0; i < size; i++) { - for (int j = 0; j < size; j++) { - T err = psdMatrixCopy[i*size + j] - choleskyMatrix[i*size + j]; - dgAssert(dgAbs(err) < T(1.0e-4f)); - } - } -#endif -} - -// solve a general Linear complementary program (LCP) -// A * x = b + r -// subjected to constraints -// x(i) = low(i), if r(i) >= 0 -// x(i) = high(i), if r(i) <= 0 -// low(i) <= x(i) <= high(i), if r(i) == 0 -// -// return true is the system has a solution. -// in return -// x is the solution, -// r is return in vector b -// note: although the system is called LCP, the solver is far more general than a strict LCP -// to solve a strict LCP, set the following -// low(i) = 0 -// high(i) = infinity. -// this the same as enforcing the constraint: x(i) * r(i) = 0 -template <class T> -void dgSolveDantzigLcpLow(dgInt32 size, T* const symmetricMatrixPSD, T* const x, T* const b, T* const low, T* const high) -{ - T* const x0 = dgAlloca(T, size); - T* const r0 = dgAlloca(T, size); - T* const tmp0 = dgAlloca(T, size); - T* const tmp1 = dgAlloca(T, size); - T* const delta_r = dgAlloca(T, size); - T* const delta_x = dgAlloca(T, size); - T* const lowerTriangularMatrix = dgAlloca(T, size * size); - dgInt16* const permute = dgAlloca(dgInt16, size); - - for (dgInt32 i = 0; i < size; i++) { - permute[i] = dgInt16(i); - x0[i] = T(0.0f); - x[i] = dgMax (b[i] * b[i], T (1.0f)); - } - - for (dgInt32 n = size - 1, i = size - 1; i >= 0; i--) { - if (x[i] > T(1.0)) { - dgPermuteRows(size, n, i, symmetricMatrixPSD, lowerTriangularMatrix, x, b, low, high, permute); - n --; - } - } - - for (dgInt32 i = size - 1; (i >= 0) && (x[i] > T(1.0f)) ; i--) { - dgInt32 min = i; - for (dgInt32 j = i - 1; (j >= 0) && (x[j] > T(1.0f)); j--) { - if (x[j] > x[min]) { - min = j; - } - } - if (min != i) { - dgPermuteRows(size, i, min, symmetricMatrixPSD, lowerTriangularMatrix, x, b, low, high, permute); - } - } - - dgInt32 initialGuessCount = size; - while (x[initialGuessCount - 1] >= T(16.0f)) { - initialGuessCount --; - } - - memcpy(lowerTriangularMatrix, symmetricMatrixPSD, sizeof(T) * size * size); -#ifdef _DEBUG - bool valid = dgCholeskyFactorization(size, lowerTriangularMatrix); - dgAssert(valid); -#else - dgCholeskyFactorization(size, lowerTriangularMatrix); -#endif - for (dgInt32 j = 0; (j != -1) && initialGuessCount;) { - dgSolveCholesky(size, initialGuessCount, lowerTriangularMatrix, x0, b); - - j = -1; - T alpha(1.0f); - T value(0.0f); - for (dgInt32 i = initialGuessCount - 1; i >= 0; i--) { - T x1 = alpha * x0[i]; - if (x1 < low[i]) { - j = i; - value = low[i]; - alpha = low[i] / x0[i]; - } else if (x1 > high[i]) { - j = i; - value = high[i]; - alpha = high[i] / x0[i]; - } - } - - if (j != -1) { - x0[j] = value; - initialGuessCount--; - dgPermuteRows(size, j, initialGuessCount, symmetricMatrixPSD, lowerTriangularMatrix, x0, b, low, high, permute); - dgCholeskyUpdate(size, j, initialGuessCount, lowerTriangularMatrix, tmp0, tmp1, symmetricMatrixPSD); - } - } - - if (initialGuessCount == size) { - for (dgInt32 i = 0; i < size; i++) { - dgInt32 j = permute[i]; - x[j] = x0[i]; - b[i] = T(0.0f); - } - return; - } - - dgInt32 clampedIndex = size; - dgInt32 index = initialGuessCount; - dgInt32 count = size - initialGuessCount; - dgInt32 stride = index * size; - - for (dgInt32 i = 0; i < size; i++) { - r0[i] = T(0.0f); - delta_x[i] = T(0.0f); - delta_r[i] = T(0.0f); - } - - for (dgInt32 i = index; i < size; i++) { - r0[i] = dgDotProduct(size, &symmetricMatrixPSD[stride], x0) - b[i]; - stride += size; - } - - - while (count) { - bool loop = true; - - while (loop) { - loop = false; - T clamp_x(0.0f); - dgInt32 swapIndex = -1; - - if (dgAbs(r0[index]) > T(1.0e-12f)) { - dgCalculateDelta_x(size, index, symmetricMatrixPSD, lowerTriangularMatrix, delta_x); - dgCalculateDelta_r(size, index, symmetricMatrixPSD, delta_x, delta_r); - - dgAssert(delta_r[index] != T(0.0f)); - dgAssert(dgAbs(delta_x[index]) == T(1.0f)); - delta_r[index] = (delta_r[index] == T(0.0f)) ? T(1.0e-12f) : delta_r[index]; - - T scale = -r0[index] / delta_r[index]; - dgAssert(dgAbs(scale) >= T(0.0f)); - - for (dgInt32 i = 0; i <= index; i++) { - T x1 = x0[i] + scale * delta_x[i]; - if (x1 > high[i]) { - swapIndex = i; - clamp_x = high[i]; - scale = (high[i] - x0[i]) / delta_x[i]; - } else if (x1 < low[i]) { - swapIndex = i; - clamp_x = low[i]; - scale = (low[i] - x0[i]) / delta_x[i]; - } - } - dgAssert(dgAbs(scale) >= T(0.0f)); - - for (dgInt32 i = clampedIndex; (i < size) && (scale > T(1.0e-12f)); i++) { - T r1 = r0[i] + scale * delta_r[i]; - if ((r1 * r0[i]) < T(0.0f)) { - dgAssert(dgAbs(delta_r[i]) > T(0.0f)); - T s1 = -r0[i] / delta_r[i]; - dgAssert(dgAbs(s1) >= T(0.0f)); - dgAssert(dgAbs(s1) <= dgAbs(scale)); - if (dgAbs(s1) < dgAbs(scale)) { - scale = s1; - swapIndex = i; - } - } - } - - if (dgAbs(scale) > T(1.0e-12f)) { - for (dgInt32 i = 0; i < size; i++) { - x0[i] += scale * delta_x[i]; - r0[i] += scale * delta_r[i]; - } - } - } - - if (swapIndex == -1) { - r0[index] = T(0.0f); - delta_r[index] = T(0.0f); - index++; - count--; - loop = false; - } else if (swapIndex == index) { - count--; - clampedIndex--; - x0[index] = clamp_x; - dgPermuteRows(size, index, clampedIndex, symmetricMatrixPSD, lowerTriangularMatrix, x0, r0, low, high, permute); - dgCholeskyUpdate(size, index, clampedIndex, lowerTriangularMatrix, tmp0, tmp1, symmetricMatrixPSD); - loop = count ? true : false; - } else if (swapIndex > index) { - loop = true; - r0[swapIndex] = T(0.0f); - dgAssert(swapIndex < size); - dgAssert(clampedIndex <= size); - if (swapIndex < clampedIndex) { - count--; - clampedIndex--; - dgPermuteRows(size, clampedIndex, swapIndex, symmetricMatrixPSD, lowerTriangularMatrix, x0, r0, low, high, permute); - dgCholeskyUpdate(size, swapIndex, clampedIndex, lowerTriangularMatrix, tmp0, tmp1, symmetricMatrixPSD); - dgAssert(clampedIndex >= index); - } else { - count++; - dgAssert(clampedIndex < size); - dgPermuteRows(size, clampedIndex, swapIndex, symmetricMatrixPSD, lowerTriangularMatrix, x0, r0, low, high, permute); - dgCholeskyUpdate(size, clampedIndex, swapIndex, lowerTriangularMatrix, tmp0, tmp1, symmetricMatrixPSD); - clampedIndex++; - dgAssert(clampedIndex <= size); - dgAssert(clampedIndex >= index); - } - - } else { - dgAssert(index > 0); - x0[swapIndex] = clamp_x; - delta_x[index] = T(0.0f); - - dgAssert(swapIndex < index); - dgPermuteRows(size, swapIndex, index - 1, symmetricMatrixPSD, lowerTriangularMatrix, x0, r0, low, high, permute); - dgPermuteRows(size, index - 1, index, symmetricMatrixPSD, lowerTriangularMatrix, x0, r0, low, high, permute); - dgPermuteRows(size, clampedIndex - 1, index, symmetricMatrixPSD, lowerTriangularMatrix, x0, r0, low, high, permute); - dgCholeskyUpdate (size, swapIndex, clampedIndex - 1, lowerTriangularMatrix, tmp0, tmp1, symmetricMatrixPSD); - - clampedIndex--; - index--; - loop = true; - } - } - } - - for (dgInt32 i = 0; i < size; i++) { - dgInt32 j = permute[i]; - x[j] = x0[i]; - b[j] = r0[i]; - } -} - -/* -// solve a general Linear complementary program (LCP) -// A * x = b + r -// subjected to constraints -// x(i) = low(i), if r(i) >= 0 -// x(i) = high(i), if r(i) <= 0 -// low(i) <= x(i) <= high(i), if r(i) == 0 -// -// return true is the system has a solution. -// in return -// x is the solution, -// r is return in vector b -// note: although the system is called LCP, the solver is far more general than a strict LCP -// to solve a strict LCP, set the following -// low(i) = 0 -// high(i) = infinity. -// this the same as enforcing the constraint: x(i) * r(i) = 0 -template <class T> -bool dgSolveDantzigLCP(dgInt32 size, T* const symetricMatrix, T* const x, T* const b, T* const low, T* const high) -{ - T* const choleskyMatrix = dgAlloca(T, size * size); - dgCheckAligment(choleskyMatrix); - - memcpy (choleskyMatrix, symetricMatrix, sizeof (T) * size * size); - dgCholeskyFactorization(size, choleskyMatrix); - for (dgInt32 i = 0; i < size; i ++) { - T* const row = &choleskyMatrix[i * size]; - for (dgInt32 j = i + 1; j < size; j ++) { - row[j] = T(0.0f); - } - } - return dgSolveDantzigLCP(size, symetricMatrix, choleskyMatrix, x, b, low, high); -} -*/ - -// solve a general Linear complementary program (LCP) -// A * x = b + r -// subjected to constraints -// x(i) = low(i), if r(i) >= 0 -// x(i) = high(i), if r(i) <= 0 -// low(i) <= x(i) <= high(i), if r(i) == 0 -// -// return true is the system has a solution. -// in return -// x is the solution, -// b is zero -// note: although the system is called LCP, the solver is far more general than a strict LCP -// to solve a strict LCP, set the following -// low(i) = 0 -// high(i) = infinity. -// this is the same as enforcing the constraint: x(i) * r(i) = 0 -template <class T> -bool dgSolvePartitionDantzigLCP(dgInt32 size, T* const symmetricMatrixPSD , T* const x, T* const b, T* const low, T* const high) -{ - dgInt16* const permute = dgAlloca(dgInt16, size); - - for (dgInt32 i = 0; i < size; i++) { - x[i] = b[i]; - permute[i] = dgInt16(i); - } - - dgInt32 unboundedSize = size; - for (dgInt32 i = 0; i < unboundedSize; i++) { - if ((low[i] <= T(-DG_LCP_MAX_VALUE)) && (high[i] >= T(DG_LCP_MAX_VALUE))) { - dgCholeskyFactorizationAddRow(size, i, symmetricMatrixPSD ); - } else { - dgInt32 j = unboundedSize - 1; - if (i != j) { - T* const A = &symmetricMatrixPSD [size * i]; - T* const B = &symmetricMatrixPSD [size * j]; - for (dgInt32 k = 0; k < size; k++) { - dgSwap(A[k], B[k]); - } - - dgInt32 stride = 0; - for (dgInt32 k = 0; k < size; k++) { - dgSwap(symmetricMatrixPSD [stride + i], symmetricMatrixPSD [stride + j]); - stride += size; - } - dgSwap(x[i], x[j]); - dgSwap(b[i], b[j]); - dgSwap(low[i], low[j]); - dgSwap(high[i], high[j]); - dgSwap(permute[i], permute[j]); - } - - i--; - unboundedSize--; - } - } - - bool ret = false; - if (unboundedSize > 0) { - dgSolveCholesky(size, unboundedSize, symmetricMatrixPSD , x); - dgInt32 base = unboundedSize * size; - for (dgInt32 i = unboundedSize; i < size; i++) { - b[i] -= dgDotProduct(unboundedSize, &symmetricMatrixPSD[base], x); - base += size; - } - - const dgInt32 boundedSize = size - unboundedSize; - T* const l = dgAlloca(T, boundedSize); - T* const h = dgAlloca(T, boundedSize); - T* const c = dgAlloca(T, boundedSize); - T* const u = dgAlloca(T, boundedSize); - T* const a11 = dgAlloca(T, boundedSize * boundedSize); - T* const a10 = dgAlloca(T, boundedSize * unboundedSize); - - for (dgInt32 i = 0; i < boundedSize; i++) { - T* const g = &a10[i * unboundedSize]; - const T* const row = &symmetricMatrixPSD [(unboundedSize + i) * size]; - for (dgInt32 j = 0; j < unboundedSize; j++) { - g[j] = -row[j]; - } - dgSolveCholesky(size, unboundedSize, symmetricMatrixPSD, g); - - T* const arow = &a11[i * boundedSize]; - const T* const row2 = &symmetricMatrixPSD[(unboundedSize + i) * size]; - arow[i] = row2[unboundedSize + i] + dgDotProduct(unboundedSize, g, row2); - for (dgInt32 j = i + 1; j < boundedSize; j++) { - const T* const row1 = &symmetricMatrixPSD [(unboundedSize + j) * size]; - T elem = row1[unboundedSize + i] + dgDotProduct(unboundedSize, g, row1); - arow[j] = elem; - a11[j * boundedSize + i] = elem; - } - u[i] = T(0.0f); - c[i] = b[i + unboundedSize]; - l[i] = low[i + unboundedSize]; - h[i] = high[i + unboundedSize]; - } - - if (dgSolveDantzigLCP(boundedSize, a11, u, c, l, h)) { - for (dgInt32 i = 0; i < boundedSize; i++) { - const T s = u[i]; - x[unboundedSize + i] = s; - const T* const g = &a10[i * unboundedSize]; - for (dgInt32 j = 0; j < unboundedSize; j++) { - x[j] += g[j] * s; - } - } - ret = true; - } - } else { - for (dgInt32 i = 0; i < size; i++) { - x[i] = T(0.0f); - } - ret = dgSolveDantzigLCP(size, symmetricMatrixPSD, x, b, low, high); - } - - for (dgInt32 i = 0; i < size; i++) { - b[i] = x[i]; - } - for (dgInt32 i = 0; i < size; i++) { - dgInt32 j = permute[i]; - x[j] = b[i]; - b[i] = T(0.0f); - } - return ret; -} - - -template <class T> -void dgSolveDantzigLCP(dgInt32 size, T* const symmetricMatrixPSD, T* const x, T* const b, T* const low, T* const high) -{ - T tol2 = T(0.25f * 0.25f); - dgInt32 passes = dgClamp(size, 12, 20); - T* const r = dgAlloca(T, size); - dgInt16* const clipped = dgAlloca(dgInt16, size); - - // find an approximation to the solution - dgGaussSeidelLcpSor(size, symmetricMatrixPSD, x, b, low, high, tol2, passes, clipped, T(1.3f)); - - T err2(0.0f); - dgInt32 stride = 0; - dgInt32 clippeCount = 0; - for (dgInt32 i = 0; i < size; i++) { - const T* const row = &symmetricMatrixPSD[stride]; - r[i] = b[i] - dgDotProduct(size, row, x); - clippeCount += clipped[i]; - err2 += clipped[i] ? T(0.0f) : r[i] * r[i]; - stride += size; - } - - if (err2 > tol2) { - // check for small lcp - if ((clippeCount < 16) && ((clippeCount < 32) && (err2 < T(16.0f)))) { - // small lcp can be solved with direct method - T* const x0 = dgAlloca(T, size); - for (dgInt32 i = 0; i < size; i++) { - low[i] -= x[i]; - high[i] -= x[i]; - } - dgSolveDantzigLcpLow(size, symmetricMatrixPSD, x0, r, low, high); - for (dgInt32 i = 0; i < size; i++) { - x[i] += x0[i]; - } - } else { - // larger lcp are too hard for direct method, see if we can get better approximation - dgGaussSeidelLcpSor(size, symmetricMatrixPSD, x, b, low, high, tol2, 20, clipped, T(1.3f)); - } - } -} - -#endif diff --git a/thirdparty/src/newton/dgCore/dgGeneralVector.cpp b/thirdparty/src/newton/dgCore/dgGeneralVector.cpp deleted file mode 100644 index adfec7c57..000000000 --- a/thirdparty/src/newton/dgCore/dgGeneralVector.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgGeneralVector.h" - - diff --git a/thirdparty/src/newton/dgCore/dgGeneralVector.h b/thirdparty/src/newton/dgCore/dgGeneralVector.h deleted file mode 100644 index a8d18e031..000000000 --- a/thirdparty/src/newton/dgCore/dgGeneralVector.h +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgGeneralVector__ -#define __dgGeneralVector__ - -#include "dgStdafx.h" -#include "dgDebug.h" -#include "dgMemory.h" - -template <class T> -DG_INLINE T dgSQRH(const T num, const T den) -{ - T r(num / den); - return T(sqrt(T(1.0f) + r * r)); -} - -template <class T> -DG_INLINE T dgPythag(const T a, const T b) -{ - T absa(dgAbs(a)); - T absb(dgAbs(b)); - return (absa > absb) ? (absa * dgSQRH(absb, absa)) : ((absb == T(0.0f) ? T(0.0f) : (absb * dgSQRH(absa, absb)))); -} - -template <class T> -DG_INLINE T dgSign(const T a, const T b) -{ - return (b >= T(0.0f)) ? (a >= T(0.0f) ? a : -a) : (a >= T(0.0f) ? -a : a); -} - - -// return dot product -template<class T> -DG_INLINE T dgDotProduct(dgInt32 size, const T* const A, const T* const B) -{ - T val(0.0f); - for (dgInt32 i = 0; i < size; i++) { - val = val + A[i] * B[i]; - } - return val; -} - -template<class T> -DG_INLINE void dgAdd(dgInt32 size, T* const X, const T* const A, const T* const B) -{ - for (dgInt32 i = 0; i < size; i++) { - X[i] = A[i] + B[i]; - } -} - -template<class T> -DG_INLINE void dgSub(dgInt32 size, T* const X, const T* const A, const T* const B) -{ - for (dgInt32 i = 0; i < size; i++) { - X[i] = A[i] - B[i]; - } -} - -template<class T> -DG_INLINE void dgMulAdd(dgInt32 size, T* const X, const T* const A, const T* const B, T C) -{ - for (dgInt32 i = 0; i < size; i++) { - X[i] = A[i] + B[i] * C; - } -} - - -#endif - - diff --git a/thirdparty/src/newton/dgCore/dgGoogol.cpp b/thirdparty/src/newton/dgCore/dgGoogol.cpp deleted file mode 100644 index 7b326dd44..000000000 --- a/thirdparty/src/newton/dgCore/dgGoogol.cpp +++ /dev/null @@ -1,584 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgGoogol.h" - -dgGoogol dgGoogol::m_zero(0.0); -dgGoogol dgGoogol::m_one(1.0); -dgGoogol dgGoogol::m_two(2.0); -dgGoogol dgGoogol::m_three(3.0); -dgGoogol dgGoogol::m_half(0.5); - -#ifdef _IMPLEMENT_USING_INTEGER_ARITHMETIC_ - - dgGoogol::dgGoogol(void) - :m_sign(0) - ,m_exponent(0) - { - memset (m_mantissa, 0, sizeof (m_mantissa)); - } - - dgGoogol::dgGoogol(dgFloat64 value) - :m_sign(0) - ,m_exponent(0) - { - dgInt32 exp; - dgFloat64 mantissa = fabs (frexp(value, &exp)); - - m_exponent = dgInt16 (exp); - m_sign = (value >= 0) ? 0 : 1; - - memset (m_mantissa, 0, sizeof (m_mantissa)); - m_mantissa[0] = dgUnsigned64 (dgFloat64 (dgUnsigned64(1)<<62) * mantissa); - - // it looks like GCC have problems with this - //dgAssert (m_mantissa[0] >= 0); - dgAssert ((m_mantissa[0] & dgUnsigned64(1)<<63) == 0); - } - - void dgGoogol::CopySignedMantissa (dgUnsigned64* const mantissa) const - { - memcpy (mantissa, m_mantissa, sizeof (m_mantissa)); - if (m_sign) { - NegateMantissa (mantissa); - } - } - - dgGoogol::operator double() const - { - dgFloat64 mantissa = (dgFloat64(1.0f) / dgFloat64 (dgUnsigned64(1)<<62)) * dgFloat64 (m_mantissa[0]); - mantissa = ldexp(mantissa, m_exponent) * (m_sign ? dgFloat64 (-1.0f) : dgFloat64 (1.0f)); - return mantissa; - } - - dgGoogol dgGoogol::operator+ (const dgGoogol &A) const - { - dgGoogol tmp; - dgAssert (dgInt64 (m_mantissa[0]) >= 0); - dgAssert (dgInt64 (A.m_mantissa[0]) >= 0); - - if (m_mantissa[0] && A.m_mantissa[0]) { - dgUnsigned64 mantissa0[DG_GOOGOL_SIZE]; - dgUnsigned64 mantissa1[DG_GOOGOL_SIZE]; - dgUnsigned64 mantissa[DG_GOOGOL_SIZE]; - - CopySignedMantissa (mantissa0); - A.CopySignedMantissa (mantissa1); - - dgInt32 exponetDiff = m_exponent - A.m_exponent; - dgInt32 exponent = m_exponent; - if (exponetDiff > 0) { - ShiftRightMantissa (mantissa1, exponetDiff); - } else if (exponetDiff < 0) { - exponent = A.m_exponent; - ShiftRightMantissa (mantissa0, -exponetDiff); - } - - dgUnsigned64 carrier = 0; - for (dgInt32 i = DG_GOOGOL_SIZE - 1; i >= 0; i --) { - dgUnsigned64 m0 = mantissa0[i]; - dgUnsigned64 m1 = mantissa1[i]; - mantissa[i] = m0 + m1 + carrier; - carrier = CheckCarrier (m0, m1) | CheckCarrier (m0 + m1, carrier); - } - - dgInt8 sign = 0; - if (dgInt64 (mantissa[0]) < 0) { - sign = 1; - NegateMantissa (mantissa); - } - - dgInt32 bits = NormalizeMantissa (mantissa); - if (bits <= (-64 * DG_GOOGOL_SIZE)) { - tmp.m_sign = 0; - tmp.m_exponent = 0; - } else { - tmp.m_sign = sign; - tmp.m_exponent = dgInt16 (exponent + bits); - } - - memcpy (tmp.m_mantissa, mantissa, sizeof (m_mantissa)); - - - } else if (A.m_mantissa[0]) { - tmp = A; - } else { - tmp = *this; - } - - dgAssert (dgInt64 (tmp.m_mantissa[0]) >= 0); - return tmp; - } - - dgGoogol dgGoogol::operator- (const dgGoogol &A) const - { - dgGoogol tmp (A); - tmp.m_sign = !tmp.m_sign; - return *this + tmp; - } - - void dgGoogol::ScaleMantissa (dgUnsigned64* const dst, dgUnsigned64 scale) const - { - dgUnsigned64 carrier = 0; - for (dgInt32 i = DG_GOOGOL_SIZE - 1; i >= 0; i --) { - if (m_mantissa[i]) { - dgUnsigned64 low; - dgUnsigned64 high; - ExtendeMultiply (scale, m_mantissa[i], high, low); - dgUnsigned64 acc = low + carrier; - carrier = CheckCarrier (low, carrier); - dgAssert (CheckCarrier (carrier, high) == 0); - carrier += high; - dst[i + 1] = acc; - } else { - dst[i + 1] = carrier; - carrier = 0; - } - - } - dst[0] = carrier; - } - - dgGoogol dgGoogol::operator* (const dgGoogol &A) const - { - dgAssert (dgInt64 (m_mantissa[0]) >= 0); - dgAssert (dgInt64 (A.m_mantissa[0]) >= 0); - - if (m_mantissa[0] && A.m_mantissa[0]) { - dgUnsigned64 mantissaAcc[DG_GOOGOL_SIZE * 2]; - memset (mantissaAcc, 0, sizeof (mantissaAcc)); - for (dgInt32 i = DG_GOOGOL_SIZE - 1; i >= 0; i --) { - dgUnsigned64 a = m_mantissa[i]; - if (a) { - dgUnsigned64 mantissaScale[2 * DG_GOOGOL_SIZE]; - memset (mantissaScale, 0, sizeof (mantissaScale)); - A.ScaleMantissa (&mantissaScale[i], a); - - dgUnsigned64 carrier = 0; - for (dgInt32 j = 0; j < 2 * DG_GOOGOL_SIZE; j ++) { - const dgInt32 k = 2 * DG_GOOGOL_SIZE - 1 - j; - dgUnsigned64 m0 = mantissaAcc[k]; - dgUnsigned64 m1 = mantissaScale[k]; - mantissaAcc[k] = m0 + m1 + carrier; - carrier = CheckCarrier (m0, m1) | CheckCarrier (m0 + m1, carrier); - } - } - } - - dgUnsigned64 carrier = 0; - //dgInt32 bits = dgUnsigned64(LeadingZeros (mantissaAcc[0]) - 2); - dgInt32 bits = LeadingZeros (mantissaAcc[0]) - 2; - for (dgInt32 i = 0; i < 2 * DG_GOOGOL_SIZE; i ++) { - const dgInt32 k = 2 * DG_GOOGOL_SIZE - 1 - i; - dgUnsigned64 a = mantissaAcc[k]; - mantissaAcc[k] = (a << dgUnsigned64(bits)) | carrier; - carrier = a >> dgUnsigned64(64 - bits); - } - - dgInt32 exp = m_exponent + A.m_exponent - (bits - 2); - - dgGoogol tmp; - tmp.m_sign = m_sign ^ A.m_sign; - tmp.m_exponent = dgInt16 (exp); - memcpy (tmp.m_mantissa, mantissaAcc, sizeof (m_mantissa)); - - return tmp; - } - return dgGoogol(0.0); - } - - dgGoogol dgGoogol::operator/ (const dgGoogol &A) const - { - dgGoogol tmp (1.0 / A); - tmp = tmp * (m_two - A * tmp); - tmp = tmp * (m_two - A * tmp); - int test = 0; - dgInt32 passes = 0; - do { - passes ++; - dgGoogol tmp0 (tmp); - tmp = tmp * (m_two - A * tmp); - test = memcmp (&tmp0, &tmp, sizeof (dgGoogol)); - } while (test && (passes < (2 * DG_GOOGOL_SIZE))); - dgAssert (passes <= (2 * DG_GOOGOL_SIZE)); - return (*this) * tmp; - } - - - dgGoogol dgGoogol::Abs () const - { - dgGoogol tmp (*this); - tmp.m_sign = 0; - return tmp; - } - - dgGoogol dgGoogol::Floor () const - { - if (m_exponent < 1) { - return dgGoogol (0.0); - } - dgInt32 bits = m_exponent + 2; - dgInt32 start = 0; - while (bits >= 64) { - bits -= 64; - start ++; - } - - dgGoogol tmp (*this); - for (dgInt32 i = DG_GOOGOL_SIZE - 1; i > start; i --) { - tmp.m_mantissa[i] = 0; - } - // some compilers do no like this and I do not know why is that - //dgUnsigned64 mask = (-1LL) << (64 - bits); - dgUnsigned64 mask (~0ULL); - mask <<= (64 - bits); - tmp.m_mantissa[start] &= mask; - if (m_sign) { - dgAssert (0); - } - - return tmp; - } - - dgGoogol dgGoogol::InvSqrt () const - { - const dgGoogol& me = *this; - dgGoogol x (1.0f / sqrt (me)); - - dgInt32 test = 0; - dgInt32 passes = 0; - do { - passes ++; - dgGoogol tmp (x); - x = m_half * x * (m_three - me * x * x); - test = memcmp (&x, &tmp, sizeof (dgGoogol)); - } while (test && (passes < (2 * DG_GOOGOL_SIZE))); - dgAssert (passes <= (2 * DG_GOOGOL_SIZE)); - return x; - } - - dgGoogol dgGoogol::Sqrt () const - { - return *this * InvSqrt(); - } - - void dgGoogol::ToString (char* const string) const - { - dgGoogol tmp (*this); - dgGoogol base (10.0); - while (dgFloat64 (tmp) > 1.0) { - tmp = tmp/base; - } - - dgInt32 index = 0; - while (tmp.m_mantissa[0]) { - tmp = tmp * base; - dgGoogol digit (tmp.Floor()); - tmp -= digit; - dgFloat64 val = digit; - string[index] = char (val) + '0'; - index ++; - } - string[index] = 0; - } - - -#else - - dgGoogol::dgGoogol(void) - :m_value(0.0) - { - } - - dgGoogol::dgGoogol(dgFloat64 value) - :m_value (value) - { - } - - void dgGoogol::CopySignedMantissa (dgUnsigned64* const mantissa) const - { - } - - dgGoogol::operator double() const - { - return m_value; - } - - dgGoogol dgGoogol::operator+ (const dgGoogol &A) const - { - return m_value + A.m_value; - } - - - dgGoogol dgGoogol::operator- (const dgGoogol &A) const - { - return m_value - A.m_value; - } - - dgGoogol dgGoogol::operator* (const dgGoogol &A) const - { - return m_value * A.m_value; - } - - dgGoogol dgGoogol::operator/ (const dgGoogol &A) const - { - return m_value / A.m_value; - } - - - dgGoogol dgGoogol::Abs () const - { - return fabs (m_value); - } - - dgGoogol dgGoogol::InvSqrt () const - { - return 1.0 / sqrt (m_value); - } - - dgGoogol dgGoogol::Sqrt () const - { - return sqrt(m_value); - } - - - dgGoogol dgGoogol::Floor () const - { - return floor (m_value); - } - - void dgGoogol::ToString (char* const string) const - { - sprintf (string, "%f", m_value); - } - - void dgGoogol::ScaleMantissa (dgUnsigned64* const dst, dgUnsigned64 scale) const - { - } - -#endif - - - -void dgGoogol::NegateMantissa (dgUnsigned64* const mantissa) const -{ - dgUnsigned64 carrier = 1; - for (dgInt32 i = DG_GOOGOL_SIZE - 1; i >= 0; i --) { - dgUnsigned64 a = ~mantissa[i] + carrier; - if (a) { - carrier = 0; - } - mantissa[i] = a; - } -} - - -void dgGoogol::ShiftRightMantissa (dgUnsigned64* const mantissa, dgInt32 bits) const -{ - dgUnsigned64 carrier = 0; - if (dgInt64 (mantissa[0]) < dgInt64 (0)) { - carrier = dgUnsigned64 (-1); - } - - while (bits >= 64) { - for (dgInt32 i = DG_GOOGOL_SIZE - 2; i >= 0; i --) { - mantissa[i + 1] = mantissa[i]; - } - mantissa[0] = carrier; - bits -= 64; - } - - if (bits > 0) { - carrier <<= (64 - bits); - for (dgInt32 i = 0; i < DG_GOOGOL_SIZE; i ++) { - dgUnsigned64 a = mantissa[i]; - mantissa[i] = (a >> bits) | carrier; - carrier = a << (64 - bits); - } - } -} - -dgInt32 dgGoogol::LeadingZeros (dgUnsigned64 a) const -{ - #define dgCOUNTBIT(mask,add) \ - { \ - dgUnsigned64 test = a & mask; \ - n += test ? 0 : add; \ - a = test ? test : (a & ~mask); \ - } - - dgInt32 n = 0; - dgAssert (a); - dgCOUNTBIT (0xffffffff00000000LL, 32); - dgCOUNTBIT (0xffff0000ffff0000LL, 16); - dgCOUNTBIT (0xff00ff00ff00ff00LL, 8); - dgCOUNTBIT (0xf0f0f0f0f0f0f0f0LL, 4); - dgCOUNTBIT (0xccccccccccccccccLL, 2); - dgCOUNTBIT (0xaaaaaaaaaaaaaaaaLL, 1); - - return n; -} - -dgInt32 dgGoogol::NormalizeMantissa (dgUnsigned64* const mantissa) const -{ - dgAssert (dgInt64 (mantissa[0]) >= 0); - - dgInt32 bits = 0; - if(dgInt64 (mantissa[0] * 2) < 0) { - bits = 1; - ShiftRightMantissa (mantissa, 1); - } else { - while (!mantissa[0] && bits > (-64 * DG_GOOGOL_SIZE)) { - bits -= 64; - for (dgInt32 i = 1; i < DG_GOOGOL_SIZE; i ++) { - mantissa[i - 1] = mantissa[i]; - } - mantissa[DG_GOOGOL_SIZE - 1] = 0; - } - - if (bits > (-64 * DG_GOOGOL_SIZE)) { - dgInt32 n = LeadingZeros (mantissa[0]) - 2; - if (n > 0) { - dgAssert (n > 0); - dgUnsigned64 carrier = 0; - for (dgInt32 i = DG_GOOGOL_SIZE-1; i >= 0; i --) { - dgUnsigned64 a = mantissa[i]; - mantissa[i] = (a << n) | carrier; - carrier = a >> (64 - n); - } - bits -= n; - } else if (n < 0) { - // this is very rare but it does happens, whee the leading zeros of the mantissa is an exact multiple of 64 - dgAssert (mantissa[0] & dgUnsigned64(3)<<62); - dgUnsigned64 carrier = 0; - dgInt32 shift = -n; - for (dgInt32 i = 0; i < DG_GOOGOL_SIZE; i ++) { - dgUnsigned64 a = mantissa[i]; - mantissa[i] = (a >> shift) | carrier; - carrier = a << (64 - shift); - } - bits -= n; - - } - } - } - return bits; -} - -dgUnsigned64 dgGoogol::CheckCarrier (dgUnsigned64 a, dgUnsigned64 b) const -{ - return ((dgUnsigned64 (-1) - b) < a) ? dgUnsigned64(1) : 0; -} - - -void dgGoogol::ExtendeMultiply (dgUnsigned64 a, dgUnsigned64 b, dgUnsigned64& high, dgUnsigned64& low) const -{ - dgUnsigned64 bLow = b & 0xffffffff; - dgUnsigned64 bHigh = b >> 32; - dgUnsigned64 aLow = a & 0xffffffff; - dgUnsigned64 aHigh = a >> 32; - - dgUnsigned64 l = bLow * aLow; - - dgUnsigned64 c1 = bHigh * aLow; - dgUnsigned64 c2 = bLow * aHigh; - dgUnsigned64 m = c1 + c2; - dgUnsigned64 carrier = CheckCarrier (c1, c2) << 32; - - dgUnsigned64 h = bHigh * aHigh + carrier; - - dgUnsigned64 ml = m << 32; - dgUnsigned64 ll = l + ml; - dgUnsigned64 mh = (m >> 32) + CheckCarrier (l, ml); - dgAssert ((mh & ~0xffffffff) == 0); - - dgUnsigned64 hh = h + mh; - - low = ll; - high = hh; -} - - - - - -dgGoogol dgGoogol::operator+= (const dgGoogol &A) -{ - *this = *this + A; - return *this; -} - -dgGoogol dgGoogol::operator-= (const dgGoogol &A) -{ - *this = *this - A; - return *this; -} - - -bool dgGoogol::operator> (const dgGoogol &A) const -{ - dgGoogol tmp (*this - A); - return dgFloat64(tmp) > 0.0; -} - -bool dgGoogol::operator>= (const dgGoogol &A) const -{ - dgGoogol tmp (*this - A); - return dgFloat64 (tmp) >= 0.0; -} - -bool dgGoogol::operator< (const dgGoogol &A) const -{ - dgGoogol tmp (*this - A); - return dgFloat64 (tmp) < 0.0; -} - -bool dgGoogol::operator<= (const dgGoogol &A) const -{ - dgGoogol tmp (*this - A); - return dgFloat64 (tmp) <= 0.0; -} - -bool dgGoogol::operator== (const dgGoogol &A) const -{ - dgGoogol tmp (*this - A); - return dgFloat64 (tmp) == 0.0; -} - -bool dgGoogol::operator!= (const dgGoogol &A) const -{ - dgGoogol tmp (*this - A); - return dgFloat64 (tmp) != 0.0; -} - -void dgGoogol::Trace () const -{ - dgTrace (("%f ", dgFloat64 (*this))); -} - - - - - - - diff --git a/thirdparty/src/newton/dgCore/dgGoogol.h b/thirdparty/src/newton/dgCore/dgGoogol.h deleted file mode 100644 index 95518b5e7..000000000 --- a/thirdparty/src/newton/dgCore/dgGoogol.h +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgGoogol__ -#define __dgGoogol__ - - -#include "dgStdafx.h" -#include "dgMemory.h" -#include "dgArray.h" -#include "dgVector.h" - -#define _IMPLEMENT_USING_INTEGER_ARITHMETIC_ - -//#define DG_GOOGOL_SIZE 16 -#define DG_GOOGOL_SIZE 4 - -class dgGoogol -{ - public: - dgGoogol(void); - dgGoogol(dgFloat64 value); - - operator double() const; - dgGoogol operator+ (const dgGoogol &A) const; - dgGoogol operator- (const dgGoogol &A) const; - dgGoogol operator* (const dgGoogol &A) const; - dgGoogol operator/ (const dgGoogol &A) const; - - dgGoogol operator+= (const dgGoogol &A); - dgGoogol operator-= (const dgGoogol &A); - - bool operator> (const dgGoogol &A) const; - bool operator>= (const dgGoogol &A) const; - bool operator< (const dgGoogol &A) const; - bool operator<= (const dgGoogol &A) const; - bool operator== (const dgGoogol &A) const; - bool operator!= (const dgGoogol &A) const; - - dgGoogol Abs () const; - dgGoogol Sqrt () const; - dgGoogol InvSqrt () const; - dgGoogol Floor () const; - - void Trace () const; - void ToString (char* const string) const; - - - private: - void InitFloatFloat (dgFloat64 value); - void NegateMantissa (dgUnsigned64* const mantissa) const; - void CopySignedMantissa (dgUnsigned64* const mantissa) const; - dgInt32 NormalizeMantissa (dgUnsigned64* const mantissa) const; - dgUnsigned64 CheckCarrier (dgUnsigned64 a, dgUnsigned64 b) const; - void ShiftRightMantissa (dgUnsigned64* const mantissa, dgInt32 bits) const; - - dgInt32 LeadingZeros (dgUnsigned64 a) const; - void ExtendeMultiply (dgUnsigned64 a, dgUnsigned64 b, dgUnsigned64& high, dgUnsigned64& low) const; - void ScaleMantissa (dgUnsigned64* const out, dgUnsigned64 scale) const; - -#ifdef _IMPLEMENT_USING_INTEGER_ARITHMETIC_ - dgInt32 m_sign; - dgInt32 m_exponent; - dgUnsigned64 m_mantissa[DG_GOOGOL_SIZE]; -#else - dgFloat64 m_value; -#endif - - - public: - static dgGoogol m_zero; - static dgGoogol m_one; - static dgGoogol m_two; - static dgGoogol m_three; - static dgGoogol m_half; -}; - - -class dgHugeVector: public dgTemplateVector<dgGoogol> -{ - public: - dgHugeVector () - :dgTemplateVector<dgGoogol>() - { - } - - dgHugeVector (const dgBigVector& a) - :dgTemplateVector<dgGoogol>(dgGoogol (a.m_x), dgGoogol (a.m_y), dgGoogol (a.m_z), dgGoogol (a.m_w)) - { - } - - dgHugeVector (const dgTemplateVector<dgGoogol>& a) - :dgTemplateVector<dgGoogol>(a) - { - } - - dgHugeVector (dgFloat64 x, dgFloat64 y, dgFloat64 z, dgFloat64 w) - :dgTemplateVector<dgGoogol>(x, y, z, w) - { - } - - dgHugeVector(const dgGoogol& x, const dgGoogol& y, const dgGoogol& z, const dgGoogol& w) - :dgTemplateVector<dgGoogol>(x, y, z, w) - { - } - - dgGoogol EvaluePlane (const dgHugeVector& point) const - { - //return (point % (*this)) + m_w; - return DotProduct3(point) + m_w; - } - -#ifdef _DEBUG - void Trace () const - { - m_x.Trace(); - m_y.Trace(); - m_z.Trace(); - m_w.Trace(); - dgTrace (("\n")); - } -#endif -}; - - -#endif diff --git a/thirdparty/src/newton/dgCore/dgGraph.h b/thirdparty/src/newton/dgCore/dgGraph.h deleted file mode 100644 index db1b06e48..000000000 --- a/thirdparty/src/newton/dgCore/dgGraph.h +++ /dev/null @@ -1,191 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -/**************************************************************************** -* -* Visual C++ 6.0 created by: Julio Jerez -* -****************************************************************************/ -#ifndef __dgGraph__ -#define __dgGraph__ - -#include "dgStdafx.h" -#include "dgRef.h" -#include "dgList.h" - - -template<class dgNodeData, class dgEdgeData> class dgGraphEdge; -template<class dgNodeData, class dgEdgeData> class dgGraphNode; - - -template<class dgNodeData, class dgEdgeData> -class dgGraph: public dgList<dgGraphNode<dgNodeData, dgEdgeData> > -{ - public: - dgGraph (dgMemoryAllocator* const allocator); - ~dgGraph (); - - typename dgGraph<dgNodeData, dgEdgeData>::dgListNode* AddNode (); - void DeleteNode (typename dgGraph<dgNodeData, dgEdgeData>::dgListNode* const node); - - typename dgGraph<dgNodeData, dgEdgeData>::dgListNode* GetNodeFromNodeData(dgNodeData* const nodeData); - - //void Trace () const; -}; - -template<class dgNodeData, class dgEdgeData> -class dgGraphNode: public dgList<dgGraphEdge<dgNodeData, dgEdgeData> > -{ - public: - dgGraphNode (); - ~dgGraphNode (); - - typename dgGraphNode<dgNodeData, dgEdgeData>::dgListNode* AddEdge(typename dgGraph<dgNodeData, dgEdgeData>::dgListNode* const node); - void DeleteHalfEdge(typename dgGraphNode<dgNodeData, dgEdgeData>::dgListNode* const edge); - void DeleteEdge(typename dgGraphNode<dgNodeData, dgEdgeData>::dgListNode* const edge); - - //void Trace () const; - - dgNodeData m_nodeData; -}; - -template<class dgNodeData, class dgEdgeData> -class dgGraphEdge -{ - public: - dgGraphEdge(); - ~dgGraphEdge(); - - typename dgGraph<dgNodeData, dgEdgeData>::dgListNode* m_node; - dgEdgeData m_edgeData; -}; - - - -template<class dgNodeData, class dgEdgeData> -dgGraph<dgNodeData, dgEdgeData>::dgGraph (dgMemoryAllocator* const allocator) - :dgList<dgGraphNode<dgNodeData, dgEdgeData> >(allocator) -{ -} - - -template<class dgNodeData, class dgEdgeData> -dgGraph<dgNodeData, dgEdgeData>::~dgGraph () -{ -} - -template<class dgNodeData, class dgEdgeData> -typename dgGraph<dgNodeData, dgEdgeData>::dgListNode* dgGraph<dgNodeData, dgEdgeData>::AddNode () -{ - typename dgGraph<dgNodeData, dgEdgeData>::dgListNode* const node = dgGraph<dgNodeData, dgEdgeData>::Append(); - - node->GetInfo().SetAllocator(dgGraph<dgNodeData, dgEdgeData>::GetAllocator()); - - return node; -} - -template<class dgNodeData, class dgEdgeData> -void dgGraph<dgNodeData, dgEdgeData>::DeleteNode (typename dgGraph<dgNodeData, dgEdgeData>::dgListNode* const node) -{ - for (typename dgGraphNode<dgNodeData, dgEdgeData>::dgListNode* link = node->GetInfo().GetFirst(); link; link = link->GetNext()) { - typename dgGraph<dgNodeData, dgEdgeData>::dgListNode* const twinNode = link->GetInfo().m_node; - for (typename dgGraphNode<dgNodeData, dgEdgeData>::dgListNode* link1 = twinNode->GetInfo().GetFirst(); link1; link1 = link1->GetNext()) { - if (link1->GetInfo().m_node == node) { - twinNode->GetInfo().Remove (link1); - break; - } - } - } - dgList<dgGraphNode<dgNodeData, dgEdgeData> >::Remove (node); -} - -template<class dgNodeData, class dgEdgeData> -typename dgGraph<dgNodeData, dgEdgeData>::dgListNode* dgGraph<dgNodeData, dgEdgeData>::GetNodeFromNodeData(dgNodeData* const nodeData) -{ - dgInt32 size1 = sizeof (*nodeData); - dgInt32 size0 = sizeof (dgGraphNode<dgNodeData, dgEdgeData>); - void* const ptr = ((char*)nodeData) - (size0 - size1); - dgGraphNode<dgNodeData, dgEdgeData>* const nodeInfo = (dgGraphNode<dgNodeData, dgEdgeData>*) ptr; - return this->GetNodeFromInfo(*nodeInfo); -} - - -template<class dgNodeData, class dgEdgeData> -dgGraphNode<dgNodeData, dgEdgeData>::dgGraphNode() - :dgList<dgGraphEdge<dgNodeData, dgEdgeData> >(NULL) -{ - -} - - -template<class dgNodeData, class dgEdgeData> -dgGraphNode<dgNodeData, dgEdgeData>::~dgGraphNode() -{ - -} - -template<class dgNodeData, class dgEdgeData> -typename dgGraphNode<dgNodeData, dgEdgeData>::dgListNode* dgGraphNode<dgNodeData, dgEdgeData>::AddEdge (typename dgGraph<dgNodeData, dgEdgeData>::dgListNode* const node) -{ - typename dgGraphNode<dgNodeData, dgEdgeData>::dgListNode* const edge = dgGraphNode<dgNodeData, dgEdgeData>::Append(); - - edge->GetInfo().m_node = node; - return edge; -} - -template<class dgNodeData, class dgEdgeData> -void dgGraphNode<dgNodeData, dgEdgeData>::DeleteHalfEdge(typename dgGraphNode<dgNodeData, dgEdgeData>::dgListNode* const edge) -{ - dgList<dgGraphEdge<dgNodeData, dgEdgeData> >::Remove (edge); -} - -template<class dgNodeData, class dgEdgeData> -void dgGraphNode<dgNodeData, dgEdgeData>::DeleteEdge(typename dgGraphNode<dgNodeData, dgEdgeData>::dgListNode* const edge) -{ - typename dgGraph<dgNodeData, dgEdgeData>::dgListNode* const node = edge->GetInfo().m_node; - - for (typename dgGraphNode<dgNodeData, dgEdgeData>::dgListNode* twinEdge = node->GetInfo().GetFirst(); twinEdge; twinEdge = twinEdge->GetNext()) { - if (&twinEdge->GetInfo().m_node->GetInfo() == this) { - node->GetInfo().DeleteHalfEdge(twinEdge); - break; - } - } - - DeleteHalfEdge(edge); -} - - -template<class dgNodeData, class dgEdgeData> -dgGraphEdge<dgNodeData, dgEdgeData>::dgGraphEdge() -{ - -} - -template<class dgNodeData, class dgEdgeData> -dgGraphEdge<dgNodeData, dgEdgeData>::~dgGraphEdge() -{ - -} - - - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgHeap.h b/thirdparty/src/newton/dgCore/dgHeap.h deleted file mode 100644 index f8b91c473..000000000 --- a/thirdparty/src/newton/dgCore/dgHeap.h +++ /dev/null @@ -1,435 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -/**************************************************************************** -* -* Visual C++ 6.0 created by: Julio Jerez -* -****************************************************************************/ -#ifndef __dgHeapBase__ -#define __dgHeapBase__ - -#include "dgStdafx.h" -#include "dgMemory.h" - -//#define DG_HEAP_DEBUG_CHECK - - -template <class OBJECT, class KEY> -class dgHeapBase -{ - protected: - struct RECORD - { - KEY m_key; - OBJECT m_obj; - - RECORD (KEY key, const OBJECT& obj) - :m_key(key), m_obj(obj) - { - } - }; - - dgHeapBase (dgInt32 maxElements, dgMemoryAllocator* const allocator); - dgHeapBase (const void * const buffer, dgInt32 sizeInBytes); - ~dgHeapBase (); - - public: - DG_CLASS_ALLOCATOR(allocator) - - void Flush (); - KEY MaxValue() const; - KEY Value(dgInt32 i = 0) const; - dgInt32 GetCount() const; - dgInt32 GetMaxCount() const; - const OBJECT& operator[] (dgInt32 i) const; - dgInt32 Find (OBJECT &obj); - dgInt32 Find (KEY key); - - dgInt32 m_curCount; - dgInt32 m_maxCount; - dgMemoryAllocator* m_allocator; - RECORD *m_pool; -}; - -template <class OBJECT, class KEY> -class dgDownHeap: public dgHeapBase<OBJECT, KEY> -{ - public: - dgDownHeap (dgInt32 maxElements, dgMemoryAllocator* const allocator); - dgDownHeap (const void * const buffer, dgInt32 sizeInBytes); - - void Pop () {Remove (0);} - void Push (OBJECT &obj, KEY key); - void Sort (); - void Remove (dgInt32 Index); - bool SanityCheck(); -}; - -template <class OBJECT, class KEY> -class dgUpHeap: public dgHeapBase<OBJECT, KEY> -{ - public: - dgUpHeap (dgInt32 maxElements, dgMemoryAllocator* const allocator); - dgUpHeap (const void * const buffer, dgInt32 sizeInBytes); - - void Pop () {Remove (0);} - void Push (OBJECT &obj, KEY key); - void Sort (); - void Remove (dgInt32 Index); - bool SanityCheck(); -}; - -template <class OBJECT, class KEY> -dgHeapBase<OBJECT,KEY>::dgHeapBase (dgInt32 maxElements, dgMemoryAllocator* const allocator) -{ - m_allocator = allocator; - m_pool = (RECORD *)m_allocator->Malloc (maxElements * sizeof (RECORD)); - m_maxCount = maxElements; - Flush(); -} - -template <class OBJECT, class KEY> -dgHeapBase<OBJECT,KEY>::dgHeapBase (const void * const buffer, dgInt32 sizeInBytes) -{ - m_allocator = NULL; - m_pool = (RECORD *) buffer; - m_maxCount = dgInt32 (sizeInBytes / sizeof (RECORD)); - Flush(); -} - -template <class OBJECT, class KEY> -dgHeapBase<OBJECT,KEY>::~dgHeapBase () -{ - if (m_allocator) { - m_allocator->Free (m_pool); - } -} - - -template <class OBJECT, class KEY> -KEY dgHeapBase<OBJECT,KEY>::Value(dgInt32 i) const -{ - return m_pool[i].m_key; -} - - -template <class OBJECT, class KEY> -dgInt32 dgHeapBase<OBJECT,KEY>::GetCount() const -{ - return m_curCount; -} - -template <class OBJECT, class KEY> -void dgHeapBase<OBJECT,KEY>::Flush () -{ - m_curCount = 0; - - #ifdef _DEBUG -// dgHeapBase<OBJECT,KEY>::m_pool[dgHeapBase<OBJECT,KEY>::m_curCount].m_key = KEY (0); - #endif -} - -template <class OBJECT, class KEY> -KEY dgHeapBase<OBJECT,KEY>::MaxValue() const -{ - return m_pool[0].m_key; -} - -template <class OBJECT, class KEY> -dgInt32 dgHeapBase<OBJECT,KEY>::GetMaxCount() const -{ - return m_maxCount; -} - - -template <class OBJECT, class KEY> -dgInt32 dgHeapBase<OBJECT,KEY>::Find (OBJECT &obj) -{ - // For now let perform a linear search - // this is efficient if the size of the heap is small - // ex: m_curCount < 32 - // this will be change to a binary search in the heap should the - // the size of the heap get larger than 32 - // dgAssert (m_curCount <= 32); - for (dgInt32 i = 0; i < m_curCount; i ++) { - if (m_pool[i].obj == obj) { - return i; - } - } - return - 1; -} - - -template <class OBJECT, class KEY> -dgInt32 dgHeapBase<OBJECT,KEY>::Find (KEY key) -{ - // ex: m_curCount < 32 - // this will be change to a binary search in the heap shoud the - // the size of the heap get larger than 32 - dgAssert (m_curCount <= 32); - for (dgInt32 i = 0; i < m_curCount; i ++) { - if (m_pool[i].m_key == key) { - return i; - } - } - return - 1; -} - - -template <class OBJECT, class KEY> -const OBJECT& dgHeapBase<OBJECT,KEY>::operator[] (dgInt32 i) const -{ - dgAssert (i<= m_curCount); - return m_pool[i].m_obj; -} - - -// ************************************************************************** -// -// down Heap -// -// ************************************************************************** -template <class OBJECT, class KEY> -dgDownHeap<OBJECT,KEY>::dgDownHeap (dgInt32 maxElements, dgMemoryAllocator* const allocator) - :dgHeapBase<OBJECT, KEY> (maxElements, allocator) -{ -} - -template <class OBJECT, class KEY> -dgDownHeap<OBJECT,KEY>::dgDownHeap (const void * const buffer, dgInt32 sizeInBytes) - :dgHeapBase<OBJECT, KEY> (buffer, sizeInBytes) -{ -} - - -template <class OBJECT, class KEY> -void dgDownHeap<OBJECT,KEY>::Push (OBJECT &obj, KEY key) -{ - dgHeapBase<OBJECT,KEY>::m_curCount ++; - - dgInt32 j; - dgInt32 i = dgHeapBase<OBJECT,KEY>::m_curCount; - for (; i; i = j) { - j = i >> 1; - if (!j || (dgHeapBase<OBJECT,KEY>::m_pool[j - 1].m_key > key)) { - break; - } - dgHeapBase<OBJECT,KEY>::m_pool[i - 1] = dgHeapBase<OBJECT,KEY>::m_pool[j - 1]; - } - dgAssert (i); - dgHeapBase<OBJECT,KEY>::m_pool[i - 1].m_key = key; - dgHeapBase<OBJECT,KEY>::m_pool[i - 1].m_obj = obj; - - dgAssert (SanityCheck()); -} - -template <class OBJECT, class KEY> -void dgDownHeap<OBJECT,KEY>::Remove (dgInt32 index) -{ - dgHeapBase<OBJECT, KEY>::m_curCount--; - dgHeapBase<OBJECT, KEY>::m_pool[index] = dgHeapBase<OBJECT, KEY>::m_pool[dgHeapBase<OBJECT, KEY>::m_curCount]; - while (index && dgHeapBase<OBJECT, KEY>::m_pool[(index - 1) >> 1].m_key < dgHeapBase<OBJECT, KEY>::m_pool[index].m_key) { - dgSwap(dgHeapBase<OBJECT, KEY>::m_pool[(index - 1) >> 1], dgHeapBase<OBJECT, KEY>::m_pool[index]); - index = (index - 1) >> 1; - } - - while ((2 * index + 1) < dgHeapBase<OBJECT, KEY>::m_curCount) { - dgInt32 i0 = 2 * index + 1; - dgInt32 i1 = 2 * index + 2; - if (i1 < dgHeapBase<OBJECT, KEY>::m_curCount) { - i0 = (dgHeapBase<OBJECT, KEY>::m_pool[i0].m_key > dgHeapBase<OBJECT, KEY>::m_pool[i1].m_key) ? i0 : i1; - if (dgHeapBase<OBJECT, KEY>::m_pool[i0].m_key <= dgHeapBase<OBJECT, KEY>::m_pool[index].m_key) { - break; - } - dgSwap(dgHeapBase<OBJECT, KEY>::m_pool[i0], dgHeapBase<OBJECT, KEY>::m_pool[index]); - index = i0; - } else { - if (dgHeapBase<OBJECT, KEY>::m_pool[i0].m_key > dgHeapBase<OBJECT, KEY>::m_pool[index].m_key) { - dgSwap(dgHeapBase<OBJECT, KEY>::m_pool[i0], dgHeapBase<OBJECT, KEY>::m_pool[index]); - } - index = i0; - } - } - dgAssert (SanityCheck()); -} - -template <class OBJECT, class KEY> -void dgDownHeap<OBJECT,KEY>::Sort () -{ - dgInt32 count = dgHeapBase<OBJECT,KEY>::m_curCount; - for (dgInt32 i = 1; i < count; i ++) { - KEY key (dgHeapBase<OBJECT,KEY>::m_pool[0].m_key); - OBJECT obj (dgHeapBase<OBJECT,KEY>::m_pool[0].m_obj); - - Pop(); - - dgHeapBase<OBJECT,KEY>::m_pool[dgHeapBase<OBJECT,KEY>::m_curCount].m_key = key; - dgHeapBase<OBJECT,KEY>::m_pool[dgHeapBase<OBJECT,KEY>::m_curCount].m_obj = obj; - } - - dgHeapBase<OBJECT,KEY>::m_curCount = count; - for (dgInt32 i = 0; i < count / 2; i ++) { - KEY key (dgHeapBase<OBJECT,KEY>::m_pool[i].m_key); - OBJECT obj (dgHeapBase<OBJECT,KEY>::m_pool[i].m_obj); - - dgHeapBase<OBJECT,KEY>::m_pool[i].m_key = dgHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_key; - dgHeapBase<OBJECT,KEY>::m_pool[i].m_obj = dgHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_obj; - - dgHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_key = key; - dgHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_obj = obj; - } - dgAssert (SanityCheck()); -} - -template <class OBJECT, class KEY> -bool dgDownHeap<OBJECT,KEY>::SanityCheck() -{ -#ifdef DG_HEAP_DEBUG_CHECK - for (dgInt32 i = 0; i < m_curCount; i++) { - dgInt32 i1 = 2 * i + 1; - dgInt32 i2 = 2 * i + 2; - if ((i1 < m_curCount) && (dgHeapBase<OBJECT, KEY>::m_pool[i].m_key < dgHeapBase<OBJECT, KEY>::m_pool[i1].m_key)) { - return false; - } - if ((i2 < m_curCount) && (dgHeapBase<OBJECT, KEY>::m_pool[i].m_key < dgHeapBase<OBJECT, KEY>::m_pool[i2].m_key)) { - return false; - } - } -#endif - return true; -} - -// ************************************************************************** -// -// down Heap -// -// ************************************************************************** -template <class OBJECT, class KEY> -dgUpHeap<OBJECT,KEY>::dgUpHeap (dgInt32 maxElements, dgMemoryAllocator* const allocator) - :dgHeapBase<OBJECT, KEY> (maxElements, allocator) -{ -} - -template <class OBJECT, class KEY> -dgUpHeap<OBJECT,KEY>::dgUpHeap (const void * const buffer, dgInt32 sizeInBytes) - :dgHeapBase<OBJECT, KEY> (buffer, sizeInBytes) -{ -} - -template <class OBJECT, class KEY> -bool dgUpHeap<OBJECT,KEY>::SanityCheck() -{ -#ifdef DG_HEAP_DEBUG_CHECK - for (dgInt32 i = 0; i < m_curCount; i ++) { - dgInt32 i1 = 2 * i + 1; - dgInt32 i2 = 2 * i + 2; - if ((i1 < m_curCount) && (dgHeapBase<OBJECT,KEY>::m_pool[i].m_key > dgHeapBase<OBJECT,KEY>::m_pool[i1].m_key)) { - return false; - } - if ((i2 < m_curCount) && (dgHeapBase<OBJECT,KEY>::m_pool[i].m_key > dgHeapBase<OBJECT,KEY>::m_pool[i2].m_key)) { - return false; - } - } -#endif - return true; -} - -template <class OBJECT, class KEY> -void dgUpHeap<OBJECT,KEY>::Push (OBJECT &obj, KEY key) -{ - dgHeapBase<OBJECT,KEY>::m_curCount ++; - - dgInt32 j; - dgInt32 i = dgHeapBase<OBJECT,KEY>::m_curCount; - for (; i; i = j) { - j = i >> 1; - if (!j || (dgHeapBase<OBJECT,KEY>::m_pool[j - 1].m_key < key)) { - break; - } - dgHeapBase<OBJECT,KEY>::m_pool[i - 1] = dgHeapBase<OBJECT,KEY>::m_pool[j - 1]; - } - dgAssert (i); - dgHeapBase<OBJECT,KEY>::m_pool[i - 1].m_key = key; - dgHeapBase<OBJECT,KEY>::m_pool[i - 1].m_obj = obj; - dgAssert (SanityCheck()); -} - -template <class OBJECT, class KEY> -void dgUpHeap<OBJECT,KEY>::Sort () -{ - dgInt32 count = dgHeapBase<OBJECT,KEY>::m_curCount; - for (dgInt32 i = 1; i < count; i ++) { - KEY key (dgHeapBase<OBJECT,KEY>::m_pool[0].m_key); - OBJECT obj (dgHeapBase<OBJECT,KEY>::m_pool[0].m_obj); - - Pop(); - - dgHeapBase<OBJECT,KEY>::m_pool[dgHeapBase<OBJECT,KEY>::m_curCount].m_key = key; - dgHeapBase<OBJECT,KEY>::m_pool[dgHeapBase<OBJECT,KEY>::m_curCount].m_obj = obj; - } - - dgHeapBase<OBJECT,KEY>::m_curCount = count; - for (dgInt32 i = 0; i < count / 2; i ++) { - KEY key (dgHeapBase<OBJECT,KEY>::m_pool[i].m_key); - OBJECT obj (dgHeapBase<OBJECT,KEY>::m_pool[i].m_obj); - - dgHeapBase<OBJECT,KEY>::m_pool[i].m_key = dgHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_key; - dgHeapBase<OBJECT,KEY>::m_pool[i].m_obj = dgHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_obj; - - dgHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_key = key; - dgHeapBase<OBJECT,KEY>::m_pool[count - i - 1].m_obj = obj; - } - dgAssert (SanityCheck()); -} - -template <class OBJECT, class KEY> -void dgUpHeap<OBJECT,KEY>::Remove (dgInt32 index) -{ - dgHeapBase<OBJECT, KEY>::m_curCount--; - dgHeapBase<OBJECT, KEY>::m_pool[index] = dgHeapBase<OBJECT, KEY>::m_pool[dgHeapBase<OBJECT, KEY>::m_curCount]; - while (index && dgHeapBase<OBJECT, KEY>::m_pool[(index - 1) >> 1].m_key > dgHeapBase<OBJECT, KEY>::m_pool[index].m_key) { - dgSwap(dgHeapBase<OBJECT, KEY>::m_pool[(index - 1) >> 1], dgHeapBase<OBJECT, KEY>::m_pool[index]); - index = (index - 1) >> 1; - } - - while ((2 * index + 1) < dgHeapBase<OBJECT, KEY>::m_curCount) { - dgInt32 i0 = 2 * index + 1; - dgInt32 i1 = 2 * index + 2; - if (i1 < dgHeapBase<OBJECT, KEY>::m_curCount) { - i0 = (dgHeapBase<OBJECT, KEY>::m_pool[i0].m_key < dgHeapBase<OBJECT, KEY>::m_pool[i1].m_key) ? i0 : i1; - if (dgHeapBase<OBJECT, KEY>::m_pool[i0].m_key >= dgHeapBase<OBJECT, KEY>::m_pool[index].m_key) { - break; - } - dgSwap(dgHeapBase<OBJECT, KEY>::m_pool[i0], dgHeapBase<OBJECT, KEY>::m_pool[index]); - index = i0; - } else { - if (dgHeapBase<OBJECT, KEY>::m_pool[i0].m_key < dgHeapBase<OBJECT, KEY>::m_pool[index].m_key) { - dgSwap(dgHeapBase<OBJECT, KEY>::m_pool[i0], dgHeapBase<OBJECT, KEY>::m_pool[index]); - } - index = i0; - } - } - dgAssert (SanityCheck()); -} - - -#endif \ No newline at end of file diff --git a/thirdparty/src/newton/dgCore/dgIntersections.cpp b/thirdparty/src/newton/dgCore/dgIntersections.cpp deleted file mode 100644 index 43712d778..000000000 --- a/thirdparty/src/newton/dgCore/dgIntersections.cpp +++ /dev/null @@ -1,400 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgMemory.h" -#include "dgVector.h" -#include "dgPlane.h" -#include "dgGoogol.h" -#include "dgIntersections.h" - -#define USE_FLOAT_VERSION - - -#define DG_RAY_TOL_ERROR (dgFloat32 (-1.0e-3f)) -#define DG_RAY_TOL_ADAPTIVE_ERROR (dgFloat32 (1.0e-1f)) - - - -dgFloat32 dgFastRayTest::PolygonIntersect (const dgVector& faceNormal, dgFloat32 maxT, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount) const -{ - dgAssert (m_p0.m_w == dgFloat32 (0.0f)); - dgAssert (m_p1.m_w == dgFloat32 (0.0f)); - - if (faceNormal.DotProduct(m_unitDir).GetScalar() < dgFloat32 (0.0f)) { - dgInt32 stride = dgInt32(strideInBytes / sizeof (dgFloat32)); - dgBigVector v0(dgVector(&polygon[indexArray[indexCount - 1] * stride]) & dgVector::m_triplexMask); - dgBigVector p0(m_p0); - dgBigVector p0v0(v0 - p0); - - dgBigVector diff(m_diff); - dgBigVector normal(faceNormal); - dgFloat64 tOut = normal.DotProduct(p0v0).GetScalar() / normal.DotProduct(diff).GetScalar(); - if ((tOut >= dgFloat64(0.0f)) && (tOut <= maxT)) { - dgBigVector p (p0 + diff.Scale (tOut)); - dgBigVector unitDir(m_unitDir); - for (dgInt32 i = 0; i < indexCount; i++) { - dgInt32 i2 = indexArray[i] * stride; - dgBigVector v1(dgVector(&polygon[i2]) & dgVector::m_triplexMask); - - dgBigVector edge0(p - v0); - dgBigVector edge1(v1 - v0); - dgFloat64 area = unitDir.DotProduct (edge0.CrossProduct(edge1)).GetScalar(); - if (area < dgFloat32 (0.0f)) { - return 1.2f; - } - v0 = v1; - } - - return dgFloat32(tOut); - } - } - - return dgFloat32 (1.2f); -} - -bool dgApi dgRayBoxClip (dgVector& p0, dgVector& p1, const dgVector& boxP0, const dgVector& boxP1) -{ - dgAssert (p0.m_w == dgFloat32(0.0f)); - dgAssert (p1.m_w == dgFloat32(0.0f)); - dgAssert (boxP0.m_w == dgFloat32(0.0f)); - dgAssert (boxP1.m_w == dgFloat32(0.0f)); - for (int i = 0; i < 3; i ++) { - dgFloat32 tmp0 = boxP1[i] - p0[i]; - if (tmp0 > dgFloat32 (0.0f)) { - dgFloat32 tmp1 = boxP1[i] - p1[i]; - if (tmp1 < dgFloat32 (0.0f)) { - p1 = p0 + (p1 - p0).Scale (tmp0 / (p1[i] - p0[i])); - p1[i] = boxP1[i]; - } - } else { - dgFloat32 tmp1 = boxP1[i] - p1[i]; - if (tmp1 > dgFloat32 (0.0f)) { - p0 += (p1 - p0).Scale (tmp0 / (p1[i] - p0[i])); - p0[i] = boxP1[i]; - } else { - return false; - } - } - - tmp0 = boxP0[i] - p0[i]; - if (tmp0 < dgFloat32 (0.0f)) { - dgFloat32 tmp1 = boxP0[i] - p1[i]; - if (tmp1 > dgFloat32 (0.0f)) { - p1 = p0 + (p1 - p0).Scale (tmp0 / (p1[i] - p0[i])); - p1[i] = boxP0[i]; - } - } else { - dgFloat32 tmp1 = boxP0[i] - p1[i]; - if (tmp1 < dgFloat32 (0.0f)) { - p0 += (p1 - p0).Scale (tmp0 / (p1[i] - p0[i])); - p0[i] = boxP0[i]; - } else { - return false; - } - } - } - return true; -} - -dgBigVector dgPointToRayDistance (const dgBigVector& point, const dgBigVector& ray_p0, const dgBigVector& ray_p1) -{ - dgBigVector dp (ray_p1 - ray_p0); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - dgFloat64 t = dgClamp (dp.DotProduct(point - ray_p0).GetScalar() / dp.DotProduct(dp).GetScalar(), dgFloat64(0.0f), dgFloat64 (1.0f)); - return ray_p0 + dp.Scale (t); -} - -dgBigVector dgPointToTriangleDistance(const dgBigVector& point, const dgBigVector& p0, const dgBigVector& p1, const dgBigVector& p2) -{ - const dgBigVector e10(p1 - p0); - const dgBigVector e20(p2 - p0); - const dgFloat64 a00 = e10.DotProduct(e10).GetScalar(); - const dgFloat64 a11 = e20.DotProduct(e20).GetScalar(); - const dgFloat64 a01 = e10.DotProduct(e20).GetScalar(); - - const dgFloat64 det = a00 * a11 - a01 * a01; - dgAssert(det >= dgFloat32(0.0f)); - if (dgAbs(det) > dgFloat32(1.0e-24f)) { - dgBigVector p0Point (point - p0); - const dgFloat64 b0 = e10.DotProduct(p0Point).GetScalar(); - const dgFloat64 b1 = e20.DotProduct(p0Point).GetScalar(); - - const dgFloat64 beta = b1 * a00 - a01 * b0; - const dgFloat64 alpha = b0 * a11 - a01 * b1; - if (beta < dgFloat32(0.0f)) { - return dgPointToRayDistance (point, p0, p1); - } else if (alpha < dgFloat32(0.0f)) { - return dgPointToRayDistance (point, p0, p2); - } else if ((alpha + beta) > det) { - return dgPointToRayDistance (point, p1, p2); - } - return p0 + (e10.Scale(alpha) + e20.Scale(beta)).Scale(dgFloat64(1.0f) / det); - } - // this is a degenerated triangle. this should never happens - dgAssert(0); - return p0; -} - -dgBigVector dgPointToTetrahedrumDistance (const dgBigVector& point, const dgBigVector& p0, const dgBigVector& p1, const dgBigVector& p2, const dgBigVector& p3) -{ - const dgBigVector e10(p1 - p0); - const dgBigVector e20(p2 - p0); - const dgBigVector e30(p3 - p0); - - const dgFloat64 d0 = sqrt(e10.DotProduct(e10).GetScalar()); - if (d0 > dgFloat64(0.0f)) { - const dgFloat64 invd0 = dgFloat64(1.0f) / d0; - const dgFloat64 l10 = e20.DotProduct(e10).GetScalar() * invd0; - const dgFloat64 l20 = e30.DotProduct(e10).GetScalar() * invd0; - const dgFloat64 desc11 = e20.DotProduct(e20).GetScalar() - l10 * l10; - if (desc11 > dgFloat64(0.0f)) { - const dgFloat64 d1 = sqrt(desc11); - const dgFloat64 invd1 = dgFloat64(1.0f) / d1; - const dgFloat64 l21 = (e30.DotProduct(e20).GetScalar() - l20 * l10) * invd1; - const dgFloat64 desc22 = e30.DotProduct(e30).GetScalar() - l20 * l20 - l21 * l21; - if (desc22 > dgFloat64(0.0f)) { - dgBigVector p0Point (point - p0); - const dgFloat64 d2 = sqrt(desc22); - const dgFloat64 invd2 = dgFloat64(1.0f) / d2; - - const dgFloat64 b0 = e10.DotProduct(p0Point).GetScalar(); - const dgFloat64 b1 = e20.DotProduct(p0Point).GetScalar(); - const dgFloat64 b2 = e30.DotProduct(p0Point).GetScalar(); - - dgFloat64 u1 = b0 * invd0; - dgFloat64 u2 = (b1 - l10 * u1) * invd1; - dgFloat64 u3 = (b2 - l20 * u1 - l21 * u2) * invd2 * invd2; - u2 = (u2 - l21 * u3) * invd1; - u1 = (u1 - l10 * u2 - l20 * u3) * invd0; - if (u3 < dgFloat64(0.0f)) { - // this looks funny but it is correct - return dgPointToTriangleDistance(point, p0, p1, p2); - } else if (u2 < dgFloat64(0.0f)) { - return dgPointToTriangleDistance(point, p0, p1, p3); - } else if (u1 < dgFloat64(0.0f)) { - return dgPointToTriangleDistance(point, p0, p2, p3); - } else if (u1 + u2 + u3 > dgFloat64(1.0f)) { - return dgPointToTriangleDistance(point, p1, p2, p3); - } - return p0 + e10.Scale(u1) + e20.Scale(u2) + e30.Scale(u3); - } - } - } - // this is a degenerated tetra. this should never happens - dgAssert(0); - return p0; -} - -void dgApi dgRayToRayDistance (const dgVector& ray_p0, const dgVector& ray_p1, const dgVector& ray_q0, const dgVector& ray_q1, dgVector& pOut, dgVector& qOut) -{ - dgFloat32 sN; - dgFloat32 tN; - - dgVector u (ray_p1 - ray_p0); - dgVector v (ray_q1 - ray_q0); - dgVector w (ray_p0 - ray_q0); - dgAssert (u.m_w == dgFloat32 (0.0f)); - dgAssert (v.m_w == dgFloat32 (0.0f)); - dgAssert (w.m_w == dgFloat32 (0.0f)); - - dgFloat32 a = u.DotProduct(u).GetScalar(); - dgFloat32 b = u.DotProduct(v).GetScalar(); - dgFloat32 c = v.DotProduct(v).GetScalar(); - dgFloat32 d = u.DotProduct(w).GetScalar(); - dgFloat32 e = v.DotProduct(w).GetScalar(); - dgFloat32 D = a*c - b*b; - dgFloat32 sD = D; - dgFloat32 tD = D; - - // compute the line parameters of the two closest points - if (D < dgFloat32 (1.0e-8f)) { - sN = dgFloat32 (0.0f); - sD = dgFloat32 (1.0f); - tN = e; - tD = c; - } else { - // get the closest points on the infinite lines - sN = (b*e - c*d); - tN = (a*e - b*d); - if (sN < dgFloat32 (0.0f)) { - // sc < 0 => the s=0 edge is visible - sN = dgFloat32 (0.0f); - tN = e; - tD = c; - } else if (sN > sD) { - // sc > 1 => the s=1 edge is visible - sN = sD; - tN = e + b; - tD = c; - } - } - - - if (tN < dgFloat32 (0.0f)) { - // tc < 0 => the t=0 edge is visible - tN = dgFloat32 (0.0f); - // recompute sc for this edge - if (-d < dgFloat32 (0.0f)) { - sN = dgFloat32 (0.0f); - } else if (-d > a) { - sN = sD; - } else { - sN = -d; - sD = a; - } - } else if (tN > tD) { - // tc > 1 => the t=1 edge is visible - tN = tD; - // recompute sc for this edge - if ((-d + b) < dgFloat32 (0.0f)) { - sN = dgFloat32 (0.0f); - } else if ((-d + b) > a) { - sN = sD; - } else { - sN = (-d + b); - sD = a; - } - } - - // finally do the division to get sc and tc - dgFloat32 sc = (dgAbs(sN) < dgFloat32(1.0e-8f) ? dgFloat32 (0.0f) : sN / sD); - dgFloat32 tc = (dgAbs(tN) < dgFloat32(1.0e-8f) ? dgFloat32 (0.0f) : tN / tD); - - dgAssert (u.m_w == dgFloat32 (0.0f)); - dgAssert (v.m_w == dgFloat32 (0.0f)); - pOut = ray_p0 + u.Scale (sc); - qOut = ray_q0 + v.Scale (tc); -} - - -dgFloat32 dgRayCastSphere (const dgVector& p0, const dgVector& p1, const dgVector& origin, dgFloat32 radius) -{ - dgVector p0Origin (p0 - origin); - dgAssert (p0Origin.m_w == dgFloat32 (0.0f)); - if (p0Origin.DotProduct(p0Origin).GetScalar() < (dgFloat32 (100.0f) * radius * radius)) { - dgVector dp (p1 - p0); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - dgFloat32 a = dp.DotProduct(dp).GetScalar(); - dgFloat32 b = dgFloat32 (2.0f) * p0Origin.DotProduct(dp).GetScalar(); - dgFloat32 c = p0Origin.DotProduct(p0Origin).GetScalar() - radius * radius; - dgFloat32 desc = b * b - dgFloat32 (4.0f) * a * c; - if (desc >= 0.0f) { - desc = dgSqrt (desc); - dgFloat32 den = dgFloat32 (0.5f) / a; - dgFloat32 t0 = (-b + desc) * den; - dgFloat32 t1 = (-b - desc) * den; - if ((t0 >= dgFloat32 (0.0f)) && (t1 >= dgFloat32 (0.0f))) { - t0 = dgMin(t0, t1); - if (t0 <= dgFloat32 (1.0f)) { - return t0; - } - } else if (t0 >= dgFloat32 (0.0f)) { - if (t0 <= dgFloat32 (1.0f)) { - return t0; - } - } else { - if ((t1 >= dgFloat32 (0.0f)) && (t1 <= dgFloat32 (1.0f))) { - return t1; - } - } - } - } else { - dgBigVector p0Origin1 (p0Origin); - dgBigVector dp (p1 - p0); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - dgFloat64 a = dp.DotProduct(dp).GetScalar(); - dgFloat64 b = dgFloat32 (2.0f) * p0Origin1.DotProduct(dp).GetScalar(); - dgFloat64 c = p0Origin1.DotProduct(p0Origin1).GetScalar() - dgFloat64(radius) * radius; - dgFloat64 desc = b * b - dgFloat32 (4.0f) * a * c; - if (desc >= 0.0f) { - desc = sqrt (desc); - dgFloat64 den = dgFloat32 (0.5f) / a; - dgFloat64 t0 = (-b + desc) * den; - dgFloat64 t1 = (-b - desc) * den; - if ((t0 >= dgFloat32 (0.0f)) && (t1 >= dgFloat32 (0.0f))) { - t0 = dgMin(t0, t1); - if (t0 <= dgFloat32 (1.0f)) { - return dgFloat32 (t0); - } - } else if (t0 >= dgFloat32 (0.0f)) { - if (t0 <= dgFloat32 (1.0f)) { - return dgFloat32 (t0); - } - } else { - if ((t1 >= dgFloat32 (0.0f)) && (t1 <= dgFloat32 (1.0f))) { - return dgFloat32 (t1); - } - } - } - } - return dgFloat32 (1.2f); -} - -dgFloat32 dgRayCastBox (const dgVector& p0, const dgVector& p1, const dgVector& boxP0, const dgVector& boxP1, dgVector& normalOut) -{ - dgInt32 index = 0; - dgFloat32 signDir = dgFloat32 (0.0f); - dgFloat32 tmin = dgFloat32 (0.0f); - dgFloat32 tmax = dgFloat32 (1.0f); - - //dgVector size (boxP1 - boxP0); - for (dgInt32 i = 0; i < 3; i++) { - dgFloat32 dp = p1[i] - p0[i]; - if (dgAbs (dp) < dgFloat32 (1.0e-8f)) { - if (p0[i] <= boxP0[i] || p0[i] >= boxP1[i]) { - return dgFloat32 (1.2f); - } - } else { - dp = dgFloat32 (1.0f) / dp; - dgFloat32 t1 = (boxP0[i] - p0[i]) * dp; - dgFloat32 t2 = (boxP1[i] - p0[i]) * dp; - - dgFloat32 sign = dgFloat32 (-1.0f); - if (t1 > t2) { - sign = 1; - dgSwap(t1, t2); - } - if (t1 > tmin) { - signDir = sign; - index = i; - tmin = t1; - } - if (t2 < tmax) { - tmax = t2; - } - if (tmin > tmax) { - return dgFloat32 (1.2f); - } - } - } - - if (tmin > dgFloat32 (0.0f)) { - dgAssert (tmin < 1.0f); - normalOut = dgVector (dgFloat32 (0.0f)); - normalOut[index] = signDir; - } else { - tmin = dgFloat32 (1.2f); - } - return tmin; - -} - diff --git a/thirdparty/src/newton/dgCore/dgIntersections.h b/thirdparty/src/newton/dgCore/dgIntersections.h deleted file mode 100644 index 1e2d5af59..000000000 --- a/thirdparty/src/newton/dgCore/dgIntersections.h +++ /dev/null @@ -1,393 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgIntersections__ -#define __dgIntersections__ - -#include "dgStdafx.h" -#include "dgObb.h" -#include "dgDebug.h" -#include "dgVector.h" -#include "dgMatrix.h" - -class dgPlane; -class dgObject; -class dgPolyhedra; - -enum dgIntersectStatus -{ - t_StopSearh, - t_ContinueSearh -}; - -typedef dgIntersectStatus (*dgAABBIntersectCallback) (void* const context, - const dgFloat32* const polygon, dgInt32 strideInBytes, - const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance); - -typedef dgFloat32 (*dgRayIntersectCallback) (void* const context, - const dgFloat32* const polygon, dgInt32 strideInBytes, - const dgInt32* const indexArray, dgInt32 indexCount); - -dgBigVector dgPointToRayDistance (const dgBigVector& point, const dgBigVector& ray_p0, const dgBigVector& ray_p1); -dgBigVector dgPointToTriangleDistance (const dgBigVector& point, const dgBigVector& p0, const dgBigVector& p1, const dgBigVector& p2); -dgBigVector dgPointToTetrahedrumDistance (const dgBigVector& point, const dgBigVector& p0, const dgBigVector& p1, const dgBigVector& p2, const dgBigVector& p3); - -bool dgRayBoxClip (dgVector& ray_p0, dgVector& ray_p1, const dgVector& boxP0, const dgVector& boxP1); -void dgRayToRayDistance (const dgVector& ray_p0, const dgVector& ray_p1, const dgVector& ray_q0, const dgVector& ray_q1, dgVector& p0Out, dgVector& p1Out); -dgFloat32 dgRayCastBox (const dgVector& p0, const dgVector& p1, const dgVector& boxP0, const dgVector& boxP1, dgVector& normalOut); -dgFloat32 dgRayCastSphere (const dgVector& p0, const dgVector& p1, const dgVector& origin, dgFloat32 radius); - - -DG_INLINE dgInt32 dgOverlapTest (const dgVector& p0, const dgVector& p1, const dgVector& q0, const dgVector& q1) -{ - dgVector val((p0 - q1) * (p1 - q0)); - dgInt32 mask = val.GetSignMask(); - return ((mask & 0x07) == 0x07); -} - -DG_INLINE dgInt32 dgBoxInclusionTest (const dgVector& p0, const dgVector& p1, const dgVector& q0, const dgVector& q1) -{ - dgVector val (dgVector::m_negOne & ((p0 >= q0) & (p1 <= q1))); - dgInt32 mask = val.GetSignMask(); - return ((mask & 0x07) == 0x07); -} - -DG_INLINE dgInt32 dgCompareBox (const dgVector& p0, const dgVector& p1, const dgVector& q0, const dgVector& q1) -{ - dgAssert(0); - return (p0.m_x != q0.m_x) || (p0.m_y != q0.m_y) || (p0.m_z != q0.m_z) || (p1.m_x != q1.m_x) || (p1.m_y != q1.m_y) || (p1.m_z != q1.m_z); -} - -DG_INLINE void dgMovingAABB (dgVector& p0, dgVector& p1, const dgVector& veloc, const dgVector& omega, dgFloat32 timestep, dgFloat32 maxRadius, dgFloat32 minRadius) -{ - dgVector linearStep (veloc.Scale (timestep)); - - // estimate the maximum effect of the angular velocity and enlarge that box by that value (use 45 degrees as max angle not 90) - dgAssert (omega.m_w == dgFloat32 (0.0f)); - dgFloat32 maxAngle = dgMin (dgSqrt (omega.DotProduct(omega).GetScalar() * timestep * timestep), dgFloat32 (45.0f * dgDegreeToRad)); - - dgFloat32 angularTravel = (maxRadius - minRadius) * maxAngle; - dgVector angularStep (angularTravel, angularTravel, angularTravel, dgFloat32 (0.0f)); - - dgVector r0 (p0 - angularStep); - dgVector r1 (p1 + angularStep); - dgVector q0 (r0 + linearStep); - dgVector q1 (r1 + linearStep); - p0 = r0.GetMin (q0) & dgVector::m_triplexMask; - p1 = r1.GetMax (q1) & dgVector::m_triplexMask; -} - -DG_INLINE dgFloat32 BoxPenetration (const dgVector& minBox, const dgVector& maxBox) -{ - dgAssert(maxBox.m_x >= minBox.m_x); - dgAssert(maxBox.m_y >= minBox.m_y); - dgAssert(maxBox.m_z >= minBox.m_z); - - dgVector mask ((minBox * maxBox) < dgVector::m_zero); - dgVector dist (maxBox.GetMin (minBox.Abs()) & mask); - dist = dist.GetMin(dist.ShiftTripleRight()); - dist = dist.GetMin(dist.ShiftTripleRight()); - return dist.GetScalar(); -} - -DG_INLINE dgFloat32 dgBoxDistanceToOrigin2 (const dgVector& minBox, const dgVector& maxBox) -{ - dgAssert(maxBox.m_x >= minBox.m_x); - dgAssert(maxBox.m_y >= minBox.m_y); - dgAssert(maxBox.m_z >= minBox.m_z); - dgVector mask ((minBox * maxBox) > dgVector::m_zero); - dgVector dist (maxBox.Abs().GetMin (minBox.Abs()) & mask); - return dist.DotProduct(dist).GetScalar(); -} - -DG_MSC_VECTOR_ALIGNMENT -class dgFastRayTest -{ - public: - DG_INLINE dgFastRayTest(const dgVector& l0, const dgVector& l1) - :m_p0(l0) - ,m_p1(l1) - ,m_diff((l1 - l0) & dgVector::m_triplexMask) - ,m_minT(dgFloat32(0.0f)) - ,m_maxT(dgFloat32(1.0f)) - { - dgAssert(m_p0.m_w == dgFloat32(0.0f)); - dgAssert(m_p1.m_w == dgFloat32(0.0f)); - dgAssert(m_diff.m_w == dgFloat32(0.0f)); - - dgAssert (m_diff.DotProduct(m_diff).GetScalar() > dgFloat32 (0.0f)); - m_isParallel = (m_diff.Abs() < dgVector(1.0e-8f)); - //m_dpInv = (((dgVector(dgFloat32(1.0e-20)) & m_isParallel) | m_diff.AndNot(m_isParallel)).Reciproc()) & dgVector::m_triplexMask; - m_dpInv = m_diff.Select (dgVector(dgFloat32(1.0e-20f)), m_isParallel).Reciproc() & dgVector::m_triplexMask; - m_unitDir = m_diff.Normalize(); - } - - dgFloat32 PolygonIntersect(const dgVector& normal, dgFloat32 maxT, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount) const; - - DG_INLINE dgInt32 BoxTest(const dgVector& minBox, const dgVector& maxBox) const - { -#if 1 - dgVector test(((m_p0 <= minBox) | (m_p0 >= maxBox)) & m_isParallel); - if (test.GetSignMask() & 0x07) { - return 0; - } - - dgVector tt0(m_dpInv * (minBox - m_p0)); - dgVector tt1(m_dpInv * (maxBox - m_p0)); - - dgVector t0(m_minT.GetMax(tt0.GetMin(tt1))); - dgVector t1(m_maxT.GetMin(tt0.GetMax(tt1))); - t0 = t0.GetMax(t0.ShiftTripleRight()); - t1 = t1.GetMin(t1.ShiftTripleRight()); - t0 = t0.GetMax(t0.ShiftTripleRight()); - t1 = t1.GetMin(t1.ShiftTripleRight()); - return ((t0 < t1).GetSignMask() & 1); - -#else - - dgFloat32 tmin = 0.0f; - dgFloat32 tmax = 1.0f; - - for (dgInt32 i = 0; i < 3; i++) { - if (m_isParallel[i]) { - if (m_p0[i] <= minBox[i] || m_p0[i] >= maxBox[i]) { - return 0; - } - } else { - dgFloat32 t1 = (minBox[i] - m_p0[i]) * m_dpInv[i]; - dgFloat32 t2 = (maxBox[i] - m_p0[i]) * m_dpInv[i]; - - if (t1 > t2) { - dgSwap(t1, t2); - } - if (t1 > tmin) { - tmin = t1; - } - if (t2 < tmax) { - tmax = t2; - } - if (tmin > tmax) { - return 0; - } - } - } - return 0x1; -#endif - } - - DG_INLINE dgFloat32 BoxIntersect(const dgVector& minBox, const dgVector& maxBox) const - { - dgVector test(((m_p0 <= minBox) | (m_p0 >= maxBox)) & m_isParallel); - if (test.GetSignMask() & 0x07) { - return dgFloat32(1.2f); - } - dgVector tt0(m_dpInv * (minBox - m_p0)); - dgVector tt1(m_dpInv * (maxBox - m_p0)); - dgVector t0(m_minT.GetMax(tt0.GetMin(tt1))); - dgVector t1(m_maxT.GetMin(tt0.GetMax(tt1))); - t0 = t0.GetMax(t0.ShiftTripleRight()); - t1 = t1.GetMin(t1.ShiftTripleRight()); - t0 = t0.GetMax(t0.ShiftTripleRight()); - t1 = t1.GetMin(t1.ShiftTripleRight()); - dgVector mask(t0 < t1); - dgVector maxDist(dgFloat32(1.2f)); - //t0 = (t0 & mask) | maxDist.AndNot(mask); - t0 = maxDist.Select(t0, mask); - dgAssert((mask.GetSignMask() & 1) == (t0.m_x < dgFloat32(1.0f))); - return t0.GetScalar(); - } - - dgVector m_p0; - dgVector m_p1; - dgVector m_diff; - dgVector m_dpInv; - dgVector m_minT; - dgVector m_maxT; - dgVector m_unitDir; - dgVector m_isParallel; -} DG_GCC_VECTOR_ALIGNMENT; - - -DG_MSC_VECTOR_ALIGNMENT -class dgFastAABBInfo: public dgObb -{ - public: - DG_INLINE dgFastAABBInfo() - :dgObb() - ,m_absDir(dgGetIdentityMatrix()) - ,m_separationDistance(dgFloat32(1.0e10f)) - { - } - - DG_INLINE dgFastAABBInfo(const dgMatrix& matrix, const dgVector& size) - :dgObb(matrix, size) - ,m_separationDistance(dgFloat32(1.0e10f)) - { - SetTransposeAbsMatrix (matrix); - dgVector size1 (matrix[0].Abs().Scale(size.m_x) + matrix[1].Abs().Scale(size.m_y) + matrix[2].Abs().Scale(size.m_z)); - m_p0 = (matrix[3] - size1) & dgVector::m_triplexMask; - m_p1 = (matrix[3] + size1) & dgVector::m_triplexMask; - } - - DG_INLINE dgFastAABBInfo(const dgVector& p0, const dgVector& p1) - :dgObb(dgGetIdentityMatrix(), dgVector::m_half * (p1 - p0)) - ,m_absDir(dgGetIdentityMatrix()) - ,m_separationDistance(dgFloat32(1.0e10f)) - ,m_p0(p0) - ,m_p1(p1) - { - m_posit = ((dgVector::m_half * (p1 + p0)) & dgVector::m_triplexMask) | dgVector::m_wOne; - } - - DG_INLINE void SetTransposeAbsMatrix (const dgMatrix& matrix) - { - m_absDir = matrix.Transpose(); - m_absDir[0] = m_absDir[0].Abs(); - m_absDir[1] = m_absDir[1].Abs(); - m_absDir[2] = m_absDir[2].Abs(); - //m_absDir[3] = dgVector::m_wOne; - } - - DG_INLINE dgFloat32 PolygonBoxRayDistance (const dgVector& faceNormal, dgInt32 indexCount, const dgInt32* const indexArray, dgInt32 stride, const dgFloat32* const vertexArray, const dgFastRayTest& ray) const - { - dgVector minBox; - dgVector maxBox; - MakeBox1 (indexCount, indexArray, stride, vertexArray, minBox, maxBox); - dgFloat32 dist0 = ray.BoxIntersect(minBox, maxBox); - if (dist0 < dgFloat32 (1.0f)) { - dgMatrix faceMatrix (MakeFaceMatrix (faceNormal, indexCount, indexArray, stride, vertexArray)); - - MakeBox2 (faceMatrix, indexCount, indexArray, stride, vertexArray, minBox, maxBox); - dgVector veloc (faceMatrix.RotateVector(ray.m_diff) & dgVector::m_triplexMask); - dgFastRayTest localRay (dgVector (dgFloat32 (0.0f)), veloc); - dgFloat32 dist1 = localRay.BoxIntersect(minBox, maxBox); - dist0 = dgMax (dist1, dist0); - } - return dist0; - } - - - DG_INLINE dgFloat32 PolygonBoxDistance (const dgVector& faceNormal, dgInt32 indexCount, const dgInt32* const indexArray, dgInt32 stride, const dgFloat32* const vertexArray) const - { - dgVector minBox; - dgVector maxBox; - MakeBox1 (indexCount, indexArray, stride, vertexArray, minBox, maxBox); - dgVector mask(minBox * maxBox < dgVector(dgFloat32(0.0f))); - dgVector dist(maxBox.GetMin(minBox.Abs()) & mask); - dist = dist.GetMin(dist.ShiftTripleRight()); - dist = dist.GetMin(dist.ShiftTripleRight()); - dgFloat32 dist0 = dist.GetScalar(); - if (dist0 > dgFloat32 (0.0f)) { - dgMatrix faceMatrix (MakeFaceMatrix (faceNormal, indexCount, indexArray, stride, vertexArray)); - MakeBox2 (faceMatrix, indexCount, indexArray, stride, vertexArray, minBox, maxBox); - dgVector mask2(minBox * maxBox < dgVector(dgFloat32(0.0f))); - dgVector dist2(maxBox.GetMin(minBox.Abs()) & mask2); - dist2 = dist2.GetMin(dist2.ShiftTripleRight()); - dist2 = dist2.GetMin(dist2.ShiftTripleRight()); - dgFloat32 dist1 = dist2.GetScalar(); - dist0 = (dist1 > dgFloat32 (0.0f)) ? dgMax (dist0, dist1) : dgFloat32 (0.0f); - if (dist0 <= dgFloat32(0.0f)) { - dgVector p1p0((minBox.Abs()).GetMin(maxBox.Abs()).AndNot(mask2)); - dist2 = p1p0.DotProduct(p1p0); - dist2 = dist2.Sqrt() * dgVector::m_negOne; - dist0 = dist2.GetScalar(); - } - } else { - dgVector p1p0((minBox.Abs()).GetMin(maxBox.Abs()).AndNot(mask)); - dist = p1p0.DotProduct(p1p0); - dist = dist.Sqrt() * dgVector::m_negOne; - dist0 = dist.GetScalar(); - } - return dist0; - } - - private: - DG_INLINE void MakeBox1 (dgInt32 indexCount, const dgInt32* const indexArray, dgInt32 stride, const dgFloat32* const vertexArray, dgVector& minBox, dgVector& maxBox) const - { - dgVector faceBoxP0 (&vertexArray[indexArray[0] * stride]); - faceBoxP0 = faceBoxP0 & dgVector::m_triplexMask; - dgVector faceBoxP1 (faceBoxP0); - for (dgInt32 i = 1; i < indexCount; i ++) { - dgVector p (&vertexArray[indexArray[i] * stride]); - p = p & dgVector::m_triplexMask; - faceBoxP0 = faceBoxP0.GetMin(p); - faceBoxP1 = faceBoxP1.GetMax(p); - } - - minBox = faceBoxP0 - m_p1; - maxBox = faceBoxP1 - m_p0; - } - - DG_INLINE void MakeBox2 (const dgMatrix& faceMatrix, dgInt32 indexCount, const dgInt32* const indexArray, dgInt32 stride, const dgFloat32* const vertexArray, dgVector& minBox, dgVector& maxBox) const - { - dgVector faceBoxP0 (faceMatrix.TransformVector (dgVector (&vertexArray[indexArray[0] * stride]) & dgVector::m_triplexMask)); - dgVector faceBoxP1 (faceBoxP0); - for (dgInt32 i = 1; i < indexCount; i ++) { - dgVector p (faceMatrix.TransformVector (dgVector (&vertexArray[indexArray[i] * stride]) & dgVector::m_triplexMask)); - faceBoxP0 = faceBoxP0.GetMin(p); - faceBoxP1 = faceBoxP1.GetMax(p); - } - faceBoxP0 = faceBoxP0 & dgVector::m_triplexMask; - faceBoxP1 = faceBoxP1 & dgVector::m_triplexMask; - - dgMatrix matrix = *this * faceMatrix; - dgVector size (matrix[0].Abs().Scale(m_size.m_x) + matrix[1].Abs().Scale(m_size.m_y) + matrix[2].Abs().Scale(m_size.m_z)); - dgVector boxP0 ((matrix.m_posit - size) & dgVector::m_triplexMask); - dgVector boxP1 ((matrix.m_posit + size) & dgVector::m_triplexMask); - - minBox = faceBoxP0 - boxP1; - maxBox = faceBoxP1 - boxP0; - } - - - DG_INLINE dgMatrix MakeFaceMatrix (const dgVector& faceNormal, dgInt32 indexCount, const dgInt32* const indexArray, dgInt32 stride, const dgFloat32* const vertexArray) const - { - dgMatrix faceMatrix; - dgVector origin (&vertexArray[indexArray[0] * stride]); - dgVector pin (&vertexArray[indexArray[0] * stride]); - pin = pin & dgVector::m_triplexMask; - origin = origin & dgVector::m_triplexMask; - - dgVector pin1 (&vertexArray[indexArray[1] * stride]); - pin1 = pin1 & dgVector::m_triplexMask; - - faceMatrix[0] = faceNormal; - faceMatrix[1] = pin1 - origin; - faceMatrix[1] = faceMatrix[1].Normalize(); - faceMatrix[2] = faceMatrix[0].CrossProduct(faceMatrix[1]); - faceMatrix[3] = origin | dgVector::m_wOne; - return faceMatrix.Inverse(); - } - - protected: - dgMatrix m_absDir; - mutable dgVector m_separationDistance; - dgVector m_p0; - dgVector m_p1; - - friend class dgAABBPolygonSoup; - friend class dgCollisionUserMesh; - friend class dgCollisionHeightField; -} DG_GCC_VECTOR_ALIGNMENT; - - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgList.h b/thirdparty/src/newton/dgCore/dgList.h deleted file mode 100644 index 137efc321..000000000 --- a/thirdparty/src/newton/dgCore/dgList.h +++ /dev/null @@ -1,701 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgList__ -#define __dgList__ - -#include "dgStdafx.h" -#include "dgRef.h" -#include "dgDebug.h" -#include "dgMemory.h" - - - -template<class T> -class dgList -{ - public: - class dgListNode - { - DG_CLASS_ALLOCATOR(allocator) - - dgListNode (dgListNode* const prev, dgListNode* const next) - :m_info () - { - m_prev = prev; - m_next = next; - if (m_prev) { - m_prev->m_next = this; - } - if (m_next) { - m_next->m_prev = this; - } - } - - dgListNode (const T &info, dgListNode* const prev, dgListNode* const next) - :m_info (info) - { - m_prev = prev; - m_next = next; - if (m_prev) { - m_prev->m_next = this; - } - if (m_next) { - m_next->m_prev = this; - } - } - - virtual ~dgListNode() - { - } - - void Unlink () - { - if (m_prev) { - m_prev->m_next = m_next; - } - - if (m_next) { - m_next->m_prev = m_prev; - } - m_prev = NULL; - m_next = NULL; - } - - void AddLast(dgListNode* const node) - { - m_next = node; - node->m_prev = this; - } - - void AddFirst(dgListNode* const node) - { - m_prev = node; - node->m_next = this; - } - - public: - T& GetInfo() - { - return m_info; - } - - dgListNode *GetNext() const - { - return m_next; - } - - dgListNode *GetPrev() const - { - return m_prev; - } - - private: - T m_info; - dgListNode *m_next; - dgListNode *m_prev; - friend class dgList<T>; - - }; - - class Iterator - { - public: - Iterator (const dgList<T> &me) - { - m_ptr = NULL; - m_list = (dgList *)&me; - } - - ~Iterator () - { - } - - operator dgInt32() const - { - return m_ptr != NULL; - } - - bool operator== (const Iterator &target) const - { - return (m_ptr == target.m_ptr) && (m_list == target.m_list); - } - - void Begin() - { - m_ptr = m_list->GetFirst(); - } - - void End() - { - m_ptr = m_list->GetLast(); - } - - void Set (dgListNode* const node) - { - m_ptr = node; - } - - void operator++ () - { - dgAssert (m_ptr); - m_ptr = m_ptr->m_next(); - } - - void operator++ (dgInt32) - { - dgAssert (m_ptr); - m_ptr = m_ptr->GetNext(); - } - - void operator-- () - { - dgAssert (m_ptr); - m_ptr = m_ptr->GetPrev(); - } - - void operator-- (dgInt32) - { - dgAssert (m_ptr); - m_ptr = m_ptr->GetPrev(); - } - - T &operator* () const - { - return m_ptr->GetInfo(); - } - - dgListNode *GetNode() const - { - return m_ptr; - } - - private: - dgList *m_list; - dgListNode *m_ptr; - }; - - // *********************************************************** - // member functions - // *********************************************************** - public: - DG_CLASS_ALLOCATOR(allocator) - - dgList (dgMemoryAllocator* const allocator); - virtual ~dgList (); - - dgMemoryAllocator* GetAllocator () const; - void SetAllocator (dgMemoryAllocator* const allocator); - - operator dgInt32() const; - dgInt32 GetCount() const; - dgListNode* GetLast() const; - dgListNode* GetFirst() const; - dgListNode* Append (); - dgListNode* Append (dgListNode* const node); - dgListNode* Append (const T &element); - dgListNode* Addtop (); - dgListNode* Addtop (dgListNode* const node); - dgListNode* Addtop (const T &element); - - void RotateToEnd (dgListNode* const node); - void RotateToBegin (dgListNode* const node); - void InsertAfter (dgListNode* const root, dgListNode* const node); - void InsertBefore (dgListNode* const root, dgListNode* const node); - - - dgListNode* Find (const T &element) const; - dgListNode* GetNodeFromInfo (T &m_info) const; - void Remove (dgListNode* const node); - void Remove (const T &element); - void RemoveAll (); - - void Merge (dgList<T>& list); - void Unlink (dgListNode* const node); - bool SanityCheck () const; - - protected: -// dgListNode* SafeAddtop(const T &element); - - - // *********************************************************** - // member variables - // *********************************************************** - private: - dgInt32 m_count; - dgListNode* m_first; - dgListNode* m_last; - dgMemoryAllocator* m_allocator; - -// static dgInt32 m_size; -// static dgMemoryAllocator* m_staticAllocator; - friend class dgListNode; -}; - -/* -template<class T> -dgList<T>::dgList () -{ - m_count = 0; - m_first = NULL; - m_last = NULL; - m_allocator = NULL; -} -*/ - -template<class T> -dgList<T>::dgList (dgMemoryAllocator* const allocator) - :m_count(0) - ,m_first(NULL) - ,m_last(NULL) - ,m_allocator(allocator) -{ -} - - -template<class T> -dgList<T>::~dgList () -{ - RemoveAll (); -} - -template<class T> -void dgList<T>::SetAllocator (dgMemoryAllocator* const allocator) -{ - if ((m_count == 0) && (m_allocator == NULL)) { - m_allocator = allocator; - } -} - -template<class T> -dgMemoryAllocator* dgList<T>::GetAllocator () const -{ - return m_allocator; -} - - -template<class T> -dgInt32 dgList<T>::GetCount() const -{ - return m_count; -} - -template<class T> -dgList<T>::operator dgInt32() const -{ - return m_first != NULL; -} - -template<class T> -typename dgList<T>::dgListNode *dgList<T>::GetFirst() const -{ - return m_first; -} - -template<class T> -typename dgList<T>::dgListNode *dgList<T>::GetLast() const -{ - return m_last; -} - -template<class T> -typename dgList<T>::dgListNode *dgList<T>::Append (dgListNode* const node) -{ - dgAssert (node->m_next == NULL); - dgAssert (node->m_prev == NULL); - m_count ++; - if (m_first == NULL) { - m_last = node; - m_first = node; - } else { - m_last->AddLast (node); - m_last = node; - } -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif - return m_last; -} - -template<class T> -typename dgList<T>::dgListNode *dgList<T>::Append () -{ - m_count ++; - if (m_first == NULL) { - m_first = new (m_allocator) dgListNode(NULL, NULL); - m_last = m_first; - } else { - m_last = new (m_allocator) dgListNode(m_last, NULL); - } -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif - return m_last; -} - -template<class T> -typename dgList<T>::dgListNode *dgList<T>::Append (const T &element) -{ - m_count ++; - if (m_first == NULL) { - m_first = new (m_allocator) dgListNode(element, NULL, NULL); - m_last = m_first; - } else { - m_last = new (m_allocator) dgListNode(element, m_last, NULL); - } -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif - - return m_last; -} - - -template<class T> -typename dgList<T>::dgListNode *dgList<T>::Addtop (dgListNode* const node) -{ - dgAssert (node->m_next == NULL); - dgAssert (node->m_prev == NULL); - m_count ++; - if (m_last == NULL) { - m_last = node; - m_first = node; - } else { - m_first->AddFirst(node); - m_first = node; - } -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif - return m_first; -} - - -template<class T> -typename dgList<T>::dgListNode *dgList<T>::Addtop () -{ - m_count ++; - if (m_last == NULL) { - m_last = new (m_allocator) dgListNode(NULL, NULL); - m_first = m_last; - } else { - m_first = new (m_allocator) dgListNode(NULL, m_first); - } -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif - return m_first; -} - - -template<class T> -typename dgList<T>::dgListNode *dgList<T>::Addtop (const T &element) -{ - m_count ++; - if (m_last == NULL) { - m_last = new (m_allocator) dgListNode(element, NULL, NULL); - m_first = m_last; - } else { - m_first = new (m_allocator) dgListNode(element, NULL, m_first); - } -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif - return m_first; -} - -/* -template<class T> -typename dgList<T>::dgListNode *dgList<T>::SafeAddtop(const T& element) -{ - dgAssert (m_last); - m_count++; - - dgListNode* const node = new (m_allocator) dgListNode(element, NULL, NULL); - dgListNode* const first = (dgListNode*) dgInterlockedExchange ((void**) &m_first, (void*) node); - - node->m_next = first; - first->m_prev = node; - dgAssert (m_last); - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert(SanityCheck()); -#endif - return node; -} -*/ - -template<class T> -void dgList<T>::InsertAfter (dgListNode* const root, dgListNode* const node) -{ - dgAssert (root); - if (node != root) { - if (root->m_next != node) { - if (node == m_first) { - m_first = node->m_next; - } - if (node == m_last) { - m_last = node->m_prev; - } - node->Unlink (); - - node->m_prev = root; - node->m_next = root->m_next; - if (root->m_next) { - root->m_next->m_prev = node; - } - root->m_next = node; - - if (node->m_next == NULL) { - m_last = node; - } - - dgAssert (m_last); - dgAssert (!m_last->m_next); - dgAssert (m_first); - dgAssert (!m_first->m_prev); - dgAssert (SanityCheck ()); - } - } -} - -template<class T> -void dgList<T>::InsertBefore (dgListNode* const root, dgListNode* const node) -{ - dgAssert (root); - if (node != root) { - if (root->m_prev != node) { - if (node == m_last) { - m_last = node->m_prev; - } - if (node == m_first) { - m_first = node->m_next; - } - node->Unlink (); - - node->m_next = root; - node->m_prev = root->m_prev; - if (root->m_prev) { - root->m_prev->m_next = node; - } - root->m_prev = node; - - if (node->m_prev == NULL) { - m_first = node; - } - - dgAssert (m_first); - dgAssert (!m_first->m_prev); - dgAssert (m_last); - dgAssert (!m_last->m_next); - dgAssert (SanityCheck ()); - } - } -} - -template<class T> -void dgList<T>::RotateToEnd (dgListNode* const node) -{ - if (node != m_last) { - if (m_last != m_first) { - if (node == m_first) { - m_first = m_first->GetNext(); - } - node->Unlink(); - m_last->AddLast(node); - m_last = node; - } - } - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif -} - -template<class T> -void dgList<T>::RotateToBegin (dgListNode* const node) -{ - if (node != m_first) { - if (m_last != m_first) { - if (node == m_last) { - m_last = m_last->GetPrev(); - } - node->Unlink(); - m_first->AddFirst(node); - m_first = node; - } - } - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif -} - - -template<class T> -typename dgList<T>::dgListNode *dgList<T>::Find (const T &element) const -{ - dgListNode *node; - for (node = m_first; node; node = node->GetNext()) { - if (element == node->m_info) { - break; - } - } - return node; -} - -template<class T> -typename dgList<T>::dgListNode *dgList<T>::GetNodeFromInfo (T &info) const -{ - dgListNode* const node = (dgListNode *) &info; - dgInt64 offset = ((char*) &node->m_info) - ((char *) node); - dgListNode* const retnode = (dgListNode *) (((char *) node) - offset); - - dgAssert (&retnode->GetInfo () == &info); - return retnode; -} - - -template<class T> -void dgList<T>::Remove (const T &element) -{ - dgListNode *const node = Find (element); - if (node) { - Remove (node); - } -} - -template<class T> -void dgList<T>::Unlink (dgListNode* const node) -{ - dgAssert (node); - - m_count --; - dgAssert (m_count >= 0); - - if (node == m_first) { - m_first = m_first->GetNext(); - } - if (node == m_last) { - m_last = m_last->GetPrev(); - } - node->Unlink(); - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif -} - -template<class T> -void dgList<T>::Merge (dgList<T>& list) -{ - m_count += list.m_count; - if (list.m_first) { - list.m_first->m_prev = m_last; - } - if (m_last) { - m_last->m_next = list.m_first; - } - m_last = list.m_last; - if (!m_first) { - m_first = list.m_first; - } - - list.m_count = 0; - list.m_last = NULL; - list.m_first = NULL; -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif -} - - -template<class T> -void dgList<T>::Remove (dgListNode* const node) -{ - Unlink (node); - delete node; -} - - -template<class T> -void dgList<T>::RemoveAll () -{ - for (dgListNode *node = m_first; node; node = m_first) { - m_count --; - m_first = node->GetNext(); - node->Unlink(); - delete node; - } - dgAssert (m_count == 0); - m_last = NULL; - m_first = NULL; -} - -template<class T> -bool dgList<T>::SanityCheck () const -{ - #ifdef _DEBUG - dgInt32 tCount = 0; - for (dgListNode * node = m_first; node; node = node->GetNext()) { - tCount ++; - if (node->GetPrev()) { - dgAssert (node->GetPrev() != node->GetNext()); - if (node->GetPrev()->GetNext() != node) { - dgAssert (0); - return false; - } - } - if (node->GetNext()) { - dgAssert (node->GetPrev() != node->GetNext()); - if (node->GetNext()->GetPrev() != node) { - dgAssert (0); - return false; - } - } - } - if (tCount != m_count) { - dgAssert (0); - return false; - } - #endif - return true; -} - - -//template<class T> -//void dgList<T>::SetAllocator (dgMemoryAllocator * allocator) -//{ -// m_allocator = allocator; -//} - -//template<class T> -//dgMemoryAllocator* dgList<T>::GetAllocator () const -//{ -// return m_allocator; -//} -//template<class T> dgInt32 dgList <T>::m_size = 0; -//template<class T> dgMemoryAllocator* dgList<T>::m_staticAllocator = NULL; - - -#endif - - diff --git a/thirdparty/src/newton/dgCore/dgMatrix.cpp b/thirdparty/src/newton/dgCore/dgMatrix.cpp deleted file mode 100644 index 4f86fb2d1..000000000 --- a/thirdparty/src/newton/dgCore/dgMatrix.cpp +++ /dev/null @@ -1,778 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgMatrix.h" -#include "dgQuaternion.h" -#include "dgGeneralMatrix.h" - -#ifndef _NEWTON_USE_DOUBLE - - dgVector dgVector::m_xMask(dgInt32(-1), dgInt32(0), dgInt32(0), dgInt32(0)); - dgVector dgVector::m_yMask(dgInt32(0), dgInt32(-1), dgInt32(0), dgInt32(0)); - dgVector dgVector::m_zMask(dgInt32(0), dgInt32(0), dgInt32(-1), dgInt32(0)); - dgVector dgVector::m_wMask(dgInt32(0), dgInt32(0), dgInt32(0), dgInt32(-1)); - dgVector dgVector::m_triplexMask(dgInt32(-1), dgInt32(-1), dgInt32(-1), dgInt32(0)); - dgVector dgVector::m_signMask(dgVector(dgInt32(-1), dgInt32(-1), dgInt32(-1), dgInt32(-1)).ShiftRightLogical(1)); - - dgVector dgVector::m_zero(dgFloat32(0.0f)); - dgVector dgVector::m_one(dgFloat32(1.0f)); - dgVector dgVector::m_two(dgFloat32(2.0f)); - dgVector dgVector::m_half(dgFloat32(0.5f)); - dgVector dgVector::m_three(dgFloat32(3.0f)); - dgVector dgVector::m_negOne(dgFloat32(-1.0f)); - dgVector dgVector::m_epsilon(dgFloat32(1.0e-20f)); - dgVector dgVector::m_wOne(dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(1.0f)); -#endif - -dgBigVector dgBigVector::m_zero (dgFloat64 (0.0f)); -dgBigVector dgBigVector::m_one (dgFloat64 (1.0f)); -dgBigVector dgBigVector::m_two (dgFloat64 (2.0f)); -dgBigVector dgBigVector::m_half (dgFloat32 (0.5f)); -dgBigVector dgBigVector::m_three (dgFloat32 (3.0f)); -dgBigVector dgBigVector::m_negOne (dgFloat32 (-1.0f)); -dgBigVector dgBigVector::m_epsilon(dgFloat32(1.0e-20f)); -dgBigVector dgBigVector::m_wOne (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (1.0f)); -dgBigVector dgBigVector::m_triplexMask (dgInt32 (-1), dgInt32 (-1), dgInt32 (-1), dgInt32 (0)); -dgBigVector dgBigVector::m_signMask (dgBigVector(dgInt32 (-1), dgInt32 (-1), dgInt32 (-1), dgInt32 (-1)).ShiftRightLogical(1)); - -dgBigVector dgBigVector::m_xMask (dgInt32 (-1), dgInt32 ( 0), dgInt32 ( 0), dgInt32 ( 0)); -dgBigVector dgBigVector::m_yMask (dgInt32 ( 0), dgInt32 (-1), dgInt32 ( 0), dgInt32 ( 0)); -dgBigVector dgBigVector::m_zMask (dgInt32 ( 0), dgInt32 ( 0), dgInt32 (-1), dgInt32 ( 0)); -dgBigVector dgBigVector::m_wMask (dgInt32 ( 0), dgInt32 ( 0), dgInt32 ( 0), dgInt32 (-1)); - -dgSpatialVector dgSpatialVector::m_zero (dgFloat32 (0.0f)); - - -dgMatrix dgMatrix::m_zeroMatrix (dgVector (dgFloat32(0.0f)), - dgVector (dgFloat32(0.0f)), - dgVector (dgFloat32(0.0f)), - dgVector (dgFloat32(0.0f))); - -dgMatrix dgMatrix::m_identityMatrix (dgVector (dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)), - dgVector (dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f)), - dgVector (dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f)), - dgVector (dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(1.0f))); - - -#ifndef _NEWTON_USE_DOUBLE -#endif - -const dgMatrix& dgGetIdentityMatrix() -{ - return dgMatrix::m_identityMatrix; -} - -const dgMatrix& dgGetZeroMatrix () -{ - return dgMatrix::m_zeroMatrix; -} - - -dgMatrix::dgMatrix (const dgQuaternion &quat0, const dgVector &position) -{ - dgQuaternion quat1 (quat0); - quat1.Scale(dgFloat32 (2.0f)); - - dgFloat32 x2 = quat0.m_x * quat1.m_x; - dgFloat32 y2 = quat0.m_y * quat1.m_y; - dgFloat32 z2 = quat0.m_z * quat1.m_z; - -#ifdef _DEBUG - dgFloat32 w2 = quat0.m_w * quat1.m_w; - dgAssert (dgAbs (w2 + x2 + y2 + z2 - dgFloat32(2.0f)) <dgFloat32 (1.0e-3f)); -#endif - - dgFloat32 xy = quat0.m_x * quat1.m_y; - dgFloat32 xz = quat0.m_x * quat1.m_z; - dgFloat32 xw = quat0.m_x * quat1.m_w; - dgFloat32 yz = quat0.m_y * quat1.m_z; - dgFloat32 yw = quat0.m_y * quat1.m_w; - dgFloat32 zw = quat0.m_z * quat1.m_w; - - m_front = dgVector (dgFloat32(1.0f) - y2 - z2, xy + zw, xz - yw, dgFloat32(0.0f)); - m_up = dgVector (xy - zw, dgFloat32(1.0f) - x2 - z2, yz + xw, dgFloat32(0.0f)); - m_right = dgVector (xz + yw, yz - xw, dgFloat32(1.0f) - x2 - y2, dgFloat32(0.0f)); - - m_posit.m_x = position.m_x; - m_posit.m_y = position.m_y; - m_posit.m_z = position.m_z; - m_posit.m_w = dgFloat32(1.0f); -} - - -dgMatrix::dgMatrix (const dgMatrix& transformMatrix, const dgVector& scale, const dgMatrix& stretchAxis) -{ - dgMatrix scaledAxis; - scaledAxis[0] = stretchAxis[0].Scale (scale[0]); - scaledAxis[1] = stretchAxis[1].Scale (scale[1]); - scaledAxis[2] = stretchAxis[2].Scale (scale[2]); - scaledAxis[3] = stretchAxis[3]; - - *this = stretchAxis.Transpose() * scaledAxis * transformMatrix; -} - -dgMatrix dgMatrix::Multiply3X3 (const dgMatrix &B) const -{ - return dgMatrix (B.m_front * m_front.BroadcastX() + B.m_up * m_front.BroadcastY() + B.m_right * m_front.BroadcastZ(), - B.m_front * m_up.BroadcastX() + B.m_up * m_up.BroadcastY() + B.m_right * m_up.BroadcastZ(), - B.m_front * m_right.BroadcastX() + B.m_up * m_right.BroadcastY() + B.m_right * m_right.BroadcastZ(), - dgVector::m_wOne); -} - -dgMatrix dgMatrix::operator* (const dgMatrix &B) const -{ - return dgMatrix (B.m_front * m_front.BroadcastX() + B.m_up * m_front.BroadcastY() + B.m_right * m_front.BroadcastZ() + B.m_posit * m_front.BroadcastW(), - B.m_front * m_up.BroadcastX() + B.m_up * m_up.BroadcastY() + B.m_right * m_up.BroadcastZ() + B.m_posit * m_up.BroadcastW(), - B.m_front * m_right.BroadcastX() + B.m_up * m_right.BroadcastY() + B.m_right * m_right.BroadcastZ() + B.m_posit * m_right.BroadcastW(), - B.m_front * m_posit.BroadcastX() + B.m_up * m_posit.BroadcastY() + B.m_right * m_posit.BroadcastZ() + B.m_posit * m_posit.BroadcastW()); -} - -void dgMatrix::TransformTriplex (dgFloat32* const dst, dgInt32 dstStrideInBytes, const dgFloat32* const src, dgInt32 srcStrideInBytes, dgInt32 count) const -{ - dgInt32 dstStride = dgInt32 (dstStrideInBytes /sizeof (dgFloat32)); - dgInt32 srcStride = dgInt32 (srcStrideInBytes / sizeof (dgFloat32)); - - dgInt32 dstIndex = 0; - dgInt32 srcIndex = 0; - for (dgInt32 i = 0 ; i < count; i ++ ) { - dgFloat32 x = src[srcIndex + 0]; - dgFloat32 y = src[srcIndex + 1]; - dgFloat32 z = src[srcIndex + 2]; - srcIndex += srcStride; - dst[dstIndex + 0] = x * m_front.m_x + y * m_up.m_x + z * m_right.m_x + m_posit.m_x; - dst[dstIndex + 1] = x * m_front.m_y + y * m_up.m_y + z * m_right.m_y + m_posit.m_y; - dst[dstIndex + 2] = x * m_front.m_z + y * m_up.m_z + z * m_right.m_z + m_posit.m_z; - dstIndex += dstStride; - } -} - -#ifndef _NEWTON_USE_DOUBLE -void dgMatrix::TransformTriplex (dgFloat64* const dst, dgInt32 dstStrideInBytes, const dgFloat64* const src, dgInt32 srcStrideInBytes, dgInt32 count) const -{ - dgInt32 dstStride = dgInt32 (dstStrideInBytes /sizeof (dgFloat64)); - dgInt32 srcStride = dgInt32 (srcStrideInBytes / sizeof (dgFloat64)); - - dgInt32 dstIndex = 0; - dgInt32 srcIndex = 0; - for (dgInt32 i = 0 ; i < count; i ++ ) { - dgFloat64 x = src[srcIndex + 0]; - dgFloat64 y = src[srcIndex + 1]; - dgFloat64 z = src[srcIndex + 2]; - srcIndex += srcStride; - dst[dstIndex + 0] = x * m_front.m_x + y * m_up.m_x + z * m_right.m_x + m_posit.m_x; - dst[dstIndex + 1] = x * m_front.m_y + y * m_up.m_y + z * m_right.m_y + m_posit.m_y; - dst[dstIndex + 2] = x * m_front.m_z + y * m_up.m_z + z * m_right.m_z + m_posit.m_z; - dstIndex += dstStride; - } -} - -void dgMatrix::TransformTriplex (dgFloat64* const dst, dgInt32 dstStrideInBytes, const dgFloat32* const src, dgInt32 srcStrideInBytes, dgInt32 count) const -{ - dgInt32 dstStride = dgInt32 (dstStrideInBytes /sizeof (dgFloat64)); - dgInt32 srcStride = dgInt32 (srcStrideInBytes / sizeof (dgFloat32)); - - dgInt32 dstIndex = 0; - dgInt32 srcIndex = 0; - for (dgInt32 i = 0 ; i < count; i ++ ) { - dgFloat64 x = src[srcIndex + 0]; - dgFloat64 y = src[srcIndex + 1]; - dgFloat64 z = src[srcIndex + 2]; - srcIndex += srcStride; - dst[dstIndex + 0] = x * m_front.m_x + y * m_up.m_x + z * m_right.m_x + m_posit.m_x; - dst[dstIndex + 1] = x * m_front.m_y + y * m_up.m_y + z * m_right.m_y + m_posit.m_y; - dst[dstIndex + 2] = x * m_front.m_z + y * m_up.m_z + z * m_right.m_z + m_posit.m_z; - dstIndex += dstStride; - } -} -#endif - -void dgMatrix::TransformBBox (const dgVector& p0local, const dgVector& p1local, dgVector& p0, dgVector& p1) const -{ - const dgMatrix& matrix = *this; - //dgVector size ((p1local - p0local).Scale (dgFloat32 (0.5f))); - //dgVector center (TransformVector ((p1local + p0local).Scale (dgFloat32 (0.5f)))); - dgVector size ((p1local - p0local) * dgVector::m_half); - dgVector center (TransformVector ((p1local + p0local) * dgVector::m_half)); - dgVector extends (size.m_x * dgAbs(matrix[0][0]) + size.m_y * dgAbs(matrix[1][0]) + size.m_z * dgAbs(matrix[2][0]), - size.m_x * dgAbs(matrix[0][1]) + size.m_y * dgAbs(matrix[1][1]) + size.m_z * dgAbs(matrix[2][1]), - size.m_x * dgAbs(matrix[0][2]) + size.m_y * dgAbs(matrix[1][2]) + size.m_z * dgAbs(matrix[2][2]), dgFloat32 (0.0f)); - - p0 = center - extends; - p1 = center + extends; -} - -dgMatrix dgMatrix::Inverse4x4 () const -{ - dgMatrix tmp (*this); - dgMatrix inv (dgGetIdentityMatrix()); - for (dgInt32 i = 0; i < 4; i++) { - dgFloat32 pivot = dgAbs(tmp[i][i]); - if (pivot < dgFloat32(0.01f)) { - dgInt32 permute = i; - for (dgInt32 j = i + 1; j < 4; j++) { - dgFloat32 pivot1 = dgAbs(tmp[j][i]); - if (pivot1 > pivot) { - permute = j; - pivot = pivot1; - } - } - if (permute != i) { - dgAssert(pivot > dgFloat32(0.0f)); - dgAssert((pivot > dgFloat32(1.0e-6f)) || (dgConditionNumber(4, 4, (dgFloat32*)&(*this)[0][0]) < dgFloat32(1.0e5f))); - dgSwap(inv[i], inv[permute]); - dgSwap(tmp[i], tmp[permute]); - } - } - - for (dgInt32 j = i + 1; j < 4; j++) { - dgVector scale (tmp[j][i] / tmp[i][i]); - tmp[j] -= tmp[i] * scale; - inv[j] -= inv[i] * scale; - tmp[j][i] = dgFloat32 (0.0f); - } - } - - for (dgInt32 i = 3; i >= 0; i--) { - dgVector acc(dgVector::m_zero); - for (dgInt32 j = i + 1; j < 4; j++) { - dgVector pivot(tmp[i][j]); - acc += pivot * inv[j]; - } - dgVector den(dgFloat32(1.0f) / tmp[i][i]); - inv[i] = den * (inv[i] - acc); - } - -#ifdef _DEBUG - tmp = *this * inv; - for (dgInt32 i = 0; i < 4; i++) { - dgAssert(dgAbs(tmp[i][i] - dgFloat32(1.0f)) < dgFloat32(1.0e-6f)); - for (dgInt32 j = i + 1; j < 4; j++) { - dgAssert(dgAbs(tmp[i][j]) < dgFloat32(1.0e-5f)); - dgAssert(dgAbs(tmp[j][i]) < dgFloat32(1.0e-5f)); - } - } -#endif - - return inv; -} - -dgVector dgMatrix::SolveByGaussianElimination(const dgVector &v) const -{ -// return Inverse4x4().UnrotateVector(v); - dgMatrix tmp(*this); - dgVector ret(v); - for (dgInt32 i = 0; i < 4; i++) { - dgFloat32 pivot = dgAbs(tmp[i][i]); - if (pivot < dgFloat32(0.01f)) { - dgInt32 permute = i; - for (dgInt32 j = i + 1; j < 4; j++) { - dgFloat32 pivot1 = dgAbs(tmp[j][i]); - if (pivot1 > pivot) { - permute = j; - pivot = pivot1; - } - } - - if (permute != i) { - dgAssert(pivot > dgFloat32(1.0e-6f)); - dgSwap(ret[i], ret[permute]); - dgSwap(tmp[i], tmp[permute]); - } - } - - for (dgInt32 j = i + 1; j < 4; j++) { - dgVector scale(tmp[j][i] / tmp[i][i]); - tmp[j] -= tmp[i] * scale; - ret[j] -= ret[i] * scale.GetScalar(); - tmp[j][i] = dgFloat32(0.0f); - } - } - - for (dgInt32 i = 3; i >= 0; i--) { - dgVector pivot(tmp[i] * ret); - ret[i] = (ret[i] - pivot.AddHorizontal().GetScalar() + tmp[i][i] * ret[i]) / tmp[i][i]; - } - - return ret; -} - -void dgMatrix::CalcPitchYawRoll (dgVector& euler0, dgVector& euler1) const -{ - const dgMatrix& matrix = *this; - dgAssert (matrix[2].DotProduct(matrix[0].CrossProduct(matrix[1])).GetScalar() > 0.0f); - dgAssert (dgAbs (matrix[2].DotProduct(matrix[0].CrossProduct(matrix[1])).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-4f)); -/* - // Assuming the angles are in radians. - if (matrix[0][2] > dgFloat32 (0.99995f)) { - dgFloat32 picth0 = dgFloat32 (0.0f); - dgFloat32 yaw0 = dgFloat32 (-dgPI * 0.5f); - dgFloat32 roll0 = - dgAtan2(matrix[2][1], matrix[1][1]); - euler0[0] = picth0; - euler0[1] = yaw0; - euler0[2] = roll0; - - euler1[0] = picth0; - euler1[1] = yaw0; - euler1[2] = roll0; - - } else if (matrix[0][2] < dgFloat32 (-0.99995f)) { - dgFloat32 picth0 = dgFloat32 (0.0f); - dgFloat32 yaw0 = dgFloat32 (dgPI * 0.5f); - dgFloat32 roll0 = dgAtan2(matrix[2][1], matrix[1][1]); - euler0[0] = picth0; - euler0[1] = yaw0; - euler0[2] = roll0; - - euler1[0] = picth0; - euler1[1] = yaw0; - euler1[2] = roll0; - } else { - dgFloat32 yaw0 = -dgAsin ( matrix[0][2]); - dgFloat32 yaw1 = dgFloat32 (dgPI) - yaw0; - dgFloat32 sign0 = dgSign(dgCos (yaw0)); - dgFloat32 sign1 = dgSign(dgCos (yaw1)); - - dgFloat32 picth0 = dgAtan2(matrix[1][2] * sign0, matrix[2][2] * sign0); - dgFloat32 picth1 = dgAtan2(matrix[1][2] * sign1, matrix[2][2] * sign1); - - dgFloat32 roll0 = dgAtan2(matrix[0][1] * sign0, matrix[0][0] * sign0); - dgFloat32 roll1 = dgAtan2(matrix[0][1] * sign1, matrix[0][0] * sign1); - - if (yaw1 > dgFloat32 (dgPI)) { - yaw1 -= dgFloat32 (2.0f * dgPI); - } - - euler0[0] = picth0; - euler0[1] = yaw0; - euler0[2] = roll0; - - euler1[0] = picth1; - euler1[1] = yaw1; - euler1[2] = roll1; - } -*/ - - // Assuming the angles are in radians. - if (matrix[0][2] > dgFloat32 (0.99995f)) { - dgFloat32 picth0 = dgFloat32(0.0f); - dgFloat32 yaw0 = dgFloat32(-dgPi * 0.5f); - dgFloat32 roll0 = -dgAtan2(matrix[2][1], matrix[1][1]); - euler0[0] = picth0; - euler0[1] = yaw0; - euler0[2] = roll0; - - euler1[0] = picth0; - euler1[1] = yaw0; - euler1[2] = roll0; - - } else if (matrix[0][2] < dgFloat32 (-0.99995f)) { - dgFloat32 picth0 = dgFloat32 (0.0f); - dgFloat32 yaw0 = dgFloat32(dgPi * 0.5f); - dgFloat32 roll0 = dgAtan2(matrix[2][1], matrix[1][1]); - euler0[0] = picth0; - euler0[1] = yaw0; - euler0[2] = roll0; - - euler1[0] = picth0; - euler1[1] = yaw0; - euler1[2] = roll0; - - } else { - dgFloat32 yaw0 = -dgAsin(matrix[0][2]); - dgFloat32 yaw1 = dgFloat32(dgPi) - yaw0; - - dgFloat32 picth0 = dgAtan2( matrix[1][2], matrix[2][2]); - dgFloat32 picth1 = dgAtan2(-matrix[1][2], -matrix[2][2]); - - dgFloat32 roll0 = dgAtan2( matrix[0][1], matrix[0][0]); - dgFloat32 roll1 = dgAtan2(-matrix[0][1], -matrix[0][0]); - - if (yaw1 > dgFloat32 (dgPi)) { - yaw1 -= dgFloat32 (2.0f * dgPi); - } - - euler0[0] = picth0; - euler0[1] = yaw0; - euler0[2] = roll0; - - euler1[0] = picth1; - euler1[1] = yaw1; - euler1[2] = roll1; - } - - euler0[3] = dgFloat32(0.0f); - euler1[3] = dgFloat32(0.0f); - -#ifdef _DEBUG - dgMatrix m0 (dgPitchMatrix (euler0[0]) * dgYawMatrix(euler0[1]) * dgRollMatrix(euler0[2])); - dgMatrix m1 (dgPitchMatrix (euler1[0]) * dgYawMatrix(euler1[1]) * dgRollMatrix(euler1[2])); - for (dgInt32 i = 0; i < 3; i ++) { - for (dgInt32 j = 0; j < 3; j ++) { - dgFloat32 error = dgAbs (m0[i][j] - matrix[i][j]); - dgAssert (error < 5.0e-2f); - error = dgAbs (m1[i][j] - matrix[i][j]); - dgAssert (error < 5.0e-2f); - } - } -#endif -} - - -void dgMatrix::PolarDecomposition (dgMatrix& transformMatrix, dgVector& scale, dgMatrix& stretchAxis) const -{ - // a polar decomposition decompose matrix A = O * S - // where S = sqrt (transpose (L) * L) - - const dgMatrix& me = *this; - dgFloat32 sign = dgSign (me[2].DotProduct(me[0].CrossProduct(me[1])).GetScalar()); - stretchAxis = me * Transpose(); - scale = stretchAxis.EigenVectors(); - - // I need to deal with by seeing of some of the Scale are duplicated - // do this later (maybe by a given rotation around the non uniform axis but I do not know if it will work) - // for now just us the matrix - - scale[0] = sign * dgSqrt (scale[0]); - scale[1] = sign * dgSqrt (scale[1]); - scale[2] = sign * dgSqrt (scale[2]); - scale[3] = dgFloat32 (0.0f); - - dgMatrix scaledAxis; - scaledAxis[0] = stretchAxis[0].Scale (dgFloat32 (1.0f) / scale[0]); - scaledAxis[1] = stretchAxis[1].Scale (dgFloat32 (1.0f) / scale[1]); - scaledAxis[2] = stretchAxis[2].Scale (dgFloat32 (1.0f) / scale[2]); - scaledAxis[3] = stretchAxis[3]; - dgMatrix symetricInv (stretchAxis.Transpose() * scaledAxis); - - transformMatrix = symetricInv * (*this); - transformMatrix.m_posit = m_posit; -} - -#if 0 -dgVector dgMatrix::EigenVectors() -{ - dgMatrix& mat = *this; - dgMatrix eigenVectors(dgGetIdentityMatrix()); - - dgVector d(mat[0][0], mat[1][1], mat[2][2], dgFloat32(0.0f)); - dgVector b(d); - for (dgInt32 i = 0; i < 50; i++) { - dgFloat32 sm = mat[0][1] * mat[0][1] + mat[0][2] * mat[0][2] + mat[1][2] * mat[1][2]; - if (sm < dgFloat32(1.0e-12f)) { - // check the eigenvalue vectors - //dgVector tmp(eigenVectors.m_front.CrossProduct(eigenVectors.m_up)); - //if (tmp.DotProduct(eigenVectors.m_right).GetScalar() < dgFloat32(0.0f)) { - // eigenVectors.m_right = eigenVectors.m_right * dgVector::m_negOne; - //} - dgAssert (eigenVectors[0].DotProduct(eigenVectors[1].CrossProduct(eigenVectors[2])).GetScalar() > dgFloat32 (0.0f)); - break; - } - - dgFloat32 thresh = dgFloat32(0.0f); - if (i < 3) { - thresh = (dgFloat32)(0.2f / 9.0f) * sm; - } - - dgVector z(dgVector::m_zero); - for (dgInt32 ip = 0; ip < 2; ip++) { - for (dgInt32 iq = ip + 1; iq < 3; iq++) { - dgFloat32 g = dgFloat32(100.0f) * dgAbs(mat[ip][iq]); - if ((i > 3) && ((dgAbs(d[ip]) + g) == dgAbs(d[ip])) && ((dgAbs(d[iq]) + g) == dgAbs(d[iq]))) { - mat[ip][iq] = dgFloat32(0.0f); - } else if (dgAbs(mat[ip][iq]) > thresh) { - - dgFloat32 t; - dgFloat32 h = d[iq] - d[ip]; - if (dgAbs(h) + g == dgAbs(h)) { - t = mat[ip][iq] / h; - } else { - dgFloat32 theta = dgFloat32(0.5f) * h / mat[ip][iq]; - t = dgFloat32(1.0f) / (dgAbs(theta) + dgSqrt(dgFloat32(1.0f) + theta * theta)); - if (theta < dgFloat32(0.0f)) { - t = -t; - } - } - dgFloat32 c = dgRsqrt(dgFloat32(1.0f) + t * t); - dgFloat32 s = t * c; - dgFloat32 tau = s / (dgFloat32(1.0f) + c); - h = t * mat[ip][iq]; - z[ip] -= h; - z[iq] += h; - d[ip] -= h; - d[iq] += h; - mat[ip][iq] = dgFloat32(0.0f); - - for (dgInt32 j = 0; j <= ip - 1; j++) { - dgFloat32 g0 = mat[j][ip]; - dgFloat32 h0 = mat[j][iq]; - mat[j][ip] = g0 - s * (h0 + g0 * tau); - mat[j][iq] = h0 + s * (g0 - h0 * tau); - } - for (dgInt32 j = ip + 1; j <= iq - 1; j++) { - dgFloat32 g0 = mat[ip][j]; - dgFloat32 h0 = mat[j][iq]; - mat[ip][j] = g0 - s * (h0 + g0 * tau); - mat[j][iq] = h0 + s * (g0 - h0 * tau); - } - for (dgInt32 j = iq + 1; j < 3; j++) { - dgFloat32 g0 = mat[ip][j]; - dgFloat32 h0 = mat[iq][j]; - mat[ip][j] = g0 - s * (h0 + g0 * tau); - mat[iq][j] = h0 + s * (g0 - h0 * tau); - } - - dgVector sv(s); - dgVector tauv(tau); - dgVector gv(eigenVectors[ip]); - dgVector hv(eigenVectors[iq]); - eigenVectors[ip] -= sv * (hv + gv * tauv); - eigenVectors[iq] += sv * (gv - hv * tauv); - } - } - } - - b += z; - d = b; - } - - *this = eigenVectors; - return d; -} - -#else -dgVector dgMatrix::EigenVectors () -{ - dgMatrix matrix (*this); - dgMatrix eigenVectors(dgGetIdentityMatrix()); - -#if 0 - if (dgAbs(m_front.m_z) > dgFloat32(1.0e-6f)) { - // calculate initial guess by convert to tridiagonal matrix using householder - // but this fail since it changes the oder of the Eigen values and Eigen vectors - dgVector u(m_front); - u.m_x = dgFloat32(0.0f); - dgVector v(dgVector::m_zero); - v.m_y = dgSqrt(u.DotProduct(u).GetScalar()); - dgVector w(u - v); - w = w.Normalize(); - eigenVectors = dgMatrix(w, w); - dgMatrix ident(dgGetIdentityMatrix()); - eigenVectors[0] = ident[0] - eigenVectors[0] * dgVector::m_two; - eigenVectors[1] = ident[1] - eigenVectors[1] * dgVector::m_two; - eigenVectors[2] = ident[2] - eigenVectors[2] * dgVector::m_two; - matrix = eigenVectors * matrix * eigenVectors; - } - matrix[0][2] = dgFloat32(0.0f); - matrix[2][0] = dgFloat32(0.0f); -#endif - - // QR algorithm is really bad at converging matrices with very different eigenvalue. - // the solution is to use RD with double shift which I do not feel like implementing. - // using Jacobi diagonalize instead - dgVector d (matrix[0][0], matrix[1][1], matrix[2][2], dgFloat32 (0.0f)); - dgVector b (d); - for (dgInt32 i = 0; i < 50; i++) { - dgFloat32 sm = matrix[0][1] * matrix[0][1] + matrix[0][2] * matrix[0][2] + matrix[1][2] * matrix[1][2]; - if (sm < dgFloat32 (1.0e-12f)) { - // make sure the the Eigen vectors are orthonormal - //dgVector tmp (eigenVectors.m_front.CrossProduct(eigenVectors.m_up)); - //if (tmp.DotProduct(eigenVectors.m_right).GetScalar() < dgFloat32(0.0f)) { - // eigenVectors.m_right = eigenVectors.m_right * dgVector::m_negOne; - //} - dgAssert (eigenVectors[0].DotProduct(eigenVectors[1].CrossProduct(eigenVectors[2])).GetScalar() > dgFloat32 (0.0f)); - break; - } - - dgFloat32 thresh = dgFloat32 (0.0f); - if (i < 3) { - thresh = (dgFloat32)(0.2f / 9.0f) * sm; - } - - dgVector z (dgVector::m_zero); - for (dgInt32 j = 0; j < 2; j ++) { - for (dgInt32 k = j + 1; k < 3; k ++) { - dgFloat32 g = dgFloat32 (100.0f) * dgAbs(matrix[j][k]); - if ((i > 3) && ((dgAbs(d[j]) + g) == dgAbs(d[j])) && ((dgAbs(d[k]) + g) == dgAbs(d[k]))) { - matrix[j][k] = dgFloat32 (0.0f); - } else if (dgAbs(matrix[j][k]) > thresh) { - - dgFloat32 t; - dgFloat32 h = d[k] - d[j]; - if (dgAbs(h) + g == dgAbs(h)) { - t = matrix[j][k] / h; - } else { - dgFloat32 theta = dgFloat32 (0.5f) * h / matrix[j][k]; - t = dgFloat32(1.0f) / (dgAbs(theta) + dgSqrt(dgFloat32(1.0f) + theta * theta)); - if (theta < dgFloat32 (0.0f)) { - t = -t; - } - } - dgFloat32 c = dgRsqrt (dgFloat32 (1.0f) + t * t); - dgFloat32 s = t * c; - dgFloat32 tau = s / (dgFloat32(1.0f) + c); - h = t * matrix[j][k]; - z[j] -= h; - z[k] += h; - d[j] -= h; - d[k] += h; - matrix[j][k] = dgFloat32(0.0f); - - for (dgInt32 n = 0; n <= j - 1; n ++) { - dgFloat32 g0 = matrix[n][j]; - dgFloat32 h0 = matrix[n][k]; - matrix[n][j] = g0 - s * (h0 + g0 * tau); - matrix[n][k] = h0 + s * (g0 - h0 * tau); - } - for (dgInt32 n = j + 1; n <= k - 1; n ++) { - dgFloat32 g0 = matrix[j][n]; - dgFloat32 h0 = matrix[n][k]; - matrix[j][n] = g0 - s * (h0 + g0 * tau); - matrix[n][k] = h0 + s * (g0 - h0 * tau); - } - for (dgInt32 n = k + 1; n < 3; n ++) { - dgFloat32 g0 = matrix[j][n]; - dgFloat32 h0 = matrix[k][n]; - matrix[j][n] = g0 - s * (h0 + g0 * tau); - matrix[k][n] = h0 + s * (g0 - h0 * tau); - } - - dgVector sv (s); - dgVector tauv (tau); - dgVector gv (eigenVectors[j]); - dgVector hv (eigenVectors[k]); - eigenVectors[j] -= sv * (hv + gv * tauv); - eigenVectors[k] += sv * (gv - hv * tauv); - } - } - } - - b += z; - d = b; - } - - #ifdef _DEBUG - dgMatrix diag(dgGetIdentityMatrix()); - diag[0][0] = d[0]; - diag[1][1] = d[1]; - diag[2][2] = d[2]; - dgMatrix E(eigenVectors.Transpose()); - dgMatrix originalMatrix(*this); - dgMatrix tempMatrix(E * diag * E.Transpose()); - for (dgInt32 j = 0; j < 3; j++) { - for (dgInt32 k = 0; k < 3; k++) { - dgFloat32 error = originalMatrix[j][k] - tempMatrix[j][k]; - dgAssert((error * error) < dgFloat32(1.0e-4f)); - } - } - #endif - - *this = eigenVectors; - return d; -} -#endif - -dgSpatialMatrix dgSpatialMatrix::Inverse(dgInt32 rows) const -{ - dgSpatialMatrix tmp(*this); - dgSpatialMatrix inv(dgFloat64(0.0f)); - for (dgInt32 i = 0; i < rows; i++) { - inv[i][i] = dgFloat32(1.0f); - } - - for (dgInt32 i = 0; i < rows; i++) { - dgFloat64 pivot = dgAbs(tmp[i][i]); - if (pivot < dgFloat64(0.01f)) { - int permute = i; - for (dgInt32 j = i + 1; j < rows; j++) { - dgFloat64 pivot1 = dgAbs(tmp[j][i]); - if (pivot1 > pivot) { - permute = j; - pivot = pivot1; - } - } - dgAssert(pivot > dgFloat32(0.0f)); - dgAssert((pivot > dgFloat32(1.0e-6f)) || (dgConditionNumber(rows, 6, (dgFloat64*)&m_rows[0]) < dgFloat32(1.0e5f))); - //if (!((pivot > dgFloat32(1.0e-6f)) || (dgConditionNumber(rows, 6, (dgFloat64*)&m_rows[0]) < dgFloat32(1.0e5f)))) - //{ - // for (dgInt32 m = 0; m < rows; m++) { - // for (dgInt32 n = 0; n < rows; n++) { - // dgTrace(("%f ", m_rows[m][n])); - // } - // dgTrace(("\n")); - // } - // dgAssert(0); - //} - - if (permute != i) { - for (dgInt32 j = 0; j < rows; j++) { - dgSwap(tmp[i][j], tmp[permute][j]); - dgSwap(tmp[i][j], tmp[permute][j]); - } - } - } - - for (dgInt32 j = i + 1; j < rows; j++) { - dgFloat64 scale = tmp[j][i] / tmp[i][i]; - tmp[j][i] = dgFloat64(0.0f); - for (int k = i + 1; k < rows; k++) { - tmp[j][k] -= scale * tmp[i][k]; - } - for (int k = 0; k <= i; k++) { - inv[j][k] -= scale * inv[i][k]; - } - } - } - - for (dgInt32 i = rows - 1; i >= 0; i--) { - dgSpatialVector acc(dgFloat64(0.0f)); - for (dgInt32 j = i + 1; j < rows; j++) { - dgFloat64 pivot = tmp[i][j]; - for (int k = 0; k < rows; k++) { - acc[k] += pivot * inv[j][k]; - } - } - dgFloat64 den = dgFloat64(1.0f) / tmp[i][i]; - for (dgInt32 k = 0; k < rows; k++) { - inv[i][k] = den * (inv[i][k] - acc[k]); - } - } - - -#ifdef _DEBUG - for (dgInt32 i = 0; i < rows; i++) { - for (dgInt32 j = 0; j < rows; j++) { - tmp[i][j] = m_rows[j][i]; - } - } - for (dgInt32 i = 0; i < rows; i++) { - dgSpatialVector v(inv.VectorTimeMatrix(tmp[i], rows)); - dgAssert(dgAbs(v[i] - dgFloat64(1.0f)) < dgFloat64(1.0e-6f)); - for (dgInt32 j = 0; j < rows; j++) { - if (j != i) { - dgAssert(dgAbs(v[j]) < dgFloat64(1.0e-6f)); - } - } - } -#endif - - return inv; -} diff --git a/thirdparty/src/newton/dgCore/dgMatrix.h b/thirdparty/src/newton/dgCore/dgMatrix.h deleted file mode 100644 index 38b36cff4..000000000 --- a/thirdparty/src/newton/dgCore/dgMatrix.h +++ /dev/null @@ -1,380 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgMatrix__ -#define __dgMatrix__ - - -#include "dgStdafx.h" -#include "dgDebug.h" -#include "dgVector.h" -#include "dgPlane.h" -#include <math.h> - -class dgMatrix; -class dgQuaternion; - -const dgMatrix& dgGetZeroMatrix (); -const dgMatrix& dgGetIdentityMatrix(); - - -DG_MSC_VECTOR_ALIGNMENT -class dgMatrix -{ - public: - DG_CLASS_ALLOCATOR(allocator) - - dgMatrix (); - dgMatrix (const dgFloat32* const array); - dgMatrix (const dgVector &front, const dgVector &up, const dgVector &right, const dgVector &posit); - dgMatrix (const dgQuaternion &rotation, const dgVector &position); - - // create a orthonormal normal vector basis, front become m_front vector, and m_up and m_right are mutualiperpendicular to fron and to each other - dgMatrix (const dgVector &front); - - // create a covariance Matrix = transpose(p) * q - dgMatrix (const dgVector& p, const dgVector& q); - - dgVector& operator[] (dgInt32 i); - const dgVector& operator[] (dgInt32 i) const; - - dgMatrix Inverse () const; - dgMatrix Inverse4x4 () const; - dgMatrix Transpose () const; - dgMatrix Transpose4X4 () const; - dgVector RotateVector (const dgVector &v) const; - dgVector UnrotateVector (const dgVector &v) const; - dgVector TransformVector (const dgVector &v) const; - dgVector UntransformVector (const dgVector &v) const; - dgPlane TransformPlane (const dgPlane &localPlane) const; - dgPlane UntransformPlane (const dgPlane &globalPlane) const; - dgVector SolveByGaussianElimination(const dgVector &v) const; - void TransformBBox (const dgVector& p0local, const dgVector& p1local, dgVector& p0, dgVector& p1) const; - - void CalcPitchYawRoll (dgVector& euler0, dgVector& euler1) const; - void TransformTriplex (dgFloat32* const dst, dgInt32 dstStrideInBytes, - const dgFloat32* const src, dgInt32 srcStrideInBytes, dgInt32 count) const; - -#ifndef _NEWTON_USE_DOUBLE - void TransformTriplex (dgFloat64* const dst, dgInt32 dstStrideInBytes, - const dgFloat64* const src, dgInt32 srcStrideInBytes, dgInt32 count) const; - - void TransformTriplex (dgFloat64* const dst, dgInt32 dstStrideInBytes, - const dgFloat32* const src, dgInt32 srcStrideInBytes, dgInt32 count) const; -#endif - - bool TestIdentity() const; - bool TestSymetric3x3() const; - bool TestOrthogonal(dgFloat32 tol = dgFloat32 (1.0e-4f)) const; - - dgMatrix Multiply3X3 (const dgMatrix &B) const; - dgMatrix operator* (const dgMatrix &B) const; - - // these function can only be called when dgMatrix is a PDS matrix - //void EigenVectors (); - dgVector EigenVectors (); - void PolarDecomposition (dgMatrix& transformMatrix, dgVector& scale, dgMatrix& stretchAxis) const; - - // constructor for polar composition - dgMatrix (const dgMatrix& transformMatrix, const dgVector& scale, const dgMatrix& stretchAxis); - - dgVector m_front; - dgVector m_up; - dgVector m_right; - dgVector m_posit; - - static dgMatrix m_zeroMatrix; - static dgMatrix m_identityMatrix; -} DG_GCC_VECTOR_ALIGNMENT; - - - -DG_INLINE dgMatrix::dgMatrix () -{ -} - -DG_INLINE dgMatrix::dgMatrix (const dgFloat32* const array) -{ - memcpy (&m_front.m_x, array, sizeof (dgMatrix)) ; -} - -DG_INLINE dgMatrix::dgMatrix (const dgVector &front, const dgVector &up, const dgVector &right, const dgVector &posit) - :m_front (front), m_up(up), m_right(right), m_posit(posit) -{ -} - -DG_INLINE dgMatrix::dgMatrix (const dgVector& p, const dgVector& q) - :m_front(q * p.BroadcastX()) - ,m_up (q * p.BroadcastY()) - ,m_right(q * p.BroadcastZ()) - ,m_posit (dgVector::m_wOne) -{ -} - -DG_INLINE dgMatrix::dgMatrix (const dgVector& front) -{ - m_front = front; - if (dgAbs (front.m_z) > dgFloat32 (0.577f)) { - m_right = front.CrossProduct(dgVector (-front.m_y, front.m_z, dgFloat32(0.0f), dgFloat32(0.0f))); - } else { - m_right = front.CrossProduct(dgVector (-front.m_y, front.m_x, dgFloat32(0.0f), dgFloat32(0.0f))); - } - //m_right = m_right.Scale (dgRsqrt (m_right.DotProduct(m_right).GetScalar())); - m_right = m_right.Normalize(); - m_up = m_right.CrossProduct(m_front); - - m_front.m_w = dgFloat32(0.0f); - m_up.m_w = dgFloat32(0.0f); - m_right.m_w = dgFloat32(0.0f); - m_posit = dgVector (dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(1.0f)); - - dgAssert ((dgAbs (m_front.DotProduct(m_front).GetScalar()) - dgFloat32(1.0f)) < dgFloat32(1.0e-5f)); - dgAssert ((dgAbs (m_up.DotProduct(m_up).GetScalar()) - dgFloat32(1.0f)) < dgFloat32(1.0e-5f)); - dgAssert ((dgAbs (m_right.DotProduct(m_right).GetScalar()) - dgFloat32(1.0f)) < dgFloat32(1.0e-5f)); - dgAssert ((dgAbs (m_right.DotProduct(m_front.CrossProduct(m_up)).GetScalar()) - dgFloat32(1.0f)) < dgFloat32(1.0e-5f)); -} - -DG_INLINE dgVector& dgMatrix::operator[] (dgInt32 i) -{ - dgAssert (i < 4); - dgAssert (i >= 0); - return (&m_front)[i]; -} - -DG_INLINE const dgVector& dgMatrix::operator[] (dgInt32 i) const -{ - dgAssert (i < 4); - dgAssert (i >= 0); - return (&m_front)[i]; -} - - -DG_INLINE dgMatrix dgMatrix::Transpose () const -{ - dgMatrix inv; - dgVector::Transpose4x4(inv[0], inv[1], inv[2], inv[3], m_front, m_up, m_right, dgVector::m_wOne); - return inv; -} - -DG_INLINE dgMatrix dgMatrix::Transpose4X4 () const -{ - dgMatrix inv; - dgVector::Transpose4x4(inv[0], inv[1], inv[2], inv[3], m_front, m_up, m_right, m_posit); - return inv; -} - -DG_INLINE dgVector dgMatrix::RotateVector (const dgVector &v) const -{ - return m_front * v.BroadcastX() + m_up * v.BroadcastY() + m_right * v.BroadcastZ(); -} - -DG_INLINE dgVector dgMatrix::UnrotateVector (const dgVector &v) const -{ - return dgVector ((m_front * v).AddHorizontal().GetScalar(), (m_up * v).AddHorizontal().GetScalar(), (m_right * v).AddHorizontal().GetScalar(), dgFloat32 (0.0f)); -} - -DG_INLINE dgVector dgMatrix::TransformVector (const dgVector &v) const -{ - return RotateVector(v) + m_posit; -} - -DG_INLINE dgVector dgMatrix::UntransformVector (const dgVector &v) const -{ - return UnrotateVector(v - m_posit); -} - -DG_INLINE dgPlane dgMatrix::TransformPlane (const dgPlane &localPlane) const -{ - return dgPlane (RotateVector (localPlane), localPlane.m_w - (localPlane.DotProduct(UnrotateVector (m_posit)).GetScalar())); -} - -DG_INLINE dgPlane dgMatrix::UntransformPlane (const dgPlane &globalPlane) const -{ - return dgPlane (UnrotateVector (globalPlane), globalPlane.Evalue(m_posit)); -} - -/* -DG_INLINE void dgMatrix::EigenVectors () -{ - dgVector eigenValues; - EigenVectors (eigenValues); -} -*/ - -DG_INLINE dgMatrix dgMatrix::Inverse () const -{ - // much faster inverse - dgMatrix inv; - dgVector::Transpose4x4 (inv[0], inv[1], inv[2], inv[3], m_front, m_up, m_right, dgVector::m_wOne); - inv.m_posit -= inv[0] * m_posit.BroadcastX() + inv[1] * m_posit.BroadcastY() + inv[2] * m_posit.BroadcastZ(); - return inv; -} - -DG_INLINE bool dgMatrix::TestIdentity() const -{ - const dgMatrix& me = *this; - for (int i = 0; i < 4; i++) { - if (me[i][i] != dgFloat32 (1.0f)) { - return false; - } - for (int j = i + 1; j < 4; j++) { - if (me[i][j] != dgFloat32 (0.0f)) { - return false; - } - if (me[j][i] != dgFloat32(0.0f)) { - return false; - } - } - } - return true; -} - -DG_INLINE bool dgMatrix::TestOrthogonal(dgFloat32 tol) const -{ - dgVector n (m_front.CrossProduct(m_up)); - dgFloat32 a = m_right.DotProduct(m_right).GetScalar(); - dgFloat32 b = m_up.DotProduct(m_up).GetScalar(); - dgFloat32 c = m_front.DotProduct(m_front).GetScalar(); - dgFloat32 d = n.DotProduct(m_right).GetScalar(); - -#ifdef _DEBUG - const dgMatrix& me = *this; - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - dgAssert(dgCheckFloat(me[i][j])); - } - } -#endif - - return (m_front[3] == dgFloat32 (0.0f)) & - (m_up[3] == dgFloat32 (0.0f)) & - (m_right[3] == dgFloat32 (0.0f)) & - (m_posit[3] == dgFloat32 (1.0f)) & - (dgAbs(a - dgFloat32 (1.0f)) < tol) & - (dgAbs(b - dgFloat32 (1.0f)) < tol) & - (dgAbs(c - dgFloat32 (1.0f)) < tol) & - (dgAbs(d - dgFloat32 (1.0f)) < tol); -} - -DG_INLINE bool dgMatrix::TestSymetric3x3() const -{ - const dgMatrix& me = *this; - return (dgAbs (me[0][1] - me[1][0]) < dgFloat32 (1.0e-5f)) && - (dgAbs (me[0][2] - me[2][0]) < dgFloat32 (1.0e-5f)) && - (dgAbs (me[1][2] - me[2][1]) < dgFloat32 (1.0e-5f)) && - (me[0][3] == dgFloat32 (0.0f)) && - (me[1][3] == dgFloat32 (0.0f)) && - (me[2][3] == dgFloat32 (0.0f)) && - (me[3][0] == dgFloat32 (0.0f)) && - (me[3][1] == dgFloat32 (0.0f)) && - (me[3][2] == dgFloat32 (0.0f)) && - (me[3][3] == dgFloat32 (1.0f)); -} - -DG_INLINE dgMatrix dgPitchMatrix(dgFloat32 ang) -{ - dgFloat32 sinAng = dgSin (ang); - dgFloat32 cosAng = dgCos (ang); - return dgMatrix (dgVector (dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)), - dgVector (dgFloat32(0.0f), cosAng, sinAng, dgFloat32(0.0f)), - dgVector (dgFloat32(0.0f), -sinAng, cosAng, dgFloat32(0.0f)), - dgVector (dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(1.0f))); - -} - -DG_INLINE dgMatrix dgYawMatrix(dgFloat32 ang) -{ - dgFloat32 sinAng = dgSin (ang); - dgFloat32 cosAng = dgCos (ang); - return dgMatrix (dgVector (cosAng, dgFloat32(0.0f), -sinAng, dgFloat32(0.0f)), - dgVector (dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f)), - dgVector (sinAng, dgFloat32(0.0f), cosAng, dgFloat32(0.0f)), - dgVector (dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(1.0f))); -} - -DG_INLINE dgMatrix dgRollMatrix(dgFloat32 ang) -{ - dgFloat32 sinAng = dgSin (ang); - dgFloat32 cosAng = dgCos (ang); - return dgMatrix (dgVector ( cosAng, sinAng, dgFloat32(0.0f), dgFloat32(0.0f)), - dgVector (-sinAng, cosAng, dgFloat32(0.0f), dgFloat32(0.0f)), - dgVector ( dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f)), - dgVector ( dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(1.0f))); -} - - - -DG_MSC_VECTOR_ALIGNMENT -class dgSpatialMatrix -{ - public: - DG_INLINE dgSpatialMatrix() - { - } - - DG_INLINE dgSpatialMatrix(dgFloat32 val) - { - const dgSpatialVector row (val); - for (dgInt32 i = 0; i < 6; i++) { - m_rows[i] = row; - } - } - - DG_INLINE dgSpatialVector& operator[] (dgInt32 i) - { - dgAssert(i < 6); - dgAssert(i >= 0); - return m_rows[i]; - } - - DG_INLINE const dgSpatialVector& operator[] (dgInt32 i) const - { - dgAssert(i < 6); - dgAssert(i >= 0); - return m_rows[i]; - } - - dgSpatialMatrix Inverse(dgInt32 rows) const; - - DG_INLINE dgSpatialVector VectorTimeMatrix(const dgSpatialVector& jacobian) const - { - dgSpatialVector tmp(m_rows[0].Scale (jacobian[0])); - for (dgInt32 i = 1; i < 6; i++) { - tmp = tmp + m_rows[i].Scale(jacobian[i]); - } - return tmp; - } - - DG_INLINE dgSpatialVector VectorTimeMatrix(const dgSpatialVector& jacobian, dgInt32 dof) const - { - dgSpatialVector tmp(dgFloat32 (0.0f)); - for (dgInt32 i = 0; i < dof; i++) { - tmp = tmp + m_rows[i].Scale(jacobian[i]); - } - return tmp; - } - - dgSpatialVector m_rows[6]; -} DG_GCC_VECTOR_ALIGNMENT; - - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgMemory.cpp b/thirdparty/src/newton/dgCore/dgMemory.cpp deleted file mode 100644 index 4fe5be585..000000000 --- a/thirdparty/src/newton/dgCore/dgMemory.cpp +++ /dev/null @@ -1,781 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgList.h" -#include "dgDebug.h" -#include "dgMemory.h" - - -#ifdef DG_OLD_ALLOCATOR -dgInt32 dgMemoryAllocator::m_lock0 = 0; -dgInt32 dgMemoryAllocator::m_lock1 = 0; -#define DG_MEMORY_LOCK() dgScopeSpinPause lock (&dgMemoryAllocator::m_lock0); -#define DG_MEMORY_LOCK_LOW() dgScopeSpinPause lock (&dgMemoryAllocator::m_lock1); - -class dgMemoryAllocator::dgMemoryBin -{ - public: - class dgMemoryBinInfo - { - public: - dgInt32 m_count; - dgInt32 m_totalCount; - dgInt32 m_stepInBytes; - dgMemoryBin* m_next; - dgMemoryBin* m_prev; - }; - char m_pool[DG_MEMORY_BIN_SIZE - sizeof (dgMemoryBinInfo)-DG_MEMORY_GRANULARITY * 2]; - dgMemoryBinInfo m_info; -}; - -class dgMemoryAllocator::dgMemoryCacheEntry -{ - public: - dgMemoryCacheEntry* m_next; - dgMemoryCacheEntry* m_prev; -}; - -class dgMemoryAllocator::dgMemoryInfo -{ - public: - void *m_ptr; - dgMemoryAllocator* m_allocator; - dgInt32 m_size; - dgInt32 m_enum; - - #ifdef _DEBUG - dgInt32 m_workingSize; - #endif - - DG_INLINE void SaveInfo(dgMemoryAllocator* const allocator, void* const ptr, dgInt32 size, dgInt32& enumerator, dgInt32 workingSize = 0) - { - m_ptr = ptr; - m_size = size; - m_enum = enumerator; - enumerator++; - m_allocator = allocator; -#ifdef _DEBUG - m_workingSize = workingSize; -#endif - } -}; - -class dgGlobalAllocator: public dgMemoryAllocator, public dgList<dgMemoryAllocator*> -{ - public: - dgGlobalAllocator () - :dgMemoryAllocator (__malloc__, __free__), dgList<dgMemoryAllocator*> (NULL) - { - SetAllocator (this); - } - - ~dgGlobalAllocator () - { - dgAssert (GetCount() == 0); - } - - static void* dgApi __malloc__ (dgUnsigned32 size) - { - return malloc (size); - } - - static void dgApi __free__ (void* const ptr, dgUnsigned32 size) - { - free (ptr); - } - - void operator delete (void* const ptr) - { - dgAssert (0); - free (ptr); - } - - dgInt32 GetMemoryUsed () const - { - dgInt32 mem = m_memoryUsed; - for (dgList<dgMemoryAllocator*>::dgListNode* node = GetFirst(); node; node = node->GetNext()) { - mem += node->GetInfo()->GetMemoryUsed(); - } - return mem; - } - - static dgGlobalAllocator& GetGlobalAllocator() - { - static dgGlobalAllocator m_globalAllocator; - return m_globalAllocator; - } -}; - -dgMemoryAllocator::dgMemoryAllocator () - :m_free(NULL) - ,m_malloc(NULL) - ,m_enumerator(0) - ,m_memoryUsed(0) - ,m_isInList(1) -{ - SetAllocatorsCallback (dgGlobalAllocator::GetGlobalAllocator().m_malloc, dgGlobalAllocator::GetGlobalAllocator().m_free); - memset (m_memoryDirectory, 0, sizeof (m_memoryDirectory)); - dgGlobalAllocator::GetGlobalAllocator().Append(this); -} - -dgMemoryAllocator::dgMemoryAllocator (dgMemAlloc memAlloc, dgMemFree memFree) - :m_free(NULL) - ,m_malloc(NULL) - ,m_enumerator(0) - ,m_memoryUsed(0) - ,m_isInList(0) -{ - SetAllocatorsCallback (memAlloc, memFree); - memset (m_memoryDirectory, 0, sizeof (m_memoryDirectory)); -} - -dgMemoryAllocator::~dgMemoryAllocator () -{ - if (m_isInList) { - dgGlobalAllocator::GetGlobalAllocator().Remove(this); - } - dgAssert (m_memoryUsed == 0); -} - - -void *dgMemoryAllocator::operator new (size_t size) -{ - return dgMallocStack(size); -} - -void dgMemoryAllocator::operator delete (void* const ptr) -{ - dgFreeStack(ptr); -} - -dgInt32 dgMemoryAllocator::GetMemoryUsed() const -{ - return m_memoryUsed; -} - -void dgMemoryAllocator::SetAllocatorsCallback (dgMemAlloc memAlloc, dgMemFree memFree) -{ - m_free = memFree; - m_malloc = memAlloc; -} - -void *dgMemoryAllocator::MallocLow (dgInt32 workingSize, dgInt32 alignment) -{ - DG_MEMORY_LOCK_LOW(); - alignment = dgMax (alignment, DG_MEMORY_GRANULARITY); - dgAssert (((-alignment) & (alignment - 1)) == 0); - dgInt32 size = workingSize + alignment * 2; - void* const ptr = m_malloc(dgUnsigned32 (size)); - dgAssert (ptr); -#ifdef _DEBUG - memset(ptr, 99, size_t(size)); -#endif - - dgUnsigned64 val = dgUnsigned64 (PointerToInt(ptr)); - val = (val & dgUnsigned64(-alignment)) + alignment * 2; - void* const retPtr = IntToPointer (val); - - dgMemoryInfo* const info = ((dgMemoryInfo*) (retPtr)) - 1; - info->SaveInfo(this, ptr, size, m_enumerator, workingSize); - - dgAtomicExchangeAndAdd (&m_memoryUsed, size); - return retPtr; -} - -void dgMemoryAllocator::FreeLow (void* const retPtr) -{ - DG_MEMORY_LOCK_LOW(); - dgMemoryInfo* const info = ((dgMemoryInfo*) (retPtr)) - 1; - dgAssert (info->m_allocator == this); - - dgAtomicExchangeAndAdd (&m_memoryUsed, -info->m_size); - -#ifdef _DEBUG - memset (retPtr, 0, size_t(info->m_workingSize)); -#endif - - m_free (info->m_ptr, dgUnsigned32 (info->m_size)); -} - -void *dgMemoryAllocator::Malloc (dgInt32 memsize) -{ - dgAssert (dgInt32 (sizeof (dgMemoryCacheEntry) + sizeof (dgInt32) + sizeof(dgInt32)) <= DG_MEMORY_GRANULARITY); - - dgInt32 size = memsize + DG_MEMORY_GRANULARITY - 1; - size &= (-DG_MEMORY_GRANULARITY); - - dgInt32 paddedSize = size + DG_MEMORY_GRANULARITY; - dgInt32 entry = paddedSize >> DG_MEMORY_GRANULARITY_BITS; - - void* ptr; - if (entry >= DG_MEMORY_BIN_ENTRIES) { - ptr = MallocLow (size); - } else { - DG_MEMORY_LOCK(); - if (!m_memoryDirectory[entry].m_cache) { - dgMemoryBin* const bin = (dgMemoryBin*) MallocLow (sizeof (dgMemoryBin)); - - dgInt32 count = dgInt32 (sizeof (bin->m_pool) / paddedSize); - bin->m_info.m_count = 0; - bin->m_info.m_totalCount = count; - bin->m_info.m_stepInBytes = paddedSize; - bin->m_info.m_next = m_memoryDirectory[entry].m_first; - bin->m_info.m_prev = NULL; - if (bin->m_info.m_next) { - bin->m_info.m_next->m_info.m_prev = bin; - } - - m_memoryDirectory[entry].m_first = bin; - - dgInt8* charPtr = reinterpret_cast<dgInt8*>(bin->m_pool); - m_memoryDirectory[entry].m_cache = (dgMemoryCacheEntry*)charPtr; - - for (dgInt32 i = 0; i < count; i ++) { - dgMemoryCacheEntry* const cashe = (dgMemoryCacheEntry*) charPtr; - cashe->m_next = (dgMemoryCacheEntry*) (charPtr + paddedSize); - cashe->m_prev = (dgMemoryCacheEntry*) (charPtr - paddedSize); - dgMemoryInfo* const info = ((dgMemoryInfo*) (charPtr + DG_MEMORY_GRANULARITY)) - 1; - info->SaveInfo(this, bin, entry, m_enumerator, memsize); - charPtr += paddedSize; - } - dgMemoryCacheEntry* const cashe = (dgMemoryCacheEntry*) (charPtr - paddedSize); - cashe->m_next = NULL; - m_memoryDirectory[entry].m_cache->m_prev = NULL; - } - - - dgAssert (m_memoryDirectory[entry].m_cache); - - dgMemoryCacheEntry* const cashe = m_memoryDirectory[entry].m_cache; - m_memoryDirectory[entry].m_cache = cashe->m_next; - if (cashe->m_next) { - cashe->m_next->m_prev = NULL; - } - - ptr = ((dgInt8*)cashe) + DG_MEMORY_GRANULARITY; - - dgMemoryInfo* info; - info = ((dgMemoryInfo*) (ptr)) - 1; - dgAssert (info->m_allocator == this); - - dgMemoryBin* const bin = (dgMemoryBin*) info->m_ptr; - bin->m_info.m_count ++; - } - return ptr; -} - -void dgMemoryAllocator::Free (void* const retPtr) -{ - dgMemoryInfo* const info = ((dgMemoryInfo*) (retPtr)) - 1; - dgAssert (info->m_allocator == this); - - dgInt32 entry = info->m_size; - - if (entry >= DG_MEMORY_BIN_ENTRIES) { - FreeLow (retPtr); - } else { - DG_MEMORY_LOCK(); - dgMemoryCacheEntry* const cashe = (dgMemoryCacheEntry*) (((char*)retPtr) - DG_MEMORY_GRANULARITY) ; - - dgMemoryCacheEntry* const tmpCashe = m_memoryDirectory[entry].m_cache; - if (tmpCashe) { - dgAssert (!tmpCashe->m_prev); - tmpCashe->m_prev = cashe; - } - cashe->m_next = tmpCashe; - cashe->m_prev = NULL; - - m_memoryDirectory[entry].m_cache = cashe; - - dgMemoryBin* const bin = (dgMemoryBin *) info->m_ptr; - - dgAssert (bin); -#ifdef _DEBUG - dgAssert ((bin->m_info.m_stepInBytes - DG_MEMORY_GRANULARITY) > 0); - memset (retPtr, 0, size_t(bin->m_info.m_stepInBytes - DG_MEMORY_GRANULARITY)); -#endif - - bin->m_info.m_count --; - if (bin->m_info.m_count == 0) { - - dgInt32 count = bin->m_info.m_totalCount; - dgInt32 sizeInBytes = bin->m_info.m_stepInBytes; - char* charPtr = bin->m_pool; - for (dgInt32 i = 0; i < count; i ++) { - dgMemoryCacheEntry* const tmpCashe1 = (dgMemoryCacheEntry*)charPtr; - charPtr += sizeInBytes; - - if (tmpCashe1 == m_memoryDirectory[entry].m_cache) { - m_memoryDirectory[entry].m_cache = tmpCashe1->m_next; - } - - if (tmpCashe1->m_prev) { - tmpCashe1->m_prev->m_next = tmpCashe1->m_next; - } - - if (tmpCashe1->m_next) { - tmpCashe1->m_next->m_prev = tmpCashe1->m_prev; - } - } - - if (m_memoryDirectory[entry].m_first == bin) { - m_memoryDirectory[entry].m_first = bin->m_info.m_next; - } - - if (bin->m_info.m_next) { - bin->m_info.m_next->m_info.m_prev = bin->m_info.m_prev; - } - if (bin->m_info.m_prev) { - bin->m_info.m_prev->m_info.m_next = bin->m_info.m_next; - } - - FreeLow (bin); - } - } -} - -dgInt32 dgMemoryAllocator::GetSize (void* const retPtr) -{ - dgMemoryInfo* const info = ((dgMemoryInfo*)(retPtr)) - 1; - return info->m_size; -} - -void dgMemoryAllocator::SetGlobalAllocators (dgMemAlloc malloc, dgMemFree free) -{ - dgGlobalAllocator::GetGlobalAllocator().SetAllocatorsCallback (malloc, free); -} - -dgInt32 dgMemoryAllocator::GetGlobalMemoryUsed () -{ - return dgGlobalAllocator::GetGlobalAllocator().GetMemoryUsed(); -} - -// this can be used by function that allocates large memory pools memory locally on the stack -// this by pases the pool allocation because this should only be used for very large memory blocks. -// this was using virtual memory on windows but -// but because of many complaint I changed it to use malloc and free -void* dgApi dgMallocStack (size_t size) -{ - void * const ptr = dgGlobalAllocator::GetGlobalAllocator().MallocLow (dgInt32 (size)); - return ptr; -} - -void* dgApi dgMallocAligned (size_t size, dgInt32 align) -{ - void * const ptr = dgGlobalAllocator::GetGlobalAllocator().MallocLow (dgInt32 (size), align); - return ptr; -} - -// this can be used by function that allocates large memory pools memory locally on the stack -// this by pases the pool allocation because this should only be used for very large memory blocks. -// this was using virtual memory on windows but -// but because of many complaint I changed it to use malloc and free -void dgApi dgFreeStack (void* const ptr) -{ - dgGlobalAllocator::GetGlobalAllocator().FreeLow (ptr); -} - -// general memory allocation for all data in the library -void* dgApi dgMalloc (size_t size, dgMemoryAllocator* const allocator) -{ - void* ptr = NULL; - dgAssert (allocator); - - if (size) { - ptr = allocator->Malloc (dgInt32 (size)); - } - return ptr; -} - -// general deletion allocation for all data in the library -void dgApi dgFree (void* const ptr) -{ - if (ptr) { - dgMemoryAllocator::dgMemoryInfo* const info = ((dgMemoryAllocator::dgMemoryInfo*) ptr) - 1; - dgAssert (info->m_allocator); - info->m_allocator->Free (ptr); - } -} - -#else - - -void* dgGlobalAllocator::__malloc__(dgUnsigned32 size) -{ - return malloc(size); -} - -void dgGlobalAllocator::__free__(void* const ptr, dgUnsigned32 size) -{ - free(ptr); -} - -void dgGlobalAllocator::SetAllocatorsCallback (dgMemAlloc malloc, dgMemFree free) -{ - m_free = free; - m_malloc = malloc; -} - - -void* dgGlobalAllocator::Malloc(dgInt32 size) -{ - dgInt32 paddedSize = size + sizeof (dgMemoryAllocator::dgMemoryGranularity) + sizeof (dgMemoryAllocator::dgMemoryHeader); - char* const ptr = (char*)m_malloc(paddedSize); - - dgUnsigned64 address = dgUnsigned64(ptr + sizeof (dgMemoryAllocator::dgMemoryHeader) + sizeof (dgMemoryAllocator::dgMemoryGranularity)-1) & ~(sizeof (dgMemoryAllocator::dgMemoryGranularity)-1); - - dgMemoryAllocator::dgMemoryHeader* const info = ((dgMemoryAllocator::dgMemoryHeader*)address) - 1; - info->m_ptr = ptr; - info->m_allocator = this; - info->m_size = size; - info->m_paddedSize = paddedSize; - dgAtomicExchangeAndAdd(&m_memoryUsed, paddedSize); - return &info[1]; -} - -void dgGlobalAllocator::Free(void* const ptr) -{ - dgMemoryAllocator::dgMemoryHeader* const info = ((dgMemoryAllocator::dgMemoryHeader*)ptr) - 1; - dgAssert(info->m_allocator == this); - - dgAtomicExchangeAndAdd(&m_memoryUsed, -info->m_paddedSize); - m_free(info->m_ptr, info->m_paddedSize); -} - -dgMemoryAllocatorBase& dgGlobalAllocator::GetGlobalAllocator() -{ - static dgGlobalAllocator m_globalAllocator; - return m_globalAllocator; -} - - -dgMemoryAllocator::dgMemoryPage::dgMemoryPage(dgInt32 size, dgMemoryPage* const root, dgMemoryAllocator* const allocator) - :m_next(root) - ,m_prev(NULL) - ,m_fullPageNext(NULL) - ,m_fullPagePrev(NULL) - ,m_freeList (NULL) - ,m_count(0) - ,m_capacity(0) -{ - if (root) { - dgAssert (!root->m_prev); - root->m_prev = this; - } - dgInt32 paddSize = size + sizeof (dgMemoryHeader); - dgAssert ((paddSize & (sizeof (dgMemoryGranularity) - 1)) == 0); - - const char* const ptr1 = &m_buffer[sizeof (m_buffer) - paddSize]; - for (char* ptr = &m_buffer[sizeof (dgMemoryGranularity)]; ptr <= ptr1; ptr += paddSize) { - dgAssert ((dgUnsigned64(ptr) & (sizeof (dgMemoryGranularity) - 1)) == 0); - - dgMemoryGranularity* const freeList = (dgMemoryGranularity*) ptr; - dgMemoryHeader* const header = ((dgMemoryHeader*)freeList) - 1; - header->m_page = this; - header->m_allocator = allocator; - header->m_size = 0; - header->m_paddedSize = size; - - freeList->m_next = m_freeList; - m_freeList = freeList; - m_count ++; - } - - m_capacity = m_count; -} - -dgMemoryAllocator::dgMemoryPage::~dgMemoryPage() -{ - dgAssert(m_count == m_capacity); -} - -void *dgMemoryAllocator::dgMemoryPage::operator new (size_t size) -{ - dgMemoryAllocatorBase& globalAllocator = dgGlobalAllocator::GetGlobalAllocator(); - return globalAllocator.Malloc(dgInt32 (size)); -} - -void dgMemoryAllocator::dgMemoryPage::operator delete (void* const ptr) -{ - dgMemoryAllocatorBase& globalAllocator = dgGlobalAllocator::GetGlobalAllocator(); - globalAllocator.Free(ptr); -} - -void* dgMemoryAllocator::dgMemoryPage::Malloc(dgInt32 size) -{ - m_count --; - dgAssert (m_count >= 0); - dgMemoryGranularity* const freeList = m_freeList; - m_freeList = m_freeList->m_next; - - dgMemoryHeader* const header = ((dgMemoryHeader*)freeList) - 1; - header->m_size = size; - return freeList; -} - -void dgMemoryAllocator::dgMemoryPage::Free(void* const ptr) -{ - m_count++; - dgAssert(m_count <= m_capacity); - dgMemoryHeader* const info = ((dgMemoryHeader*)ptr) - 1; - info->m_size = 0; - - dgMemoryGranularity* const freeList = (dgMemoryGranularity*) ptr; - freeList->m_next = m_freeList; - m_freeList = freeList; -} - -dgMemoryAllocator::dgMemoryBeam::dgMemoryBeam() - :m_firstPage(NULL) - ,m_fullPage(NULL) - ,m_beamSize(0) - ,m_inUsedCount(0) - ,m_fullPageCount(0) -{ -} - -dgMemoryAllocator::dgMemoryBeam::~dgMemoryBeam() -{ - while (m_firstPage) { - if (m_firstPage->m_next) { - m_firstPage->m_next->m_prev = NULL; - } - dgMemoryPage* const firstPage = m_firstPage; - m_firstPage = m_firstPage->m_next; - delete firstPage; - } - - while (m_fullPage) { - dgAssert(0); - if (m_fullPage->m_fullPageNext) { - m_fullPage->m_fullPageNext->m_fullPagePrev = NULL; - } - dgMemoryPage* const fullPage = m_fullPage; - m_fullPage = m_fullPage->m_fullPageNext; - delete fullPage; - } - - m_fullPage = NULL; - m_firstPage = NULL; -} - -void* dgMemoryAllocator::dgMemoryBeam::Malloc(dgInt32 size) -{ - dgAssert (size <= m_beamSize); - if (!m_firstPage) { - m_firstPage = new dgMemoryPage (m_beamSize, m_firstPage, m_allocator); - m_inUsedCount ++; - } - - dgAssert (m_firstPage->m_count); - //if (m_firstPage->m_count == 0) { - // m_firstPage = new dgMemoryPage (m_beamSize, m_firstPage, m_allocator); - //} - - void* ptr = m_firstPage->Malloc(size); - if (m_firstPage->m_count == 0) { - dgMemoryPage* const page = m_firstPage; - - m_inUsedCount --; - m_fullPageCount ++; - - m_firstPage = page->m_next; - if (m_firstPage) { - m_firstPage->m_prev = NULL; - } - page->m_next = NULL; - page->m_prev = NULL; - - dgAssert(!page->m_fullPageNext); - dgAssert(!page->m_fullPagePrev); - page->m_fullPageNext = m_fullPage; - if (m_fullPage) { - m_fullPage->m_fullPagePrev = page; - } - m_fullPage = page; - } - return ptr; -} - -void dgMemoryAllocator::dgMemoryBeam::Free(void* const ptr) -{ - dgMemoryHeader* const info = ((dgMemoryHeader*)ptr) - 1; - dgMemoryPage* const page = info->m_page; - - page->Free(ptr); - dgAssert (page->m_count <= page->m_capacity); - if (page->m_count == page->m_capacity) { - m_inUsedCount --; - if (page == m_firstPage) { - m_firstPage = m_firstPage->m_next; - } - if (page->m_next) { - page->m_next->m_prev = page->m_prev; - } - if (page->m_prev) { - page->m_prev->m_next = page->m_next; - } - page->m_next = NULL; - page->m_prev = NULL; - delete page; - } else if (page->m_count == 1) { - - m_inUsedCount++; - m_fullPageCount--; - - if (page == m_fullPage) { - m_fullPage = m_fullPage->m_fullPageNext; - } - if (page->m_fullPageNext) { - page->m_fullPageNext->m_fullPagePrev = page->m_fullPagePrev; - } - if (page->m_fullPagePrev) { - page->m_fullPagePrev->m_fullPageNext = page->m_fullPageNext; - } - page->m_fullPagePrev = NULL; - page->m_fullPageNext = NULL; - - dgAssert(!page->m_next); - dgAssert(!page->m_prev); - page->m_next = m_firstPage; - if (m_firstPage) { - m_firstPage->m_prev = page; - } - m_firstPage = page; - -// } else if (page->m_prev) { -// dgInt32 key = page->GetSortKey(); -// dgMemoryPage* prevPage = page->m_prev; -// while (prevPage && prevPage->GetSortKey() < key) -// { -// prevPage = prevPage->m_prev; -// } -// -// if (prevPage) { -// dgAssert(0); -// } else { -// dgAssert(0); -// } - } -} - -void dgMemoryAllocator::dgMemoryBeam::Init(dgInt32 size, dgMemoryAllocator* const allocator) -{ - m_beamSize = size; - m_allocator = allocator; -} - -dgMemoryAllocator::dgMemoryAllocator() -{ -// for (dgInt32 i = 0; i < DG_MEMORY_BEAMS_COUNT; i++) { -// dgInt32 size = ((dgInt32 (sizeof (dgMemoryGranularity) * (dgPow(dgFloat32(1.6f), i + 2) - dgPow(dgFloat32(1.6f), i + 1))) + sizeof(dgMemoryGranularity) - 1) & -dgInt32 (sizeof(dgMemoryGranularity))) - sizeof (dgMemoryHeader); -// m_beams[i].Init (size, this); -// } - - dgInt32 index = 0; - dgInt32 size0 = 0; - dgFloat32 base = dgFloat32(1.3f); - dgFloat32 exp = dgFloat32 (0.0f); - while (index < DG_MEMORY_BEAMS_COUNT) { - dgFloat32 x0 = dgPow(base, exp); - dgFloat32 x1 = dgPow(base, exp + dgFloat32(1.0f)); - dgInt32 size = ((dgInt32(sizeof(dgMemoryGranularity) * (x1 - x0) + sizeof(dgMemoryGranularity) - 1)) & -dgInt32(sizeof(dgMemoryGranularity))) - sizeof(dgMemoryHeader); - exp += dgFloat32(1.0f); - if (size > size0) { - size0 = size; - m_beams[index].Init(size, this); - index++; - } - } -} - -dgMemoryAllocator::~dgMemoryAllocator() -{ -} - -void *dgMemoryAllocator::operator new (size_t size) -{ - dgMemoryAllocatorBase& globalAllocator = dgGlobalAllocator::GetGlobalAllocator(); - return globalAllocator.Malloc(dgInt32 (size)); -} - -void dgMemoryAllocator::operator delete (void* const ptr) -{ - dgMemoryAllocatorBase& globalAllocator = dgGlobalAllocator::GetGlobalAllocator(); - globalAllocator.Free (ptr); -} - -void dgMemoryAllocator::SetGlobalAllocators(dgMemAlloc malloc, dgMemFree free) -{ - dgGlobalAllocator* const globalAllocator = (dgGlobalAllocator*)&dgGlobalAllocator::GetGlobalAllocator(); - globalAllocator->SetAllocatorsCallback(malloc, free); -} - -dgInt32 dgMemoryAllocator::GetGlobalMemoryUsed() -{ - dgGlobalAllocator* const globalAllocator = (dgGlobalAllocator*)&dgGlobalAllocator::GetGlobalAllocator(); - return globalAllocator->GetMemoryUsed(); -} - -dgInt32 dgMemoryAllocator::GetSize (void* const ptr) -{ - dgMemoryHeader* const info = ((dgMemoryHeader*)ptr) - 1; - return info->m_size; -} - -void* dgMemoryAllocator::Malloc(dgInt32 size) -{ - dgMemoryAllocatorBase& globalAllocator = dgGlobalAllocator::GetGlobalAllocator(); - if (size > m_beams[DG_MEMORY_BEAMS_COUNT-1].m_beamSize) { - return globalAllocator.Malloc(size); - } else { - dgMemoryBeam* const beam = FindBeam(size); - return beam->Malloc(size); - } -} - -void dgMemoryAllocator::Free(void* const ptr) -{ - dgMemoryHeader* const info = ((dgMemoryHeader*)ptr) - 1; - dgMemoryAllocatorBase& globalAllocator = dgGlobalAllocator::GetGlobalAllocator(); - if (info->m_size > m_beams[DG_MEMORY_BEAMS_COUNT - 1].m_beamSize) { - globalAllocator.Free (ptr); - } else { - dgMemoryBeam* const beam = FindBeam(info->m_size); - beam->Free(ptr); - } -} - -dgMemoryAllocator::dgMemoryBeam* dgMemoryAllocator::FindBeam(dgInt32 size) -{ - dgInt32 i = m_beams[DG_MEMORY_BEAMS_COUNT / 2].m_beamSize >= size ? 0 : DG_MEMORY_BEAMS_COUNT / 2; - for (; i < DG_MEMORY_BEAMS_COUNT; i++) { - if (m_beams[i].m_beamSize >= size) { - return &m_beams[i]; - } - } - dgAssert(0); - return NULL; -} - - -#endif \ No newline at end of file diff --git a/thirdparty/src/newton/dgCore/dgMemory.h b/thirdparty/src/newton/dgCore/dgMemory.h deleted file mode 100644 index 62ecb9897..000000000 --- a/thirdparty/src/newton/dgCore/dgMemory.h +++ /dev/null @@ -1,352 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgMemory__ -#define __dgMemory__ - -#include "dgStdafx.h" - -class dgMemoryAllocator; - -#define DG_CLASS_ALLOCATOR_NEW(allocator) DG_INLINE void* operator new (size_t size, dgMemoryAllocator* const allocator) { return dgMalloc(size, allocator);} -#define DG_CLASS_ALLOCATOR_NEW_ARRAY(allocator) DG_INLINE void* operator new[] (size_t size, dgMemoryAllocator* const allocator) { return dgMalloc(size, allocator);} -#define DG_CLASS_ALLOCATOR_DELETE(allocator) DG_INLINE void operator delete (void* const ptr, dgMemoryAllocator* const allocator) { dgFree(ptr); } -#define DG_CLASS_ALLOCATOR_DELETE_ARRAY(allocator) DG_INLINE void operator delete[] (void* const ptr, dgMemoryAllocator* const allocator) { dgFree(ptr); } -#define DG_CLASS_ALLOCATOR_NEW_DUMMY DG_INLINE void* operator new (size_t size) { dgAssert (0); return dgMalloc(size, NULL);} -#define DG_CLASS_ALLOCATOR_NEW_ARRAY_DUMMY DG_INLINE void* operator new[] (size_t size) { dgAssert (0); return dgMalloc(size, NULL);} -#define DG_CLASS_ALLOCATOR_DELETE_DUMMY DG_INLINE void operator delete (void* const ptr) { dgFree(ptr); } -#define DG_CLASS_ALLOCATOR_DELETE_ARRAY_DUMMY DG_INLINE void operator delete[] (void* const ptr) { dgFree(ptr); } - - -#define DG_CLASS_ALLOCATOR(allocator) \ - DG_CLASS_ALLOCATOR_DELETE(allocator) \ - DG_CLASS_ALLOCATOR_DELETE_ARRAY(allocator) \ - DG_CLASS_ALLOCATOR_NEW(allocator) \ - DG_CLASS_ALLOCATOR_NEW_ARRAY(allocator) \ - DG_CLASS_ALLOCATOR_NEW_DUMMY \ - DG_CLASS_ALLOCATOR_NEW_ARRAY_DUMMY \ - DG_CLASS_ALLOCATOR_DELETE_DUMMY \ - DG_CLASS_ALLOCATOR_DELETE_ARRAY_DUMMY - -typedef void* (dgApi *dgMemAlloc) (dgUnsigned32 size); -typedef void (dgApi *dgMemFree) (void* const ptr, dgUnsigned32 size); - -#define DG_OLD_ALLOCATOR - -#ifdef DG_OLD_ALLOCATOR - -void* dgApi dgMalloc (size_t size, dgMemoryAllocator* const allocator); -void dgApi dgFree (void* const ptr); - -void* dgApi dgMallocStack (size_t size); -void* dgApi dgMallocAligned (size_t size, dgInt32 alignmentInBytes); -void dgApi dgFreeStack (void* const ptr); - - - -class dgMemoryAllocator -{ - #if (defined (__LP64__) || defined (_WIN_64_VER) || defined (__MINGW64__) || defined (_POSIX_VER_64) || defined (_MACOSX_VER)) - #define DG_MEMORY_GRANULARITY_BITS 6 - #else - #define DG_MEMORY_GRANULARITY_BITS 5 - #endif - #define DG_MEMORY_GRANULARITY (1 << DG_MEMORY_GRANULARITY_BITS) - #define DG_MEMORY_SIZE (1024 - 64) - #define DG_MEMORY_BIN_SIZE (1024 * 16) - #define DG_MEMORY_BIN_ENTRIES (DG_MEMORY_SIZE / DG_MEMORY_GRANULARITY) - - public: - class dgMemoryBin; - class dgMemoryInfo; - class dgMemoryCacheEntry; - - class dgMemDirectory - { - public: - dgMemoryBin* m_first; - dgMemoryCacheEntry* m_cache; - }; - - dgMemoryAllocator (); - virtual ~dgMemoryAllocator (); - - void *operator new (size_t size); - void operator delete (void* const ptr); - dgInt32 GetMemoryUsed() const; - - void SetAllocatorsCallback (dgMemAlloc memAlloc, dgMemFree memFree); - virtual void *MallocLow (dgInt32 size, dgInt32 alignment = DG_MEMORY_GRANULARITY); - virtual void FreeLow (void* const retPtr); - virtual void *Malloc (dgInt32 memsize); - virtual void Free (void* const retPtr); - virtual int GetSize (void* const retPtr); - - static dgInt32 GetGlobalMemoryUsed (); - static void SetGlobalAllocators (dgMemAlloc alloc, dgMemFree free); - - protected: - dgMemoryAllocator (bool init) - :m_free(NULL) - ,m_malloc(NULL) - ,m_enumerator(0) - ,m_memoryUsed(0) - ,m_isInList(0) - { - } - - dgMemoryAllocator (dgMemAlloc memAlloc, dgMemFree memFree); - - dgMemFree m_free; - dgMemAlloc m_malloc; - dgMemDirectory m_memoryDirectory[DG_MEMORY_BIN_ENTRIES + 1]; - dgInt32 m_enumerator; - dgInt32 m_memoryUsed; - dgInt32 m_isInList; - - public: - static dgInt32 m_lock0; - static dgInt32 m_lock1; -}; - -class dgStackMemoryAllocator: public dgMemoryAllocator -{ - public: - DG_INLINE dgStackMemoryAllocator(void* const pool, dgInt32 size) - :dgMemoryAllocator (false) - ,m_pool((dgInt8*) pool) - ,m_index(0) - ,m_size(size) - { - } - - DG_INLINE ~dgStackMemoryAllocator() - { - } - - DG_INLINE void* Alloc(dgInt32 size) - { - dgInt8* const ptr = (dgInt8*) (reinterpret_cast<uintptr_t>(m_pool + m_index + 15) & -0x10); - m_index = dgInt32 (ptr - m_pool) + size; - dgAssert (m_index < m_size); - return ptr; - } - - DG_INLINE void* Malloc(dgInt32 size) - { - return Alloc(size); - } - - DG_INLINE void* MallocLow(dgInt32 size, dgInt32 alignment) - { - return Alloc(size); - } - - DG_INLINE void Free(void* const retPtr) - { - } - - DG_INLINE void FreeLow(void* const retPtr) - { - } - - dgInt8* m_pool; - dgInt32 m_index; - dgInt32 m_size; -}; - -#else - - -class dgMemoryAllocatorBase -{ - public: - dgMemoryAllocatorBase() {} - virtual ~dgMemoryAllocatorBase() {} - - virtual void* Malloc(dgInt32 size) = 0; - virtual void Free(void* const ptr) = 0; -}; - -class dgGlobalAllocator: public dgMemoryAllocatorBase -{ - public: - dgGlobalAllocator() - :dgMemoryAllocatorBase() - ,m_free(__free__) - ,m_malloc(__malloc__) - ,m_memoryUsed(0) - { - } - - ~dgGlobalAllocator() - { - } - - void SetAllocatorsCallback(dgMemAlloc malloc, dgMemFree free); - - static dgMemoryAllocatorBase& GetGlobalAllocator(); - dgInt32 GetMemoryUsed() const { return m_memoryUsed; } - - private: - static void* dgApi __malloc__(dgUnsigned32 size); - static void dgApi __free__(void* const ptr, dgUnsigned32 size); - - void* Malloc(dgInt32 size); - void Free(void* const ptr); - - dgMemFree m_free; - dgMemAlloc m_malloc; - dgInt32 m_memoryUsed; -}; - - -class dgMemoryAllocator: public dgMemoryAllocatorBase -{ - public: - #define DG_MEMORY_GRANULARITY_BITS 6 - #define DG_MEMORY_GRANULARITY (1 << DG_MEMORY_GRANULARITY_BITS) - #define DG_MEMORY_BEAMS_COUNT 16 -// #define DG_MEMORY_BEAMS_COUNT 1 - #define DG_MEMORY_BEAMS_BUFFER_SIZE (1024 * 32) - - class dgMemoryPage; - class dgMemoryHeader - { - public: - dgMemoryAllocatorBase* m_allocator; - union { - void* m_ptr; - dgMemoryPage* m_page; - }; - dgInt32 m_size; - dgInt32 m_paddedSize; - }; - - class dgMemoryGranularity - { - public: - union - { - dgMemoryGranularity* m_next; - char m_padd1[DG_MEMORY_GRANULARITY]; - }; - }; - - class dgMemoryPage - { - public: - dgMemoryPage(dgInt32 size, dgMemoryPage* const root, dgMemoryAllocator* const allocator); - ~dgMemoryPage(); - void *operator new (size_t size); - void operator delete (void* const ptr); - - void* Malloc(dgInt32 size); - void Free(void* const ptr); - - char m_buffer[DG_MEMORY_BEAMS_BUFFER_SIZE]; - - dgMemoryPage* m_next; - dgMemoryPage* m_prev; - dgMemoryPage* m_fullPageNext; - dgMemoryPage* m_fullPagePrev; - dgMemoryGranularity* m_freeList; - dgInt32 m_count; - dgInt32 m_capacity; - }; - - class dgMemoryBeam - { - public: - dgMemoryBeam(); - ~dgMemoryBeam(); - void Init(dgInt32 size, dgMemoryAllocator* const allocator); - - void* Malloc(dgInt32 size); - void Free(void* const ptr); - - dgMemoryPage* m_firstPage; - dgMemoryPage* m_fullPage; - dgMemoryAllocator* m_allocator; - dgInt32 m_beamSize; - - dgInt32 m_inUsedCount; - dgInt32 m_fullPageCount; - }; - - dgMemoryAllocator(); - virtual ~dgMemoryAllocator(); - - virtual void* Malloc(dgInt32 size); - virtual void Free(void* const ptr); - virtual dgInt32 GetSize (void* const ptr); - - void* MallocLow(dgInt32 size, dgInt32 aligment=DG_MEMORY_GRANULARITY) - { - return Malloc(size); - } - - void FreeLow(void* const ptr) - { - Free (ptr); - } - - static dgInt32 GetGlobalMemoryUsed(); - static void SetGlobalAllocators(dgMemAlloc alloc, dgMemFree free); - - void *operator new (size_t size); - void operator delete (void* const ptr); - - private: - dgMemoryBeam* FindBeam(dgInt32 size); - - dgMemoryBeam m_beams[DG_MEMORY_BEAMS_COUNT]; -}; - - -DG_INLINE void* dgMalloc(size_t size, dgMemoryAllocatorBase* const allocator) -{ - void* const ptr = allocator->Malloc(dgInt32(size)); - return ptr; -} - -DG_INLINE void dgFree(void* const ptr) -{ - dgMemoryAllocator::dgMemoryHeader* const info = ((dgMemoryAllocator::dgMemoryHeader*)ptr) - 1; - dgAssert(info->m_allocator); - info->m_allocator->Free(ptr); -} - -DG_INLINE void* dgMallocStack(size_t size) -{ - return dgMalloc(size, (dgGlobalAllocator*) &dgGlobalAllocator::GetGlobalAllocator()); -} - -DG_INLINE void dgFreeStack(void* const ptr) -{ - dgFree(ptr); -} - - -#endif - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgMutexThread.cpp b/thirdparty/src/newton/dgCore/dgMutexThread.cpp deleted file mode 100644 index bf6a3db84..000000000 --- a/thirdparty/src/newton/dgCore/dgMutexThread.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgThread.h" -#include "dgMutexThread.h" - - -dgMutexThread::dgMutexThread(const char* const name, dgInt32 id) - :dgThread(name, id) - ,m_mutex() - ,m_parentMutex() -{ - Init (); -} - -dgMutexThread::~dgMutexThread(void) -{ - Terminate(); -} - -void dgMutexThread::Terminate() -{ - if (IsThreadActive()) { - dgInterlockedExchange(&m_terminate, 1); - m_mutex.Release(); - Close(); - } -} - -void dgMutexThread::Execute (dgInt32 threadID) -{ - // suspend this tread until the call thread decide to - dgAssert (threadID == m_id); - while (!m_terminate) { - // wait for the main thread to signal an update - m_mutex.Wait(); - if (!m_terminate) { - TickCallback(threadID); - } - m_parentMutex.Release(); - } -} - -void dgMutexThread::Tick() -{ - // let the thread run until the update function return - m_mutex.Release(); - m_parentMutex.Wait(); -} - -dgAsyncThread::dgAsyncThread(const char* const name, dgInt32 id) - :dgThread(name, id) - ,m_mutex() - ,m_inUpdate(0) - ,m_beginUpdate(0) -{ - Init(); -} - -dgAsyncThread::~dgAsyncThread(void) -{ - Terminate(); -} - -void dgAsyncThread::Terminate() -{ - if (IsThreadActive()) { - dgInterlockedExchange(&m_terminate, 1); - m_mutex.Release(); - Close(); - } -} - -void dgAsyncThread::Sync() -{ - while (m_inUpdate) { - dgThreadYield(); - } -} - -void dgAsyncThread::Tick() -{ - // let the thread run until the update function return - Sync(); - m_beginUpdate = 0; - m_mutex.Release(); - while (!m_beginUpdate) { - dgThreadPause(); - } -} - - -void dgAsyncThread::Execute(dgInt32 threadID) -{ - dgAssert(threadID == m_id); - while (!m_terminate) { - m_mutex.Wait(); - if (!m_terminate) { - dgInterlockedExchange(&m_inUpdate, 1); - dgInterlockedExchange(&m_beginUpdate, 1); - TickCallback(threadID); - dgInterlockedExchange(&m_inUpdate, 0); - } - } -} \ No newline at end of file diff --git a/thirdparty/src/newton/dgCore/dgMutexThread.h b/thirdparty/src/newton/dgCore/dgMutexThread.h deleted file mode 100644 index 725f47c4f..000000000 --- a/thirdparty/src/newton/dgCore/dgMutexThread.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DG_MUTEX_THREAD_H__ -#define __DG_MUTEX_THREAD_H__ - -#include "dgTypes.h" -#include "dgThread.h" - -class dgMutexThread: public dgThread -{ - public: - dgMutexThread(const char* const name, dgInt32 id); - virtual ~dgMutexThread(void); - - void Tick(); - void Terminate(); - - protected: - virtual void Execute (dgInt32 threadID); - virtual void TickCallback (dgInt32 threadID) = 0; - - private: - dgSemaphore m_mutex; - dgSemaphore m_parentMutex; -}; - - -class dgAsyncThread: public dgThread -{ - public: - dgAsyncThread(const char* const name, dgInt32 id); - virtual ~dgAsyncThread(void); - - void Tick(); - void Sync(); - void Terminate(); - - protected: - virtual void Execute(dgInt32 threadID); - virtual void TickCallback(dgInt32 threadID) = 0; - - private: - dgSemaphore m_mutex; - dgInt32 m_inUpdate; - dgInt32 m_beginUpdate; -}; -#endif \ No newline at end of file diff --git a/thirdparty/src/newton/dgCore/dgNode.cpp b/thirdparty/src/newton/dgCore/dgNode.cpp deleted file mode 100644 index 02dc635e0..000000000 --- a/thirdparty/src/newton/dgCore/dgNode.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgNode.h" - - -dgInitRtti(dgBaseNode); - -dgBaseNode::dgBaseNode (const dgBaseNode &clone) - :dgRef (clone) -{ - Clear (); - - for (dgBaseNode* obj = clone.child; obj; obj = obj->sibling) { - dgBaseNode* newObj = (dgBaseNode *)obj->CreateClone (); - newObj->Attach (this); - newObj->Release(); - } -} - - -dgBaseNode::~dgBaseNode () -{ - if (child) { - dgBaseNode* tmp; - for (dgBaseNode* ptr = child; ptr && ptr->Release(); ptr = tmp) { - ptr->Kill(); - tmp = ptr->sibling; - ptr->parent = NULL; - ptr->sibling = NULL; - } - } - - dgBaseNode* tmp; - for (dgBaseNode* ptr = sibling; ptr && ptr->Release(); ptr = tmp) { - ptr->Kill(); - tmp = ptr->sibling; - ptr->parent = NULL; - ptr->sibling = NULL; - } -} - -void dgBaseNode::CloneFixUp (const dgBaseNode &clone) -{ - dgAssert (GetNameID() == clone.GetNameID()); - - dgBaseNode* cloneChild = clone.GetChild(); - for (dgBaseNode* obj = child; obj; obj = obj->sibling) { - obj->CloneFixUp (*cloneChild); - cloneChild = cloneChild->GetSibling(); - } -} - - -void dgBaseNode::Attach (dgBaseNode *parentArg, bool addFirst) -{ - dgAssert (!parent); - dgAssert (!sibling); - dgAssert (parentArg); - - - parent = parentArg; - if (parent->child) { - if (addFirst) { - sibling = parent->child; - parent->child = this; - } else { - dgBaseNode* obj = parent->child; - for (; obj->sibling; obj = obj->sibling) - { - - } - obj->sibling = this; - } - } else { - parent->child = this; - } - - AddRef(); -} - - -void dgBaseNode::Detach () -{ - if (parent) { - if (parent->child == this) { - parent->child = sibling; - } else { - dgBaseNode* ptr = parent->child; - for (; ptr->sibling != this; ptr = ptr->sibling) - { - - } - ptr->sibling = sibling; - } - parent = NULL; - sibling = NULL; - Release(); - } -} - - -dgBaseNode* dgBaseNode::GetRoot() const -{ - const dgBaseNode* root = this; - for (; root->parent; root = root->parent) - { - - } - return (dgBaseNode*)root; -} - - -dgBaseNode* dgBaseNode::GetFirst() const -{ - dgBaseNode* ptr = (dgBaseNode *)this; - for (; ptr->child; ptr = ptr->child) - { - - } - return ptr; -} - -dgBaseNode* dgBaseNode::GetNext() const -{ - if (sibling) { - return sibling->GetFirst(); - } - - dgBaseNode* ptr = parent; - dgBaseNode* x = (dgBaseNode *)this; - for (; ptr && (x == ptr->sibling); ptr = ptr->parent) { - x = ptr; - } - return ptr; -} - - - -dgBaseNode* dgBaseNode::GetLast() const -{ - - dgBaseNode* ptr = (dgBaseNode *)this; - for (ptr = (dgBaseNode *)this; ptr->sibling; ptr = ptr->sibling) - { - - } - return ptr; -} - - -dgBaseNode* dgBaseNode::GetPrev() const -{ - if (child) { - return child->GetNext(); - } - - dgBaseNode* ptr = parent; - dgBaseNode* x = (dgBaseNode *)this; - for (; ptr && (x == ptr->child); ptr = ptr->child) { - x = ptr; - } - return ptr; -} - - - -dgBaseNode* dgBaseNode::Find (dgUnsigned32 nameCRC) const -{ - dgBaseNode *ptr = GetFirst(); - for (; ptr; ptr = ptr->GetNext()) { - if (nameCRC == ptr->GetNameID()) { - break; - } - } - return ptr; -} - -bool dgBaseNode::SanityCheck() -{ - return true; -} - -void dgBaseNode::PrintHierarchy ( - dgFile &file, - char *indent) const -{ - char newIndent[1024]; - - sprintf (newIndent, "%s ", indent); - for (dgBaseNode *node = child; node; node = node->sibling) { - node->PrintHierarchy (file, newIndent); - } -} - - -void dgBaseNode::DebugPrint (const char *fileName) -{ -/* - char indent[512]; - - indent[0] = '\0'; - dgFile file (fileName, "w"); - PrintHierarchy (file, indent); -*/ -} - - - - - - diff --git a/thirdparty/src/newton/dgCore/dgNode.h b/thirdparty/src/newton/dgCore/dgNode.h deleted file mode 100644 index 3b3bd07b2..000000000 --- a/thirdparty/src/newton/dgCore/dgNode.h +++ /dev/null @@ -1,262 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgNode__ -#define __dgNode__ - -#include "dgStdafx.h" -#include "dgCRC.h" -#include "dgRef.h" -#include "dgRtti.h" - - -class dgFile; -//enum dgSaveType; - - -class dgBaseNode: public dgRef -{ - public: - dgBaseNode *GetChild () const; - dgBaseNode *GetParent () const; - dgBaseNode *GetSibling () const; - - void Detach (); - void Attach (dgBaseNode* const parent, bool addFirst = false); - - dgBaseNode *GetRoot () const; - dgBaseNode *GetFirst() const; - dgBaseNode *GetLast() const; - dgBaseNode *GetNext() const; - dgBaseNode *GetPrev() const; - - dgBaseNode *Find (dgUnsigned32 nameCRC) const; - dgBaseNode *Find (const char* const name) const; - void DebugPrint (const char* const fileName); - bool SanityCheck(); - - - protected: - dgBaseNode (); - dgBaseNode (const char* const name); - dgBaseNode (const dgBaseNode &clone); - ~dgBaseNode (); - -// virtual void Save (dgFile &file, dgSaveType saveType, void* const context) const; - virtual void CloneFixUp (const dgBaseNode &clone); - virtual void PrintHierarchy (dgFile &file, char* indentation) const; - - private: - inline void Clear(); - - dgAddRtti(dgRef); - dgBaseNode* parent; - dgBaseNode* child; - dgBaseNode* sibling; - -}; - -template<class T> -class dgNode: public dgBaseNode -{ - public: - dgNode (); - dgNode (const char* const name); - void Attach (T* parent, bool addFirst = false); - void Detach (); - T* GetChild () const; - T* GetSibling () const; - T* GetParent () const; - T* GetRoot () const; - T* GetFirst() const; - T* GetLast() const; - T* GetNext() const; - T* GetPrev() const; - T* Find (dgUnsigned32 nameCRC) const; - T* Find (const char* const name) const; - - protected: - dgNode (const T &clone); - virtual ~dgNode (); - dgRef *CreateClone () const; - -}; - - - - - -inline dgBaseNode::dgBaseNode () - :dgRef () -{ - Clear (); -} - -inline dgBaseNode::dgBaseNode (const char* const name) - :dgRef (name) -{ - Clear (); -} - - -inline void dgBaseNode::Clear() -{ - child = NULL; - parent = NULL; - sibling = NULL; -} - - -inline dgBaseNode *dgBaseNode::GetChild () const -{ - return child; -} - -inline dgBaseNode *dgBaseNode::GetSibling () const -{ - return sibling; -} - -inline dgBaseNode *dgBaseNode::GetParent () const -{ - return parent; -} - - -inline dgBaseNode *dgBaseNode::Find (const char* const name) const -{ - return Find (dgCRC (name)); -} - - - - -template<class T> -dgNode<T>::dgNode () - :dgBaseNode () -{ -} - -template<class T> -dgNode<T>::dgNode (const T &clone) - :dgBaseNode (clone) -{ -} - -template<class T> -dgNode<T>::dgNode (const char* const name) - :dgBaseNode (name) -{ -} - -template<class T> -dgNode<T>::~dgNode () -{ -} - - -template<class T> -dgRef *dgNode<T>::CreateClone () const -{ - return new T (*(T*)this); -} - -template<class T> -void dgNode<T>::Attach (T* const parent, bool addFirst) -{ - dgBaseNode::Attach(parent, addFirst); -} - -template<class T> -void dgNode<T>::Detach () -{ - dgBaseNode::Detach (); -} - -template<class T> -T* dgNode<T>::GetChild () const -{ - return (T*) dgBaseNode::GetChild(); -} - -template<class T> -T* dgNode<T>::GetSibling () const -{ - return (T*) dgBaseNode::GetSibling (); -} - -template<class T> -T* dgNode<T>::GetParent () const -{ - return (T*) dgBaseNode::GetParent (); -} - - -template<class T> -T* dgNode<T>::GetRoot () const -{ - return (T*) dgBaseNode::GetRoot (); -} - - -template<class T> -T* dgNode<T>::GetFirst() const -{ - return (T*) dgBaseNode::GetFirst (); -} - -template<class T> -T* dgNode<T>::GetLast() const -{ - return (T*) dgBaseNode::GetLast (); -} - - -template<class T> -T* dgNode<T>::GetNext() const -{ - return (T*) dgBaseNode::GetNext (); -} - -template<class T> -T* dgNode<T>::GetPrev() const -{ - return (T*) dgBaseNode::GetPrev (); -} - - -template<class T> -T* dgNode<T>::Find (dgUnsigned32 nameCRC) const -{ - return (T*) dgBaseNode::Find (nameCRC); -} - -template<class T> -T* dgNode<T>::Find (const char* const name) const -{ - return (T*) dgBaseNode::Find (name); -} - - - - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgObb.cpp b/thirdparty/src/newton/dgCore/dgObb.cpp deleted file mode 100644 index 3b12f2201..000000000 --- a/thirdparty/src/newton/dgCore/dgObb.cpp +++ /dev/null @@ -1,868 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgObb.h" -#include "dgDebug.h" -#include "dgPlane.h" -#include "dgMatrix.h" - - -namespace InternalSphere -{ - const dgFloat32 SPHERE_TOL = 0.002f; - - static dgFloat32 AspectRatio (dgFloat32 x, dgFloat32 y) - { - dgFloat32 tmp; - x = dgAbs (x); - y = dgAbs (y); - - if (y < x) { - tmp = y; - y = x; - x = tmp; - } - if (y < 1.0e-12) { - y = 1.0e-12f; - } - return x / y; - } - - - static void BoundingBox (const dgMatrix& matrix, const dgFloat32 vertex[], dgInt32 stride, const dgInt32 index[], dgInt32 indexCount, dgVector &min, dgVector &max) - { - dgFloat32 xmin = dgFloat32 (1.0e10f); - dgFloat32 ymin = dgFloat32 (1.0e10f); - dgFloat32 zmin = dgFloat32 (1.0e10f); - - dgFloat32 xmax = dgFloat32 (-1.0e10f); - dgFloat32 ymax = dgFloat32 (-1.0e10f); - dgFloat32 zmax = dgFloat32 (-1.0e10f); - - const dgFloat32* const ptr = vertex; - for (dgInt32 j = 0 ; j < indexCount; j ++ ) { - dgInt32 i = index[j] * stride; - dgVector tmp (ptr[i + 0], ptr[i + 1], ptr[i + 2], dgFloat32 (0.0f)); - tmp = matrix.UnrotateVector (tmp); - if (tmp.m_x < xmin) xmin = tmp.m_x; - if (tmp.m_y < ymin) ymin = tmp.m_y; - if (tmp.m_z < zmin) zmin = tmp.m_z; - if (tmp.m_x > xmax) xmax = tmp.m_x; - if (tmp.m_y > ymax) ymax = tmp.m_y; - if (tmp.m_z > zmax) zmax = tmp.m_z; - } - - min = dgVector (xmin, ymin, zmin, dgFloat32 (0.0f)); - max = dgVector (xmax, ymax, zmax, dgFloat32 (0.0f)); - } - - // Compute axis aligned box - static void BoundingBox (const dgMatrix &Mat, const dgFloat32 vertex[], dgInt32 vertexCount, dgInt32 stride, dgVector &min, dgVector &max) - { - dgFloat32 xmin = dgFloat32 (1.0e10f); - dgFloat32 ymin = dgFloat32 (1.0e10f); - dgFloat32 zmin = dgFloat32 (1.0e10f); - - dgFloat32 xmax = dgFloat32 (-1.0e10f); - dgFloat32 ymax = dgFloat32 (-1.0e10f); - dgFloat32 zmax = dgFloat32 (-1.0e10f); - - const dgFloat32* ptr = vertex; - for (dgInt32 i = 0 ; i < vertexCount; i ++ ) { - dgVector tmp (ptr[0], ptr[1], ptr[2], dgFloat32 (0.0f)); - ptr += stride; - tmp = Mat.UnrotateVector (tmp); - if (tmp.m_x < xmin) xmin = tmp.m_x; - if (tmp.m_y < ymin) ymin = tmp.m_y; - if (tmp.m_z < zmin) zmin = tmp.m_z; - if (tmp.m_x > xmax) xmax = tmp.m_x; - if (tmp.m_y > ymax) ymax = tmp.m_y; - if (tmp.m_z > zmax) zmax = tmp.m_z; - } - - min = dgVector (xmin, ymin, zmin, dgFloat32 (0.0f)); - max = dgVector (xmax, ymax, zmax, dgFloat32 (0.0f)); - } - - - static void Statistics (dgObb &sphere, dgVector &eigenValues, const dgVector &scale, const dgFloat32 vertex[], const dgInt32 faceIndex[], dgInt32 indexCount, dgInt32 stride) - { - dgVector var (dgFloat32 (0.0f)); - dgVector cov (dgFloat32 (0.0f)); - dgVector centre (dgFloat32 (0.0f)); - dgVector massCenter (dgFloat32 (0.0f)); - - dgVector scaleVector (scale & dgVector::m_triplexMask); - - dgFloat64 totalArea = dgFloat32 (0.0f); - const dgFloat32* const ptr = vertex; - for (dgInt32 i = 0; i < indexCount; i += 3) { - dgInt32 index = faceIndex[i] * stride; - dgVector p0 (&ptr[index]); - p0 = p0 & dgVector::m_triplexMask; - p0 = p0 * scaleVector; - - index = faceIndex[i + 1] * stride;; - dgVector p1 (&ptr[index]); - p1 = p1 & dgVector::m_triplexMask; - p1 = p1 * scaleVector; - - index = faceIndex[i + 2] * stride;; - dgVector p2 (&ptr[index]); - p2 = p2 & dgVector::m_triplexMask; - p2 = p2 * scaleVector; - - dgVector normal ((p1 - p0).CrossProduct(p2 - p0)); - dgAssert(normal.m_w == dgFloat32(0.0f)); - dgFloat64 area = dgFloat32 (0.5f) * sqrt (normal.DotProduct(normal).GetScalar()); - - centre = p0 + p1 + p2; - centre = centre.Scale (dgFloat32 (1.0f / 3.0f)); - - // Inertia of each point in the triangle - dgFloat64 Ixx = p0.m_x * p0.m_x + p1.m_x * p1.m_x + p2.m_x * p2.m_x; - dgFloat64 Iyy = p0.m_y * p0.m_y + p1.m_y * p1.m_y + p2.m_y * p2.m_y; - dgFloat64 Izz = p0.m_z * p0.m_z + p1.m_z * p1.m_z + p2.m_z * p2.m_z; - - dgFloat64 Ixy = p0.m_x * p0.m_y + p1.m_x * p1.m_y + p2.m_x * p2.m_y; - dgFloat64 Iyz = p0.m_y * p0.m_z + p1.m_y * p1.m_z + p2.m_y * p2.m_z; - dgFloat64 Ixz = p0.m_x * p0.m_z + p1.m_x * p1.m_z + p2.m_x * p2.m_z; - - if (area > dgEpsilon * 10.0) { - dgFloat64 K = area / dgFloat64 (12.0); - //Coriolis theorem for Inertia of a triangle in an arbitrary orientation - Ixx = K * (Ixx + 9.0 * centre.m_x * centre.m_x); - Iyy = K * (Iyy + 9.0 * centre.m_y * centre.m_y); - Izz = K * (Izz + 9.0 * centre.m_z * centre.m_z); - - Ixy = K * (Ixy + 9.0 * centre.m_x * centre.m_y); - Ixz = K * (Ixz + 9.0 * centre.m_x * centre.m_z); - Iyz = K * (Iyz + 9.0 * centre.m_y * centre.m_z); - centre = centre.Scale ((dgFloat32)area); - } - - totalArea += area; - massCenter += centre; - var += dgVector ((dgFloat32)Ixx, (dgFloat32)Iyy, (dgFloat32)Izz, dgFloat32 (0.0f)); - cov += dgVector ((dgFloat32)Ixy, (dgFloat32)Ixz, (dgFloat32)Iyz, dgFloat32 (0.0f)); - } - - if (totalArea > dgEpsilon * 10.0) { - dgFloat64 K = dgFloat64 (1.0) / totalArea; - var = var.Scale ((dgFloat32)K); - cov = cov.Scale ((dgFloat32)K); - massCenter = massCenter.Scale ((dgFloat32)K); - } - - dgFloat64 Ixx = var.m_x - massCenter.m_x * massCenter.m_x; - dgFloat64 Iyy = var.m_y - massCenter.m_y * massCenter.m_y; - dgFloat64 Izz = var.m_z - massCenter.m_z * massCenter.m_z; - - dgFloat64 Ixy = cov.m_x - massCenter.m_x * massCenter.m_y; - dgFloat64 Ixz = cov.m_y - massCenter.m_x * massCenter.m_z; - dgFloat64 Iyz = cov.m_z - massCenter.m_y * massCenter.m_z; - - sphere.m_front = dgVector ((dgFloat32)Ixx, (dgFloat32)Ixy, (dgFloat32)Ixz, dgFloat32 (0.0f)); - sphere.m_up = dgVector ((dgFloat32)Ixy, (dgFloat32)Iyy, (dgFloat32)Iyz, dgFloat32 (0.0f)); - sphere.m_right = dgVector ((dgFloat32)Ixz, (dgFloat32)Iyz, (dgFloat32)Izz, dgFloat32 (0.0f)); - eigenValues = sphere.EigenVectors(); - } - - - static void Statistics (dgObb& sphere, dgVector &eigenValues, dgVector &scaleVector, const dgFloat32 vertex[], dgInt32 vertexCount, dgInt32 stride) - { - dgBigVector var (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgBigVector cov (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgBigVector massCenter (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - - const dgFloat32* ptr = vertex; - for (dgInt32 i = 0; i < vertexCount; i ++) { - dgFloat32 x = ptr[0] * scaleVector.m_x; - dgFloat32 y = ptr[1] * scaleVector.m_y; - dgFloat32 z = ptr[2] * scaleVector.m_z; - ptr += stride; - massCenter += dgBigVector (x, y, z, dgFloat32 (0.0f)); - var += dgBigVector (x * x, y * y, z * z, dgFloat32 (0.0f)); - cov += dgBigVector (x * y, x * z, y * z, dgFloat32 (0.0f)); - } - - dgFloat64 k = dgFloat64 (1.0) / vertexCount; - var = var.Scale (k); - cov = cov.Scale (k); - massCenter = massCenter.Scale (k); - - dgFloat64 Ixx = var.m_x - massCenter.m_x * massCenter.m_x; - dgFloat64 Iyy = var.m_y - massCenter.m_y * massCenter.m_y; - dgFloat64 Izz = var.m_z - massCenter.m_z * massCenter.m_z; - - dgFloat64 Ixy = cov.m_x - massCenter.m_x * massCenter.m_y; - dgFloat64 Ixz = cov.m_y - massCenter.m_x * massCenter.m_z; - dgFloat64 Iyz = cov.m_z - massCenter.m_y * massCenter.m_z; - - sphere.m_front = dgVector (dgFloat32(Ixx), dgFloat32(Ixy), dgFloat32(Ixz), dgFloat32 (0.0f)); - sphere.m_up = dgVector (dgFloat32(Ixy), dgFloat32(Iyy), dgFloat32(Iyz), dgFloat32 (0.0f)); - sphere.m_right = dgVector (dgFloat32(Ixz), dgFloat32(Iyz), dgFloat32(Izz), dgFloat32 (0.0f)); - eigenValues = sphere.EigenVectors (); - } - -/* - static void Statistics ( - dgObb &sphere, - dgVector &eigenValues, - const dgVector &scaleVector, - const dgFloat32 vertex[], - dgInt32 stride, - const dgFace face[], - dgInt32 faceCount) - { - dgAssert (0); - - dgInt32 i; - dgInt32 index; - const dgFloat32 *ptr; - dgFloat64 K; - dgFloat64 Ixx; - dgFloat64 Iyy; - dgFloat64 Izz; - dgFloat64 Ixy; - dgFloat64 Ixz; - dgFloat64 Iyz; - dgFloat64 area; - dgFloat64 totalArea; - const dgFace *Face; - - dgVector var (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector cov (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector centre (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector massCenter (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - - totalArea = 0.0; - ptr = vertex; - for (i = 0; i < faceCount; i ++) { - Face = &face[i]; - - index = Face->m_wireFrame[0] * stride; - dgVector p0 (&ptr[index]); - p0 = p0 * scaleVector; - - index = Face->m_wireFrame[1] * stride; - dgVector p1 (&ptr[index]); - p1 = p1 * scaleVector; - - index = Face->m_wireFrame[2] * stride; - dgVector p2 (&ptr[index]); - p2 = p2 * scaleVector; - - dgVector normal ((p1 - p0) * (p2 - p0)); - - area = 0.5 * sqrt (normal % normal); - - centre = p0 + p1 + p2; - centre = centre.Scale (1.0f / 3.0f); - - // Inercia of each point in the triangle - Ixx = p0.m_x * p0.m_x + p1.m_x * p1.m_x + p2.m_x * p2.m_x; - Iyy = p0.m_y * p0.m_y + p1.m_y * p1.m_y + p2.m_y * p2.m_y; - Izz = p0.m_z * p0.m_z + p1.m_z * p1.m_z + p2.m_z * p2.m_z; - - Ixy = p0.m_x * p0.m_y + p1.m_x * p1.m_y + p2.m_x * p2.m_y; - Iyz = p0.m_y * p0.m_z + p1.m_y * p1.m_z + p2.m_y * p2.m_z; - Ixz = p0.m_x * p0.m_z + p1.m_x * p1.m_z + p2.m_x * p2.m_z; - - if (area > dgEPSILON * 10.0) { - K = area / 12.0; - //Coriolis theorem for Inertia of a triangle in an arbitrary orientation - Ixx = K * (Ixx + 9.0 * centre.m_x * centre.m_x); - Iyy = K * (Iyy + 9.0 * centre.m_y * centre.m_y); - Izz = K * (Izz + 9.0 * centre.m_z * centre.m_z); - - Ixy = K * (Ixy + 9.0 * centre.m_x * centre.m_y); - Ixz = K * (Ixz + 9.0 * centre.m_x * centre.m_z); - Iyz = K * (Iyz + 9.0 * centre.m_y * centre.m_z); - centre = centre.Scale ((dgFloat32)area); - } - - totalArea += area; - massCenter += centre; - var += dgVector ((dgFloat32)Ixx, (dgFloat32)Iyy, (dgFloat32)Izz); - cov += dgVector ((dgFloat32)Ixy, (dgFloat32)Ixz, (dgFloat32)Iyz); - } - - if (totalArea > dgEPSILON * 10.0) { - K = 1.0 / totalArea; - var = var.Scale ((dgFloat32)K); - cov = cov.Scale ((dgFloat32)K); - massCenter = massCenter.Scale ((dgFloat32)K); - } - - Ixx = var.m_x - massCenter.m_x * massCenter.m_x; - Iyy = var.m_y - massCenter.m_y * massCenter.m_y; - Izz = var.m_z - massCenter.m_z * massCenter.m_z; - - Ixy = cov.m_x - massCenter.m_x * massCenter.m_y; - Ixz = cov.m_y - massCenter.m_x * massCenter.m_z; - Iyz = cov.m_z - massCenter.m_y * massCenter.m_z; - - sphere.m_front = dgVector ((dgFloat32)Ixx, (dgFloat32)Ixy, (dgFloat32)Ixz); - sphere.m_up = dgVector ((dgFloat32)Ixy, (dgFloat32)Iyy, (dgFloat32)Iyz); - sphere.m_right = dgVector ((dgFloat32)Ixz, (dgFloat32)Iyz, (dgFloat32)Izz); - sphere.EigenVectors(eigenValues); - } -*/ -} - - - -void dgObb::SetDimensions (const dgFloat32 vertex[], dgInt32 strideInBytes, const dgInt32 triangles[], dgInt32 indexCount, const dgMatrix *basis) -{ - dgVector eigen; - dgVector scaleVector (dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)); - - if (indexCount < 3) { - return; - } - - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat32)); - if (!basis) { - - InternalSphere::Statistics (*this, eigen, scaleVector, vertex, triangles, indexCount, stride); - - dgInt32 k = 0; - for (dgInt32 i = 0; i < 3; i ++) { - if (k >= 6) { - break; - } - for (dgInt32 j = i + 1; j < 3; j ++) { - dgFloat32 aspect = InternalSphere::AspectRatio (eigen[i], eigen[j]); - if (aspect > dgFloat32 (0.9f)) { - scaleVector[i] *= dgFloat32 (2.0f); - InternalSphere::Statistics (*this, eigen, scaleVector, vertex, triangles, indexCount, stride); - k ++; - i = -1; - break; - } - } - } - } else { - *this = *basis; - } - - dgVector min; - dgVector max; - InternalSphere::BoundingBox (*this, vertex, stride, triangles, indexCount, min, max); - - dgVector massCenter ((max + min) * dgVector::m_half); - //massCenter = massCenter.Scale (dgFloat32 (0.5f)); - m_posit = TransformVector (massCenter); - - dgVector dim ((max - min) * dgVector::m_half); - //dim = dim.Scale (dgFloat32(0.5f)); - SetDimensions (dim.m_x, dim.m_y, dim.m_z); -} - - -void dgObb::SetDimensions (const dgFloat32 vertex[], dgInt32 strideInBytes, dgInt32 count, const dgMatrix *basis) -{ - dgVector eigen; - dgVector scaleVector (dgFloat32(1.0f), dgFloat32(1.0f), dgFloat32(1.0f), dgFloat32 (0.0f)); - - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat32)); - if (!basis) { - InternalSphere::Statistics (*this, eigen, scaleVector, vertex, count, stride); - - dgInt32 k = 0; - for (dgInt32 i = 0; i < 3; i ++) { - if (k >= 6) { - break; - } - for (dgInt32 j = i + 1; j < 3; j ++) { - dgFloat32 aspect = InternalSphere::AspectRatio (eigen[i], eigen[j]); - if (aspect > dgFloat32 (0.9f)) { - scaleVector[i] *= dgFloat32 (2.0f); - InternalSphere::Statistics (*this, eigen, scaleVector, vertex, count, stride); - k ++; - i = -1; - break; - } - } - } - } else { - *this = *basis; - } - - dgVector min; - dgVector max; - InternalSphere::BoundingBox (*this, vertex, count, stride, min, max); - - dgVector massCenter ((max + min) * dgVector::m_half); - //massCenter = massCenter.Scale (0.5); - m_posit = TransformVector (massCenter); - - dgVector dim ((max - min) * dgVector::m_half); - //dim = dim.Scale (dgFloat32(0.5f)); - SetDimensions (dim.m_x + InternalSphere::SPHERE_TOL, - dim.m_y + InternalSphere::SPHERE_TOL, - dim.m_z + InternalSphere::SPHERE_TOL); -} - -/* -void dgObb::SetDimensions ( - const dgFloat32 vertex[], - dgInt32 strideInBytes, - const dgInt32 index[], - dgInt32 indexCount, - const dgMatrix *basis) -{ - dgInt32 i; - dgInt32 j; - dgInt32 k; - dgInt32 stride; - dgFloat32 aspect; - dgVector eigen; - dgVector scaleVector (dgFloat32(1.0f), dgFloat32(1.0f), dgFloat32(1.0f), dgFloat32 (0.0f)); - - stride = strideInBytes / sizeof (dgFloat32); - if (!basis) { - InternalSphere::Statistics (*this, eigen, scaleVector, vertex, index, indexCount, stride); - - k = 0; - for (i = 0; i < 3; i ++) { - if (k >= 6) { - break; - } - for (j = i + 1; j < 3; j ++) { - aspect = InternalSphere::AspectRatio (eigen[i], eigen[j]); - if (aspect > dgFloat32 (0.9f)) { - scaleVector[i] *= dgFloat32 (2.0f); - InternalSphere::Statistics (*this, eigen, scaleVector, vertex, index, indexCount, stride); - i = -1; - k ++; - break; - } - } - } - } else { - *this = *basis; - } - - dgVector min; - dgVector max; - InternalSphere::BoundingBox (*this, vertex, stride, index, indexCount, min, max); - - dgVector massCenter (max + min); - massCenter = massCenter.Scale (dgFloat32(0.5f)); - m_posit = TransformVector (massCenter); - - dgVector dim (max - min); - dim = dim.Scale (dgFloat32(0.5f)); - SetDimensions (dim.m_x + InternalSphere::SPHERE_TOL, - dim.m_y + InternalSphere::SPHERE_TOL, - dim.m_z + InternalSphere::SPHERE_TOL); -} -*/ - - - -/* -dgObb::dgObb ( - const dgObb &dgObb, - const dgVector &Dir) -{ - if ((Dir % Dir) < EPSILON * 0.01f) { - *this = dgObb; - return; - } - - front = Dir; - front.Fast_Normalize(); - - if (dgAbs (front % dgObb.right) < 0.995) { - up = front * dgObb.right; - up.Fast_Normalize(); - } else { - up = dgObb.up; - } - right = up * front; - - dgVector Step (Dir.Scale(0.5)); - size.m_x = (dgFloat32)(dgObb.size.m_x * dgAbs (right % dgObb.right) + - dgObb.size.m_y * dgAbs (right % dgObb.up) + - dgObb.size.m_z * dgAbs (right % dgObb.front)); - - size.m_y = (dgFloat32)(dgObb.size.m_x * dgAbs (up % dgObb.right) + - dgObb.size.m_y * dgAbs (up % dgObb.up) + - dgObb.size.m_z * dgAbs (up % dgObb.front)); - - size.m_z = (dgFloat32)(sqrt (Step % Step) + - dgObb.size.m_x * dgAbs (front % dgObb.right) + - dgObb.size.m_y * dgAbs (front % dgObb.up) + - dgObb.size.m_z * dgAbs (front % dgObb.front)); - posit = dgObb.posit + Step; - -} - - - -bool dgObb::dgObb_Overlap_Test (const dgObb &dgObb) -{ - dgFloat64 R; - dgVector Dir (dgObb.posit - posit); - - R = size.m_x * dgAbs (right % Dir) + dgObb.size.m_x * dgAbs (dgObb.right % Dir) + - size.m_y * dgAbs (up % Dir) + dgObb.size.m_y * dgAbs (dgObb.up % Dir) + - size.m_z * dgAbs (front %Dir) + dgObb.size.m_z * dgAbs (dgObb.front % Dir); - if (R < (Dir % Dir)) { - return false; - } - - R = size.m_x * dgAbs (right % dgObb.right) + - size.m_y * dgAbs (up % dgObb.right) + - size.m_z * dgAbs (front % dgObb.right) + dgObb.size.m_x; - if (R < dgAbs (Dir % dgObb.right)) { - return false; - } - - R = size.m_x * dgAbs (right % dgObb.up) + - size.m_y * dgAbs (up % dgObb.up) + - size.m_z * dgAbs (front % dgObb.up) + dgObb.size.m_y; - if (R < dgAbs (Dir % dgObb.up)) { - return false; - } - - R = size.m_x * dgAbs (right % dgObb.front) + - size.m_y * dgAbs (up % dgObb.front) + - size.m_z * dgAbs (front % dgObb.front) + dgObb.size.m_z; - if (R < dgAbs (Dir % dgObb.front)) { - return false; - } - - R = dgObb.size.m_x * dgAbs (dgObb.right % right) + - dgObb.size.m_y * dgAbs (dgObb.up % right) + - dgObb.size.m_z * dgAbs (dgObb.front % right) + size.m_x; - if (R < dgAbs (Dir % right)) { - return false; - } - - R = dgObb.size.m_x * dgAbs (dgObb.right % up) + - dgObb.size.m_y * dgAbs (dgObb.up % up) + - dgObb.size.m_z * dgAbs (dgObb.front % up) + size.m_y; - if (R < dgAbs (Dir % up)) { - return false; - } - - R = dgObb.size.m_x * dgAbs (dgObb.right % front) + - dgObb.size.m_y * dgAbs (dgObb.up % front) + - dgObb.size.m_z * dgAbs (dgObb.front % front) + size.m_z; - if (R < dgAbs (Dir % front)) { - return false; - } - - return true; -} - - -void dgObb::Swept_Volume ( - dgVector &min, - dgVector &max) -{ - dgFloat32 w; - dgFloat32 h; - dgFloat32 b; - - w = (dgFloat32)(size.m_x * dgAbs(right.m_x) + size.m_y * dgAbs(up.m_x) + size.m_z * dgAbs(front.m_x)); - h = (dgFloat32)(size.m_x * dgAbs(right.m_y) + size.m_y * dgAbs(up.m_y) + size.m_z * dgAbs(front.m_y)); - b = (dgFloat32)(size.m_x * dgAbs(right.m_z) + size.m_y * dgAbs(up.m_z) + size.m_z * dgAbs(front.m_z)); - - min.m_x = posit.m_x - w; - min.m_y = posit.m_y - h; - min.m_z = posit.m_z - b; - - max.m_x = posit.m_x + w; - max.m_y = posit.m_y + h; - max.m_z = posit.m_z + b; -} -*/ - - -/* -dgInt32 dgObb::FrontTest ( - const dgMatrix& matrix, - const dgPlane* plane) const -{ - dgFloat32 R; - dgFloat32 dR; - InternalSphere::dgFloatSign flag0; - InternalSphere::dgFloatSign flag1; - - dR = m_size.m_x * dgAbs (matrix.m_front.m_x) + m_size.m_y * dgAbs (matrix.m_up.m_x) + m_size.m_z * dgAbs (matrix.m_right.m_x); - R = plane[5].m_x * matrix.m_posit.m_x + plane[5].m_w; - - flag0.f = R + dR; - flag1.f = R - dR; - flag0.i = flag0.i >> 30 & 2; - flag1.i = flag1.i >> 31 & 1; - return InternalSphere::CodeTbl[flag0.i | flag1.i]; -} - -dgInt32 dgObb::RearTest (const dgMatrix& matrix, const dgPlane* plane) const -{ - dgFloat32 R; - dgFloat32 dR; - InternalSphere::dgFloatSign flag0; - InternalSphere::dgFloatSign flag1; - - dR = m_size.m_x * dgAbs (matrix.m_front.m_x) + m_size.m_y * dgAbs (matrix.m_up.m_x) + m_size.m_z * dgAbs (matrix.m_right.m_x); - R = plane[4].m_x * matrix.m_posit.m_x + plane[4].m_w; - - flag0.f = R + dR; - flag1.f = R - dR; - flag0.i = flag0.i >> 30 & 2; - flag1.i = flag1.i >> 31 & 1; - return InternalSphere::CodeTbl[flag0.i | flag1.i]; -} - - -dgInt32 dgObb::LeftTest (const dgMatrix& matrix, const dgPlane* plane) const -{ - dgFloat32 R; - dgFloat32 dR; - InternalSphere::dgFloatSign flag0; - InternalSphere::dgFloatSign flag1; - - dR = m_size.m_x * dgAbs (matrix.m_front.m_x * plane[0].m_x + matrix.m_front.m_z * plane[0].m_z) + - m_size.m_y * dgAbs (matrix.m_up.m_x * plane[0].m_x + matrix.m_up.m_z * plane[0].m_z) + - m_size.m_z * dgAbs (matrix.m_right.m_x * plane[0].m_x + matrix.m_right.m_z * plane[0].m_z); - R = plane[0].m_x * matrix.m_posit.m_x + plane[0].m_z * matrix.m_posit.m_z; - - flag0.f = R + dR; - flag1.f = R - dR; - flag0.i = (flag0.i >> 30) & 2; - flag1.i = (flag1.i >> 31) & 1; - return InternalSphere::CodeTbl[flag0.i | flag1.i]; -} - -dgInt32 dgObb::RightTest (const dgMatrix& matrix, const dgPlane* plane) const -{ - dgFloat32 R; - dgFloat32 dR; - InternalSphere::dgFloatSign flag0; - InternalSphere::dgFloatSign flag1; - - dR = m_size.m_x * dgAbs (matrix.m_front.m_x * plane[1].m_x + matrix.m_front.m_z * plane[1].m_z) + - m_size.m_y * dgAbs (matrix.m_up.m_x * plane[1].m_x + matrix.m_up.m_z * plane[1].m_z) + - m_size.m_z * dgAbs (matrix.m_right.m_x * plane[1].m_x + matrix.m_right.m_z * plane[1].m_z); - R = plane[1].m_x * matrix.m_posit.m_x + plane[1].m_z * matrix.m_posit.m_z; - - flag0.f = R + dR; - flag1.f = R - dR; - flag0.i = (flag0.i >> 30) & 2; - flag1.i = (flag1.i >> 31) & 1; - return InternalSphere::CodeTbl[flag0.i | flag1.i]; -} - -dgInt32 dgObb::BottomTest (const dgMatrix& matrix, const dgPlane* plane) const -{ - dgFloat32 R; - dgFloat32 dR; - InternalSphere::dgFloatSign flag0; - InternalSphere::dgFloatSign flag1; - - dR = m_size.m_x * dgAbs (matrix.m_front.m_x * plane[2].m_x + matrix.m_front.m_y * plane[2].m_y) + - m_size.m_y * dgAbs (matrix.m_up.m_x * plane[2].m_x + matrix.m_up.m_y * plane[2].m_y) + - m_size.m_z * dgAbs (matrix.m_right.m_x * plane[2].m_x + matrix.m_right.m_y * plane[2].m_y); - - R = plane[2].m_x * matrix.m_posit.m_x + plane[2].m_y * matrix.m_posit.m_y; - - flag0.f = R + dR; - flag1.f = R - dR; - flag0.i = (flag0.i >> 30) & 2; - flag1.i = (flag1.i >> 31) & 1; - - return InternalSphere::CodeTbl[flag0.i | flag1.i]; -} - -dgInt32 dgObb::TopTest (const dgMatrix& matrix, const dgPlane* plane) const -{ - dgFloat32 R; - dgFloat32 dR; - InternalSphere::dgFloatSign flag0; - InternalSphere::dgFloatSign flag1; - - dR = m_size.m_x * dgAbs (matrix.m_front.m_x * plane[3].m_x + matrix.m_front.m_y * plane[3].m_y) + - m_size.m_y * dgAbs (matrix.m_up.m_x * plane[3].m_x + matrix.m_up.m_y * plane[3].m_y) + - m_size.m_z * dgAbs (matrix.m_right.m_x * plane[3].m_x + matrix.m_right.m_y * plane[3].m_y); - - R = plane[3].m_x * matrix.m_posit.m_x + plane[3].m_y * matrix.m_posit.m_y; - - flag0.f = R + dR; - flag1.f = R - dR; - flag0.i = (flag0.i >> 30) & 2; - flag1.i = (flag1.i >> 31) & 1; - return InternalSphere::CodeTbl[flag0.i | flag1.i]; -} - - - -dgInt32 dgObb::VisibilityTestLow ( - const dgCamera* camera, - const dgMatrix& matrix) const -{ - dgInt32 i; - dgInt32 code; - const dgPlane* planes; - const dgPlane* guardPlanes; - - planes = camera->GetViewVolume(); - - code = (this->*planeTest) (matrix, planes); - if (code != -1) { - for (i = 0; i < 6; i ++) { - code |= (this->*planeTestArray[i]) (matrix, planes); - if (code == -1) { - planeTest = planeTestArray[i]; - return -1; - } - } - - if (code) { - guardPlanes = camera->GetGuardViewVolume(); - if (guardPlanes) { - code = 0; - for (i = 0; i < 6; i ++) { - code |= (this->*planeTestArray[i]) (matrix, guardPlanes); - dgAssert (code >= 0); - if (code) { - return code; - } - } - } - } - } - - return code; -} - - -dgInt32 dgObb::VisibilityTest (const dgCamera* camera) const -{ - dgMatrix viewMatrix (*this * camera->GetViewMatrix()); - return VisibilityTestLow (camera, viewMatrix); -} - -dgInt32 dgObb::VisibilityTest (const dgCamera* camera, const dgMatrix &worldMatrix) const -{ - dgMatrix viewMatrix (*this * worldMatrix * camera->GetViewMatrix()); - return VisibilityTestLow (camera, viewMatrix); -} - -void dgObb::Render ( - const dgCamera* camera, - const dgMatrix &worldMatrix, - dgUnsigned32 rgb) const -{ - dgInt32 i; - struct ColorVertex - { - dgFloat32 m_x; - dgFloat32 m_y; - dgFloat32 m_z; - dgColor m_color; - }; - - dgUnsigned32 index [][2] = { - {0, 4}, {1, 5}, {2, 6}, {3, 7}, - {0, 1}, {4, 5}, {7, 6}, {3, 2}, - {1, 2}, {5, 6}, {4, 7}, {0, 3}, - }; - - ColorVertex* ptr; - ColorVertex box[8]; - - box[0].m_x = -size.m_x; - box[0].m_y = -size.m_y; - box[0].m_z = -size.m_z; - box[0].m_color.m_val = rgb; - - box[1].m_x = size.m_x; - box[1].m_y = -size.m_y; - box[1].m_z = -size.m_z; - box[1].m_color.m_val = rgb; - - box[2].m_x = size.m_x; - box[2].m_y = -size.m_y; - box[2].m_z = size.m_z; - box[2].m_color.m_val = rgb; - - box[3].m_x = -size.m_x; - box[3].m_y = -size.m_y; - box[3].m_z = size.m_z; - box[3].m_color.m_val = rgb; - - box[4].m_x = -size.m_x; - box[4].m_y = size.m_y; - box[4].m_z = -size.m_z; - box[4].m_color.m_val = rgb; - - box[5].m_x = size.m_x; - box[5].m_y = size.m_y; - box[5].m_z = -size.m_z; - box[5].m_color.m_val = rgb; - - box[6].m_x = size.m_x; - box[6].m_y = size.m_y; - box[6].m_z = size.m_z; - box[6].m_color.m_val = rgb; - - box[7].m_x = -size.m_x; - box[7].m_y = size.m_y; - box[7].m_z = size.m_z; - box[7].m_color.m_val = rgb; - - dgRenderDescriptorParams param; - param.m_indexCount = 0; - param.m_vertexCount = sizeof (index) / sizeof (dgInt32); - param.m_descType = dgDynamicVertex; - param.m_primitiveType = RENDER_LINELIST; - param.m_vertexFlags = VERTEX_ENABLE_XYZ | COLOR_ENABLE; - - dgRenderDescriptor desc (param); - - dgMatrix tmpMat (*this * worldMatrix); - camera->SetWorldMatrix (&tmpMat); - - desc.m_material = dgMaterial::UseDebugMaterial(); - - dgVertexRecord vertexRecord (desc.LockVertex()); - ptr = (ColorVertex*) vertexRecord.vertex.ptr; - for (i = 0; i < (sizeof (index) / (2 * sizeof (dgUnsigned32))); i ++) { - ptr[0] = box[index[i][0]]; - ptr[1] = box[index[i][1]]; - ptr += 2; - } - desc.UnlockVertex(); - - camera->Render (desc); - - desc.m_material->Release(); -} -*/ - diff --git a/thirdparty/src/newton/dgCore/dgObb.h b/thirdparty/src/newton/dgCore/dgObb.h deleted file mode 100644 index 4dfdeff36..000000000 --- a/thirdparty/src/newton/dgCore/dgObb.h +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgOOBB_H__ -#define __dgOOBB_H__ - -#include "dgStdafx.h" -#include "dgTypes.h" -#include "dgVector.h" -#include "dgMatrix.h" -#include "dgQuaternion.h" - - -class dgPlane; - -DG_MSC_VECTOR_ALIGNMENT -class dgObb: public dgMatrix -{ - public: - DG_INLINE dgObb (){}; - dgObb (const dgQuaternion &quat, const dgVector &position, const dgVector& dim = dgVector(0.0f)); - dgObb (const dgMatrix& matrix, const dgVector& dim = dgVector(0.0f)); - - dgObb &operator= (const dgMatrix &arg); - void Scale (dgFloat32 Ws, dgFloat32 Hs, dgFloat32 Bs) ; - void SetDimensions (dgFloat32 W, dgFloat32 H, dgFloat32 B); - void SetDimensions (const dgFloat32 vertex[], dgInt32 strideInBytes, dgInt32 vertexCount, const dgMatrix *basis = NULL); - void SetDimensions (const dgFloat32 vertex[], dgInt32 strideInBytes, const dgInt32 triangles[], dgInt32 indexCount, const dgMatrix *basis); -// void SetDimensions (const dgFloat32 vertex[], dgInt32 strideInBytes, const dgInt32 index[], dgInt32 indexCount, const dgMatrix *basis = NULL); - - // return: 0 if the sphere is wholly inside the view port - // 1 if the sphere is partially inside the view port - // -1 if the sphere is wholly outside the view port -// dgInt32 VisibilityTest (const dgCamera* camera) const; -// dgInt32 VisibilityTest (const dgCamera* camera, const dgMatrix &worldMatrix) const; -// void Render (const dgCamera* camera, const dgMatrix &transform, unsigned rgb) const; - - private: -/* - typedef dgInt32 (dgSphere::*CachedVisibilityTest) (const dgMatrix &point, const dgPlane* plane) const; - - mutable CachedVisibilityTest planeTest; - static CachedVisibilityTest planeTestArray[6]; - - void ChangeCachedVisibilityTest (CachedVisibilityTest fnt); - dgInt32 FrontTest (const dgMatrix &point, const dgPlane* plane) const; - dgInt32 RearTest (const dgMatrix &point, const dgPlane* plane) const; - dgInt32 LeftTest (const dgMatrix &point, const dgPlane* plane) const; - dgInt32 RightTest (const dgMatrix &point, const dgPlane* plane) const; - dgInt32 TopTest (const dgMatrix &point, const dgPlane* plane) const; - dgInt32 BottomTest (const dgMatrix &point, const dgPlane* plane) const; - dgInt32 VisibilityTestLow (const dgCamera* camera, const dgMatrix& viewMNatrix) const; -*/ - - public: - dgVector m_size; -} DG_GCC_VECTOR_ALIGNMENT; - - -inline dgObb::dgObb (const dgQuaternion &quat, const dgVector &position, const dgVector& dim) - :dgMatrix(quat, position) -{ - SetDimensions (dim.m_x, dim.m_y, dim.m_z); - dgAssert (0); -} - -inline dgObb::dgObb(const dgMatrix& matrix, const dgVector& dim) - :dgMatrix(matrix) -{ - SetDimensions (dim.m_x, dim.m_y, dim.m_z); -} - - - - -inline dgObb &dgObb::operator= (const dgMatrix &arg) -{ - m_front = arg.m_front; - m_up = arg.m_up; - m_right = arg.m_right; - m_posit = arg.m_posit; - return *this; -} - -inline void dgObb::SetDimensions (dgFloat32 W, dgFloat32 H, dgFloat32 B) -{ - m_size = dgVector (dgAbs(W), dgAbs(H), dgAbs(B), dgSqrt (W * W + H * H + B * B)); -} - -inline void dgObb::Scale (dgFloat32 Ws, dgFloat32 Hs, dgFloat32 Bs) -{ - SetDimensions (m_size.m_x * Ws, m_size.m_y * Hs, m_size.m_z * Bs); -} - - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgPathFinder.h b/thirdparty/src/newton/dgCore/dgPathFinder.h deleted file mode 100644 index b5e321fe9..000000000 --- a/thirdparty/src/newton/dgCore/dgPathFinder.h +++ /dev/null @@ -1,226 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgPathFinder__ -#define __dgPathFinder__ - -#include "dgStdafx.h" -#include "dgTree.h" -#include "dgHeap.h" - -template<class NODEID, class COST> class dgPathFinder; - - -#define DG_MAX_PATH_ENUMERATION_CHILDREN 128 - -template<class NODEID, class COST> -class dgPathNode -{ - friend class dgPathFinder<NODEID, COST>; - NODEID m_Id; - COST m_NodeCostToGoal; - COST m_NodeCostFromSource; - dgPathNode* m_Next; - - public: - dgPathNode(); - NODEID GetId() const; - const dgPathNode* GetNext() const; - const dgPathNode* GetParent() const; -}; - -template<class NODEID, class COST> -class dgPathCloseList: public dgTree<dgPathNode<NODEID, COST>, NODEID> -{ - protected: - dgPathCloseList(): dgTree<dgPathNode<NODEID, COST>, NODEID>() {} -}; - - -template<class NODEID, class COST> -class dgPathOpenHeap: public dgUpHeap<typename dgPathCloseList<NODEID, COST>::dgTreeNode*, COST> -{ - protected: - dgPathOpenHeap(dgInt32 maxElements) - :dgUpHeap<typename dgPathCloseList<NODEID, COST>::dgTreeNode*, COST>(maxElements) - { - } - - friend class dgPathFinder<NODEID, COST>; -}; - - -template<class NODEID, class COST> -class dgPathFinder: public dgPathCloseList<NODEID, COST> -{ - dgInt32 maxChildren; - - public: - dgPathFinder(dgInt32 maxElementsInOpenList, dgInt32 nodeMaxChildren); - virtual ~dgPathFinder(); - - virtual const dgPathNode<NODEID, COST>* CalCulatePath (NODEID source, NODEID goal); - - // this funtions must be overloaded by the user - virtual COST GetCostFromParent(const dgPathNode<NODEID, COST>& node) const; - virtual COST GetEstimatedCostToGoal(NODEID id) const; - virtual dgInt32 EnumerateChildren(NODEID parent, NODEID array[]) const; - - dgPathOpenHeap<NODEID, COST> m_openList; -}; - - -template<class NODEID, class COST> -dgPathNode<NODEID, COST>::dgPathNode () -{ -} - -template<class NODEID, class COST> -NODEID dgPathNode<NODEID, COST>::GetId () const -{ - return m_Id; -} - - -template<class NODEID, class COST> -const dgPathNode<NODEID, COST>* dgPathNode<NODEID, COST>::GetNext() const -{ - return m_Next; -} - - -template<class NODEID, class COST> -const dgPathNode<NODEID, COST>* dgPathNode<NODEID, COST>::GetParent() const -{ - return m_Next; -} - - -template<class NODEID, class COST> -dgPathFinder<NODEID, COST>::dgPathFinder( - dgInt32 maxElementsInOpenList, - dgInt32 nodeMaxChildren) - :dgPathCloseList<NODEID, COST>(), - m_openList(maxElementsInOpenList) -{ - maxChildren = nodeMaxChildren; -} - - -template<class NODEID, class COST> -dgPathFinder<NODEID, COST>::~dgPathFinder() -{ -} - -template<class NODEID, class COST> -const dgPathNode<NODEID, COST>* dgPathFinder<NODEID, COST>::CalCulatePath (NODEID source, NODEID goal) -{ - dgInt32 count; - dgInt32 heapMaxCount; - dgPathNode<NODEID, COST> cell; - dgPathNode<NODEID, COST>* next; - dgPathNode<NODEID, COST>* prev; - dgPathNode<NODEID, COST>* link; - typename dgPathCloseList<NODEID, COST>::dgTreeNode* node; - NODEID idArray[DG_MAX_PATH_ENUMERATION_CHILDREN]; - - dgPathCloseList<NODEID, COST>& close = *this; - - m_openList.Flush(); - close.RemoveAll(); - - cell.m_Id = source; - cell.m_Next = NULL; - cell.m_NodeCostFromSource = COST (0); - cell.m_NodeCostToGoal = GetEstimatedCostToGoal(cell.m_Id); - - node = close.Insert (cell, source); - - heapMaxCount = m_openList.GetMaxCount(); - m_openList.Push (node, cell.m_NodeCostFromSource + cell.m_NodeCostToGoal); - while (m_openList.GetCount()) { - node = m_openList[0]; - dgPathNode<NODEID, COST>& parent = node->GetInfo(); - if (parent.m_Id == goal) { - link = &parent; - next = NULL; - do { - prev = link->m_Next; - link->m_Next = next; - next = link; - link = prev; - } while (link); - return next; - } - - m_openList.Pop(); - count = EnumerateChildren(node->GetKey(), idArray); - cell.m_Next = &parent; - for (int i = 0; i < count; i ++) { - bool state; - cell.m_Id = idArray[i]; - - COST newCostFromSource (GetCostFromParent(cell) + parent.m_NodeCostFromSource); - node = close.Insert (cell, cell.m_Id, state); - dgPathNode<NODEID, COST>& newCell = node->GetInfo(); - if (state) { - if (newCell.m_NodeCostFromSource <= newCostFromSource) { - continue; - } - //newCell.m_Next = cell.m_Next; - } - - newCell.m_NodeCostFromSource = newCostFromSource; - newCell.m_NodeCostToGoal = GetEstimatedCostToGoal(newCell.m_Id); - if (m_openList.GetCount() >= heapMaxCount) { - m_openList.Remove (heapMaxCount); - } - m_openList.Push (node, newCell.m_NodeCostFromSource + newCell.m_NodeCostToGoal); - } - } - return NULL; -} - -template<class NODEID, class COST> -COST dgPathFinder<NODEID, COST>::GetCostFromParent(const dgPathNode<NODEID, COST>& node) const -{ - return COST (1); -} - -template<class NODEID, class COST> -COST dgPathFinder<NODEID, COST>::GetEstimatedCostToGoal(NODEID id) const -{ - return COST (1); -} - -template<class NODEID, class COST> -dgInt32 dgPathFinder<NODEID, COST>::EnumerateChildren(NODEID parent, NODEID array[]) const -{ - return 0; -} - - - - -#endif - - - diff --git a/thirdparty/src/newton/dgCore/dgPlane.h b/thirdparty/src/newton/dgCore/dgPlane.h deleted file mode 100644 index 3e5883b0f..000000000 --- a/thirdparty/src/newton/dgCore/dgPlane.h +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgPlane__ -#define __dgPlane__ - -#include "dgStdafx.h" -#include "dgVector.h" - - -#ifdef _NEWTON_USE_DOUBLE - #define dgPlane dgBigPlane -#else - -DG_MSC_VECTOR_ALIGNMENT -class dgPlane: public dgVector -{ - public: - dgPlane (); - dgPlane (const dgVector& point); - dgPlane (dgFloat32 x, dgFloat32 y, dgFloat32 z, dgFloat32 w); - dgPlane (const dgVector &normal, dgFloat32 distance); - dgPlane (const dgVector &P0, const dgVector &P1, const dgVector &P2); - dgPlane Scale (dgFloat32 s) const; - dgFloat32 Evalue (const dgFloat32* const point) const; - dgFloat32 Evalue (const dgVector &point) const; -} DG_GCC_VECTOR_ALIGNMENT; - -#endif - - -DG_MSC_VECTOR_ALIGNMENT -class dgBigPlane: public dgBigVector -{ - public: - dgBigPlane (); - dgBigPlane (const dgBigVector& point); - dgBigPlane (dgFloat64 x, dgFloat64 y, dgFloat64 z, dgFloat64 w); - dgBigPlane (const dgBigVector &normal, dgFloat64 distance); - dgBigPlane (const dgBigVector &P0, const dgBigVector &P1, const dgBigVector &P2); - dgBigPlane Scale (dgFloat64 s) const; - dgFloat64 Evalue (const dgFloat64* const point) const; - dgFloat64 Evalue (const dgBigVector &point) const; -} DG_GCC_VECTOR_ALIGNMENT; - - - -#ifndef _NEWTON_USE_DOUBLE - -DG_INLINE dgPlane::dgPlane () - :dgVector () -{ -} - -DG_INLINE dgPlane::dgPlane (const dgVector& point) - :dgVector (point) -{ -} - -DG_INLINE dgPlane::dgPlane (dgFloat32 x, dgFloat32 y, dgFloat32 z, dgFloat32 w) - :dgVector (x, y, z, w) -{ -} - -DG_INLINE dgPlane::dgPlane (const dgVector &normal, dgFloat32 distance) - :dgVector (normal) -{ - m_w = distance; -} - -DG_INLINE dgPlane::dgPlane (const dgVector &P0, const dgVector &P1, const dgVector &P2) - :dgVector ((P1 - P0).CrossProduct(P2 - P0)) -{ - m_w = - DotProduct(P0 & dgVector::m_triplexMask).GetScalar(); -} - -DG_INLINE dgPlane dgPlane::Scale (dgFloat32 s) const -{ - return dgPlane(*this * dgVector(s)); -} - - -DG_INLINE dgFloat32 dgPlane::Evalue (const dgFloat32* const point) const -{ - dgVector p (point); - return DotProduct ((p & m_triplexMask) | m_wOne).GetScalar(); -} - -DG_INLINE dgFloat32 dgPlane::Evalue (const dgVector& point) const -{ - return DotProduct ((point & m_triplexMask) | m_wOne).GetScalar(); -} -#endif - - -DG_INLINE dgBigPlane::dgBigPlane () - :dgBigVector () -{ -} - -DG_INLINE dgBigPlane::dgBigPlane (const dgBigVector& point) - :dgBigVector (point) -{ -} - -DG_INLINE dgBigPlane::dgBigPlane (dgFloat64 x, dgFloat64 y, dgFloat64 z, dgFloat64 w) - :dgBigVector (x, y, z, w) -{ -} - -DG_INLINE dgBigPlane::dgBigPlane (const dgBigVector &normal, dgFloat64 distance) - :dgBigVector (normal) -{ - m_w = distance; -} - -DG_INLINE dgBigPlane::dgBigPlane (const dgBigVector &P0, const dgBigVector &P1, const dgBigVector &P2) - :dgBigVector ((P1 - P0).CrossProduct(P2 - P0)) -{ - m_w = - DotProduct(P0 & dgBigVector::m_triplexMask).GetScalar(); -} - -DG_INLINE dgBigPlane dgBigPlane::Scale (dgFloat64 s) const -{ - return dgBigPlane (m_x * s, m_y * s, m_z * s, m_w * s); -} - -DG_INLINE dgFloat64 dgBigPlane::Evalue (const dgFloat64* const point) const -{ - return m_x * point[0] + m_y * point[1] + m_z * point[2] + m_w; -} - - -DG_INLINE dgFloat64 dgBigPlane::Evalue (const dgBigVector &point) const -{ - return m_x * point.m_x + m_y * point.m_y + m_z * point.m_z + m_w; -} - -#endif - - diff --git a/thirdparty/src/newton/dgCore/dgPolygonSoupBuilder.cpp b/thirdparty/src/newton/dgCore/dgPolygonSoupBuilder.cpp deleted file mode 100644 index 44dbca865..000000000 --- a/thirdparty/src/newton/dgCore/dgPolygonSoupBuilder.cpp +++ /dev/null @@ -1,1090 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -/**************************************************************************** -* -* Visual C++ 6.0 created by: Julio Jerez -* -****************************************************************************/ -#include "dgStdafx.h" -#include "dgStack.h" -#include "dgMatrix.h" -#include "dgMemory.h" -#include "dgPolyhedra.h" -#include "dgPolygonSoupBuilder.h" - -#define DG_POINTS_RUN (512 * 1024) - - - -class dgPolygonSoupDatabaseBuilder::dgFaceInfo -{ - public: - dgInt32 indexCount; - dgInt32 indexStart; -}; - -class dgPolygonSoupDatabaseBuilder::dgFaceBucket: public dgList<dgFaceInfo> -{ - public: - dgFaceBucket (dgMemoryAllocator* const allocator) - :dgList<dgFaceInfo>(allocator) - { - } -}; - -class dgPolygonSoupDatabaseBuilder::dgFaceMap: public dgTree<dgFaceBucket, dgInt32> -{ - public: - dgFaceMap (dgMemoryAllocator* const allocator, dgPolygonSoupDatabaseBuilder& builder) - :dgTree<dgFaceBucket, dgInt32>(allocator) - { - dgInt32 polygonIndex = 0; - dgInt32 faceCount = builder.m_faceCount; - const dgInt32* const faceVertexCounts = &builder.m_faceVertexCount[0]; - const dgInt32* const faceVertexIndex = &builder.m_vertexIndex[0]; - for (dgInt32 i = 0; i < faceCount; i ++) { - dgInt32 count = faceVertexCounts[i]; - dgInt32 attribute = faceVertexIndex[polygonIndex + count - 1]; - - dgTreeNode* node = Find(attribute); - if (!node) { - dgFaceBucket tmp (GetAllocator()); - node = Insert(tmp, attribute); - } - - dgFaceBucket& bucket = node->GetInfo(); - dgFaceInfo& face = bucket.Append()->GetInfo(); - face.indexCount = count; - face.indexStart = polygonIndex; - polygonIndex += count; - } - } -}; - -class dgPolygonSoupDatabaseBuilder::dgPolySoupFilterAllocator: public dgPolyhedra -{ - public: - dgPolySoupFilterAllocator (dgMemoryAllocator* const allocator) - :dgPolyhedra (allocator) - { - } - - ~dgPolySoupFilterAllocator () - { - } - - dgInt32 AddFilterFace (dgUnsigned32 count, dgInt32* const pool) - { - BeginFace(); - dgAssert (count); - bool reduction = true; - while (reduction && !AddFace (dgInt32 (count), pool)) { - reduction = false; - if (count >3) { - for (dgUnsigned32 i = 0; i < count; i ++) { - for (dgUnsigned32 j = i + 1; j < count; j ++) { - if (pool[j] == pool[i]) { - for (i = j; i < count - 1; i ++) { - pool[i] = pool[i + 1]; - } - count --; - i = count; - reduction = true; - break; - } - } - } - } - } - EndFace(); - return reduction ? dgInt32 (count) : 0; - } -}; - - -dgPolygonSoupDatabaseBuilder::dgPolygonSoupDatabaseBuilder (dgMemoryAllocator* const allocator) - :m_faceVertexCount(allocator) - ,m_vertexIndex(allocator) - ,m_normalIndex(allocator) - ,m_vertexPoints(allocator) - ,m_normalPoints(allocator) -{ - m_run = DG_POINTS_RUN; - m_faceCount = 0; - m_indexCount = 0; - m_vertexCount = 0; - m_normalCount = 0; - m_allocator = allocator; -} - -dgPolygonSoupDatabaseBuilder::dgPolygonSoupDatabaseBuilder (const dgPolygonSoupDatabaseBuilder& source) - :m_faceVertexCount(source.m_allocator) - ,m_vertexIndex(source.m_allocator) - ,m_normalIndex(source.m_allocator) - ,m_vertexPoints(source.m_allocator) - ,m_normalPoints(source.m_allocator) -{ - m_run = DG_POINTS_RUN; - m_faceCount = source.m_faceCount; - m_indexCount = source.m_indexCount; - m_vertexCount = source.m_vertexCount; - m_normalCount = source.m_normalCount; - m_allocator = source.m_allocator; - - m_vertexIndex[m_indexCount-1] = 0; - m_faceVertexCount[m_faceCount-1] = 0; - m_vertexPoints[m_vertexCount-1].m_w = 0; - - memcpy (&m_vertexIndex[0], &source.m_vertexIndex[0], sizeof (dgInt32) * m_indexCount); - memcpy (&m_faceVertexCount[0], &source.m_faceVertexCount[0], sizeof (dgInt32) * m_faceCount); - memcpy (&m_vertexPoints[0], &source.m_vertexPoints[0], sizeof (dgBigVector) * m_vertexCount); - - if (m_normalCount) { - m_normalIndex[m_faceCount-1] = 0; - m_normalPoints[m_normalCount - 1].m_w = 0; - - memcpy (&m_normalIndex[0], &source.m_normalIndex[0], sizeof (dgInt32) * m_faceCount); - memcpy (&m_normalPoints[0], &source.m_normalPoints[0], sizeof (dgBigVector) * m_normalCount); - } else { - m_normalIndex[0] = 0; - m_normalPoints[0].m_w = 0; - } -} - -dgPolygonSoupDatabaseBuilder::~dgPolygonSoupDatabaseBuilder () -{ -} - -void dgPolygonSoupDatabaseBuilder::Begin() -{ - m_run = DG_POINTS_RUN; - m_faceCount = 0; - m_indexCount = 0; - m_vertexCount = 0; - m_normalCount = 0; -} - -void dgPolygonSoupDatabaseBuilder::SavePLY(const char* const fileName) const -{ - FILE* const file = fopen(fileName, "wb"); - - fprintf(file, "ply\n"); - fprintf(file, "format ascii 1.0\n"); - - //dgInt32 faceCount = 0; - fprintf(file, "element vertex %d\n", m_vertexCount); - fprintf(file, "property float x\n"); - fprintf(file, "property float y\n"); - fprintf(file, "property float z\n"); - fprintf(file, "element face %d\n", m_faceCount); - fprintf(file, "property list uchar int vertex_index\n"); - fprintf(file, "end_header\n"); - - for (dgInt32 i = 0; i < m_vertexCount; i ++) { - const dgBigVector& point = m_vertexPoints[i]; - fprintf(file, "%f %f %f\n", point.m_x, point.m_y, point.m_z); - } - - dgInt32 index = 0; - for (dgInt32 i = 0; i < m_faceCount; i ++) { - dgInt32 count = m_faceVertexCount[i]; - fprintf(file, "%d", count - 1); - for (dgInt32 j = 0; j < count - 1; j++) { - fprintf(file, " %d", m_vertexIndex[index + j]); - } - index += count; - fprintf(file, "\n"); - } - fclose(file); -} - -void dgPolygonSoupDatabaseBuilder::AddMesh (const dgFloat32* const vertex, dgInt32 vertexCount, dgInt32 strideInBytes, dgInt32 faceCount, - const dgInt32* const faceArray, const dgInt32* const indexArray, const dgInt32* const faceMaterialId, const dgMatrix& worldMatrix) -{ - dgInt32 faces[256]; - dgInt32 pool[2048]; - - m_vertexPoints[m_vertexCount + vertexCount].m_x = dgFloat64 (0.0f); - dgBigVector* const vertexPool = &m_vertexPoints[m_vertexCount]; - - worldMatrix.TransformTriplex (&vertexPool[0].m_x, sizeof (dgBigVector), vertex, strideInBytes, vertexCount); - for (dgInt32 i = 0; i < vertexCount; i ++) { - vertexPool[i].m_w = dgFloat64 (0.0f); - } - - dgInt32 totalIndexCount = faceCount; - for (dgInt32 i = 0; i < faceCount; i ++) { - totalIndexCount += faceArray[i]; - } - - m_vertexIndex[m_indexCount + totalIndexCount] = 0; - m_faceVertexCount[m_faceCount + faceCount] = 0; - - dgInt32 k = 0; - for (dgInt32 i = 0; i < faceCount; i ++) { - dgInt32 count = faceArray[i]; - for (dgInt32 j = 0; j < count; j ++) { - dgInt32 index = indexArray[k]; - pool[j] = index + m_vertexCount; - k ++; - } - - dgInt32 convexFaces = 0; - if (count == 3) { - convexFaces = 1; - dgBigVector p0 (m_vertexPoints[pool[2]]); - p0 = p0 & dgBigVector::m_triplexMask; - for (dgInt32 j = 0; j < 3; j ++) { - dgBigVector p1 (m_vertexPoints[pool[j]]); - p1 = p1 & dgBigVector::m_triplexMask; - dgBigVector edge (p1 - p0); - dgFloat64 mag2 = edge.DotProduct(edge).GetScalar(); - if (mag2 < dgFloat32 (1.0e-6f)) { - convexFaces = 0; - } - p0 = p1; - } - - if (convexFaces) { - dgBigVector edge0 (m_vertexPoints[pool[2]] - m_vertexPoints[pool[0]]); - dgBigVector edge1 (m_vertexPoints[pool[1]] - m_vertexPoints[pool[0]]); - dgAssert (edge0.m_w == dgFloat32 (0.0f)); - dgAssert (edge1.m_w == dgFloat32 (0.0f)); - dgBigVector normal (edge0.CrossProduct(edge1)); - dgFloat64 mag2 = normal.DotProduct(normal).GetScalar(); - if (mag2 < dgFloat32 (1.0e-8f)) { - convexFaces = 0; - } - } - - if (convexFaces) { - faces[0] = 3; - } - - } else { - convexFaces = AddConvexFace (count, pool, faces); - } - - dgInt32 indexAcc = 0; - for (dgInt32 j = 0; j < convexFaces; j ++) { - dgInt32 count1 = faces[j]; - m_vertexIndex[m_indexCount + count1] = faceMaterialId[i]; - for (dgInt32 m = 0; m < count1; m ++) { - m_vertexIndex[m_indexCount + m] = pool[indexAcc + m]; - } - indexAcc += count1; - m_indexCount += (count1 + 1); - m_faceVertexCount[m_faceCount] = count1 + 1; - m_faceCount ++; - } - } - m_vertexCount += vertexCount; - m_run -= vertexCount; - if (m_run <= 0) { - PackArray(); - } -} - -void dgPolygonSoupDatabaseBuilder::PackArray() -{ - dgStack<dgInt32> indexMapPool (m_vertexCount); - dgInt32* const indexMap = &indexMapPool[0]; - m_vertexCount = dgVertexListToIndexList (&m_vertexPoints[0].m_x, sizeof (dgBigVector), 3, m_vertexCount, &indexMap[0], dgFloat32 (1.0e-6f)); - - dgInt32 k = 0; - for (dgInt32 i = 0; i < m_faceCount; i ++) { - dgInt32 count = m_faceVertexCount[i] - 1; - for (dgInt32 j = 0; j < count; j ++) { - dgInt32 index = m_vertexIndex[k]; - index = indexMap[index]; - m_vertexIndex[k] = index; - k ++; - } - k ++; - } - - m_run = DG_POINTS_RUN; -} - -void dgPolygonSoupDatabaseBuilder::Finalize() -{ - if (m_faceCount) { - dgStack<dgInt32> indexMapPool (m_indexCount + m_vertexCount); - - dgInt32* const indexMap = &indexMapPool[0]; - m_vertexCount = dgVertexListToIndexList (&m_vertexPoints[0].m_x, sizeof (dgBigVector), 3, m_vertexCount, &indexMap[0], dgFloat32 (1.0e-4f)); - - dgInt32 k = 0; - for (dgInt32 i = 0; i < m_faceCount; i ++) { - dgInt32 count = m_faceVertexCount[i] - 1; - for (dgInt32 j = 0; j < count; j ++) { - dgInt32 index = m_vertexIndex[k]; - index = indexMap[index]; - m_vertexIndex[k] = index; - k ++; - } - k ++; - } - OptimizeByIndividualFaces(); - } -} - -void dgPolygonSoupDatabaseBuilder::FinalizeAndOptimize() -{ - Finalize(); - dgPolyhedra polyhedra(m_allocator); - dgPolygonSoupDatabaseBuilder source(*this); - dgPolygonSoupDatabaseBuilder leftOver(m_allocator); - dgInt32 tmpIndexPool[1024]; - dgVector tmpVertexPool[1024]; - - Begin(); - leftOver.Begin(); - polyhedra.BeginFace (); - dgInt32 faceIndexNumber = 0; - dgInt32 attribute = m_vertexIndex[0]; - - for (dgInt32 i = 0; i < source.m_faceCount; i ++) { - dgInt32 indexCount = source.m_faceVertexCount[i]; - dgAssert (indexCount < 1024); - - dgEdge* const face = polyhedra.AddFace(indexCount - 1, &source.m_vertexIndex[faceIndexNumber]); - if (!face) { - for (dgInt32 j = 0; j < indexCount - 1; j ++) { - dgInt32 index = source.m_vertexIndex[faceIndexNumber + j]; - tmpVertexPool[j] = source.m_vertexPoints[index]; - tmpIndexPool[j] = j; - } - dgInt32 faceArray = indexCount - 1; - leftOver.AddMesh (&tmpVertexPool[0].m_x, indexCount, sizeof (tmpVertexPool[0]), 1, &faceArray, tmpIndexPool, &attribute, dgGetIdentityMatrix()); - } else { - // set the attribute - dgEdge* ptr = face; - do { - ptr->m_userData = dgUnsigned64 (attribute); - ptr = ptr->m_next; - } while (ptr != face); - } - faceIndexNumber += indexCount; - } - polyhedra.EndFace(); - - dgPolyhedra facesLeft(m_allocator); - facesLeft.BeginFace(); - polyhedra.ConvexPartition (&source.m_vertexPoints[0].m_x, source.m_vertexPoints.GetElementSize(), &facesLeft); - facesLeft.EndFace(); - - dgInt32 mark = polyhedra.IncLRU(); - dgPolyhedra::Iterator iter (polyhedra); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if (edge->m_incidentFace < 0) { - continue; - } - if (edge->m_mark == mark) { - continue; - } - - dgEdge* ptr = edge; - dgInt32 indexCount = 0; - do { - ptr->m_mark = mark; - tmpVertexPool[indexCount] = source.m_vertexPoints[ptr->m_incidentVertex]; - tmpIndexPool[indexCount] = indexCount; - indexCount ++; - ptr = ptr->m_next; - } while (ptr != edge); - - if (indexCount >= 3) { - AddMesh (&tmpVertexPool[0].m_x, indexCount, sizeof (tmpVertexPool[0]), 1, &indexCount, tmpIndexPool, &attribute, dgGetIdentityMatrix()); - } - } - - - mark = facesLeft.IncLRU(); - dgPolyhedra::Iterator iter1 (facesLeft); - for (iter1.Begin(); iter1; iter1 ++) { - dgEdge* const edge = &(*iter1); - if (edge->m_incidentFace < 0) { - continue; - } - if (edge->m_mark == mark) { - continue; - } - - dgEdge* ptr = edge; - dgInt32 indexCount = 0; - do { - ptr->m_mark = mark; - tmpVertexPool[indexCount] = source.m_vertexPoints[ptr->m_incidentVertex]; - tmpIndexPool[indexCount] = indexCount; - indexCount ++; - ptr = ptr->m_next; - } while (ptr != edge); - if (indexCount >= 3) { - AddMesh (&tmpVertexPool[0].m_x, indexCount, sizeof (dgVector), 1, &indexCount, tmpIndexPool, &attribute, dgGetIdentityMatrix()); - } - } - - faceIndexNumber = 0; - for (dgInt32 i = 0; i < leftOver.m_faceCount; i ++) { - dgInt32 indexCount = leftOver.m_faceVertexCount[i] - 1; - for (dgInt32 j = 0; j < indexCount; j ++) { - dgInt32 index = leftOver.m_vertexIndex[faceIndexNumber + j]; - tmpVertexPool[j] = leftOver.m_vertexPoints[index]; - tmpIndexPool[j] = j; - } - dgInt32 faceArray = indexCount; - AddMesh (&tmpVertexPool[0].m_x, indexCount, sizeof (tmpVertexPool[0]), 1, &faceArray, tmpIndexPool, &attribute, dgGetIdentityMatrix()); - - faceIndexNumber += (indexCount + 1); - } - - Finalize(); -} - -void dgPolygonSoupDatabaseBuilder::OptimizeByIndividualFaces() -{ - dgInt32* const faceArray = &m_faceVertexCount[0]; - dgInt32* const indexArray = &m_vertexIndex[0]; - - dgInt32* const oldFaceArray = &m_faceVertexCount[0]; - dgInt32* const oldIndexArray = &m_vertexIndex[0]; - - dgInt32 polygonIndex = 0; - dgInt32 newFaceCount = 0; - dgInt32 newIndexCount = 0; - for (dgInt32 i = 0; i < m_faceCount; i ++) { - dgInt32 oldCount = oldFaceArray[i]; - dgInt32 count = FilterFace (oldCount - 1, &oldIndexArray[polygonIndex]); - if (count) { - faceArray[newFaceCount] = count + 1; - for (dgInt32 j = 0; j < count; j ++) { - indexArray[newIndexCount + j] = oldIndexArray[polygonIndex + j]; - } - indexArray[newIndexCount + count] = oldIndexArray[polygonIndex + oldCount - 1]; - newFaceCount ++; - newIndexCount += (count + 1); - } - polygonIndex += oldCount; - } - dgAssert (polygonIndex == m_indexCount); - m_faceCount = newFaceCount; - m_indexCount = newIndexCount; -} - - -void dgPolygonSoupDatabaseBuilder::End(bool optimize) -{ - if (optimize) { - dgPolygonSoupDatabaseBuilder copy (*this); - dgFaceMap faceMap (m_allocator, copy); - - Begin(); - dgFaceMap::Iterator iter (faceMap); - for (iter.Begin(); iter; iter ++) { - const dgFaceBucket& bucket = iter.GetNode()->GetInfo(); - Optimize(iter.GetNode()->GetKey(), bucket, copy); - } - } - Finalize(); - - // build the normal array and adjacency array - // calculate all face the normals - dgInt32 indexCount = 0; - m_normalPoints[m_faceCount].m_x = dgFloat64 (0.0f); - for (dgInt32 i = 0; i < m_faceCount; i ++) { - dgInt32 faceIndexCount = m_faceVertexCount[i]; - - const dgInt32* const ptr = &m_vertexIndex[indexCount]; - dgBigVector v0 (&m_vertexPoints[ptr[0]].m_x); - dgBigVector v1 (&m_vertexPoints[ptr[1]].m_x); - dgBigVector e0 (v1 - v0); - dgBigVector normal0 (dgBigVector::m_zero); - for (dgInt32 j = 2; j < faceIndexCount - 1; j ++) { - dgBigVector v2 (&m_vertexPoints[ptr[j]].m_x); - dgBigVector e1 (v2 - v0); - normal0 += e0.CrossProduct(e1); - e0 = e1; - } - dgBigVector normal (normal0.Normalize()); - - m_normalPoints[i].m_x = normal.m_x; - m_normalPoints[i].m_y = normal.m_y; - m_normalPoints[i].m_z = normal.m_z; - m_normalPoints[i].m_w = dgFloat32 (0.0f); - indexCount += faceIndexCount; - } - // compress normals array - m_normalIndex[m_faceCount] = 0; - m_normalCount = dgVertexListToIndexList(&m_normalPoints[0].m_x, sizeof (dgBigVector), 3, m_faceCount, &m_normalIndex[0], dgFloat32 (1.0e-6f)); -} - - -void dgPolygonSoupDatabaseBuilder::Optimize(dgInt32 faceId, const dgFaceBucket& faceBucket, const dgPolygonSoupDatabaseBuilder& source) -{ - #define DG_MESH_PARTITION_SIZE (1024 * 4) - - const dgInt32* const indexArray = &source.m_vertexIndex[0]; - const dgBigVector* const points = &source.m_vertexPoints[0]; - - dgVector face[256]; - dgInt32 faceIndex[256]; - if (faceBucket.GetCount() >= DG_MESH_PARTITION_SIZE) { - dgStack<dgFaceBucket::dgListNode*> array(faceBucket.GetCount()); - dgInt32 count = 0; - for (dgFaceBucket::dgListNode* node = faceBucket.GetFirst(); node; node = node->GetNext()) { - array[count] = node; - count ++; - } - - dgInt32 stack = 1; - dgInt32 segments[32][2]; - - segments[0][0] = 0; - segments[0][1] = count; - - while (stack) { - stack --; - dgInt32 faceStart = segments[stack][0]; - dgInt32 faceCount = segments[stack][1]; - - if (faceCount <= DG_MESH_PARTITION_SIZE) { - - dgPolygonSoupDatabaseBuilder tmpBuilder (m_allocator); - for (dgInt32 i = 0; i < faceCount; i ++) { - const dgFaceInfo& faceInfo = array[faceStart + i]->GetInfo(); - - dgInt32 count1 = faceInfo.indexCount - 1; - dgInt32 start1 = faceInfo.indexStart; - dgAssert (faceId == indexArray[start1 + count1]); - for (dgInt32 j = 0; j < count1; j ++) { - dgInt32 index = indexArray[start1 + j]; - face[j] = points[index]; - faceIndex[j] = j; - } - dgInt32 faceIndexCount = count1; - tmpBuilder.AddMesh (&face[0].m_x, count1, sizeof (dgVector), 1, &faceIndexCount, &faceIndex[0], &faceId, dgGetIdentityMatrix()); - } - tmpBuilder.FinalizeAndOptimize (); - - dgInt32 faceIndexNumber = 0; - for (dgInt32 i = 0; i < tmpBuilder.m_faceCount; i ++) { - dgInt32 indexCount = tmpBuilder.m_faceVertexCount[i] - 1; - for (dgInt32 j = 0; j < indexCount; j ++) { - dgInt32 index = tmpBuilder.m_vertexIndex[faceIndexNumber + j]; - face[j] = tmpBuilder.m_vertexPoints[index]; - faceIndex[j] = j; - } - dgInt32 faceArray = indexCount; - AddMesh (&face[0].m_x, indexCount, sizeof (dgVector), 1, &faceArray, faceIndex, &faceId, dgGetIdentityMatrix()); - - faceIndexNumber += (indexCount + 1); - } - - } else { - dgBigVector median (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgBigVector varian (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - for (dgInt32 i = 0; i < faceCount; i ++) { - const dgFaceInfo& faceInfo = array[faceStart + i]->GetInfo(); - dgInt32 count1 = faceInfo.indexCount - 1; - dgInt32 start1 = faceInfo.indexStart; - dgBigVector p0 (dgFloat32 ( 1.0e10f), dgFloat32 ( 1.0e10f), dgFloat32 ( 1.0e10f), dgFloat32 (0.0f)); - dgBigVector p1 (dgFloat32 (-1.0e10f), dgFloat32 (-1.0e10f), dgFloat32 (-1.0e10f), dgFloat32 (0.0f)); - for (dgInt32 j = 0; j < count1; j ++) { - dgInt32 index = indexArray[start1 + j]; - const dgBigVector& p = points[index]; - dgAssert(p.m_w == dgFloat32(0.0f)); - p0 = p0.GetMin(p); - p1 = p1.GetMax(p); - } - dgBigVector p ((p0 + p1).Scale (0.5f)); - median += p; - varian += p * p; - } - - varian = varian.Scale (dgFloat32 (faceCount)) - median * median; - - dgInt32 axis = 0; - dgFloat32 maxVarian = dgFloat32 (-1.0e10f); - for (dgInt32 i = 0; i < 3; i ++) { - if (varian[i] > maxVarian) { - axis = i; - maxVarian = dgFloat32 (varian[i]); - } - } - dgBigVector center = median.Scale (dgFloat32 (1.0f) / dgFloat32 (faceCount)); - dgFloat64 axisVal = center[axis]; - - dgInt32 leftCount = 0; - dgInt32 lastFace = faceCount; - - for (dgInt32 i = 0; i < lastFace; i ++) { - dgInt32 side = 0; - const dgFaceInfo& faceInfo = array[faceStart + i]->GetInfo(); - - dgInt32 start1 = faceInfo.indexStart; - dgInt32 count1 = faceInfo.indexCount - 1; - for (dgInt32 j = 0; j < count1; j ++) { - dgInt32 index = indexArray[start1 + j]; - const dgBigVector& p = points[index]; - if (p[axis] > axisVal) { - side = 1; - break; - } - } - - if (side) { - dgSwap (array[faceStart + i], array[faceStart + lastFace - 1]); - lastFace --; - i --; - } else { - leftCount ++; - } - } - dgAssert (leftCount); - dgAssert (leftCount < faceCount); - - segments[stack][0] = faceStart; - segments[stack][1] = leftCount; - stack ++; - - segments[stack][0] = faceStart + leftCount; - segments[stack][1] = faceCount - leftCount; - stack ++; - } - } - - } else { - dgPolygonSoupDatabaseBuilder tmpBuilder (m_allocator); - for (dgFaceBucket::dgListNode* node = faceBucket.GetFirst(); node; node = node->GetNext()) { - const dgFaceInfo& faceInfo = node->GetInfo(); - - dgInt32 count = faceInfo.indexCount - 1; - dgInt32 start = faceInfo.indexStart; - dgAssert (faceId == indexArray[start + count]); - for (dgInt32 j = 0; j < count; j ++) { - dgInt32 index = indexArray[start + j]; - face[j] = points[index]; - faceIndex[j] = j; - } - dgInt32 faceIndexCount = count; - tmpBuilder.AddMesh (&face[0].m_x, count, sizeof (dgVector), 1, &faceIndexCount, &faceIndex[0], &faceId, dgGetIdentityMatrix()); - } - tmpBuilder.FinalizeAndOptimize (); - - dgInt32 faceIndexNumber = 0; - for (dgInt32 i = 0; i < tmpBuilder.m_faceCount; i ++) { - dgInt32 indexCount = tmpBuilder.m_faceVertexCount[i] - 1; - for (dgInt32 j = 0; j < indexCount; j ++) { - dgInt32 index = tmpBuilder.m_vertexIndex[faceIndexNumber + j]; - face[j] = tmpBuilder.m_vertexPoints[index]; - faceIndex[j] = j; - } - dgInt32 faceArray = indexCount; - AddMesh (&face[0].m_x, indexCount, sizeof (dgVector), 1, &faceArray, faceIndex, &faceId, dgGetIdentityMatrix()); - - faceIndexNumber += (indexCount + 1); - } - } -} - - -dgInt32 dgPolygonSoupDatabaseBuilder::FilterFace (dgInt32 count, dgInt32* const pool) -{ - if (count == 3) { - dgBigVector p0 (m_vertexPoints[pool[2]]); - p0 = p0 & dgBigVector::m_triplexMask; - for (dgInt32 i = 0; i < 3; i ++) { - dgBigVector p1 (m_vertexPoints[pool[i]]); - p1 = p1 & dgBigVector::m_triplexMask; - dgBigVector edge (p1 - p0); - dgFloat64 mag2 = edge.DotProduct(edge).GetScalar(); - if (mag2 < dgFloat32 (1.0e-6f)) { - count = 0; - } - p0 = p1; - } - - if (count == 3) { - dgBigVector edge0 (m_vertexPoints[pool[2]] - m_vertexPoints[pool[0]]); - dgBigVector edge1 (m_vertexPoints[pool[1]] - m_vertexPoints[pool[0]]); - dgBigVector normal (edge0.CrossProduct(edge1)); - - dgAssert(edge0.m_w == dgFloat32(0.0f)); - dgAssert(edge1.m_w == dgFloat32(0.0f)); - dgAssert (normal.m_w == dgFloat32 (0.0f)); - dgFloat64 mag2 = normal.DotProduct(normal).GetScalar(); - if (mag2 < dgFloat32 (1.0e-8f)) { - count = 0; - } - } - } else { - dgPolySoupFilterAllocator polyhedra(m_allocator); - count = polyhedra.AddFilterFace (dgUnsigned32 (count), pool); - - if (!count) { - return 0; - } - - dgEdge* edge = &polyhedra.GetRoot()->GetInfo(); - if (edge->m_incidentFace < 0) { - edge = edge->m_twin; - } - - bool flag = true; - while (flag) { - flag = false; - if (count >= 3) { - dgEdge* ptr = edge; - - dgBigVector p0 (&m_vertexPoints[ptr->m_incidentVertex].m_x); - p0 = p0 & dgBigVector::m_triplexMask; - do { - dgBigVector p1 (&m_vertexPoints[ptr->m_next->m_incidentVertex].m_x); - p1 = p1 & dgBigVector::m_triplexMask; - dgBigVector e0 (p1 - p0); - dgFloat64 mag2 = e0.DotProduct(e0).GetScalar(); - if (mag2 < dgFloat32 (1.0e-6f)) { - count --; - flag = true; - edge = ptr->m_next; - ptr->m_prev->m_next = ptr->m_next; - ptr->m_next->m_prev = ptr->m_prev; - ptr->m_twin->m_next->m_prev = ptr->m_twin->m_prev; - ptr->m_twin->m_prev->m_next = ptr->m_twin->m_next; - break; - } - p0 = p1; - ptr = ptr->m_next; - } while (ptr != edge); - } - } - if (count >= 3) { - flag = true; - dgBigVector normal (polyhedra.FaceNormal (edge, &m_vertexPoints[0].m_x, sizeof (dgBigVector))); - dgAssert (normal.m_w == dgFloat32 (0.0f)); - - dgAssert (normal.DotProduct(normal).GetScalar() > dgFloat32 (1.0e-10f)); - normal = normal.Scale (dgFloat64 (1.0f) / sqrt (normal.DotProduct(normal).GetScalar() + dgFloat32 (1.0e-24f))); - - while (flag) { - flag = false; - if (count >= 3) { - dgEdge* ptr = edge; - - dgBigVector p0 (&m_vertexPoints[ptr->m_prev->m_incidentVertex].m_x); - dgBigVector p1 (&m_vertexPoints[ptr->m_incidentVertex].m_x); - - p0 = p0 & dgBigVector::m_triplexMask; - p1 = p1 & dgBigVector::m_triplexMask; - dgBigVector e0 (p1 - p0); - e0 = e0.Scale (dgFloat64 (1.0f) / sqrt (e0.DotProduct(e0).GetScalar() + dgFloat32(1.0e-24f))); - do { - dgBigVector p2 (&m_vertexPoints[ptr->m_next->m_incidentVertex].m_x); - p2 = p2 & dgBigVector::m_triplexMask; - dgBigVector e1 (p2 - p1); - - e1 = e1.Scale (dgFloat64 (1.0f) / sqrt (e1.DotProduct(e1).GetScalar() + dgFloat32(1.0e-24f))); - dgFloat64 mag2 = e1.DotProduct(e0).GetScalar(); - if (mag2 > dgFloat32 (0.9999f)) { - count --; - flag = true; - edge = ptr->m_next; - ptr->m_prev->m_next = ptr->m_next; - ptr->m_next->m_prev = ptr->m_prev; - ptr->m_twin->m_next->m_prev = ptr->m_twin->m_prev; - ptr->m_twin->m_prev->m_next = ptr->m_twin->m_next; - break; - } - - dgBigVector n (e0.CrossProduct(e1)); - dgAssert (n.m_w == dgFloat32 (0.0f)); - mag2 = n.DotProduct(normal).GetScalar(); - if (mag2 < dgFloat32 (1.0e-5f)) { - count --; - flag = true; - edge = ptr->m_next; - ptr->m_prev->m_next = ptr->m_next; - ptr->m_next->m_prev = ptr->m_prev; - ptr->m_twin->m_next->m_prev = ptr->m_twin->m_prev; - ptr->m_twin->m_prev->m_next = ptr->m_twin->m_next; - break; - } - - e0 = e1; - p1 = p2; - ptr = ptr->m_next; - } while (ptr != edge); - } - } - } - - dgEdge* first = edge; - if (count >= 3) { - dgFloat64 best = dgFloat32 (2.0f); - dgEdge* ptr = edge; - - dgBigVector p0 (&m_vertexPoints[ptr->m_incidentVertex].m_x); - dgBigVector p1 (&m_vertexPoints[ptr->m_next->m_incidentVertex].m_x); - p0 = p0 & dgBigVector::m_triplexMask; - p1 = p1 & dgBigVector::m_triplexMask; - dgBigVector e0 (p1 - p0); - e0 = e0.Scale (dgFloat64 (1.0f) / sqrt (e0.DotProduct(e0).GetScalar() + dgFloat32(1.0e-24f))); - do { - dgBigVector p2 (&m_vertexPoints[ptr->m_next->m_next->m_incidentVertex].m_x); - p2 = p2 & dgBigVector::m_triplexMask; - dgBigVector e1 (p2 - p1); - - e1 = e1.Scale (dgFloat64 (1.0f) / sqrt (e1.DotProduct(e1).GetScalar() + dgFloat32(1.0e-24f))); - dgFloat64 mag2 = fabs (e1.DotProduct(e0).GetScalar()); - if (mag2 < best) { - best = mag2; - first = ptr; - } - - e0 = e1; - p1 = p2; - ptr = ptr->m_next; - } while (ptr != edge); - - count = 0; - ptr = first; - do { - pool[count] = ptr->m_incidentVertex; - count ++; - ptr = ptr->m_next; - } while (ptr != first); - } - - #ifdef _DEBUG - if (count >= 3) { - dgInt32 j0 = count - 2; - dgInt32 j1 = count - 1; - dgBigVector normal (polyhedra.FaceNormal (edge, &m_vertexPoints[0].m_x, sizeof (dgBigVector))); - dgAssert (normal.m_w == dgFloat32 (0.0f)); - for (dgInt32 j2 = 0; j2 < count; j2 ++) { - dgBigVector p0 (&m_vertexPoints[pool[j0]].m_x); - dgBigVector p1 (&m_vertexPoints[pool[j1]].m_x); - dgBigVector p2 (&m_vertexPoints[pool[j2]].m_x); - p0 = p0 & dgBigVector::m_triplexMask; - p1 = p1 & dgBigVector::m_triplexMask; - p2 = p2 & dgBigVector::m_triplexMask; - - dgBigVector e0 ((p0 - p1)); - dgBigVector e1 ((p2 - p1)); - - dgBigVector n (e1.CrossProduct(e0)); - dgAssert (n.DotProduct(normal).GetScalar() > dgFloat32 (0.0f)); - j0 = j1; - j1 = j2; - } - } - #endif - } - - return (count >= 3) ? count : 0; -} - - -dgInt32 dgPolygonSoupDatabaseBuilder::AddConvexFace (dgInt32 count, dgInt32* const pool, dgInt32* const facesArray) -{ - dgPolySoupFilterAllocator polyhedra(m_allocator); - - count = polyhedra.AddFilterFace(dgUnsigned32 (count), pool); - - dgEdge* edge = &polyhedra.GetRoot()->GetInfo(); - if (edge->m_incidentFace < 0) { - edge = edge->m_twin; - } - - - dgInt32 isconvex = 1; - dgInt32 facesCount = 0; - - dgInt32 flag = 1; - while (flag) { - flag = 0; - if (count >= 3) { - dgEdge* ptr = edge; - - dgBigVector p0 (&m_vertexPoints[ptr->m_incidentVertex].m_x); - do { - dgBigVector p1 (&m_vertexPoints[ptr->m_next->m_incidentVertex].m_x); - dgBigVector e0 (p1 - p0); - dgFloat64 mag2 = e0.DotProduct3(e0); - if (mag2 < dgFloat32 (1.0e-6f)) { - count --; - flag = 1; - edge = ptr->m_next; - ptr->m_prev->m_next = ptr->m_next; - ptr->m_next->m_prev = ptr->m_prev; - ptr->m_twin->m_next->m_prev = ptr->m_twin->m_prev; - ptr->m_twin->m_prev->m_next = ptr->m_twin->m_next; - break; - } - p0 = p1; - ptr = ptr->m_next; - } while (ptr != edge); - } - } - if (count >= 3) { - flag = 1; - - while (flag) { - flag = 0; - if (count >= 3) { - dgEdge* ptr = edge; - - dgBigVector p0 (&m_vertexPoints[ptr->m_prev->m_incidentVertex].m_x); - dgBigVector p1 (&m_vertexPoints[ptr->m_incidentVertex].m_x); - dgBigVector e0 (p1 - p0); - e0 = e0.Scale (dgFloat64 (1.0f) / sqrt (e0.DotProduct3(e0) + dgFloat32(1.0e-24f))); - do { - dgBigVector p2 (&m_vertexPoints[ptr->m_next->m_incidentVertex].m_x); - dgBigVector e1 (p2 - p1); - - e1 = e1.Scale (dgFloat64 (1.0f) / sqrt (e1.DotProduct3(e1) + dgFloat32(1.0e-24f))); - dgFloat64 mag2 = e1.DotProduct3(e0); - if (mag2 > dgFloat32 (0.9999f)) { - count --; - flag = 1; - edge = ptr->m_next; - ptr->m_prev->m_next = ptr->m_next; - ptr->m_next->m_prev = ptr->m_prev; - ptr->m_twin->m_next->m_prev = ptr->m_twin->m_prev; - ptr->m_twin->m_prev->m_next = ptr->m_twin->m_next; - break; - } - - e0 = e1; - p1 = p2; - ptr = ptr->m_next; - } while (ptr != edge); - } - } - - dgBigVector normal (polyhedra.FaceNormal (edge, &m_vertexPoints[0].m_x, sizeof (dgBigVector))); - dgFloat64 mag2 = normal.DotProduct3(normal); - if (mag2 < dgFloat32 (1.0e-8f)) { - return 0; - } - normal = normal.Scale (dgFloat64 (1.0f) / sqrt (mag2)); - - if (count >= 3) { - dgEdge* ptr = edge; - dgBigVector p0 (&m_vertexPoints[ptr->m_prev->m_incidentVertex].m_x); - dgBigVector p1 (&m_vertexPoints[ptr->m_incidentVertex].m_x); - dgBigVector e0 (p1 - p0); - e0 = e0.Scale (dgFloat64 (1.0f) / sqrt (e0.DotProduct3(e0) + dgFloat32(1.0e-24f))); - do { - dgBigVector p2 (&m_vertexPoints[ptr->m_next->m_incidentVertex].m_x); - dgBigVector e1 (p2 - p1); - - e1 = e1.Scale (dgFloat64 (1.0f) / sqrt (e1.DotProduct3(e1) + dgFloat32(1.0e-24f))); - - dgBigVector n (e0.CrossProduct(e1)); - dgFloat64 magnitud2 = n.DotProduct3(normal); - if (magnitud2 < dgFloat32 (1.0e-5f)) { - isconvex = 0; - break; - } - - e0 = e1; - p1 = p2; - ptr = ptr->m_next; - } while (ptr != edge); - } - } - - if (isconvex) { - dgEdge* const first = edge; - if (count >= 3) { - count = 0; - dgEdge* ptr = first; - do { - pool[count] = ptr->m_incidentVertex; - count ++; - ptr = ptr->m_next; - } while (ptr != first); - facesArray[facesCount] = count; - facesCount = 1; - } - } else { - dgPolyhedra leftOver(m_allocator); - dgPolyhedra polyhedra2(m_allocator); - dgEdge* ptr = edge; - count = 0; - do { - pool[count] = ptr->m_incidentVertex; - count ++; - ptr = ptr->m_next; - } while (ptr != edge); - - - polyhedra2.BeginFace(); - polyhedra2.AddFace (count, pool); - polyhedra2.EndFace(); - leftOver.BeginFace(); - polyhedra2.ConvexPartition (&m_vertexPoints[0].m_x, m_vertexPoints.GetElementSize(), &leftOver); - leftOver.EndFace(); - -#if _DEBUG - if (leftOver.GetCount()) { - dgTrace (("warning: %d faces with more that a one shared edge\n", leftOver.GetCount())); - dgTrace ((" this mesh is not a manifold and may lead to collision malfunctions\n")); - } -#endif - - dgInt32 mark = polyhedra2.IncLRU(); - dgInt32 index = 0; - dgPolyhedra::Iterator iter (polyhedra2); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge1 = &(*iter); - if (edge1->m_incidentFace < 0) { - continue; - } - if (edge1->m_mark == mark) { - continue; - } - - ptr = edge1; - count = 0; - do { - ptr->m_mark = mark; - pool[index] = ptr->m_incidentVertex; - index ++; - count ++; - ptr = ptr->m_next; - } while (ptr != edge1); - - facesArray[facesCount] = count; - facesCount ++; - } - } - - return facesCount; -} - - - - diff --git a/thirdparty/src/newton/dgCore/dgPolygonSoupBuilder.h b/thirdparty/src/newton/dgCore/dgPolygonSoupBuilder.h deleted file mode 100644 index e3881160a..000000000 --- a/thirdparty/src/newton/dgCore/dgPolygonSoupBuilder.h +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -/**************************************************************************** -* -* Visual C++ 6.0 created by: Julio Jerez -* -****************************************************************************/ -#ifndef __dgPolygonSoupDatabaseBuilder0x23413452233__ -#define __dgPolygonSoupDatabaseBuilder0x23413452233__ - - -#include "dgStdafx.h" -#include "dgRef.h" -#include "dgArray.h" -#include "dgIntersections.h" - - -class AdjacentdFace -{ - public: - dgPlane m_normal; - dgInt32 m_count; - dgInt32 *m_index; - dgInt64 m_edgeMap[256]; -}; - -class dgPolygonSoupDatabaseBuilder -{ - class dgFaceMap; - class dgFaceInfo; - class dgFaceBucket; - class dgPolySoupFilterAllocator; - public: - - dgPolygonSoupDatabaseBuilder (dgMemoryAllocator* const allocator); - dgPolygonSoupDatabaseBuilder (const dgPolygonSoupDatabaseBuilder& sopurce); - ~dgPolygonSoupDatabaseBuilder (); - - DG_CLASS_ALLOCATOR(allocator) - - void Begin(); - void End(bool optimize); - void AddMesh (const dgFloat32* const vertex, dgInt32 vertexCount, dgInt32 strideInBytes, dgInt32 faceCount, - const dgInt32* const faceArray, const dgInt32* const indexArray, const dgInt32* const faceTagsData, const dgMatrix& worldMatrix); - - void SavePLY(const char* const fileName) const; - - private: - void Optimize(dgInt32 faceId, const dgFaceBucket& faceBucket, const dgPolygonSoupDatabaseBuilder& source); - - void Finalize(); - void FinalizeAndOptimize(); - void OptimizeByIndividualFaces(); - dgInt32 FilterFace (dgInt32 count, dgInt32* const indexArray); - dgInt32 AddConvexFace (dgInt32 count, dgInt32* const indexArray, dgInt32* const facesArray); - void PackArray(); - - public: - class dgVertexArray: public dgArray<dgBigVector> - { - public: - dgVertexArray(dgMemoryAllocator* const allocator) - :dgArray<dgBigVector>(allocator) - { - } - }; - - class dgIndexArray: public dgArray<dgInt32> - { - public: - dgIndexArray(dgMemoryAllocator* const allocator) - :dgArray<dgInt32>(allocator) - { - } - }; - - dgInt32 m_run; - dgInt32 m_faceCount; - dgInt32 m_indexCount; - dgInt32 m_vertexCount; - dgInt32 m_normalCount; - dgIndexArray m_faceVertexCount; - dgIndexArray m_vertexIndex; - dgIndexArray m_normalIndex; - dgVertexArray m_vertexPoints; - dgVertexArray m_normalPoints; - dgMemoryAllocator* m_allocator; - -}; - - - - - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgPolygonSoupDatabase.cpp b/thirdparty/src/newton/dgCore/dgPolygonSoupDatabase.cpp deleted file mode 100644 index 184c8cc6b..000000000 --- a/thirdparty/src/newton/dgCore/dgPolygonSoupDatabase.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -/**************************************************************************** -* -* Visual C++ 6.0 created by: Julio Jerez -* -****************************************************************************/ - -#include "dgStdafx.h" -#include "dgPolygonSoupDatabase.h" - - -dgPolygonSoupDatabase::dgPolygonSoupDatabase(const char* const name) -{ - m_vertexCount = 0; - m_strideInBytes = 0; - m_localVertex = NULL; -} - -dgPolygonSoupDatabase::~dgPolygonSoupDatabase () -{ - if (m_localVertex) { - dgFreeStack (m_localVertex); - } -} - - -dgUnsigned32 dgPolygonSoupDatabase::GetTagId(const dgInt32* const face, dgInt32 indexCount) const -{ - return dgUnsigned32 (face[indexCount]); -} - -void dgPolygonSoupDatabase::SetTagId(const dgInt32* const facePtr, dgInt32 indexCount, dgUnsigned32 newID) const -{ - dgUnsigned32* const face = (dgUnsigned32*) facePtr; - face[indexCount] = newID; -} - -dgInt32 dgPolygonSoupDatabase::GetVertexCount() const -{ - return m_vertexCount; -} - -dgFloat32* dgPolygonSoupDatabase::GetLocalVertexPool() const -{ - return m_localVertex; -} - -dgInt32 dgPolygonSoupDatabase::GetStrideInBytes() const -{ - return m_strideInBytes; -} - -dgFloat32 dgPolygonSoupDatabase::GetRadius() const -{ - return 0.0f; -} - - - diff --git a/thirdparty/src/newton/dgCore/dgPolygonSoupDatabase.h b/thirdparty/src/newton/dgCore/dgPolygonSoupDatabase.h deleted file mode 100644 index 9b81d5092..000000000 --- a/thirdparty/src/newton/dgCore/dgPolygonSoupDatabase.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -/**************************************************************************** -* -* Visual C++ 6.0 created by: Julio Jerez -* -****************************************************************************/ -#ifndef __dgPolygonSoupDatabase_H_ -#define __dgPolygonSoupDatabase_H_ - - -#include "dgStdafx.h" -#include "dgRef.h" -#include "dgArray.h" -#include "dgIntersections.h" - -class dgMatrix; - - - -class dgPolygonSoupDatabase -{ - public: - dgFloat32 GetRadius() const; - dgInt32 GetVertexCount() const; - dgInt32 GetStrideInBytes() const; - dgFloat32* GetLocalVertexPool() const; - - dgUnsigned32 GetTagId(const dgInt32* const face, dgInt32 indexCount) const; - void SetTagId(const dgInt32* const face, dgInt32 indexCount, dgUnsigned32 newID) const; - - virtual void Serialize (dgSerialize callback, void* const userData) const = 0; - virtual void Deserialize (dgDeserialize callback, void* const userData, dgInt32 revisionNumber) = 0; - - protected: - dgPolygonSoupDatabase(const char* const name = NULL); - virtual ~dgPolygonSoupDatabase (); - - dgInt32 m_vertexCount; - dgInt32 m_strideInBytes; - dgFloat32* m_localVertex; -}; - - - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgPolyhedra.cpp b/thirdparty/src/newton/dgCore/dgPolyhedra.cpp deleted file mode 100644 index 80d13a3dd..000000000 --- a/thirdparty/src/newton/dgCore/dgPolyhedra.cpp +++ /dev/null @@ -1,2864 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgObb.h" -#include "dgHeap.h" -#include "dgDebug.h" -#include "dgStack.h" -#include "dgPolyhedra.h" -#include "dgConvexHull3d.h" -#include "dgSmallDeterminant.h" - - -#define DG_LOCAL_BUFFER_SIZE 1024 - -class dgDiagonalEdge -{ - public: - dgDiagonalEdge (dgEdge* const edge) - :m_i0(edge->m_incidentVertex), m_i1(edge->m_twin->m_incidentVertex) - { - } - dgInt32 m_i0; - dgInt32 m_i1; -}; - - -struct dgEdgeCollapseEdgeHandle -{ - dgEdgeCollapseEdgeHandle (dgEdge* const newEdge) - :m_inList(false), m_edge(newEdge) - { - } - - dgEdgeCollapseEdgeHandle (const dgEdgeCollapseEdgeHandle &dataHandle) - :m_inList(true), m_edge(dataHandle.m_edge) - { - dgEdgeCollapseEdgeHandle* const handle = (dgEdgeCollapseEdgeHandle *)IntToPointer (m_edge->m_userData); - if (handle) { - dgAssert (handle != this); - handle->m_edge = NULL; - } - m_edge->m_userData = dgUnsigned64 (PointerToInt(this)); - } - - ~dgEdgeCollapseEdgeHandle () - { - if (m_inList) { - if (m_edge) { - dgEdgeCollapseEdgeHandle* const handle = (dgEdgeCollapseEdgeHandle *)IntToPointer (m_edge->m_userData); - if (handle == this) { - m_edge->m_userData = PointerToInt (NULL); - } - } - } - m_edge = NULL; - } - - dgUnsigned32 m_inList; - dgEdge* m_edge; -}; - - -class dgVertexCollapseVertexMetric -{ - public: - dgVertexCollapseVertexMetric (const dgBigPlane &plane) - { - elem[0] = plane.m_x * plane.m_x; - elem[1] = plane.m_y * plane.m_y; - elem[2] = plane.m_z * plane.m_z; - elem[3] = plane.m_w * plane.m_w; - elem[4] = dgFloat64 (2.0) * plane.m_x * plane.m_y; - elem[5] = dgFloat64 (2.0) * plane.m_x * plane.m_z; - elem[6] = dgFloat64 (2.0) * plane.m_x * plane.m_w; - elem[7] = dgFloat64 (2.0) * plane.m_y * plane.m_z; - elem[8] = dgFloat64 (2.0) * plane.m_y * plane.m_w; - elem[9] = dgFloat64 (2.0) * plane.m_z * plane.m_w; - } - - void Clear () - { - memset (elem, 0, 10 * sizeof (dgFloat64)); - } - - void Accumulate (const dgVertexCollapseVertexMetric& p) - { - elem[0] += p.elem[0]; - elem[1] += p.elem[1]; - elem[2] += p.elem[2]; - elem[3] += p.elem[3]; - elem[4] += p.elem[4]; - elem[5] += p.elem[5]; - elem[6] += p.elem[6]; - elem[7] += p.elem[7]; - elem[8] += p.elem[8]; - elem[9] += p.elem[9]; - } - - void Accumulate (const dgBigPlane& plane) - { - elem[0] += plane.m_x * plane.m_x; - elem[1] += plane.m_y * plane.m_y; - elem[2] += plane.m_z * plane.m_z; - elem[3] += plane.m_w * plane.m_w; - - elem[4] += dgFloat64 (2.0f) * plane.m_x * plane.m_y; - elem[5] += dgFloat64 (2.0f) * plane.m_x * plane.m_z; - elem[7] += dgFloat64 (2.0f) * plane.m_y * plane.m_z; - - elem[6] += dgFloat64 (2.0f) * plane.m_x * plane.m_w; - elem[8] += dgFloat64 (2.0f) * plane.m_y * plane.m_w; - elem[9] += dgFloat64 (2.0f) * plane.m_z * plane.m_w; - } - - - dgFloat64 Evalue (const dgBigVector &p) const - { - dgFloat64 acc = elem[0] * p.m_x * p.m_x + elem[1] * p.m_y * p.m_y + elem[2] * p.m_z * p.m_z + - elem[4] * p.m_x * p.m_y + elem[5] * p.m_x * p.m_z + elem[7] * p.m_y * p.m_z + - elem[6] * p.m_x + elem[8] * p.m_y + elem[9] * p.m_z + elem[3]; - return fabs (acc); - } - - dgFloat64 elem[10]; -}; - - - -dgPolyhedra::dgPolyhedra (dgMemoryAllocator* const allocator) - :dgTree <dgEdge, dgInt64>(allocator) - ,m_baseMark(0) - ,m_edgeMark(0) - ,m_faceSecuence(0) -{ -} - -dgPolyhedra::dgPolyhedra (const dgPolyhedra &polyhedra) - :dgTree <dgEdge, dgInt64>(polyhedra.GetAllocator()) - ,m_baseMark(0) - ,m_edgeMark(0) - ,m_faceSecuence(0) -{ - dgStack<dgInt32> indexPool (DG_LOCAL_BUFFER_SIZE * 16); - dgStack<dgUnsigned64> userPool (DG_LOCAL_BUFFER_SIZE * 16); - dgInt32* const index = &indexPool[0]; - dgUnsigned64* const user = &userPool[0]; - - BeginFace (); - Iterator iter(polyhedra); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if (edge->m_incidentFace < 0) { - continue; - } - - if (!FindEdge(edge->m_incidentVertex, edge->m_twin->m_incidentVertex)) { - dgInt32 indexCount = 0; - dgEdge* ptr = edge; - do { - user[indexCount] = ptr->m_userData; - index[indexCount] = ptr->m_incidentVertex; - indexCount ++; - ptr = ptr->m_next; - } while (ptr != edge); - - dgEdge* const face = AddFace (indexCount, index, (dgInt64*) user); - if (face) { - ptr = face; - do { - ptr->m_incidentFace = edge->m_incidentFace; - ptr = ptr->m_next; - } while (ptr != face); - } - } - } - EndFace(); - - m_faceSecuence = polyhedra.m_faceSecuence; - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck()); -#endif -} - -dgPolyhedra::~dgPolyhedra () -{ -} - -void dgPolyhedra::SavePLY(const char* const fileName, const dgFloat64* const vertexArray, dgInt32 strideInBytes) const -{ - FILE* const file = fopen(fileName, "wb"); - - fprintf(file, "ply\n"); - fprintf(file, "format ascii 1.0\n"); - - dgPolyhedra copy(*this); - - dgInt32 faceCount = 0; - Iterator iter(copy); - int mark = copy.IncLRU(); - for (iter.Begin(); iter; iter++) { - dgEdge* const face = &iter.GetNode()->GetInfo(); - if ((face->m_mark < mark) && (face->m_incidentFace > 0)) { - faceCount++; - dgEdge* edge = face; - do { - edge->m_mark = mark; - edge = edge->m_next; - } while (edge != face); - } - } - - mark = copy.IncLRU(); - dgInt32 vertexCount = 0; - for (iter.Begin(); iter; iter++) { - dgEdge* const vertex = &iter.GetNode()->GetInfo(); - if (vertex->m_mark < mark) { - dgEdge* edge = vertex; - do { - edge->m_userData = vertexCount; - edge->m_mark = mark; - edge = edge->m_twin->m_next; - } while (edge != vertex); - vertexCount++; - } - } - - fprintf(file, "element vertex %d\n", vertexCount); - fprintf(file, "property float x\n"); - fprintf(file, "property float y\n"); - fprintf(file, "property float z\n"); - fprintf(file, "element face %d\n", faceCount); - fprintf(file, "property list uchar int vertex_index\n"); - fprintf(file, "end_header\n"); - - mark = copy.IncLRU(); - const dgInt8* const points = (dgInt8*)vertexArray; - for (iter.Begin(); iter; iter++) { - dgEdge* const vertex = &iter.GetNode()->GetInfo(); - if (vertex->m_mark < mark) { - dgEdge* edge = vertex; - do { - edge->m_mark = mark; - edge = edge->m_twin->m_next; - } while (edge != vertex); - dgInt32 index = edge->m_incidentVertex * strideInBytes; - - const dgFloat64* const p = (dgFloat64*)&points[index]; - dgBigVector point(p[0], p[1], p[2], dgFloat64(0.0f)); - fprintf(file, "%f %f %f\n", point.m_x, point.m_y, point.m_z); - } - } - - mark = copy.IncLRU(); - for (iter.Begin(); iter; iter++) { - dgInt32 indices[1024]; - dgInt32 count = 0; - dgEdge* const face = &iter.GetNode()->GetInfo(); - if ((face->m_mark < mark) && (face->m_incidentFace > 0)) { - dgEdge* edge = face; - do { - indices[count] = dgInt32 (edge->m_userData); - count++; - edge->m_mark = mark; - edge = edge->m_next; - } while (edge != face); - - fprintf(file, "%d", count); - for (dgInt32 j = 0; j < count; j++) { - fprintf(file, " %d", indices[j]); - } - fprintf(file, "\n"); - } - } - fclose(file); -} - -dgInt32 dgPolyhedra::GetFaceCount() const -{ - Iterator iter (*this); - dgInt32 count = 0; - dgInt32 mark = IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if (edge->m_mark == mark) { - continue; - } - - if (edge->m_incidentFace < 0) { - continue; - } - - count ++; - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - } - return count; -} - -dgEdge* dgPolyhedra::AddFace ( dgInt32 count, const dgInt32* const index, const dgInt64* const userdata) -{ - class IntersectionFilter - { - public: - IntersectionFilter () - { - m_count = 0; - } - - bool Insert (dgInt64 value) - { - dgInt32 i = 0; - for (; i < m_count; i ++) { - if (m_array[i] == value) { - return false; - } - } - m_array[i] = value; - m_count ++; - return true; - } - - dgInt32 m_count; - dgInt64 m_array[2048]; - }; - - IntersectionFilter selfIntersectingFaceFilter; - - dgInt32 i0 = index[count-1]; - for (dgInt32 i = 0; i < count; i ++) { - dgInt32 i1 = index[i]; - - dgPairKey code0 (i0, i1); - if (!selfIntersectingFaceFilter.Insert (code0.GetVal())) { - return NULL; - } - - dgPairKey code1 (i1, i0); - if (!selfIntersectingFaceFilter.Insert (code1.GetVal())) { - return NULL; - } - - if (i0 == i1) { - return NULL; - } - if (FindEdge (i0, i1)) { - return NULL; - } - i0 = i1; - } - - m_faceSecuence ++; - - i0 = index[count-1]; - dgInt32 i1 = index[0]; - dgUnsigned64 udata0 = 0; - dgUnsigned64 udata1 = 0; - if (userdata) { - udata0 = dgUnsigned64 (userdata[count-1]); - udata1 = dgUnsigned64 (userdata[0]); - } - - bool state; - dgPairKey code (i0, i1); - dgEdge tmpEdge (i0, m_faceSecuence, udata0); - dgTreeNode* const node = Insert (tmpEdge, code.GetVal(), state); - dgAssert (!state); - dgEdge* edge0 = &node->GetInfo(); - dgEdge* const first = edge0; - - for (dgInt32 i = 1; i < count; i ++) { - i0 = i1; - i1 = index[i]; - udata0 = udata1; - udata1 = dgUnsigned64 (userdata ? userdata[i] : 0); - - dgPairKey code1 (i0, i1); - dgEdge tmpEdge1 (i0, m_faceSecuence, udata0); - dgTreeNode* const node1 = Insert (tmpEdge1, code1.GetVal(), state); - dgAssert (!state); - - dgEdge* const edge1 = &node1->GetInfo(); - edge0->m_next = edge1; - edge1->m_prev = edge0; - edge0 = edge1; - } - - first->m_prev = edge0; - edge0->m_next = first; - - return first->m_next; -} - -bool dgPolyhedra::EndFace () -{ - dgPolyhedra::Iterator iter (*this); - - // Connect all twin edge - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if (!edge->m_twin) { - edge->m_twin = FindEdge (edge->m_next->m_incidentVertex, edge->m_incidentVertex); - if (edge->m_twin) { - edge->m_twin->m_twin = edge; - } - } - } - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck()); -#endif - dgStack<dgEdge*> edgeArrayPool(GetCount() * 2 + 256); - - dgInt32 edgeCount = 0; - dgEdge** const edgeArray = &edgeArrayPool[0]; - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if (!edge->m_twin) { - bool state; - dgPolyhedra::dgPairKey code (edge->m_next->m_incidentVertex, edge->m_incidentVertex); - dgEdge tmpEdge (edge->m_next->m_incidentVertex, -1); - tmpEdge.m_incidentFace = -1; - dgPolyhedra::dgTreeNode* const node = Insert (tmpEdge, code.GetVal(), state); - dgAssert (!state); - edge->m_twin = &node->GetInfo(); - edge->m_twin->m_twin = edge; - edgeArray[edgeCount] = edge->m_twin; - edgeCount ++; - } - } - - for (dgInt32 i = 0; i < edgeCount; i ++) { - dgEdge* const edge = edgeArray[i]; - dgAssert (!edge->m_prev); - dgEdge *ptr = edge->m_twin; - for (; ptr->m_next; ptr = ptr->m_next->m_twin){} - ptr->m_next = edge; - edge->m_prev = ptr; - } - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif - - return true; -} - -void dgPolyhedra::DeleteFace(dgEdge* const face) -{ - dgEdge* edgeList[DG_LOCAL_BUFFER_SIZE * 16]; - - if (face->m_incidentFace > 0) { - dgInt32 count = 0; - dgEdge* ptr = face; - do { - ptr->m_incidentFace = -1; - dgInt32 i = 0; - for (; i < count; i ++) { - if ((edgeList[i] == ptr) || (edgeList[i]->m_twin == ptr)) { - break; - } - } - if (i == count) { - edgeList[count] = ptr; - count ++; - } - ptr = ptr->m_next; - } while (ptr != face); - - - for (dgInt32 i = 0; i < count; i ++) { - dgEdge* const ptr1 = edgeList[i]; - if (ptr1->m_twin->m_incidentFace < 0) { - DeleteEdge (ptr1); - } - } - } -} - -dgBigVector dgPolyhedra::FaceNormal (const dgEdge* const face, const dgFloat64* const pool, dgInt32 strideInBytes) const -{ - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat64)); - const dgEdge* edge = face; - dgBigVector p0 (&pool[edge->m_incidentVertex * stride]); - edge = edge->m_next; - dgBigVector p1 (&pool[edge->m_incidentVertex * stride]); - dgBigVector e1 (p1 - p0); - - dgBigVector normal (dgFloat32 (0.0f)); - for (edge = edge->m_next; edge != face; edge = edge->m_next) { - dgBigVector p2 (&pool[edge->m_incidentVertex * stride]); - dgBigVector e2 (p2 - p0); - normal += e1.CrossProduct(e2); - e1 = e2; - } - dgAssert (normal.m_w == dgFloat32 (0.0f)); - return normal; -} - - -dgEdge* dgPolyhedra::AddHalfEdge (dgInt32 v0, dgInt32 v1) -{ - if (v0 != v1) { - dgPairKey pairKey (v0, v1); - dgEdge tmpEdge (v0, -1); - - dgTreeNode* node = Insert (tmpEdge, pairKey.GetVal()); - return node ? &node->GetInfo() : NULL; - } else { - return NULL; - } -} - - -void dgPolyhedra::DeleteEdge (dgEdge* const edge) -{ - dgEdge *const twin = edge->m_twin; - - edge->m_prev->m_next = twin->m_next; - twin->m_next->m_prev = edge->m_prev; - edge->m_next->m_prev = twin->m_prev; - twin->m_prev->m_next = edge->m_next; - - dgTreeNode *const nodeA = GetNodeFromInfo (*edge); - dgTreeNode *const nodeB = GetNodeFromInfo (*twin); - - dgAssert (&nodeA->GetInfo() == edge); - dgAssert (&nodeB->GetInfo() == twin); - - Remove (nodeA); - Remove (nodeB); -} - - -dgEdge* dgPolyhedra::ConnectVertex (dgEdge* const e0, dgEdge* const e1) -{ - dgEdge* const edge = AddHalfEdge(e1->m_incidentVertex, e0->m_incidentVertex); - dgEdge* const twin = AddHalfEdge(e0->m_incidentVertex, e1->m_incidentVertex); - dgAssert ((edge && twin) || !(edge || twin)); - if (edge) { - edge->m_twin = twin; - twin->m_twin = edge; - - edge->m_incidentFace = e0->m_incidentFace; - twin->m_incidentFace = e1->m_incidentFace; - - edge->m_userData = e1->m_userData; - twin->m_userData = e0->m_userData; - - edge->m_next = e0; - edge->m_prev = e1->m_prev; - - twin->m_next = e1; - twin->m_prev = e0->m_prev; - - e0->m_prev->m_next = twin; - e0->m_prev = edge; - - e1->m_prev->m_next = edge; - e1->m_prev = twin; - } - - return edge; -} - -dgEdge* dgPolyhedra::SpliteEdge (dgInt32 newIndex, dgEdge* const edge) -{ - dgEdge* const edge00 = edge->m_prev; - dgEdge* const edge01 = edge->m_next; - dgEdge* const twin00 = edge->m_twin->m_next; - dgEdge* const twin01 = edge->m_twin->m_prev; - - dgInt32 i0 = edge->m_incidentVertex; - dgInt32 i1 = edge->m_twin->m_incidentVertex; - - dgInt32 f0 = edge->m_incidentFace; - dgInt32 f1 = edge->m_twin->m_incidentFace; - - DeleteEdge (edge); - - dgEdge* const edge0 = AddHalfEdge (i0, newIndex); - dgEdge* const edge1 = AddHalfEdge (newIndex, i1); - - dgEdge* const twin0 = AddHalfEdge (newIndex, i0); - dgEdge* const twin1 = AddHalfEdge (i1, newIndex); - dgAssert (edge0); - dgAssert (edge1); - dgAssert (twin0); - dgAssert (twin1); - - edge0->m_twin = twin0; - twin0->m_twin = edge0; - - edge1->m_twin = twin1; - twin1->m_twin = edge1; - - edge0->m_next = edge1; - edge1->m_prev = edge0; - - twin1->m_next = twin0; - twin0->m_prev = twin1; - - edge0->m_prev = edge00; - edge00 ->m_next = edge0; - - edge1->m_next = edge01; - edge01->m_prev = edge1; - - twin0->m_next = twin00; - twin00->m_prev = twin0; - - twin1->m_prev = twin01; - twin01->m_next = twin1; - - edge0->m_incidentFace = f0; - edge1->m_incidentFace = f0; - - twin0->m_incidentFace = f1; - twin1->m_incidentFace = f1; - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - // dgAssert (SanityCheck ()); -#endif - - return edge0; -} - -bool dgPolyhedra::FlipEdge (dgEdge* const edge) -{ - // dgTreeNode *node; - if (edge->m_next->m_next->m_next != edge) { - return false; - } - - if (edge->m_twin->m_next->m_next->m_next != edge->m_twin) { - return false; - } - - if (FindEdge(edge->m_prev->m_incidentVertex, edge->m_twin->m_prev->m_incidentVertex)) { - return false; - } - - dgEdge *const prevEdge = edge->m_prev; - dgEdge *const prevTwin = edge->m_twin->m_prev; - - dgPairKey edgeKey (prevTwin->m_incidentVertex, prevEdge->m_incidentVertex); - dgPairKey twinKey (prevEdge->m_incidentVertex, prevTwin->m_incidentVertex); - - ReplaceKey (GetNodeFromInfo (*edge), edgeKey.GetVal()); - // dgAssert (node); - - ReplaceKey (GetNodeFromInfo (*edge->m_twin), twinKey.GetVal()); - // dgAssert (node); - - edge->m_incidentVertex = prevTwin->m_incidentVertex; - edge->m_twin->m_incidentVertex = prevEdge->m_incidentVertex; - - edge->m_userData = prevTwin->m_userData; - edge->m_twin->m_userData = prevEdge->m_userData; - - prevEdge->m_next = edge->m_twin->m_next; - prevTwin->m_prev->m_prev = edge->m_prev; - - prevTwin->m_next = edge->m_next; - prevEdge->m_prev->m_prev = edge->m_twin->m_prev; - - edge->m_prev = prevTwin->m_prev; - edge->m_next = prevEdge; - - edge->m_twin->m_prev = prevEdge->m_prev; - edge->m_twin->m_next = prevTwin; - - prevTwin->m_prev->m_next = edge; - prevTwin->m_prev = edge->m_twin; - - prevEdge->m_prev->m_next = edge->m_twin; - prevEdge->m_prev = edge; - - edge->m_next->m_incidentFace = edge->m_incidentFace; - edge->m_prev->m_incidentFace = edge->m_incidentFace; - - edge->m_twin->m_next->m_incidentFace = edge->m_twin->m_incidentFace; - edge->m_twin->m_prev->m_incidentFace = edge->m_twin->m_incidentFace; - - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif - - return true; -} - - - -bool dgPolyhedra::GetConectedSurface (dgPolyhedra &polyhedra) const -{ - if (!GetCount()) { - return false; - } - - dgEdge* edge = NULL; - Iterator iter(*this); - for (iter.Begin (); iter; iter ++) { - edge = &(*iter); - if ((edge->m_mark < m_baseMark) && (edge->m_incidentFace > 0)) { - break; - } - } - - if (!iter) { - return false; - } - - dgInt32 faceIndex[4096]; - dgInt64 faceDataIndex[4096]; - dgStack<dgEdge*> stackPool (GetCount()); - dgEdge** const stack = &stackPool[0]; - - dgInt32 mark = IncLRU(); - - polyhedra.BeginFace (); - stack[0] = edge; - dgInt32 index = 1; - while (index) { - index --; - dgEdge* const edge1 = stack[index]; - dgAssert (edge1); - if (edge1->m_mark == mark) { - continue; - } - - dgInt32 count = 0; - dgEdge* ptr = edge1; - do { - dgAssert (ptr); - ptr->m_mark = mark; - faceIndex[count] = ptr->m_incidentVertex; - faceDataIndex[count] = dgInt64 (ptr->m_userData); - count ++; - dgAssert (count < dgInt32 ((sizeof (faceIndex)/sizeof(faceIndex[0])))); - - if ((ptr->m_twin->m_incidentFace > 0) && (ptr->m_twin->m_mark != mark)) { - stack[index] = ptr->m_twin; - index ++; - dgAssert (index < GetCount()); - } - - ptr = ptr->m_next; - } while (ptr != edge1); - - polyhedra.AddFace (count, &faceIndex[0], &faceDataIndex[0]); - } - - polyhedra.EndFace (); - - return true; -} - - -void dgPolyhedra::ChangeEdgeIncidentVertex (dgEdge* const edge, dgInt32 newIndex) -{ - dgEdge* ptr = edge; - do { - dgTreeNode* node = GetNodeFromInfo(*ptr); - dgPairKey Key0 (newIndex, ptr->m_twin->m_incidentVertex); - ReplaceKey (node, Key0.GetVal()); - - node = GetNodeFromInfo(*ptr->m_twin); - dgPairKey Key1 (ptr->m_twin->m_incidentVertex, newIndex); - ReplaceKey (node, Key1.GetVal()); - - ptr->m_incidentVertex = newIndex; - - ptr = ptr->m_twin->m_next; - } while (ptr != edge); -} - - -void dgPolyhedra::DeleteDegenerateFaces (const dgFloat64* const pool, dgInt32 strideInBytes, dgFloat64 area) -{ - if (!GetCount()) { - return; - } - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif - dgStack <dgPolyhedra::dgTreeNode*> faceArrayPool(GetCount() / 2 + 100); - - dgInt32 count = 0; - dgPolyhedra::dgTreeNode** const faceArray = &faceArrayPool[0]; - dgInt32 mark = IncLRU(); - Iterator iter (*this); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - - if ((edge->m_mark != mark) && (edge->m_incidentFace > 0)) { - faceArray[count] = iter.GetNode(); - count ++; - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - } - } - - dgFloat64 area2 = area * area; - area2 *= dgFloat64 (4.0f); - - for (dgInt32 i = 0; i < count; i ++) { - dgPolyhedra::dgTreeNode* const faceNode = faceArray[i]; - dgEdge* const edge = &faceNode->GetInfo(); - - dgBigVector normal (FaceNormal (edge, pool, strideInBytes)); - - dgFloat64 faceArea = normal.DotProduct(normal).GetScalar(); - if (faceArea < area2) { - DeleteFace (edge); - } - } - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - mark = IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if ((edge->m_mark != mark) && (edge->m_incidentFace > 0)) { - //dgAssert (edge->m_next->m_next->m_next == edge); - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - - dgBigVector normal (FaceNormal (edge, pool, strideInBytes)); - - dgFloat64 faceArea = normal.DotProduct(normal).GetScalar(); - dgAssert (faceArea >= area2); - } - } - dgAssert (SanityCheck ()); -#endif -} - - -dgBigPlane dgPolyhedra::UnboundedLoopPlane (dgInt32 i0, dgInt32 i1, dgInt32 i2, const dgBigVector* const pool) -{ - const dgBigVector p0 = pool[i0]; - const dgBigVector p1 = pool[i1]; - const dgBigVector p2 = pool[i2]; - dgBigVector E0 (p1 - p0); - dgBigVector E1 (p2 - p0); - - dgBigVector N ((E0.CrossProduct(E1)).CrossProduct(E0)); - dgFloat64 dist = - N.DotProduct3(p0); - dgBigPlane plane (N, dist); - - dgFloat64 mag = sqrt (plane.DotProduct3(plane)); - if (mag < dgFloat64 (1.0e-12f)) { - mag = dgFloat64 (1.0e-12f); - } - mag = dgFloat64 (10.0f) / mag; - - plane.m_x *= mag; - plane.m_y *= mag; - plane.m_z *= mag; - plane.m_w *= mag; - - return plane; -} - -dgEdge* dgPolyhedra::CollapseEdge(dgEdge* const edge) -{ - dgInt32 v0 = edge->m_incidentVertex; - dgInt32 v1 = edge->m_twin->m_incidentVertex; - - dgEdge* retEdge = edge->m_twin->m_prev->m_twin; - if (retEdge == edge->m_twin->m_next) { - return NULL; - } - if (retEdge == edge->m_twin) { - return NULL; - } - if (retEdge == edge->m_next) { - retEdge = edge->m_prev->m_twin; - if (retEdge == edge->m_twin->m_next) { - return NULL; - } - if (retEdge == edge->m_twin) { - return NULL; - } - } - - dgEdge* lastEdge = NULL; - dgEdge* firstEdge = NULL; - if ((edge->m_incidentFace >= 0) && (edge->m_twin->m_incidentFace >= 0)) { - lastEdge = edge->m_prev->m_twin; - firstEdge = edge->m_twin->m_next->m_twin->m_next; - } else if (edge->m_twin->m_incidentFace >= 0) { - firstEdge = edge->m_twin->m_next->m_twin->m_next; - lastEdge = edge; - } else { - lastEdge = edge->m_prev->m_twin; - firstEdge = edge->m_twin->m_next; - } - - for (dgEdge* ptr = firstEdge; ptr != lastEdge; ptr = ptr->m_twin->m_next) { - dgEdge* const badEdge = FindEdge (edge->m_twin->m_incidentVertex, ptr->m_twin->m_incidentVertex); - if (badEdge) { - return NULL; - } - } - - dgEdge* const twin = edge->m_twin; - if (twin->m_next == twin->m_prev->m_prev) { - twin->m_prev->m_twin->m_twin = twin->m_next->m_twin; - twin->m_next->m_twin->m_twin = twin->m_prev->m_twin; - - Remove (GetNodeFromInfo(*twin->m_prev)); - Remove (GetNodeFromInfo(*twin->m_next)); - } else { - twin->m_next->m_userData = twin->m_userData; - twin->m_next->m_prev = twin->m_prev; - twin->m_prev->m_next = twin->m_next; - } - - if (edge->m_next == edge->m_prev->m_prev) { - edge->m_next->m_twin->m_twin = edge->m_prev->m_twin; - edge->m_prev->m_twin->m_twin = edge->m_next->m_twin; - Remove (GetNodeFromInfo(*edge->m_next)); - Remove (GetNodeFromInfo(*edge->m_prev)); - } else { - edge->m_next->m_prev = edge->m_prev; - edge->m_prev->m_next = edge->m_next; - } - - dgAssert (twin->m_twin->m_incidentVertex == v0); - dgAssert (edge->m_twin->m_incidentVertex == v1); - Remove (GetNodeFromInfo(*twin)); - Remove (GetNodeFromInfo(*edge)); - - dgEdge* ptr = retEdge; - do { - dgPolyhedra::dgPairKey pairKey (v0, ptr->m_twin->m_incidentVertex); - - dgPolyhedra::dgTreeNode* node = Find (pairKey.GetVal()); - if (node) { - if (&node->GetInfo() == ptr) { - dgPolyhedra::dgPairKey key (v1, ptr->m_twin->m_incidentVertex); - ptr->m_incidentVertex = v1; - node = ReplaceKey (node, key.GetVal()); - dgAssert (node); - } - } - - dgPolyhedra::dgPairKey TwinKey (ptr->m_twin->m_incidentVertex, v0); - node = Find (TwinKey.GetVal()); - if (node) { - if (&node->GetInfo() == ptr->m_twin) { - dgPolyhedra::dgPairKey key (ptr->m_twin->m_incidentVertex, v1); - node = ReplaceKey (node, key.GetVal()); - dgAssert (node); - } - } - - ptr = ptr->m_twin->m_next; - } while (ptr != retEdge); - - return retEdge; -} - - - -void dgPolyhedra::RemoveHalfEdge (dgEdge* const edge) -{ - dgEdgeCollapseEdgeHandle* const handle = (dgEdgeCollapseEdgeHandle *) IntToPointer (edge->m_userData); - if (handle) { - handle->m_edge = NULL; - } - - dgPolyhedra::dgTreeNode* const node = GetNodeFromInfo(*edge); - dgAssert (node); - Remove (node); -} - - -dgEdge* dgPolyhedra::FindEarTip (dgEdge* const face, const dgFloat64* const pool, dgInt32 stride, dgDownHeap<dgEdge*, dgFloat64>& heap, const dgBigVector &normal) const -{ - dgEdge* ptr = face; - dgBigVector p0 (&pool[ptr->m_prev->m_incidentVertex * stride]); - dgBigVector p1 (&pool[ptr->m_incidentVertex * stride]); - dgBigVector d0 (p1 - p0); - dgFloat64 val = sqrt (d0.DotProduct3(d0)); - if (val < dgFloat64 (1.0e-10f)) { - val = dgFloat64 (1.0e-10f); - } - d0 = d0.Scale (dgFloat64 (1.0f) / val); - - dgFloat64 minAngle = dgFloat32 (10.0f); - do { - dgBigVector p2 (&pool [ptr->m_next->m_incidentVertex * stride]); - dgBigVector d1 (p2 - p1); - dgFloat64 val1 = dgFloat64 (1.0f) / sqrt (d1.DotProduct3(d1)); - if (val1 < dgFloat64 (1.0e-10f)) { - val1 = dgFloat64 (1.0e-10f); - } - d1 = d1.Scale (dgFloat32 (1.0f) / val1); - dgBigVector n (d0.CrossProduct(d1)); - - dgFloat64 angle = normal.DotProduct3(n); - if (angle >= dgFloat64 (0.0f)) { - heap.Push (ptr, angle); - } - - if (angle < minAngle) { - minAngle = angle; - } - - d0 = d1; - p1 = p2; - ptr = ptr->m_next; - } while (ptr != face); - - if (minAngle > dgFloat32 (0.1f)) { - return heap[0]; - } - - dgEdge* ear = NULL; - while (heap.GetCount()) { - ear = heap[0]; - heap.Pop(); - - if (FindEdge (ear->m_prev->m_incidentVertex, ear->m_next->m_incidentVertex)) { - continue; - } - - dgBigVector q0 (&pool [ear->m_prev->m_incidentVertex * stride]); - dgBigVector q1 (&pool [ear->m_incidentVertex * stride]); - dgBigVector q2 (&pool [ear->m_next->m_incidentVertex * stride]); - - dgBigVector p10 (q1 - q0); - dgBigVector p21 (q2 - q1); - dgBigVector p02 (q0 - q2); - - for (ptr = ear->m_next->m_next; ptr != ear->m_prev; ptr = ptr->m_next) { - if (!((ptr->m_incidentVertex == ear->m_incidentVertex) || (ptr->m_incidentVertex == ear->m_prev->m_incidentVertex) || (ptr->m_incidentVertex == ear->m_next->m_incidentVertex))) { - dgBigVector p (&pool [ptr->m_incidentVertex * stride]); - - //dgFloat64 side = ((p - p0) * p10) % normal; - dgFloat64 side = normal.DotProduct3((p - q0).CrossProduct(p10)); - if (side < dgFloat64 (0.05f)) { - //side = ((p - p1) * p21) % normal; - side = normal.DotProduct3((p - q1).CrossProduct(p21)); - if (side < dgFloat64 (0.05f)) { - //side = ((p - p2) * p02) % normal; - side = normal.DotProduct3((p - q2).CrossProduct(p02)); - if (side < dgFloat32 (0.05f)) { - break; - - } - } - } - } - } - - if (ptr == ear->m_prev) { - break; - } - } - - return ear; -} - -dgEdge* dgPolyhedra::TriangulateFace (dgEdge* const faceIn, const dgFloat64* const pool, dgInt32 stride, dgDownHeap<dgEdge*, dgFloat64>& heap, dgBigVector* const faceNormalOut) -{ - dgEdge* face = faceIn; - dgBigVector normal (FaceNormal (face, pool, dgInt32 (stride * sizeof (dgFloat64)))); - - dgFloat64 dot = normal.DotProduct3(normal); - if (dot < dgFloat64 (1.0e-12f)) { - if (faceNormalOut) { - *faceNormalOut = dgBigVector (dgFloat32 (0.0f)); - } - return face; - } - normal = normal.Scale (dgFloat64 (1.0f) / sqrt (dot)); - if (faceNormalOut) { - *faceNormalOut = normal; - } - - while (face->m_next->m_next->m_next != face) { - dgEdge* const ear = FindEarTip (face, pool, stride, heap, normal); - if (!ear) { - return face; - } - if ((face == ear) || (face == ear->m_prev)) { - face = ear->m_prev->m_prev; - } - dgEdge* const edge = AddHalfEdge (ear->m_next->m_incidentVertex, ear->m_prev->m_incidentVertex); - if (!edge) { - return face; - } - dgEdge* const twin = AddHalfEdge (ear->m_prev->m_incidentVertex, ear->m_next->m_incidentVertex); - if (!twin) { - return face; - } - dgAssert (twin); - - - edge->m_mark = ear->m_mark; - edge->m_userData = ear->m_next->m_userData; - edge->m_incidentFace = ear->m_incidentFace; - - twin->m_mark = ear->m_mark; - twin->m_userData = ear->m_prev->m_userData; - twin->m_incidentFace = ear->m_incidentFace; - - edge->m_twin = twin; - twin->m_twin = edge; - - twin->m_prev = ear->m_prev->m_prev; - twin->m_next = ear->m_next; - ear->m_prev->m_prev->m_next = twin; - ear->m_next->m_prev = twin; - - edge->m_next = ear->m_prev; - edge->m_prev = ear; - ear->m_prev->m_prev = edge; - ear->m_next = edge; - - heap.Flush (); - } - return NULL; -} - - -void dgPolyhedra::MarkAdjacentCoplanarFaces (dgPolyhedra& polyhedraOut, dgEdge* const face, const dgFloat64* const pool, dgInt32 strideInBytes) -{ - const dgFloat64 normalDeviation = dgFloat64 (0.9999f); - const dgFloat64 distanceFromPlane = dgFloat64 (1.0f / 128.0f); - - dgInt32 faceIndex[DG_LOCAL_BUFFER_SIZE * 8]; - dgInt64 userIndex[DG_LOCAL_BUFFER_SIZE * 8]; - dgEdge* stack[DG_LOCAL_BUFFER_SIZE * 8]; - dgEdge* deleteEdge[DG_LOCAL_BUFFER_SIZE * 32]; - - dgInt32 deleteCount = 1; - deleteEdge[0] = face; - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat64)); - - dgAssert (face->m_incidentFace > 0); - - dgBigVector normalAverage (FaceNormal (face, pool, strideInBytes)); - dgAssert (normalAverage.m_w == dgFloat32 (0.0f)); - dgFloat64 dot = normalAverage.DotProduct(normalAverage).GetScalar(); - if (dot > dgFloat64 (1.0e-12f)) { - dgInt32 testPointsCount = 1; - dot = dgFloat64 (1.0f) / sqrt (dot); - dgBigVector normal (normalAverage.Scale (dot)); - - dgBigVector averageTestPoint (&pool[face->m_incidentVertex * stride]); - dgBigPlane testPlane(normal, - normal.DotProduct(averageTestPoint & dgBigVector::m_triplexMask).GetScalar()); - - polyhedraOut.BeginFace(); - - IncLRU(); - dgInt32 faceMark = IncLRU(); - - dgInt32 faceIndexCount = 0; - dgEdge* ptr = face; - do { - ptr->m_mark = faceMark; - faceIndex[faceIndexCount] = ptr->m_incidentVertex; - userIndex[faceIndexCount] = dgInt64 (ptr->m_userData); - faceIndexCount ++; - dgAssert (faceIndexCount < dgInt32 (sizeof (faceIndex) / sizeof (faceIndex[0]))); - ptr = ptr ->m_next; - } while (ptr != face); - polyhedraOut.AddFace(faceIndexCount, faceIndex, userIndex); - - dgInt32 index = 1; - deleteCount = 0; - stack[0] = face; - while (index) { - index --; - dgEdge* const face1 = stack[index]; - deleteEdge[deleteCount] = face1; - deleteCount ++; - dgAssert (deleteCount < dgInt32 (sizeof (deleteEdge) / sizeof (deleteEdge[0]))); - dgAssert (face1->m_next->m_next->m_next == face1); - - dgEdge* edge = face1; - do { - dgEdge* const ptr1 = edge->m_twin; - if (ptr1->m_incidentFace > 0) { - if (ptr1->m_mark != faceMark) { - dgEdge* ptr2 = ptr1; - faceIndexCount = 0; - do { - ptr2->m_mark = faceMark; - faceIndex[faceIndexCount] = ptr2->m_incidentVertex; - userIndex[faceIndexCount] = dgInt64 (ptr2->m_userData); - dgAssert (faceIndexCount < dgInt32 (sizeof (faceIndex) / sizeof (faceIndex[0]))); - faceIndexCount ++; - ptr2 = ptr2 ->m_next; - } while (ptr2 != ptr1); - - dgBigVector normal1 (FaceNormal (ptr1, pool, strideInBytes)); - dot = normal1.DotProduct(normal1).GetScalar(); - if (dot < dgFloat64 (1.0e-12f)) { - deleteEdge[deleteCount] = ptr1; - deleteCount ++; - dgAssert (deleteCount < dgInt32 (sizeof (deleteEdge) / sizeof (deleteEdge[0]))); - } else { - dgBigVector testNormal (normal1.Scale (dgFloat64 (1.0f) / sqrt (dot))); - dgAssert (testNormal.m_w == dgFloat32 (0.0f)); - dot = normal.DotProduct(testNormal).GetScalar(); - if (dot >= normalDeviation) { - dgBigVector testPoint (&pool[ptr1->m_prev->m_incidentVertex * stride]); - dgFloat64 dist = fabs (testPlane.Evalue (testPoint)); - if (dist < distanceFromPlane) { - testPointsCount ++; - - averageTestPoint += testPoint; - testPoint = averageTestPoint.Scale (dgFloat64 (1.0f) / dgFloat64(testPointsCount)); - - normalAverage += normal1; - dgAssert (normalAverage.m_w == dgFloat32 (0.0f)); - testNormal = normalAverage.Scale (dgFloat64 (1.0f) / sqrt (normalAverage.DotProduct(normalAverage).GetScalar())); - testPlane = dgBigPlane (testNormal, - testPoint.DotProduct (testNormal).GetScalar()); - - polyhedraOut.AddFace(faceIndexCount, faceIndex, userIndex); - stack[index] = ptr1; - index ++; - dgAssert (index < dgInt32 (sizeof (stack) / sizeof (stack[0]))); - } - } - } - } - } - - edge = edge->m_next; - } while (edge != face1); - } - polyhedraOut.EndFace(); - } - - for (dgInt32 index = 0; index < deleteCount; index ++) { - DeleteFace (deleteEdge[index]); - } -} - -void dgPolyhedra::RefineTriangulation (const dgFloat64* const vertex, dgInt32 stride, const dgBigVector& normal, dgInt32 perimeterCount, dgEdge** const perimeter) -{ - dgList<dgDiagonalEdge> dignonals(GetAllocator()); - - for (dgInt32 i = 1; i <= perimeterCount; i ++) { - dgEdge* const last = perimeter[i - 1]; - for (dgEdge* ptr = perimeter[i]->m_prev; ptr != last; ptr = ptr->m_twin->m_prev) { - dgList<dgDiagonalEdge>::dgListNode* node = dignonals.GetFirst(); - for (; node; node = node->GetNext()) { - const dgDiagonalEdge& key = node->GetInfo(); - if (((key.m_i0 == ptr->m_incidentVertex) && (key.m_i1 == ptr->m_twin->m_incidentVertex)) || - ((key.m_i1 == ptr->m_incidentVertex) && (key.m_i0 == ptr->m_twin->m_incidentVertex))) { - break; - } - } - if (!node) { - dgDiagonalEdge key (ptr); - dignonals.Append(key); - } - } - } - - dgEdge* const face = perimeter[0]; - dgInt32 i0 = face->m_incidentVertex * stride; - dgInt32 i1 = face->m_next->m_incidentVertex * stride; - dgBigVector p0 (vertex[i0], vertex[i0 + 1], vertex[i0 + 2], dgFloat32 (0.0f)); - dgBigVector p1 (vertex[i1], vertex[i1 + 1], vertex[i1 + 2], dgFloat32 (0.0f)); - - dgBigVector p1p0 (p1 - p0); - dgFloat64 mag2 = p1p0.DotProduct(p1p0).GetScalar(); - for (dgEdge* ptr = face->m_next->m_next; mag2 < dgFloat32 (1.0e-12f); ptr = ptr->m_next) { - dgInt32 i2 = ptr->m_incidentVertex * stride; - dgBigVector p2 (vertex[i2], vertex[i2 + 1], vertex[i2 + 2], dgFloat32 (0.0f)); - p1p0 = p2 - p0; - mag2 = p1p0.DotProduct(p1p0).GetScalar(); - } - - dgAssert (p1p0.m_w == dgFloat32 (0.0f)); - dgMatrix matrix (dgGetIdentityMatrix()); - matrix.m_posit = p0; - matrix.m_front = dgVector (p1p0.Scale (dgFloat64 (1.0f) / sqrt (mag2))); - matrix.m_right = dgVector (normal.Scale (dgFloat64 (1.0f) / sqrt (normal.DotProduct(normal).GetScalar()))); - matrix.m_up = matrix.m_right.CrossProduct(matrix.m_front); - matrix = matrix.Inverse(); - dgAssert (matrix.m_posit.m_w == dgFloat32 (1.0f)); -// matrix.m_posit.m_w = dgFloat32 (1.0f); - - dgInt32 maxCount = dignonals.GetCount() * dignonals.GetCount(); - while (dignonals.GetCount() && maxCount) { - maxCount --; - dgList<dgDiagonalEdge>::dgListNode* const node = dignonals.GetFirst(); - dgDiagonalEdge key (node->GetInfo()); - dignonals.Remove(node); - dgEdge* const edge = FindEdge(key.m_i0, key.m_i1); - if (edge) { - dgInt32 k0 = edge->m_incidentVertex * stride; - dgInt32 k1 = edge->m_next->m_incidentVertex * stride; - dgInt32 k2 = edge->m_next->m_next->m_incidentVertex * stride; - dgInt32 k3 = edge->m_twin->m_prev->m_incidentVertex * stride; - - dgBigVector q0 (vertex[k0], vertex[k0 + 1], vertex[k0 + 2], dgFloat64 (1.0f)); - dgBigVector q1 (vertex[k1], vertex[k1 + 1], vertex[k1 + 2], dgFloat64 (1.0f)); - dgBigVector q2 (vertex[k2], vertex[k2 + 1], vertex[k2 + 2], dgFloat64 (1.0f)); - dgBigVector q3 (vertex[k3], vertex[k3 + 1], vertex[k3 + 2], dgFloat64 (1.0f)); - - q0 = matrix.TransformVector(q0); - q1 = matrix.TransformVector(q1); - q2 = matrix.TransformVector(q2); - q3 = matrix.TransformVector(q3); - - dgFloat64 circleTest[3][3]; - circleTest[0][0] = q0[0] - q3[0]; - circleTest[0][1] = q0[1] - q3[1]; - circleTest[0][2] = circleTest[0][0] * circleTest[0][0] + circleTest[0][1] * circleTest[0][1]; - - circleTest[1][0] = q1[0] - q3[0]; - circleTest[1][1] = q1[1] - q3[1]; - circleTest[1][2] = circleTest[1][0] * circleTest[1][0] + circleTest[1][1] * circleTest[1][1]; - - circleTest[2][0] = q2[0] - q3[0]; - circleTest[2][1] = q2[1] - q3[1]; - circleTest[2][2] = circleTest[2][0] * circleTest[2][0] + circleTest[2][1] * circleTest[2][1]; - - dgFloat64 error; - dgFloat64 det = Determinant3x3 (circleTest, &error); - if (det < dgFloat32 (0.0f)) { - dgEdge* frontFace0 = edge->m_prev; - dgEdge* backFace0 = edge->m_twin->m_prev; - - FlipEdge(edge); - - if (perimeterCount > 4) { - dgEdge* backFace1 = backFace0->m_next; - dgEdge* frontFace1 = frontFace0->m_next; - for (dgInt32 i = 0; i < perimeterCount; i ++) { - if (frontFace0 == perimeter[i]) { - frontFace0 = NULL; - } - if (frontFace1 == perimeter[i]) { - frontFace1 = NULL; - } - - if (backFace0 == perimeter[i]) { - backFace0 = NULL; - } - if (backFace1 == perimeter[i]) { - backFace1 = NULL; - } - } - - if (backFace0 && (backFace0->m_incidentFace > 0) && (backFace0->m_twin->m_incidentFace > 0)) { - dgDiagonalEdge key0 (backFace0); - dignonals.Append(key0); - } - if (backFace1 && (backFace1->m_incidentFace > 0) && (backFace1->m_twin->m_incidentFace > 0)) { - dgDiagonalEdge key1 (backFace1); - dignonals.Append(key1); - } - - if (frontFace0 && (frontFace0->m_incidentFace > 0) && (frontFace0->m_twin->m_incidentFace > 0)) { - dgDiagonalEdge key0 (frontFace0); - dignonals.Append(key0); - } - - if (frontFace1 && (frontFace1->m_incidentFace > 0) && (frontFace1->m_twin->m_incidentFace > 0)) { - dgDiagonalEdge key1 (frontFace1); - dignonals.Append(key1); - } - } - } - } - } -} - -void dgPolyhedra::RefineTriangulation (const dgFloat64* const vertex, dgInt32 stride) -{ - if (GetCount() <= 6) { - return; - } - - dgInt32 mark = IncLRU(); - dgInt32 loopCount = 0; - - dgPolyhedra::Iterator iter (*this); - dgEdge* edgePerimeters[DG_LOCAL_BUFFER_SIZE * 16]; - dgInt32 perimeterCount = 0; - dgTree<dgEdge*, dgInt32> filter (GetAllocator()); - for (iter.Begin(); iter && (loopCount <= 1) ; iter ++) { - dgEdge* const edge = &(*iter); - if ((edge->m_incidentFace < 0) && (edge->m_mark != mark)){ - loopCount ++; - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - if (!filter.Insert(ptr, ptr->m_incidentVertex)) { - loopCount = 2; - break; - } - edgePerimeters[perimeterCount] = ptr->m_twin; - perimeterCount ++; - dgAssert (perimeterCount < dgInt32 (sizeof (edgePerimeters) / sizeof (edgePerimeters[0]))); - ptr = ptr->m_prev; - } while (ptr != edge); - } - } - - if (loopCount == 1) { - #ifdef _DEBUG - for (dgInt32 i = 0; i < perimeterCount; i ++) { - for (dgInt32 j = i + 1; j < perimeterCount; j ++) { - dgAssert (edgePerimeters[i]->m_incidentVertex != edgePerimeters[j]->m_incidentVertex); - } - } - #endif - - dgAssert (perimeterCount); - dgAssert (perimeterCount < dgInt32 (sizeof (edgePerimeters) / sizeof (edgePerimeters[0]))); - edgePerimeters[perimeterCount] = edgePerimeters[0]; - - dgBigVector normal (FaceNormal(edgePerimeters[0], vertex, dgInt32 (stride * sizeof (dgFloat64)))); - if (normal.DotProduct(normal).GetScalar() > dgFloat32 (1.0e-12f)) { - RefineTriangulation (vertex, stride, normal, perimeterCount, edgePerimeters); - } - } -} - - -void dgPolyhedra::OptimizeTriangulation (const dgFloat64* const vertex, dgInt32 strideInBytes) -{ - dgInt32 polygon[DG_LOCAL_BUFFER_SIZE * 8]; - dgInt64 userData[DG_LOCAL_BUFFER_SIZE * 8]; - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat64)); - - dgPolyhedra leftOver(GetAllocator()); - dgPolyhedra buildConvex(GetAllocator()); - - buildConvex.BeginFace(); - dgPolyhedra::Iterator iter (*this); - - for (iter.Begin(); iter; ) { - dgEdge* const edge = &(*iter); - iter++; - - if (edge->m_incidentFace > 0) { - dgPolyhedra flatFace(GetAllocator()); - MarkAdjacentCoplanarFaces (flatFace, edge, vertex, strideInBytes); - //dgAssert (flatFace.GetCount()); - - if (flatFace.GetCount()) { - flatFace.RefineTriangulation (vertex, stride); - - dgInt32 mark = flatFace.IncLRU(); - dgPolyhedra::Iterator iter1 (flatFace); - for (iter1.Begin(); iter1; iter1 ++) { - dgEdge* const edge1 = &(*iter1); - if (edge1->m_mark != mark) { - if (edge1->m_incidentFace > 0) { - dgEdge* ptr = edge1; - dgInt32 vertexCount = 0; - do { - polygon[vertexCount] = ptr->m_incidentVertex; - userData[vertexCount] = dgInt64 (ptr->m_userData); - vertexCount ++; - dgAssert (vertexCount < dgInt32 (sizeof (polygon) / sizeof (polygon[0]))); - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge1); - if (vertexCount >= 3) { - buildConvex.AddFace (vertexCount, polygon, userData); - } - } - } - } - } - iter.Begin(); - } - } - buildConvex.EndFace(); - dgAssert (GetCount() == 0); - SwapInfo(buildConvex); -} - -void dgPolyhedra::Triangulate (const dgFloat64* const vertex, dgInt32 strideInBytes, dgPolyhedra* const leftOver) -{ - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat64)); - - dgInt32 count = GetCount() / 2; - dgStack<char> memPool (dgInt32 ((count + 512) * (2 * sizeof (dgFloat64)))); - dgDownHeap<dgEdge*, dgFloat64> heap(&memPool[0], memPool.GetSizeInBytes()); - - dgInt32 mark = IncLRU(); - Iterator iter (*this); - for (iter.Begin(); iter; ) { - dgEdge* const thisEdge = &(*iter); - iter ++; - - if (thisEdge->m_mark == mark) { - continue; - } - if (thisEdge->m_incidentFace < 0) { - continue; - } - - count = 0; - dgEdge* ptr = thisEdge; - do { - count ++; - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != thisEdge); - - if (count > 3) { - dgEdge* const edge = TriangulateFace (thisEdge, vertex, stride, heap, NULL); - heap.Flush (); - - if (edge) { - dgAssert (edge->m_incidentFace > 0); - - if (leftOver) { - dgInt32* const index = (dgInt32 *) &heap[0]; - dgInt64* const data = (dgInt64 *)&index[count]; - dgInt32 i = 0; - dgEdge* ptr1 = edge; - do { - index[i] = ptr1->m_incidentVertex; - data[i] = dgInt64 (ptr1->m_userData); - i ++; - ptr1 = ptr1->m_next; - } while (ptr1 != edge); - leftOver->AddFace(i, index, data); - - } else { - dgTrace (("Deleting face:")); - ptr = edge; - do { - dgTrace (("%d ", ptr->m_incidentVertex)); - } while (ptr != edge); - dgTrace (("\n")); - } - - DeleteFace (edge); - iter.Begin(); - } - } - } - - OptimizeTriangulation (vertex, strideInBytes); - - mark = IncLRU(); - m_faceSecuence = 1; - for (iter.Begin(); iter; iter ++) { - dgEdge* edge = &(*iter); - if (edge->m_mark == mark) { - continue; - } - if (edge->m_incidentFace < 0) { - continue; - } - dgAssert (edge == edge->m_next->m_next->m_next); - - for (dgInt32 i = 0; i < 3; i ++) { - edge->m_incidentFace = m_faceSecuence; - edge->m_mark = mark; - edge = edge->m_next; - } - m_faceSecuence ++; - } -} - -bool dgPolyhedra::IsFaceConvex(dgEdge* const face, const dgFloat64* const vertex, dgInt32 strideInBytes) const -{ - if (face->m_next->m_next->m_next == face) { - return true; - } - dgBigVector normal(FaceNormal(face, vertex, strideInBytes)); - normal.m_w = dgFloat32(0.0f); - - dgInt32 stride = strideInBytes / sizeof(dgFloat64); - dgEdge* ptr = face; - do { - dgBigVector p0(&vertex[ptr->m_incidentVertex * stride]); - dgBigVector p1(&vertex[ptr->m_prev->m_incidentVertex * stride]); - dgBigVector p2(&vertex[ptr->m_next->m_incidentVertex * stride]); - dgBigVector e0(p1 - p0); - dgBigVector e1(p2 - p1); - dgBigVector cornerNormal(e1.CrossProduct(e0)); - dgFloat64 project(normal.DotProduct(cornerNormal).GetScalar()); - if (project < dgFloat32(0.0f)) { - return false; - } - - ptr = ptr->m_next; - } while (ptr != face); - - return true; -} - -void dgPolyhedra::RemoveOuterColinearEdges (dgPolyhedra& flatFace, const dgFloat64* const vertex, dgInt32 stride) -{ - dgEdge* edgePerimeters[DG_LOCAL_BUFFER_SIZE]; - - dgInt32 perimeterCount = 0; - dgInt32 mark = flatFace.IncLRU(); - dgPolyhedra::Iterator iter (flatFace); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if ((edge->m_incidentFace < 0) && (edge->m_mark != mark)) { - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - - edgePerimeters[perimeterCount] = edge; - perimeterCount++; - dgAssert(perimeterCount < dgInt32(sizeof(edgePerimeters) / sizeof(edgePerimeters[0]))); - } - } - - dgInt8 buffer[2048 * sizeof (dgFloat64)]; - dgDownHeap<dgEdge*, dgFloat64> heap(&buffer[0], sizeof (buffer)); - for (dgInt32 i = 0; i < perimeterCount; i ++) { - dgEdge* edge = edgePerimeters[i]; - dgEdge* ptr = edge; - dgBigVector p0 (&vertex[ptr->m_incidentVertex * stride]); - dgBigVector p1 (&vertex[ptr->m_next->m_incidentVertex * stride]); - dgBigVector e0 (p1 - p0) ; - e0 = e0.Scale (dgRsqrt (e0.DotProduct3(e0) + dgFloat32 (1.0e-12f))); - dgInt32 ignoreTest = 1; - do { - ignoreTest = 0; - dgBigVector p2 (&vertex[ptr->m_next->m_next->m_incidentVertex * stride]); - dgBigVector e1 (p2 - p1); - e1 = e1.Scale (dgRsqrt (e1.DotProduct3(e1) + dgFloat32 (1.0e-12f))); - dgFloat64 dot = e1.DotProduct3(e0); - if (dot > dgFloat32 (dgFloat32 (0.9999f))) { - - for (dgEdge* interiorEdge = ptr->m_next->m_twin->m_next; interiorEdge != ptr->m_twin; interiorEdge = ptr->m_next->m_twin->m_next) { - dgAssert((interiorEdge->m_incidentFace > 0) && (interiorEdge->m_twin->m_incidentFace > 0)); - if ((interiorEdge->m_incidentFace > 0) && (interiorEdge->m_twin->m_incidentFace > 0)) { - flatFace.DeleteEdge(interiorEdge); - } else { - return; - } - } - - if (ptr->m_twin->m_next->m_next->m_next == ptr->m_twin) { - dgAssert (ptr->m_twin->m_next->m_incidentFace > 0); - flatFace.DeleteEdge (ptr->m_twin->m_next); - } - - dgAssert (ptr->m_next->m_twin->m_next->m_twin == ptr); - edge = ptr->m_next; - - if (!flatFace.FindEdge (ptr->m_incidentVertex, edge->m_twin->m_incidentVertex) && - !flatFace.FindEdge (edge->m_twin->m_incidentVertex, ptr->m_incidentVertex)) { - ptr->m_twin->m_prev = edge->m_twin->m_prev; - edge->m_twin->m_prev->m_next = ptr->m_twin; - - edge->m_next->m_prev = ptr; - ptr->m_next = edge->m_next; - - edge->m_next = edge->m_twin; - edge->m_prev = edge->m_twin; - edge->m_twin->m_next = edge; - edge->m_twin->m_prev = edge; - flatFace.DeleteEdge (edge); - flatFace.ChangeEdgeIncidentVertex (ptr->m_twin, ptr->m_next->m_incidentVertex); - - if (!flatFace.IsFaceConvex(ptr->m_twin, vertex, stride * sizeof(dgFloat64))) { - heap.Flush(); - flatFace.TriangulateFace(ptr->m_twin, vertex, stride, heap, NULL); - } - - e1 = e0; - p1 = p2; - edge = ptr; - ignoreTest = 1; - continue; - } - } - - e0 = e1; - p1 = p2; - ptr = ptr->m_next; - } while ((ptr != edge) || ignoreTest); - } -} - -void dgPolyhedra::RemoveInteriorColinearEdges(dgPolyhedra& flatFace, const dgFloat64* const vertex, dgInt32 stride) -{ - bool foundEdge = true; - while (foundEdge) { - foundEdge = false; - dgPolyhedra::Iterator iter(flatFace); - for (iter.Begin(); iter; iter++) { - dgEdge* const edge = &(*iter); - if ((edge->m_incidentFace > 0) && (edge->m_twin->m_incidentFace > 0)) { - if (edge->m_twin->m_next->m_twin->m_next == edge) { - dgBigVector p0(&vertex[edge->m_prev->m_incidentVertex * stride]); - dgBigVector p1(&vertex[edge->m_incidentVertex * stride]); - dgBigVector p2(&vertex[edge->m_next->m_incidentVertex * stride]); - - dgBigVector e0(p1 - p0); - dgBigVector e1(p2 - p1); - e0 = e0.Scale(dgRsqrt(e0.DotProduct3(e0) + dgFloat32(1.0e-12f))); - e1 = e1.Scale(dgRsqrt(e1.DotProduct3(e1) + dgFloat32(1.0e-12f))); - dgFloat64 dot = e1.DotProduct3(e0); - if (dot > dgFloat32(0.9999f)) { - dgInt32 v = edge->m_twin->m_incidentVertex; - dgEdge* const nextEdge = edge->m_twin->m_next; - edge->m_next->m_prev = edge->m_prev; - edge->m_prev->m_next = edge->m_next; - edge->m_twin->m_next->m_prev = edge->m_twin->m_prev; - edge->m_twin->m_prev->m_next = edge->m_twin->m_next; - - edge->m_next = edge->m_twin; - edge->m_prev = edge->m_twin; - edge->m_twin->m_next = edge; - edge->m_twin->m_prev = edge; - flatFace.DeleteEdge(edge); - flatFace.ChangeEdgeIncidentVertex(nextEdge, v); - foundEdge = true; - break; - } - } - } - } - } -} - - -dgInt32 dgPolyhedra::GetInteriorDiagonals (dgPolyhedra& polyhedra, dgEdge** const diagonals, dgInt32 maxCount) -{ - dgInt32 count = 0; - dgInt32 mark = polyhedra.IncLRU(); - dgPolyhedra::Iterator iter (polyhedra); - for (iter.Begin(); iter; iter++) { - dgEdge* const edge = &(*iter); - if (edge->m_mark != mark) { - if (edge->m_incidentFace > 0) { - if (edge->m_twin->m_incidentFace > 0) { - edge->m_twin->m_mark = mark; - if (count < maxCount){ - diagonals[count] = edge; - count ++; - } - dgAssert (count <= maxCount); - } - } - } - edge->m_mark = mark; - } - - return count; -} - -bool dgPolyhedra::IsEssensialPointDiagonal (dgEdge* const diagonal, const dgBigVector& normal, const dgFloat64* const pool, dgInt32 stride) -{ - if (diagonal->m_twin->m_next->m_twin->m_next != diagonal) { - dgBigVector p0 (&pool[diagonal->m_incidentVertex * stride]); - dgBigVector p1 (&pool[diagonal->m_twin->m_next->m_twin->m_incidentVertex * stride]); - dgBigVector p2 (&pool[diagonal->m_prev->m_incidentVertex * stride]); - - dgBigVector e1 (p1 - p0); - dgFloat64 dot = e1.DotProduct3(e1); - if (dot < dgFloat64 (1.0e-12f)) { - return false; - } - e1 = e1.Scale (dgFloat64 (1.0f) / sqrt(dot)); - - dgBigVector e2 (p2 - p0); - dot = e2.DotProduct3(e2); - if (dot < dgFloat64 (1.0e-12f)) { - return false; - } - e2 = e2.Scale (dgFloat64 (1.0f) / sqrt(dot)); - - dgBigVector n1 (e1.CrossProduct(e2)); - - dot = normal.DotProduct3(n1); - if (dot >= dgFloat64 (0.0f)) { - return false; - } - } - return true; -} - - -bool dgPolyhedra::IsEssensialDiagonal (dgEdge* const diagonal, const dgBigVector& normal, const dgFloat64* const pool, dgInt32 stride) -{ - return IsEssensialPointDiagonal (diagonal, normal, pool, stride) || IsEssensialPointDiagonal (diagonal->m_twin, normal, pool, stride); -} - -dgObb dgPolyhedra::CalculateSphere (const dgFloat64* const vertex, dgInt32 strideInBytes, const dgMatrix* const basis) const -{ - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat64)); - - dgInt32 vertexCount = 0; - dgInt32 mark = IncLRU(); - dgPolyhedra::Iterator iter(*this); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if (edge->m_mark != mark) { - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - vertexCount ++; - } - } - dgAssert (vertexCount); - - mark = IncLRU(); - dgInt32 vertexCountIndex = 0; - dgStack<dgBigVector> pool (vertexCount); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if (edge->m_mark != mark) { - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - dgInt32 incidentVertex = edge->m_incidentVertex * stride; - pool[vertexCountIndex] = dgBigVector (vertex[incidentVertex + 0], vertex[incidentVertex + 1], vertex[incidentVertex + 2], dgFloat32 (0.0f)); - vertexCountIndex ++; - } - } - dgAssert (vertexCountIndex <= vertexCount); - - dgMatrix axis (dgGetIdentityMatrix()); - dgObb sphere (axis); - dgConvexHull3d convexHull (GetAllocator(), &pool[0].m_x, sizeof (dgBigVector), vertexCountIndex, 0.0f); - if (convexHull.GetCount()) { - dgStack<dgInt32> triangleList (convexHull.GetCount() * 3); - dgInt32 trianglesCount = 0; - for (dgConvexHull3d::dgListNode* node = convexHull.GetFirst(); node; node = node->GetNext()) { - dgConvexHull3DFace* const face = &node->GetInfo(); - triangleList[trianglesCount * 3 + 0] = face->m_index[0]; - triangleList[trianglesCount * 3 + 1] = face->m_index[1]; - triangleList[trianglesCount * 3 + 2] = face->m_index[2]; - trianglesCount ++; - dgAssert ((trianglesCount * 3) <= triangleList.GetElementsCount()); - } - - dgVector* const dst = (dgVector*) &pool[0].m_x; - for (dgInt32 i = 0; i < convexHull.GetVertexCount(); i ++) { - dst[i] = convexHull.GetVertex(i); - } - sphere.SetDimensions (&dst[0].m_x, sizeof (dgVector), &triangleList[0], trianglesCount * 3, NULL); - - } else if (vertexCountIndex >= 3) { - dgStack<dgInt32> triangleList (GetCount() * 3 * 2); - dgInt32 mark1 = IncLRU(); - dgInt32 trianglesCount = 0; - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if (edge->m_mark != mark1) { - dgEdge* ptr = edge; - do { - ptr->m_mark = mark1; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - - ptr = edge->m_next->m_next; - do { - triangleList[trianglesCount * 3 + 0] = edge->m_incidentVertex; - triangleList[trianglesCount * 3 + 1] = ptr->m_prev->m_incidentVertex; - triangleList[trianglesCount * 3 + 2] = ptr->m_incidentVertex; - trianglesCount ++; - dgAssert ((trianglesCount * 3) <= triangleList.GetElementsCount()); - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - - dgVector* const dst = (dgVector*) &pool[0].m_x; - for (dgInt32 i = 0; i < vertexCountIndex; i ++) { - dst[i] = pool[i]; - } - sphere.SetDimensions (&dst[0].m_x, sizeof (dgVector), &triangleList[0], trianglesCount * 3, NULL); - } - } - } - return sphere; -} - -dgBigPlane dgPolyhedra::EdgePlane (dgInt32 i0, dgInt32 i1, dgInt32 i2, const dgBigVector* const pool) const -{ - const dgBigVector& p0 = pool[i0]; - const dgBigVector& p1 = pool[i1]; - const dgBigVector& p2 = pool[i2]; - - dgBigPlane plane (p0, p1, p2); - dgFloat64 mag = sqrt (plane.DotProduct(plane & dgBigPlane::m_triplexMask).GetScalar()); - if (mag < dgFloat64 (1.0e-12f)) { - mag = dgFloat64 (1.0e-12f); - } - mag = dgFloat64 (1.0f) / mag; - - plane.m_x *= mag; - plane.m_y *= mag; - plane.m_z *= mag; - plane.m_w *= mag; - - return plane; -} - - -void dgPolyhedra::CalculateVertexMetrics (dgVertexCollapseVertexMetric* const table, const dgBigVector* const pool, dgEdge* const edge) const -{ - dgInt32 i0 = edge->m_incidentVertex; - - table[i0].Clear (); - dgEdge* ptr = edge; - do { - - if (ptr->m_incidentFace > 0) { - dgInt32 i1 = ptr->m_next->m_incidentVertex; - dgInt32 i2 = ptr->m_prev->m_incidentVertex; - dgBigPlane constrainPlane (EdgePlane (i0, i1, i2, pool)); - table[i0].Accumulate (constrainPlane); - - } else { - dgInt32 i1 = ptr->m_twin->m_incidentVertex; - dgInt32 i2 = ptr->m_twin->m_prev->m_incidentVertex; - dgBigPlane constrainPlane (UnboundedLoopPlane (i0, i1, i2, pool)); - table[i0].Accumulate (constrainPlane); - - i1 = ptr->m_prev->m_incidentVertex; - i2 = ptr->m_prev->m_twin->m_prev->m_incidentVertex; - constrainPlane = UnboundedLoopPlane (i0, i1, i2, pool); - table[i0].Accumulate (constrainPlane); - } - - ptr = ptr->m_twin->m_next; - } while (ptr != edge); -} - - -void dgPolyhedra::CalculateAllMetrics (dgVertexCollapseVertexMetric* const table, const dgBigVector* const pool) const -{ - dgInt32 edgeMark = IncLRU(); - dgPolyhedra::Iterator iter (*this); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - - dgAssert (edge); - if (edge->m_mark != edgeMark) { - - if (edge->m_incidentFace > 0) { - dgInt32 i0 = edge->m_incidentVertex; - dgInt32 i1 = edge->m_next->m_incidentVertex; - dgInt32 i2 = edge->m_prev->m_incidentVertex; - - dgBigPlane constrainPlane (EdgePlane (i0, i1, i2, pool)); - dgVertexCollapseVertexMetric tmp (constrainPlane); - - dgEdge* ptr = edge; - do { - ptr->m_mark = edgeMark; - i0 = ptr->m_incidentVertex; - table[i0].Accumulate(tmp); - - ptr = ptr->m_next; - } while (ptr != edge); - - } else { - dgAssert (edge->m_twin->m_incidentFace > 0); - dgInt32 i0 = edge->m_twin->m_incidentVertex; - dgInt32 i1 = edge->m_twin->m_next->m_incidentVertex; - dgInt32 i2 = edge->m_twin->m_prev->m_incidentVertex; - - edge->m_mark = edgeMark; - dgBigPlane constrainPlane (UnboundedLoopPlane (i0, i1, i2, pool)); - dgVertexCollapseVertexMetric tmp (constrainPlane); - - i0 = edge->m_incidentVertex; - table[i0].Accumulate(tmp); - - i0 = edge->m_twin->m_incidentVertex; - table[i0].Accumulate(tmp); - } - } - } -} - -bool dgPolyhedra::IsOkToCollapse (const dgBigVector* const pool, dgEdge* const edge) const -{ - const dgBigVector& q = pool[edge->m_incidentVertex]; - const dgBigVector& p = pool[edge->m_twin->m_incidentVertex]; - for (dgEdge* triangle = edge->m_prev->m_twin; triangle != edge->m_twin->m_next; triangle = triangle->m_prev->m_twin) { - if (triangle->m_incidentFace > 0) { - dgAssert ((edge->m_incidentFace < 0) || (edge->m_incidentVertex == edge->m_next->m_next->m_next->m_incidentVertex)); - - dgBigVector originalArea ((pool[triangle->m_next->m_incidentVertex] - q).CrossProduct(pool[triangle->m_prev->m_incidentVertex] - q)); - dgBigVector newArea ((pool[triangle->m_next->m_incidentVertex] - p).CrossProduct(pool[triangle->m_prev->m_incidentVertex] - p)); - - dgFloat64 projectedArea = newArea.DotProduct3(originalArea); - if (projectedArea <= dgFloat64 (0.0f)) { - return false; - } - - dgFloat64 mag20 = newArea.DotProduct3(newArea); - dgFloat64 mag21 = originalArea.DotProduct3(originalArea); - if ((projectedArea * projectedArea) < (mag20 * mag21 * dgFloat64 (1.0e-10f))) { - return false; - } - } - } - - return true; -} - - -dgEdge* dgPolyhedra::OptimizeCollapseEdge (dgEdge* const edge) -{ - dgInt32 v0 = edge->m_incidentVertex; - dgInt32 v1 = edge->m_twin->m_incidentVertex; - -#ifdef _DEBUG - dgPolyhedra::dgPairKey TwinKey (v1, v0); - dgPolyhedra::dgTreeNode* const node = Find (TwinKey.GetVal()); - dgEdge* const twin1 = node ? &node->GetInfo() : NULL; - dgAssert (twin1); - dgAssert (edge->m_twin == twin1); - dgAssert (twin1->m_twin == edge); - dgAssert (edge->m_incidentFace != 0); - dgAssert (twin1->m_incidentFace != 0); - dgAssert ((edge->m_incidentFace < 0) || (edge->m_incidentVertex == edge->m_next->m_next->m_next->m_incidentVertex)); - dgAssert ((edge->m_twin->m_incidentFace < 0) || (edge->m_twin->m_incidentVertex == edge->m_twin->m_next->m_next->m_next->m_incidentVertex)); -#endif - - dgEdge* retEdge = edge->m_twin->m_prev->m_twin; - if (retEdge == edge->m_twin->m_next) { - return NULL; - } - if (retEdge == edge->m_twin) { - return NULL; - } - if (retEdge == edge->m_next) { - retEdge = edge->m_prev->m_twin; - if (retEdge == edge->m_twin->m_next) { - return NULL; - } - if (retEdge == edge->m_twin) { - return NULL; - } - } - - dgEdge* lastEdge = NULL; - dgEdge* firstEdge = NULL; - if ((edge->m_incidentFace >= 0) && (edge->m_twin->m_incidentFace >= 0)) { - lastEdge = edge->m_prev->m_twin; - firstEdge = edge->m_twin->m_next->m_twin->m_next; - } else if (edge->m_twin->m_incidentFace >= 0) { - firstEdge = edge->m_twin->m_next->m_twin->m_next; - lastEdge = edge; - } else { - lastEdge = edge->m_prev->m_twin; - firstEdge = edge->m_twin->m_next; - } - - for (dgEdge* ptr = firstEdge; ptr != lastEdge; ptr = ptr->m_twin->m_next) { - dgEdge* badEdge = FindEdge (edge->m_twin->m_incidentVertex, ptr->m_twin->m_incidentVertex); - if (badEdge) { - return NULL; - } - } - - dgEdge* const twin = edge->m_twin; - if (twin->m_next == twin->m_prev->m_prev) { - twin->m_prev->m_twin->m_twin = twin->m_next->m_twin; - twin->m_next->m_twin->m_twin = twin->m_prev->m_twin; - - RemoveHalfEdge (twin->m_prev); - RemoveHalfEdge (twin->m_next); - } else { - twin->m_next->m_prev = twin->m_prev; - twin->m_prev->m_next = twin->m_next; - } - - if (edge->m_next == edge->m_prev->m_prev) { - edge->m_next->m_twin->m_twin = edge->m_prev->m_twin; - edge->m_prev->m_twin->m_twin = edge->m_next->m_twin; - RemoveHalfEdge (edge->m_next); - RemoveHalfEdge (edge->m_prev); - } else { - edge->m_next->m_prev = edge->m_prev; - edge->m_prev->m_next = edge->m_next; - } - - dgAssert (twin->m_twin->m_incidentVertex == v0); - dgAssert (edge->m_twin->m_incidentVertex == v1); - RemoveHalfEdge (twin); - RemoveHalfEdge (edge); - - dgEdge* remapPtr = retEdge; - do { - dgPolyhedra::dgPairKey pairKey (v0, remapPtr->m_twin->m_incidentVertex); - dgPolyhedra::dgTreeNode* const pairEdgeNode = Find (pairKey.GetVal()); - if (pairEdgeNode) { - if (&pairEdgeNode->GetInfo() == remapPtr) { - dgPolyhedra::dgPairKey key (v1, remapPtr->m_twin->m_incidentVertex); - remapPtr->m_incidentVertex = v1; - ReplaceKey (pairEdgeNode, key.GetVal()); - } - } - - dgPolyhedra::dgPairKey twinKey1 (remapPtr->m_twin->m_incidentVertex, v0); - dgPolyhedra::dgTreeNode* const pairTwinNode = Find (twinKey1.GetVal()); - if (pairTwinNode) { - if (&pairTwinNode->GetInfo() == remapPtr->m_twin) { - dgPolyhedra::dgPairKey key (remapPtr->m_twin->m_incidentVertex, v1); - ReplaceKey (pairTwinNode, key.GetVal()); - } - } - - remapPtr = remapPtr->m_twin->m_next; - } while (remapPtr != retEdge); - - return retEdge; -} - - -dgFloat64 dgPolyhedra::EdgePenalty (const dgBigVector* const pool, dgEdge* const edge, dgFloat64 dist) const -{ - dgInt32 i0 = edge->m_incidentVertex; - dgInt32 i1 = edge->m_next->m_incidentVertex; - - dgFloat32 maxPenalty = dgFloat32 (1.0e14f); - - const dgBigVector& p0 = pool[i0]; - const dgBigVector& p1 = pool[i1]; - dgBigVector dp (p1 - p0); - - dgFloat64 dot = dp.DotProduct3(dp); - if (dot < dgFloat64(1.0e-6f)) { - return dist * maxPenalty; - } - - if ((edge->m_incidentFace > 0) && (edge->m_twin->m_incidentFace > 0)) { - dgBigVector edgeNormal (FaceNormal (edge, &pool[0].m_x, sizeof (dgBigVector))); - dgBigVector twinNormal (FaceNormal (edge->m_twin, &pool[0].m_x, sizeof (dgBigVector))); - - dgFloat64 mag0 = edgeNormal.DotProduct3(edgeNormal); - dgFloat64 mag1 = twinNormal.DotProduct3(twinNormal); - if ((mag0 < dgFloat64 (1.0e-24f)) || (mag1 < dgFloat64 (1.0e-24f))) { - return dist * maxPenalty; - } - - edgeNormal = edgeNormal.Scale (dgFloat64 (1.0f) / sqrt(mag0)); - twinNormal = twinNormal.Scale (dgFloat64 (1.0f) / sqrt(mag1)); - - dot = edgeNormal.DotProduct3(twinNormal); - if (dot < dgFloat64 (-0.9f)) { - return dist * maxPenalty; - } - - dgEdge* ptr = edge; - do { - if ((ptr->m_incidentFace <= 0) || (ptr->m_twin->m_incidentFace <= 0)){ - dgEdge* const adj = edge->m_twin; - ptr = edge; - do { - if ((ptr->m_incidentFace <= 0) || (ptr->m_twin->m_incidentFace <= 0)){ - return dist * maxPenalty; - } - ptr = ptr->m_twin->m_next; - } while (ptr != adj); - } - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - } - - dgInt32 faceA = edge->m_incidentFace; - dgInt32 faceB = edge->m_twin->m_incidentFace; - - i0 = edge->m_twin->m_incidentVertex; - dgBigVector p (pool[i0].m_x, pool[i0].m_y, pool[i0].m_z, dgFloat32 (0.0f)); - - bool penalty = false; - dgEdge* ptr = edge; - do { - dgEdge* const adj = ptr->m_twin; - - dgInt32 face = adj->m_incidentFace; - if ((face != faceB) && (face != faceA) && (face >= 0) && (adj->m_next->m_incidentFace == face) && (adj->m_prev->m_incidentFace == face)){ - - dgInt32 k0 = adj->m_next->m_incidentVertex; - const dgBigVector& q0 = pool[k0]; - - dgInt32 k1 = adj->m_incidentVertex; - const dgBigVector& q1 = pool[k1]; - - dgInt32 k2 = adj->m_prev->m_incidentVertex; - const dgBigVector& q2 = pool[k2]; - - dgBigVector n0 ((q1 - q0).CrossProduct(q2 - q0)); - dgBigVector n1 ((q1 - p).CrossProduct(q2 - p)); - dgFloat64 project = n0.DotProduct3(n1); - if (project < dgFloat64 (0.0f)) { - penalty = true; - break; - } - } - - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - - dgFloat64 aspect = dgFloat32 (0.0f); - if (!penalty) { - dgInt32 k0 = edge->m_twin->m_incidentVertex; - dgBigVector q0 (pool[k0]); - - aspect = dgFloat32 (1.0f); - for (dgEdge* ptr1 = edge->m_twin->m_next->m_twin->m_next; ptr1 != edge; ptr1 = ptr1->m_twin->m_next) { - if (ptr1->m_incidentFace > 0) { - dgInt32 k1 = ptr1->m_next->m_incidentVertex; - const dgBigVector& q1 = pool[k1]; - - dgInt32 k2 = ptr1->m_prev->m_incidentVertex; - const dgBigVector& q2 = pool[k2]; - - dgBigVector e0 (q1 - q0); - dgBigVector e1 (q2 - q1); - dgBigVector e2 (q0 - q2); - - dgFloat64 mag0 = e0.DotProduct3(e0); - dgFloat64 mag1 = e1.DotProduct3(e1); - dgFloat64 mag2 = e2.DotProduct3(e2); - dgFloat64 maxMag = dgMax (mag0, mag1, mag2); - dgFloat64 minMag = dgMin (mag0, mag1, mag2); - dgFloat64 ratio = minMag / maxMag; - - if (ratio < aspect) { - aspect = ratio; - } - } - } - aspect = dgFloat32 (1.0f) - aspect; - } - return aspect * aspect * dist; -} - - -bool dgPolyhedra::Optimize (const dgFloat64* const array, dgInt32 strideInBytes, dgReportProgress normalizedProgress, void* const reportProgressUserData, dgFloat64 tol, dgInt32 maxFaceCount) -{ - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat64)); - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif - - dgFloat32 progressDen = dgFloat32 (1.0f / GetEdgeCount()); - dgInt32 edgeCount = GetEdgeCount() * 4 + DG_LOCAL_BUFFER_SIZE * 16; - dgInt32 maxVertexIndex = GetLastVertexIndex(); - - dgStack<dgBigVector> vertexPool (maxVertexIndex); - dgStack<dgVertexCollapseVertexMetric> vertexMetrics (maxVertexIndex + 512); - - dgList <dgEdgeCollapseEdgeHandle> edgeHandleList(GetAllocator()); - dgStack<char> heapPool (2 * edgeCount * dgInt32 (sizeof (dgFloat64) + sizeof (dgEdgeCollapseEdgeHandle*) + sizeof (dgInt32))); - dgUpHeap<dgList <dgEdgeCollapseEdgeHandle>::dgListNode* , dgFloat64> bigHeapArray(&heapPool[0], heapPool.GetSizeInBytes()); - - for (dgInt32 i = 0; i < maxVertexIndex; i ++) { - vertexPool[i].m_x = array[i * stride + 0]; - vertexPool[i].m_y = array[i * stride + 1]; - vertexPool[i].m_z = array[i * stride + 2]; - vertexPool[i].m_w= dgFloat64 (0.0f); - } - - memset (&vertexMetrics[0], 0, maxVertexIndex * sizeof (dgVertexCollapseVertexMetric)); - CalculateAllMetrics (&vertexMetrics[0], &vertexPool[0]); - - const dgFloat64 maxCost = dgFloat32 (1.0e-3f); - dgFloat64 tol2 = tol * tol; - dgFloat64 distTol = dgMax (tol2, dgFloat64 (1.0e-12f)); - Iterator iter (*this); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - - edge->m_userData = 0; - dgInt32 index0 = edge->m_incidentVertex; - dgInt32 index1 = edge->m_twin->m_incidentVertex; - - dgVertexCollapseVertexMetric &metric = vertexMetrics[index0]; - const dgBigVector& p = vertexPool[index1]; - dgFloat64 faceCost = metric.Evalue (p); - dgFloat64 edgePenalty = EdgePenalty (&vertexPool[0], edge, distTol); - dgAssert (edgePenalty >= dgFloat32 (0.0f)); - dgEdgeCollapseEdgeHandle handle (edge); - dgList <dgEdgeCollapseEdgeHandle>::dgListNode* handleNodePtr = edgeHandleList.Addtop (handle); - bigHeapArray.Push (handleNodePtr, faceCost + edgePenalty); - } - - bool progress = true; - dgInt32 interPasses = 0; - dgInt32 faceCount = GetFaceCount(); - while (bigHeapArray.GetCount() && (bigHeapArray.Value() < maxCost) && ((bigHeapArray.Value() < tol2) || (faceCount > maxFaceCount)) && progress ) { - dgList <dgEdgeCollapseEdgeHandle>::dgListNode* const handleNodePtr = bigHeapArray[0]; - - dgEdge* edge = handleNodePtr->GetInfo().m_edge; - bigHeapArray.Pop(); - edgeHandleList.Remove (handleNodePtr); - - if (edge) { - if (IsOkToCollapse (&vertexPool[0], edge)) { - - if (normalizedProgress) { - interPasses ++; - faceCount -= 2; - if (interPasses >= 400) { - interPasses = 0; - faceCount = GetFaceCount(); - progress = normalizedProgress(dgFloat32 (1.0f) - GetEdgeCount() * progressDen, reportProgressUserData); - } - } - - if (bigHeapArray.GetCount() > (bigHeapArray.GetMaxCount() - 100)) { - for(dgInt32 i = bigHeapArray.GetCount() - 1; i >= 0; i --) { - dgList <dgEdgeCollapseEdgeHandle>::dgListNode* const emptyHandle = bigHeapArray[i]; - if (!emptyHandle->GetInfo().m_edge) { - bigHeapArray.Remove(i); - edgeHandleList.Remove (emptyHandle); - } - } - } - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif - - edge = OptimizeCollapseEdge(edge); - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - dgAssert (SanityCheck ()); -#endif - if (edge) { - // Update vertex metrics - CalculateVertexMetrics (&vertexMetrics[0], &vertexPool[0], edge); - - // Update metrics for all surrounding vertex - dgEdge* ptr = edge; - do { - CalculateVertexMetrics (&vertexMetrics[0], &vertexPool[0], ptr->m_twin); - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - - // calculate edge cost of all incident edges - dgInt32 mark = IncLRU(); - ptr = edge; - do { - dgAssert (ptr->m_mark != mark); - ptr->m_mark = mark; - - dgInt32 index0 = ptr->m_incidentVertex; - dgInt32 index1 = ptr->m_twin->m_incidentVertex; - - dgVertexCollapseVertexMetric &metric = vertexMetrics[index0]; - const dgBigVector& p = vertexPool[index1]; - - dgFloat64 faceCost = metric.Evalue (p); - dgFloat64 edgePenalty = EdgePenalty (&vertexPool[0], ptr, distTol); - dgAssert (edgePenalty >= dgFloat32 (0.0f)); - dgEdgeCollapseEdgeHandle handle (ptr); - dgList <dgEdgeCollapseEdgeHandle>::dgListNode* handleNodePtr1 = edgeHandleList.Addtop (handle); - bigHeapArray.Push (handleNodePtr1, faceCost + edgePenalty); - - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - - - // calculate edge cost of all incident edges to a surrounding vertex - ptr = edge; - do { - dgEdge* const incidentEdge = ptr->m_twin; - - dgEdge* ptr1 = incidentEdge; - do { - dgInt32 index0 = ptr1->m_incidentVertex; - dgInt32 index1 = ptr1->m_twin->m_incidentVertex; - - if (ptr1->m_mark != mark) { - ptr1->m_mark = mark; - dgVertexCollapseVertexMetric &metric = vertexMetrics[index0]; - const dgBigVector& p = vertexPool[index1]; - - dgFloat64 faceCost = metric.Evalue (p); - dgFloat64 edgePenalty = EdgePenalty (&vertexPool[0], ptr1, distTol); - dgAssert (edgePenalty >= dgFloat32 (0.0f)); - dgEdgeCollapseEdgeHandle handle (ptr1); - dgList <dgEdgeCollapseEdgeHandle>::dgListNode* handleNodePtr1 = edgeHandleList.Addtop (handle); - bigHeapArray.Push (handleNodePtr1, faceCost + edgePenalty); - } - - if (ptr1->m_twin->m_mark != mark) { - ptr1->m_twin->m_mark = mark; - dgVertexCollapseVertexMetric &metric = vertexMetrics[index1]; - const dgBigVector& p = vertexPool[index0]; - dgFloat64 faceCost = metric.Evalue (p); - dgFloat64 edgePenalty = EdgePenalty (&vertexPool[0], ptr1->m_twin, distTol); - dgAssert (edgePenalty >= dgFloat32 (0.0f)); - dgEdgeCollapseEdgeHandle handle (ptr1->m_twin); - dgList <dgEdgeCollapseEdgeHandle>::dgListNode* handleNodePtr1 = edgeHandleList.Addtop (handle); - bigHeapArray.Push (handleNodePtr1, faceCost + edgePenalty); - } - - ptr1 = ptr1->m_twin->m_next; - } while (ptr1 != incidentEdge); - - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - } - } - } - } - - if (normalizedProgress && progress) { - progress = normalizedProgress(dgFloat32 (1.0f), reportProgressUserData); - } - return progress; -} - -bool dgPolyhedra::TriangulateFace(dgEdge* const face, const dgFloat64* const pool, dgInt32 strideInBytes) -{ - if (face->m_next->m_next->m_next != face) { - dgInt32 mark = IncLRU(); - dgEdge* ptr = face; - do { - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != face); - char memPool[DG_LOCAL_BUFFER_SIZE * (sizeof (dgEdge*)+sizeof (dgFloat64))]; - dgDownHeap<dgEdge*, dgFloat64> heap(&memPool[0], sizeof (memPool)); - - dgInt32 stride = dgInt32(strideInBytes / sizeof (dgFloat64)); - dgEdge* const edge = TriangulateFace(face, pool, stride, heap, NULL); - dgAssert(!edge); - return !edge; - } - return true; -} - - -dgEdge* dgPolyhedra::BestEdgePolygonizeFace(const dgBigVector& normal, dgEdge* const edge, const dgFloat64* const pool, dgInt32 stride, const dgBigVector& point) const -{ - dgBigVector p0(&pool[edge->m_incidentVertex * stride]); - dgBigVector r(point - p0); - dgEdge* e0 = edge; - do { - dgBigVector p1(&pool[e0->m_twin->m_incidentVertex * stride]); - dgBigVector p2(&pool[e0->m_prev->m_incidentVertex * stride]); - //dgFloat64 test0 = (normal * (p1 - p0)) % r; - //dgFloat64 test1 = ((p2 - p0) * normal) % r; - dgFloat64 test0 = r.DotProduct3(normal.CrossProduct(p1 - p0)); - dgFloat64 test1 = r.DotProduct3((p2 - p0).CrossProduct(normal)); - - if ((test0 > 0.0f) && (test1 > 0.0f)) { - break; - } - e0 = e0->m_prev->m_twin; - } while (e0 != edge); - return e0; -} - -bool dgPolyhedra::PolygonizeFace(dgEdge* const face, const dgFloat64* const pool, dgInt32 strideInBytes) -{ - dgPolyhedra flatFace(GetAllocator()); - dgEdge* array[DG_LOCAL_BUFFER_SIZE]; - - dgInt32 count = 0; - dgEdge* edge = face; - do { - dgEdge* const perimeter = flatFace.AddHalfEdge (edge->m_incidentVertex, edge->m_twin->m_incidentVertex); - dgAssert (perimeter); - perimeter->m_userData = edge->m_userData; - perimeter->m_incidentFace = 1; - perimeter->m_twin = NULL; - perimeter->m_prev = NULL; - perimeter->m_next = NULL; - - array[count] = perimeter; - count++; - dgAssert(count <= DG_LOCAL_BUFFER_SIZE); - edge = edge->m_next; - } while (edge != face); - - dgInt32 i0 = count - 1; - for(dgInt32 i = 0; i < count; i ++) { - dgEdge* const edge1 = array[i]; - dgEdge* const prev1 = array[i0]; - - edge1->m_prev = prev1; - prev1->m_next = edge1; - i0 = i; - } - - for(dgInt32 i = 0; i < count; i ++) { - dgEdge* const edge1 = array[i]; - dgEdge* const twin1 = flatFace.FindEdge (edge1->m_next->m_incidentVertex, edge1->m_incidentVertex); - if (twin1) { - twin1->m_twin = edge1; - edge1->m_twin = twin1; - } else { - dgEdge* const perimeter = flatFace.AddHalfEdge (edge1->m_next->m_incidentVertex, edge1->m_incidentVertex); - perimeter->m_twin = edge1; - edge1->m_twin = perimeter; - perimeter->m_incidentFace = -1; - perimeter->m_prev = NULL; - perimeter->m_next = NULL; - } - } - - for (dgInt32 i = 0; i < count; i++) { - dgEdge* const edge1 = array[i]; - dgEdge* const twin1 = edge1->m_twin; - if (!twin1->m_next) { - dgEdge* next = edge1->m_prev->m_twin; - while (next->m_prev) { - next = next->m_prev->m_twin; - } - twin1->m_next = next; - next->m_prev = next; - } - } - - dgBigVector normal (flatFace.FaceNormal(array[0], pool, strideInBytes)); - if (flatFace.TriangulateFace(array[0], pool, strideInBytes)) { - dgInt32 stride = dgInt32(strideInBytes / sizeof (dgFloat64)); - flatFace.RefineTriangulation(pool, stride); - - //RemoveOuterColinearEdges(*this, vertex, stride); - dgInt32 polygon[DG_LOCAL_BUFFER_SIZE]; - dgEdge* diagonalsPool[DG_LOCAL_BUFFER_SIZE]; - - dgInt32 diagonalCount = GetInteriorDiagonals(flatFace, diagonalsPool, sizeof (diagonalsPool) / sizeof (diagonalsPool[0])); - - if (diagonalCount) { - dgEdge* edge1 = &flatFace.GetRoot()->GetInfo(); - if (edge1->m_incidentFace < 0) { - edge1 = edge1->m_twin; - } - - dgAssert(edge1->m_incidentFace > 0); - - dgBigVector normal1(flatFace.FaceNormal(edge1, pool, strideInBytes)); - normal1 = normal1.Scale(dgFloat64(1.0f) / sqrt(normal1.DotProduct3(normal1))); - - edge1 = NULL; - dgPolyhedra::Iterator iter0(flatFace); - for (iter0.Begin(); iter0; iter0++) { - edge1 = &(*iter0); - if (edge1->m_incidentFace < 0) { - break; - } - } - dgAssert(edge1); - - dgInt32 isConvex = 1; - dgEdge* ptr = edge1; - dgInt32 mark = flatFace.IncLRU(); - - dgBigVector normal2(normal1); - dgBigVector p0(&pool[ptr->m_prev->m_incidentVertex * stride]); - dgBigVector p1(&pool[ptr->m_incidentVertex * stride]); - dgBigVector e0(p1 - p0); - e0 = e0.Scale(dgFloat64(1.0f) / sqrt(e0.DotProduct3(e0) + dgFloat64(1.0e-24f))); - do { - dgBigVector p2(&pool[ptr->m_next->m_incidentVertex * stride]); - dgBigVector e1(p2 - p1); - e1 = e1.Scale(dgFloat64(1.0f) / sqrt(e1.DotProduct3(e1) + dgFloat32(1.0e-24f))); - dgFloat64 dot = normal2.DotProduct3(e0.CrossProduct(e1)); - - if (dot > dgFloat32(5.0e-3f)) { - isConvex = 0; - break; - } - ptr->m_mark = mark; - e0 = e1; - p1 = p2; - ptr = ptr->m_next; - } while (ptr != edge1); - - if (isConvex) { - dgPolyhedra::Iterator iter(flatFace); - for (iter.Begin(); iter; iter++) { - ptr = &(*iter); - if (ptr->m_incidentFace < 0) { - if (ptr->m_mark < mark) { - isConvex = 0; - break; - } - } - } - } - - if (isConvex) { - if (diagonalCount > 2) { - dgInt32 count1 = 0; - ptr = edge1; - do { - polygon[count1] = ptr->m_incidentVertex; - count1++; - dgAssert(count1 < dgInt32(sizeof (polygon) / sizeof (polygon[0]))); - ptr = ptr->m_next; - } while (ptr != edge1); - - for (dgInt32 i = 0; i < count1 - 1; i++) { - for (dgInt32 j = i + 1; j < count1; j++) { - if (polygon[i] == polygon[j]) { - i = count1; - isConvex = 0; - break; - } - } - } - } - } - - if (isConvex) { - for (dgInt32 j = 0; j < diagonalCount; j++) { - dgEdge* const diagonal = diagonalsPool[j]; - flatFace.DeleteEdge(diagonal); - } - } else { - for (dgInt32 j = 0; j < diagonalCount; j++) { - dgEdge* const diagonal = diagonalsPool[j]; - if (!IsEssensialDiagonal(diagonal, normal1, pool, stride)) { - flatFace.DeleteEdge(diagonal); - } - } - } - } - - dgInt32 mark = flatFace.IncLRU(); - dgPolyhedra::Iterator iter0(flatFace); - for (iter0.Begin(); iter0; iter0++) { - dgEdge* const edge1 = &(*iter0); - if ((edge1->m_mark != mark) && (edge1->m_incidentFace > 0)) { - edge1->m_mark = mark; - edge1->m_twin->m_mark = mark; - if (!FindEdge(edge1->m_incidentVertex, edge1->m_twin->m_incidentVertex)) { - dgPairKey key0 (edge1->m_incidentVertex, 0); - dgPairKey key1 (edge1->m_twin->m_incidentVertex, 0); - dgTreeNode* const node0 = FindGreater (key0.GetVal()); - dgTreeNode* const node1 = FindGreater (key1.GetVal()); - dgAssert (node0); - dgAssert (node1); - dgEdge* e0 = &node0->GetInfo(); - dgEdge* e1 = &node1->GetInfo(); - - dgBigVector p0 (&pool[e0->m_incidentVertex * stride]); - dgBigVector p1 (&pool[e1->m_incidentVertex * stride]); - e0 = BestEdgePolygonizeFace (normal, e0, pool, stride, p1); - e1 = BestEdgePolygonizeFace (normal, e1, pool, stride, p0); - ConnectVertex (e0, e1); - } - } - } - } - - return true; -} - -void dgPolyhedra::RemoveInteriorEdges (dgPolyhedra& buildConvex, const dgFloat64* const vertex, dgInt32 strideInBytes) -{ - dgInt32 polygon[DG_LOCAL_BUFFER_SIZE * 8]; - dgEdge* diagonalsPool[DG_LOCAL_BUFFER_SIZE * 8]; - - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat64)); - - buildConvex.BeginFace(); - dgPolyhedra::Iterator iter(*this); - for (iter.Begin(); iter;) { - dgEdge* edge = &(*iter); - iter++; - if (edge->m_incidentFace > 0) { - - dgPolyhedra flatFace(GetAllocator()); - MarkAdjacentCoplanarFaces(flatFace, edge, vertex, strideInBytes); - if (flatFace.GetCount()) { - //flatFace.RefineTriangulation(vertex, stride); - RemoveOuterColinearEdges(flatFace, vertex, stride); - RemoveInteriorColinearEdges(flatFace, vertex, stride); - flatFace.RefineTriangulation(vertex, stride); - - dgInt32 diagonalCount = GetInteriorDiagonals(flatFace, diagonalsPool, sizeof(diagonalsPool) / sizeof(diagonalsPool[0])); - if (diagonalCount) { - edge = &flatFace.GetRoot()->GetInfo(); - if (edge->m_incidentFace < 0) { - edge = edge->m_twin; - } - dgAssert(edge->m_incidentFace > 0); - - dgBigVector normal(FaceNormal(edge, vertex, strideInBytes)); - normal = normal.Scale(dgFloat64(1.0f) / sqrt(normal.DotProduct3(normal))); - - edge = NULL; - dgPolyhedra::Iterator iter1(flatFace); - for (iter1.Begin(); iter1; iter1++) { - edge = &(*iter1); - if (edge->m_incidentFace < 0) { - break; - } - } - dgAssert(edge); - - dgInt32 isConvex = 1; - dgEdge* ptr = edge; - dgInt32 mark = flatFace.IncLRU(); - - dgBigVector normal2(normal); - dgBigVector p0(&vertex[ptr->m_prev->m_incidentVertex * stride]); - dgBigVector p1(&vertex[ptr->m_incidentVertex * stride]); - dgBigVector e0(p1 - p0); - e0 = e0.Scale(dgFloat64(1.0f) / sqrt(e0.DotProduct3(e0) + dgFloat64(1.0e-24f))); - do { - dgBigVector p2(&vertex[ptr->m_next->m_incidentVertex * stride]); - dgBigVector e1(p2 - p1); - e1 = e1.Scale(dgFloat64(1.0f) / sqrt(e1.DotProduct3(e1) + dgFloat32(1.0e-24f))); - dgFloat64 dot = normal2.DotProduct3(e0.CrossProduct(e1)); - - if (dot > dgFloat32(5.0e-3f)) { - isConvex = 0; - break; - } - ptr->m_mark = mark; - e0 = e1; - p1 = p2; - ptr = ptr->m_next; - } while (ptr != edge); - - if (isConvex) { - dgPolyhedra::Iterator iter2(flatFace); - for (iter2.Begin(); iter2; iter2++) { - ptr = &(*iter2); - if (ptr->m_incidentFace < 0) { - if (ptr->m_mark < mark) { - isConvex = 0; - break; - } - } - } - } - - if (isConvex) { - if (diagonalCount > 2) { - dgInt32 count = 0; - ptr = edge; - do { - polygon[count] = ptr->m_incidentVertex; - count++; - dgAssert(count < dgInt32(sizeof(polygon) / sizeof(polygon[0]))); - ptr = ptr->m_next; - } while (ptr != edge); - - for (dgInt32 i = 0; i < count - 1; i++) { - for (dgInt32 j = i + 1; j < count; j++) { - if (polygon[i] == polygon[j]) { - i = count; - isConvex = 0; - break; - } - } - } - } - } - - if (isConvex) { - for (dgInt32 j = 0; j < diagonalCount; j++) { - dgEdge* const diagonal = diagonalsPool[j]; - flatFace.DeleteEdge(diagonal); - } - } else { - for (dgInt32 j = 0; j < diagonalCount; j++) { - dgEdge* const diagonal = diagonalsPool[j]; - if (!IsEssensialDiagonal(diagonal, normal, vertex, stride)) { - flatFace.DeleteEdge(diagonal); - } - } - } - } - - dgInt32 mark = flatFace.IncLRU(); - dgPolyhedra::Iterator iter1(flatFace); - for (iter1.Begin(); iter1; iter1++) { - dgEdge* const edge1 = &(*iter1); - if (edge1->m_mark != mark) { - if (edge1->m_incidentFace > 0) { - dgEdge* ptr = edge1; - dgInt32 diagonalCount1 = 0; - do { - polygon[diagonalCount1] = ptr->m_incidentVertex; - diagonalCount1++; - dgAssert(diagonalCount1 < dgInt32(sizeof(polygon) / sizeof(polygon[0]))); - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge1); - if (diagonalCount1 >= 3) { - buildConvex.AddFace(diagonalCount1, polygon); - } - } - } - } - } - - iter.Begin(); - } - } - - buildConvex.EndFace(); - dgAssert(GetCount() == 0); -} - -void dgPolyhedra::ConvexPartition (const dgFloat64* const vertex, dgInt32 strideInBytes, dgPolyhedra* const leftOversOut) -{ - if (GetCount()) { - Triangulate (vertex, strideInBytes, leftOversOut); - DeleteDegenerateFaces (vertex, strideInBytes, dgFloat32 (1.0e-5f)); - Optimize (vertex, strideInBytes, NULL, NULL, dgFloat32 (1.0e-3f)); - DeleteDegenerateFaces (vertex, strideInBytes, dgFloat32 (1.0e-5f)); - - if (GetCount()) { - dgPolyhedra buildConvex(GetAllocator()); - RemoveInteriorEdges (buildConvex, vertex, strideInBytes); - SwapInfo(buildConvex); - } - } -} diff --git a/thirdparty/src/newton/dgCore/dgPolyhedra.h b/thirdparty/src/newton/dgCore/dgPolyhedra.h deleted file mode 100644 index 03b594088..000000000 --- a/thirdparty/src/newton/dgCore/dgPolyhedra.h +++ /dev/null @@ -1,325 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgPolyhedra__ -#define __dgPolyhedra__ - -#include "dgStdafx.h" -#include "dgList.h" -#include "dgTree.h" -#include "dgHeap.h" -#include "dgDebug.h" - - - - -class dgEdge; -class dgPlane; -class dgObb; -class dgMatrix; -class dgPolyhedra; -class dgVertexCollapseVertexMetric; - -typedef dgInt64 dgEdgeKey; - - -DG_MSC_VECTOR_ALIGNMENT -class dgEdge -{ - public: - dgEdge (); - dgEdge (dgInt32 vertex, dgInt32 face, dgUnsigned64 userdata = 0); - ~dgEdge (); - - dgInt32 m_incidentVertex; - dgInt32 m_incidentFace; - dgUnsigned64 m_userData; - dgEdge* m_next; - dgEdge* m_prev; - dgEdge* m_twin; - dgInt32 m_mark; -} DG_GCC_VECTOR_ALIGNMENT; - - -class dgPolyhedra: public dgTree <dgEdge, dgEdgeKey> -{ - public: - class dgPairKey - { - public: - dgPairKey() - { - } - - dgPairKey(dgInt64 key) - :m_key(dgUnsigned64(key)) - { - } - - dgPairKey(dgInt32 keyHigh, dgInt32 keyLow) - :m_keyLow(dgUnsigned32 (keyLow)) - ,m_keyHigh(dgUnsigned32 (keyHigh)) - { - } - - dgInt64 GetVal() const - { - return dgInt64(m_key); - } - - dgInt32 GetLowKey() const - { - return dgInt32(m_keyLow); - } - - dgInt32 GetHighKey() const - { - return dgInt32(m_keyHigh); - } - - bool operator<(const dgPairKey& key) const - { - return m_key < key.m_key; - } - - bool operator>(const dgPairKey& key) const - { - return m_key > key.m_key; - } - - - private: - union { - dgUnsigned64 m_key; - struct { - dgUnsigned32 m_keyLow; - dgUnsigned32 m_keyHigh; - }; - }; - }; - - dgPolyhedra (dgMemoryAllocator* const allocator); - dgPolyhedra (const dgPolyhedra &polyhedra); - virtual ~dgPolyhedra(); - - virtual void BeginFace(); - dgEdge* AddFace (dgInt32 v0, dgInt32 v1, dgInt32 v2); - dgEdge* AddFace (dgInt32 count, const dgInt32* const index); - dgEdge* AddFace (dgInt32 count, const dgInt32* const index, const dgInt64* const userdata); - virtual bool EndFace (); - virtual void DeleteFace(dgEdge* const edge); - - dgInt32 GetFaceCount() const; - dgInt32 GetEdgeCount() const; - dgInt32 GetLastVertexIndex() const; - - dgInt32 IncLRU() const; - dgInt32 GetLRU() const; - void SetLRU(dgInt32 lru) const; - - dgEdge* FindEdge (dgInt32 v0, dgInt32 v1) const; - dgTreeNode* FindEdgeNode (dgInt32 v0, dgInt32 v1) const; - - dgEdge* AddHalfEdge (dgInt32 v0, dgInt32 v1); - void DeleteEdge (dgEdge* const edge); - void DeleteEdge (dgInt32 v0, dgInt32 v1); - - dgEdge* ConnectVertex (dgEdge* const e0, dgEdge* const e1); - - bool FlipEdge (dgEdge* const edge); - dgEdge* SpliteEdge (dgInt32 newIndex, dgEdge* const edge); - dgBigVector FaceNormal (const dgEdge* const face, const dgFloat64* const vertex, dgInt32 strideInBytes) const; - - void SavePLY(const char* const fileName, const dgFloat64* const vertex, dgInt32 strideInBytes) const; - - void BeginConectedSurface() const; - bool GetConectedSurface (dgPolyhedra &polyhedra) const; - void EndConectedSurface() const; - - dgObb CalculateSphere (const dgFloat64* const vertex, dgInt32 strideInBytes, const dgMatrix* const basis = NULL) const; - void ChangeEdgeIncidentVertex (dgEdge* const edge, dgInt32 newIndex); - void DeleteDegenerateFaces (const dgFloat64* const pool, dgInt32 dstStrideInBytes, dgFloat64 minArea); - - bool Optimize (const dgFloat64* const pool, dgInt32 strideInBytes, dgReportProgress normalizedProgress, void* const reportProgressUserData, dgFloat64 tol, dgInt32 maxFaceCount = 1<<28); - void Triangulate (const dgFloat64* const vertex, dgInt32 strideInBytes, dgPolyhedra* const leftOversOut); - void ConvexPartition (const dgFloat64* const vertex, dgInt32 strideInBytes, dgPolyhedra* const leftOversOut); - bool IsFaceConvex(dgEdge* const face, const dgFloat64* const pool, dgInt32 strideInBytes) const; - - protected: - dgEdge* CollapseEdge(dgEdge* const edge); - bool PolygonizeFace(dgEdge* const face, const dgFloat64* const pool, dgInt32 stride); - bool TriangulateFace(dgEdge* const face, const dgFloat64* const pool, dgInt32 stride); - - private: - void RefineTriangulation (const dgFloat64* const vertex, dgInt32 stride); - void RefineTriangulation (const dgFloat64* const vertex, dgInt32 stride, const dgBigVector& normal, dgInt32 perimeterCount, dgEdge** const perimeter); - void OptimizeTriangulation (const dgFloat64* const vertex, dgInt32 strideInBytes); - void RemoveInteriorEdges (dgPolyhedra& polyhedraOut, const dgFloat64* const vertex, dgInt32 strideInBytes); - void MarkAdjacentCoplanarFaces (dgPolyhedra& polyhedraOut, dgEdge* const face, const dgFloat64* const pool, dgInt32 strideInBytes); - dgEdge* FindEarTip (dgEdge* const face, const dgFloat64* const pool, dgInt32 stride, dgDownHeap<dgEdge*, dgFloat64>& heap, const dgBigVector &normal) const; - dgEdge* TriangulateFace (dgEdge* const face, const dgFloat64* const pool, dgInt32 stride, dgDownHeap<dgEdge*, dgFloat64>& heap, dgBigVector* const faceNormalOut); - - - void RemoveHalfEdge (dgEdge* const edge); - dgEdge* OptimizeCollapseEdge (dgEdge* const edge); - bool IsOkToCollapse (const dgBigVector* const pool, dgEdge* const edge) const; - dgFloat64 EdgePenalty (const dgBigVector* const pool, dgEdge* const edge, dgFloat64 dist) const; - dgBigPlane EdgePlane (dgInt32 i0, dgInt32 i1, dgInt32 i2, const dgBigVector* const pool) const; - void CalculateAllMetrics (dgVertexCollapseVertexMetric* const table, const dgBigVector* const pool) const; - void CalculateVertexMetrics (dgVertexCollapseVertexMetric* const table, const dgBigVector* const pool, dgEdge* const edge) const; - dgEdge* BestEdgePolygonizeFace(const dgBigVector& normal, dgEdge* const edge, const dgFloat64* const pool, dgInt32 stride, const dgBigVector& point) const; - - static dgInt32 GetInteriorDiagonals (dgPolyhedra& polyhedra, dgEdge** const diagonals, dgInt32 maxCount); - static dgBigPlane UnboundedLoopPlane (dgInt32 i0, dgInt32 i1, dgInt32 i2, const dgBigVector* const pool); - static void RemoveOuterColinearEdges(dgPolyhedra& flatFace, const dgFloat64* const vertex, dgInt32 stride); - static void RemoveInteriorColinearEdges(dgPolyhedra& flatFace, const dgFloat64* const vertex, dgInt32 stride); - static bool IsEssensialDiagonal (dgEdge* const diagonal, const dgBigVector& normal, const dgFloat64* const pool, dgInt32 stride); - static bool IsEssensialPointDiagonal (dgEdge* const diagonal, const dgBigVector& normal, const dgFloat64* const pool, dgInt32 stride); - - mutable dgInt32 m_baseMark; - mutable dgInt32 m_edgeMark; - mutable dgInt32 m_faceSecuence; - friend class dgPolyhedraDescriptor; -}; - -DG_INLINE dgEdge::dgEdge () -{ -} - -DG_INLINE dgEdge::dgEdge (dgInt32 vertex, dgInt32 face, dgUnsigned64 userdata) - :m_incidentVertex(vertex) - ,m_incidentFace(face) - ,m_userData(userdata) - ,m_next(NULL) - ,m_prev(NULL) - ,m_twin(NULL) - ,m_mark(0) -{ -} - -DG_INLINE dgEdge::~dgEdge () -{ -} - -DG_INLINE void dgPolyhedra::BeginFace () -{ -} - -DG_INLINE dgEdge* dgPolyhedra::AddFace (dgInt32 count, const dgInt32* const index) -{ - return AddFace (count, index, NULL); -} - -DG_INLINE dgEdge* dgPolyhedra::AddFace (dgInt32 v0, dgInt32 v1, dgInt32 v2) -{ - dgInt32 vertex[3]; - - vertex [0] = v0; - vertex [1] = v1; - vertex [2] = v2; - return AddFace (3, vertex, NULL); -} - -DG_INLINE dgInt32 dgPolyhedra::GetEdgeCount() const -{ -#ifdef _DEBUG - dgInt32 edgeCount = 0; - Iterator iter(*this); - for (iter.Begin(); iter; iter ++) { - edgeCount ++; - } - dgAssert (edgeCount == GetCount());; -#endif - return GetCount(); -} - -DG_INLINE dgInt32 dgPolyhedra::GetLastVertexIndex() const -{ - dgInt32 maxVertexIndex = -1; - Iterator iter(*this); - for (iter.Begin(); iter; iter ++) { - const dgEdge* const edge = &(*iter); - if (edge->m_incidentVertex > maxVertexIndex) { - maxVertexIndex = edge->m_incidentVertex; - } - } - return maxVertexIndex + 1; -} - - -DG_INLINE dgInt32 dgPolyhedra::IncLRU() const -{ - m_edgeMark ++; - dgAssert (m_edgeMark < 0x7fffffff); - return m_edgeMark; -} - -DG_INLINE dgInt32 dgPolyhedra::GetLRU() const -{ - return m_edgeMark; -} - -DG_INLINE void dgPolyhedra::SetLRU(dgInt32 lru) const -{ - if (lru > m_edgeMark) { - m_edgeMark = lru; - } -} - -DG_INLINE void dgPolyhedra::BeginConectedSurface() const -{ - m_baseMark = IncLRU(); -} - -DG_INLINE void dgPolyhedra::EndConectedSurface() const -{ -} - -DG_INLINE dgPolyhedra::dgTreeNode* dgPolyhedra::FindEdgeNode (dgInt32 i0, dgInt32 i1) const -{ - dgPairKey key (i0, i1); - return Find (key.GetVal()); -} - -DG_INLINE dgEdge *dgPolyhedra::FindEdge (dgInt32 i0, dgInt32 i1) const -{ - // dgTreeNode *node; - // dgPairKey key (i0, i1); - // node = Find (key.GetVal()); - // return node ? &node->GetInfo() : NULL; - dgTreeNode* const node = FindEdgeNode (i0, i1); - return node ? &node->GetInfo() : NULL; -} - -DG_INLINE void dgPolyhedra::DeleteEdge (dgInt32 v0, dgInt32 v1) -{ - dgPairKey pairKey (v0, v1); - dgTreeNode* const node = Find(pairKey.GetVal()); - dgEdge* const edge = node ? &node->GetInfo() : NULL; - if (!edge) { - return; - } - DeleteEdge (edge); -} - - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgPolyhedraMassProperties.cpp b/thirdparty/src/newton/dgCore/dgPolyhedraMassProperties.cpp deleted file mode 100644 index a26ea96ac..000000000 --- a/thirdparty/src/newton/dgCore/dgPolyhedraMassProperties.cpp +++ /dev/null @@ -1,573 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgVector.h" -#include "dgPolyhedraMassProperties.h" - - -#if 0 -class dgPolyhedraMassProperties -{ -#define X 0 -#define Y 1 -#define Z 2 -#define SQR(x) ((x)*(x)) -#define CUBE(x) ((x)*(x)*(x)) - - -public: - dgPolyhedraMassProperties() - { - memset (this, 0, sizeof (dgPolyhedraMassProperties)); - } - - void ProjectionIntegrals( - dgInt32 indexCount, - const dgVector* faceVertex) - { - dgInt32 i0; - dgInt32 i1; - dgFloat32 a0, a1, da; - dgFloat32 b0, b1, db; - - dgFloat32 C1; - dgFloat32 Ca; - dgFloat32 Cb; - dgFloat32 Caa; - dgFloat32 Cbb; - dgFloat32 Cab; - dgFloat32 Kab; - dgFloat32 a0_2; - dgFloat32 a0_3; - dgFloat32 a1_2; - dgFloat32 b0_2; - dgFloat32 b0_3; - - m_P1 = dgFloat32 (0.0f); - m_Pa = dgFloat32 (0.0f); - m_Pb = dgFloat32 (0.0f); - m_Paa = dgFloat32 (0.0f); - m_Pbb = dgFloat32 (0.0f); - m_Pab = dgFloat32 (0.0f); - - i0 = indexCount - 1; - for (i1 = 0; i1 < indexCount; i1 ++) { - a0 = faceVertex[i0][m_A]; - b0 = faceVertex[i0][m_B]; - - a1 = faceVertex[i1][m_A]; - b1 = faceVertex[i1][m_B]; - i0 = i1; - - da = a1 - a0; - db = b1 - b0; - - a0_2 = a0 * a0; - a0_3 = a0_2 * a0; - - - b0_2 = b0 * b0; - b0_3 = b0_2 * b0; - - a1_2 = a1 * a1; - - C1 = a1 + a0; - Ca = a1 * C1 + a0_2; - Caa = a1*Ca + a0_3; - - Cb = b1 * (b1 + b0) + b0_2; - Cbb = b1*Cb + b0_3; - - Cab = dgFloat32 (3.0f) * a1_2 + dgFloat32 (2.0f) * a1 * a0 + a0_2; - Kab = a1_2 + dgFloat32 (2.0f) * a1 * a0 + dgFloat32 (3.0f) * a0_2; - - m_P1 += db * C1; - m_Pa += db * Ca; - m_Paa += db * Caa; - - m_Pb += da * Cb; - m_Pbb += da * Cbb; - m_Pab += db * (b1 * Cab + b0 * Kab); - } - - m_P1 *= dgFloat32 (0.5f); - m_Pa *= dgFloat32 ( 1.0f / 6.0f); - m_Pb *= dgFloat32 (-1.0f / 6.0f); - m_Paa *= dgFloat32 (1.0f / 12.0f); - m_Pbb *= dgFloat32 (-1.0f / 12.0f); - m_Pab *= dgFloat32 ( 1.0f / 24.0f); - } - - - void FaceIntegrals ( - dgInt32 count, - const dgPlane& plane, - const dgVector* faceVertex) - { - - dgFloat32 k1, k2, k3, k4; - - ProjectionIntegrals (count, faceVertex); - - k1 = dgFloat32 (1.0f) / plane[m_C]; - k2 = k1 * k1; - k3 = k2 * k1; - k4 = k3 * k1; - - m_Fa = k1 * m_Pa; - m_Fb = k1 * m_Pb; - m_Fc = -k2 * (plane[m_A] * m_Pa + plane[m_B] * m_Pb + plane[3] * m_P1); - - m_Faa = k1 * m_Paa; - m_Fbb = k1 * m_Pbb; - m_Fcc = k3 * (SQR(plane[m_A]) * m_Paa + dgFloat32 (2.0f) * plane[m_A] * plane[m_B] * m_Pab + - SQR(plane[m_B]) * m_Pbb + plane[3] * (dgFloat32 (2.0f) *(plane[m_A] * m_Pa + plane[m_B] * m_Pb) + plane[3] * m_P1)); - } - - - void VolumeIntegrals( - dgInt32 indexCount, - const dgPlane& plane, - const dgVector* faceVertex) - { - dgFloat32 mag2; - - mag2 = plane % plane; - if (mag2 > dgFloat32 (1.0e-8f)) { - if ((dgAbs (plane.m_x) > dgAbs (plane.m_y)) && (dgAbs (plane.m_x) > dgAbs (plane.m_z))) { - m_C = X; - } else { - m_C = (dgAbs (plane.m_y) > dgAbs (plane.m_z)) ? Y : Z; - } - m_A = (m_C + 1) % 3; - m_B = (m_A + 1) % 3; - FaceIntegrals (indexCount, plane, faceVertex); - - m_T0 += plane[X] * ((m_A == X) ? m_Fa : ((m_B == X) ? m_Fb : m_Fc)); - - m_T1[m_A] += plane[m_A] * m_Faa; - m_T1[m_B] += plane[m_B] * m_Fbb; - m_T1[m_C] += plane[m_C] * m_Fcc; - //dgTrace (("(%f %f %f) (%f %f %f) (%f %f %f)\n", m_T1[m_A], m_T1[m_B], m_T1[m_C], plane[m_A], plane[m_B], plane[m_C], m_Faa, m_Fbb, m_Fcc)) - } - } - - - void AddInertia (int indexCount, const dgFloat32* faceVertex) - { - dgInt32 i0; - dgInt32 i1; - dgFloat32 a0, a1, da; - dgFloat32 b0, b1, db; - dgFloat32 C1; - dgFloat32 Ca; - dgFloat32 Cb; - dgFloat32 Caa; - dgFloat32 Cbb; - dgFloat32 Cab; - dgFloat32 Kab; - dgFloat32 Caaa; - dgFloat32 Cbbb; - dgFloat32 Cabb; - dgFloat32 Caab; - dgFloat32 Kabb; - dgFloat32 Kaab; - dgFloat32 a0_2; - dgFloat32 a0_3; - dgFloat32 a0_4; - dgFloat32 a1_2; - dgFloat32 a1_3; - dgFloat32 b0_2; - dgFloat32 b0_3; - dgFloat32 b0_4; - dgFloat32 b1_2; - dgFloat32 b1_3; - dgFloat32 mag2; - - dgVector p0 (&faceVertex[0]); - dgVector p1 (&faceVertex[3]); - dgVector p2 (&faceVertex[6]); - dgPlane plane (p0, p1, p2); - - mag2 = plane % plane; - if (mag2 > dgFloat32 (1.0e-8f)) { - plane = plane.Scale (dgRsqrt ((plane % plane))); - if ((dgAbs (plane.m_x) > dgAbs (plane.m_y)) && (dgAbs (plane.m_x) > dgAbs (plane.m_z))) { - m_C = X; - } else { - m_C = (dgAbs (plane.m_y) > dgAbs (plane.m_z)) ? Y : Z; - } - m_A = (m_C + 1) % 3; - m_B = (m_A + 1) % 3; - - // FaceIntegrals (indexCount, plane, faceVertex); - dgFloat32 k1, k2, k3, k4; - { - { - //ProjectionIntegrals (count, faceVertex); - m_P1 = dgFloat32 (0.0f); - m_Pa = dgFloat32 (0.0f); - m_Pb = dgFloat32 (0.0f); - m_Paa = dgFloat32 (0.0f); - m_Pbb = dgFloat32 (0.0f); - m_Pab = dgFloat32 (0.0f); - - m_Paaa = dgFloat32 (0.0f); - m_Pbbb = dgFloat32 (0.0f); - m_Paab = dgFloat32 (0.0f); - m_Pabb = dgFloat32 (0.0f); - - i0 = indexCount - 1; - for (i1 = 0; i1 < indexCount; i1 ++) { - a0 = faceVertex[i0 * 3 + m_A]; - b0 = faceVertex[i0 * 3 + m_B]; - - a1 = faceVertex[i1 * 3 + m_A]; - b1 = faceVertex[i1 * 3 + m_B]; - - i0 = i1; - - da = a1 - a0; - db = b1 - b0; - - a0_2 = a0 * a0; - a0_3 = a0_2 * a0; - a0_4 = a0_3 * a0; - - b0_2 = b0 * b0; - b0_3 = b0_2 * b0; - b0_4 = b0_3 * b0; - - a1_2 = a1 * a1; - a1_3 = a1_2 * a1; - - b1_2 = b1 * b1; - b1_3 = b1_2 * b1; - - C1 = a1 + a0; - - Ca = a1 * C1 + a0_2; - Caa = a1 * Ca + a0_3; - Caaa = a1 * Caa + a0_4; - - Cb = b1 * (b1 + b0) + b0_2; - Cbb = b1 * Cb + b0_3; - Cbbb = b1 * Cbb + b0_4; - - Cab = dgFloat32 (3.0f) * a1_2 + dgFloat32 (2.0f) * a1 * a0 + a0_2; - Kab = a1_2 + dgFloat32 (2.0f) * a1 * a0 + dgFloat32 (3.0f) * a0_2; - - Caab = a0 * Cab + dgFloat32 (4.0f) * a1_3; - Kaab = a1 * Kab + dgFloat32 (4.0f) * a0_3; - Cabb = dgFloat32 (4.0f) * b1_3 + dgFloat32 (3.0f) * b1_2 * b0 + dgFloat32 (2.0f) * b1 * b0_2 + b0_3; - Kabb = b1_3 + dgFloat32 (2.0f) * b1_2 * b0 + dgFloat32 (3.0f) * b1 * b0_2 + dgFloat32 (4.0f) * b0_3; - - m_P1 += (db * C1); - m_Pa += (db * Ca); - m_Paa += (db * Caa); - - m_Pb += (da * Cb); - m_Pbb += (da * Cbb); - m_Pab += (db * (b1 * Cab + b0 * Kab)); - - m_Paaa += (db * Caaa); - m_Pbbb += (da * Cbbb); - m_Paab += (db * (b1 * Caab + b0 * Kaab)); - m_Pabb += (da * (a1 * Cabb + a0 * Kabb)); - } - - m_P1 *= dgFloat32 (0.5f); - m_Pa *= dgFloat32 ( 1.0f / 6.0f); - m_Pb *= dgFloat32 (-1.0f / 6.0f); - m_Paa *= dgFloat32 (1.0f / 12.0f); - m_Pbb *= dgFloat32 (-1.0f / 12.0f); - m_Pab *= dgFloat32 ( 1.0f / 24.0f); - - m_Paaa *= dgFloat32 (1.0f / 20.0); - m_Pbbb *= dgFloat32 (-1.0f / 20.0); - m_Paab *= dgFloat32 (1.0f / 60.0); - m_Pabb *= dgFloat32 (-1.0f / 60.0); - } - - k1 = dgFloat32 (1.0f) / plane[m_C]; - k2 = k1 * k1; - k3 = k2 * k1; - k4 = k3 * k1; - - m_Fa = k1 * m_Pa; - m_Fb = k1 * m_Pb; - m_Fc = -k2 * (plane[m_A] * m_Pa + plane[m_B] * m_Pb + plane[3] * m_P1); - - m_Faa = k1 * m_Paa; - m_Fbb = k1 * m_Pbb; - m_Fcc = k3 * (SQR(plane[m_A]) * m_Paa + dgFloat32 (2.0f) * plane[m_A] * plane[m_B] * m_Pab + - SQR(plane[m_B]) * m_Pbb + plane[3] * (dgFloat32 (2.0f) *(plane[m_A] * m_Pa + plane[m_B] * m_Pb) + plane[3] * m_P1)); - - m_Faaa = k1 * m_Paaa; - m_Fbbb = k1 * m_Pbbb; - m_Fccc = -k4 * (CUBE(plane[m_A]) * m_Paaa + - dgFloat32(3.0f) * SQR(plane[m_A]) * plane[m_B] * m_Paab + - dgFloat32(3.0f) * plane[m_A] * SQR(plane[m_B]) * m_Pabb + CUBE(plane[m_B]) * m_Pbbb + - dgFloat32(3.0f) * plane[3] * (SQR(plane[m_A]) * m_Paa + dgFloat32 (2.0f) * plane[m_A] * plane[m_B] * m_Pab + SQR(plane[m_B]) * m_Pbb) + - SQR(plane[3]) * (dgFloat32(3.0f) * (plane[m_A] * m_Pa + plane[m_B] * m_Pb) + plane[3] * m_P1)); - - m_Faab = k1 * m_Paab; - m_Fbbc = -k2 * (plane[m_A] * m_Pabb + plane[m_B] * m_Pbbb + plane[3] * m_Pbb); - m_Fcca = k3 * (SQR(plane[m_A]) * m_Paaa + dgFloat32 (2.0f) * plane[m_A] * plane[m_B] * m_Paab + SQR(plane[m_B]) * m_Pabb + - plane[3] * (dgFloat32 (2.0f) * (plane[m_A] * m_Paa + plane[m_B] * m_Pab) + plane[3] * m_Pa)); - } - - m_T0 += (plane[X] * ((m_A == X) ? m_Fa : ((m_B == X) ? m_Fb : m_Fc))); - - m_T1[m_A] += (plane[m_A] * m_Faa); - m_T1[m_B] += (plane[m_B] * m_Fbb); - m_T1[m_C] += (plane[m_C] * m_Fcc); - - m_T2[m_A] += (plane[m_A] * m_Faaa); - m_T2[m_B] += (plane[m_B] * m_Fbbb); - m_T2[m_C] += (plane[m_C] * m_Fccc); - - m_TP[m_A] += (plane[m_A] * m_Faab); - m_TP[m_B] += (plane[m_B] * m_Fbbc); - m_TP[m_C] += (plane[m_C] * m_Fcca); - } - } - - - dgInt32 m_A; // alpha - dgInt32 m_B; // beta - dgInt32 m_C; // gamma - - dgFloat32 m_T0; - dgFloat32 m_T1[3]; - dgFloat32 m_T2[3]; - dgFloat32 m_TP[3]; - - dgFloat32 m_P1; - dgFloat32 m_Pa; - dgFloat32 m_Pb; - - dgFloat32 m_Paa; - dgFloat32 m_Pbb; - dgFloat32 m_Pab; - - dgFloat32 m_Paaa; - dgFloat32 m_Pbbb; - dgFloat32 m_Paab; - dgFloat32 m_Pabb; - - dgFloat32 m_Fa; - dgFloat32 m_Fb; - dgFloat32 m_Fc; - - dgFloat32 m_Faa; - dgFloat32 m_Fbb; - dgFloat32 m_Fcc; - - dgFloat32 m_Faaa; - dgFloat32 m_Fbbb; - dgFloat32 m_Fccc; - - dgFloat32 m_Faab; - dgFloat32 m_Fbbc; - dgFloat32 m_Fcca; -}; -#endif - - - -dgPolyhedraMassProperties::dgPolyhedraMassProperties() -{ - memset (this, 0, sizeof (dgPolyhedraMassProperties)); - mult[0] = dgFloat32 (1.0f/6.0f); - mult[1] = dgFloat32 (1.0f/24.0f); - mult[2] = dgFloat32 (1.0f/24.0f); - mult[3] = dgFloat32 (1.0f/24.0f); - mult[4] = dgFloat32 (1.0f/60.0f); - mult[5] = dgFloat32 (1.0f/60.0f); - mult[6] = dgFloat32 (1.0f/60.0f); - mult[7] = dgFloat32 (1.0f/120.0f); - mult[8] = dgFloat32 (1.0f/120.0f); - mult[9] = dgFloat32 (1.0f/120.0f); -} - -void dgPolyhedraMassProperties::AddCGFace (dgInt32 indexCount, const dgVector* const faceVertex) -{ - #define CDSubexpressions(w0,w1,w2,f1,f2) \ - { \ - dgFloat32 temp0 = w0 + w1; \ - f1 = temp0 + w2; \ - f2 = w0 * w0 + w1 * temp0 + w2 * f1; \ - } - - const dgVector& p0 = faceVertex[0]; - dgVector p1 (faceVertex[1]); - - for (dgInt32 i = 2; i < indexCount; i++) { - const dgVector& p2 = faceVertex[i]; - - dgVector e01 (p1 - p0); - dgVector e02 (p2 - p0); - dgVector d (e01.CrossProduct(e02)); - - dgVector f1; - dgVector f2; - CDSubexpressions (p0.m_x, p1.m_x, p2.m_x, f1.m_x, f2.m_x); - CDSubexpressions (p0.m_y, p1.m_y, p2.m_y, f1.m_y, f2.m_y); - CDSubexpressions (p0.m_z, p1.m_z, p2.m_z, f1.m_z, f2.m_z); - - // update integrals - intg[0] += d[0] * f1.m_x; - - intg[1] += d[0] * f2.m_x; - intg[2] += d[1] * f2.m_y; - intg[3] += d[2] * f2.m_z; - - p1 = p2; - } -} - -void dgPolyhedraMassProperties::AddInertiaFace (dgInt32 indexCount, const dgFloat32* const faceVertex) -{ - #define InertiaSubexpression(w0,w1,w2,f1,f2,f3) \ - { \ - dgFloat32 temp0 = w0 + w1; \ - dgFloat32 temp1 = w0 * w0; \ - dgFloat32 temp2 = temp1 + w1 * temp0; \ - f1 = temp0 + w2; \ - f2 = temp2 + w2 * f1; \ - f3 = w0 * temp1 + w1 * temp2 + w2 * f2; \ - } - - dgVector p0 (faceVertex[0], faceVertex[1], faceVertex[2], 0.0f); - dgVector p1 (faceVertex[3], faceVertex[4], faceVertex[5], 0.0f); - - for (dgInt32 i = 2; i < indexCount; i++) { - dgVector p2 (faceVertex[i * 3], faceVertex[i * 3 + 1], faceVertex[i * 3 + 2], 0.0f); - - dgVector e01 (p1 - p0); - dgVector e02 (p2 - p0); - dgVector d (e01.CrossProduct(e02)); - - dgVector f1; - dgVector f2; - dgVector f3; - InertiaSubexpression (p0.m_x, p1.m_x, p2.m_x, f1.m_x, f2.m_x, f3.m_x); - InertiaSubexpression (p0.m_y, p1.m_y, p2.m_y, f1.m_y, f2.m_y, f3.m_y); - InertiaSubexpression (p0.m_z, p1.m_z, p2.m_z, f1.m_z, f2.m_z, f3.m_z); - - // update integrals - intg[0] += d[0] * f1.m_x; - - intg[1] += d[0] * f2.m_x; - intg[2] += d[1] * f2.m_y; - intg[3] += d[2] * f2.m_z; - - intg[4] += d[0] * f3.m_x; - intg[5] += d[1] * f3.m_y; - intg[6] += d[2] * f3.m_z; - - p1 = p2; - } -} - - -void dgPolyhedraMassProperties::AddInertiaAndCrossFace (dgInt32 indexCount, const dgFloat32* const faceVertex) -{ - #define Subexpressions(w0,w1,w2,f1,f2,f3,g0,g1,g2) \ - { \ - dgFloat32 temp0 = w0 + w1; \ - dgFloat32 temp1 = w0 * w0; \ - dgFloat32 temp2 = temp1 + w1 * temp0; \ - f1 = temp0 + w2; \ - f2 = temp2 + w2 * f1; \ - f3 = w0 * temp1 + w1 * temp2 + w2 * f2; \ - g0 = f2 + w0 * (f1 + w0); \ - g1 = f2 + w1 * (f1 + w1); \ - g2 = f2 + w2 * (f1 + w2); \ - } - - dgVector p0 (&faceVertex[0]); - dgVector p1 (&faceVertex[3]); - p0 = p0 & dgVector::m_triplexMask; - p1 = p1 & dgVector::m_triplexMask; - for (dgInt32 i = 2; i < indexCount; i++) { - dgVector p2 (&faceVertex[i * 3]); - p2 = p2 & dgVector::m_triplexMask; - - dgVector e01 (p1 - p0); - dgVector e02 (p2 - p0); - dgVector d (e01.CrossProduct(e02)); - - dgVector f1; - dgVector f2; - dgVector f3; - dgVector g0; - dgVector g1; - dgVector g2; - Subexpressions (p0.m_x, p1.m_x, p2.m_x, f1.m_x, f2.m_x, f3.m_x, g0.m_x, g1.m_x, g2.m_x); - Subexpressions (p0.m_y, p1.m_y, p2.m_y, f1.m_y, f2.m_y, f3.m_y, g0.m_y, g1.m_y, g2.m_y); - Subexpressions (p0.m_z, p1.m_z, p2.m_z, f1.m_z, f2.m_z, f3.m_z, g0.m_z, g1.m_z, g2.m_z); - - // update integrals - intg[0] += d[0] * f1.m_x; - - intg[1] += d[0] * f2.m_x; - intg[2] += d[1] * f2.m_y; - intg[3] += d[2] * f2.m_z; - - intg[4] += d[0] * f3.m_x; - intg[5] += d[1] * f3.m_y; - intg[6] += d[2] * f3.m_z; - - intg[7] += d[0] * (p0.m_y * g0.m_x + p1.m_y * g1.m_x + p2.m_y * g2.m_x); - intg[8] += d[1] * (p0.m_z * g0.m_y + p1.m_z * g1.m_y + p2.m_z * g2.m_y); - intg[9] += d[2] * (p0.m_x * g0.m_z + p1.m_x * g1.m_z + p2.m_x * g2.m_z); - - p1 = p2; - } -} - - -dgFloat32 dgPolyhedraMassProperties::MassProperties (dgVector& cg, dgVector& inertia, dgVector& crossInertia) -{ - for (dgInt32 i = 0; i < 10; i++) { - intg[i] *= mult[i]; - } - - cg.m_x = intg[1]; - cg.m_y = intg[2]; - cg.m_z = intg[3]; - cg.m_w = dgFloat32 (0.0f); - inertia.m_x = intg[5] + intg[6]; - inertia.m_y = intg[4] + intg[6]; - inertia.m_z = intg[4] + intg[5]; - inertia.m_w = dgFloat32 (0.0f); - crossInertia.m_x = -intg[8]; - crossInertia.m_y = -intg[9]; - crossInertia.m_z = -intg[7]; - crossInertia.m_w = dgFloat32 (0.0f); - return intg[0]; -} - - - diff --git a/thirdparty/src/newton/dgCore/dgPolyhedraMassProperties.h b/thirdparty/src/newton/dgCore/dgPolyhedraMassProperties.h deleted file mode 100644 index 751745de7..000000000 --- a/thirdparty/src/newton/dgCore/dgPolyhedraMassProperties.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgPolyhedraMassProperties__ -#define __dgPolyhedraMassProperties__ - -class dgPolyhedraMassProperties -{ - public: - dgPolyhedraMassProperties(); - - void AddCGFace (dgInt32 indexCount, const dgVector* const faceVertex); - void AddInertiaFace (dgInt32 indexCount, const dgFloat32* const faceVertex); - void AddInertiaAndCrossFace (dgInt32 indexCount, const dgFloat32* const faceVertex); - - dgFloat32 MassProperties (dgVector& cg, dgVector& inertia, dgVector& crossInertia); - - private: - dgFloat32 intg[10]; - dgFloat32 mult[10]; -}; - -#endif diff --git a/thirdparty/src/newton/dgCore/dgProfiler.cpp b/thirdparty/src/newton/dgCore/dgProfiler.cpp deleted file mode 100644 index c0bf7165d..000000000 --- a/thirdparty/src/newton/dgCore/dgProfiler.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgProfiler.h" diff --git a/thirdparty/src/newton/dgCore/dgProfiler.h b/thirdparty/src/newton/dgCore/dgProfiler.h deleted file mode 100644 index 9b6adfb8d..000000000 --- a/thirdparty/src/newton/dgCore/dgProfiler.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DG_PROFILER_H__ -#define __DG_PROFILER_H__ - -// to make a profile build use Use CMAKE to create a profile configuration -// or make a configuration that define macro D_PROFILER - -#ifdef D_PROFILER - #include <dProfiler.h> - #define D_TRACKTIME() dProfilerZoneScoped(__FUNCTION__) - #define D_SET_TRACK_NAME(trackName) dProfilerSetTrackName(trackName) - #define DG_TRACKTIME() D_TRACKTIME() -#else - #define D_TRACKTIME() - #define D_SET_TRACK_NAME(trackName) - #define DG_TRACKTIME() -#endif - -#endif diff --git a/thirdparty/src/newton/dgCore/dgQuaternion.cpp b/thirdparty/src/newton/dgCore/dgQuaternion.cpp deleted file mode 100644 index 4190c26e1..000000000 --- a/thirdparty/src/newton/dgCore/dgQuaternion.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgVector.h" -#include "dgMatrix.h" -#include "dgQuaternion.h" - -enum QUAT_INDEX -{ - X_INDEX = 0, - Y_INDEX = 1, - Z_INDEX = 2 -}; -static QUAT_INDEX QIndex[] = { Y_INDEX, Z_INDEX, X_INDEX }; - -dgQuaternion::dgQuaternion (const dgMatrix& matrix) -{ - dgFloat32 trace = matrix[0][0] + matrix[1][1] + matrix[2][2]; - if (trace > dgFloat32(0.0f)) { - trace = dgSqrt (trace + dgFloat32(1.0f)); - m_w = dgFloat32 (0.5f) * trace; - trace = dgFloat32 (0.5f) / trace; - m_x = (matrix[1][2] - matrix[2][1]) * trace; - m_y = (matrix[2][0] - matrix[0][2]) * trace; - m_z = (matrix[0][1] - matrix[1][0]) * trace; - - } else { - QUAT_INDEX i = X_INDEX; - if (matrix[Y_INDEX][Y_INDEX] > matrix[X_INDEX][X_INDEX]) { - i = Y_INDEX; - } - if (matrix[Z_INDEX][Z_INDEX] > matrix[i][i]) { - i = Z_INDEX; - } - QUAT_INDEX j = QIndex [i]; - QUAT_INDEX k = QIndex [j]; - - trace = dgFloat32(1.0f) + matrix[i][i] - matrix[j][j] - matrix[k][k]; - trace = dgSqrt (trace); - - dgFloat32* const ptr = &m_x; - ptr[i] = dgFloat32 (0.5f) * trace; - trace = dgFloat32 (0.5f) / trace; - m_w = (matrix[j][k] - matrix[k][j]) * trace; - ptr[j] = (matrix[i][j] + matrix[j][i]) * trace; - ptr[k] = (matrix[i][k] + matrix[k][i]) * trace; - } - -#ifdef _DEBUG - dgMatrix tmp (*this, matrix.m_posit); - dgMatrix unitMatrix (tmp * matrix.Inverse()); - for (dgInt32 i = 0; i < 4; i ++) { - dgFloat32 err = dgAbs (unitMatrix[i][i] - dgFloat32(1.0f)); - dgAssert (err < dgFloat32 (1.0e-2f)); - } - - dgFloat32 err = dgAbs (DotProduct(*this) - dgFloat32(1.0f)); - dgAssert (err < dgFloat32(dgEpsilon * 100.0f)); -#endif -} - -dgQuaternion::dgQuaternion (const dgVector &unitAxis, dgFloat32 angle) -{ - angle *= dgFloat32 (0.5f); - m_w = dgCos (angle); - dgFloat32 sinAng = dgSin (angle); - -#ifdef _DEBUG - if (dgAbs (angle) > dgFloat32(dgEpsilon / 10.0f)) { - dgAssert (dgAbs (dgFloat32(1.0f) - unitAxis.DotProduct(unitAxis & dgVector::m_triplexMask).GetScalar()) < dgFloat32(dgEpsilon * 10.0f)); - } -#endif - m_x = unitAxis.m_x * sinAng; - m_y = unitAxis.m_y * sinAng; - m_z = unitAxis.m_z * sinAng; - -} - -dgVector dgQuaternion::CalcAverageOmega (const dgQuaternion &q1, dgFloat32 invdt) const -{ - dgQuaternion q0 (*this); - if (q0.DotProduct (q1) < 0.0f) { - q0.Scale(-1.0f); - } - dgQuaternion dq (q0.Inverse() * q1); - dgVector omegaDir (dq.m_x, dq.m_y, dq.m_z, dgFloat32 (0.0f)); - - dgFloat32 dirMag2 = omegaDir.DotProduct(omegaDir).GetScalar(); - if (dirMag2 < dgFloat32(dgFloat32 (1.0e-5f) * dgFloat32 (1.0e-5f))) { - return dgVector (dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - } - - dgFloat32 dirMagInv = dgRsqrt (dirMag2); - dgFloat32 dirMag = dirMag2 * dirMagInv; - - dgFloat32 omegaMag = dgFloat32(2.0f) * dgAtan2 (dirMag, dq.m_w) * invdt; - return omegaDir.Scale (dirMagInv * omegaMag); -} - -dgQuaternion dgQuaternion::Slerp (const dgQuaternion &q1, dgFloat32 t) const -{ - dgQuaternion q0; - - dgFloat32 dot = DotProduct (q1); - if ((dot + dgFloat32(1.0f)) > dgEpsilon) { - dgFloat32 Sclp; - dgFloat32 Sclq; - if (dot < (dgFloat32(1.0f) - dgEpsilon) ) { - dgFloat32 ang = dgAcos (dot); - - dgFloat32 sinAng = dgSin (ang); - dgFloat32 den = dgFloat32(1.0f) / sinAng; - - Sclp = dgSin ((dgFloat32(1.0f) - t ) * ang) * den; - Sclq = dgSin (t * ang) * den; - } else { - Sclp = dgFloat32(1.0f) - t; - Sclq = t; - } - - q0.m_w = m_w * Sclp + q1.m_w * Sclq; - q0.m_x = m_x * Sclp + q1.m_x * Sclq; - q0.m_y = m_y * Sclp + q1.m_y * Sclq; - q0.m_z = m_z * Sclp + q1.m_z * Sclq; - - } else { - q0.m_w = m_z; - q0.m_x = -m_y; - q0.m_y = m_x; - q0.m_z = m_w; - - dgFloat32 Sclp = dgSin ((dgFloat32(1.0f) - t) * dgPi * dgFloat32 (0.5f)); - dgFloat32 Sclq = dgSin (t * dgPi * dgFloat32 (0.5f)); - - q0.m_w = m_w * Sclp + q0.m_w * Sclq; - q0.m_x = m_x * Sclp + q0.m_x * Sclq; - q0.m_y = m_y * Sclp + q0.m_y * Sclq; - q0.m_z = m_z * Sclp + q0.m_z * Sclq; - } - - dot = q0.DotProduct (q0); - if ((dot) < dgFloat32(1.0f - dgEpsilon * 10.0f) ) { - //dot = dgFloat32(1.0f) / dgSqrt (dot); - dot = dgRsqrt (dot); - q0.m_w *= dot; - q0.m_x *= dot; - q0.m_y *= dot; - q0.m_z *= dot; - } - return q0; -} - - diff --git a/thirdparty/src/newton/dgCore/dgQuaternion.h b/thirdparty/src/newton/dgCore/dgQuaternion.h deleted file mode 100644 index 91ddae957..000000000 --- a/thirdparty/src/newton/dgCore/dgQuaternion.h +++ /dev/null @@ -1,138 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgQuaternion__ -#define __dgQuaternion__ - -#include "dgStdafx.h" - -class dgVector; -class dgMatrix; - -DG_MSC_VECTOR_ALIGNMENT -class dgQuaternion -{ - public: - dgQuaternion (); - dgQuaternion (const dgMatrix& matrix); - dgQuaternion (dgFloat32 q0, dgFloat32 q1, dgFloat32 q2, dgFloat32 q3); - dgQuaternion (const dgVector &unit_Axis, dgFloat32 angle = dgFloat32 (0.0f)); - -// dgFloat32& operator[] (dgInt32 i); -// const dgFloat32& operator[] (dgInt32 i) const; - - void Scale (dgFloat32 scale); - void Normalize (); - dgQuaternion Inverse () const; - dgQuaternion Slerp (const dgQuaternion &q1, dgFloat32 t) const; - - dgFloat32 DotProduct (const dgQuaternion &QB) const; - dgVector CalcAverageOmega (const dgQuaternion &q1, dgFloat32 invdt) const; - - dgQuaternion operator* (const dgQuaternion &B) const; - dgQuaternion operator+ (const dgQuaternion &B) const; - dgQuaternion operator- (const dgQuaternion &B) const; - - dgFloat32 m_x; - dgFloat32 m_y; - dgFloat32 m_z; - dgFloat32 m_w; -} DG_GCC_VECTOR_ALIGNMENT; - - -DG_INLINE dgQuaternion::dgQuaternion() - :m_x(dgFloat32(0.0f)) - ,m_y(dgFloat32(0.0f)) - ,m_z(dgFloat32(0.0f)) - ,m_w(dgFloat32(1.0f)) -{ -} - -DG_INLINE dgQuaternion::dgQuaternion(dgFloat32 Q0, dgFloat32 Q1, dgFloat32 Q2, dgFloat32 Q3) - :m_x(Q1) - ,m_y(Q2) - ,m_z(Q3) - ,m_w(Q0) -{ -// dgAssert (dgAbs (DotProduct (*this) -dgFloat32 (1.0f)) < dgFloat32(1.0e-4f)); -} - -/* -DG_INLINE dgFloat32& dgQuaternion::operator[] (dgInt32 i) -{ - dgAssert(i < 4); - dgAssert(i >= 0); - return (&m_w)[i]; -} - -DG_INLINE const dgFloat32& dgQuaternion::operator[] (dgInt32 i) const -{ - dgAssert(i < 4); - dgAssert(i >= 0); - return (&m_w)[i]; -} -*/ - -DG_INLINE void dgQuaternion::Scale (dgFloat32 scale) -{ - m_w *= scale; - m_x *= scale; - m_y *= scale; - m_z *= scale; -} - -DG_INLINE void dgQuaternion::Normalize () -{ - Scale (dgRsqrt (DotProduct (*this))); -} - -DG_INLINE dgFloat32 dgQuaternion::DotProduct (const dgQuaternion &q1) const -{ - return m_w * q1.m_w + m_x * q1.m_x + m_y * q1.m_y + m_z * q1.m_z; -} - -DG_INLINE dgQuaternion dgQuaternion::Inverse () const -{ - return dgQuaternion (m_w, -m_x, -m_y, -m_z); -} - -DG_INLINE dgQuaternion dgQuaternion::operator+ (const dgQuaternion &q) const -{ - return dgQuaternion (m_w + q.m_w, m_x + q.m_x, m_y + q.m_y, m_z + q.m_z); -} - -DG_INLINE dgQuaternion dgQuaternion::operator- (const dgQuaternion &q) const -{ - return dgQuaternion (m_w - q.m_w, m_x - q.m_x, m_y - q.m_y, m_z - q.m_z); -} - -DG_INLINE dgQuaternion dgQuaternion::operator* (const dgQuaternion &q) const -{ - return dgQuaternion (q.m_w * m_w - q.m_x * m_x - q.m_y * m_y - q.m_z * m_z, - q.m_x * m_w + q.m_w * m_x - q.m_z * m_y + q.m_y * m_z, - q.m_y * m_w + q.m_z * m_x + q.m_w * m_y - q.m_x * m_z, - q.m_z * m_w - q.m_y * m_x + q.m_x * m_y + q.m_w * m_z); -} - - - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgRandom.cpp b/thirdparty/src/newton/dgCore/dgRandom.cpp deleted file mode 100644 index e7e16ec74..000000000 --- a/thirdparty/src/newton/dgCore/dgRandom.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgRandom.h" - -#define RAND_MUL 31415821u -static dgUnsigned32 randSeed = RAND_MUL; - -void dgApi dgRandomize (dgUnsigned32 Seed) -{ - randSeed = Seed; -} - -dgUnsigned32 dgApi dgRandom() -{ - randSeed = RAND_MUL * randSeed + 1; - return randSeed; -} - - diff --git a/thirdparty/src/newton/dgCore/dgRandom.h b/thirdparty/src/newton/dgCore/dgRandom.h deleted file mode 100644 index 76dc313df..000000000 --- a/thirdparty/src/newton/dgCore/dgRandom.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgRandom__ -#define __dgRandom__ - -#include "dgStdafx.h" - -const dgFloat64 fRandom = (dgFloat64 (1.0) / dgFloat64 ((dgUnsigned32)(0xffffffff))); - -// return a random number between 0 and 0xffffffff; -dgUnsigned32 dgApi dgRandom(); - -inline dgFloat32 dgfRandom() -{ - return (dgFloat32) (dgRandom() * fRandom); -} - - -void dgApi dgRandomize (dgUnsigned32 Seed); - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgRef.cpp b/thirdparty/src/newton/dgCore/dgRef.cpp deleted file mode 100644 index a34299a2a..000000000 --- a/thirdparty/src/newton/dgCore/dgRef.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgRef.h" -#include "dgList.h" -#include "dgTree.h" - - -dgRtti dgRef::m_rtti ("dgRef"); - -dgRefFlags::dgRefFlags() -{ - *this = 0; - m_alive = true; - m_ref = 1; -} - -dgInt32 dgRefFlags::operator = (dgInt32 val) -{ - dgInt32* ptr; - ptr = &(*(dgInt32*)this); - *ptr = val; - return val; -} - - - -dgRef::dgRef() -{ - m_id = 0; -} - -dgRef::dgRef(const char *name) -{ - SetName(name); -} - -dgRef::dgRef(dgUnsigned32 idArg) -{ - SetNameID(idArg); -} - -dgRef::dgRef(const dgRef &Clone) -{ - m_id = Clone.m_id; -} - -dgRef::~dgRef() -{ -} - -dgRef *dgRef::AddRef() -{ - m_ref++; - dgAssert(m_ref < ((1 << 24) - 1)); - return this; -} - -dgInt32 dgRef::Release() -{ - m_ref--; - if (m_ref) { - return dgInt32(m_ref); - } - delete this; - return 0; -} - -dgRef *dgRef::CreateClone() const -{ - dgAssert(0); - return NULL; -} - - -dgUnsigned32 dgRef::GetTypeId() const -{ - return m_rtti.GetTypeId(); -} - -bool dgRef::IsType(dgUnsigned32 typeId) const -{ - return m_rtti.IsTypeID(typeId); -} - -dgUnsigned32 dgRef::GetRttiType() -{ - return m_rtti.GetTypeId(); -} - - -bool dgRef::GetUserFlag0() const -{ - return m_userFlag0 ? true : false; -} - -bool dgRef::GetUserFlag1() const -{ - return m_userFlag1 ? true : false; -} - - -void dgRef::SetUserFlag0(bool flags) -{ - m_userFlag0 = dgUnsigned8(flags); -} - -void dgRef::SetUserFlag1(bool flags) -{ - m_userFlag1 = dgUnsigned8(flags); -} - - -bool dgRef::IsAlive() const -{ - return m_alive ? true : false; -} - -void dgRef::Kill() -{ - m_alive = false; -} - -void dgRef::Unkill() -{ - m_alive = true; -} - -void dgRef::SetNameID(dgUnsigned32 newID) -{ - m_id = newID; -} - -dgUnsigned32 dgRef::GetNameID() const -{ - return m_id; -} - - -const char* dgRef::GetName() const -{ - return dgInverseCRC(GetNameID()); -} - -dgInt32 dgRef::GetRefCount() const -{ - return dgInt32(m_ref); -} - - -void dgRef::SetName(const char *name) -{ - SetNameID(0); - if (name) { - SetNameID(dgCRC(name)); - } -} - -bool dgRef::IsTypeByName(const char *typeName) const -{ - return IsType(dgCRC(typeName, (dgInt32)strlen(typeName))); -} - - -void dgRef::AttachRef ( - dgRef **oldObj, - dgRef *newObj) -{ - if (*oldObj) { - (*oldObj)->Release(); - } - *oldObj = newObj; - if (newObj) { - newObj->AddRef(); - } -} - - - diff --git a/thirdparty/src/newton/dgCore/dgRef.h b/thirdparty/src/newton/dgCore/dgRef.h deleted file mode 100644 index 2f252afee..000000000 --- a/thirdparty/src/newton/dgCore/dgRef.h +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgRef__ -#define __dgRef__ - -#include "dgStdafx.h" -#include "dgRtti.h" -#include "dgDebug.h" -#include "dgMemory.h" - - -struct dgRefFlags -{ - dgRefFlags (); - inline dgInt32 operator = (dgInt32 val); - - dgUnsigned8 m_alive; - dgUnsigned8 m_userFlag0; - dgUnsigned8 m_userFlag1; - dgUnsigned8 m_userFlag2; -// dgUnsigned32 m_userFlag3 : 1; -// dgUnsigned32 m_userFlag4 : 1; -// dgUnsigned32 m_userFlag5 : 1; -// dgUnsigned32 m_userFlag6 : 1; - - dgUnsigned32 m_ref; -}; - - -class dgRef: public dgRefFlags -{ - public: - dgRef (); - dgRef (const char *name); - dgRef (dgUnsigned32 idArg); - dgRef(const dgRef &Clone); - dgRef *AddRef () ; - dgInt32 Release (); - dgInt32 GetRefCount() const; - - DG_CLASS_ALLOCATOR(allocator) - - virtual dgRef *CreateClone () const; - virtual dgUnsigned32 GetTypeId () const; - virtual bool IsType (dgUnsigned32 typeId) const; - - bool GetUserFlag0 () const; - bool GetUserFlag1 () const; - void SetUserFlag0 (bool flags); - void SetUserFlag1 (bool flags); - - bool IsAlive() const; - virtual void Kill(); - virtual void Unkill(); - - const char* GetName () const; - dgUnsigned32 GetNameID () const; - inline void SetNameID (dgUnsigned32 newID); - virtual void SetName (const char *name); - - void AttachRef (dgRef **oldRef, dgRef *newRef); - - - bool IsTypeByName (const char *typeName) const; - static dgUnsigned32 GetRttiType(); - - protected: - virtual ~dgRef (); - - private: - dgUnsigned32 m_id; - static dgRtti m_rtti; -}; - - - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgRefCounter.cpp b/thirdparty/src/newton/dgCore/dgRefCounter.cpp deleted file mode 100644 index 05f87f718..000000000 --- a/thirdparty/src/newton/dgCore/dgRefCounter.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgRefCounter.h" - -/* -dgRefCounter::dgRefCounter(void) -{ - m_refCount = 1; -} - -dgRefCounter::~dgRefCounter(void) -{ -} - - -int dgRefCounter::GetRef() const -{ - return m_refCount; -} - -int dgRefCounter::Release() -{ - m_refCount --; - if (!m_refCount) { - delete this; - return 0; - } - return m_refCount; -} - -void dgRefCounter::AddRef() -{ - m_refCount ++; -} -*/ - diff --git a/thirdparty/src/newton/dgCore/dgRefCounter.h b/thirdparty/src/newton/dgCore/dgRefCounter.h deleted file mode 100644 index 5f349d58f..000000000 --- a/thirdparty/src/newton/dgCore/dgRefCounter.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGREF_COUNTER__ -#define __DGREF_COUNTER__ - -class dgRefCounter -{ - public: - dgRefCounter(void); - int GetRef() const; - int Release(); - void AddRef(); - - protected: - virtual ~dgRefCounter(void); - - private: - int m_refCount; -}; - - -inline dgRefCounter::dgRefCounter(void) -{ - m_refCount = 1; -} - -inline dgRefCounter::~dgRefCounter(void) -{ - dgAssert (m_refCount <= 1); -} - - -inline int dgRefCounter::GetRef() const -{ - return m_refCount; -} - -inline int dgRefCounter::Release() -{ - m_refCount --; - if (!m_refCount) { - delete this; - return 0; - } - return m_refCount; -} - -inline void dgRefCounter::AddRef() -{ - m_refCount ++; -} - -#endif diff --git a/thirdparty/src/newton/dgCore/dgRtti.h b/thirdparty/src/newton/dgCore/dgRtti.h deleted file mode 100644 index fbac83383..000000000 --- a/thirdparty/src/newton/dgCore/dgRtti.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgRtti__ -#define __dgRtti__ - -#include "dgStdafx.h" -#include "dgCRC.h" - -class dgRtti -{ - public: - dgRtti(const char* typeName); - dgUnsigned32 GetTypeId() const; - bool IsTypeID(dgUnsigned32 id) const; - - private: - dgUnsigned32 m_TypeId; -}; - -inline dgRtti::dgRtti(const char* typeName) -{ - m_TypeId = dgCRC (typeName, (dgInt32) strlen (typeName)); -} - -inline dgUnsigned32 dgRtti::GetTypeId() const -{ - return m_TypeId; -} - -inline bool dgRtti::IsTypeID (dgUnsigned32 id) const -{ - return m_TypeId == id; -} - - - -#define dgAddRtti(baseClass) \ - private: \ - static dgRtti rtti; \ - public: \ - virtual bool IsType (dgUnsigned32 typeId) const \ - { \ - if (rtti.IsTypeID (typeId)) { \ - return true; \ - } \ - return baseClass::IsType (typeId); \ - } \ - virtual dgUnsigned32 GetTypeId () const \ - { \ - return rtti.GetTypeId (); \ - } \ - static dgUnsigned32 GetRttiType() \ - { \ - return rtti.GetTypeId(); \ - } - - -#define dgInitRtti(className) \ - dgRtti className::rtti (#className) - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgSmallDeterminant.cpp b/thirdparty/src/newton/dgCore/dgSmallDeterminant.cpp deleted file mode 100644 index 644d25c1f..000000000 --- a/thirdparty/src/newton/dgCore/dgSmallDeterminant.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgGoogol.h" -#include "dgSmallDeterminant.h" - -#define Absolute(a) ((a) >= 0.0 ? (a) : -(a)) - -dgFloat64 Determinant2x2 (const dgFloat64 matrix[2][2], dgFloat64* const error) -{ - dgFloat64 a00xa11 = matrix[0][0] * matrix[1][1]; - dgFloat64 a01xa10 = matrix[0][1] * matrix[1][0]; - *error = Absolute(a00xa11) + Absolute(a01xa10); - return a00xa11 - a01xa10; -} - -dgGoogol Determinant2x2 (const dgGoogol matrix[2][2]) -{ - dgGoogol a00xa11 (matrix[0][0] * matrix[1][1]); - dgGoogol a01xa10 (matrix[0][1] * matrix[1][0]); - return a00xa11 - a01xa10; -} - - - -dgFloat64 Determinant3x3 (const dgFloat64 matrix[3][3], dgFloat64* const error) -{ - dgFloat64 sign = dgFloat64 (-1.0f); - dgFloat64 det = dgFloat64 (0.0f); - dgFloat64 accError = dgFloat64 (0.0f); - for (dgInt32 i = 0; i < 3; i ++) { - dgFloat64 cofactor[2][2]; - for (dgInt32 j = 0; j < 2; j ++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 3; k ++) { - if (k != i) { - cofactor[j][k0] = matrix[j][k]; - k0 ++; - } - } - } - - dgFloat64 parcialError; - dgFloat64 minorDet = Determinant2x2 (cofactor, &parcialError); - accError += parcialError * Absolute (matrix[2][i]); - det += sign * minorDet * matrix[2][i]; - sign *= dgFloat64 (-1.0f); - } - - *error = accError; - return det; -} - -dgGoogol Determinant3x3 (const dgGoogol matrix[3][3]) -{ - dgGoogol negOne (dgFloat64 (-1.0f)); - dgGoogol sign (dgFloat64 (-1.0f)); - dgGoogol det = dgFloat64 (0.0f); - for (dgInt32 i = 0; i < 3; i ++) { - dgGoogol cofactor[2][2]; - - for (dgInt32 j = 0; j < 2; j ++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 3; k ++) { - if (k != i) { - cofactor[j][k0] = matrix[j][k]; - k0 ++; - } - } - } - - dgGoogol minorDet (Determinant2x2 (cofactor)); - det = det + sign * minorDet * matrix[2][i]; - sign = sign * negOne; - } - return det; -} - - -dgFloat64 Determinant4x4 (const dgFloat64 matrix[4][4], dgFloat64* const error) -{ - dgFloat64 sign = dgFloat64 (1.0f); - dgFloat64 det = dgFloat64 (0.0f); - dgFloat64 accError = dgFloat64 (0.0f); - for (dgInt32 i = 0; i < 4; i ++) { - dgFloat64 cofactor[3][3]; - for (dgInt32 j = 0; j < 3; j ++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 4; k ++) { - if (k != i) { - cofactor[j][k0] = matrix[j][k]; - k0 ++; - } - } - } - - dgFloat64 parcialError; - dgFloat64 minorDet = Determinant3x3 (cofactor, &parcialError); - accError += parcialError * Absolute (matrix[3][i]); - det += sign * minorDet * matrix[3][i]; - sign *= dgFloat64 (-1.0f); - } - - *error = accError; - return det; -} - - -dgGoogol Determinant4x4 (const dgGoogol matrix[4][4]) -{ - dgGoogol sign = dgFloat64 (1.0f); - dgGoogol det = dgFloat64 (0.0f); - dgGoogol negOne (dgFloat64 (-1.0f)); - //dgGoogol accError = dgFloat64 (0.0f); - for (dgInt32 i = 0; i < 4; i ++) { - dgGoogol cofactor[3][3]; - for (dgInt32 j = 0; j < 3; j ++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 4; k ++) { - if (k != i) { - cofactor[j][k0] = matrix[j][k]; - k0 ++; - } - } - } - - dgGoogol minorDet = Determinant3x3 (cofactor); - det = det + sign * minorDet * matrix[3][i]; - sign = sign * negOne; - } - return det; -} - - diff --git a/thirdparty/src/newton/dgCore/dgSmallDeterminant.h b/thirdparty/src/newton/dgCore/dgSmallDeterminant.h deleted file mode 100644 index bbc9d4d7c..000000000 --- a/thirdparty/src/newton/dgCore/dgSmallDeterminant.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgSMALLDETERMINANT__ -#define __dgSMALLDETERMINANT__ - -#include "dgStdafx.h" - -class dgGoogol; -dgFloat64 Determinant2x2 (const dgFloat64 matrix[2][2], dgFloat64* const error); -dgFloat64 Determinant3x3 (const dgFloat64 matrix[3][3], dgFloat64* const error); -dgFloat64 Determinant4x4 (const dgFloat64 matrix[4][4], dgFloat64* const error); - - -dgGoogol Determinant2x2 (const dgGoogol matrix[2][2]); -dgGoogol Determinant3x3 (const dgGoogol matrix[3][3]); -dgGoogol Determinant4x4 (const dgGoogol matrix[4][4]); - -#endif diff --git a/thirdparty/src/newton/dgCore/dgSort.h b/thirdparty/src/newton/dgCore/dgSort.h deleted file mode 100644 index 63650c4b9..000000000 --- a/thirdparty/src/newton/dgCore/dgSort.h +++ /dev/null @@ -1,439 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DG_SORT_H__ -#define __DG_SORT_H__ -#include "dgStdafx.h" -#include "dgHeap.h" -#include "dgProfiler.h" -#include "dgThreadHive.h" - -#define DG_PARALLET_SORT_BATCH_SIZE 1024 - -template <class T> -dgInt32 dgBinarySearch(T const* array, dgInt32 elements, const T& entry, dgInt32(*compare) (const T* const A, const T* const B, void* const context), void* const context = NULL) -{ - dgInt32 index0 = 0; - dgInt32 index2 = elements - 1; - - while ((index2 - index0) > 4) { - dgInt32 index1 = (index0 + index2) >> 1; - dgInt32 test = compare(&array[index1], &entry, context); - if (test < 0) { - index0 = index1; - } - else { - index2 = index1; - } - } - - index0 = (index0 > 0) ? index0 - 1 : 0; - index2 = ((index2 + 1) < elements) ? index2 + 1 : elements; - dgInt32 index = index0 - 1; - for (dgInt32 i = index0; i < index2; i++) { - dgInt32 test = compare(&array[i], &entry, context); - if (!test) { - return i; - } - else if (test > 0) { - break; - } - index = i; - } - return index; -} - -template <class T> -dgInt32 dgBinarySearchIndirect(T** const array, dgInt32 elements, const T& entry, dgInt32(*compare) (const T* const A, const T* const B, void* const context), void* const context = NULL) -{ - dgInt32 index0 = 0; - dgInt32 index2 = elements - 1; - - while ((index2 - index0) > 4) { - dgInt32 index1 = (index0 + index2) >> 1; - dgInt32 test = compare(array[index1], &entry, context); - if (test < 0) { - index0 = index1; - } - else { - index2 = index1; - } - } - - index0 = (index0 > 0) ? index0 - 1 : 0; - index2 = ((index2 + 1) < elements) ? index2 + 1 : elements; - dgInt32 index = index0 - 1; - for (dgInt32 i = index0; i < index2; i++) { - dgInt32 test = compare(array[i], &entry, context); - if (!test) { - return i; - } - else if (test > 0) { - break; - } - index = i; - } - return index; -} - -template <class T> -void dgRadixSort(T* const array, T* const tmpArray, dgInt32 elements, dgInt32 radixPass, dgInt32(*getRadixKey) (const T* const A, void* const context), void* const context = NULL) -{ - dgInt32 scanCount[256]; - dgInt32 histogram[256][4]; - - dgAssert(radixPass >= 1); - dgAssert(radixPass <= 4); - - memset(histogram, 0, sizeof(histogram)); - for (dgInt32 i = 0; i < elements; i++) { - dgInt32 key = getRadixKey(&array[i], context); - for (dgInt32 j = 0; j < radixPass; j++) { - dgInt32 radix = (key >> (j << 3)) & 0xff; - histogram[radix][j] = histogram[radix][j] + 1; - } - } - - for (dgInt32 radix = 0; radix < radixPass; radix += 2) { - scanCount[0] = 0; - for (dgInt32 i = 1; i < 256; i++) { - scanCount[i] = scanCount[i - 1] + histogram[i - 1][radix]; - } - dgInt32 radixShift = radix << 3; - for (dgInt32 i = 0; i < elements; i++) { - dgInt32 key = (getRadixKey(&array[i], context) >> radixShift) & 0xff; - dgInt32 index = scanCount[key]; - tmpArray[index] = array[i]; - scanCount[key] = index + 1; - } - - if ((radix + 1) < radixPass) { - scanCount[0] = 0; - for (dgInt32 i = 1; i < 256; i++) { - scanCount[i] = scanCount[i - 1] + histogram[i - 1][radix + 1]; - } - - dgInt32 radixShift = (radix + 1) << 3; - for (dgInt32 i = 0; i < elements; i++) { - dgInt32 key = (getRadixKey(&array[i], context) >> radixShift) & 0xff; - dgInt32 index = scanCount[key]; - array[index] = tmpArray[i]; - scanCount[key] = index + 1; - } - } - else { - memcpy(array, tmpArray, elements * sizeof(T)); - } - } - -#ifdef _DEBUG - for (dgInt32 i = 0; i < (elements - 1); i++) { - dgAssert(getRadixKey(&array[i], context) <= getRadixKey(&array[i + 1], context)); - } -#endif -} - -template <class T> -void dgSort(T* const array, dgInt32 elements, dgInt32(*compare) (const T* const A, const T* const B, void* const context), void* const context = NULL) -{ - //DG_TRACKTIME(); - const dgInt32 batchSize = 8; - dgInt32 stack[1024][2]; - - stack[0][0] = 0; - stack[0][1] = elements - 1; - dgInt32 stackIndex = 1; - while (stackIndex) { - stackIndex--; - dgInt32 lo = stack[stackIndex][0]; - dgInt32 hi = stack[stackIndex][1]; - if ((hi - lo) > batchSize) { - dgInt32 mid = (lo + hi) >> 1; - if (compare(&array[lo], &array[mid], context) > 0) { - dgSwap(array[lo], array[mid]); - } - if (compare(&array[mid], &array[hi], context) > 0) { - dgSwap(array[mid], array[hi]); - } - if (compare(&array[lo], &array[mid], context) > 0) { - dgSwap(array[lo], array[mid]); - } - dgInt32 i = lo + 1; - dgInt32 j = hi - 1; - T pivot(array[mid]); - do { - while (compare(&array[i], &pivot, context) < 0) i++; - while (compare(&array[j], &pivot, context) > 0) j--; - - if (i <= j) { - dgSwap(array[i], array[j]); - i++; - j--; - } - } while (i <= j); - - if (i < hi) { - stack[stackIndex][0] = i; - stack[stackIndex][1] = hi; - stackIndex++; - } - if (lo < j) { - stack[stackIndex][0] = lo; - stack[stackIndex][1] = j; - stackIndex++; - } - dgAssert(stackIndex < dgInt32(sizeof(stack) / (2 * sizeof(stack[0][0])))); - } - } - - dgInt32 stride = batchSize + 1; - if (elements < stride) { - stride = elements; - } - for (dgInt32 i = 1; i < stride; i++) { - if (compare(&array[0], &array[i], context) > 0) { - dgSwap(array[0], array[i]); - } - } - - for (dgInt32 i = 1; i < elements; i++) { - dgInt32 j = i; - T tmp(array[i]); - for (; compare(&array[j - 1], &tmp, context) > 0; j--) { - dgAssert(j > 0); - array[j] = array[j - 1]; - } - array[j] = tmp; - } - -#ifdef _DEBUG - for (dgInt32 i = 0; i < (elements - 1); i++) { - dgAssert(compare(&array[i], &array[i + 1], context) <= 0); - } -#endif -} - -template <class T> -void dgSortIndirect(T** const array, dgInt32 elements, dgInt32(*compare) (const T* const A, const T* const B, void* const context), void* const context = NULL) -{ - //DG_TRACKTIME(); - const dgInt32 batchSize = 8; - dgInt32 stack[1024][2]; - - stack[0][0] = 0; - stack[0][1] = elements - 1; - dgInt32 stackIndex = 1; - while (stackIndex) { - stackIndex--; - dgInt32 lo = stack[stackIndex][0]; - dgInt32 hi = stack[stackIndex][1]; - if ((hi - lo) > batchSize) { - dgInt32 mid = (lo + hi) >> 1; - if (compare(array[lo], array[mid], context) > 0) { - dgSwap(array[lo], array[mid]); - } - if (compare(array[mid], array[hi], context) > 0) { - dgSwap(array[mid], array[hi]); - } - if (compare(array[lo], array[mid], context) > 0) { - dgSwap(array[lo], array[mid]); - } - dgInt32 i = lo + 1; - dgInt32 j = hi - 1; - T* val(array[mid]); - do { - while (compare(array[i], val, context) < 0) i++; - while (compare(array[j], val, context) > 0) j--; - - if (i <= j) { - dgSwap(array[i], array[j]); - i++; - j--; - } - } while (i <= j); - - if (i < hi) { - stack[stackIndex][0] = i; - stack[stackIndex][1] = hi; - stackIndex++; - } - if (lo < j) { - stack[stackIndex][0] = lo; - stack[stackIndex][1] = j; - stackIndex++; - } - dgAssert(stackIndex < dgInt32(sizeof(stack) / (2 * sizeof(stack[0][0])))); - } - } - - dgInt32 stride = batchSize + 1; - if (elements < stride) { - stride = elements; - } - for (dgInt32 i = 1; i < stride; i++) { - if (compare(array[0], array[i], context) > 0) { - dgSwap(array[0], array[i]); - } - } - - for (dgInt32 i = 1; i < elements; i++) { - dgInt32 j = i; - T* tmp(array[i]); - for (; compare(array[j - 1], tmp, context) > 0; j--) { - dgAssert(j > 0); - array[j] = array[j - 1]; - } - array[j] = tmp; - } - -#ifdef _DEBUG - for (dgInt32 i = 0; i < (elements - 1); i++) { - dgAssert(compare(array[i], array[i + 1], context) <= 0); - } -#endif -} - - -class dgParallelSortRange -{ - public: - dgParallelSortRange() {} - dgParallelSortRange(dgInt32 i0, dgInt32 i1) - :m_i0(i0) - , m_i1(i1) - { - } - dgInt32 m_i0; - dgInt32 m_i1; -}; - -template <class T> -class dgParallelSourtDesc -{ - public: - typedef dgInt32(*CompareFunction) (const T* const A, const T* const B, void* const context); - - dgParallelSourtDesc(dgThreadHive& threadPool, T* const array, dgInt32 elements, CompareFunction compareFunct, void* const context) - :m_data(array) - ,m_callback(compareFunct) - ,m_context(context) - ,m_threadCount(threadPool.GetThreadCount()) - { - dgDownHeap<dgParallelSortRange, dgInt32> rangeMerge(m_buffer, sizeof(m_buffer)); - - dgParallelSortRange range(0, elements - 1); - rangeMerge.Push(range, elements); - - const dgInt32 batchSize = DG_PARALLET_SORT_BATCH_SIZE; - const dgInt32 rangesCount = m_threadCount; - - while ((rangeMerge.GetCount() < rangesCount) && (rangeMerge.Value() > batchSize)) { - dgParallelSortRange splitRange(rangeMerge[0]); - rangeMerge.Pop(); - - const dgInt32 lo = splitRange.m_i0; - const dgInt32 hi = splitRange.m_i1; - const dgInt32 mid = (lo + hi) >> 1; - if (m_callback(&array[lo], &array[mid], context) > 0) { - dgSwap(array[lo], array[mid]); - } - if (m_callback(&array[mid], &array[hi], context) > 0) { - dgSwap(array[mid], array[hi]); - } - if (m_callback(&array[lo], &array[mid], context) > 0) { - dgSwap(array[lo], array[mid]); - } - dgInt32 i = lo; - dgInt32 j = hi; - T pivot(array[mid]); - for (;;) { - do { - i++; - } while (m_callback(&array[i], &pivot, context) < 0); - do { - j--; - } while (m_callback(&array[j], &pivot, context) > 0); - - if (i >= j) { - break; - } - dgSwap(array[i], array[j]); - } - - dgParallelSortRange newRange0(lo, j); - dgParallelSortRange newRange1(j + 1, hi); - rangeMerge.Push(newRange0, j - lo + 1); - rangeMerge.Push(newRange1, hi - j); - } - - m_rangeMerge = &rangeMerge; - for (dgInt32 i = 0; i < m_threadCount; i++) { - threadPool.QueueJob(dgParallelKernel, this, NULL, __FUNCTION__); - } - threadPool.SynchronizationBarrier(); - - #ifdef _DEBUG - for (dgInt32 i = 0; i < (elements - 1); i++) { - dgAssert(m_callback(&m_data[i], &m_data[i + 1], context) <= 0); - } - #endif - } - - static void dgParallelKernel(void* const context, void* const worldContext, dgInt32 threadID) - { - DG_TRACKTIME(); - dgParallelSourtDesc<T>* const me = (dgParallelSourtDesc<T>*) context; - me->dgParallelKernel(threadID); - } - - void dgParallelKernel(dgInt32 threadID) - { - dgDownHeap<dgParallelSortRange, dgInt32>& rangeMerge = *((dgDownHeap<dgParallelSortRange, dgInt32>*)m_rangeMerge); - const dgInt32 count = rangeMerge.GetCount(); - for (dgInt32 i = threadID; i < count; i += m_threadCount) { - dgParallelSortRange range(rangeMerge[i]); - T* const data = &m_data[range.m_i0]; - dgSort(data, range.m_i1 - range.m_i0 + 1, m_callback, m_context); - } - } - - T* m_data; - void* m_rangeMerge; - CompareFunction m_callback; - void* m_context; - int m_threadCount; - dgInt8 m_buffer[256 * sizeof (dgParallelSortRange)]; -}; - -template <class T> -void dgParallelSort(dgThreadHive& threadPool, T* const array, dgInt32 elements, dgInt32(*compare) (const T* const A, const T* const B, void* const context), void* const context = NULL) -{ - //DG_TRACKTIME(); - if ((threadPool.GetThreadCount() <= 1) || (elements < DG_PARALLET_SORT_BATCH_SIZE)) { -// if (1) { - dgSort(array, elements, compare, context); - } else { - dgParallelSourtDesc<T> sort(threadPool, array, elements, compare, context); - } -} - -#endif diff --git a/thirdparty/src/newton/dgCore/dgStack.h b/thirdparty/src/newton/dgCore/dgStack.h deleted file mode 100644 index f0eaacbb5..000000000 --- a/thirdparty/src/newton/dgCore/dgStack.h +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgStack__ -#define __dgStack__ - -#include "dgStdafx.h" -#include "dgDebug.h" -#include "dgMemory.h" - -class dgStackBase -{ - protected: - dgStackBase (dgInt32 size); - ~dgStackBase (); - - const void *m_ptr; -}; - -inline dgStackBase::dgStackBase (dgInt32 size) - :m_ptr (dgMallocStack (size_t (size))) -{ -} - -inline dgStackBase::~dgStackBase () -{ - dgFreeStack ((void*)m_ptr); -} - -template<class T> -class dgStack: public dgStackBase -{ - public: - dgStack (dgInt32 size); - ~dgStack (); - dgInt32 GetSizeInBytes() const; - dgInt32 GetElementsCount() const; - - DG_INLINE T& operator[] (dgInt32 entry); - DG_INLINE const T& operator[] (dgInt32 entry) const; - - private: - dgInt32 m_size; -}; - -template<class T> -dgStack<T>::dgStack (dgInt32 size) - :dgStackBase (dgInt32 (size * sizeof(T))) -{ - m_size = size; -} - -template<class T> -dgStack<T>::~dgStack () -{ -} - -template<class T> -dgInt32 dgStack<T>::GetElementsCount() const -{ - return m_size; -} - -template<class T> -dgInt32 dgStack<T>::GetSizeInBytes() const -{ - return dgInt32 (m_size * sizeof(T)); -} - - -template<class T> -DG_INLINE T& dgStack<T>::operator[] (dgInt32 entry) -{ - dgAssert (entry >= 0); - dgAssert ((entry < m_size) || ((m_size == 0) && (entry == 0))); - - T* const mem = (T*) m_ptr; - return mem[entry]; -} - -template<class T> -DG_INLINE const T& dgStack<T>::operator[] (dgInt32 entry) const -{ - dgAssert (entry >= 0); - dgAssert ((entry < m_size) || ((m_size == 0) && (entry == 0))); - - const T* const mem = (T*) m_ptr; - return mem[entry]; -} - - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgStdafx.h b/thirdparty/src/newton/dgCore/dgStdafx.h deleted file mode 100644 index fc9f647dc..000000000 --- a/thirdparty/src/newton/dgCore/dgStdafx.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_TYPES_H_ -#define _DG_TYPES_H_ - -#include "dgTypes.h" - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgThread.cpp b/thirdparty/src/newton/dgCore/dgThread.cpp deleted file mode 100644 index 9ca91bdc8..000000000 --- a/thirdparty/src/newton/dgCore/dgThread.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgThread.h" -#include "dgProfiler.h" - -dgThread::dgThread () - :m_id(0) - ,m_terminate(0) - ,m_threadRunning(0) -{ - m_name[0] = 0; -} - -dgThread::dgThread (const char* const name, dgInt32 id) - :m_id(id) - ,m_terminate(0) - ,m_threadRunning(0) -{ - strncpy (m_name, name, sizeof (m_name) - 1); -} - -void dgThread::Init (const char* const name, dgInt32 id) -{ - m_id = id; - strncpy (m_name, name, sizeof (m_name) - 1); - Init (); -} - - -bool dgThread::IsThreadActive() const -{ - return m_threadRunning ? true : false; -} - -#ifdef DG_USE_THREAD_EMULATION - -dgThread::dgSemaphore::dgSemaphore () -{ - m_sem = 0; -} - -dgThread::dgSemaphore::~dgSemaphore () -{ -} - -void dgThread::dgSemaphore::Release () -{ -} - -void dgThread::dgSemaphore::Wait() -{ -} - -dgThread::~dgThread () -{ -} - -void dgThread::Init () -{ -} - -void dgThread::Close () -{ -} - -//void dgThread::Wait (dgSemaphore& mutex) -//{ -//} - -void dgThread::Wait (dgInt32 count, dgSemaphore* const semArray) -{ -} - -void* dgThread::dgThreadSystemCallback(void* threadData) -{ - return 0; -} - -#else - -dgThread::dgSemaphore::dgSemaphore () - :m_count(0) -{ -} - -dgThread::dgSemaphore::~dgSemaphore () -{ -} - -void dgThread::dgSemaphore::Release () -{ - std::unique_lock <std::mutex> lck(m_mutex); - m_count ++; - m_sem.notify_one(); -} - -void dgThread::dgSemaphore::Wait() -{ - std::unique_lock <std::mutex> lck(m_mutex); - dgAssert (m_count >= 0); - while (m_count == 0) - { - m_sem.wait(lck); - } - m_count --; -} - -dgThread::~dgThread () -{ -} - - -void dgThread::SetName() -{ -#if defined(_MSC_VER) - // a hideous way to set the thread name, bu this is how Microsoft does it - const DWORD MS_VC_EXCEPTION = 0x406D1388; - #pragma pack(push,8) - struct THREADNAME_INFO - { - DWORD dwType; // Must be 0x1000. - LPCSTR szName; // Pointer to name (in user addr space). - DWORD dwThreadID; // Thread ID (-1=caller thread). - DWORD dwFlags; // Reserved for future use, must be zero. - }; - #pragma pack(pop) - - - THREADNAME_INFO info; - info.dwType = 0x1000; - info.szName = m_name; - info.dwThreadID = GetThreadId(m_handle.native_handle()); - info.dwFlags = 0; - __try { - RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info); - } - __except (EXCEPTION_EXECUTE_HANDLER) - { - } -#endif -} - - -void dgThread::Init () -{ - // This must be set now because otherwise if this thread is - // immediately closed the Terminate method won't detect that the - // thread is running - dgInterlockedExchange(&m_threadRunning, 0); - m_handle = std::thread(dgThreadSystemCallback, this); - // wait until the thread procedure is called. - while (!m_threadRunning) { - dgThreadYield(); - } - - SetName(); -} - -void dgThread::Close () -{ - m_handle.join(); -} - -void dgThread::Wait (dgInt32 count, dgSemaphore* const semArray) -{ - for (dgInt32 i = 0; i < count; i ++) { - semArray[i].Wait(); - } -} - - -void* dgThread::dgThreadSystemCallback(void* threadData) -{ - dgFloatExceptions exception; - dgSetPrecisionDouble precision; - - dgThread* const me = (dgThread*) threadData; - - D_SET_TRACK_NAME(me->m_name); - dgInterlockedExchange(&me->m_threadRunning, 1); - me->Execute(me->m_id); - dgInterlockedExchange(&me->m_threadRunning, 0); - - return 0; -} - - -#endif - - - diff --git a/thirdparty/src/newton/dgCore/dgThread.h b/thirdparty/src/newton/dgCore/dgThread.h deleted file mode 100644 index a0900cd13..000000000 --- a/thirdparty/src/newton/dgCore/dgThread.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DG_THREAD_API_H__ -#define __DG_THREAD_API_H__ - -// by default newton is run on a separate thread, optionally concurrent with the calling thread, it also uses a thread job pool for multi core systems. -// define DG_USE_THREAD_EMULATION on the command line for platform that do not support hardware multi threading or if multi threading is not stable -//#define DG_USE_THREAD_EMULATION - - -class dgThread -{ - public: - class dgSemaphore - { - public: - dgSemaphore (); - ~dgSemaphore (); - void Wait(); - void Release(); - - dgInt32 GetCount() const - { - #ifdef DG_USE_THREAD_EMULATION - return 0; - #else - return m_count; - #endif - } - - private: - #ifdef DG_USE_THREAD_EMULATION - dgInt32 m_sem; - #else - std::condition_variable m_sem; - std::mutex m_mutex; - dgInt32 m_count; - #endif - }; - - dgThread (); - dgThread (const char* const name, dgInt32 id); - virtual ~dgThread (); - - virtual void Execute (dgInt32 threadId) = 0; - - bool IsThreadActive() const; - void Wait (dgInt32 count, dgSemaphore* const mutexes); - - protected: - void Init (); - void Init (const char* const name, dgInt32 id); - void Close (); - void SetName (); - static void* dgThreadSystemCallback(void* threadData); - - #ifndef DG_USE_THREAD_EMULATION - std::thread m_handle; - #endif - dgInt32 m_id; - dgInt32 m_terminate; - dgInt32 m_threadRunning; - - char m_name[32]; -}; - -#endif diff --git a/thirdparty/src/newton/dgCore/dgThreadHive.cpp b/thirdparty/src/newton/dgCore/dgThreadHive.cpp deleted file mode 100644 index 50bcdbdbc..000000000 --- a/thirdparty/src/newton/dgCore/dgThreadHive.cpp +++ /dev/null @@ -1,386 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgTypes.h" -#include "dgMemory.h" -#include "dgProfiler.h" -#include "dgThreadHive.h" - -#ifdef USE_UNIX_THREAD_POOL -dgThreadHive::dgWorkerThread::dgWorkerThread() - :dgThread() - ,m_hive(NULL) - ,m_allocator(NULL) - ,m_isBusy(0) - ,m_jobsCount(0) - ,m_workerSemaphore() -{ -} - -dgThreadHive::dgWorkerThread::~dgWorkerThread() -{ - while (IsBusy()); - - dgInterlockedExchange(&m_terminate, 1); - m_workerSemaphore.Release(); - Close(); -} - -void dgThreadHive::dgWorkerThread::SetUp(dgMemoryAllocator* const allocator, const char* const name, dgInt32 id, dgThreadHive* const hive) -{ - m_hive = hive; - m_allocator = allocator; - Init (name, id); - - #ifndef DG_USE_THREAD_EMULATION - #if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - SetThreadPriority(m_handle.native_handle(), THREAD_PRIORITY_ABOVE_NORMAL); - #endif - #endif -} - -bool dgThreadHive::dgWorkerThread::IsBusy() const -{ - return m_isBusy ? true : false; -} - -void dgThreadHive::dgWorkerThread::Execute (dgInt32 threadId) -{ - m_hive->OnBeginWorkerThread (threadId); - - while (!m_terminate) { - dgInterlockedExchange(&m_isBusy, 0); - m_workerSemaphore.Wait(); - dgInterlockedExchange(&m_isBusy, 1); - if (!m_terminate) { - RunNextJobInQueue(threadId); - m_hive->m_beginSectionSemaphores[threadId].Release(); - } - } - - dgInterlockedExchange(&m_isBusy, 0); - - m_hive->OnEndWorkerThread (threadId); -} - -dgInt32 dgThreadHive::dgWorkerThread::PushJob(const dgThreadJob& job) -{ - dgAssert (m_jobsCount < sizeof (m_jobPool)/ sizeof (m_jobPool[0])); - m_jobPool[m_jobsCount] = job; - m_jobsCount ++; - return m_jobsCount; -} - -void dgThreadHive::dgWorkerThread::RunNextJobInQueue(dgInt32 threadId) -{ - for (dgInt32 i = 0; i < m_jobsCount; i ++) { - const dgThreadJob& job = m_jobPool[i]; - job.m_callback (job.m_context0, job.m_context1, m_id); - } - m_jobsCount = 0; -} - -dgThreadHive::dgThreadHive(dgMemoryAllocator* const allocator) - :m_parentThread(NULL) - ,m_workerThreads(NULL) - ,m_allocator(allocator) - ,m_jobsCount(0) - ,m_workerThreadsCount(0) - ,m_globalCriticalSection(0) -{ -} - -dgThreadHive::~dgThreadHive() -{ - DestroyThreads(); -} - -void dgThreadHive::SetParentThread (dgThread* const parentThread) -{ - m_parentThread = parentThread; -} - -void dgThreadHive::DestroyThreads() -{ - if (m_workerThreadsCount) { - delete[] m_workerThreads; - m_workerThreads = NULL; - m_workerThreadsCount = 0; - } -} - -void dgThreadHive::SetThreadsCount (dgInt32 threads) -{ - DestroyThreads(); - - m_workerThreadsCount = dgMin (threads, DG_MAX_THREADS_HIVE_COUNT); - if (m_workerThreadsCount == 1) { - m_workerThreadsCount = 0; - } - - if (m_workerThreadsCount) { - m_workerThreads = new (m_allocator) dgWorkerThread[dgUnsigned32 (m_workerThreadsCount)]; - - for (dgInt32 i = 0; i < m_workerThreadsCount; i ++) { - char name[256]; - sprintf (name, "dgWorkerThread%d", i); - m_workerThreads[i].SetUp(m_allocator, name, i, this); - } - } -} - -void dgThreadHive::QueueJob (dgWorkerThreadTaskCallback callback, void* const context0, void* const context1, const char* const functionName) -{ - if (!m_workerThreadsCount) { - //DG_TRACKTIME(functionName); - callback (context0, context1, 0); - } else { - dgInt32 workerTreadEntry = m_jobsCount % m_workerThreadsCount; - #ifdef DG_USE_THREAD_EMULATION - //DG_TRACKTIME(functionName); - callback (context0, context1, workerTreadEntry); - #else - dgInt32 index = m_workerThreads[workerTreadEntry].PushJob(dgThreadJob(context0, context1, callback, functionName)); - if (index >= DG_THREAD_POOL_JOB_SIZE) { - dgAssert (0); - SynchronizationBarrier (); - } - #endif - } - - m_jobsCount ++; -} - -void dgThreadHive::OnBeginWorkerThread (dgInt32 threadId) -{ -} - -void dgThreadHive::OnEndWorkerThread (dgInt32 threadId) -{ -} - -void dgThreadHive::SynchronizationBarrier () -{ - if (m_workerThreadsCount) { - //DG_TRACKTIME(); - for (dgInt32 i = 0; i < m_workerThreadsCount; i ++) { - m_workerThreads[i].m_workerSemaphore.Release(); - } - m_parentThread->Wait(m_workerThreadsCount, m_beginSectionSemaphores); - } - m_jobsCount = 0; -} - -#else - -dgThreadHive::dgWorkerThread::dgWorkerThread() - :dgThread() - ,m_workerSemaphore() - ,m_hive(NULL) - ,m_allocator(NULL) - ,m_concurrentWork(0) - ,m_pendingWork(0) - ,m_jobsCount(0) -{ -} - -dgThreadHive::dgWorkerThread::~dgWorkerThread() -{ - dgInterlockedExchange(&m_terminate, 1); - m_workerSemaphore.Release(); - Close(); -} - -void dgThreadHive::dgWorkerThread::SetUp(dgMemoryAllocator* const allocator, const char* const name, dgInt32 id, dgThreadHive* const hive) -{ - m_hive = hive; - m_allocator = allocator; - Init(name, id); -} - -void dgThreadHive::dgWorkerThread::RunNextJobInQueue(dgInt32 threadId) -{ - for (dgInt32 i = 0; i < m_jobsCount; i++) { - const dgThreadJob& job = m_jobPool[i]; - job.m_callback(job.m_context0, job.m_context1, m_id); - } -} - -dgInt32 dgThreadHive::dgWorkerThread::PushJob(const dgThreadJob& job) -{ - dgAssert(m_jobsCount < sizeof (m_jobPool) / sizeof (m_jobPool[0])); - m_jobPool[m_jobsCount] = job; - m_jobsCount++; - return m_jobsCount; -} - - -void dgThreadHive::dgWorkerThread::ConcurrentWork(dgInt32 threadId) -{ - while (dgInterlockedTest(&m_concurrentWork, 1)) { - if (dgInterlockedExchange(&m_pendingWork, 0)) { - //DG_TRACKTIME(); - RunNextJobInQueue(threadId); - m_jobsCount = 0; - dgAtomicExchangeAndAdd(&m_hive->m_syncLock, -1); - } - dgThreadYield(); - } -} - -void dgThreadHive::dgWorkerThread::Execute(dgInt32 threadId) -{ - m_hive->OnBeginWorkerThread(threadId); - - while (!m_terminate) { - m_workerSemaphore.Wait(); - if (!m_terminate) { - m_concurrentWork = 1; - m_hive->m_beginSectionSemaphores[threadId].Release(); - ConcurrentWork(threadId); - m_hive->m_endSectionSemaphores[threadId].Release(); - } - } - - m_hive->OnEndWorkerThread(threadId); -} - -dgThreadHive::dgThreadHive(dgMemoryAllocator* const allocator) - :m_parentThread(NULL) - ,m_workerThreads(NULL) - ,m_allocator(allocator) - ,m_syncLock(0) - ,m_jobsCount(0) - ,m_workerThreadsCount(0) - ,m_globalCriticalSection(0) -{ -} - -dgThreadHive::~dgThreadHive() -{ - DestroyThreads(); -} - -void dgThreadHive::SetParentThread(dgThread* const mastertThread) -{ - m_parentThread = mastertThread; -} - -void dgThreadHive::OnBeginWorkerThread(dgInt32 threadId) -{ -} - -void dgThreadHive::OnEndWorkerThread(dgInt32 threadId) -{ -} - -void dgThreadHive::BeginSection() -{ - if (m_workerThreadsCount) { - //DG_TRACKTIME(); - for (dgInt32 i = 0; i < m_workerThreadsCount; i++) { - m_workerThreads[i].m_workerSemaphore.Release(); - } - m_parentThread->Wait(m_workerThreadsCount, m_beginSectionSemaphores); - } -} - -void dgThreadHive::EndSection() -{ - if (m_workerThreadsCount) { - //DG_TRACKTIME(); - for (dgInt32 i = 0; i < m_workerThreadsCount; i++) { - dgInterlockedExchange(&m_workerThreads[i].m_concurrentWork, 0); - } - m_parentThread->Wait(m_workerThreadsCount, m_endSectionSemaphores); - } -} - -void dgThreadHive::QueueJob(dgWorkerThreadTaskCallback callback, void* const context0, void* const context1, const char* const functionName) -{ - if (!m_workerThreadsCount) { - //DG_TRACKTIME(functionName); - callback(context0, context1, 0); - } else { - dgInt32 workerTreadEntry = m_jobsCount % m_workerThreadsCount; - #ifdef DG_USE_THREAD_EMULATION - //DG_TRACKTIME(functionName); - callback(context0, context1, workerTreadEntry); - #else - dgInt32 index = m_workerThreads[workerTreadEntry].PushJob(dgThreadJob(context0, context1, callback, functionName)); - if (index >= DG_THREAD_POOL_JOB_SIZE) { - dgAssert(0); - SynchronizationBarrier(); - } - #endif - } - m_jobsCount++; -} - -void dgThreadHive::SetThreadsCount(dgInt32 threads) -{ - DestroyThreads(); - - m_workerThreadsCount = dgMin(threads, DG_MAX_THREADS_HIVE_COUNT); - if (m_workerThreadsCount == 1) { - m_workerThreadsCount = 0; - } - - if (m_workerThreadsCount) { - m_workerThreads = new (m_allocator) dgWorkerThread[dgUnsigned32(m_workerThreadsCount)]; - - for (dgInt32 i = 0; i < m_workerThreadsCount; i++) { - char name[256]; - sprintf(name, "dgWorkerThread%d", i); - m_workerThreads[i].SetUp(m_allocator, name, i, this); - } - } -} - -void dgThreadHive::SynchronizationBarrier() -{ - if (m_workerThreadsCount) { - //DG_TRACKTIME(); - - #ifndef DG_USE_THREAD_EMULATION - m_syncLock = m_workerThreadsCount; - for (dgInt32 i = 0; i < m_workerThreadsCount; i++) { - dgInterlockedExchange(&m_workerThreads[i].m_pendingWork, 1); - } - while (dgInterlockedTest(&m_syncLock, 0)) { - dgThreadYield(); - } - #endif - } - m_jobsCount = 0; -} - -void dgThreadHive::DestroyThreads() -{ - if (m_workerThreadsCount) { - delete[] m_workerThreads; - m_workerThreads = NULL; - m_workerThreadsCount = 0; - } -} - -#endif \ No newline at end of file diff --git a/thirdparty/src/newton/dgCore/dgThreadHive.h b/thirdparty/src/newton/dgCore/dgThreadHive.h deleted file mode 100644 index d5fc39e42..000000000 --- a/thirdparty/src/newton/dgCore/dgThreadHive.h +++ /dev/null @@ -1,283 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DG_THREAD_HIVE_H__ -#define __DG_THREAD_HIVE_H__ - -#include "dgThread.h" -#include "dgMemory.h" -#include "dgFastQueue.h" - -#define DG_THREAD_POOL_JOB_SIZE (256) -typedef void (*dgWorkerThreadTaskCallback) (void* const context0, void* const context1, dgInt32 threadID); - -#ifndef WIN32 -#define USE_UNIX_THREAD_POOL -#endif - -#ifdef USE_UNIX_THREAD_POOL - class dgThreadHive - { - public: - class dgThreadJob - { - public: - dgThreadJob() - { - } - - dgThreadJob (void* const context0, void* const context1, dgWorkerThreadTaskCallback callback, const char* const jobName) - :m_context0(context0) - ,m_context1(context1) - ,m_callback(callback) - ,m_jobName(jobName) - { - } - - void* m_context0; - void* m_context1; - dgWorkerThreadTaskCallback m_callback; - const char* m_jobName; - }; - - class dgWorkerThread: public dgThread - { - public: - DG_CLASS_ALLOCATOR(allocator) - - dgWorkerThread(); - ~dgWorkerThread(); - - bool IsBusy() const; - void SetUp(dgMemoryAllocator* const allocator, const char* const name, dgInt32 id, dgThreadHive* const hive); - virtual void Execute (dgInt32 threadId); - - dgInt32 PushJob(const dgThreadJob& job); - void RunNextJobInQueue(dgInt32 threadId); - - dgThreadHive* m_hive; - dgMemoryAllocator* m_allocator; - dgInt32 m_isBusy; - dgInt32 m_jobsCount; - dgSemaphore m_workerSemaphore; - dgThreadJob m_jobPool[DG_THREAD_POOL_JOB_SIZE]; - }; - - dgThreadHive(dgMemoryAllocator* const allocator); - virtual ~dgThreadHive(); - - virtual void OnBeginWorkerThread (dgInt32 threadId); - virtual void OnEndWorkerThread (dgInt32 threadId); - - void BeginSection() {} - void EndSection() {} - - void SetParentThread (dgThread* const mastertThread); - - void GlobalLock() const; - void GlobalUnlock() const; - - void GetIndirectLock (dgInt32* const criticalSectionLock) const; - void ReleaseIndirectLock (dgInt32* const criticalSectionLock) const; - - dgInt32 GetThreadCount() const; - dgInt32 GetMaxThreadCount() const; - void SetThreadsCount (dgInt32 count); - - virtual void QueueJob (dgWorkerThreadTaskCallback callback, void* const context0, void* const context1, const char* const functionName); - virtual void SynchronizationBarrier (); - - private: - void DestroyThreads(); - - dgThread* m_parentThread; - dgWorkerThread* m_workerThreads; - dgMemoryAllocator* m_allocator; - dgInt32 m_jobsCount; - dgInt32 m_workerThreadsCount; - mutable dgInt32 m_globalCriticalSection; - dgThread::dgSemaphore m_beginSectionSemaphores[DG_MAX_THREADS_HIVE_COUNT]; - }; - - DG_INLINE dgInt32 dgThreadHive::GetThreadCount() const - { - return m_workerThreadsCount ? m_workerThreadsCount : 1; - } - - DG_INLINE dgInt32 dgThreadHive::GetMaxThreadCount() const - { - return DG_MAX_THREADS_HIVE_COUNT; - } - - - DG_INLINE void dgThreadHive::GlobalLock() const - { - GetIndirectLock(&m_globalCriticalSection); - } - - DG_INLINE void dgThreadHive::GlobalUnlock() const - { - ReleaseIndirectLock(&m_globalCriticalSection); - } - - DG_INLINE void dgThreadHive::GetIndirectLock (dgInt32* const criticalSectionLock) const - { - if (m_workerThreadsCount) { - dgSpinLock(criticalSectionLock); - } - } - - DG_INLINE void dgThreadHive::ReleaseIndirectLock (dgInt32* const criticalSectionLock) const - { - if (m_workerThreadsCount) { - dgSpinUnlock(criticalSectionLock); - } - } - -#else - class dgThreadHive - { - - class dgThreadJob - { - public: - dgThreadJob() - { - } - - dgThreadJob(void* const context0, void* const context1, dgWorkerThreadTaskCallback callback, const char* const jobName) - :m_context0(context0) - ,m_context1(context1) - ,m_callback(callback) - ,m_jobName(jobName) - { - } - - void* m_context0; - void* m_context1; - const char* m_jobName; - dgWorkerThreadTaskCallback m_callback; - }; - - - class dgWorkerThread: public dgThread - { - public: - DG_CLASS_ALLOCATOR(allocator) - - dgWorkerThread(); - ~dgWorkerThread(); - - void SetUp(dgMemoryAllocator* const allocator, const char* const name, dgInt32 id, dgThreadHive* const hive); - virtual void Execute(dgInt32 threadId); - - dgInt32 PushJob(const dgThreadJob& job); - void RunNextJobInQueue(dgInt32 threadId); - void ConcurrentWork(dgInt32 threadId); - - // bool IsBusy() const; - // dgInt32 m_isBusy; - - dgSemaphore m_workerSemaphore; - dgThreadHive* m_hive; - dgMemoryAllocator* m_allocator; - dgInt32 m_concurrentWork; - dgInt32 m_pendingWork; - dgInt32 m_jobsCount; - dgThreadJob m_jobPool[DG_THREAD_POOL_JOB_SIZE]; - }; - - public: - dgThreadHive(dgMemoryAllocator* const allocator); - virtual ~dgThreadHive(); - - virtual void OnBeginWorkerThread(dgInt32 threadId); - virtual void OnEndWorkerThread(dgInt32 threadId); - - void BeginSection(); - void EndSection(); - - void SetParentThread(dgThread* const mastertThread); - - void GlobalLock() const; - void GlobalUnlock() const; - - void GetIndirectLock(dgInt32* const criticalSectionLock) const; - void ReleaseIndirectLock(dgInt32* const criticalSectionLock) const; - - dgInt32 GetThreadCount() const; - dgInt32 GetMaxThreadCount() const; - void SetThreadsCount(dgInt32 count); - - virtual void QueueJob(dgWorkerThreadTaskCallback callback, void* const context0, void* const context1, const char* const functionName); - virtual void SynchronizationBarrier(); - - private: - void DestroyThreads(); - - dgThread* m_parentThread; - dgWorkerThread* m_workerThreads; - dgMemoryAllocator* m_allocator; - dgInt32 m_syncLock; - dgInt32 m_jobsCount; - dgInt32 m_workerThreadsCount; - mutable dgInt32 m_globalCriticalSection; - dgThread::dgSemaphore m_endSectionSemaphores[DG_MAX_THREADS_HIVE_COUNT]; - dgThread::dgSemaphore m_beginSectionSemaphores[DG_MAX_THREADS_HIVE_COUNT]; - }; - - DG_INLINE dgInt32 dgThreadHive::GetThreadCount() const - { - return m_workerThreadsCount ? m_workerThreadsCount : 1; - } - - DG_INLINE dgInt32 dgThreadHive::GetMaxThreadCount() const - { - return DG_MAX_THREADS_HIVE_COUNT; - } - - DG_INLINE void dgThreadHive::GlobalLock() const - { - GetIndirectLock(&m_globalCriticalSection); - } - - DG_INLINE void dgThreadHive::GlobalUnlock() const - { - ReleaseIndirectLock(&m_globalCriticalSection); - } - - DG_INLINE void dgThreadHive::GetIndirectLock(dgInt32* const criticalSectionLock) const - { - if (m_workerThreadsCount) { - dgSpinLock(criticalSectionLock); - } - } - - DG_INLINE void dgThreadHive::ReleaseIndirectLock(dgInt32* const criticalSectionLock) const - { - if (m_workerThreadsCount) { - dgSpinUnlock(criticalSectionLock); - } - } -#endif - -#endif diff --git a/thirdparty/src/newton/dgCore/dgTree.cpp b/thirdparty/src/newton/dgCore/dgTree.cpp deleted file mode 100644 index 5ddcdada4..000000000 --- a/thirdparty/src/newton/dgCore/dgTree.cpp +++ /dev/null @@ -1,423 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" -#include "dgTree.h" - - -dgRedBackNode *dgRedBackNode::Minimum () const -{ - dgRedBackNode* ptr = (dgRedBackNode *)this; - for (; ptr->m_left; ptr = ptr->m_left){} - return ptr; -} - -dgRedBackNode *dgRedBackNode::Maximum () const -{ - dgRedBackNode* ptr = (dgRedBackNode *)this; - for (; ptr->m_right; ptr = ptr->m_right){} - return ptr; -} - - -dgRedBackNode *dgRedBackNode::Prev () const -{ - if (m_left) { - return m_left->Maximum (); - } - - dgRedBackNode* node = (dgRedBackNode *)this; - dgRedBackNode* ptr = m_parent; - for (; ptr && node == ptr->m_left; ptr = ptr->m_parent) { - node = ptr; - } - return ptr; - -} - -dgRedBackNode *dgRedBackNode::Next () const -{ - - if (m_right) { - return m_right->Minimum (); - } - - dgRedBackNode* node = (dgRedBackNode *)this; - dgRedBackNode* ptr = m_parent; - for (; ptr && node == ptr->m_right; ptr = ptr->m_parent) { - node = ptr; - } - return ptr; -} - -// rotate node me to left -void dgRedBackNode::RotateLeft(dgRedBackNode** const head) -{ - dgRedBackNode* const me = this; - dgRedBackNode* const child = me->m_right; - - //establish me->m_right link - me->m_right = child->m_left; - if (child->m_left != NULL) { - child->m_left->m_parent = me; - } - - // establish child->m_parent link - if (child != NULL) { - child->m_parent = me->m_parent; - } - if (me->m_parent) { - if (me == me->m_parent->m_left) { - me->m_parent->m_left = child; - } else { - me->m_parent->m_right = child; - } - } else { - *head = child; - } - - // link child and me - dgAssert (child); - child->m_left = me; - if (me != NULL) { - me->m_parent = child; - } -} - - -// rotate node me to right * -void dgRedBackNode::RotateRight(dgRedBackNode ** const head) -{ - dgRedBackNode* const me = this; - dgRedBackNode* const child = me->m_left; - - // establish me->m_left link - me->m_left = child->m_right; - if (child->m_right != NULL) { - child->m_right->m_parent = me; - } - - // establish child->m_parent link - if (child != NULL) { - child->m_parent = me->m_parent; - } - if (me->m_parent) { - if (me == me->m_parent->m_right) { - me->m_parent->m_right = child; - } else { - me->m_parent->m_left = child; - } - } else { - *head = child; - } - - // link me and child - dgAssert (child); - child->m_right = me; - if (me != NULL) { - me->m_parent = child; - } -} - - -// maintain Red-Black tree balance after inserting node ptr -void dgRedBackNode::InsertFixup(dgRedBackNode ** const head) -{ - dgRedBackNode* ptr = this; - // check Red-Black properties - while ((ptr != *head) && (ptr->m_parent->GetColor() == RED)) { - // we have a violation - dgAssert (ptr->m_parent); - dgAssert (ptr->m_parent->m_parent); - if (ptr->m_parent == ptr->m_parent->m_parent->m_left) { - dgRedBackNode* const tmp = ptr->m_parent->m_parent->m_right; - if (tmp && (tmp->GetColor() == RED)) { - // uncle is RED - ptr->m_parent->SetColor(BLACK); - tmp->SetColor(BLACK) ; - ptr->m_parent->m_parent->SetColor(RED) ; - ptr = ptr->m_parent->m_parent; - } else { - // uncle is BLACK - if (ptr == ptr->m_parent->m_right) { - // make ptr a left child - ptr = ptr->m_parent; - ptr->RotateLeft(head); - } - - ptr->m_parent->SetColor(BLACK); - if (ptr->m_parent->m_parent) { - ptr->m_parent->m_parent->SetColor(RED); - ptr->m_parent->m_parent->RotateRight(head); - } - } - } else { - dgAssert (ptr->m_parent == ptr->m_parent->m_parent->m_right); - // mirror image of above code - dgRedBackNode* const tmp = ptr->m_parent->m_parent->m_left; - if (tmp && (tmp->GetColor() == RED)) { - //uncle is RED - ptr->m_parent->SetColor(BLACK); - tmp->SetColor(BLACK) ; - ptr->m_parent->m_parent->SetColor(RED) ; - ptr = ptr->m_parent->m_parent; - } else { - // uncle is BLACK - if (ptr == ptr->m_parent->m_left) { - ptr = ptr->m_parent; - ptr->RotateRight(head); - } - ptr->m_parent->SetColor(BLACK); - if (ptr->m_parent->m_parent->GetColor() == BLACK) { - ptr->m_parent->m_parent->SetColor(RED) ; - ptr->m_parent->m_parent->RotateLeft (head); - } - } - } - } - (*head)->SetColor(BLACK); -} - - -//maintain Red-Black tree balance after deleting node x -void dgRedBackNode::RemoveFixup (dgRedBackNode* const thisNode, dgRedBackNode ** const head) -{ - dgRedBackNode* ptr = this; - dgRedBackNode* node = thisNode; - while ((node != *head) && (!node || node->GetColor() == BLACK)) { - if (node == ptr->m_left) { - if (!ptr) { - return; - } - dgRedBackNode* tmp = ptr->m_right; - if (!tmp) { - return; - } - if (tmp->GetColor() == RED) { - tmp->SetColor(BLACK) ; - ptr->SetColor(RED) ; - ptr->RotateLeft (head); - tmp = ptr->m_right; - //if (!ptr || !tmp) { - if (!tmp) { - return; - } - } - if ((!tmp->m_left || (tmp->m_left->GetColor() == BLACK)) && - (!tmp->m_right || (tmp->m_right->GetColor() == BLACK))) { - tmp->SetColor(RED); - node = ptr; - ptr = ptr->m_parent; - continue; - } else if (!tmp->m_right || (tmp->m_right->GetColor() == BLACK)) { - tmp->m_left->SetColor(BLACK); - tmp->SetColor(RED); - tmp->RotateRight (head); - tmp = ptr->m_right; - //if (!ptr || !tmp) { - if (!tmp) { - return; - } - } - tmp->SetColor (ptr->GetColor()); - if (tmp->m_right) { - tmp->m_right->SetColor(BLACK) ; - } - if (ptr) { - ptr->SetColor(BLACK) ; - ptr->RotateLeft (head); - } - node = *head; - - } else { - if (!ptr) { - return; - } - dgRedBackNode* tmp = ptr->m_left; - if (!tmp) { - return; - } - if (tmp->GetColor() == RED) { - tmp->SetColor(BLACK) ; - ptr->SetColor(RED) ; - ptr->RotateRight (head); - tmp = ptr->m_left; - //if (!ptr || !tmp) { - if (!tmp) { - return; - } - } - - if ((!tmp->m_right || (tmp->m_right->GetColor() == BLACK)) && - (!tmp->m_left || (tmp->m_left->GetColor() == BLACK))) { - tmp->SetColor(RED) ; - node = ptr; - ptr = ptr->m_parent; - continue; - } else if (!tmp->m_left || (tmp->m_left->GetColor() == BLACK)) { - tmp->m_right->SetColor(BLACK) ; - tmp->SetColor(RED) ; - tmp->RotateLeft (head); - tmp = ptr->m_left; - //if (!ptr || !tmp) { - if (!tmp) { - return; - } - } - tmp->SetColor (ptr->GetColor()); - if (tmp->m_left) { - tmp->m_left->SetColor(BLACK); - } - if (ptr) { - ptr->SetColor(BLACK) ; - ptr->RotateRight (head); - } - node = *head; - } - } - if (node) { - node->SetColor(BLACK); - } -} - -void dgRedBackNode::Unlink (dgRedBackNode ** const head) -{ -// dgRedBackNode *child; -// dgRedBackNode *endNode; -// dgRedBackNode *endNodeParent; -// dgRedBackNode::REDBLACK_COLOR oldColor; - - dgRedBackNode* const node = this; -// node->Kill(); - node->SetInTreeFlag(false); - - if (!node->m_left || !node->m_right) { - // y has a NULL node as a child - dgRedBackNode* const endNode = node; - - // x is y's only child - dgRedBackNode* child = endNode->m_right; - if (endNode->m_left) { - child = endNode->m_left; - } - - // remove y from the parent chain - if (child) { - child->m_parent = endNode->m_parent; - } - - if (endNode->m_parent) { - if (endNode == endNode->m_parent->m_left) { - endNode->m_parent->m_left = child; - } else { - endNode->m_parent->m_right = child; - } - } else { - *head = child; - } - - if (endNode->GetColor() == BLACK) { - endNode->m_parent->RemoveFixup (child, head); - } -// endNode->Release(); -// delete endNode; - - } else { - - // find tree successor with a NULL node as a child - dgRedBackNode* endNode = node->m_right; - while (endNode->m_left != NULL) { - endNode = endNode->m_left; - } - - dgAssert (endNode); - dgAssert (endNode->m_parent); - dgAssert (!endNode->m_left); - - // x is y's only child - dgRedBackNode* const child = endNode->m_right; - - dgAssert ((endNode != node->m_right) || !child || (child->m_parent == endNode)); - - endNode->m_left = node->m_left; - node->m_left->m_parent = endNode; - - dgRedBackNode* endNodeParent = endNode; - if (endNode != node->m_right) { - if (child) { - child->m_parent = endNode->m_parent; - } - endNode->m_parent->m_left = child; - endNode->m_right = node->m_right; - node->m_right->m_parent = endNode; - endNodeParent = endNode->m_parent; - } - - - if (node == *head) { - *head = endNode; - } else if (node == node->m_parent->m_left) { - node->m_parent->m_left = endNode; - } else { - node->m_parent->m_right = endNode; - } - endNode->m_parent = node->m_parent; - - dgRedBackNode::REDBLACK_COLOR oldColor = endNode->GetColor(); - endNode->SetColor (node->GetColor()); - node->SetColor (oldColor); - - if (oldColor == BLACK) { - endNodeParent->RemoveFixup (child, head); - } -// node->Release(); -// delete node; - } -} - -void dgRedBackNode::Remove (dgRedBackNode ** const head) -{ - Unlink (head); - delete this; -} - -void dgRedBackNode::RemoveAllLow () -{ - if (m_left) { - m_left->RemoveAllLow(); - } - if (m_right) { - m_right->RemoveAllLow (); - } - SetInTreeFlag(false); -// Kill(); -// Release(); - delete this; -} - -void dgRedBackNode::RemoveAll () -{ - dgRedBackNode* root = this; - for (; root->m_parent; root = root->m_parent); - root->RemoveAllLow(); -} - - diff --git a/thirdparty/src/newton/dgCore/dgTree.h b/thirdparty/src/newton/dgCore/dgTree.h deleted file mode 100644 index a89361d27..000000000 --- a/thirdparty/src/newton/dgCore/dgTree.h +++ /dev/null @@ -1,848 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgTree__ -#define __dgTree__ - -#include "dgStdafx.h" -#include "dgRef.h" -#include "dgDebug.h" -#include "dgMemory.h" - - - -// Note: this is a low level class for dgTree use only -// unpredictable result will happen if you attempt to manipulate -// any member of this class -class dgRedBackNode -{ - public: - enum REDBLACK_COLOR - { - RED = true, - BLACK = false - }; - - DG_CLASS_ALLOCATOR(allocator) - - dgRedBackNode() - { - } - - virtual ~dgRedBackNode () - { - } - - void RemoveAllLow (); - void RotateLeft(dgRedBackNode** const head); - void RotateRight(dgRedBackNode** const head); - void RemoveFixup (dgRedBackNode* const node, dgRedBackNode* * const head); - - dgRedBackNode* GetLeft() const; - dgRedBackNode* GetRight() const; - dgRedBackNode* GetParent() const; - - dgRedBackNode (dgRedBackNode* const parent); - inline void Initdata (dgRedBackNode* const parent); - inline void SetColor (REDBLACK_COLOR color); - REDBLACK_COLOR GetColor () const; - dgUnsigned32 IsInTree () const; - inline void SetInTreeFlag (dgUnsigned32 flag); - - void RemoveAll (); - dgRedBackNode* Prev() const; - dgRedBackNode* Next() const; - dgRedBackNode* Minimum() const; - dgRedBackNode* Maximum() const; - void Remove (dgRedBackNode** const head); - void Unlink (dgRedBackNode** const head); - void InsertFixup(dgRedBackNode** const head); - - dgRedBackNode* m_left; - dgRedBackNode* m_right; - dgRedBackNode* m_parent; - dgUnsigned32 m_color : 1; - dgUnsigned32 m_inTree : 1; -// dgUnsigned32 m_pad[2]; -}; - -template<class OBJECT, class KEY> -class dgTree -{ - public: - class dgTreeNode: public dgRedBackNode - { - dgTreeNode ( - const OBJECT &info, - const KEY &key, - dgTreeNode* parentNode) - :dgRedBackNode(parentNode), m_info (info), m_key (key) - { -// dgAssert ((dgUnsigned64 (&m_info) & 0x0f) == 0); - } - - ~dgTreeNode () - { - } - - dgTreeNode* GetLeft () const - { - return (dgTreeNode* )dgRedBackNode::m_left; - } - - dgTreeNode* GetRight () const - { - return (dgTreeNode* )dgRedBackNode::m_right; - } - - dgTreeNode* GetParent () - { - return (dgTreeNode* )dgRedBackNode::m_parent; - } - - void SetLeft (dgTreeNode* const node) - { - dgRedBackNode::m_left = node; - } - - void SetRight (dgTreeNode* const node) - { - dgRedBackNode::m_right = node; - } - - void SetParent (dgTreeNode* const node) - { - dgRedBackNode::m_parent = node; - } - - public: - const KEY& GetKey() const - { - return m_key; - } - - OBJECT& GetInfo() - { - return m_info; - } - - private: - OBJECT m_info; - KEY m_key; - friend class dgTree<OBJECT, KEY>; - - }; - - class Iterator - { - - public: - Iterator(const dgTree<OBJECT,KEY> &me) - { - m_ptr = NULL; - m_tree = &me; - } - - ~Iterator() - { - } - - void Begin() - { - m_ptr = m_tree->Minimum(); - } - - void End() - { - m_ptr = m_tree->Maximum(); - } - - void Set (dgTreeNode* const node) - { - m_ptr = node; - } - - operator dgInt32() const - { - return m_ptr != NULL; - } - - void operator++ () - { - dgAssert (m_ptr); - m_ptr = m_ptr->Next(); - } - - void operator++ (dgInt32) - { - dgAssert (m_ptr); - m_ptr = m_ptr->Next(); - } - - void operator-- () - { - dgAssert (m_ptr); - m_ptr = m_ptr->Prev(); - } - - void operator-- (dgInt32) - { - dgAssert (m_ptr); - m_ptr = m_ptr->Prev(); - } - - OBJECT &operator* () const - { - return ((dgTreeNode*)m_ptr)->GetInfo(); - } - - dgTreeNode* GetNode() const - { - return (dgTreeNode*)m_ptr; - } - - KEY GetKey () const - { - dgTreeNode* const tmp = (dgTreeNode*)m_ptr; - return tmp ? tmp->GetKey() : KEY(0); - } - - private: - dgRedBackNode* m_ptr; - const dgTree* m_tree; - - }; - - - // *********************************************************** - // member functions - // *********************************************************** - public: - DG_CLASS_ALLOCATOR(allocator) - -// dgTree (); - dgTree (dgMemoryAllocator* const allocator); - virtual ~dgTree (); - - dgMemoryAllocator* GetAllocator () const; - void SetAllocator (dgMemoryAllocator* const allocator); - - - operator dgInt32() const; - dgInt32 GetCount() const; - - dgTreeNode* GetRoot () const; - dgTreeNode* Minimum () const; - dgTreeNode* Maximum () const; - - dgTreeNode* Find (KEY key) const; - dgTreeNode* FindGreater (KEY key) const; - dgTreeNode* FindGreaterEqual (KEY key) const; - dgTreeNode* FindLessEqual (KEY key) const; - - dgTreeNode* GetNodeFromInfo (OBJECT &info) const; - - dgTreeNode* Insert (const OBJECT &element, KEY key, bool& elementWasInTree); - dgTreeNode* Insert (const OBJECT &element, KEY key); - dgTreeNode* Insert (dgTreeNode* const node, KEY key); - - dgTreeNode* Replace (OBJECT &element, KEY key); - dgTreeNode* ReplaceKey (KEY oldKey, KEY newKey); - dgTreeNode* ReplaceKey (dgTreeNode* const node, KEY key); - - void Remove (KEY key); - void Remove (dgTreeNode* const node); - void RemoveAll (); - - void Unlink (dgTreeNode* const node); - void SwapInfo (dgTree& tree); - - bool SanityCheck () const; - - // *********************************************************** - // member variables - // *********************************************************** - private: - dgInt32 m_count; - dgTreeNode* m_head; - dgMemoryAllocator* m_allocator; - - dgInt32 CompareKeys (const KEY &key0, const KEY &key1) const; - bool SanityCheck (dgTreeNode* const ptr, dgInt32 height) const; - - friend class dgTreeNode; -}; - - -inline dgRedBackNode::dgRedBackNode (dgRedBackNode* const parent) -{ - Initdata (parent); -} - -inline void dgRedBackNode::Initdata (dgRedBackNode* const parent) -{ - SetColor (RED); - SetInTreeFlag (true); - m_left = NULL; - m_right = NULL; - m_parent = parent; -} - -inline void dgRedBackNode::SetColor (dgRedBackNode::REDBLACK_COLOR color) -{ - m_color = color; -} - - - -inline dgRedBackNode::REDBLACK_COLOR dgRedBackNode::GetColor () const -{ - return REDBLACK_COLOR (m_color); -} - - -inline void dgRedBackNode::SetInTreeFlag (dgUnsigned32 flag) -{ - m_inTree = flag; -} - -inline dgUnsigned32 dgRedBackNode::IsInTree () const -{ - return m_inTree; -} - -/* -template<class OBJECT, class KEY> -dgTree<OBJECT, KEY>::dgTree () -{ - m_count = 0; - m_head = NULL; - m_allocator = NULL; -} -*/ - -template<class OBJECT, class KEY> -dgTree<OBJECT, KEY>::dgTree (dgMemoryAllocator* const allocator) - :m_count(0) - ,m_head(NULL) - ,m_allocator(allocator) -{ -} - - -template<class OBJECT, class KEY> -dgTree<OBJECT, KEY>::~dgTree () -{ - RemoveAll(); -} - -template<class OBJECT, class KEY> -dgMemoryAllocator* dgTree<OBJECT, KEY>::GetAllocator () const -{ - return m_allocator; -} - -template<class OBJECT, class KEY> -void dgTree<OBJECT, KEY>::SetAllocator (dgMemoryAllocator* const allocator) -{ - if ((m_count == 0) && (m_allocator == NULL)) { - m_allocator = allocator; - } -} - - -template<class OBJECT, class KEY> -dgTree<OBJECT, KEY>::operator dgInt32() const -{ - return m_head != NULL; -} - -template<class OBJECT, class KEY> -dgInt32 dgTree<OBJECT, KEY>::GetCount() const -{ - return m_count; -} - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::Minimum () const -{ - return m_head ? (dgTreeNode* )m_head->Minimum() : NULL; -} - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::Maximum () const -{ - return m_head ? (dgTreeNode* )m_head->Maximum() : NULL; -} - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::GetRoot () const -{ - return m_head; -} - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::Find (KEY key) const -{ - if (m_head == NULL) { - return NULL; - } - - dgTreeNode* ptr = m_head; - while (ptr != NULL) { - if (key < ptr->m_key) { - dgAssert (CompareKeys (ptr->m_key, key) == -1) ; - ptr = ptr->GetLeft(); - } else if (key > ptr->m_key) { - dgAssert (CompareKeys (ptr->m_key, key) == 1) ; - ptr = ptr->GetRight(); - } else { - dgAssert (CompareKeys (ptr->m_key, key) == 0) ; - break; - } - } - return ptr; -} - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::GetNodeFromInfo (OBJECT &info) const -{ - dgTreeNode* const node = (dgTreeNode* ) &info; - dgInt64 offset = ((char*) &node->m_info) - ((char *) node); - dgTreeNode* const retnode = (dgTreeNode* ) (((char *) node) - offset); - - dgAssert (retnode->IsInTree ()); - dgAssert (&retnode->GetInfo () == &info); - return (retnode->IsInTree ()) ? retnode : NULL; - -} - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::FindGreater (KEY key) const -{ - if (m_head == NULL) { - return NULL; - } - - dgTreeNode* prev = NULL; - dgTreeNode* ptr = m_head; - - while (ptr != NULL) { - if (key < ptr->m_key) { - prev = ptr; - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - if (prev) { - Iterator iter (*this); - for (iter.Begin(); iter.GetNode() != prev; iter ++) { - KEY key1 = iter.GetKey(); - dgAssert (key1 <= key); - } - for (; iter.GetNode(); iter ++) { - KEY key1 = iter.GetKey(); - dgAssert (key1 > key); - } - } -#endif - - return (dgTreeNode* )prev; -} - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::FindGreaterEqual (KEY key) const -{ - if (m_head == NULL) { - return NULL; - } - - dgTreeNode* prev = NULL; - dgTreeNode* ptr = m_head; - - while (ptr != NULL) { - if (key == ptr->m_key) { - return ptr; - } - if (key < ptr->m_key) { - prev = ptr; - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - if (prev) { - Iterator iter (*this); - for (iter.Begin(); iter.GetNode() != prev; iter ++) { - KEY key1 = iter.GetKey(); - dgAssert (key1 <= key); - } - for (; iter.GetNode(); iter ++) { - KEY key1 = iter.GetKey(); - dgAssert (key1 >= key); - } - } -#endif - - return (dgTreeNode* )prev; -} - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::FindLessEqual (KEY key) const -{ - if (m_head == NULL) { - return NULL; - } - - dgTreeNode* prev = NULL; - dgTreeNode* ptr = m_head; - - while (ptr != NULL) { - if (key == ptr->m_key) { - return ptr; - } - - if (key < ptr->m_key) { - ptr = ptr->GetLeft(); - } else { - prev = ptr; - ptr = ptr->GetRight(); - } - - } - -#ifdef __ENABLE_DG_CONTAINERS_SANITY_CHECK - if (prev) { - Iterator iter (*this); - for (iter.End(); iter.GetNode() != prev; iter --) { - KEY key1 = iter.GetKey(); - dgAssert (key1 >= key); - } - for (; iter.GetNode(); iter --) { - KEY key1 = iter.GetKey(); - dgAssert (key1 < key); - } - } -#endif - - return (dgTreeNode* )prev; -} - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::Insert (const OBJECT &element, KEY key, bool& elementWasInTree) -{ - dgTreeNode* parent = NULL; - dgTreeNode* ptr = m_head; - dgInt32 val = 0; - elementWasInTree = false; - while (ptr != NULL) { - parent = ptr; - - if (key < ptr->m_key) { - dgAssert (CompareKeys (ptr->m_key, key) == -1) ; - val = -1; - ptr = ptr->GetLeft(); - } else if (key > ptr->m_key) { - dgAssert (CompareKeys (ptr->m_key, key) == 1) ; - val = 1; - ptr = ptr->GetRight(); - } else { - dgAssert (CompareKeys (ptr->m_key, key) == 0) ; - elementWasInTree = true; - return ptr; - } - } - - m_count ++; - dgAssert (m_allocator); - ptr = new (m_allocator) dgTreeNode (element, key, parent); - if (!parent) { - m_head = ptr; - } else { - if (val < 0) { - parent->m_left = ptr; - } else { - parent->m_right = ptr; - } - } - - dgTreeNode** const headPtr = (dgTreeNode**) &m_head; -// ptr->InsertFixup ((dgRedBackNode**)&m_head); - ptr->InsertFixup ((dgRedBackNode**)headPtr); - return ptr; -} - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::Insert (const OBJECT &element, KEY key) -{ - bool foundState; - - dgTreeNode* const node = Insert (element, key, foundState); - if (foundState) { - return NULL; - } - return node; -} - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::Insert (typename dgTree<OBJECT, KEY>::dgTreeNode* const node, KEY key) -{ - dgInt32 val = 0; - dgTreeNode* ptr = m_head; - dgTreeNode* parent = NULL; - while (ptr != NULL) { - parent = ptr; -// val = CompareKeys (ptr->m_key, key); -// if (val < 0) { -// ptr = ptr->GetLeft(); -// } else if (val > 0) { -// ptr = ptr->GetRight(); -// } else { -// return NULL; -// } - - if (key < ptr->m_key) { - dgAssert (CompareKeys (ptr->m_key, key) == -1) ; - val = -1; - ptr = ptr->GetLeft(); - } else if (key > ptr->m_key) { - dgAssert (CompareKeys (ptr->m_key, key) == 1) ; - val = 1; - ptr = ptr->GetRight(); - } else { - dgAssert (CompareKeys (ptr->m_key, key) == 0) ; - return NULL; - } - } - - m_count ++; - - ptr = node; - ptr->m_key = key; - ptr->Initdata (parent); - - if (!parent) { - m_head = ptr; - } else { - if (val < 0) { - parent->m_left = ptr; - } else { - parent->m_right = ptr; - } - } - - dgTreeNode** const headPtr = (dgTreeNode**) &m_head; -// ptr->InsertFixup ((dgRedBackNode**)&m_head); - ptr->InsertFixup ((dgRedBackNode**)headPtr); - return ptr; -} - - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::Replace (OBJECT &element, KEY key) -{ - dgTreeNode* parent = NULL; - dgTreeNode* ptr = m_head; - dgInt32 val = 0; - while (ptr != NULL) { - parent = ptr; - - dgAssert (0); - val = CompareKeys (ptr->m_key, key); - if (val == 0) { - ptr->m_info = element; - return ptr; - } - if (val < 0) { - ptr = ptr->GetLeft(); - } else { - ptr = ptr->GetRight(); - } - } - - dgAssert (m_allocator); - ptr = new (m_allocator) dgTreeNode (element, key, parent); - if (!parent) { - m_head = ptr; - } else { - if (val < 0) { - parent->m_left = ptr; - } else { - parent->m_right = ptr; - } - } - - dgTreeNode** const headPtr = (dgTreeNode**) &m_head; -// ptr->InsertFixup ((dgRedBackNode**)&m_head); - ptr->InsertFixup ((dgRedBackNode**)headPtr ); - return ptr; -} - - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::ReplaceKey (typename dgTree<OBJECT, KEY>::dgTreeNode* const node, KEY key) -{ - Unlink (node); - dgTreeNode* const ptr = Insert (node, key); - dgAssert (ptr); - return ptr; -} - -template<class OBJECT, class KEY> -typename dgTree<OBJECT, KEY>::dgTreeNode* dgTree<OBJECT, KEY>::ReplaceKey (KEY oldKey, KEY newKey) -{ - dgTreeNode* const node = Find (oldKey); - return node ? ReplaceKey (node, newKey) : NULL; -} - -template<class OBJECT, class KEY> -void dgTree<OBJECT, KEY>::Unlink (typename dgTree<OBJECT, KEY>::dgTreeNode* const node) -{ - m_count --; - - dgTreeNode** const headPtr = (dgTreeNode**) &m_head; - node->Unlink ((dgRedBackNode**)headPtr); - dgAssert (!Find (node->GetKey())); -} - - -template<class OBJECT, class KEY> -void dgTree<OBJECT, KEY>::Remove (typename dgTree<OBJECT, KEY>::dgTreeNode* const node) -{ - m_count --; - dgTreeNode** const headPtr = (dgTreeNode**) &m_head; - node->Remove ((dgRedBackNode**)headPtr); -} - -template<class OBJECT, class KEY> -void dgTree<OBJECT, KEY>::Remove (KEY key) -{ - dgTreeNode* node; - - // find node in tree - node = Find (key); - if (node == NULL) { - return; - } - Remove (node); -} - -template<class OBJECT, class KEY> -void dgTree<OBJECT, KEY>::RemoveAll () -{ - if (m_head) { - m_count = 0; - m_head->RemoveAll (); - m_head = NULL; - } -} - -template<class OBJECT, class KEY> -bool dgTree<OBJECT, KEY>::SanityCheck () const -{ - return SanityCheck (m_head, 0); -} - - -template<class OBJECT, class KEY> -bool dgTree<OBJECT, KEY>::SanityCheck (typename dgTree<OBJECT, KEY>::dgTreeNode* const ptr, dgInt32 height) const -{ - if (!ptr) { - return true; - } - - if (!ptr->IsInTree()) { - return false; - } - - if (ptr->m_left) { - if (CompareKeys (ptr->m_key, ptr->GetLeft()->m_key) > 0) { - return false; - } - } - - if (ptr->m_right) { - if (CompareKeys (ptr->m_key, ptr->GetRight()->m_key) < 0) { - return false; - } - } - - if (ptr->GetColor() == dgTreeNode::BLACK) { - height ++; - } else if (!((!ptr->m_left || (ptr->m_left->GetColor() == dgTreeNode::BLACK)) && - (!ptr->m_right || (ptr->m_right->GetColor() == dgTreeNode::BLACK)))) { - return false; - } - - if (!ptr->m_left && !ptr->m_right) { - dgInt32 bh = 0; - for (dgTreeNode* x = ptr; x; x = x->GetParent()) { - if (x->GetColor() == dgTreeNode::BLACK) { - bh ++; - } - } - if (bh != height) { - return false; - } - } - - if (ptr->m_left && !SanityCheck (ptr->GetLeft(), height)) { - return false; - } - - if (ptr->m_right && !SanityCheck (ptr->GetRight(), height)) { - return false; - } - return true; -} - - -template<class OBJECT, class KEY> -dgInt32 dgTree<OBJECT, KEY>::CompareKeys (const KEY &key0, const KEY &key1) const -{ - if (key1 < key0) { - return - 1; - } - if (key1 > key0) { - return 1; - } - return 0; -} - -template<class OBJECT, class KEY> -void dgTree<OBJECT, KEY>::SwapInfo (dgTree<OBJECT, KEY>& tree) -{ - dgSwap (m_head, tree.m_head); - dgSwap (m_count, tree.m_count); -} - -//template<class OBJECT, class KEY> dgInt32 dgTree<OBJECT,KEY>::m_size = 0; -//template<class OBJECT, class KEY> dgMemoryAllocator* dgTree<OBJECT,KEY>::m_staticAllocator = NULL; - - -#endif - - diff --git a/thirdparty/src/newton/dgCore/dgTypes.cpp b/thirdparty/src/newton/dgCore/dgTypes.cpp deleted file mode 100644 index 5843e2053..000000000 --- a/thirdparty/src/newton/dgCore/dgTypes.cpp +++ /dev/null @@ -1,548 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgStdafx.h" - -#include "dgTypes.h" -#include "dgDebug.h" -#include "dgVector.h" -#include "dgMemory.h" -#include "dgStack.h" - - -dgUnsigned64 dgGetTimeInMicrosenconds() -{ -#if (defined (_MSC_VER) || defined (_MINGW_32_VER) || defined (_MINGW_64_VER)) - static LARGE_INTEGER frequency; - static LARGE_INTEGER baseCount; - if (!frequency.QuadPart) { - QueryPerformanceFrequency(&frequency); - QueryPerformanceCounter (&baseCount); - } - - LARGE_INTEGER count; - QueryPerformanceCounter (&count); - count.QuadPart -= baseCount.QuadPart; - dgUnsigned64 ticks = dgUnsigned64 (count.QuadPart * LONGLONG (1000000) / frequency.QuadPart); - return ticks; - -#elif (defined (_POSIX_VER) || defined (_POSIX_VER_64) || defined (ANDROID)) - - timespec ts; - static dgUnsigned64 baseCount = 0; - if (!baseCount) { - clock_gettime(CLOCK_REALTIME, &ts); - baseCount = dgUnsigned64 (ts.tv_sec) * 1000000 + ts.tv_nsec / 1000; - } - clock_gettime(CLOCK_REALTIME, &ts); // Works on Linux - return dgUnsigned64 (ts.tv_sec) * 1000000 + ts.tv_nsec / 1000 - baseCount; - -#elif defined (_MACOSX_VER) - timeval tp; - static dgUnsigned64 baseCount = 0; - if (!baseCount) { - gettimeofday(&tp, NULL); - baseCount = dgUnsigned64 (tp.tv_sec) * 1000000 + tp.tv_usec; - } - - gettimeofday(&tp, NULL); - dgUnsigned64 microsecunds = dgUnsigned64 (tp.tv_sec) * 1000000 + tp.tv_usec; - return microsecunds - baseCount; -#else - #error "dgGetTimeInMicrosenconds implementation required" - return 0; -#endif -} - - -dgFloat64 dgRoundToFloat(dgFloat64 val) -{ - dgInt32 exp; - dgFloat64 mantissa = frexp(val, &exp); - - const dgFloat64 power = 1 << 23; - const dgFloat64 invPower = dgFloat64(1.0f) / power; - mantissa = floor(mantissa * power) * invPower; - - dgFloat64 val1 = ldexp(mantissa, exp); - return val1; -} - - -void dgGetMinMax (dgBigVector &minOut, dgBigVector &maxOut, const dgFloat64* const vertexArray, dgInt32 vCount, dgInt32 strideInBytes) -{ - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat64)); - const dgFloat64* vArray = vertexArray + stride; - - dgAssert (stride >= 3); - minOut = dgBigVector (vertexArray[0], vertexArray[1], vertexArray[2], dgFloat64 (0.0f)); - maxOut = dgBigVector (vertexArray[0], vertexArray[1], vertexArray[2], dgFloat64 (0.0f)); - - for (dgInt32 i = 1; i < vCount; i ++) { - minOut.m_x = dgMin (minOut.m_x, vArray[0]); - minOut.m_y = dgMin (minOut.m_y, vArray[1]); - minOut.m_z = dgMin (minOut.m_z, vArray[2]); - - maxOut.m_x = dgMax (maxOut.m_x, vArray[0]); - maxOut.m_y = dgMax (maxOut.m_y, vArray[1]); - maxOut.m_z = dgMax (maxOut.m_z, vArray[2]); - - vArray += stride; - } -} - - - - -static inline dgInt32 cmp_vertex (const dgFloat64* const v1, const dgFloat64* const v2, dgInt32 firstSortAxis) -{ - if (v1[firstSortAxis] < v2[firstSortAxis]) { - return -1; - } - - if (v1[firstSortAxis] > v2[firstSortAxis]){ - return 1; - } - - return 0; -} - -static dgInt32 SortVertices (dgFloat64* const vertexList, dgInt32 stride, dgInt32 compareCount, dgInt32 vertexCount, dgFloat64 tolerance) -{ - dgBigVector xc(dgFloat64(0.0f)); - dgBigVector x2c(dgFloat64(0.0f)); - dgBigVector minP (dgFloat64 (1.0e10f), dgFloat64 (1.0e10f), dgFloat64 (1.0e10f), dgFloat64 (0.0f)); - dgBigVector maxP (dgFloat64 (-1.0e10f), dgFloat64 (-1.0e10f), dgFloat64 (-1.0e10f), dgFloat64 (0.0f)); - - for (dgInt32 k = 0, i = 0; i < vertexCount; i ++) { - - dgBigVector x(vertexList[k + 2], vertexList[k + 3], vertexList[k + 4], dgFloat64(0.0f)); - xc += x; - x2c += x * x; - minP = minP.GetMin(x); - maxP = maxP.GetMax(x); - k += stride; - } - - dgBigVector del (maxP - minP); - dgFloat64 minDist = dgMin (del.m_x, del.m_y, del.m_z); - if (minDist < dgFloat64 (1.0e-3f)) { - minDist = dgFloat64 (1.0e-3f); - } - - dgFloat64 tol = tolerance * minDist + dgFloat64 (1.0e-12f); - dgFloat64 sweptWindow = dgFloat64 (2.0f) * tol; - sweptWindow += dgFloat64 (1.0e-4f); - - x2c = x2c.Scale (dgFloat32 (vertexCount)) - xc * xc; - - dgInt32 firstSortAxis = 2; - if ((x2c.m_y >= x2c.m_x) && (x2c.m_y >= x2c.m_z)) { - firstSortAxis = 3; - } else if ((x2c.m_z >= x2c.m_x) && (x2c.m_z >= x2c.m_y)) { - firstSortAxis = 4; - } - - dgInt32 stack[1024][2]; - stack[0][0] = 0; - stack[0][1] = vertexCount - 1; - dgInt32 stackIndex = 1; - while (stackIndex) { - stackIndex --; - dgInt32 lo = stack[stackIndex][0]; - dgInt32 hi = stack[stackIndex][1]; - if ((hi - lo) > 8) { - dgInt32 i = lo; - dgInt32 j = hi; - dgFloat64 val[64]; - memcpy (val, &vertexList[((lo + hi) >> 1) * stride], stride * sizeof (dgFloat64)); - do { - while (cmp_vertex (&vertexList[i * stride], val, firstSortAxis) < 0) i ++; - while (cmp_vertex (&vertexList[j * stride], val, firstSortAxis) > 0) j --; - - if (i <= j) { - if (i < j) { - dgFloat64 tmp[64]; - memcpy (tmp, &vertexList[i * stride], stride * sizeof (dgFloat64)); - memcpy (&vertexList[i * stride], &vertexList[j * stride], stride * sizeof (dgFloat64)); - memcpy (&vertexList[j * stride], tmp, stride * sizeof (dgFloat64)); - } - i++; - j--; - } - } while (i <= j); - - if (i < hi) { - stack[stackIndex][0] = i; - stack[stackIndex][1] = hi; - stackIndex ++; - } - if (lo < j) { - stack[stackIndex][0] = lo; - stack[stackIndex][1] = j; - stackIndex ++; - } - dgAssert (stackIndex < dgInt32 (sizeof (stack) / (2 * sizeof (stack[0][0])))); - } else { - for (dgInt32 i = lo + 1; i <= hi ; i++) { - dgFloat64 tmp[64]; - memcpy (tmp, &vertexList[i * stride], stride * sizeof (dgFloat64)); - - dgInt32 j = i; - for (; j && (cmp_vertex (&vertexList[(j - 1) * stride], tmp, firstSortAxis) > 0); j --) { - memcpy (&vertexList[j * stride], &vertexList[(j - 1)* stride], stride * sizeof (dgFloat64)); - } - memcpy (&vertexList[j * stride], tmp, stride * sizeof (dgFloat64)); - } - } - } - - -#ifdef _DEBUG - for (dgInt32 i = 0; i < (vertexCount - 1); i ++) { - dgAssert (cmp_vertex (&vertexList[i * stride], &vertexList[(i + 1) * stride], firstSortAxis) <= 0); - } -#endif - - dgInt32 count = 0; - for (dgInt32 i = 0; i < vertexCount; i ++) { - dgInt32 m = i * stride; - dgInt32 index = dgInt32 (vertexList[m + 0]); - if (index == dgInt32 (0xffffffff)) { - dgFloat64 swept = vertexList[m + firstSortAxis] + sweptWindow; - dgInt32 k = i * stride + stride; - for (dgInt32 i1 = i + 1; i1 < vertexCount; i1 ++) { - - index = dgInt32 (vertexList[k + 0]); - if (index == dgInt32 (0xffffffff)) { - dgFloat64 val = vertexList[k + firstSortAxis]; - if (val >= swept) { - break; - } - bool test = true; - for (dgInt32 t = 0; test && (t < compareCount); t ++) { - val = fabs (vertexList[m + t + 2] - vertexList[k + t + 2]); - test = test && (val <= tol); - } - if (test) { - vertexList[k + 0] = dgFloat64 (count); - } - } - k += stride; - } - - dgAssert (&vertexList[count * stride + 2] <= &vertexList[m + 2]); - if (&vertexList[count * stride + 2] < &vertexList[m + 2]) { - memcpy (&vertexList[count * stride + 2], &vertexList[m + 2], (stride - 2) * sizeof (dgFloat64)); - } - vertexList[m + 0] = dgFloat64 (count); - count ++; - } - } - - return count; -} - - -static dgInt32 QuickSortVertices (dgFloat64* const vertList, dgInt32 stride, dgInt32 compareCount, dgInt32 vertexCount, dgFloat64 tolerance) -{ - dgInt32 count = 0; - if (vertexCount > (1024 * 256)) { - dgFloat64 x = dgFloat32 (0.0f); - dgFloat64 y = dgFloat32 (0.0f); - dgFloat64 z = dgFloat32 (0.0f); - dgFloat64 xd = dgFloat32 (0.0f); - dgFloat64 yd = dgFloat32 (0.0f); - dgFloat64 zd = dgFloat32 (0.0f); - - for (dgInt32 i = 0; i < vertexCount; i ++) { - dgFloat64 x0 = vertList[i * stride + 2]; - dgFloat64 y0 = vertList[i * stride + 3]; - dgFloat64 z0 = vertList[i * stride + 4]; - x += x0; - y += y0; - z += z0; - xd += x0 * x0; - yd += y0 * y0; - zd += z0 * z0; - } - - xd = vertexCount * xd - x * x; - yd = vertexCount * yd - y * y; - zd = vertexCount * zd - z * z; - - dgInt32 axis = 2; - dgFloat64 axisVal = x / vertexCount; - if ((yd > xd) && (yd > zd)) { - axis = 3; - axisVal = y / vertexCount; - } - if ((zd > xd) && (zd > yd)) { - axis = 4; - axisVal = z / vertexCount; - } - - dgInt32 i0 = 0; - dgInt32 i1 = vertexCount - 1; - do { - for ( ;vertList[i0 * stride + axis] < axisVal; i0 ++); - for ( ;vertList[i1 * stride + axis] > axisVal; i1 --); - if (i0 <= i1) { - for (dgInt32 i = 0; i < stride; i ++) { - dgSwap (vertList[i0 * stride + i], vertList[i1 * stride + i]); - } - i0 ++; - i1 --; - } - } while (i0 <= i1); - dgAssert (i0 < vertexCount); - - dgInt32 count0 = QuickSortVertices (&vertList[ 0 * stride], stride, compareCount, i0, tolerance); - dgInt32 count1 = QuickSortVertices (&vertList[i0 * stride], stride, compareCount, vertexCount - i0, tolerance); - - count = count0 + count1; - - for (dgInt32 i = 0; i < count1; i ++) { - memcpy (&vertList[(count0 + i) * stride + 2], &vertList[(i0 + i) * stride + 2], (stride - 2) * sizeof (dgFloat64)); - } - - - // dgFloat64* const indexPtr = (dgInt64*)vertList; - for (dgInt32 i = i0; i < vertexCount; i ++) { - // indexPtr[i * stride] += count0; - vertList[i * stride] += dgFloat64 (count0); - } - - } else { - count = SortVertices (vertList, stride, compareCount, vertexCount, tolerance); - } - - return count; -} - - -dgInt32 dgVertexListToIndexList (dgFloat64* const vertList, dgInt32 strideInBytes, dgInt32 compareCount, dgInt32 vertexCount, dgInt32* const indexListOut, dgFloat64 tolerance) -{ - dgSetPrecisionDouble precision; - - if (strideInBytes < 3 * dgInt32 (sizeof (dgFloat64))) { - return 0; - } - if (compareCount < 3) { - return 0; - } - dgAssert (compareCount <= dgInt32 (strideInBytes / sizeof (dgFloat64))); - dgAssert (strideInBytes == dgInt32 (sizeof (dgFloat64) * (strideInBytes / sizeof (dgFloat64)))); - - dgInt32 stride = strideInBytes / dgInt32 (sizeof (dgFloat64)); - dgInt32 stride2 = stride + 2; - - dgStack<dgFloat64>pool (stride2 * vertexCount); - dgFloat64* const tmpVertexList = &pool[0]; - - dgInt32 k = 0; - dgInt32 m = 0; - for (dgInt32 i = 0; i < vertexCount; i ++) { - memcpy (&tmpVertexList[m + 2], &vertList[k], stride * sizeof (dgFloat64)); - tmpVertexList[m + 0] = dgFloat64 (- 1.0f); - tmpVertexList[m + 1] = dgFloat64 (i); - k += stride; - m += stride2; - } - - dgInt32 count = QuickSortVertices (tmpVertexList, stride2, compareCount, vertexCount, tolerance); - - k = 0; - m = 0; - for (dgInt32 i = 0; i < count; i ++) { - k = i * stride; - m = i * stride2; - memcpy (&vertList[k], &tmpVertexList[m + 2], stride * sizeof (dgFloat64)); - k += stride; - m += stride2; - } - - m = 0; - for (dgInt32 i = 0; i < vertexCount; i ++) { - dgInt32 i1 = dgInt32 (tmpVertexList [m + 1]); - dgInt32 index = dgInt32 (tmpVertexList [m + 0]); - indexListOut[i1] = index; - m += stride2; - } - - return count; -} - -dgInt32 dgVertexListToIndexList (dgFloat32* const vertList, dgInt32 strideInBytes, dgInt32 floatSizeInBytes, dgInt32 unsignedSizeInBytes, dgInt32 vertexCount, dgInt32* const indexList, dgFloat32 tolerance) -{ - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat32)); - - dgAssert (!unsignedSizeInBytes); - dgStack<dgFloat64> pool(vertexCount * stride); - - dgInt32 floatCount = dgInt32 (floatSizeInBytes / sizeof (dgFloat32)); - - dgFloat64* const data = &pool[0]; - for (dgInt32 i = 0; i < vertexCount; i ++) { - - dgFloat64* const dst = &data[i * stride]; - dgFloat32* const src = &vertList[i * stride]; - for (dgInt32 j = 0; j < stride; j ++) { - dst[j] = src[j]; - } - } - - dgInt32 count = dgVertexListToIndexList (data, dgInt32 (stride * sizeof (dgFloat64)), floatCount, vertexCount, indexList, dgFloat64 (tolerance)); - for (dgInt32 i = 0; i < count; i ++) { - dgFloat64* const src = &data[i * stride]; - dgFloat32* const dst = &vertList[i * stride]; - for (dgInt32 j = 0; j < stride; j ++) { - dst[j] = dgFloat32 (src[j]); - } - } - - return count; -} - - -//#define SERIALIZE_END 'dne ' -#define SERIALIZE_END 0x646e6520 - -struct dgSerializeMarkerData -{ - dgSerializeMarkerData() - :m_maker0(SERIALIZE_END) - ,m_maker1(SERIALIZE_END) - ,m_maker2(SERIALIZE_END) - ,m_revision(m_currentRevision) - { - } - dgInt32 m_maker0; - dgInt32 m_maker1; - dgInt32 m_maker2; - dgInt32 m_revision; -}; - -void dgSerializeMarker(dgSerialize serializeCallback, void* const userData) -{ - dgSerializeMarkerData marker; - serializeCallback (userData, &marker, sizeof (dgSerializeMarkerData)); -} - -dgInt32 dgDeserializeMarker(dgDeserialize serializeCallback, void* const userData) -{ - dgInt32 state = 0; - while (state != 3) { - dgInt32 marker; - serializeCallback (userData, &marker, sizeof (marker)); - switch (state) - { - case 0: - { - if (marker == SERIALIZE_END) { - state = 1; - break; - } else { - state = 0; - } - break; - } - - case 1: - { - if (marker == SERIALIZE_END) { - state = 2; - break; - } else { - state = 0; - } - break; - } - - case 2: - { - if (marker == SERIALIZE_END) { - state = 3; - break; - } else { - state = 0; - } - break; - } - } - } - - dgInt32 revision; - serializeCallback (userData, &revision, sizeof (revision)); - return revision; -} - - -dgSetPrecisionDouble::dgSetPrecisionDouble() -{ - #if (defined (_MSC_VER) && defined (_WIN_32_VER)) - dgClearFP(); - m_mask = dgInt32 (dgControlFP(0, 0)); - dgControlFP (_PC_53, _MCW_PC); - #endif -} - -dgSetPrecisionDouble::~dgSetPrecisionDouble() -{ - #if (defined (_MSC_VER) && defined (_WIN_32_VER)) - dgClearFP(); - dgControlFP (dgUnsigned32(m_mask), _MCW_PC); - #endif -} - -dgFloatExceptions::dgFloatExceptions(dgUnsigned32 mask) -{ - #if (defined (_MSC_VER) && defined (_WIN_32_VER)) - dgClearFP(); - m_mask = dgControlFP(0, 0); - dgControlFP (m_mask & ~mask, _MCW_EM); - #endif - - #ifdef _MACOSX_VER - #ifndef IOS - fesetenv(FE_DFL_DISABLE_SSE_DENORMS_ENV); - #endif - #elif (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); - #elif defined (_ARM_VER) - //_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); - #pragma message ("warning!!! do not forget to set flush to zero for arm cpus") - #endif - -// float a (1.0f); -// float b (0.1f); -// while (a != 0.0f) -// a = a * b; -} - -dgFloatExceptions::~dgFloatExceptions() -{ - #if (defined (_MSC_VER) && defined (_WIN_32_VER)) - dgClearFP(); - dgControlFP(m_mask, _MCW_EM); - #endif -} - diff --git a/thirdparty/src/newton/dgCore/dgTypes.h b/thirdparty/src/newton/dgCore/dgTypes.h deleted file mode 100644 index 08c6ee94f..000000000 --- a/thirdparty/src/newton/dgCore/dgTypes.h +++ /dev/null @@ -1,696 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGTYPES_H__ -#define __DGTYPES_H__ - -#ifdef _MSC_VER - #ifdef _M_ARM - #ifndef _ARM_VER - #define _ARM_VER - #endif - #elif defined (_M_X64) - #ifndef _WIN_64_VER - #define _WIN_64_VER - #endif - #elif defined (_M_IX86) - #ifndef _WIN_32_VER - #define _WIN_32_VER - #endif - #else - #error target platform not defined - #endif - - #if _MSC_VER >= 1400 - #define HAVE_STRUCT_TIMESPEC - #endif -#endif - -#if (defined (_WIN_32_VER) || defined (_WIN_64_VER) || (defined (_MSC_VER ) && defined (_ARM_VER)) ) - #pragma warning (disable: 4100) //unreferenced formal parameter - #pragma warning (disable: 4201) //nonstandard extension used : nameless struct/union - #pragma warning (disable: 4324) //structure was padded due to __declspec(align()) - #pragma warning (disable: 4514) //unreferenced inline function has been removed - #pragma warning (disable: 4530) //C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc - #pragma warning (disable: 4625) //copy constructor could not be generated because a base class copy constructor is inaccessible or deleted - #pragma warning (disable: 4626) //assignment operator could not be generated because a base class assignment operator is inaccessible or deleted - #pragma warning (disable: 4640) //construction of local static object is not thread-safe - #pragma warning (disable: 4820) //bytes padding added after data member - #pragma warning (disable: 4005) //'__useHeader': macro redefinition - //#pragma warning (disable: 4577) // 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc - - #include <io.h> - #include <direct.h> - #include <malloc.h> - #include <float.h> - #include <stdarg.h> - #include <process.h> - - #ifdef _DEBUG - #pragma warning (disable: 4127) //conditional expression is constant - #endif - - #pragma warning (push, 3) - #include <windows.h> - #include <crtdbg.h> - //#ifndef _DURANGO - // #include <tlhelp32.h> - //#endif - #pragma warning (pop) -#endif - -#include <new> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <time.h> -#include <math.h> -#include <float.h> -#include <ctype.h> - -#if (defined (__MINGW32__) || defined (__MINGW64__)) - #include <io.h> - #include <direct.h> - #include <malloc.h> - #include <float.h> - #include <windows.h> - #include <process.h> -#endif - -#if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - #include <intrin.h> - #include <emmintrin.h> - #include <pmmintrin.h> -#endif - -#if (defined (_POSIX_VER) || defined (_POSIX_VER_64) || defined (__MINGW32__) || defined (__MINGW64__)) - /* CMake defines NDEBUG for _not_ debug builds. Therefore, set - Newton's _DEBUG flag only when NDEBUG is not defined. - */ - #ifndef NDEBUG - #define _DEBUG 1 - #endif - - #include <unistd.h> - #include <assert.h> - #if (!defined(__arm__) && !defined(__aarch64__)) // it was __ARMCC_VERSION before, it should be __ARM__ or aarch64, otherwise cross compiling in gcc fails. - extern "C" - { - // for SSE3 and up - #include <pmmintrin.h> - #include <emmintrin.h> - #include <mmintrin.h> - } - #endif -#endif - -#ifdef _MACOSX_VER - #include <unistd.h> - #include <sys/sysctl.h> - #include <assert.h> - #if (defined __i386__ || defined __x86_64__) - #include <fenv.h> - #include <pmmintrin.h> - #include <emmintrin.h> //sse3 - #include <mmintrin.h> - #endif -#endif - -// uncomment out D_PROFILER to enable profiler frame capture profiler traces -// alternatively the end application can use a command line option to enable this define -//#define D_PROFILER - -// uncomment this for Scalar floating point -// alternatively the end application can use a command line option to enable this define -//#define DG_SCALAR_VECTOR_CLASS - -// uncomment this for Scalar floating point -// alternatively the end application can use a command line option to enable this define -//#define __ANDROID__ - -// by default newton run on a separate thread and -// optionally concurrent with the calling thread, -// it also uses a thread job pool for multi core systems. -// define DG_USE_THREAD_EMULATION on the command line for -// platform that do not support hardware multi threading or -// if the and application want to control threading at the application level -//#define DG_USE_THREAD_EMULATION - -#if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - #if _MSC_VER < 1700 - #ifndef DG_USE_THREAD_EMULATION - #define DG_USE_THREAD_EMULATION - #endif - #endif -#endif - -#ifndef DG_USE_THREAD_EMULATION - #include <mutex> - #include <thread> - #include <condition_variable> -#endif - - -//************************************************************ -#ifdef DG_DISABLE_ASSERT - #define dgAssert(x) -#else - #if defined (_WIN_32_VER) || defined (_WIN_64_VER) - #define dgAssert(x) _ASSERTE(x) - #elif defined (_MSC_VER ) && defined (_ARM_VER) - #define dgAssert(x) _ASSERTE(x) - #else - #ifdef _DEBUG - #define dgAssert(x) assert(x) - #else - #define dgAssert(x) - #endif - #endif -#endif - - -#define DG_MAX_THREADS_HIVE_COUNT 16 - -#ifdef _DEBUG -//#define __ENABLE_DG_CONTAINERS_SANITY_CHECK -#endif - - -#ifdef DLL_DECLSPEC -#undef DLL_DECLSPEC -#endif - -#ifdef _DEBUG - #define DG_INLINE inline -#else - #if defined(_MSC_VER) - #define DG_INLINE __forceinline - #else - #define DG_INLINE inline - //#define DG_INLINE __attribute__((always_inline)) - #endif -#endif - - -#define DG_VECTOR_SIMD_SIZE 16 -#define DG_VECTOR_AVX2_SIZE 32 - -#if defined(_MSC_VER) - #define DG_GCC_VECTOR_ALIGNMENT - #define DG_MSC_VECTOR_ALIGNMENT __declspec(align(DG_VECTOR_SIMD_SIZE)) -#else - #define DG_GCC_VECTOR_ALIGNMENT __attribute__ ((aligned (DG_VECTOR_SIMD_SIZE))) - #define DG_MSC_VECTOR_ALIGNMENT -#endif - -#if defined(_MSC_VER) - #define DG_GCC_AVX_ALIGNMENT - #define DG_MSC_AVX_ALIGNMENT __declspec(align(DG_VECTOR_AVX2_SIZE)) -#else - #define DG_GCC_AVX_ALIGNMENT __attribute__ ((aligned (DG_VECTOR_AVX2_SIZE))) - #define DG_MSC_AVX_ALIGNMENT -#endif - -#if defined(_MSC_VER) - #define DG_LIBRARY_EXPORT __declspec(dllexport) - #define DG_LIBRARY_IMPORT __declspec(dllimport) - #define DG_LIBRARY_STATIC -#else - #define DG_LIBRARY_EXPORT __attribute__((visibility("default"))) - #define DG_LIBRARY_IMPORT __attribute__((visibility("default"))) - #define DG_LIBRARY_STATIC -#endif - - -#if ((defined (_WIN_32_VER) || defined (_WIN_64_VER)) && (_MSC_VER >= 1600)) - #include <stdint.h> - typedef int8_t dgInt8; - typedef uint8_t dgUnsigned8; - - typedef int16_t dgInt16; - typedef uint16_t dgUnsigned16; - - typedef int32_t dgInt32; - typedef uint32_t dgUnsigned32; - - typedef int64_t dgInt64; - typedef uint64_t dgUnsigned64; -#else - typedef char dgInt8; - typedef unsigned char dgUnsigned8; - - typedef short dgInt16; - typedef unsigned short dgUnsigned16; - - typedef int dgInt32; - typedef unsigned dgUnsigned32; - typedef unsigned int dgUnsigned32; - - typedef long long dgInt64; - typedef unsigned long long dgUnsigned64; - typedef double dgFloat64; -#endif - - -typedef double dgFloat64; - -#ifdef _NEWTON_USE_DOUBLE - typedef double dgFloat32; -#else - typedef float dgFloat32; -#endif - - -class dgTriplex -{ - public: - dgFloat32 m_x; - dgFloat32 m_y; - dgFloat32 m_z; -}; - -#define dgPi dgFloat32 (3.141592f) -#define dgPI2 dgFloat32 (dgPi * 2.0f) -#define dgEXP dgFloat32 (2.71828f) -#define dgEpsilon dgFloat32 (1.0e-5f) -#define dgDegreeToRad dgFloat32 (dgPi / 180.0f) -#define dgRadToDegree dgFloat32 (180.0f / dgPi) - -class dgBigVector; -#ifndef _NEWTON_USE_DOUBLE -class dgVector; -#endif - - -#if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - #define dgApi __cdecl - #define dgStdApi __stdcall -#else - #define dgApi - #define dgStdApi -#endif - - - -#if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - #define dgCheckFloat(x) (_finite(x) && !_isnan(x)) -// #define dgCheckFloat(x) 1 -#else - #define dgCheckFloat(x) (isfinite(x) && !isnan(x)) -// #define dgCheckFloat(x) 1 -#endif - -typedef void (dgApi *dgDeserialize) (void* const userData, void* buffer, dgInt32 size); -typedef void (dgApi *dgSerialize) (void* const userData, const void* const buffer, dgInt32 size); -typedef bool (dgApi *dgReportProgress) (dgFloat32 progressNormalzedPercent, void* const userData); - -// assume this function returns memory aligned to 16 bytes -#define dgAlloca(type, count) (type*) alloca (sizeof (type) * (count)) - -DG_INLINE dgInt32 dgExp2 (dgInt32 x) -{ - dgInt32 exp; - for (exp = -1; x; x >>= 1) { - exp ++; - } - return exp; -} - -DG_INLINE dgInt32 dgBitReversal(dgInt32 v, dgInt32 base) -{ - dgInt32 x = 0; - dgInt32 power = dgExp2 (base) - 1; - do { - x += (v & 1) << power; - v >>= 1; - power--; - } while (v); - dgAssert(x < base); - return x; -} - - -template <class T> -DG_INLINE T dgMin(T A, T B) -{ - return (A < B) ? A : B; -} - -template <class T> -DG_INLINE T dgMax(T A, T B) -{ - return (A > B) ? A : B; -} - -template <class T> -DG_INLINE T dgMin(T A, T B, T C) -{ - return dgMin(dgMin (A, B), C); -} - -template <class T> -DG_INLINE T dgMax(T A, T B, T C) -{ - return dgMax(dgMax (A, B), C); -} - -template <class T> -DG_INLINE T dgClamp(T val, T min, T max) -{ - return dgMax (min, dgMin (max, val)); -} - -template <class T> -DG_INLINE void dgSwap(T& A, T& B) -{ - T tmp (A); - A = B; - B = tmp; -} - -template <class T> -DG_INLINE T dgAbs(T A) -{ - // according to Intel this is better because is does not read after write - return (A >= T(0)) ? A : -A; -} - -template <class T> -DG_INLINE T dgSign(T A) -{ - return (A >= T(0)) ? T(1) : T(-1); -} - -template <class T> -DG_INLINE bool dgAreEqual(T A, T B, T tol) -{ - if ((dgAbs(A) < tol) && (dgAbs(B) < tol)) { - return true; - } -/* - dgInt32 exp0; - dgFloat64 mantissa0 = frexp(dgFloat64 (A), &exp0); - - dgInt32 exp1; - dgFloat64 mantissa1 = frexp(dgFloat64(B), &exp1); - - if ((exp0 < -12) && (exp1 < -12)) { - return true; - } - - if (exp0 != exp1) { - return false; - } - return dgAbs(mantissa0 - mantissa1) < tol; -*/ - T den = dgMax(dgAbs(A), dgAbs(B)) + tol; - A /= den; - B /= den; - return dgAbs(A - B) < tol; -} - -#ifdef _NEWTON_USE_DOUBLE - union dgFloatSign - { - struct { - dgInt32 m_dommy; - dgInt32 m_iVal; - } m_integer; - dgFloat64 m_fVal; - }; -#else - union dgFloatSign - { - struct { - dgInt32 m_iVal; - } m_integer; - dgFloat32 m_fVal; - }; -#endif - -union dgDoubleInt -{ - struct { - dgInt32 m_intL; - dgInt32 m_intH; - }; - void* m_ptr; - dgInt64 m_int; - dgFloat64 m_float; -}; - - -void dgGetMinMax (dgBigVector &Min, dgBigVector &Max, const dgFloat64* const vArray, dgInt32 vCount, dgInt32 strideInBytes); -dgInt32 dgVertexListToIndexList (dgFloat64* const vertexList, dgInt32 strideInBytes, dgInt32 compareCount, dgInt32 vertexCount, dgInt32* const indexListOut, dgFloat64 tolerance = dgEpsilon); -dgInt32 dgVertexListToIndexList (dgFloat32* const vertexList, dgInt32 strideInBytes, dgInt32 floatSizeInBytes, dgInt32 unsignedSizeInBytes, dgInt32 vertexCount, dgInt32* const indexListOut, dgFloat32 tolerance = dgEpsilon); - -#define PointerToInt(x) ((size_t)x) -#define IntToPointer(x) ((void*)(size_t(x))) - - -#ifndef _MSC_VER - #define _stricmp(x,y) strcasecmp(x,y) -#endif - -#define dgSqrt(x) dgFloat32 (sqrt(x)) -#define dgSin(x) dgFloat32 (sin(x)) -#define dgCos(x) dgFloat32 (cos(x)) -#define dgAsin(x) dgFloat32 (asin(x)) -#define dgAcos(x) dgFloat32 (acos(x)) -#define dgLog(x) dgFloat32 (log(x)) -#define dgCeil(x) dgFloat32 (ceil(x)) -#define dgFloor(x) dgFloat32 (floor(x)) -#define dgPow(x,y) dgFloat32 (pow(x,y)) -#define dgFmod(x,y) dgFloat32 (fmod(x,y)) -#define dgAtan2(x,y) dgFloat32 (atan2(x,y)) -#define dgRsqrt(x) (dgFloat32 (1.0f) / dgSqrt(x)) -#define dgClearFP() _clearfp() -#define dgControlFP(x,y) _controlfp(x,y) - -enum dgSerializeRevisionNumber -{ - m_firstRevision = 100, - // add new serialization revision number here - m_currentRevision -}; - -dgUnsigned64 dgGetTimeInMicrosenconds(); -dgFloat64 dgRoundToFloat(dgFloat64 val); -void dgSerializeMarker(dgSerialize serializeCallback, void* const userData); -dgInt32 dgDeserializeMarker(dgDeserialize serializeCallback, void* const userData); - -class dgFloatExceptions -{ - public: - #ifdef _MSC_VER - #define DG_FLOAT_EXECTIONS_MASK (EM_INVALID | EM_DENORMAL | EM_ZERODIVIDE) - #else - #define DG_FLOAT_EXECTIONS_MASK 0 - #endif - - dgFloatExceptions(dgUnsigned32 mask = DG_FLOAT_EXECTIONS_MASK); - ~dgFloatExceptions(); - - private: - #if (defined (_MSC_VER) && defined (_WIN_32_VER)) - dgUnsigned32 m_mask; -#endif -}; - -class dgSetPrecisionDouble -{ - public: - dgSetPrecisionDouble(); - ~dgSetPrecisionDouble(); - #if (defined (_MSC_VER) && defined (_WIN_32_VER)) - dgInt32 m_mask; - #endif -}; - -DG_INLINE dgInt32 dgAtomicExchangeAndAdd (dgInt32* const addend, dgInt32 amount) -{ - #if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - return _InterlockedExchangeAdd((long*)addend, long(amount)); - #elif defined (_MSC_VER ) && defined (_ARM_VER) - return _InterlockedExchangeAdd((long*)addend, long(amount)); - #elif (defined (__MINGW32__) || defined (__MINGW64__)) - return InterlockedExchangeAdd((long*)addend, long(amount)); - #elif (defined (_POSIX_VER) || defined (_POSIX_VER_64) ||defined (_MACOSX_VER)|| defined ANDROID) - return __sync_fetch_and_add((int32_t*)addend, amount); - #else - #error "dgAtomicExchangeAndAdd implementation required" - #endif -} - -DG_INLINE dgInt32 dgInterlockedExchange(dgInt32* const ptr, dgInt32 value) -{ - #if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - return _InterlockedExchange((long*) ptr, value); - #elif defined (_MSC_VER ) && defined (_ARM_VER) - return _InterlockedExchange((long*)ptr, value); - #elif (defined (__MINGW32__) || defined (__MINGW64__)) - return InterlockedExchange((long*) ptr, value); - #elif (defined (_POSIX_VER) || defined (_POSIX_VER_64) ||defined (_MACOSX_VER)) - return __sync_lock_test_and_set((int32_t*)ptr, value); - #else - #error "dgInterlockedExchange implementation required" - #endif -} - -/* -DG_INLINE void* dgInterlockedExchange(void** const ptr, void* value) -{ - #if defined(_WIN32) - #ifdef _M_X64 - return (void*)_InterlockedExchange64((dgInt64*)ptr, dgInt64 (value)); - #else - return (void*)_InterlockedExchange((long*) ptr, dgInt32(value)); - #endif - #elif defined(__linux__) || defined(_MACOSX_VER) - #if defined(__ANDROID__) - return __sync_lock_test_and_set(ptr, value); - #else - #ifdef __x86_64__ - return (void*)__sync_lock_test_and_set((dgInt64*) ptr, (dgInt64)value); - #else - return (void*)__sync_lock_test_and_set((dgInt32*) ptr, (dgInt32) value); - #endif - #endif - #else - #error "dgInterlockedExchange implementation required" - #endif -} -*/ - -DG_INLINE dgInt32 dgInterlockedTest(dgInt32* const ptr, dgInt32 value) -{ - #if (defined (_WIN_32_VER) || defined (_WIN_64_VER)) - return _InterlockedCompareExchange((long*)ptr, value, value); - #elif defined (_MSC_VER ) && defined (_ARM_VER) - return _InterlockedCompareExchange((long*)ptr, value, value); - #elif (defined (__MINGW32__) || defined (__MINGW64__)) - return InterlockedCompareExchange((long*)ptr, value, value); - #elif (defined (_POSIX_VER) || defined (_POSIX_VER_64) ||defined (_MACOSX_VER)) - return __sync_lock_test_and_set((int32_t*)ptr, value); - #else - #error "dgInterlockedTest implementation required" - #endif -} - -DG_INLINE void dgThreadYield() -{ -#ifndef DG_USE_THREAD_EMULATION - std::this_thread::yield(); -#endif -} - -DG_INLINE void dgThreadPause() -{ -#ifndef DG_USE_THREAD_EMULATION - //#if defined (_WIN_32_VER) || defined (_WIN_64_VER) || defined (WIN32) || defined (i386_) || defined (x86_64_) - #if defined (_WIN_32_VER) || defined (_WIN_64_VER) - _mm_pause(); - #else - std::this_thread::yield(); - #endif -#endif -} - -DG_INLINE void dgSpinLock(dgInt32* const ptr) -{ -#ifndef DG_USE_THREAD_EMULATION - while (dgInterlockedExchange(ptr, 1)) { - dgThreadYield(); - } -#endif -} - - -DG_INLINE void dgSpinUnlock (dgInt32* const ptr) -{ - #ifndef DG_USE_THREAD_EMULATION - dgInterlockedExchange(ptr, 0); - #else - *ptr = 0; - #endif -} - - -class dgScopeSpinLock -{ - public: - DG_INLINE dgScopeSpinLock(dgInt32* const lock) - :m_atomicLock(lock) - { - dgSpinLock(m_atomicLock); - } - - DG_INLINE ~dgScopeSpinLock() - { - dgSpinUnlock(m_atomicLock); - } - - dgInt32* m_atomicLock; -}; - -class dgScopeSpinPause -{ - public: - DG_INLINE dgScopeSpinPause(dgInt32* const lock) - :m_atomicLock(lock) - { - while (dgInterlockedExchange(m_atomicLock, 1)) { - dgThreadPause(); - } - } - - DG_INLINE ~dgScopeSpinPause() - { - dgSpinUnlock(m_atomicLock); - } - - dgInt32* m_atomicLock; -}; - - - -#ifdef _MACOSX_VER -#include <sys/time.h> -#ifndef CLOCK_REALTIME - #define CLOCK_REALTIME 0 -#endif -#ifndef CLOCK_MONOTONIC - #define CLOCK_MONOTONIC 0 -#endif -//clock_gettime is not implemented on OSX -DG_INLINE int clock_gettime(int /*clk_id*/, struct timespec* t) { - struct timeval now; - int rv = gettimeofday(&now, NULL); - if (rv) return rv; - t->tv_sec = now.tv_sec; - t->tv_nsec = now.tv_usec * 1000; - return 0; -} -#endif - -#endif - diff --git a/thirdparty/src/newton/dgCore/dgVector.h b/thirdparty/src/newton/dgCore/dgVector.h deleted file mode 100644 index a23339c57..000000000 --- a/thirdparty/src/newton/dgCore/dgVector.h +++ /dev/null @@ -1,228 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgVector__ -#define __dgVector__ - -#include "dgStdafx.h" -#include "dgTypes.h" -#include "dgDebug.h" -#include "dgMemory.h" - -#define dgCheckVector(x) (dgCheckFloat(x[0]) && dgCheckFloat(x[1]) && dgCheckFloat(x[2]) && dgCheckFloat(x[3])) - -#ifdef DG_SCALAR_VECTOR_CLASS - #include "dgVectorScalar.h" -#elif defined(__ANDROID__) || defined (_ARM_VER) - #include "dgVectorArmNeon.h" -#else - #include "dgVectorSimd.h" -#endif - -template<class T> -class dgTemplateVector -{ - public: - DG_CLASS_ALLOCATOR(allocator) - - DG_INLINE dgTemplateVector () - { - } - - DG_INLINE dgTemplateVector (const T* const ptr) - :m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w (ptr[3]) - { - //dgAssert (dgCheckVector ((*this))); - } - - DG_INLINE dgTemplateVector (const dgTemplateVector<T>& copy) - :m_x(copy.m_x), m_y(copy.m_y), m_z(copy.m_z), m_w (copy.m_w) - { - // dgAssert (dgCheckVector ((*this))); - } - - DG_INLINE dgTemplateVector (T x, T y, T z, T w) - :m_x(x), m_y(y), m_z(z), m_w (w) - { - } - - DG_INLINE T& operator[] (dgInt32 i) - { - dgAssert (i < 4); - dgAssert (i >= 0); - return (&m_x)[i]; - } - - DG_INLINE const T& operator[] (dgInt32 i) const - { - dgAssert (i < 4); - dgAssert (i >= 0); - return (&m_x)[i]; - } - - DG_INLINE T GetScalar() const - { - return m_x; - } - - DG_INLINE dgTemplateVector<T> Scale (T scale) const - { - return dgTemplateVector<T> (m_x * scale, m_y * scale, m_z * scale, m_w * scale); - } - - DG_INLINE dgTemplateVector<T> operator+ (const dgTemplateVector<T>& B) const - { - return dgTemplateVector<T> (m_x + B.m_x, m_y + B.m_y, m_z + B.m_z, m_w + B.m_w); - } - - DG_INLINE dgTemplateVector<T>& operator+= (const dgTemplateVector<T>& A) - { - return (*this = dgTemplateVector<T> (m_x + A.m_x, m_y + A.m_y, m_z + A.m_z, m_w + A.m_w)); - } - - DG_INLINE dgTemplateVector<T> operator- (const dgTemplateVector<T>& A) const - { - return dgTemplateVector<T> (m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w); - } - - DG_INLINE dgTemplateVector<T>& operator-= (const dgTemplateVector<T>& A) - { - return (*this = dgTemplateVector<T> (m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w)); - } - - DG_INLINE dgTemplateVector<T> operator* (const dgTemplateVector<T>& B) const - { - return dgTemplateVector<T>(m_x * B.m_x, m_y * B.m_y, m_z * B.m_z, m_w * B.m_w); - } - - DG_INLINE dgTemplateVector<T> operator*= (const dgTemplateVector<T>& B) const - { - return (*this = dgTemplateVector<T>(m_x * B.m_x, m_y * B.m_y, m_z * B.m_z, m_w * B.m_w)); - } - - DG_INLINE dgTemplateVector<T> AddHorizontal() const - { - T val(m_x + m_y + m_z + m_w); - return dgTemplateVector<T>(val, val, val, val); - } - - DG_INLINE dgTemplateVector<T> MulAdd(const dgTemplateVector<T>& A, const dgTemplateVector<T>& B) const - { - return *this + A * B; - } - - DG_INLINE dgTemplateVector<T> MulSub(const dgTemplateVector<T>& A, const dgTemplateVector<T>& B) const - { - return *this - A * B; - } - - // return dot product - DG_INLINE T DotProduct3 (const dgTemplateVector<T>& A) const - { - return m_x * A.m_x + m_y * A.m_y + m_z * A.m_z; - } - - // return cross product - DG_INLINE dgTemplateVector<T> CrossProduct (const dgTemplateVector<T>& B) const - { - return dgTemplateVector<T> (m_y * B.m_z - m_z * B.m_y, - m_z * B.m_x - m_x * B.m_z, - m_x * B.m_y - m_y * B.m_x, m_w); - } - - DG_INLINE dgTemplateVector<T> CrossProduct(const dgTemplateVector &A, const dgTemplateVector &B) const - { - T cofactor[3][3]; - T array[4][4]; - - const dgTemplateVector<T>& me = *this; - for (dgInt32 i = 0; i < 4; i++) { - array[0][i] = me[i]; - array[1][i] = A[i]; - array[2][i] = B[i]; - array[3][i] = T(1.0f); - } - - dgTemplateVector<T> normal; - T sign = T(-1.0f); - for (dgInt32 i = 0; i < 4; i++) { - - for (dgInt32 j = 0; j < 3; j++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 4; k++) { - if (k != i) { - cofactor[j][k0] = array[j][k]; - k0++; - } - } - } - T x = cofactor[0][0] * (cofactor[1][1] * cofactor[2][2] - cofactor[1][2] * cofactor[2][1]); - T y = cofactor[0][1] * (cofactor[1][2] * cofactor[2][0] - cofactor[1][0] * cofactor[2][2]); - T z = cofactor[0][2] * (cofactor[1][0] * cofactor[2][1] - cofactor[1][1] * cofactor[2][0]); - T det = x + y + z; - - normal[i] = sign * det; - sign *= T(-1.0f); - } - - return normal; - } - - // return dot 4d dot product - DG_INLINE dgTemplateVector<T> DotProduct (const dgTemplateVector &A) const - { - T val (m_x * A.m_x + m_y * A.m_y + m_z * A.m_z + m_w * A.m_w); - return dgTemplateVector<T> (val, val, val, val); - } - - - T GetMax () const - { - return dgMax(dgMax(m_x, m_y), dgMax(m_z, m_w)); - } - - DG_INLINE dgTemplateVector<T> GetMax(const dgTemplateVector<T>& data) const - { - return dgTemplateVector<T>((m_x > data.m_x) ? m_x : data.m_x, (m_y > data.m_y) ? m_y : data.m_y, (m_z > data.m_z) ? m_z : data.m_z, (m_w > data.m_w) ? m_w : data.m_w); - } - - DG_INLINE dgTemplateVector<T> GetMin(const dgTemplateVector<T>& data) const - { - return dgTemplateVector<T>((m_x < data.m_x) ? m_x : data.m_x, (m_y < data.m_y) ? m_y : data.m_y, (m_z < data.m_z) ? m_z : data.m_z, (m_w < data.m_w) ? m_w : data.m_w); - } - - // check validity of floats -#ifdef _DEBUG - void Trace (char* const name) const - { - dgTrace (("%s %f %f %f %f\n", name, m_x, m_y, m_z, m_w)); - } -#endif - - T m_x; - T m_y; - T m_z; - T m_w; -}; - - - -#endif \ No newline at end of file diff --git a/thirdparty/src/newton/dgCore/dgVectorArmNeon.h b/thirdparty/src/newton/dgCore/dgVectorArmNeon.h deleted file mode 100644 index 883897181..000000000 --- a/thirdparty/src/newton/dgCore/dgVectorArmNeon.h +++ /dev/null @@ -1,2049 +0,0 @@ -/* Copyright (c) <2003-2016> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgVectorArmNeon__ -#define __dgVectorArmNeon__ - -#if 0 -// ***************************************************************************************** -// -// 4 x 1 single precision vector class declaration -// -// ***************************************************************************************** -#ifdef _NEWTON_USE_DOUBLE -#define dgVector dgBigVector -#else - - -#if DG_ARCH >= DG_ARCH_NEON_64 - -A R M 6 4 - -#define vec_minv vminvq_u32 -#define vec_maxv maxvq_u32 -#define vec_hadd4 vaddvq_f32 -#define vec_floor vrndq_f32 - -#else - - -#define DG_INLINE_FORCEINLINE(type) static inline type - -DG_INLINE_FORCEINLINE(int) vec_minv(uint32x4_t v) -{ - uint32x2_t tmp = vpmin_u32(vget_low_u32(v), vget_high_u32(v)); - tmp = vpmin_u32(tmp, tmp); - return tmp[0] != 0; -} - -DG_INLINE_FORCEINLINE(int) vec_maxv(uint32x4_t v) -{ - uint32x2_t tmp = vpmax_u32(vget_low_u32(v), vget_high_u32(v)); - tmp = vpmax_u32(tmp, tmp); - return tmp[0] != 0; -} - - -DG_INLINE_FORCEINLINE(float)vec_hadd4(float32x4_t v) -{ - float32x4_t tmp = vaddq_f32(v, vrev64q_f32(v)); - tmp = vaddq_f32(tmp, vcombine_f32(vget_high_f32(tmp), vget_low_f32(tmp))); - return tmp[0]; -} - - - - -#endif - -DG_INLINE_FORCEINLINE(float) vec_hadd3(float32x4_t v) -{ - float32x2_t temp = vpadd_f32(vget_low_f32(v), vget_low_f32(v)); - temp = vadd_f32(temp, vget_high_f32(v)); - return vget_lane_f32(temp, 0); -} - - -#define vec_mul vmulq_f32 -#define vec_add vaddq_f32 -#define vec_sub vsubq_f32 -#define vec_max vmaxq_f32 -#define vec_min vminq_f32 -#define vec_splat vdupq_n_f32 -#define vec_div vdivq_f32 -#define vec_rcp vrecpeq_f32 -#define vec_store vst1q_f32 -#define vec_load vld1q_f32 -#define vec_abs vabsq_f32 -#define vec_cvt vcvtq_s32_f32 -#define vec_sqrt vrsqrtsq_f32 -#define vec_recp vrecpsq_f32 -#define vec_rsqrt rsqrteq_f32 -#define vec_cmpne vceqq_f32 -#define vec_cmpgt vcgtq_f32 -#define vec_cmpge vcgeq_f32 -#define vec_cmpeq vceqq_f32 -#define vec_cmplt vcltq_f32 -#define vec_cmple vcleq_f32 -#define vec_xor veorq_u32 -#define vec_or vorrq_u32 -#define vec_and vandq_u32 -#define vec_not vmvnq_u32 -#define vec_andnot vbicq_u32 - -#if defined __ARM_FEATURE_FMA -// a * b + c (no rounding, better results) -#define vec_madd vfmaq_f32 -#define vec_msub vmlsq_f32 -#else -#define vec_madd vmlaq_f32 -#define vec_msub vmlsq_f32 -#endif - -static inline float32x4_t vec_set(const float w, const float z, const float y, const float x) -{ - float ptr[] = { x, y, z, w }; - return vec_load(ptr); -} - - -class dgBigVector; -DG_MSC_VECTOR_ALIGMENT -class dgVector { -public: - DG_INLINE dgVector() - { - } - - DG_INLINE dgVector(const float32x4_t type) - : m_type(type) { - } - - DG_INLINE dgVector(const uint32x4_t type) - : m_typeInt(type) { - } - - - DG_INLINE dgVector(dgFloat32 val) - : m_type(vmovq_n_f32(val)) - { - } - - DG_INLINE dgVector (const dgVector& v) - : m_type( v.m_type ) - { - //dgAssert (dgCheckVector ((*this))); - } - - DG_INLINE dgVector (const dgFloat32* const ptr) - :m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w (dgFloat32 (0.0f)) - { - dgAssert (dgCheckVector ((*this))); - } - -#ifndef _NEWTON_USE_DOUBLE - DG_INLINE dgVector(const dgFloat64* const ptr) - :m_x(dgFloat32(ptr[0])) - ,m_y(dgFloat32(ptr[1])) - ,m_z(dgFloat32(ptr[2])) - ,m_w(dgFloat32(0.0f)) - { - } -#endif - - - DG_INLINE dgVector (dgFloat32 x, dgFloat32 y, dgFloat32 z, dgFloat32 w) - :m_x(x), m_y(y), m_z(z), m_w(w) - { - dgAssert (dgCheckVector ((*this))); - } - - DG_INLINE dgVector (dgInt32 ix, dgInt32 iy, dgInt32 iz, dgInt32 iw) - :m_x(*((dgFloat32*)&ix)), m_y(*((dgFloat32*)&iy)), m_z(*((dgFloat32*)&iz)), m_w(*((dgFloat32*)&iw)) - { - } - -#ifndef _NEWTON_USE_DOUBLE - DG_INLINE dgVector (const dgBigVector& copy) - :m_x(dgFloat32 (((dgFloat64*)©)[0])) - ,m_y(dgFloat32 (((dgFloat64*)©)[1])) - ,m_z(dgFloat32 (((dgFloat64*)©)[2])) - ,m_w(dgFloat32 (((dgFloat64*)©)[3])) - { - dgAssert (dgCheckVector ((*this))); - } -#endif - - DG_INLINE dgFloat32 GetScalar () const - { - return m_x; - } - - DG_INLINE void Store (dgFloat32* const dst) const - { - vec_store(dst, m_type); - } - - DG_INLINE dgVector BroadcastX () const - { - return dgVector (m_x); - } - - DG_INLINE dgVector BroadcastY () const - { - return dgVector (m_y); - } - - DG_INLINE dgVector BroadcastZ () const - { - return dgVector (m_z); - } - - DG_INLINE dgVector BroadcastW () const - { - return dgVector (m_w); - } - - - DG_INLINE dgFloat32& operator[] (dgInt32 i) - { - dgAssert (i < 4); - dgAssert (i >= 0); - return (&m_x)[i]; - } - - DG_INLINE const dgFloat32& operator[] (dgInt32 i) const - { - dgAssert (i < 4); - dgAssert (i >= 0); - return (&m_x)[i]; - } - - DG_INLINE dgVector operator+ (const dgVector& A) const - { - return vec_add(m_type, A.m_type); - } - - DG_INLINE dgVector operator- (const dgVector& A) const - { - return vec_sub(m_type, A.m_type); - } - - DG_INLINE dgVector operator* (const dgVector& A) const - { - return vec_mul(m_type, A.m_type); - } - - DG_INLINE dgVector& operator+= (const dgVector& A) - { - m_type = vec_add(m_type, A.m_type); - return *this; - } - - DG_INLINE dgVector& operator-= (const dgVector& A) - { - m_type = vec_sub(m_type, A.m_type); - return *this; - } - - DG_INLINE dgVector& operator*= (const dgVector& A) - { - m_type = vec_mul(m_type, A.m_type); - return *this; - } - - - - DG_INLINE dgVector AddHorizontal () const - { - return vec_hadd3(m_type); // dgVector (m_x + m_y + m_z + m_w); - } - - DG_INLINE dgVector Scale3 (dgFloat32 scale) const - { - return dgVector (m_x * scale, m_y * scale, m_z * scale, m_w); - } - - DG_INLINE dgVector Scale (dgFloat32 scale) const - { - return vec_mul(vmovq_n_f32(scale), m_type); - } - - // component wise multiplication - DG_INLINE dgVector CompProduct3 (const dgVector& A) const - { - return dgVector (m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, A.m_w); - } - - // return dot product - DG_INLINE dgFloat32 DotProduct3 (const dgVector& A) const - { - return vec_hadd3(vec_mul(A.m_type, m_type)); // m_x * A.m_x + m_y * A.m_y + m_z * A.m_z; - } - - // return cross product - DG_INLINE dgVector CrossProduct (const dgVector& B) const - { - /* - float32x4_t v1 = m_type; - float32x4_t v2 = B.m_type; - float32x4x2_t v_1203 = vzipq_f32(vcombine_f32(vrev64_f32(vget_low_f32(v1)), vrev64_f32(vget_low_f32(v2))), vcombine_f32(vget_high_f32(v1), vget_high_f32(v2))); - float32x4x2_t v_2013 = vzipq_f32(vcombine_f32(vrev64_f32(vget_low_f32(v_1203.val[0])), vrev64_f32(vget_low_f32(v_1203.val[1]))), vcombine_f32(vget_high_f32(v_1203.val[0]), vget_high_f32(v_1203.val[1]))); - inVec->vec = vmlsq_f32(vmulq_f32(v_1203.val[0], v_2013.val[1]), v_1203.val[1], v_2013.val[0]); - */ - return dgVector (m_y * B.m_z - m_z * B.m_y, - m_z * B.m_x - m_x * B.m_z, - m_x * B.m_y - m_y * B.m_x, m_w); - } - - DG_INLINE dgVector CrossProduct (const dgVector& A, const dgVector& B) const - { - dgFloat32 cofactor[3][3]; - dgFloat32 array[4][4]; - - const dgVector& me = *this; - for (dgInt32 i = 0; i < 4; i ++) { - array[0][i] = me[i]; - array[1][i] = A[i]; - array[2][i] = B[i]; - array[3][i] = dgFloat32 (1.0f); - } - - dgVector normal; - dgFloat32 sign = dgFloat32 (-1.0f); - for (dgInt32 i = 0; i < 4; i ++) { - - for (dgInt32 j = 0; j < 3; j ++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 4; k ++) { - if (k != i) { - cofactor[j][k0] = array[j][k]; - k0 ++; - } - } - } - dgFloat32 x = cofactor[0][0] * (cofactor[1][1] * cofactor[2][2] - cofactor[1][2] * cofactor[2][1]); - dgFloat32 y = cofactor[0][1] * (cofactor[1][2] * cofactor[2][0] - cofactor[1][0] * cofactor[2][2]); - dgFloat32 z = cofactor[0][2] * (cofactor[1][0] * cofactor[2][1] - cofactor[1][1] * cofactor[2][0]); - dgFloat32 det = x + y + z; - - normal[i] = sign * det; - sign *= dgFloat32 (-1.0f); - } - - return normal; - } - - DG_INLINE dgVector GetInt () const - { - return vcvtq_u32_f32(m_type); - } - - DG_INLINE dgVector GetFloat () const - { - return vcvtq_f32_u32(m_type); - } - - DG_INLINE dgVector TestZero() const - { - return m_negOne & (*this == m_zero); - } - - DG_INLINE dgVector Floor () const - { -#if DG_ARCH >= DG_ARCH_NEON_64 - // #if __ARM_ARCH >= 8 && defined(__ARM_FEATURE_DIRECTED_ROUNDING) - return vec_floor(m_type); -#else - return dgVector (dgFloor (m_x), dgFloor (m_y), dgFloor (m_z), dgFloor (m_w)); - -#endif - } - - DG_INLINE dgVector DotProduct (const dgVector &A) const - { - auto tmp = vec_mul(m_type, A.m_type); - return vec_hadd4(tmp); - } - - - - DG_INLINE dgVector InvMagSqrt() const - { - return dgVector(dgRsqrt(DotProduct(*this).m_x)); - } - - DG_INLINE dgVector Reciproc() const - { - float32x4_t reciprocal = vrecpeq_f32(m_type); - reciprocal = vrecpsq_f32(m_type, reciprocal) * reciprocal; - return reciprocal; - - } - - - DG_INLINE dgVector MulAdd(const dgVector& A, const dgVector& B) const - { - // a * b + this - return vec_madd(A.m_type, B.m_type, m_type); - } - - DG_INLINE dgVector MulSub(const dgVector& A, const dgVector& B) const - { - // a * b - this - return vec_msub(A.m_type, B.m_type, m_type); - } - - DG_INLINE dgVector InvSqrt() const - { - float32x4_t sqrt_reciprocal = vrsqrteq_f32(m_type); - return vrsqrtsq_f32(m_type * sqrt_reciprocal, sqrt_reciprocal) * sqrt_reciprocal; - } - - DG_INLINE dgVector Sqrt() const - { - float32x4_t sqrt_reciprocal = vrsqrteq_f32(m_type); - float32x4_t tmp = vrsqrtsq_f32(m_type * sqrt_reciprocal, sqrt_reciprocal) * sqrt_reciprocal; - return vec_mul(m_type, tmp); - } - - DG_INLINE dgVector Normalize () const - { - dgAssert (m_w == dgFloat32 (0.0f)); - const dgVector& me = *this; - return me * InvMagSqrt(); - } - - dgVector Abs () const - { - return vec_abs(m_type); - } - - dgFloat32 GetMax () const - { - return dgMax(dgMax(m_x, m_y), dgMax(m_z, m_w)); - } - - dgVector GetMax (const dgVector& data) const - { - return vec_max(m_type, data.m_type); - } - - dgVector GetMin (const dgVector& data) const - { - return vec_min(m_type, data.m_type); - } - - // relational operators - DG_INLINE dgVector operator== (const dgVector& data) const - { - return vec_cmpeq(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator!= (const dgVector& data) const - { - return vec_cmpne(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator> (const dgVector& data) const - { - return vec_cmpgt(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator< (const dgVector& data) const - { - return vec_cmplt(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator>= (const dgVector& data) const - { - return vec_cmpge(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator<= (const dgVector& data) const - { - return vec_cmple(m_typeInt, data.m_typeInt); - } - - // logical operations - DG_INLINE dgVector operator& (const dgVector& data) const - { - return vec_and(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator| (const dgVector& data) const - { - return vec_or(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator^ (const dgVector& data) const - { - return vec_xor(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector AndNot (const dgVector& data) const - { - return vec_andnot(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgInt32 GetSignMask() const - { - const dgInt32* const a = (dgInt32*)&m_x; - return (((a[0] & 0x80000000) ? 1 : 0) | ((a[1] & 0x80000000) ? 2 : 0) | ((a[2] & 0x80000000) ? 4 : 0) | ((a[3] & 0x80000000) ? 8 : 0)); - } - - DG_INLINE dgVector ShiftTripleRight () const - { - return dgVector (m_z, m_x, m_y, m_w); - } - - DG_INLINE dgVector ShiftTripleLeft () const - { - return dgVector (m_y, m_z, m_x, m_w); - } - - DG_INLINE dgVector ShiftRightLogical (int bits) const - { - return dgVector (dgInt32 (dgUnsigned32 (m_ix) >> bits), dgInt32 (dgUnsigned32 (m_iy) >> bits), dgInt32 (dgUnsigned32 (m_iz) >> bits), dgInt32 (dgUnsigned32 (m_iw) >> bits)); - } - - DG_INLINE static void Transpose4x4 (dgVector& dst0, dgVector& dst1, dgVector& dst2, dgVector& dst3, const dgVector& src0, const dgVector& src1, const dgVector& src2, const dgVector& src3) - { - float32x4x2_t vtrn1 = vzipq_f32(src0.m_type, src2.m_type); - float32x4x2_t vtrn2 = vzipq_f32(src1.m_type, src3.m_type); - float32x4x2_t res1 = vzipq_f32(vtrn1.val[0], vtrn2.val[0]); - float32x4x2_t res2 = vzipq_f32(vtrn1.val[1], vtrn2.val[1]); - dst0.m_type = res1.val[0]; - dst1.m_type = res1.val[1]; - dst2.m_type = res2.val[0]; - dst3.m_type = res2.val[1]; - - } - - DG_CLASS_ALLOCATOR(allocator) - - union { - float32x4_t m_type; - uint32x4_t m_typeInt; - dgInt32 m_i[4]; - struct { - dgFloat32 m_x; - dgFloat32 m_y; - dgFloat32 m_z; - dgFloat32 m_w; - }; - struct { - dgInt32 m_ix; - dgInt32 m_iy; - dgInt32 m_iz; - dgInt32 m_iw; - }; - }; - - static dgVector m_zero; - static dgVector m_one; - static dgVector m_wOne; - static dgVector m_half; - static dgVector m_two; - static dgVector m_three; - static dgVector m_negOne; - static dgVector m_xMask; - static dgVector m_yMask; - static dgVector m_zMask; - static dgVector m_wMask; - static dgVector m_signMask; - static dgVector m_triplexMask; -} DG_GCC_VECTOR_ALIGMENT; - -#endif - -DG_MSC_VECTOR_ALIGMENT -class dgBigVector -{ -public: - DG_INLINE dgBigVector() - { - } - - DG_INLINE dgBigVector(dgFloat64 val) - :m_x(val), m_y(val), m_z(val), m_w(val) - { - } - - DG_INLINE dgBigVector(const dgBigVector& v) - : m_x(v.m_x), m_y(v.m_y), m_z(v.m_z), m_w(v.m_w) - { - } - -#ifndef _NEWTON_USE_DOUBLE - DG_INLINE dgBigVector(const dgVector& v) - : m_x(v.m_x), m_y(v.m_y), m_z(v.m_z), m_w(v.m_w) - { - } - - DG_INLINE dgBigVector(const dgFloat32* const ptr) - : m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w(dgFloat32(0.0f)) - { - dgAssert(dgCheckVector((*this))); - } -#endif - - DG_INLINE dgBigVector(const dgFloat64* const ptr) - :m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w(dgFloat32(0.0f)) - { - dgAssert(dgCheckVector((*this))); - } - - DG_INLINE dgBigVector(dgFloat64 x, dgFloat64 y, dgFloat64 z, dgFloat64 w) - : m_x(x), m_y(y), m_z(z), m_w(w) - { - dgAssert(dgCheckVector((*this))); - } - - DG_INLINE dgBigVector(dgInt32 ix, dgInt32 iy, dgInt32 iz, dgInt32 iw) - : m_ix(ix), m_iy(iy), m_iz(iz), m_iw(iw) - { - } - - DG_INLINE dgBigVector(dgInt64 ix, dgInt64 iy, dgInt64 iz, dgInt64 iw) - : m_ix(ix), m_iy(iy), m_iz(iz), m_iw(iw) - { - } - - DG_INLINE dgFloat64 GetScalar() const - { - return m_x; - } - - DG_INLINE void Store(dgFloat64* const dst) const - { - dst[0] = m_x; - dst[1] = m_y; - dst[2] = m_z; - dst[3] = m_w; - } - - DG_INLINE dgBigVector BroadcastX() const - { - return dgBigVector(m_x); - } - - DG_INLINE dgBigVector BroadcastY() const - { - return dgBigVector(m_y); - } - - DG_INLINE dgBigVector BroadcastZ() const - { - return dgBigVector(m_z); - } - - DG_INLINE dgBigVector BroadcastW() const - { - return dgBigVector(m_w); - } - - - DG_INLINE dgFloat64& operator[] (dgInt32 i) - { - dgAssert(i < 4); - dgAssert(i >= 0); - return (&m_x)[i]; - } - - DG_INLINE const dgFloat64& operator[] (dgInt32 i) const - { - dgAssert(i < 4); - dgAssert(i >= 0); - return (&m_x)[i]; - } - - DG_INLINE dgBigVector operator+ (const dgBigVector& A) const - { - return dgBigVector(m_x + A.m_x, m_y + A.m_y, m_z + A.m_z, m_w + A.m_w); - } - - DG_INLINE dgBigVector operator- (const dgBigVector& A) const - { - return dgBigVector(m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w); - } - - DG_INLINE dgBigVector operator* (const dgBigVector& A) const - { - return dgBigVector(m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, m_w * A.m_w); - } - - DG_INLINE dgBigVector& operator+= (const dgBigVector& A) - { - return (*this = dgBigVector(m_x + A.m_x, m_y + A.m_y, m_z + A.m_z, m_w + A.m_w)); - } - - DG_INLINE dgBigVector& operator-= (const dgBigVector& A) - { - return (*this = dgBigVector(m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w)); - } - - DG_INLINE dgBigVector& operator*= (const dgBigVector& A) - { - return (*this = dgBigVector(m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, m_w * A.m_w)); - } - - DG_INLINE dgBigVector AddHorizontal() const - { - return dgBigVector(m_x + m_y + m_z + m_w); - } - - DG_INLINE dgBigVector Scale3(dgFloat64 scale) const - { - return dgBigVector(m_x * scale, m_y * scale, m_z * scale, m_w); - } - - DG_INLINE dgBigVector Scale(dgFloat64 scale) const - { - return dgBigVector(m_x * scale, m_y * scale, m_z * scale, m_w * scale); - } - - // component wise multiplication - DG_INLINE dgBigVector CompProduct3(const dgBigVector& A) const - { - return dgBigVector(m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, A.m_w); - } - - // return dot product - DG_INLINE dgFloat64 DotProduct3(const dgBigVector& A) const - { - return m_x * A.m_x + m_y * A.m_y + m_z * A.m_z; - } - - // return cross product - DG_INLINE dgBigVector CrossProduct(const dgBigVector& B) const - { - return dgBigVector(m_y * B.m_z - m_z * B.m_y, m_z * B.m_x - m_x * B.m_z, m_x * B.m_y - m_y * B.m_x, m_w); - } - - DG_INLINE dgBigVector CrossProduct(const dgBigVector& A, const dgBigVector& B) const - { - dgFloat64 cofactor[3][3]; - dgFloat64 array[4][4]; - - const dgBigVector& me = *this; - for (dgInt32 i = 0; i < 4; i++) { - array[0][i] = me[i]; - array[1][i] = A[i]; - array[2][i] = B[i]; - array[3][i] = dgFloat32(1.0f); - } - - dgBigVector normal; - dgFloat64 sign = dgFloat64(-1.0f); - for (dgInt32 i = 0; i < 4; i++) { - - for (dgInt32 j = 0; j < 3; j++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 4; k++) { - if (k != i) { - cofactor[j][k0] = array[j][k]; - k0++; - } - } - } - dgFloat64 x = cofactor[0][0] * (cofactor[1][1] * cofactor[2][2] - cofactor[1][2] * cofactor[2][1]); - dgFloat64 y = cofactor[0][1] * (cofactor[1][2] * cofactor[2][0] - cofactor[1][0] * cofactor[2][2]); - dgFloat64 z = cofactor[0][2] * (cofactor[1][0] * cofactor[2][1] - cofactor[1][1] * cofactor[2][0]); - dgFloat64 det = x + y + z; - - normal[i] = sign * det; - sign *= dgFloat64(-1.0f); - } - - return normal; - } - - DG_INLINE dgBigVector GetInt() const - { - return dgBigVector(dgInt64(floor(m_x)), dgInt64(floor(m_y)), dgInt64(floor(m_z)), dgInt64(floor(m_w))); - } - - DG_INLINE dgBigVector TestZero() const - { - const dgInt64* const a = (dgInt64*)&m_x; - return dgBigVector((a[0] == 0) ? dgFloat64(-1.0f) : dgFloat64(1.0f), - (a[1] == 0) ? dgFloat64(-1.0f) : dgFloat64(1.0f), - (a[2] == 0) ? dgFloat64(-1.0f) : dgFloat64(1.0f), - (a[3] == 0) ? dgFloat64(-1.0f) : dgFloat64(1.0f)); - } - - - DG_INLINE dgBigVector Floor() const - { - return dgBigVector(floor(m_x), floor(m_y), floor(m_z), floor(m_w)); - } - - DG_INLINE dgBigVector DotProduct(const dgBigVector &A) const - { - return dgBigVector(m_x * A.m_x + m_y * A.m_y + m_z * A.m_z + m_w * A.m_w); - } - - DG_INLINE dgBigVector Reciproc() const - { - return dgBigVector(dgFloat64(1.0f) / m_x, dgFloat64(1.0f) / m_y, dgFloat64(1.0f) / m_z, dgFloat64(1.0f) / m_w); - } - - DG_INLINE dgBigVector Sqrt() const - { - return dgBigVector(sqrt(m_x), sqrt(m_y), sqrt(m_z), sqrt(m_w)); - } - - DG_INLINE dgBigVector InvSqrt() const - { - return dgBigVector(dgFloat64(1.0f) / sqrt(m_x), dgFloat64(1.0f) / sqrt(m_y), dgFloat64(1.0f) / sqrt(m_z), dgFloat64(1.0f) / sqrt(m_w)); - } - - DG_INLINE dgBigVector InvMagSqrt() const - { - return dgBigVector(dgFloat64(1.0f) / sqrt(DotProduct(*this).m_x)); - } - - DG_INLINE dgBigVector Normalize() const - { - dgAssert(m_w == dgFloat64(0.0f)); - //const dgBigVector& me = *this; - //return *this * dgBigVector (dgRsqrt(DotProduct(*this).m_x)); - return *this * InvMagSqrt(); - } - - dgBigVector Abs() const - { - return dgBigVector((m_x > dgFloat64(0.0f)) ? m_x : -m_x, - (m_y > dgFloat64(0.0f)) ? m_y : -m_y, - (m_z > dgFloat64(0.0f)) ? m_z : -m_z, - (m_w > dgFloat64(0.0f)) ? m_w : -m_w); - } - - dgFloat64 GetMax() const - { - return dgMax(dgMax(m_x, m_y), dgMax(m_z, m_w)); - } - - dgBigVector GetMax(const dgBigVector& data) const - { - return dgBigVector((m_x > data.m_x) ? m_x : data.m_x, - (m_y > data.m_y) ? m_y : data.m_y, - (m_z > data.m_z) ? m_z : data.m_z, - (m_w > data.m_w) ? m_w : data.m_w); - } - - dgBigVector GetMin(const dgBigVector& data) const - { - return dgBigVector((m_x < data.m_x) ? m_x : data.m_x, - (m_y < data.m_y) ? m_y : data.m_y, - (m_z < data.m_z) ? m_z : data.m_z, - (m_w < data.m_w) ? m_w : data.m_w); - } - - // relational operators - DG_INLINE dgBigVector operator== (const dgBigVector& data) const - { - return dgBigVector((m_x == data.m_x) ? dgInt64(-1) : dgInt64(0), - (m_y == data.m_y) ? dgInt64(-1) : dgInt64(0), - (m_z == data.m_z) ? dgInt64(-1) : dgInt64(0), - (m_w == data.m_w) ? dgInt64(-1) : dgInt64(0)); - } - - DG_INLINE dgBigVector operator> (const dgBigVector& data) const - { - return dgBigVector((m_x > data.m_x) ? dgInt64(-1) : dgInt64(0), - (m_y > data.m_y) ? dgInt64(-1) : dgInt64(0), - (m_z > data.m_z) ? dgInt64(-1) : dgInt64(0), - (m_w > data.m_w) ? dgInt64(-1) : dgInt64(0)); - } - - DG_INLINE dgBigVector operator< (const dgBigVector& data) const - { - return dgBigVector((m_x < data.m_x) ? dgInt64(-1) : dgInt64(0), - (m_y < data.m_y) ? dgInt64(-1) : dgInt64(0), - (m_z < data.m_z) ? dgInt64(-1) : dgInt64(0), - (m_w < data.m_w) ? dgInt64(-1) : dgInt64(0)); - } - - DG_INLINE dgBigVector operator>= (const dgBigVector& data) const - { - return dgBigVector((m_x >= data.m_x) ? dgInt64(-1) : dgInt64(0), - (m_y >= data.m_y) ? dgInt64(-1) : dgInt64(0), - (m_z >= data.m_z) ? dgInt64(-1) : dgInt64(0), - (m_w >= data.m_w) ? dgInt64(-1) : dgInt64(0)); - } - - DG_INLINE dgBigVector operator<= (const dgBigVector& data) const - { - return dgBigVector((m_x <= data.m_x) ? dgInt64(-1) : dgInt64(0), - (m_y <= data.m_y) ? dgInt64(-1) : dgInt64(0), - (m_z <= data.m_z) ? dgInt64(-1) : dgInt64(0), - (m_w <= data.m_w) ? dgInt64(-1) : dgInt64(0)); - } - - - // logical operations - DG_INLINE dgBigVector operator& (const dgBigVector& data) const - { - const dgInt64* const a = (dgInt64*)&m_x; - const dgInt64* const b = (dgInt64*)&data.m_x; - return dgBigVector(a[0] & b[0], a[1] & b[1], a[2] & b[2], a[3] & b[3]); - } - - DG_INLINE dgBigVector operator| (const dgBigVector& data) const - { - const dgInt64* const a = (dgInt64*)&m_x; - const dgInt64* const b = (dgInt64*)&data.m_x; - return dgBigVector(a[0] | b[0], a[1] | b[1], a[2] | b[2], a[3] | b[3]); - } - - DG_INLINE dgBigVector operator^ (const dgBigVector& data) const - { - const dgInt64* const a = (dgInt64*)&m_x; - const dgInt64* const b = (dgInt64*)&data.m_x; - return dgBigVector(a[0] ^ b[0], a[1] ^ b[1], a[2] ^ b[2], a[3] ^ b[3]); - } - - DG_INLINE dgBigVector AndNot(const dgBigVector& data) const - { - const dgInt64* const a = (dgInt64*)&m_x; - const dgInt64* const b = (dgInt64*)&data.m_x; - return dgBigVector(a[0] & ~b[0], a[1] & ~b[1], a[2] & ~b[2], a[3] & ~b[3]); - } - - DG_INLINE dgInt32 GetSignMask() const - { - const dgInt64* const a = (dgInt64*)&m_x; - return (((a[0] >> 63) ? 1 : 0) | ((a[1] >> 63) ? 2 : 0) | ((a[2] >> 63) ? 4 : 0) | ((a[3] >> 63) ? 8 : 0)); - } - - DG_INLINE dgBigVector ShiftTripleRight() const - { - return dgBigVector(m_z, m_x, m_y, m_w); - } - - DG_INLINE dgBigVector ShiftTripleLeft() const - { - return dgBigVector(m_y, m_z, m_x, m_w); - } - - DG_INLINE dgBigVector ShiftRightLogical(int bits) const - { - return dgBigVector(dgInt64(dgUnsigned64(m_ix) >> bits), dgInt64(dgUnsigned64(m_iy) >> bits), dgInt64(dgUnsigned64(m_iz) >> bits), dgInt64(dgUnsigned64(m_iw) >> bits)); - } - - DG_INLINE static void Transpose4x4(dgBigVector& dst0, dgBigVector& dst1, dgBigVector& dst2, dgBigVector& dst3, const dgBigVector& src0, const dgBigVector& src1, const dgBigVector& src2, const dgBigVector& src3) - { - dgBigVector tmp0(src0); - dgBigVector tmp1(src1); - dgBigVector tmp2(src2); - dgBigVector tmp3(src3); - - dst0 = dgBigVector(tmp0.m_x, tmp1.m_x, tmp2.m_x, tmp3.m_x); - dst1 = dgBigVector(tmp0.m_y, tmp1.m_y, tmp2.m_y, tmp3.m_y); - dst2 = dgBigVector(tmp0.m_z, tmp1.m_z, tmp2.m_z, tmp3.m_z); - dst3 = dgBigVector(tmp0.m_w, tmp1.m_w, tmp2.m_w, tmp3.m_w); - } - - DG_CLASS_ALLOCATOR(allocator) - - union - { -#if DG_ARCH >= DG_ARCH_NEON_64 - struct { - float64x2_t m_xy; - float64x2_t m_zw; - }; - struct { - int64x2_t m_ixy; - int64x2_t m_izw; - }; -#endif - dgInt64 m_i[4]; - struct - { - dgFloat64 m_x; - dgFloat64 m_y; - dgFloat64 m_z; - dgFloat64 m_w; - }; - struct - { - dgInt64 m_ix; - dgInt64 m_iy; - dgInt64 m_iz; - dgInt64 m_iw; - }; - }; - - static dgBigVector m_zero; - static dgBigVector m_one; - static dgBigVector m_wOne; - static dgBigVector m_half; - static dgBigVector m_two; - static dgBigVector m_three; - static dgBigVector m_negOne; - static dgBigVector m_xMask; - static dgBigVector m_yMask; - static dgBigVector m_zMask; - static dgBigVector m_wMask; - static dgBigVector m_signMask; - static dgBigVector m_triplexMask; -} DG_GCC_VECTOR_ALIGMENT; - - -DG_MSC_VECTOR_ALIGMENT -class dgSpatialVector -{ -public: - DG_INLINE dgSpatialVector() - { - } - - DG_INLINE dgSpatialVector(const dgFloat32 a) - { - for (dgInt32 i = 0; i < 6; i++) { - m_d[i] = a; - } - } - - DG_INLINE dgSpatialVector(const dgVector& low, const dgVector& high) - { - for (dgInt32 i = 0; i < 3; i++) { - m_d[i] = low[i]; - m_d[i + 3] = high[i]; - } - } - - DG_INLINE dgSpatialVector(const dgSpatialVector& src) - { - for (dgInt32 i = 0; i < 6; i++) { - m_d[i] = src[i]; - } - } - - DG_INLINE dgFloat64& operator[] (dgInt32 i) - { - dgAssert(i < 6); - dgAssert(i >= 0); - return m_d[i]; - } - - DG_INLINE const dgFloat64& operator[] (dgInt32 i) const - { - dgAssert(i < 6); - dgAssert(i >= 0); - return m_d[i]; - } - - DG_INLINE dgSpatialVector operator+ (const dgSpatialVector& A) const - { - dgSpatialVector tmp; - for (dgInt32 i = 0; i < 6; i++) { - tmp[i] = m_d[i] + A.m_d[i]; - } - return tmp; - } - - DG_INLINE dgSpatialVector operator* (const dgSpatialVector& A) const - { - dgSpatialVector tmp; - for (dgInt32 i = 0; i < 6; i++) { - tmp[i] = m_d[i] * A.m_d[i]; - } - return tmp; - } - - DG_INLINE dgFloat64 DotProduct(const dgSpatialVector& v) const - { - dgFloat64 ret = dgFloat64(0.0f); - for (dgInt32 i = 0; i < 6; i++) { - ret += m_d[i] * v.m_d[i]; - } - return ret; - } - - DG_INLINE dgSpatialVector Scale(dgFloat64 s) const - { - dgSpatialVector tmp; - for (dgInt32 i = 0; i < 6; i++) { - tmp[i] = m_d[i] * s; - } - return tmp; - } - - dgFloat64 m_d[6]; - static dgSpatialVector m_zero; -} DG_GCC_VECTOR_ALIGMENT; - -#endif - - -// ***************************************************************************************** -// -// 4 x 1 single precision vector class declaration -// -// ***************************************************************************************** -#ifdef _NEWTON_USE_DOUBLE -#define dgVector dgBigVector -#else - -class dgBigVector; -DG_MSC_VECTOR_ALIGNMENT -class dgVector -{ -public: - DG_INLINE dgVector() - { - } - - DG_INLINE dgVector(dgFloat32 val) - :m_type(vmovq_n_f32(val)) - { - } - - DG_INLINE dgVector(const dgVector& v) - :m_type(v.m_type) - { - } - - DG_INLINE dgVector(const float32x4_t type) - :m_type(type) - { - } - - DG_INLINE dgVector(const dgFloat32* const ptr) - //: m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w(ptr[3]) - :m_type(vld1q_f32 (ptr)) - { - dgAssert(dgCheckVector((*this))); - } - -#ifndef _NEWTON_USE_DOUBLE - DG_INLINE dgVector(const dgFloat64* const ptr) - :m_x(dgFloat32(ptr[0])) - ,m_y(dgFloat32(ptr[1])) - ,m_z(dgFloat32(ptr[2])) - ,m_w(dgFloat32(ptr[3])) - { - } -#endif - - DG_INLINE dgVector(dgFloat32 x, dgFloat32 y, dgFloat32 z, dgFloat32 w) - :m_x(x), m_y(y), m_z(z), m_w(w) - { - dgAssert(dgCheckVector((*this))); - } - - DG_INLINE dgVector(dgInt32 ix, dgInt32 iy, dgInt32 iz, dgInt32 iw) - : m_x(*((dgFloat32*)&ix)), m_y(*((dgFloat32*)&iy)), m_z(*((dgFloat32*)&iz)), m_w(*((dgFloat32*)&iw)) - { - } - -#ifndef _NEWTON_USE_DOUBLE - DG_INLINE dgVector(const dgBigVector& copy) - :m_x(dgFloat32(((dgFloat64*)©)[0])) - ,m_y(dgFloat32(((dgFloat64*)©)[1])) - ,m_z(dgFloat32(((dgFloat64*)©)[2])) - ,m_w(dgFloat32(((dgFloat64*)©)[3])) - { - dgAssert(dgCheckVector((*this))); - } -#endif - - DG_INLINE dgFloat32 GetScalar() const - { - return m_x; - } - - DG_INLINE void Store(dgFloat32* const dst) const - { - vst1q_f32(dst, m_type); - } - - DG_INLINE dgVector BroadcastX() const - { - return dgVector(m_x); - } - - DG_INLINE dgVector BroadcastY() const - { - return dgVector(m_y); - } - - DG_INLINE dgVector BroadcastZ() const - { - return dgVector(m_z); - } - - DG_INLINE dgVector BroadcastW() const - { - return dgVector(m_w); - } - - - DG_INLINE dgFloat32& operator[] (dgInt32 i) - { - dgAssert(i < 4); - dgAssert(i >= 0); - return (&m_x)[i]; - } - - DG_INLINE const dgFloat32& operator[] (dgInt32 i) const - { - dgAssert(i < 4); - dgAssert(i >= 0); - return (&m_x)[i]; - } - - DG_INLINE dgVector operator+ (const dgVector& A) const - { - return vaddq_f32(m_type, A.m_type); - } - - DG_INLINE dgVector operator- (const dgVector& A) const - { - return vsubq_f32(m_type, A.m_type); - } - - DG_INLINE dgVector operator* (const dgVector& A) const - { - return vmulq_f32(m_type, A.m_type); - } - - DG_INLINE dgVector& operator+= (const dgVector& A) - { - return (*this = vsubq_f32(m_type, A.m_type)); - } - - DG_INLINE dgVector& operator-= (const dgVector& A) - { - return (*this = vsubq_f32(m_type, A.m_type)); - } - - DG_INLINE dgVector& operator*= (const dgVector& A) - { - return (*this = vmulq_f32(m_type, A.m_type)); - } - - DG_INLINE dgVector MulAdd(const dgVector& A, const dgVector& B) const - { - //return *this + A * B; - //return vfmaq_f32(A.m_type, B.m_type, m_type); - return vmlaq_f32(m_type, A.m_type, B.m_type); - } - - DG_INLINE dgVector MulSub(const dgVector& A, const dgVector& B) const - { - //return *this - A * B; - return vmlsq_f32(m_type, A.m_type, B.m_type); - } - - DG_INLINE dgVector AddHorizontal() const - { - return dgVector(m_x + m_y + m_z + m_w); - //float32x2_t temp = vpadd_f32(vget_low_f32(m_type), vget_low_f32(m_type)); - //temp = vadd_f32(temp, vget_high_f32(m_type)); - //return vget_lane_f32(temp, 0); - } - - DG_INLINE dgVector Scale(dgFloat32 scale) const - { - return dgVector(m_x * scale, m_y * scale, m_z * scale, m_w * scale); - } - - // return dot product - DG_INLINE dgFloat32 DotProduct3(const dgVector& A) const - { - return m_x * A.m_x + m_y * A.m_y + m_z * A.m_z; - } - - // return cross product - DG_INLINE dgVector CrossProduct(const dgVector& B) const - { - return dgVector(m_y * B.m_z - m_z * B.m_y, - m_z * B.m_x - m_x * B.m_z, - m_x * B.m_y - m_y * B.m_x, m_w); - } - - DG_INLINE dgVector CrossProduct(const dgVector& A, const dgVector& B) const - { - dgFloat32 cofactor[3][3]; - dgFloat32 array[4][4]; - - const dgVector& me = *this; - for (dgInt32 i = 0; i < 4; i++) { - array[0][i] = me[i]; - array[1][i] = A[i]; - array[2][i] = B[i]; - array[3][i] = dgFloat32(1.0f); - } - - dgVector normal; - dgFloat32 sign = dgFloat32(-1.0f); - for (dgInt32 i = 0; i < 4; i++) { - - for (dgInt32 j = 0; j < 3; j++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 4; k++) { - if (k != i) { - cofactor[j][k0] = array[j][k]; - k0++; - } - } - } - dgFloat32 x = cofactor[0][0] * (cofactor[1][1] * cofactor[2][2] - cofactor[1][2] * cofactor[2][1]); - dgFloat32 y = cofactor[0][1] * (cofactor[1][2] * cofactor[2][0] - cofactor[1][0] * cofactor[2][2]); - dgFloat32 z = cofactor[0][2] * (cofactor[1][0] * cofactor[2][1] - cofactor[1][1] * cofactor[2][0]); - dgFloat32 det = x + y + z; - - normal[i] = sign * det; - sign *= dgFloat32(-1.0f); - } - - return normal; - } - - DG_INLINE dgVector GetInt() const - { - return dgVector(dgInt32(dgFloor(m_x)), dgInt32(dgFloor(m_y)), dgInt32(dgFloor(m_z)), dgInt32(dgFloor(m_w))); - } - - DG_INLINE dgVector TestZero() const - { - const dgInt32* const a = (dgInt32*)&m_x; - return dgVector((a[0] == 0) ? dgFloat32(-1.0f) : dgFloat32(1.0f), - (a[1] == 0) ? dgFloat32(-1.0f) : dgFloat32(1.0f), - (a[2] == 0) ? dgFloat32(-1.0f) : dgFloat32(1.0f), - (a[3] == 0) ? dgFloat32(-1.0f) : dgFloat32(1.0f)); - } - - - DG_INLINE dgVector Floor() const - { - return dgVector(dgFloor(m_x), dgFloor(m_y), dgFloor(m_z), dgFloor(m_w)); - } - - DG_INLINE dgVector DotProduct(const dgVector &A) const - { - return dgVector(m_x * A.m_x + m_y * A.m_y + m_z * A.m_z + m_w * A.m_w); - } - - DG_INLINE dgVector Reciproc() const - { - return dgVector(dgFloat32(1.0f) / m_x, dgFloat32(1.0f) / m_y, dgFloat32(1.0f) / m_z, dgFloat32(1.0f) / m_w); - } - - DG_INLINE dgVector Sqrt() const - { - return dgVector(dgSqrt(m_x), dgSqrt(m_y), dgSqrt(m_z), dgSqrt(m_w)); - } - - DG_INLINE dgVector InvSqrt() const - { - return dgVector(dgRsqrt(m_x), dgRsqrt(m_y), dgRsqrt(m_z), dgRsqrt(m_w)); - } - - DG_INLINE dgVector InvMagSqrt() const - { - return dgVector(dgRsqrt(DotProduct(*this).m_x)); - } - - DG_INLINE dgVector Normalize() const - { - dgAssert(m_w == dgFloat32(0.0f)); - const dgVector& me = *this; - return me * InvMagSqrt(); - } - - dgVector Abs() const - { - return vabsq_f32(m_type); - } - - dgFloat32 GetMax() const - { - return dgMax(dgMax(m_x, m_y), dgMax(m_z, m_w)); - } - - dgVector GetMax(const dgVector& data) const - { - return vmaxq_f32(m_type, data.m_type); - } - - dgVector GetMin(const dgVector& data) const - { - return vminq_f32(m_type, data.m_type); - } - - // relational operators - DG_INLINE dgVector operator== (const dgVector& data) const - { - return vceqq_f32(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator> (const dgVector& data) const - { - return vcgtq_f32(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator< (const dgVector& data) const - { - return vcltq_f32(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator>= (const dgVector& data) const - { - return vcgeq_f32(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator<= (const dgVector& data) const - { - return vcleq_f32(m_typeInt, data.m_typeInt); - } - - // logical operations - DG_INLINE dgVector operator& (const dgVector& data) const - { - return vandq_u32(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator| (const dgVector& data) const - { - return vorrq_u32(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector operator^ (const dgVector& data) const - { - return veorq_u32(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector AndNot(const dgVector& data) const - { - return vbicq_u32(m_typeInt, data.m_typeInt); - } - - DG_INLINE dgVector Select(const dgVector& data, const dgVector& mask) const - { - // (((b ^ a) & mask)^a) - return (*this) ^ (mask & (data ^ (*this))); - } - - DG_INLINE dgInt32 GetSignMask() const - { - const dgInt32* const a = (dgInt32*)&m_x; - return (((a[0] & 0x80000000) ? 1 : 0) | ((a[1] & 0x80000000) ? 2 : 0) | ((a[2] & 0x80000000) ? 4 : 0) | ((a[3] & 0x80000000) ? 8 : 0)); - } - - DG_INLINE dgVector ShiftRight() const - { - return dgVector(m_w, m_x, m_y, m_z); - } - - DG_INLINE dgVector ShiftTripleRight() const - { - return dgVector(m_z, m_x, m_y, m_w); - } - - DG_INLINE dgVector ShiftTripleLeft() const - { - return dgVector(m_y, m_z, m_x, m_w); - } - - DG_INLINE dgVector ShiftRightLogical(int bits) const - { - return dgVector(dgInt32(dgUnsigned32(m_ix) >> bits), dgInt32(dgUnsigned32(m_iy) >> bits), dgInt32(dgUnsigned32(m_iz) >> bits), dgInt32(dgUnsigned32(m_iw) >> bits)); - } - - DG_INLINE static void Transpose4x4(dgVector& dst0, dgVector& dst1, dgVector& dst2, dgVector& dst3, const dgVector& src0, const dgVector& src1, const dgVector& src2, const dgVector& src3) - { - float32x4x2_t vtrn1 = vzipq_f32(src0.m_type, src2.m_type); - float32x4x2_t vtrn2 = vzipq_f32(src1.m_type, src3.m_type); - float32x4x2_t res1 = vzipq_f32(vtrn1.val[0], vtrn2.val[0]); - float32x4x2_t res2 = vzipq_f32(vtrn1.val[1], vtrn2.val[1]); - dst0.m_type = res1.val[0]; - dst1.m_type = res1.val[1]; - dst2.m_type = res2.val[0]; - dst3.m_type = res2.val[1]; - } - - DG_CLASS_ALLOCATOR(allocator) - - union { - dgFloat32 m_f[4]; - dgInt32 m_i[4]; - float32x4_t m_type; - uint32x4_t m_typeInt; - struct { - dgFloat32 m_x; - dgFloat32 m_y; - dgFloat32 m_z; - dgFloat32 m_w; - }; - struct { - dgInt32 m_ix; - dgInt32 m_iy; - dgInt32 m_iz; - dgInt32 m_iw; - }; - }; - - static dgVector m_zero; - static dgVector m_one; - static dgVector m_wOne; - static dgVector m_half; - static dgVector m_two; - static dgVector m_three; - static dgVector m_negOne; - static dgVector m_xMask; - static dgVector m_yMask; - static dgVector m_zMask; - static dgVector m_wMask; - static dgVector m_epsilon; - static dgVector m_signMask; - static dgVector m_triplexMask; -} DG_GCC_VECTOR_ALIGNMENT; - -#endif - -DG_MSC_VECTOR_ALIGNMENT -class dgBigVector -{ -public: - DG_INLINE dgBigVector() - { - } - - DG_INLINE dgBigVector(dgFloat64 val) - :m_x(val), m_y(val), m_z(val), m_w(val) - { - } - - DG_INLINE dgBigVector(const dgBigVector& v) - : m_x(v.m_x), m_y(v.m_y), m_z(v.m_z), m_w(v.m_w) - { - } - -#ifndef _NEWTON_USE_DOUBLE - DG_INLINE dgBigVector(const dgVector& v) - : m_x(v.m_x), m_y(v.m_y), m_z(v.m_z), m_w(v.m_w) - { - } - - DG_INLINE dgBigVector(const dgFloat32* const ptr) - : m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w(dgFloat32(0.0f)) - { - dgAssert(dgCheckVector((*this))); - } -#endif - - DG_INLINE dgBigVector(const dgFloat64* const ptr) - :m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w(ptr[3]) - { - dgAssert(dgCheckVector((*this))); - } - - DG_INLINE dgBigVector(dgFloat64 x, dgFloat64 y, dgFloat64 z, dgFloat64 w) - : m_x(x), m_y(y), m_z(z), m_w(w) - { - dgAssert(dgCheckVector((*this))); - } - - DG_INLINE dgBigVector(dgInt32 ix, dgInt32 iy, dgInt32 iz, dgInt32 iw) - : m_ix(ix), m_iy(iy), m_iz(iz), m_iw(iw) - { - } - - DG_INLINE dgBigVector(dgInt64 ix, dgInt64 iy, dgInt64 iz, dgInt64 iw) - : m_ix(ix), m_iy(iy), m_iz(iz), m_iw(iw) - { - } - - DG_INLINE dgFloat64 GetScalar() const - { - return m_x; - } - - DG_INLINE void Store(dgFloat64* const dst) const - { - dst[0] = m_x; - dst[1] = m_y; - dst[2] = m_z; - dst[3] = m_w; - } - - DG_INLINE dgBigVector BroadcastX() const - { - return dgBigVector(m_x); - } - - DG_INLINE dgBigVector BroadcastY() const - { - return dgBigVector(m_y); - } - - DG_INLINE dgBigVector BroadcastZ() const - { - return dgBigVector(m_z); - } - - DG_INLINE dgBigVector BroadcastW() const - { - return dgBigVector(m_w); - } - - DG_INLINE dgFloat64& operator[] (dgInt32 i) - { - dgAssert(i < 4); - dgAssert(i >= 0); - return (&m_x)[i]; - } - - DG_INLINE const dgFloat64& operator[] (dgInt32 i) const - { - dgAssert(i < 4); - dgAssert(i >= 0); - return (&m_x)[i]; - } - - DG_INLINE dgBigVector operator+ (const dgBigVector& A) const - { - return dgBigVector(m_x + A.m_x, m_y + A.m_y, m_z + A.m_z, m_w + A.m_w); - } - - DG_INLINE dgBigVector operator- (const dgBigVector& A) const - { - return dgBigVector(m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w); - } - - DG_INLINE dgBigVector operator* (const dgBigVector& A) const - { - return dgBigVector(m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, m_w * A.m_w); - } - - DG_INLINE dgBigVector& operator+= (const dgBigVector& A) - { - return (*this = dgBigVector(m_x + A.m_x, m_y + A.m_y, m_z + A.m_z, m_w + A.m_w)); - } - - DG_INLINE dgBigVector& operator-= (const dgBigVector& A) - { - return (*this = dgBigVector(m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w)); - } - - DG_INLINE dgBigVector& operator*= (const dgBigVector& A) - { - return (*this = dgBigVector(m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, m_w * A.m_w)); - } - - DG_INLINE dgBigVector MulAdd(const dgBigVector& A, const dgBigVector& B) const - { - return *this + A * B; - } - - DG_INLINE dgBigVector MulSub(const dgVector& A, const dgBigVector& B) const - { - return *this - A * B; - } - - - DG_INLINE dgBigVector AddHorizontal() const - { - return dgBigVector(m_x + m_y + m_z + m_w); - } - - DG_INLINE dgBigVector Scale(dgFloat64 scale) const - { - return dgBigVector(m_x * scale, m_y * scale, m_z * scale, m_w * scale); - } - - // return dot product - DG_INLINE dgFloat64 DotProduct3(const dgBigVector& A) const - { - return m_x * A.m_x + m_y * A.m_y + m_z * A.m_z; - } - - // return cross product - DG_INLINE dgBigVector CrossProduct(const dgBigVector& B) const - { - return dgBigVector(m_y * B.m_z - m_z * B.m_y, m_z * B.m_x - m_x * B.m_z, m_x * B.m_y - m_y * B.m_x, m_w); - } - - DG_INLINE dgBigVector CrossProduct(const dgBigVector& A, const dgBigVector& B) const - { - dgFloat64 cofactor[3][3]; - dgFloat64 array[4][4]; - - const dgBigVector& me = *this; - for (dgInt32 i = 0; i < 4; i++) { - array[0][i] = me[i]; - array[1][i] = A[i]; - array[2][i] = B[i]; - array[3][i] = dgFloat32(1.0f); - } - - dgBigVector normal; - dgFloat64 sign = dgFloat64(-1.0f); - for (dgInt32 i = 0; i < 4; i++) { - - for (dgInt32 j = 0; j < 3; j++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 4; k++) { - if (k != i) { - cofactor[j][k0] = array[j][k]; - k0++; - } - } - } - dgFloat64 x = cofactor[0][0] * (cofactor[1][1] * cofactor[2][2] - cofactor[1][2] * cofactor[2][1]); - dgFloat64 y = cofactor[0][1] * (cofactor[1][2] * cofactor[2][0] - cofactor[1][0] * cofactor[2][2]); - dgFloat64 z = cofactor[0][2] * (cofactor[1][0] * cofactor[2][1] - cofactor[1][1] * cofactor[2][0]); - dgFloat64 det = x + y + z; - - normal[i] = sign * det; - sign *= dgFloat64(-1.0f); - } - - return normal; - } - - DG_INLINE dgBigVector GetInt() const - { - return dgBigVector(dgInt64(floor(m_x)), dgInt64(floor(m_y)), dgInt64(floor(m_z)), dgInt64(floor(m_w))); - } - - DG_INLINE dgBigVector TestZero() const - { - const dgInt64* const a = (dgInt64*)&m_x; - return dgBigVector((a[0] == 0) ? dgFloat64(-1.0f) : dgFloat64(1.0f), - (a[1] == 0) ? dgFloat64(-1.0f) : dgFloat64(1.0f), - (a[2] == 0) ? dgFloat64(-1.0f) : dgFloat64(1.0f), - (a[3] == 0) ? dgFloat64(-1.0f) : dgFloat64(1.0f)); - } - - - DG_INLINE dgBigVector Floor() const - { - return dgBigVector(floor(m_x), floor(m_y), floor(m_z), floor(m_w)); - } - - DG_INLINE dgBigVector DotProduct(const dgBigVector &A) const - { - return dgBigVector(m_x * A.m_x + m_y * A.m_y + m_z * A.m_z + m_w * A.m_w); - } - - DG_INLINE dgBigVector Reciproc() const - { - return dgBigVector(dgFloat64(1.0f) / m_x, dgFloat64(1.0f) / m_y, dgFloat64(1.0f) / m_z, dgFloat64(1.0f) / m_w); - } - - DG_INLINE dgBigVector Sqrt() const - { - return dgBigVector(sqrt(m_x), sqrt(m_y), sqrt(m_z), sqrt(m_w)); - } - - DG_INLINE dgBigVector InvSqrt() const - { - return dgBigVector(dgFloat64(1.0f) / sqrt(m_x), dgFloat64(1.0f) / sqrt(m_y), dgFloat64(1.0f) / sqrt(m_z), dgFloat64(1.0f) / sqrt(m_w)); - } - - DG_INLINE dgBigVector InvMagSqrt() const - { - return dgBigVector(dgFloat64(1.0f) / sqrt(DotProduct(*this).m_x)); - } - - DG_INLINE dgBigVector Normalize() const - { - dgAssert(m_w == dgFloat64(0.0f)); - //const dgBigVector& me = *this; - //return *this * dgBigVector (dgRsqrt(DotProduct(*this).m_x)); - return *this * InvMagSqrt(); - } - - dgBigVector Abs() const - { - return dgBigVector((m_x > dgFloat64(0.0f)) ? m_x : -m_x, - (m_y > dgFloat64(0.0f)) ? m_y : -m_y, - (m_z > dgFloat64(0.0f)) ? m_z : -m_z, - (m_w > dgFloat64(0.0f)) ? m_w : -m_w); - } - - dgFloat64 GetMax() const - { - return dgMax(dgMax(m_x, m_y), dgMax(m_z, m_w)); - } - - dgBigVector GetMax(const dgBigVector& data) const - { - return dgBigVector((m_x > data.m_x) ? m_x : data.m_x, - (m_y > data.m_y) ? m_y : data.m_y, - (m_z > data.m_z) ? m_z : data.m_z, - (m_w > data.m_w) ? m_w : data.m_w); - } - - dgBigVector GetMin(const dgBigVector& data) const - { - return dgBigVector((m_x < data.m_x) ? m_x : data.m_x, - (m_y < data.m_y) ? m_y : data.m_y, - (m_z < data.m_z) ? m_z : data.m_z, - (m_w < data.m_w) ? m_w : data.m_w); - } - - // relational operators - DG_INLINE dgBigVector operator== (const dgBigVector& data) const - { - return dgBigVector((m_x == data.m_x) ? dgInt64(-1) : dgInt64(0), - (m_y == data.m_y) ? dgInt64(-1) : dgInt64(0), - (m_z == data.m_z) ? dgInt64(-1) : dgInt64(0), - (m_w == data.m_w) ? dgInt64(-1) : dgInt64(0)); - } - - DG_INLINE dgBigVector operator> (const dgBigVector& data) const - { - return dgBigVector((m_x > data.m_x) ? dgInt64(-1) : dgInt64(0), - (m_y > data.m_y) ? dgInt64(-1) : dgInt64(0), - (m_z > data.m_z) ? dgInt64(-1) : dgInt64(0), - (m_w > data.m_w) ? dgInt64(-1) : dgInt64(0)); - } - - DG_INLINE dgBigVector operator< (const dgBigVector& data) const - { - return dgBigVector((m_x < data.m_x) ? dgInt64(-1) : dgInt64(0), - (m_y < data.m_y) ? dgInt64(-1) : dgInt64(0), - (m_z < data.m_z) ? dgInt64(-1) : dgInt64(0), - (m_w < data.m_w) ? dgInt64(-1) : dgInt64(0)); - } - - DG_INLINE dgBigVector operator>= (const dgBigVector& data) const - { - return dgBigVector((m_x >= data.m_x) ? dgInt64(-1) : dgInt64(0), - (m_y >= data.m_y) ? dgInt64(-1) : dgInt64(0), - (m_z >= data.m_z) ? dgInt64(-1) : dgInt64(0), - (m_w >= data.m_w) ? dgInt64(-1) : dgInt64(0)); - } - - DG_INLINE dgBigVector operator<= (const dgBigVector& data) const - { - return dgBigVector((m_x <= data.m_x) ? dgInt64(-1) : dgInt64(0), - (m_y <= data.m_y) ? dgInt64(-1) : dgInt64(0), - (m_z <= data.m_z) ? dgInt64(-1) : dgInt64(0), - (m_w <= data.m_w) ? dgInt64(-1) : dgInt64(0)); - } - - - // logical operations - DG_INLINE dgBigVector operator& (const dgBigVector& data) const - { - const dgInt64* const a = (dgInt64*)&m_x; - const dgInt64* const b = (dgInt64*)&data.m_x; - return dgBigVector(a[0] & b[0], a[1] & b[1], a[2] & b[2], a[3] & b[3]); - } - - DG_INLINE dgBigVector operator| (const dgBigVector& data) const - { - const dgInt64* const a = (dgInt64*)&m_x; - const dgInt64* const b = (dgInt64*)&data.m_x; - return dgBigVector(a[0] | b[0], a[1] | b[1], a[2] | b[2], a[3] | b[3]); - } - - DG_INLINE dgBigVector operator^ (const dgBigVector& data) const - { - const dgInt64* const a = (dgInt64*)&m_x; - const dgInt64* const b = (dgInt64*)&data.m_x; - return dgBigVector(a[0] ^ b[0], a[1] ^ b[1], a[2] ^ b[2], a[3] ^ b[3]); - } - - DG_INLINE dgBigVector AndNot(const dgBigVector& data) const - { - const dgInt64* const a = (dgInt64*)&m_x; - const dgInt64* const b = (dgInt64*)&data.m_x; - return dgBigVector(a[0] & ~b[0], a[1] & ~b[1], a[2] & ~b[2], a[3] & ~b[3]); - } - - DG_INLINE dgBigVector Select(const dgBigVector& data, const dgBigVector& mask) const - { - // (((b ^ a) & mask)^a) - return (*this) ^ (mask & (data ^ (*this))); - } - - DG_INLINE dgInt32 GetSignMask() const - { - const dgInt64* const a = (dgInt64*)&m_x; - return (((a[0] >> 63) ? 1 : 0) | ((a[1] >> 63) ? 2 : 0) | ((a[2] >> 63) ? 4 : 0) | ((a[3] >> 63) ? 8 : 0)); - } - - DG_INLINE dgVector ShiftRight() const - { - return dgBigVector(m_w, m_x, m_y, m_z); - } - - DG_INLINE dgBigVector ShiftTripleRight() const - { - return dgBigVector(m_z, m_x, m_y, m_w); - } - - DG_INLINE dgBigVector ShiftTripleLeft() const - { - return dgBigVector(m_y, m_z, m_x, m_w); - } - - DG_INLINE dgBigVector ShiftRightLogical(int bits) const - { - return dgBigVector(dgInt64(dgUnsigned64(m_ix) >> bits), dgInt64(dgUnsigned64(m_iy) >> bits), dgInt64(dgUnsigned64(m_iz) >> bits), dgInt64(dgUnsigned64(m_iw) >> bits)); - } - - DG_INLINE static void Transpose4x4(dgBigVector& dst0, dgBigVector& dst1, dgBigVector& dst2, dgBigVector& dst3, const dgBigVector& src0, const dgBigVector& src1, const dgBigVector& src2, const dgBigVector& src3) - { - dgBigVector tmp0(src0); - dgBigVector tmp1(src1); - dgBigVector tmp2(src2); - dgBigVector tmp3(src3); - - dst0 = dgBigVector(tmp0.m_x, tmp1.m_x, tmp2.m_x, tmp3.m_x); - dst1 = dgBigVector(tmp0.m_y, tmp1.m_y, tmp2.m_y, tmp3.m_y); - dst2 = dgBigVector(tmp0.m_z, tmp1.m_z, tmp2.m_z, tmp3.m_z); - dst3 = dgBigVector(tmp0.m_w, tmp1.m_w, tmp2.m_w, tmp3.m_w); - } - - DG_CLASS_ALLOCATOR(allocator) - - union - { - dgInt64 m_i[4]; - struct - { - dgFloat64 m_x; - dgFloat64 m_y; - dgFloat64 m_z; - dgFloat64 m_w; - }; - struct - { - dgInt64 m_ix; - dgInt64 m_iy; - dgInt64 m_iz; - dgInt64 m_iw; - }; - }; - - static dgBigVector m_zero; - static dgBigVector m_one; - static dgBigVector m_wOne; - static dgBigVector m_half; - static dgBigVector m_two; - static dgBigVector m_three; - static dgBigVector m_negOne; - static dgBigVector m_xMask; - static dgBigVector m_yMask; - static dgBigVector m_zMask; - static dgBigVector m_wMask; - static dgBigVector m_epsilon; - static dgBigVector m_signMask; - static dgBigVector m_triplexMask; -} DG_GCC_VECTOR_ALIGNMENT; - - -DG_MSC_VECTOR_ALIGNMENT -class dgSpatialVector -{ - public: - DG_INLINE dgSpatialVector() - { - } - - DG_INLINE dgSpatialVector(const dgFloat32 a) - { - for (dgInt32 i = 0; i < 6; i++) { - m_d[i] = a; - } - } - - DG_INLINE dgSpatialVector(const dgVector& low, const dgVector& high) - { - for (dgInt32 i = 0; i < 3; i++) { - m_d[i] = low[i]; - m_d[i + 3] = high[i]; - } - } - - DG_INLINE dgSpatialVector(const dgSpatialVector& src) - { - for (dgInt32 i = 0; i < 6; i++) { - m_d[i] = src[i]; - } - } - - DG_INLINE dgFloat64& operator[] (dgInt32 i) - { - dgAssert(i < 6); - dgAssert(i >= 0); - return m_d[i]; - } - - DG_INLINE const dgFloat64& operator[] (dgInt32 i) const - { - dgAssert(i < 6); - dgAssert(i >= 0); - return m_d[i]; - } - - DG_INLINE dgSpatialVector operator+ (const dgSpatialVector& A) const - { - dgSpatialVector tmp; - for (dgInt32 i = 0; i < 6; i++) { - tmp[i] = m_d[i] + A.m_d[i]; - } - return tmp; - } - - DG_INLINE dgSpatialVector operator* (const dgSpatialVector& A) const - { - dgSpatialVector tmp; - for (dgInt32 i = 0; i < 6; i++) { - tmp[i] = m_d[i] * A.m_d[i]; - } - return tmp; - } - - DG_INLINE dgFloat64 DotProduct(const dgSpatialVector& v) const - { - dgFloat64 ret = dgFloat64(0.0f); - for (dgInt32 i = 0; i < 6; i++) { - ret += m_d[i] * v.m_d[i]; - } - return ret; - } - - DG_INLINE dgSpatialVector Scale(dgFloat64 s) const - { - dgSpatialVector tmp; - for (dgInt32 i = 0; i < 6; i++) { - tmp[i] = m_d[i] * s; - } - return tmp; - } - - dgFloat64 m_d[6]; - static dgSpatialVector m_zero; -} DG_GCC_VECTOR_ALIGNMENT; - -#endif \ No newline at end of file diff --git a/thirdparty/src/newton/dgCore/dgVectorScalar.h b/thirdparty/src/newton/dgCore/dgVectorScalar.h deleted file mode 100644 index c7b3f756a..000000000 --- a/thirdparty/src/newton/dgCore/dgVectorScalar.h +++ /dev/null @@ -1,1002 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgVectorScalar__ -#define __dgVectorScalar__ - -// ***************************************************************************************** -// -// 4 x 1 single precision vector class declaration -// -// ***************************************************************************************** -#ifdef _NEWTON_USE_DOUBLE - #define dgVector dgBigVector -#else - -class dgBigVector; -DG_MSC_VECTOR_ALIGNMENT -class dgVector -{ - public: - DG_INLINE dgVector() - { - } - - DG_INLINE dgVector(dgFloat32 val) - :m_x(val), m_y(val), m_z(val), m_w(val) - { - } - - DG_INLINE dgVector (const dgVector& v) - :m_x(v.m_x), m_y(v.m_y), m_z(v.m_z), m_w(v.m_w) - { - //dgAssert (dgCheckVector ((*this))); - } - - DG_INLINE dgVector (const dgFloat32* const ptr) - :m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w (ptr[3]) - { - dgAssert (dgCheckVector ((*this))); - } - -#ifndef _NEWTON_USE_DOUBLE - DG_INLINE dgVector(const dgFloat64* const ptr) - :m_x(dgFloat32(ptr[0])) - ,m_y(dgFloat32(ptr[1])) - ,m_z(dgFloat32(ptr[2])) - ,m_w(dgFloat32(ptr[3])) - { - } -#endif - - - DG_INLINE dgVector (dgFloat32 x, dgFloat32 y, dgFloat32 z, dgFloat32 w) - :m_x(x), m_y(y), m_z(z), m_w(w) - { - dgAssert (dgCheckVector ((*this))); - } - - DG_INLINE dgVector (dgInt32 ix, dgInt32 iy, dgInt32 iz, dgInt32 iw) - :m_x(*((dgFloat32*)&ix)), m_y(*((dgFloat32*)&iy)), m_z(*((dgFloat32*)&iz)), m_w(*((dgFloat32*)&iw)) - { - } - -#ifndef _NEWTON_USE_DOUBLE - DG_INLINE dgVector (const dgBigVector& copy) - :m_x(dgFloat32 (((dgFloat64*)©)[0])) - ,m_y(dgFloat32 (((dgFloat64*)©)[1])) - ,m_z(dgFloat32 (((dgFloat64*)©)[2])) - ,m_w(dgFloat32 (((dgFloat64*)©)[3])) - { - dgAssert (dgCheckVector ((*this))); - } -#endif - - DG_INLINE dgFloat32 GetScalar () const - { - return m_x; - } - - DG_INLINE void Store (dgFloat32* const dst) const - { - dst[0] = m_x; - dst[1] = m_y; - dst[2] = m_z; - dst[3] = m_w; - } - - DG_INLINE dgVector BroadcastX () const - { - return dgVector (m_x); - } - - DG_INLINE dgVector BroadcastY () const - { - return dgVector (m_y); - } - - DG_INLINE dgVector BroadcastZ () const - { - return dgVector (m_z); - } - - DG_INLINE dgVector BroadcastW () const - { - return dgVector (m_w); - } - - - DG_INLINE dgFloat32& operator[] (dgInt32 i) - { - dgAssert (i < 4); - dgAssert (i >= 0); - return (&m_x)[i]; - } - - DG_INLINE const dgFloat32& operator[] (dgInt32 i) const - { - dgAssert (i < 4); - dgAssert (i >= 0); - return (&m_x)[i]; - } - - DG_INLINE dgVector operator+ (const dgVector& A) const - { - return dgVector (m_x + A.m_x, m_y + A.m_y, m_z + A.m_z, m_w + A.m_w); - } - - DG_INLINE dgVector operator- (const dgVector& A) const - { - return dgVector (m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w); - } - - DG_INLINE dgVector operator* (const dgVector& A) const - { - return dgVector(m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, m_w * A.m_w); - } - - DG_INLINE dgVector& operator+= (const dgVector& A) - { - return (*this = dgVector (m_x + A.m_x, m_y + A.m_y, m_z + A.m_z, m_w + A.m_w)); - } - - DG_INLINE dgVector& operator-= (const dgVector& A) - { - return (*this = dgVector (m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w)); - } - - DG_INLINE dgVector& operator*= (const dgVector& A) - { - return (*this = dgVector(m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, m_w * A.m_w)); - } - - DG_INLINE dgVector MulAdd(const dgVector& A, const dgVector& B) const - { - return *this + A * B; - } - - DG_INLINE dgVector MulSub(const dgVector& A, const dgVector& B) const - { - return *this - A * B; - } - - DG_INLINE dgVector AddHorizontal () const - { - return dgVector (m_x + m_y + m_z + m_w); - } - - DG_INLINE dgVector Scale (dgFloat32 scale) const - { - return dgVector (m_x * scale, m_y * scale, m_z * scale, m_w * scale); - } - - // return dot product - DG_INLINE dgFloat32 DotProduct3 (const dgVector& A) const - { - return m_x * A.m_x + m_y * A.m_y + m_z * A.m_z; - } - - // return cross product - DG_INLINE dgVector CrossProduct (const dgVector& B) const - { - return dgVector (m_y * B.m_z - m_z * B.m_y, - m_z * B.m_x - m_x * B.m_z, - m_x * B.m_y - m_y * B.m_x, m_w); - } - - DG_INLINE dgVector CrossProduct (const dgVector& A, const dgVector& B) const - { - dgFloat32 cofactor[3][3]; - dgFloat32 array[4][4]; - - const dgVector& me = *this; - for (dgInt32 i = 0; i < 4; i ++) { - array[0][i] = me[i]; - array[1][i] = A[i]; - array[2][i] = B[i]; - array[3][i] = dgFloat32 (1.0f); - } - - dgVector normal; - dgFloat32 sign = dgFloat32 (-1.0f); - for (dgInt32 i = 0; i < 4; i ++) { - - for (dgInt32 j = 0; j < 3; j ++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 4; k ++) { - if (k != i) { - cofactor[j][k0] = array[j][k]; - k0 ++; - } - } - } - dgFloat32 x = cofactor[0][0] * (cofactor[1][1] * cofactor[2][2] - cofactor[1][2] * cofactor[2][1]); - dgFloat32 y = cofactor[0][1] * (cofactor[1][2] * cofactor[2][0] - cofactor[1][0] * cofactor[2][2]); - dgFloat32 z = cofactor[0][2] * (cofactor[1][0] * cofactor[2][1] - cofactor[1][1] * cofactor[2][0]); - dgFloat32 det = x + y + z; - - normal[i] = sign * det; - sign *= dgFloat32 (-1.0f); - } - - return normal; - } - - DG_INLINE dgVector GetInt () const - { - return dgVector (dgInt32 (dgFloor (m_x)), dgInt32(dgFloor (m_y)), dgInt32(dgFloor (m_z)), dgInt32 (dgFloor (m_w))); - } - - DG_INLINE dgVector TestZero() const - { - const dgInt32* const a = (dgInt32*)&m_x; - return dgVector ((a[0] == 0) ? dgFloat32 (-1.0f) : dgFloat32 (1.0f), - (a[1] == 0) ? dgFloat32 (-1.0f) : dgFloat32 (1.0f), - (a[2] == 0) ? dgFloat32 (-1.0f) : dgFloat32 (1.0f), - (a[3] == 0) ? dgFloat32 (-1.0f) : dgFloat32 (1.0f)); - } - - - DG_INLINE dgVector Floor () const - { - return dgVector (dgFloor (m_x), dgFloor (m_y), dgFloor (m_z), dgFloor (m_w)); - } - - DG_INLINE dgVector DotProduct (const dgVector &A) const - { - return dgVector (m_x * A.m_x + m_y * A.m_y + m_z * A.m_z + m_w * A.m_w); - } - - DG_INLINE dgVector Reciproc () const - { - return dgVector (dgFloat32 (1.0f) / m_x, dgFloat32 (1.0f) / m_y, dgFloat32 (1.0f) / m_z, dgFloat32 (1.0f) / m_w); - } - - DG_INLINE dgVector Sqrt () const - { - return dgVector (dgSqrt (m_x), dgSqrt (m_y), dgSqrt (m_z), dgSqrt (m_w)); - } - - DG_INLINE dgVector InvSqrt () const - { - return dgVector (dgRsqrt (m_x), dgRsqrt (m_y), dgRsqrt (m_z), dgRsqrt (m_w)); - } - - DG_INLINE dgVector InvMagSqrt () const - { - return dgVector (dgRsqrt (DotProduct(*this).m_x)); - } - - DG_INLINE dgVector Normalize () const - { - dgAssert (m_w == dgFloat32 (0.0f)); - //return *this * dgVector (dgRsqrt (DotProduct(*this).m_x)); - //return Scale (dgRsqrt (DotProduct(*this).GetScalar())); - const dgVector& me = *this; - return me * InvMagSqrt(); - } - - dgVector Abs () const - { - return dgVector ((m_x > dgFloat32 (0.0f)) ? m_x : -m_x, - (m_y > dgFloat32 (0.0f)) ? m_y : -m_y, - (m_z > dgFloat32 (0.0f)) ? m_z : -m_z, - (m_w > dgFloat32 (0.0f)) ? m_w : -m_w); - } - - dgFloat32 GetMax () const - { - return dgMax(dgMax(m_x, m_y), dgMax(m_z, m_w)); - } - - dgVector GetMax (const dgVector& data) const - { - return dgVector ((m_x > data.m_x) ? m_x : data.m_x, - (m_y > data.m_y) ? m_y : data.m_y, - (m_z > data.m_z) ? m_z : data.m_z, - (m_w > data.m_w) ? m_w : data.m_w); - } - - dgVector GetMin (const dgVector& data) const - { - return dgVector ((m_x < data.m_x) ? m_x : data.m_x, - (m_y < data.m_y) ? m_y : data.m_y, - (m_z < data.m_z) ? m_z : data.m_z, - (m_w < data.m_w) ? m_w : data.m_w); - } - - - // relational operators - DG_INLINE dgVector operator== (const dgVector& data) const - { - return dgVector ((m_x == data.m_x) ? dgInt32 (0xffffffff) : 0, - (m_y == data.m_y) ? dgInt32 (0xffffffff) : 0, - (m_z == data.m_z) ? dgInt32 (0xffffffff) : 0, - (m_w == data.m_w) ? dgInt32 (0xffffffff) : 0); - } - - DG_INLINE dgVector operator> (const dgVector& data) const - { - return dgVector ((m_x > data.m_x) ? dgInt32 (0xffffffff) : 0, - (m_y > data.m_y) ? dgInt32 (0xffffffff) : 0, - (m_z > data.m_z) ? dgInt32 (0xffffffff) : 0, - (m_w > data.m_w) ? dgInt32 (0xffffffff) : 0); - } - - DG_INLINE dgVector operator< (const dgVector& data) const - { - return dgVector ((m_x < data.m_x) ? dgInt32 (0xffffffff) : 0, - (m_y < data.m_y) ? dgInt32 (0xffffffff) : 0, - (m_z < data.m_z) ? dgInt32 (0xffffffff) : 0, - (m_w < data.m_w) ? dgInt32 (0xffffffff) : 0); - } - - DG_INLINE dgVector operator>= (const dgVector& data) const - { - return dgVector ((m_x >= data.m_x) ? dgInt32 (0xffffffff) : 0, - (m_y >= data.m_y) ? dgInt32 (0xffffffff) : 0, - (m_z >= data.m_z) ? dgInt32 (0xffffffff) : 0, - (m_w >= data.m_w) ? dgInt32 (0xffffffff) : 0); - } - - DG_INLINE dgVector operator<= (const dgVector& data) const - { - return dgVector ((m_x <= data.m_x) ? dgInt32 (0xffffffff) : 0, - (m_y <= data.m_y) ? dgInt32 (0xffffffff) : 0, - (m_z <= data.m_z) ? dgInt32 (0xffffffff) : 0, - (m_w <= data.m_w) ? dgInt32 (0xffffffff) : 0); - } - - - // logical operations - DG_INLINE dgVector operator& (const dgVector& data) const - { - const dgInt32* const a = (dgInt32*)&m_x; - const dgInt32* const b = (dgInt32*)&data.m_x; - return dgVector (a[0] & b[0], a[1] & b[1], a[2] & b[2], a[3] & b[3]); - } - - DG_INLINE dgVector operator| (const dgVector& data) const - { - const dgInt32* const a = (dgInt32*)&m_x; - const dgInt32* const b = (dgInt32*)&data.m_x; - return dgVector (a[0] | b[0], a[1] | b[1], a[2] | b[2], a[3] | b[3]); - } - - DG_INLINE dgVector operator^ (const dgVector& data) const - { - const dgInt32* const a = (dgInt32*)&m_x; - const dgInt32* const b = (dgInt32*)&data.m_x; - return dgVector (a[0] ^ b[0], a[1] ^ b[1], a[2] ^ b[2], a[3] ^ b[3]); - } - - DG_INLINE dgVector AndNot (const dgVector& data) const - { - const dgInt32* const a = (dgInt32*)&m_x; - const dgInt32* const b = (dgInt32*)&data.m_x; - return dgVector (a[0] & ~b[0], a[1] & ~b[1], a[2] & ~b[2], a[3] & ~b[3]); - } - - DG_INLINE dgVector Select (const dgVector& data, const dgVector& mask) const - { - // (((b ^ a) & mask)^a) - return (*this) ^ (mask & (data ^ (*this))); - } - - DG_INLINE dgInt32 GetSignMask() const - { - const dgInt32* const a = (dgInt32*)&m_x; - return (((a[0] & 0x80000000) ? 1 : 0) | ((a[1] & 0x80000000) ? 2 : 0) | ((a[2] & 0x80000000) ? 4 : 0) | ((a[3] & 0x80000000) ? 8 : 0)); - } - - DG_INLINE dgVector ShiftRight() const - { - return dgVector (m_w, m_x, m_y, m_z); - } - - DG_INLINE dgVector ShiftTripleRight () const - { - return dgVector (m_z, m_x, m_y, m_w); - } - - DG_INLINE dgVector ShiftTripleLeft () const - { - return dgVector (m_y, m_z, m_x, m_w); - } - - DG_INLINE dgVector ShiftRightLogical (int bits) const - { - return dgVector (dgInt32 (dgUnsigned32 (m_ix) >> bits), dgInt32 (dgUnsigned32 (m_iy) >> bits), dgInt32 (dgUnsigned32 (m_iz) >> bits), dgInt32 (dgUnsigned32 (m_iw) >> bits)); - } - - DG_INLINE static void Transpose4x4 (dgVector& dst0, dgVector& dst1, dgVector& dst2, dgVector& dst3, const dgVector& src0, const dgVector& src1, const dgVector& src2, const dgVector& src3) - { - dgVector tmp0 (src0); - dgVector tmp1 (src1); - dgVector tmp2 (src2); - dgVector tmp3 (src3); - - dst0 = dgVector (tmp0.m_x, tmp1.m_x, tmp2.m_x, tmp3.m_x); - dst1 = dgVector (tmp0.m_y, tmp1.m_y, tmp2.m_y, tmp3.m_y); - dst2 = dgVector (tmp0.m_z, tmp1.m_z, tmp2.m_z, tmp3.m_z); - dst3 = dgVector (tmp0.m_w, tmp1.m_w, tmp2.m_w, tmp3.m_w); - } - - DG_CLASS_ALLOCATOR(allocator) - - union { - dgInt32 m_i[4]; - struct { - dgFloat32 m_x; - dgFloat32 m_y; - dgFloat32 m_z; - dgFloat32 m_w; - }; - struct { - dgInt32 m_ix; - dgInt32 m_iy; - dgInt32 m_iz; - dgInt32 m_iw; - }; - }; - - static dgVector m_zero; - static dgVector m_one; - static dgVector m_wOne; - static dgVector m_half; - static dgVector m_two; - static dgVector m_three; - static dgVector m_negOne; - static dgVector m_xMask; - static dgVector m_yMask; - static dgVector m_zMask; - static dgVector m_wMask; - static dgVector m_epsilon; - static dgVector m_signMask; - static dgVector m_triplexMask; -} DG_GCC_VECTOR_ALIGNMENT; - -#endif - -DG_MSC_VECTOR_ALIGNMENT -class dgBigVector -{ - public: - DG_INLINE dgBigVector() - { - } - - DG_INLINE dgBigVector(dgFloat64 val) - :m_x(val), m_y(val), m_z(val), m_w(val) - { - } - - DG_INLINE dgBigVector (const dgBigVector& v) - :m_x(v.m_x), m_y(v.m_y), m_z(v.m_z), m_w(v.m_w) - { - } - -#ifndef _NEWTON_USE_DOUBLE - DG_INLINE dgBigVector (const dgVector& v) - :m_x(v.m_x), m_y(v.m_y), m_z(v.m_z), m_w(v.m_w) - { - } - - DG_INLINE dgBigVector (const dgFloat32* const ptr) - :m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w (dgFloat32 (0.0f)) - { - dgAssert (dgCheckVector ((*this))); - } -#endif - - DG_INLINE dgBigVector (const dgFloat64* const ptr) - :m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w (ptr[3]) - { - dgAssert (dgCheckVector ((*this))); - } - - DG_INLINE dgBigVector (dgFloat64 x, dgFloat64 y, dgFloat64 z, dgFloat64 w) - :m_x(x), m_y(y), m_z(z), m_w(w) - { - dgAssert (dgCheckVector ((*this))); - } - - DG_INLINE dgBigVector (dgInt32 ix, dgInt32 iy, dgInt32 iz, dgInt32 iw) - :m_ix(ix), m_iy(iy), m_iz(iz), m_iw(iw) - { - } - - DG_INLINE dgBigVector (dgInt64 ix, dgInt64 iy, dgInt64 iz, dgInt64 iw) - :m_ix(ix), m_iy(iy), m_iz(iz), m_iw(iw) - { - } - - DG_INLINE dgFloat64 GetScalar () const - { - return m_x; - } - - DG_INLINE void Store (dgFloat64* const dst) const - { - dst[0] = m_x; - dst[1] = m_y; - dst[2] = m_z; - dst[3] = m_w; - } - - DG_INLINE dgBigVector BroadcastX () const - { - return dgBigVector (m_x); - } - - DG_INLINE dgBigVector BroadcastY () const - { - return dgBigVector (m_y); - } - - DG_INLINE dgBigVector BroadcastZ () const - { - return dgBigVector (m_z); - } - - DG_INLINE dgBigVector BroadcastW () const - { - return dgBigVector (m_w); - } - - - DG_INLINE dgFloat64& operator[] (dgInt32 i) - { - dgAssert (i < 4); - dgAssert (i >= 0); - return (&m_x)[i]; - } - - DG_INLINE const dgFloat64& operator[] (dgInt32 i) const - { - dgAssert (i < 4); - dgAssert (i >= 0); - return (&m_x)[i]; - } - - DG_INLINE dgBigVector operator+ (const dgBigVector& A) const - { - return dgBigVector (m_x + A.m_x, m_y + A.m_y, m_z + A.m_z, m_w + A.m_w); - } - - DG_INLINE dgBigVector operator- (const dgBigVector& A) const - { - return dgBigVector (m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w); - } - - DG_INLINE dgBigVector operator* (const dgBigVector& A) const - { - return dgBigVector(m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, m_w * A.m_w); - } - - DG_INLINE dgBigVector& operator+= (const dgBigVector& A) - { - return (*this = dgBigVector (m_x + A.m_x, m_y + A.m_y, m_z + A.m_z, m_w + A.m_w)); - } - - DG_INLINE dgBigVector& operator-= (const dgBigVector& A) - { - return (*this = dgBigVector (m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w)); - } - - DG_INLINE dgBigVector& operator*= (const dgBigVector& A) - { - return (*this = dgBigVector(m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, m_w * A.m_w)); - } - - DG_INLINE dgBigVector MulAdd(const dgBigVector& A, const dgBigVector& B) const - { - return *this + A * B; - } - - DG_INLINE dgBigVector MulSub(const dgVector& A, const dgBigVector& B) const - { - return *this - A * B; - } - - - DG_INLINE dgBigVector AddHorizontal () const - { - return dgBigVector (m_x + m_y + m_z + m_w); - } - - DG_INLINE dgBigVector Scale (dgFloat64 scale) const - { - return dgBigVector (m_x * scale, m_y * scale, m_z * scale, m_w * scale); - } - - // return dot product - DG_INLINE dgFloat64 DotProduct3 (const dgBigVector& A) const - { - return m_x * A.m_x + m_y * A.m_y + m_z * A.m_z; - } - - // return cross product - DG_INLINE dgBigVector CrossProduct (const dgBigVector& B) const - { - return dgBigVector (m_y * B.m_z - m_z * B.m_y, m_z * B.m_x - m_x * B.m_z, m_x * B.m_y - m_y * B.m_x, m_w); - } - - DG_INLINE dgBigVector CrossProduct (const dgBigVector& A, const dgBigVector& B) const - { - dgFloat64 cofactor[3][3]; - dgFloat64 array[4][4]; - - const dgBigVector& me = *this; - for (dgInt32 i = 0; i < 4; i ++) { - array[0][i] = me[i]; - array[1][i] = A[i]; - array[2][i] = B[i]; - array[3][i] = dgFloat32 (1.0f); - } - - dgBigVector normal; - dgFloat64 sign = dgFloat64 (-1.0f); - for (dgInt32 i = 0; i < 4; i ++) { - - for (dgInt32 j = 0; j < 3; j ++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 4; k ++) { - if (k != i) { - cofactor[j][k0] = array[j][k]; - k0 ++; - } - } - } - dgFloat64 x = cofactor[0][0] * (cofactor[1][1] * cofactor[2][2] - cofactor[1][2] * cofactor[2][1]); - dgFloat64 y = cofactor[0][1] * (cofactor[1][2] * cofactor[2][0] - cofactor[1][0] * cofactor[2][2]); - dgFloat64 z = cofactor[0][2] * (cofactor[1][0] * cofactor[2][1] - cofactor[1][1] * cofactor[2][0]); - dgFloat64 det = x + y + z; - - normal[i] = sign * det; - sign *= dgFloat64 (-1.0f); - } - - return normal; - } - - DG_INLINE dgBigVector GetInt () const - { - return dgBigVector (dgInt64 (floor (m_x)), dgInt64(floor (m_y)), dgInt64(floor (m_z)), dgInt64 (floor (m_w))); - } - - DG_INLINE dgBigVector TestZero() const - { - const dgInt64* const a = (dgInt64*)&m_x; - return dgBigVector ((a[0] == 0) ? dgFloat64 (-1.0f) : dgFloat64 (1.0f), - (a[1] == 0) ? dgFloat64 (-1.0f) : dgFloat64 (1.0f), - (a[2] == 0) ? dgFloat64 (-1.0f) : dgFloat64 (1.0f), - (a[3] == 0) ? dgFloat64 (-1.0f) : dgFloat64 (1.0f)); - } - - - DG_INLINE dgBigVector Floor () const - { - return dgBigVector (floor (m_x), floor (m_y), floor (m_z), floor (m_w)); - } - - DG_INLINE dgBigVector DotProduct (const dgBigVector &A) const - { - return dgBigVector (m_x * A.m_x + m_y * A.m_y + m_z * A.m_z + m_w * A.m_w); - } - - DG_INLINE dgBigVector Reciproc () const - { - return dgBigVector (dgFloat64 (1.0f) / m_x, dgFloat64 (1.0f) / m_y, dgFloat64 (1.0f) / m_z, dgFloat64 (1.0f) / m_w); - } - - DG_INLINE dgBigVector Sqrt () const - { - return dgBigVector (sqrt (m_x), sqrt (m_y), sqrt (m_z), sqrt (m_w)); - } - - DG_INLINE dgBigVector InvSqrt () const - { - return dgBigVector (dgFloat64 (1.0f) / sqrt (m_x), dgFloat64 (1.0f) / sqrt (m_y), dgFloat64 (1.0f) / sqrt (m_z), dgFloat64 (1.0f) / sqrt (m_w)); - } - - DG_INLINE dgBigVector InvMagSqrt () const - { - return dgBigVector (dgFloat64 (1.0f) / sqrt (DotProduct(*this).m_x)); - } - - DG_INLINE dgBigVector Normalize() const - { - dgAssert (m_w == dgFloat64 (0.0f)); - //const dgBigVector& me = *this; - //return *this * dgBigVector (dgRsqrt(DotProduct(*this).m_x)); - return *this * InvMagSqrt(); - } - - dgBigVector Abs () const - { - return dgBigVector ((m_x > dgFloat64 (0.0f)) ? m_x : -m_x, - (m_y > dgFloat64 (0.0f)) ? m_y : -m_y, - (m_z > dgFloat64 (0.0f)) ? m_z : -m_z, - (m_w > dgFloat64 (0.0f)) ? m_w : -m_w); - } - - dgFloat64 GetMax () const - { - return dgMax(dgMax(m_x, m_y), dgMax(m_z, m_w)); - } - - dgBigVector GetMax (const dgBigVector& data) const - { - return dgBigVector ((m_x > data.m_x) ? m_x : data.m_x, - (m_y > data.m_y) ? m_y : data.m_y, - (m_z > data.m_z) ? m_z : data.m_z, - (m_w > data.m_w) ? m_w : data.m_w); - } - - dgBigVector GetMin (const dgBigVector& data) const - { - return dgBigVector ((m_x < data.m_x) ? m_x : data.m_x, - (m_y < data.m_y) ? m_y : data.m_y, - (m_z < data.m_z) ? m_z : data.m_z, - (m_w < data.m_w) ? m_w : data.m_w); - } - - // relational operators - DG_INLINE dgBigVector operator== (const dgBigVector& data) const - { - return dgBigVector ((m_x == data.m_x) ? dgInt64 (-1) : dgInt64 (0), - (m_y == data.m_y) ? dgInt64 (-1) : dgInt64 (0), - (m_z == data.m_z) ? dgInt64 (-1) : dgInt64 (0), - (m_w == data.m_w) ? dgInt64 (-1) : dgInt64 (0)); - } - - DG_INLINE dgBigVector operator> (const dgBigVector& data) const - { - return dgBigVector ((m_x > data.m_x) ? dgInt64 (-1) : dgInt64 (0), - (m_y > data.m_y) ? dgInt64 (-1) : dgInt64 (0), - (m_z > data.m_z) ? dgInt64 (-1) : dgInt64 (0), - (m_w > data.m_w) ? dgInt64 (-1) : dgInt64 (0)); - } - - DG_INLINE dgBigVector operator< (const dgBigVector& data) const - { - return dgBigVector ((m_x < data.m_x) ? dgInt64 (-1) : dgInt64 (0), - (m_y < data.m_y) ? dgInt64 (-1) : dgInt64 (0), - (m_z < data.m_z) ? dgInt64 (-1) : dgInt64 (0), - (m_w < data.m_w) ? dgInt64 (-1) : dgInt64 (0)); - } - - DG_INLINE dgBigVector operator>= (const dgBigVector& data) const - { - return dgBigVector ((m_x >= data.m_x) ? dgInt64 (-1) : dgInt64 (0), - (m_y >= data.m_y) ? dgInt64 (-1) : dgInt64 (0), - (m_z >= data.m_z) ? dgInt64 (-1) : dgInt64 (0), - (m_w >= data.m_w) ? dgInt64 (-1) : dgInt64 (0)); - } - - DG_INLINE dgBigVector operator<= (const dgBigVector& data) const - { - return dgBigVector ((m_x <= data.m_x) ? dgInt64 (-1) : dgInt64 (0), - (m_y <= data.m_y) ? dgInt64 (-1) : dgInt64 (0), - (m_z <= data.m_z) ? dgInt64 (-1) : dgInt64 (0), - (m_w <= data.m_w) ? dgInt64 (-1) : dgInt64 (0)); - } - - - // logical operations - DG_INLINE dgBigVector operator& (const dgBigVector& data) const - { - const dgInt64* const a = (dgInt64*)&m_x; - const dgInt64* const b = (dgInt64*)&data.m_x; - return dgBigVector (a[0] & b[0], a[1] & b[1], a[2] & b[2], a[3] & b[3]); - } - - DG_INLINE dgBigVector operator| (const dgBigVector& data) const - { - const dgInt64* const a = (dgInt64*)&m_x; - const dgInt64* const b = (dgInt64*)&data.m_x; - return dgBigVector (a[0] | b[0], a[1] | b[1], a[2] | b[2], a[3] | b[3]); - } - - DG_INLINE dgBigVector operator^ (const dgBigVector& data) const - { - const dgInt64* const a = (dgInt64*)&m_x; - const dgInt64* const b = (dgInt64*)&data.m_x; - return dgBigVector (a[0] ^ b[0], a[1] ^ b[1], a[2] ^ b[2], a[3] ^ b[3]); - } - - DG_INLINE dgBigVector AndNot (const dgBigVector& data) const - { - const dgInt64* const a = (dgInt64*)&m_x; - const dgInt64* const b = (dgInt64*)&data.m_x; - return dgBigVector (a[0] & ~b[0], a[1] & ~b[1], a[2] & ~b[2], a[3] & ~b[3]); - } - - DG_INLINE dgBigVector Select(const dgBigVector& data, const dgBigVector& mask) const - { - // (((b ^ a) & mask)^a) - return (*this) ^ (mask & (data ^ (*this))); - } - - DG_INLINE dgInt32 GetSignMask() const - { - const dgInt64* const a = (dgInt64*)&m_x; - return (((a[0]>>63) ? 1 : 0) | ((a[1]>>63) ? 2 : 0) | ((a[2]>>63) ? 4 : 0) | ((a[3]>>63) ? 8 : 0)); - } - - DG_INLINE dgVector ShiftRight() const - { - return dgBigVector (m_w, m_x, m_y, m_z); - } - - DG_INLINE dgBigVector ShiftTripleRight () const - { - return dgBigVector (m_z, m_x, m_y, m_w); - } - - DG_INLINE dgBigVector ShiftTripleLeft () const - { - return dgBigVector (m_y, m_z, m_x, m_w); - } - - DG_INLINE dgBigVector ShiftRightLogical (int bits) const - { - return dgBigVector (dgInt64 (dgUnsigned64 (m_ix) >> bits), dgInt64 (dgUnsigned64 (m_iy) >> bits), dgInt64 (dgUnsigned64 (m_iz) >> bits), dgInt64 (dgUnsigned64 (m_iw) >> bits)); - } - - DG_INLINE static void Transpose4x4 (dgBigVector& dst0, dgBigVector& dst1, dgBigVector& dst2, dgBigVector& dst3, const dgBigVector& src0, const dgBigVector& src1, const dgBigVector& src2, const dgBigVector& src3) - { - dgBigVector tmp0 (src0); - dgBigVector tmp1 (src1); - dgBigVector tmp2 (src2); - dgBigVector tmp3 (src3); - - dst0 = dgBigVector (tmp0.m_x, tmp1.m_x, tmp2.m_x, tmp3.m_x); - dst1 = dgBigVector (tmp0.m_y, tmp1.m_y, tmp2.m_y, tmp3.m_y); - dst2 = dgBigVector (tmp0.m_z, tmp1.m_z, tmp2.m_z, tmp3.m_z); - dst3 = dgBigVector (tmp0.m_w, tmp1.m_w, tmp2.m_w, tmp3.m_w); - } - - DG_CLASS_ALLOCATOR(allocator) - - union - { - dgInt64 m_i[4]; - struct - { - dgFloat64 m_x; - dgFloat64 m_y; - dgFloat64 m_z; - dgFloat64 m_w; - }; - struct - { - dgInt64 m_ix; - dgInt64 m_iy; - dgInt64 m_iz; - dgInt64 m_iw; - }; - }; - - static dgBigVector m_zero; - static dgBigVector m_one; - static dgBigVector m_wOne; - static dgBigVector m_half; - static dgBigVector m_two; - static dgBigVector m_three; - static dgBigVector m_negOne; - static dgBigVector m_xMask; - static dgBigVector m_yMask; - static dgBigVector m_zMask; - static dgBigVector m_wMask; - static dgBigVector m_epsilon; - static dgBigVector m_signMask; - static dgBigVector m_triplexMask; -} DG_GCC_VECTOR_ALIGNMENT; - - -DG_MSC_VECTOR_ALIGNMENT -class dgSpatialVector -{ - public: - DG_INLINE dgSpatialVector() - { - } - - DG_INLINE dgSpatialVector(const dgFloat32 a) - { - for (dgInt32 i = 0; i < 6; i ++) { - m_d[i] = a; - } - } - - DG_INLINE dgSpatialVector(const dgVector& low, const dgVector& high) - { - for (dgInt32 i = 0; i < 3; i ++) { - m_d[i] = low[i]; - m_d[i + 3] = high[i]; - } - } - - DG_INLINE dgSpatialVector(const dgSpatialVector& src) - { - for (dgInt32 i = 0; i < 6; i++) { - m_d[i] = src[i]; - } - } - - DG_INLINE dgFloat64& operator[] (dgInt32 i) - { - dgAssert(i < 6); - dgAssert(i >= 0); - return m_d[i]; - } - - DG_INLINE const dgFloat64& operator[] (dgInt32 i) const - { - dgAssert(i < 6); - dgAssert(i >= 0); - return m_d[i]; - } - - DG_INLINE dgSpatialVector operator+ (const dgSpatialVector& A) const - { - dgSpatialVector tmp; - for (dgInt32 i = 0; i < 6; i++) { - tmp[i] = m_d[i] + A.m_d[i]; - } - return tmp; - } - - DG_INLINE dgSpatialVector operator* (const dgSpatialVector& A) const - { - dgSpatialVector tmp; - for (dgInt32 i = 0; i < 6; i++) { - tmp[i] = m_d[i] * A.m_d[i]; - } - return tmp; - } - - DG_INLINE dgFloat64 DotProduct(const dgSpatialVector& v) const - { - dgFloat64 ret = dgFloat64 (0.0f); - for (dgInt32 i = 0; i < 6; i++) { - ret += m_d[i] * v.m_d[i]; - } - return ret; - } - - DG_INLINE dgSpatialVector Scale(dgFloat64 s) const - { - dgSpatialVector tmp; - for (dgInt32 i = 0; i < 6; i++) { - tmp[i] = m_d[i] * s; - } - return tmp; - } - - dgFloat64 m_d[6]; - static dgSpatialVector m_zero; -} DG_GCC_VECTOR_ALIGNMENT; - - -#endif diff --git a/thirdparty/src/newton/dgCore/dgVectorSimd.h b/thirdparty/src/newton/dgCore/dgVectorSimd.h deleted file mode 100644 index 274720631..000000000 --- a/thirdparty/src/newton/dgCore/dgVectorSimd.h +++ /dev/null @@ -1,983 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgVectorSimd__ -#define __dgVectorSimd__ - -#ifndef DG_SCALAR_VECTOR_CLASS - -#ifdef _NEWTON_USE_DOUBLE - #define dgVector dgBigVector -#else - -class dgBigVector; -// ***************************************************************************************** -// -// 4 x 1 single precision SSE vector class declaration -// -// ***************************************************************************************** -DG_MSC_VECTOR_ALIGNMENT -class dgVector -{ - #define PERMUTE_MASK(w, z, y, x) _MM_SHUFFLE (w, z, y, x) - public: - DG_INLINE dgVector() - { - } - - DG_INLINE dgVector(const __m128 type) - :m_type (type) - { - } - - DG_INLINE dgVector(const __m128i type) - :m_typeInt (type) - { - } - - DG_INLINE dgVector (const dgFloat32 a) - :m_type(_mm_set_ps1(a)) - { - } - - DG_INLINE dgVector (const dgFloat32* const ptr) - :m_type(_mm_loadu_ps (ptr)) - { - } - -#ifndef _NEWTON_USE_DOUBLE - DG_INLINE dgVector(const dgFloat64* const ptr) - :m_type(_mm_set_ps(dgFloat32(ptr[3]), dgFloat32(ptr[2]), dgFloat32(ptr[1]), dgFloat32(ptr[0]))) - { - } -#endif - - DG_INLINE dgVector (const dgVector& copy) - :m_type(copy.m_type) - { - } - - DG_INLINE dgVector (const dgBigVector& copy) - :m_type(_mm_shuffle_ps (_mm_cvtpd_ps (((__m128d*)©)[0]), _mm_cvtpd_ps (((__m128d*)©)[1]), PERMUTE_MASK(1, 0, 1, 0))) - { - dgAssert (dgCheckVector ((*this))); - } - - DG_INLINE dgVector (dgFloat32 x, dgFloat32 y, dgFloat32 z, dgFloat32 w) - :m_type(_mm_set_ps(w, z, y, x)) - { - } - - DG_INLINE dgVector (dgInt32 ix, dgInt32 iy, dgInt32 iz, dgInt32 iw) - :m_type(_mm_set_ps(*(dgFloat32*)&iw, *(dgFloat32*)&iz, *(dgFloat32*)&iy, *(dgFloat32*)&ix)) - { - } - - DG_INLINE dgFloat32 GetScalar () const - { - //return m_x; - return _mm_cvtss_f32 (m_type); - } - - DG_INLINE void Store (dgFloat32* const dst) const - { - _mm_storeu_ps(dst, m_type); - } - - DG_INLINE dgVector BroadcastX () const - { - return _mm_shuffle_ps (m_type, m_type, PERMUTE_MASK(0, 0, 0, 0)); - } - - DG_INLINE dgVector BroadcastY () const - { - return _mm_shuffle_ps (m_type, m_type, PERMUTE_MASK(1, 1, 1, 1)); - } - - DG_INLINE dgVector BroadcastZ () const - { - return _mm_shuffle_ps (m_type, m_type, PERMUTE_MASK(2, 2, 2, 2)); - } - - DG_INLINE dgVector BroadcastW () const - { - return _mm_shuffle_ps (m_type, m_type, PERMUTE_MASK(3, 3, 3, 3)); - } - - DG_INLINE dgVector Scale (dgFloat32 s) const - { - return _mm_mul_ps (m_type, _mm_set_ps1(s)); - } - - DG_INLINE dgFloat32& operator[] (dgInt32 i) - { - dgAssert (i < 4); - dgAssert (i >= 0); - return m_f[i]; - } - - DG_INLINE const dgFloat32& operator[] (dgInt32 i) const - { - dgAssert (i < 4); - dgAssert (i >= 0); - return m_f[i]; - } - - DG_INLINE dgVector operator+ (const dgVector& A) const - { - return _mm_add_ps (m_type, A.m_type); - } - - DG_INLINE dgVector operator- (const dgVector& A) const - { - return _mm_sub_ps (m_type, A.m_type); - } - - DG_INLINE dgVector operator* (const dgVector& A) const - { - return _mm_mul_ps(m_type, A.m_type); - } - - DG_INLINE dgVector& operator+= (const dgVector& A) - { - return (*this = _mm_add_ps (m_type, A.m_type)); - } - - DG_INLINE dgVector& operator-= (const dgVector& A) - { - return (*this = _mm_sub_ps (m_type, A.m_type)); - } - - DG_INLINE dgVector& operator*= (const dgVector& A) - { - return (*this = _mm_mul_ps(m_type, A.m_type)); - } - - // return cross product - DG_INLINE dgVector CrossProduct (const dgVector& B) const - { - return _mm_sub_ps (_mm_mul_ps (_mm_shuffle_ps (m_type, m_type, PERMUTE_MASK(3, 0, 2, 1)), _mm_shuffle_ps (B.m_type, B.m_type, PERMUTE_MASK(3, 1, 0, 2))), - _mm_mul_ps (_mm_shuffle_ps (m_type, m_type, PERMUTE_MASK(3, 1, 0, 2)), _mm_shuffle_ps (B.m_type, B.m_type, PERMUTE_MASK(3, 0, 2, 1)))); - } - - DG_INLINE dgVector DotProduct(const dgVector& A) const - { - return (*this * A).AddHorizontal(); - } - - DG_INLINE dgVector CrossProduct (const dgVector& A, const dgVector& B) const - { - dgFloat32 cofactor[3][3]; - dgFloat32 array[4][4]; - - const dgVector& me = *this; - for (dgInt32 i = 0; i < 4; i ++) { - array[0][i] = me[i]; - array[1][i] = A[i]; - array[2][i] = B[i]; - array[3][i] = dgFloat32 (1.0f); - } - - dgVector normal; - dgFloat32 sign = dgFloat32 (-1.0f); - for (dgInt32 i = 0; i < 4; i ++) { - - for (dgInt32 j = 0; j < 3; j ++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 4; k ++) { - if (k != i) { - cofactor[j][k0] = array[j][k]; - k0 ++; - } - } - } - dgFloat32 x = cofactor[0][0] * (cofactor[1][1] * cofactor[2][2] - cofactor[1][2] * cofactor[2][1]); - dgFloat32 y = cofactor[0][1] * (cofactor[1][2] * cofactor[2][0] - cofactor[1][0] * cofactor[2][2]); - dgFloat32 z = cofactor[0][2] * (cofactor[1][0] * cofactor[2][1] - cofactor[1][1] * cofactor[2][0]); - dgFloat32 det = x + y + z; - - normal[i] = sign * det; - sign *= dgFloat32 (-1.0f); - } - - return normal; - } - - DG_INLINE dgVector Reciproc () const - { - return _mm_div_ps (m_one.m_type, m_type); - } - - DG_INLINE dgVector MulAdd(const dgVector& A, const dgVector& B) const - { - return _mm_add_ps(m_type, _mm_mul_ps(A.m_type, B.m_type)); - } - - DG_INLINE dgVector MulSub(const dgVector& A, const dgVector& B) const - { - return _mm_sub_ps(m_type, _mm_mul_ps(A.m_type, B.m_type)); - } - - DG_INLINE dgVector AddHorizontal () const - { - __m128 tmp (_mm_hadd_ps (m_type, m_type)); - return _mm_hadd_ps (tmp, tmp); - } - - DG_INLINE dgVector Abs () const - { - return _mm_and_ps (m_type, m_signMask.m_type); - } - - dgFloat32 GetMax () const - { - __m128 tmp (_mm_max_ps (m_type, _mm_shuffle_ps (m_type, m_type, PERMUTE_MASK(3, 2, 3, 2)))); - //return dgVector (_mm_max_ps (tmp, _mm_shuffle_ps (tmp, tmp, PERMUTE_MASK(3, 2, 0, 1)))).GetScalar(); - return _mm_cvtss_f32(_mm_max_ss (tmp, _mm_shuffle_ps(tmp, tmp, PERMUTE_MASK(3, 2, 0, 1)))); - } - - dgVector GetMax (const dgVector& data) const - { - return _mm_max_ps (m_type, data.m_type); - } - - dgVector GetMin (const dgVector& data) const - { - return _mm_min_ps (m_type, data.m_type); - } - - DG_INLINE dgVector GetInt () const - { - return dgVector(_mm_cvtps_epi32(Floor().m_type)); - } - - DG_INLINE dgVector TestZero() const - { - //return dgVector (_mm_cmpeq_epi32 (m_typeInt, m_zero.m_typeInt)) & m_negOne; - return m_negOne & (*this == m_zero); - } - - DG_INLINE dgVector Floor () const - { - dgVector truncated (_mm_cvtepi32_ps (_mm_cvttps_epi32 (m_type))); - dgVector ret (truncated - (dgVector::m_one & (*this < truncated))); - dgAssert (ret.m_f[0] == dgFloor(m_f[0])); - dgAssert (ret.m_f[1] == dgFloor(m_f[1])); - dgAssert (ret.m_f[2] == dgFloor(m_f[2])); - dgAssert (ret.m_f[3] == dgFloor(m_f[3])); - return ret; - } - - DG_INLINE dgVector Sqrt () const - { - return _mm_sqrt_ps(m_type); - } - - DG_INLINE dgVector InvSqrt () const - { - dgVector tmp0 (_mm_rsqrt_ps(m_type)); - return m_half * tmp0 * (m_three - *this * tmp0 * tmp0); - } - - DG_INLINE dgVector InvMagSqrt () const - { - return DotProduct(*this).InvSqrt(); - } - - DG_INLINE dgVector Normalize () const - { - dgAssert (m_w == dgFloat32 (0.0f)); - // somehow this function changes the behavior with 3.13 - //return Scale(dgFloat32 (1.0f) / dgSqrt(DotProduct(*this).GetScalar())); - return *this * InvMagSqrt (); - } - - // relational operators - DG_INLINE dgVector operator> (const dgVector& data) const - { - return _mm_cmpgt_ps (m_type, data.m_type); - } - - DG_INLINE dgVector operator== (const dgVector& data) const - { - return _mm_cmpeq_ps (m_type, data.m_type); - } - - DG_INLINE dgVector operator< (const dgVector& data) const - { - return _mm_cmplt_ps (m_type, data.m_type); - } - - DG_INLINE dgVector operator>= (const dgVector& data) const - { - return _mm_cmpge_ps (m_type, data.m_type); - } - - DG_INLINE dgVector operator<= (const dgVector& data) const - { - return _mm_cmple_ps (m_type, data.m_type); - } - - // logical operations - DG_INLINE dgVector operator& (const dgVector& data) const - { - return _mm_and_ps (m_type, data.m_type); - } - - DG_INLINE dgVector operator| (const dgVector& data) const - { - return _mm_or_ps (m_type, data.m_type); - } - - DG_INLINE dgVector operator^ (const dgVector& data) const - { - return _mm_xor_ps (m_type, data.m_type); - } - - DG_INLINE dgVector AndNot(const dgVector& data) const - { - return _mm_andnot_ps(data.m_type, m_type); - } - - DG_INLINE dgVector Select(const dgVector& data, const dgVector& mask) const - { - // (((b ^ a) & mask)^a) - //return _mm_or_ps (_mm_and_ps (mask.m_type, data.m_type), _mm_andnot_ps(mask.m_type, m_type)); - return _mm_xor_ps(m_type, _mm_and_ps (mask.m_type, _mm_xor_ps(m_type, data.m_type))); - } - - DG_INLINE dgInt32 GetSignMask() const - { - return _mm_movemask_ps(m_type); - } - - DG_INLINE dgVector ShiftRight() const - { - return _mm_shuffle_ps(m_type, m_type, PERMUTE_MASK(2, 1, 0, 3)); - } - - DG_INLINE dgVector ShiftTripleRight () const - { - return _mm_shuffle_ps(m_type, m_type, PERMUTE_MASK(3, 1, 0, 2)); - } - - DG_INLINE dgVector ShiftTripleLeft () const - { - return _mm_shuffle_ps (m_type, m_type, PERMUTE_MASK(3, 0, 2, 1)); - } - - DG_INLINE dgVector ShiftRightLogical (int bits) const - { - return dgVector (_mm_srli_epi32(m_typeInt, bits)); - } - - DG_INLINE static void Transpose4x4 (dgVector& dst0, dgVector& dst1, dgVector& dst2, dgVector& dst3, const dgVector& src0, const dgVector& src1, const dgVector& src2, const dgVector& src3) - { - __m128 tmp0 (_mm_unpacklo_ps (src0.m_type, src1.m_type)); - __m128 tmp1 (_mm_unpacklo_ps (src2.m_type, src3.m_type)); - __m128 tmp2 (_mm_unpackhi_ps (src0.m_type, src1.m_type)); - __m128 tmp3 (_mm_unpackhi_ps (src2.m_type, src3.m_type)); - - dst0 = dgVector (_mm_movelh_ps (tmp0, tmp1)); - dst1 = dgVector (_mm_movehl_ps (tmp1, tmp0)); - dst2 = dgVector (_mm_movelh_ps (tmp2, tmp3)); - dst3 = dgVector (_mm_movehl_ps (tmp3, tmp2)); - } - -#ifdef _DEBUG - DG_INLINE void Trace(char* const name) const - { - dgTrace(("%s %f %f %f %f\n", name, m_x, m_y, m_z, m_w)); - } -#else - DG_INLINE void Trace(char* const name) const {} -#endif - - DG_CLASS_ALLOCATOR(allocator) - - union { - dgFloat32 m_f[4]; - dgInt32 m_i[4]; - __m128 m_type; - __m128i m_typeInt; - struct { - dgFloat32 m_x; - dgFloat32 m_y; - dgFloat32 m_z; - dgFloat32 m_w; - }; - struct { - dgInt32 m_ix; - dgInt32 m_iy; - dgInt32 m_iz; - dgInt32 m_iw; - }; - }; - - static dgVector m_zero; - static dgVector m_one; - static dgVector m_wOne; - static dgVector m_two; - static dgVector m_half; - static dgVector m_three; - static dgVector m_negOne; - static dgVector m_xMask; - static dgVector m_yMask; - static dgVector m_zMask; - static dgVector m_wMask; - static dgVector m_epsilon; - static dgVector m_signMask; - static dgVector m_triplexMask; -} DG_GCC_VECTOR_ALIGNMENT; -#endif - - -// ***************************************************************************************** -// -// 4 x 1 double precision SSE2 vector class declaration -// -// ***************************************************************************************** -DG_MSC_VECTOR_ALIGNMENT -class dgBigVector -{ - #define PERMUT_MASK_DOUBLE(y, x) _MM_SHUFFLE2 (y, x) - - public: - DG_INLINE dgBigVector() - { - } - - DG_INLINE dgBigVector(const dgBigVector& copy) - :m_typeLow(copy.m_typeLow) - ,m_typeHigh(copy.m_typeHigh) - { - } - - DG_INLINE dgBigVector(const __m128d typeLow, const __m128d typeHigh) - :m_typeLow(typeLow) - ,m_typeHigh(typeHigh) - { - } - - DG_INLINE dgBigVector(const __m128i typeLow, const __m128i typeHigh) - :m_typeIntLow(typeLow) - ,m_typeIntHigh(typeHigh) - { - } - - DG_INLINE dgBigVector(const dgFloat64 a) - :m_typeLow(_mm_set1_pd(a)) - ,m_typeHigh(_mm_set1_pd(a)) - { - } - -#ifdef _NEWTON_USE_DOUBLE - DG_INLINE dgBigVector (const dgFloat32* const ptr) - :m_typeLow(_mm_loadu_pd(ptr)) - ,m_typeHigh(_mm_loadu_pd(&ptr[2])) - { - } -#else - - DG_INLINE dgBigVector(const dgVector& v) - :m_typeLow(_mm_cvtps_pd (v.m_type)) - ,m_typeHigh(_mm_cvtps_pd (_mm_shuffle_ps (v.m_type, v.m_type, PERMUTE_MASK(3, 2, 3, 2)))) - { - dgAssert(dgCheckVector((*this))); - } - - DG_INLINE dgBigVector(const dgFloat64* const ptr) - :m_typeLow(_mm_loadu_pd(ptr)) - ,m_typeHigh(_mm_loadu_pd(&ptr[2])) - { - } -#endif - - - DG_INLINE dgBigVector(dgFloat64 x, dgFloat64 y, dgFloat64 z, dgFloat64 w) - :m_typeLow(_mm_set_pd(y, x)) - ,m_typeHigh(_mm_set_pd(w, z)) - { - } - - DG_INLINE dgBigVector(dgInt32 ix, dgInt32 iy, dgInt32 iz, dgInt32 iw) - :m_ix(dgInt64(ix)), m_iy(dgInt64(iy)), m_iz(dgInt64(iz)), m_iw(dgInt64(iw)) - { - } - - DG_INLINE dgBigVector(dgInt64 ix, dgInt64 iy, dgInt64 iz, dgInt64 iw) - :m_ix(ix), m_iy(iy), m_iz(iz), m_iw(iw) - { - } - - - DG_INLINE dgFloat64& operator[] (dgInt32 i) - { - dgAssert(i < 4); - dgAssert(i >= 0); - return m_f[i]; - } - - DG_INLINE const dgFloat64& operator[] (dgInt32 i) const - { - dgAssert(i < 4); - dgAssert(i >= 0); - return m_f[i]; - } - - DG_INLINE dgFloat64 GetScalar() const - { - //return m_x; - return _mm_cvtsd_f64(m_typeLow); - } - - DG_INLINE dgBigVector operator+ (const dgBigVector& A) const - { - return dgBigVector(_mm_add_pd(m_typeLow, A.m_typeLow), _mm_add_pd(m_typeHigh, A.m_typeHigh)); - } - - DG_INLINE dgBigVector operator- (const dgBigVector& A) const - { - return dgBigVector(_mm_sub_pd(m_typeLow, A.m_typeLow), _mm_sub_pd(m_typeHigh, A.m_typeHigh)); - } - - DG_INLINE dgBigVector operator* (const dgBigVector& A) const - { - return dgBigVector(_mm_mul_pd(m_typeLow, A.m_typeLow), _mm_mul_pd(m_typeHigh, A.m_typeHigh)); - } - - DG_INLINE dgBigVector& operator+= (const dgBigVector& A) - { - m_typeLow = _mm_add_pd(m_typeLow, A.m_typeLow); - m_typeHigh = _mm_add_pd(m_typeHigh, A.m_typeHigh); - return *this; - } - - DG_INLINE dgBigVector& operator-= (const dgBigVector& A) - { - m_typeLow = _mm_sub_pd(m_typeLow, A.m_typeLow); - m_typeHigh = _mm_sub_pd(m_typeHigh, A.m_typeHigh); - return *this; - } - - DG_INLINE dgBigVector& operator*= (const dgBigVector& A) - { - m_typeLow = _mm_mul_pd(m_typeLow, A.m_typeLow); - m_typeHigh = _mm_mul_pd(m_typeHigh, A.m_typeHigh); - return *this; - } - - DG_INLINE dgBigVector MulAdd(const dgBigVector& A, const dgBigVector& B) const - { - return *this + A * B; - } - - DG_INLINE dgBigVector MulSub(const dgBigVector& A, const dgBigVector& B) const - { - return *this - A * B; - } - - // return cross product - DG_INLINE dgBigVector CrossProduct(const dgBigVector& B) const - { - return dgBigVector(m_y * B.m_z - m_z * B.m_y, m_z * B.m_x - m_x * B.m_z, m_x * B.m_y - m_y * B.m_x, m_w); - } - - DG_INLINE dgBigVector AddHorizontal() const - { - __m128d tmp0(_mm_add_pd(m_typeHigh, m_typeLow)); - __m128d tmp1(_mm_hadd_pd(tmp0, tmp0)); - return dgBigVector(tmp1, tmp1); - } - - DG_INLINE dgBigVector BroadcastX() const - { - return dgBigVector(m_x); - } - - DG_INLINE dgBigVector BroadcastY() const - { - return dgBigVector(m_y); - } - - DG_INLINE dgBigVector BroadcastZ() const - { - return dgBigVector(m_z); - } - - DG_INLINE dgBigVector BroadcastW() const - { - return dgBigVector(m_w); - } - - DG_INLINE dgBigVector Scale(dgFloat64 s) const - { - __m128d tmp0(_mm_set1_pd(s)); - return dgBigVector(_mm_mul_pd(m_typeLow, tmp0), _mm_mul_pd(m_typeHigh, tmp0)); - } - - DG_INLINE dgBigVector Abs() const - { - return dgBigVector(_mm_and_pd(m_typeLow, m_signMask.m_typeLow), _mm_and_pd(m_typeHigh, m_signMask.m_typeLow)); - } - - DG_INLINE dgBigVector Reciproc() const - { - return dgBigVector(_mm_div_pd(m_one.m_typeLow, m_typeLow), _mm_div_pd(m_one.m_typeHigh, m_typeHigh)); - } - - DG_INLINE dgBigVector Sqrt() const - { - return dgBigVector(_mm_sqrt_pd(m_typeLow), _mm_sqrt_pd(m_typeHigh)); - } - - DG_INLINE dgBigVector InvSqrt() const - { - return Sqrt().Reciproc(); - } - - DG_INLINE dgBigVector Normalize() const - { - dgAssert (m_w == dgFloat32 (0.0f)); - dgFloat64 mag2 = DotProduct(*this).GetScalar(); - return Scale(dgFloat64 (1.0f) / sqrt (mag2)); - } - - dgFloat64 GetMax() const - { - __m128d tmp(_mm_max_pd(m_typeLow, m_typeHigh)); - return dgBigVector(_mm_max_pd(tmp, _mm_shuffle_pd(tmp, tmp, PERMUT_MASK_DOUBLE(0, 1))), tmp).GetScalar(); - } - - dgBigVector GetMax(const dgBigVector& data) const - { - return dgBigVector(_mm_max_pd(m_typeLow, data.m_typeLow), _mm_max_pd(m_typeHigh, data.m_typeHigh)); - } - - dgBigVector GetMin(const dgBigVector& data) const - { - return dgBigVector(_mm_min_pd(m_typeLow, data.m_typeLow), _mm_min_pd(m_typeHigh, data.m_typeHigh)); - } - - DG_INLINE dgBigVector GetInt() const - { - dgBigVector temp(Floor()); - dgInt64 x = _mm_cvtsd_si32(temp.m_typeLow); - dgInt64 y = _mm_cvtsd_si32(_mm_shuffle_pd(temp.m_typeLow, temp.m_typeLow, PERMUT_MASK_DOUBLE(1, 1))); - dgInt64 z = _mm_cvtsd_si32(temp.m_typeHigh); - dgInt64 w = _mm_cvtsd_si32(_mm_shuffle_pd(temp.m_typeHigh, temp.m_typeHigh, PERMUT_MASK_DOUBLE(1, 1))); - return dgBigVector(_mm_set_pd(*(dgFloat32*)&y, *(dgFloat32*)&x), _mm_set_pd(*(dgFloat32*)&w, *(dgFloat32*)&z)); - } - - // relational operators - DG_INLINE dgBigVector operator> (const dgBigVector& data) const - { - return dgBigVector(_mm_cmpgt_pd(m_typeLow, data.m_typeLow), _mm_cmpgt_pd(m_typeHigh, data.m_typeHigh)); - } - - DG_INLINE dgBigVector operator== (const dgBigVector& data) const - { - return dgBigVector(_mm_cmpeq_pd(m_typeLow, data.m_typeLow), _mm_cmpeq_pd(m_typeHigh, data.m_typeHigh)); - } - - DG_INLINE dgBigVector operator< (const dgBigVector& data) const - { - return dgBigVector(_mm_cmplt_pd(m_typeLow, data.m_typeLow), _mm_cmplt_pd(m_typeHigh, data.m_typeHigh)); - } - - DG_INLINE dgBigVector operator>= (const dgBigVector& data) const - { - return dgBigVector(_mm_cmpge_pd(m_typeLow, data.m_typeLow), _mm_cmpge_pd(m_typeHigh, data.m_typeHigh)); - } - - DG_INLINE dgBigVector operator<= (const dgBigVector& data) const - { - return dgBigVector(_mm_cmple_pd(m_typeLow, data.m_typeLow), _mm_cmple_pd(m_typeHigh, data.m_typeHigh)); - } - - // logical operations - DG_INLINE dgBigVector operator& (const dgBigVector& data) const - { - return dgBigVector(_mm_and_pd(m_typeLow, data.m_typeLow), _mm_and_pd(m_typeHigh, data.m_typeHigh)); - } - - DG_INLINE dgBigVector operator| (const dgBigVector& data) const - { - return dgBigVector(_mm_or_pd(m_typeLow, data.m_typeLow), _mm_or_pd(m_typeHigh, data.m_typeHigh)); - } - - DG_INLINE dgBigVector operator^ (const dgBigVector& data) const - { - return dgBigVector(_mm_xor_pd(m_typeLow, data.m_typeLow), _mm_xor_pd(m_typeHigh, data.m_typeHigh)); - } - - DG_INLINE dgBigVector AndNot(const dgBigVector& data) const - { - return dgBigVector(_mm_andnot_pd(data.m_typeLow, m_typeLow), _mm_andnot_pd(data.m_typeHigh, m_typeHigh)); - } - - DG_INLINE dgBigVector Select(const dgBigVector& data, const dgBigVector& mask) const - { - // (((b ^ a) & mask)^a) - return dgBigVector(_mm_xor_pd(m_typeLow, _mm_and_pd(mask.m_typeLow, _mm_xor_pd(m_typeLow, data.m_typeLow))), - _mm_xor_pd(m_typeHigh, _mm_and_pd(mask.m_typeHigh, _mm_xor_pd(m_typeHigh, data.m_typeHigh)))); - } - - DG_INLINE dgBigVector ShiftRight() const - { - //return dgBigVector (m_w, m_x, m_y, m_z); - return dgBigVector(_mm_shuffle_pd(m_typeHigh, m_typeLow, PERMUT_MASK_DOUBLE(0, 1)), _mm_shuffle_pd(m_typeLow, m_typeHigh, PERMUT_MASK_DOUBLE(0, 1))); - } - - DG_INLINE dgBigVector ShiftTripleRight() const - { - return dgBigVector(_mm_shuffle_pd(m_typeHigh, m_typeLow, PERMUT_MASK_DOUBLE(0, 0)), _mm_shuffle_pd(m_typeLow, m_typeHigh, PERMUT_MASK_DOUBLE(1, 1))); - } - - DG_INLINE dgBigVector ShiftTripleLeft() const - { - return dgBigVector(_mm_shuffle_pd(m_typeLow, m_typeHigh, PERMUT_MASK_DOUBLE(0, 1)), _mm_shuffle_pd(m_typeLow, m_typeHigh, PERMUT_MASK_DOUBLE(1, 0))); - } - - DG_INLINE dgBigVector ShiftRightLogical(int bits) const - { - //return dgBigVector(dgInt64(dgUnsigned64(m_ix) >> bits), dgInt64(dgUnsigned64(m_iy) >> bits), dgInt64(dgUnsigned64(m_iz) >> bits), dgInt64(dgUnsigned64(m_iw) >> bits)); - return dgBigVector(_mm_srli_epi64(m_typeIntLow, bits), _mm_srli_epi64(m_typeIntHigh, bits)); - } - - DG_INLINE dgInt32 GetSignMask() const - { - return _mm_movemask_pd(m_typeLow) | (_mm_movemask_pd(m_typeHigh) << 2); - } - - DG_INLINE dgBigVector Floor() const - { - return dgBigVector(floor(m_x), floor(m_y), floor(m_z), floor(m_w)); - } - - DG_INLINE dgBigVector TestZero() const - { - return m_negOne & (*this == m_zero); - } - - DG_INLINE static void Transpose4x4(dgBigVector& dst0, dgBigVector& dst1, dgBigVector& dst2, dgBigVector& dst3, - const dgBigVector& src0, const dgBigVector& src1, const dgBigVector& src2, const dgBigVector& src3) - { - dgBigVector tmp0(src0); - dgBigVector tmp1(src1); - dgBigVector tmp2(src2); - dgBigVector tmp3(src3); - - dst0 = dgBigVector(tmp0.m_x, tmp1.m_x, tmp2.m_x, tmp3.m_x); - dst1 = dgBigVector(tmp0.m_y, tmp1.m_y, tmp2.m_y, tmp3.m_y); - dst2 = dgBigVector(tmp0.m_z, tmp1.m_z, tmp2.m_z, tmp3.m_z); - dst3 = dgBigVector(tmp0.m_w, tmp1.m_w, tmp2.m_w, tmp3.m_w); - } - - DG_INLINE dgFloat64 DotProduct3(const dgBigVector& A) const - { - return m_x * A.m_x + m_y * A.m_y + m_z * A.m_z; - } - - // return dot 4d dot product - DG_INLINE dgBigVector DotProduct(const dgBigVector &A) const - { - return (*this * A).AddHorizontal(); - } - - DG_INLINE dgBigVector CrossProduct(const dgBigVector& A, const dgBigVector& B) const - { - dgFloat64 cofactor[3][3]; - dgFloat64 array[4][4]; - - const dgBigVector& me = *this; - for (dgInt32 i = 0; i < 4; i++) { - array[0][i] = me[i]; - array[1][i] = A[i]; - array[2][i] = B[i]; - array[3][i] = dgFloat64(1.0f); - } - - dgBigVector normal; - dgFloat64 sign = dgFloat64(-1.0f); - for (dgInt32 i = 0; i < 4; i++) { - - for (dgInt32 j = 0; j < 3; j++) { - dgInt32 k0 = 0; - for (dgInt32 k = 0; k < 4; k++) { - if (k != i) { - cofactor[j][k0] = array[j][k]; - k0++; - } - } - } - dgFloat64 x = cofactor[0][0] * (cofactor[1][1] * cofactor[2][2] - cofactor[1][2] * cofactor[2][1]); - dgFloat64 y = cofactor[0][1] * (cofactor[1][2] * cofactor[2][0] - cofactor[1][0] * cofactor[2][2]); - dgFloat64 z = cofactor[0][2] * (cofactor[1][0] * cofactor[2][1] - cofactor[1][1] * cofactor[2][0]); - dgFloat64 det = x + y + z; - - normal[i] = sign * det; - sign *= dgFloat64(-1.0f); - } - - return normal; - } - - DG_CLASS_ALLOCATOR(allocator) - - union - { - dgFloat64 m_f[4]; - dgInt64 m_i[4]; - struct - { - __m128d m_typeLow; - __m128d m_typeHigh; - }; - struct - { - __m128i m_typeIntLow; - __m128i m_typeIntHigh; - }; - struct - { - dgFloat64 m_x; - dgFloat64 m_y; - dgFloat64 m_z; - dgFloat64 m_w; - }; - struct - { - dgInt64 m_ix; - dgInt64 m_iy; - dgInt64 m_iz; - dgInt64 m_iw; - }; - }; - - static dgBigVector m_zero; - static dgBigVector m_one; - static dgBigVector m_wOne; - static dgBigVector m_two; - static dgBigVector m_half; - static dgBigVector m_three; - static dgBigVector m_negOne; - static dgBigVector m_xMask; - static dgBigVector m_yMask; - static dgBigVector m_zMask; - static dgBigVector m_wMask; - static dgBigVector m_epsilon; - static dgBigVector m_signMask; - static dgBigVector m_triplexMask; -} DG_GCC_VECTOR_ALIGNMENT; - - -DG_MSC_VECTOR_ALIGNMENT -class dgSpatialVector -{ - public: - DG_INLINE dgSpatialVector() - { - } - - DG_INLINE dgSpatialVector(const dgFloat32 a) - :m_d0(_mm_set1_pd(a)) - ,m_d1(_mm_set1_pd(a)) - ,m_d2(_mm_set1_pd(a)) - { - } - -#ifdef _NEWTON_USE_DOUBLE -#define PURMUT_MASK2(y, x) _MM_SHUFFLE2(x, y) - DG_INLINE dgSpatialVector(const dgVector& low, const dgVector& high) - :m_d0(low.m_typeLow) - ,m_d1(_mm_shuffle_pd(low.m_typeHigh, high.m_typeLow, PURMUT_MASK2(0, 0))) - ,m_d2(_mm_shuffle_pd(high.m_typeLow, high.m_typeHigh, PURMUT_MASK2(1, 0))) - { - } -#else - DG_INLINE dgSpatialVector(const dgVector& low, const dgVector& high) - :m_d0(_mm_cvtps_pd(low.m_type)) - ,m_d1(_mm_cvtps_pd(_mm_unpackhi_ps(low.m_type, _mm_shuffle_ps(low.m_type, high.m_type, PERMUTE_MASK(0, 0, 0, 2))))) - ,m_d2(_mm_cvtps_pd(_mm_shuffle_ps(high.m_type, high.m_type, PERMUTE_MASK(3, 3, 2, 1)))) - { - } -#endif - - DG_INLINE dgSpatialVector(const dgSpatialVector& copy) - :m_d0(copy.m_d0) - ,m_d1(copy.m_d1) - ,m_d2(copy.m_d2) - { - } - - DG_INLINE dgSpatialVector(const __m128d d0, const __m128d d1, const __m128d d2) - :m_d0(d0) - ,m_d1(d1) - ,m_d2(d2) - { - } - - DG_INLINE dgFloat64& operator[] (dgInt32 i) - { - dgAssert(i < 6); - dgAssert(i >= 0); - return ((dgFloat64*)&m_d0)[i]; - } - - DG_INLINE const dgFloat64& operator[] (dgInt32 i) const - { - dgAssert(i < 6); - dgAssert(i >= 0); - return ((dgFloat64*)&m_d0)[i]; - } - - DG_INLINE dgSpatialVector operator+ (const dgSpatialVector& A) const - { - return dgSpatialVector(_mm_add_pd(m_d0, A.m_d0), _mm_add_pd(m_d1, A.m_d1), _mm_add_pd(m_d2, A.m_d2)); - } - - DG_INLINE dgSpatialVector operator*(const dgSpatialVector& A) const - { - return dgSpatialVector(_mm_mul_pd(m_d0, A.m_d0), _mm_mul_pd(m_d1, A.m_d1), _mm_mul_pd(m_d2, A.m_d2)); - } - - DG_INLINE dgFloat64 DotProduct(const dgSpatialVector& v) const - { - dgSpatialVector tmp(*this * v); - __m128d tmp2(_mm_add_pd(tmp.m_d0, _mm_add_pd(tmp.m_d1, tmp.m_d2))); - return _mm_cvtsd_f64(_mm_hadd_pd(tmp2, tmp2)); - } - - DG_INLINE dgSpatialVector Scale(dgFloat64 s) const - { - __m128d tmp(_mm_set1_pd(s)); - return dgSpatialVector(_mm_mul_pd(m_d0, tmp), _mm_mul_pd(m_d1, tmp), _mm_mul_pd(m_d2, tmp)); - } - - __m128d m_d0; - __m128d m_d1; - __m128d m_d2; - static dgSpatialVector m_zero; -} DG_GCC_VECTOR_ALIGNMENT; - -#endif -#endif diff --git a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect.h b/thirdparty/src/newton/dgMeshUtil/dgMeshEffect.h deleted file mode 100644 index d79e95360..000000000 --- a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect.h +++ /dev/null @@ -1,596 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __dgMeshEffect_H__ -#define __dgMeshEffect_H__ - -#include <dgRefCounter.h> - -class dgWorld; -class dgMeshEffect; -class dgCollisionInstance; - -#define DG_MESH_EFFECT_PRECISION_BITS 48 -#define DG_MESH_EFFECT_PRECISION_SCALE dgFloat64(dgInt64(1)<<DG_MESH_EFFECT_PRECISION_BITS) -#define DG_MESH_EFFECT_PRECISION_SCALE_INV (dgFloat64 (1.0f) / DG_MESH_EFFECT_PRECISION_SCALE) - -#define DG_VERTEXLIST_INDEXLIST_TOL (dgFloat64 (0.0f)) -#define DG_MESH_EFFECT_POINT_SPLITED 512 -#define DG_MESH_EFFECT_BVH_STACK_DEPTH 256 - -class dgMeshEffect: public dgPolyhedra, public dgRefCounter -{ - public: - enum dgChannelType - { - m_vertex, - m_normal, - m_binormal, - m_uv0, - m_uv1, - m_color, - m_material, - m_layer, - m_point, - }; - - class dgMeshVertexFormat - { - public: - class dgDoubleData - { - public: - const dgFloat64* m_data; - const dgInt32* m_indexList; - dgInt32 m_strideInBytes; - }; - - class dgFloatData - { - public: - const dgFloat32* m_data; - const dgInt32* m_indexList; - dgInt32 m_strideInBytes; - }; - - dgMeshVertexFormat () - { - Clear (); - } - - void Clear () - { - memset (this, 0, sizeof (dgMeshVertexFormat)); - } - - dgInt32 m_faceCount; - const dgInt32* m_faceIndexCount; - const dgInt32* m_faceMaterial; - dgDoubleData m_vertex; - dgFloatData m_normal; - dgFloatData m_binormal; - dgFloatData m_uv0; - dgFloatData m_uv1; - dgFloatData m_vertexColor; - }; - - template<class T, dgChannelType type> - class dgChannel: public dgArray<T> - { - public: - dgChannel(dgMemoryAllocator* const allocator) - :dgArray<T>(allocator) - ,m_count(0) - ,m_type(type) - { - } - - dgChannel(const dgChannel& source) - :dgArray<T>(source, source.m_count) - ,m_count(source.m_count) - ,m_type(source.m_type) - { - } - - ~dgChannel() - { - } - - void CopyFrom (const dgChannel<T, type>& source) - { - dgArray<T>& me = *this; - dgChannel& src = *((dgChannel*)&source); - - Clear(); - m_count = src.m_count; - dgAssert (m_type == src.m_type); - for (dgInt32 i = 0; i < m_count; i++) { - me[i] = src[i]; - } - } - - void Clear() - { - m_count = 0; - dgArray<T>::Clear (); - } - - void Reserve (dgInt32 size) - { - dgArray<T>::Resize(size); - m_count = size; - } - - void PushBack (const T& element) - { - T tmp (element); - dgArray<T>& me = *this; - me[m_count] = tmp; - m_count ++; - } - - void SetCount (dgInt32 count) - { - if (m_count) { - dgAssert (count >= 0); - dgAssert (m_count >= count); - m_count = count; - } - } - - dgInt32 m_count; - dgChannelType m_type; - }; - - class dgFormat - { - public: - class dgSortKey - { - public: - dgInt32 m_mask; - dgInt32 m_ordinal; - dgInt32 m_vertexIndex; - dgInt32 m_attibuteIndex; - }; - class VertexSortData - { - public: - const dgChannel<dgBigVector, m_point>* m_points; - dgInt32 m_vertexSortIndex; - }; - - dgInt32 GetSortIndex (const dgChannel<dgBigVector, m_point>& points, dgFloat64& dist) const; - static dgInt32 CompareVertex(const dgSortKey* const ptr0, const dgSortKey* const ptr1, void* const context); - }; - - class dgPointFormat: public dgFormat - { - public: - dgPointFormat(dgMemoryAllocator* const allocator); - dgPointFormat(const dgPointFormat& source); - ~dgPointFormat(); - - void Clear(); - void SetCount (dgInt32 count); - void CompressData(dgInt32* const indexList); - - dgChannel<dgInt32, m_layer> m_layers; - dgChannel <dgBigVector, m_point> m_vertex; - }; - - class dgAttibutFormat: public dgFormat - { - public: - class dgUV - { - public: - dgFloat32 m_u; - dgFloat32 m_v; - }; - - dgAttibutFormat(dgMemoryAllocator* const allocator); - dgAttibutFormat(const dgAttibutFormat& source); - ~dgAttibutFormat(); - - void Clear(); - void SetCount (dgInt32 count); - void CopyFrom (const dgAttibutFormat& source); - void CopyEntryFrom (dgInt32 index, const dgAttibutFormat& source, dgInt32 sourceIndex); - void CompressData (const dgPointFormat& points, dgInt32* const indexList); - - dgChannel<dgInt32, m_vertex> m_pointChannel; - dgChannel<dgInt32, m_material> m_materialChannel; - dgChannel<dgTriplex, m_normal> m_normalChannel; - dgChannel<dgTriplex, m_binormal> m_binormalChannel; - dgChannel<dgVector, m_color> m_colorChannel; - dgChannel<dgUV, m_uv0> m_uv0Channel; - dgChannel<dgUV, m_uv1> m_uv1Channel; - }; - - class dgIndexArray - { - public: - dgInt32 m_materialCount; - dgInt32 m_indexCount; - dgInt32 m_materials[256]; - dgInt32 m_materialsIndexCount[256]; - dgInt32* m_indexList; - }; - - class dgMeshBVH - { - public: - class dgMeshBVHNode - { - public: - dgMeshBVHNode (const dgMeshEffect* const mesh, dgEdge* const face, void* const userData); - dgMeshBVHNode (dgMeshBVHNode* const left, dgMeshBVHNode* const right); - ~dgMeshBVHNode (); - void SetBox (const dgVector& p0, const dgVector& p1); - - DG_CLASS_ALLOCATOR(allocator) - dgVector m_p0; - dgVector m_p1; - - dgFloat32 m_area; - dgEdge* m_face; - void* m_userData; - dgMeshBVHNode* m_left; - dgMeshBVHNode* m_right; - dgMeshBVHNode* m_parent; - }; - - class dgFitnessList: public dgTree <dgMeshBVHNode*, dgMeshBVHNode*> - { - public: - dgFitnessList (dgMemoryAllocator* const allocator); - dgFloat64 TotalCost () const; - }; - - - dgMeshBVH (const dgMeshEffect* const mesh); - virtual ~dgMeshBVH(); - - virtual void Build (); - virtual void Cleanup (); - - void FaceRayCast (const dgBigVector& l0, const dgBigVector& l1, void* const userData) const; - void GetOverlapNodes (dgList<dgMeshBVHNode*>& overlapNodes, const dgBigVector& p0, const dgBigVector& p1) const; - - protected: - virtual dgMeshBVHNode* CreateLeafNode (dgEdge* const face, void* const userData) = 0; - - dgMeshBVHNode* AddFaceNode (dgEdge* const face, void* const userData); - void RemoveNode (dgMeshBVHNode* const treeNode); - void ImproveNodeFitness (); - void ImproveNodeFitness (dgMeshBVHNode* const node); - dgFloat32 CalculateSurfaceArea (dgMeshBVHNode* const node0, dgMeshBVHNode* const node1, dgVector& minBox, dgVector& maxBox) const; - virtual bool SanityCheck() const; - - virtual dgFloat64 RayFaceIntersect (const dgMeshBVHNode* const face, const dgBigVector& p0, const dgBigVector& p1, void* const userData) const; -// virtual dgFloat64 VertexRayCast (const dgBigVector& l0, const dgBigVector& l1) const; -// virtual bool RayRayIntersect (dgEdge* const edge, const dgMeshEffect* const otherMesh, dgEdge* const otherEdge, dgFloat64& param, dgFloat64& otherParam) const; - - const dgMeshEffect* m_mesh; - dgMeshBVHNode* m_rootNode; - dgFitnessList m_fitness; - friend class dgMeshEffect; - }; - - dgMeshEffect (); - dgMeshEffect(dgMemoryAllocator* const allocator); - dgMeshEffect(dgCollisionInstance* const collision); - dgMeshEffect(const dgMeshEffect& source); - dgMeshEffect(dgPolyhedra& mesh, const dgMeshEffect& source); - dgMeshEffect (dgMemoryAllocator* const allocator, dgDeserialize deserialization, void* const userData); - - // create from OFF or PLY file format - dgMeshEffect(dgMemoryAllocator* const allocator, const char* const fileName); - - // Create a convex hull Mesh form point cloud - dgMeshEffect (dgMemoryAllocator* const allocator, const dgFloat64* const vertexCloud, dgInt32 count, dgInt32 strideInByte, dgFloat64 distTol); - - // create a planar Mesh - dgMeshEffect(dgMemoryAllocator* const allocator, const dgMatrix& planeMatrix, dgFloat32 witdth, dgFloat32 breadth, dgInt32 material, const dgMatrix& textureMatrix0, const dgMatrix& textureMatrix1); - virtual ~dgMeshEffect(void); - - void Init(); - - void Trace () const; - - void ApplyTransform (const dgMatrix& matrix); - dgMatrix CalculateOOBB (dgBigVector& size) const; - void CalculateAABB (dgBigVector& min, dgBigVector& max) const; - - void FlipWinding(); - void UniformBoxMapping (dgInt32 material, const dgMatrix& textureMatrix); - void CalculateNormals (dgFloat64 angleInRadians); - void SphericalMapping (dgInt32 material, const dgMatrix& uvAligment); - void BoxMapping (dgInt32 front, dgInt32 side, dgInt32 top, const dgMatrix& uvAligment); - void CylindricalMapping (dgInt32 cylinderMaterial, dgInt32 capMaterial, const dgMatrix& uvAligment); - void AngleBaseFlatteningMapping (dgInt32 cylinderMaterial, dgReportProgress progressReportCallback, void* const userData); - - dgEdge* InsertEdgeVertex (dgEdge* const edge, dgFloat64 param); - - dgMeshEffect* Union (const dgMatrix& matrix, const dgMeshEffect* const clipper) const; - dgMeshEffect* Difference (const dgMatrix& matrix, const dgMeshEffect* const clipper) const; - dgMeshEffect* Intersection (const dgMatrix& matrix, const dgMeshEffect* const clipper) const; - void ClipMesh (const dgMatrix& matrix, const dgMeshEffect* const clipper, dgMeshEffect** const top, dgMeshEffect** const bottom) const; - - //bool PlaneClip (const dgBigPlane& plane); - - dgMeshEffect* ConvexMeshIntersection (const dgMeshEffect* const convexMesh) const; - - dgMeshEffect* GetFirstLayer (); - dgMeshEffect* GetNextLayer (dgMeshEffect* const layer); - - void Triangulate (); - void ConvertToPolygons (); - void RemoveUnusedVertices(dgInt32* const vertexRemapTable); - - void BeginBuild (); - void BeginBuildFace (); - void AddPoint (dgFloat64 x, dgFloat64 y, dgFloat64 z); - void AddLayer (dgInt32 layer); - void AddMaterial (dgInt32 materialIndex); - void AddNormal (dgFloat32 x, dgFloat32 y, dgFloat32 z); - void AddBinormal (dgFloat32 x, dgFloat32 y, dgFloat32 z); - void AddVertexColor (dgFloat32 x, dgFloat32 y, dgFloat32 z, dgFloat32 w); - void AddUV0 (dgFloat32 u, dgFloat32 v); - void AddUV1 (dgFloat32 u, dgFloat32 v); - void EndBuildFace (); - void EndBuild (dgFloat64 tol, bool fixTjoint = true); - - dgInt32 GetVertexCount() const; - dgInt32 GetVertexStrideInByte() const; - const dgFloat64* GetVertexPool () const; - - dgInt32 GetVertexBaseCount() const; - void SetVertexBaseCount(dgInt32 count); - - dgEdge* SpliteFace (dgInt32 v0, dgInt32 v1); - - dgInt32 GetTotalFaceCount() const; - dgInt32 GetTotalIndexCount() const; - void GetFaces (dgInt32* const faceCount, dgInt32* const materials, void** const faceNodeList) const; - - void RepairTJoints (); - bool SeparateDuplicateLoops (dgEdge* const face); - - bool HasOpenEdges () const; - - dgFloat64 CalculateVolume () const; - - void OptimizePoints(); - void OptimizeAttibutes(); - void BuildFromIndexList(const dgMeshVertexFormat* const format); - - dgInt32 GetPropertiesCount() const; - const dgInt32* GetIndexToVertexMap() const; - - bool HasLayersChannel() const; - bool HasNormalChannel() const; - bool HasBinormalChannel() const; - bool HasUV0Channel() const; - bool HasUV1Channel() const; - bool HasVertexColorChannel() const; - - void GetVertexChannel64(dgInt32 strideInByte, dgFloat64* const bufferOut) const; - void GetVertexChannel(dgInt32 strideInByte, dgFloat32* const bufferOut) const; - void GetNormalChannel(dgInt32 strideInByte, dgFloat32* const bufferOut) const; - void GetBinormalChannel(dgInt32 strideInByte, dgFloat32* const bufferOut) const; - void GetUV0Channel(dgInt32 strideInByte, dgFloat32* const bufferOut) const; - void GetUV1Channel(dgInt32 strideInByte, dgFloat32* const bufferOut) const; - void GetVertexColorChannel(dgInt32 strideInByte, dgFloat32* const bufferOut) const; -// void GetWeightBlendChannel(dgInt32 strideInByte, dgFloat32* const bufferOut) const; -// void GetWeightIndexChannel(dgInt32 strideInByte, dgInt32* const bufferOut) const; - - dgIndexArray* MaterialGeometryBegin(); - void MaterialGeomteryEnd(dgIndexArray* const handle); - dgInt32 GetFirstMaterial (dgIndexArray* const handle) const; - dgInt32 GetNextMaterial (dgIndexArray* const handle, dgInt32 materialHandle) const; - dgInt32 GetMaterialID (dgIndexArray* const handle, dgInt32 materialHandle) const; - dgInt32 GetMaterialIndexCount (dgIndexArray* const handle, dgInt32 materialHandle) const; - void GetMaterialGetIndexStream (dgIndexArray* const handle, dgInt32 materialHandle, dgInt32* const index) const; - void GetMaterialGetIndexStreamShort (dgIndexArray* const handle, dgInt32 materialHandle, dgInt16* const index) const; - - dgCollisionInstance* CreateCollisionTree(dgWorld* const world, dgInt32 shapeID) const; - dgCollisionInstance* CreateConvexCollision(dgWorld* const world, dgFloat64 tolerance, dgInt32 shapeID, const dgMatrix& matrix = dgGetIdentityMatrix()) const; - - dgMeshEffect* CreateSimplification (dgInt32 maxVertexCount, dgReportProgress reportProgressCallback, void* const userData) const; - dgMeshEffect* CreateConvexApproximation (dgFloat32 maxConcavity, dgFloat32 backFaceDistanceFactor, dgInt32 maxHullOuputCount, dgInt32 maxVertexPerHull, dgReportProgress reportProgressCallback, void* const userData) const; - - dgMeshEffect* CreateTetrahedraIsoSurface() const; - void CreateTetrahedraLinearBlendSkinWeightsChannel (const dgMeshEffect* const tetrahedraMesh); - - static dgMeshEffect* CreateVoronoiConvexDecomposition (dgMemoryAllocator* const allocator, dgInt32 pointCount, dgInt32 pointStrideInBytes, const dgFloat32* const pointCloud, dgInt32 materialId, const dgMatrix& textureProjectionMatrix); - static dgMeshEffect* CreateFromSerialization (dgMemoryAllocator* const allocator, dgDeserialize deserialization, void* const userData); - - void LoadOffMesh (const char* const filename); - void LoadTetraMesh (const char* const filename); - void Serialize (dgSerialize callback, void* const userData) const; - - dgBigVector GetVertex (dgInt32 index) const; - dgInt32 GetVertexLayer (dgInt32 index) const; - - void TransformMesh (const dgMatrix& matrix); - - void* GetFirstVertex () const; - void* GetNextVertex (const void* const vertex) const; - int GetVertexIndex (const void* const vertex) const; - - void* GetFirstPoint () const; - void* GetNextPoint (const void* const point) const; - dgInt32 GetPointIndex (const void* const point) const; - dgInt32 GetVertexIndexFromPoint (const void* const point) const; - - void* GetFirstEdge () const; - void* GetNextEdge (const void* const edge) const; -// void* FindEdge (dgInt32 v0, dgInt32 v1) const; - void GetEdgeIndex (const void* const edge, dgInt32& v0, dgInt32& v1) const; -// void GetEdgeAttributeIndex (const void* edge, dgInt32& v0, dgInt32& v1) const; - - const dgEdge* GetPolyhedraEdgeFromNode(const void* const edge) const; - - void* GetFirstFace () const; - void* GetNextFace (const void* const face) const; - dgInt32 IsFaceOpen (const void* const face) const; - dgInt32 GetFaceMaterial (const void* const face) const; - dgInt32 GetFaceIndexCount (const void* const face) const; - void GetFaceIndex (const void* const face, dgInt32* const indices) const; - void GetFaceAttributeIndex (const void* const face, dgInt32* const indices) const; - dgBigVector CalculateFaceNormal (const void* const face) const; - - void SetFaceMaterial (const void* const face, int materialID); - void AddInterpolatedEdgeAttribute (dgEdge* const edge, dgFloat64 param); - dgInt32 AddInterpolatedHalfAttribute(dgEdge* const edge, dgInt32 midPoint); - dgInt32 InterpolateVertex (const dgBigVector& point, const dgEdge* const face) const; - - bool Sanity () const; - - protected: - virtual void BeginFace(); - virtual bool EndFace (); - - dgBigVector GetOrigin ()const; - dgInt32 CalculateMaxAttributes () const; - dgFloat64 QuantizeCordinade(dgFloat64 val) const; - - void MergeFaces (const dgMeshEffect* const source); -// void ReverseMergeFaces (dgMeshEffect* const source); - - bool PlaneClip (const dgMeshEffect& convexMesh, const dgEdge* const face); - - dgMeshEffect* GetNextLayer (dgInt32 mark); - dgMeshEffect* CreateVoronoiConvex (const dgBigVector* const conevexPointCloud, dgInt32 count, dgInt32 materialId, const dgMatrix& textureProjectionMatrix, dgFloat32 normalAngleInRadians) const; - - void PackAttibuteData (); - void UnpackAttibuteData (); - - void PackPoints (dgFloat64 tol); - void UnpackPoints(); - - dgPointFormat m_points; - dgAttibutFormat m_attrib; - dgInt32 m_vertexBaseCount; - dgInt32 m_constructionIndex; - - friend class dgConvexHull3d; - friend class dgConvexHull4d; - friend class dgBooleanMeshBVH; - friend class dgHACDClusterGraph; - friend class dgTriangleAnglesToUV; - friend class dgTetraIsoSufaceStuffing; - friend class dgCollisionCompoundFractured; -}; - -DG_INLINE dgInt32 dgMeshEffect::GetVertexCount() const -{ - return m_points.m_vertex.m_count; -} - -DG_INLINE dgInt32 dgMeshEffect::GetVertexBaseCount() const -{ - return m_vertexBaseCount; -} - -DG_INLINE void dgMeshEffect::SetVertexBaseCount(dgInt32 count) -{ - m_vertexBaseCount = count; -} - - -DG_INLINE dgInt32 dgMeshEffect::GetPropertiesCount() const -{ - return m_attrib.m_pointChannel.m_count; -} - -DG_INLINE const dgInt32* dgMeshEffect::GetIndexToVertexMap() const -{ - return &m_attrib.m_pointChannel[0]; -} - -DG_INLINE dgInt32 dgMeshEffect::GetMaterialID (dgIndexArray* const handle, dgInt32 materialHandle) const -{ - return handle->m_materials[materialHandle]; -} - -DG_INLINE dgInt32 dgMeshEffect::GetMaterialIndexCount (dgIndexArray* const handle, dgInt32 materialHandle) const -{ - return handle->m_materialsIndexCount[materialHandle]; -} - -DG_INLINE dgBigVector dgMeshEffect::GetVertex (dgInt32 index) const -{ - dgAssert(index >= 0); - dgAssert(index < m_points.m_vertex.m_count); - return m_points.m_vertex[index]; -} - -DG_INLINE bool dgMeshEffect::HasLayersChannel() const -{ - return m_points.m_layers.m_count != 0; -} - -DG_INLINE dgInt32 dgMeshEffect::GetVertexLayer(dgInt32 index) const -{ - dgAssert(index >= 0); - dgAssert(index < m_points.m_vertex.m_count); - return (m_points.m_layers.m_count) ? m_points.m_layers[index] : 0; -} - - -DG_INLINE dgInt32 dgMeshEffect::GetVertexStrideInByte() const -{ - return sizeof (dgBigVector); -} - -DG_INLINE const dgFloat64* dgMeshEffect::GetVertexPool () const -{ - return &m_points.m_vertex[0].m_x; -} - -DG_INLINE dgMeshEffect* dgMeshEffect::GetFirstLayer () -{ - return GetNextLayer (IncLRU()); -} - -DG_INLINE dgMeshEffect* dgMeshEffect::GetNextLayer (dgMeshEffect* const layerSegment) -{ - if (!layerSegment) { - return NULL; - } - return GetNextLayer (layerSegment->IncLRU() - 1); -} - - -DG_INLINE dgFloat64 dgMeshEffect::QuantizeCordinade(dgFloat64 x) const -{ - dgInt32 exp; - dgFloat64 mantissa = frexp(x, &exp); - mantissa = DG_MESH_EFFECT_PRECISION_SCALE_INV * floor (mantissa * DG_MESH_EFFECT_PRECISION_SCALE); - - dgFloat64 x1 = ldexp(mantissa, exp); - return x1; -} - -#endif diff --git a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect1.cpp b/thirdparty/src/newton/dgMeshUtil/dgMeshEffect1.cpp deleted file mode 100644 index 2e2729ca8..000000000 --- a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect1.cpp +++ /dev/null @@ -1,4016 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgMeshEffect.h" -#include "dgCollisionBVH.h" -#include "dgCollisionCompound.h" -#include "dgCollisionConvexHull.h" - - -dgMeshEffect::dgPointFormat::dgPointFormat(dgMemoryAllocator* const allocator) - :m_layers(allocator) - ,m_vertex(allocator) -{ -} - -dgMeshEffect::dgPointFormat::dgPointFormat(const dgPointFormat& source) - :m_layers(source.m_layers) - ,m_vertex(source.m_vertex) -{ -} - -dgMeshEffect::dgPointFormat::~dgPointFormat() -{ -} - -void dgMeshEffect::dgPointFormat::Clear() -{ - m_layers.Clear(); - m_vertex.Clear(); -} - -void dgMeshEffect::dgPointFormat::SetCount(dgInt32 count) -{ - m_layers.SetCount(count); - m_vertex.SetCount(count); -} - -dgInt32 dgMeshEffect::dgFormat::GetSortIndex (const dgChannel<dgBigVector, m_point>& points, dgFloat64& dist) const -{ - dgBigVector xc(dgFloat64(0.0f)); - dgBigVector x2c(dgFloat64(0.0f)); - dgBigVector minP(dgFloat64(1.0e10f)); - dgBigVector maxP(dgFloat64(-1.0e10f)); - for (dgInt32 i = 0; i < points.m_count; i++) { - dgBigVector x(points[i]); - xc += x; - x2c += x * x; - minP = minP.GetMin(x); - maxP = maxP.GetMax(x); - } - - dgBigVector del(maxP - minP); - dgFloat64 minDist = dgMin(del.m_x, del.m_y, del.m_z); - if (minDist < dgFloat64(1.0e-3f)) { - minDist = dgFloat64(1.0e-3f); - } - - dgInt32 firstSortAxis = 0; - x2c = x2c.Scale(points.m_count) - xc * xc; - if ((x2c.m_y >= x2c.m_x) && (x2c.m_y >= x2c.m_z)) { - firstSortAxis = 1; - } - else if ((x2c.m_z >= x2c.m_x) && (x2c.m_z >= x2c.m_y)) { - firstSortAxis = 2; - } - dist = minDist; - return firstSortAxis; -} - -dgInt32 dgMeshEffect::dgFormat::CompareVertex(const dgSortKey* const ptr0, const dgSortKey* const ptr1, void* const context) -{ - const VertexSortData* const sortContext = (VertexSortData*)context; - const dgInt32 compIndex = sortContext->m_vertexSortIndex; - const dgChannel<dgBigVector, m_point>& points = *sortContext->m_points; - const dgFloat64 x0 = points[ptr0->m_vertexIndex][compIndex]; - const dgFloat64 x1 = points[ptr1->m_vertexIndex][compIndex]; - - if (x0 < x1) { - return -1; - } else if (x0 > x1) { - return 1; - } - return 0; -} - -void dgMeshEffect::dgPointFormat::CompressData(dgInt32* const indexList) -{ - dgFloat64 minDist; - const dgInt32 firstSortAxis = GetSortIndex(m_vertex, minDist); - - dgStack<dgFormat::dgSortKey> indirectListBuffer(m_vertex.m_count); - dgFormat::dgSortKey* indirectList = &indirectListBuffer[0]; - for (dgInt32 i = 0; i < m_vertex.m_count; i++) { - indirectList[i].m_mask = -1; - indirectList[i].m_ordinal = i; - indirectList[i].m_vertexIndex = i; - indirectList[i].m_attibuteIndex = -1; - } - - dgPointFormat tmpFormat(*this); - VertexSortData sortContext; - sortContext.m_points = &tmpFormat.m_vertex; - //sortContext.m_points = &tmpFormat; - sortContext.m_vertexSortIndex = firstSortAxis; - dgSort(indirectList, m_vertex.m_count, dgFormat::CompareVertex, &sortContext); - - const dgFloat64 tolerance = dgMin (minDist, dgFloat64 (1.0e-12f)); - const dgFloat64 sweptWindow = dgFloat64(2.0f) * tolerance + dgFloat64 (1.0e-10f); - - dgInt32 newCount = 0; - for (dgInt32 i = 0; i < tmpFormat.m_vertex.m_count; i++) { - const dgInt32 ii = indirectList[i].m_mask; - if (ii == -1) { - const dgInt32 i0 = indirectList[i].m_ordinal; - const dgInt32 iii = indirectList[i].m_vertexIndex; - const dgBigVector& p = tmpFormat.m_vertex[iii]; - //const dgFloat64 swept = tmpFormat.m_vertex[iii][firstSortAxis] + sweptWindow; - const dgFloat64 swept = p[firstSortAxis] + sweptWindow; - for (dgInt32 j = i + 1; j < tmpFormat.m_vertex.m_count; j++) { - - const dgInt32 jj = indirectList[j].m_mask; - if (jj == -1) { - const dgInt32 j0 = indirectList[j].m_ordinal; - const dgInt32 jjj = indirectList[j].m_vertexIndex; - const dgBigVector& q = tmpFormat.m_vertex[jjj]; - //dgFloat64 val = tmpFormat.m_vertex[jjj][firstSortAxis]; - dgFloat64 val = q[firstSortAxis]; - if (val >= swept) { - break; - } - - bool test = true; - if (iii != jjj) { - //dgBigVector dp(tmpFormat.m_vertex[iii] - tmpFormat.m_vertex[jjj]); - dgBigVector dp(p - q); - for (dgInt32 k = 0; k < 3; k++) { - test &= (fabs(dp[k]) <= tolerance); - } - } - if (test && tmpFormat.m_layers.m_count) { - test &= (tmpFormat.m_layers[i0] == tmpFormat.m_layers[j0]); - } - // note, is ok weight duplicate to be ignored. - - if (test) { - indirectList[j].m_mask = newCount; - } - } - } - - //indirectList[newCount].m_attibuteIndex = indirectList[i].m_attibuteIndex; - indirectList[newCount].m_vertexIndex = indirectList[i].m_vertexIndex; - indirectList[i].m_mask = newCount; - newCount++; - } - } - - Clear(); - for (dgInt32 i = 0; i < newCount; i++) { - dgAssert (indirectList[i].m_attibuteIndex == -1); - m_vertex.PushBack(tmpFormat.m_vertex[indirectList[i].m_vertexIndex]); - } - - if (tmpFormat.m_layers.m_count) { - for (dgInt32 i = 0; i < newCount; i++) { - m_layers.PushBack(tmpFormat.m_layers[indirectList[i].m_vertexIndex]); - } - } - - for (dgInt32 i = 0; i < tmpFormat.m_vertex.m_count; i++) { - dgInt32 i1 = indirectList[i].m_ordinal; - dgInt32 index = indirectList[i].m_mask; - indexList[i1] = index; - } -} - -dgMeshEffect::dgAttibutFormat::dgAttibutFormat(dgMemoryAllocator* const allocator) - :m_pointChannel(allocator) - ,m_materialChannel(allocator) - ,m_normalChannel(allocator) - ,m_binormalChannel(allocator) - ,m_colorChannel(allocator) - ,m_uv0Channel(allocator) - ,m_uv1Channel(allocator) -{ -} - -dgMeshEffect::dgAttibutFormat::dgAttibutFormat(const dgAttibutFormat& source) - :m_pointChannel(source.m_pointChannel) - ,m_materialChannel(source.m_materialChannel) - ,m_normalChannel(source.m_normalChannel) - ,m_binormalChannel(source.m_binormalChannel) - ,m_colorChannel(source.m_colorChannel) - ,m_uv0Channel(source.m_uv0Channel) - ,m_uv1Channel(source.m_uv1Channel) -{ -} - -dgMeshEffect::dgAttibutFormat::~dgAttibutFormat() -{ -} - - -void dgMeshEffect::dgAttibutFormat::Clear() -{ - m_pointChannel.Clear(); - m_materialChannel.Clear(); - m_normalChannel.Clear(); - m_binormalChannel.Clear(); - m_colorChannel.Clear(); - m_uv0Channel.Clear(); - m_uv1Channel.Clear(); -} - -void dgMeshEffect::dgAttibutFormat::SetCount (dgInt32 count) -{ - m_pointChannel.SetCount(count); - m_materialChannel.SetCount(count); - m_normalChannel.SetCount(count); - m_binormalChannel.SetCount(count); - m_colorChannel.SetCount(count); - m_uv0Channel.SetCount(count); - m_uv1Channel.SetCount(count); -} - -void dgMeshEffect::dgAttibutFormat::CopyFrom (const dgAttibutFormat& source) -{ - m_pointChannel.CopyFrom(source.m_pointChannel); - m_materialChannel.CopyFrom(source.m_materialChannel); - m_normalChannel.CopyFrom(source.m_normalChannel); - m_binormalChannel.CopyFrom(source.m_binormalChannel); - m_colorChannel.CopyFrom(source.m_colorChannel); - m_uv0Channel.CopyFrom(source.m_uv0Channel); - m_uv1Channel.CopyFrom(source.m_uv1Channel); -} - -void dgMeshEffect::dgAttibutFormat::CompressData (const dgPointFormat& points, dgInt32* const indexList) -{ - dgFloat64 minDist; - const dgInt32 firstSortAxis = GetSortIndex(points.m_vertex, minDist); - - dgStack<dgFormat::dgSortKey> indirectListBuffer(m_pointChannel.m_count); - dgFormat::dgSortKey* indirectList = &indirectListBuffer[0]; - for (dgInt32 i = 0; i < m_pointChannel.m_count; i++) { - indirectList[i].m_mask = -1; - indirectList[i].m_ordinal = i; - indirectList[i].m_attibuteIndex = i; - indirectList[i].m_vertexIndex = m_pointChannel[i]; - } - - VertexSortData sortContext; - sortContext.m_points = &points.m_vertex; - sortContext.m_vertexSortIndex = firstSortAxis; - dgSort (indirectList, m_pointChannel.m_count, dgFormat::CompareVertex, &sortContext); - dgAttibutFormat tmpFormat (*this); - Clear(); - - const dgFloat64 tolerance = dgMin(minDist, dgFloat64(1.0e-12f)); - const dgFloat64 sweptWindow = dgFloat64(2.0f) * tolerance + dgFloat64(1.0e-10f); - - dgInt32 newCount = 0; - for (dgInt32 i = 0; i < tmpFormat.m_pointChannel.m_count; i ++) { - const dgInt32 ii = indirectList[i].m_mask; - if (ii == -1) { - const dgInt32 i0 = indirectList[i].m_ordinal; - const dgInt32 iii = indirectList[i].m_vertexIndex; - const dgFloat64 swept = points.m_vertex[iii][firstSortAxis] + sweptWindow; - for (dgInt32 j = i + 1; j < tmpFormat.m_pointChannel.m_count; j++) { - const dgInt32 jj = indirectList[j].m_mask; - if (jj == -1) { - const dgInt32 j0 = indirectList[j].m_ordinal; - const dgInt32 jjj = indirectList[j].m_vertexIndex;; - dgFloat64 val = points.m_vertex[jjj][firstSortAxis]; - if (val >= swept) { - break; - } - - bool test = true; - if (iii != jjj) { - dgBigVector dp (points.m_vertex[iii] - points.m_vertex[jjj]); - for (dgInt32 k = 0; k < 3; k ++) { - test &= (fabs (dp[k]) <= tolerance); - } - } - if (test && points.m_layers.m_count) { - test &= (points.m_layers[iii] == points.m_layers[jjj]); - } - - if (test && tmpFormat.m_normalChannel.m_count) { - dgVector n0(tmpFormat.m_normalChannel[i0].m_x, tmpFormat.m_normalChannel[i0].m_y, tmpFormat.m_normalChannel[i0].m_z, dgFloat32 (0.0f)); - dgVector n1(tmpFormat.m_normalChannel[j0].m_x, tmpFormat.m_normalChannel[j0].m_y, tmpFormat.m_normalChannel[j0].m_z, dgFloat32 (0.0f)); - dgVector dp (n1 - n0); - for (dgInt32 k = 0; k < 3; k++) { - test &= (fabs(dp[k]) <= tolerance); - } - } - - if (test && tmpFormat.m_binormalChannel.m_count) { - dgVector n0(tmpFormat.m_binormalChannel[i0].m_x, tmpFormat.m_binormalChannel[i0].m_y, tmpFormat.m_binormalChannel[i0].m_z, dgFloat32(0.0f)); - dgVector n1(tmpFormat.m_binormalChannel[j0].m_x, tmpFormat.m_binormalChannel[j0].m_y, tmpFormat.m_binormalChannel[j0].m_z, dgFloat32(0.0f)); - dgVector dp(n1 - n0); - for (dgInt32 k = 0; k < 3; k++) { - test &= (fabs(dp[k]) <= tolerance); - } - } - - if (test && tmpFormat.m_uv0Channel.m_count) { - dgVector n0(tmpFormat.m_uv0Channel[i0].m_u, tmpFormat.m_uv0Channel[i0].m_v, dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector n1(tmpFormat.m_uv0Channel[j0].m_u, tmpFormat.m_uv0Channel[j0].m_v, dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector dp(n1 - n0); - for (dgInt32 k = 0; k < 2; k++) { - test &= (fabs(dp[k]) <= tolerance); - } - } - - if (test && tmpFormat.m_uv1Channel.m_count) { - dgVector n0(tmpFormat.m_uv1Channel[i0].m_u, tmpFormat.m_uv1Channel[i0].m_v, dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector n1(tmpFormat.m_uv1Channel[j0].m_u, tmpFormat.m_uv1Channel[j0].m_v, dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector dp(n1 - n0); - for (dgInt32 k = 0; k < 2; k++) { - test &= (fabs(dp[k]) <= tolerance); - } - } - - if (test && tmpFormat.m_colorChannel.m_count) { - dgVector dp(m_colorChannel[i0] - m_colorChannel[j0]); - for (dgInt32 k = 0; k < 3; k++) { - test &= (fabs(dp[k]) <= tolerance); - } - } - - if (test && tmpFormat.m_materialChannel.m_count) { - test &= (tmpFormat.m_materialChannel[i0] == tmpFormat.m_materialChannel[j0]); - } - - if (test) { - indirectList[j].m_mask = newCount; - } - } - } - - indirectList[newCount].m_attibuteIndex = indirectList[i].m_attibuteIndex; - indirectList[newCount].m_vertexIndex = indirectList[i].m_vertexIndex; - indirectList[i].m_mask = newCount; - newCount++; - } - } - - for (dgInt32 i = 0; i < newCount; i ++) { - m_pointChannel.PushBack(indirectList[i].m_vertexIndex); - } - - if (tmpFormat.m_normalChannel.m_count) { - for (dgInt32 i = 0; i < newCount; i++) { - m_normalChannel.PushBack(tmpFormat.m_normalChannel[indirectList[i].m_attibuteIndex]); - } - } - - if (tmpFormat.m_binormalChannel.m_count) { - for (dgInt32 i = 0; i < newCount; i++) { - m_binormalChannel.PushBack(tmpFormat.m_binormalChannel[indirectList[i].m_attibuteIndex]); - } - } - - if (tmpFormat.m_uv0Channel.m_count) { - for (dgInt32 i = 0; i < newCount; i++) { - m_uv0Channel.PushBack(tmpFormat.m_uv0Channel[indirectList[i].m_attibuteIndex]); - } - } - - if (tmpFormat.m_uv1Channel.m_count) { - for (dgInt32 i = 0; i < newCount; i++) { - m_uv1Channel.PushBack(tmpFormat.m_uv1Channel[indirectList[i].m_attibuteIndex]); - } - } - - if (tmpFormat.m_colorChannel.m_count) { - for (dgInt32 i = 0; i < newCount; i++) { - m_colorChannel.PushBack(tmpFormat.m_colorChannel[indirectList[i].m_attibuteIndex]); - } - } - - if (tmpFormat.m_materialChannel.m_count) { - for (dgInt32 i = 0; i < newCount; i++) { - m_materialChannel.PushBack(tmpFormat.m_materialChannel[indirectList[i].m_attibuteIndex]); - } - } - - for (dgInt32 i = 0; i < tmpFormat.m_pointChannel.m_count; i ++) { - dgInt32 i1 = indirectList[i].m_ordinal; - dgInt32 index = indirectList[i].m_mask; - indexList[i1] = index; - } -} - -dgMeshEffect::dgMeshBVH::dgFitnessList::dgFitnessList (dgMemoryAllocator* const allocator) - :dgTree <dgMeshBVHNode*, dgMeshBVHNode*>(allocator) -{ -} - -dgFloat64 dgMeshEffect::dgMeshBVH::dgFitnessList::TotalCost () const -{ - dgFloat64 cost = dgFloat32 (0.0f); - Iterator iter (*this); - for (iter.Begin(); iter; iter ++) { - dgTreeNode* const node = iter.GetNode(); - dgMeshBVHNode* const box = node->GetInfo(); - cost += box->m_area; - } - return cost; -} - - -dgMeshEffect::dgMeshBVH::dgMeshBVHNode::dgMeshBVHNode (const dgMeshEffect* const mesh, dgEdge* const face, void* const userData) - :m_area(dgFloat32 (0.0f)) - ,m_face (face) - ,m_userData(userData) - ,m_left (NULL) - ,m_right(NULL) - ,m_parent(NULL) -{ - dgBigVector p0(dgFloat32 ( 1.0e30f)); - dgBigVector p1(dgFloat32 (-1.0e30f)); - - const dgBigVector* const points = (dgBigVector*) mesh->GetVertexPool(); - - dgEdge* ptr = m_face; - do { - dgInt32 i = ptr->m_incidentVertex; - const dgBigVector& p = points[i]; - p0 = p.GetMin(p0); - p1 = p.GetMax(p1); - - ptr = ptr->m_next; - } while (ptr != face); - - dgVector padding (dgFloat32 (1.0f / 32.0f)); - SetBox (p0 - padding, p1 + padding); -} - -dgMeshEffect::dgMeshBVH::dgMeshBVHNode::dgMeshBVHNode (dgMeshBVHNode* const left, dgMeshBVHNode* const right) - :m_area(dgFloat32 (0.0f)) - ,m_face (NULL) - ,m_userData(NULL) - ,m_left (left) - ,m_right(right) - ,m_parent(NULL) -{ - m_left->m_parent = this; - m_right->m_parent = this; - -// dgVector p0 (dgMin (left->m_p0.m_x, right->m_p0.m_x), dgMin (left->m_p0.m_y, right->m_p0.m_y), dgMin (left->m_p0.m_z, right->m_p0.m_z), dgFloat32 (0.0f)); -// dgVector p1 (dgMax (left->m_p1.m_x, right->m_p1.m_x), dgMax (left->m_p1.m_y, right->m_p1.m_y), dgMax (left->m_p1.m_z, right->m_p1.m_z), dgFloat32 (0.0f)); - dgVector p0 (left->m_p0.GetMin(right->m_p0)); - dgVector p1 (left->m_p1.GetMax(right->m_p1)); - SetBox(p0, p1); -} - - -dgMeshEffect::dgMeshBVH::dgMeshBVHNode::~dgMeshBVHNode () -{ - if (m_left) { - delete m_left; - } - if (m_right) { - delete m_right; - } -} - -void dgMeshEffect::dgMeshBVH::dgMeshBVHNode::SetBox (const dgVector& p0, const dgVector& p1) -{ - m_p0 = p0 & dgVector::m_triplexMask; - m_p1 = p1 & dgVector::m_triplexMask; - dgVector size (dgVector::m_half * (m_p1 - m_p0)); - dgVector size1(size.ShiftTripleLeft()); - dgAssert (size1.m_w == dgFloat32 (0.0f)); - m_area = size.DotProduct(size1).GetScalar(); -} - -dgMeshEffect::dgMeshBVH::dgMeshBVH (const dgMeshEffect* const mesh) - :m_mesh(mesh) - ,m_rootNode(NULL) - ,m_fitness(m_mesh->GetAllocator()) -{ -} - - -dgMeshEffect::dgMeshBVH::~dgMeshBVH() -{ - Cleanup (); -} - -dgMeshEffect* dgMeshEffect::CreateFromSerialization (dgMemoryAllocator* const allocator, dgDeserialize deserialization, void* const userData) -{ - return new (allocator) dgMeshEffect(allocator, deserialization, userData); -} - -void dgMeshEffect::Serialize (dgSerialize callback, void* const userData) const -{ - dgAssert(0); -/* - dgInt32 faceCount = 0; - dgTree<dgEdge*, dgEdge*>filter(GetAllocator()); - Iterator iter (*this); - for (iter.Begin(); iter; iter ++) { - dgEdge* const face = &iter.GetNode()->GetInfo(); - if (!filter.Find(face) && (face->m_incidentFace > 0)) { - faceCount ++; - dgEdge* edge = face; - do { - filter.Insert(edge, edge); - edge = edge->m_next; - } while (edge != face); - } - } - - callback (userData, &faceCount, sizeof (dgInt32)); - callback (userData, &m_pointCount, sizeof (dgInt32)); - callback (userData, &m_atribCount, sizeof (dgInt32)); - callback (userData, &m_atribCount, sizeof (dgInt32)); - - callback (userData, m_points, m_pointCount * sizeof (dgBigVector)); - callback (userData, m_attrib, m_atribCount * sizeof (dgVertexAtribute)); - - filter.RemoveAll(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const face = &iter.GetNode()->GetInfo(); - if (!filter.Find(face) && (face->m_incidentFace > 0)) { - dgInt32 indices[1024]; - dgInt64 attibuteIndex[1024]; - dgInt32 vertexCount = 0; - dgEdge* edge = face; - do { - indices[vertexCount] = edge->m_incidentVertex; - attibuteIndex[vertexCount] = edge->m_userData; - vertexCount ++; - filter.Insert(edge, edge); - edge = edge->m_next; - } while (edge != face); - - callback (userData, &vertexCount, sizeof (dgInt32)); - callback (userData, indices, vertexCount * sizeof (dgInt32)); - callback (userData, attibuteIndex, vertexCount * sizeof (dgInt64)); - } - } -*/ -} - -void dgMeshEffect::dgMeshBVH::Build () -{ - dgInt32 lru = m_mesh->IncLRU(); -/* - for (void* faceNode = m_mesh->GetFirstFace (); faceNode; faceNode = m_mesh->GetNextFace(faceNode)) { - if (!m_mesh->IsFaceOpen(faceNode)) { - dgEdge* const face = &((dgTreeNode*)faceNode)->GetInfo(); - if (face->m_mark != mark) { - AddFaceNode(face, NULL); - } - } - } -*/ - dgMeshEffect::Iterator iter(*m_mesh); - for (iter.Begin(); iter; iter++) { - dgEdge* const face = &iter.GetNode()->GetInfo(); - if (face->m_mark != lru) { - AddFaceNode(face, NULL); - } - } - ImproveNodeFitness (); -} - -void dgMeshEffect::dgMeshBVH::Cleanup () -{ - if (m_rootNode) { - delete m_rootNode; - } -} - -dgFloat32 dgMeshEffect::dgMeshBVH::CalculateSurfaceArea (dgMeshBVHNode* const node0, dgMeshBVHNode* const node1, dgVector& minBox, dgVector& maxBox) const -{ - minBox = dgVector (dgMin (node0->m_p0.m_x, node1->m_p0.m_x), dgMin (node0->m_p0.m_y, node1->m_p0.m_y), dgMin (node0->m_p0.m_z, node1->m_p0.m_z), dgFloat32 (0.0f)); - maxBox = dgVector (dgMax (node0->m_p1.m_x, node1->m_p1.m_x), dgMax (node0->m_p1.m_y, node1->m_p1.m_y), dgMax (node0->m_p1.m_z, node1->m_p1.m_z), dgFloat32 (0.0f)); - dgVector side0 ((maxBox - minBox) * dgVector::m_half); - dgVector side1 (side0.ShiftTripleLeft()); - dgAssert (side1.m_w == dgFloat32 (0.0f)); - return side0.DotProduct(side1).GetScalar(); -} - -void dgMeshEffect::dgMeshBVH::ImproveNodeFitness (dgMeshBVHNode* const node) -{ - dgAssert (node->m_left); - dgAssert (node->m_right); - - if (node->m_parent) { - if (node->m_parent->m_left == node) { - dgFloat32 cost0 = node->m_area; - - dgVector cost1P0; - dgVector cost1P1; - dgFloat32 cost1 = CalculateSurfaceArea (node->m_right, node->m_parent->m_right, cost1P0, cost1P1); - - dgVector cost2P0; - dgVector cost2P1; - dgFloat32 cost2 = CalculateSurfaceArea (node->m_left, node->m_parent->m_right, cost2P0, cost2P1); - - if ((cost1 <= cost0) && (cost1 <= cost2)) { - dgMeshBVHNode* const parent = node->m_parent; - node->m_p0 = parent->m_p0; - node->m_p1 = parent->m_p1; - node->m_area = parent->m_area; - - if (parent->m_parent) { - if (parent->m_parent->m_left == parent) { - parent->m_parent->m_left = node; - } else { - dgAssert (parent->m_parent->m_right == parent); - parent->m_parent->m_right = node; - } - } else { - m_rootNode = node; - } - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_right->m_parent = parent; - parent->m_left = node->m_right; - node->m_right = parent; - parent->m_p0 = cost1P0; - parent->m_p1 = cost1P1; - parent->m_area = cost1; - - - } else if ((cost2 <= cost0) && (cost2 <= cost1)) { - dgMeshBVHNode* const parent = node->m_parent; - node->m_p0 = parent->m_p0; - node->m_p1 = parent->m_p1; - node->m_area = parent->m_area; - - if (parent->m_parent) { - if (parent->m_parent->m_left == parent) { - parent->m_parent->m_left = node; - } else { - dgAssert (parent->m_parent->m_right == parent); - parent->m_parent->m_right = node; - } - } else { - m_rootNode = node; - } - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_left->m_parent = parent; - parent->m_left = node->m_left; - node->m_left = parent; - - parent->m_p0 = cost2P0; - parent->m_p1 = cost2P1; - parent->m_area = cost2; - } - } else { - dgFloat32 cost0 = node->m_area; - - dgVector cost1P0; - dgVector cost1P1; - dgFloat32 cost1 = CalculateSurfaceArea (node->m_left, node->m_parent->m_left, cost1P0, cost1P1); - - dgVector cost2P0; - dgVector cost2P1; - dgFloat32 cost2 = CalculateSurfaceArea (node->m_right, node->m_parent->m_left, cost2P0, cost2P1); - - if ((cost1 <= cost0) && (cost1 <= cost2)) { - dgMeshBVHNode* const parent = node->m_parent; - node->m_p0 = parent->m_p0; - node->m_p1 = parent->m_p1; - node->m_area = parent->m_area; - - if (parent->m_parent) { - if (parent->m_parent->m_left == parent) { - parent->m_parent->m_left = node; - } else { - dgAssert (parent->m_parent->m_right == parent); - parent->m_parent->m_right = node; - } - } else { - m_rootNode = node; - } - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_left->m_parent = parent; - parent->m_right = node->m_left; - node->m_left = parent; - - parent->m_p0 = cost1P0; - parent->m_p1 = cost1P1; - parent->m_area = cost1; - - } else if ((cost2 <= cost0) && (cost2 <= cost1)) { - dgMeshBVHNode* const parent = node->m_parent; - node->m_p0 = parent->m_p0; - node->m_p1 = parent->m_p1; - node->m_area = parent->m_area; - - if (parent->m_parent) { - if (parent->m_parent->m_left == parent) { - parent->m_parent->m_left = node; - } else { - dgAssert (parent->m_parent->m_right == parent); - parent->m_parent->m_right = node; - } - } else { - m_rootNode = node; - } - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_right->m_parent = parent; - parent->m_right = node->m_right; - node->m_right = parent; - - parent->m_p0 = cost2P0; - parent->m_p1 = cost2P1; - parent->m_area = cost2; - } - } - } - // dgAssert (SanityCheck()); -} - - -void dgMeshEffect::dgMeshBVH::ImproveNodeFitness () -{ - dgFloat64 cost0 = m_fitness.TotalCost (); - dgFloat64 cost1 = cost0; - do { - cost0 = cost1; - dgFitnessList::Iterator iter (m_fitness); - for (iter.Begin(); iter; iter ++) { - dgFitnessList::dgTreeNode* const node = iter.GetNode(); - ImproveNodeFitness (node->GetInfo()); - } - cost1 = m_fitness.TotalCost (); - } while (cost1 < (dgFloat32 (0.95f)) * cost0); -} - -/* -dgMeshEffect::dgMeshBVH::dgMeshBVHNode* dgMeshEffect::dgMeshBVH::CreateLeafNode (dgEdge* const face, void* const userData) -{ - dgMemoryAllocator* const allocator = m_mesh->GetAllocator(); - return new (allocator) dgMeshBVHNode (m_mesh, face, userData); -} -*/ - -dgMeshEffect::dgMeshBVH::dgMeshBVHNode* dgMeshEffect::dgMeshBVH::AddFaceNode (dgEdge* const face, void* const userData) -{ - dgMemoryAllocator* const allocator = m_mesh->GetAllocator(); - - dgMeshBVHNode* const newNode = CreateLeafNode (face, userData); - if (!m_rootNode) { - m_rootNode = newNode; - } else { - - dgVector p0; - dgVector p1; - dgMeshBVHNode* sibling = m_rootNode; - - dgFloat32 surfaceArea = dgMeshBVH::CalculateSurfaceArea (newNode, sibling, p0, p1); - while(sibling->m_left && sibling->m_right) { - - if (surfaceArea > sibling->m_area) { - break; - } - - sibling->SetBox (p0, p1); - - dgVector leftP0; - dgVector leftP1; - dgFloat32 leftSurfaceArea = CalculateSurfaceArea (newNode, sibling->m_left, leftP0, leftP1); - - dgVector rightP0; - dgVector rightP1; - dgFloat32 rightSurfaceArea = CalculateSurfaceArea (newNode, sibling->m_right, rightP0, rightP1); - - if (leftSurfaceArea < rightSurfaceArea) { - sibling = sibling->m_left; - p0 = leftP0; - p1 = leftP1; - surfaceArea = leftSurfaceArea; - } else { - sibling = sibling->m_right; - p0 = rightP0; - p1 = rightP1; - surfaceArea = rightSurfaceArea; - } - } - - if (!sibling->m_parent) { - m_rootNode = new (allocator) dgMeshBVHNode (sibling, newNode); - m_fitness.Insert(m_rootNode, m_rootNode); - } else { - dgMeshBVHNode* const parent = sibling->m_parent; - if (parent->m_left == sibling) { - dgMeshBVHNode* const node = new (allocator) dgMeshBVHNode (sibling, newNode); - m_fitness.Insert(node, node); - parent->m_left = node; - node->m_parent = parent; - } else { - dgAssert (parent->m_right == sibling); - dgMeshBVHNode* const node = new (allocator) dgMeshBVHNode (sibling, newNode); - m_fitness.Insert(node, node); - parent->m_right = node; - node->m_parent = parent; - } - } - } - - return newNode; -} - - -void dgMeshEffect::dgMeshBVH::RemoveNode (dgMeshBVHNode* const treeNode) -{ - if (!treeNode->m_parent) { - delete (m_rootNode); - m_rootNode = NULL; - } else if (!treeNode->m_parent->m_parent) { - dgMeshBVHNode* const root = m_rootNode; - if (treeNode->m_parent->m_left == treeNode) { - m_rootNode = treeNode->m_parent->m_right; - treeNode->m_parent->m_right = NULL; - } else { - dgAssert (treeNode->m_parent->m_right == treeNode); - m_rootNode = treeNode->m_parent->m_left; - treeNode->m_parent->m_left= NULL; - } - m_rootNode->m_parent = NULL; - dgAssert (m_fitness.Find(root)); - m_fitness.Remove(root); - delete (root); - - } else { - dgMeshBVHNode* const root = treeNode->m_parent->m_parent; - if (treeNode->m_parent == root->m_left) { - if (treeNode->m_parent->m_right == treeNode) { - root->m_left = treeNode->m_parent->m_left; - treeNode->m_parent->m_left = NULL; - } else { - dgAssert (treeNode->m_parent->m_left == treeNode); - root->m_left = treeNode->m_parent->m_right; - treeNode->m_parent->m_right = NULL; - } - root->m_left->m_parent = root; - } else { - if (treeNode->m_parent->m_right == treeNode) { - root->m_right = treeNode->m_parent->m_left; - treeNode->m_parent->m_left = NULL; - } else { - dgAssert (treeNode->m_parent->m_left == treeNode); - root->m_right = treeNode->m_parent->m_right; - treeNode->m_parent->m_right = NULL; - } - root->m_right->m_parent = root; - } - - dgAssert (m_fitness.Find(treeNode->m_parent)); - m_fitness.Remove(treeNode->m_parent); - delete (treeNode->m_parent); - } - - //dgAssert (SanityCheck()); -} - -bool dgMeshEffect::dgMeshBVH::SanityCheck() const -{ - #ifdef _DEBUG - dgAssert (m_mesh->Sanity ()); - - if (!m_rootNode) { - return false; - } - - if ((!m_rootNode->m_left && m_rootNode->m_right) || (m_rootNode->m_left && !m_rootNode->m_right)) { - return false; - } - - if (m_rootNode->m_left && m_rootNode->m_right) { - if (m_rootNode->m_left->m_parent != m_rootNode) { - return false; - } - if (m_rootNode->m_right->m_parent != m_rootNode) { - return false; - } - - dgMeshBVHNode* stackPool[DG_MESH_EFFECT_BVH_STACK_DEPTH]; - - dgInt32 stack = 2; - stackPool[0] = m_rootNode->m_left; - stackPool[1] = m_rootNode->m_right; - while (stack) { - stack --; - dgMeshBVHNode* const node = stackPool[stack]; - - if ((node->m_parent->m_left != node) && (node->m_parent->m_right != node)){ - return false; - } - - if (node->m_left) { - dgAssert (node->m_right); - stackPool[stack] = node->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgMeshBVHNode*))); - - stackPool[stack] = node->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgMeshBVHNode*))); - } - } - } - #endif - return true; -} - -void dgMeshEffect::dgMeshBVH::GetOverlapNodes (dgList<dgMeshBVHNode*>& overlapNodes, const dgBigVector& p0, const dgBigVector& p1) const -{ - dgMeshBVHNode* stackPool[DG_MESH_EFFECT_BVH_STACK_DEPTH]; - - dgInt32 stack = 1; - stackPool[0] = m_rootNode; - - dgVector l0(p0); - dgVector l1(p1); - - while (stack) { - stack --; - dgMeshBVHNode* const me = stackPool[stack]; - - if (me && dgOverlapTest (me->m_p0, me->m_p1, l0, l1)) { - - if (!me->m_left) { - dgAssert (!me->m_right); - overlapNodes.Append(me); - } else { - dgAssert (me->m_left); - dgAssert (me->m_right); - stackPool[stack] = me->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgMeshBVHNode*))); - - stackPool[stack] = me->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgMeshBVHNode*))); - } - } - } -} - -/* -dgFloat64 dgMeshEffect::dgMeshBVH::VertexRayCast (const dgBigVector& p0, const dgBigVector& p1) const -{ - dgAssert (0); - - dgMeshBVHNode* stackPool[DG_MESH_EFFECT_BVH_STACK_DEPTH]; - - dgInt32 stack = 1; - stackPool[0] = m_rootNode; - - dgVector l0(p0); - dgVector l1(p1); - dgBigVector p1p0 (p1 - p0); - dgFloat64 den = p1p0 % p1p0; - - const dgBigVector* const points = (dgBigVector*) m_mesh->GetVertexPool(); - while (stack) { - stack --; - dgMeshBVHNode* const me = stackPool[stack]; - - if (me && dgOverlapTest (me->m_p0, me->m_p1, l0, l1)) { - if (!me->m_left) { - dgAssert (!me->m_right); - - dgEdge* ptr = me->m_face; - do { - dgInt32 index = ptr->m_incidentVertex; - const dgBigVector& q0 = points[index]; - dgBigVector q0p0 (q0 - p0); - dgFloat64 alpha = q0p0 % p1p0; - if ((alpha > (DG_BOOLEAN_ZERO_TOLERANCE * den)) && (alpha < (den - DG_BOOLEAN_ZERO_TOLERANCE))) { - dgBigVector dist (p0 + p1p0.Scale (alpha / den) - q0); - dgFloat64 dist2 = dist % dist; - if (dist2 < (DG_BOOLEAN_ZERO_TOLERANCE * DG_BOOLEAN_ZERO_TOLERANCE)) { - return alpha / den; - } - } - - ptr = ptr->m_next; - } while (ptr != me->m_face); - } else { - dgAssert (me->m_left); - dgAssert (me->m_right); - stackPool[stack] = me->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgMeshBVHNode*))); - - stackPool[stack] = me->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgMeshBVHNode*))); - } - } - } - return 1.2f; -} - - -bool dgMeshEffect::dgMeshBVH::RayRayIntersect (dgEdge* const edge, const dgMeshEffect* const otherMesh, dgEdge* const otherEdge, dgFloat64& param, dgFloat64& otherParam) const -{ - dgAssert (0); - - dgBigVector ray_p0 (m_mesh->m_points[edge->m_incidentVertex]); - dgBigVector ray_p1 (m_mesh->m_points[edge->m_twin->m_incidentVertex]); - - dgBigVector ray_q0 (otherMesh->m_points[otherEdge->m_incidentVertex]); - dgBigVector ray_q1 (otherMesh->m_points[otherEdge->m_twin->m_incidentVertex]); - - dgBigVector p1p0 (ray_p1 - ray_p0); - dgBigVector q1q0 (ray_q1 - ray_q0); - dgBigVector p0q0 (ray_p0 - ray_q0); - - dgFloat64 a = p1p0 % p1p0; // always >= 0 - dgFloat64 c = q1q0 % q1q0; // always >= 0 - dgFloat64 b = p1p0 % q1q0; - - dgFloat64 d = (p1p0 % p0q0); - dgFloat64 e = (q1q0 % p0q0); - dgFloat64 den = a * c - b * b; // always >= 0 - // compute the line parameters of the two closest points - if (den < DG_BOOLEAN_ZERO_TOLERANCE) { - // the lines are almost parallel - return false; - } else { - // get the closest points on the infinite lines - dgFloat64 t = b * e - c * d; - dgFloat64 s = a * e - b * d; - - if (t < (DG_BOOLEAN_ZERO_TOLERANCE * den) || (s < (DG_BOOLEAN_ZERO_TOLERANCE * den)) || (t > (den - DG_BOOLEAN_ZERO_TOLERANCE)) || (s > (den - DG_BOOLEAN_ZERO_TOLERANCE))) { - return false; - } - //dgBigVector normal (p1p0 * q1q0); - dgBigVector r0 (ray_p0 + p1p0.Scale (t / den)); - dgBigVector r1 (ray_q0 + q1q0.Scale (s / den)); - dgBigVector r1r0 (r1 - r0); - dgFloat64 dist2 = r1r0 % r1r0; - if (dist2 > (DG_BOOLEAN_ZERO_TOLERANCE * DG_BOOLEAN_ZERO_TOLERANCE)) { - return false; - } - - param = t / den; - otherParam = s / den; - } - return true; -} -*/ - - -dgFloat64 dgMeshEffect::dgMeshBVH::RayFaceIntersect (const dgMeshBVHNode* const faceNode, const dgBigVector& p0, const dgBigVector& p1, void* const userData) const -{ - dgAssert (0); - return 0; -/* - dgBigVector normal (m_mesh->FaceNormal(faceNode->m_face, m_mesh->GetVertexPool(), sizeof(dgBigVector))); - - dgBigVector diff (p1 - p0); - - dgFloat64 tOut = 2.0f; - const dgBigVector* const points = (dgBigVector*) m_mesh->GetVertexPool(); - dgFloat64 dir = normal.DotProduct3(diff); - if (dir < 0.0f) { - dgEdge* ptr = faceNode->m_face; - do { - dgInt32 index0 = ptr->m_incidentVertex; - dgInt32 index1 = ptr->m_next->m_incidentVertex; - dgBigVector p0v0 (points[index0] - p0); - dgBigVector p0v1 (points[index1] - p0); - dgFloat64 alpha = p0v0.DotProduct3(diff.CrossProduct(p0v1)); - if (alpha <= 0.0f) { - return 1.2f; - } - - ptr = ptr->m_next; - } while (ptr != faceNode->m_face); - - dgInt32 index0 = ptr->m_incidentVertex; - dgBigVector p0v0 (points[index0] - p0); - tOut = normal.DotProduct3(p0v0); - dgFloat64 dist = normal.DotProduct3(diff); - tOut = tOut / dist; - - } else if (doubleSidedFaces && (dir > 0.0f)) { - dgEdge* ptr = faceNode->m_face; - do { - dgInt32 index0 = ptr->m_incidentVertex; - dgInt32 index1 = ptr->m_prev->m_incidentVertex; - dgBigVector p0v0 (points[index0] - p0); - dgBigVector p0v1 (points[index1] - p0); - dgFloat64 alpha = p0v0.DotProduct3(diff.CrossProduct(p0v1)); - if (alpha <= 0.0f) { - return 1.2f; - } - - ptr = ptr->m_prev; - } while (ptr != faceNode->m_face); - - dgInt32 index0 = ptr->m_incidentVertex; - dgBigVector p0v0 (points[index0] - p0); - tOut = normal.DotProduct3(p0v0); - dgFloat64 dist = normal.DotProduct3(diff); - tOut = tOut / dist; - } - - if (tOut < 1.e-12f) { - tOut = 2.0f; - } else if (tOut > (1.0 - 1.e-12f)) { - tOut = 2.0f; - } - return tOut; -*/ -} - - -void dgMeshEffect::dgMeshBVH::FaceRayCast (const dgBigVector& p0, const dgBigVector& p1, void* const userData) const -{ - dgMeshBVHNode* stackPool[DG_MESH_EFFECT_BVH_STACK_DEPTH]; - - dgInt32 stack = 1; - dgMeshBVHNode* node = NULL; - - stackPool[0] = m_rootNode; - dgFloat64 maxParam = dgFloat32 (1.2f); - - dgVector l0(p0); - dgVector l1(p1); - l0 = l0 & dgVector::m_triplexMask; - l1 = l1 & dgVector::m_triplexMask; - dgFastRayTest ray (l0, l1); - while (stack) { - stack --; - dgMeshBVHNode* const me = stackPool[stack]; - if (me && ray.BoxTest (me->m_p0, me->m_p1)) { - if (!me->m_left) { - dgAssert (!me->m_right); - dgFloat64 param = RayFaceIntersect (me, p0, p1, userData); - if (param < dgFloat64 (0.0f)) { - break; - } - if (param < maxParam) { - node = me; - maxParam = param; - } - } else { - dgAssert (me->m_left); - dgAssert (me->m_right); - stackPool[stack] = me->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgMeshBVHNode*))); - - stackPool[stack] = me->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgMeshBVHNode*))); - } - } - } -} - - -dgMeshEffect::dgMeshEffect () - :dgPolyhedra(NULL) - ,m_points(NULL) - ,m_attrib(NULL) - ,m_vertexBaseCount(-1) - ,m_constructionIndex(0) -{ - Init(); -} - -dgMeshEffect::dgMeshEffect(dgMemoryAllocator* const allocator) - :dgPolyhedra(allocator) - ,m_points(allocator) - ,m_attrib(allocator) - ,m_vertexBaseCount(-1) - ,m_constructionIndex(0) -{ - Init(); -} - -dgMeshEffect::dgMeshEffect (dgMemoryAllocator* const allocator, const dgMatrix& planeMatrix, dgFloat32 witdth, dgFloat32 breadth, dgInt32 material, const dgMatrix& textureMatrix0, const dgMatrix& textureMatrix1) - :dgPolyhedra(allocator) - ,m_points(allocator) - ,m_attrib(allocator) - ,m_vertexBaseCount(-1) - ,m_constructionIndex(0) -{ - dgAssert (0); - Init(); -/* - dgInt32 index[4]; - dgInt64 attrIndex[4]; - dgBigVector face[4]; - -// Init(); - - face[0] = dgBigVector (dgFloat32 (0.0f), -witdth, -breadth, dgFloat32 (0.0f)); - face[1] = dgBigVector (dgFloat32 (0.0f), witdth, -breadth, dgFloat32 (0.0f)); - face[2] = dgBigVector (dgFloat32 (0.0f), witdth, breadth, dgFloat32 (0.0f)); - face[3] = dgBigVector (dgFloat32 (0.0f), -witdth, breadth, dgFloat32 (0.0f)); - - for (dgInt32 i = 0; i < 4; i ++) { - dgBigVector uv0 (textureMatrix0.TransformVector(face[i])); - dgBigVector uv1 (textureMatrix1.TransformVector(face[i])); - - m_points[i] = planeMatrix.TransformVector(face[i]); - - m_attrib[i].m_vertex.m_x = m_points[i].m_x; - m_attrib[i].m_vertex.m_y = m_points[i].m_y; - m_attrib[i].m_vertex.m_z = m_points[i].m_z; - m_attrib[i].m_vertex.m_w = dgFloat64 (0.0f); - - m_attrib[i].m_normal_x = planeMatrix.m_front.m_x; - m_attrib[i].m_normal_y = planeMatrix.m_front.m_y; - m_attrib[i].m_normal_z = planeMatrix.m_front.m_z; - - m_attrib[i].m_u0 = uv0.m_y; - m_attrib[i].m_v0 = uv0.m_z; - - m_attrib[i].m_u1 = uv1.m_y; - m_attrib[i].m_v1 = uv1.m_z; - - m_attrib[i].m_material = material; - - index[i] = i; - attrIndex[i] = i; - } - - m_pointCount = 4; - m_atribCount = 4; - BeginFace(); - AddFace (4, index, attrIndex); - EndFace(); -*/ -} - - -dgMeshEffect::dgMeshEffect(dgPolyhedra& mesh, const dgMeshEffect& source) - :dgPolyhedra (mesh) - ,m_points(source.m_points) - ,m_attrib(source.m_attrib) - ,m_vertexBaseCount(-1) - ,m_constructionIndex(0) -{ - Init(); -} - -dgMeshEffect::dgMeshEffect(const dgMeshEffect& source) - :dgPolyhedra (source) - ,m_points(source.m_points) - ,m_attrib(source.m_attrib) - ,m_vertexBaseCount(-1) - ,m_constructionIndex(0) -{ - Init(); -} - -dgMeshEffect::dgMeshEffect(dgCollisionInstance* const collision) - :dgPolyhedra (collision->GetAllocator()) - ,m_points(collision->GetAllocator()) - ,m_attrib(collision->GetAllocator()) - ,m_vertexBaseCount(-1) - ,m_constructionIndex(0) -{ - class dgMeshEffectBuilder - { - public: - dgMeshEffectBuilder (dgMemoryAllocator* const allocator) - :m_vertex(allocator) - ,m_faceIndexCount(allocator) - ,m_brush(0) - ,m_faceCount(0) - ,m_vertexCount(0) - { - } - - static void GetShapeFromCollision (void* userData, dgInt32 vertexCount, const dgFloat32* faceVertex, dgInt32 id) - { - dgInt32 vertexIndex; - dgMeshEffectBuilder& builder = *((dgMeshEffectBuilder*)userData); - - builder.m_faceIndexCount[builder.m_faceCount] = vertexCount; - builder.m_faceCount = builder.m_faceCount + 1; - - vertexIndex = builder.m_vertexCount; - dgFloat64 brush = dgFloat64 (builder.m_brush); - for (dgInt32 i = 0; i < vertexCount; i ++) { - builder.m_vertex[vertexIndex] = dgBigVector (faceVertex[i * 3 + 0], faceVertex[i * 3 + 1], faceVertex[i * 3 + 2], brush); - vertexIndex ++; - } - - builder.m_vertexCount = vertexIndex; - } - - dgArray<dgBigVector> m_vertex; - dgArray<dgInt32> m_faceIndexCount; - dgInt32 m_brush; - dgInt32 m_faceCount; - dgInt32 m_vertexCount; - }; - dgMeshEffectBuilder builder(GetAllocator()); - - Init(); - if (collision->IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionInfo collisionInfo; - collision->GetCollisionInfo (&collisionInfo); - - dgInt32 brush = 0; - dgMatrix matrix (collisionInfo.m_offsetMatrix); - dgCollisionCompound* const compoundCollision = (dgCollisionCompound*) collision->GetChildShape(); - for (dgTree<dgCollisionCompound::dgNodeBase*, dgInt32>::dgTreeNode* node = compoundCollision->GetFirstNode(); node; node = compoundCollision->GetNextNode(node)) { - builder.m_brush = brush; - brush ++; - dgCollisionInstance* const childShape = compoundCollision->GetCollisionFromNode(node); - childShape->DebugCollision (matrix, (dgCollision::OnDebugCollisionMeshCallback) dgMeshEffectBuilder::GetShapeFromCollision, &builder); - } - - } else { - dgMatrix matrix (dgGetIdentityMatrix()); - collision->DebugCollision (matrix, (dgCollision::OnDebugCollisionMeshCallback) dgMeshEffectBuilder::GetShapeFromCollision, &builder); - } - - dgStack<dgInt32>indexListBuffer (builder.m_vertexCount); - dgInt32* const indexList = &indexListBuffer[0]; - dgVertexListToIndexList (&builder.m_vertex[0].m_x, sizeof (dgBigVector), 4, builder.m_vertexCount, &indexList[0], DG_VERTEXLIST_INDEXLIST_TOL); - - dgMeshVertexFormat vertexFormat; - - vertexFormat.m_faceCount = builder.m_faceCount; - vertexFormat.m_faceIndexCount = &builder.m_faceIndexCount[0]; -// vertexFormat.m_faceMaterial = materialIndex; - - vertexFormat.m_vertex.m_data = &builder.m_vertex[0].m_x; - vertexFormat.m_vertex.m_strideInBytes = sizeof (dgBigVector); - vertexFormat.m_vertex.m_indexList = &indexList[0]; - - BuildFromIndexList (&vertexFormat); - - RepairTJoints(); - CalculateNormals(dgFloat32 (45.0f * dgDegreeToRad)); -} - -// create a convex hull -dgMeshEffect::dgMeshEffect(dgMemoryAllocator* const allocator, const dgFloat64* const vertexCloud, dgInt32 count, dgInt32 strideInByte, dgFloat64 distTol) - :dgPolyhedra(allocator) - ,m_points(allocator) - ,m_attrib(allocator) -{ - Init(); - if (count >= 4) { - dgConvexHull3d convexHull(allocator, vertexCloud, strideInByte, count, distTol); - if (convexHull.GetCount()) { - dgStack<dgInt32> faceCountPool(convexHull.GetCount()); - dgStack<dgInt32> vertexIndexListPool(convexHull.GetCount() * 3); - - dgInt32 index = 0; - dgMeshVertexFormat format; - format.m_faceCount = convexHull.GetCount(); - format.m_faceIndexCount = &faceCountPool[0]; - format.m_vertex.m_indexList = &vertexIndexListPool[0]; - format.m_vertex.m_data = &convexHull.GetVertexPool()[0].m_x; - format.m_vertex.m_strideInBytes = sizeof (dgBigVector); - for (dgConvexHull3d::dgListNode* faceNode = convexHull.GetFirst(); faceNode; faceNode = faceNode->GetNext()) { - dgConvexHull3DFace& face = faceNode->GetInfo(); - faceCountPool[index] = 3; - vertexIndexListPool[index * 3 + 0] = face.m_index[0]; - vertexIndexListPool[index * 3 + 1] = face.m_index[1]; - vertexIndexListPool[index * 3 + 2] = face.m_index[2]; - index++; - } - BuildFromIndexList(&format); - RepairTJoints(); - } - } -} - - -dgMeshEffect::dgMeshEffect (dgMemoryAllocator* const allocator, dgDeserialize deserialization, void* const userData) - :dgPolyhedra (allocator) - ,m_points(allocator) - ,m_attrib(allocator) - ,m_vertexBaseCount(-1) - ,m_constructionIndex(0) -{ - Init(); -dgAssert (0); -/* - dgInt32 faceCount; - deserialization (userData, &faceCount, sizeof (dgInt32)); - deserialization (userData, &m_pointCount, sizeof (dgInt32)); - deserialization (userData, &m_atribCount, sizeof (dgInt32)); - deserialization (userData, &m_atribCount, sizeof (dgInt32)); - - m_maxPointCount = m_pointCount; - m_maxAtribCount = m_atribCount; - - m_points = (dgBigVector*) GetAllocator()->MallocLow(dgInt32 (m_pointCount * sizeof(dgBigVector))); - m_attrib = (dgVertexAtribute*) GetAllocator()->MallocLow(dgInt32 (m_atribCount * sizeof(dgVertexAtribute))); - - deserialization (userData, m_points, m_pointCount * sizeof (dgBigVector)); - deserialization (userData, m_attrib, m_atribCount * sizeof (dgVertexAtribute)); - - BeginFace(); - for (dgInt32 i = 0; i < faceCount; i ++) { - dgInt32 vertexCount; - dgInt32 face[1024]; - dgInt64 attrib[1024]; - deserialization (userData, &vertexCount, sizeof (dgInt32)); - deserialization (userData, face, vertexCount * sizeof (dgInt32)); - deserialization (userData, attrib, vertexCount * sizeof (dgInt64)); - AddFace (vertexCount, face, attrib); - } - EndFace(); -*/ -} - - -dgMeshEffect::~dgMeshEffect(void) -{ -} - -void dgMeshEffect::Init() -{ -// dgAssert (); -} - -void dgMeshEffect::BeginFace() -{ - dgPolyhedra::BeginFace(); -} - -bool dgMeshEffect::EndFace () -{ - dgPolyhedra::EndFace(); - bool state = false; - for (bool hasVertexCollision = true; hasVertexCollision;) { - hasVertexCollision = false; - const dgInt32 currentCount = m_points.m_vertex.m_count; - dgStack<dgInt8> verterCollisionBuffer (currentCount); - dgInt8* const verterCollision = &verterCollisionBuffer[0]; - memset (&verterCollision[0], 0, verterCollisionBuffer.GetSizeInBytes()); - - Iterator iter (*this); - dgInt32 mark = IncLRU(); - dgList<dgTreeNode*> collisionFound(GetAllocator()); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if (edge->m_mark != mark) { - if ((edge->m_incidentVertex < currentCount) && (verterCollision[edge->m_incidentVertex] == 0)) { - verterCollision[edge->m_incidentVertex] = 1; - } else { - hasVertexCollision = true; - collisionFound.Append(iter.GetNode()); - } - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - } - } - - dgAssert (!collisionFound.GetFirst() || Sanity()); - for (dgList<dgTreeNode*>::dgListNode* node = collisionFound.GetFirst(); node; node = node->GetNext()) { - state = true; - dgEdge* const edge = &node->GetInfo()->GetInfo(); - - // this is a vertex collision - m_points.m_vertex.PushBack (m_points.m_vertex[edge->m_incidentVertex]); - if (m_points.m_layers.m_count) { - m_points.m_layers.PushBack (m_points.m_layers[edge->m_incidentVertex]); - } - - dgEdge* ptr = edge; - do { - if (ptr->m_incidentFace > 0) { - //m_attrib.m_pointChannel[dgInt32 (ptr->m_userData)] = m_points.m_vertex.m_count - 1; - dgInt32 index = dgInt32 (ptr->m_userData); - m_attrib.m_pointChannel.PushBack(m_points.m_vertex.m_count - 1); - if (m_attrib.m_materialChannel.m_count) { - m_attrib.m_materialChannel.PushBack(m_attrib.m_materialChannel[index]); - } - if (m_attrib.m_normalChannel.m_count) { - m_attrib.m_normalChannel.PushBack(m_attrib.m_normalChannel[index]); - } - if (m_attrib.m_binormalChannel.m_count) { - m_attrib.m_binormalChannel.PushBack(m_attrib.m_binormalChannel[index]); - } - if (m_attrib.m_colorChannel.m_count) { - m_attrib.m_colorChannel.PushBack(m_attrib.m_colorChannel[index]); - } - if (m_attrib.m_uv0Channel.m_count) { - m_attrib.m_uv0Channel.PushBack(m_attrib.m_uv0Channel[index]); - } - if (m_attrib.m_uv1Channel.m_count) { - m_attrib.m_uv1Channel.PushBack(m_attrib.m_uv1Channel[index]); - } - ptr->m_userData = m_attrib.m_pointChannel.m_count - 1; - } - - dgTreeNode* const edgeNode = GetNodeFromInfo (*ptr); - dgPairKey edgeKey (ptr->m_incidentVertex, ptr->m_twin->m_incidentVertex); - ReplaceKey (edgeNode, edgeKey.GetVal()); - - dgTreeNode* const twinNode = GetNodeFromInfo (*(ptr->m_twin)); - dgPairKey twinKey (ptr->m_twin->m_incidentVertex, ptr->m_incidentVertex); - ReplaceKey (twinNode, twinKey.GetVal()); - - ptr->m_incidentVertex = m_points.m_vertex.m_count - 1; - - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - } - dgAssert (!collisionFound.GetFirst() || Sanity()); - } - - return !state; -} - - -void dgMeshEffect::Trace () const -{ -dgAssert (0); -/* - for (dgInt32 i = 0; i < m_pointCount; i ++ ) { - dgTrace (("%d-> %f %f %f\n", i, m_points[i].m_x, m_points[i].m_y, m_points[i].m_z)); - } - - - dgTree<dgEdge*, dgEdge*>filter(GetAllocator()); - Iterator iter (*this); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if (!filter.Find(edge)) { - dgEdge* ptr = edge; - do { - filter.Insert(edge, ptr); - dgTrace (("%d ", ptr->m_incidentVertex)); - ptr = ptr->m_next; - } while (ptr != edge); - if (edge->m_incidentFace <= 0) { - dgTrace (("open")); - } - dgTrace (("\n")); - } - } - dgTrace (("\n")); -*/ -}; - -void dgMeshEffect::FlipWinding() -{ - dgInt32 index[DG_MESH_EFFECT_POINT_SPLITED]; - dgInt64 userData[DG_MESH_EFFECT_POINT_SPLITED]; - - dgPolyhedra polyhedra(*this); - RemoveAll(); - - dgPolyhedra::BeginFace(); - dgInt32 mark = polyhedra.IncLRU(); - dgPolyhedra::Iterator iter(polyhedra); - for (iter.Begin(); iter; iter++) { - dgEdge* const face = &iter.GetNode()->GetInfo(); - if ((face->m_mark != mark) && (face->m_incidentFace > 0)) { - - dgEdge* ptr = face; - dgInt32 indexCount = 0; - do { - index[indexCount] = ptr->m_incidentVertex; - userData[indexCount] = ptr->m_userData; - ptr->m_mark = mark; - indexCount++; - ptr = ptr->m_prev; - } while (ptr != face); - AddFace(indexCount, index, userData); - } - } - dgPolyhedra::EndFace(); -} - - -void dgMeshEffect::Triangulate () -{ -/* - dgInt32 index[DG_MESH_EFFECT_POINT_SPLITED]; - dgInt64 userData[DG_MESH_EFFECT_POINT_SPLITED]; - dgPolyhedra polygon(GetAllocator()); - polygon.BeginFace(); - dgInt32 mark = IncLRU(); - dgPolyhedra::Iterator iter1 (*this); - for (iter1.Begin(); iter1; iter1 ++) { - dgEdge* const face = &iter1.GetNode()->GetInfo(); - if ((face->m_mark != mark) && (face->m_incidentFace > 0)) { - dgEdge* ptr = face; - dgInt32 indexCount = 0; - do { - index[indexCount] = dgInt32 (ptr->m_userData); - userData[indexCount] = ptr->m_incidentVertex; - ptr->m_mark = mark; - indexCount ++; - ptr = ptr->m_next; - } while (ptr != face); - polygon.AddFace(indexCount, index, userData); - } - } - polygon.EndFace(); - - dgPolyhedra leftOversOut(GetAllocator()); - polygon.Triangulate(&m_points.m_vertex[0].m_x, sizeof (dgBigVector), &leftOversOut); - dgAssert (leftOversOut.GetCount() == 0); - - SetLRU (0); - RemoveAll(); - BeginFace(); - mark = polygon.IncLRU(); - dgPolyhedra::Iterator iter (polygon); - for (iter.Begin(); iter; iter ++){ - dgEdge* const face = &iter.GetNode()->GetInfo(); - if ((face->m_mark != mark) && (face->m_incidentFace > 0)) { - dgEdge* ptr = face; - dgInt32 indexCount = 0; - do { - ptr->m_mark = mark; - index[indexCount] = dgInt32 (ptr->m_userData); - userData[indexCount] = ptr->m_incidentVertex; - indexCount ++; - ptr = ptr->m_next; - } while (ptr != face); - AddFace(indexCount, index, userData); - } - } - EndFace(); -*/ - UnpackPoints(); - dgPolyhedra leftOversOut(GetAllocator()); - dgPolyhedra::Triangulate(&m_points.m_vertex[0].m_x, sizeof (dgBigVector), &leftOversOut); - dgAssert(leftOversOut.GetCount() == 0); - - dgPolyhedra::Iterator iter(*this); - for (iter.Begin(); iter; iter++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - edge->m_userData = (edge->m_incidentFace) > 0 ? edge->m_incidentVertex : 0; - } - PackPoints(dgFloat32(1.0e-24f)); - - RepairTJoints (); - dgAssert (Sanity ()); -} - -void dgMeshEffect::ConvertToPolygons () -{ - UnpackPoints(); - dgPolyhedra leftOversOut(GetAllocator()); - dgPolyhedra::ConvexPartition(&m_points.m_vertex[0].m_x, sizeof (dgBigVector), &leftOversOut); - dgAssert(leftOversOut.GetCount() == 0); - - dgPolyhedra::Iterator iter(*this); - for (iter.Begin(); iter; iter++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - edge->m_userData = (edge->m_incidentFace) > 0 ? edge->m_incidentVertex : 0; - } - PackPoints(dgFloat32 (1.0e-24f)); - - RepairTJoints (); - dgAssert (Sanity ()); -} - -void dgMeshEffect::RemoveUnusedVertices(dgInt32* const vertexMapResult) -{ - dgAssert (!vertexMapResult); - UnpackAttibuteData(); - PackAttibuteData(); - UnpackPoints(); - PackPoints(dgFloat32 (1.0e-24f)); -} - - -void dgMeshEffect::ApplyTransform (const dgMatrix& matrix) -{ - matrix.TransformTriplex(&m_points.m_vertex[0].m_x, sizeof (dgBigVector), &m_points.m_vertex[0].m_x, sizeof (dgBigVector), m_points.m_vertex.m_count); - - dgMatrix invMatix(matrix.Inverse4x4()); - invMatix.m_posit = dgVector::m_wOne; - dgMatrix rotation (invMatix.Transpose4X4()); - for (dgInt32 i = 0; i < m_attrib.m_normalChannel.m_count; i ++) { - dgVector n (dgFloat32 (m_attrib.m_normalChannel[i].m_x), dgFloat32 (m_attrib.m_normalChannel[i].m_y), dgFloat32 (m_attrib.m_normalChannel[i].m_z), dgFloat32 (0.0f)); - n = rotation.RotateVector(n); - dgAssert(n.m_w == dgFloat32(0.0f)); - dgAssert (n.DotProduct(n).GetScalar() > dgFloat32 (0.0f)); - n = n.Normalize(); - m_attrib.m_normalChannel[i].m_x = n.m_x; - m_attrib.m_normalChannel[i].m_y = n.m_y; - m_attrib.m_normalChannel[i].m_z = n.m_z; - } - - for (dgInt32 i = 0; i < m_attrib.m_binormalChannel.m_count; i++) { - dgVector n(dgFloat32(m_attrib.m_binormalChannel[i].m_x), dgFloat32(m_attrib.m_binormalChannel[i].m_y), dgFloat32(m_attrib.m_binormalChannel[i].m_z), dgFloat32(0.0f)); - n = rotation.RotateVector(n); - dgAssert(n.m_w == dgFloat32(0.0f)); - dgAssert(n.DotProduct(n).GetScalar() > dgFloat32(0.0f)); - n = n.Normalize(); - m_attrib.m_binormalChannel[i].m_x = n.m_x; - m_attrib.m_binormalChannel[i].m_y = n.m_y; - m_attrib.m_binormalChannel[i].m_z = n.m_z; - } -} - -dgMatrix dgMeshEffect::CalculateOOBB (dgBigVector& size) const -{ - dgObb sphere (CalculateSphere (&m_points.m_vertex[0].m_x, sizeof (dgBigVector), NULL)); - size = sphere.m_size; - size.m_w = 0.0f; - -// dgMatrix permuation (dgGetIdentityMatrix()); -// permuation[0][0] = dgFloat32 (0.0f); -// permuation[0][1] = dgFloat32 (1.0f); -// permuation[1][1] = dgFloat32 (0.0f); -// permuation[1][2] = dgFloat32 (1.0f); -// permuation[2][2] = dgFloat32 (0.0f); -// permuation[2][0] = dgFloat32 (1.0f); -// while ((size.m_x < size.m_y) || (size.m_x < size.m_z)) { -// sphere = permuation * sphere; -// size = permuation.UnrotateVector(size); -// } - - return sphere; -} - -void dgMeshEffect::CalculateAABB (dgBigVector& minBox, dgBigVector& maxBox) const -{ - dgBigVector minP ( dgFloat64 (1.0e15f), dgFloat64 (1.0e15f), dgFloat64 (1.0e15f), dgFloat64 (0.0f)); - dgBigVector maxP (-dgFloat64 (1.0e15f), -dgFloat64 (1.0e15f), -dgFloat64 (1.0e15f), dgFloat64 (0.0f)); - - dgPolyhedra::Iterator iter (*this); - const dgBigVector* const points = &m_points.m_vertex[0]; - for (iter.Begin(); iter; iter ++){ - dgEdge* const edge = &(*iter); - const dgBigVector& p (points[edge->m_incidentVertex]); - - minP.m_x = dgMin (p.m_x, minP.m_x); - minP.m_y = dgMin (p.m_y, minP.m_y); - minP.m_z = dgMin (p.m_z, minP.m_z); - - maxP.m_x = dgMax (p.m_x, maxP.m_x); - maxP.m_y = dgMax (p.m_y, maxP.m_y); - maxP.m_z = dgMax (p.m_z, maxP.m_z); - } - - minBox = minP; - maxBox = maxP; -} - - -void dgMeshEffect::BeginBuild () -{ - m_points.Clear(); - m_attrib.Clear(); - RemoveAll(); - BeginFace(); - m_vertexBaseCount = -1; - m_constructionIndex = 0; -} - - -void dgMeshEffect::BeginBuildFace () -{ - m_constructionIndex = m_points.m_vertex.m_count; -} - -void dgMeshEffect::AddPoint (dgFloat64 x, dgFloat64 y, dgFloat64 z) -{ - m_attrib.m_pointChannel.PushBack(m_points.m_vertex.m_count); - m_points.m_vertex.PushBack(dgBigVector (QuantizeCordinade(x), QuantizeCordinade(y), QuantizeCordinade(z), dgFloat64(0.0f))); -} - -void dgMeshEffect::AddLayer(dgInt32 layer) -{ - m_points.m_layers.PushBack(layer); -} - -void dgMeshEffect::AddVertexColor(dgFloat32 x, dgFloat32 y, dgFloat32 z, dgFloat32 w) -{ - m_attrib.m_colorChannel.PushBack(dgVector (x, y, z, w)); -} - -void dgMeshEffect::AddNormal(dgFloat32 x, dgFloat32 y, dgFloat32 z) -{ - dgTriplex n; - n.m_x = x; - n.m_y = y; - n.m_z = z; - m_attrib.m_normalChannel.PushBack(n); -} - -void dgMeshEffect::AddBinormal(dgFloat32 x, dgFloat32 y, dgFloat32 z) -{ - dgTriplex n; - n.m_x = x; - n.m_y = y; - n.m_z = z; - m_attrib.m_binormalChannel.PushBack(n); -} - -void dgMeshEffect::AddUV0(dgFloat32 u, dgFloat32 v) -{ - dgAttibutFormat::dgUV uv; - uv.m_u = u; - uv.m_v = v; - m_attrib.m_uv0Channel.PushBack(uv); -} - -void dgMeshEffect::AddUV1(dgFloat32 u, dgFloat32 v) -{ - dgAttibutFormat::dgUV uv; - uv.m_u = u; - uv.m_v = v; - m_attrib.m_uv1Channel.PushBack(uv); -} - -void dgMeshEffect::AddMaterial (dgInt32 materialIndex) -{ - m_attrib.m_materialChannel.PushBack(materialIndex); -} - - -void dgMeshEffect::EndBuildFace () -{ - dgInt32 count = m_points.m_vertex.m_count - m_constructionIndex; - if (count > 3) { - dgInt32 indexList[256]; - - dgAssert(count < dgInt32(sizeof (indexList) / sizeof(indexList[0]))); - dgPolyhedra polygon(GetAllocator()); - - dgPointFormat points(GetAllocator()); - dgAttibutFormat attibutes(GetAllocator()); - for (dgInt32 i = 0; i < count; i++) { - indexList[i] = i; - - points.m_vertex.PushBack(m_points.m_vertex[m_constructionIndex + i]); - if (m_points.m_layers.m_count) { - points.m_layers.PushBack(m_points.m_layers[m_constructionIndex + i]); - } - - if (m_attrib.m_materialChannel.m_count) { - attibutes.m_materialChannel.PushBack(m_attrib.m_materialChannel[m_constructionIndex + i]); - } - - if (m_attrib.m_normalChannel.m_count) { - attibutes.m_normalChannel.PushBack(m_attrib.m_normalChannel[m_constructionIndex + i]); - } - - if (m_attrib.m_binormalChannel.m_count) { - attibutes.m_binormalChannel.PushBack(m_attrib.m_binormalChannel[m_constructionIndex + i]); - } - - if (m_attrib.m_binormalChannel.m_count) { - attibutes.m_colorChannel.PushBack(m_attrib.m_colorChannel[m_constructionIndex + i]); - } - - if (m_attrib.m_uv0Channel.m_count) { - attibutes.m_uv0Channel.PushBack(m_attrib.m_uv0Channel[m_constructionIndex + i]); - } - - if (attibutes.m_uv1Channel.m_count) { - attibutes.m_uv1Channel.PushBack(attibutes.m_uv1Channel[m_constructionIndex + i]); - } - } - - polygon.BeginFace(); - polygon.AddFace(count, indexList, NULL); - polygon.EndFace(); - polygon.Triangulate(&points.m_vertex[0].m_x, sizeof (dgBigVector), NULL); - - m_points.SetCount (m_constructionIndex); - m_attrib.SetCount (m_constructionIndex); - dgInt32 mark = polygon.IncLRU(); - dgPolyhedra::Iterator iter(polygon); - for (iter.Begin(); iter; iter++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if ((edge->m_incidentFace > 0) && (edge->m_mark < mark)) { - dgInt32 i0 = edge->m_incidentVertex; - dgInt32 i1 = edge->m_next->m_incidentVertex; - dgInt32 i2 = edge->m_next->m_next->m_incidentVertex; - edge->m_mark = mark; - edge->m_next->m_mark = mark; - edge->m_next->m_next->m_mark = mark; - - const dgBigVector& p0 = points.m_vertex[i0]; - const dgBigVector& p1 = points.m_vertex[i1]; - const dgBigVector& p2 = points.m_vertex[i2]; - - dgBigVector e1(p1 - p0); - dgBigVector e2(p2 - p0); - dgBigVector n(e1.CrossProduct(e2)); - - dgAssert (e1.m_w == dgFloat32 (0.0f)); - dgAssert (e2.m_w == dgFloat32 (0.0f)); - dgAssert (n.m_w == dgFloat32 (0.0f)); - - dgFloat64 mag3 = n.DotProduct(n).GetScalar(); - if (mag3 >= dgFloat64(DG_MESH_EFFECT_PRECISION_SCALE_INV * DG_MESH_EFFECT_PRECISION_SCALE_INV)) { - dgInt32 index[] = {i0, i1, i2}; - for (dgInt32 i = 0; i < 3; i ++) { - dgInt32 j = index[i]; - AddPoint(points.m_vertex[j].m_x, points.m_vertex[j].m_y, points.m_vertex[j].m_z); - if (points.m_layers.m_count) { - AddLayer(points.m_layers[j]); - } - - if (attibutes.m_materialChannel.m_count) { - AddMaterial(attibutes.m_materialChannel[j]); - } - - if (attibutes.m_normalChannel.m_count) { - AddNormal(attibutes.m_normalChannel[j].m_x, attibutes.m_normalChannel[j].m_y, attibutes.m_normalChannel[j].m_z); - } - - if (attibutes.m_binormalChannel.m_count) { - AddBinormal(attibutes.m_binormalChannel[j].m_x, attibutes.m_binormalChannel[j].m_y, attibutes.m_binormalChannel[j].m_z); - } - - if (attibutes.m_colorChannel.m_count) { - AddVertexColor(attibutes.m_colorChannel[j].m_x, attibutes.m_colorChannel[j].m_y, attibutes.m_colorChannel[j].m_z, attibutes.m_colorChannel[j].m_w); - } - - if (attibutes.m_uv0Channel.m_count) { - AddUV0(attibutes.m_uv0Channel[j].m_u, attibutes.m_uv0Channel[j].m_v); - } - - if (attibutes.m_uv1Channel.m_count) { - AddUV1(attibutes.m_uv1Channel[j].m_u, attibutes.m_uv1Channel[j].m_v); - } - } - } - } - } - - } else { - const dgBigVector& p0 = m_points.m_vertex[m_constructionIndex + 0]; - const dgBigVector& p1 = m_points.m_vertex[m_constructionIndex + 1]; - const dgBigVector& p2 = m_points.m_vertex[m_constructionIndex + 2]; - - dgBigVector e1(p1 - p0); - dgBigVector e2(p2 - p0); - dgBigVector n(e1.CrossProduct(e2)); - dgAssert(e1.m_w == dgFloat32(0.0f)); - dgAssert(e2.m_w == dgFloat32(0.0f)); - dgAssert(n.m_w == dgFloat32(0.0f)); - - dgFloat64 mag3 = n.DotProduct(n).GetScalar(); - if (mag3 < dgFloat64(DG_MESH_EFFECT_PRECISION_SCALE_INV * DG_MESH_EFFECT_PRECISION_SCALE_INV)) { - m_attrib.SetCount (m_constructionIndex); - m_points.SetCount (m_constructionIndex); - } - } -} - - -void dgMeshEffect::UnpackAttibuteData() -{ - dgAttibutFormat attibutes(m_attrib); - m_attrib.Clear(); - - Iterator iter(*this); - dgInt32 attributeCount = 0; - const dgInt32 lru = IncLRU(); - for (iter.Begin(); iter; iter++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if ((edge->m_incidentFace > 0) && (edge->m_mark != lru)) { - dgEdge* ptr = edge; - - ptr = edge; - do { - ptr->m_mark = lru; - m_attrib.m_pointChannel.PushBack(ptr->m_incidentVertex); - - if (attibutes.m_materialChannel.m_count) { - m_attrib.m_materialChannel.PushBack(attibutes.m_materialChannel[dgInt32(ptr->m_userData)]); - } - - if (attibutes.m_normalChannel.m_count) { - m_attrib.m_normalChannel.PushBack(attibutes.m_normalChannel[dgInt32(ptr->m_userData)]); - } - - if (attibutes.m_binormalChannel.m_count) { - m_attrib.m_binormalChannel.PushBack(attibutes.m_binormalChannel[dgInt32(ptr->m_userData)]); - } - - if (attibutes.m_colorChannel.m_count) { - m_attrib.m_colorChannel.PushBack(attibutes.m_colorChannel[dgInt32(ptr->m_userData)]); - } - - if (attibutes.m_uv0Channel.m_count) { - m_attrib.m_uv0Channel.PushBack(attibutes.m_uv0Channel[dgInt32(ptr->m_userData)]); - } - - if (attibutes.m_uv1Channel.m_count) { - m_attrib.m_uv1Channel.PushBack(attibutes.m_uv1Channel[dgInt32(ptr->m_userData)]); - } - - ptr->m_userData = attributeCount; - attributeCount++; - ptr = ptr->m_next; - } while (ptr != edge); - } - } - dgAssert(m_attrib.m_pointChannel.m_count == attributeCount); -} - -void dgMeshEffect::PackAttibuteData() -{ - dgStack<dgInt32>attrIndexBuffer(m_attrib.m_pointChannel.m_count); - dgInt32* const attrIndexMap = &attrIndexBuffer[0]; - m_attrib.CompressData(m_points, &attrIndexMap[0]); - - Iterator iter(*this); - for (iter.Begin(); iter; iter++) { - dgEdge* const edge = &(*iter); - if (edge->m_incidentFace > 0) { - edge->m_userData = attrIndexMap[edge->m_userData]; - } - } - - memset (attrIndexMap, -1, sizeof (dgInt32) * m_attrib.m_pointChannel.m_count); - dgAttibutFormat tmpFormat (m_attrib); - m_attrib.Clear(); - - dgInt32 remapIndex = 0; - for (iter.Begin(); iter; iter++) { - dgEdge* const edge = &(*iter); - if (edge->m_incidentFace > 0) { - dgInt32 index = dgInt32(edge->m_userData); - if (attrIndexMap[edge->m_userData] == -1) { - attrIndexMap[index] = remapIndex; - remapIndex ++; - - m_attrib.m_pointChannel.PushBack(tmpFormat.m_pointChannel[index]); - if (tmpFormat.m_materialChannel.m_count) { - m_attrib.m_materialChannel.PushBack(tmpFormat.m_materialChannel[index]); - } - if (tmpFormat.m_normalChannel.m_count) { - m_attrib.m_normalChannel.PushBack(tmpFormat.m_normalChannel[index]); - } - if (tmpFormat.m_binormalChannel.m_count) { - m_attrib.m_binormalChannel.PushBack(tmpFormat.m_binormalChannel[index]); - } - if (tmpFormat.m_uv0Channel.m_count) { - m_attrib.m_uv0Channel.PushBack(tmpFormat.m_uv0Channel[index]); - } - if (tmpFormat.m_uv1Channel.m_count) { - m_attrib.m_uv1Channel.PushBack(tmpFormat.m_uv1Channel[index]); - } - if (tmpFormat.m_colorChannel.m_count) { - m_attrib.m_colorChannel.PushBack(tmpFormat.m_colorChannel[index]); - } - } - edge->m_userData = attrIndexMap[index]; - } - } -} - -void dgMeshEffect::PackPoints (dgFloat64 tol) -{ - dgStack<dgInt32>vertexIndexMapBuffer(m_points.m_vertex.m_count); - dgInt32* const vertexIndexMap = &vertexIndexMapBuffer[0]; - m_points.CompressData(&vertexIndexMap[0]); - - dgInt32 index[DG_MESH_EFFECT_POINT_SPLITED]; - dgInt64 userData[DG_MESH_EFFECT_POINT_SPLITED]; - dgPolyhedra polygon(GetAllocator()); - SwapInfo(polygon); - dgAssert(GetCount() == 0); - - BeginFace(); - const dgInt32 mark = IncLRU(); - dgPolyhedra::Iterator iter(polygon); - for (iter.Begin(); iter; iter++) { - dgEdge* const edge = &(*iter); - if ((edge->m_mark != mark) && (edge->m_incidentFace > 0)) { - dgEdge* ptr = edge; - dgInt32 indexCount = 0; - do { - ptr->m_mark = mark; - index[indexCount] = vertexIndexMap[ptr->m_incidentVertex]; - m_attrib.m_pointChannel[dgInt32 (ptr->m_userData)] = vertexIndexMap[ptr->m_incidentVertex]; - userData[indexCount] = ptr->m_userData; - - indexCount++; - ptr = ptr->m_next; - } while (ptr != edge); - dgEdge* const face = AddFace(indexCount, index, userData); - if (!face) { - dgTrace (("skiping degeneraded face\n")); - //dgAssert (0); - } - } - } - EndFace(); -} - -void dgMeshEffect::UnpackPoints() -{ - do { - dgPointFormat points(m_points); - m_points.Clear(); - for (dgInt32 i = 0; i < m_attrib.m_pointChannel.m_count; i++) { - dgInt32 index = m_attrib.m_pointChannel[i]; - m_points.m_vertex.PushBack(points.m_vertex[index]); - if (points.m_layers.m_count) { - m_points.m_layers.PushBack(points.m_layers[index]); - } - - m_attrib.m_pointChannel[i] = i; - } - - dgInt32 index[DG_MESH_EFFECT_POINT_SPLITED]; - dgInt64 userData[DG_MESH_EFFECT_POINT_SPLITED]; - dgPolyhedra polygon(GetAllocator()); - SwapInfo (polygon); - dgAssert (GetCount() == 0); - BeginFace(); - const dgInt32 mark = IncLRU(); - dgPolyhedra::Iterator iter(polygon); - for (iter.Begin(); iter; iter++) { - dgEdge* const face = &(*iter); - if ((face->m_mark != mark) && (face->m_incidentFace > 0)) { - dgEdge* ptr = face; - dgInt32 indexCount = 0; - do { - ptr->m_mark = mark; - index[indexCount] = dgInt32(ptr->m_userData); - userData[indexCount] = ptr->m_userData; - indexCount++; - ptr = ptr->m_next; - } while (ptr != face); - AddFace(indexCount, index, userData); - } - } - } while (!EndFace()); - - dgAssert(m_points.m_vertex.m_count == m_attrib.m_pointChannel.m_count); -#ifdef _DEBUG - for (dgInt32 i = 0; i < m_attrib.m_pointChannel.m_count; i++) { - dgAssert(m_attrib.m_pointChannel[i] == i); - } -#endif - -} - - -void dgMeshEffect::EndBuild (dgFloat64 tol, bool fixTjoint) -{ -#ifdef _DEBUG - for (dgInt32 i = 0; i < m_points.m_vertex.m_count; i += 3) { - dgBigVector p0 (m_points.m_vertex[i + 0]); - dgBigVector p1 (m_points.m_vertex[i + 1]); - dgBigVector p2 (m_points.m_vertex[i + 2]); - dgBigVector e1 (p1 - p0); - dgBigVector e2 (p2 - p0); - dgBigVector n (e1.CrossProduct(e2)); - - dgAssert(e1.m_w == dgFloat32(0.0f)); - dgAssert(e2.m_w == dgFloat32(0.0f)); - dgAssert(n.m_w == dgFloat32(0.0f)); - dgFloat64 mag2 = n.DotProduct(n).GetScalar(); - dgAssert (mag2 > dgFloat32 (0.0f)); - } -#endif - - dgInt32 triangCount = m_points.m_vertex.m_count / 3; - const dgInt32* const indexList = &m_attrib.m_pointChannel[0]; - for (dgInt32 i = 0; i < triangCount; i ++) { - dgInt32 index[3]; - dgInt64 userdata[3]; - - index[0] = indexList[i * 3 + 0]; - index[1] = indexList[i * 3 + 1]; - index[2] = indexList[i * 3 + 2]; - - dgBigVector e1 (m_points.m_vertex[index[1]] - m_points.m_vertex[index[0]]); - dgBigVector e2 (m_points.m_vertex[index[2]] - m_points.m_vertex[index[0]]); - dgBigVector n (e1.CrossProduct(e2)); - - dgAssert(e1.m_w == dgFloat32(0.0f)); - dgAssert(e2.m_w == dgFloat32(0.0f)); - dgAssert(n.m_w == dgFloat32(0.0f)); - dgFloat64 mag2 = n.DotProduct(n).GetScalar(); - if (mag2 > dgFloat64 (1.0e-12f)) { - userdata[0] = i * 3 + 0; - userdata[1] = i * 3 + 1; - userdata[2] = i * 3 + 2; - dgEdge* const edge = AddFace (3, index, userdata); - if (!edge) { - dgAssert (0); -/* - //dgAssert ((m_pointCount + 3) <= m_maxPointCount); - m_points[m_pointCount + 0] = m_points[index[0]]; - m_points[m_pointCount + 1] = m_points[index[1]]; - m_points[m_pointCount + 2] = m_points[index[2]]; - - index[0] = m_pointCount + 0; - index[1] = m_pointCount + 1; - index[2] = m_pointCount + 2; - - m_pointCount += 3; - - #ifdef _DEBUG - dgEdge* test = AddFace (3, index, userdata); - dgAssert (test); - #else - AddFace (3, index, userdata); - #endif -*/ - } - } - } - EndFace(); - - PackAttibuteData (); - PackPoints (tol); - - if (fixTjoint) { - RepairTJoints (); - } - -#ifdef _DEBUG - dgPolyhedra::Iterator iter (*this); - for (iter.Begin(); iter; iter ++){ - dgEdge* const face = &(*iter); - if (face->m_incidentFace > 0) { - dgBigVector p0 (m_points.m_vertex[face->m_incidentVertex]); - dgBigVector p1 (m_points.m_vertex[face->m_next->m_incidentVertex]); - dgBigVector p2 (m_points.m_vertex[face->m_next->m_next->m_incidentVertex]); - dgBigVector e1 (p1 - p0); - dgBigVector e2 (p2 - p0); - dgBigVector n (e1.CrossProduct(e2)); - - dgAssert(e1.m_w == dgFloat32(0.0f)); - dgAssert(e2.m_w == dgFloat32(0.0f)); - dgAssert(n.m_w == dgFloat32(0.0f)); - dgFloat64 mag2 = n.DotProduct(n).GetScalar(); - dgAssert (mag2 >= dgFloat32 (0.0f)); - } - } -#endif -} - - -void dgMeshEffect::OptimizePoints() -{ - -} - -void dgMeshEffect::OptimizeAttibutes() -{ - UnpackAttibuteData (); - PackAttibuteData(); -} - -void dgMeshEffect::BuildFromIndexList(const dgMeshVertexFormat* const format) -{ - BeginBuild(); - dgAssert (format->m_vertex.m_data); - dgAssert (format->m_vertex.m_indexList); - dgAssert (format->m_vertex.m_strideInBytes); - - // calculate vertex Count - dgInt32 vertexCount = 0; - dgInt32 maxAttribCount = 0; - for (dgInt32 j = 0; j < format->m_faceCount; j++) { - dgInt32 count = format->m_faceIndexCount[j]; - for (dgInt32 i = 0; i < count; i++) { - vertexCount = dgMax(vertexCount, format->m_vertex.m_indexList[maxAttribCount + i] + 1); - } - maxAttribCount += count; - } - m_vertexBaseCount = vertexCount; - - dgInt32 layerIndex = 0; - dgInt32 vertexStride = dgInt32(format->m_vertex.m_strideInBytes / sizeof (dgFloat64)); - const dgFloat64* const vertex = format->m_vertex.m_data; - for (dgInt32 i = 0; i < vertexCount; i++) { - dgInt32 index = i * vertexStride; - m_points.m_layers.PushBack(layerIndex); - dgBigVector p(vertex[index + 0], vertex[index + 1], vertex[index + 2], dgFloat64(0.0f)); - m_points.m_vertex.PushBack(p); - } - - bool pendingFaces = true; - dgInt32 layerBase = 0; - dgInt32 attributeCount = 0; - - dgInt32 normalStride = dgInt32(format->m_normal.m_strideInBytes / sizeof (dgFloat32)); - dgInt32 binormalStride = dgInt32(format->m_binormal.m_strideInBytes / sizeof (dgFloat32)); - dgInt32 uv0Stride = dgInt32(format->m_uv0.m_strideInBytes / sizeof (dgFloat32)); - dgInt32 uv1Stride = dgInt32(format->m_uv1.m_strideInBytes / sizeof (dgFloat32)); - dgInt32 vertexColorStride = dgInt32(format->m_vertexColor.m_strideInBytes / sizeof (dgFloat32)); - - dgStack<dgInt8> faceMark(format->m_faceCount); - memset(&faceMark[0], 0, faceMark.GetSizeInBytes()); - const dgInt32* const vertexIndex = format->m_vertex.m_indexList; - - while (pendingFaces) { - dgInt32 acc = 0; - pendingFaces = false; - dgInt32 vertexBank = layerIndex * vertexCount; - for (dgInt32 j = 0; j < format->m_faceCount; j++) { - dgInt32 indexCount = format->m_faceIndexCount[j]; - - if (indexCount > 0) { - dgInt32 index[256]; - dgInt64 userdata[256]; - dgAssert(indexCount >= 3); - dgAssert(indexCount < dgInt32(sizeof (index) / sizeof (index[0]))); - - if (!faceMark[j]) { - for (int i = 0; i < indexCount; i++) { - dgInt32 k = attributeCount + i; - userdata[i] = k; - index[i] = vertexIndex[acc + i] + vertexBank; - } - - - dgEdge* const edge = AddFace(indexCount, index, userdata); - if (edge) { - faceMark[j] = 1; - for (int i = 0; i < indexCount; i++) { - m_attrib.m_pointChannel.PushBack(index[i]); - } - - if (format->m_faceMaterial) { - dgInt32 materialIndex = format->m_faceMaterial[j]; - for (int i = 0; i < indexCount; i++) { - m_attrib.m_materialChannel.PushBack(materialIndex); - } - } - - if (format->m_normal.m_data) { - dgTriplex normal; - for (int i = 0; i < indexCount; i++) { - dgInt32 k = attributeCount + i; - dgInt32 m = format->m_normal.m_indexList[k] * normalStride; - normal.m_x = format->m_normal.m_data[m + 0]; - normal.m_y = format->m_normal.m_data[m + 1]; - normal.m_z = format->m_normal.m_data[m + 2]; - m_attrib.m_normalChannel.PushBack(normal); - } - } - - if (format->m_binormal.m_data) { - dgTriplex normal; - for (int i = 0; i < indexCount; i++) { - dgInt32 k = attributeCount + i; - dgInt32 m = format->m_binormal.m_indexList[k] * binormalStride; - normal.m_x = format->m_binormal.m_data[m + 0]; - normal.m_y = format->m_binormal.m_data[m + 1]; - normal.m_z = format->m_binormal.m_data[m + 2]; - m_attrib.m_binormalChannel.PushBack(normal); - } - } - - if (format->m_vertexColor.m_data) { - for (int i = 0; i < indexCount; i++) { - dgInt32 k = attributeCount + i; - dgInt32 m = format->m_vertexColor.m_indexList[k] * vertexColorStride; - dgVector color(format->m_vertexColor.m_data[m + 0], format->m_vertexColor.m_data[m + 1], format->m_vertexColor.m_data[m + 2], format->m_vertexColor.m_data[m + 3]); - m_attrib.m_colorChannel.PushBack(color); - } - } - - if (format->m_uv0.m_data) { - dgAttibutFormat::dgUV uv; - for (int i = 0; i < indexCount; i++) { - dgInt32 k = attributeCount + i; - dgInt32 m = format->m_uv0.m_indexList[k] * uv0Stride; - uv.m_u = format->m_uv0.m_data[m + 0]; - uv.m_v = format->m_uv0.m_data[m + 1]; - m_attrib.m_uv0Channel.PushBack(uv); - } - } - - if (format->m_uv1.m_data) { - dgAttibutFormat::dgUV uv; - for (int i = 0; i < indexCount; i++) { - dgInt32 k = attributeCount + i; - dgInt32 m = format->m_uv1.m_indexList[k] * uv1Stride; - uv.m_u = format->m_uv1.m_data[m + 0]; - uv.m_v = format->m_uv1.m_data[m + 1]; - m_attrib.m_uv1Channel.PushBack(uv); - } - } - attributeCount += indexCount; - - } else { - // check if the face is not degenerated - bool degeneratedFace = false; - for (int i = 0; i < indexCount - 1; i++) { - for (int k = i + 1; k < indexCount; k++) { - if (index[i] == index[k]) { - degeneratedFace = true; - } - } - } - if (degeneratedFace) { - faceMark[j] = 1; - } else { - pendingFaces = true; - } - } - } - acc += indexCount; - } - } - - if (pendingFaces) { - //dgAssert (0); - layerIndex++; - layerBase += vertexCount; - for (dgInt32 i = 0; i < vertexCount; i++) { - m_points.m_layers.PushBack(layerIndex); - dgInt32 index = i * vertexStride; - dgBigVector p (vertex[index + 0], vertex[index + 1], vertex[index + 2], vertex[index + 3]); - m_points.m_vertex.PushBack(p); - } - } - } - - dgAssert (m_points.m_vertex.m_count == vertexCount * (layerIndex + 1)); - dgAssert (m_attrib.m_pointChannel.m_count == attributeCount); - - EndFace(); - PackAttibuteData(); -} - -dgInt32 dgMeshEffect::GetTotalFaceCount() const -{ - return GetFaceCount(); -} - -dgInt32 dgMeshEffect::GetTotalIndexCount() const -{ - Iterator iter (*this); - dgInt32 count = 0; - dgInt32 mark = IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if (edge->m_mark == mark) { - continue; - } - - if (edge->m_incidentFace < 0) { - continue; - } - - dgEdge* ptr = edge; - do { - count ++; - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - } - return count; -} - -void dgMeshEffect::GetFaces (dgInt32* const facesIndex, dgInt32* const materials, void** const faceNodeList) const -{ - Iterator iter (*this); - - dgInt32 faces = 0; - dgInt32 indexCount = 0; - dgInt32 mark = IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if (edge->m_mark == mark) { - continue; - } - - if (edge->m_incidentFace < 0) { - continue; - } - - dgInt32 faceCount = 0; - dgEdge* ptr = edge; - do { -// indexList[indexCount] = dgInt32 (ptr->m_userData); - faceNodeList[indexCount] = GetNodeFromInfo (*ptr); - indexCount ++; - faceCount ++; - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - - facesIndex[faces] = faceCount; - //materials[faces] = dgFastInt(m_attrib[dgInt32 (edge->m_userData)].m_material); - materials[faces] = m_attrib.m_materialChannel.m_count ? m_attrib.m_materialChannel[dgInt32(edge->m_userData)] : 0; - faces ++; - } -} - -void* dgMeshEffect::GetFirstVertex () const -{ - Iterator iter (*this); - iter.Begin(); - - dgTreeNode* node = NULL; - if (iter) { - dgInt32 mark = IncLRU(); - node = iter.GetNode(); - - dgEdge* const edge = &node->GetInfo(); - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - } - return node; -} - -void* dgMeshEffect::GetNextVertex (const void* const vertex) const -{ - dgTreeNode* const node0 = (dgTreeNode*) vertex; - dgInt32 mark = node0->GetInfo().m_mark; - - Iterator iter (*this); - iter.Set (node0); - for (iter ++; iter; iter ++) { - dgTreeNode* node = iter.GetNode(); - if (node->GetInfo().m_mark != mark) { - dgEdge* const edge = &node->GetInfo(); - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - return node; - } - } - return NULL; -} - -dgInt32 dgMeshEffect::GetVertexIndex (const void* const vertex) const -{ - dgTreeNode* const node = (dgTreeNode*) vertex; - dgEdge* const edge = &node->GetInfo(); - return edge->m_incidentVertex; -} - -void* dgMeshEffect::GetFirstPoint () const -{ - Iterator iter (*this); - for (iter.Begin(); iter; iter ++) { - dgTreeNode* const node = iter.GetNode(); - dgEdge* const edge = &node->GetInfo(); - if (edge->m_incidentFace > 0) { - return node; - } - } - return NULL; -} - -void* dgMeshEffect::GetNextPoint (const void* const point) const -{ - Iterator iter (*this); - iter.Set ((dgTreeNode*) point); - for (iter ++; iter; iter ++) { - dgTreeNode* const node = iter.GetNode(); - dgEdge* const edge = &node->GetInfo(); - if (edge->m_incidentFace > 0) { - return node; - } - } - return NULL; -} - -dgInt32 dgMeshEffect::GetPointIndex (const void* const point) const -{ - dgTreeNode* const node = (dgTreeNode*) point; - dgEdge* const edge = &node->GetInfo(); - return int (edge->m_userData); -} - - -dgInt32 dgMeshEffect::GetVertexIndexFromPoint (const void* const point) const -{ - return GetVertexIndex (point); -} - -dgEdge* dgMeshEffect::SpliteFace (dgInt32 v0, dgInt32 v1) -{ - if (!FindEdge(v0, v1)) { - dgPolyhedra::dgPairKey key (v0, 0); - dgTreeNode* const node = FindGreaterEqual(key.GetVal()); - if (node) { - dgEdge* const edge = &node->GetInfo(); - dgEdge* edge0 = edge; - do { - if (edge0->m_incidentFace > 0) { - for (dgEdge* edge1 = edge0->m_next->m_next; edge1 != edge0->m_prev; edge1 = edge1->m_next) { - if (edge1->m_incidentVertex == v1) { - return ConnectVertex (edge0, edge1); - } - }; - } - edge0 = edge0->m_twin->m_next; - } while (edge0 != edge); - } - } - return NULL; -} - -const dgEdge* dgMeshEffect::GetPolyhedraEdgeFromNode(const void* const edge) const -{ - dgTreeNode* const node = (dgTreeNode*)edge; - return &node->GetInfo(); -} - -void* dgMeshEffect::GetFirstEdge () const -{ - Iterator iter (*this); - iter.Begin(); - - dgTreeNode* node = NULL; - if (iter) { - dgInt32 mark = IncLRU(); - - node = iter.GetNode(); - - dgEdge* const edge = &node->GetInfo(); - edge->m_mark = mark; - edge->m_twin->m_mark = mark; - } - return node; -} - -void* dgMeshEffect::GetNextEdge (const void* const edge) const -{ - dgTreeNode* const node0 = (dgTreeNode*) edge; - dgInt32 mark = node0->GetInfo().m_mark; - - Iterator iter (*this); - iter.Set (node0); - for (iter ++; iter; iter ++) { - dgTreeNode* const node = iter.GetNode(); - if (node->GetInfo().m_mark != mark) { - node->GetInfo().m_mark = mark; - node->GetInfo().m_twin->m_mark = mark; - return node; - } - } - return NULL; -} - - -void dgMeshEffect::GetEdgeIndex (const void* const edge, dgInt32& v0, dgInt32& v1) const -{ - dgTreeNode* const node = (dgTreeNode*) edge; - v0 = node->GetInfo().m_incidentVertex; - v1 = node->GetInfo().m_twin->m_incidentVertex; -} - -//void* dgMeshEffect::FindEdge (dgInt32 v0, dgInt32 v1) const -//{ -// return FindEdgeNode(v0, v1); -//} - -//void dgMeshEffect::GetEdgeAttributeIndex (const void* edge, dgInt32& v0, dgInt32& v1) const -//{ -// dgTreeNode* node = (dgTreeNode*) edge; -// v0 = int (node->GetInfo().m_userData); -// v1 = int (node->GetInfo().m_twin->m_userData); -//} - - -void* dgMeshEffect::GetFirstFace () const -{ - Iterator iter (*this); - iter.Begin(); - - dgTreeNode* node = NULL; - if (iter) { - dgInt32 mark = IncLRU(); - node = iter.GetNode(); - - dgEdge* const edge = &node->GetInfo(); - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - } - - return node; -} - -void* dgMeshEffect::GetNextFace (const void* const face) const -{ - dgTreeNode* const node0 = (dgTreeNode*) face; - dgInt32 mark = node0->GetInfo().m_mark; - - Iterator iter (*this); - iter.Set (node0); - for (iter ++; iter; iter ++) { - dgTreeNode* node = iter.GetNode(); - if (node->GetInfo().m_mark != mark) { - dgEdge* const edge = &node->GetInfo(); - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - return node; - } - } - return NULL; -} - - -dgInt32 dgMeshEffect::IsFaceOpen (const void* const face) const -{ - dgTreeNode* const node = (dgTreeNode*) face; - dgEdge* const edge = &node->GetInfo(); - return (edge->m_incidentFace > 0) ? 0 : 1; -} - -dgInt32 dgMeshEffect::GetFaceMaterial (const void* const face) const -{ - dgTreeNode* const node = (dgTreeNode*) face; - dgEdge* const edge = &node->GetInfo(); - return dgInt32 (m_attrib.m_materialChannel.m_count ? m_attrib.m_materialChannel[dgInt32 (edge->m_userData)] : 0); -} - -void dgMeshEffect::SetFaceMaterial (const void* const face, int mateialID) -{ - if (m_attrib.m_materialChannel.m_count) { - dgTreeNode* const node = (dgTreeNode*) face; - dgEdge* const edge = &node->GetInfo(); - if (edge->m_incidentFace > 0) { - dgEdge* ptr = edge; - do { - //dgVertexAtribute* const attrib = &m_attrib[ptr->m_userData]; - //attrib->m_material = dgFloat64 (mateialID); - m_attrib.m_materialChannel[dgInt32 (edge->m_userData)] = mateialID; - ptr = ptr->m_next; - } while (ptr != edge) ; - } - } -} - -dgInt32 dgMeshEffect::GetFaceIndexCount (const void* const face) const -{ - int count = 0; - dgTreeNode* node = (dgTreeNode*) face; - dgEdge* const edge = &node->GetInfo(); - dgEdge* ptr = edge; - do { - count ++; - ptr = ptr->m_next; - } while (ptr != edge); - return count; -} - -void dgMeshEffect::GetFaceIndex (const void* const face, dgInt32* const indices) const -{ - int count = 0; - dgTreeNode* node = (dgTreeNode*) face; - dgEdge* const edge = &node->GetInfo(); - dgEdge* ptr = edge; - do { - indices[count] = ptr->m_incidentVertex; - count ++; - ptr = ptr->m_next; - } while (ptr != edge); -} - -void dgMeshEffect::GetFaceAttributeIndex (const void* const face, dgInt32* const indices) const -{ - int count = 0; - dgTreeNode* node = (dgTreeNode*) face; - dgEdge* const edge = &node->GetInfo(); - dgEdge* ptr = edge; - do { - indices[count] = int (ptr->m_userData); - count ++; - ptr = ptr->m_next; - } while (ptr != edge); -} - - -dgBigVector dgMeshEffect::CalculateFaceNormal (const void* const face) const -{ - dgTreeNode* const node = (dgTreeNode*) face; - dgEdge* const faceEdge = &node->GetInfo(); - dgBigVector normal (FaceNormal (faceEdge, &m_points.m_vertex[0].m_x, sizeof (dgBigVector))); - dgAssert (normal.m_w == dgFloat32 (0.0f)); - //normal = normal.Scale (1.0f / sqrt (normal.DotProduct3(normal))); - normal = normal.Normalize(); - return normal; -} - -/* -dgInt32 GetTotalFaceCount() const; -{ - dgInt32 mark; - dgInt32 count; - dgInt32 materialCount; - dgInt32 materials[256]; - dgInt32 streamIndexMap[256]; - dgIndexArray* array; - - count = 0; - materialCount = 0; - - array = (dgIndexArray*) GetAllocator()->MallocLow (4 * sizeof (dgInt32) * GetCount() + sizeof (dgIndexArray) + 2048); - array->m_indexList = (dgInt32*)&array[1]; - - mark = IncLRU(); - dgPolyhedra::Iterator iter (*this); - memset(streamIndexMap, 0, sizeof (streamIndexMap)); - for(iter.Begin(); iter; iter ++){ - - dgEdge* const edge; - edge = &(*iter); - if ((edge->m_incidentFace >= 0) && (edge->m_mark != mark)) { - dgEdge* ptr; - dgInt32 hashValue; - dgInt32 index0; - dgInt32 index1; - - ptr = edge; - ptr->m_mark = mark; - index0 = dgInt32 (ptr->m_userData); - - ptr = ptr->m_next; - ptr->m_mark = mark; - index1 = dgInt32 (ptr->m_userData); - - ptr = ptr->m_next; - do { - ptr->m_mark = mark; - - array->m_indexList[count * 4 + 0] = index0; - array->m_indexList[count * 4 + 1] = index1; - array->m_indexList[count * 4 + 2] = dgInt32 (ptr->m_userData); - array->m_indexList[count * 4 + 3] = m_attrib[dgInt32 (edge->m_userData)].m_material; - index1 = dgInt32 (ptr->m_userData); - - hashValue = array->m_indexList[count * 4 + 3] & 0xff; - streamIndexMap[hashValue] ++; - materials[hashValue] = array->m_indexList[count * 4 + 3]; - count ++; - - ptr = ptr->m_next; - } while (ptr != edge); - } - } -} -*/ - -bool dgMeshEffect::HasNormalChannel() const -{ - return m_attrib.m_normalChannel.m_count != 0; -} - -bool dgMeshEffect::HasBinormalChannel() const -{ - return m_attrib.m_binormalChannel.m_count != 0; -} - -bool dgMeshEffect::HasUV0Channel() const -{ - return m_attrib.m_uv0Channel.m_count != 0; -} - -bool dgMeshEffect::HasUV1Channel() const -{ - return m_attrib.m_uv1Channel.m_count != 0; -} - -bool dgMeshEffect::HasVertexColorChannel() const -{ - return m_attrib.m_colorChannel.m_count != 0; -} - -void dgMeshEffect::GetVertexChannel64(dgInt32 strideInByte, dgFloat64* const bufferOut) const -{ - dgInt32 stride = strideInByte / sizeof (dgFloat64); - for (dgInt32 i = 0; i < m_attrib.m_pointChannel.m_count; i ++) { - const dgInt32 j = i * stride; - const dgInt32 index = m_attrib.m_pointChannel[i]; - bufferOut[j + 0] = m_points.m_vertex[index].m_x; - bufferOut[j + 1] = m_points.m_vertex[index].m_y; - bufferOut[j + 2] = m_points.m_vertex[index].m_z; - } -} - -void dgMeshEffect::GetVertexChannel(dgInt32 strideInByte, dgFloat32* const bufferOut) const -{ - dgInt32 stride = strideInByte / sizeof (dgFloat32); - for (dgInt32 i = 0; i < m_attrib.m_pointChannel.m_count; i++) { - const dgInt32 j = i * stride; - const dgInt32 index = m_attrib.m_pointChannel[i]; - const dgBigVector& p = m_points.m_vertex[index]; - bufferOut[j + 0] = dgFloat32(p.m_x); - bufferOut[j + 1] = dgFloat32(p.m_y); - bufferOut[j + 2] = dgFloat32(p.m_z); - } -} - -/* -void dgMeshEffect::GetWeightBlendChannel(dgInt32 strideInByte, dgFloat32* const bufferOut) const -{ - dgInt8* const buffer = (dgInt8*)bufferOut; - for (dgInt32 i = 0; i < m_attrib.m_pointChannel.m_count; i++) { - const dgInt32 j = i * strideInByte; - dgFloat32* const ptr = (dgFloat32*)&buffer[j]; - - const dgInt32 index = m_attrib.m_pointChannel[i]; - const dgFloat32* const p = &m_points.m_weights[index].m_weightBlends[0]; - ptr[0] = dgFloat32(p[0]); - ptr[1] = dgFloat32(p[1]); - ptr[2] = dgFloat32(p[2]); - ptr[3] = dgFloat32(p[3]); - } -} - -void dgMeshEffect::GetWeightIndexChannel(dgInt32 strideInByte, dgInt32* const bufferOut) const -{ - dgInt8* const buffer = (dgInt8*)bufferOut; - for (dgInt32 i = 0; i < m_attrib.m_pointChannel.m_count; i++) { - const dgInt32 j = i * strideInByte; - dgInt32* const ptr = (dgInt32*)&buffer[j]; - const dgInt32 index = m_attrib.m_pointChannel[i]; - const dgInt32* const p = &m_points.m_weights[index].m_controlIndex[0]; - ptr[0] = p[0]; - ptr[1] = p[1]; - ptr[2] = p[2]; - ptr[3] = p[3]; - } -} -*/ - -void dgMeshEffect::GetNormalChannel(dgInt32 strideInByte, dgFloat32* const bufferOut) const -{ - dgInt32 stride = strideInByte / sizeof (dgFloat32); - for (dgInt32 i = 0; i < m_attrib.m_normalChannel.m_count; i++) { - const dgInt32 j = i * stride; - bufferOut[j + 0] = dgFloat32(m_attrib.m_normalChannel[i].m_x); - bufferOut[j + 1] = dgFloat32(m_attrib.m_normalChannel[i].m_y); - bufferOut[j + 2] = dgFloat32(m_attrib.m_normalChannel[i].m_z); - } -} - -void dgMeshEffect::GetBinormalChannel(dgInt32 strideInByte, dgFloat32* const bufferOut) const -{ - dgInt32 stride = strideInByte / sizeof (dgFloat32); - for (dgInt32 i = 0; i < m_attrib.m_binormalChannel.m_count; i++) { - const dgInt32 j = i * stride; - bufferOut[j + 0] = dgFloat32(m_attrib.m_binormalChannel[i].m_x); - bufferOut[j + 1] = dgFloat32(m_attrib.m_binormalChannel[i].m_y); - bufferOut[j + 2] = dgFloat32(m_attrib.m_binormalChannel[i].m_z); - } -} - -void dgMeshEffect::GetUV0Channel(dgInt32 strideInByte, dgFloat32* const bufferOut) const -{ - dgInt32 stride = strideInByte / sizeof (dgFloat32); - for (dgInt32 i = 0; i < m_attrib.m_uv0Channel.m_count; i++) { - const dgInt32 j = i * stride; - bufferOut[j + 0] = dgFloat32(m_attrib.m_uv0Channel[i].m_u); - bufferOut[j + 1] = dgFloat32(m_attrib.m_uv0Channel[i].m_v); - } -} - -void dgMeshEffect::GetUV1Channel(dgInt32 strideInByte, dgFloat32* const bufferOut) const -{ - dgInt32 stride = strideInByte / sizeof (dgFloat32); - for (dgInt32 i = 0; i < m_attrib.m_uv1Channel.m_count; i++) { - const dgInt32 j = i * stride; - bufferOut[j + 0] = dgFloat32(m_attrib.m_uv1Channel[i].m_u); - bufferOut[j + 1] = dgFloat32(m_attrib.m_uv1Channel[i].m_v); - } -} - -void dgMeshEffect::GetVertexColorChannel(dgInt32 strideInByte, dgFloat32* const bufferOut) const -{ - dgInt32 stride = strideInByte / sizeof (dgFloat32); - for (dgInt32 i = 0; i < m_attrib.m_colorChannel.m_count; i++) { - const dgInt32 j = i * stride; - bufferOut[j + 0] = dgFloat32(m_attrib.m_colorChannel[i].m_x); - bufferOut[j + 1] = dgFloat32(m_attrib.m_colorChannel[i].m_y); - bufferOut[j + 2] = dgFloat32(m_attrib.m_colorChannel[i].m_z); - bufferOut[j + 3] = dgFloat32(m_attrib.m_colorChannel[i].m_w); - } -} - -dgMeshEffect::dgIndexArray* dgMeshEffect::MaterialGeometryBegin() -{ - dgInt32 materials[256]; - dgInt32 streamIndexMap[256]; - - dgInt32 count = 0; - dgInt32 materialCount = 0; - - dgIndexArray* const array = (dgIndexArray*) GetAllocator()->MallocLow (dgInt32 (4 * sizeof (dgInt32) * GetCount() + sizeof (dgIndexArray) + 2048)); - array->m_indexList = (dgInt32*)&array[1]; - - dgInt32 mark = IncLRU(); - dgPolyhedra::Iterator iter (*this); - memset(streamIndexMap, 0, sizeof (streamIndexMap)); - for(iter.Begin(); iter; iter ++){ - dgEdge* const edge = &(*iter); - if ((edge->m_incidentFace >= 0) && (edge->m_mark != mark)) { - dgEdge* ptr = edge; - ptr->m_mark = mark; - dgInt32 index0 = dgInt32 (ptr->m_userData); - - ptr = ptr->m_next; - ptr->m_mark = mark; - dgInt32 index1 = dgInt32 (ptr->m_userData); - - ptr = ptr->m_next; - do { - ptr->m_mark = mark; - - array->m_indexList[count * 4 + 0] = index0; - array->m_indexList[count * 4 + 1] = index1; - array->m_indexList[count * 4 + 2] = dgInt32 (ptr->m_userData); - array->m_indexList[count * 4 + 3] = m_attrib.m_materialChannel.m_count ? dgInt32 (m_attrib.m_materialChannel[dgInt32 (edge->m_userData)]) : 0; - index1 = dgInt32 (ptr->m_userData); - - dgInt32 hashValue = array->m_indexList[count * 4 + 3] & 0xff; - streamIndexMap[hashValue] ++; - materials[hashValue] = array->m_indexList[count * 4 + 3]; - count ++; - - ptr = ptr->m_next; - } while (ptr != edge); - } - } - - array->m_indexCount = count; - array->m_materialCount = materialCount; - - count = 0; - for (dgInt32 i = 0; i < 256;i ++) { - if (streamIndexMap[i]) { - array->m_materials[count] = materials[i]; - array->m_materialsIndexCount[count] = streamIndexMap[i] * 3; - count ++; - } - } - - array->m_materialCount = count; - - return array; -} - -void dgMeshEffect::MaterialGeomteryEnd(dgIndexArray* const handle) -{ - GetAllocator()->FreeLow (handle); -} - - -dgInt32 dgMeshEffect::GetFirstMaterial (dgIndexArray* const handle) const -{ - return GetNextMaterial (handle, -1); -} - -dgInt32 dgMeshEffect::GetNextMaterial (dgIndexArray* const handle, dgInt32 materialId) const -{ - materialId ++; - if(materialId >= handle->m_materialCount) { - materialId = -1; - } - return materialId; -} - -void dgMeshEffect::GetMaterialGetIndexStream (dgIndexArray* const handle, dgInt32 materialHandle, dgInt32* const indexArray) const -{ - - dgInt32 index = 0; - dgInt32 textureID = handle->m_materials[materialHandle]; - for (dgInt32 j = 0; j < handle->m_indexCount; j ++) { - if (handle->m_indexList[j * 4 + 3] == textureID) { - indexArray[index + 0] = handle->m_indexList[j * 4 + 0]; - indexArray[index + 1] = handle->m_indexList[j * 4 + 1]; - indexArray[index + 2] = handle->m_indexList[j * 4 + 2]; - - index += 3; - } - } -} - -void dgMeshEffect::GetMaterialGetIndexStreamShort (dgIndexArray* const handle, dgInt32 materialHandle, dgInt16* const indexArray) const -{ - dgInt32 index = 0; - dgInt32 textureID = handle->m_materials[materialHandle]; - for (dgInt32 j = 0; j < handle->m_indexCount; j ++) { - if (handle->m_indexList[j * 4 + 3] == textureID) { - indexArray[index + 0] = (dgInt16)handle->m_indexList[j * 4 + 0]; - indexArray[index + 1] = (dgInt16)handle->m_indexList[j * 4 + 1]; - indexArray[index + 2] = (dgInt16)handle->m_indexList[j * 4 + 2]; - index += 3; - } - } -} - -dgCollisionInstance* dgMeshEffect::CreateCollisionTree(dgWorld* const world, dgInt32 shapeID) const -{ - dgCollisionBVH* const collision = new (GetAllocator()) dgCollisionBVH (world); - - collision->BeginBuild(); - - dgInt32 mark = IncLRU(); - dgPolyhedra::Iterator iter (*this); - for (iter.Begin(); iter; iter ++){ - dgTreeNode* const faceNode = iter.GetNode(); - //dgEdge* const face = &(*iter); - dgEdge* const face = &faceNode->GetInfo(); - if ((face->m_mark != mark) && (face->m_incidentFace > 0)) { - dgInt32 count = 0; - dgVector polygon[256]; - dgEdge* ptr = face; - do { - //polygon[count] = dgVector (m_points[ptr->m_incidentVertex]); - polygon[count] = GetVertex(ptr->m_incidentVertex); - count ++; - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != face); - //collision->AddFace(count, &polygon[0].m_x, sizeof (dgVector), dgInt32 (m_attrib[face->m_userData].m_material)); - collision->AddFace(count, &polygon[0].m_x, sizeof (dgVector), GetFaceMaterial(faceNode)); - } - } - collision->EndBuild(0); - - dgCollisionInstance* const instance = world->CreateInstance(collision, shapeID, dgGetIdentityMatrix()); - collision->Release(); - return instance; -} - -dgCollisionInstance* dgMeshEffect::CreateConvexCollision(dgWorld* const world, dgFloat64 tolerance, dgInt32 shapeID, const dgMatrix& srcMatrix) const -{ - dgStack<dgVector> poolPtr (m_points.m_vertex.m_count * 2); - dgVector* const pool = &poolPtr[0]; - - dgBigVector minBox; - dgBigVector maxBox; - CalculateAABB (minBox, maxBox); - //dgVector com ((minBox + maxBox).Scale (dgFloat32 (0.5f))); - dgVector com ((minBox + maxBox) * dgVector::m_half); - - dgInt32 count = 0; - dgInt32 mark = IncLRU(); - dgPolyhedra::Iterator iter (*this); - for (iter.Begin(); iter; iter ++){ - dgEdge* const vertex = &(*iter); - if (vertex->m_mark != mark) { - dgEdge* ptr = vertex; - do { - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != vertex); - - if (count < dgInt32 (poolPtr.GetElementsCount())) { - const dgBigVector p (m_points.m_vertex[vertex->m_incidentVertex]); - pool[count] = dgVector (p) - com; - count ++; - } - } - } - - dgMatrix matrix (srcMatrix); - matrix.m_posit += matrix.RotateVector(com); - matrix.m_posit.m_w = dgFloat32 (1.0f); - - dgUnsigned32 crc = dgCollisionConvexHull::CalculateSignature (count, &pool[0].m_x, sizeof (dgVector)); - dgCollisionConvexHull* const collision = new (GetAllocator()) dgCollisionConvexHull (GetAllocator(), crc, count, sizeof (dgVector), dgFloat32 (tolerance), &pool[0].m_x); - if (!collision->GetConvexVertexCount()) { - collision->Release(); - return NULL; - } - dgCollisionInstance* const instance = world->CreateInstance(collision, shapeID, matrix); - collision->Release(); - return instance; -} - - -void dgMeshEffect::TransformMesh (const dgMatrix& matrix) -{ - dgAssert(0); - /* - dgMatrix normalMatrix (matrix); - normalMatrix.m_posit = dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (1.0f)); - - matrix.TransformTriplex (&m_points->m_x, sizeof (dgBigVector), &m_points->m_x, sizeof (dgBigVector), m_pointCount); - matrix.TransformTriplex (&m_attrib[0].m_vertex.m_x, sizeof (dgVertexAtribute), &m_attrib[0].m_vertex.m_x, sizeof (dgVertexAtribute), m_atribCount); - normalMatrix.TransformTriplex (&m_attrib[0].m_normal_x, sizeof (dgVertexAtribute), &m_attrib[0].m_normal_x, sizeof (dgVertexAtribute), m_atribCount); -*/ -} - -dgInt32 dgMeshEffect::AddInterpolatedHalfAttribute(dgEdge* const edge, dgInt32 midPoint) -{ - dgBigVector p0(m_points.m_vertex[edge->m_incidentVertex]); - dgBigVector p2(m_points.m_vertex[edge->m_next->m_incidentVertex]); - dgBigVector p1(m_points.m_vertex[midPoint]); - dgBigVector p2p0(p2 - p0); - - dgAssert(p2p0.m_w == dgFloat32(0.0f)); - - dgFloat64 den = p2p0.DotProduct(p2p0).GetScalar(); - dgFloat64 param = p2p0.DotProduct(p1 - p0).GetScalar() / den; - dgFloat64 t1 = param; - dgFloat64 t0 = dgFloat64(1.0f) - t1; - dgAssert(t1 >= dgFloat64(0.0f)); - dgAssert(t1 <= dgFloat64(1.0f)); - - m_attrib.m_pointChannel.PushBack(midPoint); - - if (m_attrib.m_materialChannel.m_count) { - m_attrib.m_materialChannel.PushBack(m_attrib.m_materialChannel[dgInt32(edge->m_userData)]); - } - if (m_attrib.m_normalChannel.m_count) { - dgTriplex edgeNormal; - dgTriplex edgeNormal0(m_attrib.m_normalChannel[dgInt32(edge->m_userData)]); - dgTriplex edgeNormal1(m_attrib.m_normalChannel[dgInt32(edge->m_next->m_userData)]); - edgeNormal.m_x = edgeNormal0.m_x * dgFloat32(t0) + edgeNormal1.m_x * dgFloat32(t1); - edgeNormal.m_y = edgeNormal0.m_y * dgFloat32(t0) + edgeNormal1.m_y * dgFloat32(t1); - edgeNormal.m_z = edgeNormal0.m_z * dgFloat32(t0) + edgeNormal1.m_z * dgFloat32(t1); - m_attrib.m_normalChannel.PushBack(edgeNormal); - } - if (m_attrib.m_binormalChannel.m_count) { - dgAssert(0); - } - - if (m_attrib.m_uv0Channel.m_count) { - dgAttibutFormat::dgUV edgeUV; - dgAttibutFormat::dgUV edgeUV0(m_attrib.m_uv0Channel[dgInt32(edge->m_userData)]); - dgAttibutFormat::dgUV edgeUV1(m_attrib.m_uv0Channel[dgInt32(edge->m_next->m_userData)]); - edgeUV.m_u = edgeUV0.m_u * dgFloat32(t0) + edgeUV1.m_u * dgFloat32(t1); - edgeUV.m_v = edgeUV0.m_v * dgFloat32(t0) + edgeUV1.m_v * dgFloat32(t1); - m_attrib.m_uv0Channel.PushBack(edgeUV); - } - - if (m_attrib.m_uv1Channel.m_count) { - dgAssert(0); - } - - if (m_attrib.m_colorChannel.m_count) { - dgAssert(0); - } - return m_attrib.m_pointChannel.m_count - 1; -} - -void dgMeshEffect::AddInterpolatedEdgeAttribute (dgEdge* const edge, dgFloat64 param) -{ - dgFloat64 t1 = param; - dgFloat64 t0 = dgFloat64 (1.0f) - t1; - dgAssert (t1 >= dgFloat64(0.0f)); - dgAssert (t1 <= dgFloat64(1.0f)); - - const dgInt32 vertexIndex = m_points.m_vertex.m_count; - m_points.m_vertex.PushBack(m_points.m_vertex[edge->m_incidentVertex].Scale(t0) + m_points.m_vertex[edge->m_next->m_incidentVertex].Scale(t1)); - if (m_points.m_layers.m_count) { - m_points.m_layers.PushBack(m_points.m_layers[edge->m_incidentVertex]); - } - - m_attrib.m_pointChannel.PushBack(vertexIndex); - m_attrib.m_pointChannel.PushBack(vertexIndex); - - if (m_attrib.m_materialChannel.m_count) { - m_attrib.m_materialChannel.PushBack(m_attrib.m_materialChannel[dgInt32(edge->m_userData)]); - m_attrib.m_materialChannel.PushBack(m_attrib.m_materialChannel[dgInt32(edge->m_twin->m_userData)]); - } - if (m_attrib.m_normalChannel.m_count) { - dgTriplex edgeNormal; - dgTriplex edgeNormal0(m_attrib.m_normalChannel[dgInt32(edge->m_userData)]); - dgTriplex edgeNormal1(m_attrib.m_normalChannel[dgInt32(edge->m_next->m_userData)]); - edgeNormal.m_x = edgeNormal0.m_x * dgFloat32(t0) + edgeNormal1.m_x * dgFloat32(t1); - edgeNormal.m_y = edgeNormal0.m_y * dgFloat32(t0) + edgeNormal1.m_y * dgFloat32(t1); - edgeNormal.m_z = edgeNormal0.m_z * dgFloat32(t0) + edgeNormal1.m_z * dgFloat32(t1); - m_attrib.m_normalChannel.PushBack(edgeNormal); - - dgTriplex twinNormal; - dgTriplex twinNormal0(m_attrib.m_normalChannel[dgInt32(edge->m_twin->m_next->m_userData)]); - dgTriplex twinNormal1(m_attrib.m_normalChannel[dgInt32(edge->m_twin->m_userData)]); - twinNormal.m_x = twinNormal0.m_x * dgFloat32(t0) + twinNormal1.m_x * dgFloat32(t1); - twinNormal.m_y = twinNormal0.m_y * dgFloat32(t0) + twinNormal1.m_y * dgFloat32(t1); - twinNormal.m_z = twinNormal0.m_z * dgFloat32(t0) + twinNormal1.m_z * dgFloat32(t1); - m_attrib.m_normalChannel.PushBack(twinNormal); - } - if (m_attrib.m_binormalChannel.m_count) { - dgAssert(0); - } - - if (m_attrib.m_uv0Channel.m_count) { - dgAttibutFormat::dgUV edgeUV; - dgAttibutFormat::dgUV edgeUV0(m_attrib.m_uv0Channel[dgInt32(edge->m_userData)]); - dgAttibutFormat::dgUV edgeUV1(m_attrib.m_uv0Channel[dgInt32(edge->m_next->m_userData)]); - edgeUV.m_u = edgeUV0.m_u * dgFloat32(t0) + edgeUV1.m_u * dgFloat32(t1); - edgeUV.m_v = edgeUV0.m_v * dgFloat32(t0) + edgeUV1.m_v * dgFloat32(t1); - m_attrib.m_uv0Channel.PushBack(edgeUV); - - dgAttibutFormat::dgUV twinUV; - dgAttibutFormat::dgUV twinUV0(m_attrib.m_uv0Channel[dgInt32(edge->m_twin->m_next->m_userData)]); - dgAttibutFormat::dgUV twinUV1(m_attrib.m_uv0Channel[dgInt32(edge->m_twin->m_userData)]); - twinUV.m_u = twinUV0.m_u * dgFloat32(t0) + twinUV1.m_u * dgFloat32(t1); - twinUV.m_v = twinUV0.m_v * dgFloat32(t0) + twinUV1.m_v * dgFloat32(t1); - m_attrib.m_uv0Channel.PushBack(twinUV); - } - - if (m_attrib.m_uv1Channel.m_count) { - dgAssert(0); - } - - if (m_attrib.m_colorChannel.m_count) { - dgAssert(0); - } -} - -bool dgMeshEffect::Sanity () const -{ - #ifdef _DEBUG - dgMeshEffect::Iterator iter (*this); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - dgAssert(edge->m_twin); - dgAssert(edge->m_next); - dgAssert(edge->m_prev); - dgAssert (edge->m_twin->m_twin == edge); - dgAssert (edge->m_next->m_incidentVertex == edge->m_twin->m_incidentVertex); - dgAssert (edge->m_incidentVertex == edge->m_twin->m_next->m_incidentVertex); - } - #endif - return true; -} - - -dgEdge* dgMeshEffect::InsertEdgeVertex (dgEdge* const edge, dgFloat64 param) -{ - dgEdge* const twin = edge->m_twin; - AddInterpolatedEdgeAttribute(edge, param); - - dgInt32 edgeAttrV0 = dgInt32 (edge->m_userData); - dgInt32 twinAttrV0 = dgInt32 (twin->m_userData); - - dgEdge* const faceA0 = edge->m_next; - dgEdge* const faceA1 = edge->m_prev; - dgEdge* const faceB0 = twin->m_next; - dgEdge* const faceB1 = twin->m_prev; - SpliteEdge (m_points.m_vertex.m_count - 1, edge); - - faceA0->m_prev->m_userData = dgUnsigned64 (m_attrib.m_pointChannel.m_count - 2); - faceA1->m_next->m_userData = dgUnsigned64 (edgeAttrV0); - - faceB0->m_prev->m_userData = dgUnsigned64 (m_attrib.m_pointChannel.m_count - 1); - faceB1->m_next->m_userData = dgUnsigned64 (twinAttrV0); - return faceA1->m_next; -} - - - -//dgMeshEffect::dgVertexAtribute dgMeshEffect::InterpolateVertex (const dgBigVector& srcPoint, const dgEdge* const face) const -dgInt32 dgMeshEffect::InterpolateVertex (const dgBigVector& srcPoint, const dgEdge* const face) const -{ -dgAssert(0); -return 0; -/* - const dgBigVector point (srcPoint); - - dgVertexAtribute attribute; - memset (&attribute, 0, sizeof (attribute)); - -// dgBigVector normal (FaceNormal(face, &m_points[0].m_x, sizeof(dgBigVector))); -// normal = normal.Scale (dgFloat64 (1.0f) / sqrt (normal % normal)); -// attribute.m_vertex = srcPoint; -// attribute.m_normal_x = normal.m_x; -// attribute.m_normal_y = normal.m_y; -// attribute.m_normal_z = normal.m_z; - - dgFloat64 tol = dgFloat32 (1.0e-4f); - for (dgInt32 i = 0; i < 4; i ++) { - const dgEdge* ptr = face; - const dgEdge* const edge0 = ptr; - dgBigVector q0 (m_points[ptr->m_incidentVertex]); - - ptr = ptr->m_next; - const dgEdge* edge1 = ptr; - dgBigVector q1 (m_points[ptr->m_incidentVertex]); - - ptr = ptr->m_next; - const dgEdge* edge2 = ptr; - do { - const dgBigVector q2 (m_points[ptr->m_incidentVertex]); - - dgBigVector p10 (q1 - q0); - dgBigVector p20 (q2 - q0); - - dgFloat64 dot = p20.DotProduct3(p10); - dgFloat64 mag1 = p10.DotProduct3(p10); - dgFloat64 mag2 = p20.DotProduct3(p20); - dgFloat64 collinear = dot * dot - mag2 * mag1; - if (fabs (collinear) > dgFloat64 (1.0e-8f)) { - dgBigVector p_p0 (point - q0); - dgBigVector p_p1 (point - q1); - dgBigVector p_p2 (point - q2); - - dgFloat64 alpha1 = p10.DotProduct3(p_p0); - dgFloat64 alpha2 = p20.DotProduct3(p_p0); - dgFloat64 alpha3 = p10.DotProduct3(p_p1); - dgFloat64 alpha4 = p20.DotProduct3(p_p1); - dgFloat64 alpha5 = p10.DotProduct3(p_p2); - dgFloat64 alpha6 = p20.DotProduct3(p_p2); - - dgFloat64 vc = alpha1 * alpha4 - alpha3 * alpha2; - dgFloat64 vb = alpha5 * alpha2 - alpha1 * alpha6; - dgFloat64 va = alpha3 * alpha6 - alpha5 * alpha4; - dgFloat64 den = va + vb + vc; - dgFloat64 minError = den * (-tol); - dgFloat64 maxError = den * (dgFloat32 (1.0f) + tol); - if ((va > minError) && (vb > minError) && (vc > minError) && (va < maxError) && (vb < maxError) && (vc < maxError)) { - edge2 = ptr; - - den = dgFloat64 (1.0f) / (va + vb + vc); - - dgFloat64 alpha0 = dgFloat32 (va * den); - dgFloat64 alpha1 = dgFloat32 (vb * den); - dgFloat64 alpha2 = dgFloat32 (vc * den); - - const dgVertexAtribute& attr0 = m_attrib[edge0->m_userData]; - const dgVertexAtribute& attr1 = m_attrib[edge1->m_userData]; - const dgVertexAtribute& attr2 = m_attrib[edge2->m_userData]; - dgBigVector normal (attr0.m_normal_x * alpha0 + attr1.m_normal_x * alpha1 + attr2.m_normal_x * alpha2, - attr0.m_normal_y * alpha0 + attr1.m_normal_y * alpha1 + attr2.m_normal_y * alpha2, - attr0.m_normal_z * alpha0 + attr1.m_normal_z * alpha1 + attr2.m_normal_z * alpha2, dgFloat32 (0.0f)); - //normal = normal.Scale (dgFloat64 (1.0f) / sqrt (normal.DotProduct3(normal))); - normal = normal.Normalize(); - - #ifdef _DEBUG - dgBigVector testPoint (attr0.m_vertex.m_x * alpha0 + attr1.m_vertex.m_x * alpha1 + attr2.m_vertex.m_x * alpha2, - attr0.m_vertex.m_y * alpha0 + attr1.m_vertex.m_y * alpha1 + attr2.m_vertex.m_y * alpha2, - attr0.m_vertex.m_z * alpha0 + attr1.m_vertex.m_z * alpha1 + attr2.m_vertex.m_z * alpha2, dgFloat32 (0.0f)); - dgAssert (fabs (testPoint.m_x - point.m_x) < dgFloat32 (1.0e-2f)); - dgAssert (fabs (testPoint.m_y - point.m_y) < dgFloat32 (1.0e-2f)); - dgAssert (fabs (testPoint.m_z - point.m_z) < dgFloat32 (1.0e-2f)); - #endif - - - attribute.m_vertex.m_x = point.m_x; - attribute.m_vertex.m_y = point.m_y; - attribute.m_vertex.m_z = point.m_z; - attribute.m_vertex.m_w = point.m_w; - attribute.m_normal_x = normal.m_x; - attribute.m_normal_y = normal.m_y; - attribute.m_normal_z = normal.m_z; - attribute.m_u0 = attr0.m_u0 * alpha0 + attr1.m_u0 * alpha1 + attr2.m_u0 * alpha2; - attribute.m_v0 = attr0.m_v0 * alpha0 + attr1.m_v0 * alpha1 + attr2.m_v0 * alpha2; - attribute.m_u1 = attr0.m_u1 * alpha0 + attr1.m_u1 * alpha1 + attr2.m_u1 * alpha2; - attribute.m_v1 = attr0.m_v1 * alpha0 + attr1.m_v1 * alpha1 + attr2.m_v1 * alpha2; - - attribute.m_material = attr0.m_material; - dgAssert (attr0.m_material == attr1.m_material); - dgAssert (attr0.m_material == attr2.m_material); - return attribute; - } - } - - q1 = q2; - edge1 = ptr; - - ptr = ptr->m_next; - } while (ptr != face); - tol *= dgFloat64 (2.0f); - } - // this should never happens - dgAssert (0); - return attribute; -*/ -} - -bool dgMeshEffect::HasOpenEdges () const -{ - dgPolyhedra::Iterator iter (*this); - for (iter.Begin(); iter; iter ++){ - dgEdge* const face = &(*iter); - if (face->m_incidentFace < 0){ - return true; - } - } - return false; -} - -dgFloat64 dgMeshEffect::CalculateVolume () const -{ - dgAssert (0); - return 0; - /* - - dgPolyhedraMassProperties localData; - - dgInt32 mark = IncLRU(); - dgPolyhedra::Iterator iter (*this); - for (iter.Begin(); iter; iter ++){ - dgInt32 count; - dgEdge* ptr; - dgEdge* face; - dgVector points[256]; - - face = &(*iter); - if ((face->m_incidentFace > 0) && (face->m_mark != mark)) { - count = 0; - ptr = face; - do { - points[count] = m_points[ptr->m_incidentVertex]; - count ++; - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != face); - localData.AddCGFace (count, points); - } - } - - dgFloat32 volume; - dgVector p0; - dgVector p1; - dgVector com; - dgVector inertia; - dgVector crossInertia; - volume = localData.MassProperties (com, inertia, crossInertia); - return volume; -*/ -} - - -dgMeshEffect* dgMeshEffect::GetNextLayer (dgInt32 mark) -{ - Iterator iter(*this); - dgEdge* edge = NULL; - for (iter.Begin (); iter; iter ++) { - edge = &(*iter); - if ((edge->m_mark < mark) && (edge->m_incidentFace > 0)) { - break; - } - } - - if (!edge) { - return NULL; - } - - const dgInt32 layer = m_points.m_layers.m_count ? m_points.m_layers[edge->m_incidentVertex] : 0; - dgPolyhedra polyhedra(GetAllocator()); - - polyhedra.BeginFace (); - for (iter.Begin (); iter; iter ++) { - dgEdge* const edge1 = &(*iter); - if ((edge1->m_mark < mark) && (edge1->m_incidentFace > 0)) { - const dgInt32 thislayer = m_points.m_layers.m_count ? m_points.m_layers[edge1->m_incidentVertex] : 0; - if (thislayer == layer) { - dgEdge* ptr = edge1; - dgInt32 count = 0; - dgInt32 faceIndex[256]; - dgInt64 faceDataIndex[256]; - do { - ptr->m_mark = mark; - faceIndex[count] = ptr->m_incidentVertex; - faceDataIndex[count] = ptr->m_userData; - count ++; - dgAssert (count < dgInt32 (sizeof (faceIndex)/ sizeof(faceIndex[0]))); - ptr = ptr->m_next; - } while (ptr != edge1); - polyhedra.AddFace (count, &faceIndex[0], &faceDataIndex[0]); - } - } - } - polyhedra.EndFace (); - - dgMeshEffect* solid = NULL; - if (polyhedra.GetCount()) { - solid = new (GetAllocator()) dgMeshEffect(polyhedra, *this); - solid->SetLRU(mark); - } - return solid; -} - - - -void dgMeshEffect::MergeFaces (const dgMeshEffect* const source) -{ - dgInt32 mark = source->IncLRU(); - dgPolyhedra::Iterator iter (*source); - for(iter.Begin(); iter; iter ++){ - dgEdge* const edge = &(*iter); - if ((edge->m_incidentFace > 0) && (edge->m_mark < mark)) { - BeginBuildFace (); - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - dgInt32 vIndex = ptr->m_incidentVertex; - dgInt32 aIndex = dgInt32 (ptr->m_userData); - AddPoint (source->m_points.m_vertex[vIndex].m_x, source->m_points.m_vertex[vIndex].m_y, source->m_points.m_vertex[vIndex].m_z); - if (source->m_points.m_layers.m_count) { - AddLayer (source->m_points.m_layers[vIndex]); - } - - if (source->m_attrib.m_materialChannel.m_count) { - AddMaterial (source->m_attrib.m_materialChannel[aIndex]); - } - if (source->m_attrib.m_colorChannel.m_count) { - AddVertexColor(source->m_attrib.m_colorChannel[aIndex].m_x, source->m_attrib.m_colorChannel[aIndex].m_y, source->m_attrib.m_colorChannel[aIndex].m_z, source->m_attrib.m_colorChannel[aIndex].m_w); - } - if (source->m_attrib.m_normalChannel.m_count) { - AddNormal(source->m_attrib.m_normalChannel[aIndex].m_x, source->m_attrib.m_normalChannel[aIndex].m_y, source->m_attrib.m_normalChannel[aIndex].m_z); - } - if (source->m_attrib.m_binormalChannel.m_count) { - AddBinormal(source->m_attrib.m_binormalChannel[aIndex].m_x, source->m_attrib.m_binormalChannel[aIndex].m_y, source->m_attrib.m_binormalChannel[aIndex].m_z); - } - if (source->m_attrib.m_uv0Channel.m_count) { - AddUV0(source->m_attrib.m_uv0Channel[aIndex].m_u, source->m_attrib.m_uv0Channel[aIndex].m_v); - } - if (source->m_attrib.m_uv1Channel.m_count) { - AddUV1(source->m_attrib.m_uv1Channel[aIndex].m_u, source->m_attrib.m_uv1Channel[aIndex].m_v); - } - ptr = ptr->m_next; - } while (ptr != edge); - EndBuildFace (); - } - } -} - -bool dgMeshEffect::SeparateDuplicateLoops (dgEdge* const face) -{ - for (dgEdge* ptr0 = face; ptr0 != face->m_prev; ptr0 = ptr0->m_next) { - dgInt32 index = ptr0->m_incidentVertex; - - dgEdge* ptr1 = ptr0->m_next; - do { - if (ptr1->m_incidentVertex == index) { - dgEdge* const ptr00 = ptr0->m_prev; - dgEdge* const ptr11 = ptr1->m_prev; - - ptr00->m_next = ptr1; - ptr1->m_prev = ptr00; - - ptr11->m_next = ptr0; - ptr0->m_prev = ptr11; - - return true; - } - - ptr1 = ptr1->m_next; - } while (ptr1 != face); - } - return false; -} - -void dgMeshEffect::RepairTJoints () -{ - dgAssert (Sanity ()); - - // delete edge of zero length - bool dirty = true; - while (dirty) { - dgFloat64 tol = dgFloat64 (1.0e-5f); - dgFloat64 tol2 = tol * tol; - dirty = false; - dgPolyhedra::Iterator iter (*this); - for (iter.Begin(); iter; ) { - dgEdge* const edge = &(*iter); - iter ++; - const dgBigVector& p0 = m_points.m_vertex[edge->m_incidentVertex]; - const dgBigVector& p1 = m_points.m_vertex[edge->m_twin->m_incidentVertex]; - dgBigVector dist (p1 - p0); - dgAssert(dist.m_w == dgFloat32(0.0f)); - dgFloat64 mag2 = dist.DotProduct(dist).GetScalar(); - if (mag2 < tol2) { - bool move = true; - while (move) { - move = false; - dgEdge* ptr = edge->m_twin; - do { - if ((&(*iter) == ptr) || (&(*iter) == ptr->m_twin)) { - move = true; - iter ++; - } - ptr = ptr->m_twin->m_next; - } while (ptr != edge->m_twin); - - ptr = edge; - do { - if ((&(*iter) == ptr) || (&(*iter) == ptr->m_twin)) { - move = true; - iter ++; - } - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - } - - dgEdge* const collapsedEdge = CollapseEdge(edge); - if (collapsedEdge) { - //dgAssert (0); - dgTrace(("remember to finish this!!: %s %s line:%d\n", __FILE__, __FUNCTION__, __LINE__)); - dirty = true; - dgBigVector q (m_points.m_vertex[collapsedEdge->m_incidentVertex]); - dgEdge* ptr = collapsedEdge; - do { - if (ptr->m_incidentFace > 0) { - //dgAssert (0); - //m_attrib[ptr->m_userData].m_vertex = q; - dgTrace(("remember to finish this!!: %s %s line:%d\n", __FILE__, __FUNCTION__, __LINE__)); - } - ptr = ptr->m_twin->m_next; - } while (ptr != collapsedEdge); - } - } - } - } - dgAssert (Sanity ()); - - // repair straight open edges - dgInt32 mark = IncLRU(); - dgPolyhedra::Iterator iter (*this); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if ((edge->m_mark) != mark && (edge->m_incidentFace < 0)) { - - while (SeparateDuplicateLoops (edge)); - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - } - } - - dgAssert (Sanity ()); - DeleteDegenerateFaces(&m_points.m_vertex[0].m_x, sizeof (dgBigVector), dgFloat64 (1.0e-7f)); - dgAssert (Sanity ()); - - // delete straight line edges - dirty = true; -// dirty = false; - while (dirty) { - dgFloat64 tol = dgFloat64(1.0 - 1.0e-8); - dgFloat64 tol2 = tol * tol; - - dirty = false; - dgAssert (Sanity ()); - - dgPolyhedra::Iterator iter1 (*this); - for (iter1.Begin(); iter1; ) { - dgEdge* const edge = &(*iter1); - iter1 ++; - - const dgBigVector& p0 = m_points.m_vertex[edge->m_incidentVertex]; - const dgBigVector& p1 = m_points.m_vertex[edge->m_next->m_incidentVertex]; - const dgBigVector& p2 = m_points.m_vertex[edge->m_next->m_next->m_incidentVertex]; - - dgBigVector A (p1 - p0); - dgBigVector B (p2 - p1); - dgAssert(A.m_w == dgFloat32(0.0f)); - dgAssert(B.m_w == dgFloat32(0.0f)); - dgFloat64 ab = A.DotProduct(B).GetScalar(); - if (ab >= 0.0f) { - dgFloat64 aa = A.DotProduct(A).GetScalar(); - dgFloat64 bb = B.DotProduct(B).GetScalar(); - - dgFloat64 magab2 = ab * ab; - dgFloat64 magaabb = aa * bb * tol2; - if (magab2 >= magaabb) { - if ((edge->m_incidentFace > 0) && (edge->m_twin->m_incidentFace > 0)) { - if (edge->m_twin->m_prev == edge->m_next->m_twin) { - dgEdge* const newEdge = AddHalfEdge(edge->m_incidentVertex, edge->m_next->m_next->m_incidentVertex); - if (newEdge) { - dirty = true; - dgEdge* const newTwin = AddHalfEdge(edge->m_next->m_next->m_incidentVertex, edge->m_incidentVertex); - dgAssert (newEdge); - dgAssert (newTwin); - - newEdge->m_twin = newTwin; - newTwin->m_twin = newEdge; - - newEdge->m_userData = edge->m_userData; - newTwin->m_userData = edge->m_twin->m_prev->m_userData; - - newEdge->m_incidentFace = edge->m_incidentFace; - newTwin->m_incidentFace = edge->m_twin->m_incidentFace; - - dgEdge* const nextEdge = edge->m_next; - - nextEdge->m_twin->m_prev->m_next = newTwin; - newTwin->m_prev = nextEdge->m_twin->m_prev; - - edge->m_twin->m_next->m_prev = newTwin; - newTwin->m_next = edge->m_twin->m_next; - - nextEdge->m_next->m_prev = newEdge; - newEdge->m_next = nextEdge->m_next; - - edge->m_prev->m_next = newEdge; - newEdge->m_prev = edge->m_prev; - - while ((&(*iter1) == edge->m_twin) || (&(*iter1) == nextEdge) || (&(*iter1) == nextEdge->m_twin)) { - iter1 ++; - } - - nextEdge->m_twin->m_prev = nextEdge; - nextEdge->m_twin->m_next = nextEdge; - nextEdge->m_prev = nextEdge->m_twin; - nextEdge->m_next = nextEdge->m_twin; - - edge->m_twin->m_prev = edge; - edge->m_twin->m_next = edge; - edge->m_prev = edge->m_twin; - edge->m_next = edge->m_twin; - - DeleteEdge(edge); - DeleteEdge(nextEdge); - //dgAssert (Sanity ()); - - } else if (edge->m_next->m_next->m_next == edge) { - dgAssert (0); -/* - dirty = true; - dgEdge* const openEdge = edge; - dgEdge* const nextEdge = openEdge->m_next; - dgEdge* const deletedEdge = openEdge->m_prev; - while ((&(*iter) == deletedEdge) || (&(*iter) == deletedEdge->m_twin)) { - iter ++; - } - - openEdge->m_userData = deletedEdge->m_twin->m_userData; - - dgBigVector p2p0 (p2 - p0); - dgFloat64 den = p2p0.DotProduct3(p2p0); - dgFloat64 param1 = p2p0.DotProduct3(p1 - p0) / den; - dgVertexAtribute attib1 = AddInterpolateEdgeAttibute (deletedEdge->m_twin, param1); - AddAtribute(attib1); - openEdge->m_next->m_userData = m_atribCount - 1; - - openEdge->m_incidentFace = deletedEdge->m_twin->m_incidentFace; - openEdge->m_next->m_incidentFace = deletedEdge->m_twin->m_incidentFace; - - deletedEdge->m_twin->m_prev->m_next = openEdge; - openEdge->m_prev = deletedEdge->m_twin->m_prev; - - deletedEdge->m_twin->m_next->m_prev = nextEdge; - nextEdge->m_next = deletedEdge->m_twin->m_next; - - deletedEdge->m_twin->m_next = deletedEdge; - deletedEdge->m_twin->m_prev = deletedEdge; - deletedEdge->m_next = deletedEdge->m_twin; - deletedEdge->m_prev = deletedEdge->m_twin; - DeleteEdge(deletedEdge); - //dgAssert (Sanity ()); -*/ - } - } - } else if (FindEdge(edge->m_incidentVertex, edge->m_next->m_next->m_incidentVertex)) { - dgEdge* const openEdge = edge; - //dgAssert (openEdge->m_incidentFace <= 0); - dgTrace(("remember to finish this!!: %s %s line:%d\n", __FILE__, __FUNCTION__, __LINE__)); - dgEdge* const nextEdge = openEdge->m_next; - dgEdge* const deletedEdge = openEdge->m_prev; - if (deletedEdge == openEdge->m_next->m_next) { - dirty = true; - while ((&(*iter1) == deletedEdge) || (&(*iter1) == deletedEdge->m_twin)) { - iter1 ++; - } - - //dgAssert (deletedEdge->m_twin->m_incidentFace > 0); - dgTrace(("remember to finish this!!: %s %s line:%d\n", __FILE__, __FUNCTION__, __LINE__)); - openEdge->m_incidentFace = deletedEdge->m_twin->m_incidentFace; - openEdge->m_next->m_incidentFace = deletedEdge->m_twin->m_incidentFace; - - dgInt32 attibuteIndex = AddInterpolatedHalfAttribute(deletedEdge->m_twin, nextEdge->m_incidentVertex); - openEdge->m_next->m_userData = attibuteIndex; - openEdge->m_userData = deletedEdge->m_twin->m_userData; - - deletedEdge->m_twin->m_prev->m_next = openEdge; - openEdge->m_prev = deletedEdge->m_twin->m_prev; - - deletedEdge->m_twin->m_next->m_prev = nextEdge; - nextEdge->m_next = deletedEdge->m_twin->m_next; - - deletedEdge->m_twin->m_next = deletedEdge; - deletedEdge->m_twin->m_prev = deletedEdge; - deletedEdge->m_next = deletedEdge->m_twin; - deletedEdge->m_prev = deletedEdge->m_twin; - DeleteEdge(deletedEdge); - dgAssert (Sanity ()); - } - - } else { - dgEdge* const openEdge = (edge->m_incidentFace <= 0) ? edge : edge->m_twin; - dgAssert (openEdge->m_incidentFace <= 0); - - const dgBigVector& p3 = m_points.m_vertex[openEdge->m_next->m_next->m_next->m_incidentVertex]; - - dgBigVector A0 (p3 - p2); - dgBigVector B0 (p2 - p1); - dgAssert(A0.m_w == dgFloat32(0.0f)); - dgAssert(B0.m_w == dgFloat32(0.0f)); - - dgFloat64 ab0 = A0.DotProduct(B0).GetScalar(); - if (ab0 >= 0.0) { - dgFloat64 aa0 = A0.DotProduct(A0).GetScalar(); - dgFloat64 bb0 = B0.DotProduct(B0).GetScalar(); - - dgFloat64 ab0ab0 = ab0 * ab0; - dgFloat64 aa0bb0 = aa0 * bb0 * tol2; - if (ab0ab0 >= aa0bb0) { - if (openEdge->m_next->m_next->m_next->m_next != openEdge) { - const dgBigVector& p4 = m_points.m_vertex[openEdge->m_prev->m_incidentVertex]; - dgBigVector A1 (p1 - p0); - dgBigVector B1 (p1 - p4); - dgAssert(A1.m_w == dgFloat32(0.0f)); - dgAssert(B1.m_w == dgFloat32(0.0f)); - dgFloat64 ab1 = A1.DotProduct(B1).GetScalar(); - if (ab1 < 0.0f) { - dgFloat64 ab1ab1 = ab1 * ab1; - dgFloat64 aa1bb1 = aa0 * bb0 * tol2; - if (ab1ab1 >= aa1bb1) { - dgEdge* const newFace = ConnectVertex (openEdge->m_prev, openEdge->m_next); - dirty |= newFace ? true : false; - } - } - //dgAssert (Sanity ()); - } else if (openEdge->m_prev->m_twin->m_incidentFace > 0) { - dirty = true; - - dgEdge* const deletedEdge = openEdge->m_prev; - while ((&(*iter1) == deletedEdge) || (&(*iter1) == deletedEdge->m_twin)) { - iter1 ++; - } - - openEdge->m_incidentFace = deletedEdge->m_twin->m_incidentFace; - openEdge->m_next->m_incidentFace = deletedEdge->m_twin->m_incidentFace; - openEdge->m_next->m_next->m_incidentFace = deletedEdge->m_twin->m_incidentFace; - - dgInt32 attibuteIndex0 = AddInterpolatedHalfAttribute(deletedEdge->m_twin, openEdge->m_next->m_incidentVertex); - dgInt32 attibuteIndex1 = AddInterpolatedHalfAttribute(deletedEdge->m_twin, openEdge->m_next->m_next->m_incidentVertex); - - openEdge->m_userData = deletedEdge->m_twin->m_userData; - openEdge->m_next->m_userData = attibuteIndex0; - openEdge->m_next->m_next->m_userData = attibuteIndex1; - - - deletedEdge->m_twin->m_prev->m_next = openEdge; - openEdge->m_prev = deletedEdge->m_twin->m_prev; - - deletedEdge->m_twin->m_next->m_prev = deletedEdge->m_prev; - deletedEdge->m_prev->m_next = deletedEdge->m_twin->m_next; - - deletedEdge->m_twin->m_next = deletedEdge; - deletedEdge->m_twin->m_prev = deletedEdge; - deletedEdge->m_next = deletedEdge->m_twin; - deletedEdge->m_prev = deletedEdge->m_twin; - DeleteEdge(deletedEdge); - //dgAssert (Sanity ()); - } - } - } - } - } - } - } - } - dgAssert (Sanity ()); - - DeleteDegenerateFaces(&m_points.m_vertex[0].m_x, sizeof (dgBigVector), dgFloat64 (1.0e-7f)); -/* - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if (edge->m_incidentFace > 0) { - dgBigVector p0 (m_points[edge->m_incidentVertex]); - m_attrib[edge->m_userData].m_vertex.m_x = p0.m_x; - m_attrib[edge->m_userData].m_vertex.m_y = p0.m_y; - m_attrib[edge->m_userData].m_vertex.m_z = p0.m_z; - } - } -*/ - dgAssert (Sanity ()); -} - diff --git a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect2.cpp b/thirdparty/src/newton/dgMeshUtil/dgMeshEffect2.cpp deleted file mode 100644 index c380f4b69..000000000 --- a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect2.cpp +++ /dev/null @@ -1,1221 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgMeshEffect.h" -#include "dgCollisionConvexHull.h" - - - -class dgRayTrataAABBAccelerator: public dgMeshEffect::dgMeshBVH -{ - public: - dgRayTrataAABBAccelerator(const dgMeshEffect* const tetraMesh) - :dgMeshEffect::dgMeshBVH(tetraMesh) - { - Build(); - } - - dgMeshBVHNode* CreateLeafNode(dgEdge* const face, void* const userData) - { - dgMemoryAllocator* const allocator = m_mesh->GetAllocator(); - dgMeshBVHNode* const node = new (allocator)dgMeshBVHNode(m_mesh, face, userData); - - dgInt32 mark = m_mesh->GetLRU(); - - dgVector p0(m_mesh->GetVertex(face->m_twin->m_prev->m_incidentVertex)); - dgVector p1(p0); - dgEdge* faceEdge = face; - do { - dgEdge* twinFace = faceEdge->m_twin; - do { - twinFace->m_mark = mark; - twinFace = twinFace->m_next; - } while (twinFace != faceEdge->m_twin); - - dgVector point(m_mesh->GetVertex(faceEdge->m_incidentVertex)); - p0 = point.GetMin(p0); - p1 = point.GetMax(p1); - - faceEdge = faceEdge->m_next; - } while (faceEdge != face); - - dgVector padding(dgFloat32(0.01f)); - p0 -= padding; - p1 += padding; - node->SetBox(p0, p1); - return node; - } -}; - - -// idea taken from paper: Fast Tetrahedral Meshes with Good Dihedral Angles, by Francois Labelle Jonathan Richard Shewchuk -// but quite different approach. -class dgTetraIsoSufaceStuffing -{ - public: - enum dgVertexSign - { - m_onSuface, - m_inside, - m_outside, - }; - - class dgGridDimension - { - public: - dgBigVector m_origin; - dgFloat64 m_cellSize; - dgFloat64 m_diameter; - dgInt32 m_gridSizeX; - dgInt32 m_gridSizeY; - dgInt32 m_gridSizeZ; - dgInt32 m_innerSize; - dgInt32 m_outerSize; - }; - - template<class T, dgInt32 size> - class dgAssessor - { - public: - dgAssessor() - :m_count(0) - { - } - - dgInt32 GetCount() const - { - return m_count; - } - - const T& operator[] (dgInt32 i) const - { - dgAssert(i >= 0); - dgAssert(i < size); - return m_elements[i]; - } - - T& operator[] (dgInt32 i) - { - dgAssert (i >= 0); - dgAssert (i < size); - return m_elements[i]; - } - - void PushBack (const T data) - { - dgAssert(m_count >= 0); - dgAssert(m_count < size); - m_elements[m_count] = data; - m_count ++; - } - - private: - dgInt32 m_count; - T m_elements[size]; - }; - - typedef dgAssessor<dgInt32, 4> dgTetrahedra; - typedef dgAssessor<dgFloat32, 6> dgTetraEdgeCuts; - typedef dgAssessor<dgInt32, 32> dgTetraToVertexNode; - - class dgNormalMap - { - public: - dgNormalMap() - :m_count(sizeof (m_normal)/sizeof (m_normal[0])) - { - dgVector p0(dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p1(dgFloat32(-1.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p2(dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p3(dgFloat32(0.0f), dgFloat32(-1.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p4(dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f)); - dgVector p5(dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(-1.0f), dgFloat32(0.0f)); - - dgInt32 count = 0; - dgInt32 subdivitions = 1; - TessellateTriangle(subdivitions, p4, p0, p2, count); - TessellateTriangle(subdivitions, p0, p5, p2, count); - TessellateTriangle(subdivitions, p5, p1, p2, count); - TessellateTriangle(subdivitions, p1, p4, p2, count); - TessellateTriangle(subdivitions, p0, p4, p3, count); - TessellateTriangle(subdivitions, p5, p0, p3, count); - TessellateTriangle(subdivitions, p1, p5, p3, count); - TessellateTriangle(subdivitions, p4, p1, p3, count); - } - - private: - void TessellateTriangle(dgInt32 level, const dgVector& p0, const dgVector& p1, const dgVector& p2, dgInt32& count) - { - if (level) { - dgAssert(dgAbs(p0.DotProduct(p0).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p1.DotProduct(p1).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p2.DotProduct(p2).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgVector p01(p0 + p1); - dgVector p12(p1 + p2); - dgVector p20(p2 + p0); - - p01 = p01.Scale(dgRsqrt(p01.DotProduct(p01).GetScalar())); - p12 = p12.Scale(dgRsqrt(p12.DotProduct(p12).GetScalar())); - p20 = p20.Scale(dgRsqrt(p20.DotProduct(p20).GetScalar())); - - dgAssert(dgAbs(p01.DotProduct(p01).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p12.DotProduct(p12).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p20.DotProduct(p20).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - - TessellateTriangle(level - 1, p0, p01, p20, count); - TessellateTriangle(level - 1, p1, p12, p01, count); - TessellateTriangle(level - 1, p2, p20, p12, count); - TessellateTriangle(level - 1, p01, p12, p20, count); - } else { - dgBigPlane n(p0, p1, p2); - n = n.Scale(dgFloat64(1.0f) / sqrt(n.DotProduct3(n))); - n.m_w = dgFloat64(0.0f); - dgInt32 index = dgBitReversal(count, sizeof (m_normal) / sizeof (m_normal[0])); - m_normal[index] = n; - count++; - dgAssert(count <= sizeof (m_normal) / sizeof (m_normal[0])); - } - } - - public: - dgBigVector m_normal[32]; - dgInt32 m_count; - }; - - class dgClosePointsAccelerator: public dgMeshEffect::dgMeshBVH - { - public: - dgClosePointsAccelerator(const dgMeshEffect* const mesh) - :dgMeshEffect::dgMeshBVH(mesh) - { - Build(); - } - - dgMeshBVHNode* CreateLeafNode(dgEdge* const face, void* const userData) - { - dgMemoryAllocator* const allocator = m_mesh->GetAllocator(); - dgMeshBVHNode* const node = new (allocator)dgMeshBVHNode(m_mesh, face, userData); - - dgInt32 mark = m_mesh->GetLRU(); - dgAssert(mark != face->m_mark); - - dgEdge* faceEdge = face; - do { - faceEdge->m_mark = mark; - faceEdge = faceEdge->m_twin->m_next; - } while (faceEdge != face); - - dgVector padding(dgFloat32(1.0f / 32.0f)); - dgVector p(m_mesh->GetVertex(face->m_incidentVertex)); - dgVector p0(p - padding); - dgVector p1(p + padding); - node->SetBox(p0, p1); - return node; - } - - bool DoesTetrahedrumHasInsidePoints (const dgArray<dgBigVector>& points, const dgTetrahedra& tetra) const - { - dgBigVector box0(dgFloat64( 1.0e10f)); - dgBigVector box1(dgFloat64(-1.0e10f)); - for (dgInt32 i = 0; i < 4; i++) { - box0 = box0.GetMin(points[tetra[i]]); - box1 = box1.GetMax(points[tetra[i]]); - } - - dgBigVector padding (dgFloat64 (0.01f)); - box0 -= padding; - box1 += padding; - - dgList<dgMeshBVH::dgMeshBVHNode*> overlapNodes(m_mesh->GetAllocator()); - GetOverlapNodes(overlapNodes, box0, box1); - if (overlapNodes.GetCount()) { - dgBigVector p0(points[tetra[0]]); - dgBigVector p1(points[tetra[1]]); - dgBigVector p2(points[tetra[2]]); - dgBigVector p3(points[tetra[3]]); - - for (dgList<dgMeshBVH::dgMeshBVHNode*>::dgListNode* node = overlapNodes.GetFirst(); node; node = node->GetNext()) { - dgEdge* const edge = node->GetInfo()->m_face; - dgBigVector point(m_mesh->GetVertex(edge->m_incidentVertex)); - dgBigVector closestPoint(dgPointToTetrahedrumDistance(point, p0, p1, p2, p3)); - dgBigVector error(closestPoint - point); - dgFloat64 error2 = error.DotProduct3(error); - if (error2 < dgFloat64(1.0e-8f)) { - return true; - } - } - } - - return false; - } - }; - - class dgRayTraceAccelerator: public dgMeshEffect::dgMeshBVH - { - enum dgTraceType - { - m_pointSide, - m_pointOnSurface, - }; - - class dgRayTraceBase - { - public: - dgRayTraceBase(dgTraceType type) - :m_type(type) - { - } - dgTraceType m_type; - }; - - class dgRayTracePointSide: public dgRayTraceBase - { - public: - dgRayTracePointSide() - :dgRayTraceBase(m_pointSide) - ,m_hitCount(0) - ,m_rayIsDegenerate(true) - { - } - dgInt32 m_hitCount; - bool m_rayIsDegenerate; - }; - - class dgRayPointOnSurface: public dgRayTraceBase - { - public: - dgRayPointOnSurface() - :dgRayTraceBase(m_pointOnSurface) - ,m_param(2.0f) - { - } - - dgFloat32 m_param; - }; - - public: - dgRayTraceAccelerator(const dgMeshEffect* const mesh, dgFloat64 diameter) - :dgMeshEffect::dgMeshBVH(mesh) - ,m_normals() - ,m_diameter(diameter) - { - Build(); - } - - dgMeshBVHNode* CreateLeafNode(dgEdge* const face, void* const userData) - { - dgMemoryAllocator* const allocator = m_mesh->GetAllocator(); - dgMeshBVHNode* const node = new (allocator)dgMeshBVHNode(m_mesh, face, userData); - dgInt32 mark = m_mesh->GetLRU(); - dgAssert(mark != face->m_mark); - - dgEdge* faceEdge = face; - do { - faceEdge->m_mark = mark; - faceEdge = faceEdge->m_next; - } while (faceEdge != face); - return node; - } - - dgFloat64 dgPointToRayDistance (const dgBigVector& point, const dgBigVector& ray_p0, const dgBigVector& ray_p1, dgRayTracePointSide* const rayType) const - { - dgBigVector dp(ray_p1 - ray_p0); - dgFloat64 den = dp.DotProduct3(dp); - dgFloat64 num = dp.DotProduct3(point - ray_p0); - if ((num >= dgFloat64 (0.0f)) && (num <= den)) { - dgBigVector p (ray_p0 + dp.Scale (num / den)); - dgBigVector dist (point - p); - if (dist.DotProduct3(dist) < dgFloat64 (1.0e-12f)) { - rayType->m_rayIsDegenerate = true; - return dgFloat64 (-2.0f); - } - } - return dgFloat64 (2.0f); - } - - dgFloat64 PointSideTest(const dgMeshBVHNode* const faceNode, const dgBigVector& point0, const dgBigVector& point1, dgRayTracePointSide* const rayType) const - { - const dgEdge* const edge = faceNode->m_face; - const dgBigVector p0 (m_mesh->GetVertex(edge->m_incidentVertex)); - const dgBigVector p1 (m_mesh->GetVertex(edge->m_next->m_incidentVertex)); - const dgBigVector p2 (m_mesh->GetVertex(edge->m_next->m_next->m_incidentVertex)); - - const dgBigVector e10(p1 - p0); - const dgBigVector e20(p2 - p0); - const dgFloat64 a00 = e10.DotProduct(e10).GetScalar(); - const dgFloat64 a11 = e20.DotProduct(e20).GetScalar(); - const dgFloat64 a01 = e10.DotProduct(e20).GetScalar(); - - const dgFloat64 det = a00 * a11 - a01 * a01; - dgAssert(det >= dgFloat32(0.0f)); - if (dgAbs(det) > dgFloat32(1.0e-24f)) { - dgBigVector p0Point(point0 - p0); - dgBigVector normal(e10.CrossProduct(e20)); - dgFloat64 t = -normal.DotProduct3(p0Point) / normal.DotProduct3(point1 - point0); - if ((t > dgFloat64(0.0f)) && (t < dgFloat64(1.0f))) { - dgBigVector point(point0 + (point1 - point0).Scale(t)); - dgBigVector variPoint(point - p0); - const dgFloat64 b0 = e10.DotProduct(variPoint).GetScalar(); - const dgFloat64 b1 = e20.DotProduct(variPoint).GetScalar(); - - dgFloat64 beta = b1 * a00 - a01 * b0; - dgFloat64 alpha = b0 * a11 - a01 * b1; - - if (beta <= dgFloat32(0.0f)) { - return dgPointToRayDistance (point, p0, p1, rayType); - } else if (alpha <= dgFloat32(0.0f)) { - return dgPointToRayDistance (point, p0, p2, rayType); - } else if ((alpha + beta) >= det) { - return dgPointToRayDistance (point, p1, p2, rayType); - } - rayType->m_hitCount ++; - } - } - return dgFloat64 (2.0f); - } - - - dgFloat64 PointSurfaceHit(const dgMeshBVHNode* const faceNode, const dgBigVector& point0, const dgBigVector& point1, dgRayPointOnSurface* const rayType) const - { - const dgEdge* const edge = faceNode->m_face; - const dgBigVector p0(m_mesh->GetVertex(edge->m_incidentVertex)); - const dgBigVector p1(m_mesh->GetVertex(edge->m_next->m_incidentVertex)); - const dgBigVector p2(m_mesh->GetVertex(edge->m_next->m_next->m_incidentVertex)); - - const dgBigVector e10(p1 - p0); - const dgBigVector e20(p2 - p0); - const dgFloat64 a00 = e10.DotProduct(e10).GetScalar(); - const dgFloat64 a11 = e20.DotProduct(e20).GetScalar(); - const dgFloat64 a01 = e10.DotProduct(e20).GetScalar(); - - const dgFloat64 det = a00 * a11 - a01 * a01; - dgAssert(det >= dgFloat32(0.0f)); - if (dgAbs(det) > dgFloat32(1.0e-24f)) { - dgBigVector p0Point(point0 - p0); - dgBigVector normal(e10.CrossProduct(e20)); - dgFloat64 t = -normal.DotProduct3(p0Point) / normal.DotProduct3(point1 - point0); - if ((t > dgFloat64(0.0f)) && (t < dgFloat64(1.0f))) { - dgBigVector point(point0 + (point1 - point0).Scale(t)); - dgBigVector variPoint(point - p0); - const dgFloat64 b0 = e10.DotProduct(variPoint).GetScalar(); - const dgFloat64 b1 = e20.DotProduct(variPoint).GetScalar(); - - dgFloat64 beta = b1 * a00 - a01 * b0; - dgFloat64 alpha = b0 * a11 - a01 * b1; - - if (beta <= dgFloat32(0.0f)) { - return dgFloat64(2.0f); - } else if (alpha <= dgFloat32(0.0f)) { - return dgFloat64(2.0f); - } else if ((alpha + beta) >= det) { - return dgFloat64(2.0f); - } - if (t < rayType->m_param) { - rayType->m_param = dgFloat32 (t); - } - } - } - return dgFloat64(2.0f); - } - - dgFloat64 RayFaceIntersect(const dgMeshBVHNode* const faceNode, const dgBigVector& point0, const dgBigVector& point1, void* const userData) const - { - dgRayTraceBase* const rayType = (dgRayTraceBase*)userData; - - switch (rayType->m_type) - { - case m_pointSide: - return PointSideTest(faceNode, point0, point1, (dgRayTracePointSide*) rayType); - - case m_pointOnSurface: - return PointSurfaceHit(faceNode, point0, point1, (dgRayPointOnSurface*) rayType); - } - - dgAssert (0); - return dgFloat64 (-1.0f); - } - - dgVertexSign CalculateVertexSide (const dgBigVector& point0) const - { - dgRayTracePointSide hits; - for (dgInt32 i = 0; (i < m_normals.m_count) && hits.m_rayIsDegenerate; i ++) { - hits.m_hitCount = 0; - hits.m_rayIsDegenerate = false; - dgBigVector point1 (point0 + dgBigVector (m_normals.m_normal[i].Scale (m_diameter))); - FaceRayCast (point0, point1, &hits); - } - dgAssert (!hits.m_rayIsDegenerate); - return (hits.m_hitCount & 1) ? m_inside : m_outside; - } - - dgFloat32 CalculateEdgeCut (const dgBigVector& point0, const dgBigVector& point1) const - { - dgRayPointOnSurface pointOnSurface; - FaceRayCast (point0, point1, &pointOnSurface); - return pointOnSurface.m_param; - } - - dgNormalMap m_normals; - dgFloat64 m_diameter; - }; - - dgTetraIsoSufaceStuffing(const dgMeshEffect* const mesh, dgFloat64 cellSize) - :m_points(mesh->GetAllocator()) - ,m_tetraList(mesh->GetAllocator()) - ,m_pointCount(0) - ,m_tetraCount(0) - { - dgArray<dgVertexSign> vertexSide(mesh->GetAllocator()); - dgArray<dgTetraToVertexNode> tetraGraph(mesh->GetAllocator()); - dgArray<dgTetraEdgeCuts> tetraEdgeCuts(mesh->GetAllocator()); - - dgGridDimension gridDim (CalculateGridSize(mesh, cellSize)); - dgClosePointsAccelerator closePointaAccelerator (mesh); - dgRayTraceAccelerator rayAccelerator (mesh, gridDim.m_diameter); - - PopulateGridPoints (gridDim); - CalculateVertexSide (vertexSide, rayAccelerator); - BuildTetraGraph (gridDim, vertexSide, closePointaAccelerator, tetraGraph); - //CalculateEdgeCuts (tetraEdgeCuts, tetraGraph, vertexSide, rayAccelerator); - //SnapClosePoints (tetraEdgeCuts, tetraGraph, vertexSide, rayAccelerator); - } - - void CalculateEdgeCuts (dgArray<dgTetraEdgeCuts>& tetraEdgeCuts, const dgArray<dgTetraToVertexNode>& tetraGraph, const dgArray<dgVertexSign>& vertexSide, const dgRayTraceAccelerator& rayAccelerator) - { - tetraEdgeCuts.Resize(m_tetraCount); - for (dgInt32 i = 0; i < m_tetraCount; i ++) { - tetraEdgeCuts[i] = dgTetraEdgeCuts(); - for (dgInt32 j = 0; j < 6; j ++) { - tetraEdgeCuts[i].PushBack(dgFloat32(-1.0f)); - } - } - - for (dgInt32 i = 0; i < m_pointCount; i ++) { - if (vertexSide[i] == m_outside) { - const dgTetraToVertexNode& graphNode = tetraGraph[i]; - for (dgInt32 j = 0; j < graphNode.GetCount(); j ++) { - dgTetraEdgeCuts& cuts = tetraEdgeCuts[graphNode[j]]; - const dgTetrahedra& tetra = m_tetraList[graphNode[j]]; - dgAssert ((tetra[0] == i) || (tetra[1] == i) || (tetra[2] == i) || (tetra[3] == i)); - - dgInt32 index = 0; - for (dgInt32 i0 = 0; i0 < 3; i0 ++) { - const dgBigVector& p0 = m_points[tetra[i0]]; - for (dgInt32 i1 = i0 + 1; i1 < 4; i1 ++) { - if ((tetra[i0] == i) && (vertexSide[tetra[i1]] == m_inside)) { - const dgBigVector& p1 = m_points[tetra[i1]]; - dgFloat32 param = rayAccelerator.CalculateEdgeCut (p0, p1); - cuts[index] = param; - } - index ++; - dgAssert (index <= 6); - } - } - } - } - } - } - - void SnapClosePoints (dgArray<dgTetraEdgeCuts>& tetraEdgeCuts, const dgArray<dgTetraToVertexNode>& tetraGraph, const dgArray<dgVertexSign>& vertexSide, const dgRayTraceAccelerator& rayAccelerator) - { - for (dgInt32 i = 0; i < m_pointCount; i++) { - if (vertexSide[i] == m_outside) { -/* - const dgTetraToVertexNode& graphNode = tetraGraph[i]; - for (dgInt32 j = 0; j < graphNode.GetCount(); j++) { - dgTetraEdgeCuts& cuts = tetraEdgeCuts[graphNode[j]]; - const dgTetrahedra& tetra = m_tetraList[graphNode[j]]; - dgAssert((tetra[0] == i) || (tetra[1] == i) || (tetra[2] == i) || (tetra[3] == i)); - - dgInt32 index = 0; - for (dgInt32 i0 = 0; i0 < 3; i0++) { - const dgBigVector& p0 = m_points[tetra[i0]]; - for (dgInt32 i1 = i0 + 1; i1 < 4; i1++) { - if ((tetra[i0] == i) && (vertexSide[tetra[i1]] == m_inside)) { - const dgBigVector& p1 = m_points[tetra[i1]]; - dgFloat32 param = rayAccelerator.CalculateEdgeCut(p0, p1); - cuts[index] = param; - } - index++; - dgAssert(index <= 6); - } - } - } -*/ - } - } - } - - void CalculateVertexSide (dgArray<dgVertexSign>& vertexSide, const dgRayTraceAccelerator& rayAccelerator) - { - vertexSide.Resize(m_pointCount); - for (dgInt32 i = 0; i < m_pointCount; i ++) { - vertexSide[i] = rayAccelerator.CalculateVertexSide (m_points[i]); - } - } - - dgGridDimension CalculateGridSize(const dgMeshEffect* const mesh, dgFloat64 cellsize) const - { - dgBigVector minBox; - dgBigVector maxBox; - mesh->CalculateAABB(minBox, maxBox); - minBox -= (maxBox - minBox).Scale(dgFloat64(1.e-3f)); - maxBox += (maxBox - minBox).Scale(dgFloat64(1.e-3f)); - - dgBigVector mMinInt((minBox.Scale(dgFloat64(1.0f) / cellsize)).Floor()); - dgBigVector mMaxInt((maxBox.Scale(dgFloat64(1.0f) / cellsize)).Floor() + dgBigVector::m_one); - dgBigVector gridSize(mMaxInt - mMinInt + dgBigVector::m_one); - - dgBigVector size(maxBox - minBox); - - dgGridDimension gridDimension; - gridDimension.m_origin = minBox; - gridDimension.m_cellSize = cellsize; - gridDimension.m_diameter = sqrt (size.DotProduct3(size)); - gridDimension.m_gridSizeX = dgInt32(gridSize.m_x); - gridDimension.m_gridSizeY = dgInt32(gridSize.m_y); - gridDimension.m_gridSizeZ = dgInt32(gridSize.m_z); - - gridDimension.m_innerSize = gridDimension.m_gridSizeX * gridDimension.m_gridSizeY * gridDimension.m_gridSizeZ; - gridDimension.m_outerSize = gridDimension.m_innerSize + (gridDimension.m_gridSizeX + 1) * (gridDimension.m_gridSizeY + 1) * (gridDimension.m_gridSizeZ + 1); - return gridDimension; - } - - void PopulateGridPoints(const dgGridDimension& gridDimension) - { - m_pointCount = 0; - m_points.Resize(gridDimension.m_outerSize); - - for (dgInt32 z = 0; z < gridDimension.m_gridSizeZ; z++) { - for (dgInt32 y = 0; y < gridDimension.m_gridSizeY; y++) { - for (dgInt32 x = 0; x < gridDimension.m_gridSizeX; x++) { - m_points[m_pointCount] = gridDimension.m_origin + dgBigVector(x * gridDimension.m_cellSize, y * gridDimension.m_cellSize, z * gridDimension.m_cellSize, dgFloat64(0.0f)); - m_pointCount++; - } - } - } - - dgBigVector outerOrigin(gridDimension.m_origin - dgBigVector(gridDimension.m_cellSize * dgFloat64(0.5f))); - outerOrigin.m_w = dgFloat64 (0.0f); - for (dgInt32 z = 0; z < gridDimension.m_gridSizeZ + 1; z++) { - for (dgInt32 y = 0; y < gridDimension.m_gridSizeY + 1; y++) { - for (dgInt32 x = 0; x < gridDimension.m_gridSizeX + 1; x++) { - m_points[m_pointCount] = outerOrigin + dgBigVector(x * gridDimension.m_cellSize, y * gridDimension.m_cellSize, z * gridDimension.m_cellSize, dgFloat64(0.0f)); - m_pointCount++; - } - } - } - } - - void AddTetra(dgArray<dgTetraToVertexNode>& graph, const dgTetrahedra& tetra, const dgArray<dgVertexSign>& vertexSigns, const dgClosePointsAccelerator& closePoint) - { - dgAssert(CalculateVolume(tetra) > dgFloat64(0.0f)); - bool hasInsizePoints = false; - hasInsizePoints = hasInsizePoints || (vertexSigns[tetra[0]] == m_inside); - hasInsizePoints = hasInsizePoints || (vertexSigns[tetra[1]] == m_inside); - hasInsizePoints = hasInsizePoints || (vertexSigns[tetra[2]] == m_inside); - hasInsizePoints = hasInsizePoints || (vertexSigns[tetra[3]] == m_inside); - hasInsizePoints = hasInsizePoints || closePoint.DoesTetrahedrumHasInsidePoints(m_points, tetra); - - if (hasInsizePoints) { - m_tetraList[m_tetraCount] = tetra; - dgTetrahedra& tetraEntry = m_tetraList[m_tetraCount]; - for (dgInt32 i = 0; i < 4; i ++) { - dgInt32 vertexIndex = tetra[i]; - tetraEntry.PushBack(vertexIndex); - graph[vertexIndex].PushBack(m_tetraCount); - } - m_tetraCount ++; - } - } - - void BuildTetraGraph(const dgGridDimension& gridDimension, const dgArray<dgVertexSign>& vertexSigns, const dgClosePointsAccelerator& closePoint, dgArray<dgTetraToVertexNode>& graph) - { - graph.Resize(m_pointCount); - for (dgInt32 i = 0; i < m_pointCount; i ++) { - graph[i] = dgTetraToVertexNode(); - } - - dgDelaunayTetrahedralization delaunayTetrahedras(m_points.GetAllocator(), &m_points[0].m_x, m_pointCount, sizeof (dgBigVector), dgFloat32(0.0f)); - delaunayTetrahedras.RemoveUpperHull(); - - for (dgDelaunayTetrahedralization::dgListNode* node = delaunayTetrahedras.GetFirst(); node; node = node->GetNext()) { - dgTetrahedra stuffingTetra; - dgConvexHull4dTetraherum& delaunayTetra = node->GetInfo(); - - for (dgInt32 i = 0; i < 4; i ++) { - stuffingTetra[i] = delaunayTetra.m_faces[0].m_index[i]; - } - dgFloat64 volume = CalculateVolume(stuffingTetra); - if (volume < dgFloat64 (0.0f)) { - dgSwap(stuffingTetra[0], stuffingTetra[1]); - } - AddTetra(graph, stuffingTetra, vertexSigns, closePoint); - } - - -/* - const dgInt32 base = gridDimension.m_innerSize; - for (dgInt32 z = 0; z < gridDimension.m_gridSizeZ; z++) { - for (dgInt32 y = 0; y < gridDimension.m_gridSizeY; y++) { - for (dgInt32 x = 0; x < gridDimension.m_gridSizeX - 1; x++) { - dgTetrahedra tetra; - tetra[0] = ((z * gridDimension.m_gridSizeY + y) * gridDimension.m_gridSizeX) + x; - tetra[1] = ((z * gridDimension.m_gridSizeY + y) * gridDimension.m_gridSizeX) + x + 1; - tetra[2] = base + (((z + 0) * (gridDimension.m_gridSizeY + 1) + y + 0) * (gridDimension.m_gridSizeX + 1)) + x + 1; - tetra[3] = base + (((z + 0) * (gridDimension.m_gridSizeY + 1) + y + 1) * (gridDimension.m_gridSizeX + 1)) + x + 1; - AddTetra(graph, tetra, vertexSigns, closePoint); - - tetra[0] = ((z * gridDimension.m_gridSizeY + y) * gridDimension.m_gridSizeX) + x; - tetra[1] = ((z * gridDimension.m_gridSizeY + y) * gridDimension.m_gridSizeX) + x + 1; - tetra[3] = base + (((z + 1) * (gridDimension.m_gridSizeY + 1) + y + 0) * (gridDimension.m_gridSizeX + 1)) + x + 1; - tetra[2] = base + (((z + 1) * (gridDimension.m_gridSizeY + 1) + y + 1) * (gridDimension.m_gridSizeX + 1)) + x + 1; - AddTetra(graph, tetra, vertexSigns, closePoint); - } - } - } - - for (dgInt32 z = 0; z < gridDimension.m_gridSizeZ; z++) { - for (dgInt32 y = 0; y < gridDimension.m_gridSizeY - 1; y++) { - for (dgInt32 x = 0; x < gridDimension.m_gridSizeX; x++) { - dgTetrahedra tetra; - tetra[0] = ((z * gridDimension.m_gridSizeY + (y + 0)) * gridDimension.m_gridSizeX) + x; - tetra[1] = ((z * gridDimension.m_gridSizeY + (y + 1)) * gridDimension.m_gridSizeX) + x; - tetra[3] = base + (((z + 0) * (gridDimension.m_gridSizeY + 1) + y + 1) * (gridDimension.m_gridSizeX + 1)) + x + 1; - tetra[2] = base + (((z + 1) * (gridDimension.m_gridSizeY + 1) + y + 1) * (gridDimension.m_gridSizeX + 1)) + x + 1; - AddTetra(graph, tetra, vertexSigns, closePoint); - - tetra[0] = ((z * gridDimension.m_gridSizeY + (y + 0)) * gridDimension.m_gridSizeX) + x; - tetra[1] = ((z * gridDimension.m_gridSizeY + (y + 1)) * gridDimension.m_gridSizeX) + x; - tetra[2] = base + (((z + 0) * (gridDimension.m_gridSizeY + 1) + y + 1) * (gridDimension.m_gridSizeX + 1)) + x + 0; - tetra[3] = base + (((z + 1) * (gridDimension.m_gridSizeY + 1) + y + 1) * (gridDimension.m_gridSizeX + 1)) + x + 0; - AddTetra(graph, tetra, vertexSigns, closePoint); - } - } - } - - for (dgInt32 z = 0; z < gridDimension.m_gridSizeZ - 1; z++) { - for (dgInt32 y = 0; y < gridDimension.m_gridSizeY; y++) { - for (dgInt32 x = 0; x < gridDimension.m_gridSizeX; x++) { - dgTetrahedra tetra; - tetra[0] = (((z + 0) * gridDimension.m_gridSizeY + y + 0) * gridDimension.m_gridSizeX) + x; - tetra[1] = (((z + 1) * gridDimension.m_gridSizeY + y + 0) * gridDimension.m_gridSizeX) + x; - tetra[3] = base + (((z + 1) * (gridDimension.m_gridSizeY + 1) + y + 0) * (gridDimension.m_gridSizeX + 1)) + x + 0; - tetra[2] = base + (((z + 1) * (gridDimension.m_gridSizeY + 1) + y + 1) * (gridDimension.m_gridSizeX + 1)) + x + 0; - AddTetra(graph, tetra, vertexSigns, closePoint); - - tetra[0] = (((z + 0) * gridDimension.m_gridSizeY + y + 0) * gridDimension.m_gridSizeX) + x; - tetra[1] = (((z + 1) * gridDimension.m_gridSizeY + y + 0) * gridDimension.m_gridSizeX) + x; - tetra[2] = base + (((z + 1) * (gridDimension.m_gridSizeY + 1) + y + 0) * (gridDimension.m_gridSizeX + 1)) + x + 1; - tetra[3] = base + (((z + 1) * (gridDimension.m_gridSizeY + 1) + y + 1) * (gridDimension.m_gridSizeX + 1)) + x + 1; - AddTetra(graph, tetra, vertexSigns, closePoint); - } - } - } - - for (dgInt32 z = 0; z < gridDimension.m_gridSizeZ; z++) { - for (dgInt32 y = 0; y < gridDimension.m_gridSizeY - 1; y++) { - for (dgInt32 x = 0; x < gridDimension.m_gridSizeX; x++) { - dgTetrahedra tetra; - tetra[0] = ((z * gridDimension.m_gridSizeY + (y + 0)) * gridDimension.m_gridSizeX) + x; - tetra[1] = ((z * gridDimension.m_gridSizeY + (y + 1)) * gridDimension.m_gridSizeX) + x; - tetra[2] = base + (((z + 1) * (gridDimension.m_gridSizeY + 1) + y + 1) * (gridDimension.m_gridSizeX + 1)) + x + 0; - tetra[3] = base + (((z + 1) * (gridDimension.m_gridSizeY + 1) + y + 1) * (gridDimension.m_gridSizeX + 1)) + x + 1; - AddTetra(graph, tetra, vertexSigns, closePoint); - - tetra[0] = ((z * gridDimension.m_gridSizeY + (y + 0)) * gridDimension.m_gridSizeX) + x; - tetra[1] = ((z * gridDimension.m_gridSizeY + (y + 1)) * gridDimension.m_gridSizeX) + x; - tetra[3] = base + (((z + 0) * (gridDimension.m_gridSizeY + 1) + y + 1) * (gridDimension.m_gridSizeX + 1)) + x + 0; - tetra[2] = base + (((z + 0) * (gridDimension.m_gridSizeY + 1) + y + 1) * (gridDimension.m_gridSizeX + 1)) + x + 1; - AddTetra(graph, tetra, vertexSigns, closePoint); - } - } - } -*/ - } - - dgFloat64 CalculateVolume(const dgTetrahedra& tetra) const - { - const dgBigVector& p0 = m_points[tetra[0]]; - const dgBigVector& p1 = m_points[tetra[1]]; - const dgBigVector& p2 = m_points[tetra[2]]; - const dgBigVector& p3 = m_points[tetra[3]]; - dgBigVector p10(p1 - p0); - dgBigVector p20(p2 - p0); - dgBigVector p30(p3 - p0); - return p10.DotProduct3(p20.CrossProduct(p30)); - } - - dgArray<dgBigVector> m_points; - dgArray<dgTetrahedra> m_tetraList; - dgInt32 m_pointCount; - dgInt32 m_tetraCount; -}; - -void dgMeshEffect::LoadOffMesh(const char* const fileName) -{ - class ParceOFF - { - public: - enum Token - { - m_off, - m_value, - m_end, - }; - - ParceOFF(FILE* const file) - :m_file(file) - { - } - - Token GetToken(char* const buffer) const - { - while (!feof(m_file) && fscanf(m_file, "%s", buffer)) { - if (buffer[0] == '#') { - SkipLine(); - } else { - if (!_stricmp(buffer, "OFF")) { - return m_off; - } - return m_value; - } - } - return m_end; - } - - char* SkipLine() const - { - char tmp[1024]; - return fgets(tmp, sizeof (tmp), m_file); - } - - dgInt32 GetInteger() const - { - char buffer[1024]; - GetToken(buffer); - return atoi(buffer); - } - - dgFloat64 GetFloat() const - { - char buffer[1024]; - GetToken(buffer); - return atof(buffer); - } - - FILE* m_file; - }; - - FILE* const file = fopen(fileName, "rb"); - if (file) { - ParceOFF parcel(file); - - dgInt32 vertexCount = 0; - dgInt32 faceCount = 0; - //dgInt32 edgeCount = 0; - - char buffer[1024]; - bool stillData = true; - while (stillData) { - ParceOFF::Token token = parcel.GetToken(buffer); - switch (token) - { - case ParceOFF::m_off: - { - vertexCount = parcel.GetInteger(); - faceCount = parcel.GetInteger(); - // edgeCount = parcel.GetInteger(); - parcel.SkipLine(); - - dgArray<dgBigVector> points(GetAllocator()); - for (dgInt32 i = 0; i < vertexCount; i++) { - dgFloat64 x = parcel.GetFloat(); - dgFloat64 y = parcel.GetFloat(); - dgFloat64 z = parcel.GetFloat(); - dgBigVector p(x, y, z, dgFloat32(0.0f)); - points[i] = p; - } - - dgArray<dgInt32> indexList(GetAllocator()); - dgArray<dgInt32> faceVertex(GetAllocator()); - dgInt32 index = 0; - for (dgInt32 i = 0; i < faceCount; i++) { - const dgInt32 faceVertexCount = parcel.GetInteger(); - faceVertex[i] = faceVertexCount; - for (dgInt32 j = 0; j < faceVertexCount; j++) { - indexList[index] = parcel.GetInteger(); - index++; - } - parcel.SkipLine(); - } - - dgMeshVertexFormat vertexFormat; - vertexFormat.m_faceCount = faceCount; - vertexFormat.m_faceIndexCount = &faceVertex[0]; - - vertexFormat.m_vertex.m_data = &points[0].m_x; - vertexFormat.m_vertex.m_strideInBytes = sizeof (dgBigVector); - vertexFormat.m_vertex.m_indexList = &indexList[0]; - BuildFromIndexList(&vertexFormat); - - CalculateNormals(30.0f * dgDegreeToRad); - stillData = false; - break; - } - - default:; - } - } - - fclose(file); - } -} - -void dgMeshEffect::LoadTetraMesh (const char* const filename) -{ - FILE* const file = fopen(filename, "rb"); - if (file) { - dgInt32 vertexCount; - size_t ret = fscanf(file, "%d", &vertexCount); - dgArray<dgBigVector> points(GetAllocator()); - for (dgInt32 i = 0; i < vertexCount; i ++) { - float x; - float y; - float z; - ret = fscanf(file, "%f %f %f", &x, &y, &z); - points[i] = dgBigVector (x, y, z, dgFloat32 (0.0f)); - } - - BeginBuild(); - dgInt32 tetras; - ret = fscanf(file, "%d", &tetras); - dgMemoryAllocator* const allocator = GetAllocator(); - for (dgInt32 layers = 0; layers < tetras; layers ++) { - dgInt32 tetra[4]; - ret = fscanf(file, "%d %d %d %d", &tetra[0], &tetra[1], &tetra[2], &tetra[3]); - ret = 0; - dgBigVector pointArray[4]; - for (dgInt32 i = 0; i < 4; i++) { - dgInt32 index = tetra[i]; - pointArray[i] = points[index]; - } - - dgMeshEffect convexMesh(allocator, &pointArray[0].m_x, 4, sizeof (dgBigVector), dgFloat64(0.0f)); - - dgAssert(convexMesh.GetCount()); - convexMesh.CalculateNormals(dgFloat32(30.0f * dgDegreeToRad)); - for (dgInt32 i = 0; i < convexMesh.m_points.m_vertex.m_count; i++) { - convexMesh.m_points.m_layers[i] = layers; - } - MergeFaces(&convexMesh); - } - EndBuild(dgFloat64(1.0e-8f), false); - fclose(file); - } -} - -dgMeshEffect* dgMeshEffect::CreateVoronoiConvexDecomposition (dgMemoryAllocator* const allocator, dgInt32 pointCount, dgInt32 pointStrideInBytes, const dgFloat32* const pointCloud, dgInt32 materialId, const dgMatrix& textureProjectionMatrix) -{ - dgStack<dgBigVector> buffer(pointCount + 16); - dgBigVector* const pool = &buffer[0]; - dgInt32 count = 0; - dgFloat64 quantizeFactor = dgFloat64 (16.0f); - dgFloat64 invQuantizeFactor = dgFloat64 (1.0f) / quantizeFactor; - dgInt32 stride = pointStrideInBytes / sizeof (dgFloat32); - - dgBigVector pMin (dgFloat32 (1.0e10f), dgFloat32 (1.0e10f), dgFloat32 (1.0e10f), dgFloat32 (0.0f)); - dgBigVector pMax (dgFloat32 (-1.0e10f), dgFloat32 (-1.0e10f), dgFloat32 (-1.0e10f), dgFloat32 (0.0f)); - for (dgInt32 i = 0; i < pointCount; i ++) { - dgFloat64 x = pointCloud[i * stride + 0]; - dgFloat64 y = pointCloud[i * stride + 1]; - dgFloat64 z = pointCloud[i * stride + 2]; - x = floor (x * quantizeFactor) * invQuantizeFactor; - y = floor (y * quantizeFactor) * invQuantizeFactor; - z = floor (z * quantizeFactor) * invQuantizeFactor; - dgBigVector p (x, y, z, dgFloat64 (0.0f)); - pMin = dgBigVector (dgMin (x, pMin.m_x), dgMin (y, pMin.m_y), dgMin (z, pMin.m_z), dgFloat64 (0.0f)); - pMax = dgBigVector (dgMax (x, pMax.m_x), dgMax (y, pMax.m_y), dgMax (z, pMax.m_z), dgFloat64 (0.0f)); - pool[count] = p; - count ++; - } - // add the bbox as a barrier - pool[count + 0] = dgBigVector ( pMin.m_x, pMin.m_y, pMin.m_z, dgFloat64 (0.0f)); - pool[count + 1] = dgBigVector ( pMax.m_x, pMin.m_y, pMin.m_z, dgFloat64 (0.0f)); - pool[count + 2] = dgBigVector ( pMin.m_x, pMax.m_y, pMin.m_z, dgFloat64 (0.0f)); - pool[count + 3] = dgBigVector ( pMax.m_x, pMax.m_y, pMin.m_z, dgFloat64 (0.0f)); - pool[count + 4] = dgBigVector ( pMin.m_x, pMin.m_y, pMax.m_z, dgFloat64 (0.0f)); - pool[count + 5] = dgBigVector ( pMax.m_x, pMin.m_y, pMax.m_z, dgFloat64 (0.0f)); - pool[count + 6] = dgBigVector ( pMin.m_x, pMax.m_y, pMax.m_z, dgFloat64 (0.0f)); - pool[count + 7] = dgBigVector ( pMax.m_x, pMax.m_y, pMax.m_z, dgFloat64 (0.0f)); - count += 8; - - dgStack<dgInt32> indexList(count); - count = dgVertexListToIndexList(&pool[0].m_x, sizeof (dgBigVector), 3, count, &indexList[0], dgFloat64 (5.0e-2f)); - dgAssert (count >= 8); - - dgFloat64 maxSize = dgMax(pMax.m_x - pMin.m_x, pMax.m_y - pMin.m_y, pMax.m_z - pMin.m_z); - pMin -= dgBigVector (maxSize, maxSize, maxSize, dgFloat64 (0.0f)); - pMax += dgBigVector (maxSize, maxSize, maxSize, dgFloat64 (0.0f)); - - // add the a guard zone, so that we do no have to clip - dgInt32 guardVertexKey = count; - pool[count + 0] = dgBigVector ( pMin.m_x, pMin.m_y, pMin.m_z, dgFloat64 (0.0f)); - pool[count + 1] = dgBigVector ( pMax.m_x, pMin.m_y, pMin.m_z, dgFloat64 (0.0f)); - pool[count + 2] = dgBigVector ( pMin.m_x, pMax.m_y, pMin.m_z, dgFloat64 (0.0f)); - pool[count + 3] = dgBigVector ( pMax.m_x, pMax.m_y, pMin.m_z, dgFloat64 (0.0f)); - pool[count + 4] = dgBigVector ( pMin.m_x, pMin.m_y, pMax.m_z, dgFloat64 (0.0f)); - pool[count + 5] = dgBigVector ( pMax.m_x, pMin.m_y, pMax.m_z, dgFloat64 (0.0f)); - pool[count + 6] = dgBigVector ( pMin.m_x, pMax.m_y, pMax.m_z, dgFloat64 (0.0f)); - pool[count + 7] = dgBigVector ( pMax.m_x, pMax.m_y, pMax.m_z, dgFloat64 (0.0f)); - count += 8; - - dgDelaunayTetrahedralization delaunayTetrahedras (allocator, &pool[0].m_x, count, sizeof (dgBigVector), dgFloat32 (0.0f)); - delaunayTetrahedras.RemoveUpperHull (); - -// delaunayTetrahedras.Save("xxx0.txt"); - dgInt32 tetraCount = delaunayTetrahedras.GetCount(); - dgStack<dgBigVector> voronoiPoints(tetraCount + 32); - dgStack<dgDelaunayTetrahedralization::dgListNode*> tetradrumNode(tetraCount); - dgTree<dgList<dgInt32>, dgInt32> delaunayNodes (allocator); - - dgInt32 index = 0; - const dgConvexHull4dVector* const convexHulPoints = delaunayTetrahedras.GetHullVertexArray(); - for (dgDelaunayTetrahedralization::dgListNode* node = delaunayTetrahedras.GetFirst(); node; node = node->GetNext()) { - dgConvexHull4dTetraherum& tetra = node->GetInfo(); - voronoiPoints[index] = tetra.CircumSphereCenter (convexHulPoints); - tetradrumNode[index] = node; - - for (dgInt32 i = 0; i < 4; i ++) { - dgTree<dgList<dgInt32>, dgInt32>::dgTreeNode* header = delaunayNodes.Find(tetra.m_faces[0].m_index[i]); - if (!header) { - dgList<dgInt32> list (allocator); - header = delaunayNodes.Insert(list, tetra.m_faces[0].m_index[i]); - } - header->GetInfo().Append (index); - } - index ++; - } - - const dgFloat32 normalAngleInRadians = dgFloat32 (30.0f * dgDegreeToRad); - dgMeshEffect* const voronoiPartition = new (allocator) dgMeshEffect (allocator); - voronoiPartition->BeginBuild(); - dgInt32 layer = 0; - dgTree<dgList<dgInt32>, dgInt32>::Iterator iter (delaunayNodes); - for (iter.Begin(); iter; iter ++) { - dgTree<dgList<dgInt32>, dgInt32>::dgTreeNode* const nodeNode = iter.GetNode(); - const dgList<dgInt32>& list = nodeNode->GetInfo(); - dgInt32 key = nodeNode->GetKey(); - - if (key < guardVertexKey) { - dgBigVector pointArray[512]; - dgInt32 indexArray[512]; - - dgInt32 count1 = 0; - for (dgList<dgInt32>::dgListNode* ptr = list.GetFirst(); ptr; ptr = ptr->GetNext()) { - dgInt32 i = ptr->GetInfo(); - pointArray[count1] = voronoiPoints[i]; - count1 ++; - dgAssert (count1 < dgInt32 (sizeof (pointArray) / sizeof (pointArray[0]))); - } - - count1 = dgVertexListToIndexList(&pointArray[0].m_x, sizeof (dgBigVector), 3, count1, &indexArray[0], dgFloat64 (1.0e-3f)); - if (count1 >= 4) { - dgMeshEffect convexMesh (allocator, &pointArray[0].m_x, count1, sizeof (dgBigVector), dgFloat64 (0.0f)); - if (convexMesh.GetCount()) { - convexMesh.CalculateNormals(normalAngleInRadians); - convexMesh.UniformBoxMapping (materialId, textureProjectionMatrix); - for (dgInt32 i = 0; i < convexMesh.m_points.m_vertex.m_count; i ++) { - convexMesh.m_points.m_layers[i] = layer; - } - voronoiPartition->MergeFaces(&convexMesh); - layer ++; - } - } - } - } - voronoiPartition->EndBuild(dgFloat64 (1.0e-8f), false); - //voronoiPartition->SaveOFF("xxx0.off"); - return voronoiPartition; -} - - -dgMeshEffect* dgMeshEffect::CreateTetrahedraIsoSurface() const -{ -/* -dgMeshEffect xxxx (GetAllocator()); -xxxx.BeginBuild(); - -xxxx.BeginBuildFace (); -xxxx.AddPoint (0.0, 0.0, -1.0); -xxxx.AddLayer (0); - -xxxx.AddPoint (1.0, 0.0, 0.0); -xxxx.AddLayer (0); - -xxxx.AddPoint (0.0, 0.0, 1.0); -xxxx.AddLayer (0); -xxxx.EndBuildFace (); - -xxxx.BeginBuildFace (); -xxxx.AddPoint (0.0, 0.0, -1.0); -xxxx.AddLayer (1); - -xxxx.AddPoint (0.0, 0.0, 1.0); -xxxx.AddLayer (1); - -xxxx.AddPoint (-1.0, 0.0, 0.0); -xxxx.AddLayer (1); - -xxxx.EndBuildFace (); -xxxx.EndBuild(dgFloat64(1.0e-8f), false); -*/ - - - dgTetraIsoSufaceStuffing tetraIsoStuffing (this, dgFloat64(0.125f)); - - dgMeshEffect* delaunayPartition = NULL; - if (tetraIsoStuffing.m_tetraCount) { - dgMemoryAllocator* const allocator = GetAllocator(); - delaunayPartition = new (allocator) dgMeshEffect (allocator); - delaunayPartition->BeginBuild(); - dgInt32 layer = 0; - dgBigVector pointArray[4]; - for (dgInt32 j = 0; j < tetraIsoStuffing.m_tetraCount; j ++) { - dgTetraIsoSufaceStuffing::dgTetrahedra& tetra = tetraIsoStuffing.m_tetraList[j]; - for (dgInt32 i = 0; i < 4; i ++) { - dgInt32 index = tetra[i]; - pointArray[i] = tetraIsoStuffing.m_points[index]; - } - dgMeshEffect convexMesh(allocator, &pointArray[0].m_x, 4, sizeof (dgBigVector), dgFloat64(0.0f)); - //dgAssert (convexMesh.GetCount()); - //convexMesh.CalculateNormals(dgFloat32 (30.0f * dgDEG2RAD)); - for (dgInt32 i = 0; i < convexMesh.m_points.m_vertex.m_count; i++) { - convexMesh.m_points.m_layers[i] = layer; - } - delaunayPartition->MergeFaces(&convexMesh); - layer++; - } - delaunayPartition->EndBuild(dgFloat64(1.0e-8f), false); - } - - return delaunayPartition; -} - -void dgMeshEffect::CreateTetrahedraLinearBlendSkinWeightsChannel (const dgMeshEffect* const tetrahedraMesh) -{ -dgAssert(0); -/* - dgRayTrataAABBAccelerator accelerator (tetrahedraMesh); - m_points.m_weights.Clear(); - m_points.m_weights.Reserve(m_points.m_vertex.m_count); - - dgBigVector padding (dgFloat64(1.0f / 32.0f)); - for (dgInt32 i = 0; i < m_points.m_weights.m_count; i ++) { - dgBigVector p (m_points.m_vertex[i]); - dgBigVector p0 (p - padding); - dgBigVector p1 (p + padding); - dgList<dgMeshBVH::dgMeshBVHNode*> overlapNodes (GetAllocator()); - accelerator.GetOverlapNodes (overlapNodes, p0, p1); - dgAssert (overlapNodes.GetCount()); - - bool weightFound = false; - for (dgList<dgMeshBVH::dgMeshBVHNode*>::dgListNode* node = overlapNodes.GetFirst(); node; node = node->GetNext()) { - dgEdge* const edge = node->GetInfo()->m_face; - - dgInt32 i0 = edge->m_incidentVertex; - dgInt32 i1 = edge->m_next->m_incidentVertex; - dgInt32 i2 = edge->m_prev->m_incidentVertex; - dgInt32 i3 = edge->m_twin->m_prev->m_incidentVertex; - dgBigVector q0 (tetrahedraMesh->m_points.m_vertex[i0]); - dgBigVector q1 (tetrahedraMesh->m_points.m_vertex[i1]); - dgBigVector q2 (tetrahedraMesh->m_points.m_vertex[i2]); - dgBigVector q3 (tetrahedraMesh->m_points.m_vertex[i3]); - - const dgBigVector e10(q1 - q0); - const dgBigVector e20(q2 - q0); - const dgBigVector e30(q3 - q0); - - dgAssert (e10.DotProduct(e10).GetScalar() > dgFloat32 (0.0f)); - const dgFloat64 d0 = sqrt(e10.DotProduct(e10).GetScalar()); - const dgFloat64 invd0 = dgFloat64(1.0f) / d0; - const dgFloat64 l10 = e20.DotProduct(e10).GetScalar() * invd0; - const dgFloat64 l20 = e30.DotProduct(e10).GetScalar() * invd0; - - dgAssert ((e20.DotProduct(e20).GetScalar() - l10 * l10) > dgFloat32 (0.0f)); - const dgFloat64 desc11 = e20.DotProduct(e20).GetScalar() - l10 * l10; - - const dgFloat64 d1 = sqrt(desc11); - const dgFloat64 invd1 = dgFloat64(1.0f) / d1; - const dgFloat64 l21 = (e30.DotProduct(e20).GetScalar() - l20 * l10) * invd1; - dgAssert (e30.DotProduct(e30).GetScalar() - l20 * l20 - l21 * l21 > dgFloat32 (0.0f)); - const dgFloat64 desc22 = e30.DotProduct(e30).GetScalar() - l20 * l20 - l21 * l21; - - dgBigVector p0Point(p - q0); - const dgFloat64 d2 = sqrt(desc22); - const dgFloat64 invd2 = dgFloat64(1.0f) / d2; - - const dgFloat64 b0 = e10.DotProduct(p0Point).GetScalar(); - const dgFloat64 b1 = e20.DotProduct(p0Point).GetScalar(); - const dgFloat64 b2 = e30.DotProduct(p0Point).GetScalar(); - - dgFloat64 u1 = b0 * invd0; - dgFloat64 u2 = (b1 - l10 * u1) * invd1; - dgFloat64 u3 = (b2 - l20 * u1 - l21 * u2) * invd2; - - u3 = u3 * invd2; - u2 = (u2 - l21 * u3) * invd1; - u1 = (u1 - l10 * u2 - l20 * u3) * invd0; - if ((u1 >= dgFloat64(0.0f)) && (u2 >= dgFloat64(0.0f)) && (u3 >= dgFloat64(0.0f)) && ((u1 + u2 + u3) <= dgFloat64(1.0f))) { - dgBigVector r0 (q0 + e10.Scale(u1) + e20.Scale(u2) + e30.Scale(u3)); - - dgFloat64 u0 = dgFloat64 (1.0f) - u1 - u2 - u3; - dgBigVector r1 (q0.Scale (u0) + q1.Scale (u1) + q2.Scale (u2) + q3.Scale (u3)); - dgWeights& weighSet = m_points.m_weights[i]; - - weighSet.m_controlIndex[0] = i0; - weighSet.m_weightBlends[0] = dgFloat32(u0); - - weighSet.m_controlIndex[1] = i1; - weighSet.m_weightBlends[1] = dgFloat32(u1); - - weighSet.m_controlIndex[2] = i2; - weighSet.m_weightBlends[2] = dgFloat32(u2); - - weighSet.m_controlIndex[3] = i3; - weighSet.m_weightBlends[3] = dgFloat32(u3); - - weightFound = true; - break; - } - } - dgAssert (weightFound); - if (!weightFound) { - dgTrace (("%d %f %f %f\n", i, p.m_x, p.m_y, p.m_z)); - } - - overlapNodes.RemoveAll(); - } -*/ -} diff --git a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect3.cpp b/thirdparty/src/newton/dgMeshUtil/dgMeshEffect3.cpp deleted file mode 100644 index b2031e70b..000000000 --- a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect3.cpp +++ /dev/null @@ -1,1371 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgMeshEffect.h" -#include "dgCollisionConvexHull.h" - - - -// based of the paper Hierarchical Approximate Convex Decomposition by Khaled Mamou -// with his permission to adapt his algorithm to be more efficient. -// also making some addition to his heuristic for better convex clusters selections -// for the details http://kmamou.blogspot.com/ - - -#define DG_CONCAVITY_SCALE dgFloat64 (100.0f) -#define DG_CONCAVITY_PERIMETER_HANDICAP dgFloat64 (0.5f) - -class dgHACDEdge -{ - public: - dgHACDEdge () - :m_mark(0) - ,m_proxyListNode(NULL) - ,m_backFaceHandicap(dgFloat64 (1.0)) - { - } - ~dgHACDEdge () - { - } - - dgInt32 m_mark; - void* m_proxyListNode; - dgFloat64 m_backFaceHandicap; -}; - -class dgHACDClusterFace -{ - public: - dgHACDClusterFace() - :m_edge(NULL) - ,m_area(dgFloat64(0.0f)) - { - } - ~dgHACDClusterFace() - { - } - - dgEdge* m_edge; - dgFloat64 m_area; - dgBigVector m_normal; -}; - - -class dgHACDCluster: public dgList<dgHACDClusterFace> -{ - public: - dgHACDCluster () - :dgList<dgHACDClusterFace>(NULL) - ,m_color(0) - ,m_hierachicalClusterIndex(0) - ,m_area(dgFloat64 (0.0f)) - ,m_concavity(dgFloat64 (0.0f)) - { - } - - bool IsCoplanar(const dgBigPlane& plane, const dgMeshEffect& mesh, dgFloat64 tolerance) const - { - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - for (dgListNode* node = GetFirst(); node; node = node->GetNext()) { - const dgHACDClusterFace& info = node->GetInfo(); - dgEdge* ptr = info.m_edge; - do { - const dgBigVector& p = points[ptr->m_incidentVertex]; - dgFloat64 dist = fabs(plane.Evalue(p)); - if (dist > tolerance) { - return false; - } - ptr = ptr->m_next; - } while (ptr != info.m_edge); - } - return true; - } - - - dgInt32 m_color; - dgInt32 m_hierachicalClusterIndex; - dgFloat64 m_area; - dgFloat64 m_concavity; -}; - - -class dgHACDClusterGraph: public dgGraph<dgHACDCluster, dgHACDEdge> -{ - public: - class dgHACDConveHull: public dgConvexHull3d - { - class dgConvexHullRayCastData - { - public: - dgFloat64 m_normalProjection; - dgConvexHull3DFace* m_face; - }; - - public: - dgHACDConveHull (const dgHACDConveHull& hull) - :dgConvexHull3d(hull) - ,m_mark(1) - { - } - - dgHACDConveHull (dgMemoryAllocator* const allocator, const dgBigVector* const points, dgInt32 count) - :dgConvexHull3d(allocator, &points[0].m_x, sizeof (dgBigVector),count, dgFloat64 (0.0f)) - ,m_mark(1) - { - } - - - dgFloat64 CalculateTriangleConcavity(const dgBigVector& normal, dgInt32 i0, dgInt32 i1, dgInt32 i2, const dgBigVector* const points) - { - dgUnsigned32 head = 1; - dgUnsigned32 tail = 0; - dgBigVector pool[1<<8][3]; - - pool[0][0] = points[i0]; - pool[0][1] = points[i1]; - pool[0][2] = points[i2]; - - const dgFloat64 rayLength = dgFloat64(4.0f) * GetDiagonal(); - const dgBigVector step(normal.Scale(rayLength)); - - dgFloat64 concavity = dgFloat32(0.0f); - dgFloat64 minArea = dgFloat32(0.125f); - dgFloat64 minArea2 = minArea * minArea * 0.5f; - - dgInt32 maxCount = 4; - dgUnsigned32 mask = (sizeof (pool) / (3 * sizeof (pool[0][0]))) - 1; - - dgConvexHull3DFace* firstGuess = NULL; - while ((tail != head) && (maxCount >= 0)) { - maxCount --; - dgBigVector p0(pool[tail][0]); - dgBigVector p1(pool[tail][1]); - dgBigVector p2(pool[tail][2]); - p0.m_w = dgFloat32 (0.0f); - p1.m_w = dgFloat32 (0.0f); - p2.m_w = dgFloat32 (0.0f); - - tail = (tail + 1) & mask; - - dgBigVector q1((p0 + p1 + p2).Scale(dgFloat64(1.0f / 3.0f))); - dgBigVector q0(q1 + step); - - dgFloat64 param = RayCast(q0, q1, &firstGuess); - if (param > dgFloat64(1.0f)) { - param = dgFloat64(1.0f); - } - dgBigVector dq(step.Scale(dgFloat32(1.0f) - param)); - dgAssert(dq.m_w == dgFloat32(0.0f)); - dgFloat64 lenght2 = sqrt (dq.DotProduct(dq).GetScalar()); - if (lenght2 > concavity) { - concavity = lenght2; - } - - if (((head + 1) & mask) != tail) { - dgBigVector edge10(p1 - p0); - dgBigVector edge20(p2 - p0); - dgBigVector n(edge10.CrossProduct(edge20)); - dgAssert(n.m_w == dgFloat32(0.0f)); - dgFloat64 area2 = n.DotProduct(n).GetScalar(); - if (area2 > minArea2) { - dgBigVector p01((p0 + p1).Scale(dgFloat64(0.5f))); - dgBigVector p12((p1 + p2).Scale(dgFloat64(0.5f))); - dgBigVector p20((p2 + p0).Scale(dgFloat64(0.5f))); - - pool[head][0] = p0; - pool[head][1] = p01; - pool[head][2] = p20; - head = (head + 1) & mask; - - if (((head + 1) & mask) != tail) { - pool[head][0] = p1; - pool[head][1] = p12; - pool[head][2] = p01; - head = (head + 1) & mask; - - if (((head + 1) & mask) != tail) { - pool[head][0] = p2; - pool[head][1] = p20; - pool[head][2] = p12; - head = (head + 1) & mask; - } - } - } - } - } - return concavity; - } - - - - dgFloat64 FaceRayCast (const dgConvexHull3DFace* const face, const dgBigVector& origin, const dgBigVector& dist, dgFloat64& normalProjection) const - { - dgInt32 i0 = face->m_index[0]; - dgInt32 i1 = face->m_index[1]; - dgInt32 i2 = face->m_index[2]; - - const dgBigVector& p0 = m_points[i0]; - dgBigVector normal ((m_points[i1] - p0).CrossProduct(m_points[i2] - p0)); - - //dgFloat64 N = (origin - p0) % normal; - dgAssert(normal.m_w == dgFloat32(0.0f)); - dgFloat64 N = normal.DotProduct(origin - p0).GetScalar(); - dgFloat64 D = normal.DotProduct(dist).GetScalar(); - - if (fabs(D) < dgFloat64 (1.0e-16f)) { // - normalProjection = dgFloat32 (0.0); - if (N > dgFloat64 (0.0f)) { - return dgFloat32 (-1.0e30); - } else { - - return dgFloat32 (1.0e30); - } - } - normalProjection = D; - return - N / D; - } - - dgConvexHull3DFace* ClosestFaceVertexToPoint (const dgBigVector& point) - { - // note, for this function to be effective point should be an already close point to the Hull. - // for example casting the point to the OBB or the AABB of the full is a good first guess. - dgConvexHull3DFace* closestFace = &GetFirst()->GetInfo(); - dgInt8 pool[256 * (sizeof (dgConvexHull3DFace*) + sizeof (dgFloat64))]; - dgUpHeap<dgConvexHull3DFace*,dgFloat64> heap (pool, sizeof (pool)); - - for (dgInt32 i = 0; i < 3; i ++) { - dgBigVector dist (m_points[closestFace->m_index[i]] - point); - dgAssert(dist.m_w == dgFloat32(0.0f)); - heap.Push(closestFace, dist.DotProduct(dist).GetScalar()); - } - - m_mark ++; - dgFloat64 minDist = heap.Value(); - while (heap.GetCount()) { - dgConvexHull3DFace* const face = heap[0]; - if (heap.Value() < minDist) { - minDist = heap.Value(); - closestFace = face; - } - heap.Pop(); - //face->m_mark = m_mark; - face->SetMark(m_mark); - for (dgInt32 i = 0; i < 3; i ++) { - dgConvexHull3DFace* twin = &face->GetTwin(i)->GetInfo(); - if (twin->GetMark() != m_mark) { - dgBigVector dist (m_points[twin->m_index[i]] - point); - // use hysteresis to prevent stops at a local minimal, but at the same time fast descend - dgAssert(dist.m_w == dgFloat32(0.0f)); - dgFloat64 dist2 = dist.DotProduct(dist).GetScalar(); - if (dist2 < (minDist * dgFloat64 (1.001f))) { - heap.Push(twin, dist2); - } - } - } - } - - return closestFace; - } - - - // this version have input sensitive complexity (approximately log2) - // when casting parallel rays and using the last face as initial guess this version has const time complexity - dgFloat64 RayCast (const dgBigVector& localP0, const dgBigVector& localP1, dgConvexHull3DFace** firstFaceGuess) - { - dgConvexHull3DFace* face = &GetFirst()->GetInfo(); - if (firstFaceGuess && *firstFaceGuess) { - face = *firstFaceGuess; - } else { - if (GetCount() > 32) { - dgVector q0 (localP0); - dgVector q1 (localP1); - if (dgRayBoxClip (q0, q1, m_aabbP0, m_aabbP1)) { - face = ClosestFaceVertexToPoint (q0); - } - } - } - - m_mark ++; - face->SetMark (m_mark); - dgInt8 pool[256 * (sizeof (dgConvexHullRayCastData) + sizeof (dgFloat64))]; - dgDownHeap<dgConvexHullRayCastData,dgFloat64> heap (pool, sizeof (pool)); - - dgFloat64 t0 = dgFloat64 (-1.0e20); //for the maximum entering segment parameter; - dgFloat64 t1 = dgFloat64 ( 1.0e20); //for the minimum leaving segment parameter; - dgBigVector dS (localP1 - localP0); // is the segment direction vector; - dgConvexHullRayCastData data; - data.m_face = face; - dgFloat64 t = FaceRayCast (face, localP0, dS, data.m_normalProjection); - if (data.m_normalProjection >= dgFloat32 (0.0f)) { - t = dgFloat64 (-1.0e30); - } - - heap.Push (data, t); - while (heap.GetCount()) { - dgConvexHullRayCastData data1 (heap[0]); - t = heap.Value(); - dgConvexHull3DFace* const face1 = data1.m_face; - dgFloat64 normalDistProjection = data1.m_normalProjection; - heap.Pop(); - bool foundThisBestFace = true; - if (normalDistProjection < dgFloat64 (0.0f)) { - if (t > t0) { - t0 = t; - } - if (t0 > t1) { - return dgFloat64 (1.2f); - } - } else { - foundThisBestFace = false; - } - - for (dgInt32 i = 0; i < 3; i ++) { - dgConvexHull3DFace* const face2 = &face1->GetTwin(i)->GetInfo(); - - if (face2->GetMark() != m_mark) { - face2->SetMark (m_mark); - dgConvexHullRayCastData data2; - data2.m_face = face2; - t = FaceRayCast (face2, localP0, dS, data2.m_normalProjection); - if (data2.m_normalProjection >= dgFloat32 (0.0)) { - t = dgFloat64 (-1.0e30); - } else if (t > t0) { - foundThisBestFace = false; - } else if (fabs (t - t0) < dgFloat64 (1.0e-10f)) { - return dgConvexHull3d::RayCast (localP0, localP1); - } - if ((heap.GetCount() + 2)>= heap.GetMaxCount()) { - // remove t values that are old and way outside interval [0.0, 1.0] - for (dgInt32 j = heap.GetCount() - 1; j >= 0; j--) { - dgFloat64 val = heap.Value(j); - if ((val < dgFloat64 (-100.0f)) || (val > dgFloat64 (100.0f))) { - heap.Remove(j); - } - } - } - heap.Push (data2, t); - } - } - if (foundThisBestFace) { - if ((t0 >= dgFloat64 (0.0f)) && (t0 <= dgFloat64 (1.0f))) { - if (firstFaceGuess) { - *firstFaceGuess = face1; - } - return t0; - } - break; - } - } - return dgFloat64 (1.2f); - } - - - dgInt32 m_mark; - }; - - class dgHACDConvacityLookAheadTree - { - public: - DG_CLASS_ALLOCATOR(allocator) - - dgHACDConvacityLookAheadTree (dgMemoryAllocator* const allocator, dgEdge* const face, dgFloat64 concavity) - :m_concavity(concavity) - ,m_faceList (allocator) - ,m_left (NULL) - ,m_right (NULL) - { - m_faceList.Append(face); - } - - - dgHACDConvacityLookAheadTree (dgMemoryAllocator* const allocator, dgHACDConvacityLookAheadTree* const leftChild, dgHACDConvacityLookAheadTree* const rightChild, dgFloat64 concavity) - :m_concavity(concavity) - ,m_faceList (allocator) - ,m_left (leftChild) - ,m_right (rightChild) - { - dgAssert (leftChild); - dgAssert (rightChild); - - dgFloat64 concavityTest = m_concavity - dgFloat64 (1.0e-5f); - if ((((m_left->m_faceList.GetCount() == 1) || (m_right->m_faceList.GetCount() == 1))) || - ((concavityTest <= m_left->m_concavity) && (concavityTest <= m_right->m_concavity))) { - //The the parent has lower concavity this mean that the two do no add more detail, - //the can be deleted and replaced the parent node - // for example the two children can be two convex strips that are part of a larger convex piece - // but each part has a non zero concavity, while the convex part has a lower concavity - m_faceList.Merge (m_left->m_faceList); - m_faceList.Merge (m_right->m_faceList); - - delete m_left; - delete m_right; - m_left = NULL; - m_right = NULL; - } else { - for (dgList<dgEdge*>::dgListNode* node = m_left->m_faceList.GetFirst(); node; node = node->GetNext()) { - m_faceList.Append(node->GetInfo()); - } - for (dgList<dgEdge*>::dgListNode* node = m_right->m_faceList.GetFirst(); node; node = node->GetNext()) { - m_faceList.Append(node->GetInfo()); - } - } - } - - ~dgHACDConvacityLookAheadTree () - { - if (m_left) { - dgAssert (m_right); - delete m_left; - delete m_right; - } - } - - dgInt32 GetNodesCount () const - { - dgInt32 count = 0; - dgInt32 stack = 1; - const dgHACDConvacityLookAheadTree* pool[1024]; - pool[0] = this; - while (stack) { - stack --; - count ++; - const dgHACDConvacityLookAheadTree* const root = pool[stack]; - if (root->m_left) { - dgAssert (root->m_right); - pool[stack] = root->m_left; - stack ++; - dgAssert (stack < sizeof (pool)/sizeof (pool[0])); - pool[stack] = root->m_right; - stack ++; - dgAssert (stack < sizeof (pool)/sizeof (pool[0])); - } - } - return count; - } - - void ReduceByCount (dgInt32 count, dgDownHeap<dgHACDConvacityLookAheadTree*, dgFloat64>& approximation) - { - if (count < 1) { - count = 1; - } - - approximation.Flush(); - dgHACDConvacityLookAheadTree* tmp = this; - approximation.Push(tmp, m_concavity); - while ((approximation.GetCount() < count) && (approximation.Value() >= dgFloat32 (0.0f))) { - dgHACDConvacityLookAheadTree* worseCluster = approximation[0]; - dgFloat64 concavity = approximation.Value(); - if (!worseCluster->m_left && (concavity >= dgFloat32 (0.0f))) { - dgAssert (!worseCluster->m_right); - approximation.Pop(); - approximation.Push(worseCluster, concavity - dgFloat64 (1.0e10f)); - } else { - dgAssert (worseCluster->m_left); - dgAssert (worseCluster->m_right); - approximation.Pop(); - approximation.Push(worseCluster->m_left, worseCluster->m_left->m_concavity); - approximation.Push(worseCluster->m_right, worseCluster->m_right->m_concavity); - } - } - } - - - void ReduceByConcavity (dgFloat64 concavity, dgDownHeap<dgHACDConvacityLookAheadTree*, dgFloat64>& approximation) - { - approximation.Flush(); - dgHACDConvacityLookAheadTree* tmp = this; - - approximation.Push(tmp, m_concavity); - while (approximation.Value() > concavity) { - dgHACDConvacityLookAheadTree* worseCluster = approximation[0]; - if (!worseCluster->m_left && approximation.Value() >= dgFloat32 (0.0f)) { - approximation.Pop(); - approximation.Push(worseCluster, dgFloat32 (-1.0f)); - } else { - dgAssert (worseCluster->m_left); - dgAssert (worseCluster->m_right); - approximation.Pop(); - approximation.Push(worseCluster->m_left, worseCluster->m_left->m_concavity); - approximation.Push(worseCluster->m_right, worseCluster->m_right->m_concavity); - } - } - } - - dgFloat64 m_concavity; - dgList<dgEdge*> m_faceList; - dgHACDConvacityLookAheadTree* m_left; - dgHACDConvacityLookAheadTree* m_right; - }; - - class dgPairProxy - { - public: - dgPairProxy() - :m_nodeA(NULL) - ,m_nodeB(NULL) - ,m_hierachicalClusterIndexA(0) - ,m_hierachicalClusterIndexB(0) - ,m_area(dgFloat64(0.0f)) - { - } - - ~dgPairProxy() - { - } - - dgListNode* m_nodeA; - dgListNode* m_nodeB; - dgInt32 m_hierachicalClusterIndexA; - dgInt32 m_hierachicalClusterIndexB; - dgFloat64 m_area; - dgFloat64 m_distanceConcavity; - }; - - - class dgBackFaceFinder: public dgMeshEffect::dgMeshBVH - { - public: - dgBackFaceFinder(dgMeshEffect* const mesh, dgHACDClusterGraph* const graph) - :dgMeshEffect::dgMeshBVH(mesh) - ,m_clusterA(NULL) - ,m_graph(graph) - { - for (dgListNode* clusterNode = graph->GetFirst(); clusterNode; clusterNode = clusterNode->GetNext()) { - dgHACDCluster& cluster = clusterNode->GetInfo().m_nodeData; - dgHACDClusterFace& face = cluster.GetFirst()->GetInfo(); - dgEdge* const edge = face.m_edge; - AddFaceNode(edge, &cluster); - } - } - - //dgFloat64 RayFaceIntersect (const dgMeshBVHNode* const face, const dgBigVector& p0, const dgBigVector& p1, bool doublesided) const - dgFloat64 RayFaceIntersect (const dgMeshBVHNode* const face, const dgBigVector& p0, const dgBigVector& p1, void* const userData) const - { - dgHACDCluster* const clusterFace = (dgHACDCluster*) face->m_userData; - - dgFloat64 param = dgFloat32 (100.0f); - if (clusterFace->m_color != m_clusterA->m_color) { - param = dgMeshEffect::dgMeshBVH::RayFaceIntersect (face, p1, p0, NULL); - if ((param >= dgFloat32 (0.0f)) && (param <= dgFloat32(1.0f))) { - param = dgFloat32 (1.0f) - param; - } - } - return param; - } - - void CastBackFace (dgListNode* const clusterNodeA, const dgBigVector& p0, const dgBigVector& p1, const dgBigVector& p2, dgFloat32 distanceThreshold) - { - dgAssert(0); - /* - dgBigVector origin ((p0 + p1 + p2).Scale (dgFloat32 (1.0f/3.0f))); - - dgFloat32 rayDistance = distanceThreshold * dgFloat32 (2.0f); - - - m_clusterA = &clusterNodeA->GetInfo().m_nodeData; - dgHACDClusterFace& faceA = m_clusterA->GetFirst()->GetInfo(); - dgBigVector end (origin - faceA.m_normal.Scale (rayDistance)); - - dgFloat64 paramOut; - //dgMeshBVHNode* const node = FaceRayCast (origin, end, paramOut, false); - - dgMeshBVHNode* node; - FaceRayCast (origin, end, paramOut, &node); - - if (node) { - dgHACDCluster* const clusterB = (dgHACDCluster*) node->m_userData; - dgAssert (clusterB->m_color != m_clusterA->m_color); - dgFloat64 distance = rayDistance * paramOut; - - if (distance < distanceThreshold) { - dgHACDClusterFace& faceB = clusterB->GetFirst()->GetInfo(); - dgEdge* const edgeB = faceB.m_edge; - - - bool isAdjacent = false; - dgEdge* ptrA = faceA.m_edge; - do { - dgEdge* ptrB = edgeB; - do { - if (ptrB->m_twin == ptrA) { - ptrA = faceA.m_edge->m_prev; - isAdjacent = true; - break; - } - ptrB = ptrB->m_next; - } while (ptrB != edgeB); - - ptrA = ptrA->m_next; - } while (ptrA != faceA.m_edge); - - if (!isAdjacent) { - isAdjacent = false; - dgHACDClusterGraph::dgListNode* const clusterNodeB = m_graph->GetNodeFromNodeData (clusterB); - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNode = clusterNodeA->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - if (edgeNode->GetInfo().m_node == clusterNodeB) { - isAdjacent = true; - break; - } - } - - if (!isAdjacent) { - dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* const edgeNodeAB = clusterNodeA->GetInfo().AddEdge (clusterNodeB); - dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* const edgeNodeBA = clusterNodeB->GetInfo().AddEdge (clusterNodeA); - - dgHACDEdge& edgeAB = edgeNodeAB->GetInfo().m_edgeData; - dgHACDEdge& edgeBA = edgeNodeBA->GetInfo().m_edgeData; - edgeAB.m_backFaceHandicap = DG_CONCAVITY_PERIMETER_HANDICAP; - edgeBA.m_backFaceHandicap = DG_CONCAVITY_PERIMETER_HANDICAP; - } - } - } - } -*/ - } - - - dgHACDCluster* m_clusterA; - dgHACDClusterGraph* m_graph; - }; - - dgHACDClusterGraph(dgMeshEffect& mesh, dgFloat32 backFaceDistanceFactor, dgReportProgress reportProgressCallback, void* const reportProgressUserData) - :dgGraph<dgHACDCluster, dgHACDEdge> (mesh.GetAllocator()) - ,m_mark(0) - ,m_faceCount(0) - ,m_vertexMark(0) - ,m_progress(0) - ,m_concavityTreeIndex(0) - ,m_invFaceCount(dgFloat32 (1.0f)) - ,m_diagonal(dgFloat64(1.0f)) - ,m_vertexMarks(NULL) - ,m_vertexPool(NULL) - ,m_proxyList(mesh.GetAllocator()) - ,m_concavityTreeArray(NULL) - ,m_convexProximation(mesh.GetAllocator()) - ,m_priorityHeap (mesh.GetCount() * 2 + 2048, mesh.GetAllocator()) - ,m_reportProgressCallback(reportProgressCallback) - ,m_reportProgressUserData(reportProgressUserData) - { - m_faceCount = mesh.GetTotalFaceCount(); - - dgMemoryAllocator* const allocator = mesh.GetAllocator(); - m_invFaceCount = dgFloat32 (1.0f) / (m_faceCount); - - // init some auxiliary structures - dgInt32 vertexCount = mesh.GetVertexCount(); - m_vertexMarks = (dgInt32*) dgMallocStack(vertexCount * sizeof(dgInt32)); - m_vertexPool = (dgBigVector*) dgMallocStack(vertexCount * sizeof(dgBigVector)); - memset(m_vertexMarks, 0, vertexCount * sizeof(dgInt32)); - - m_concavityTreeIndex = m_faceCount + 1; - m_concavityTreeArray = (dgHACDConvacityLookAheadTree**) dgMallocStack(2 * m_concavityTreeIndex * sizeof(dgHACDConvacityLookAheadTree*)); - memset(m_concavityTreeArray, 0, 2 * m_concavityTreeIndex * sizeof(dgHACDConvacityLookAheadTree*)); - - // scan the mesh and and add a node for each face - dgInt32 color = 1; - dgMeshEffect::Iterator iter(mesh); - - dgInt32 meshMask = mesh.IncLRU(); - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - for (iter.Begin(); iter; iter++) { - dgEdge* const edge = &(*iter); - if ((edge->m_mark != meshMask) && (edge->m_incidentFace > 0)) { - - dgListNode* const clusterNode = AddNode (); - dgHACDCluster& cluster = clusterNode->GetInfo().m_nodeData; - cluster.SetAllocator(mesh.GetAllocator()); - - dgFloat64 perimeter = dgFloat64(0.0f); - dgEdge* ptr = edge; - do { - dgBigVector p1p0(points[ptr->m_incidentVertex] - points[ptr->m_prev->m_incidentVertex]); - dgAssert(p1p0.m_w == dgFloat32(0.0f)); - perimeter += sqrt(p1p0.DotProduct(p1p0).GetScalar()); - ptr->m_incidentFace = color; - ptr->m_userData = dgUnsigned64 (clusterNode); - ptr->m_mark = meshMask; - ptr = ptr->m_next; - } while (ptr != edge); - - dgBigVector normal (mesh.FaceNormal(edge, &points[0][0], sizeof(dgBigVector))); - dgFloat64 mag = sqrt(normal.DotProduct(normal).GetScalar()); - - cluster.m_color = color; - cluster.m_hierachicalClusterIndex = color; - cluster.m_area = dgFloat64(0.5f) * mag; - cluster.m_concavity = CalculateConcavityMetric (dgFloat64 (0.0f), cluster.m_area, perimeter, 1, 0); - - dgHACDClusterFace& face = cluster.Append()->GetInfo(); - face.m_edge = edge; - face.m_area = dgFloat64(0.5f) * mag; - face.m_normal = normal.Scale(dgFloat64(1.0f) / mag); - - m_concavityTreeArray[color] = new (allocator) dgHACDConvacityLookAheadTree (allocator, edge, dgFloat64 (0.0f)); - - color ++; - } - } - - // add all link adjacent faces links - for (dgListNode* clusterNode = GetFirst(); clusterNode; clusterNode = clusterNode->GetNext()) { - - dgHACDCluster& cluster = clusterNode->GetInfo().m_nodeData; - dgHACDClusterFace& face = cluster.GetFirst()->GetInfo(); - dgEdge* const edge = face.m_edge; - dgEdge* ptr = edge; - do { - if (ptr->m_twin->m_incidentFace > 0) { - dgAssert (ptr->m_twin->m_userData); - dgListNode* const twinClusterNode = (dgListNode*) ptr->m_twin->m_userData; - dgAssert (twinClusterNode); - - bool doubleEdge = false; - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNode = clusterNode->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - if (edgeNode->GetInfo().m_node == twinClusterNode) { - doubleEdge = true; - break; - } - } - if (!doubleEdge) { - clusterNode->GetInfo().AddEdge (twinClusterNode); - } - } - ptr = ptr->m_next; - } while (ptr != edge); - } - - Trace(); - dgAssert (0); -/* - // add links to back faces - dgBigVector minAABB; - dgBigVector maxAABB; - mesh.CalculateAABB (minAABB, maxAABB); - maxAABB -= minAABB; - dgAssert(maxAABB.m_w == dgFloat32(0.0f)); - dgFloat32 rayDiagonalLength = dgFloat32 (sqrt (maxAABB.DotProduct(maxAABB).GetScalar())); - m_diagonal = rayDiagonalLength; - - dgBackFaceFinder backFaces(&mesh, this); - dgFloat32 distanceThreshold = rayDiagonalLength * backFaceDistanceFactor; - dgAssert (distanceThreshold >= dgFloat32 (0.0f)); - for (dgListNode* clusterNodeA = GetFirst(); clusterNodeA; clusterNodeA = clusterNodeA->GetNext()) { - - dgHACDCluster& clusterA = clusterNodeA->GetInfo().m_nodeData; - dgHACDClusterFace& faceA = clusterA.GetFirst()->GetInfo(); - dgEdge* const edgeA = faceA.m_edge; - dgEdge* ptr = edgeA; - - dgBigVector p0 (points[ptr->m_incidentVertex]); - dgBigVector p1 (points[ptr->m_next->m_incidentVertex]); - ptr = ptr->m_next->m_next; - do { - dgBigVector p2 (points[ptr->m_incidentVertex]); - dgBigVector p01 ((p0 + p1).Scale (dgFloat32 (0.5f))); - dgBigVector p12 ((p1 + p2).Scale (dgFloat32 (0.5f))); - dgBigVector p20 ((p2 + p0).Scale (dgFloat32 (0.5f))); - - backFaces.CastBackFace (clusterNodeA, p0, p01, p20, distanceThreshold); - backFaces.CastBackFace (clusterNodeA, p1, p12, p01, distanceThreshold); - backFaces.CastBackFace (clusterNodeA, p2, p20, p12, distanceThreshold); - backFaces.CastBackFace (clusterNodeA, p01, p12, p20, distanceThreshold); - - p1 = p2; - ptr = ptr->m_next; - } while (ptr != edgeA); - } -*/ - Trace(); - } - - ~dgHACDClusterGraph () - { - for (dgInt32 i = 0; i < m_faceCount * 2; i ++) { - if (m_concavityTreeArray[i]) { - delete m_concavityTreeArray[i]; - } - } - - dgFreeStack(m_concavityTreeArray); - dgFreeStack(m_vertexPool); - dgFreeStack(m_vertexMarks); - } - - - - - void Trace() const - { -#if 0 - for (dgListNode* clusterNodeA = GetFirst(); clusterNodeA; clusterNodeA = clusterNodeA->GetNext()) { - dgHACDCluster& clusterA = clusterNodeA->GetInfo().m_nodeData; - //dgHACDClusterFace& faceA = clusterA.GetFirst()->GetInfo(); - //dgEdge* const edgeA = faceA.m_edge; - - dgTrace (("cluster node: %d\n", clusterA.m_color)); - dgTrace ((" links: ")); - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeA = clusterNodeA->GetInfo().GetFirst(); edgeNodeA; edgeNodeA = edgeNodeA->GetNext()) { - dgListNode* const clusterNodeB = edgeNodeA->GetInfo().m_node; - dgHACDCluster& clusterB = clusterNodeB->GetInfo().m_nodeData; - dgTrace (("%d ", clusterB.m_color)); - } - dgTrace (("\n")); - } - dgTrace (("\n")); -#endif - } - - - // you can insert callback here to print the progress as it collapse clusters - bool ReportProgress () - { - bool state = true; - m_progress ++; - if (m_reportProgressCallback) { - dgFloat32 progress = dgFloat32(m_progress) * m_invFaceCount; - state = m_reportProgressCallback (progress * dgFloat32 (0.5f) + 0.5f, m_reportProgressUserData); - } - return state; - } - - dgMeshEffect* CreatePartitionMesh (dgMeshEffect& mesh, dgInt32 maxVertexPerHull) - { - dgMemoryAllocator* const allocator = mesh.GetAllocator(); - dgMeshEffect* const convexPartionMesh = new (allocator) dgMeshEffect(allocator); - - dgArray<dgBigVector> convexVertexBuffer(mesh.m_points.m_vertex, mesh.m_points.m_vertex.m_count); - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - - dgInt32 layer = 0; - convexPartionMesh->BeginBuild(); - for (dgList<dgHACDConvacityLookAheadTree*>::dgListNode* clusterNode = m_convexProximation.GetFirst(); clusterNode; clusterNode = clusterNode->GetNext()) { - dgHACDConvacityLookAheadTree* const cluster = clusterNode->GetInfo(); - - dgInt32 vertexCount = 0; - for (dgList<dgEdge*>::dgListNode* faceNode = cluster->m_faceList.GetFirst(); faceNode; faceNode = faceNode->GetNext()) { - dgEdge* const edge = faceNode->GetInfo(); - dgEdge* ptr = edge; - do { - dgInt32 index = ptr->m_incidentVertex; - convexVertexBuffer[vertexCount] = points[index]; - vertexCount++; - ptr = ptr->m_next; - } while (ptr != edge); - } - - //dgConvexHull3d convexHull(allocator, &convexVertexBuffer[0].m_x, sizeof(dgBigVector), vertexCount, 0.0, maxVertexPerHull); - dgMeshEffect convexMesh(allocator, &convexVertexBuffer[0].m_x, vertexCount, sizeof(dgBigVector), dgFloat64(0.0f)); - if (convexMesh.GetCount()) { - for (dgInt32 i = 0; i < convexMesh.m_points.m_vertex.m_count; i++) { - convexMesh.m_points.m_layers[i] = layer; - } - convexPartionMesh->MergeFaces(&convexMesh); - layer++; - } - } - convexPartionMesh->EndBuild(1.0e-5f); - - m_progress = m_faceCount - 1; - ReportProgress(); - return convexPartionMesh; - } - - dgFloat64 ConcavityByFaceMedian (dgInt32 faceCountA, dgInt32 faceCountB) const - { - dgFloat64 faceCountCost = DG_CONCAVITY_SCALE * dgFloat64 (0.1f) * (faceCountA + faceCountB) * m_invFaceCount; - return faceCountCost; - } - - dgFloat64 CalculateConcavityMetric (dgFloat64 convexConcavity, dgFloat64 area, dgFloat64 perimeter, dgInt32 faceCountA, dgInt32 faceCountB) const - { - dgFloat64 edgeCost = perimeter * perimeter / (dgFloat64(4.0f * dgPi) * area); - return convexConcavity * DG_CONCAVITY_SCALE + edgeCost + ConcavityByFaceMedian (faceCountA, faceCountB); - } - - void SubmitInitialEdgeCosts (dgMeshEffect& mesh) - { - m_mark ++; - for (dgListNode* clusterNodeA = GetFirst(); clusterNodeA; clusterNodeA = clusterNodeA->GetNext()) { - // call the progress callback - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeAB = clusterNodeA->GetInfo().GetFirst(); edgeNodeAB; edgeNodeAB = edgeNodeAB->GetNext()) { - dgHACDEdge& edgeAB = edgeNodeAB->GetInfo().m_edgeData; - dgFloat64 weight = edgeAB.m_backFaceHandicap; - if (edgeAB.m_mark != m_mark) { - edgeAB.m_mark = m_mark; - dgListNode* const clusterNodeB = edgeNodeAB->GetInfo().m_node; - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeBA = clusterNodeB->GetInfo().GetFirst(); edgeNodeBA; edgeNodeBA = edgeNodeBA->GetNext()) { - dgListNode* const clusterNode = edgeNodeBA->GetInfo().m_node; - if (clusterNode == clusterNodeA) { - dgHACDEdge& edgeBA = edgeNodeBA->GetInfo().m_edgeData; - edgeBA.m_mark = m_mark; - dgAssert (!edgeAB.m_proxyListNode); - dgAssert (!edgeBA.m_proxyListNode); - - dgAssert (edgeBA.m_backFaceHandicap == weight); - dgList<dgPairProxy>::dgListNode* const proxyNode = SubmitEdgeCost (mesh, clusterNodeA, clusterNodeB, weight * edgeBA.m_backFaceHandicap); - edgeAB.m_proxyListNode = proxyNode; - edgeBA.m_proxyListNode = proxyNode; - break; - } - } - } - } - } - } - - dgInt32 CopyVertexToPool(const dgMeshEffect& mesh, const dgHACDCluster& cluster, dgInt32 start) - { - dgInt32 count = start; - - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - for (dgList<dgHACDClusterFace>::dgListNode* node = cluster.GetFirst(); node; node = node->GetNext()) { - const dgHACDClusterFace& clusterFace = node->GetInfo(); - dgEdge* edge = clusterFace.m_edge; - do { - dgInt32 index = edge->m_incidentVertex; - if (m_vertexMarks[index] != m_vertexMark) { - m_vertexMarks[index] = m_vertexMark; - m_vertexPool[count] = points[index]; - count++; - } - edge = edge->m_next; - } while (edge != clusterFace.m_edge); - } - return count; - } - - - void MarkInteriorClusterEdges (dgMeshEffect& mesh, dgInt32 mark, const dgHACDCluster& cluster, dgInt32 colorA, dgInt32 colorB) const - { - dgAssert (colorA != colorB); - for (dgList<dgHACDClusterFace>::dgListNode* node = cluster.GetFirst(); node; node = node->GetNext()) { - dgHACDClusterFace& clusterFace = node->GetInfo(); - dgEdge* edge = clusterFace.m_edge; - do { - if ((edge->m_twin->m_incidentFace == colorA) || (edge->m_twin->m_incidentFace == colorB)) { - edge->m_mark = mark; - edge->m_twin->m_mark = mark; - } - edge = edge->m_next; - } while (edge != clusterFace.m_edge); - } - } - - dgFloat64 CalculateClusterPerimeter (dgMeshEffect& mesh, dgInt32 mark, const dgHACDCluster& cluster, dgInt32 colorA, dgInt32 colorB) const - { - dgAssert (colorA != colorB); - dgFloat64 perimeter = dgFloat64 (0.0f); - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - for (dgList<dgHACDClusterFace>::dgListNode* node = cluster.GetFirst(); node; node = node->GetNext()) { - dgHACDClusterFace& clusterFace = node->GetInfo(); - dgEdge* edge = clusterFace.m_edge; - do { - if (!((edge->m_twin->m_incidentFace == colorA) || (edge->m_twin->m_incidentFace == colorB))) { - dgBigVector p1p0(points[edge->m_twin->m_incidentVertex] - points[edge->m_incidentVertex]); - dgAssert(p1p0.m_w == dgFloat32(0.0f)); - perimeter += sqrt(p1p0.DotProduct(p1p0).GetScalar()); - } - edge = edge->m_next; - } while (edge != clusterFace.m_edge); - } - - return perimeter; - } - - void HeapCollectGarbage () - { - if ((m_priorityHeap.GetCount() + 20) > m_priorityHeap.GetMaxCount()) { - for (dgInt32 i = m_priorityHeap.GetCount() - 1; i >= 0; i--) { - dgList<dgPairProxy>::dgListNode* const emptyNode = m_priorityHeap[i]; - dgPairProxy& emptyPair = emptyNode->GetInfo(); - if ((emptyPair.m_nodeA == NULL) && (emptyPair.m_nodeB == NULL)) { - m_priorityHeap.Remove(i); - } - } - } - } - - - dgFloat64 CalculateConcavity(dgHACDConveHull& hull, const dgMeshEffect& mesh, const dgHACDCluster& cluster) - { - dgFloat64 concavity = dgFloat32(0.0f); - - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - for (dgList<dgHACDClusterFace>::dgListNode* node = cluster.GetFirst(); node; node = node->GetNext()) { - dgHACDClusterFace& clusterFace = node->GetInfo(); - dgEdge* edge = clusterFace.m_edge; - dgInt32 i0 = edge->m_incidentVertex; - dgInt32 i1 = edge->m_next->m_incidentVertex; - for (dgEdge* ptr = edge->m_next->m_next; ptr != edge; ptr = ptr->m_next) { - dgInt32 i2 = ptr->m_incidentVertex; - dgFloat64 val = hull.CalculateTriangleConcavity(clusterFace.m_normal, i0, i1, i2, points); - if (val > concavity) { - concavity = val; - } - i1 = i2; - } - } - - return concavity; - } - - dgFloat64 CalculateConcavity (dgHACDConveHull& hull, dgMeshEffect& mesh, dgHACDCluster& clusterA, dgHACDCluster& clusterB) - { - return dgMax(CalculateConcavity(hull, mesh, clusterA), CalculateConcavity(hull, mesh, clusterB)); - } - - - dgList<dgPairProxy>::dgListNode* SubmitEdgeCost (dgMeshEffect& mesh, dgListNode* const clusterNodeA, dgListNode* const clusterNodeB, dgFloat64 perimeterHandicap) - { - dgHACDCluster& clusterA = clusterNodeA->GetInfo().m_nodeData; - dgHACDCluster& clusterB = clusterNodeB->GetInfo().m_nodeData; - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - - bool flatStrip = true; - dgFloat64 tol = dgFloat64 (1.0e-5f) * m_diagonal; - dgHACDClusterFace& clusterFaceA = clusterA.GetFirst()->GetInfo(); - dgAssert(clusterFaceA.m_normal.m_w == dgFloat32(0.0f)); - dgBigPlane plane(clusterFaceA.m_normal, - points[clusterFaceA.m_edge->m_incidentVertex].DotProduct(clusterFaceA.m_normal).GetScalar()); - - if (clusterA.GetCount() > 1) { - flatStrip = clusterA.IsCoplanar(plane, mesh, tol); - } - - if (flatStrip) { - flatStrip = clusterB.IsCoplanar(plane, mesh, tol); - } - - dgList<dgPairProxy>::dgListNode* pairNode = NULL; - if (!flatStrip) { - m_vertexMark ++; - dgInt32 vertexCount = CopyVertexToPool(mesh, clusterA, 0); - vertexCount = CopyVertexToPool(mesh, clusterB, vertexCount); - - dgHACDConveHull convexHull(mesh.GetAllocator(), m_vertexPool, vertexCount); - - if (convexHull.GetVertexCount()) { - dgInt32 mark = mesh.IncLRU(); - MarkInteriorClusterEdges (mesh, mark, clusterA, clusterA.m_color, clusterB.m_color); - MarkInteriorClusterEdges (mesh, mark, clusterB, clusterA.m_color, clusterB.m_color); - - dgFloat64 area = clusterA.m_area + clusterB.m_area; - dgFloat64 perimeter = CalculateClusterPerimeter (mesh, mark, clusterA, clusterA.m_color, clusterB.m_color) + - CalculateClusterPerimeter (mesh, mark, clusterB, clusterA.m_color, clusterB.m_color); - dgFloat64 concavity = CalculateConcavity (convexHull, mesh, clusterA, clusterB); - - if (concavity < dgFloat64(1.0e-3f)) { - concavity = dgFloat64(0.0f); - } - - // see if the heap will overflow - HeapCollectGarbage (); - - // add a new pair to the heap - dgList<dgPairProxy>::dgListNode* pairNode1 = m_proxyList.Append(); - dgPairProxy& pair = pairNode1->GetInfo(); - pair.m_nodeA = clusterNodeA; - pair.m_nodeB = clusterNodeB; - pair.m_distanceConcavity = concavity; - pair.m_hierachicalClusterIndexA = clusterA.m_hierachicalClusterIndex; - pair.m_hierachicalClusterIndexB = clusterB.m_hierachicalClusterIndex; - - pair.m_area = area; - dgFloat64 cost = CalculateConcavityMetric (concavity, area * perimeterHandicap, perimeter * perimeterHandicap, clusterA.GetCount(), clusterB.GetCount()); - m_priorityHeap.Push(pairNode1, cost); - - return pairNode1; - } - } - return pairNode; - } - - - bool CollapseEdge (dgList<dgPairProxy>::dgListNode* const pairNode, dgMeshEffect& mesh, dgFloat64 concavity) - { - dgListNode* adjacentNodes[1024]; - dgPairProxy& pair = pairNode->GetInfo(); - - dgMemoryAllocator* const allocator = mesh.GetAllocator(); - - bool continueColapsing = true; - dgAssert((pair.m_nodeA && pair.m_nodeB) || (!pair.m_nodeA && !pair.m_nodeB)); - if (pair.m_nodeA && pair.m_nodeB && continueColapsing) { - // call the progress callback - continueColapsing = ReportProgress(); - - dgListNode* const clusterNodeA = pair.m_nodeA; - dgListNode* const clusterNodeB = pair.m_nodeB; - dgAssert (clusterNodeA != clusterNodeB); - - dgHACDCluster& clusterA = clusterNodeA->GetInfo().m_nodeData; - dgHACDCluster& clusterB = clusterNodeB->GetInfo().m_nodeData; - - dgAssert (&clusterA != &clusterB); - dgAssert(clusterA.m_color != clusterB.m_color); - - dgHACDConvacityLookAheadTree* const leftTree = m_concavityTreeArray[pair.m_hierachicalClusterIndexA]; - dgHACDConvacityLookAheadTree* const rightTree = m_concavityTreeArray[pair.m_hierachicalClusterIndexB]; - dgAssert (leftTree); - dgAssert (rightTree); - m_concavityTreeArray[pair.m_hierachicalClusterIndexA] = NULL; - m_concavityTreeArray[pair.m_hierachicalClusterIndexB] = NULL; - dgAssert (m_concavityTreeIndex < (2 * (m_faceCount + 1))); - - dgFloat64 treeConcavity = pair.m_distanceConcavity; -// dgAssert (treeConcavity < 0.1); - m_concavityTreeArray[m_concavityTreeIndex] = new (allocator) dgHACDConvacityLookAheadTree (allocator, leftTree, rightTree, treeConcavity); - clusterA.m_hierachicalClusterIndex = m_concavityTreeIndex; - clusterB.m_hierachicalClusterIndex = m_concavityTreeIndex; - m_concavityTreeIndex ++; - - // merge two clusters - while (clusterB.GetCount()) { - - dgHACDCluster::dgListNode* const nodeB = clusterB.GetFirst(); - clusterB.Unlink(nodeB); - - // now color code all faces of the merged cluster - dgHACDClusterFace& faceB = nodeB->GetInfo(); - dgEdge* ptr = faceB.m_edge; - do { - ptr->m_incidentFace = clusterA.m_color; - ptr = ptr->m_next; - } while (ptr != faceB.m_edge); - clusterA.Append(nodeB); - } - clusterA.m_area = pair.m_area; - clusterA.m_concavity = concavity; - - // invalidate all proxies that are still in the heap - dgInt32 adjacentCount = 1; - adjacentNodes[0] = clusterNodeA; - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeAB = clusterNodeA->GetInfo().GetFirst(); edgeNodeAB; edgeNodeAB = edgeNodeAB->GetNext()) { - dgHACDEdge& edgeAB = edgeNodeAB->GetInfo().m_edgeData; - dgList<dgPairProxy>::dgListNode* const proxyNode = (dgList<dgPairProxy>::dgListNode*) edgeAB.m_proxyListNode; - if (proxyNode) { - dgPairProxy& pairProxy = proxyNode->GetInfo(); - dgAssert ((edgeNodeAB->GetInfo().m_node == pairProxy.m_nodeA) || (edgeNodeAB->GetInfo().m_node == pairProxy.m_nodeB)); - pairProxy.m_nodeA = NULL; - pairProxy.m_nodeB = NULL; - edgeAB.m_proxyListNode = NULL; - } - - adjacentNodes[adjacentCount] = edgeNodeAB->GetInfo().m_node; - adjacentCount ++; - dgAssert (adjacentCount < sizeof (adjacentNodes)/ sizeof (adjacentNodes[0])); - } - - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeBA = clusterNodeB->GetInfo().GetFirst(); edgeNodeBA; edgeNodeBA = edgeNodeBA->GetNext()) { - dgHACDEdge& edgeBA = edgeNodeBA->GetInfo().m_edgeData; - dgList<dgPairProxy>::dgListNode* const proxyNode = (dgList<dgPairProxy>::dgListNode*) edgeBA.m_proxyListNode; - if (proxyNode) { - dgPairProxy& pairProxy = proxyNode->GetInfo(); - pairProxy.m_nodeA = NULL; - pairProxy.m_nodeB = NULL; - edgeBA.m_proxyListNode = NULL; - } - - bool alreadyLinked = false; - dgListNode* const node = edgeNodeBA->GetInfo().m_node; - for (dgInt32 i = 0; i < adjacentCount; i ++) { - if (node == adjacentNodes[i]) { - alreadyLinked = true; - break; - } - } - if (!alreadyLinked) { - clusterNodeA->GetInfo().AddEdge (node); - node->GetInfo().AddEdge (clusterNodeA); - } - } - DeleteNode (clusterNodeB); - - // submit all new costs for each edge connecting this new node to any other node - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeAB = clusterNodeA->GetInfo().GetFirst(); edgeNodeAB; edgeNodeAB = edgeNodeAB->GetNext()) { - dgHACDEdge& edgeAB = edgeNodeAB->GetInfo().m_edgeData; - dgFloat64 weigh = edgeAB.m_backFaceHandicap; - dgListNode* const clusterNodeB1 = edgeNodeAB->GetInfo().m_node; - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeBA = clusterNodeB1->GetInfo().GetFirst(); edgeNodeBA; edgeNodeBA = edgeNodeBA->GetNext()) { - dgListNode* const clusterNode = edgeNodeBA->GetInfo().m_node; - if (clusterNode == clusterNodeA) { - dgHACDEdge& edgeBA = edgeNodeBA->GetInfo().m_edgeData; - dgList<dgPairProxy>::dgListNode* const proxyNode = SubmitEdgeCost (mesh, clusterNodeA, clusterNodeB1, weigh * edgeBA.m_backFaceHandicap); - if (proxyNode) { - edgeBA.m_proxyListNode = proxyNode; - edgeAB.m_proxyListNode = proxyNode; - } - break; - } - } - } - } - m_proxyList.Remove(pairNode); - - return continueColapsing; - } - - bool CollapseClusters (dgMeshEffect& mesh, dgFloat64 maxConcavity___, dgInt32 maxClustesCount) - { - bool collapseEdgeState = true; - while (m_priorityHeap.GetCount() && collapseEdgeState) { - dgFloat64 concavity = m_priorityHeap.Value(); - dgList<dgPairProxy>::dgListNode* const pairNode = m_priorityHeap[0]; - m_priorityHeap.Pop(); - collapseEdgeState = CollapseEdge (pairNode, mesh, concavity); - } - - if (collapseEdgeState) { - dgInt32 treeCounts = 0; - for (dgInt32 i = 0; i < m_concavityTreeIndex; i ++) { - if (m_concavityTreeArray[i]) { - m_concavityTreeArray[treeCounts] = m_concavityTreeArray[i]; - m_concavityTreeArray[i] = NULL; - treeCounts ++; - } - } - - if (treeCounts > 1) { - for (dgInt32 i = 0; i < treeCounts; i ++) { - dgAssert (m_concavityTreeArray[i]); - if (m_concavityTreeArray[i]->m_faceList.GetCount()==1) { - delete m_concavityTreeArray[i]; - m_concavityTreeArray[i] = m_concavityTreeArray[treeCounts-1]; - m_concavityTreeArray[treeCounts-1]= NULL; - treeCounts --; - i--; - } - } - - - dgFloat32 largeConcacvity = 10000; - while (treeCounts > 1) { - dgHACDConvacityLookAheadTree* const leftTree = m_concavityTreeArray[treeCounts-1]; - dgHACDConvacityLookAheadTree* const rightTree = m_concavityTreeArray[treeCounts-2]; - m_concavityTreeArray[treeCounts-1] = NULL; - m_concavityTreeArray[treeCounts-2] = new (mesh.GetAllocator()) dgHACDConvacityLookAheadTree (mesh.GetAllocator(), leftTree, rightTree, largeConcacvity); - largeConcacvity *= 2; - treeCounts --; - } - - } - - dgHACDConvacityLookAheadTree* const tree = m_concavityTreeArray[0]; - if (tree) { - dgDownHeap<dgHACDConvacityLookAheadTree*, dgFloat64> approximation(maxClustesCount * 2, mesh.GetAllocator()); - - tree->ReduceByCount (maxClustesCount, approximation); - //tree->ReduceByConcavity (maxConcavity, approximation); - -//while ((approximation.Value() + dgFloat64 (1.0e10f)) > 1.0e-5) { -//approximation.Pop(); -//} - - while (approximation.GetCount()) { - m_convexProximation.Append(approximation[0]); - approximation.Pop(); - } - } - } - return collapseEdgeState; - } - - - dgInt32 m_mark; - dgInt32 m_faceCount; - dgInt32 m_vertexMark; - dgInt32 m_progress; - dgInt32 m_concavityTreeIndex; - dgFloat32 m_invFaceCount; - dgFloat64 m_diagonal; - dgInt32* m_vertexMarks; - dgBigVector* m_vertexPool; - dgList<dgPairProxy> m_proxyList; - dgHACDConvacityLookAheadTree** m_concavityTreeArray; - dgList<dgHACDConvacityLookAheadTree*> m_convexProximation; - dgUpHeap<dgList<dgPairProxy>::dgListNode*, dgFloat64> m_priorityHeap; - dgReportProgress m_reportProgressCallback; - void* m_reportProgressUserData; -}; - -dgMeshEffect* dgMeshEffect::CreateConvexApproximation(dgFloat32 maxConcavity, dgFloat32 backFaceDistanceFactor, dgInt32 maxHullsCount, dgInt32 maxVertexPerHull, dgReportProgress reportProgressCallback, void* const progressReportUserData) const -{ - // dgMeshEffect triangleMesh(*this); - if (maxHullsCount <= 1) { - maxHullsCount = 1; - } - if (maxConcavity <= dgFloat32 (1.0e-5f)) { - maxConcavity = dgFloat32 (1.0e-5f); - } - - if (maxVertexPerHull < 4) { - maxVertexPerHull = 4; - } - backFaceDistanceFactor = dgClamp(backFaceDistanceFactor, dgFloat32 (1.0e-6f), dgFloat32 (1.0f)); - - dgMeshEffect* partition = NULL; - - // make a copy of the mesh - dgMeshEffect mesh(*this); - mesh.m_attrib.m_materialChannel.Clear(); - mesh.m_attrib.m_normalChannel.Clear(); - mesh.m_attrib.m_binormalChannel.Clear(); - mesh.m_attrib.m_colorChannel.Clear(); - mesh.m_attrib.m_uv0Channel.Clear(); - mesh.m_attrib.m_uv1Channel.Clear(); - mesh.Triangulate (); - - mesh.UnpackAttibuteData(); - mesh.PackAttibuteData(); - mesh.UnpackPoints(); - bool state = mesh.Optimize (&mesh.m_points.m_vertex[0].m_x, sizeof (dgBigVector), reportProgressCallback, progressReportUserData, dgFloat32 (1.0e-3f), 1500); - // optimized override userdata - dgPolyhedra::Iterator iter(mesh); - for (iter.Begin(); iter; iter++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if (edge->m_incidentFace > 0) { - edge->m_userData = edge->m_incidentVertex; - } - } - mesh.PackPoints(dgFloat32 (1.0e-24f)); - if (state) { - mesh.DeleteDegenerateFaces (&mesh.m_points.m_vertex[0].m_x, sizeof (dgBigVector), dgFloat32 (1.0e-12f)); - mesh.RepairTJoints(); - mesh.ConvertToPolygons(); - //mesh.SaveOFF ("xxxxxx.off"); - - // create a general connectivity graph - dgHACDClusterGraph graph (mesh, backFaceDistanceFactor, reportProgressCallback, progressReportUserData); - - // calculate initial edge costs - graph.SubmitInitialEdgeCosts (mesh); - - // collapse the graph - if (graph.CollapseClusters (mesh, maxConcavity, maxHullsCount)) { - // Create Partition Mesh - partition = graph.CreatePartitionMesh (mesh, maxVertexPerHull); - } - } - - return partition; -} diff --git a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect4.cpp b/thirdparty/src/newton/dgMeshUtil/dgMeshEffect4.cpp deleted file mode 100644 index 38435cdf9..000000000 --- a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect4.cpp +++ /dev/null @@ -1,1625 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgMeshEffect.h" -#include "dgCollisionConvexHull.h" - - - -#if 0 -#define DG_BUILD_HIERACHICAL_HACD - -#define DG_CONCAVITY_MAX_THREADS 8 -#define DG_CONCAVITY_SCALE dgFloat64 (100.0f) - - - - -class dgHACDEdge -{ - public: - dgHACDEdge () - :m_mark(0) - ,m_proxyListNode(NULL) - ,m_backFaceHandicap(dgFloat64 (1.0)) - { - } - ~dgHACDEdge () - { - } - - dgInt32 m_mark; - void* m_proxyListNode; - dgFloat64 m_backFaceHandicap; -}; - -class dgHACDClusterFace -{ - public: - dgHACDClusterFace() - :m_edge(NULL) - ,m_area(dgFloat64(0.0f)) - { - } - ~dgHACDClusterFace() - { - } - - dgEdge* m_edge; - dgFloat64 m_area; - dgBigVector m_normal; -}; - - -class dgHACDCluster: public dgList<dgHACDClusterFace> -{ - public: - dgHACDCluster () - :dgList<dgHACDClusterFace>(NULL) - ,m_color(0) - ,m_hierachicalClusterIndex(0) - ,m_area(dgFloat64 (0.0f)) - ,m_concavity(dgFloat64 (0.0f)) - { - } - - bool IsCoplanar(const dgBigPlane& plane, const dgMeshEffect& mesh, dgFloat64 tolerance) const - { - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - for (dgListNode* node = GetFirst(); node; node = node->GetNext()) { - const dgHACDClusterFace& info = node->GetInfo(); - dgEdge* ptr = info.m_edge; - do { - const dgBigVector& p = points[ptr->m_incidentVertex]; - dgFloat64 dist = fabs(plane.Evalue(p)); - if (dist > tolerance) { - return false; - } - ptr = ptr->m_next; - } while (ptr != info.m_edge); - } - return true; - } - - - dgInt32 m_color; - dgInt32 m_hierachicalClusterIndex; - dgFloat64 m_area; - dgFloat64 m_concavity; -}; - - -class dgHACDClusterGraph - :public dgGraph<dgHACDCluster, dgHACDEdge> - ,public dgAABBPolygonSoup -{ - public: - - class dgHACDConveHull: public dgConvexHull3d - { - class dgConvexHullRayCastData - { - public: - dgFloat64 m_normalProjection; - dgConvexHull3DFace* m_face; - }; - - public: - dgHACDConveHull (const dgHACDConveHull& hull) - :dgConvexHull3d(hull) - ,m_mark(1) - { - } - - dgHACDConveHull (dgMemoryAllocator* const allocator, const dgBigVector* const points, dgInt32 count) - :dgConvexHull3d(allocator, &points[0].m_x, sizeof (dgBigVector),count, dgFloat64 (0.0f)) - ,m_mark(1) - { - - } - - dgFloat64 CalculateTriangleConcavity(const dgBigVector& normal, dgInt32 i0, dgInt32 i1, dgInt32 i2, const dgBigVector* const points) - { - dgUnsigned32 head = 1; - dgUnsigned32 tail = 0; - dgBigVector pool[1<<8][3]; - - pool[0][0] = points[i0]; - pool[0][1] = points[i1]; - pool[0][2] = points[i2]; - - const dgBigVector step(normal.Scale(dgFloat64(4.0f) * GetDiagonal())); - - dgFloat64 concavity = dgFloat32(0.0f); - dgFloat64 minArea = dgFloat32(0.125f); - dgFloat64 minArea2 = minArea * minArea * 0.5f; - - dgInt32 maxCount = 4; - dgUnsigned32 mask = (sizeof (pool) / (3 * sizeof (pool[0][0]))) - 1; - - dgConvexHull3DFace* firstGuess = NULL; - while ((tail != head) && (maxCount >= 0)) { - maxCount --; - dgBigVector p0(pool[tail][0]); - dgBigVector p1(pool[tail][1]); - dgBigVector p2(pool[tail][2]); - tail = (tail + 1) & mask; - - dgBigVector q1((p0 + p1 + p2).Scale(dgFloat64(1.0f / 3.0f))); - dgBigVector q0(q1 + step); - - //dgFloat64 param = convexHull.RayCast(q0, q1, &firstGuess); - dgFloat64 param = FastRayCast(q0, q1, &firstGuess); - if (param > dgFloat64(1.0f)) { - param = dgFloat64(1.0f); - } - dgBigVector dq(step.Scale(dgFloat32(1.0f) - param)); - dgFloat64 lenght2 = sqrt (dq % dq); - //dgAssert (lenght2 < GetDiagonal()); - if (lenght2 > concavity) { - concavity = lenght2; - } - - if (((head + 1) & mask) != tail) { - dgBigVector edge10(p1 - p0); - dgBigVector edge20(p2 - p0); - dgBigVector n(edge10 * edge20); - dgFloat64 area2 = n % n; - if (area2 > minArea2) { - dgBigVector p01((p0 + p1).Scale(dgFloat64(0.5f))); - dgBigVector p12((p1 + p2).Scale(dgFloat64(0.5f))); - dgBigVector p20((p2 + p0).Scale(dgFloat64(0.5f))); - - pool[head][0] = p0; - pool[head][1] = p01; - pool[head][2] = p20; - head = (head + 1) & mask; - - if (((head + 1) & mask) != tail) { - pool[head][0] = p1; - pool[head][1] = p12; - pool[head][2] = p01; - head = (head + 1) & mask; - - if (((head + 1) & mask) != tail) { - pool[head][0] = p2; - pool[head][1] = p20; - pool[head][2] = p12; - head = (head + 1) & mask; - } - } - } - } - } - return concavity; - } - - - - dgFloat64 FaceRayCast (const dgConvexHull3DFace* const face, const dgBigVector& origin, const dgBigVector& dist, dgFloat64& normalProjection) const - { - dgInt32 i0 = face->m_index[0]; - dgInt32 i1 = face->m_index[1]; - dgInt32 i2 = face->m_index[2]; - - const dgBigVector& p0 = m_points[i0]; - dgBigVector normal ((m_points[i1] - p0) * (m_points[i2] - p0)); - - dgFloat64 N = (origin - p0) % normal; - dgFloat64 D = dist % normal; - - if (fabs(D) < dgFloat64 (1.0e-16f)) { // - normalProjection = dgFloat32 (0.0); - if (N > dgFloat64 (0.0f)) { - return dgFloat32 (-1.0e30); - } else { - - return dgFloat32 (1.0e30); - } - } - normalProjection = D; - return - N / D; - } - - dgConvexHull3DFace* ClosestFaceVertexToPoint (const dgBigVector& point) - { - // note, for this function to be effective point should be an already close point to the Hull. - // for example casting the point to the OBB or the AABB of the full is a good first guess. - dgConvexHull3DFace* closestFace = &GetFirst()->GetInfo(); - dgInt8 pool[256 * (sizeof (dgConvexHull3DFace*) + sizeof (dgFloat64))]; - dgUpHeap<dgConvexHull3DFace*,dgFloat64> heap (pool, sizeof (pool)); - - for (dgInt32 i = 0; i < 3; i ++) { - dgBigVector dist (m_points[closestFace->m_index[i]] - point); - heap.Push(closestFace, dist % dist); - } - - m_mark ++; - dgFloat64 minDist = heap.Value(); - while (heap.GetCount()) { - dgConvexHull3DFace* const face = heap[0]; - if (heap.Value() < minDist) { - minDist = heap.Value(); - closestFace = face; - } - heap.Pop(); - //face->m_mark = m_mark; - face->SetMark(m_mark); - for (dgInt32 i = 0; i < 3; i ++) { - //const dgConvexHull3DFace* twin = &face->m_twin[i]->GetInfo(); - dgConvexHull3DFace* twin = &face->GetTwin(i)->GetInfo(); - //if (twin->m_mark != m_mark) { - if (twin->GetMark() != m_mark) { - dgBigVector dist (m_points[twin->m_index[i]] - point); - // use hysteresis to prevent stops at a local minimal, but at the same time fast descend - dgFloat64 dist2 = dist % dist; - if (dist2 < (minDist * dgFloat64 (1.001f))) { - heap.Push(twin, dist2); - } - } - } - } - - return closestFace; - } - - - // this version have input sensitive complexity (approximately log2) - // when casting parallel rays and using the last face as initial guess this version has const time complexity - dgFloat64 RayCast (const dgBigVector& localP0, const dgBigVector& localP1, dgConvexHull3DFace** firstFaceGuess) - { - dgConvexHull3DFace* face = &GetFirst()->GetInfo(); - if (firstFaceGuess && *firstFaceGuess) { - face = *firstFaceGuess; - } else { - if (GetCount() > 32) { - dgVector q0 (localP0); - dgVector q1 (localP1); - if (dgRayBoxClip (q0, q1, m_aabbP0, m_aabbP1)) { - face = ClosestFaceVertexToPoint (q0); - } - } - } - - m_mark ++; - //face->m_mark = m_mark; - face->SetMark (m_mark); - dgInt8 pool[256 * (sizeof (dgConvexHullRayCastData) + sizeof (dgFloat64))]; - dgDownHeap<dgConvexHullRayCastData,dgFloat64> heap (pool, sizeof (pool)); - - dgFloat64 t0 = dgFloat64 (-1.0e20); //for the maximum entering segment parameter; - dgFloat64 t1 = dgFloat64 ( 1.0e20); //for the minimum leaving segment parameter; - dgBigVector dS (localP1 - localP0); // is the segment direction vector; - dgConvexHullRayCastData data; - data.m_face = face; - dgFloat64 t = FaceRayCast (face, localP0, dS, data.m_normalProjection); - if (data.m_normalProjection >= dgFloat32 (0.0)) { - t = dgFloat64 (-1.0e30); - } - - heap.Push (data, t); - while (heap.GetCount()) { - dgConvexHullRayCastData data (heap[0]); - dgFloat64 t = heap.Value(); - dgConvexHull3DFace* face = data.m_face; - dgFloat64 normalDistProjection = data.m_normalProjection; - heap.Pop(); - bool foundThisBestFace = true; - if (normalDistProjection < dgFloat64 (0.0f)) { - if (t > t0) { - t0 = t; - } - if (t0 > t1) { - return dgFloat64 (1.2f); - } - } else { - foundThisBestFace = false; - } - - for (dgInt32 i = 0; i < 3; i ++) { - //dgConvexHull3DFace* const face1 = &face->m_twin[i]->GetInfo(); - dgConvexHull3DFace* const face1 = &face->GetTwin(i)->GetInfo(); - - //if (face1->m_mark != m_mark) { - if (face1->GetMark() != m_mark) { - //face1->m_mark = m_mark; - face1->SetMark (m_mark); - dgConvexHullRayCastData data; - data.m_face = face1; - dgFloat64 t = FaceRayCast (face1, localP0, dS, data.m_normalProjection); - if (data.m_normalProjection >= dgFloat32 (0.0)) { - t = dgFloat64 (-1.0e30); - } else if (t > t0) { - foundThisBestFace = false; - } else if (fabs (t - t0) < dgFloat64 (1.0e-10f)) { - return dgConvexHull3d::RayCast (localP0, localP1); - } - if ((heap.GetCount() + 2)>= heap.GetMaxCount()) { - // remove t values that are old and way outside interval [0.0, 1.0] - for (dgInt32 i = heap.GetCount() - 1; i >= 0; i--) { - dgFloat64 val = heap.Value(i); - if ((val < dgFloat64 (-100.0f)) || (val > dgFloat64 (100.0f))) { - heap.Remove(i); - } - } - } - heap.Push (data, t); - } - } - if (foundThisBestFace) { - if ((t0 >= dgFloat64 (0.0f)) && (t0 <= dgFloat64 (1.0f))) { - if (firstFaceGuess) { - *firstFaceGuess = face; - } - return t0; - } - break; - } - } - - return dgFloat64 (1.2f); - - } - - dgFloat64 FastRayCast (const dgBigVector& localP0, const dgBigVector& localP1, dgConvexHull3DFace** guess) - { -#if 0 - #ifdef _DEBUG - dgFloat64 t0 = dgConvexHull3d::RayCast (localP0, localP1); - dgFloat64 t1 = RayCast (localP0, localP1, guess); - dgAssert (fabs(t0 - t1) < dgFloat64 (1.0e-5f)); - #endif -#endif - - //return dgConvexHull3d::RayCast (localP0, localP1); - return RayCast (localP0, localP1, guess); - } - - dgInt32 m_mark; - }; - - class dgHACDConvacityLookAheadTree - { - public: - DG_CLASS_ALLOCATOR(allocator) - - dgHACDConvacityLookAheadTree (dgMemoryAllocator* const allocator, dgEdge* const face, dgFloat64 concavity) - :m_concavity(concavity) - ,m_faceList (allocator) - ,m_left (NULL) - ,m_right (NULL) - { - m_faceList.Append(face); - } - - - dgHACDConvacityLookAheadTree (dgMemoryAllocator* const allocator, dgHACDConvacityLookAheadTree* const leftChild, dgHACDConvacityLookAheadTree* const rightChild, dgFloat64 concavity) - :m_concavity(concavity) - ,m_faceList (allocator) - ,m_left (leftChild) - ,m_right (rightChild) - { - dgAssert (leftChild); - dgAssert (rightChild); - - dgFloat64 concavityTest = m_concavity - dgFloat64 (1.0e-5f); - //if ((m_left->m_faceList.GetCount() == 1) || (m_right->m_faceList.GetCount() == 1)) { - if ((((m_left->m_faceList.GetCount() == 1) || (m_right->m_faceList.GetCount() == 1))) || - ((concavityTest <= m_left->m_concavity) && (concavityTest <= m_right->m_concavity))) { - //The the parent has lower concavity this mean that the two do no add more detail, - //the can be deleted and replaced the parent node - // for example the two children can be two convex strips that are part of a larger convex piece - // but each part has a non zero concavity, while the convex part has a lower concavity - m_faceList.Merge (m_left->m_faceList); - m_faceList.Merge (m_right->m_faceList); - - delete m_left; - delete m_right; - m_left = NULL; - m_right = NULL; - } else { - for (dgList<dgEdge*>::dgListNode* node = m_left->m_faceList.GetFirst(); node; node = node->GetNext()) { - m_faceList.Append(node->GetInfo()); - } - for (dgList<dgEdge*>::dgListNode* node = m_right->m_faceList.GetFirst(); node; node = node->GetNext()) { - m_faceList.Append(node->GetInfo()); - } - } - } - - ~dgHACDConvacityLookAheadTree () - { - if (m_left) { - dgAssert (m_right); - delete m_left; - delete m_right; - } - } - - dgInt32 GetNodesCount () const - { - dgInt32 count = 0; - dgInt32 stack = 1; - const dgHACDConvacityLookAheadTree* pool[1024]; - pool[0] = this; - while (stack) { - stack --; - count ++; - const dgHACDConvacityLookAheadTree* const root = pool[stack]; - if (root->m_left) { - dgAssert (root->m_right); - pool[stack] = root->m_left; - stack ++; - dgAssert (stack < sizeof (pool)/sizeof (pool[0])); - pool[stack] = root->m_right; - stack ++; - dgAssert (stack < sizeof (pool)/sizeof (pool[0])); - } - } - return count; - } - - void ReduceByCount (dgInt32 count, dgDownHeap<dgHACDConvacityLookAheadTree*, dgFloat64>& approximation) - { - if (count < 1) { - count = 1; - } -// dgInt32 nodesCount = GetNodesCount(); - - approximation.Flush(); - dgHACDConvacityLookAheadTree* tmp = this; - approximation.Push(tmp, m_concavity); -// nodesCount --; - //while (nodesCount && (approximation.GetCount() < count) && (approximation.Value() >= dgFloat32 (0.0f))) { - while ((approximation.GetCount() < count) && (approximation.Value() >= dgFloat32 (0.0f))) { - dgHACDConvacityLookAheadTree* worseCluster = approximation[0]; - if (!worseCluster->m_left && approximation.Value() >= dgFloat32 (0.0f)) { - approximation.Pop(); - approximation.Push(worseCluster, dgFloat32 (-1.0f)); - } else { - dgAssert (worseCluster->m_left); - dgAssert (worseCluster->m_right); - approximation.Pop(); - approximation.Push(worseCluster->m_left, worseCluster->m_left->m_concavity); - approximation.Push(worseCluster->m_right, worseCluster->m_right->m_concavity); -// nodesCount -= 2; - } - } - } - - - void ReduceByConcavity (dgFloat64 concavity, dgDownHeap<dgHACDConvacityLookAheadTree*, dgFloat64>& approximation) - { - approximation.Flush(); - dgHACDConvacityLookAheadTree* tmp = this; - - approximation.Push(tmp, m_concavity); - while (approximation.Value() > concavity) { - dgHACDConvacityLookAheadTree* worseCluster = approximation[0]; - if (!worseCluster->m_left && approximation.Value() >= dgFloat32 (0.0f)) { - approximation.Pop(); - approximation.Push(worseCluster, dgFloat32 (-1.0f)); - } else { - dgAssert (worseCluster->m_left); - dgAssert (worseCluster->m_right); - approximation.Pop(); - approximation.Push(worseCluster->m_left, worseCluster->m_left->m_concavity); - approximation.Push(worseCluster->m_right, worseCluster->m_right->m_concavity); - } - } - } - - dgFloat64 m_concavity; - dgList<dgEdge*> m_faceList; - dgHACDConvacityLookAheadTree* m_left; - dgHACDConvacityLookAheadTree* m_right; - }; - - class dgPairProxy - { - public: - dgPairProxy() - :m_nodeA(NULL) - ,m_nodeB(NULL) - ,m_hierachicalClusterIndexA(0) - ,m_hierachicalClusterIndexB(0) - ,m_area(dgFloat64(0.0f)) - { - } - - ~dgPairProxy() - { - } - - dgListNode* m_nodeA; - dgListNode* m_nodeB; - dgInt32 m_hierachicalClusterIndexA; - dgInt32 m_hierachicalClusterIndexB; - dgFloat64 m_area; - dgFloat64 m_distanceConcavity; - }; - - class dgHACDRayCasterContext: public dgFastRayTest - { - public: - dgHACDRayCasterContext (const dgVector& l0, const dgVector& l1, dgHACDClusterGraph* const me, dgInt32 mycolor) - :dgFastRayTest (l0, l1) - ,m_myColor(mycolor) - ,m_colorHit(-1) - ,m_param (1.0f) - ,m_me (me) - { - } - - dgInt32 m_myColor; - dgInt32 m_colorHit; - dgFloat32 m_param; - dgHACDClusterGraph* m_me; - }; - - - dgHACDClusterGraph(dgMeshEffect& mesh, dgFloat32 backFaceDistanceFactor, dgReportProgress reportProgressCallback) - :dgGraph<dgHACDCluster, dgHACDEdge> (mesh.GetAllocator()) - ,dgAABBPolygonSoup() - ,m_mark(0) - ,m_faceCount(0) - ,m_vertexMark(0) - ,m_progress(0) - ,m_cancavityTreeIndex(0) - ,m_invFaceCount(dgFloat32 (1.0f)) - ,m_vertexMarks(NULL) - ,m_diagonal(dgFloat64(1.0f)) - ,m_vertexPool(NULL) - ,m_proxyList(mesh.GetAllocator()) - ,m_concavityTreeArray(NULL) - ,m_convexProximation(mesh.GetAllocator()) - ,m_priorityHeap (mesh.GetCount() + 2048, mesh.GetAllocator()) - ,m_reportProgressCallback (reportProgressCallback) - ,m_parallerConcavityCalculator(mesh.GetAllocator()) - { - - m_parallerConcavityCalculator.SetThreadsCount(DG_CONCAVITY_MAX_THREADS); - - // precondition the mesh for better approximation - mesh.ConvertToPolygons(); - - m_faceCount = mesh.GetTotalFaceCount(); - - dgMemoryAllocator* const allocator = mesh.GetAllocator(); - m_invFaceCount = dgFloat32 (1.0f) / (m_faceCount); - - // init some auxiliary structures - dgInt32 vertexCount = mesh.GetVertexCount(); - m_vertexMarks = (dgInt32*) dgMallocStack(vertexCount * sizeof(dgInt32)); - m_vertexPool = (dgBigVector*) dgMallocStack(vertexCount * sizeof(dgBigVector)); - memset(m_vertexMarks, 0, vertexCount * sizeof(dgInt32)); - - m_cancavityTreeIndex = m_faceCount + 1; - m_concavityTreeArray = (dgHACDConvacityLookAheadTree**) dgMallocStack(2 * m_cancavityTreeIndex * sizeof(dgHACDConvacityLookAheadTree*)); - memset(m_concavityTreeArray, 0, 2 * m_cancavityTreeIndex * sizeof(dgHACDConvacityLookAheadTree*)); - - // scan the mesh and and add a node for each face - dgInt32 color = 1; - dgMeshEffect::Iterator iter(mesh); - - dgInt32 meshMask = mesh.IncLRU(); - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - for (iter.Begin(); iter; iter++) { - dgEdge* const edge = &(*iter); - if ((edge->m_mark != meshMask) && (edge->m_incidentFace > 0)) { - - // call the progress callback - //ReportProgress(); - - dgListNode* const clusterNode = AddNode (); - dgHACDCluster& cluster = clusterNode->GetInfo().m_nodeData; - cluster.SetAllocator(mesh.GetAllocator()); - - dgFloat64 perimeter = dgFloat64(0.0f); - dgEdge* ptr = edge; - do { - dgBigVector p1p0(points[ptr->m_incidentVertex] - points[ptr->m_prev->m_incidentVertex]); - perimeter += sqrt(p1p0 % p1p0); - ptr->m_incidentFace = color; - ptr->m_userData = dgUnsigned64 (clusterNode); - ptr->m_mark = meshMask; - ptr = ptr->m_next; - } while (ptr != edge); - - dgBigVector normal = mesh.FaceNormal(edge, &points[0][0], sizeof(dgBigVector)); - dgFloat64 mag = sqrt(normal % normal); - - cluster.m_color = color; - cluster.m_hierachicalClusterIndex = color; - cluster.m_area = dgFloat64(0.5f) * mag; - cluster.m_concavity = CalculateConcavityMetric (dgFloat64 (0.0f), cluster.m_area, perimeter, 1, 0); - - dgHACDClusterFace& face = cluster.Append()->GetInfo(); - face.m_edge = edge; - face.m_area = dgFloat64(0.5f) * mag; - face.m_normal = normal.Scale(dgFloat64(1.0f) / mag); - - //m_concavityTreeArray[color] = new (allocator) dgHACDConvacityLookAheadTree (allocator, edge, cluster.m_concavity); - m_concavityTreeArray[color] = new (allocator) dgHACDConvacityLookAheadTree (allocator, edge, dgFloat64 (0.0f)); - - color ++; - } - } - - // add all link adjacent faces links - for (dgListNode* clusterNode = GetFirst(); clusterNode; clusterNode = clusterNode->GetNext()) { - - // call the progress callback - //ReportProgress(); - - dgHACDCluster& cluster = clusterNode->GetInfo().m_nodeData; - dgHACDClusterFace& face = cluster.GetFirst()->GetInfo(); - dgEdge* const edge = face.m_edge; - dgEdge* ptr = edge; - do { - if (ptr->m_twin->m_incidentFace > 0) { - dgAssert (ptr->m_twin->m_userData); - dgListNode* const twinClusterNode = (dgListNode*) ptr->m_twin->m_userData; - dgAssert (twinClusterNode); - - bool doubleEdge = false; - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNode = clusterNode->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - if (edgeNode->GetInfo().m_node == twinClusterNode) { - doubleEdge = true; - break; - } - } - if (!doubleEdge) { - clusterNode->GetInfo().AddEdge (twinClusterNode); - } - } - ptr = ptr->m_next; - } while (ptr != edge); - } - - Trace(); - - // add links to back faces - dgPolygonSoupDatabaseBuilder builder (mesh.GetAllocator()); - dgVector polygon[64]; - dgInt32 indexList[64]; - - dgMatrix matrix (dgGetIdentityMatrix()); - for (dgInt32 i = 0; i < sizeof (polygon) / sizeof (polygon[0]); i ++) { - indexList[i] = i; - } - - dgBigVector minAABB; - dgBigVector maxAABB; - mesh.CalculateAABB (minAABB, maxAABB); - maxAABB -= minAABB; - dgFloat32 rayDiagonalLength = dgFloat32 (sqrt (maxAABB % maxAABB)); - m_diagonal = rayDiagonalLength; - - builder.Begin(); - dgTree<dgListNode*,dgInt32> clusterMap (GetAllocator()); - for (dgListNode* clusterNode = GetFirst(); clusterNode; clusterNode = clusterNode->GetNext()) { - - // call the progress callback - //ReportProgress(); - - dgHACDCluster& cluster = clusterNode->GetInfo().m_nodeData; - clusterMap.Insert(clusterNode, cluster.m_color); - dgHACDClusterFace& face = cluster.GetFirst()->GetInfo(); - dgEdge* const edge = face.m_edge; - dgInt32 count = 0; - dgEdge* ptr = edge; - do { - polygon[count] = points[ptr->m_incidentVertex]; - count ++; - ptr = ptr->m_prev; - } while (ptr != edge); - - builder.AddMesh(&polygon[0].m_x, count, sizeof (dgVector), 1, &count, indexList, &cluster.m_color, matrix); - } - builder.End(false); - Create (builder, false); - - - dgFloat32 distanceThreshold = rayDiagonalLength * backFaceDistanceFactor; - for (dgListNode* clusterNodeA = GetFirst(); clusterNodeA; clusterNodeA = clusterNodeA->GetNext()) { - - // call the progress callback - //ReportProgress(); - dgHACDCluster& clusterA = clusterNodeA->GetInfo().m_nodeData; - dgHACDClusterFace& faceA = clusterA.GetFirst()->GetInfo(); - dgEdge* const edgeA = faceA.m_edge; - dgEdge* ptr = edgeA; - - dgVector p0 (points[ptr->m_incidentVertex]); - dgVector p1 (points[ptr->m_next->m_incidentVertex]); - ptr = ptr->m_next->m_next; - do { - dgVector p2 (points[ptr->m_incidentVertex]); - dgVector p01 ((p0 + p1).Scale (dgFloat32 (0.5f))); - dgVector p12 ((p1 + p2).Scale (dgFloat32 (0.5f))); - dgVector p20 ((p2 + p0).Scale (dgFloat32 (0.5f))); - - CastBackFace (clusterNodeA, p0, p01, p20, distanceThreshold, clusterMap); - CastBackFace (clusterNodeA, p1, p12, p01, distanceThreshold, clusterMap); - CastBackFace (clusterNodeA, p2, p20, p12, distanceThreshold, clusterMap); - CastBackFace (clusterNodeA, p01, p12, p20, distanceThreshold, clusterMap); - - p1 = p2; - ptr = ptr->m_next; - } while (ptr != edgeA); - } - - Trace(); - } - - ~dgHACDClusterGraph () - { - for (dgInt32 i = 0; i < m_faceCount * 2; i ++) { - if (m_concavityTreeArray[i]) { - delete m_concavityTreeArray[i]; - } - } - - dgFreeStack(m_concavityTreeArray); - dgFreeStack(m_vertexPool); - dgFreeStack(m_vertexMarks); - } - - - void CastBackFace ( - dgListNode* const clusterNodeA, - const dgVector& p0, - const dgVector& p1, - const dgVector& p2, - dgFloat32 distanceThreshold, - dgTree<dgListNode*,dgInt32>& clusterMap) - { - dgVector origin ((p0 + p1 + p2).Scale (dgFloat32 (1.0f/3.0f))); - - dgFloat32 rayDistance = distanceThreshold * dgFloat32 (2.0f); - - dgHACDCluster& clusterA = clusterNodeA->GetInfo().m_nodeData; - dgHACDClusterFace& faceA = clusterA.GetFirst()->GetInfo(); - dgVector end (origin - dgVector (faceA.m_normal).Scale (rayDistance)); - - dgHACDRayCasterContext ray (origin, end, this, clusterA.m_color); - ForAllSectorsRayHit(ray, RayHit, &ray); - - if (ray.m_colorHit != -1) { - dgAssert (ray.m_colorHit != ray.m_myColor); - dgFloat32 distance = rayDistance * ray.m_param; - - if (distance < distanceThreshold) { - - dgAssert (ray.m_colorHit != clusterA.m_color); - dgAssert (clusterMap.Find(ray.m_colorHit)); - dgListNode* const clusterNodeB = clusterMap.Find(ray.m_colorHit)->GetInfo(); - dgHACDCluster& clusterB = clusterNodeB->GetInfo().m_nodeData; - - dgHACDClusterFace& faceB = clusterB.GetFirst()->GetInfo(); - dgEdge* const edgeB = faceB.m_edge; - - bool isAdjacent = false; - dgEdge* ptrA = faceA.m_edge; - do { - dgEdge* ptrB = edgeB; - do { - if (ptrB->m_twin == ptrA) { - ptrA = faceA.m_edge->m_prev; - isAdjacent = true; - break; - } - ptrB = ptrB->m_next; - } while (ptrB != edgeB); - - ptrA = ptrA->m_next; - } while (ptrA != faceA.m_edge); - - if (!isAdjacent) { - - isAdjacent = false; - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNode = clusterNodeA->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - if (edgeNode->GetInfo().m_node == clusterNodeB) { - isAdjacent = true; - break; - } - } - - if (!isAdjacent) { - - dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* const edgeNodeAB = clusterNodeA->GetInfo().AddEdge (clusterNodeB); - dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* const edgeNodeBA = clusterNodeB->GetInfo().AddEdge (clusterNodeA); - - dgHACDEdge& edgeAB = edgeNodeAB->GetInfo().m_edgeData; - dgHACDEdge& edgeBA = edgeNodeBA->GetInfo().m_edgeData; - edgeAB.m_backFaceHandicap = dgFloat64 (0.5f); - edgeBA.m_backFaceHandicap = dgFloat64 (0.5f); - } - } - } - } - } - - - void Trace() const - { - /* - for (dgListNode* clusterNodeA = GetFirst(); clusterNodeA; clusterNodeA = clusterNodeA->GetNext()) { - dgHACDCluster& clusterA = clusterNodeA->GetInfo().m_nodeData; - //dgHACDClusterFace& faceA = clusterA.GetFirst()->GetInfo(); - //dgEdge* const edgeA = faceA.m_edge; - - dgTrace (("cluster node: %d\n", clusterA.m_color)); - dgTrace ((" links: ")); - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeA = clusterNodeA->GetInfo().GetFirst(); edgeNodeA; edgeNodeA = edgeNodeA->GetNext()) { - dgListNode* const clusterNodeB = edgeNodeA->GetInfo().m_node; - dgHACDCluster& clusterB = clusterNodeB->GetInfo().m_nodeData; - dgTrace (("%d ", clusterB.m_color)); - } - dgTrace (("\n")); - } - dgTrace (("\n")); - */ - } - - - // you can insert cal callback here to print the progress as it collapse clusters - void ReportProgress () - { - m_progress ++; - if (m_reportProgressCallback) { - dgFloat32 progress = dgFloat32(m_progress) * m_invFaceCount; - m_reportProgressCallback (progress); - } - } - - dgMeshEffect* CreatePatitionMesh (dgMeshEffect& mesh, dgInt32 maxVertexPerHull) - { - dgMemoryAllocator* const allocator = mesh.GetAllocator(); - dgMeshEffect* const convexPartionMesh = new (allocator) dgMeshEffect(allocator, true); - - dgMeshEffect::dgVertexAtribute polygon[256]; - memset(polygon, 0, sizeof(polygon)); - dgArray<dgBigVector> convexVertexBuffer(mesh.GetCount(), GetAllocator()); - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - - convexPartionMesh->BeginBuild(); - dgFloat64 layer = dgFloat64 (0.0f); - for (dgList<dgHACDConvacityLookAheadTree*>::dgListNode* clusterNode = m_convexProximation.GetFirst(); clusterNode; clusterNode = clusterNode->GetNext()) { - dgHACDConvacityLookAheadTree* const cluster = clusterNode->GetInfo(); - - dgInt32 vertexCount = 0; - for (dgList<dgEdge*>::dgListNode* faceNode = cluster->m_faceList.GetFirst(); faceNode; faceNode = faceNode->GetNext()) { - dgEdge* const edge = faceNode->GetInfo(); - dgEdge* ptr = edge; - do { - dgInt32 index = ptr->m_incidentVertex; - convexVertexBuffer[vertexCount] = points[index]; - vertexCount++; - ptr = ptr->m_next; - } while (ptr != edge); - } - dgConvexHull3d convexHull(allocator, &convexVertexBuffer[0].m_x, sizeof(dgBigVector), vertexCount, 0.0, maxVertexPerHull); - if (convexHull.GetCount()) { - const dgBigVector* const vertex = convexHull.GetVertexPool(); - for (dgConvexHull3d::dgListNode* node = convexHull.GetFirst(); node; node = node->GetNext()) { - const dgConvexHull3DFace* const face = &node->GetInfo(); - - dgInt32 i0 = face->m_index[0]; - dgInt32 i1 = face->m_index[1]; - dgInt32 i2 = face->m_index[2]; - - polygon[0].m_vertex = vertex[i0]; - polygon[0].m_vertex.m_w = layer; - - polygon[1].m_vertex = vertex[i1]; - polygon[1].m_vertex.m_w = layer; - - polygon[2].m_vertex = vertex[i2]; - polygon[2].m_vertex.m_w = layer; - - convexPartionMesh->AddPolygon(3, &polygon[0].m_vertex.m_x, sizeof(dgMeshEffect::dgVertexAtribute), 0); - } - layer += dgFloat64 (1.0f); - } - } - convexPartionMesh->EndBuild(1.0e-5f); - - m_progress = m_faceCount - 1; - ReportProgress(); - - return convexPartionMesh; - } - - - - static dgFloat32 RayHit (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount) - { - dgHACDRayCasterContext& me = *((dgHACDRayCasterContext*) context); - dgVector normal (&polygon[indexArray[indexCount] * (strideInBytes / sizeof (dgFloat32))]); - dgFloat32 t = me.PolygonIntersect (normal, polygon, strideInBytes, indexArray, indexCount); - if (t < me.m_param) { - dgInt32 faceColor = me.m_me->GetTagId(indexArray); - if (faceColor != me.m_myColor) { - me.m_param = t; - me.m_colorHit = faceColor; - } - } - return t; - } - - - dgFloat64 ConcavityByFaceMedian (dgInt32 faceCountA, dgInt32 faceCountB) const - { - dgFloat64 faceCountCost = DG_CONCAVITY_SCALE * dgFloat64 (0.1f) * (faceCountA + faceCountB) * m_invFaceCount; - //faceCountCost *= 0; - return faceCountCost; - } - - dgFloat64 CalculateConcavityMetric (dgFloat64 convexConcavity, dgFloat64 area, dgFloat64 perimeter, dgInt32 faceCountA, dgInt32 faceCountB) const - { - dgFloat64 edgeCost = perimeter * perimeter / (dgFloat64(4.0f * dgPi) * area); - return convexConcavity * DG_CONCAVITY_SCALE + edgeCost + ConcavityByFaceMedian (faceCountA, faceCountB); - } - - void SubmitInitialEdgeCosts (dgMeshEffect& mesh) - { - m_mark ++; - for (dgListNode* clusterNodeA = GetFirst(); clusterNodeA; clusterNodeA = clusterNodeA->GetNext()) { - // call the progress callback - //ReportProgress(); - - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeAB = clusterNodeA->GetInfo().GetFirst(); edgeNodeAB; edgeNodeAB = edgeNodeAB->GetNext()) { - dgHACDEdge& edgeAB = edgeNodeAB->GetInfo().m_edgeData; - dgFloat64 weight = edgeAB.m_backFaceHandicap; - if (edgeAB.m_mark != m_mark) { - edgeAB.m_mark = m_mark; - dgListNode* const clusterNodeB = edgeNodeAB->GetInfo().m_node; - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeBA = clusterNodeB->GetInfo().GetFirst(); edgeNodeBA; edgeNodeBA = edgeNodeBA->GetNext()) { - dgListNode* const clusterNode = edgeNodeBA->GetInfo().m_node; - if (clusterNode == clusterNodeA) { - dgHACDEdge& edgeBA = edgeNodeBA->GetInfo().m_edgeData; - edgeBA.m_mark = m_mark; - dgAssert (!edgeAB.m_proxyListNode); - dgAssert (!edgeBA.m_proxyListNode); - - dgList<dgPairProxy>::dgListNode* const proxyNode = SubmitEdgeCost (mesh, clusterNodeA, clusterNodeB, weight * edgeBA.m_backFaceHandicap); - edgeAB.m_proxyListNode = proxyNode; - edgeBA.m_proxyListNode = proxyNode; - break; - } - } - } - } - } - } - - dgInt32 CopyVertexToPool(const dgMeshEffect& mesh, const dgHACDCluster& cluster, dgInt32 start) - { - dgInt32 count = start; - - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - for (dgList<dgHACDClusterFace>::dgListNode* node = cluster.GetFirst(); node; node = node->GetNext()) { - const dgHACDClusterFace& clusterFace = node->GetInfo(); - dgEdge* edge = clusterFace.m_edge; - do { - dgInt32 index = edge->m_incidentVertex; - if (m_vertexMarks[index] != m_vertexMark) { - m_vertexMarks[index] = m_vertexMark; - m_vertexPool[count] = points[index]; - count++; - } - edge = edge->m_next; - } while (edge != clusterFace.m_edge); - } - return count; - } - - - void MarkInteriorClusterEdges (dgMeshEffect& mesh, dgInt32 mark, const dgHACDCluster& cluster, dgInt32 colorA, dgInt32 colorB) const - { - dgAssert (colorA != colorB); - for (dgList<dgHACDClusterFace>::dgListNode* node = cluster.GetFirst(); node; node = node->GetNext()) { - dgHACDClusterFace& clusterFace = node->GetInfo(); - dgEdge* edge = clusterFace.m_edge; - do { - if ((edge->m_twin->m_incidentFace == colorA) || (edge->m_twin->m_incidentFace == colorB)) { - edge->m_mark = mark; - edge->m_twin->m_mark = mark; - } - edge = edge->m_next; - } while (edge != clusterFace.m_edge); - } - } - - dgFloat64 CalculateClusterPerimeter (dgMeshEffect& mesh, dgInt32 mark, const dgHACDCluster& cluster, dgInt32 colorA, dgInt32 colorB) const - { - dgAssert (colorA != colorB); - dgFloat64 perimeter = dgFloat64 (0.0f); - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - for (dgList<dgHACDClusterFace>::dgListNode* node = cluster.GetFirst(); node; node = node->GetNext()) { - dgHACDClusterFace& clusterFace = node->GetInfo(); - dgEdge* edge = clusterFace.m_edge; - do { - if (!((edge->m_twin->m_incidentFace == colorA) || (edge->m_twin->m_incidentFace == colorB))) { - dgBigVector p1p0(points[edge->m_twin->m_incidentVertex] - points[edge->m_incidentVertex]); - perimeter += sqrt(p1p0 % p1p0); - } - edge = edge->m_next; - } while (edge != clusterFace.m_edge); - } - - return perimeter; - } - - void HeapCollectGarbage () - { - if ((m_priorityHeap.GetCount() + 20) > m_priorityHeap.GetMaxCount()) { - for (dgInt32 i = m_priorityHeap.GetCount() - 1; i >= 0; i--) { - dgList<dgPairProxy>::dgListNode* const emptyNode = m_priorityHeap[i]; - dgPairProxy& emptyPair = emptyNode->GetInfo(); - if ((emptyPair.m_nodeA == NULL) && (emptyPair.m_nodeB == NULL)) { - m_priorityHeap.Remove(i); - } - } - } - } - - - dgFloat64 CalculateConcavity(dgHACDConveHull& hull, const dgMeshEffect& mesh, const dgHACDCluster& cluster) - { - dgFloat64 concavity = dgFloat32(0.0f); - - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - for (dgList<dgHACDClusterFace>::dgListNode* node = cluster.GetFirst(); node; node = node->GetNext()) { - dgHACDClusterFace& clusterFace = node->GetInfo(); - dgEdge* edge = clusterFace.m_edge; - dgInt32 i0 = edge->m_incidentVertex; - dgInt32 i1 = edge->m_next->m_incidentVertex; - for (dgEdge* ptr = edge->m_next->m_next; ptr != edge; ptr = ptr->m_next) { - dgInt32 i2 = ptr->m_incidentVertex; - dgFloat64 val = hull.CalculateTriangleConcavity(clusterFace.m_normal, i0, i1, i2, points); - if (val > concavity) { - concavity = val; - } - i1 = i2; - } - } - - return concavity; - } - - dgFloat64 CalculateConcavitySingleThread (dgHACDConveHull& hull, dgMeshEffect& mesh, dgHACDCluster& clusterA, dgHACDCluster& clusterB) - { - return dgMax(CalculateConcavity(hull, mesh, clusterA), CalculateConcavity(hull, mesh, clusterB)); - } - - - class dgConvexHullRayCastContext - { - public: - dgConvexHullRayCastContext (dgHACDConveHull& hull, dgMeshEffect& mesh, dgThreadHive* const manager) - :m_atomicLock(0) - ,m_mesh(&mesh) - ,m_cluster(NULL) - ,m_threadManager(manager) - ,m_faceNode(NULL) - { - for(dgInt32 i = 0; i < DG_CONCAVITY_MAX_THREADS; i ++) { - hullArray[i] = new (mesh.GetAllocator()) dgHACDConveHull (hull); - } - } - - ~dgConvexHullRayCastContext () - { - for(dgInt32 i = 0; i < DG_CONCAVITY_MAX_THREADS; i ++) { - delete hullArray[i]; - } - } - - void SetCluster (dgHACDCluster& cluster) - { - m_cluster = &cluster; - m_node = m_cluster->GetFirst(); - memset (m_concavity, 0, sizeof (m_concavity)); - } - - dgFloat64 GetConcavity() const - { - dgFloat64 concavity = dgFloat32(0.0f); - for (dgInt32 i = 0; i < DG_CONCAVITY_MAX_THREADS; i ++) { - if (concavity < m_concavity[i]) { - concavity = m_concavity[i]; - } - } - return concavity; - } - - - static void RayCastKernel (void* const context, dgInt32 threadID) - { - dgConvexHullRayCastContext* const data = (dgConvexHullRayCastContext*) context; - const dgBigVector* const points = (dgBigVector*) data->m_mesh->GetVertexPool(); - - data->m_threadManager->GetIndirectLock(&data->m_atomicLock, threadID); - dgList<dgHACDClusterFace>::dgListNode* node = data->m_node; - if (node) { - data->m_node = node->GetNext(); - } - data->m_threadManager->ReleaseIndirectLock (&data->m_atomicLock); - for (; node;) { - - dgHACDClusterFace& clusterFace = node->GetInfo(); - dgEdge* edge = clusterFace.m_edge; - dgInt32 i0 = edge->m_incidentVertex; - dgInt32 i1 = edge->m_next->m_incidentVertex; - for (dgEdge* ptr = edge->m_next->m_next; ptr != edge; ptr = ptr->m_next) { - dgInt32 i2 = ptr->m_incidentVertex; - dgFloat64 val = data->hullArray[threadID]->CalculateTriangleConcavity(clusterFace.m_normal, i0, i1, i2, points); - if (val > data->m_concavity[threadID]) { - data->m_concavity[threadID] = val; - } - i1 = i2; - } - - data->m_threadManager->GetIndirectLock(&data->m_atomicLock, threadID); - node = data->m_node; - if (node) { - data->m_node = node->GetNext();; - } - data->m_threadManager->ReleaseIndirectLock (&data->m_atomicLock); - } - } - - - dgInt32 m_atomicLock; - dgMeshEffect* m_mesh; - dgHACDCluster* m_cluster; - dgThreadHive* m_threadManager; - dgList<dgHACDClusterFace>::dgListNode* m_node; - - dgList<dgHACDClusterFace>::dgListNode* m_faceNode; - dgFloat64 m_concavity[DG_CONCAVITY_MAX_THREADS]; - dgHACDConveHull* hullArray[DG_CONCAVITY_MAX_THREADS]; - }; - - - dgFloat64 CalculateConcavityMultiThread (dgHACDConveHull& hull, dgMeshEffect& mesh, dgHACDCluster& clusterA, dgHACDCluster& clusterB) - { - dgConvexHullRayCastContext data (hull, mesh, &m_parallerConcavityCalculator); - - dgInt32 threadsCount = m_parallerConcavityCalculator.GetThreadCount(); - data.SetCluster (clusterA); - for (dgInt32 i = 0; i < threadsCount; i ++) { - m_parallerConcavityCalculator.QueueJob(dgConvexHullRayCastContext::RayCastKernel, &data); - } - m_parallerConcavityCalculator.SynchronizationBarrier(); - dgFloat64 concavity = data.GetConcavity(); - - data.SetCluster (clusterB); - for (dgInt32 i = 0; i < threadsCount; i ++) { - m_parallerConcavityCalculator.QueueJob(dgConvexHullRayCastContext::RayCastKernel, &data); - } - m_parallerConcavityCalculator.SynchronizationBarrier(); - - concavity = dgMax(concavity, data.GetConcavity()); - //dgFloat64 xxx = CalculateConcavitySingleThread (hull, mesh, clusterA, clusterB); - //dgAssert (fabs(concavity - xxx) < dgFloat64 (1.0e-5f)); - return concavity; - } - - dgList<dgPairProxy>::dgListNode* SubmitEdgeCost (dgMeshEffect& mesh, dgListNode* const clusterNodeA, dgListNode* const clusterNodeB, dgFloat64 perimeterHandicap) - { - dgHACDCluster& clusterA = clusterNodeA->GetInfo().m_nodeData; - dgHACDCluster& clusterB = clusterNodeB->GetInfo().m_nodeData; - const dgBigVector* const points = (dgBigVector*) mesh.GetVertexPool(); - - bool flatStrip = true; - dgFloat64 tol = dgFloat64 (1.0e-5f) * m_diagonal; - dgHACDClusterFace& clusterFaceA = clusterA.GetFirst()->GetInfo(); - dgBigPlane plane(clusterFaceA.m_normal, -(points[clusterFaceA.m_edge->m_incidentVertex] % clusterFaceA.m_normal)); - - if (clusterA.GetCount() > 1) { - flatStrip = clusterA.IsCoplanar(plane, mesh, tol); - } - - if (flatStrip) { - flatStrip = clusterB.IsCoplanar(plane, mesh, tol); - } - - dgList<dgPairProxy>::dgListNode* pairNode = NULL; - if (!flatStrip) { - m_vertexMark ++; - dgInt32 vertexCount = CopyVertexToPool(mesh, clusterA, 0); - vertexCount = CopyVertexToPool(mesh, clusterB, vertexCount); - - dgHACDConveHull convexHull(mesh.GetAllocator(), m_vertexPool, vertexCount); - - if (convexHull.GetVertexCount()) { - dgInt32 mark = mesh.IncLRU(); - MarkInteriorClusterEdges (mesh, mark, clusterA, clusterA.m_color, clusterB.m_color); - MarkInteriorClusterEdges (mesh, mark, clusterB, clusterA.m_color, clusterB.m_color); - - dgFloat64 area = clusterA.m_area + clusterB.m_area; - dgFloat64 perimeter = CalculateClusterPerimeter (mesh, mark, clusterA, clusterA.m_color, clusterB.m_color) + - CalculateClusterPerimeter (mesh, mark, clusterB, clusterA.m_color, clusterB.m_color); - - - dgFloat64 concavity = dgFloat64 (0.0f); - if ((convexHull.GetCount() > 128) && ((clusterA.GetCount() > 256) || (clusterB.GetCount() > 256))) { - concavity = CalculateConcavityMultiThread (convexHull, mesh, clusterA, clusterB); - } else { - concavity = CalculateConcavitySingleThread (convexHull, mesh, clusterA, clusterB); - } - - if (concavity < dgFloat64(1.0e-3f)) { - concavity = dgFloat64(0.0f); - } - - // see if the heap will overflow - HeapCollectGarbage (); - - // add a new pair to the heap - dgList<dgPairProxy>::dgListNode* pairNode = m_proxyList.Append(); - dgPairProxy& pair = pairNode->GetInfo(); - pair.m_nodeA = clusterNodeA; - pair.m_nodeB = clusterNodeB; - pair.m_distanceConcavity = concavity; - pair.m_hierachicalClusterIndexA = clusterA.m_hierachicalClusterIndex; - pair.m_hierachicalClusterIndexB = clusterB.m_hierachicalClusterIndex; - - pair.m_area = area; - dgFloat64 cost = CalculateConcavityMetric (concavity, area, perimeter * perimeterHandicap, clusterA.GetCount(), clusterB.GetCount()); - m_priorityHeap.Push(pairNode, cost); - - return pairNode; - } - } - return pairNode; - } - - - void CollapseEdge (dgList<dgPairProxy>::dgListNode* const pairNode, dgMeshEffect& mesh, dgFloat64 concavity) - { - dgListNode* adjacentNodes[1024]; - dgPairProxy& pair = pairNode->GetInfo(); - - dgMemoryAllocator* const allocator = mesh.GetAllocator(); - - - dgAssert((pair.m_nodeA && pair.m_nodeB) || (!pair.m_nodeA && !pair.m_nodeB)); - if (pair.m_nodeA && pair.m_nodeB) { - // call the progress callback - ReportProgress(); - - dgListNode* const clusterNodeA = pair.m_nodeA; - dgListNode* const clusterNodeB = pair.m_nodeB; - dgAssert (clusterNodeA != clusterNodeB); - - dgHACDCluster& clusterA = clusterNodeA->GetInfo().m_nodeData; - dgHACDCluster& clusterB = clusterNodeB->GetInfo().m_nodeData; - - dgAssert (&clusterA != &clusterB); - dgAssert(clusterA.m_color != clusterB.m_color); - - dgHACDConvacityLookAheadTree* const leftTree = m_concavityTreeArray[pair.m_hierachicalClusterIndexA]; - dgHACDConvacityLookAheadTree* const rightTree = m_concavityTreeArray[pair.m_hierachicalClusterIndexB]; - dgAssert (leftTree); - dgAssert (rightTree); - m_concavityTreeArray[pair.m_hierachicalClusterIndexA] = NULL; - m_concavityTreeArray[pair.m_hierachicalClusterIndexB] = NULL; - dgAssert (m_cancavityTreeIndex < (2 * (m_faceCount + 1))); - - dgFloat64 treeConcavity = pair.m_distanceConcavity; -// dgAssert (treeConcavity < 0.1); - m_concavityTreeArray[m_cancavityTreeIndex] = new (allocator) dgHACDConvacityLookAheadTree (allocator, leftTree, rightTree, treeConcavity); - clusterA.m_hierachicalClusterIndex = m_cancavityTreeIndex; - clusterB.m_hierachicalClusterIndex = m_cancavityTreeIndex; - m_cancavityTreeIndex ++; - - // merge two clusters - while (clusterB.GetCount()) { - - dgHACDCluster::dgListNode* const nodeB = clusterB.GetFirst(); - clusterB.Unlink(nodeB); - - // now color code all faces of the merged cluster - dgHACDClusterFace& faceB = nodeB->GetInfo(); - dgEdge* ptr = faceB.m_edge; - do { - ptr->m_incidentFace = clusterA.m_color; - ptr = ptr->m_next; - } while (ptr != faceB.m_edge); - clusterA.Append(nodeB); - } - clusterA.m_area = pair.m_area; - clusterA.m_concavity = concavity; - - // invalidate all proxies that are still in the heap - dgInt32 adjacentCount = 1; - adjacentNodes[0] = clusterNodeA; - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeAB = clusterNodeA->GetInfo().GetFirst(); edgeNodeAB; edgeNodeAB = edgeNodeAB->GetNext()) { - dgHACDEdge& edgeAB = edgeNodeAB->GetInfo().m_edgeData; - dgList<dgPairProxy>::dgListNode* const proxyNode = (dgList<dgPairProxy>::dgListNode*) edgeAB.m_proxyListNode; - if (proxyNode) { - dgPairProxy& pairProxy = proxyNode->GetInfo(); - dgAssert ((edgeNodeAB->GetInfo().m_node == pairProxy.m_nodeA) || (edgeNodeAB->GetInfo().m_node == pairProxy.m_nodeB)); - pairProxy.m_nodeA = NULL; - pairProxy.m_nodeB = NULL; - edgeAB.m_proxyListNode = NULL; - } - - adjacentNodes[adjacentCount] = edgeNodeAB->GetInfo().m_node; - adjacentCount ++; - dgAssert (adjacentCount < sizeof (adjacentNodes)/ sizeof (adjacentNodes[0])); - } - - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeBA = clusterNodeB->GetInfo().GetFirst(); edgeNodeBA; edgeNodeBA = edgeNodeBA->GetNext()) { - dgHACDEdge& edgeBA = edgeNodeBA->GetInfo().m_edgeData; - dgList<dgPairProxy>::dgListNode* const proxyNode = (dgList<dgPairProxy>::dgListNode*) edgeBA.m_proxyListNode; - if (proxyNode) { - dgPairProxy& pairProxy = proxyNode->GetInfo(); - pairProxy.m_nodeA = NULL; - pairProxy.m_nodeB = NULL; - edgeBA.m_proxyListNode = NULL; - } - - bool alreadyLinked = false; - dgListNode* const node = edgeNodeBA->GetInfo().m_node; - for (dgInt32 i = 0; i < adjacentCount; i ++) { - if (node == adjacentNodes[i]) { - alreadyLinked = true; - break; - } - } - if (!alreadyLinked) { - clusterNodeA->GetInfo().AddEdge (node); - node->GetInfo().AddEdge (clusterNodeA); - } - } - DeleteNode (clusterNodeB); - - // submit all new costs for each edge connecting this new node to any other node - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeAB = clusterNodeA->GetInfo().GetFirst(); edgeNodeAB; edgeNodeAB = edgeNodeAB->GetNext()) { - dgHACDEdge& edgeAB = edgeNodeAB->GetInfo().m_edgeData; - dgListNode* const clusterNodeB = edgeNodeAB->GetInfo().m_node; - dgFloat64 weigh = edgeAB.m_backFaceHandicap; - for (dgGraphNode<dgHACDCluster, dgHACDEdge>::dgListNode* edgeNodeBA = clusterNodeB->GetInfo().GetFirst(); edgeNodeBA; edgeNodeBA = edgeNodeBA->GetNext()) { - dgListNode* const clusterNode = edgeNodeBA->GetInfo().m_node; - if (clusterNode == clusterNodeA) { - dgHACDEdge& edgeBA = edgeNodeBA->GetInfo().m_edgeData; - dgList<dgPairProxy>::dgListNode* const proxyNode = SubmitEdgeCost (mesh, clusterNodeA, clusterNodeB, weigh * edgeBA.m_backFaceHandicap); - if (proxyNode) { - edgeBA.m_proxyListNode = proxyNode; - edgeAB.m_proxyListNode = proxyNode; - } - break; - } - } - } - } - m_proxyList.Remove(pairNode); - } - -#ifdef DG_BUILD_HIERACHICAL_HACD - void CollapseClusters (dgMeshEffect& mesh, dgFloat64 maxConcavity, dgInt32 maxClustesCount) - { - - maxConcavity *= (m_diagonal * DG_CONCAVITY_SCALE); - while (m_priorityHeap.GetCount()) { - dgFloat64 concavity = m_priorityHeap.Value(); - dgList<dgPairProxy>::dgListNode* const pairNode = m_priorityHeap[0]; - m_priorityHeap.Pop(); - CollapseEdge (pairNode, mesh, concavity); - -//if (m_progress == 24) -//break; - - } - - - - dgInt32 treeCounts = 0; - for (dgInt32 i = 0; i < m_cancavityTreeIndex; i ++) { - if (m_concavityTreeArray[i]) { - m_concavityTreeArray[treeCounts] = m_concavityTreeArray[i]; - m_concavityTreeArray[i] = NULL; - treeCounts ++; - } - } - - if (treeCounts > 1) { - - for (dgInt32 i = 0; i < treeCounts; i ++) { - if (m_concavityTreeArray[i]->m_faceList.GetCount()==1) { - delete m_concavityTreeArray[i]; - m_concavityTreeArray[i] = m_concavityTreeArray[treeCounts-1]; - m_concavityTreeArray[treeCounts-1]= NULL; - treeCounts --; - i--; - } - } - - - dgFloat32 C = 10000; - while (treeCounts > 1) { - dgHACDConvacityLookAheadTree* const leftTree = m_concavityTreeArray[treeCounts-1]; - dgHACDConvacityLookAheadTree* const rightTree = m_concavityTreeArray[treeCounts-2]; - m_concavityTreeArray[treeCounts-1] = NULL; - m_concavityTreeArray[treeCounts-2] = new (mesh.GetAllocator()) dgHACDConvacityLookAheadTree (mesh.GetAllocator(), leftTree, rightTree, C); - C *= 2; - treeCounts --; - } - - } - - dgHACDConvacityLookAheadTree* const tree = m_concavityTreeArray[0]; - dgDownHeap<dgHACDConvacityLookAheadTree*, dgFloat64> approximation(maxClustesCount * 2, mesh.GetAllocator()); - - tree->ReduceByCount (maxClustesCount, approximation); - // tree->ReduceByConcavity (maxConcavity, approximation); - - while (approximation.GetCount()) { - m_convexProximation.Append(approximation[0]); - approximation.Pop(); - } - } -#else - void CollapseClusters (dgMeshEffect& mesh, dgFloat64 maxConcavity, dgInt32 maxClustesCount) - { - maxConcavity *= (m_diagonal * DG_CONCAVITY_SCALE); - - bool terminate = false; - while (m_priorityHeap.GetCount() && !terminate) { - dgFloat64 concavity = m_priorityHeap.Value(); - dgList<dgPairProxy>::dgListNode* const pairNode = m_priorityHeap[0]; - if ((concavity < maxConcavity) && (GetCount() < maxClustesCount)) { - terminate = true; - } else { - m_priorityHeap.Pop(); - CollapseEdge (pairNode, mesh, concavity); - } - } - } -#endif - - dgInt32 m_mark; - dgInt32 m_faceCount; - dgInt32 m_vertexMark; - dgInt32 m_progress; - dgInt32 m_cancavityTreeIndex; - dgInt32* m_vertexMarks; - dgFloat32 m_invFaceCount; - dgFloat64 m_diagonal; - dgBigVector* m_vertexPool; - dgList<dgPairProxy> m_proxyList; - dgHACDConvacityLookAheadTree** m_concavityTreeArray; - dgList<dgHACDConvacityLookAheadTree*> m_convexProximation; - dgUpHeap<dgList<dgPairProxy>::dgListNode*, dgFloat64> m_priorityHeap; - dgReportProgress m_reportProgressCallback; - dgThreadHive m_parallerConcavityCalculator; -}; - -#endif - -dgMeshEffect* dgMeshEffect::CreateSimplification(dgInt32 maxVertexCount, dgReportProgress reportProgressCallback, void* const reportPrgressUserData) const -{ - if (GetVertexCount() <= maxVertexCount) { - return new (GetAllocator()) dgMeshEffect(*this); - } -dgAssert (0); -return new (GetAllocator()) dgMeshEffect(*this); -/* - // dgMeshEffect triangleMesh(*this); - if (maxHullsCount <= 1) { - maxHullsCount = 1; - } - if (maxConcavity <= dgFloat32 (1.0e-5f)) { - maxConcavity = dgFloat32 (1.0e-5f); - } - - if (maxVertexPerHull < 4) { - maxVertexPerHull = 4; - } - ClampValue(backFaceDistanceFactor, dgFloat32 (0.01f), dgFloat32 (1.0f)); - - if (reportProgressCallback) { - reportProgressCallback (0.0f); - } - - - // make a copy of the mesh - dgMeshEffect mesh(*this); - mesh.ClearAttributeArray(); - - - dgInt32 faceCount = mesh.GetTotalFaceCount(); - if (faceCount > meshSimplicationMaxFaceCount) { - mesh.Triangulate(); - - dgPolyhedra polygon(GetAllocator()); - dgInt32 mark = mesh.IncLRU(); - polygon.BeginFace(); - dgPolyhedra::Iterator iter (mesh); - for (iter.Begin(); iter; iter ++){ - dgEdge* const face = &(*iter); - - if ((face->m_mark != mark) && (face->m_incidentFace > 0)) { - dgInt32 index[DG_MESH_EFFECT_POINT_SPLITED]; - - dgEdge* ptr = face; - dgInt32 indexCount = 0; - do { - index[indexCount] = ptr->m_incidentVertex; - ptr->m_mark = mark; - indexCount ++; - ptr = ptr->m_next; - } while (ptr != face); - polygon.AddFace(indexCount, index); - } - } - polygon.EndFace(); - - polygon.Optimize(&mesh.m_points[0].m_x, sizeof (dgFloat64), 1000.0f, meshSimplicationMaxFaceCount); - - mesh.RemoveAll(); - - mark = polygon.IncLRU(); - mesh.BeginFace(); - dgPolyhedra::Iterator iter1 (polygon); - for (iter1.Begin(); iter1; iter1 ++){ - dgEdge* const face = &(*iter1); - if ((face->m_mark != mark) && (face->m_incidentFace > 0)) { - dgInt32 index[DG_MESH_EFFECT_POINT_SPLITED]; - dgEdge* ptr = face; - dgInt32 indexCount = 0; - do { - ptr->m_mark = mark; - index[indexCount] = dgInt32 (ptr->m_incidentVertex); - indexCount ++; - ptr = ptr->m_next; - } while (ptr != face); - mesh.AddFace(indexCount, index); - } - } - mesh.EndFace(); - - faceCount = mesh.GetTotalFaceCount(); - mesh.ClearAttributeArray(); - } - - // create a general connectivity graph - dgHACDClusterGraph graph (mesh, backFaceDistanceFactor, reportProgressCallback); - - // calculate initial edge costs - graph.SubmitInitialEdgeCosts (mesh); - - // collapse the graph - graph.CollapseClusters (mesh, maxConcavity, maxHullsCount); - - // Create Partition Mesh - return graph.CreatePatitionMesh (mesh, maxVertexPerHull); -*/ -} diff --git a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect5.cpp b/thirdparty/src/newton/dgMeshUtil/dgMeshEffect5.cpp deleted file mode 100644 index c33ec3786..000000000 --- a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect5.cpp +++ /dev/null @@ -1,1160 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgMeshEffect.h" -#include "dgCollisionConvexHull.h" - - - -bool dgMeshEffect::PlaneClip(const dgMeshEffect& convexMesh, const dgEdge* const convexFace) -{ - dgAssert (convexFace->m_incidentFace > 0); - - dgBigVector normal (convexMesh.FaceNormal(convexFace, &convexMesh.m_points.m_vertex[0].m_x, sizeof(dgBigVector))); - dgFloat64 mag2 = normal.DotProduct(normal).GetScalar(); - if (mag2 < dgFloat64 (1.0e-30)) { - dgAssert (0); - return true; - } - - normal = normal.Normalize(); - dgBigVector origin (convexMesh.m_points.m_vertex[convexFace->m_incidentVertex]); - dgBigPlane plane (normal, - origin.DotProduct(normal).GetScalar()); - - dgAssert (!HasOpenEdges()); - - dgInt32 pointCount = GetVertexCount(); - dgStack <dgFloat64> testPool (2 * pointCount + 1024); - dgFloat64* const test = &testPool[0]; - for (dgInt32 i = 0; i < pointCount; i ++) { - test[i] = plane.Evalue (m_points.m_vertex[i]); - if (fabs (test[i]) < dgFloat32 (1.0e-5f)) { - test[i] = dgFloat32 (0.0f); - } - } - - dgInt32 positive = 0; - dgInt32 negative = 0; - dgPolyhedra::Iterator iter (*this); - for (iter.Begin(); iter && !(positive && negative); iter ++){ - dgEdge* const edge = &(*iter); - positive += test[edge->m_incidentVertex] > dgFloat32 (0.0f); - negative += test[edge->m_incidentVertex] < dgFloat32 (0.0f); - } - if (positive && !negative) { - return false; - } - - if (positive && negative) { - const dgEdge* e0 = convexFace; - const dgEdge* e1 = e0->m_next; - const dgEdge* e2 = e1->m_next; - - dgMatrix matrix; - dgBigVector p1 (convexMesh.m_points.m_vertex[e1->m_incidentVertex]); - - dgBigVector xDir (p1 - origin); - dgAssert(xDir.m_w == dgFloat32(0.0f)); - dgAssert (xDir.DotProduct(xDir).GetScalar() > dgFloat32 (0.0f)); - matrix[2] = dgVector (normal); - matrix[0] = dgVector(xDir.Scale(dgFloat64 (1.0f) / sqrt (xDir.DotProduct(xDir).GetScalar()))); - matrix[1] = matrix[2].CrossProduct(matrix[0]); - matrix[3] = dgVector (origin); - matrix[3][3] = dgFloat32 (1.0f); - - dgVector q0 (matrix.UntransformVector(dgVector(convexMesh.m_points.m_vertex[e0->m_incidentVertex]))); - dgVector q1 (matrix.UntransformVector(dgVector(convexMesh.m_points.m_vertex[e1->m_incidentVertex]))); - dgVector q2 (matrix.UntransformVector(dgVector(convexMesh.m_points.m_vertex[e2->m_incidentVertex]))); - - dgVector p10 (q1 - q0); - dgVector p20 (q2 - q0); - dgVector faceNormal (matrix.UnrotateVector (dgVector(normal))); - dgAssert(faceNormal.m_w == dgFloat32(0.0f)); - dgFloat32 areaInv = faceNormal.DotProduct(p10.CrossProduct(p20)).GetScalar(); - if (e2->m_next != e0) { - const dgEdge* edge = e2; - dgVector r1 (q2); - dgVector q10 (p20); - do { - dgVector r2 (matrix.UntransformVector(dgVector(convexMesh.m_points.m_vertex[edge->m_next->m_incidentVertex]))); - dgVector q20 (r2 - q0); - dgFloat32 areaInv1 = faceNormal.DotProduct(q10.CrossProduct(q20)).GetScalar(); - if (areaInv1 > areaInv) { - e1 = edge; - e2 = edge->m_next; - q1 = r1; - q2 = r2; - areaInv = areaInv1; - } - r1 = r2; - q10 = q20; - edge = edge->m_next; - } while (edge->m_next != e0); - } - - dgAssert (areaInv > dgFloat32 (0.0f)); - areaInv = dgFloat32 (1.0f) / areaInv; - - dgVector uv0[3]; - dgVector uv1[3]; - memset(uv0, 0, sizeof(uv0)); - memset(uv1, 0, sizeof(uv1)); - if (m_attrib.m_uv0Channel.m_count && convexMesh.m_attrib.m_uv0Channel.m_count) { - uv0[0] = dgVector (dgFloat32(convexMesh.m_attrib.m_uv0Channel[dgInt32 (e0->m_userData)].m_u), dgFloat32(convexMesh.m_attrib.m_uv0Channel[dgInt32(e0->m_userData)].m_v), dgFloat32(0.0f), dgFloat32(0.0f)); - uv0[1] = dgVector(dgFloat32(convexMesh.m_attrib.m_uv0Channel[dgInt32 (e1->m_userData)].m_u), dgFloat32(convexMesh.m_attrib.m_uv0Channel[dgInt32(e1->m_userData)].m_v), dgFloat32(0.0f), dgFloat32(0.0f)); - uv0[2] = dgVector(dgFloat32(convexMesh.m_attrib.m_uv0Channel[dgInt32 (e2->m_userData)].m_u), dgFloat32(convexMesh.m_attrib.m_uv0Channel[dgInt32(e2->m_userData)].m_v), dgFloat32(0.0f), dgFloat32(0.0f)); - } - - if (m_attrib.m_uv1Channel.m_count && convexMesh.m_attrib.m_uv1Channel.m_count) { - uv1[0] = dgVector(dgFloat32(convexMesh.m_attrib.m_uv1Channel[dgInt32(e0->m_userData)].m_u), dgFloat32(convexMesh.m_attrib.m_uv1Channel[dgInt32(e0->m_userData)].m_v), dgFloat32(0.0f), dgFloat32(0.0f)); - uv1[1] = dgVector(dgFloat32(convexMesh.m_attrib.m_uv1Channel[dgInt32(e1->m_userData)].m_u), dgFloat32(convexMesh.m_attrib.m_uv1Channel[dgInt32(e1->m_userData)].m_v), dgFloat32(0.0f), dgFloat32(0.0f)); - uv1[2] = dgVector(dgFloat32(convexMesh.m_attrib.m_uv1Channel[dgInt32(e2->m_userData)].m_u), dgFloat32(convexMesh.m_attrib.m_uv1Channel[dgInt32(e2->m_userData)].m_v), dgFloat32(0.0f), dgFloat32(0.0f)); - } - - for (iter.Begin(); iter; iter ++){ - dgEdge* const edge = &(*iter); - - dgFloat64 side0 = test[edge->m_prev->m_incidentVertex]; - dgFloat64 side1 = test[edge->m_incidentVertex]; - - if ((side0 < dgFloat32 (0.0f)) && (side1 > dgFloat64 (0.0f))) { - dgBigVector dp (m_points.m_vertex[edge->m_incidentVertex] - m_points.m_vertex[edge->m_prev->m_incidentVertex]); - dgAssert(dp.m_w == dgFloat32(0.0f)); - dgFloat64 param = - side0 / plane.DotProduct(dp).GetScalar(); - - dgEdge* const splitEdge = InsertEdgeVertex (edge->m_prev, param); - test[splitEdge->m_next->m_incidentVertex] = dgFloat64 (0.0f); - } - } - - dgInt32 colorMark = IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - dgFloat64 side0 = test[edge->m_incidentVertex]; - dgFloat64 side1 = test[edge->m_next->m_incidentVertex]; - - if ((side0 > dgFloat32 (0.0f)) || (side1 > dgFloat64 (0.0f))) { - edge->m_mark = colorMark; - } - } - - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - dgFloat64 side0 = test[edge->m_incidentVertex]; - dgFloat64 side1 = test[edge->m_next->m_incidentVertex]; - if ((side0 == dgFloat32 (0.0f)) && (side1 == dgFloat64 (0.0f))) { - dgEdge* ptr = edge->m_next; - do { - if (ptr->m_mark == colorMark) { - edge->m_mark = colorMark; - break; - } - ptr = ptr->m_next; - } while (ptr != edge); - } - } - - - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if ((edge->m_mark == colorMark) && (edge->m_next->m_mark < colorMark)) { - dgEdge* const startEdge = edge->m_next; - dgEdge* end = startEdge; - do { - if (end->m_mark == colorMark) { - break; - } - - end = end->m_next; - } while (end != startEdge); - dgAssert (end != startEdge); - dgEdge* const devideEdge = ConnectVertex (startEdge, end); - dgAssert (devideEdge); - dgAssert (devideEdge->m_next->m_mark != colorMark); - dgAssert (devideEdge->m_prev->m_mark != colorMark); - dgAssert (devideEdge->m_twin->m_next->m_mark == colorMark); - dgAssert (devideEdge->m_twin->m_prev->m_mark == colorMark); - devideEdge->m_mark = colorMark - 1; - devideEdge->m_twin->m_mark = colorMark; - } - } - - dgInt32 mark = IncLRU(); - dgList<dgEdge*> faceList (GetAllocator()); - for (iter.Begin(); iter; iter ++){ - dgEdge* const face = &(*iter); - if ((face->m_mark >= colorMark) && (face->m_mark != mark)) { - faceList.Append(face); - dgEdge* edge = face; - do { - edge->m_mark = mark; - edge = edge->m_next; - } while (edge != face); - } - } - - for (dgList<dgEdge*>::dgListNode* node = faceList.GetFirst(); node; node = node->GetNext()) { - dgEdge* const face = node->GetInfo(); - DeleteFace(face); - } - - mark = IncLRU(); - faceList.RemoveAll(); - for (iter.Begin(); iter; iter ++){ - dgEdge* const face = &(*iter); - if ((face->m_mark != mark) && (face->m_incidentFace < 0)) { - faceList.Append(face); - dgEdge* edge = face; - do { - edge->m_mark = mark; - edge = edge->m_next; - } while (edge != face); - } - } - - - const dgInt32 capAttribute = convexMesh.m_attrib.m_materialChannel.m_count ? convexMesh.m_attrib.m_materialChannel[dgInt32 (convexFace->m_userData)] : 0; - for (dgList<dgEdge*>::dgListNode* node = faceList.GetFirst(); node; node = node->GetNext()) { - dgEdge* const face = node->GetInfo(); - - dgEdge* edge = face; - do { - edge->m_incidentFace = 1; - edge->m_userData = m_attrib.m_pointChannel.m_count; - - m_attrib.m_pointChannel.PushBack(edge->m_incidentVertex); - if (m_attrib.m_normalChannel.m_count) { - dgTriplex n; - n.m_x = dgFloat32(normal.m_x); - n.m_y = dgFloat32(normal.m_y); - n.m_z = dgFloat32(normal.m_z); - m_attrib.m_normalChannel.PushBack(n); - } - - if (m_attrib.m_binormalChannel.m_count) { - dgAssert(0); - } - - if (m_attrib.m_colorChannel.m_count) { - dgAssert(0); - } - - if (m_attrib.m_materialChannel.m_count) { - m_attrib.m_materialChannel.PushBack(capAttribute); - } - - //dgVector p (matrix.UntransformVector (attibute.m_vertex)); - dgVector p (matrix.UntransformVector(m_points.m_vertex[edge->m_incidentVertex])); - dgVector p_p0 (p - q0); - dgVector p_p1 (p - q1); - dgVector p_p2 (p - q2); - dgAssert(faceNormal.m_w == dgFloat32 (0.0f)); - dgFloat32 alpha0 = faceNormal.DotProduct(p_p1.CrossProduct(p_p2)).GetScalar() * areaInv; - dgFloat32 alpha1 = faceNormal.DotProduct(p_p2.CrossProduct(p_p0)).GetScalar() * areaInv; - dgFloat32 alpha2 = faceNormal.DotProduct(p_p0.CrossProduct(p_p1)).GetScalar() * areaInv; - - //alpha0 = 0.0f; - //alpha1 = 0.0f; - //alpha2 = 0.0;; - if (m_attrib.m_uv0Channel.m_count && convexMesh.m_attrib.m_uv0Channel.m_count) { - dgAttibutFormat::dgUV uv; - uv.m_u = uv0[0].m_x * alpha0 + uv0[1].m_x * alpha1 + uv0[2].m_x * alpha2; - uv.m_v = uv0[0].m_y * alpha0 + uv0[1].m_y * alpha1 + uv0[2].m_y * alpha2; - m_attrib.m_uv0Channel.PushBack(uv); - } - - if (m_attrib.m_uv1Channel.m_count && convexMesh.m_attrib.m_uv1Channel.m_count) { - dgAttibutFormat::dgUV uv; - uv.m_u = uv1[0].m_x * alpha0 + uv1[1].m_x * alpha1 + uv1[2].m_x * alpha2; - uv.m_v = uv1[0].m_y * alpha0 + uv1[1].m_y * alpha1 + uv1[2].m_y * alpha2; - m_attrib.m_uv1Channel.PushBack(uv); - } - - edge = edge->m_next; - } while (edge != face); - } - } - - return true; -} - - -dgMeshEffect* dgMeshEffect::ConvexMeshIntersection (const dgMeshEffect* const convexMeshSrc) const -{ - dgMeshEffect convexMesh (*convexMeshSrc); - convexMesh.ConvertToPolygons(); - dgMeshEffect* const convexIntersection = new (GetAllocator()) dgMeshEffect (*this); - - dgInt32 mark = convexMesh.IncLRU(); - dgPolyhedra::Iterator iter (convexMesh); - - for (iter.Begin(); iter; iter ++){ - dgEdge* const convexFace = &(*iter); - if ((convexFace->m_incidentFace > 0) && (convexFace->m_mark != mark)) { - dgEdge* ptr = convexFace; - do { - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != convexFace); - if (!convexIntersection->PlaneClip(convexMesh, convexFace)) { - delete convexIntersection; - return NULL; - } - } - } - - if (!convexIntersection->GetVertexCount()) { - delete convexIntersection; - return NULL; - } - convexIntersection->RemoveUnusedVertices(NULL); - return convexIntersection; -} - - -void dgMeshEffect::ClipMesh (const dgMatrix& matrix, const dgMeshEffect* const clipMesh, dgMeshEffect** const back, dgMeshEffect** const front) const -{ - dgAssert (0); -/* - dgMeshEffect clipper (*clipMesh); - clipper.TransformMesh (matrix); - - dgMeshEffect* backMeshSource = NULL; - dgMeshEffect* frontMeshSource = NULL; - dgMeshEffect* backMeshClipper = NULL; - dgMeshEffect* frontMeshClipper = NULL; - - ClipMesh (&clipper, &backMeshSource, &frontMeshSource); - if (backMeshSource && frontMeshSource) { - clipper.ClipMesh (this, &backMeshClipper, &frontMeshClipper); - if (backMeshSource && frontMeshSource) { - - dgMeshEffect* backMesh; - dgMeshEffect* frontMesh; - - backMesh = new (GetAllocator()) dgMeshEffect (GetAllocator(), true); - frontMesh = new (GetAllocator()) dgMeshEffect (GetAllocator(), true); - - backMesh->BeginPolygon(); - frontMesh->BeginPolygon(); - - backMesh->MergeFaces(backMeshSource); - backMesh->MergeFaces(backMeshClipper); - - frontMesh->MergeFaces(frontMeshSource); - frontMesh->ReverseMergeFaces(backMeshClipper); - - backMesh->EndPolygon(dgFloat64 (1.0e-5f)); - frontMesh->EndPolygon(dgFloat64 (1.0e-5f)); - - *back = backMesh; - *front = frontMesh; - } - } - - if (backMeshClipper) { - delete backMeshClipper; - } - - if (frontMeshClipper) { - delete frontMeshClipper; - } - - if (backMeshSource) { - delete backMeshSource; - } - - if (frontMeshSource) { - delete frontMeshSource; - } -*/ -} - - - - -dgMeshEffect* dgMeshEffect::Union (const dgMatrix& matrix, const dgMeshEffect* const clipperMesh) const -{ - dgAssert (0); - return NULL; -/* - dgMeshEffect copy (*this); - dgMeshEffect clipper (*clipperMesh); - clipper.TransformMesh (matrix); - - dgBooleanMeshClipper::ClipMeshesAndColorize (©, &clipper); - - dgMeshEffect* const mesh = new (GetAllocator()) dgMeshEffect (GetAllocator()); - mesh->BeginFace(); - dgBooleanMeshClipper::CopyPoints(mesh, ©); - dgBooleanMeshClipper::AddExteriorFaces (mesh, ©); - - dgBooleanMeshClipper::AddExteriorFaces (mesh, &clipper); - mesh->EndFace (); - mesh->RepairTJoints(); - mesh->RemoveUnusedVertices(NULL); - return mesh; -*/ -} - -dgMeshEffect* dgMeshEffect::Difference (const dgMatrix& matrix, const dgMeshEffect* const clipperMesh) const -{ -/* - dgMeshEffect copy (*this); - dgMeshEffect clipper (*clipperMesh); - clipper.TransformMesh (matrix); - - dgBooleanMeshClipper::ClipMeshesAndColorize (©, &clipper); - - dgMeshEffect* const mesh = new (GetAllocator()) dgMeshEffect (GetAllocator()); - mesh->BeginFace(); - dgBooleanMeshClipper::CopyPoints(mesh, ©); - dgBooleanMeshClipper::AddExteriorFaces (mesh, ©); - dgBooleanMeshClipper::AddInteriorFacesInvertWinding (mesh, &clipper); - mesh->EndFace (); - mesh->RepairTJoints(); - mesh->RemoveUnusedVertices(NULL); - return mesh; -*/ - - dgAssert (0); - return NULL; -} - - -class dgBooleanMeshClipper: public dgMeshEffect::dgMeshBVH -{ - class dgPoint: public dgBigVector - { - public: - dgPoint() - :dgBigVector(dgFloat32 (0.0f)) - ,m_links(NULL) - ,m_lru(0) - { - dgAssert (0); - } - - dgPoint(const dgBigVector& point, dgMemoryAllocator* const allocator) - :dgBigVector(point) - ,m_links(allocator) - ,m_lru(0) - { - } - - dgList<dgTree<dgPoint, dgFloat64>::dgTreeNode*> m_links; - dgInt32 m_lru; - }; - - class dgCurvesNetwork: public dgTree<dgPoint, dgFloat64> - { - public: - dgCurvesNetwork () - :dgTree<dgPoint, dgFloat64>(NULL) - { - dgAssert (0); - } - - dgCurvesNetwork (dgMemoryAllocator* const allocator) - :dgTree<dgPoint, dgFloat64>(allocator) - { - } - - dgTreeNode* AddVertex(const dgBigVector& point, dgMemoryAllocator* const allocator) - { - dgFloat64 key = ((point.m_z * dgFloat64 (1024.0f) + point.m_y) * dgFloat64 (1024.0f)) + point.m_x; - dgTreeNode* node = Find(key); - if (!node) { - dgPoint entry (point, allocator); - node = Insert(entry, key); - } - return node; - } - -/* - dgCurvesNetwork(dgBooleanMeshClipper* const BVHmeshA, dgBooleanMeshClipper* const BVHmeshB) - :dgTree<dgPoint, dgFloat64>(BVHmeshA->m_mesh->GetAllocator()) -// ,m_meshA(BVHmeshA->m_mesh) -// ,m_meshB(BVHmeshB->m_mesh) -// ,m_pointBaseA(m_meshA->GetVertexCount()) -// ,m_pointBaseB(m_meshB->GetVertexCount()) -// ,m_lru(0) - { - } -*/ -/* - dgHugeVector CalculateFaceNormal (const dgMeshEffect* const mesh, dgEdge* const face) - { - dgHugeVector plane(dgGoogol::m_zero, dgGoogol::m_zero, dgGoogol::m_zero, dgGoogol::m_zero); - dgEdge* edge = face; - dgHugeVector p0(mesh->GetVertex(edge->m_incidentVertex)); - edge = edge->m_next; - dgHugeVector p1(mesh->GetVertex(edge->m_incidentVertex)); - dgHugeVector p1p0(p1 - p0); - edge = edge->m_next; - do { - dgHugeVector p2(mesh->GetVertex(edge->m_incidentVertex)); - dgHugeVector p2p0(p2 - p0); - plane += p2p0 * p1p0; - p1p0 = p2p0; - edge = edge->m_next; - } while (edge != face); - - plane.m_w = dgGoogol::m_zero - (plane % p0); - return plane; - } - - - bool IsPointInFace (const dgHugeVector& point, const dgMeshEffect* const mesh, dgEdge* const face, const dgHugeVector& normal) const - { - dgEdge* edge = face; - - dgTrace (("%f %f %f\n", dgFloat64 (point.m_x), dgFloat64 (point.m_y), dgFloat64 (point.m_z))); - do { - dgBigVector p1(mesh->GetVertex(edge->m_incidentVertex)); - dgTrace (("%f %f %f\n", dgFloat64 (p1.m_x), dgFloat64 (p1.m_y), dgFloat64 (p1.m_z))); - edge = edge->m_next; - } while (edge != face); - - dgHugeVector p0(mesh->GetVertex(face->m_incidentVertex)); - do { - dgHugeVector p1(mesh->GetVertex(edge->m_twin->m_incidentVertex)); - dgHugeVector p1p0(p1 - p0); - dgHugeVector q1p0(point - p0); - dgGoogol side (q1p0 % (normal * p1p0)); - if (side >= dgGoogol::m_zero) { - return false; - } - p0 = p1; - edge = edge->m_next; - } while (edge != face); - - return true; - } - - dgFloat64 ClipEdgeFace(const dgMeshEffect* const meshEdge, dgEdge* const edge, const dgMeshEffect* const meshFace, dgEdge* const face, const dgHugeVector& plane) - { - dgHugeVector p0 (meshEdge->GetVertex(edge->m_incidentVertex)); - dgHugeVector p1 (meshEdge->GetVertex(edge->m_twin->m_incidentVertex)); - - dgGoogol test0 (plane.EvaluePlane(p0)); - dgGoogol test1 (plane.EvaluePlane(p1)); - - if ((test0 * test1) > dgGoogol::m_zero) { - // both point are in one side - return -1.0f; - } - - if ((test0 * test1) < dgGoogol::m_zero) { - //point on different size, clip the line - dgHugeVector p1p0 (p1 - p0); - dgGoogol param = dgGoogol::m_zero - plane.EvaluePlane(p0) / (plane % p1p0); - dgHugeVector p (p0 + p1p0.Scale (param)); - if (IsPointInFace (p, meshFace, face, plane)) { - return param; - } - return -1.0f; - } else { - dgAssert (0); - //special cases; - } - - return -1.0f; - } - - void AddPoint (dgMeshEffect* const edgeOwnerMesh, dgEdge* const edgeStart, dgMeshEffect* const faceOwnerMesh, dgEdge* const face, const dgHugeVector& plane, dgTreeNode** nodes, dgInt32& index) - { - dgEdge* edge = edgeStart; - do { - dgFloat64 param = ClipEdgeFace(edgeOwnerMesh, edge, faceOwnerMesh, face, plane); - if (param > 0.0f) { - dgPoint point(edgeOwnerMesh, edge, param, faceOwnerMesh, face); - dgTreeNode* node = Find(dgNodeKey(edge, param)); - if (!node) { - node = Insert(point, dgNodeKey(edge, param)); - } - nodes[index] = node; - index ++; - } - edge = edge->m_next; - } while (edge != edgeStart); - - } - - void ClipMeshesFaces(dgEdge* const faceA, dgEdge* const faceB) - { - dgAssert (m_meshA->FindEdge(faceA->m_incidentVertex, faceA->m_twin->m_incidentVertex) == faceA); - dgAssert (m_meshB->FindEdge(faceB->m_incidentVertex, faceB->m_twin->m_incidentVertex) == faceB); - - dgHugeVector planeA (CalculateFaceNormal (m_meshA, faceA)); - dgHugeVector planeB (CalculateFaceNormal (m_meshB, faceB)); - - dgInt32 index = 0; - dgTreeNode* nodes[16]; - AddPoint (m_meshA, faceA, m_meshB, faceB, planeB, nodes, index); - AddPoint (m_meshB, faceB, m_meshA, faceA, planeA, nodes, index); - dgAssert ((index == 0) || (index == 2)); - if (index == 2) { - dgPoint& pointA = nodes[0]->GetInfo(); - dgPoint& pointB = nodes[1]->GetInfo(); - pointA.m_links.Append(nodes[1]); - pointB.m_links.Append(nodes[0]); - } - } - - void GetCurve (dgList<dgTreeNode*>& curve, dgTreeNode* const node) - { - dgInt32 stack = 1; - dgTreeNode* pool[64]; - - pool[0] = node; - while (stack) { - stack --; - dgTreeNode* const ptr = pool[stack]; - dgPoint& point = ptr->GetInfo(); - if (point.m_lru != m_lru) { - point.m_lru = m_lru; - curve.Append(ptr); - for (dgList<dgTree<dgPoint, dgNodeKey>::dgTreeNode*>::dgListNode* ptrPoint = point.m_links.GetFirst(); ptrPoint; ptrPoint = ptrPoint->GetNext()) { - dgTreeNode* const nextnode = ptrPoint->GetInfo(); - dgPoint& nextPoint = nextnode->GetInfo(); - if (nextPoint.m_lru != m_lru) { - pool[stack] = nextnode; - stack ++; - } - } - } - } - } - - void EmbedCurveToSingleFace (dgList<dgTreeNode*>& curve, dgMeshEffect* const mesh) - { - dgEdge* const face = curve.GetFirst()->GetInfo()->GetInfo().m_face; - - dgInt32 indexBase = mesh->GetVertexCount(); - dgInt32 indexAttribBase = mesh->GetPropertiesCount(); - - for (dgList<dgTreeNode*>::dgListNode* node = curve.GetFirst(); node; node = node->GetNext()) { - dgPoint& point = node->GetInfo()->GetInfo(); - dgAssert (point.m_face == face); - dgMeshEffect::dgVertexAtribute attribute(mesh->InterpolateVertex(point.m_posit, face)); - mesh->AddVertex(point.m_posit); - mesh->AddAtribute(attribute); - } - - dgList<dgEdge*> list(GetAllocator()); - dgInt32 i0 = curve.GetCount() - 1; - for (dgInt32 i = 0; i < curve.GetCount(); i++) { - dgEdge* const edge = mesh->AddHalfEdge(indexBase + i0, indexBase + i); - dgEdge* const twin = mesh->AddHalfEdge(indexBase + i, indexBase + i0); - - edge->m_incidentFace = 1; - twin->m_incidentFace = 1; - edge->m_userData = indexAttribBase + i0; - twin->m_userData = indexAttribBase + i; - twin->m_twin = edge; - edge->m_twin = twin; - i0 = i; - list.Append(edge); - } - - dgEdge* closestEdge = NULL; - dgFloat64 dist2 = dgFloat64 (1.0e10f); - dgBigVector p(mesh->GetVertex(face->m_incidentVertex)); - - list.Append(list.GetFirst()->GetInfo()); - list.Addtop(list.GetLast()->GetInfo()); - for (dgList<dgEdge*>::dgListNode* node = list.GetFirst()->GetNext(); node != list.GetLast(); node = node->GetNext()) { - dgEdge* const edge = node->GetInfo(); - - dgEdge* const prev = node->GetPrev()->GetInfo(); - edge->m_prev = prev; - prev->m_next = edge; - edge->m_twin->m_next = prev->m_twin; - prev->m_twin->m_prev = edge->m_twin; - - dgEdge* const next = node->GetNext()->GetInfo(); - edge->m_next = next; - next->m_prev = edge; - edge->m_twin->m_prev = next->m_twin; - next->m_twin->m_next = edge->m_twin; - - dgBigVector dist(mesh->GetVertex(edge->m_incidentVertex) - p); - dgFloat64 err2 = dist % dist; - if (err2 < dist2) { - closestEdge = edge; - dist2 = err2; - } - } - - dgBigVector faceNormal (mesh->FaceNormal(face, mesh->GetVertexPool(), mesh->GetVertexStrideInByte())); - dgBigVector clipNormal (mesh->FaceNormal(closestEdge, mesh->GetVertexPool(), mesh->GetVertexStrideInByte())); - if ((clipNormal % faceNormal) > dgFloat64(0.0f)) { - closestEdge = closestEdge->m_twin->m_next; - } - dgEdge* const glueEdge = mesh->ConnectVertex (closestEdge, face); - dgAssert (glueEdge); - mesh->PolygonizeFace(glueEdge, mesh->GetVertexPool(), sizeof (dgBigVector)); - } - - void EmbedCurveToMulipleFaces (dgList<dgTreeNode*>& curve, dgMeshEffect* const mesh) - { - for (dgList<dgTreeNode*>::dgListNode* node = curve.GetFirst(); node; node = node->GetNext()) { - dgPoint& point = node->GetInfo()->GetInfo(); - if (point.m_edgeOwnerMesh == mesh) { - dgEdge* const edge = point.m_edge; - dgBigVector p0 (mesh->GetVertex(edge->m_incidentVertex)); - dgBigVector p1 (mesh->GetVertex(edge->m_twin->m_incidentVertex)); - dgVector p1p0 (p1 - p0); - dgVector qp0 (point.m_posit - p0); - dgFloat64 param = (qp0 % p1p0) / (p1p0 % p1p0); - dgAssert (param >= dgFloat64 (0.0f)); - dgAssert (param <= dgFloat64 (1.0f)); - dgEdge* const newEdge = mesh->InsertEdgeVertex (edge, param); - } -// mesh->AddVertex(point.m_posit); -// mesh->AddAtribute(attribute); - } - } - - - void AddCurveToMesh (dgList<dgTreeNode*>& curve, dgMeshEffect* const mesh) - { - bool isIscribedInFace = true; - dgEdge* const face = curve.GetFirst()->GetInfo()->GetInfo().m_face; - for (dgList<dgTreeNode*>::dgListNode* node = curve.GetFirst(); isIscribedInFace && node; node = node->GetNext()) { - dgPoint& point = node->GetInfo()->GetInfo(); - isIscribedInFace = isIscribedInFace && (point.m_face == face); - isIscribedInFace = isIscribedInFace && (point.m_faceOwnerMesh == mesh); - } - - if (isIscribedInFace) { - EmbedCurveToSingleFace (curve, mesh); - } else { - EmbedCurveToMulipleFaces (curve, mesh); - } - } - - void Colorize() - { - m_lru ++; - Iterator iter (*this); - for (iter.Begin(); iter; iter ++) { - dgPoint& point = iter.GetNode()->GetInfo(); - if (point.m_lru != m_lru) { - dgList<dgTreeNode*> curve (GetAllocator()); - GetCurve (curve, iter.GetNode()); - AddCurveToMesh (curve, m_meshB); - AddCurveToMesh (curve, m_meshA); - } - } - - m_meshA->SaveOFF("xxxA0.off"); - m_meshB->SaveOFF("xxxB0.off"); - } - - dgMeshEffect* m_meshA; - dgMeshEffect* m_meshB; - dgInt32 m_pointBaseA; - dgInt32 m_pointBaseB; - dgInt32 m_lru; -*/ - }; - - class dgClippedFace: public dgMeshEffect - { - public: - dgClippedFace () - :dgMeshEffect() - ,m_curveNetwork() - { - dgAssert (0); - } - - dgClippedFace (dgMemoryAllocator* const allocator) - :dgMeshEffect(allocator) - ,m_curveNetwork(allocator) - { - } - - dgClippedFace (const dgClippedFace& copy) - :dgMeshEffect(copy) - ,m_curveNetwork(copy.m_curveNetwork) - { - } - - void InitFace(dgMeshEffect* const mesh, dgEdge* const face) - { - dgInt32 indexCount = 0; - dgInt32 faceIndex[256]; - dgInt64 faceDataIndex[256]; - BeginFace (); - dgEdge* ptr = face; - do { - dgAssert (0); - //const dgMeshEffect::dgVertexAtribute& point = mesh->GetAttribute(dgInt32 (ptr->m_userData)); - //AddPoint (&point.m_vertex.m_x, dgInt32 (point.m_material)); - faceIndex[indexCount] = indexCount; - faceDataIndex[indexCount] = indexCount; - indexCount ++; - ptr = ptr->m_next; - } while (ptr != face); - AddFace (indexCount, faceIndex, faceDataIndex); - EndFace (); - } - - - void AddSegment (const dgBigVector& plane, const dgBigVector* const segment) - { - dgAssert (0); -/* - dgCurvesNetwork::dgTreeNode* const node0 = m_curveNetwork.AddVertex (segment[0], GetAllocator()); - dgCurvesNetwork::dgTreeNode* const node1 = m_curveNetwork.AddVertex (segment[1], GetAllocator()); - - dgPoint& pointA = node0->GetInfo(); - dgPoint& pointB = node1->GetInfo(); - pointA.m_links.Append(node1); - pointB.m_links.Append(node0); -*/ - } - - dgCurvesNetwork m_curveNetwork; - }; - - class dgClipppedFaces: public dgTree<dgClippedFace, dgEdge*> - { - public: - dgClipppedFaces(dgMeshEffect* const mesh) - :dgTree<dgClippedFace, dgEdge*>(mesh->GetAllocator()) - ,m_parentMesh (mesh) - { - } - - void ClipMeshesFaces(dgEdge* const faceA, const dgMeshEffect* const meshB, dgEdge* const faceB, const dgBigVector& planeB, const dgBigVector* const segment) - { - dgTreeNode* node = Find (faceA); - if (!node) { - dgClippedFace tmp (m_parentMesh->GetAllocator()); - node = Insert (tmp, faceA); - dgClippedFace& faceHead = node->GetInfo(); - faceHead.InitFace (m_parentMesh, faceA); - } - dgAssert (node); - dgClippedFace& faceHead = node->GetInfo(); - faceHead.AddSegment(planeB, segment); - } - - dgMeshEffect* m_parentMesh; - }; - - - public: - dgBooleanMeshClipper(dgMeshEffect* const mesh) - :dgMeshBVH(mesh) - ,m_clippedFaces(mesh) - { - dgMeshBVH::Build(); - } - - ~dgBooleanMeshClipper() - { - } - -/* - dgFloat64 IntersetionSegment(const dgMeshEffect* const meshEdge, dgEdge* const edge, const dgMeshEffect* const meshFace, dgEdge* const face, const dgHugeVector& plane) - { - dgHugeVector p0 (meshEdge->GetVertex(edge->m_incidentVertex)); - dgHugeVector p1 (meshEdge->GetVertex(edge->m_twin->m_incidentVertex)); - - dgGoogol test0 (plane.EvaluePlane(p0)); - dgGoogol test1 (plane.EvaluePlane(p1)); - - if ((test0 * test1) > dgGoogol::m_zero) { - // both point are in one side - return -1.0f; - } - - if ((test0 * test1) < dgGoogol::m_zero) { - //point on different size, clip the line - dgHugeVector p1p0 (p1 - p0); - dgGoogol param = dgGoogol::m_zero - plane.EvaluePlane(p0) / (plane % p1p0); - dgHugeVector p (p0 + p1p0.Scale (param)); - if (IsPointInFace (p, meshFace, face, plane)) { - return param; - } - return -1.0f; - } else { - dgAssert (0); - //special cases; - } - - return -1.0f; - } -*/ - - static dgHugeVector CalculateFaceNormal (const dgMeshEffect* const mesh, dgEdge* const face) - { - dgHugeVector plane(dgGoogol::m_zero, dgGoogol::m_zero, dgGoogol::m_zero, dgGoogol::m_zero); - dgEdge* edge = face; - dgHugeVector p0(mesh->GetVertex(edge->m_incidentVertex)); - edge = edge->m_next; - dgHugeVector p1(mesh->GetVertex(edge->m_incidentVertex)); - dgHugeVector p1p0(p1 - p0); - edge = edge->m_next; - do { - dgHugeVector p2(mesh->GetVertex(edge->m_incidentVertex)); - dgHugeVector p2p0(p2 - p0); - plane += p1p0.CrossProduct(p2p0); - p1p0 = p2p0; - edge = edge->m_next; - } while (edge != face); - - dgAssert(plane.m_w == dgGoogol(0.0)); - plane.m_w = dgGoogol::m_zero - plane.DotProduct(p0).GetScalar(); - return plane; - } - - static bool IsPointInFace (const dgHugeVector& point, const dgMeshEffect* const mesh, dgEdge* const face, const dgHugeVector& normal) - { - dgEdge* edge = face; - dgHugeVector p0(mesh->GetVertex(face->m_incidentVertex)); - do { - dgHugeVector p1(mesh->GetVertex(edge->m_twin->m_incidentVertex)); - dgHugeVector p1p0(p1 - p0); - dgHugeVector q1p0(point - p0); - dgAssert(p1p0.m_w == dgGoogol(0.0)); - dgGoogol side (q1p0.DotProduct(p1p0.CrossProduct(normal)).GetScalar()); - if (side >= dgGoogol::m_zero) { - return false; - } - p0 = p1; - edge = edge->m_next; - } while (edge != face); - - return true; - } - - static bool ClipEdgeFace(dgBigVector& point, const dgMeshEffect* const meshEdge, dgEdge* const edgeSrc, const dgMeshEffect* const meshFace, dgEdge* const face, const dgHugeVector& plane) - { - const dgEdge* const edge = (edgeSrc->m_incidentVertex < edgeSrc->m_twin->m_incidentVertex) ? edgeSrc : edgeSrc->m_twin; - dgHugeVector p0 (meshEdge->GetVertex(edge->m_incidentVertex)); - dgHugeVector p1 (meshEdge->GetVertex(edge->m_twin->m_incidentVertex)); - - dgGoogol test0 (plane.EvaluePlane(p0)); - dgGoogol test1 (plane.EvaluePlane(p1)); - - if ((test0 * test1) > dgGoogol::m_zero) { - // both point are in one side - return false; - } - - if ((test0 * test1) < dgGoogol::m_zero) { - //point on different size, clip the line - dgHugeVector p1p0 (p1 - p0); - dgAssert(p1p0.m_w == dgGoogol(0.0)); - dgGoogol param = dgGoogol::m_zero - plane.EvaluePlane(p0) / plane.DotProduct(p1p0).GetScalar(); - dgHugeVector p (p0 + p1p0.Scale (param)); - if (IsPointInFace (p, meshFace, face, plane)) { - point = dgBigVector(p.m_x, p.m_y, p.m_z, p.m_w); - return true; - } - return false; - } else { - dgAssert (0); - //special cases; - } - - return false; - } - - static void CalculateIntersection (const dgMeshEffect* const edgeOwnerMesh, dgEdge* const edgeStart, const dgMeshEffect* const faceOwnerMesh, dgEdge* const face, const dgHugeVector& facePlane, dgBigVector* const data, dgInt32& index) - { - dgEdge* edge = edgeStart; - do { - bool isCleipped = ClipEdgeFace(data[index], edgeOwnerMesh, edge, faceOwnerMesh, face, facePlane); - if (isCleipped) { - index ++; - } - edge = edge->m_next; - } while (edge != edgeStart); - } - - static void ClipMeshesFaces(dgBooleanMeshClipper& bvhMeshA, dgEdge* const faceA, dgBooleanMeshClipper& bvhMeshB, dgEdge* const faceB) - { - const dgMeshEffect* const meshA = bvhMeshA.m_mesh; - const dgMeshEffect* const meshB = bvhMeshB.m_mesh; - dgAssert (meshA->FindEdge(faceA->m_incidentVertex, faceA->m_twin->m_incidentVertex) == faceA); - dgAssert (meshB->FindEdge(faceB->m_incidentVertex, faceB->m_twin->m_incidentVertex) == faceB); - - dgHugeVector planeA (CalculateFaceNormal (meshA, faceA)); - dgHugeVector planeB (CalculateFaceNormal (meshB, faceB)); - - dgBigVector points[16]; - dgInt32 pointCount = 0; - CalculateIntersection (meshA, faceA, meshB, faceB, planeB, points, pointCount); - CalculateIntersection (meshB, faceB, meshA, faceA, planeA, points, pointCount); - dgAssert ((pointCount == 0) || (pointCount == 2)); - if (pointCount == 2) { - dgBigVector facePlaneA (planeA.m_x, planeA.m_y, planeA.m_z, planeA.m_w); - dgBigVector facePlaneB (planeB.m_x, planeB.m_y, planeB.m_z, planeB.m_w); - - bvhMeshA.m_clippedFaces.ClipMeshesFaces(faceA, meshB, faceB, facePlaneB, points); - bvhMeshB.m_clippedFaces.ClipMeshesFaces(faceB, meshA, faceA, facePlaneA, points); - } - } - - static void ClipMeshesAndColorize(dgMeshEffect* const meshA, dgMeshEffect* const meshB) - { - dgAssert (0); -/* - dgBooleanMeshClipper BVHmeshA(meshA); - dgBooleanMeshClipper BVHmeshB(meshB); - - int stack = 1; - - dgMeshBVHNode* stackPool[2 * DG_MESH_EFFECT_BVH_STACK_DEPTH][2]; - - stackPool[0][0] = BVHmeshA.m_rootNode; - stackPool[0][1] = BVHmeshB.m_rootNode; - while (stack) { - stack --; - dgMeshBVHNode* const nodeA = stackPool[stack][0]; - dgMeshBVHNode* const nodeB = stackPool[stack][1]; - if (dgOverlapTest (nodeA->m_p0, nodeA->m_p1, nodeB->m_p0, nodeB->m_p1)) { - if (nodeA->m_face && nodeB->m_face) { - ClipMeshesFaces(BVHmeshA, nodeA->m_face, BVHmeshB, nodeB->m_face); - } else if (nodeA->m_face) { - stackPool[stack][0] = nodeA; - stackPool[stack][1] = nodeB->m_left; - stack++; - dgAssert(stack < sizeof (stackPool) / sizeof (stackPool[0])); - - stackPool[stack][0] = nodeA; - stackPool[stack][1] = nodeB->m_right; - stack++; - dgAssert(stack < sizeof (stackPool) / sizeof (stackPool[0])); - - } else if (nodeB->m_face) { - stackPool[stack][0] = nodeA->m_left; - stackPool[stack][1] = nodeB; - stack++; - dgAssert(stack < sizeof (stackPool) / sizeof (stackPool[0])); - - stackPool[stack][0] = nodeA->m_right; - stackPool[stack][1] = nodeB; - stack++; - dgAssert(stack < sizeof (stackPool) / sizeof (stackPool[0])); - - } else { - stackPool[stack][0] = nodeA->m_left; - stackPool[stack][1] = nodeB->m_left; - stack ++; - dgAssert (stack < sizeof (stackPool) / sizeof (stackPool[0])); - - stackPool[stack][0] = nodeA->m_left; - stackPool[stack][1] = nodeB->m_right; - stack++; - dgAssert(stack < sizeof (stackPool) / sizeof (stackPool[0])); - - stackPool[stack][0] = nodeA->m_right; - stackPool[stack][1] = nodeB->m_left; - stack++; - dgAssert(stack < sizeof (stackPool) / sizeof (stackPool[0])); - - stackPool[stack][0] = nodeA->m_right; - stackPool[stack][1] = nodeB->m_right; - stack++; - dgAssert(stack < sizeof (stackPool) / sizeof (stackPool[0])); - } - } - } -*/ - dgAssert (0); -// network.Colorize(); - - -/* - dgInt32 baseAttibuteCountB = BVHmeshB.m_mesh->GetPropertiesCount(); - - BVHmeshA.m_mesh->SaveOFF("xxxA0.off"); - BVHmeshB.m_mesh->SaveOFF("xxxB0.off"); - - // edge-face, edge-edge and edge-vertex intersections until not more intersections are found - for (bool intersectionFound = true; intersectionFound;) { - intersectionFound = false; - - intersectionFound |= BVHmeshA.CalculateEdgeFacesIntersetions(BVHmeshB); - intersectionFound |= BVHmeshB.CalculateEdgeFacesIntersetions(BVHmeshA); - - intersectionFound |= BVHmeshA.CalculateVertexFacesIntersetions(BVHmeshB); - intersectionFound |= BVHmeshB.CalculateVertexFacesIntersetions(BVHmeshA); - - - BVHmeshA.m_mesh->SaveOFF("xxxA1.off"); - BVHmeshB.m_mesh->SaveOFF("xxxB1.off"); - - intersectionFound |= BVHmeshA.CalculateEdgeEdgeIntersetions(BVHmeshB); - - BVHmeshA.m_mesh->SaveOFF("xxxA2.off"); - BVHmeshB.m_mesh->SaveOFF("xxxB2.off"); - - intersectionFound |= BVHmeshA.CalculateEdgeVertexIntersetions(BVHmeshB); - intersectionFound |= BVHmeshB.CalculateEdgeVertexIntersetions(BVHmeshA); - - BVHmeshA.m_mesh->SaveOFF("xxxA3.off"); - BVHmeshB.m_mesh->SaveOFF("xxxB3.off"); - } -*/ - } - - dgClipppedFaces m_clippedFaces; -}; - - - -dgMeshEffect* dgMeshEffect::Intersection (const dgMatrix& matrix, const dgMeshEffect* const clipperMesh) const -{ - dgMeshEffect copy (*this); - dgMeshEffect clipper (*clipperMesh); - clipper.TransformMesh (matrix); - - dgBooleanMeshClipper::ClipMeshesAndColorize (©, &clipper); -/* - dgMeshEffect* const mesh = new (GetAllocator()) dgMeshEffect (GetAllocator()); - mesh->BeginFace(); - dgBooleanMeshClipper::CopyPoints(mesh, ©); - dgBooleanMeshClipper::AddInteriorFaces (mesh, ©); - dgBooleanMeshClipper::AddInteriorFaces (mesh, &clipper); - mesh->EndFace (); - mesh->RepairTJoints(); - mesh->RemoveUnusedVertices(NULL); - - return mesh; -*/ - - dgAssert (0); - return NULL; -} - - diff --git a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect6.cpp b/thirdparty/src/newton/dgMeshUtil/dgMeshEffect6.cpp deleted file mode 100644 index 25aacadc5..000000000 --- a/thirdparty/src/newton/dgMeshUtil/dgMeshEffect6.cpp +++ /dev/null @@ -1,1917 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -// algorithm from paper: Non-Distorted Texture Mapping Using Angle Based Flattening -// by: A. Sheffer and E. de Sturler -// http://www.math.vt.edu/people/sturler/Publications/UIUCDCS-R-2001-2257.pdf -// -// also improvement from paper: ABF++: Fast and Robust Angle Based Flattening -// http://hal.archives-ouvertes.fr/docs/00/10/56/89/PDF/abf_plus_plus_temp.pdf -// by: Alla Sheffer, Bruno Lévy, Inria Lorraine, Maxim Mogilnitsky and Alexander Bogomyakov -// -// also looking at paper -// Least Squares Conformal Maps for Automatic Texture Atlas Generation -// http://www.cs.jhu.edu/~misha/Fall09/Levy02.pdf -// by Bruno Lévy Sylvain Petitjean Nicolas Ray Jérome Maillot -// for automatic seam and atlas generation - -#include "dgPhysicsStdafx.h" -#include "dgWorld.h" -#include "dgMeshEffect.h" - -#define dgABF_MAX_ITERATIONS 5 -#define dgABF_TOL2 dgFloat64 (1.0e-12) -#define dgABF_LINEAR_SOLVER_TOL dgFloat64 (1.0e-14) -#define dgABF_PI dgFloat64 (3.1415926535) - -#define dgABF_UV_TOL2 dgFloat64 (1.0e-8) - -#if 1 - #define DG_DEBUG_UV dgTrace -#else - #define DG_DEBUG_UV -#endif - - -class dgTriangleAnglesToUV: public dgSymmetricConjugateGradientSolver<dgFloat64> -{ - public: - dgTriangleAnglesToUV (dgMeshEffect* const mesh, dgInt32 material, dgReportProgress progressReportCallback, void* const userData, const dgFloat64* const pinnedPoint, dgFloat64* const triangleAnglesVector = NULL) - :m_hessianCoLumnIndex (mesh->GetAllocator()) - ,m_hessianCoLumnValue(mesh->GetAllocator()) - ,m_mesh(mesh) - ,m_triangleAngles(triangleAnglesVector) - ,m_pinnedPoints(pinnedPoint) - ,m_trianglesCount(0) - ,m_matrixElementCount(0) - ,m_allocated(false) - { - dgInt32 mark = m_mesh->IncLRU(); - dgMeshEffect::Iterator iter (*m_mesh); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if ((edge->m_incidentFace > 0) && (edge->m_mark != mark)) { - dgEdge *ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - m_trianglesCount ++; - dgAssert (edge->m_next->m_next->m_next == edge); - } - } - - m_triangles = (dgEdge**) m_mesh->GetAllocator()->MallocLow (m_trianglesCount * sizeof (dgEdge*)); - - dgInt32 count = 0; - mark = m_mesh->IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if ((edge->m_incidentFace > 0) && (edge->m_mark != mark)) { - dgEdge *ptr = edge; - do { - ptr->m_incidentFace = count + 1; - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - m_triangles[count] = ptr; - count ++; - dgAssert (count <= m_trianglesCount); - } - } - - if (!m_triangleAngles) { - dgAssert (0); - AnglesFromUV (); - } - - m_uvArray = (dgFloat64*) m_mesh->GetAllocator()->MallocLow (2 * m_mesh->GetVertexCount() * sizeof (dgFloat64)); - mark = m_mesh->IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if (edge->m_mark != mark) { - dgEdge* ptr = edge; - dgEdge* uvEdge = edge; - do { - if ((uvEdge->m_incidentFace < 0) && (ptr->m_incidentFace > 0)) { - uvEdge = ptr; - } - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - dgAssert (0); -/* - dgInt32 index = dgInt32 (uvEdge->m_userData); - dgMeshEffect::dgVertexAtribute& attribute = m_mesh->GetAttribute (index); - m_uvArray[index * 2 + 0] = attribute.m_u0; - m_uvArray[index * 2 + 1] = attribute.m_v0; -*/ - } - } - - m_sinTable = (dgFloat64*) m_mesh->GetAllocator()->MallocLow (3 * m_trianglesCount * sizeof (dgFloat64)); - m_cosTable = (dgFloat64*) m_mesh->GetAllocator()->MallocLow (3 * m_trianglesCount * sizeof (dgFloat64)); - - // pre-compute sin cos tables - for (dgInt32 i = 0; i < m_trianglesCount * 3; i ++) { - m_sinTable[i] = sin (m_triangleAngles[i]); - m_cosTable[i] = cos (m_triangleAngles[i]); - } - - m_vertexEdge = (dgEdge**) m_mesh->GetAllocator()->MallocLow (m_mesh->GetVertexCount() * sizeof (dgEdge*)); - mark = m_mesh->IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const vertex = &iter.GetNode()->GetInfo(); - if (vertex->m_mark != mark) { - dgInt32 index = vertex->m_incidentVertex; - m_vertexEdge[index] = vertex; - dgEdge* ptr = vertex; - do { - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next ; - } while (ptr != vertex); - } - } - - m_gradients = (dgFloat64*) m_mesh->GetAllocator()->MallocLow (2 * m_mesh->GetVertexCount() * sizeof (dgFloat64)); - m_diagonal = (dgFloat64*) m_mesh->GetAllocator()->MallocLow (2 * m_mesh->GetVertexCount() * sizeof (dgFloat64)); - - LagrangeOptimization(); - - dgAssert (0); -/* - dgStack<dgMeshEffect::dgVertexAtribute>attribArray (m_mesh->GetCount()); -// dgInt32 attribCount = m_mesh->EnumerateAttributeArray (&attribArray[0]); - mark = m_mesh->IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if (edge->m_mark != mark) { - dgInt32 vertexIndex = edge->m_incidentVertex; - dgEdge* const vertexEdge = m_vertexEdge[vertexIndex]; - dgFloat64 u = m_uvArray[vertexIndex * 2 + 0]; - dgFloat64 v = m_uvArray[vertexIndex * 2 + 1]; - dgEdge* ptr = vertexEdge; - do { - if (ptr->m_incidentFace > 0) { - dgInt32 index = dgInt32 (ptr->m_userData); - dgMeshEffect::dgVertexAtribute& attribute = m_mesh->GetAttribute (index); - attribute.m_u0 = u; - attribute.m_v0 = v; - attribute.m_material = material; - } - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != vertexEdge); - } - } -*/ - dgAssert (0); - //m_mesh->ApplyAttributeArray(&attribArray[0], attribCount); - } - - ~dgTriangleAnglesToUV() - { - m_mesh->GetAllocator()->FreeLow (m_diagonal); - m_mesh->GetAllocator()->FreeLow (m_gradients); - m_mesh->GetAllocator()->FreeLow (m_vertexEdge); - m_mesh->GetAllocator()->FreeLow (m_sinTable); - m_mesh->GetAllocator()->FreeLow (m_cosTable); - m_mesh->GetAllocator()->FreeLow (m_uvArray); - m_mesh->GetAllocator()->FreeLow (m_triangles); - - if (m_allocated) { - m_mesh->GetAllocator()->FreeLow (m_triangleAngles); - } - } - -/* - void GenerateUVCoordinates () - { - m_mesh->SaveOFF("xxx.off"); - - dgStack<dgInt8> attibuteUsed (m_attibuteCount); - memset (&attibuteUsed[0], 0, attibuteUsed.GetSizeInBytes()); - dgInt32 mark = m_mesh->IncLRU(); - for (dgInt32 i = 0; i < m_triangleCount; i ++) { - dgEdge* const face = m_betaEdge[i * 3]; - if (face->m_mark != mark) { - dgEdge* ptr = face; - do { - if (ptr->m_incidentFace > 0) { - dgInt32 index = dgInt32 (ptr->m_userData); - attibuteUsed[index] = 1; - m_uvArray[index].m_u0 = dgFloat32 (0.0f); - m_uvArray[index].m_v0 = dgFloat32 (0.0f); - } - ptr = ptr->m_twin->m_next; - } while (ptr != face); - - dgEdge* const twinFace = face->m_twin; - const dgBigVector& p0 = m_mesh->GetVertex(face->m_incidentVertex); - const dgBigVector& p1 = m_mesh->GetVertex(twinFace->m_incidentVertex); - dgBigVector p10 (p1 - p0); - dgFloat64 e0length = sqrt (p10 % p10); - - ptr = twinFace; - do { - if (ptr->m_incidentFace > 0) { - dgInt32 index = dgInt32 (ptr->m_userData); - attibuteUsed[index] = 1; - m_uvArray[index].m_u0 = e0length; - m_uvArray[index].m_v0 = dgFloat32 (0.0f); - } - ptr = ptr->m_twin->m_next; - } while (ptr != twinFace); - - dgList<dgEdge*> stack(m_mesh->GetAllocator()); - stack.Append(face); - while (stack.GetCount()) { - dgList<dgEdge*>::dgListNode* const node = stack.GetFirst(); - dgEdge* const face = node->GetInfo(); - stack.Remove (node); - if (face->m_mark != mark) { - dgInt32 uvIndex2 = dgInt32 (face->m_prev->m_userData); - if (!attibuteUsed[uvIndex2]) { - - dgInt32 uvIndex0 = dgInt32 (face->m_userData); - dgInt32 uvIndex1 = dgInt32 (face->m_next->m_userData); - - dgInt32 edgeIndex0 = GetAlphaLandaIndex (face); - dgInt32 edgeIndex1 = GetAlphaLandaIndex (face->m_next); - dgInt32 edgeIndex2 = GetAlphaLandaIndex (face->m_prev); - - dgFloat64 refAngleCos = cos (m_variables[edgeIndex0]); - dgFloat64 refAngleSin = sin (m_variables[edgeIndex0]); - dgFloat64 scale = sin (m_variables[edgeIndex1]) / sin (m_variables[edgeIndex2]); - - dgFloat64 du = (m_uvArray[uvIndex1].m_u0 - m_uvArray[uvIndex0].m_u0) * scale; - dgFloat64 dv = (m_uvArray[uvIndex1].m_v0 - m_uvArray[uvIndex0].m_v0) * scale; - dgFloat64 u = m_uvArray[uvIndex0].m_u0 + du * refAngleCos - dv * refAngleSin; - dgFloat64 v = m_uvArray[uvIndex0].m_v0 + du * refAngleSin + dv * refAngleCos; - - dgEdge* ptr = face->m_prev; - do { - if (ptr->m_incidentFace > 0) { - dgInt32 index = dgInt32 (ptr->m_userData); - attibuteUsed[index] = 1; - m_uvArray[index].m_u0 = u; - m_uvArray[index].m_v0 = v; - } - ptr = ptr->m_twin->m_next; - } while (ptr != face->m_prev); - } - - face->m_mark = mark; - face->m_next->m_mark = mark; - face->m_prev->m_mark = mark; - - if (face->m_next->m_twin->m_incidentFace > 0) { - stack.Append(face->m_next->m_twin); - } - - if (face->m_prev->m_twin->m_incidentFace > 0) { - stack.Append(face->m_prev->m_twin); - } - } - } - } - } - } -*/ - - dgInt32 GetAlphaLandaIndex (const dgEdge* const edge) const - { - return edge->m_incidentFace - 1; - } - - void AnglesFromUV () - { - m_allocated = true; - m_triangleAngles = (dgFloat64*) m_mesh->GetAllocator()->MallocLow (3 * m_trianglesCount * sizeof (dgFloat64)); - - // calculate initial beta angle for each triangle - for (dgInt32 i = 0; i < m_trianglesCount; i ++) { - dgEdge* const edge = m_triangles[i]; - - const dgBigVector& p0 = m_mesh->GetVertex(edge->m_incidentVertex); - const dgBigVector& p1 = m_mesh->GetVertex(edge->m_next->m_incidentVertex); - const dgBigVector& p2 = m_mesh->GetVertex(edge->m_prev->m_incidentVertex); - - dgBigVector e10 (p1 - p0); - dgBigVector e20 (p2 - p0); - dgBigVector e12 (p2 - p1); - dgAssert(e10.m_w == dgFloat32(0.0f)); - dgAssert(e20.m_w == dgFloat32(0.0f)); - dgAssert(e12.m_w == dgFloat32(0.0f)); - - e10 = e10.Scale (dgFloat64 (1.0) / sqrt (e10.DotProduct(e10).GetScalar())); - e20 = e20.Scale (dgFloat64 (1.0) / sqrt (e20.DotProduct(e20).GetScalar())); - e12 = e20.Scale (dgFloat64 (1.0) / sqrt (e12.DotProduct(e12).GetScalar())); - - m_triangleAngles[i * 3 + 0] = acos (dgClamp(e10.DotProduct(e20).GetScalar(), dgFloat64 (-1.0f), dgFloat64 (1.0f))); - m_triangleAngles[i * 3 + 1] = acos (dgClamp(e10.DotProduct(e20).GetScalar(), dgFloat64 (-1.0f), dgFloat64 (1.0f))); - m_triangleAngles[i * 3 + 2] = dgABF_PI - m_triangleAngles[i * 3 + 0] - m_triangleAngles[i * 3 + 1]; - } - } - -/* - // objective function - f[u2_,v2_,u3_,v3_,u4_,v4_,u5_,v5_,u6_,v6_] := - (cos[a0] * sin[b0] * (u1 - u0) + sin[a0] * sin[b0] * (v1 - v0) - sin[c0] * (u6 - u0)) ^ 2 + - (cos[a0] * sin[b0] * (v1 - v0) + sin[a0] * sin[b0] * (u1 - u0) - sin[c0] * (v6 - v0)) ^ 2 + - (cos[a1] * sin[b1] * (u2 - u0) + sin[a1] * sin[b1] * (v2 - v0) - sin[c1] * (u1 - u0)) ^ 2 + - (cos[a1] * sin[b1] * (v2 - v0) + sin[a1] * sin[b1] * (u2 - u0) - sin[c1] * (v1 - v0)) ^ 2 + - (cos[a2] * sin[b2] * (u5 - u0) + sin[a2] * sin[b2] * (v5 - v0) - sin[c2] * (u2 - u0)) ^ 2 + - (cos[a2] * sin[b2] * (v5 - v0) + sin[a2] * sin[b2] * (u5 - u0) - sin[c2] * (v2 - v0)) ^ 2 + - (cos[a3] * sin[b3] * (u2 - u1) + sin[a3] * sin[b3] * (v2 - v1) - sin[c3] * (u3 - u1)) ^ 2 + - (cos[a3] * sin[b3] * (v2 - v1) + sin[a3] * sin[b3] * (u2 - u1) - sin[c3] * (v3 - v1)) ^ 2 + - (cos[a4] * sin[b4] * (u3 - u1) + sin[a4] * sin[b4] * (v3 - v1) - sin[c4] * (u4 - u1)) ^ 2 + - (cos[a4] * sin[b4] * (v3 - v1) + sin[a4] * sin[b4] * (u3 - u1) - sin[c4] * (v4 - v1)) ^ 2 + - (cos[a5] * sin[b5] * (u4 - u1) + sin[a5] * sin[b5] * (v4 - v1) - sin[c5] * (u6 - u1)) ^ 2 + - (cos[a5] * sin[b5] * (v4 - v1) + sin[a5] * sin[b5] * (u4 - u1) - sin[c5] * (v6 - v1)) ^ 2 + - (cos[a6] * sin[b6] * (u4 - u2) + sin[a6] * sin[b6] * (v4 - v2) - sin[c6] * (u3 - u2)) ^ 2 + - (cos[a6] * sin[b6] * (v4 - v2) + sin[a6] * sin[b6] * (u4 - u2) - sin[c6] * (v3 - v2)) ^ 2 + - (cos[a7] * sin[b7] * (u5 - u2) + sin[a7] * sin[b7] * (v5 - v2) - sin[c7] * (u4 - u2)) ^ 2 + - (cos[a7] * sin[b7] * (v5 - v2) + sin[a7] * sin[b7] * (u5 - u2) - sin[c7] * (v4 - v2)) ^ 2 + - (cos[a8] * sin[b8] * (u5 - u4) + sin[a8] * sin[b8] * (v5 - v4) - sin[c8] * (u6 - u4)) ^ 2 + - (cos[a8] * sin[b8] * (v5 - v4) + sin[a8] * sin[b8] * (u5 - u4) - sin[c8] * (v6 - v4)) ^ 2 -*/ - void TraceObjectiveFunction() const - { - DG_DEBUG_UV (("f[")); - for (dgInt32 i = 2; i < m_mesh->GetVertexCount(); i ++) { - DG_DEBUG_UV (("u%d_,v%d_", i, i)); - if (i != (m_mesh->GetVertexCount() - 1)) { - DG_DEBUG_UV ((",")); - } - } - DG_DEBUG_UV (("] := \n")); - - for (dgInt32 i = 0; i < m_trianglesCount; i ++) { - dgEdge* const face = m_triangles[i]; - - dgInt32 v0 = face->m_incidentVertex; - dgInt32 v1 = face->m_next->m_incidentVertex; - dgInt32 v2 = face->m_prev->m_incidentVertex; - (void)(v0); - (void)(v1); - (void)(v2); - DG_DEBUG_UV (("(cos[a%d] * sin[b%d] * (u%d - u%d) + sin[a%d] * sin[b%d] * (v%d - v%d) - sin[c%d] * (u%d - u%d)) ^ 2 +\n", i, i, v1, v0, i, i, v1, v0, i, v2, v0)); - DG_DEBUG_UV (("(cos[a%d] * sin[b%d] * (v%d - v%d) + sin[a%d] * sin[b%d] * (u%d - u%d) - sin[c%d] * (v%d - v%d)) ^ 2", i, i, v1, v0, i, i, v1, v0, i, v2, v0)); - if (i != (m_trianglesCount - 1)) { - DG_DEBUG_UV ((" + \n")); - } else { - DG_DEBUG_UV (("\n")); - } - } - } - - dgFloat64 CalculateExpression_U_face (const dgEdge* const face) const - { - dgInt32 faceIndex = GetAlphaLandaIndex (face); - dgEdge* const faceStartEdge = m_triangles[faceIndex]; - - dgInt32 uvIndex0 = dgInt32 (faceStartEdge->m_incidentVertex); - dgInt32 uvIndex1 = dgInt32 (faceStartEdge->m_next->m_incidentVertex); - dgInt32 uvIndex2 = dgInt32 (faceStartEdge->m_prev->m_incidentVertex); - - dgInt32 alphaIndex0 = faceIndex * 3; - dgInt32 alphaIndex1 = faceIndex * 3 + 1; - dgInt32 alphaIndex2 = faceIndex * 3 + 2; - - DG_DEBUG_UV (("(")); - DG_DEBUG_UV (("cos(a%d) * sin(b%d) * (u%d - u%d) + ", faceIndex, faceIndex, uvIndex1, uvIndex0)); - DG_DEBUG_UV (("sin(a%d) * sin(b%d) * (v%d - v%d) + ", faceIndex, faceIndex, uvIndex1, uvIndex0)); - DG_DEBUG_UV (("sin(c%d) * (u%d - u%d)", faceIndex, uvIndex2, uvIndex0)); - DG_DEBUG_UV ((")")); - - dgFloat64 gradient = m_cosTable[alphaIndex0] * m_sinTable[alphaIndex1] * (m_uvArray[uvIndex1 * 2] - m_uvArray[uvIndex0 * 2]) + - m_sinTable[alphaIndex0] * m_sinTable[alphaIndex1] * (m_uvArray[uvIndex1 * 2 + 1] - m_uvArray[uvIndex0 * 2 + 1]) + - m_sinTable[alphaIndex2] * (m_uvArray[uvIndex2 * 2] - m_uvArray[uvIndex0 * 2]); - return gradient; - } - - dgFloat64 CalculateExpression_V_face (const dgEdge* const face) const - { - dgInt32 faceIndex = GetAlphaLandaIndex (face); - dgEdge* const faceStartEdge = m_triangles[faceIndex]; - - dgInt32 uvIndex0 = dgInt32 (faceStartEdge->m_incidentVertex); - dgInt32 uvIndex1 = dgInt32 (faceStartEdge->m_next->m_incidentVertex); - dgInt32 uvIndex2 = dgInt32 (faceStartEdge->m_prev->m_incidentVertex); - - dgInt32 alphaIndex0 = faceIndex * 3; - dgInt32 alphaIndex1 = faceIndex * 3 + 1; - dgInt32 alphaIndex2 = faceIndex * 3 + 2; - - DG_DEBUG_UV (("(")); - DG_DEBUG_UV (("cos(a%d) * sin(b%d) * (v%d - v%d) + ", faceIndex, faceIndex, uvIndex1, uvIndex0)); - DG_DEBUG_UV (("sin(a%d) * sin(b%d) * (u%d - u%d) + ", faceIndex, faceIndex, uvIndex1, uvIndex0)); - DG_DEBUG_UV (("sin(c%d) * (v%d - v%d)", faceIndex, uvIndex2, uvIndex0)); - DG_DEBUG_UV ((")")); - - dgFloat64 gradient = m_cosTable[alphaIndex0] * m_sinTable[alphaIndex1] * (m_uvArray[uvIndex1 * 2 + 1] - m_uvArray[uvIndex0 * 2 + 1]) + - m_sinTable[alphaIndex0] * m_sinTable[alphaIndex1] * (m_uvArray[uvIndex1 * 2] - m_uvArray[uvIndex0 * 2]) + - m_sinTable[alphaIndex2] * (m_uvArray[uvIndex2 * 2 + 1] - m_uvArray[uvIndex0 * 2 + 1]); - return gradient; - } - - - dgFloat64 CalculateGradient_U_Coefficent (const dgEdge* const edge, bool u) const - { - DG_DEBUG_UV (("(")); - dgInt32 faceIndex = GetAlphaLandaIndex (edge); - dgEdge* const faceStartEdge = m_triangles[faceIndex]; - - dgFloat64 gradient = dgFloat64 (0.0f); - - dgInt32 alphaIndex0 = faceIndex * 3; - dgInt32 alphaIndex1 = faceIndex * 3 + 1; - dgInt32 alphaIndex2 = faceIndex * 3 + 2; - if (faceStartEdge == edge) { - if (u) { - DG_DEBUG_UV ((" - cos(a%d) * sin(b%d) - sin(c%d)", faceIndex, faceIndex, faceIndex)); - gradient = - m_cosTable[alphaIndex0] * m_sinTable[alphaIndex1] - m_sinTable[alphaIndex2]; - } else { - DG_DEBUG_UV ((" - sin(a%d) * sin(b%d) - sin(c%d)", faceIndex, faceIndex, faceIndex)); - gradient = - m_sinTable[alphaIndex0] * m_sinTable[alphaIndex1] - m_sinTable[alphaIndex2]; - } - } else if (faceStartEdge->m_next == edge) { - if (u) { - DG_DEBUG_UV (("cos(a%d) * sin(b%d)", faceIndex, faceIndex)); - gradient = m_cosTable[alphaIndex0] * m_sinTable[alphaIndex1]; - } else { - DG_DEBUG_UV (("sin(a%d) * sin(b%d)", faceIndex, faceIndex)); - gradient = m_sinTable[alphaIndex0] * m_sinTable[alphaIndex1]; - } - } else { - dgAssert (faceStartEdge->m_prev == edge); - if (u) { - DG_DEBUG_UV ((" - sin(c%d)", faceIndex)); - gradient = -m_sinTable[alphaIndex2]; - } else { - DG_DEBUG_UV (("0")); - } - } - DG_DEBUG_UV ((")")); - return gradient; - } - - dgFloat64 CalculateGradient_V_Coefficent (const dgEdge* const edge, bool u) const - { - DG_DEBUG_UV (("(")); - dgInt32 faceIndex = GetAlphaLandaIndex (edge); - dgEdge* const faceStartEdge = m_triangles[faceIndex]; - - dgInt32 alphaIndex0 = faceIndex * 3; - dgInt32 alphaIndex1 = faceIndex * 3 + 1; - dgInt32 alphaIndex2 = faceIndex * 3 + 2; - - dgFloat64 gradient = dgFloat64 (0.0f); - if (faceStartEdge == edge) { - if (!u) { - DG_DEBUG_UV ((" - cos(a%d) * sin(b%d) - sin(c%d)", faceIndex, faceIndex, faceIndex)); - gradient = - m_cosTable[alphaIndex0] * m_sinTable[alphaIndex1] - m_sinTable[alphaIndex2]; - } else { - DG_DEBUG_UV ((" - sin(a%d) * sin(b%d) - sin(c%d)", faceIndex, faceIndex, faceIndex)); - gradient = - m_sinTable[alphaIndex0] * m_sinTable[alphaIndex1] - m_sinTable[alphaIndex2]; - } - } else if (faceStartEdge->m_next == edge) { - if (!u) { - DG_DEBUG_UV (("cos(a%d) * sin(b%d)", faceIndex, faceIndex)); - gradient = m_cosTable[alphaIndex0] * m_sinTable[alphaIndex1]; - } else { - DG_DEBUG_UV (("sin(a%d) * sin(b%d)", faceIndex, faceIndex)); - gradient = m_sinTable[alphaIndex0] * m_sinTable[alphaIndex1]; - } - } else { - dgAssert (faceStartEdge->m_prev == edge); - if (!u) { - DG_DEBUG_UV ((" - sin(c%d)", faceIndex)); - gradient = -m_sinTable[alphaIndex2]; - } else { - DG_DEBUG_UV (("0")); - } - } - DG_DEBUG_UV ((")")); - return gradient; - } - - - dgFloat64 CalculateHessianExpression_U_V (const dgEdge* const face) const - { - dgInt32 faceIndex = GetAlphaLandaIndex (face); - //dgEdge* const faceStartEdge = m_triangles[faceIndex]; - //dgInt32 uvIndex0 = dgInt32 (faceStartEdge->m_incidentVertex); - //dgInt32 uvIndex1 = dgInt32 (faceStartEdge->m_next->m_incidentVertex); - //dgInt32 uvIndex2 = dgInt32 (faceStartEdge->m_prev->m_incidentVertex); - dgInt32 alphaIndex0 = faceIndex * 3; - dgInt32 alphaIndex1 = faceIndex * 3 + 1; - //dgInt32 alphaIndex2 = faceIndex * 3 + 2; - DG_DEBUG_UV (("( - sin(a%d) * sin(b%d))", faceIndex, faceIndex)); - return - m_sinTable[alphaIndex0] * m_sinTable[alphaIndex1]; - } - - - dgFloat64 CalculateHessianExpression_V_V (const dgEdge* const face) const - { - dgInt32 faceIndex = GetAlphaLandaIndex (face); - //dgEdge* const faceStartEdge = m_triangles[faceIndex]; - //dgInt32 uvIndex0 = dgInt32 (faceStartEdge->m_incidentVertex); - //dgInt32 uvIndex1 = dgInt32 (faceStartEdge->m_next->m_incidentVertex); - //dgInt32 uvIndex2 = dgInt32 (faceStartEdge->m_prev->m_incidentVertex); - - dgInt32 alphaIndex0 = faceIndex * 3; - dgInt32 alphaIndex1 = faceIndex * 3 + 1; - dgInt32 alphaIndex2 = faceIndex * 3 + 2; - DG_DEBUG_UV (("(- cos(a%d) * sin(b%d) - sin(c%d))", faceIndex, faceIndex, faceIndex)); - return - m_cosTable[alphaIndex0] * m_sinTable[alphaIndex1] - m_sinTable[alphaIndex2]; - } - - - void CalculateGradientU (dgInt32 vertexIndex) - { - // calculate U Gradient derivative - const dgEdge* const vertex = m_vertexEdge[vertexIndex]; - DG_DEBUG_UV (("du%d =\n", vertexIndex)); - dgFloat64 gradient = dgFloat64 (0.0f); - const dgEdge* ptr = vertex; - do { - if (ptr->m_incidentFace > 0) { - DG_DEBUG_UV (("2 * ")); - dgAssert (ptr->m_incidentVertex == vertexIndex); - dgFloat64 a = CalculateGradient_U_Coefficent (ptr, true) ; - DG_DEBUG_UV ((" * ")); - gradient += a * CalculateExpression_U_face (ptr); - DG_DEBUG_UV ((" +\n")); - - DG_DEBUG_UV (("2 * ")); - a = CalculateGradient_U_Coefficent (ptr, false); - DG_DEBUG_UV ((" * ")); - gradient += a * CalculateExpression_V_face (ptr); - DG_DEBUG_UV ((" +\n")); - } - ptr = ptr->m_twin->m_next; - } while (ptr != vertex); - m_gradients[2 * vertexIndex] = - gradient; - DG_DEBUG_UV (("\n")); - - // calculate diagonal derivative - DG_DEBUG_UV (("H(u%d,u%d) =\n", vertexIndex, vertexIndex)); - dgFloat64 diagonal = dgFloat64 (0.0f); - ptr = vertex; - do { - if (ptr->m_incidentFace > 0) { - DG_DEBUG_UV (("2 * ")); - dgAssert (ptr->m_incidentVertex == vertexIndex); - dgFloat64 diag = CalculateGradient_U_Coefficent (ptr, true); - diagonal += diag * diag; - DG_DEBUG_UV (("^2 +\n")); - - DG_DEBUG_UV (("2 * ")); - diag = CalculateGradient_U_Coefficent (ptr, false); - diagonal += diag * diag; - DG_DEBUG_UV (("^2 +\n")); - } - ptr = ptr->m_twin->m_next; - } while (ptr != vertex); - dgAssert (diagonal > dgFloat32 (0.0f)); - - m_hessianCoLumnValue[m_matrixElementCount] = diagonal; - m_hessianCoLumnIndex[m_matrixElementCount] = vertexIndex * 2 + 0; - m_matrixElementCount ++; - m_diagonal[2 * vertexIndex] = diagonal; - DG_DEBUG_UV (("\n")); - - // calculate of diagonal UiVi derivative - DG_DEBUG_UV (("H(u%d,v%d) =\n", vertexIndex, vertexIndex)); - dgFloat64 hessianUV = dgFloat64 (0.0); - ptr = vertex; - do { - if (ptr->m_incidentFace > 0) { - DG_DEBUG_UV (("2 * ")); - dgAssert (ptr->m_incidentVertex == vertexIndex); - dgFloat64 a = CalculateGradient_U_Coefficent (ptr, true); - DG_DEBUG_UV ((" * ")); - hessianUV += a * CalculateHessianExpression_U_V (ptr); - DG_DEBUG_UV ((" +\n")); - - DG_DEBUG_UV (("2 * ")); - a = CalculateGradient_U_Coefficent (ptr, false); - DG_DEBUG_UV ((" * ")); - hessianUV += a * CalculateHessianExpression_V_V (ptr); - DG_DEBUG_UV ((" +\n")); - } - ptr = ptr->m_twin->m_next; - } while (ptr != vertex); - - m_hessianCoLumnValue[m_matrixElementCount] = hessianUV; - m_hessianCoLumnIndex[m_matrixElementCount] = vertexIndex * 2 + 1; - m_matrixElementCount ++; - DG_DEBUG_UV (("\n")); - - -/* - // calculate off diagonal partial derivatives - ptr = vertex; - do { - // derivative respect to U(i, j) - dgInt32 vertexIndex2 = ptr->m_twin->m_incidentVertex; - DG_DEBUG_UV (("H(u%d,u%d) =\n", vertexIndex, vertexIndex2)); - if (ptr->m_incidentFace > 0) { - DG_DEBUG_UV (("2 * ")); - dgAssert (ptr->m_incidentVertex == vertexIndex); - dgFloat64 a = CalculateGradient_U_Coefficent (ptr, true); - DG_DEBUG_UV ((" * ")); -// gradient += diag * TraceExpression_U_face (ptr); - DG_DEBUG_UV ((" +\n")); - - DG_DEBUG_UV (("2 * ")); - a = CalculateGradient_U_Coefficent (ptr, false); - DG_DEBUG_UV ((" * ")); -// gradient += diag * TraceExpression_V_face (ptr); - DG_DEBUG_UV ((" +\n")); - } - - if (ptr->m_twin->m_incidentFace > 0) { - DG_DEBUG_UV (("2 * ")); - dgAssert (ptr->m_incidentVertex == vertexIndex); - dgFloat64 a = CalculateGradient_U_Coefficent (ptr->m_twin->m_next, true); - DG_DEBUG_UV ((" * ")); - // gradient += diag * TraceExpression_U_face (ptr); - DG_DEBUG_UV ((" +\n")); - - DG_DEBUG_UV (("2 * ")); - a = CalculateGradient_U_Coefficent (ptr->m_twin->m_next, false); - DG_DEBUG_UV ((" * ")); - // gradient += diag * TraceExpression_V_face (ptr); - DG_DEBUG_UV ((" +\n")); - } - - // derivative respect to V(i, j) - DG_DEBUG_UV (("H(u%d,v%d) =\n", vertexIndex, vertexIndex2)); - if (ptr->m_incidentFace > 0) { - - DG_DEBUG_UV (("2 * ")); - dgAssert (ptr->m_incidentVertex == vertexIndex); - dgFloat64 a = CalculateGradient_U_Coefficent (ptr, true); - DG_DEBUG_UV ((" * ")); - // gradient += diag * TraceExpression_U_face (ptr); - DG_DEBUG_UV ((" +\n")); - - DG_DEBUG_UV (("2 * ")); - a = CalculateGradient_U_Coefficent (ptr, false); - DG_DEBUG_UV ((" * ")); - // gradient += diag * TraceExpression_V_face (ptr); - DG_DEBUG_UV ((" +\n")); - - } - - if (ptr->m_twin->m_incidentFace > 0) { - - DG_DEBUG_UV (("2 * ")); - dgAssert (ptr->m_incidentVertex == vertexIndex); - dgFloat64 a = CalculateGradient_U_Coefficent (ptr->m_twin->m_next, true); - DG_DEBUG_UV ((" * ")); - // gradient += diag * TraceExpression_U_face (ptr); - DG_DEBUG_UV ((" +\n")); - - DG_DEBUG_UV (("2 * ")); - a = CalculateGradient_U_Coefficent (ptr->m_twin->m_next, false); - DG_DEBUG_UV ((" * ")); - // gradient += diag * TraceExpression_V_face (ptr); - DG_DEBUG_UV ((" +\n")); - - } - - DG_DEBUG_UV (("\n")); - ptr = ptr->m_twin->m_next; - } while (ptr != vertex); -*/ - } - - - void CalculateGradientV (dgInt32 vertexIndex) - { - // calculate U Gradient derivative - const dgEdge* const vertex = m_vertexEdge[vertexIndex]; - DG_DEBUG_UV (("dv%d =\n", vertexIndex)); - - dgFloat64 gradient = dgFloat64 (0.0f); - const dgEdge* ptr = vertex; - do { - if (ptr->m_incidentFace > 0) { - DG_DEBUG_UV (("2 * ")); - dgAssert (ptr->m_incidentVertex == vertexIndex); - dgFloat64 a = CalculateGradient_V_Coefficent (ptr, true); - DG_DEBUG_UV ((" * ")); - gradient += a * CalculateExpression_U_face (ptr); - DG_DEBUG_UV ((" +\n")); - - DG_DEBUG_UV (("2 * ")); - a = CalculateGradient_V_Coefficent (ptr, false); - DG_DEBUG_UV ((" * ")); - gradient += a * CalculateExpression_V_face (ptr); - DG_DEBUG_UV ((" +\n")); - } - ptr = ptr->m_twin->m_next; - } while (ptr != vertex); - m_gradients[2 * vertexIndex + 1] = - gradient; - DG_DEBUG_UV (("\n")); - - - // calculate diagonal derivative - DG_DEBUG_UV (("H(v%d,v%d) =\n", vertexIndex, vertexIndex)); - dgFloat64 diagonal = dgFloat64 (0.0f); - ptr = vertex; - do { - if (ptr->m_incidentFace > 0) { - DG_DEBUG_UV (("2 * ")); - dgAssert (ptr->m_incidentVertex == vertexIndex); - dgFloat64 diag = CalculateGradient_V_Coefficent (ptr, true); - diagonal += diag * diag; - DG_DEBUG_UV (("^2 +\n")); - - DG_DEBUG_UV (("2 * ")); - diag = CalculateGradient_V_Coefficent (ptr, false); - diagonal += diag * diag; - DG_DEBUG_UV (("^2 +\n")); - } - ptr = ptr->m_twin->m_next; - } while (ptr != vertex); - dgAssert (diagonal > dgFloat32 (0.0f)); - - m_hessianCoLumnValue[m_matrixElementCount] = diagonal; - m_hessianCoLumnIndex[m_matrixElementCount] = vertexIndex * 2 + 1; - m_matrixElementCount ++; - m_diagonal[2 * vertexIndex + 1] = diagonal; - DG_DEBUG_UV (("\n")); - - - - - - } - - - - void CalculateGradientVectorAndHessianMatrix () - { - // trace objective function -// TraceObjectiveFunction(); - - // trace gradients - DG_DEBUG_UV (("\n")); - dgInt32 count = m_mesh->GetVertexCount(); - for (dgInt32 i = 0; i < count; i ++) { - CalculateGradientU (i); - CalculateGradientV (i); - } - DG_DEBUG_UV (("\n")); - } - - void InversePrecoditionerTimeVector (dgFloat64* const out, const dgFloat64* const v) const - { - const dgInt32 count = m_mesh->GetVertexCount(); - for (dgInt32 i = 0; i < count; i ++) { - out[2 * i + 0] = m_pinnedPoints[i] * v[i * 2 + 0] / m_diagonal[2 * i + 0]; - out[2 * i + 1] = m_pinnedPoints[i] * v[i * 2 + 1] / m_diagonal[2 * i + 1]; - } - } - - void MatrixTimeVector (dgFloat64* const out, const dgFloat64* const v) const - { -/* - const dgInt32 count = m_mesh->GetVertexCount(); - for (dgInt32 i = 0; i < count; i ++) { - dgEdge* const vertex = m_vertexEdge[i]; - dgAssert (vertex->m_incidentVertex == i); - out[i * 2 + 0] = m_diagonal[2 * i + 0] * v[2 * i + 0]; - out[i * 2 + 1] = m_diagonal[2 * i + 1] * v[2 * i + 1]; - } - DG_DEBUG_UV (("\n")); - dgInt32 count = m_mesh->GetVertexCount(); - for (dgInt32 i = 0; count; i ++) { - CalculateHessianDiagonalUU (i); - } - DG_DEBUG_UV (("\n")); -*/ - } - - void LagrangeOptimization() - { - CalculateGradientVectorAndHessianMatrix (); - dgStack<dgFloat64> r0(2 * m_mesh->GetVertexCount()); - dgStack<dgFloat64> z0(2 * m_mesh->GetVertexCount()); - dgStack<dgFloat64> p0(2 * m_mesh->GetVertexCount()); - dgStack<dgFloat64> q0(2 * m_mesh->GetVertexCount()); - SetBuffers(&r0[0], &z0[0], &p0[0], &q0[0]); - Solve(2 * m_mesh->GetVertexCount(), dgABF_UV_TOL2, m_uvArray, m_gradients); - SetBuffers(NULL, NULL, NULL, NULL); - } - - dgArray<dgInt32> m_hessianCoLumnIndex; - dgArray<dgFloat64> m_hessianCoLumnValue; - dgMeshEffect* m_mesh; - dgEdge** m_triangles; - dgEdge** m_vertexEdge; - dgFloat64* m_uvArray; - dgFloat64* m_sinTable; - dgFloat64* m_cosTable; - dgFloat64* m_gradients; - dgFloat64* m_diagonal; - dgFloat64* m_triangleAngles; - const dgFloat64* m_pinnedPoints; - - dgInt32 m_trianglesCount; - dgInt32 m_matrixElementCount; - bool m_allocated; -}; - -class dgAngleBasedFlatteningMapping: public dgSymmetricConjugateGradientSolver<dgFloat64> -{ - public: - dgAngleBasedFlatteningMapping (dgMeshEffect* const mesh, dgInt32 material, dgReportProgress progressReportCallback, void* const userData) - :m_mesh(mesh) - ,m_progressReportUserData(userData) - ,m_progressReportCallback(progressReportCallback) - { -dgAssert (0); -/* - AllocVectors(); - InitEdgeVector(); - CalculateInitialAngles (); - LagrangeOptimization(); - - dgEdge* const face = m_betaEdge[0]; - dgEdge* ptr = face; - do { - if (ptr->m_incidentFace > 0) { - dgInt32 index = dgInt32 (ptr->m_userData); - dgMeshEffect::dgVertexAtribute& attribute = m_mesh->GetAttribute (index); - attribute.m_u0 = dgFloat32 (0.0f); - attribute.m_v0 = dgFloat32 (0.0f); - } - ptr = ptr->m_twin->m_next; - } while (ptr != face); - - dgEdge* const twinFace = face->m_twin; - const dgBigVector& p0 = m_mesh->GetVertex(face->m_incidentVertex); - const dgBigVector& p1 = m_mesh->GetVertex(twinFace->m_incidentVertex); - dgBigVector p10 (p1 - p0); - dgAssert(p10.m_w == dgFloat32(0.0f)); - dgFloat64 e0length = sqrt (p10.DotProduct(p10).GetScalar()); - - ptr = twinFace; - do { - if (ptr->m_incidentFace > 0) { - dgInt32 index = dgInt32 (ptr->m_userData); - dgMeshEffect::dgVertexAtribute& attribute = m_mesh->GetAttribute (index); - attribute.m_u0 = e0length; - attribute.m_v0 = dgFloat32 (0.0f); - } - ptr = ptr->m_twin->m_next; - } while (ptr != twinFace); - - DeleteAuxiliaryVectors(); - - m_deltaVariables[0] = 0.0f; - m_deltaVariables[1] = 0.0f; - for (dgInt32 i = 2; i < m_totalVariablesCount; i ++) { - m_deltaVariables[i] = 1.0f; - } - dgTriangleAnglesToUV anglesToUV (mesh, material, progressReportCallback, userData, m_deltaVariables, m_variables); -*/ - } - - ~dgAngleBasedFlatteningMapping() - { - m_mesh->GetAllocator()->FreeLow (m_variables); - m_mesh->GetAllocator()->FreeLow (m_deltaVariables); - } - - - void AllocVectors() - { - CalculateNumberOfVariables(); - dgInt32 vertexCount = m_mesh->GetVertexCount(); - - // alloc intermediate vectors - m_betaEdge = (dgEdge**) m_mesh->GetAllocator()->MallocLow(m_anglesCount * sizeof (dgEdge*)); - m_interiorIndirectMap = (dgInt32*) m_mesh->GetAllocator()->MallocLow (vertexCount * sizeof (dgInt32)); - m_beta = (dgFloat64*) m_mesh->GetAllocator()->MallocLow (m_anglesCount * sizeof (dgFloat64)); - m_weight= (dgFloat64*) m_mesh->GetAllocator()->MallocLow (m_anglesCount * sizeof (dgFloat64)); - m_sinTable = (dgFloat64*) m_mesh->GetAllocator()->MallocLow (m_anglesCount * sizeof (dgFloat64)); - m_cosTable = (dgFloat64*) m_mesh->GetAllocator()->MallocLow (m_anglesCount * sizeof (dgFloat64)); - m_gradients = (dgFloat64*) m_mesh->GetAllocator()->MallocLow (m_totalVariablesCount * sizeof (dgFloat64)); - - // allocate angle and internal vertex vector - m_variables = (dgFloat64*) m_mesh->GetAllocator()->MallocLow (m_totalVariablesCount * sizeof (dgFloat64)); - m_deltaVariables = (dgFloat64*) m_mesh->GetAllocator()->MallocLow (m_totalVariablesCount * sizeof (dgFloat64)); - } - - void DeleteAuxiliaryVectors() - { - // delete intermediate vectors - m_mesh->GetAllocator()->FreeLow (m_betaEdge); - m_mesh->GetAllocator()->FreeLow (m_interiorIndirectMap); - m_mesh->GetAllocator()->FreeLow (m_sinTable); - m_mesh->GetAllocator()->FreeLow (m_cosTable); - m_mesh->GetAllocator()->FreeLow (m_beta); - m_mesh->GetAllocator()->FreeLow (m_weight); - m_mesh->GetAllocator()->FreeLow (m_gradients); - - m_beta = NULL; - m_weight = NULL; - m_betaEdge = NULL; - m_sinTable = NULL; - m_cosTable = NULL; - m_gradients = NULL; - m_interiorIndirectMap = NULL; - } - - - void CalculateNumberOfVariables() - { - //m_mesh->SaveOFF("xxx.off"); - m_anglesCount = 0; - m_triangleCount = 0; - m_interiorVertexCount = 0; - - dgInt32 mark = m_mesh->IncLRU(); - dgMeshEffect::Iterator iter (*m_mesh); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if ((edge->m_incidentFace > 0) && (edge->m_mark != mark)) { - dgEdge *ptr = edge; - do { - m_anglesCount ++; - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - m_triangleCount ++; - dgAssert (edge->m_next->m_next->m_next == edge); - } - } - - mark = m_mesh->IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if ((edge->m_incidentFace > 0) && (edge->m_mark != mark)) { - bool isInterior = true; - dgEdge *ptr = edge; - do { - isInterior &= (ptr->m_incidentFace > 0); - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - m_interiorVertexCount += isInterior ? 1 : 0; - } - } - m_totalVariablesCount = m_anglesCount + m_triangleCount + 2 * m_interiorVertexCount; - } - - void InitEdgeVector() - { - dgInt32 count = 0; - dgInt32 mark = m_mesh->IncLRU(); - dgMeshEffect::Iterator iter (*m_mesh); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if ((edge->m_incidentFace > 0) && (edge->m_mark != mark)) { - dgEdge *ptr = edge; - do { - ptr->m_mark = mark; - m_betaEdge[count] = ptr; - ptr->m_incidentFace = count + 1; - count ++; - dgAssert (count <= m_anglesCount); - ptr = ptr->m_next; - } while (ptr != edge); - } - } - - count = 0; - mark = m_mesh->IncLRU(); - memset (m_interiorIndirectMap, -1, m_mesh->GetVertexCount() * sizeof (m_interiorIndirectMap[0])); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if ((edge->m_incidentFace > 0) && (edge->m_mark != mark)) { - - bool isInterior = true; - dgEdge* ptr = edge; - do { - isInterior &= (ptr->m_incidentFace > 0); - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - if (isInterior) { - m_interiorIndirectMap[edge->m_incidentVertex] = m_anglesCount + m_triangleCount + count; - count ++; - } - } - } - } - - dgInt32 GetAlphaLandaIndex (const dgEdge* const edge) const - { - return edge->m_incidentFace - 1; - } - - dgInt32 GetTriangleIndex (const dgInt32 alphaIndex) const - { - return alphaIndex / 3 + m_anglesCount; - } - - dgInt32 GetTriangleIndex (const dgEdge* const edge) const - { - return GetAlphaLandaIndex(edge) / 3 + m_anglesCount; - } - - dgInt32 GetInteriorVertex(const dgEdge* const edge) const - { - return m_interiorIndirectMap[edge->m_incidentVertex]; - } - - void CalculateInitialAngles () - { - // calculate initial beta angle for each triangle - for (dgInt32 i = 0; i < m_anglesCount; i ++) { - dgEdge* const edge = m_betaEdge[i]; - - const dgBigVector& p0 = m_mesh->GetVertex(edge->m_incidentVertex); - const dgBigVector& p1 = m_mesh->GetVertex(edge->m_next->m_incidentVertex); - const dgBigVector& p2 = m_mesh->GetVertex(edge->m_prev->m_incidentVertex); - - dgBigVector e10 (p1 - p0); - dgBigVector e20 (p2 - p0); - - e10 = e10.Scale (dgFloat64 (1.0) / sqrt (e10.DotProduct(e10).GetScalar())); - e20 = e20.Scale (dgFloat64 (1.0) / sqrt (e20.DotProduct(e20).GetScalar())); - dgAssert(e10.m_w == dgFloat32(0.0f)); - dgAssert(e20.m_w == dgFloat32(0.0f)); - - m_beta[i] = acos (dgClamp(e10.DotProduct(e20).GetScalar(), dgFloat64 (-1.0f), dgFloat64 (1.0f))); - dgAssert (m_beta[i] > dgFloat64 (0.0f)); - } - - #ifdef _DEBUG - for (dgInt32 i = 0; i < m_triangleCount; i ++) { - dgInt32 i0 = i * 3 + 0; - dgInt32 i1 = i * 3 + 1; - dgInt32 i2 = i * 3 + 2; - dgAssert (fabs (m_beta[i0] + m_beta[i1] + m_beta[i2] - dgABF_PI) < dgFloat64 (1.0e-6f)); - } - #endif - - // for each interior vertex apply the scale factor - dgInt32 mark = m_mesh->IncLRU(); - for (dgInt32 i = 0; i < m_anglesCount; i ++) { - dgEdge* const edge = m_betaEdge[i]; - if ((edge->m_mark != mark) && (GetInteriorVertex(edge) >= 0)) { - dgFloat64 scale = dgFloat64 (0.0f); - dgEdge* ptr = edge; - do { - dgInt32 index = GetAlphaLandaIndex (ptr); - dgAssert (index >= 0); - dgAssert (index <= m_anglesCount); - scale += m_beta[index]; - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - dgAssert (scale > dgFloat32 (0.0f)); - - scale = dgFloat64 (2.0f) * dgABF_PI / scale; - ptr = edge; - do { - dgInt32 index = GetAlphaLandaIndex (ptr); - dgAssert (index >= 0); - dgAssert (index <= m_anglesCount); - m_beta[index] *= scale; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - } - } - - // initialized each alpha lambda to the beta angle and also calcual ethe derivatoe coeficent (2.0 / (betai * betai)) - for (dgInt32 i = 0; i < m_anglesCount; i ++) { - dgAssert (m_beta[i] > dgFloat64 (0.0f)); - m_variables[i] = m_beta[i]; - m_weight[i] = dgFloat64 (2.0f) / (m_beta[i] * m_beta[i]); - } - } - - // angular derivative component - // (wi * (xi - bi) + T0 - // where wi = 2.0 / (bi ^ 2) - dgFloat64 CalculateAngularGradientDerivative (dgInt32 alphaIndex) const - { - dgFloat64 gradient = (m_variables[alphaIndex] - m_beta[alphaIndex]) * m_weight[alphaIndex] + m_variables[GetTriangleIndex(alphaIndex)]; - dgAssert (fabs(gradient) < dgFloat64(1.0e10f)); - return gradient; - } - - // Vi if the the edge is an interior vertex - dgFloat64 CalculateInteriorVertexGradient (dgInt32 alphaIndex) const - { - dgInt32 index = GetInteriorVertex(m_betaEdge[alphaIndex]); - dgFloat64 gradient = (index != -1) ? m_variables[index] : dgFloat32 (0.0f); - dgAssert (fabs(gradient) < dgFloat64(1.0e10f)); - return gradient; - } - - // Wj * cos(alpha) * sum (alphai) for eadh previsu or next interior incdent vertex - dgFloat64 CalculatePlanarityGradient (dgInt32 alphaIndex) const - { - dgFloat64 gradient = dgFloat64 (0.0f); - - dgEdge* const incidentEdge = m_betaEdge[alphaIndex]; - - if (GetInteriorVertex (incidentEdge->m_next) != -1) { - dgEdge* const edge = m_betaEdge[GetAlphaLandaIndex(incidentEdge->m_next)]; - dgFloat64 product = m_cosTable[GetAlphaLandaIndex(edge->m_prev)]; - dgEdge* ptr = edge->m_twin->m_next; - do { - product *= m_sinTable[GetAlphaLandaIndex(ptr->m_prev)]; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - dgInt32 interiorVertexIndex = GetInteriorVertex (incidentEdge->m_next) + m_interiorVertexCount; - gradient -= m_variables[interiorVertexIndex] * product; - } - - if (GetInteriorVertex (incidentEdge->m_prev) != -1) { - dgEdge* const edge = m_betaEdge[GetAlphaLandaIndex(incidentEdge->m_prev)]; - dgFloat64 product = m_cosTable[GetAlphaLandaIndex(edge->m_next)]; - dgEdge* ptr = edge->m_twin->m_next; - do { - product *= m_sinTable[GetAlphaLandaIndex(ptr->m_next)]; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - dgInt32 interiorVertexIndex = GetInteriorVertex (incidentEdge->m_prev) + m_interiorVertexCount; - gradient += m_variables[interiorVertexIndex] * product; - } - dgAssert (fabs(gradient) < dgFloat64(1.0e10f)); - return gradient; - } - - // sample of the Gradient Vector according to Mathematic to a generic mesh, this can be generalize for and arbitrary mesh topology - // x0 - x14 are the planar angles in 2d - // b0 - b14 are the mesh angles in 3d. - // T0 - T4 are the triangle lambdas - // V0 - V1 interior vertex lambdas - // W0 - W1 interior vertex wheel lambdas - // - // Gradient derivatives: - //0 (2 (-b0 + x0))/b0^2 + T0 + W2 Cos[x0] Sin[x5] Sin[x9] - //1 (2 (-b1 + x1))/b1^2 + T0 - W2 Cos[x1] Sin[x10] Sin[x3] - //2 (2 (-b2 + x2))/b2^2 + T0 + V2 - //3 (2 (-b3 + x3))/b3^2 + T1 - W2 Cos[x3] Sin[x1] Sin[x10] + W3 Cos[x3] Sin[x11] Sin[x12] Sin[x8] - //4 (2 (-b4 + x4))/b4^2 + T1 + V2 - W3 Cos[x4] Sin[x13] Sin[x6] Sin[x9] - //5 (2 (-b5 + x5))/b5^2 + T1 + V3 + W2 Cos[x5] Sin[x0] Sin[x9] - //6 (2 (-b6 + x6))/b6^2 + T2 - W3 Cos[x6] Sin[x13] Sin[x4] Sin[x9] - //7 (2 (-b7 + x7))/b7^2 + T2 + V3 - //8 (2 (-b8 + x8))/b8^2 + T2 + W3 Cos[x8] Sin[x11] Sin[x12] Sin[x3] - //9 (2 (-b09 + x09))/b09^2 + T3 + W2 Cos[x9] Sin[x0] Sin[x5] - W3 Cos[x9] Sin[x13] Sin[x4] Sin[x6] - //10 (2 (-b10 + x10))/b10^2 + T3 + V3 - W2 Cos[x10] Sin[x1] Sin[x3] - //11 (2 (-b11 + x11))/b11^2 + T3 + V2 + W3 Cos[x11] Sin[x12] Sin[x3] Sin[x8] - //12 (2 (-b12 + x12))/b12^2 + T4 + W3 Cos[x12] Sin[x11] Sin[x3] Sin[x8] - //13 (2 (-b13 + x13))/b13^2 + T4 - W3 Cos[x13] Sin[x4] Sin[x6] Sin[x9] - //14 (2 (-b14 + x14))/b14^2 + T4 + V3 - // - //15 x0 + x1 + x2 - pi - //16 x3 + x4 + x5 - pi - //17 x6 + x7 + x8 - pi - //18 x10 + x11 + x9 - pi - //19 x12 + x13 + x14 - pi - // - //20 x11 + x2 + x4 - 2 pi - //21 x10 + x14 + x5 + x7 - 2 pi - // - //22 Sin[x0] Sin[x5] Sin[x9] - Sin[x1] Sin[x10] Sin[x3] - //23 Sin[x11] Sin[x12] Sin[x3] Sin[x8] - Sin[x13] Sin[x4] Sin[x6] Sin[x9] - dgFloat64 CalculateGradientVector () - { - // pre-compute sin cos tables - for (dgInt32 i = 0; i < m_anglesCount; i ++) { - m_sinTable[i] = sin (m_variables[i]); - m_cosTable[i] = cos (m_variables[i]); - } - - dgFloat64 gradientNorm = dgFloat64 (0.0f); - - // calculate gradients due to the difference between a matching edge angle and it projected angle msu be mminimal Wei * (Xei - Bei) ^ e = minimal - for (dgInt32 i = 0; i < m_anglesCount; i ++) { - dgFloat64 gradient = CalculateAngularGradientDerivative (i) + CalculateInteriorVertexGradient (i) + CalculatePlanarityGradient (i); - m_gradients[i] = -gradient; - gradientNorm += gradient * gradient; - } - - // calculate gradient due to the equality that the sum on the internal angle of a triangle must add to 180 degree. (Xt0 + Xt1 + Xt2 - pi) = 0 - for (dgInt32 i = 0; i < m_triangleCount; i ++) { - dgFloat64 gradient = m_variables[i * 3 + 0] + m_variables[i * 3 + 1] + m_variables[i * 3 + 2] - dgABF_PI; - m_gradients[m_anglesCount + i] = -gradient; - gradientNorm += gradient * gradient; - } - - // calculate the gradient due to the equality that the sum of all the angle incident to and interior vertex must be 3060 degree sum (Xvi) - 2 * pi = 0 - dgInt32 mark = m_mesh->IncLRU(); - for (dgInt32 i = 0; i < m_anglesCount; i ++) { - dgEdge* const edge = m_betaEdge[i]; - - if ((edge->m_mark != mark) && GetInteriorVertex(edge) != -1) { - dgInt32 vertexIndex = GetInteriorVertex(edge); - dgFloat64 gradient = - dgFloat64 (2.0f) * dgABF_PI; - - dgEdge* ptr = edge; - do { - dgInt32 index = GetAlphaLandaIndex(ptr); - gradient += m_variables[index]; - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - m_gradients[vertexIndex] = - gradient; - gradientNorm += gradient * gradient; - } - } - - // calculate the gradient due to the equality that the difference of the product of the sin of the angle to the - // incident to an interior vertex must be zero product (sin (Xvi + 1) - product (sin (Xvi - 1) = 0 - mark = m_mesh->IncLRU(); - for (dgInt32 i = 0; i < m_anglesCount; i ++) { - dgEdge* const edge = m_betaEdge[i]; - - dgInt32 vertexIndex = GetInteriorVertex(edge); - if ((edge->m_mark != mark) && (vertexIndex != -1)) { - vertexIndex += m_interiorVertexCount; - dgFloat64 partialProdut0 = dgFloat64 (1.0f); - dgFloat64 partialProdut1 = dgFloat64 (1.0f); - dgEdge* ptr = edge; - do { - dgInt32 index0 = GetAlphaLandaIndex(ptr->m_next); - dgInt32 index1 = GetAlphaLandaIndex(ptr->m_prev); - partialProdut0 *= m_sinTable[index0]; - partialProdut1 *= m_sinTable[index1]; - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - dgFloat64 gradient = partialProdut0 - partialProdut1; - m_gradients[vertexIndex] = - gradient; - gradientNorm += gradient * gradient; - } - } - - return gradientNorm; - } - - // the Hessian matrix is compose of these second partial derivatives - // these derivatives are too complex and make the solver to spend too much time, - // [0][0] 2/b0^2 - W2 Sin[x0] Sin[x5] Sin[x9], 0, 0, 0, 0, W2 Cos[x0] Cos[x5] Sin[x9], 0, 0, 0, W2 Cos[x0] Cos[x9] Sin[x5], 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, Cos[x0] Sin[x5] Sin[x9], 0, - // [0][[1] {0, 2/b1^2 + W2 Sin[x1] Sin[x10] Sin[x3], 0, -W2 Cos[x1] Cos[x3] Sin[x10], 0, 0, 0, 0, 0, 0, -W2 Cos[x1] Cos[x10] Sin[x3], 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -Cos[x1] Sin[x10] Sin[x3], 0}, - // ... - - // the optimize version of the algorithms assume that the second derivatives are linear, therefore all sine terms are neglected, I will do the same - // [ 0][0-n] 2/b0^2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, Cos[x0] Sin[x5] Sin[x9], 0 - // [ 1][0-n] 0, 2/b1^2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -Cos[x1] Sin[x10] Sin[x3], 0 - // [ 2][0-n] 0, 0, 2/b2^2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0 - // [ 3][0-n] 0, 0, 0, 2/b3^2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -Cos[x3] Sin[x1] Sin[x10], Cos[x3] Sin[x11] Sin[x12] Sin[x8] - // [ 4][0-n] 0, 0, 0, 0, 2/b4^2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -Cos[x4] Sin[x13] Sin[x6] Sin[x9]} - // [ 5][0-n] 0, 0, 0, 0, 0, 2/b5^2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, Cos[x5] Sin[x0] Sin[x9], 0 - // [ 6][0-n] 0, 0, 0, 0, 0, 0, 2/b6^2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -Cos[x6] Sin[x13] Sin[x4] Sin[x9] - // [ 7][0-n] 0, 0, 0, 0, 0, 0, 0, 2/b7^2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 - // [ 8][0-n] 0, 0, 0, 0, 0, 0, 0, 0, 2/b8^2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, Cos[x8] Sin[x11] Sin[x12] Sin[x3] - // [ 9][0-n] 0, 0, 0, 0, 0, 0, 0, 0, 0, 2/b9^2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, Cos[x9] Sin[x0] Sin[x5], -Cos[x9] Sin[x13] Sin[x4] Sin[x6] - // [10][0-n] 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2/b10^2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, -Cos[x10] Sin[x1] Sin[x3], 0}, - // [11][0-n] 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2/b11^2, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, Cos[x11] Sin[x12] Sin[x3] Sin[x8] - // [12][0-n] 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2/b12^2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, Cos[x12] Sin[x11] Sin[x3] Sin[x8] - // [13][0-n] 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2/b13^2, 0, 0, 0, 0, 0, 1, 0, 0, 0, -Cos[x13] Sin[x4] Sin[x6] Sin[x9] - // [14][0-n] 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2/b14^2, 0, 0, 0, 0, 1, 0, 1, 0, 0 - - // [15][0-n] 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - // [16][0-n] 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - // [17][0-n] 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - // [18][0-n] 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - // [19][0-n] 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - - // [20][0-n] 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - // [21][0-n] 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 - - // [22][0-n] Cos[x0] Sin[x5] Sin[x9], -Cos[x1] Sin[x10] Sin[x3], 0, -Cos[x3] Sin[x1] Sin[x10], 0, Cos[x5] Sin[x0] Sin[x9], 0, 0, 0, Cos[x9] Sin[x0] Sin[x5], -Cos[x10] Sin[x1] Sin[x3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - // [23][0-n] 0, 0, 0, Cos[x3] Sin[x11] Sin[x12] Sin[x8], -Cos[x4] Sin[x13] Sin[x6] Sin[x9], 0, -Cos[x6] Sin[x13] Sin[x4] Sin[x9], 0, Cos[x8] Sin[x11] Sin[x12] Sin[x3], -Cos[x9] Sin[x13] Sin[x4] Sin[x6], 0, Cos[x11] Sin[x12] Sin[x3] Sin[x8], Cos[x12] Sin[x11] Sin[x3] Sin[x8], -Cos[x13] Sin[x4] Sin[x6] Sin[x9], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - void MatrixTimeVector (dgFloat64* const out, const dgFloat64* const v) const - { - for (dgInt32 i = 0; i < m_interiorVertexCount; i ++) { - out[i + m_anglesCount + m_triangleCount] = dgFloat64 (0.0f); - out[i + m_anglesCount + m_triangleCount + m_interiorVertexCount] = dgFloat64 (0.0f); - } - - for (dgInt32 i = 0; i < m_anglesCount; i ++) { - out[i] = m_weight[i] * v[i]; - - dgEdge* const edge = m_betaEdge[i]; - dgInt32 vertexIndex = GetInteriorVertex(edge); - if (vertexIndex >= 0) { - out[i] += v[vertexIndex]; - out[vertexIndex] += v[i]; - } - } - - for (dgInt32 i = 0; i < m_triangleCount; i ++) { - dgInt32 j = i * 3; - out[j + 0] += v[i + m_anglesCount]; - out[j + 1] += v[i + m_anglesCount]; - out[j + 2] += v[i + m_anglesCount]; - out[i + m_anglesCount] = v[j + 0] + v[j + 1] + v[j + 2]; - } - - for (dgInt32 i = 0; i < m_anglesCount; i ++) { - { - dgEdge* const edge = m_betaEdge[i]->m_prev; - dgInt32 vertexIndex = GetInteriorVertex(edge); - if (vertexIndex >= 0) { - dgInt32 index = GetAlphaLandaIndex(edge->m_next); - dgFloat64 product = m_cosTable[index]; - dgEdge* ptr = edge->m_twin->m_next; - do { - dgInt32 m = GetAlphaLandaIndex(ptr->m_next); - product *= m_sinTable[m]; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - out[i] += v[vertexIndex + m_interiorVertexCount] * product; - out[vertexIndex + m_interiorVertexCount] += product * v[i]; - } - } - - { - dgEdge* const edge = m_betaEdge[i]->m_next; - dgInt32 vertexIndex = GetInteriorVertex(edge); - if (vertexIndex >= 0) { - dgInt32 index = GetAlphaLandaIndex(edge->m_prev); - dgFloat64 product = m_cosTable[index]; - dgEdge* ptr = edge->m_twin->m_next; - do { - dgInt32 m = GetAlphaLandaIndex(ptr->m_prev); - product *= m_sinTable[m]; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - out[i] -= v[vertexIndex + m_interiorVertexCount] * product; - out[vertexIndex + m_interiorVertexCount] -= product * v[i]; - } - } - } - } - - void InversePrecoditionerTimeVector (dgFloat64* const out, const dgFloat64* const v) const - { - for (dgInt32 i = 0; i < m_anglesCount; i ++) { - out[i] = v[i] / m_weight[i]; - } - for (dgInt32 i = 0; i < m_triangleCount; i ++) { - out[i + m_anglesCount] = v[i + m_anglesCount]; - } - - for (dgInt32 i = 0; i < m_interiorVertexCount; i ++) { - out[i + m_anglesCount + m_triangleCount] = v[i + m_anglesCount + m_triangleCount]; - out[i + m_anglesCount + m_triangleCount + m_interiorVertexCount] = v[i + m_anglesCount + m_triangleCount + m_interiorVertexCount]; - } - - m_progressNum ++; - if (m_progressReportCallback) { - if ((m_progressNum & 127) == 127) { - m_continueExecution = m_progressReportCallback (dgMin (dgFloat32 (m_progressNum) / m_progressDen, dgFloat32 (1.0f)), m_progressReportUserData); - } - } - } - - void LagrangeOptimization() - { - memset (m_deltaVariables, 0, m_totalVariablesCount * sizeof (dgFloat64)); - memset (&m_variables[m_anglesCount], 0, m_triangleCount * sizeof (dgFloat64)); - - for (dgInt32 i = 0; i < m_interiorVertexCount; i ++) { - m_variables[i + m_anglesCount + m_triangleCount] = dgFloat32 (1.0f); - m_variables[i + m_anglesCount + m_triangleCount + m_interiorVertexCount] = dgFloat32 (1.0f); - } - - m_progressNum = 0; - m_continueExecution = true; - -/* - dgStack<dgFloat64> r0(2 * m_mesh->GetVertexCount()); - dgStack<dgFloat64> z0(2 * m_mesh->GetVertexCount()); - dgStack<dgFloat64> p0(2 * m_mesh->GetVertexCount()); - dgStack<dgFloat64> q0(2 * m_mesh->GetVertexCount()); - SetBuffers(&r0[0], &z0[0], &p0[0], &q0[0]); - dgFloat64 gradientNorm = CalculateGradientVector (); - for (dgInt32 iter = 0; (iter < dgABF_MAX_ITERATIONS) && (gradientNorm > dgABF_TOL2) && m_continueExecution; iter++) { - m_progressDen = m_progressNum + m_totalVariablesCount; - Solve(m_totalVariablesCount, dgABF_LINEAR_SOLVER_TOL, m_deltaVariables, m_gradients); - for (dgInt32 i = 0; i < m_totalVariablesCount; i ++) { - m_variables[i] += m_deltaVariables[i]; - } - gradientNorm = CalculateGradientVector (); - } - SetBuffers(NULL, NULL, NULL, NULL); -*/ - -#ifdef _DEBUG - // calculate gradient due to the equality that the sum on the internal angle of a triangle must add to 180 degree. (Xt0 + Xt1 + Xt2 - pi) = 0 -// for (dgInt32 i = 0; i < m_triangleCount; i ++) { -// dgFloat64 gradient = m_variables[i * 3 + 0] + m_variables[i * 3 + 1] + m_variables[i * 3 + 2] - dgABF_PI; -// dgAssert (fabs (gradient) < dgFloat64 (1.0e-2f)); -// } -#endif - } - - dgMeshEffect* m_mesh; - dgEdge** m_betaEdge; - dgInt32* m_interiorIndirectMap; - - dgFloat64* m_beta; - dgFloat64* m_weight; - dgFloat64* m_sinTable; - dgFloat64* m_cosTable; - dgFloat64* m_variables; - dgFloat64* m_gradients; - dgFloat64* m_deltaVariables; - - dgInt32 m_anglesCount; - dgInt32 m_triangleCount; - dgInt32 m_interiorVertexCount; - dgInt32 m_totalVariablesCount; - - void* m_progressReportUserData; - dgReportProgress m_progressReportCallback; - mutable dgInt32 m_progressNum; - mutable dgInt32 m_progressDen; - mutable bool m_continueExecution; -}; - -dgBigVector dgMeshEffect::GetOrigin ()const -{ - dgBigVector origin (dgFloat64 (0.0f), dgFloat64 (0.0f), dgFloat64 (0.0f), dgFloat64 (0.0f)); - for (dgInt32 i = 0; i < m_points.m_vertex.m_count; i ++) { - origin += m_points.m_vertex[i]; - } - return origin.Scale (dgFloat64 (1.0f) / m_points.m_vertex.m_count); -} - -/* -void dgMeshEffect::ClearAttributeArray () -{ - dgAssert(0); - - dgStack<dgVertexAtribute>attribArray (m_pointCount); - - memset (&attribArray[0], 0, m_pointCount * sizeof (dgVertexAtribute)); - dgInt32 mark = IncLRU(); - dgPolyhedra::Iterator iter (*this); - for(iter.Begin(); iter; iter ++){ - dgEdge* const edge = &(*iter); - if (edge->m_mark < mark){ - dgEdge* ptr = edge; - - dgInt32 index = ptr->m_incidentVertex; - dgVertexAtribute& attrib = attribArray[index]; - attrib.m_vertex = m_points[index]; - do { - ptr->m_mark = mark; - ptr->m_userData = index; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - - } - } - ApplyAttributeArray (&attribArray[0], m_pointCount); -} -*/ - -void dgMeshEffect::CalculateNormals (dgFloat64 angleInRadians) -{ - dgEdge* edgeBuffer[256]; - dgBigVector faceNormal[256]; - - UnpackAttibuteData (); - m_attrib.m_normalChannel.Reserve(m_attrib.m_pointChannel.m_count); - - dgInt32 mark = IncLRU(); - dgPolyhedra::Iterator iter (*this); - dgFloat32 smoothValue = dgCos (angleInRadians); - - dgTree<dgInt32, dgEdge*> normalsMap(GetAllocator()) ; - for(iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if ((edge->m_mark < mark) && (edge->m_incidentFace > 0)) { - dgInt32 edgeIndex = 0; - normalsMap.RemoveAll(); - dgEdge* edgePtr = edge; - do { - dgVector normal (FaceNormal (edgePtr, &m_points.m_vertex[0].m_x, sizeof (dgBigVector))); - dgAssert (normal.m_w == dgFloat32 (0.0f)); - normal = normal.Scale (dgFloat32 (1.0f) / dgFloat32 (sqrt(normal.DotProduct(normal).GetScalar()) + dgFloat32(1.0e-16f))); - faceNormal[edgeIndex] = normal; - normalsMap.Insert(edgeIndex, edgePtr); - edgeIndex ++; - edgePtr = edgePtr->m_twin->m_next; - } while (edgePtr != edge); - - dgEdge* startEdge = edge; - dgVector normal0 (faceNormal[normalsMap.Find(startEdge)->GetInfo()]); - for (dgEdge* ptr = edge->m_prev->m_twin ; (ptr->m_mark != mark) && (ptr != edge) && (ptr->m_incidentFace > 0); ptr = ptr->m_prev->m_twin) { - const dgVector& normal1 (faceNormal[normalsMap.Find(ptr)->GetInfo()]); - dgAssert(normal0.m_w == dgFloat32(0.0f)); - dgFloat32 dot = normal0.DotProduct(normal1).GetScalar(); - if (dot < smoothValue) { - break; - } - startEdge = ptr; - normal0 = normal1; - } - - dgInt32 attribCount = 1; - edgeBuffer[0] = startEdge; - normal0 = faceNormal[normalsMap.Find(startEdge)->GetInfo()]; - dgVector normal (normal0); - for (dgEdge* ptr = startEdge->m_twin->m_next; (ptr->m_mark != mark) && (ptr != startEdge) && (ptr->m_incidentFace > 0); ptr = ptr->m_twin->m_next) { - const dgVector& normal1 (faceNormal[normalsMap.Find(ptr)->GetInfo()]); - dgAssert(normal0.m_w == dgFloat32(0.0f)); - dgFloat32 dot = normal0.DotProduct(normal1).GetScalar(); - if (dot < smoothValue) { - break; - } - edgeBuffer[attribCount] = ptr; - attribCount ++; - normal += normal1; - normal0 = normal1; - } - - dgAssert(normal.m_w == dgFloat32(0.0f)); - normal = normal.Scale (dgFloat32 (1.0f) / dgFloat32(sqrt(normal.DotProduct(normal).GetScalar()) + dgFloat32(1.0e-16f))); - dgTriplex n; - n.m_x = normal.m_x; - n.m_y = normal.m_y; - n.m_z = normal.m_z; - for (dgInt32 i = 0; i < attribCount; i ++) { - edgeBuffer[i]->m_mark = mark; - dgInt32 index = dgInt32 (edgeBuffer[i]->m_userData); - m_attrib.m_normalChannel[index] = n; - } - } - } - PackAttibuteData (); -} - -void dgMeshEffect::SphericalMapping (dgInt32 material, const dgMatrix& uvAligment) -{ - dgBigVector origin (GetOrigin()); - dgStack<dgBigVector>sphere (m_points.m_vertex.m_count); - for (dgInt32 i = 0; i < m_points.m_vertex.m_count; i ++) { - dgBigVector point(uvAligment.RotateVector(m_points.m_vertex[i] - origin)); - dgAssert(point.m_w == dgFloat32(0.0f)); - dgAssert(point.DotProduct(point).GetScalar() > dgFloat32(0.0f)); - point = point.Normalize(); - - dgFloat64 u = dgAsin(dgClamp(point.m_x, dgFloat64(-1.0f + 1.0e-6f), dgFloat64(1.0f - 1.0e-6f))); - dgFloat64 v = dgAtan2(point.m_y, point.m_z); - - u = dgFloat32(1.0f) - (dgFloat64(dgPi / 2.0f) - u) / dgFloat64(dgPi); - dgAssert(u >= dgFloat32(0.0f)); - dgAssert(u <= dgFloat32(1.0f)); - - v = v + dgPi; - sphere[i].m_x = u; - sphere[i].m_y = v; - } - - UnpackAttibuteData (); - m_attrib.m_uv0Channel.Reserve(m_attrib.m_pointChannel.m_count); - m_attrib.m_materialChannel.Reserve(m_attrib.m_pointChannel.m_count); - - dgPolyhedra::Iterator iter (*this); - for(iter.Begin(); iter; iter ++){ - dgEdge* const edge = &(*iter); - dgAttibutFormat::dgUV uv; - uv.m_u = dgFloat32 (sphere[edge->m_incidentVertex].m_x); - uv.m_v = dgFloat32 (sphere[edge->m_incidentVertex].m_y); - m_attrib.m_uv0Channel[dgInt32 (edge->m_userData)] = uv; - m_attrib.m_materialChannel[dgInt32 (edge->m_userData)] = material; - } - - dgInt32 mark = IncLRU (); - for(iter.Begin(); iter; iter ++){ - dgEdge* const edge = &(*iter); - if ((edge->m_incidentFace > 0) && (edge->m_mark != mark)) { - dgAttibutFormat::dgUV uvRef(m_attrib.m_uv0Channel[dgInt32(edge->m_userData)]); - dgFloat32 UVrefSin = dgSin(uvRef.m_v); - dgFloat32 UVrefCos = dgCos(uvRef.m_v); - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - dgAttibutFormat::dgUV uv(m_attrib.m_uv0Channel[dgInt32(ptr->m_userData)]); - dgFloat32 sinAngle = UVrefCos * dgSin(uv.m_v) - UVrefSin * dgCos(uv.m_v); - dgFloat32 cosAngle = UVrefCos * dgCos(uv.m_v) + UVrefSin * dgSin(uv.m_v); - dgFloat32 deltaAngle = dgAtan2(sinAngle, cosAngle); - uv.m_v = (uvRef.m_v + deltaAngle) / dgPI2; - m_attrib.m_uv0Channel[dgInt32(ptr->m_userData)] = uv; - ptr = ptr->m_next; - } while (ptr != edge); - } - } - - PackAttibuteData(); -} - -void dgMeshEffect::CylindricalMapping (dgInt32 cylinderMaterial, dgInt32 capMaterial, const dgMatrix& uvAligment) -{ - dgBigVector origin (GetOrigin()); - dgStack<dgBigVector> buffer(m_points.m_vertex.m_count); - dgBigVector pMin(dgFloat64(1.0e10f), dgFloat64(1.0e10f), dgFloat64(1.0e10f), dgFloat64(0.0f)); - dgBigVector pMax(dgFloat64(-1.0e10f), dgFloat64(-1.0e10f), dgFloat64(-1.0e10f), dgFloat64(0.0f)); - - for (dgInt32 i = 0; i < m_points.m_vertex.m_count; i ++) { - buffer[i] = uvAligment.RotateVector (m_points.m_vertex[i] - origin); - const dgBigVector& tmp = buffer[i]; - pMin.m_x = dgMin (pMin.m_x, tmp.m_x); - pMax.m_x = dgMax (pMax.m_x, tmp.m_x); - pMin.m_y = dgMin (pMin.m_y, tmp.m_y); - pMax.m_y = dgMax (pMax.m_y, tmp.m_y); - pMin.m_z = dgMin (pMin.m_z, tmp.m_z); - pMax.m_z = dgMax (pMax.m_z, tmp.m_z); - } - - dgStack<dgBigVector>cylinder (m_points.m_vertex.m_count); - dgBigVector scale (dgFloat64 (1.0f)/ (pMax.m_x - pMin.m_x), dgFloat64 (1.0f)/ (pMax.m_y - pMin.m_y), dgFloat64 (1.0f)/ (pMax.m_z - pMin.m_z), dgFloat64 (0.0f)); - for (dgInt32 i = 0; i < m_points.m_vertex.m_count; i ++) { - //dgBigVector point (uvAligment.RotateVector (m_points.m_vertex[i] - origin)); - dgBigVector point (buffer[i]); - dgFloat64 u = (point.m_x - pMin.m_x) * scale.m_x; - - dgAssert(point.m_w == dgFloat32(0.0f)); - dgAssert(point.DotProduct(point).GetScalar() > dgFloat32 (0.0f)); - point = point.Normalize(); - dgFloat64 v = dgAtan2 (point.m_y, point.m_z); - - v = v + dgPi; - cylinder[i].m_x = u; - cylinder[i].m_y = v; - } - - UnpackAttibuteData(); - m_attrib.m_uv0Channel.Reserve(m_attrib.m_pointChannel.m_count); - m_attrib.m_materialChannel.Reserve(m_attrib.m_pointChannel.m_count); - - dgPolyhedra::Iterator iter (*this); - for(iter.Begin(); iter; iter ++){ - dgEdge* const edge = &(*iter); - dgAttibutFormat::dgUV uv; - uv.m_u = dgFloat32(cylinder[edge->m_incidentVertex].m_x); - uv.m_v = dgFloat32(cylinder[edge->m_incidentVertex].m_y); - m_attrib.m_uv0Channel[dgInt32(edge->m_userData)] = uv; - m_attrib.m_materialChannel[dgInt32(edge->m_userData)] = cylinderMaterial; - } - - dgInt32 mark = IncLRU (); - for(iter.Begin(); iter; iter ++){ - dgEdge* const edge = &(*iter); - if ((edge->m_incidentFace > 0) && (edge->m_mark != mark)) { - dgAttibutFormat::dgUV uvRef(m_attrib.m_uv0Channel[dgInt32(edge->m_userData)]); - dgFloat32 UVrefSin = dgSin(uvRef.m_v); - dgFloat32 UVrefCos = dgCos(uvRef.m_v); - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - dgAttibutFormat::dgUV uv(m_attrib.m_uv0Channel[dgInt32(ptr->m_userData)]); - dgFloat32 sinAngle = UVrefCos * dgSin(uv.m_v) - UVrefSin * dgCos(uv.m_v); - dgFloat32 cosAngle = UVrefCos * dgCos(uv.m_v) + UVrefSin * dgSin(uv.m_v); - dgFloat32 deltaAngle = dgAtan2(sinAngle, cosAngle); - uv.m_v = (uvRef.m_v + deltaAngle) / dgPI2; - m_attrib.m_uv0Channel[dgInt32(ptr->m_userData)] = uv; - ptr = ptr->m_next; - } while (ptr != edge); - } - } - - // apply cap mapping - mark = IncLRU (); - for(iter.Begin(); iter; iter ++){ - dgEdge* const edge = &(*iter); - if ((edge->m_incidentFace > 0) && (edge->m_mark != mark)) { - //dgVector p0(uvAligment.RotateVector(m_points.m_vertex[edge->m_incidentVertex] - origin)); - //dgVector p1(uvAligment.RotateVector(m_points.m_vertex[edge->m_next->m_incidentVertex] - origin)); - dgVector p0(buffer[edge->m_incidentVertex]); - dgVector p1(buffer[edge->m_next->m_incidentVertex]); - - dgVector e1(p1 - p0); - dgBigVector normal(dgFloat32(0.0f)); - for (dgEdge* ptr = edge->m_next; ptr != edge; ptr = ptr->m_next) { - //dgVector p2(uvAligment.RotateVector(m_points.m_vertex[ptr->m_next->m_incidentVertex] - origin)); - dgVector p2(buffer[ptr->m_next->m_incidentVertex]); - dgBigVector e2(p2 - p0); - normal += e1.CrossProduct(e2); - e1 = e2; - } - normal = normal.Normalize(); - if (dgAbs(normal.m_x) > dgFloat32 (0.99f)) { - dgEdge* ptr = edge; - do { - dgAttibutFormat::dgUV uv; - //dgVector p(uvAligment.RotateVector(m_points.m_vertex[ptr->m_incidentVertex] - origin)); - dgVector p(buffer[ptr->m_incidentVertex]); - uv.m_u = dgFloat32((p.m_y - pMin.m_y) * scale.m_y); - uv.m_v = dgFloat32((p.m_z - pMin.m_z) * scale.m_z); - m_attrib.m_uv0Channel[dgInt32(ptr->m_userData)] = uv; - m_attrib.m_materialChannel[dgInt32(ptr->m_userData)] = capMaterial; - ptr = ptr->m_next; - } while (ptr != edge); - } - - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_next; - } while (ptr != edge); - - } - } - PackAttibuteData(); -} - -void dgMeshEffect::BoxMapping (dgInt32 front, dgInt32 side, dgInt32 top, const dgMatrix& uvAligment) -{ -/* - dgBigVector minVal; - dgBigVector maxVal; - - dgGetMinMax (minVal, maxVal, &m_points.m_vertex[0][0], m_points.m_vertex.m_count, sizeof (dgBigVector)); - dgBigVector dist (maxVal - minVal); - dist[0] = dgMax (dgFloat64 (1.0e-3f), dist[0]); - dist[1] = dgMax (dgFloat64 (1.0e-3f), dist[1]); - dist[2] = dgMax (dgFloat64 (1.0e-3f), dist[2]); - dgBigVector scale (dgFloat64 (1.0f)/ dist[0], dgFloat64 (1.0f)/ dist[1], dgFloat64 (1.0f)/ dist[2], dgFloat64 (0.0f)); -*/ - - dgBigVector origin(GetOrigin()); - dgStack<dgBigVector> buffer(m_points.m_vertex.m_count); - dgBigVector pMin(dgFloat64(1.0e10f), dgFloat64(1.0e10f), dgFloat64(1.0e10f), dgFloat64(0.0f)); - dgBigVector pMax(dgFloat64(-1.0e10f), dgFloat64(-1.0e10f), dgFloat64(-1.0e10f), dgFloat64(0.0f)); - - for (dgInt32 i = 0; i < m_points.m_vertex.m_count; i++) { - buffer[i] = uvAligment.RotateVector(m_points.m_vertex[i] - origin); - const dgBigVector& tmp = buffer[i]; - pMin.m_x = dgMin(pMin.m_x, tmp.m_x); - pMax.m_x = dgMax(pMax.m_x, tmp.m_x); - pMin.m_y = dgMin(pMin.m_y, tmp.m_y); - pMax.m_y = dgMax(pMax.m_y, tmp.m_y); - pMin.m_z = dgMin(pMin.m_z, tmp.m_z); - pMax.m_z = dgMax(pMax.m_z, tmp.m_z); - } - dgInt32 materialArray[3]; - - dgBigVector dist (pMax); - dist[0] = dgMax(dgFloat64(1.0e-3f), dist[0]); - dist[1] = dgMax(dgFloat64(1.0e-3f), dist[1]); - dist[2] = dgMax(dgFloat64(1.0e-3f), dist[2]); - dgBigVector scale (dgFloat64 (0.5f)/ dist[0], dgFloat64 (0.5f)/ dist[1], dgFloat64 (0.5f)/ dist[2], dgFloat64 (0.0f)); - - UnpackAttibuteData(); - m_attrib.m_uv0Channel.Reserve(m_attrib.m_pointChannel.m_count); - m_attrib.m_materialChannel.Reserve(m_attrib.m_pointChannel.m_count); - - materialArray[0] = front; - materialArray[1] = side; - materialArray[2] = top; - - dgInt32 mark = IncLRU(); - dgPolyhedra::Iterator iter (*this); - for(iter.Begin(); iter; iter ++){ - dgEdge* const edge = &(*iter); - if ((edge->m_mark < mark) && (edge->m_incidentFace > 0)) { - const dgBigVector& p0 = buffer[edge->m_incidentVertex]; - const dgBigVector& p1 = buffer[edge->m_next->m_incidentVertex]; - const dgBigVector& p2 = buffer[edge->m_prev->m_incidentVertex]; - - edge->m_mark = mark; - edge->m_next->m_mark = mark; - edge->m_prev->m_mark = mark; - - dgBigVector e0 (p1 - p0); - dgBigVector e1 (p2 - p0); - dgBigVector n (e0.CrossProduct(e1)); - - dgInt32 index = 0; - dgFloat64 maxProjection = dgFloat32 (0.0f); - - for (dgInt32 i = 0; i < 3; i ++) { - dgFloat64 proj = fabs (n[i]); - if (proj > maxProjection) { - index = i; - maxProjection = proj; - } - } - - dgInt32 u = (index + 1) % 3; - dgInt32 v = (u + 1) % 3; - if (index == 1) { - dgSwap (u, v); - } - dgEdge* ptr = edge; - do { - dgAttibutFormat::dgUV uv; - dgBigVector p(scale * buffer[ptr->m_incidentVertex] - dgFloat32 (0.5f)); - uv.m_u = dgFloat32 (p[u]); - uv.m_v = dgFloat32 (p[v]); - m_attrib.m_uv0Channel[dgInt32(ptr->m_userData)] = uv; - m_attrib.m_materialChannel[dgInt32(ptr->m_userData)] = materialArray[index]; - ptr = ptr->m_next; - } while (ptr != edge); - } - } - PackAttibuteData(); -} - - -void dgMeshEffect::UniformBoxMapping (dgInt32 material, const dgMatrix& textureMatrix) -{ - UnpackAttibuteData(); - m_attrib.m_uv0Channel.Reserve(m_attrib.m_pointChannel.m_count); - m_attrib.m_materialChannel.Reserve(m_attrib.m_pointChannel.m_count); - - dgInt32 mark = IncLRU(); - for (dgInt32 i = 0; i < 3; i ++) { - dgMatrix rotationMatrix (dgGetIdentityMatrix()); - if (i == 1) { - rotationMatrix = dgYawMatrix(dgFloat32 (90.0f * dgDegreeToRad)); - } else if (i == 2) { - rotationMatrix = dgPitchMatrix(dgFloat32 (90.0f * dgDegreeToRad)); - } - - dgPolyhedra::Iterator iter (*this); - - for(iter.Begin(); iter; iter ++){ - dgEdge* const edge = &(*iter); - if ((edge->m_mark < mark) && (edge->m_incidentFace > 0)) { - dgBigVector n (FaceNormal(edge, &m_points.m_vertex[0].m_x, sizeof (dgBigVector))); - dgVector normal (rotationMatrix.RotateVector(dgVector (n.Normalize()))); - normal.m_x = dgAbs (normal.m_x); - normal.m_y = dgAbs (normal.m_y); - normal.m_z = dgAbs (normal.m_z); - if ((normal.m_z >= (normal.m_x - dgFloat32 (1.0e-4f))) && (normal.m_z >= (normal.m_y - dgFloat32 (1.0e-4f)))) { - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - dgAttibutFormat::dgUV uv; - dgVector p (textureMatrix.TransformVector(rotationMatrix.RotateVector(m_points.m_vertex[ptr->m_incidentVertex]))); - uv.m_u = p.m_x; - uv.m_v = p.m_y; - m_attrib.m_uv0Channel[dgInt32(ptr->m_userData)] = uv; - m_attrib.m_materialChannel[dgInt32(ptr->m_userData)] = material; - - ptr = ptr->m_next; - }while (ptr != edge); - } - } - } - } - - PackAttibuteData(); -} - - -void dgMeshEffect::AngleBaseFlatteningMapping (dgInt32 material, dgReportProgress progressReportCallback, void* const userData) -{ - dgSetPrecisionDouble presicion; - - dgMeshEffect tmp (*this); - - dgBigVector minBox; - dgBigVector maxBox; - tmp.CalculateAABB(minBox, maxBox); - - dgBigVector size (maxBox - minBox); - dgFloat32 scale = dgFloat32 (1.0 / dgMax (size.m_x, size.m_y, size.m_z)); - - dgMatrix matrix (dgGetIdentityMatrix()); - matrix[0][0] = scale; - matrix[1][1] = scale; - matrix[2][2] = scale; - tmp.ApplyTransform(matrix); - - dgAngleBasedFlatteningMapping angleBadedFlattening (&tmp, material, progressReportCallback, userData); -} diff --git a/thirdparty/src/newton/dgNewton/Newton.cpp b/thirdparty/src/newton/dgNewton/Newton.cpp deleted file mode 100644 index 162597887..000000000 --- a/thirdparty/src/newton/dgNewton/Newton.cpp +++ /dev/null @@ -1,8681 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "NewtonStdAfx.h" -#include "Newton.h" -#include "NewtonClass.h" - - -#ifdef _NEWTON_BUILD_DLL - #if (defined (__MINGW32__) || defined (__MINGW64__)) - int main(int argc, char* argv[]) - { - return 0; - } - #endif - - #ifdef _MSC_VER - BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) - { - switch (ul_reason_for_call) - { - case DLL_THREAD_ATTACH: - case DLL_PROCESS_ATTACH: - // check for memory leaks - #ifdef _DEBUG - // Track all memory leaks at the operating system level. - // make sure no Newton tool or utility leaves leaks behind. - _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF)); - #endif - - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; - } - #endif -#endif - - - -/*! @defgroup Misc Misc -Misc -@{ -*/ - -//#define SAVE_COLLISION - -#ifdef SAVE_COLLISION -void SerializeFile (void* serializeHandle, const void* buffer, size_t size) -{ - fwrite (buffer, size, 1, (FILE*) serializeHandle); -} - -void DeSerializeFile (void* serializeHandle, void* buffer, size_t size) -{ - fread (buffer, size, 1, (FILE*) serializeHandle); -} - - -void SaveCollision (const NewtonCollision* const collisionPtr) -{ - FILE* file; - // save the collision file - file = fopen ("collisiontest.bin", "wb"); - //SerializeFile (file, MAGIC_NUMBER, strlen (MAGIC_NUMBER) + 1); - NewtonCollisionSerialize (collisionPtr, SerializeFile, file); - fclose (file); -} -#endif - - -/*! - Return the exact amount of memory (in Bytes) use by the engine at any given time. - - @return total memory use by the engine. - - Applications can use this function to ascertain that the memory use by the - engine is balanced at all times. - - See also: ::NewtonCreate -*/ -int NewtonGetMemoryUsed() -{ - TRACE_FUNCTION(__FUNCTION__); - return dgMemoryAllocator::GetGlobalMemoryUsed(); -} - -// fixme: needs docu -// @param mallocFnt is a pointer to the memory allocator callback function. If this parameter is NULL the standard *malloc* function is used. -// @param mfreeFnt is a pointer to the memory release callback function. If this parameter is NULL the standard *free* function is used. -// -void NewtonSetMemorySystem (NewtonAllocMemory mallocFnt, NewtonFreeMemory mfreeFnt) -{ - dgMemFree _free; - dgMemAlloc _malloc; - - TRACE_FUNCTION(__FUNCTION__); - - if (mallocFnt && mfreeFnt) { - _malloc = (dgMemAlloc) mallocFnt; - _free = (dgMemFree) mfreeFnt; - } else { - _malloc = (dgMemAlloc) Newton::DefaultAllocMemory; - _free = (dgMemFree) Newton::DefaultFreeMemory; - } - - dgMemoryAllocator::SetGlobalAllocators (_malloc, _free); -} - - -void* NewtonAlloc (int sizeInBytes) -{ - return dgMallocStack(sizeInBytes); -} - -void NewtonFree (void* const ptr) -{ - dgFreeStack(ptr); -} - -/*! @} */ // end of group Misc - - -/*! @defgroup World World -World interface -@{ -*/ - -/*! - Create an instance of the Newton world. - - @return Pointer to new Newton world. - - This function must be called before any of the other API functions. - - See also: ::NewtonDestroy, ::NewtonDestroyAllBodies -*/ -NewtonWorld* NewtonCreate() -{ - TRACE_FUNCTION(__FUNCTION__); - dgMemoryAllocator* const allocator = new dgMemoryAllocator(); - - NewtonWorld* const world = (NewtonWorld*) new (allocator) Newton (allocator); - return world; -} - - -/*! - Destroy an instance of the Newton world. - - @param *newtonWorld Pointer to the Newton world. - @return Nothing. - - This function will destroy the entire Newton world. - - See also: ::NewtonCreate, ::NewtonDestroyAllBodies -*/ -void NewtonDestroy(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - - Newton* const world = (Newton *) newtonWorld; - dgMemoryAllocator* const allocator = world->dgWorld::GetAllocator(); - - delete world; - delete allocator; -} - -void NewtonSetPostUpdateCallback(const NewtonWorld* const newtonWorld, NewtonPostUpdateCallback callback) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->SetPostUpdateCallback((OnPostUpdateCallback) callback); -} - -NewtonPostUpdateCallback NewtonGetPostUpdateCallback(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return (NewtonPostUpdateCallback)world->GetPostUpdateCallback(); -} - -int NewtonGetBroadphaseAlgorithm (const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - return world->GetBroadPhaseType(); -} - -void NewtonSelectBroadphaseAlgorithm (const NewtonWorld* const newtonWorld, int algorithmType) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->SetBroadPhaseType(algorithmType); -} - -void NewtonResetBroadphase(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - return world->ResetBroadPhase(); -} - - -dFloat NewtonGetContactMergeTolerance (const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - return world->GetContactMergeTolerance(); -} - -void NewtonSetContactMergeTolerance (const NewtonWorld* const newtonWorld, dFloat tolerance) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->SetContactMergeTolerance(tolerance); -} - - -/*! - Reset all internal engine states. - - @param *newtonWorld Pointer to the Newton world. - - Call this function whenever you want to create a reproducible simulation from - a pre-defined initial condition. - - It does *not* suffice to merely reset the position and velocity of - objects. This is because Newton takes advantage of frame-to-frame coherence for - performance reasons. - - This function must be called outside of a Newton Update. - - Note: this kind of synchronization incurs a heavy performance penalty if - called during each update. - - See also: ::NewtonUpdate -*/ -void NewtonInvalidateCache(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - world->FlushCache(); -} - -void NewtonSetJointSerializationCallbacks (const NewtonWorld* const newtonWorld, NewtonOnJointSerializationCallback serializeJoint, NewtonOnJointDeserializationCallback deserializeJoint) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->SetJointSerializationCallbacks (dgWorld::OnJointSerializationCallback(serializeJoint), dgWorld::OnJointDeserializationCallback(deserializeJoint)); -} - -void NewtonGetJointSerializationCallbacks (const NewtonWorld* const newtonWorld, NewtonOnJointSerializationCallback* const serializeJoint, NewtonOnJointDeserializationCallback* const deserializeJoint) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->GetJointSerializationCallbacks ((dgWorld::OnJointSerializationCallback*)serializeJoint, (dgWorld::OnJointDeserializationCallback*)deserializeJoint); -} - - -void NewtonSerializeScene(const NewtonWorld* const newtonWorld, NewtonOnBodySerializationCallback bodyCallback, void* const bodyUserData, - NewtonSerializeCallback serializeCallback, void* const serializeHandle) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->SerializeScene(bodyUserData, dgWorld::OnBodySerialize(bodyCallback), (dgSerialize) serializeCallback, serializeHandle); -} - -void NewtonDeserializeScene(const NewtonWorld* const newtonWorld, NewtonOnBodyDeserializationCallback bodyCallback, void* const bodyUserData, - NewtonDeserializeCallback deserializeCallback, void* const serializeHandle) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->DeserializeScene(bodyUserData, (dgWorld::OnBodyDeserialize)bodyCallback, (dgDeserialize) deserializeCallback, serializeHandle); -} - - -void NewtonSerializeToFile (const NewtonWorld* const newtonWorld, const char* const filename, NewtonOnBodySerializationCallback bodyCallback, void* const bodyUserData) -{ - TRACE_FUNCTION(__FUNCTION__); - FILE* const file = fopen(filename, "wb"); - if (file) { - NewtonSerializeScene(newtonWorld, bodyCallback, bodyUserData, dgWorld::OnSerializeToFile, file); - fclose (file); - } -} - -void NewtonDeserializeFromFile (const NewtonWorld* const newtonWorld, const char* const filename, NewtonOnBodyDeserializationCallback bodyCallback, void* const bodyUserData) -{ - TRACE_FUNCTION(__FUNCTION__); - FILE* const file = fopen(filename, "rb"); - if (file) { - NewtonDeserializeScene(newtonWorld, bodyCallback, bodyUserData, dgWorld::OnDeserializeFromFile, file); - fclose (file); - } -} - -NewtonBody* NewtonFindSerializedBody(const NewtonWorld* const newtonWorld, int bodySerializedID) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - dgAssert (0); - return (NewtonBody*) world->FindBodyFromSerializedID(bodySerializedID); -} - -void NewtonLoadPlugins(const NewtonWorld* const newtonWorld, const char* const plugInPath) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - world->LoadPlugins(plugInPath); -} - -void NewtonUnloadPlugins(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - world->UnloadPlugins(); -} - -void* NewtonCurrentPlugin(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->GetCurrentPlugin(); -} - -void* NewtonGetFirstPlugin(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->GetFirstPlugin(); -} - -void* NewtonGetNextPlugin(const NewtonWorld* const newtonWorld, const void* const plugin) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgWorldPluginList::dgListNode* const node = (dgWorldPluginList::dgListNode*) plugin; - return world->GetNextPlugin(node); -} - -const char* NewtonGetPluginString(const NewtonWorld* const newtonWorld, const void* const plugin) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgWorldPluginList::dgListNode* const node = (dgWorldPluginList::dgListNode*) plugin; - return world->GetPluginId (node); -} - -void NewtonSelectPlugin(const NewtonWorld* const newtonWorld, const void* const plugin) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgWorldPluginList::dgListNode* const node = (dgWorldPluginList::dgListNode*) plugin; - return world->SelectPlugin(node); -} - -void* NewtonGetPreferedPlugin(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->GetpreferedPlugin(); -} - - -/*! - this function block all other threads from executing the same subsequent code simultaneously. - - @param *newtonWorld Pointer to the Newton world. - @param threadIndex thread index from whe thsi function is called, zero if call form outsize a newton update - - this function should use to present racing conditions when when a call back ins executed form a mutithreaded loop. - In general most call back are thread safe when they do not write to object outside the scope of the call back. - this means for example that the application can modify values of object pointed by the arguments and or call that function - that are allowed to be call for such callback. - There are cases, however, when the application need to collect data for the client logic, example of such case are collecting - information to display debug information, of collecting data for feedback. - In these situations it is possible the the same critical code could be execute at the same time but several thread causing unpredictable side effect. - so it is necessary to block all of the thread from executing any pieces of critical code. - - Not calling function *NewtonWorldCriticalSectionUnlock* will result on the engine going into an infinite loop. - - it is important that the critical section wrapped by functions *NewtonWorldCriticalSectionLock* and - *NewtonWorldCriticalSectionUnlock* be keep small if the application is using the multi threaded functionality of the engine - no doing so will lead to serialization of the parallel treads since only one thread can run the a critical section at a time. - - @return Nothing. - - See also: ::NewtonWorldCriticalSectionUnlock -*/ -void NewtonWorldCriticalSectionLock (const NewtonWorld* const newtonWorld, int threadIndex) -{ - TRACE_FUNCTION(__FUNCTION__); - - Newton* const world = (Newton *)newtonWorld; - world->GlobalLock(); -} - - -int NewtonAtomicSwap (int* const ptr, int value) -{ - TRACE_FUNCTION(__FUNCTION__); - return dgInterlockedExchange(ptr, value); -} - -int NewtonAtomicAdd (int* const ptr, int value) -{ - TRACE_FUNCTION(__FUNCTION__); - return dgAtomicExchangeAndAdd (ptr, value); -} - -void NewtonYield () -{ - TRACE_FUNCTION(__FUNCTION__); - dgThreadYield(); -} - - -/*! - this function block all other threads from executing the same subsequent code simultaneously. - - @param *newtonWorld Pointer to the Newton world. - - - this function should use to present racing conditions when when a call back ins executed form a multi threaded loop. - In general most call back are thread safe when they do not write to object outside the scope of the call back. - this means for example that the application can modify values of object pointed by the arguments and or call that function - that are allowed to be call for such callback. - There are cases, however, when the application need to collect data for the client logic, example of such case are collecting - information to display debug information, of collecting data for feedback. - In these situations it is possible the the same critical code could be execute at the same time but several thread causing unpredictable side effect. - so it is necessary to block all of the thread from executing any pieces of critical code. - - it is important that the critical section wrapped by functions *NewtonWorldCriticalSectionLock* and - *NewtonWorldCriticalSectionUnlock* be keep small if the application is using the multi threaded functionality of the engine - no doing so will lead to serialization of the parallel treads since only one thread can run the a critical section at a time. - - @return Nothing. - - See also: ::NewtonWorldCriticalSectionLock -*/ -void NewtonWorldCriticalSectionUnlock(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - - Newton* const world = (Newton *)newtonWorld; - world->GlobalUnlock(); -} - - - -/*! - Set the maximum number of threads the engine can use. - - @param *newtonWorld Pointer to the Newton world. - @param threads Maximum number of allowed threads. - - @return Nothing - - The maximum number of threaded is set on initialization to the maximum number - of CPU in the system. - fixme: this appears to be wrong. It is set to 1. - - See also: ::NewtonGetThreadsCount -*/ -void NewtonSetThreadsCount(const NewtonWorld* const newtonWorld, int threads) -{ - TRACE_FUNCTION(__FUNCTION__); - - Newton* const world = (Newton *)newtonWorld; - world->SetThreadsCount(threads); -} - - -/*! - Return the number of threads currently used by the engine. - - @param *newtonWorld Pointer to the Newton world. - - @return Number threads - - See also: ::NewtonSetThreadsCount, ::NewtonSetParallelSolverOnLargeIsland -*/ -int NewtonGetThreadsCount(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - - Newton* const world = (Newton *)newtonWorld; - return world->GetThreadCount(); -} - - -/*! - Return the maximum number of threads supported on this platform. - - @param *newtonWorld Pointer to the Newton world. - - @return Number threads. - - This function will return 1 on single core version of the library. - // fixme; what is a single core version? - - See also: ::NewtonSetThreadsCount, ::NewtonSetParallelSolverOnLargeIsland -*/ -int NewtonGetMaxThreadsCount(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - - Newton* const world = (Newton *)newtonWorld; - return world->GetMaxThreadCount(); -} - - -/*! - Enable/disable multi-threaded constraint resolution for large islands - (disabled by default). - - @param *newtonWorld Pointer to the Newton world. - @param mode 1: enabled 0: disabled (default) - - @return Nothing - - Multi threaded mode is not always faster. Among the reasons are - - 1 - Significant software cost to set up threads, as well as instruction overhead. - 2 - Different systems have different cost for running separate threads in a shared memory environment. - 3 - Parallel algorithms often have decreased converge rate. This can be as - high as half of the of the sequential version. Consequently, the parallel - solver requires a higher number of interactions to achieve similar convergence. - - It is recommended this option is enabled on system with more than two cores, - since the performance gain in a dual core system are marginally better. Your - mileage may vary. - - At the very least the application must test the option to verify the performance gains. - - This option has no impact on other subsystems of the engine. - - See also: ::NewtonGetThreadsCount, ::NewtonSetThreadsCount -*/ -void NewtonSetParallelSolverOnLargeIsland(const NewtonWorld* const newtonWorld, int mode) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - world->EnableParallelSolverOnLargeIsland (mode); -} - - -void NewtonDispachThreadJob(const NewtonWorld* const newtonWorld, NewtonJobTask task, void* const usedData, const char* const functionName) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - world->ExecuteUserJob (dgWorkerThreadTaskCallback (task), usedData, functionName); -} - -void NewtonSyncThreadJobs(const NewtonWorld* const newtonWorld) -{ - Newton* const world = (Newton *)newtonWorld; - world->SynchronizationBarrier(); -} - -int NewtonGetParallelSolverOnLargeIsland(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->GetParallelSolverOnLargeIsland(); -} - -/*! - Set the solver precision mode. - - @param *newtonWorld is the pointer to the Newton world - @param model model of operation n = number of iteration default value is 4. - - @return Nothing - - n: the solve will execute a maximum of n iteration per cluster of connected joints and will terminate regardless of the - of the joint residual acceleration. - If it happen that the joints residual acceleration fall below the minimum tolerance 1.0e-5 - then the solve will terminate before the number of iteration reach N. -*/ -void NewtonSetSolverIterations(const NewtonWorld* const newtonWorld, int model) -{ - Newton* const world = (Newton *)newtonWorld; - - TRACE_FUNCTION(__FUNCTION__); - world->SetSolverIterations (model); -} - -/*! -Get the solver precision mode. -*/ -int NewtonGetSolverIterations(const NewtonWorld* const newtonWorld) -{ - Newton* const world = (Newton *)newtonWorld; - - TRACE_FUNCTION(__FUNCTION__); - return world->GetSolverIterations(); -} - - -/*! - Advance the simulation by a user defined amount of time. - - @param *newtonWorld is the pointer to the Newton world - @param timestep time step in seconds. - - @return Nothing - - This function will advance the simulation by the specified amount of time. - - The Newton Engine does not perform sub-steps, nor does it need - tuning parameters. As a consequence, the application is responsible for - requesting sane time steps. - - See also: ::NewtonInvalidateCache -*/ -void NewtonUpdate(const NewtonWorld* const newtonWorld, dFloat timestep) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - -//NewtonSerializeToFile (newtonWorld, "xxx.bin", NULL, NULL); - world->UpdatePhysics (timestep); -} - -void NewtonUpdateAsync (const NewtonWorld* const newtonWorld, dFloat timestep) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - - world->UpdatePhysicsAsync(timestep); -} - -void NewtonWaitForUpdateToFinish (const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - world->Sync (); -} - -dFloat NewtonGetLastUpdateTime (const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->GetUpdateTime(); -} - - -void NewtonSetNumberOfSubsteps (const NewtonWorld* const newtonWorld, int subSteps) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->SetSubsteps (subSteps); -} - -int NewtonGetNumberOfSubsteps (const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - return world->GetSubsteps (); -} - - - -/*! - Remove all bodies and joints from the Newton world. - - @param *newtonWorld Pointer to the Newton world. - - @return Nothing - - This function will destroy all bodies and all joints in the Newton world, but - will retain group IDs. - - Use this function for when you want to clear the world but preserve all the - group IDs and material pairs. - - See also: ::NewtonMaterialDestroyAllGroupID -*/ -void NewtonDestroyAllBodies(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - - Newton* const world = (Newton *) newtonWorld; - world->DestroyAllBodies (); -} - -/*! - Set a function callback to be call on each island update. - - @param *newtonWorld Pointer to the Newton world. - @param islandUpdate callback function. - - @return Nothing. - - The application can set a function callback to be called just after the array - of all bodies making an island of connected bodies are collected. This - function will be called just before the array is accepted for contact - resolution and integration. - - The callback function must return an integer 0 or 1 to either skip or process - the bodies in that particular island. - - Applications can leverage this function to implement an game physics LOD. For - example the application can determine the AABB of the island and check it - against the view frustum. If the entire island AABB is invisible, then the - application can suspend its simulation, even if it is not in equilibrium. - - Other possible applications are to implement of a visual debugger, or freeze - entire islands for application specific reasons. - - The application must not create, modify, or destroy bodies inside the callback - or risk putting the engine into an undefined state (ie it will crash, if you - are lucky). - - See also: ::NewtonIslandGetBody -*/ -void NewtonSetIslandUpdateEvent(const NewtonWorld* const newtonWorld, NewtonIslandUpdate islandUpdate) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->SetIslandUpdateCallback((dgWorld::OnClusterUpdate) islandUpdate); -} - - - - -/*! - Get the first body in the body in the world body list. - - @param *newtonWorld Pointer to the Newton world. - - @return nothing - - The application can call this function to iterate thought every body in the world. - - The application call this function for debugging purpose - See also: ::NewtonWorldGetNextBody, ::NewtonWorldForEachBodyInAABBDo, ::NewtonWorldForEachJointDo -*/ -NewtonBody* NewtonWorldGetFirstBody(const NewtonWorld* const newtonWorld) -{ - Newton* const world = (Newton *) newtonWorld; - dgBodyMasterList& masterList = *world; - - TRACE_FUNCTION(__FUNCTION__); - dgAssert (masterList.GetFirst()->GetInfo().GetBody() == world->GetSentinelBody()); - dgBodyMasterList::dgListNode* const node = masterList.GetFirst()->GetNext(); -// body = node->GetInfo().GetBody(); -// node = node->GetNext(); -// callback ((const NewtonBody*) body); -// } - if (node) { - return (NewtonBody*)node->GetInfo().GetBody(); - } else { - return NULL; - } -} - - -/*! - Get the first body in the general body. - - @param *newtonWorld Pointer to the Newton world. - @param curBody fixme - - @return nothing - - The application can call this function to iterate through every body in the world. - - The application call this function for debugging purpose - - See also: ::NewtonWorldGetFirstBody, ::NewtonWorldForEachBodyInAABBDo, ::NewtonWorldForEachJointDo -*/ -NewtonBody* NewtonWorldGetNextBody(const NewtonWorld* const newtonWorld, const NewtonBody* const curBody) -{ - dgBody* const body = (dgBody*) curBody; - - TRACE_FUNCTION(__FUNCTION__); - - dgBodyMasterList::dgListNode* const node = body->GetMasterList()->GetNext(); - if (node) { - return (NewtonBody*)node->GetInfo().GetBody(); - } else { - return NULL; - } - -} - - -/*! - Trigger callback function for each joint in the world. - - @param *newtonWorld Pointer to the Newton world. - @param callback The callback function to invoke for each joint. - @param *userData User data to pass into the callback. - - @return nothing - - The application should provide the function *NewtonJointIterator callback* to - be called by Newton for every joint in the world. - - Note that this function is primarily for debugging. The performance penalty - for calling it is high. - - See also: ::NewtonWorldForEachBodyInAABBDo, ::NewtonWorldGetFirstBody -*/ -void NewtonWorldForEachJointDo(const NewtonWorld* const newtonWorld, NewtonJointIterator callback, void* const userData) -{ - Newton* const world = (Newton *) newtonWorld; - dgBodyMasterList& masterList = *world; - - TRACE_FUNCTION(__FUNCTION__); - dgTree<dgConstraint*, dgConstraint*> jointMap(world->dgWorld::GetAllocator()); - for (dgBodyMasterList::dgListNode* node = masterList.GetFirst()->GetNext(); node; node = node->GetNext()) { - dgBodyMasterListRow& row = node->GetInfo(); - for (dgBodyMasterListRow::dgListNode* jointNode = row.GetFirst(); jointNode; jointNode = jointNode->GetNext()) { - const dgBodyMasterListCell& cell = jointNode->GetInfo(); - if (cell.m_joint->GetId() != dgConstraint::m_contactConstraint) { - if (!jointMap.Find(cell.m_joint)) { - jointMap.Insert(cell.m_joint, cell.m_joint); - callback ((const NewtonJoint*) cell.m_joint, userData); - } - } - } - } -} - - -/*! - Trigger a callback for every body that intersects the specified AABB. - - @param *newtonWorld Pointer to the Newton world. - @param *p0 - pointer to an array of at least three floats to hold minimum value for the AABB. - @param *p1 - pointer to an array of at least three floats to hold maximum value for the AABB. - @param callback application defined callback - @param *userData pointer to the user defined user data value. - - @return nothing - - The application should provide the function *NewtonBodyIterator callback* to - be called by Newton for every body in the world. - - For small AABB volumes this function is much more inefficients (fixme: more or - less efficient?) than NewtonWorldGetFirstBody. However, if the AABB contains - the majority of objects in the scene, the overhead of scanning the internal - Broadphase collision plus the AABB test make this function more expensive. - - See also: ::NewtonWorldGetFirstBody -*/ -void NewtonWorldForEachBodyInAABBDo(const NewtonWorld* const newtonWorld, const dFloat* const p0, const dFloat* const p1, NewtonBodyIterator callback, void* const userData) -{ - TRACE_FUNCTION(__FUNCTION__); - - Newton* const world = (Newton *) newtonWorld; - dgVector q0 (dgMin (p0[0], p1[0]), dgMin (p0[1], p1[1]), dgMin (p0[2], p1[2]), dgFloat32 (0.0f)); - dgVector q1 (dgMax (p0[0], p1[0]), dgMax (p0[1], p1[1]), dgMax (p0[2], p1[2]), dgFloat32 (0.0f)); - - world->GetBroadPhase()->ForEachBodyInAABB (q0, q1, (OnBodiesInAABB) callback, userData); -} - - -/*! - Return the current library version number. - - @return version number as an integer, eg 314. - - The version number is a three-digit integer. - - First digit: major version (interface changes among other things) - Second digit: major patch number (new features, and bug fixes) - Third Digit: minor bug fixed patch. -*/ -int NewtonWorldGetVersion() -{ - TRACE_FUNCTION(__FUNCTION__); - return NEWTON_MAJOR_VERSION * 100 + NEWTON_MINOR_VERSION; -} - - -/*! - Return the size of a Newton dFloat in bytes. - - @return sizeof(dFloat) -*/ -int NewtonWorldFloatSize () -{ - TRACE_FUNCTION(__FUNCTION__); - return sizeof (dFloat); -} - - -/*! - Store a user defined data value with the world. - - @param *newtonWorld is the pointer to the newton world. - @param *userData pointer to the user defined user data value. - - @return Nothing. - - The application can attach custom data to the Newton world. Newton will never - look at this data. - - The user data is useful for application developing object oriented classes - based on the Newton API. - - See also: ::NewtonBodyGetUserData, ::NewtonWorldSetUserData, ::NewtonWorldGetUserData -*/ -void NewtonWorldSetUserData(const NewtonWorld* const newtonWorld, void* const userData) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->SetUserData (userData); -} - -/*! - Retrieve the user data attached to the world. - - @param *newtonWorld Pointer to the Newton world. - - @return Pointer to user data. - - See also: ::NewtonBodySetUserData, ::NewtonWorldSetUserData, ::NewtonWorldGetUserData - */ -void* NewtonWorldGetUserData(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - return world->GetUserData(); -} - -/*! - Specify a custom destructor callback for destroying the world. - - @param *newtonWorld Pointer to the Newton world. - @param destructor function poiter callback - - The application may specify its own world destructor. - - See also: ::NewtonWorldSetDestructorCallback, ::NewtonWorldGetUserData -*/ -void NewtonWorldSetDestructorCallback(const NewtonWorld* const newtonWorld, NewtonWorldDestructorCallback destructor) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->m_destructor = destructor; -} - - -/*! - Return pointer to destructor call back function. - - @param *newtonWorld Pointer to the Newton world. - - See also: ::NewtonWorldGetUserData, ::NewtonWorldSetDestructorCallback -*/ -NewtonWorldDestructorCallback NewtonWorldGetDestructorCallback(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - return world->m_destructor; -} - -void NewtonWorldSetCreateDestroyContactCallback(const NewtonWorld* const newtonWorld, NewtonCreateContactCallback createContact, NewtonDestroyContactCallback destroyContact) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - world->SetCreateDestroyContactCallback((dgWorld::OnCreateContact) createContact, (dgWorld::OnDestroyContact) destroyContact); -} - -void NewtonWorldSetCollisionConstructorDestructorCallback (const NewtonWorld* const newtonWorld, NewtonCollisionCopyConstructionCallback constructor, NewtonCollisionDestructorCallback destructor) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->SetCollisionInstanceConstructorDestructor((dgWorld::OnCollisionInstanceDuplicate) constructor, (dgWorld::OnCollisionInstanceDestroy)destructor); -} - -void* NewtonWorldAddListener(const NewtonWorld* const newtonWorld, const char* const nameId, void* const listenerUserData) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->AddListener(nameId, listenerUserData); -} - -void* NewtonWorldGetListener(const NewtonWorld* const newtonWorld, const char* const nameId) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->FindListener(nameId); -} - -void* NewtonWorldGetListenerUserData (const NewtonWorld* const newtonWorld, void* const listener) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - return world->GetListenerUserData (listener); -} - -NewtonWorldListenerBodyDestroyCallback NewtonWorldListenerGetBodyDestroyCallback (const NewtonWorld* const newtonWorld, void* const listener) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - return (NewtonWorldListenerBodyDestroyCallback) world->GetListenerBodyDestroyCallback (listener); -} - -void NewtonWorldListenerSetBodyDestroyCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldListenerBodyDestroyCallback callback) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->SetListenerBodyDestroyCallback (listener, (dgWorld::OnListenerBodyDestroyCallback) callback); -} - -void NewtonWorldListenerSetDestructorCallback(const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldDestroyListenerCallback callback) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->ListenerSetDestroyCallback(listener, (dgWorld::OnListenerDestroyCallback) callback); -} - -void NewtonWorldListenerSetPreUpdateCallback(const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldUpdateListenerCallback callback) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->ListenerSetPreUpdate(listener, (dgWorld::OnListenerUpdateCallback) callback); -} - -void NewtonWorldListenerSetPostUpdateCallback(const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldUpdateListenerCallback callback) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->ListenerSetPostUpdate(listener, (dgWorld::OnListenerUpdateCallback) callback); -} - -void NewtonWorldListenerSetPostStepCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldUpdateListenerCallback callback) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->ListenerSetPostStep(listener, (dgWorld::OnListenerUpdateCallback) callback); -} - -void NewtonWorldListenerSetDebugCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldListenerDebugCallback callback) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->SetListenerBodyDebugCallback (listener, (dgWorld::OnListenerDebugCallback) callback); -} - -void NewtonWorldListenerDebug(const NewtonWorld* const newtonWorld, void* const context) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->ListenersDebug(context); -} - -/*! - Return the total number of rigid bodies in the world. - - @param *newtonWorld Pointer to the Newton world. - - @return Number of rigid bodies in the world. - -*/ -int NewtonWorldGetBodyCount(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - return world->GetBodiesCount(); -} - -/*! - Return the total number of constraints in the world. - - @param *newtonWorld pointer to the Newton world. - - @return number of constraints. - -*/ -int NewtonWorldGetConstraintCount(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - return world->GetConstraintsCount(); -} - - -/*! - Shoot ray from point p0 to p1 and trigger callback for each body on that line. - - @param *newtonWorld Pointer to the Newton world. - @param *p0 - pointer to an array of at least three floats containing the beginning of the ray in global space. - @param *p1 - pointer to an array of at least three floats containing the end of the ray in global space. - @param filter Callback function for each hit during the ray scan. - @param *userData user data to pass along to the filter callback. - @param prefilter user defined function to be called for each body before intersection. - @param threadIndex Index of thread that called this function (zero if called form outsize a newton update). - - @return nothing - - The ray cast function will trigger the callback for every intersection between - the line segment (from p0 to p1) and a body in the world. - - By writing the callback filter function in different ways the application can - implement different flavors of ray casting. For example an all body ray cast - can be easily implemented by having the filter function always returning 1.0, - and copying each rigid body into an array of pointers; a closest hit ray cast - can be implemented by saving the body with the smaller intersection parameter - and returning the parameter t; and a report the first body hit can be - implemented by having the filter function returning zero after the first call - and saving the pointer to the rigid body. - - The most common use for the ray cast function is the closest body hit, In this - case it is important, for performance reasons, that the filter function - returns the intersection parameter. If the filter function returns a value of - zero the ray cast will terminate immediately. - - if prefilter is not NULL, Newton will call the application right before - executing the intersections between the ray and the primitive. if the function - returns zero the Newton will not ray cast the primitive. passing a NULL - pointer will ray cast the. The application can use this implement faster or - smarter filters when implementing complex logic, otherwise for normal all ray - cast this parameter could be NULL. - - The ray cast function is provided as an utility function, this means that even - thought the function is very high performance by function standards, it can - not by batched and therefore it can not be an incremental function. For - example the cost of calling 1000 ray cast is 1000 times the cost of calling - one ray cast. This is much different than the collision system where the cost - of calculating collision for 1000 pairs in much, much less that the 1000 times - the cost of one pair. Therefore this function must be used with care, as - excessive use of it can degrade performance. - - See also: ::NewtonWorldConvexCast -*/ -void NewtonWorldRayCast(const NewtonWorld* const newtonWorld, const dFloat* const p0, const dFloat* const p1, NewtonWorldRayFilterCallback filter, void* const userData, NewtonWorldRayPrefilterCallback prefilter, int threadIndex) -{ - TRACE_FUNCTION(__FUNCTION__); - if (filter) { - dgVector pp0 (p0[0], p0[1], p0[2], dgFloat32 (0.0f)); - dgVector pp1 (p1[0], p1[1], p1[2], dgFloat32 (0.0f)); - Newton* const world = (Newton *) newtonWorld; - world->GetBroadPhase()->RayCast (pp0, pp1, (OnRayCastAction) filter, (OnRayPrecastAction) prefilter, userData); - } -} - - -/*! - cast a simple convex shape along the ray that goes for the matrix position to the destination and get the firsts contacts of collision. - - @param *newtonWorld Pointer to the Newton world. - @param *matrix pointer to an array of at least three floats containing the beginning and orienetaion of the shape in global space. - @param *target pointer to an array of at least three floats containing the end of the ray in global space. - @param shape collision shap[e use to cat the ray. - @param param pointe to a variable the will contart the time to closet aproah to the collision. - @param *userData user data to be passed to the prefilter callback. - @param prefilter user define function to be called for each body before intersection. - @param *info pointer to an array of contacts at the point of intesections. - @param maxContactsCount maximun number of contacts to be conclaculated, the variable sould be initialized to the capaciaty of *info* - @param threadIndex thread index from whe thsi function is called, zero if call form outsize a newton update - - @return the number of contact at the intesection point (a value equal o lower than maxContactsCount. - variable *hitParam* will be set the uintesation parameter an the momen of impact. - - passing and value of NULL in *info* an dzero in maxContactsCount will turn thos function into a spcial Ray cast - where the function will only calculate the *hitParam* at the momenet of contacts. tshi si one of the most effiecnet way to use thsio function. - - these function is similar to *NewtonWorldRayCast* but instead of casting a point it cast a simple convex shape along a ray for maoprix.m_poit - to target position. the shape is global orientation and position is set to matrix and then is swept along the segment to target and it will stop at the very first intersession contact. - - for case where the application need to cast solid short to medium rays, it is better to use this function instead of casting and array of parallel rays segments. - examples of these are: implementation of ray cast cars with cylindrical tires, foot placement of character controllers, kinematic motion of objects, user controlled continuous collision, etc. - this function may not be as efficient as sampling ray for long segment, for these cases try using parallel ray cast. - - The most common use for the ray cast function is the closest body hit, In this case it is important, for performance reasons, - that the filter function returns the intersection parameter. If the filter function returns a value of zero the ray cast will terminate - immediately. - - if prefilter is not NULL, Newton will call the application right before executing the intersections between the ray and the primitive. - if the function returns zero the Newton will not ray cast the primitive. - The application can use this callback to implement faster or smarter filters when implementing complex logic, otherwise for normal all ray cast - this parameter could be NULL. - - See also: ::NewtonWorldRayCast -*/ -int NewtonWorldConvexCast(const NewtonWorld* const newtonWorld, const dFloat* const matrix, const dFloat* const target, const NewtonCollision* const shape, - dFloat* const param, void* const userData, NewtonWorldRayPrefilterCallback prefilter, NewtonWorldConvexCastReturnInfo* const info, - int maxContactsCount, int threadIndex) -{ - TRACE_FUNCTION(__FUNCTION__); - dgVector destination (target[0], target[1], target[2], dgFloat32 (0.0f)); - Newton* const world = (Newton *) newtonWorld; - return world->GetBroadPhase()->ConvexCast ((dgCollisionInstance*) shape, dgMatrix (matrix), destination, param, (OnRayPrecastAction) prefilter, userData, (dgConvexCastReturnInfo*)info, maxContactsCount, threadIndex); -} - -int NewtonWorldCollide (const NewtonWorld* const newtonWorld, const dFloat* const matrix, const NewtonCollision* const shape, void* const userData, - NewtonWorldRayPrefilterCallback prefilter, NewtonWorldConvexCastReturnInfo* const info, int maxContactsCount, int threadIndex) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->GetBroadPhase()->Collide((dgCollisionInstance*)shape, dgMatrix(matrix), (OnRayPrecastAction)prefilter, userData, (dgConvexCastReturnInfo*)info, maxContactsCount, threadIndex); -} - -NewtonJoint* NewtonWorldFindJoint(const NewtonBody* const body0, const NewtonBody* const body1) -{ - for (NewtonJoint* joint = NewtonBodyGetFirstJoint(body0); joint; joint = NewtonBodyGetNextJoint(body0, joint)) { - if (((body0 == NewtonJointGetBody0(joint)) && (body1 == NewtonJointGetBody1(joint))) || - ((body1 == NewtonJointGetBody0(joint)) && (body0 == NewtonJointGetBody1(joint)))) { - return joint; - } - } - return NULL; -} - -/*! - Retrieve body by index from island. - - @param island Pointer to simulation island. - @param bodyIndex Index of body on current island. - - @return requested body. fixme: does it return NULL on error? - - This function can only be called from an island update callback. - - See also: ::NewtonSetIslandUpdateEvent -*/ -NewtonBody* NewtonIslandGetBody(const void* const island, int bodyIndex) -{ - TRACE_FUNCTION(__FUNCTION__); - dgWorld* const world = *(dgWorld**)island; - return (NewtonBody*)world->GetClusterBody (island, bodyIndex); -} - - -/*! - Return the AABB of the body on this island - - @param island Pointer to simulation island. - @param bodyIndex index to the body in current island. - @param p0 - fixme - @param p1 - fixme - - This function can only be called from an island update callback. - - See also: ::NewtonSetIslandUpdateEvent -*/ -void NewtonIslandGetBodyAABB(const void* const island, int bodyIndex, dFloat* const p0, dFloat* const p1) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody*) NewtonIslandGetBody(island, bodyIndex); - if (body) { - body->GetAABB ((dgVector&) *p0, (dgVector&) *p1); - } -} - -/*! @} */ // end of group World - -/*! @defgroup GroupID GroupID -GroupID interface -@{ -*/ - - -/*! - Get the value of the default MaterialGroupID. - - @param *newtonWorld pointer to the Newton world. - - @return The ID number for the default Group ID. - - Group IDs can be interpreted as the nodes of a dense graph. The edges of the graph are the physics materials. - When the Newton world is created, the default Group ID is created by the engine. - When bodies are created the application assigns a group ID to the body. -*/ -int NewtonMaterialGetDefaultGroupID(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return int (world->GetDefualtBodyGroupID()); -} - - -/*! - Create a new MaterialGroupID. - - @param *newtonWorld pointer to the Newton world. - - @return The ID of a new GroupID. - - Group IDs can be interpreted as the nodes of a dense graph. The edges of the graph are the physics materials. - When the Newton world is created, the default Group ID is created by the engine. - When bodies are created the application assigns a group ID to the body. - - Note: The only way to destroy a Group ID after its creation is by destroying all the bodies and calling the function *NewtonMaterialDestroyAllGroupID*. - - See also: ::NewtonMaterialDestroyAllGroupID -*/ -int NewtonMaterialCreateGroupID(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return int (world->CreateBodyGroupID()); -} - -/*! - Remove all groups ID from the Newton world. - - @param *newtonWorld pointer to the Newton world. - - @return Nothing. - - This function removes all groups ID from the Newton world. - This function must be called after there are no more rigid bodies in the word. - - See also: ::NewtonDestroyAllBodies -*/ -void NewtonMaterialDestroyAllGroupID(const NewtonWorld* const newtonWorld) -{ -// dgAssert (0); - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - world-> RemoveAllGroupID(); -} - -/*! @} */ // end of GroupID - -/*! @defgroup MaterialSetup MaterialSetup -Material setup interface -@{ -*/ - - -/*! - Set the material interaction between two physics materials to be collidable or non-collidable by default. - - @param *newtonWorld pointer to the Newton world. - @param id0 - group id0 - @param id1 - group id1 - @param state state for this material: 1 = collidable; 0 = non collidable - - @return Nothing. -*/ -void NewtonMaterialSetDefaultCollidable(const NewtonWorld* const newtonWorld, int id0, int id1, int state) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgContactMaterial* const material = world->GetMaterial (dgUnsigned32 (id0), dgUnsigned32 (id1)); - if (state) { - material->m_flags |= dgContactMaterial::m_collisionEnable; - } else { - material->m_flags &= ~dgContactMaterial::m_collisionEnable; - } -} - -/*! - Set an imaginary thickness between the collision geometry of two colliding bodies whose physics - properties are defined by this material pair - - @param *newtonWorld pointer to the Newton world. - @param id0 - group id0 - @param id1 - group id1 - @param thickness material thickness a value form 0.0 to 0.125; the default surface value is 0.0 - - @return Nothing. - - when two bodies collide the engine resolve contact inter penetration by applying a small restoring - velocity at each contact point. By default this restoring velocity will stop when the two contacts are - at zero inter penetration distance. However by setting a non zero thickness the restoring velocity will - continue separating the contacts until the distance between the two point of the collision geometry is equal - to the surface thickness. - - Surfaces thickness can improve the behaviors of rolling objects on flat surfaces. - - Surface thickness does not alter the performance of contact calculation. -*/ -void NewtonMaterialSetSurfaceThickness(const NewtonWorld* const newtonWorld, int id0, int id1, dFloat thickness) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgContactMaterial* const material = world->GetMaterial (dgUnsigned32 (id0), dgUnsigned32 (id1)); - material->m_skinThickness = dgClamp (thickness, dgFloat32 (0.0f), DG_MAX_COLLISION_AABB_PADDING * dgFloat32 (0.5f)); -} - - -/*! - Set the default coefficients of friction for the material interaction between two physics materials . - - @param *newtonWorld pointer to the Newton world. - @param id0 - group id0 - @param id1 - group id1 - @param staticFriction static friction coefficients - @param kineticFriction dynamic coefficient of friction - - @return Nothing. - - *staticFriction* and *kineticFriction* must be positive values. *kineticFriction* must be lower than *staticFriction*. - It is recommended that *staticFriction* and *kineticFriction* be set to a value lower or equal to 1.0, however because some synthetic materials - can have higher than one coefficient of friction Newton allows for the coefficient of friction to be as high as 2.0. -*/ -void NewtonMaterialSetDefaultFriction(const NewtonWorld* const newtonWorld, int id0, int id1, dFloat staticFriction, dFloat kineticFriction) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgContactMaterial* const material = world->GetMaterial (dgUnsigned32 (id0), dgUnsigned32 (id1)); - - staticFriction = dgAbs (staticFriction); - kineticFriction = dgAbs (kineticFriction); - - if (material) { - if (staticFriction >= dgFloat32 (1.0e-2f)) { - dFloat stat0 = dgClamp (staticFriction, dFloat(0.01f), dFloat(2.0f)); - dFloat kine0 = dgClamp (kineticFriction, dFloat(0.01f), dFloat(2.0f)); - dFloat stat = dgMax (stat0, kine0); - dFloat kine = dgMin (stat0, kine0); - material->m_staticFriction0 = stat; - material->m_staticFriction1 = stat; - material->m_dynamicFriction0 = kine; - material->m_dynamicFriction1 = kine; - material->m_flags |= (dgContactMaterial::m_friction0Enable | dgContactMaterial::m_friction1Enable); - } else { - material->m_flags &= ~(dgContactMaterial::m_friction0Enable | dgContactMaterial::m_friction1Enable); - } - } -} - - -/*! - Set the default coefficients of restitution (elasticity) for the material interaction between two physics materials . - - @param *newtonWorld pointer to the Newton world. - @param id0 - group id0 - @param id1 - group id1 - @param elasticCoef static friction coefficients - - @return Nothing. - - *elasticCoef* must be a positive value. - It is recommended that *elasticCoef* be set to a value lower or equal to 1.0 -*/ -void NewtonMaterialSetDefaultElasticity(const NewtonWorld* const newtonWorld, int id0, int id1, dFloat elasticCoef) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgContactMaterial* const material = world->GetMaterial (dgUnsigned32 (id0), dgUnsigned32 (id1)); - - material->m_restitution = dgClamp (elasticCoef, dFloat(0.0f), dFloat(2.0f)); -} - - -/*! - Set the default softness coefficients for the material interaction between two physics materials . - - @param *newtonWorld pointer to the Newton world. - @param id0 - group id0 - @param id1 - group id1 - @param softnessCoef softness coefficient - - @return Nothing. - - *softnessCoef* must be a positive value. - It is recommended that *softnessCoef* be set to value lower or equal to 1.0 - A low value for *softnessCoef* will make the material soft. A typical value for *softnessCoef* is 0.15 -*/ -void NewtonMaterialSetDefaultSoftness(const NewtonWorld* const newtonWorld, int id0, int id1, dFloat softnessCoef) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgContactMaterial* const material = world->GetMaterial (dgUnsigned32 (id0), dgUnsigned32 (id1)); - - material->m_softness = dgClamp (softnessCoef, dFloat(0.01f), dFloat(dgFloat32(1.0f))); -} - -void NewtonMaterialSetCallbackUserData (const NewtonWorld* const newtonWorld, int id0, int id1, void* const userData) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgContactMaterial* const material = world->GetMaterial(dgUnsigned32(id0), dgUnsigned32(id1)); - material->SetUserData(userData); -} - -void NewtonMaterialJointResetIntraJointCollision(const NewtonWorld* const newtonWorld, int id0, int id1) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgContactMaterial* const material = world->GetMaterial(dgUnsigned32(id0), dgUnsigned32(id1)); - material->m_flags |= dgContactMaterial::m_resetSkeletonIntraCollision; -} - -void NewtonMaterialJointResetSelftJointCollision(const NewtonWorld* const newtonWorld, int id0, int id1) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgContactMaterial* const material = world->GetMaterial(dgUnsigned32(id0), dgUnsigned32(id1)); - material->m_flags |= dgContactMaterial::m_resetSkeletonSelfCollision; -} - - -/*! - Set userData and the functions event handlers for the material interaction between two physics materials . - - @param *newtonWorld Pointer to the Newton world. - @param id0 - group id0. - @param id1 - group id1. - @param *aabbOverlap address of the event function called when the AABB of tow bodyes overlap. This parameter can be NULL. - @param *processCallback address of the event function called for every contact resulting from contact calculation. This parameter can be NULL. - - @return Nothing. - - When the AABB extend of the collision geometry of two bodies overlap, Newton collision system retrieves the material - interaction that defines the behavior between the pair of bodies. The material interaction is collected from a database of materials, - indexed by the material gruopID assigned to the bodies. If the material is tagged as non collidable, - then no action is taken and the simulation continues. - If the material is tagged as collidable, and a *aabbOverlap* was set for this material, then the *aabbOverlap* function is called. - If the function *aabbOverlap* returns 0, no further action is taken for this material (this can be use to ignore the interaction under - certain conditions). If the function *aabbOverlap* returns 1, Newton proceeds to calculate the array of contacts for the pair of - colliding bodies. If the function *processCallback* was set, the application receives a callback for every contact found between the - two colliding bodies. Here the application can perform fine grain control over the behavior of the collision system. For example, - rejecting the contact, making the contact frictionless, applying special effects to the surface etc. - After all contacts are processed and if the function *endCallback* was set, Newton calls *endCallback*. - Here the application can collect information gathered during the contact-processing phase and provide some feedback to the player. - A typical use for the material callback is to play sound effects. The application passes the address of structure in the *userData* along with - three event function callbacks. When the function *aabbOverlap* is called by Newton, the application resets a variable say *maximumImpactSpeed*. - Then for every call to the function *processCallback*, the application compares the impact speed for this contact with the value of - *maximumImpactSpeed*, if the value is larger, then the application stores the new value along with the position, and any other quantity desired. - When the application receives the call to *endCallback* the application plays a 3d sound based in the position and strength of the contact. -*/ -void NewtonMaterialSetCollisionCallback(const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnAABBOverlap aabbOverlap, NewtonContactsProcess processCallback) -{ - Newton* const world = (Newton *)newtonWorld; - - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = world->GetMaterial (dgUnsigned32 (id0), dgUnsigned32 (id1)); - material->SetCollisionCallback ((dgContactMaterial::OnAABBOverlap) aabbOverlap, (dgContactMaterial::OnContactCallback) processCallback); -} - -void NewtonMaterialSetContactGenerationCallback (const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnContactGeneration contactGeneration) -{ - Newton* const world = (Newton *)newtonWorld; - - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = world->GetMaterial(dgUnsigned32(id0), dgUnsigned32(id1)); - material->SetCollisionGenerationCallback ((dgContactMaterial::OnContactGeneration) contactGeneration); -} - -/*! - Set userData and the functions event handlers for the material interaction between two physics materials . - - @param *newtonWorld Pointer to the Newton world. - @param id0 - group id0. - @param id1 - group id1. - @param *compoundAabbOverlap: fixme (can this be NULL?) - - @return Nothing. - - When the AABB extents of the collision geometry of two bodies overlap, the Newton collision system retrieves the material - interaction that defines the behavior between the pair of bodies. The material interaction is collected from a database of materials, - indexed by the material gruopID assigned to the bodies. If the material is tagged as non collidable, - then no action is taken and the simulation continues. - If the material is tagged as collidable, and a *aabbOverlap* was set for this material, then the *aabbOverlap* function is called. - If the function *aabbOverlap* returns 0, no further action is taken for this material (this can be use to ignore the interaction under - certain conditions). If the function *aabbOverlap* returns 1, Newton proceeds to calculate the array of contacts for the pair of - colliding bodies. If the function *processCallback* was set, the application receives a callback for every contact found between the - two colliding bodies. Here the application can perform fine grain control over the behavior of the collision system. For example, - rejecting the contact, making the contact frictionless, applying special effects to the surface etc. - After all contacts are processed and if the function *endCallback* was set, Newton calls *endCallback*. - Here the application can collect information gathered during the contact-processing phase and provide some feedback to the player. - A typical use for the material callback is to play sound effects. The application passes the address of structure in the *userData* along with - three event function callbacks. When the function *aabbOverlap* is called by Newton, the application resets a variable say *maximumImpactSpeed*. - Then for every call to the function *processCallback*, the application compares the impact speed for this contact with the value of - *maximumImpactSpeed*, if the value is larger, then the application stores the new value along with the position, and any other quantity desired. - When the application receives the call to *endCallback* the application plays a 3d sound based in the position and strength of the contact. -*/ -void NewtonMaterialSetCompoundCollisionCallback(const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnCompoundSubCollisionAABBOverlap compoundAabbOverlap) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgContactMaterial* const material = world->GetMaterial (dgUnsigned32 (id0), dgUnsigned32 (id1)); - - material->SetCompoundCollisionCallback ((dgContactMaterial::OnCompoundCollisionPrefilter) compoundAabbOverlap); -} - - -/*! - Get userData associated with this material. - - @param *newtonWorld Pointer to the Newton world. - @param id0 - group id0. - @param id1 - group id1. - - @return Nothing. -*/ -void* NewtonMaterialGetUserData (const NewtonWorld* const newtonWorld, int id0, int id1) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgContactMaterial* const material = world->GetMaterial (dgUnsigned32 (id0), dgUnsigned32 (id1)); - - return material->GetUserData(); -} - - -/*! - Get the first Material pair from the material array. - - @param *newtonWorld Pointer to the Newton world. - - @return the first material. - - See also: ::NewtonWorldGetNextMaterial -*/ -NewtonMaterial* NewtonWorldGetFirstMaterial(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return (NewtonMaterial*) world->GetFirstMaterial (); -} - -/*! - Get the next Material pair from the material array. - - @param *newtonWorld Pointer to the Newton world. - @param *material corrent material - - @return next material in material array or NULL if material is the last material in the list. - - See also: ::NewtonWorldGetFirstMaterial -*/ -NewtonMaterial* NewtonWorldGetNextMaterial(const NewtonWorld* const newtonWorld, const NewtonMaterial* const material) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - - return (NewtonMaterial*)world->GetNextMaterial ((dgContactMaterial*) material); -} - -/*! @} */ // end of MaterialSetup - - -/*! @defgroup ContactBehaviour ContactBehaviour -Contact behavior control interface -@{ -*/ - -/*! - Get the userData set by the application when it created this material pair. - - @param materialHandle pointer to a material pair - - @return Application user data. - - This function can only be called from a material callback event handler. - - See also: ::NewtonMaterialSetCollisionCallback -*/ -void* NewtonMaterialGetMaterialPairUserData(const NewtonMaterial* const materialHandle) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - return material->GetUserData(); -} - -/*! - Return the face attribute assigned to this face when for a user defined collision or a Newton collision tree. - - @param materialHandle pointer to a material pair - - @return face attribute for collision trees. Zero if the contact was generated by two convex collisions. - - This function can only be called from a material callback event handler. - - this function can be used by the application to retrieve the face id of a polygon for a collision tree. - - See also: ::NewtonMaterialSetCollisionCallback -*/ -unsigned NewtonMaterialGetContactFaceAttribute(const NewtonMaterial* const materialHandle) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - return (unsigned) (material->m_shapeId1); -} - - -/*! - Calculate the speed of this contact along the normal vector of the contact. - - @param materialHandle pointer to a material pair - - @return Contact speed. A positive value means the contact is repulsive. - - This function can only be called from a material callback event handler. - - See also: ::NewtonMaterialSetCollisionCallback -*/ -dFloat NewtonMaterialGetContactNormalSpeed(const NewtonMaterial* const materialHandle) -{ -// dgAssert (0); - - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; -// contact = (dgContact*) contactlHandle; - - const dgBody* const body0 = material->m_body0; - const dgBody* const body1 = material->m_body1; - - dgVector p0 (material->m_point - body0->GetPosition()); - dgVector p1 (material->m_point - body1->GetPosition()); - - dgVector v0 (body0->GetVelocity() + body0->GetOmega().CrossProduct(p0)); - dgVector v1 (body1->GetVelocity() + body1->GetOmega().CrossProduct(p1)); - - dgVector dv (v1 - v0); - - dgAssert (material->m_normal.m_w == dgFloat32 (0.0f)); - dFloat speed = dv.DotProduct(material->m_normal).GetScalar(); - return speed; -} - -/*! - Calculate the speed of this contact along the tangent vector of the contact. - - @param materialHandle pointer to a material pair. - @param index index to the tangent vector. This value can be 0 for primary tangent direction or 1 for the secondary tangent direction. - - @return Contact tangent speed. - - This function can only be called from a material callback event handler. - - See also: ::NewtonMaterialSetCollisionCallback -*/ -dFloat NewtonMaterialGetContactTangentSpeed(const NewtonMaterial* const materialHandle, int index) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - - const dgBody* const body0 = material->m_body0; - const dgBody* const body1 = material->m_body1; - - dgVector p0 (material->m_point - body0->GetPosition()); - dgVector p1 (material->m_point - body1->GetPosition()); - - dgVector v0 (body0->GetVelocity() + body0->GetOmega().CrossProduct(p0)); - dgVector v1 (body1->GetVelocity() + body1->GetOmega().CrossProduct(p1)); - - dgVector dv (v1 - v0); - dgVector dir (index ? material->m_dir1 : material->m_dir0); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dFloat speed = dv.DotProduct(dir).GetScalar(); - return - speed; -} - - -dFloat NewtonMaterialGetContactMaxNormalImpact(const NewtonMaterial* const materialHandle) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - return material->m_normal_Force.m_impact; -} - -dFloat NewtonMaterialGetContactMaxTangentImpact(const NewtonMaterial* const materialHandle, int index) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - return index ? material->m_dir1_Force.m_impact: material->m_dir0_Force.m_impact; -} - - -/*! - Get the contact position and normal in global space. - - @param materialHandle pointer to a material pair. - @param *body pointer to body - @param *positPtr pointer to an array of at least three floats to hold the contact position. - @param *normalPtr pointer to an array of at least three floats to hold the contact normal. - - @return Nothing. - - This function can only be called from a material callback event handle. - - See also: ::NewtonMaterialSetCollisionCallback -*/ -void NewtonMaterialGetContactPositionAndNormal(const NewtonMaterial* const materialHandle, const NewtonBody* const body, dFloat* const positPtr, dFloat* const normalPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - - positPtr[0] = material->m_point.m_x; - positPtr[1] = material->m_point.m_y; - positPtr[2] = material->m_point.m_z; - - normalPtr[0] = material->m_normal.m_x; - normalPtr[1] = material->m_normal.m_y; - normalPtr[2] = material->m_normal.m_z; - - if ((dgBody*)body != material->m_body0) { - normalPtr[0] *= dgFloat32 (-1.0f); - normalPtr[1] *= dgFloat32 (-1.0f); - normalPtr[2] *= dgFloat32 (-1.0f); - } -} - - - -/*! - Get the contact force vector in global space. - - @param materialHandle pointer to a material pair. - @param *body pointer to body - @param *forcePtr pointer to an array of at least three floats to hold the force vector in global space. - - @return Nothing. - - The contact force value is only valid when calculating resting contacts. This means if two bodies collide with - non zero relative velocity, the reaction force will be an impulse, which is not a reaction force, this will return zero vector. - this function will only return meaningful values when the colliding bodies are at rest. - - This function can only be called from a material callback event handler. - - See also: ::NewtonMaterialSetCollisionCallback -*/ -void NewtonMaterialGetContactForce(const NewtonMaterial* const materialHandle, const NewtonBody* const body, dFloat* const forcePtr) -{ - - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - - dgVector force (material->m_normal.Scale(material->m_normal_Force.m_force) + material->m_dir0.Scale (material->m_dir0_Force.m_force) + material->m_dir1.Scale (material->m_dir1_Force.m_force)); - - forcePtr[0] = force.m_x; - forcePtr[1] = force.m_y; - forcePtr[2] = force.m_z; - - if ((dgBody*)body != material->m_body0) { - forcePtr[0] *= dgFloat32 (-1.0f); - forcePtr[1] *= dgFloat32 (-1.0f); - forcePtr[2] *= dgFloat32 (-1.0f); - } -} - - - -/*! - Get the contact tangent vector to the contact point. - - @param materialHandle pointer to a material pair. - @param *body pointer to body - @param *dir0 - pointer to an array of at least three floats to hold the contact primary tangent vector. - @param *dir1 - pointer to an array of at least three floats to hold the contact secondary tangent vector. - - @return Nothing. - - This function can only be called from a material callback event handler. - - See also: ::NewtonMaterialSetCollisionCallback -*/ -void NewtonMaterialGetContactTangentDirections(const NewtonMaterial* const materialHandle, const NewtonBody* const body, dFloat* const dir0, dFloat* const dir1) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - - dir0[0] = material->m_dir0.m_x; - dir0[1] = material->m_dir0.m_y; - dir0[2] = material->m_dir0.m_z; - - dir1[0] = material->m_dir1.m_x; - dir1[1] = material->m_dir1.m_y; - dir1[2] = material->m_dir1.m_z; - - if ((dgBody*)body != material->m_body0) { - dir0[0] *= dgFloat32 (-1.0f); - dir0[1] *= dgFloat32 (-1.0f); - dir0[2] *= dgFloat32 (-1.0f); - - dir1[0] *= dgFloat32 (-1.0f); - dir1[1] *= dgFloat32 (-1.0f); - dir1[2] *= dgFloat32 (-1.0f); - } -} - -dFloat NewtonMaterialGetContactPenetration (const NewtonMaterial* const materialHandle) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - return material->m_penetration; -} - -NewtonCollision* NewtonMaterialGetBodyCollidingShape(const NewtonMaterial* const materialHandle, const NewtonBody* const body) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const bodyPtr = (dgBody*) body; - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - - const dgCollisionInstance* collision = material->m_collision0; - if (bodyPtr == material->m_body1) { - collision = material->m_collision1; - } - return (NewtonCollision*) collision; -} - - -//dFloat NewtonMaterialGetContactPruningTolerance(const NewtonBody* const body0, const NewtonBody* const body1) -dFloat NewtonMaterialGetContactPruningTolerance(const NewtonJoint* const contactJointPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContact* const contact = (dgContact*) contactJointPtr; - return contact->GetPruningTolerance (); -} - -void NewtonMaterialSetContactPruningTolerance(const NewtonJoint* const contactJointPtr, dFloat tolerance) -{ - TRACE_FUNCTION(__FUNCTION__); - TRACE_FUNCTION(__FUNCTION__); - dgContact* const contact = (dgContact*) contactJointPtr; - dgAssert(contact); - contact->SetPruningTolerance (dgMax (tolerance, dFloat (1.0e-3f))); -} - - -/*! - Override the default softness value for the contact. - - @param materialHandle pointer to a material pair. - @param softness softness value, must be positive. - - @return Nothing. - - This function can only be called from a material callback event handler. - - See also: ::NewtonMaterialSetCollisionCallback, ::NewtonMaterialSetDefaultSoftness -*/ -void NewtonMaterialSetContactSoftness(const NewtonMaterial* const materialHandle, dFloat softness) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - material->m_softness = dgClamp (softness, dFloat(0.01f), dFloat(0.7f)); -} - -/*! - Override the default contact skin thickness value for the contact. - - @param materialHandle pointer to a material pair. - @param thickness skin thickness value, must be positive. - - @return Nothing. - - This function can only be called from a material callback event handler. - - See also: ::NewtonMaterialSetCollisionCallback, ::NewtonMaterialSetDefaultSoftness -*/ -void NewtonMaterialSetContactThickness (const NewtonMaterial* const materialHandle, dFloat thickness) -{ - TRACE_FUNCTION(__FUNCTION__); - dgAssert (thickness >= dgFloat32 (0.0f)); - dgContactMaterial* const material = (dgContactMaterial*)materialHandle; - material->m_skinThickness = thickness; -} - -/*! - Override the default elasticity (coefficient of restitution) value for the contact. - - @param materialHandle pointer to a material pair. - @param restitution elasticity value, must be positive. - - @return Nothing. - - This function can only be called from a material callback event handler. - - See also: ::NewtonMaterialSetCollisionCallback, ::NewtonMaterialSetDefaultElasticity -*/ -void NewtonMaterialSetContactElasticity(const NewtonMaterial* const materialHandle, dFloat restitution) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - material->m_restitution = dgClamp (restitution, dFloat(0.0f), dFloat(2.0f)); -} - - -/*! - Enable or disable friction calculation for this contact. - - @param materialHandle pointer to a material pair. - @param state* new state. 0 makes the contact frictionless along the index tangent vector. - @param index index to the tangent vector. 0 for primary tangent vector or 1 for the secondary tangent vector. - - @return Nothing. - - This function can only be called from a material callback event handler. - - See also: ::NewtonMaterialSetCollisionCallback -*/ -void NewtonMaterialSetContactFrictionState(const NewtonMaterial* const materialHandle, int state, int index) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - - if (index) { - if (state) { - material->m_flags |= dgContactMaterial::m_friction1Enable; - } else { - material->m_flags &= ~dgContactMaterial::m_friction1Enable; - } - } else { - if (state) { - material->m_flags |= dgContactMaterial::m_friction0Enable; - } else { - material->m_flags &= ~dgContactMaterial::m_friction0Enable; - } - } -} - - - -/*! - Override the default value of the kinetic and static coefficient of friction for this contact. - - @param materialHandle pointer to a material pair. - @param staticFrictionCoef static friction coefficient. Must be positive. - @param kineticFrictionCoef static friction coefficient. Must be positive. - @param index index to the tangent vector. 0 for primary tangent vector or 1 for the secondary tangent vector. - - @return Nothing. - - This function can only be called from a material callback event handler. - - It is recommended that *coef* be set to a value lower or equal to 1.0, however because some synthetic materials - can have hight than one coefficient of friction Newton allows for the coefficient of friction to be as high as 2.0. - - the value *staticFrictionCoef* and *kineticFrictionCoef* will be clamped between 0.01f and 2.0. - If the application wants to set a kinetic friction higher than the current static friction it must increase the static friction first. - - See also: ::NewtonMaterialSetCollisionCallback, ::NewtonMaterialSetDefaultFriction -*/ -void NewtonMaterialSetContactFrictionCoef(const NewtonMaterial* const materialHandle, dFloat staticFrictionCoef, dFloat kineticFrictionCoef, int index) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - - if (staticFrictionCoef < kineticFrictionCoef) { - staticFrictionCoef = kineticFrictionCoef; - } - - if (index) { - material->m_staticFriction1 = dgClamp (staticFrictionCoef, dFloat(0.01f), dFloat(2.0f)); - material->m_dynamicFriction1 = dgClamp (kineticFrictionCoef, dFloat(0.01f), dFloat(2.0f)); - } else { - material->m_staticFriction0 = dgClamp (staticFrictionCoef, dFloat(0.01f), dFloat(2.0f)); - material->m_dynamicFriction0 = dgClamp (kineticFrictionCoef, dFloat(0.01f), dFloat(2.0f)); - } -} - -/*! - Force the contact point to have a non-zero acceleration aligned this the contact normal. - - @param materialHandle pointer to a material pair. - @param accel desired contact acceleration, Must be a positive value - - @return Nothing. - - This function can only be called from a material callback event handler. - - This function can be used for spacial effects like implementing jump, of explosive contact in a call back. - - See also: ::NewtonMaterialSetCollisionCallback -*/ -void NewtonMaterialSetContactNormalAcceleration(const NewtonMaterial* const materialHandle, dFloat accel) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - material->m_normal_Force.m_force = accel; - material->m_flags |= dgContactMaterial::m_overrideNormalAccel; -} - -void NewtonMaterialSetAsSoftContact (const NewtonMaterial* const materialHandle, dFloat relaxation) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - material->SetAsSoftContact (relaxation); -} - -/*! - Force the contact point to have a non-zero acceleration along the surface plane. - - @param materialHandle pointer to a material pair. - @param accel desired contact acceleration. - @param index index to the tangent vector. 0 for primary tangent vector or 1 for the secondary tangent vector. - - @return Nothing. - - This function can only be called from a material callback event handler. - - See also: ::NewtonMaterialSetCollisionCallback, ::NewtonMaterialContactRotateTangentDirections -*/ -void NewtonMaterialSetContactTangentAcceleration(const NewtonMaterial* const materialHandle, dFloat accel, int index) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - if (index) { - material->m_dir1_Force.m_force = accel; - material->m_flags |= dgContactMaterial::m_override1Accel; - } else { - material->m_dir0_Force.m_force = accel; - material->m_flags |= dgContactMaterial::m_override0Accel; - } -} - -void NewtonMaterialSetContactTangentFriction (const NewtonMaterial* const materialHandle, dFloat friction, int index) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - friction = dgMax (dFloat(0.01f), dgAbs (friction)); - if (index) { - material->m_flags |= dgContactMaterial::m_override1Friction; - dgAssert (index == 1); - material->m_staticFriction1 = friction; - material->m_dynamicFriction1 = friction; - } else { - material->m_flags |= dgContactMaterial::m_override0Friction; - material->m_staticFriction0 = friction; - material->m_dynamicFriction0 = friction; - } -} - -/*! - Set the new direction of the for this contact point. - - @param materialHandle pointer to a material pair. - @param *direction pointer to an array of at least three floats holding the direction vector. - - @return Nothing. - - This function can only be called from a material callback event handler. - This function changes the basis of the contact point to one where the contact normal is aligned to the new direction vector - and the tangent direction are recalculated to be perpendicular to the new contact normal. - - In 99.9% of the cases the collision system can calculates a very good contact normal. - however this algorithm that calculate the contact normal use as criteria the normal direction - that will resolve the inter penetration with the least amount on motion. - There are situations however when this solution is not the best. Take for example a rolling - ball over a tessellated floor, when the ball is over a flat polygon, the contact normal is always - perpendicular to the floor and pass by the origin of the sphere, however when the sphere is going - across two adjacent polygons, the contact normal is now perpendicular to the polygons edge and this does - not guarantee they it will pass bay the origin of the sphere, but we know that the best normal is always - the one passing by the origin of the sphere. - - See also: ::NewtonMaterialSetCollisionCallback, ::NewtonMaterialContactRotateTangentDirections -*/ -void NewtonMaterialSetContactNormalDirection(const NewtonMaterial* const materialHandle, const dFloat* const direction) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - dgVector normal (direction[0], direction[1], direction[2], dgFloat32 (0.0f)); - - //dgAssert (normal.DotProduct3(material->m_normal) > dgFloat32 (0.01f)); - if (normal.DotProduct(material->m_normal).GetScalar() < dgFloat32 (0.0f)) { - normal = normal * dgVector::m_negOne; - } - material->m_normal = normal; - - dgMatrix matrix (normal); - material->m_dir1 = matrix.m_up; - material->m_dir0 = matrix.m_right; -} - -void NewtonMaterialSetContactPosition(const NewtonMaterial* const materialHandle, const dFloat* const position) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*)materialHandle; - dgVector point(position[0], position[1], position[2], dgFloat32(1.0f)); - material->m_point = point; -} - - -/*! - Rotate the tangent direction of the contacts until the primary direction is aligned with the alignVector. - - @param *materialHandle pointer to a material pair. - @param *alignVector pointer to an array of at least three floats holding the aligning vector. - - @return Nothing. - - This function can only be called from a material callback event handler. - This function rotates the tangent vectors of the contact point until the primary tangent vector and the align vector - are perpendicular (ex. when the dot product between the primary tangent vector and the alignVector is 1.0). This - function can be used in conjunction with NewtonMaterialSetContactTangentAcceleration in order to - create special effects. For example, conveyor belts, cheap low LOD vehicles, slippery surfaces, etc. - - See also: ::NewtonMaterialSetCollisionCallback, ::NewtonMaterialSetContactNormalDirection -*/ -void NewtonMaterialContactRotateTangentDirections(const NewtonMaterial* const materialHandle, const dFloat* const alignVector) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContactMaterial* const material = (dgContactMaterial*) materialHandle; - - const dgVector dir0 (alignVector[0], alignVector[1], alignVector[2], dgFloat32 (0.0f)); - - dgVector dir1 (material->m_normal.CrossProduct(dir0)); - dgAssert(dir1.m_w == dgFloat32(0.0f)); - dFloat mag2 = dir1.DotProduct(dir1).GetScalar(); - if (mag2 > dgFloat32(1.0e-6f)) { - material->m_dir1 = dir1.Normalize(); - material->m_dir0 = material->m_dir1.CrossProduct(material->m_normal); - } -} - -/*! @} */ // end of ContactBehaviour - -/*! @defgroup CshapesConvexSimple CshapesConvexSimple -Convex collision primitives interface -@{ -*/ - - -/*! - Create a transparent collision primitive. - - @param *newtonWorld Pointer to the Newton world. - - @return Pointer to the collision object. - - Some times the application needs to create helper rigid bodies that will never collide with other bodies, - for example the neck of a rag doll, or an internal part of an articulated structure. This can be done by using the material system - but it too much work and it will increase unnecessarily the material count, and therefore the project complexity. The Null collision - is a collision object that satisfy all this conditions without having to change the engine philosophy. - -*/ -NewtonCollision* NewtonCreateNull(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return (NewtonCollision*) world->CreateNull(); -} - - -/*! - Create a box primitive for collision. - - @param *newtonWorld Pointer to the Newton world. - @param dx box side one x dimension. - @param dy box side one y dimension. - @param dz box side one z dimension. - @param shapeID fixme - @param *offsetMatrix pointer to an array of 16 floats containing the offset matrix of the box relative to the body. If this parameter is NULL, then the primitive is centered at the origin of the body. - - @return Pointer to the box - -*/ -NewtonCollision* NewtonCreateBox(const NewtonWorld* const newtonWorld, dFloat dx, dFloat dy, dFloat dz, int shapeID, const dFloat* const offsetMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgMatrix matrix (dgGetIdentityMatrix()); - if (offsetMatrix) { - matrix = dgMatrix (offsetMatrix); - } - return (NewtonCollision*) world->CreateBox (dx, dy, dz, shapeID, matrix); -} - -/*! - Create a generalized ellipsoid primitive.. - - @param *newtonWorld Pointer to the Newton world. - @param radius sphere radius - @param shapeID user specified collision index that can be use for multi material collision. - @param *offsetMatrix pointer to an array of 16 floats containing the offset matrix of the sphere relative to the body. If this parameter is NULL then the sphere is centered at the origin of the body. - - @return Pointer to the generalized sphere. - - Sphere collision are generalized ellipsoids, the application can create many different kind of objects by just playing with dimensions of the radius. - for example to make a sphere set all tree radius to the same value, to make a ellipse of revolution just set two of the tree radius to the same value. - - General ellipsoids are very good hull geometries to represent the outer shell of avatars in a game. - -*/ -NewtonCollision* NewtonCreateSphere(const NewtonWorld* const newtonWorld, dFloat radius, int shapeID, const dFloat* const offsetMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgMatrix matrix (dgGetIdentityMatrix()); - if (offsetMatrix) { - matrix = dgMatrix (offsetMatrix); - } - - return (NewtonCollision*) world->CreateSphere(dgAbs(radius), shapeID, matrix); -} - - -/*! - Create a cone primitive for collision. - - @param *newtonWorld Pointer to the Newton world. - @param radius cone radius at the base. - @param height cone height along the x local axis from base to tip. - @param shapeID user specified collision index that can be use for multi material collision. - @param *offsetMatrix pointer to an array of 16 floats containing the offset matrix of the box relative to the body. If this parameter is NULL, then the primitive is centered at the origin of the body. - - @return Pointer to the box - -*/ -NewtonCollision* NewtonCreateCone(const NewtonWorld* const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat* const offsetMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgMatrix matrix (dgGetIdentityMatrix()); - if (offsetMatrix) { - matrix = dgMatrix (offsetMatrix); - } - return (NewtonCollision*) world->CreateCone (radius, height, shapeID, matrix); -} - - -/*! - Create a capsule primitive for collision. - - @param *newtonWorld Pointer to the Newton world. - @param radio0 - fixme - @param radio1 - fixme - @param height capsule height along the x local axis from tip to tip. - @param shapeID fixme - @param *offsetMatrix pointer to an array of 16 floats containing the offset matrix of the box relative to the body. If this parameter is NULL, then the primitive is centered at the origin of the body. - - @return Pointer to the box - - the capsule height must equal of larger than the sum of the cap radius. If this is not the case the height will be clamped the 2 * radius. - -*/ -NewtonCollision* NewtonCreateCapsule(const NewtonWorld* const newtonWorld, dFloat radio0, dFloat radio1, dFloat height, int shapeID, const dFloat* const offsetMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgMatrix matrix(dgGetIdentityMatrix()); - if (offsetMatrix) { - matrix = dgMatrix(offsetMatrix); - } - return (NewtonCollision*)world->CreateCapsule(radio0, radio1, height, shapeID, matrix); -} - - -/*! - Create a cylinder primitive for collision. - - @param *newtonWorld Pointer to the Newton world. - @param radio0 - fixme - @param radio1 - fixme - @param height cylinder height along the x local axis. - @param shapeID fixme - @param *offsetMatrix pointer to an array of 16 floats containing the offset matrix of the box relative to the body. If this parameter is NULL, then the primitive is centered at the origin of the body. - - @return Pointer to the box - -*/ -NewtonCollision* NewtonCreateCylinder(const NewtonWorld* const newtonWorld, dFloat radio0, dFloat radio1, dFloat height, int shapeID, const dFloat* const offsetMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgMatrix matrix(dgGetIdentityMatrix()); - if (offsetMatrix) { - matrix = dgMatrix(offsetMatrix); - } - return (NewtonCollision*)world->CreateCylinder(radio0, radio1, height, shapeID, matrix); -} - - -/*! - Create a ChamferCylinder primitive for collision. - - @param *newtonWorld Pointer to the Newton world. - @param radius ChamferCylinder radius at the base. - @param height ChamferCylinder height along the x local axis. - @param shapeID fixme - @param *offsetMatrix pointer to an array of 16 floats containing the offset matrix of the box relative to the body. If this parameter is NULL, then the primitive is centered at the origin of the body. - - @return Pointer to the box - -*/ -NewtonCollision* NewtonCreateChamferCylinder(const NewtonWorld* const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat* const offsetMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgMatrix matrix (dgGetIdentityMatrix()); - if (offsetMatrix) { - matrix = dgMatrix (offsetMatrix); - } - return (NewtonCollision*) world->CreateChamferCylinder (radius, height, shapeID, matrix); -} - - -/*! - Create a ConvexHull primitive from collision from a cloud of points. - - @param *newtonWorld Pointer to the Newton world. - @param count number of consecutive point to follow must be at least 4. - @param *vertexCloud pointer to and array of point. - @param strideInBytes vertex size in bytes, must be at least 12. - @param tolerance tolerance value for the hull generation. - @param shapeID fixme - @param *offsetMatrix pointer to an array of 16 floats containing the offset matrix of the box relative to the body. If this parameter is NULL, then the primitive is centered at the origin of the body. - - @return Pointer to the collision mesh, NULL if the function fail to generate convex shape - - Convex hulls are the solution to collision primitive that can not be easily represented by an implicit solid. - The implicit solid primitives (spheres, cubes, cylinders, capsules, cones, etc.), have constant time complexity for contact calculation - and are also extremely efficient on memory usage, therefore the application get perfect smooth behavior. - However for cases where the shape is too difficult or a polygonal representation is desired, convex hulls come closest to the to the model shape. - For example it is a mistake to model a 10000 point sphere as a convex hull when the perfect sphere is available, but it is better to represent a - pyramid by a convex hull than with a sphere or a box. - - There is not upper limit as to how many vertex the application can pass to make a hull shape, - however for performance and memory usage concern it is the application responsibility to keep the max vertex at the possible minimum. - The minimum number of vertex should be equal or larger than 4 and it is the application responsibility that the points are part of a solid geometry. - Unpredictable results will occur if all points happen to be collinear or coplanar. - - The performance of collision with convex hull proxies is sensitive to the vertex count of the hull. Since a the convex hull - of a visual geometry is already an approximation of the mesh, for visual purpose there is not significant difference between the - appeal of a exact hull and one close to the exact hull but with but with a smaller vertex count. - It just happens that sometime complex meshes lead to generation of convex hulls with lots of small detail that play not - roll of the quality of the simulation but that have a significant impact on the performance because of a large vertex count. - For this reason the application have the option to set a *tolerance* parameter. - *tolerance* is use to post process the final geometry in the following faction, a point on the surface of the hull can - be remove if the distance of all of the surrounding vertex immediately adjacent to the average plane equation formed the - faces adjacent to that point, is smaller than the tolerance. A value of zero in *tolerance* will generate an exact hull and a value langer that zero - will generate a loosely fitting hull and it willbe faster to generate. - -*/ -NewtonCollision* NewtonCreateConvexHull(const NewtonWorld* const newtonWorld, int count, const dFloat* const vertexCloud, int strideInBytes, dgFloat32 tolerance, int shapeID, const dFloat* const offsetMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgMatrix matrix (dgGetIdentityMatrix()); - if (offsetMatrix) { - matrix = dgMatrix (offsetMatrix); - } - tolerance = dgClamp (tolerance, dgFloat32 (0.0f), dgFloat32 (0.125f)); - return (NewtonCollision*) world->CreateConvexHull (count, vertexCloud, strideInBytes, tolerance, shapeID, matrix); -} - - -/*! - Create a ConvexHull primitive from a special effect mesh. - - @param *newtonWorld Pointer to the Newton world. - @param *mesh special effect mesh - @param tolerance tolerance value for the hull generation. - @param shapeID fixme - - @return Pointer to the collision mesh, NULL if the function fail to generate convex shape - - Because the in general this function is used for runtime special effect like debris and or solid particles - it is recommended that the source mesh complexity is kept small. - - See also: ::NewtonCreateConvexHull, ::NewtonMeshCreate -*/ -NewtonCollision* NewtonCreateConvexHullFromMesh(const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, dFloat tolerance, int shapeID) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - return (NewtonCollision*) meshEffect->CreateConvexCollision(world, tolerance, shapeID); -} - - -/*! - Create a container to hold an array of convex collision primitives. - - @param *newtonWorld Pointer to the Newton world. - @param shapeID: fixme - - @return Pointer to the compound collision. - - Compound collision primitives can only be made of convex collision primitives and they can not contain compound collision. Therefore they are treated as convex primitives. - - Compound collision primitives are treated as instance collision objects that can not shared by multiples rigid bodies. - -*/ -NewtonCollision* NewtonCreateCompoundCollision(const NewtonWorld* const newtonWorld, int shapeID) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgCollisionInstance* const collision = world->CreateCompound (); - collision->SetUserDataID(dgUnsigned32 (shapeID)); - return (NewtonCollision*) collision; -} - -void* NewtonCompoundCollisionAddSubCollision (NewtonCollision* const compoundCollision, const NewtonCollision* const convexCollision) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgCollisionInstance* const compoundInstance = (dgCollisionInstance*) compoundCollision; - dgCollisionInstance* const compoundInstanceChild = (dgCollisionInstance*) convexCollision; - if (compoundInstance->IsType (dgCollision::dgCollisionCompound_RTTI) && compoundInstanceChild->IsType(dgCollision::dgCollisionConvexShape_RTTI)) { - dgCollisionCompound* const collision = (dgCollisionCompound*) compoundInstance->GetChildShape(); - return collision->AddCollision (compoundInstanceChild); - } - return NULL; -} - - -void NewtonCompoundCollisionRemoveSubCollision (NewtonCollision* const compoundCollision, const void* const collisionNode) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) compoundCollision; - if (instance->IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionCompound* const collision = (dgCollisionCompound*) instance->GetChildShape(); - dgCollisionInstance* const childCollision = collision->GetCollisionFromNode((dgCollisionCompound::dgTreeArray::dgTreeNode*)collisionNode); - if (childCollision && childCollision->IsType(dgCollision::dgCollisionConvexShape_RTTI)) { - collision->RemoveCollision ((dgCollisionCompound::dgTreeArray::dgTreeNode*)collisionNode); - } - } -} - -void NewtonCompoundCollisionRemoveSubCollisionByIndex (NewtonCollision* const compoundCollision, int nodeIndex) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) compoundCollision; - if (instance->IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionCompound* const collision = (dgCollisionCompound*) instance->GetChildShape(); - NewtonCompoundCollisionRemoveSubCollision (compoundCollision, collision->FindNodeByIndex(nodeIndex)); - } -} - - -void NewtonCompoundCollisionSetSubCollisionMatrix (NewtonCollision* const compoundCollision, const void* const collisionNode, const dFloat* const matrix) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const compoundInstance = (dgCollisionInstance*) compoundCollision; - if (compoundInstance->IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionCompound* const collision = (dgCollisionCompound*) compoundInstance->GetChildShape(); - collision->SetCollisionMatrix((dgCollisionCompound::dgTreeArray::dgTreeNode*)collisionNode, dgMatrix(matrix)); - } -} - - -void NewtonCompoundCollisionBeginAddRemove (NewtonCollision* const compoundCollision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) compoundCollision; - if (instance->IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionCompound* const collision = (dgCollisionCompound*) instance->GetChildShape(); - collision->BeginAddRemove(); - } -} - -void NewtonCompoundCollisionEndAddRemove (NewtonCollision* const compoundCollision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) compoundCollision; - if (instance->IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionCompound* const collision = (dgCollisionCompound*) instance->GetChildShape(); - collision->EndAddRemove(); - } -} - - -void* NewtonCompoundCollisionGetFirstNode (NewtonCollision* const compoundCollision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) compoundCollision; - if (instance->IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionCompound* const collision = (dgCollisionCompound*) instance->GetChildShape(); - return collision->GetFirstNode(); - } - return NULL; -} - -void* NewtonCompoundCollisionGetNextNode (NewtonCollision* const compoundCollision, const void* const node) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) compoundCollision; - if (instance->IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionCompound* const collision = (dgCollisionCompound*) instance->GetChildShape(); - return collision->GetNextNode((dgCollisionCompound::dgTreeArray::dgTreeNode*)node); - } - return NULL; -} - -void* NewtonCompoundCollisionGetNodeByIndex (NewtonCollision* const compoundCollision, int index) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) compoundCollision; - if (instance->IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionCompound* const collision = (dgCollisionCompound*) instance->GetChildShape(); - return collision->FindNodeByIndex(index); - } - return NULL; -} - -int NewtonCompoundCollisionGetNodeIndex (NewtonCollision* const compoundCollision, const void* const node) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) compoundCollision; - if (instance->IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionCompound* const collision = (dgCollisionCompound*) instance->GetChildShape(); - return collision->GetNodeIndex((dgCollisionCompound::dgTreeArray::dgTreeNode*)node); - } - return -1; -} - - -NewtonCollision* NewtonCompoundCollisionGetCollisionFromNode (NewtonCollision* const compoundCollision, const void* const node) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const compoundInstance = (dgCollisionInstance*) compoundCollision; - if (compoundInstance->IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionCompound* const collision = (dgCollisionCompound*) compoundInstance->GetChildShape(); - return (NewtonCollision*) collision->GetCollisionFromNode((dgCollisionCompound::dgTreeArray::dgTreeNode*)node); - } - return NULL; -} - - -/*! - Create a compound collision from a concave mesh by an approximate convex partition - - @param *newtonWorld Pointer to the Newton world. - @param *convexAproximation fixme - @param hullTolerance fixme - @param shapeID fixme - @param subShapeID fixme - - - @return Pointer to the compound collision. - - The algorithm will separated the the original mesh into a series of sub meshes until either - the worse concave point is smaller than the specified min concavity or the max number convex shapes is reached. - - is is recommended that convex approximation are made by person with a graphics toll by physically overlaying collision primitives over the concave mesh. - but for quit test of maybe for simple meshes and algorithm approximations can be used. - - is is recommended that for best performance this function is used in an off line toll and serialize the output. - - Compound collision primitives are treated as instanced collision objects that cannot be shared by multiples rigid bodies. - -*/ -NewtonCollision* NewtonCreateCompoundCollisionFromMesh (const NewtonWorld* const newtonWorld, const NewtonMesh* const convexAproximation, dFloat hullTolerance, int shapeID, int subShapeID) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonCollision* const compound = NewtonCreateCompoundCollision(newtonWorld, shapeID); - NewtonCompoundCollisionBeginAddRemove(compound); - - NewtonMesh* nextSegment = NULL; - for (NewtonMesh* segment = NewtonMeshCreateFirstSingleSegment (convexAproximation); segment; segment = nextSegment) { - nextSegment = NewtonMeshCreateNextSingleSegment (convexAproximation, segment); - - NewtonCollision* const convexHull = NewtonCreateConvexHullFromMesh (newtonWorld, segment, hullTolerance, subShapeID); - if (convexHull) { - NewtonCompoundCollisionAddSubCollision (compound, convexHull); - NewtonDestroyCollision(convexHull); - } - NewtonMeshDestroy(segment); - } - - NewtonCompoundCollisionEndAddRemove(compound); - - return compound; -} - - -NewtonCollision* NewtonCreateFracturedCompoundCollision (const NewtonWorld* const newtonWorld, const NewtonMesh* const solidMesh, int shapeID, int fracturePhysicsMaterialID, int pointcloudCount, const dFloat* const vertexCloud, int strideInBytes, int materialID, const dFloat* const textureMatrix, - NewtonFractureCompoundCollisionReconstructMainMeshCallBack regenerateMainMeshCallback, - NewtonFractureCompoundCollisionOnEmitCompoundFractured emitFracturedCompound, NewtonFractureCompoundCollisionOnEmitChunk emitFracfuredChunk) -{ - TRACE_FUNCTION(__FUNCTION__); - - Newton* const world = (Newton *)newtonWorld; - dgMeshEffect* const mesh = (dgMeshEffect*) solidMesh; - - dgMatrix textMatrix (textureMatrix); - dgCollisionInstance* const collision = world->CreateFracturedCompound (mesh, shapeID, fracturePhysicsMaterialID, pointcloudCount, vertexCloud, strideInBytes, materialID, textMatrix, - (dgCollisionCompoundFractured::OnEmitFractureChunkCallBack) emitFracfuredChunk, - (dgCollisionCompoundFractured::OnEmitNewCompundFractureCallBack) emitFracturedCompound, - (dgCollisionCompoundFractured::OnReconstructFractureMainMeshCallBack) regenerateMainMeshCallback); - return (NewtonCollision*) collision; -} - -NewtonCollision* NewtonFracturedCompoundPlaneClip (const NewtonCollision* const fracturedCompound, const dFloat* const plane) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) fracturedCompound; - - if (collision->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) collision->GetChildShape(); - dgWorld* const world = (dgWorld*)collision->GetWorld(); - dgCollisionCompoundFractured* const newCompound = compound->PlaneClip(dgVector (plane[0], plane[1], plane[2], plane[3])); - if (newCompound) { - dgCollisionInstance* const newCollision = world->CreateInstance (newCompound, int (collision->GetUserDataID()), dgGetIdentityMatrix()); - newCompound->Release(); - return (NewtonCollision*)newCollision; - } - } - return NULL; -} - -void NewtonFracturedCompoundSetCallbacks (const NewtonCollision* const fracturedCompound, - NewtonFractureCompoundCollisionReconstructMainMeshCallBack regenerateMainMeshCallback, - NewtonFractureCompoundCollisionOnEmitCompoundFractured emitFracturedCompound, NewtonFractureCompoundCollisionOnEmitChunk emitFracfuredChunk) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) fracturedCompound; - - if (collision->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) collision->GetChildShape(); - compound->SetCallbacks ((dgCollisionCompoundFractured::OnEmitFractureChunkCallBack) emitFracfuredChunk, (dgCollisionCompoundFractured::OnEmitNewCompundFractureCallBack) emitFracturedCompound, (dgCollisionCompoundFractured::OnReconstructFractureMainMeshCallBack) regenerateMainMeshCallback); - } -} - - -int NewtonFracturedCompoundNeighborNodeList (const NewtonCollision* const fracturedCompound, void* const collisionNode, void** const nodesArray, int maxCount) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) fracturedCompound; - if (collision->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) collision->GetChildShape(); - return compound->GetFirstNiegborghArray ((dgCollisionCompound::dgTreeArray::dgTreeNode*)collisionNode, (dgCollisionCompound::dgTreeArray::dgTreeNode**) nodesArray, maxCount); - } - return 0; -} - - - -int NewtonFracturedCompoundIsNodeFreeToDetach (const NewtonCollision* const fracturedCompound, void* const collisionNode) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) fracturedCompound; - - if (collision->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) collision->GetChildShape(); - return compound->IsNodeSaseToDetach((dgCollisionCompound::dgTreeArray::dgTreeNode*)collisionNode) ? 1 : 0; - } - return 0; -} - -NewtonFracturedCompoundMeshPart* NewtonFracturedCompoundGetFirstSubMesh(const NewtonCollision* const fracturedCompound) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) fracturedCompound; - - NewtonFracturedCompoundMeshPart* mesh = NULL; - if (collision->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) collision->GetChildShape(); - mesh = (NewtonFracturedCompoundMeshPart*) compound->GetFirstMesh(); - } - return mesh; -} - -NewtonFracturedCompoundMeshPart* NewtonFracturedCompoundGetNextSubMesh(const NewtonCollision* const fracturedCompound, NewtonFracturedCompoundMeshPart* const subMesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) fracturedCompound; - - NewtonFracturedCompoundMeshPart* mesh = NULL; - if (collision->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) collision->GetChildShape(); - mesh = (NewtonFracturedCompoundMeshPart*) compound->GetNextMesh((dgCollisionCompoundFractured::dgConectivityGraph::dgListNode*) subMesh); - } - return mesh; -} - -NewtonFracturedCompoundMeshPart* NewtonFracturedCompoundGetMainMesh (const NewtonCollision* const fracturedCompound) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) fracturedCompound; - - NewtonFracturedCompoundMeshPart* mesh = NULL; - if (collision->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) collision->GetChildShape(); - mesh = (NewtonFracturedCompoundMeshPart*) compound->GetMainMesh(); - } - return mesh; -} - - -int NewtonFracturedCompoundCollisionGetVertexCount (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) fracturedCompound; - - dgInt32 count = 0; - if (collision->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) collision->GetChildShape(); - count = compound->GetVertecCount((dgCollisionCompoundFractured::dgConectivityGraph::dgListNode*) meshOwner); - } - return count; -} - - -const dFloat* NewtonFracturedCompoundCollisionGetVertexPositions (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) fracturedCompound; - - const dgFloat32* points = NULL; - if (collision->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) collision->GetChildShape(); - points = compound->GetVertexPositions((dgCollisionCompoundFractured::dgConectivityGraph::dgListNode*) meshOwner); - } - return points; -} - - -const dFloat* NewtonFracturedCompoundCollisionGetVertexNormals (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) fracturedCompound; - - const dgFloat32* points = NULL; - if (collision->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) collision->GetChildShape(); - points = compound->GetVertexNormal((dgCollisionCompoundFractured::dgConectivityGraph::dgListNode*) meshOwner); - } - return points; -} - -const dFloat* NewtonFracturedCompoundCollisionGetVertexUVs (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) fracturedCompound; - - const dgFloat32* points = NULL; - if (collision->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) collision->GetChildShape(); - points = compound->GetVertexUVs((dgCollisionCompoundFractured::dgConectivityGraph::dgListNode*) meshOwner); - } - return points; -} - -int NewtonFracturedCompoundMeshPartGetIndexStream (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner, const void* const segment, int* const index) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgInt32 count = 0; - dgCollisionInstance* const collision = (dgCollisionInstance*) fracturedCompound; - if (collision->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) collision; - count = compound->GetSegmentIndexStream ((dgCollisionCompoundFractured::dgConectivityGraph::dgListNode*) meshOwner, (dgCollisionCompoundFractured::dgMesh::dgListNode*) segment, index); - } - return count; -} - - -void* NewtonFracturedCompoundMeshPartGetFirstSegment (const NewtonFracturedCompoundMeshPart* const breakableComponentMesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionCompoundFractured::dgConectivityGraph::dgListNode* const node = (dgCollisionCompoundFractured::dgConectivityGraph::dgListNode*) breakableComponentMesh; - return node->GetInfo().m_nodeData.m_mesh->GetFirst(); -} - -void* NewtonFracturedCompoundMeshPartGetNextSegment (const void* const breakableComponentSegment) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionCompoundFractured::dgMesh::dgListNode* const node = (dgCollisionCompoundFractured::dgMesh::dgListNode*) breakableComponentSegment; - return node->GetNext(); -} - -int NewtonFracturedCompoundMeshPartGetMaterial (const void* const segment) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgCollisionCompoundFractured::dgMesh::dgListNode* const node = (dgCollisionCompoundFractured::dgMesh::dgListNode*) segment; - return node->GetInfo().m_material; -} - - -int NewtonFracturedCompoundMeshPartGetIndexCount (const void* const segment) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgCollisionCompoundFractured::dgMesh::dgListNode* const node = (dgCollisionCompoundFractured::dgMesh::dgListNode*) segment; - return node->GetInfo().m_faceCount * 3; -} - - - - - -// Return the trigger volume flag of this shape. -// -// @param convexCollision is the pointer to a convex collision primitive. -// -// @return 0 if collision shape is solid, non zero is collision shape is a trigger volume. -// -// this function can be used to place collision triggers in the scene. -// Setting this flag is not really a necessary to place a collision trigger however this option hint the engine that -// this particular shape is a trigger volume and no contact calculation is desired. -int NewtonCollisionGetMode(const NewtonCollision* const convexCollision) -{ - dgCollisionInstance* const collision = (dgCollisionInstance*) convexCollision; - TRACE_FUNCTION(__FUNCTION__); - return collision->GetCollisionMode() ? 1 : 0; -} - - -// Set a flag on a convex collision shape to indicate that no contacts should calculated for this shape. -// -// @param convexCollision is the pointer to a convex collision primitive. -// @param triggerMode 1 disable contact calculation, 0 enable contact calculation. -// -// @return nothing -// -// this function can be used to place collision triggers in the scene. -// Setting this flag is not really a necessary to place a collision trigger however this option hint the engine that -// this particular shape is a trigger volume and no contact calculation is desired. -// -void NewtonCollisionSetMode (const NewtonCollision* const convexCollision, int mode) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) convexCollision; - collision->SetCollisionMode(mode ? true : false); -} - -/* -void NewtonCollisionSetMaxBreakImpactImpulse(const NewtonCollision* const convexHullCollision, dFloat maxImpactImpulse) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) convexHullCollision; - collision->SetBreakImpulse(dgFloat32 (maxImpactImpulse)); -} - -dFloat NewtonCollisionGetMaxBreakImpactImpulse(const NewtonCollision* const convexHullCollision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) convexHullCollision; - return dgFloat32 (collision->GetBreakImpulse()); -} -*/ - -int NewtonConvexHullGetVertexData (const NewtonCollision* const convexHullCollision, dFloat** const vertexData, int* strideInBytes) -{ - dgAssert (0); - return 0; -} - - -/*! - Return the number of vertices of face and copy each index into array faceIndices. - - @param convexHullCollision is the pointer to a convex collision hull primitive. - @param face fixme - @param faceIndices fixme - - @return user face count of face. - - this function will return zero on all shapes other than a convex full collision shape. - - To get the number of faces of a convex hull shape see function *NewtonCollisionGetInfo* - - See also: ::NewtonCollisionGetInfo, ::NewtonCreateConvexHull -*/ -int NewtonConvexHullGetFaceIndices(const NewtonCollision* const convexHullCollision, int face, int* const faceIndices) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const coll = (dgCollisionInstance*) convexHullCollision; - - if (coll->IsType (dgCollision::dgCollisionConvexHull_RTTI)) { - //return ((dgCollisionConvexHull*)coll)->GetFaceIndices (face, faceIndices); - return ((dgCollisionConvexHull*)coll->GetChildShape())->GetFaceIndices (face, faceIndices); - } else { - return 0; - } -} - -/*! - calculate the total volume defined by a convex collision geometry. - - @param *convexCollision pointer to the collision. - - @return collision geometry volume. This function will return zero if the body collision geometry is no convex. - - The total volume calculated by the function is only an approximation of the ideal volume. This is not an error, it is a fact resulting from the polygonal representation of convex solids. - - This function can be used to assist the application in calibrating features like fluid density weigh factor when calibrating buoyancy forces for more realistic result. -*/ -dFloat NewtonConvexCollisionCalculateVolume(const NewtonCollision* const convexCollision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*)convexCollision; - return collision->GetVolume(); -} - - -/*! - Calculate the three principal axis and the the values of the inertia matrix of a convex collision objects. - - @param convexCollision is the pointer to a convex collision primitive. - @param *inertia pointer to and array of a least 3 floats to hold the values of the principal inertia. - @param *origin pointer to and array of a least 3 floats to hold the values of the center of mass for the principal inertia. - - This function calculate a general inertial matrix for arbitrary convex collision including compound collisions. - - See also: ::NewtonBodySetMassMatrix, ::NewtonBodyGetMass, ::NewtonBodySetCentreOfMass, ::NewtonBodyGetCentreOfMass -*/ -void NewtonConvexCollisionCalculateInertialMatrix(const NewtonCollision* convexCollision, dFloat* const inertia, dFloat* const origin) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*)convexCollision; - -// dgVector tmpInertia; -// dgVector tmpOringin; -// collision->CalculateInertia(tmpInertia, tmpOringin); - dgMatrix tmpInertia (collision->CalculateInertia()); - - inertia[0] = tmpInertia[0][0]; - inertia[1] = tmpInertia[1][1]; - inertia[2] = tmpInertia[2][2]; - origin[0] = tmpInertia[3][0]; - origin[1] = tmpInertia[3][1]; - origin[2] = tmpInertia[3][2]; -} - - -/*! - Add buoyancy force and torque for bodies immersed in a fluid. - - @param convexCollision fixme - @param matrix fixme - @param fluidPlane fixme - @param centerOfBuoyancy fixme - - @return Nothing. - - This function is only effective when called from *NewtonApplyForceAndTorque callback* - - This function adds buoyancy force and torque to a body when it is immersed in a fluid. - The force is calculated according to Archimedes Buoyancy Principle. When the parameter *buoyancyPlane* is set to NULL, the body is considered - to completely immersed in the fluid. This can be used to simulate boats and lighter than air vehicles etc.. - - If *buoyancyPlane* return 0 buoyancy calculation for this collision primitive is ignored, this could be used to filter buoyancy calculation - of compound collision geometry with different IDs. - - See also: ::NewtonConvexCollisionCalculateVolume -*/ -//void NewtonConvexCollisionCalculateBuoyancyAcceleration (const NewtonCollision* const convexCollision, const dFloat* const matrix, const dFloat* const shapeOrigin, const dFloat* const gravityVector, const dFloat* const fluidPlane, dFloat fluidDensity, dFloat* const accel, dFloat* const alpha) -dFloat NewtonConvexCollisionCalculateBuoyancyVolume (const NewtonCollision* const convexCollision, const dFloat* const matrix, const dFloat* const fluidPlane, dFloat* const centerOfBuoyancy) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*)convexCollision; - dgVector plane (fluidPlane[0], fluidPlane[1], fluidPlane[2], fluidPlane[3]); - - dgVector com (instance->CalculateBuoyancyVolume (dgMatrix (matrix), plane)); - centerOfBuoyancy[0] = com[0]; - centerOfBuoyancy[1] = com[1]; - centerOfBuoyancy[2] = com[2]; - return com.m_w; -} - -const void* NewtonCollisionDataPointer (const NewtonCollision* const convexCollision) -{ - dgCollisionInstance* const coll = (dgCollisionInstance*) convexCollision; - return coll->GetChildShape(); -} - -/*! @} */ // end of CshapesConvexSimple - -/*! @defgroup CshapesConvexComplex CshapesConvexComplex -Complex collision primitives interface -@{ -*/ - - -/*! - Create a complex collision geometry to be controlled by the application. - - @param *newtonWorld Pointer to the Newton world. - @param *minBox pointer to an array of at least three floats to hold minimum value for the box relative to the collision. - @param *maxBox pointer to an array of at least three floats to hold maximum value for the box relative to the collision. - @param *userData pointer to user data to be used as context for event callback. - @param collideCallback pointer to an event function for providing Newton with the polygon inside a given box region. - @param rayHitCallback pointer to an event function for providing Newton with ray intersection information. - @param destroyCallback pointer to an event function for destroying any data allocated for use by the application. - @param getInfoCallback fixme - @param getAABBOverlapTestCallback fixme - @param facesInAABBCallback fixme - @param serializeCallback fixme - @param shapeID fixme - - @return Pointer to the user collision. - - *UserMeshCollision* provides the application with a method of overloading the built-in collision system for background objects. - UserMeshCollision can be used for implementing collisions with height maps, collisions with BSP, and any other collision structure the application - supports and wishes to preserve. - However, *UserMeshCollision* can not take advantage of the efficient and sophisticated algorithms and data structures of the - built-in *TreeCollision*. We suggest you experiment with both methods and use the method best suited to your situation. - - When a *UserMeshCollision* is assigned to a body, the mass of the body is ignored in all dynamics calculations. - This make the body behave as a static body. - -*/ -NewtonCollision* NewtonCreateUserMeshCollision( - const NewtonWorld* const newtonWorld, - const dFloat* const minBox, - const dFloat* const maxBox, - void* const userData, - NewtonUserMeshCollisionCollideCallback collideCallback, - NewtonUserMeshCollisionRayHitCallback rayHitCallback, - NewtonUserMeshCollisionDestroyCallback destroyCallback, - NewtonUserMeshCollisionGetCollisionInfo getInfoCallback, - NewtonUserMeshCollisionAABBTest getAABBOverlapTestCallback, - NewtonUserMeshCollisionGetFacesInAABB facesInAABBCallback, - NewtonOnUserCollisionSerializationCallback serializeCallback, - int shapeID) -{ - TRACE_FUNCTION(__FUNCTION__); - dgVector p0 (minBox[0], minBox[1], minBox[2], dgFloat32(1.0f)); - dgVector p1 (maxBox[0], maxBox[1], maxBox[2], dgFloat32(1.0f)); - - Newton* const world = (Newton *)newtonWorld; - - dgUserMeshCreation data; - data.m_userData = userData; - data.m_collideCallback = (dgCollisionUserMesh::OnUserMeshCollideCallback) collideCallback; - data.m_rayHitCallback = (dgCollisionUserMesh::OnUserMeshRayHitCallback) rayHitCallback; - data.m_destroyCallback = (dgCollisionUserMesh::OnUserMeshDestroyCallback) destroyCallback; - data.m_getInfoCallback = (dgCollisionUserMesh::OnUserMeshCollisionInfo)getInfoCallback; - data.m_getAABBOvelapTestCallback = (dgCollisionUserMesh::OnUserMeshAABBOverlapTest) getAABBOverlapTestCallback; - data.m_faceInAABBCallback = (dgCollisionUserMesh::OnUserMeshFacesInAABB) facesInAABBCallback; - data.m_serializeCallback = (dgCollisionUserMesh::OnUserMeshSerialize) serializeCallback; - - - dgCollisionInstance* const collision = world->CreateStaticUserMesh (p0, p1, data); - collision->SetUserDataID(dgUnsigned32 (shapeID)); - return (NewtonCollision*)collision; -} - - - -int NewtonUserMeshCollisionContinuousOverlapTest (const NewtonUserMeshCollisionCollideDesc* const collideDescData, const void* const rayHandle, const dFloat* const minAabb, const dFloat* const maxAabb) -{ - const dgFastRayTest* const ray = (dgFastRayTest*) rayHandle; - - dgVector p0 (minAabb); - dgVector p1 (maxAabb); - - dgVector q0 (collideDescData->m_boxP0); - dgVector q1 (collideDescData->m_boxP1); - - p0 = p0 & dgVector::m_triplexMask; - p1 = p1 & dgVector::m_triplexMask; - q0 = q0 & dgVector::m_triplexMask; - q1 = q1 & dgVector::m_triplexMask; - - dgVector box0 (p0 - q1); - dgVector box1 (p1 - q0); - - dgFloat32 dist = ray->BoxIntersect(box0, box1); - return (dist < dgFloat32 (1.0f)) ? 1 : 0; -} - - - -/*! - Create an empty complex collision geometry tree. - - @param *newtonWorld Pointer to the Newton world. - @param shapeID fixme - - @return Pointer to the collision tree. - - *TreeCollision* is the preferred method within Newton for collision with polygonal meshes of arbitrary complexity. - The mesh must be made of flat non-intersecting polygons, but they do not explicitly need to be triangles. - *TreeCollision* can be serialized by the application to/from an arbitrary storage device. - - When a *TreeCollision* is assigned to a body the mass of the body is ignored in all dynamics calculations. - This makes the body behave as a static body. - - See also: ::NewtonTreeCollisionBeginBuild, ::NewtonTreeCollisionAddFace, ::NewtonTreeCollisionEndBuild, ::NewtonStaticCollisionSetDebugCallback, ::NewtonTreeCollisionGetFaceAttribute, ::NewtonTreeCollisionSetFaceAttribute -*/ -NewtonCollision* NewtonCreateTreeCollision(const NewtonWorld* const newtonWorld, int shapeID) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgCollisionInstance* const collision = world->CreateBVH (); - collision->SetUserDataID(dgUnsigned32 (shapeID)); - return (NewtonCollision*) collision; -} - - -NewtonCollision* NewtonCreateTreeCollisionFromMesh (const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, int shapeID) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - dgCollisionInstance* const collision = meshEffect->CreateCollisionTree(world, shapeID); - return (NewtonCollision*) collision; -} - - -/*! - set a function call back to be call during the face query of a collision tree. - - @param *staticCollision is the pointer to the static collision (a CollisionTree of a HeightFieldCollision) - @param *userCallback pointer to an event function to call before Newton evaluates the polygons colliding with a body. This parameter can be NULL. - - because debug display display report all the faces of a collision primitive, it could get slow on very large static collision. - this function can be used for debugging purpose to just report only faces intersection the collision AABB of the collision shape colliding with the polyginal mesh collision. - - this function is not recommended to use for production code only for debug purpose. - - See also: ::NewtonTreeCollisionGetFaceAttribute, ::NewtonTreeCollisionSetFaceAttribute -*/ -void NewtonStaticCollisionSetDebugCallback(const NewtonCollision* const staticCollision, NewtonTreeCollisionCallback userCallback) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*)staticCollision; - if (collision->IsType (dgCollision::dgCollisionMesh_RTTI)) { - dgCollisionMesh* const mesh = (dgCollisionMesh*) collision->GetChildShape(); - mesh->SetDebugCollisionCallback ((dgCollisionMeshCollisionCallback) userCallback); - } - -} - -/*! - set a function call back to be called during the face query of a collision tree. - - @param *treeCollision is the pointer to the collision tree. - @param rayHitCallback pointer to an event function for providing Newton with ray intersection information. - - In general a ray cast on a collision tree will stops at the first intersections with the closest face in the tree - that was hit by the ray. In some cases the application may be interested in the intesation with faces other than the fiorst hit. - In this cases the application can set this alternate callback and the ray scanner will notify the application of each face hit by the ray scan. - - since this function faces the ray scanner to visit all of the potential faces intersected by the ray, - setting the function call back make the ray casting on collision tree less efficient than the default behavior. - So it is this functionality is only recommended for cases were the application is using especial effects like transparencies, or other effects - - calling this function with *rayHitCallback* = NULL will rest the collision tree to it default raycast mode, which is return with the closest hit. - - when *rayHitCallback* is not null then the callback is dalled with the follwing arguments - *const NewtonCollisio* collision - pointer to the collision tree - interseption - inetstion parameters of the ray - *normal - unnormalized face mormal in the space fo eth parent of the collision. - faceId - id of this face in the collision tree. - - See also: ::NewtonTreeCollisionGetFaceAttribute, ::NewtonTreeCollisionSetFaceAttribute -*/ -void NewtonTreeCollisionSetUserRayCastCallback(const NewtonCollision* const treeCollision, NewtonCollisionTreeRayCastCallback rayHitCallback) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*)treeCollision; -// dgCollisionBVH* const collision = (dgCollisionBVH*) treeCollision; - if (collision->IsType (dgCollision::dgCollisionBVH_RTTI)) { - dgCollisionBVH* const shape = (dgCollisionBVH*) collision->GetChildShape(); - shape->SetCollisionRayCastCallback ((dgCollisionBVHUserRayCastCallback) rayHitCallback); - } -} - - -void NewtonHeightFieldSetUserRayCastCallback (const NewtonCollision* const heightField, NewtonHeightFieldRayCastCallback rayHitCallback) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*)heightField; - if (collision->IsType (dgCollision::dgCollisionHeightField_RTTI)) { - dgCollisionHeightField* const shape = (dgCollisionHeightField*) collision->GetChildShape(); - shape->SetCollisionRayCastCallback ((dgCollisionHeightFieldRayCastCallback) rayHitCallback); - } -} - -/*! - Prepare a *TreeCollision* to begin to accept the polygons that comprise the collision mesh. - - @param *treeCollision is the pointer to the collision tree. - - @return Nothing. - - See also: ::NewtonTreeCollisionAddFace, ::NewtonTreeCollisionEndBuild -*/ -void NewtonTreeCollisionBeginBuild(const NewtonCollision* const treeCollision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionBVH* const collision = (dgCollisionBVH*) ((dgCollisionInstance*)treeCollision)->GetChildShape(); - dgAssert (collision->IsType (dgCollision::dgCollisionBVH_RTTI)); - - collision->BeginBuild(); -} - -/*! - Add an individual polygon to a *TreeCollision*. - - @param *treeCollision is the pointer to the collision tree. - @param vertexCount number of vertex in *vertexPtr* - @param *vertexPtr pointer to an array of vertex. The vertex should consist of at least 3 floats each. - @param strideInBytes size of each vertex in bytes. This value should be 12 or larger. - @param faceAttribute id that identifies the polygon. The application can use this value to customize the behavior of the collision geometry. - - @return Nothing. - - After the call to *NewtonTreeCollisionBeginBuild* the *TreeCollision* is ready to accept polygons. The application should iterate - through the application's mesh, adding the mesh polygons to the *TreeCollision* one at a time. - The polygons must be flat and non-self intersecting. - - See also: ::NewtonTreeCollisionAddFace, ::NewtonTreeCollisionEndBuild -*/ -void NewtonTreeCollisionAddFace(const NewtonCollision* const treeCollision, int vertexCount, const dFloat* const vertexPtr, int strideInBytes, int faceAttribute) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionBVH* const collision = (dgCollisionBVH*) ((dgCollisionInstance*)treeCollision)->GetChildShape(); - dgAssert (collision->IsType (dgCollision::dgCollisionBVH_RTTI)); - collision->AddFace(vertexCount, vertexPtr, strideInBytes, faceAttribute); -} - -/*! - Finalize the construction of the polygonal mesh. - - @param *treeCollision is the pointer to the collision tree. - @param optimize flag that indicates to Newton whether it should optimize this mesh. Set to 1 to optimize the mesh, otherwise 0. - - @return Nothing. - - - After the application has finished adding polygons to the *TreeCollision*, it must call this function to finalize the construction of the collision mesh. - If concave polygons are added to the *TreeCollision*, the application must call this function with the parameter *optimize* set to 1. - With the *optimize* parameter set to 1, Newton will optimize the collision mesh by removing non essential edges from adjacent flat polygons. - Newton will not change the topology of the mesh but significantly reduces the number of polygons in the mesh. The reduction factor of the number of polygons in the mesh depends upon the irregularity of the mesh topology. - A reduction factor of 1.5 to 2.0 is common. - Calling this function with the parameter *optimize* set to zero, will leave the mesh geometry unaltered. - - See also: ::NewtonTreeCollisionAddFace, ::NewtonTreeCollisionEndBuild -*/ -void NewtonTreeCollisionEndBuild(const NewtonCollision* const treeCollision, int optimize) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionBVH* const collision = (dgCollisionBVH*) ((dgCollisionInstance*)treeCollision)->GetChildShape(); - dgAssert (collision->IsType (dgCollision::dgCollisionBVH_RTTI)); - collision->EndBuild(optimize); -} - - -/*! - Get the user defined collision attributes stored with each face of the collision mesh. - - @param treeCollision fixme - @param *faceIndexArray pointer to the face index list passed to the function *NewtonTreeCollisionCallback userCallback - @param indexCount fixme - - @return User id of the face. - - This function is used to obtain the user data stored in faces of the collision geometry. - The application can use this user data to achieve per polygon material behavior in large static collision meshes. - - See also: ::NewtonTreeCollisionSetFaceAttribute, ::NewtonCreateTreeCollision -*/ -int NewtonTreeCollisionGetFaceAttribute(const NewtonCollision* const treeCollision, const int* const faceIndexArray, int indexCount) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionBVH* const collision = (dgCollisionBVH*) ((dgCollisionInstance*)treeCollision)->GetChildShape(); - dgAssert (collision->IsType (dgCollision::dgCollisionBVH_RTTI)); - - return int (collision->GetTagId (faceIndexArray, indexCount)); -} - -/*! - Change the user defined collision attribute stored with faces of the collision mesh. - - @param *treeCollision fixme - @param *faceIndexArray pointer to the face index list passed to the NewtonTreeCollisionCallback function - @param indexCount fixme - @param attribute value of the user defined attribute to be stored with the face. - - @return User id of the face. - - This function is used to obtain the user data stored in faces of the collision geometry. - The application can use this user data to achieve per polygon material behavior in large static collision meshes. - By changing the value of this user data the application can achieve modifiable surface behavior with the collision geometry. - For example, in a driving game, the surface of a polygon that represents the street can changed from pavement to oily or wet after - some collision event occurs. - - See also: ::NewtonTreeCollisionGetFaceAttribute, ::NewtonCreateTreeCollision -*/ -void NewtonTreeCollisionSetFaceAttribute(const NewtonCollision* const treeCollision, const int* const faceIndexArray, int indexCount, int attribute) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionBVH* const collision = (dgCollisionBVH*) ((dgCollisionInstance*)treeCollision)->GetChildShape(); - dgAssert (collision->IsType (dgCollision::dgCollisionBVH_RTTI)); - - collision->SetTagId (faceIndexArray, indexCount, dgUnsigned32 (attribute)); -} - -void NewtonTreeCollisionForEachFace (const NewtonCollision* const treeCollision, NewtonTreeCollisionFaceCallback forEachFaceCallback, void* const context) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionBVH* const collision = (dgCollisionBVH*) ((dgCollisionInstance*)treeCollision)->GetChildShape(); - dgAssert (collision->IsType (dgCollision::dgCollisionBVH_RTTI)); - - collision->ForEachFace ((dgAABBIntersectCallback) forEachFaceCallback, context); -} - - - -/*! - collect the vertex list index list mesh intersecting the AABB in collision mesh. - - @param *treeCollision fixme - @param *p0 - pointer to an array of at least three floats representing the ray origin in the local space of the geometry. - @param *p1 - pointer to an array of at least three floats representing the ray end in the local space of the geometry. - @param **vertexArray pointer to a the vertex array of vertex. - @param *vertexCount pointer int to return the number of vertex in vertexArray. - @param *vertexStrideInBytes pointer to int to return the size of each vertex in vertexArray. - @param *indexList pointer to array on integers containing the triangles intersection the aabb. - @param maxIndexCount maximum number of indices the function will copy to indexList. - @param *faceAttribute pointer to array on integers top contain the face containing the . - - @return the number of triangles in indexList. - - indexList should be a list 3 * maxIndexCount the number of elements. - - faceAttributet should be a list maxIndexCount the number of elements. - - this function could be used by the application for many purposes. - for example it can be used to draw the collision geometry intersecting a collision primitive instead - of drawing the entire collision tree in debug mode. - Another use for this function is to to efficient draw projective texture shadows. -*/ -int NewtonTreeCollisionGetVertexListTriangleListInAABB(const NewtonCollision* const treeCollision, const dFloat* const p0, const dFloat* const p1, - const dFloat** const vertexArray, int* const vertexCount, int* const vertexStrideInBytes, - const int* const indexList, int maxIndexCount, const int* const faceAttribute) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgInt32 count = 0; - dgCollisionInstance* meshColl = (dgCollisionInstance*) treeCollision; - if (meshColl->IsType (dgCollision::dgCollisionMesh_RTTI)) { - dgCollisionMesh* const collision = (dgCollisionMesh*) ((dgCollisionInstance*)treeCollision)->GetChildShape(); - - dgVector pmin (p0[0], p0[1], p0[2], dgFloat32 (0.0f)); - dgVector pmax (p1[0], p1[1], p1[2], dgFloat32 (0.0f)); - - dgCollisionMesh::dgMeshVertexListIndexList data; - data.m_indexList = (dgInt32 *)indexList; - data.m_userDataList = (dgInt32 *)faceAttribute; - data.m_maxIndexCount = maxIndexCount; - data.m_triangleCount = 0; - collision->GetVertexListIndexList (pmin, pmax, data); - - count = data.m_triangleCount; - *vertexArray = data.m_veterxArray; - *vertexCount = data.m_vertexCount; - *vertexStrideInBytes = data.m_vertexStrideInBytes; - } - return count; -} - - -/*! - Create a height field collision geometry. - - @param *newtonWorld Pointer to the Newton world. - @param width the number of sample points in the x direction (fixme) - @param height the number of sample points in the y direction (fixme) - @param gridsDiagonals fixme - @param elevationdatType fixme - @param elevationMap array holding elevation data of size = width*height (fixme) - @param attributeMap array holding attribute data of size = width*height (fixme) - @param verticalScale scale of the elevation (fixme) - @param horizontalScale scale in the xy direction. (fixme) - @param shapeID fixme - - @return Pointer to the collision. - - NewtonCollision* NewtonCreateHeightFieldCollision(const NewtonWorld* const newtonWorld, int width, int height, int cellsDiagonals, - const dFloat* const elevationMap, const char* const atributeMap, - dFloat horizontalScale, int shapeID) -*/ - NewtonCollision* NewtonCreateHeightFieldCollision (const NewtonWorld* const newtonWorld, int width, int height, int gridsDiagonals, dgInt32 elevationdatType, - const void* const elevationMap, const char* const attributeMap, dFloat verticalScale, dFloat horizontalScale_x, dFloat horizontalScale_z, int shapeID) -{ - Newton* const world = (Newton *)newtonWorld; - - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = world->CreateHeightField(width, height, gridsDiagonals, elevationdatType, elevationMap, (const dgInt8* const) attributeMap, verticalScale, horizontalScale_x, horizontalScale_z); - collision->SetUserDataID(dgUnsigned32 (shapeID)); - return (NewtonCollision*) collision; -} - - - -/*! - Create a height field collision geometry. - - @param *newtonWorld Pointer to the Newton world. - @param shapeID fixme - - @return Pointer to the collision. - -*/ -NewtonCollision* NewtonCreateSceneCollision (const NewtonWorld* const newtonWorld, int shapeID) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - - dgCollisionInstance* const collision = world->CreateScene (); - - collision->SetUserDataID(dgUnsigned32 (shapeID)); - return (NewtonCollision*) collision; -} - - -void NewtonSceneCollisionBeginAddRemove (NewtonCollision* const sceneCollision) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonCompoundCollisionBeginAddRemove (sceneCollision); -} - -void NewtonSceneCollisionEndAddRemove (NewtonCollision* const sceneCollision) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonCompoundCollisionEndAddRemove (sceneCollision); -} - - -void NewtonSceneCollisionSetSubCollisionMatrix (NewtonCollision* const sceneCollision, const void* const collisionNode, const dFloat* const matrix) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonCompoundCollisionSetSubCollisionMatrix (sceneCollision, collisionNode, matrix); -} - - -void* NewtonSceneCollisionAddSubCollision (NewtonCollision* const sceneCollision, const NewtonCollision* const collision) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgCollisionInstance* const sceneInstance = (dgCollisionInstance*) sceneCollision; - dgCollisionInstance* const sceneInstanceChild = (dgCollisionInstance*) collision; - if (sceneInstance->IsType (dgCollision::dgCollisionScene_RTTI) && !sceneInstanceChild->IsType(dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionScene* const collision1 = (dgCollisionScene*) sceneInstance->GetChildShape(); - return collision1->AddCollision (sceneInstanceChild); - } - return NULL; -} - -void NewtonSceneCollisionRemoveSubCollision (NewtonCollision* const sceneCollision, const void* const collisionNode) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const sceneInstance = (dgCollisionInstance*) sceneCollision; - if (sceneInstance->IsType (dgCollision::dgCollisionScene_RTTI)) { - dgCollisionScene* const collision = (dgCollisionScene*) sceneInstance->GetChildShape(); - dgCollisionInstance* const childCollision = collision->GetCollisionFromNode((dgCollisionCompound::dgTreeArray::dgTreeNode*)collisionNode); - if (childCollision) { - collision->RemoveCollision ((dgCollisionCompound::dgTreeArray::dgTreeNode*)collisionNode); - } - } -} - -void NewtonSceneCollisionRemoveSubCollisionByIndex (NewtonCollision* const sceneCollision, int nodeIndex) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) sceneCollision; - if (instance->IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgCollisionCompound* const collision = (dgCollisionCompound*) instance->GetChildShape(); - NewtonSceneCollisionRemoveSubCollision (sceneCollision, collision->FindNodeByIndex(nodeIndex)); - } -} - - -void* NewtonSceneCollisionGetNodeByIndex (NewtonCollision* const sceneCollision, int index) -{ - TRACE_FUNCTION(__FUNCTION__); - return NewtonCompoundCollisionGetNodeByIndex (sceneCollision, index); -} - -int NewtonSceneCollisionGetNodeIndex (NewtonCollision* const sceneCollision, const void* const collisionNode) -{ - TRACE_FUNCTION(__FUNCTION__); - return NewtonCompoundCollisionGetNodeIndex (sceneCollision, collisionNode); -} - - -NewtonCollision* NewtonSceneCollisionGetCollisionFromNode (NewtonCollision* const sceneCollision, const void* const node) -{ - TRACE_FUNCTION(__FUNCTION__); - return NewtonCompoundCollisionGetCollisionFromNode (sceneCollision, node); -} - -void* NewtonSceneCollisionGetFirstNode (NewtonCollision* const sceneCollision) -{ - TRACE_FUNCTION(__FUNCTION__); - return NewtonCompoundCollisionGetFirstNode (sceneCollision); -} - -void* NewtonSceneCollisionGetNextNode (NewtonCollision* const sceneCollision, const void* const node) -{ - TRACE_FUNCTION(__FUNCTION__); - return NewtonCompoundCollisionGetNextNode (sceneCollision, node); -} - - -/*! @} */ // end of CshapesConvexComples - - -/*! @defgroup CollisionLibraryGeneric CollisionLibraryGeneric -Generic collision library functions -@{ -*/ - -/*! - Calculate the closest point between a point and convex collision primitive. - - @param *newtonWorld Pointer to the Newton world. - @param *point pointer to and array of a least 3 floats representing the origin. - @param *collision pointer to collision primitive. - @param *matrix pointer to an array of 16 floats containing the offset matrix of collision primitiveA. - @param *contact pointer to and array of a least 3 floats to contain the closest point to collisioA. - @param *normal pointer to and array of a least 3 floats to contain the separating vector normal. - @param threadIndex -Thread index form where the call is made from, zeor otherwize - - @return one if the two bodies are disjoint and the closest point could be found, - zero if the point is inside the convex primitive. - - This function can be used as a low-level building block for a stand-alone collision system. - Applications that have already there own physics system, and only want and quick and fast collision solution, - can use Newton advanced collision engine as the low level collision detection part. - To do this the application only needs to initialize Newton, create the collision primitives at application discretion, - and just call this function when the objects are in close proximity. Applications using Newton as a collision system - only, are responsible for implementing their own broad phase collision determination, based on any high level tree structure. - Also the application should implement their own trivial aabb test, before calling this function . - - the current implementation of this function do work on collision trees, or user define collision. - - See also: ::NewtonCollisionCollideContinue, ::NewtonCollisionClosestPoint, ::NewtonCollisionCollide, ::NewtonCollisionRayCast, ::NewtonCollisionCalculateAABB -*/ -int NewtonCollisionPointDistance(const NewtonWorld* const newtonWorld, const dFloat* const point, - const NewtonCollision* const collision, const dFloat* const matrix, - dFloat* const contact, dFloat* const normal, int threadIndex) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->ClosestPoint (*((dgTriplex*) point), (dgCollisionInstance*)collision, dgMatrix (matrix), *((dgTriplex*) contact), *((dgTriplex*) normal), threadIndex); -} - - -/*! - Calculate the closest points between two disjoint convex collision primitive. - - @param *newtonWorld Pointer to the Newton world. - @param *collisionA pointer to collision primitive A. - @param *matrixA pointer to an array of 16 floats containing the offset matrix of collision primitiveA. - @param *collisionB pointer to collision primitive B. - @param *matrixB pointer to an array of 16 floats containing the offset matrix of collision primitiveB. - @param *contactA pointer to and array of a least 3 floats to contain the closest point to collisionA. - @param *contactB pointer to and array of a least 3 floats to contain the closest point to collisionB. - @param *normalAB pointer to and array of a least 3 floats to contain the separating vector normal. - @param threadIndex -Thread index form where the call is made from, zeor otherwize - - @return one if the tow bodies are disjoint and he closest point could be found, - zero if the two collision primitives are intersecting. - - This function can be used as a low-level building block for a stand-alone collision system. - Applications that have already there own physics system, and only want and quick and fast collision solution, - can use Newton advanced collision engine as the low level collision detection part. - To do this the application only needs to initialize Newton, create the collision primitives at application discretion, - and just call this function when the objects are in close proximity. Applications using Newton as a collision system - only, are responsible for implementing their own broad phase collision determination, based on any high level tree structure. - Also the application should implement their own trivial aabb test, before calling this function . - - the current implementation of this function does not work on collision trees, or user define collision. - - See also: ::NewtonCollisionCollideContinue, ::NewtonCollisionPointDistance, ::NewtonCollisionCollide, ::NewtonCollisionRayCast, ::NewtonCollisionCalculateAABB -*/ -int NewtonCollisionClosestPoint(const NewtonWorld* const newtonWorld, - const NewtonCollision* const collisionA, const dFloat* const matrixA, - const NewtonCollision* const collisionB, const dFloat* const matrixB, - dFloat* const contactA, dFloat* const contactB, dFloat* const normalAB, int threadIndex) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->ClosestPoint ((dgCollisionInstance*)collisionA, dgMatrix (matrixA), - (dgCollisionInstance*)collisionB, dgMatrix (matrixB), - *((dgTriplex*) contactA), *((dgTriplex*) contactB), *((dgTriplex*) normalAB), threadIndex); -} - - -int NewtonCollisionIntersectionTest (const NewtonWorld* const newtonWorld, const NewtonCollision* const collisionA, const dFloat* const matrixA, const NewtonCollision* const collisionB, const dFloat* const matrixB, int threadIndex) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->IntersectionTest ((dgCollisionInstance*)collisionA, dgMatrix (matrixA), - (dgCollisionInstance*)collisionB, dgMatrix (matrixB), - threadIndex) ? 1 : 0; -} - - -/*! - Calculate contact points between two collision primitive. - - @param *newtonWorld Pointer to the Newton world. - @param maxSize size of maximum number of elements in contacts, normals, and penetration. - @param *collisionA pointer to collision primitive A. - @param *matrixA pointer to an array of 16 floats containing the offset matrix of collision primitiveA. - @param *collisionB pointer to collision primitive B. - @param *matrixB pointer to an array of 16 floats containing the offset matrix of collision primitiveB. - @param *contacts pointer to and array of a least 3 times maxSize floats to contain the collision contact points. - @param *normals pointer to and array of a least 3 times maxSize floats to contain the collision contact normals. - @param *penetration pointer to and array of a least maxSize floats to contain the collision penetration at each contact. - @param attributeA fixme - @param attributeB fixme - @param threadIndex Thread index form where the call is made from, zeor otherwize - - @return the number of contact points. - - This function can be used as a low-level building block for a stand-alone collision system. - Applications that have already there own physics system, and only want and quick and fast collision solution, - can use Newton advanced collision engine as the low level collision detection part. - To do this the application only needs to initialize Newton, create the collision primitives at application discretion, - and just call this function when the objects are in close proximity. Applications using Newton as a collision system - only, are responsible for implementing their own broad phase collision determination, based on any high level tree structure. - Also the application should implement their own trivial aabb test, before calling this function . - - See also: ::NewtonCollisionCollideContinue, ::NewtonCollisionClosestPoint, ::NewtonCollisionPointDistance, ::NewtonCollisionRayCast, ::NewtonCollisionCalculateAABB -*/ -int NewtonCollisionCollide (const NewtonWorld* const newtonWorld, int maxSize, - const NewtonCollision* const collisionA, const dFloat* const matrixA, - const NewtonCollision* const collisionB, const dFloat* const matrixB, - dFloat* const contacts, dFloat* const normals, dFloat* const penetration, - dLong* const attributeA, dLong* const attributeB, int threadIndex) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return world->Collide ((dgCollisionInstance*)collisionA, dgMatrix (matrixA), - (dgCollisionInstance*)collisionB, dgMatrix (matrixB), - (dgTriplex*) contacts, (dgTriplex*) normals, penetration, attributeA, attributeB, maxSize, threadIndex); -} - - - -/*! - Calculate time of impact of impact and contact points between two collision primitive. - - @param *newtonWorld Pointer to the Newton world. - @param maxSize size of maximum number of elements in contacts, normals, and penetration. - @param timestep maximum time interval considered for the continuous collision calculation. - @param *collisionA pointer to collision primitive A. - @param *matrixA pointer to an array of 16 floats containing the offset matrix of collision primitiveA. - @param *velocA pointer to and array of a least 3 times maxSize floats containing the linear velocity of collision primitiveA. - @param *omegaA pointer to and array of a least 3 times maxSize floats containing the angular velocity of collision primitiveA. - @param *collisionB pointer to collision primitive B. - @param *matrixB pointer to an array of 16 floats containing the offset matrix of collision primitiveB. - @param *velocB pointer to and array of a least 3 times maxSize floats containing the linear velocity of collision primitiveB. - @param *omegaB pointer to and array of a least 3 times maxSize floats containing the angular velocity of collision primitiveB. - @param *timeOfImpact pointer to least 1 float variable to contain the time of the intersection. - @param *contacts pointer to and array of a least 3 times maxSize floats to contain the collision contact points. - @param *normals pointer to and array of a least 3 times maxSize floats to contain the collision contact normals. - @param *penetration pointer to and array of a least maxSize floats to contain the collision penetration at each contact. - @param attributeA fixme - @param attributeB fixme - @param threadIndex -Thread index form where the call is made from, zeor otherwize - - @return the number of contact points. - - by passing zero as *maxSize* not contact will be calculated and the function will just determine the time of impact is any. - - if the body are inter penetrating the time of impact will be zero. - - if the bodies do not collide time of impact will be set to *timestep* - - This function can be used as a low-level building block for a stand-alone collision system. - Applications that have already there own physics system, and only want and quick and fast collision solution, - can use Newton advanced collision engine as the low level collision detection part. - To do this the application only needs to initialize Newton, create the collision primitives at application discretion, - and just call this function when the objects are in close proximity. Applications using Newton as a collision system - only, are responsible for implementing their own broad phase collision determination, based on any high level tree structure. - Also the application should implement their own trivial aabb test, before calling this function . - - See also: ::NewtonCollisionCollide, ::NewtonCollisionClosestPoint, ::NewtonCollisionPointDistance, ::NewtonCollisionRayCast, ::NewtonCollisionCalculateAABB -*/ -int NewtonCollisionCollideContinue(const NewtonWorld* const newtonWorld, int maxSize, dFloat timestep, - const NewtonCollision* const collisionA, const dFloat* const matrixA, const dFloat* const velocA, const dFloat* const omegaA, - const NewtonCollision* const collisionB, const dFloat* const matrixB, const dFloat* const velocB, const dFloat* const omegaB, - dFloat* const timeOfImpact, dFloat* const contacts, dFloat* const normals, dFloat* const penetration, - dLong* const attributeA, dLong* const attributeB, int threadIndex) -{ - Newton* const world = (Newton *)newtonWorld; - - *timeOfImpact = timestep; - - TRACE_FUNCTION(__FUNCTION__); - return world->CollideContinue ((dgCollisionInstance*)collisionA, dgMatrix (matrixA), *((dgVector*) velocA), *((dgVector*) omegaA), - (dgCollisionInstance*)collisionB, dgMatrix (matrixB), *((dgVector*) velocB), *((dgVector*) omegaB), - *timeOfImpact, (dgTriplex*) contacts, (dgTriplex*) normals, penetration, attributeA, attributeB, maxSize, threadIndex); -} - - -/*! - Calculate the most extreme point of a convex collision shape along the given direction. - - @param *collisionPtr pointer to the collision object. - @param *dir pointer to an array of at least three floats representing the search direction. - @param *vertex pointer to an array of at least three floats to hold the collision most extreme vertex along the search direction. - - @return nothing. - - the search direction must be in the space of the collision shape. - - See also: ::NewtonCollisionRayCast, ::NewtonCollisionClosestPoint, ::NewtonCollisionPointDistance -*/ -void NewtonCollisionSupportVertex(const NewtonCollision* const collisionPtr, const dFloat* const dir, dFloat* const vertex) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgCollisionInstance* const collision = (dgCollisionInstance*) collisionPtr; - - const dgMatrix& matrix = collision->GetLocalMatrix (); - dgVector searchDir (matrix.UnrotateVector(dgVector (dir[0], dir[1], dir[2], dgFloat32 (0.0f)))); - searchDir = searchDir.Normalize(); - dgVector vertexOut (matrix.TransformVector(collision->SupportVertex(searchDir))); - - vertex[0] = vertexOut[0]; - vertex[1] = vertexOut[1]; - vertex[2] = vertexOut[2]; -} - - -/*! - Ray cast specific collision object. - - @param *collisionPtr pointer to the collision object. - @param *p0 - pointer to an array of at least three floats representing the ray origin in the local space of the geometry. - @param *p1 - pointer to an array of at least three floats representing the ray end in the local space of the geometry. - @param *normal pointer to an array of at least three floats to hold the normal at the intersection point. - @param *attribute pointer to an array of at least one floats to hold the ID of the face hit by the ray. - - @return the parametric value of the intersection, between 0.0 and 1.0, an value larger than 1.0 if the ray miss. - - This function is intended for applications using newton collision system separate from the dynamics system, also for applications - implementing any king of special purpose logic like sensing distance to another object. - - the ray most be local to the collisions geometry, for example and application ray casting the collision geometry of - of a rigid body, must first take the points p0, and p1 to the local space of the rigid body by multiplying the points by the - inverse of he rigid body transformation matrix. - - See also: ::NewtonCollisionClosestPoint, ::NewtonCollisionSupportVertex, ::NewtonCollisionPointDistance, ::NewtonCollisionCollide, ::NewtonCollisionCalculateAABB -*/ -dFloat NewtonCollisionRayCast(const NewtonCollision* const collisionPtr, const dFloat* const p0, const dFloat* const p1, dFloat* const normal, dLong* const attribute) -{ - dgCollisionInstance* const collision = (dgCollisionInstance*) collisionPtr; - - TRACE_FUNCTION(__FUNCTION__); - const dgMatrix& matrix = collision->GetLocalMatrix (); - - dgVector q0 (matrix.UntransformVector (dgVector (p0[0], p0[1], p0[2], dgFloat32 (0.0f)))); - dgVector q1 (matrix.UntransformVector (dgVector (p1[0], p1[1], p1[2], dgFloat32 (0.0f)))); - dgContactPoint contact; - dgKinematicBody dommyBody; - dommyBody.SetCollision (collision); - dFloat t = collision->RayCast (q0, q1, dgFloat32 (1.0f), contact, NULL, &dommyBody, NULL); - dommyBody.SetCollision (NULL); - - if (t >= dFloat (0.0f) && t <= dFloat (dgFloat32(1.0f))) { - attribute[0] = (dLong) contact.m_shapeId0; - - dgVector n (matrix.RotateVector (contact.m_normal)); - normal[0] = n[0]; - normal[1] = n[1]; - normal[2] = n[2]; - } - return t; -} - -/*! - Calculate an axis-aligned bounding box for this collision, the box is calculated relative to *offsetMatrix*. - - @param *collisionPtr pointer to the collision object. - @param *offsetMatrix pointer to an array of 16 floats containing the offset matrix used as the coordinate system and center of the AABB. - @param *p0 - pointer to an array of at least three floats to hold minimum value for the AABB. - @param *p1 - pointer to an array of at least three floats to hold maximum value for the AABB. - - @return Nothing. - - See also: ::NewtonCollisionClosestPoint, ::NewtonCollisionPointDistance, ::NewtonCollisionCollide, ::NewtonCollisionRayCast -*/ -void NewtonCollisionCalculateAABB(const NewtonCollision* const collisionPtr, const dFloat* const offsetMatrix, dFloat* const p0, dFloat* const p1) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) collisionPtr; - dgMatrix matrix (collision->GetLocalMatrix () * dgMatrix (offsetMatrix)); - - dgVector q0; - dgVector q1; - - collision->CalcAABB (matrix, q0, q1); - p0[0] = q0.m_x; - p0[1] = q0.m_y; - p0[2] = q0.m_z; - - p1[0] = q1.m_x; - p1[1] = q1.m_y; - p1[2] = q1.m_z; -} - -/*! - Iterate thought polygon of the collision geometry of a body calling the function callback. - - @param *collisionPtr is the pointer to the collision objects. - @param *matrixPtr is the pointer to the collision objects. - @param callback application define callback - @param *userDataPtr pointer to the user defined user data value. - - @return nothing - - This function used to be a member of the rigid body, but to making it a member of the collision object provides better - low lever display capabilities. The application can still call this function to show the collision of a rigid body by - getting the collision and the transformation matrix from the rigid, and then calling this functions. - - This function can be called by the application in order to show the collision geometry. The application should provide a pointer to the function *NewtonCollisionIterator*, - Newton will convert the collision geometry into a polygonal mesh, and will call *callback* for every polygon of the mesh - - this function affect severely the performance of Newton. The application should call this function only for debugging purpose - - This function will ignore user define collision mesh - See also: ::NewtonWorldGetFirstBody, ::NewtonWorldForEachBodyInAABBDo -*/ -void NewtonCollisionForEachPolygonDo(const NewtonCollision* const collisionPtr, const dFloat* const matrixPtr, NewtonCollisionIterator callback, void* const userDataPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) (collisionPtr); - collision->DebugCollision (dgMatrix (matrixPtr), (dgCollision::OnDebugCollisionMeshCallback) callback, userDataPtr); -} - -int NewtonCollisionGetType(const NewtonCollision* const collision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - return instance->GetCollisionPrimityType(); -} - -int NewtonCollisionIsConvexShape(const NewtonCollision* const collision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*)collision; - return instance->IsType (dgCollision::dgCollisionConvexShape_RTTI) ? 1 : 0; -} - -int NewtonCollisionIsStaticShape (const NewtonCollision* const collision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*)collision; - return (instance->IsType(dgCollision::dgCollisionMesh_RTTI) || instance->IsType(dgCollision::dgCollisionScene_RTTI)) ? 1 : 0; -} - -/*! - Store a user defined value with a convex collision primitive. - - @param collision is the pointer to a collision primitive. - @param id value to store with the collision primitive. - - @return nothing - - the application can store an id with any collision primitive. This id can be used to identify what type of collision primitive generated a contact. - - See also: ::NewtonCollisionGetUserID, ::NewtonCreateBox, ::NewtonCreateSphere -*/ -void NewtonCollisionSetUserID(const NewtonCollision* const collision, dLong id) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - instance->SetUserDataID (id); -} - -/*! - Return a user define value with a convex collision primitive. - - @param collision is the pointer to a convex collision primitive. - - @return user id - - the application can store an id with any collision primitive. This id can be used to identify what type of collision primitive generated a contact. - - See also: ::NewtonCreateBox, ::NewtonCreateSphere -*/ -dLong NewtonCollisionGetUserID(const NewtonCollision* const collision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - return instance->GetUserDataID(); -} - -void NewtonCollisionSetUserData (const NewtonCollision* const collision, void* const userData) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - instance->SetUserData(userData); -} - -void* NewtonCollisionGetUserData (const NewtonCollision* const collision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - return instance->GetUserData(); -} - -void NewtonCollisionSetMaterial (const NewtonCollision* const collision, const NewtonCollisionMaterial* const userData) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - dgCollisionInfo::dgInstanceMaterial& data = instance->m_material; - data.m_alignPad = userData->m_userData.m_int; - data.m_userId = userData->m_userId; - memcpy (data.m_userParam, userData->m_userParam, sizeof (data.m_userParam)); - instance->SetMaterial (data); -} - -void NewtonCollisionGetMaterial (const NewtonCollision* const collision, NewtonCollisionMaterial* const userData) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - const dgCollisionInfo::dgInstanceMaterial& data = instance->GetMaterial(); - userData->m_userId = data.m_userId; - userData->m_userData.m_int = data.m_alignPad; - memcpy (userData->m_userParam, data.m_userParam, sizeof (data.m_userParam)); -} - -void* NewtonCollisionGetSubCollisionHandle (const NewtonCollision* const collision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - return (void*)instance->GetCollisionHandle (); -} - -NewtonCollision* NewtonCollisionGetParentInstance (const NewtonCollision* const collision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - return (NewtonCollision*)instance->GetParent(); -} - - -void NewtonCollisionSetMatrix (const NewtonCollision* collision, const dFloat* const matrix) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - instance->SetLocalMatrix(dgMatrix (matrix)); -} - -void NewtonCollisionGetMatrix (const NewtonCollision* const collision, dFloat* const matrix) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - const dgMatrix& instanceMatrix = instance->GetLocalMatrix(); - memcpy (matrix, &instanceMatrix[0][0], sizeof (dgMatrix)); -} - - -void NewtonCollisionSetScale (const NewtonCollision* const collision, dFloat scaleX, dFloat scaleY, dFloat scaleZ) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - instance->SetScale(dgVector (scaleX, scaleY, scaleZ, dgFloat32 (0.0f))); -} - - -void NewtonCollisionGetScale (const NewtonCollision* const collision, dFloat* const scaleX, dFloat* const scaleY, dFloat* const scaleZ) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - - dgVector scale (instance->GetScale()); - *scaleX = scale.m_x; - *scaleY = scale.m_y; - *scaleZ = scale.m_z; -} - - - - -/*! - Release a reference from this collision object returning control to Newton. - - @param *collisionPtr pointer to the collision object - - @return Nothing. - - to get the correct reference count of a collision primitive the application can call function *NewtonCollisionGetInfo* - -*/ -void NewtonDestroyCollision(const NewtonCollision* const collisionPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) collisionPtr; - collision->Release(); -} - -dFloat NewtonCollisionGetSkinThickness(const NewtonCollision* const collisionPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*)collisionPtr; - return collision->GetSkinThickness(); -} - -void NewtonCollisionSetSkinThickness(const NewtonCollision* const collisionPtr, dFloat thickness) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*)collisionPtr; - collision->SetSkinThickness(thickness); -} - -NewtonCollision* NewtonCollisionCreateInstance (const NewtonCollision* const collision) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const instance = (dgCollisionInstance*) collision; - return (NewtonCollision*) new (instance->GetAllocator()) dgCollisionInstance (*instance); -} - - - -/*! - Serialize a general collision shape. - - @param *newtonWorld Pointer to the Newton world. - @param *collision is the pointer to the collision tree shape. - @param serializeFunction pointer to the event function that will do the serialization. - @param *serializeHandle - user data that will be passed to the _NewtonSerialize_ callback. - - @return Nothing. - - Small and medium collision shapes like *TreeCollision* (under 50000 polygons) small convex hulls or compude collision can be constructed at application - startup without significant processing overhead. - - - See also: ::NewtonCollisionGetInfo -*/ -void NewtonCollisionSerialize(const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, NewtonSerializeCallback serializeFunction, void* const serializeHandle) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - world->SerializeCollision((dgCollisionInstance*) collision, (dgSerialize) serializeFunction, serializeHandle); -} - - -/*! - Create a collision shape via a serialization function. - - @param *newtonWorld Pointer to the Newton world. - @param deserializeFunction pointer to the event function that will do the deserialization. - @param *serializeHandle user data that will be passed to the _NewtonSerialize_ callback. - - @return Nothing. - - this function is useful to to load collision primitive for and archive file. In the case of complex shapes like convex hull and compound collision the - it save a significant amount of construction time. - - if this function is called to load a serialized tree collision, the tree collision will be loaded, but the function pointer callback will be set to NULL. - for this operation see function *NewtonCreateTreeCollisionFromSerialization* - - See also: ::NewtonCollisionSerialize, ::NewtonCollisionGetInfo -*/ -NewtonCollision* NewtonCreateCollisionFromSerialization(const NewtonWorld* const newtonWorld, NewtonDeserializeCallback deserializeFunction, void* const serializeHandle) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return (NewtonCollision*) world->CreateCollisionFromSerialization ((dgDeserialize) deserializeFunction, serializeHandle); -} - - -/*! - Get creation parameters for this collision objects. - - @param collision is the pointer to a convex collision primitive. - @param *collisionInfo pointer to a collision information record. - - This function can be used by the application for writing file format and for serialization. - - See also: ::NewtonCollisionGetInfo, ::NewtonCollisionSerialize -*/ -void NewtonCollisionGetInfo(const NewtonCollision* const collision, NewtonCollisionInfoRecord* const collisionInfo) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const coll = (dgCollisionInstance*)collision; - - dgAssert ( dgInt32 (sizeof (dgCollisionInfo)) <= dgInt32 (sizeof (NewtonCollisionInfoRecord))); - dgCollisionInfo info; - coll->GetCollisionInfo (&info); - memcpy (collisionInfo, &info, sizeof (dgCollisionInfo)); -} - - -/*! @} */ // end of CollisionLibraryGeneric - - -/*! @defgroup TransUtil TransUtil -Transform utility functions -@{ -*/ - - -/*! - Get the three Euler angles from a 4x4 rotation matrix arranged in row-major order. - - @param matrix pointer to the 4x4 rotation matrix. - @param angles0 - fixme - @param angles1 - pointer to an array of at least three floats to hold the Euler angles. - - @return Nothing. - - The motivation for this function is that many graphics engines still use Euler angles to represent the orientation - of graphics entities. - The angles are expressed in radians and represent: - *angle[0]* - rotation about first matrix row - *angle[1]* - rotation about second matrix row - *angle[2]* - rotation about third matrix row - - See also: ::NewtonSetEulerAngle -*/ -void NewtonGetEulerAngle(const dFloat* const matrix, dFloat* const angles0, dFloat* const angles1) -{ - dgMatrix mat (matrix); - - TRACE_FUNCTION(__FUNCTION__); - dgVector euler0; - dgVector euler1; - mat.CalcPitchYawRoll (euler0, euler1); - - angles0[0] = euler0.m_x; - angles0[1] = euler0.m_y; - angles0[2] = euler0.m_z; - - angles1[0] = euler1.m_x; - angles1[1] = euler1.m_y; - angles1[2] = euler1.m_z; - -} - - -/*! - Build a rotation matrix from the Euler angles in radians. - - @param matrix pointer to the 4x4 rotation matrix. - @param angles pointer to an array of at least three floats to hold the Euler angles. - - @return Nothing. - - The motivation for this function is that many graphics engines still use Euler angles to represent the orientation - of graphics entities. - The angles are expressed in radians and represent: - *angle[0]* - rotation about first matrix row - *angle[1]* - rotation about second matrix row - *angle[2]* - rotation about third matrix row - - See also: ::NewtonGetEulerAngle -*/ -void NewtonSetEulerAngle(const dFloat* const angles, dFloat* const matrix) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMatrix mat (dgPitchMatrix (angles[0]) * dgYawMatrix(angles[1]) * dgRollMatrix(angles[2])); - //dgMatrix retMatrix (matrix); - dgMatrix& retMatrix = *((dgMatrix*) matrix); - - for (dgInt32 i = 0; i < 3; i ++) { - retMatrix[3][i] = 0.0f; - for (dgInt32 j = 0; j < 4; j ++) { - retMatrix[i][j] = mat[i][j]; - } - } - retMatrix[3][3] = dgFloat32(1.0f); -} - - -/*! - Calculates the acceleration to satisfy the specified the spring damper system. - - @param dt integration time step. - @param ks spring stiffness, it must be a positive value. - @param x spring position. - @param kd desired spring damper, it must be a positive value. - @param s spring velocity. - - return: the spring acceleration. - - the acceleration calculated by this function represent the mass, spring system of the form - a = -ks * x - kd * v. -*/ -dFloat NewtonCalculateSpringDamperAcceleration(dFloat dt, dFloat ks, dFloat x, dFloat kd, dFloat v) -{ - TRACE_FUNCTION(__FUNCTION__); - //at = - (ks * x + kd * v); - //at = [- ks (x2 - x1) - kd * (v2 - v1) - dt * ks * (v2 - v1)] / [1 + dt * kd + dt * dt * ks] - dgFloat32 ksd = dt * ks; - dgFloat32 num = ks * x + kd * v + ksd * v; - dgFloat32 den = dgFloat32 (1.0f) + dt * kd + dt * ksd; - dgAssert (den > 0.0f); - dFloat accel = - num / den; - return accel; -} - -/*! @} */ // end of TransUtil - -/*! @defgroup RigidBodyInterface RigidBodyInterface -Rigid Body Interface -@{ -*/ - - -/*! - Create a rigid body. - - @param *newtonWorld Pointer to the Newton world. - @param *collisionPtr pointer to the collision object. - @param *matrixPtr fixme - - @return Pointer to the rigid body. - - This function creates a Newton rigid body and assigns a *collisionPtr* as the collision geometry representing the rigid body. - This function increments the reference count of the collision geometry. - All event functions are set to NULL and the material gruopID of the body is set to the default GroupID. - - See also: ::NewtonDestroyBody -*/ -NewtonBody* NewtonCreateDynamicBody(const NewtonWorld* const newtonWorld, const NewtonCollision* const collisionPtr, const dFloat* const matrixPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgCollisionInstance* collision = (dgCollisionInstance*)collisionPtr; - if (!collisionPtr) { - collision = (dgCollisionInstance*) NewtonCreateNull(newtonWorld); - } - - #ifdef SAVE_COLLISION - SaveCollision (collisionPtr); - #endif - - dgMatrix matrix (matrixPtr); - matrix.m_front.m_w = dgFloat32 (0.0f); - matrix.m_up.m_w = dgFloat32 (0.0f); - matrix.m_right.m_w = dgFloat32 (0.0f); - matrix.m_posit.m_w = dgFloat32 (1.0f); - - NewtonBody* const body = (NewtonBody*)world->CreateDynamicBody (collision, matrix); - if (!collisionPtr) { - NewtonDestroyCollision((NewtonCollision*)collision); - } - return body; -} - -NewtonBody* NewtonCreateAsymetricDynamicBody(const NewtonWorld* const newtonWorld, const NewtonCollision* const collisionPtr, const dFloat* const matrixPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgCollisionInstance* collision = (dgCollisionInstance*)collisionPtr; - if (!collisionPtr) { - collision = (dgCollisionInstance*)NewtonCreateNull(newtonWorld); - } - -#ifdef SAVE_COLLISION - SaveCollision(collisionPtr); -#endif - - dgMatrix matrix(matrixPtr); - matrix.m_front.m_w = dgFloat32(0.0f); - matrix.m_up.m_w = dgFloat32(0.0f); - matrix.m_right.m_w = dgFloat32(0.0f); - matrix.m_posit.m_w = dgFloat32(1.0f); - - NewtonBody* const body = (NewtonBody*)world->CreateDynamicBodyAsymetric(collision, matrix); - if (!collisionPtr) { - NewtonDestroyCollision((NewtonCollision*)collision); - } - return body; -} - -NewtonBody* NewtonCreateKinematicBody(const NewtonWorld* const newtonWorld, const NewtonCollision* const collisionPtr, const dFloat* const matrixPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgCollisionInstance* collision = (dgCollisionInstance*)collisionPtr; - if (!collisionPtr) { - collision = (dgCollisionInstance*)NewtonCreateNull(newtonWorld); - } - -#ifdef SAVE_COLLISION - SaveCollision (collisionPtr); -#endif - - dgMatrix matrix (matrixPtr); - matrix.m_front.m_w = dgFloat32 (0.0f); - matrix.m_up.m_w = dgFloat32 (0.0f); - matrix.m_right.m_w = dgFloat32 (0.0f); - matrix.m_posit.m_w = dgFloat32 (1.0f); - - NewtonBody* const body = (NewtonBody*) world->CreateKinematicBody(collision, matrix); - if (!collisionPtr) { - NewtonDestroyCollision((NewtonCollision*)collision); - } - return body; -} - - -/*! - Destroy a rigid body. - - @param *bodyPtr pointer to the body to be destroyed. - - @return Nothing. - - If this function is called from inside a simulation step the destruction of the body will be delayed until end of the time step. - This function will decrease the reference count of the collision geometry by one. If the reference count reaches zero, then the collision - geometry will be destroyed. This function will destroy all joints associated with this body. - - See also: ::NewtonCreateDynamicBody -*/ -void NewtonDestroyBody (const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgWorld* const world = body->GetWorld(); - world->DestroyBody(body); -} - -/* -void NewtonBodyEnableSimulation(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgWorld* const world = body->GetWorld(); - world->BodyEnableSimulation (body); -} - -void NewtonBodyDisableSimulation(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgWorld* const world = body->GetWorld(); - world->BodyDisableSimulation (body); -} -*/ - -/*! - Gets the current simulation state of the specified body. - - @param *bodyPtr pointer to the body to be inspected. - - @return the current simulation state 0: disabled 1: active. - - See also: ::NewtonBodySetSimulationState -*/ -int NewtonBodyGetSimulationState(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgWorld* const world = body->GetWorld(); - return world->GetBodyEnableDisableSimulationState(body) ? 1 : 0; -} - -/*! - Sets the current simulation state of the specified body. - - @param *bodyPtr pointer to the body to be changed. - @param state the new simulation state 0: disabled 1: active - - @return Nothing. - - See also: ::NewtonBodyGetSimulationState -*/ -void NewtonBodySetSimulationState(const NewtonBody* const bodyPtr, const int state) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgWorld* const world = body->GetWorld(); - - if (state) { - world->BodyEnableSimulation(body); - } else { - world->BodyDisableSimulation(body); - } -} - -int NewtonBodyGetCollidable (const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return body->IsCollidable() ? 1 : 0; -} - -void NewtonBodySetCollidable (const NewtonBody* const bodyPtr, int collidable) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - body->SetCollidable(collidable ? true : false); -} - -int NewtonBodyGetType (const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - if (body->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - return NEWTON_DYNAMIC_BODY; - } else if (body->IsRTTIType(dgBody::m_kinematicBodyRTTI)) { - return NEWTON_KINEMATIC_BODY; - } else if (body->IsRTTIType(dgBody::m_dynamicBodyAsymentricRTTI)) { - return NEWTON_DYNAMIC_ASYMETRIC_BODY; -// } else if (body->IsRTTIType(dgBody::m_deformableBodyRTTI)) { -// return NEWTON_DEFORMABLE_BODY; - } - dgAssert (0); - return 0; -} - -int NewtonBodyGetID (const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return body->GetUniqueID(); -} - -/*! - Store a user defined data value with the body. - - @param *bodyPtr pointer to the body. - @param *userDataPtr pointer to the user defined user data value. - - @return Nothing. - - The application can store a user defined value with the Body. This value can be the pointer to a structure containing some application data for special effect. - if the application allocate some resource to store the user data, the application can register a joint destructor to get rid of the allocated resource when the body is destroyed - - See also: ::NewtonBodyGetUserData -*/ -void NewtonBodySetUserData(const NewtonBody* const bodyPtr, void* const userDataPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - body->SetUserData (userDataPtr); -} - -/*! - Retrieve a user defined data value stored with the body. - - @param *bodyPtr pointer to the body. - - @return The user defined data. - - The application can store a user defined value with a rigid body. This value can be the pointer - to a structure which is the graphical representation of the rigid body. - - See also: ::NewtonBodySetUserData, -*/ -void* NewtonBodyGetUserData(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return body->GetUserData (); -} - - -/*! - Return pointer to the Newton world of the specified body. - - @param *bodyPtr Pointer to the body. - - @return World that owns this body. - - The application can also determine the world from a joint, if it queries one - of the bodies attached to that joint. -*/ -NewtonWorld* NewtonBodyGetWorld(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return (NewtonWorld*) body->GetWorld(); -} - - -/*! - Assign a transformation event function to the body. - - @param *bodyPtr pointer to the body. - @param callback pointer to a function callback in used to update the transformation matrix of the visual object that represents the rigid body. - - @return Nothing. - - The function *NewtonSetTransform callback* is called by the Newton engine every time a visual object that represents the rigid body has changed. - The application can obtain the pointer user data value that points to the visual object. - The Newton engine does not call the *NewtonSetTransform callback* function for bodies that are inactive or have reached a state of stable equilibrium. - - The matrix should be organized in row-major order (this is the way directX and OpenGL stores matrices). - - See also: NewtonBodyGetTransformCallback -*/ -void NewtonBodySetTransformCallback(const NewtonBody* const bodyPtr, NewtonSetTransform callback) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - body->SetMatrixUpdateCallback ((dgBody::OnMatrixUpdateCallback) callback); -} - - -/*! - Assign a transformation event function to the body. - - @param *bodyPtr pointer to the body. - - @return Nothing. - - The function *NewtonSetTransform callback* is called by the Newton engine every time a visual object that represents the rigid body has changed. - The application can obtain the pointer user data value that points to the visual object. - The Newton engine does not call the *NewtonSetTransform callback* function for bodies that are inactive or have reached a state of stable equilibrium. - - The matrix should be organized in row-major order (this is the way directX and OpenGL stores matrices). - - See also: ::NewtonBodySetTransformCallback -*/ -NewtonSetTransform NewtonBodyGetTransformCallback (const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return (NewtonSetTransform) body->GetMatrixUpdateCallback(); -} - - -/*! - Assign an event function for applying external force and torque to a rigid body. - - @param *bodyPtr pointer to the body. - @param callback pointer to a function callback used to apply force and torque to a rigid body. - - @return Nothing. - - Before the *NewtonApplyForceAndTorque callback* is called for a body, Newton first clears the net force and net torque for the body. - - The function *NewtonApplyForceAndTorque callback* is called by the Newton Engine every time an active body is going to be simulated. - The Newton Engine does not call the *NewtonApplyForceAndTorque callback* function for bodies that are inactive or have reached a state of stable equilibrium. - - See also: ::NewtonBodyGetUserData, ::NewtonBodyGetUserData, ::NewtonBodyGetForceAndTorqueCallback -*/ -void NewtonBodySetForceAndTorqueCallback(const NewtonBody* const bodyPtr, NewtonApplyForceAndTorque callback) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - body->SetExtForceAndTorqueCallback ((dgBody::OnApplyExtForceAndTorque) callback); -} - - -/*! - Return the pointer to the current force and torque call back function. - - @param *bodyPtr pointer to the body. - - @return pointer to the force call back. - - This function can be used to concatenate different force calculation components making more modular the - design of function components dedicated to apply special effect. For example a body may have a basic force a force that - only apply the effect of gravity, but that application can place a region in where there can be a fluid volume, or another gravity field. - we this function the application can read the correct function and save into a local variable, and set a new one. - this new function will firs call the save function pointer and upon return apply the correct effect. - this similar to the concept of virtual methods on objected oriented languages. - - The function *NewtonApplyForceAndTorque callback* is called by the Newton Engine every time an active body is going to be simulated. - The Newton Engine does not call the *NewtonApplyForceAndTorque callback* function for bodies that are inactive or have reached a state of stable equilibrium. - - See also: ::NewtonBodyGetUserData, ::NewtonBodyGetUserData, ::NewtonBodySetForceAndTorqueCallback -*/ -NewtonApplyForceAndTorque NewtonBodyGetForceAndTorqueCallback(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return (NewtonApplyForceAndTorque) body->GetExtForceAndTorqueCallback (); -} - - -/*! - Assign an event function to be called when this body is about to be destroyed. - - @param *bodyPtr pointer to the body to be destroyed. - @param callback pointer to a function callback. - - @return Nothing. - - - This function *NewtonBodyDestructor callback* acts like a destruction function in CPP. This function - is called when the body and all data joints associated with the body are about to be destroyed. - The application could use this function to destroy or release any resource associated with this body. - The application should not make reference to this body after this function returns. - - - The destruction of a body will destroy all joints associated with the body. - - See also: ::NewtonBodyGetUserData, ::NewtonBodyGetUserData -*/ -void NewtonBodySetDestructorCallback(const NewtonBody* const bodyPtr, NewtonBodyDestructor callback) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - body->SetDestructorCallback (dgBody::OnBodyDestroy (callback)); -} - -NewtonBodyDestructor NewtonBodyGetDestructorCallback (const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return NewtonBodyDestructor (body->GetDestructorCallback ()); -} - -/*! - Set the mass matrix of a rigid body. - - @param *bodyPtr pointer to the body. - @param mass mass value. - @param inertiaMatrix fixme - - @return Nothing. - - Newton algorithms have no restriction on the values for the mass, but due to floating point dynamic - range (24 bit precision) it is best if the ratio between the heaviest and the lightest body in the scene is limited to 200. - There are no special utility functions in Newton to calculate the moment of inertia of common primitives. - The application should specify the inertial values, keeping in mind that realistic inertia values are necessary for - realistic physics behavior. - - See also: ::NewtonConvexCollisionCalculateInertialMatrix, ::NewtonBodyGetMass, ::NewtonBodyGetInvMass -*/ -void NewtonBodySetFullMassMatrix(const NewtonBody* const bodyPtr, dFloat mass, const dFloat* const inertiaMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgMatrix inertia(inertiaMatrix); - body->SetMassMatrix (mass, inertia); -} - - -void NewtonBodySetMassMatrix(const NewtonBody* const bodyPtr, dFloat mass, dFloat Ixx, dFloat Iyy, dFloat Izz) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMatrix inertia (dgGetIdentityMatrix()); - inertia[0][0] = Ixx; - inertia[1][1] = Iyy; - inertia[2][2] = Izz; - NewtonBodySetFullMassMatrix(bodyPtr, mass, &inertia[0][0]); -} - -void NewtonBodySetMassProperties (const NewtonBody* const bodyPtr, dFloat mass, const NewtonCollision* const collisionPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgCollisionInstance* const collision = (dgCollisionInstance*) collisionPtr; - body->SetMassProperties (mass, collision); -} - -/*! - Get the mass matrix of a rigid body. - - @param *bodyPtr pointer to the body. - @param *mass pointer to a variable that will hold the mass value of the body. - @param *Ixx pointer to a variable that will hold the moment of inertia of the first principal axis of inertia of the body. - @param *Iyy pointer to a variable that will hold the moment of inertia of the first principal axis of inertia of the body. - @param *Izz pointer to a variable that will hold the moment of inertia of the first principal axis of inertia of the body. - - @return Nothing. - - See also: ::NewtonBodySetMassMatrix, ::NewtonBodyGetInvMass -*/ -void NewtonBodyGetMass(const NewtonBody* const bodyPtr, dFloat* const mass, dFloat* const Ixx, dFloat* const Iyy, dFloat* const Izz) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - -// dgVector vector (body->GetApparentMass()); - dgVector vector (body->GetMass()); - Ixx[0] = vector.m_x; - Iyy[0] = vector.m_y; - Izz[0] = vector.m_z; - mass[0] = vector.m_w; - if (vector.m_w > DG_INFINITE_MASS * 0.5f) { - Ixx[0] = 0.0f; - Iyy[0] = 0.0f; - Izz[0] = 0.0f; - mass[0] = 0.0f; - } -} - -/*! - Get the inverse mass matrix of a rigid body. - - @param *bodyPtr pointer to the body. - @param *invMass pointer to a variable that will hold the mass inverse value of the body. - @param *invIxx pointer to a variable that will hold the moment of inertia inverse of the first principal axis of inertia of the body. - @param *invIyy pointer to a variable that will hold the moment of inertia inverse of the first principal axis of inertia of the body. - @param *invIzz pointer to a variable that will hold the moment of inertia inverse of the first principal axis of inertia of the body. - - @return Nothing. - - See also: ::NewtonBodySetMassMatrix, ::NewtonBodyGetMass -*/ -void NewtonBodyGetInvMass(const NewtonBody* const bodyPtr, dFloat* const invMass, dFloat* const invIxx, dFloat* const invIyy, dFloat* const invIzz) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - -// dgVector vector1 (body->GetMass()); -// invIxx[0] = dgFloat32 (1.0f) / (vector1.m_x + dgFloat32 (1.0e-8f)); -// invIyy[0] = dgFloat32 (1.0f) / (vector1.m_y + dgFloat32 (1.0e-8f)); -// invIzz[0] = dgFloat32 (1.0f) / (vector1.m_z + dgFloat32 (1.0e-8f)); -// invMass[0] = dgFloat32 (1.0f) / (vector1.m_w + dgFloat32 (1.0e-8f)); - dgVector inverseMass (body->GetInvMass()); - invIxx[0] = inverseMass.m_x; - invIyy[0] = inverseMass.m_y; - invIzz[0] = inverseMass.m_z; - invMass[0] = inverseMass.m_w; -} - - -void NewtonBodyGetInertiaMatrix(const NewtonBody* const bodyPtr, dFloat* const inertiaMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - dgMatrix matrix (body->CalculateInertiaMatrix()); - memcpy (inertiaMatrix, &matrix[0][0], sizeof (dgMatrix)); -} - -void NewtonBodyGetInvInertiaMatrix(const NewtonBody* const bodyPtr, dFloat* const invInertiaMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - dgMatrix matrix (body->CalculateInvInertiaMatrix ()); - memcpy (invInertiaMatrix, &matrix[0][0], sizeof (dgMatrix)); -} - - - -/*! - Set the transformation matrix of a rigid body. - - @param *bodyPtr pointer to the body. - @param *matrixPtr pointer to an array of 16 floats containing the global matrix of the rigid body. - - @return Nothing. - - The matrix should be arranged in row-major order. - If you are using OpenGL matrices (column-major) you will need to transpose you matrices into a local array, before - passing them to Newton. - - That application should make sure the transformation matrix has not scale, otherwise unpredictable result will occur. - - See also: ::NewtonBodyGetMatrix -*/ -void NewtonBodySetMatrix(const NewtonBody* const bodyPtr, const dFloat* const matrixPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgMatrix matrix (matrixPtr); - - matrix.m_front.m_w = dgFloat32 (0.0f); - matrix.m_up.m_w = dgFloat32 (0.0f); - matrix.m_right.m_w = dgFloat32 (0.0f); - matrix.m_posit.m_w = dgFloat32 (1.0f); - body->SetMatrixResetSleep (matrix); -} - -void NewtonBodySetMatrixNoSleep (const NewtonBody* const bodyPtr, const dFloat* const matrixPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgMatrix matrix(matrixPtr); - - matrix.m_front.m_w = dgFloat32(0.0f); - matrix.m_up.m_w = dgFloat32(0.0f); - matrix.m_right.m_w = dgFloat32(0.0f); - matrix.m_posit.m_w = dgFloat32(1.0f); - body->SetMatrixNoSleep(matrix); -} - -/*! - Apply hierarchical transformation to a body. - - @param *bodyPtr pointer to the body. - @param *matrixPtr pointer to an array of 16 floats containing the global matrix of the rigid body. - - @return Nothing. - - This function applies the transformation matrix to the *body* and also applies the appropriate transformation matrix to - set of articulated bodies. If the body is in contact with another body the other body is not transformed. - - this function should not be used to transform set of articulated bodies that are connected to a static body. - doing so will result in unpredictables results. Think for example moving a chain attached to a ceiling from one place to another, - to do that in real life a person first need to disconnect the chain (destroy the joint), move the chain (apply the transformation to the - entire chain), the reconnect it in the new position (recreate the joint again). - - this function will set to zero the linear and angular velocity of all bodies that are part of the set of articulated body array. - - The matrix should be arranged in row-major order (this is the way direct x stores matrices). - If you are using OpenGL matrices (column-major) you will need to transpose you matrices into a local array, before - passing them to Newton. - - See also: ::NewtonBodySetMatrix -*/ -void NewtonBodySetMatrixRecursive(const NewtonBody* const bodyPtr, const dFloat* const matrixPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - Newton* const world = (Newton *)body->GetWorld(); - - world->BodySetMatrix (body, dgMatrix (matrixPtr)); -} - - -/*! - Get the transformation matrix of a rigid body. - - @param *bodyPtr pointer to the body. - @param *matrixPtr pointer to an array of 16 floats that will hold the global matrix of the rigid body. - - @return Nothing. - - The matrix should be arranged in row-major order (this is the way direct x stores matrices). - If you are using OpenGL matrices (column-major) you will need to transpose you matrices into a local array, before - passing them to Newton. - - See also: ::NewtonBodySetMatrix, ::NewtonBodyGetRotation -*/ -void NewtonBodyGetMatrix(const NewtonBody* const bodyPtr, dFloat* const matrixPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - const dgMatrix& matrix = body->GetMatrix(); - memcpy (matrixPtr, &matrix[0][0], sizeof (dgMatrix)); -} - -void NewtonBodyGetPosition(const NewtonBody* const bodyPtr, dFloat* const posPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - const dgVector& rot = body->GetPosition(); - posPtr[0] = rot.m_x; - posPtr[1] = rot.m_y; - posPtr[2] = rot.m_z; -} - -/*! - Get the rotation part of the transformation matrix of a body, in form of a unit quaternion. - - @param *bodyPtr pointer to the body. - @param *rotPtr pointer to an array of 4 floats that will hold the global rotation of the rigid body. - - @return Nothing. - - The rotation matrix is written set in the form of a unit quaternion in the format Rot (q0, q1, q1, q3) - - The rotation quaternion is the same as what the application would get by using at function to extract a quaternion form a matrix. - however since the rigid body already contained the rotation in it, it is more efficient to just call this function avoiding expensive conversion. - - this function could be very useful for the implementation of pseudo frame rate independent simulation. - by running the simulation at a fix rate and using linear interpolation between the last two simulation frames. - to determine the exact fraction of the render step. - - See also: ::NewtonBodySetMatrix, ::NewtonBodyGetMatrix -*/ -void NewtonBodyGetRotation(const NewtonBody* const bodyPtr, dFloat* const rotPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - const dgQuaternion& rot = body->GetRotation(); - rotPtr[0] = rot.m_x; - rotPtr[1] = rot.m_y; - rotPtr[2] = rot.m_z; - rotPtr[3] = rot.m_w; -} - - -/*! - Set the net force applied to a rigid body. - - @param *bodyPtr pointer to the body. - @param *vectorPtr pointer to an array of 3 floats containing the net force to be applied to the body. - - @return Nothing. - - This function is only effective when called from *NewtonApplyForceAndTorque callback* - - See also: ::NewtonBodyAddForce, ::NewtonBodyGetForce -*/ -void NewtonBodySetForce(const NewtonBody* const bodyPtr, const dFloat* const vectorPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgVector vector (vectorPtr[0], vectorPtr[1], vectorPtr[2], dgFloat32 (0.0f)); - body->SetForce (vector); -} - -/*! - Add the net force applied to a rigid body. - - @param *bodyPtr pointer to the body to be destroyed. - @param *vectorPtr pointer to an array of 3 floats containing the net force to be applied to the body. - - @return Nothing. - - This function is only effective when called from *NewtonApplyForceAndTorque callback* - - See also: ::NewtonBodySetForce, ::NewtonBodyGetForce -*/ -void NewtonBodyAddForce(const NewtonBody* const bodyPtr, const dFloat* const vectorPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgVector vector (vectorPtr[0], vectorPtr[1], vectorPtr[2], dgFloat32 (0.0f)); - - body->AddForce (vector); -} - -/*! - Get the net force applied to a rigid body after the last NewtonUpdate. - - @param *bodyPtr pointer to the body. - @param *vectorPtr pointer to an array of 3 floats to hold the net force of the body. - - @return Nothing. - - See also: ::NewtonBodyAddForce, ::NewtonBodyGetForce -*/ -void NewtonBodyGetForce(const NewtonBody* const bodyPtr, dFloat* const vectorPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgVector vector (body->GetForce()); - vectorPtr[0] = vector.m_x; - vectorPtr[1] = vector.m_y; - vectorPtr[2] = vector.m_z; -} - -/*! - Set the net torque applied to a rigid body. - - @param *bodyPtr pointer to the body. - @param *vectorPtr pointer to an array of 3 floats containing the net torque to be applied to the body. - - @return Nothing. - - This function is only effective when called from *NewtonApplyForceAndTorque callback* - - See also: ::NewtonBodyAddTorque, ::NewtonBodyGetTorque -*/ -void NewtonBodySetTorque(const NewtonBody* const bodyPtr, const dFloat* const vectorPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgVector vector (vectorPtr[0], vectorPtr[1], vectorPtr[2], dgFloat32 (0.0f)); - body->SetTorque (vector); -} - - -/*! - Add the net torque applied to a rigid body. - - @param *bodyPtr pointer to the body. - @param *vectorPtr pointer to an array of 3 floats containing the net torque to be applied to the body. - - @return Nothing. - - This function is only effective when called from *NewtonApplyForceAndTorque callback* - - See also: ::NewtonBodySetTorque, ::NewtonBodyGetTorque -*/ -void NewtonBodyAddTorque(const NewtonBody* const bodyPtr, const dFloat* const vectorPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgVector vector (vectorPtr[0], vectorPtr[1], vectorPtr[2], dgFloat32 (0.0f)); - body->AddTorque (vector); -} - -/*! - Get the net torque applied to a rigid body after the last NewtonUpdate. - - @param *bodyPtr pointer to the body. - @param *vectorPtr pointer to an array of 3 floats to hold the net torque of the body. - - @return Nothing. - - See also: ::NewtonBodyAddTorque, ::NewtonBodyGetTorque -*/ -void NewtonBodyGetTorque(const NewtonBody* const bodyPtr, dFloat* const vectorPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgVector vector (body->GetTorque()); - vectorPtr[0] = vector.m_x; - vectorPtr[1] = vector.m_y; - vectorPtr[2] = vector.m_z; -} - - - -/*! - Set the relative position of the center of mass of a rigid body. - - @param *bodyPtr pointer to the body. - @param *comPtr pointer to an array of 3 floats containing the relative offset of the center of mass of the body. - - @return Nothing. - - This function can be used to set the relative offset of the center of mass of a rigid body. - when a rigid body is created the center of mass is set the the point c(0, 0, 0), and normally this is - the best setting for a rigid body. However the are situations in which and object does not have symmetry or - simple some kind of special effect is desired, and this origin need to be changed. - - Care must be taken when offsetting the center of mass of a body. - The application must make sure that the external torques resulting from forces applied at at point - relative to the center of mass are calculated appropriately. - this could be done Transform and Torque callback function as the follow pseudo code fragment shows: - - Matrix matrix; - Vector center; - - NewtonGetMatrix(body, matrix) - NewtonGetCentreOfMass(body, center); - - //for global space torque. - Vector localForce (fx, fy, fz); - Vector localPosition (x, y, z); - Vector localTorque (crossproduct ((localPosition - center). localForce); - Vector globalTorque (matrix.RotateVector (localTorque)); - - //for global space torque. - Vector globalCentre (matrix.TranformVector (center)); - Vector globalPosition (x, y, z); - Vector globalForce (fx, fy, fz); - Vector globalTorque (crossproduct ((globalPosition - globalCentre). globalForce); - - See also: ::NewtonConvexCollisionCalculateInertialMatrix, ::NewtonBodyGetCentreOfMass -*/ -void NewtonBodySetCentreOfMass(const NewtonBody* const bodyPtr, const dFloat* const comPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgVector vector (comPtr[0], comPtr[1], comPtr[2], dgFloat32 (1.0f)); - body->SetCentreOfMass (vector); -} - -/*! - Get the relative position of the center of mass of a rigid body. - - @param *bodyPtr pointer to the body. - @param *comPtr pointer to an array of 3 floats to hold the relative offset of the center of mass of the body. - - @return Nothing. - - This function can be used to set the relative offset of the center of mass of a rigid body. - when a rigid body is created the center of mass is set the the point c(0, 0, 0), and normally this is - the best setting for a rigid body. However the are situations in which and object does not have symmetry or - simple some kind of special effect is desired, and this origin need to be changed. - - This function can be used in conjunction with *NewtonConvexCollisionCalculateInertialMatrix* - - See also: ::NewtonConvexCollisionCalculateInertialMatrix, ::NewtonBodySetCentreOfMass -*/ -void NewtonBodyGetCentreOfMass(const NewtonBody* const bodyPtr, dFloat* const comPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgVector vector (body->GetCentreOfMass ()); - comPtr[0] = vector.m_x; - comPtr[1] = vector.m_y; - comPtr[2] = vector.m_z; -} - - -/*! - Return a pointer to the first joint attached to this rigid body. - - @param *bodyPtr pointer to the body. - - @return Joint if at least one is attached to the body, NULL if not joint is attached - - this function will only return the pointer to user defined joints, older build in constraints will be skipped by this function. - - this function can be used to implement recursive walk of complex articulated arrangement of rodid bodies. - - See also: ::NewtonBodyGetNextJoint -*/ -NewtonJoint* NewtonBodyGetFirstJoint(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return (NewtonJoint*)body->GetFirstJoint(); -} - -/*! - Return a pointer to the next joint attached to this body. - - @param *bodyPtr pointer to the body. - @param *jointPtr pointer to current joint. - - @return Joint is at least one joint is attached to the body, NULL if not joint is attached - - this function will only return the pointer to User defined joint, older build in constraints will be skipped by this function. - - this function can be used to implement recursive walk of complex articulated arrangement of rodid bodies. - - See also: ::NewtonBodyGetFirstJoint -*/ -NewtonJoint* NewtonBodyGetNextJoint(const NewtonBody* const bodyPtr, const NewtonJoint* const jointPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return (NewtonJoint*)body->GetNextJoint((dgConstraint*)jointPtr); -} - - -/*! - Return a pointer to the first contact joint attached to this rigid body. - - @param *bodyPtr pointer to the body. - - @return Contact if the body is colliding with anther body, NULL otherwise - - See also: ::NewtonBodyGetNextContactJoint, ::NewtonContactJointGetFirstContact, ::NewtonContactJointGetNextContact, ::NewtonContactJointRemoveContact -*/ -NewtonJoint* NewtonBodyGetFirstContactJoint(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return (NewtonJoint*)body->GetFirstContact(); -} - -/*! - Return a pointer to the next contact joint attached to this rigid body. - - @param *bodyPtr pointer to the body. - @param *contactPtr pointer to corrent contact joint. - - @return Contact if the body is colliding with anther body, NULL otherwise - - See also: ::NewtonBodyGetFirstContactJoint, ::NewtonContactJointGetFirstContact, ::NewtonContactJointGetNextContact, ::NewtonContactJointRemoveContact -*/ -NewtonJoint* NewtonBodyGetNextContactJoint(const NewtonBody* const bodyPtr, const NewtonJoint* const contactPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return (NewtonJoint*)body->GetNextContact((dgConstraint*)contactPtr); -} - - -/*! - Return a pointer to the next contact joint the connect these two bodies, if the are colliding - - @param *body0 pointer to one body. - @param *body1 pointer to secund body. - - @return Contact if the body is colliding with anther body, NULL otherwise - - See also: ::NewtonBodyGetFirstContactJoint, ::NewtonContactJointGetFirstContact, ::NewtonContactJointGetNextContact, ::NewtonContactJointRemoveContact -*/ -NewtonJoint* NewtonBodyFindContact(const NewtonBody* const body0, const NewtonBody* const body1) -{ - TRACE_FUNCTION(__FUNCTION__); - const dgBody* const bodyPtr0 = (dgBody*)body0; - const dgBody* const bodyPtr1 = (dgBody*)body1; - return (NewtonJoint*)bodyPtr0->GetWorld()->FindContactJoint(bodyPtr0, bodyPtr1); -} - -int NewtonJointIsActive(const NewtonJoint* const jointPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const joint = (dgConstraint*) jointPtr; - return joint->IsActive() ? 1 : 0; -} - -/*! - Return to number of contact in this contact joint. - - @param *contactJoint pointer to corrent contact joint. - - @return number of contacts. - - See also: ::NewtonContactJointGetFirstContact, ::NewtonContactJointGetNextContact, ::NewtonContactJointRemoveContact -*/ -int NewtonContactJointGetContactCount(const NewtonJoint* const contactJoint) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContact* const joint = (dgContact *)contactJoint; - - if ((joint->GetId() == dgConstraint::m_contactConstraint) && joint->GetCount()){ - return joint->GetCount(); - } else { - return 0; - } -} - - -/*! - Return to pointer to the first contact from the contact array of the contact joint. - - @param *contactJoint pointer to a contact joint. - - @return a pointer to the first contact from the contact array, NULL if no contacts exist - - See also: ::NewtonContactJointGetNextContact, ::NewtonContactGetMaterial, ::NewtonContactJointRemoveContact -*/ -void* NewtonContactJointGetFirstContact(const NewtonJoint* const contactJoint) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContact* const joint = (dgContact *)contactJoint; - if ((joint->GetId() == dgConstraint::m_contactConstraint) && joint->GetCount() && joint->GetMaxDOF()){ - return joint->GetFirst(); - } else { - return NULL; - } -} - -/*! - Return a pointer to the next contact from the contact array of the contact joint. - - @param *contactJoint pointer to a contact joint. - @param *contact pointer to current contact. - - @return a pointer to the next contact in the contact array, NULL if no contacts exist. - - See also: ::NewtonContactJointGetFirstContact, ::NewtonContactGetMaterial, ::NewtonContactJointRemoveContact -*/ -void* NewtonContactJointGetNextContact(const NewtonJoint* const contactJoint, void* const contact) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContact* const joint = (dgContact *)contactJoint; - - if ((joint->GetId() == dgConstraint::m_contactConstraint) && joint->GetCount()){ - dgList<dgContactMaterial>::dgListNode* const node = (dgList<dgContactMaterial>::dgListNode*) contact; - return node->GetNext(); - } else { - return NULL; - } -} - - -/*! - Return to the next contact from the contact array of the contact joint. - - @param *contactJoint pointer to corrent contact joint. - @param *contact pointer to current contact. - - @return first contact contact array of the joint contact exist, NULL otherwise - - See also: ::NewtonBodyGetFirstContactJoint, ::NewtonBodyGetNextContactJoint, ::NewtonContactJointGetFirstContact, ::NewtonContactJointGetNextContact -*/ -void NewtonContactJointRemoveContact(const NewtonJoint* const contactJoint, void* const contact) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContact* const joint = (dgContact *)contactJoint; - - if ((joint->GetId() == dgConstraint::m_contactConstraint) && joint->GetCount()){ - dgList<dgContactMaterial>::dgListNode* const node = (dgList<dgContactMaterial>::dgListNode*) contact; - - dgAssert (joint->GetBody0()); - dgAssert (joint->GetBody1()); - dgWorld* const world = joint->GetBody0()->GetWorld(); - world->GlobalLock(); - joint->Remove(node); - joint->GetBody0()->SetSleepState(false); - joint->GetBody1()->SetSleepState(false); - world->GlobalUnlock(); - } -} - -dFloat NewtonContactJointGetClosestDistance(const NewtonJoint* const contactJoint) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContact* const joint = (dgContact *)contactJoint; - return joint->GetClosestDistance(); -} - -void NewtonContactJointResetSelftJointCollision(const NewtonJoint* const contactJoint) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContact* const joint = (dgContact *)contactJoint; - joint->ResetSkeletonSelftCollision(); -} - -void NewtonContactJointResetIntraJointCollision(const NewtonJoint* const contactJoint) -{ - TRACE_FUNCTION(__FUNCTION__); - dgContact* const joint = (dgContact *)contactJoint; - joint->ResetSkeletonIntraCollision(); -} - -/*! - Return to the next contact from the contact array of the contact joint. - - @param *contact pointer to current contact. - - @return first contact contact array of the joint contact exist, NULL otherwise - - See also: ::NewtonContactJointGetFirstContact, ::NewtonContactJointGetNextContact -*/ -NewtonMaterial* NewtonContactGetMaterial(const void* const contact) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgList<dgContactMaterial>::dgListNode* const node = (dgList<dgContactMaterial>::dgListNode*) contact; - dgContactMaterial& contactMaterial = node->GetInfo(); - return (NewtonMaterial*) &contactMaterial; -} - -NewtonCollision* NewtonContactGetCollision0(const void* const contact) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgList<dgContactMaterial>::dgListNode* const node = (dgList<dgContactMaterial>::dgListNode*) contact; - dgContactMaterial& contactMaterial = node->GetInfo(); - return (NewtonCollision*) contactMaterial.m_collision0; -} - -NewtonCollision* NewtonContactGetCollision1(const void* const contact) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgList<dgContactMaterial>::dgListNode* const node = (dgList<dgContactMaterial>::dgListNode*) contact; - dgContactMaterial& contactMaterial = node->GetInfo(); - return (NewtonCollision*) contactMaterial.m_collision1; -} - -void* NewtonContactGetCollisionID0(const void* const contact) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgList<dgContactMaterial>::dgListNode* const node = (dgList<dgContactMaterial>::dgListNode*) contact; - dgContactMaterial& contactMaterial = node->GetInfo(); - return (void*) contactMaterial.m_shapeId0; -} - -void* NewtonContactGetCollisionID1(const void* const contact) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgList<dgContactMaterial>::dgListNode* const node = (dgList<dgContactMaterial>::dgListNode*) contact; - dgContactMaterial& contactMaterial = node->GetInfo(); - return (NewtonCollision*) contactMaterial.m_shapeId1; -} - - - - -/*! - Assign a collision primitive to the body. - - @param *bodyPtr pointer to the body. - @param *collisionPtr pointer to the new collision geometry. - - @return Nothing. - - This function replaces a collision geometry of a body with the new collision geometry. - This function increments the reference count of the collision geometry and decrements the reference count - of the old collision geometry. If the reference count of the old collision geometry reaches zero, the old collision geometry is destroyed. - This function can be used to swap the collision geometry of bodies at runtime. - - See also: ::NewtonCreateDynamicBody, ::NewtonBodyGetCollision -*/ -void NewtonBodySetCollision(const NewtonBody* const bodyPtr, const NewtonCollision* const collisionPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgCollisionInstance* const collision = (dgCollisionInstance*) collisionPtr; - body->AttachCollision (collision); - body->UpdateCollisionMatrix(dgFloat32(0.0f), 0); -} - -void NewtonBodySetCollisionScale (const NewtonBody* const bodyPtr, dFloat scaleX, dFloat scaleY, dFloat scaleZ) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgWorld* const world = body->GetWorld(); - NewtonCollision* const collision = NewtonBodyGetCollision(bodyPtr); - - dgFloat32 mass = body->GetInvMass().m_w > dgFloat32 (0.0f) ? body->GetMass().m_w : dgFloat32 (0.0f); - NewtonCollisionSetScale (collision, scaleX, scaleY, scaleZ); - - NewtonJoint* nextJoint; - for (NewtonJoint* joint = NewtonBodyGetFirstContactJoint(bodyPtr); joint; joint = nextJoint) { - dgConstraint* const contactJoint = (dgConstraint*)joint; - nextJoint = NewtonBodyGetNextContactJoint(bodyPtr, joint); - //world->DestroyConstraint (contactJoint); - contactJoint->ResetMaxDOF(); - } - NewtonBodySetMassProperties (bodyPtr, mass, collision); - body->UpdateCollisionMatrix(dgFloat32(0.0f), 0); - world->GetBroadPhase()->ResetEntropy (); -} - - -/*! - Get the collision primitive of a body. - - @param *bodyPtr pointer to the body. - - @return Pointer to body collision geometry. - - This function does not increment the reference count of the collision geometry. - - See also: ::NewtonCreateDynamicBody, ::NewtonBodySetCollision -*/ -NewtonCollision* NewtonBodyGetCollision(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return (NewtonCollision*) body->GetCollision(); -} - - -/*! - Assign a material group id to the body. - - @param *bodyPtr pointer to the body. - @param id id of a previously created material group. - - @return Nothing. - - When the application creates a body, the default material group, *defaultGroupId*, is applied by default. - - See also: ::NewtonBodyGetMaterialGroupID, ::NewtonMaterialCreateGroupID, ::NewtonMaterialGetDefaultGroupID -*/ -void NewtonBodySetMaterialGroupID(const NewtonBody* const bodyPtr, int id) -{ - dgBody* const body = (dgBody *)bodyPtr; - - TRACE_FUNCTION(__FUNCTION__); - body->SetGroupID (dgUnsigned32 (id)); -} - - -/*! - Get the material group id of the body. - - @param *bodyPtr pointer to the body. - - @return Nothing. - - See also: ::NewtonBodySetMaterialGroupID -*/ -int NewtonBodyGetMaterialGroupID(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return int (body->GetGroupID ()); -} - -/*! - Set the continuous collision state mode for this rigid body. - continuous collision flag is off by default in when bodies are created. - - @param *bodyPtr pointer to the body. - @param state collision state. 1 indicates this body may tunnel through other objects while moving at high speed. 0 ignore high speed collision checks. - - @return Nothing. - - continuous collision mode enable allow the engine to predict colliding contact on rigid bodies - Moving at high speed of subject to strong forces. - - continuous collision mode does not prevent rigid bodies from inter penetration instead it prevent bodies from - passing trough each others by extrapolating contact points when the bodies normal contact calculation determine the bodies are not colliding. - - for performance reason the bodies angular velocities is only use on the broad face of the collision, - but not on the contact calculation. - - continuous collision does not perform back tracking to determine time of contact, instead it extrapolate contact by incrementally - extruding the collision geometries of the two colliding bodies along the linear velocity of the bodies during the time step, - if during the extrusion colliding contact are found, a collision is declared and the normal contact resolution is called. - - for continuous collision to be active the continuous collision mode must on the material pair of the colliding bodies as well as on at least one of the two colliding bodies. - - Because there is penalty of about 40% to 80% depending of the shape complexity of the collision geometry, this feature is set - off by default. It is the job of the application to determine what bodies need this feature on. Good guidelines are: very small objects, - and bodies that move a height speed. - - See also: ::NewtonBodyGetContinuousCollisionMode, ::NewtonBodySetContinuousCollisionMode -*/ -void NewtonBodySetContinuousCollisionMode(const NewtonBody* const bodyPtr, unsigned state) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - body->SetContinueCollisionMode (state ? true : false); -} - -int NewtonBodyGetSerializedID(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return body->GetSerializedID(); -} - -/*! - Get the continuous collision state mode for this rigid body. - - @param *bodyPtr pointer to the body. - - @return Nothing. - - - Because there is there is penalty of about 3 to 5 depending of the shape complexity of the collision geometry, this feature is set - off by default. It is the job of the application to determine what bodies need this feature on. Good guidelines are: very small objects, - and bodies that move a height speed. - - this feature is currently disabled: - - See also: ::NewtonBodySetContinuousCollisionMode, ::NewtonBodySetContinuousCollisionMode -*/ -int NewtonBodyGetContinuousCollisionMode (const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return body->GetContinueCollisionMode () ? 1 : false; -} - - - -/*! - Set the collision state flag of this body when the body is connected to another body by a hierarchy of joints. - - @param *bodyPtr pointer to the body. - @param state collision state. 1 indicates this body will collide with any linked body. 0 disable collision with body connected to this one by joints. - - @return Nothing. - - sometimes when making complicated arrangements of linked bodies it is possible the collision geometry of these bodies is in the way of the - joints work space. This could be a problem for the normal operation of the joints. When this situation happens the application can determine which bodies - are the problem and disable collision for those bodies while they are linked by joints. For the collision to be disable for a pair of body, - both bodies must have the collision disabled. If the joints connecting the bodies are destroyed these bodies become collidable automatically. - This feature can also be achieved by making special material for the whole configuration of jointed bodies, however it is a lot easier just to set collision disable - for jointed bodies. - - See also: ::NewtonBodySetMaterialGroupID -*/ -void NewtonBodySetJointRecursiveCollision(const NewtonBody* const bodyPtr, unsigned state) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - body->SetCollisionWithLinkedBodies (state ? true : false); -} - -/*! - Get the collision state flag when the body is joint. - - @param *bodyPtr pointer to the body. - - @return return the collision state flag for this body. - - See also: ::NewtonBodySetMaterialGroupID -*/ -int NewtonBodyGetJointRecursiveCollision (const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - return body->GetCollisionWithLinkedBodies () ? 1 : 0; -} - -/*! - get the freeze state of this body - - @param *bodyPtr is the pointer to the body to be frozen - - @return 1 id the bode is frozen, 0 if bode is unfrozen. - - When a body is created it is automatically placed in the active simulation list. As an optimization - for large scenes, you may use this function to put background bodies in an inactive equilibrium state. - - This function tells Newton that this body does not currently need to be simulated. - However, if the body is part of a larger configuration it may be affected indirectly by the reaction forces - of objects that it is connected to. - - See also: ::NewtonBodySetAutoSleep, ::NewtonBodyGetAutoSleep -*/ -int NewtonBodyGetFreezeState(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return body->GetFreeze() ? 1 : 0; -} - - -/*! - This function tells Newton to simulate or suspend simulation of this body and all other bodies in contact with it - - @param *bodyPtr is the pointer to the body to be activated - @param state 1 teels newton to freeze the bode and allconceted bodiesm, 0 to unfreze it - - @return Nothing - - This function to no activate the body, is just lock or unlock the body for physics simulation. - - See also: ::NewtonBodyGetFreezeState, ::NewtonBodySetAutoSleep, ::NewtonBodyGetAutoSleep -*/ -void NewtonBodySetFreezeState(const NewtonBody* const bodyPtr, int state) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - body->SetFreeze(state ? true : false); -} - -int NewtonBodyGetGyroscopicTorque(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return body->GetGyroMode() ? 1 : 0; -} - -void NewtonBodySetGyroscopicTorque(const NewtonBody* const bodyPtr, int state) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - body->SetGyroMode(state ? true : false); -} - -/*! - Set the auto-activation mode for this body. - - @param *bodyPtr is the pointer to the body. - @param state active mode: 1 = auto-activation on (controlled by Newton). 0 = auto-activation off and body is active all the time. - - @return Nothing. - - Bodies are created with auto-activation on by default. - - Auto activation enabled is the default state for the majority of bodies in a large scene. - However, for player control, ai control or some other special circumstance, the application may want to control - the activation/deactivation of the body. - In that case, the application may call NewtonBodySetAutoSleep (body, 0) followed by - NewtonBodySetFreezeState(body), this will make the body active forever. - - See also: ::NewtonBodyGetFreezeState, ::NewtonBodySetFreezeState, ::NewtonBodyGetAutoSleep -*/ -void NewtonBodySetAutoSleep(const NewtonBody* const bodyPtr, int state) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - body->SetAutoSleep (state ? true : false); -} - -/*! - Get the auto-activation state of the body. - - @param *bodyPtr is the pointer to the body. - - @return Auto activation state: 1 = auto-activation on. 0 = auto-activation off. - - See also: ::NewtonBodySetAutoSleep, ::NewtonBodyGetSleepState -*/ -int NewtonBodyGetAutoSleep(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - return body->GetAutoSleep () ? 1 : 0; -} - - -/*! - Return the sleep mode of a rigid body. - - @param *bodyPtr is the pointer to the body. - - @return Sleep state: 0 = active. 1 = sleeping. - - See also: ::NewtonBodySetAutoSleep -*/ -int NewtonBodyGetSleepState(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - return body->GetSleepState() ? 1 : 0; -} - -void NewtonBodySetSleepState(const NewtonBody* const bodyPtr, int state) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - body->SetSleepState(state ? true : false); -} - - -/*! - Get the world axis aligned bounding box (AABB) of the body. - - @param *bodyPtr is the pointer to the body. - @param *p0 - pointer to an array of at least three floats to hold minimum value for the AABB. - @param *p1 - pointer to an array of at least three floats to hold maximum value for the AABB. - -*/ -void NewtonBodyGetAABB(const NewtonBody* const bodyPtr, dFloat* const p0, dFloat* const p1) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgVector vector0; - dgVector vector1; - - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - body->GetAABB (vector0, vector1); - - p0[0] = vector0.m_x; - p0[1] = vector0.m_y; - p0[2] = vector0.m_z; - - p1[0] = vector1.m_x; - p1[1] = vector1.m_y; - p1[2] = vector1.m_z; -} - -/*! - Set the global linear velocity of the body. - - @param *bodyPtr is the pointer to the body. - @param *velocity pointer to an array of at least three floats containing the velocity vector. - - See also: ::NewtonBodyGetVelocity -*/ -void NewtonBodySetVelocity(const NewtonBody* const bodyPtr, const dFloat* const velocity) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - dgVector vector (velocity[0], velocity[1], velocity[2], dgFloat32 (0.0f)); - body->SetVelocity (vector); -} - -void NewtonBodySetVelocityNoSleep(const NewtonBody* const bodyPtr, const dFloat* const velocity) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - dgVector vector(velocity[0], velocity[1], velocity[2], dgFloat32(0.0f)); - body->SetVelocityNoSleep(vector); -} - - -/*! - Get the global linear velocity of the body. - - @param *bodyPtr is the pointer to the body. - @param *velocity pointer to an array of at least three floats to hold the velocity vector. - - See also: ::NewtonBodySetVelocity -*/ -void NewtonBodyGetVelocity(const NewtonBody* const bodyPtr, dFloat* const velocity) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgBody* const body = (dgBody *)bodyPtr; - - dgVector vector (body->GetVelocity()); - velocity[0] = vector.m_x; - velocity[1] = vector.m_y; - velocity[2] = vector.m_z; -} - -/*! - Set the global angular velocity of the body. - - @param *bodyPtr is the pointer to the body. - @param *omega pointer to an array of at least three floats containing the angular velocity vector. - - See also: ::NewtonBodyGetOmega -*/ -void NewtonBodySetOmega(const NewtonBody* const bodyPtr, const dFloat* const omega) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - dgVector vector (omega[0], omega[1], omega[2], dgFloat32 (0.0f)); - body->SetOmega (vector); -} - -void NewtonBodySetOmegaNoSleep(const NewtonBody* const bodyPtr, const dFloat* const omega) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - dgVector vector(omega[0], omega[1], omega[2], dgFloat32(0.0f)); - body->SetOmegaNoSleep(vector); -} - -/*! - Get the global angular velocity of the body. - - @param *bodyPtr is the pointer to the body - @param *omega pointer to an array of at least three floats to hold the angular velocity vector. - - See also: ::NewtonBodySetOmega -*/ -void NewtonBodyGetOmega(const NewtonBody* const bodyPtr, dFloat* const omega) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgBody* const body = (dgBody *)bodyPtr; - - dgVector vector (body->GetOmega()); - omega[0] = vector.m_x; - omega[1] = vector.m_y; - omega[2] = vector.m_z; -} - - -/*! -Get the global angular accelration of the body. - -@param *bodyPtr is the pointer to the body -@param *omega pointer to an array of at least three floats to hold the angular acceleration vector. -*/ -void NewtonBodyGetAlpha(const NewtonBody* const bodyPtr, dFloat* const alpha) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - const dgVector vector(body->GetAlpha()); - alpha[0] = vector.m_x; - alpha[1] = vector.m_y; - alpha[2] = vector.m_z; -} - - -/*! -Get the global linear Acceleration of the body. - -@param *bodyPtr is the pointer to the body. -@param *acceleration pointer to an array of at least three floats to hold the acceleration vector. - -See also: ::NewtonBodySetVelocity -*/ -void NewtonBodyGetAcceleration(const NewtonBody* const bodyPtr, dFloat* const acceleration) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - dgVector vector(body->GetAccel()); - acceleration[0] = vector.m_x; - acceleration[1] = vector.m_y; - acceleration[2] = vector.m_z; -} - -/*! - Apply the linear viscous damping coefficient to the body. - - @param *bodyPtr is the pointer to the body. - @param linearDamp linear damping coefficient. - - the default value of *linearDamp* is clamped to a value between 0.0 and 1.0; the default value is 0.1, - There is a non zero implicit attenuation value of 0.0001 assume by the integrator. - - The dampening viscous friction force is added to the external force applied to the body every frame before going to the solver-integrator. - This force is proportional to the square of the magnitude of the velocity to the body in the opposite direction of the velocity of the body. - An application can set *linearDamp* to zero when the application takes control of the external forces and torque applied to the body, should the application - desire to have absolute control of the forces over that body. However, it is recommended that the *linearDamp* coefficient is set to a non-zero - value for the majority of background bodies. This saves the application from having to control these forces and also prevents the integrator from - adding very large velocities to a body. - - See also: ::NewtonBodyGetLinearDamping -*/ -void NewtonBodySetLinearDamping(const NewtonBody* const bodyPtr, dFloat linearDamp) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - body->SetLinearDamping (linearDamp); -} - -/*! - Get the linear viscous damping of the body. - - @param *bodyPtr is the pointer to the body. - - @return The linear damping coefficient. - - See also: ::NewtonBodySetLinearDamping -*/ -dFloat NewtonBodyGetLinearDamping(const NewtonBody* const bodyPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - return body->GetLinearDamping(); -} - - -/*! - Apply the angular viscous damping coefficient to the body. - - @param *bodyPtr is the pointer to the body. - @param *angularDamp pointer to an array of at least three floats containing the angular damping coefficients for the principal axis of the body. - - the default value of *angularDamp* is clamped to a value between 0.0 and 1.0; the default value is 0.1, - There is a non zero implicit attenuation value of 0.0001 assumed by the integrator. - - The dampening viscous friction torque is added to the external torque applied to the body every frame before going to the solver-integrator. - This torque is proportional to the square of the magnitude of the angular velocity to the body in the opposite direction of the angular velocity of the body. - An application can set *angularDamp* to zero when the to take control of the external forces and torque applied to the body, should the application - desire to have absolute control of the forces over that body. However, it is recommended that the *linearDamp* coefficient be set to a non-zero - value for the majority of background bodies. This saves the application from needing to control these forces and also prevents the integrator from - adding very large velocities to a body. - - See also: ::NewtonBodyGetAngularDamping -*/ -void NewtonBodySetAngularDamping(const NewtonBody* const bodyPtr, const dFloat* angularDamp) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - dgVector vector (angularDamp[0], angularDamp[1], angularDamp[2], dgFloat32 (0.0f)); - body->SetAngularDamping (vector); -} - - -/*! - Get the linear viscous damping of the body. - - @param *bodyPtr is the pointer to the body. - @param *angularDamp pointer to an array of at least three floats to hold the angular damping coefficient for the principal axis of the body. - - See also: ::NewtonBodySetAngularDamping -*/ -void NewtonBodyGetAngularDamping(const NewtonBody* const bodyPtr, dFloat* angularDamp) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - -// dgVector& vector = *((dgVector*) angularDamp); -// vector = body->GetAngularDamping(); - - dgVector vector (body->GetAngularDamping()); - angularDamp[0] = vector.m_x; - angularDamp[1] = vector.m_y; - angularDamp[2] = vector.m_z; -} - - - -void NewtonBodyGetPointVelocity (const NewtonBody* const bodyPtr, const dFloat* const point, dFloat* const velocOut) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - dgVector veloc (body->GetVelocityAtPoint (dgVector (point[0], point[1], point[2], dgFloat32 (0.0f)))); - velocOut[0] = veloc[0]; - velocOut[1] = veloc[1]; - velocOut[2] = veloc[2]; -} - -/*! - Add an impulse to a specific point on a body. - - @param *bodyPtr is the pointer to the body. - @param pointDeltaVeloc pointer to an array of at least three floats containing the desired change in velocity to point pointPosit. - @param pointPosit - pointer to an array of at least three floats containing the center of the impulse in global space. - @param timestep - the update rate time step. - - @return Nothing. - - This function will activate the body. - - *pointPosit* and *pointDeltaVeloc* must be specified in global space. - - *pointDeltaVeloc* represent a change in velocity. For example, a value of *pointDeltaVeloc* of (1, 0, 0) changes the velocity - of *bodyPtr* in such a way that the velocity of point *pointDeltaVeloc* will increase by (1, 0, 0) - - *the calculate impulse will be applied to the body on next frame update - - Because *pointDeltaVeloc* represents a change in velocity, this function must be used with care. Repeated calls - to this function will result in an increase of the velocity of the body and may cause to integrator to lose stability. -*/ -void NewtonBodyAddImpulse(const NewtonBody* const bodyPtr, const dFloat* const pointDeltaVeloc, const dFloat* const pointPosit, dFloat timestep) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - if (body->GetInvMass().m_w > dgFloat32 (0.0f)) { - dgVector p (pointPosit[0], pointPosit[1], pointPosit[2], dgFloat32 (0.0f)); - dgVector v (pointDeltaVeloc[0], pointDeltaVeloc[1], pointDeltaVeloc[2], dgFloat32 (0.0f)); - body->AddImpulse (v, p, timestep); - } -} - - -/*! - Add an train of impulses to a specific point on a body. - - @param *bodyPtr is the pointer to the body. - @param impulseCount - number of impulses and distances in the array distance - @param strideInByte - sized in bytes of vector impulse and - @param impulseArray pointer to an array containing the desired impulse to apply ate position point array. - @param pointArray pointer to an array of at least three floats containing the center of the impulse in global space. - @param timestep - the update rate time step. - - @return Nothing. - - This function will activate the body. - - *pointPosit* and *pointDeltaVeloc* must be specified in global space. - - *the calculate impulse will be applied to the body on next frame update - - this function apply at general impulse to a body a oppose to a desired change on velocity - this mean that the body mass, and Inertia will determine the gain on velocity. -*/ -void NewtonBodyApplyImpulseArray (const NewtonBody* const bodyPtr, int impulseCount, int strideInByte, const dFloat* const impulseArray, const dFloat* const pointArray, dFloat timestep) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - if (body->GetInvMass().m_w > dgFloat32 (0.0f)) { - body->ApplyImpulsesAtPoint (impulseCount, strideInByte, impulseArray, pointArray, timestep); - } -} - -void NewtonBodyApplyImpulsePair (const NewtonBody* const bodyPtr, dFloat* const linearImpulse, dFloat* const angularImpulse, dFloat timestep) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - if (body->GetInvMass().m_w > dgFloat32 (0.0f)) { - dgVector l (linearImpulse[0], linearImpulse[1], linearImpulse[2], dgFloat32 (0.0f)); - dgVector a (angularImpulse[0], angularImpulse[1], angularImpulse[2], dgFloat32 (0.0f)); - body->ApplyImpulsePair (l, a, timestep); - } -} - -void NewtonBodyIntegrateVelocity (const NewtonBody* const bodyPtr, dFloat timestep) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBody* const body = (dgBody *)bodyPtr; - - if (body->IsRTTIType(dgBody::m_kinematicBody) || (body->GetInvMass().m_w > dgFloat32 (0.0f))) { - body->IntegrateVelocity(timestep); - } -} - -/*! @} */ // end of RigidBodyInterface - -/*! @defgroup ConstraintBall ConstraintBall -Ball and Socket joint interface -@{ -*/ - - -/*! - Create a ball an socket joint. - - @param *newtonWorld Pointer to the Newton world. - @param *pivotPoint is origin of ball and socket in global space. - @param *childBody is the pointer to the attached rigid body, this body can not be NULL or it can not have an infinity (zero) mass. - @param *parentBody is the pointer to the parent rigid body, this body can be NULL or any kind of rigid body. - - @return Pointer to the ball and socket joint. - - This function creates a ball and socket and add it to the world. By default joint disables collision with the linked bodies. -*/ -NewtonJoint* NewtonConstraintCreateBall(const NewtonWorld* const newtonWorld, - const dFloat* pivotPoint, - const NewtonBody* const childBody, - const NewtonBody* const parentBody) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgBody* const body0 = (dgBody *)childBody; - dgBody* const body1 = (dgBody *)parentBody; - dgVector pivot (pivotPoint[0], pivotPoint[1], pivotPoint[2], dgFloat32 (0.0f)); - return (NewtonJoint*) world->CreateBallConstraint (pivot, body0, body1); -} - -/*! - Set the ball and socket cone and twist limits. - - @param *ball is the pointer to a ball and socket joint. - @param *pin pointer to a unit vector defining the cone axis in global space. - @param maxConeAngle max angle in radians the attached body is allow to swing relative to the pin axis, a value of zero will disable this limits. - @param maxTwistAngle max angle in radians the attached body is allow to twist relative to the pin axis, a value of zero will disable this limits. - - limits are disabled at creation time. A value of zero for *maxConeAngle* disable the cone limit, a value of zero for *maxTwistAngle* disable the twist limit - all non-zero value for *maxConeAngle* are clamped between 5 degree and 175 degrees - - See also: ::NewtonConstraintCreateBall -*/ -void NewtonBallSetConeLimits(const NewtonJoint* const ball, const dFloat* pin, dFloat maxConeAngle, dFloat maxTwistAngle) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBallConstraint* const joint = (dgBallConstraint*) ball; - - dgVector coneAxis (pin[0], pin[1], pin[2], dgFloat32 (0.0f)); - - if (coneAxis.DotProduct(coneAxis).GetScalar() < 1.0e-3f) { - coneAxis.m_x = dgFloat32(1.0f); - } - dgVector tmp (dgFloat32 (1.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - if (dgAbs (tmp.DotProduct(coneAxis).GetScalar()) > dgFloat32 (0.999f)) { - tmp = dgVector (dgFloat32 (0.0f), dgFloat32(1.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - if (dgAbs (tmp.DotProduct(coneAxis).GetScalar()) > dgFloat32 (0.999f)) { - tmp = dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32(1.0f), dgFloat32 (0.0f)); - dgAssert (dgAbs (tmp.DotProduct(coneAxis).GetScalar()) < dgFloat32 (0.999f)); - } - } - dgVector lateral (tmp.CrossProduct(coneAxis)); - dgAssert(lateral.m_w = dgFloat32(0.0f)); - dgAssert(coneAxis.m_w = dgFloat32(0.0f)); - lateral = lateral.Normalize(); - coneAxis = coneAxis.Normalize(); - - maxConeAngle = dgAbs (maxConeAngle); - maxTwistAngle = dgAbs (maxTwistAngle); - joint->SetConeLimitState ((maxConeAngle > dgDegreeToRad) ? true : false); - joint->SetTwistLimitState ((maxTwistAngle > dgDegreeToRad) ? true : false); - joint->SetLatealLimitState (false); - joint->SetLimits (coneAxis, -maxConeAngle, maxConeAngle, maxTwistAngle, lateral, 0.0f, 0.0f); -} - - -/*! - Set an update call back to be called when either of the two bodies linked by the joint is active. - - @param *ball pointer to the joint. - @param callback pointer to the joint function call back. - - @return nothing. - - if the application wants to have some feedback from the joint simulation, the application can register a function - update callback to be called every time any of the bodies linked by this joint is active. This is useful to provide special - effects like particles, sound or even to simulate breakable moving parts. - - See also: ::NewtonJointSetUserData -*/ -void NewtonBallSetUserCallback(const NewtonJoint* const ball, NewtonBallCallback callback) -{ - dgBallConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgBallConstraint*) ball; - contraint->SetJointParameterCallback ((dgBallJointFriction)callback); -} - - -/*! - Get the relative joint angle between the two bodies. - - @param *ball pointer to the joint. - @param *angle pointer to an array of a least three floats to hold the joint relative Euler angles. - - @return nothing. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can play a bell sound when the joint angle passes some max value. - - See also: ::NewtonBallSetUserCallback -*/ -void NewtonBallGetJointAngle (const NewtonJoint* const ball, dFloat* angle) -{ - dgBallConstraint* contraint; - - contraint = (dgBallConstraint*) ball; - dgVector angleVector (contraint->GetJointAngle ()); - - TRACE_FUNCTION(__FUNCTION__); - angle[0] = angleVector.m_x; - angle[1] = angleVector.m_y; - angle[2] = angleVector.m_z; -} - -/*! - Get the relative joint angular velocity between the two bodies. - - @param *ball pointer to the joint. - @param *omega pointer to an array of a least three floats to hold the joint relative angular velocity. - - @return nothing. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can play the creaky noise of a hanging lamp. - - See also: ::NewtonBallSetUserCallback -*/ -void NewtonBallGetJointOmega(const NewtonJoint* const ball, dFloat* omega) -{ - dgBallConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgBallConstraint*) ball; - dgVector omegaVector (contraint->GetJointOmega ()); - omega[0] = omegaVector.m_x; - omega[1] = omegaVector.m_y; - omega[2] = omegaVector.m_z; -} - -/*! - Get the total force asserted over the joint pivot point, to maintain the constraint. - - @param *ball pointer to the joint. - @param *force pointer to an array of a least three floats to hold the force value of the joint. - - @return nothing. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can destroy the joint if the force exceeds some predefined value. - - See also: ::NewtonBallSetUserCallback -*/ -void NewtonBallGetJointForce(const NewtonJoint* const ball, dFloat* const force) -{ - // fixme: type? "constraint" instead of "contraint"? - dgBallConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgBallConstraint*) ball; - dgVector forceVector (contraint->GetJointForce ()); - force[0] = forceVector.m_x; - force[1] = forceVector.m_y; - force[2] = forceVector.m_z; -} - - -/*! @} */ // end of ConstraintBall - -/*! @defgroup JointSlider JointSlider -Slider joint interface -@{ -*/ - -/*! - Create a slider joint. - - @param *newtonWorld Pointer to the Newton world. - @param *pivotPoint is origin of the slider in global space. - @param *pinDir is the line of action of the slider in global space. - @param *childBody is the pointer to the attached rigid body, this body can not be NULL or it can not have an infinity (zero) mass. - @param *parentBody is the pointer to the parent rigid body, this body can be NULL or any kind of rigid body. - - @return Pointer to the slider joint. - - This function creates a slider and add it to the world. By default joint disables collision with the linked bodies. -*/ -NewtonJoint* NewtonConstraintCreateSlider(const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir, const NewtonBody* const childBody, const NewtonBody* const parentBody) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgBody* const body0 = (dgBody *)childBody; - dgBody* const body1 = (dgBody *)parentBody; - dgVector pin (pinDir[0], pinDir[1], pinDir[2], dgFloat32 (0.0f)); - dgVector pivot (pivotPoint[0], pivotPoint[1], pivotPoint[2], dgFloat32 (0.0f)); - return (NewtonJoint*) world->CreateSlidingConstraint (pivot, pin, body0, body1); -} - - -/*! - Set an update call back to be called when either of the two body linked by the joint is active. - - @param *slider pointer to the joint. - @param callback pointer to the joint function call back. - - @return nothing. - - if the application wants to have some feedback from the joint simulation, the application can register a function - update callback to be call every time any of the bodies linked by this joint is active. This is useful to provide special - effects like particles, sound or even to simulate breakable moving parts. - - See also: ::NewtonJointGetUserData, ::NewtonJointSetUserData -*/ -void NewtonSliderSetUserCallback(const NewtonJoint* const slider, NewtonSliderCallback callback) -{ - dgSlidingConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgSlidingConstraint*) slider; - contraint->SetJointParameterCallback ((dgSlidingJointAcceleration)callback); -} - -/*! - Get the relative joint angle between the two bodies. - - @param *Slider pointer to the joint. - - @return the joint angle relative to the hinge pin. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can play a bell sound when the joint angle passes some max value. - - See also: ::NewtonSliderSetUserCallback -*/ -dFloat NewtonSliderGetJointPosit (const NewtonJoint* Slider) -{ - dgSlidingConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgSlidingConstraint*) Slider; - return contraint->GetJointPosit (); -} - -/*! - Get the relative joint angular velocity between the two bodies. - - @param *Slider pointer to the joint. - - @return the joint angular velocity relative to the pin axis. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can play the creaky noise of a hanging lamp. - - See also: ::NewtonSliderSetUserCallback -*/ -dFloat NewtonSliderGetJointVeloc(const NewtonJoint* Slider) -{ - dgSlidingConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgSlidingConstraint*) Slider; - return contraint->GetJointVeloc (); -} - - -/*! - Calculate the angular acceleration needed to stop the slider at the desired angle. - - @param *slider pointer to the joint. - @param *desc is the pointer to the Slider or slide structure. - @param distance desired stop distance relative to the pivot point - - fixme: inconsistent variable capitalisation; some functions use "slider", others "Slider". - - @return the relative linear acceleration needed to stop the slider. - - this function can only be called from a *NewtonSliderCallback* and it can be used by the application to implement slider limits. - - See also: ::NewtonSliderSetUserCallback -*/ -dFloat NewtonSliderCalculateStopAccel(const NewtonJoint* const slider, const NewtonHingeSliderUpdateDesc* const desc, dFloat distance) -{ - dgSlidingConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgSlidingConstraint*) slider; - return contraint->CalculateStopAccel (distance, (dgJointCallbackParam*) desc); -} - -/*! - Get the total force asserted over the joint pivot point, to maintain the constraint. - - @param *slider pointer to the joint. - @param *force pointer to an array of a least three floats to hold the force value of the joint. - - @return nothing. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can destroy the joint if the force exceeds some predefined value. - - See also: ::NewtonSliderSetUserCallback -*/ -void NewtonSliderGetJointForce(const NewtonJoint* const slider, dFloat* const force) -{ - dgSlidingConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgSlidingConstraint*) slider; - dgVector forceVector (contraint->GetJointForce ()); - force[0] = forceVector.m_x; - force[1] = forceVector.m_y; - force[2] = forceVector.m_z; -} - - -/*! @} */ // end of JointSlider - -/*! @defgroup JointCorkscrew JointCorkscrew -Corkscrew joint interface -@{ -*/ - -/*! - Create a corkscrew joint. - - @param *newtonWorld Pointer to the Newton world. - @param *pivotPoint is origin of the corkscrew in global space. - @param *pinDir is the line of action of the corkscrew in global space. - @param *childBody is the pointer to the attached rigid body, this body can not be NULL or it can not have an infinity (zero) mass. - @param *parentBody is the pointer to the parent rigid body, this body can be NULL or any kind of rigid body. - - @return Pointer to the corkscrew joint. - - This function creates a corkscrew and add it to the world. By default joint disables collision with the linked bodies. -*/ -NewtonJoint* NewtonConstraintCreateCorkscrew(const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir, const NewtonBody* const childBody, const NewtonBody* const parentBody) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgBody* const body0 = (dgBody *)childBody; - dgBody* const body1 = (dgBody *)parentBody; - dgVector pin (pinDir[0], pinDir[1], pinDir[2], dgFloat32 (0.0f)); - dgVector pivot (pivotPoint[0], pivotPoint[1], pivotPoint[2], dgFloat32 (0.0f)); - return (NewtonJoint*) world->CreateCorkscrewConstraint (pivot, pin, body0, body1); -} - -/*! - Set an update call back to be called when either of the two body linked by the joint is active. - - @param *corkscrew pointer to the joint. - @param callback pointer to the joint function call back. - - @return nothing. - - if the application wants to have some feedback from the joint simulation, the application can register a function - update callback to be call every time any of the bodies linked by this joint is active. This is useful to provide special - effects like particles, sound or even to simulate breakable moving parts. - - the function *NewtonCorkscrewCallback callback* should return a bit field code. - if the application does not want to set the joint acceleration the return code is zero - if the application only wants to change the joint linear acceleration the return code is 1 - if the application only wants to change the joint angular acceleration the return code is 2 - if the application only wants to change the joint angular and linear acceleration the return code is 3 - - See also: ::NewtonJointGetUserData, ::NewtonJointSetUserData -*/ -void NewtonCorkscrewSetUserCallback(const NewtonJoint* const corkscrew, NewtonCorkscrewCallback callback) -{ - dgCorkscrewConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgCorkscrewConstraint*) corkscrew; - contraint->SetJointParameterCallback ((dgCorkscrewJointAcceleration)callback); -} - -/*! - Get the relative joint angle between the two bodies. - - @param *corkscrew pointer to the joint. - - @return the joint angle relative to the hinge pin. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can play a bell sound when the joint angle passes some max value. - - See also: ::NewtonCorkscrewSetUserCallback -*/ -dFloat NewtonCorkscrewGetJointPosit (const NewtonJoint* const corkscrew) -{ - dgCorkscrewConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgCorkscrewConstraint*) corkscrew; - return contraint->GetJointPosit (); -} - -/*! - Get the relative joint angular velocity between the two bodies. - - @param *corkscrew pointer to the joint. - - @return the joint angular velocity relative to the pin axis. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can play the creaky noise of a hanging lamp. - - See also: ::NewtonCorkscrewSetUserCallback -*/ -dFloat NewtonCorkscrewGetJointVeloc(const NewtonJoint* const corkscrew) -{ - dgCorkscrewConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgCorkscrewConstraint*) corkscrew; - return contraint->GetJointVeloc (); -} - -/*! - Get the relative joint angle between the two bodies. - - @param *corkscrew pointer to the joint. - - @return the joint angle relative to the corkscrew pin. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can play a bell sound when the joint angle passes some max value. - - See also: ::NewtonCorkscrewSetUserCallback -*/ -dFloat NewtonCorkscrewGetJointAngle (const NewtonJoint* const corkscrew) -{ - dgCorkscrewConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgCorkscrewConstraint*) corkscrew; - return contraint->GetJointAngle (); - -} - -/*! - Get the relative joint angular velocity between the two bodies. - - @param *corkscrew pointer to the joint. - - @return the joint angular velocity relative to the pin axis. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can play the creaky noise of a hanging lamp. - - See also: ::NewtonCorkscrewSetUserCallback -*/ -dFloat NewtonCorkscrewGetJointOmega(const NewtonJoint* const corkscrew) -{ - dgCorkscrewConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgCorkscrewConstraint*) corkscrew; - return contraint->GetJointOmega (); -} - - -/*! - Calculate the angular acceleration needed to stop the corkscrew at the desired angle. - - @param *corkscrew pointer to the joint. - @param *desc is the pointer to the Corkscrew or slide structure. - @param angle is the desired corkscrew stop angle - - @return the relative angular acceleration needed to stop the corkscrew. - - this function can only be called from a *NewtonCorkscrewCallback* and it can be used by the application to implement corkscrew limits. - - See also: ::NewtonCorkscrewSetUserCallback -*/ -dFloat NewtonCorkscrewCalculateStopAlpha (const NewtonJoint* const corkscrew, const NewtonHingeSliderUpdateDesc* const desc, dFloat angle) -{ - dgCorkscrewConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgCorkscrewConstraint*) corkscrew; - return contraint->CalculateStopAlpha (angle, (dgJointCallbackParam*) desc); -} - - -/*! - Calculate the angular acceleration needed to stop the corkscrew at the desired angle. - - @param *corkscrew pointer to the joint. - @param *desc is the pointer to the Corkscrew or slide structure. - @param distance desired stop distance relative to the pivot point - - @return the relative linear acceleration needed to stop the corkscrew. - - this function can only be called from a *NewtonCorkscrewCallback* and it can be used by the application to implement corkscrew limits. - - See also: ::NewtonCorkscrewSetUserCallback -*/ -dFloat NewtonCorkscrewCalculateStopAccel(const NewtonJoint* const corkscrew, const NewtonHingeSliderUpdateDesc* const desc, dFloat distance) -{ - dgCorkscrewConstraint* contraint; - contraint = (dgCorkscrewConstraint*) corkscrew; - return contraint->CalculateStopAccel (distance, (dgJointCallbackParam*) desc); -} - -/*! - Get the total force asserted over the joint pivot point, to maintain the constraint. - - @param *corkscrew pointer to the joint. - @param *force pointer to an array of a least three floats to hold the force value of the joint. - - @return nothing. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can destroy the joint if the force exceeds some predefined value. - - See also: ::NewtonCorkscrewSetUserCallback -*/ -void NewtonCorkscrewGetJointForce(const NewtonJoint* const corkscrew, dFloat* const force) -{ - dgCorkscrewConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgCorkscrewConstraint*) corkscrew; - dgVector forceVector (contraint->GetJointForce ()); - force[0] = forceVector.m_x; - force[1] = forceVector.m_y; - force[2] = forceVector.m_z; -} - - -/*! @} */ // end of JointSlider - -/*! @defgroup JointUniversal JointUniversal -Universal joint interface -@{ -*/ - -/*! - Create a universal joint. - - @param *newtonWorld Pointer to the Newton world. - @param *pivotPoint is origin of the universal joint in global space. - @param *pinDir0 - first axis of rotation fixed on childBody body and perpendicular to pinDir1. - @param *pinDir1 - second axis of rotation fixed on parentBody body and perpendicular to pinDir0. - @param *childBody is the pointer to the attached rigid body, this body can not be NULL or it can not have an infinity (zero) mass. - @param *parentBody is the pointer to the parent rigid body, this body can be NULL or any kind of rigid body. - - @return Pointer to the universal joint. - - This function creates a universal joint and add it to the world. By default joint disables collision with the linked bodies. - - a universal joint is a constraint that restricts twp rigid bodies to be connected to a point fixed on both bodies, - while and allowing one body to spin around a fix axis in is own frame, and the other body to spin around another axis fixes on - it own frame. Both axis must be mutually perpendicular. -*/ -NewtonJoint* NewtonConstraintCreateUniversal(const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, - const dFloat* pinDir0, const dFloat* pinDir1, const NewtonBody* const childBody, const NewtonBody* const parentBody) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgBody* const body0 = (dgBody *)childBody; - dgBody* const body1 = (dgBody *)parentBody; - dgVector pin0 (pinDir0[0], pinDir0[1], pinDir0[2], dgFloat32 (0.0f)); - dgVector pin1 (pinDir1[0], pinDir1[1], pinDir1[2], dgFloat32 (0.0f)); - dgVector pivot (pivotPoint[0], pivotPoint[1], pivotPoint[2], dgFloat32 (0.0f)); - return (NewtonJoint*) world->CreateUniversalConstraint (pivot, pin0, pin1, body0, body1); -} - - -/*! - Set an update call back to be called when either of the two body linked by the joint is active. - - @param *universal pointer to the joint. - @param callback pointer to the joint function call back. - - @return nothing. - - if the application wants to have some feedback from the joint simulation, the application can register a function - update callback to be called every time any of the bodies linked by this joint is active. This is useful to provide special - effects like particles, sound or even to simulate breakable moving parts. - - the function *NewtonUniversalCallback callback* should return a bit field code. - if the application does not want to set the joint acceleration the return code is zero - if the application only wants to change the joint linear acceleration the return code is 1 - if the application only wants to change the joint angular acceleration the return code is 2 - if the application only wants to change the joint angular and linear acceleration the return code is 3 - - See also: ::NewtonJointGetUserData, ::NewtonJointSetUserData -*/ -void NewtonUniversalSetUserCallback(const NewtonJoint* const universal, NewtonUniversalCallback callback) -{ - dgUniversalConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgUniversalConstraint*) universal; - contraint->SetJointParameterCallback ((dgUniversalJointAcceleration)callback); -} - - -/*! - Get the relative joint angle between the two bodies. - - @param *universal pointer to the joint. - - @return the joint angle relative to the universal pin0. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can play a bell sound when the joint angle passes some max value. - - See also: ::NewtonUniversalSetUserCallback -*/ -dFloat NewtonUniversalGetJointAngle0(const NewtonJoint* const universal) -{ - dgUniversalConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgUniversalConstraint*) universal; - return contraint->GetJointAngle0 (); -} - -/*! - Get the relative joint angle between the two bodies. - - @param *universal pointer to the joint. - - @return the joint angle relative to the universal pin1. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can play a bell sound when the joint angle passes some max value. - - See also: ::NewtonUniversalSetUserCallback -*/ -dFloat NewtonUniversalGetJointAngle1(const NewtonJoint* const universal) -{ - dgUniversalConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgUniversalConstraint*) universal; - return contraint->GetJointAngle1 (); -} - - -/*! - Get the relative joint angular velocity between the two bodies. - - @param *universal pointer to the joint. - - @return the joint angular velocity relative to the pin0 axis. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can play the creaky noise of a hanging lamp. - - See also: ::NewtonUniversalSetUserCallback -*/ -dFloat NewtonUniversalGetJointOmega0(const NewtonJoint* const universal) -{ - dgUniversalConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgUniversalConstraint*) universal; - return contraint->GetJointOmega0 (); -} - - -/*! - Get the relative joint angular velocity between the two bodies. - - @param *universal pointer to the joint. - - @return the joint angular velocity relative to the pin1 axis. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can play the creaky noise of a hanging lamp. - - See also: ::NewtonUniversalSetUserCallback -*/ -dFloat NewtonUniversalGetJointOmega1(const NewtonJoint* const universal) -{ - dgUniversalConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgUniversalConstraint*) universal; - return contraint->GetJointOmega1 (); -} - - - -/*! - Calculate the angular acceleration needed to stop the universal at the desired angle. - - @param *universal pointer to the joint. - @param *desc is the pointer to the Universal or slide structure. - @param angle is the desired universal stop angle rotation around pin0 - - @return the relative angular acceleration needed to stop the universal. - - this function can only be called from a *NewtonUniversalCallback* and it can be used by the application to implement universal limits. - - See also: ::NewtonUniversalSetUserCallback -*/ -dFloat NewtonUniversalCalculateStopAlpha0(const NewtonJoint* const universal, const NewtonHingeSliderUpdateDesc* const desc, dFloat angle) -{ - dgUniversalConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgUniversalConstraint*) universal; - return contraint->CalculateStopAlpha0 (angle, (dgJointCallbackParam*) desc); -} - -/*! - Calculate the angular acceleration needed to stop the universal at the desired angle. - - @param *universal pointer to the joint. - @param *desc is the pointer to and the Universal or slide structure. - @param angle is the desired universal stop angle rotation around pin1 - - @return the relative angular acceleration needed to stop the universal. - - this function can only be called from a *NewtonUniversalCallback* and it can be used by the application to implement universal limits. - - See also: ::NewtonUniversalSetUserCallback -*/ -dFloat NewtonUniversalCalculateStopAlpha1(const NewtonJoint* const universal, const NewtonHingeSliderUpdateDesc* const desc, dFloat angle) -{ - dgUniversalConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgUniversalConstraint*) universal; - return contraint->CalculateStopAlpha1 (angle, (dgJointCallbackParam*) desc); -} - - - -/*! - Get the total force asserted over the joint pivot point, to maintain the constraint. - - @param *universal pointer to the joint. - @param *force pointer to an array of a least three floats to hold the force value of the joint. - - @return nothing. - - this function can be used during a function update call back to provide the application with some special effect. - for example the application can destroy the joint if the force exceeds some predefined value. - - See also: ::NewtonUniversalSetUserCallback -*/ -void NewtonUniversalGetJointForce(const NewtonJoint* const universal, dFloat* const force) -{ - dgUniversalConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgUniversalConstraint*) universal; - dgVector forceVector (contraint->GetJointForce ()); - force[0] = forceVector.m_x; - force[1] = forceVector.m_y; - force[2] = forceVector.m_z; -} - - -/*! @} */ // end of JointUniversal - -/*! @defgroup JointUpVector JointUpVector -UpVector joint Interface -@{ -*/ - -/*! - Create a UpVector joint. - - @param *newtonWorld Pointer to the Newton world. - @param *pinDir is the aligning vector. - @param *body is the pointer to the attached rigid body, this body can not be NULL or it can not have an infinity (zero) mass. - - @return Pointer to the up vector joint. - - This function creates an up vector joint. An up vector joint is a constraint that allows a body to translate freely in 3d space, - but it only allows the body to rotate around the pin direction vector. This could be use by the application to control a character - with physics and collision. - - Since the UpVector joint is a unary constraint, there is not need to have user callback or user data assigned to it. - The application can simple hold to the joint handle and update the pin on the force callback function of the rigid body owning the joint. -*/ -NewtonJoint* NewtonConstraintCreateUpVector (const NewtonWorld* const newtonWorld, const dFloat* pinDir, const NewtonBody* const body) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgBody* const body0 = (dgBody *)body; - dgVector pin (pinDir[0], pinDir[1], pinDir[2], dgFloat32 (0.0f)); - return (NewtonJoint*) world->CreateUpVectorConstraint(pin, body0); -} - - -/*! - Get the up vector pin of this joint in global space. - - @param *upVector pointer to the joint. - @param *pin pointer to an array of a least three floats to hold the up vector direction in global space. - - @return nothing. - - the application ca call this function to read the up vector, this is useful to animate the up vector. - if the application is going to animated the up vector, it must do so by applying only small rotation, - too large rotation can cause vibration of the joint. - - See also: ::NewtonUpVectorSetPin -*/ -void NewtonUpVectorGetPin(const NewtonJoint* const upVector, dFloat *pin) -{ - dgUpVectorConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgUpVectorConstraint*) upVector; - - dgVector pinVector (contraint ->GetPinDir ()); - pin[0] = pinVector.m_x; - pin[1] = pinVector.m_y; - pin[2] = pinVector.m_z; -} - - -/*! - Set the up vector pin of this joint in global space. - - @param *upVector pointer to the joint. - @param *pin pointer to an array of a least three floats containing the up vector direction in global space. - - @return nothing. - - the application ca call this function to change the joint up vector, this is useful to animate the up vector. - if the application is going to animated the up vector, it must do so by applying only small rotation, - too large rotation can cause vibration of the joint. - - See also: ::NewtonUpVectorGetPin -*/ -void NewtonUpVectorSetPin(const NewtonJoint* const upVector, const dFloat *pin) -{ - dgUpVectorConstraint* contraint; - - TRACE_FUNCTION(__FUNCTION__); - contraint = (dgUpVectorConstraint*) upVector; - - dgVector pinVector (pin[0], pin[1], pin[2], dgFloat32 (0.0f)); - contraint->SetPinDir (pinVector); -} - -/*! @} */ // end of JointUpVector - -/*! @defgroup JointUser JointUser -User defined joint interface -@{ -*/ - -/*! - Create a user define bilateral joint. - - @param *newtonWorld Pointer to the Newton world. - @param maxDOF is the maximum number of degree of freedom controlled by this joint. - @param submitConstraints pointer to the joint constraint definition function call back. - @param getInfo pointer to callback for collecting joint information. - @param *childBody is the pointer to the attached rigid body, this body can not be NULL or it can not have an infinity (zero) mass. - @param *parentBody is the pointer to the parent rigid body, this body can be NULL or any kind of rigid body. - - Bilateral joint are constraints that can have up to 6 degree of freedoms, 3 linear and 3 angular. - By restricting the motion along any number of these degree of freedom a very large number of useful joint between - two rigid bodies can be accomplished. Some of the degree of freedoms restriction makes no sense, and also some - combinations are so rare that only make sense to a very specific application, the Newton engine implements the more - commons combinations like, hinges, ball and socket, etc. However if and application is in the situation that any of - the provided joints can achieve the desired effect, then the application can design it own joint. - - User defined joint is a very advance feature that should be look at, only for very especial situations. - The designer must be a person with a very good understanding of constrained dynamics, and it may be the case - that many trial have to be made before a good result can be accomplished. - - function *submitConstraints* is called before the solver state to get the jacobian derivatives and the righ hand acceleration - for the definition of the constraint. - - maxDOF is and upper bound as to how many degrees of freedoms the joint can control, usually this value - can be 6 for bilateral joints, but it can be higher for special joints like vehicles where by the used of friction clamping - the number of rows can be higher. - In general the application should determine maxDof correctly, passing an unnecessary excessive value will lead to performance decreased. - - See also: ::NewtonUserJointSetFeedbackCollectorCallback -*/ -NewtonJoint* NewtonConstraintCreateUserJoint(const NewtonWorld* const newtonWorld, int maxDOF, - NewtonUserBilateralCallback submitConstraints, - const NewtonBody* const childBody, const NewtonBody* const parentBody) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgBody* const body0 = (dgBody *)childBody; - dgBody* const body1 = (dgBody *)parentBody; - dgAssert(body0); - dgAssert(body0 != body1); - return (NewtonJoint*) new (world->dgWorld::GetAllocator()) NewtonUserJoint (world, maxDOF, submitConstraints, body0, body1); -} - -/*! - Set the solver algorithm use to calculation the constraint forces. - - @param *joint pointer to the joint. - @param *model - solve model to choose. - - model = 0 zero is the default value and tells the solver to use the best possible algorithm - model = 1 to signal the engine that is two joints form a kinematic loop - model = 2 to signal the engine this joint can be solved with a less accurate algorithm. - In case multiple joints form a kinematic loop, joints with a lower model are preffered towards an exact solution. - - See also: NewtonUserJointGetSolverModel -*/ -void NewtonUserJointSetSolverModel(const NewtonJoint* const joint, int model) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const contraint = (dgConstraint*)joint; - contraint->SetSolverModel(model); -} - -/*! -Get the solver algorithm use to calculation the constraint forces. -@param *joint pointer to the joint. - -See also: NewtonUserJointGetSolverModel -*/ -int NewtonUserJointGetSolverModel(const NewtonJoint* const joint) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const contraint = (dgConstraint*)joint; - return contraint->GetSolverModel(); -} - -void NewtonUserJointMassScale(const NewtonJoint* const joint, dFloat scaleBody0, dFloat scaleBody1) -{ - NewtonUserJoint* const contraint = (NewtonUserJoint*)joint; - dgAssert (contraint->IsBilateral()); - contraint->SetMassScale(scaleBody0, scaleBody1); -} - -/*! - Add a linear restricted degree of freedom. - - @param *joint pointer to the joint. - @param *pivot0 - pointer of a vector in global space fixed on body zero. - @param *pivot1 - pointer of a vector in global space fixed on body one. - @param *dir pointer of a unit vector in global space along which the relative position, velocity and acceleration between the bodies will be driven to zero. - - A linear constraint row calculates the Jacobian derivatives and relative acceleration required to enforce the constraint condition at - the attachment point and the pin direction considered fixed to both bodies. - - The acceleration is calculated such that the relative linear motion between the two points is zero, the application can - afterward override this value to create motors. - - after this function is call and internal DOF index will point to the current row entry in the constraint matrix. - - This function call only be called from inside a *NewtonUserBilateralCallback* callback. - - See also: ::NewtonUserJointAddAngularRow, -*/ -void NewtonUserJointAddLinearRow(const NewtonJoint* const joint, const dFloat* const pivot0, const dFloat* const pivot1, const dFloat* const dir) -{ - NewtonUserJoint* const userJoint = (NewtonUserJoint*) joint; - - TRACE_FUNCTION(__FUNCTION__); - dgVector direction (dir[0], dir[1], dir[2], dgFloat32 (0.0f)); - direction = direction.Normalize(); - dgAssert (dgAbs (direction.DotProduct(direction).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-4f)); - dgVector pivotPoint0 (pivot0[0], pivot0[1], pivot0[2], dgFloat32 (0.0f)); - dgVector pivotPoint1 (pivot1[0], pivot1[1], pivot1[2], dgFloat32 (0.0f)); - - userJoint->AddLinearRowJacobian (pivotPoint0, pivotPoint1, direction); -} - - -/*! - Add an angular restricted degree of freedom. - - @param *joint pointer to the joint. - @param relativeAngleError relative angle error between both bodies around pin axis. - @param *pin pointer of a unit vector in global space along which the relative position, velocity and acceleration between the bodies will be driven to zero. - - An angular constraint row calculates the Jacobian derivatives and relative acceleration required to enforce the constraint condition at - pin direction considered fixed to both bodies. - - The acceleration is calculated such that the relative angular motion between the two points is zero, The application can - afterward override this value to create motors. - - After this function is called and internal DOF index will point to the current row entry in the constraint matrix. - - This function call only be called from inside a *NewtonUserBilateralCallback* callback. - - This function is of not practical to enforce hard constraints, but it is very useful for making angular motors. - - See also: ::NewtonUserJointAddLinearRow -*/ -void NewtonUserJointAddAngularRow(const NewtonJoint* const joint, dFloat relativeAngleError, const dFloat* const pin) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*) joint; - dgVector direction (pin[0], pin[1], pin[2], dgFloat32 (0.0f)); - direction = direction.Normalize(); - dgAssert (dgAbs (direction.DotProduct(direction).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f)); - - userJoint->AddAngularRowJacobian (direction, relativeAngleError); -} - -/*! - set the general linear and angular Jacobian for the desired degree of freedom - - @param *joint pointer to the joint. - @param *jacobian0 - pointer of a set of six values defining the linear and angular Jacobian for body0. - @param *jacobian1 - pointer of a set of six values defining the linear and angular Jacobian for body1. - - In general this function must be used for very special effects and in combination with other joints. - it is expected that the user have a knowledge of Constrained dynamics to make a good used of this function. - Must typical application of this function are the creation of synchronization or control joints like gears, pulleys, - worm gear and some other mechanical control. - - this function set the relative acceleration for this degree of freedom to zero. It is the - application responsibility to set the relative acceleration after a call to this function - - See also: ::NewtonUserJointAddLinearRow, ::NewtonUserJointAddAngularRow -*/ -void NewtonUserJointAddGeneralRow(const NewtonJoint* const joint, const dFloat* const jacobian0, const dFloat* const jacobian1) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*) joint; - userJoint->AddGeneralRowJacobian (jacobian0, jacobian1); -} - -int NewtonUserJoinRowsCount(const NewtonJoint* const joint) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*)joint; - return userJoint->GetJacobianCount(); -} - -void NewtonUserJointGetGeneralRow(const NewtonJoint* const joint, int index, dFloat* const jacobian0, dFloat* const jacobian1) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*)joint; - userJoint->GetJacobianAt(index, jacobian0, jacobian1); -} - -/*! - Set the maximum friction value the solver is allow to apply to the joint row. - - @param *joint pointer to the joint. - @param friction maximum friction value for this row. It must be a positive value between 0.0 and INFINITY. - - This function will override the default friction values set after a call to NewtonUserJointAddLinearRow or NewtonUserJointAddAngularRow. - friction value is context sensitive, if for linear constraint friction is a Max friction force, for angular constraint friction is a - max friction is a Max friction torque. - - See also: ::NewtonUserJointSetRowMinimumFriction, ::NewtonUserJointAddLinearRow, ::NewtonUserJointAddAngularRow -*/ -void NewtonUserJointSetRowMaximumFriction(const NewtonJoint* const joint, dFloat friction) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*) joint; - userJoint->SetHighFriction (friction); -} - -/*! - Set the minimum friction value the solver is allow to apply to the joint row. - - @param *joint pointer to the joint. - @param friction friction value for this row. It must be a negative value between 0.0 and -INFINITY. - - This function will override the default friction values set after a call to NewtonUserJointAddLinearRow or NewtonUserJointAddAngularRow. - friction value is context sensitive, if for linear constraint friction is a Min friction force, for angular constraint friction is a - friction is a Min friction torque. - - See also: ::NewtonUserJointSetRowMaximumFriction, ::NewtonUserJointAddLinearRow, ::NewtonUserJointAddAngularRow -*/ -void NewtonUserJointSetRowMinimumFriction(const NewtonJoint* const joint, dFloat friction) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*) joint; - userJoint->SetLowerFriction (friction); -} - -/*! - Set the value for the desired acceleration for the current constraint row. - - @param *joint pointer to the joint. - @param acceleration desired acceleration value for this row. - - This function will override the default acceleration values set after a call to NewtonUserJointAddLinearRow or NewtonUserJointAddAngularRow. - friction value is context sensitive, if for linear constraint acceleration is a linear acceleration, for angular constraint acceleration is an - angular acceleration. - - See also: ::NewtonUserJointAddLinearRow, ::NewtonUserJointAddAngularRow -*/ -void NewtonUserJointSetRowAcceleration(const NewtonJoint* const joint, dFloat acceleration) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*) joint; - userJoint->SetAcceleration (acceleration); -} - -dFloat NewtonUserJointGetRowAcceleration (const NewtonJoint* const joint) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*) joint; - return userJoint->GetAcceleration(); -} - -void NewtonUserJointGetRowJacobian(const NewtonJoint* const joint, dFloat* const linear0, dFloat* const angular0, dFloat* const linear1, dFloat* const angular1) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*)joint; - dgJacobian jacobian0; - dgJacobian jacobian1; - userJoint->GetJacobian(jacobian0, jacobian1); - for (dgInt32 i = 0; i < 3; i++) { - linear0[i] = jacobian0.m_linear[i]; - angular0[i] = jacobian0.m_angular[i]; - linear1[i] = jacobian1.m_linear[i]; - angular1[i] = jacobian1.m_angular[i]; - } -} - -dFloat NewtonUserJointCalculateRowZeroAcceleration (const NewtonJoint* const joint) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*)joint; - return userJoint->CalculateZeroMotorAcceleration(); -} - -/*! - Calculates the row acceleration to satisfy the specified the spring damper system. - - @param *joint pointer to the joint. - @param rowStiffness fraction of the row reaction forces used a sspring damper penalty. - @param spring desired spring stiffness, it must be a positive value. - @param damper desired damper coefficient, it must be a positive value. - - This function will override the default acceleration values set after a call to NewtonUserJointAddLinearRow or NewtonUserJointAddAngularRow. - friction value is context sensitive, if for linear constraint acceleration is a linear acceleration, for angular constraint acceleration is an - angular acceleration. - - the acceleration calculated by this function represent the mass, spring system of the form - a = -ks * x - kd * v. - - for this function to take place the joint stiffness must be set to a values lower than 1.0 - - See also: ::NewtonUserJointSetRowAcceleration, ::NewtonUserJointSetRowStiffness -*/ -void NewtonUserJointSetRowSpringDamperAcceleration(const NewtonJoint* const joint, dFloat rowStiffness, dFloat spring, dFloat damper) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*) joint; - userJoint->SetSpringDamperAcceleration (rowStiffness, spring, damper); -} - -/*! - Set the maximum percentage of the constraint force that will be applied to the constraint row. - - @param *joint pointer to the joint. - @param stiffness row stiffness, it must be a values between 0.0 and 1.0, the default is 0.9. - - This function will override the default stiffness value set after a call to NewtonUserJointAddLinearRow or NewtonUserJointAddAngularRow. - the row stiffness is the percentage of the constraint force that will be applied to the rigid bodies. Ideally the value should be - 1.0 (100% stiff) but dues to numerical integration error this could be the joint a little unstable, and lower values are preferred. - - See also: ::NewtonUserJointAddLinearRow, ::NewtonUserJointAddAngularRow, ::NewtonUserJointSetRowSpringDamperAcceleration -*/ -void NewtonUserJointSetRowStiffness(const NewtonJoint* const joint, dFloat stiffness) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*) joint; - userJoint->SetRowStiffness (dgFloat32 (1.0f) - stiffness); -} - -/*! - Return the magnitude previews force or torque value calculated by the solver for this constraint row. - - @param *joint pointer to the joint. - @param row index to the constraint row. - - This function can be call for any of the previews row for this particular joint, The application must keep track of the meaning of the row. - - This function can be used to produce special effects like breakable or malleable joints, fro example a hinge can turn into ball and socket - after the force in some of the row exceed certain high value. -*/ -dFloat NewtonUserJointGetRowForce(const NewtonJoint* const joint, int row) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*) joint; - return userJoint->GetRowForce (row); -} - - -/*! - Set a constrain callback to collect the force calculated by the solver to enforce this constraint - - @param *joint pointer to the joint. - @param getFeedback pointer to the joint constraint definition function call back. - - See also: ::NewtonUserJointGetRowForce -*/ -void NewtonUserJointSetFeedbackCollectorCallback(const NewtonJoint* const joint, NewtonUserBilateralCallback getFeedback) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonUserJoint* const userJoint = (NewtonUserJoint*) joint; - return userJoint->SetUpdateFeedbackFunction (getFeedback); -} - - -/*! @} */ // end of JointUser - -/*! @defgroup JointCommon JointCommon -Joint common function s -@{ -*/ - -/*! - Store a user defined data value with the joint. - - @param *joint pointer to the joint. - @param *userData pointer to the user defined user data value. - - @return Nothing. - - The application can store a user defined value with the Joint. This value can be the pointer to a structure containing some application data for special effect. - if the application allocate some resource to store the user data, the application can register a joint destructor to get rid of the allocated resource when the Joint is destroyed - - See also: ::NewtonJointSetDestructor -*/ -void NewtonJointSetUserData(const NewtonJoint* const joint, void* const userData) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const contraint = (dgConstraint*) joint; - contraint->SetUserData (userData); -} - -/*! - Retrieve a user defined data value stored with the joint. - - @param *joint pointer to the joint. - - @return The user defined data. - - The application can store a user defined value with a joint. This value can be the pointer - to a structure to store some game play data for special effect. - - See also: ::NewtonJointSetUserData -*/ -void* NewtonJointGetUserData(const NewtonJoint* const joint) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const contraint = (dgConstraint*) joint; - return contraint->GetUserData(); -} - -/*! - Get creation parameters for this joint. - - @param joint is the pointer to a convex collision primitive. - @param *jointInfo pointer to a collision information record. - - This function can be used by the application for writing file format and for serialization. - - See also: ::// See also: -*/ -void NewtonJointGetInfo(const NewtonJoint* const joint, NewtonJointRecord* const jointInfo) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const contraint = (dgConstraint*) joint; - contraint->GetInfo ((dgConstraintInfo*) jointInfo); -} - -/*! - Get the first body connected by this joint. - - @param *joint is the pointer to a convex collision primitive. - - - See also: ::// See also: -*/ -NewtonBody* NewtonJointGetBody0(const NewtonJoint* const joint) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const contraint = (dgConstraint*) joint; - dgBody* const body = contraint->GetBody0(); - dgWorld* const world = body->GetWorld(); - return (world->GetSentinelBody() != body) ? (NewtonBody*) body : NULL; -} - - -/*! - Get the second body connected by this joint. - - @param *joint is the pointer to a convex collision primitive. - - See also: ::// See also: -*/ -NewtonBody* NewtonJointGetBody1(const NewtonJoint* const joint) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const contraint = (dgConstraint*) joint; - dgBody* const body = contraint->GetBody1(); - dgWorld* const world = body->GetWorld(); - return (world->GetSentinelBody() != body) ? (NewtonBody*) body : NULL; -} - - -/*! - Enable or disable collision between the two bodies linked by this joint. The default state is collision disable when the joint is created. - - @param *joint pointer to the joint. - @param state collision state, zero mean disable collision, non zero enable collision between linked bodies. - - @return nothing. - - usually when two bodies are linked by a joint, the application wants collision between this two bodies to be disabled. - This is the default behavior of joints when they are created, however when this behavior is not desired the application can change - it by setting collision on. If the application decides to enable collision between jointed bodies, the application should make sure the - collision geometry do not collide in the work space of the joint. - - if the joint is destroyed the collision state of the two bodies linked by this joint is determined by the material pair assigned to each body. - - See also: ::NewtonJointGetCollisionState, ::NewtonBodySetJointRecursiveCollision -*/ -void NewtonJointSetCollisionState(const NewtonJoint* const joint, int state) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const contraint = (dgConstraint*) joint; - return contraint->SetCollidable (state ? true : false); -} - -/*! - Get the collision state of the two bodies linked by the joint. - - @param *joint pointer to the joint. - - @return the collision state. - - usually when two bodies are linked by a joint, the application wants collision between this two bodies to be disabled. - This is the default behavior of joints when they are created, however when this behavior is not desired the application can change - it by setting collision on. If the application decides to enable collision between jointed bodies, the application should make sure the - collision geometry do not collide in the work space of the joint. - - See also: ::NewtonJointSetCollisionState -*/ -int NewtonJointGetCollisionState(const NewtonJoint* const joint) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const contraint = (dgConstraint*) joint; - return contraint->IsCollidable () ? 1 : 0; -} - - -/*! - Set the strength coefficient to be applied to the joint reaction forces. - - @param *joint pointer to the joint. - @param stiffness stiffness coefficient, a value between 0, and 1.0, the default value for most joint is 0.9 - - @return nothing. - - Constraint keep bodies together by calculating the exact force necessary to cancel the relative acceleration between one or - more common points fixed in the two bodies. The problem is that when the bodies drift apart due to numerical integration inaccuracies, - the reaction force work to pull eliminated the error but at the expense of adding extra energy to the system, does violating the rule - that constraint forces must be work less. This is a inevitable situation and the only think we can do is to minimize the effect of the - extra energy by dampening the force by some amount. In essence the stiffness coefficient tell Newton calculate the precise reaction force - by only apply a fraction of it to the joint point. And value of 1.0 will apply the exact force, and a value of zero will apply only - 10 percent. - - The stiffness is set to a all around value that work well for most situation, however the application can play with these - parameter to make finals adjustment. A high value will make the joint stronger but more prompt to vibration of instability; a low - value will make the joint more stable but weaker. - - See also: ::NewtonJointGetStiffness -*/ -void NewtonJointSetStiffness(const NewtonJoint* const joint, dFloat stiffness) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const contraint = (dgConstraint*) joint; - contraint->SetStiffness(dgFloat32 (1.0f) - stiffness); -} - -/*! - Get the strength coefficient bing applied to the joint reaction forces. - - @param *joint pointer to the joint. - - @return stiffness coefficient. - - Constraint keep bodies together by calculating the exact force necessary to cancel the relative acceleration between one or - more common points fixed in the two bodies. The problem is that when the bodies drift apart due to numerical integration inaccuracies, - the reaction force work to pull eliminated the error but at the expense of adding extra energy to the system, does violating the rule - that constraint forces must be work less. This is a inevitable situation and the only think we can do is to minimize the effect of the - extra energy by dampening the force by some amount. In essence the stiffness coefficient tell Newton calculate the precise reaction force - by only apply a fraction of it to the joint point. And value of 1.0 will apply the exact force, and a value of zero will apply only - 10 percent. - - The stiffness is set to a all around value that work well for most situation, however the application can play with these - parameter to make finals adjustment. A high value will make the joint stronger but more prompt to vibration of instability; a low - value will make the joint more stable but weaker. - - See also: ::NewtonJointSetStiffness -*/ -dFloat NewtonJointGetStiffness(const NewtonJoint* const joint) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const contraint = (dgConstraint*) joint; - return dgFloat32 (1.0f) - contraint->GetStiffness(); -} - -/*! - Register a destructor callback to be called when the joint is about to be destroyed. - - @param *joint pointer to the joint. - @param destructor pointer to the joint destructor callback. - - @return nothing. - - If application stores any resource with the joint, or the application wants to be notified when the - joint is about to be destroyed. The application can register a destructor call back with the joint. - - See also: ::NewtonJointSetUserData -*/ -void NewtonJointSetDestructor(const NewtonJoint* const joint, NewtonConstraintDestructor destructor) -{ - TRACE_FUNCTION(__FUNCTION__); - dgConstraint* const contraint = (dgConstraint*) joint; - contraint->SetDestructorCallback ((OnConstraintDestroy) destructor); -} - - -/*! - destroy a joint. - - @param *newtonWorld is the pointer to the body. - @param *joint pointer to joint to be destroyed - - @return nothing - - The application can call this function when it wants to destroy a joint. This function can be used by the application to simulate - breakable joints - - See also: ::NewtonConstraintCreateSlider -*/ -void NewtonDestroyJoint(const NewtonWorld* const newtonWorld, const NewtonJoint* const joint) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - world->DestroyJoint ((dgConstraint*) joint); -} - -/*! @} */ // end of JointCommon - -/*! @defgroup SpecialEffectMesh SpecialEffectMesh -Special effect mesh interface -@{ -*/ - -NewtonMesh* NewtonMeshCreate(const NewtonWorld* const newtonWorld) -{ - TRACE_FUNCTION(__FUNCTION__); - - Newton* const world = (Newton *) newtonWorld; - dgMeshEffect* const mesh = new (world->dgWorld::GetAllocator()) dgMeshEffect (world->dgWorld::GetAllocator()); - return (NewtonMesh*) mesh; -} - -NewtonMesh* NewtonMeshCreateFromMesh(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const srcMesh = (dgMeshEffect*) mesh; - - dgMeshEffect* const clone = new (srcMesh->GetAllocator()) dgMeshEffect (*srcMesh); - return (NewtonMesh*) clone; -} - -NewtonMesh* NewtonMeshCreateFromCollision(const NewtonCollision* const collision) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgCollisionInstance* const shape = (dgCollisionInstance*) collision; - dgMeshEffect* const mesh = new (shape->GetAllocator()) dgMeshEffect (shape); - return (NewtonMesh*) mesh; -} - -NewtonMesh* NewtonMeshCreateConvexHull (const NewtonWorld* const newtonWorld, int count, const dFloat* const vertexCloud, int strideInBytes, dFloat tolerance) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - dgStack<dgBigVector> pool (count); - - dgInt32 stride = strideInBytes / sizeof (dgFloat32); - for (dgInt32 i = 0; i < count; i ++) { - pool[i].m_x = vertexCloud[i * stride + 0]; - pool[i].m_y = vertexCloud[i * stride + 1]; - pool[i].m_z = vertexCloud[i * stride + 2]; - pool[i].m_w = dgFloat64 (0.0); - } - dgMeshEffect* const mesh = new (world->dgWorld::GetAllocator()) dgMeshEffect (world->dgWorld::GetAllocator(), &pool[0].m_x, count, sizeof (dgBigVector), tolerance); - return (NewtonMesh*) mesh; -} - -NewtonMesh* NewtonMeshCreateTetrahedraIsoSurface(const NewtonMesh* const closeManifoldMesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) closeManifoldMesh; - return (NewtonMesh*)meshEffect->CreateTetrahedraIsoSurface(); -} - -void NewtonCreateTetrahedraLinearBlendSkinWeightsChannel(const NewtonMesh* const tetrahedraMesh, NewtonMesh* const skinMesh) -{ - dgAssert(0); - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)skinMesh; - meshEffect->CreateTetrahedraLinearBlendSkinWeightsChannel((const dgMeshEffect*)tetrahedraMesh); -} - -NewtonMesh* NewtonMeshCreateVoronoiConvexDecomposition (const NewtonWorld* const newtonWorld, int pointCount, const dFloat* const vertexCloud, int strideInBytes, int materialID, const dFloat* const textureMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - return (NewtonMesh*) dgMeshEffect::CreateVoronoiConvexDecomposition (world->dgWorld::GetAllocator(), pointCount, strideInBytes, vertexCloud, materialID, dgMatrix (textureMatrix)); -} - -NewtonMesh* NewtonMeshCreateFromSerialization (const NewtonWorld* const newtonWorld, NewtonDeserializeCallback deserializeFunction, void* const serializeHandle) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *) newtonWorld; - return (NewtonMesh*) dgMeshEffect::CreateFromSerialization (world->dgWorld::GetAllocator(), (dgDeserialize) deserializeFunction, serializeHandle); -} - -void NewtonMeshDestroy(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - delete meshEffect; -} - -void NewtonMeshSerialize (const NewtonMesh* const mesh, NewtonSerializeCallback serializeFunction, void* const serializeHandle) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - meshEffect->Serialize ((dgSerialize) serializeFunction, serializeHandle); -} - -void NewtonMeshSaveOFF(const NewtonMesh* const mesh, const char* const filename) -{ - TRACE_FUNCTION(__FUNCTION__); - dgAssert(0); - //dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - //meshEffect->SaveOFF(filename); -} - -NewtonMesh* NewtonMeshLoadOFF(const NewtonWorld* const newtonWorld, const char* const filename) -{ - TRACE_FUNCTION(__FUNCTION__); - //Newton* const world = (Newton *) newtonWorld; - //dgMemoryAllocator* const allocator = world->dgWorld::GetAllocator(); - //dgMeshEffect* const mesh = new (allocator) dgMeshEffect (allocator); - //mesh->LoadOffMesh(filename); - //return (NewtonMesh*) mesh; - dgAssert(0); - return NULL; -} - -NewtonMesh* NewtonMeshLoadTetrahedraMesh(const NewtonWorld* const newtonWorld, const char* const filename) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - dgMemoryAllocator* const allocator = world->dgWorld::GetAllocator(); - dgMeshEffect* const mesh = new (allocator) dgMeshEffect(allocator); - mesh->LoadTetraMesh (filename); - return (NewtonMesh*)mesh; -} - -void NewtonMeshApplyTransform (const NewtonMesh* const mesh, const dFloat* const matrix) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - - meshEffect->ApplyTransform(dgMatrix (matrix)); -} - -void NewtonMeshFlipWinding(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->FlipWinding(); -} - -void NewtonMeshCalculateOOBB(const NewtonMesh* const mesh, dFloat* const matrix, dFloat* const x, dFloat* const y, dFloat* const z) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - - dgBigVector size; - dgMatrix alignMatrix (meshEffect->CalculateOOBB (size)); - -// *((dgMatrix *)matrix) = alignMatrix; - memcpy (matrix, &alignMatrix[0][0], sizeof (dgMatrix)); - *x = dgFloat32 (size.m_x); - *y = dgFloat32 (size.m_y); - *z = dgFloat32 (size.m_z); -} - -void NewtonMeshCalculateVertexNormals(const NewtonMesh* const mesh, dFloat angleInRadians) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - meshEffect->CalculateNormals (angleInRadians); -} - -void NewtonMeshApplyAngleBasedMapping(const NewtonMesh* const mesh, int material, NewtonReportProgress reportPrograssCallback, void* const reportPrgressUserData, dFloat* const aligmentMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMatrix matrix(aligmentMatrix); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - meshEffect->AngleBaseFlatteningMapping(material, (dgReportProgress) reportPrograssCallback, reportPrgressUserData); -} - -void NewtonMeshApplySphericalMapping(const NewtonMesh* const mesh, int material, const dFloat* const aligmentMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMatrix matrix(aligmentMatrix); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - meshEffect->SphericalMapping (material, matrix); -} - -void NewtonMeshApplyBoxMapping(const NewtonMesh* const mesh, int front, int side, int top, const dFloat* const aligmentMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMatrix matrix(aligmentMatrix); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - meshEffect->BoxMapping (front, side, top, matrix); -} - -void NewtonMeshApplyCylindricalMapping(const NewtonMesh* const mesh, int cylinderMaterial, int capMaterial, const dFloat* const aligmentMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMatrix matrix(aligmentMatrix); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - meshEffect->CylindricalMapping (cylinderMaterial, capMaterial, matrix); -} - -void NewtonMeshTriangulate (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - ((dgMeshEffect*) mesh)->Triangulate (); -} - -void NewtonMeshPolygonize (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - ((dgMeshEffect*) mesh)->ConvertToPolygons (); -} - - -int NewtonMeshIsOpenMesh (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - - return ((dgMeshEffect*) mesh)->HasOpenEdges () ? 1 : 0; -} - -void NewtonMeshFixTJoints (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - - return ((dgMeshEffect*) mesh)->RepairTJoints(); -} - - -void NewtonMeshClip (const NewtonMesh* const mesh, const NewtonMesh* const clipper, const dFloat* const clipperMatrix, NewtonMesh** const topMesh, NewtonMesh** const bottomMesh) -{ - TRACE_FUNCTION(__FUNCTION__); - - *topMesh = NULL; - *bottomMesh = NULL; - ((dgMeshEffect*) mesh)->ClipMesh (dgMatrix (clipperMatrix), (dgMeshEffect*)clipper, (dgMeshEffect**) topMesh, (dgMeshEffect**) bottomMesh); -} - - -NewtonMesh* NewtonMeshSimplify (const NewtonMesh* const mesh, int maxVertexCount, NewtonReportProgress progressReportCallback, void* const reportPrgressUserData) -{ - TRACE_FUNCTION(__FUNCTION__); - return (NewtonMesh*) ((dgMeshEffect*) mesh)->CreateSimplification (maxVertexCount, (dgReportProgress) progressReportCallback, reportPrgressUserData); -} - -NewtonMesh* NewtonMeshApproximateConvexDecomposition (const NewtonMesh* const mesh, dFloat maxConcavity, dFloat backFaceDistanceFactor, int maxCount, int maxVertexPerHull, NewtonReportProgress progressReportCallback, void* const reportProgressUserData) -{ - TRACE_FUNCTION(__FUNCTION__); - return (NewtonMesh*) ((dgMeshEffect*) mesh)->CreateConvexApproximation (maxConcavity, backFaceDistanceFactor, maxCount, maxVertexPerHull, (dgReportProgress) progressReportCallback, reportProgressUserData); -} - - - -NewtonMesh* NewtonMeshUnion (const NewtonMesh* const mesh, const NewtonMesh* const clipper, const dFloat* const clipperMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - return (NewtonMesh*) ((dgMeshEffect*) mesh)->Union (dgMatrix (clipperMatrix), (dgMeshEffect*)clipper); -} - - -NewtonMesh* NewtonMeshDifference (const NewtonMesh* const mesh, const NewtonMesh* const clipper, const dFloat* const clipperMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - return (NewtonMesh*) ((dgMeshEffect*) mesh)->Difference (dgMatrix (clipperMatrix), (dgMeshEffect*)clipper); -} - -NewtonMesh* NewtonMeshIntersection (const NewtonMesh* const mesh, const NewtonMesh* const clipper, const dFloat* const clipperMatrix) -{ - TRACE_FUNCTION(__FUNCTION__); - return (NewtonMesh*) ((dgMeshEffect*) mesh)->Intersection (dgMatrix (clipperMatrix), (dgMeshEffect*)clipper); -} - -NewtonMesh* NewtonMeshConvexMeshIntersection (const NewtonMesh* const mesh, const NewtonMesh* const convexMesh) -{ - TRACE_FUNCTION(__FUNCTION__); - return (NewtonMesh*) ((dgMeshEffect*) mesh)->ConvexMeshIntersection ((dgMeshEffect*)convexMesh); -} - -void NewtonRemoveUnusedVertices(const NewtonMesh* const mesh, int* const vertexRemapTable) -{ - TRACE_FUNCTION(__FUNCTION__); - ((dgMeshEffect*) mesh)->RemoveUnusedVertices (vertexRemapTable); -} - - -void NewtonMeshBeginBuild(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - meshEffect->BeginBuild(); -} - -void NewtonMeshBeginFace (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->BeginBuildFace(); -} - -void NewtonMeshEndFace(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->EndBuildFace(); -} - -void NewtonMeshAddPoint(const NewtonMesh* const mesh, dFloat64 x, dFloat64 y, dFloat64 z) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->AddPoint (x, y, z); -} - -void NewtonMeshAddMaterial(const NewtonMesh* const mesh, int materialIndex) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->AddMaterial(materialIndex); -} - -void NewtonMeshAddLayer(const NewtonMesh* const mesh, int layer) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->AddLayer(layer); -} - -void NewtonMeshAddNormal(const NewtonMesh* const mesh, dFloat x, dFloat y, dFloat z) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->AddNormal(x, y, z); -} - -void NewtonMeshAddBinormal(const NewtonMesh* const mesh, dFloat x, dFloat y, dFloat z) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->AddBinormal(x, y, z); -} - -void NewtonMeshAddUV0(const NewtonMesh* const mesh, dFloat u, dFloat v) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->AddUV0(u, v); -} - -void NewtonMeshAddUV1(const NewtonMesh* const mesh, dFloat u, dFloat v) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->AddUV1(u, v); -} - -void NewtonMeshAddVertexColor(const NewtonMesh* const mesh, dFloat32 r, dFloat32 g, dFloat32 b, dFloat32 a) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->AddVertexColor(r, g, b, a); -} - -void NewtonMeshEndBuild(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - - meshEffect->EndBuild(dgFloat64 (1.0e-8f)); -} - -void NewtonMeshClearVertexFormat (NewtonMeshVertexFormat* const format) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect::dgMeshVertexFormat* const vertexFormat = (dgMeshEffect::dgMeshVertexFormat*) format; - vertexFormat->Clear (); -} - -void NewtonMeshBuildFromVertexListIndexList (const NewtonMesh* const mesh, const NewtonMeshVertexFormat* const format) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - meshEffect->BuildFromIndexList((dgMeshEffect::dgMeshVertexFormat*) format); -} - -void NewtonMeshOptimizePoints(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->OptimizePoints(); -} - -void NewtonMeshOptimizeVertex(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->OptimizeAttibutes(); -} - -void NewtonMeshOptimize(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - NewtonMeshOptimizePoints(mesh); - NewtonMeshOptimizeVertex(mesh); -} - -int NewtonMeshGetVertexCount(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - return meshEffect->GetVertexCount(); -} - -int NewtonMeshGetVertexBaseCount(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - return meshEffect->GetVertexBaseCount(); -} - -void NewtonMeshSetVertexBaseCount(const NewtonMesh* const mesh, int baseCount) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->SetVertexBaseCount(baseCount); -} - -int NewtonMeshGetVertexStrideInByte(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - - return meshEffect->GetVertexStrideInByte(); -} - -const dFloat64* NewtonMeshGetVertexArray (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - - return meshEffect->GetVertexPool (); -} - -int NewtonMeshGetPointCount (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - return meshEffect->GetPropertiesCount(); -} - -const int* NewtonMeshGetIndexToVertexMap(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - return meshEffect->GetIndexToVertexMap(); -} - -int NewtonMeshHasNormalChannel(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - return meshEffect->HasNormalChannel() ? 1 : 0; -} - -int NewtonMeshHasBinormalChannel(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - return meshEffect->HasBinormalChannel() ? 1 : 0; -} - -int NewtonMeshHasUV0Channel(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - return meshEffect->HasUV0Channel() ? 1 : 0; -} - -int NewtonMeshHasUV1Channel(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - return meshEffect->HasUV1Channel() ? 1 : 0; -} - -int NewtonMeshHasVertexColorChannel(const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - return meshEffect->HasVertexColorChannel() ? 1 : 0; -} - -void NewtonMeshGetVertexDoubleChannel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat64* const outBuffer) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->GetVertexChannel64(vertexStrideInByte, (dgFloat64*)outBuffer); -} - -void NewtonMeshGetVertexChannel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->GetVertexChannel(vertexStrideInByte, (dgFloat32*)outBuffer); -} - -void NewtonMeshGetNormalChannel(const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->GetNormalChannel(vertexStrideInByte, (dgFloat32*)outBuffer); -} - -void NewtonMeshGetBinormalChannel(const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->GetBinormalChannel(vertexStrideInByte, (dgFloat32*)outBuffer); -} - -void NewtonMeshGetUV0Channel(const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->GetUV0Channel(vertexStrideInByte, (dgFloat32*)outBuffer); -} - -void NewtonMeshGetUV1Channel(const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->GetUV1Channel(vertexStrideInByte, (dgFloat32*)outBuffer); -} - -void NewtonMeshGetVertexColorChannel(const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*)mesh; - meshEffect->GetVertexColorChannel(vertexStrideInByte, (dgFloat32*)outBuffer); -} - - -void* NewtonMeshBeginHandle (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - - return meshEffect->MaterialGeometryBegin(); -} - -void NewtonMeshEndHandle (const NewtonMesh* const mesh, void* const handle) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - meshEffect->MaterialGeomteryEnd((dgMeshEffect::dgIndexArray*) handle); -} - - - -int NewtonMeshFirstMaterial (const NewtonMesh* const mesh, void* const handle) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - - return meshEffect->GetFirstMaterial((dgMeshEffect::dgIndexArray*) handle); -} - -int NewtonMeshNextMaterial (const NewtonMesh* const mesh, void* const handle, int materialId) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - - return meshEffect->GetNextMaterial((dgMeshEffect::dgIndexArray*) handle, materialId); -} - -int NewtonMeshMaterialGetMaterial (const NewtonMesh* const mesh, void* const handle, int materialId) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - - return meshEffect->GetMaterialID ((dgMeshEffect::dgIndexArray*) handle, materialId); -} - -int NewtonMeshMaterialGetIndexCount (const NewtonMesh* const mesh, void* const handle, int materialId) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - - return meshEffect->GetMaterialIndexCount ((dgMeshEffect::dgIndexArray*) handle, materialId); -} - -void NewtonMeshMaterialGetIndexStream (const NewtonMesh* const mesh, void* const handle, int materialId, int* const index) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - - meshEffect->GetMaterialGetIndexStream ((dgMeshEffect::dgIndexArray*) handle, materialId, index); -} - -void NewtonMeshMaterialGetIndexStreamShort (const NewtonMesh* const mesh, void* const handle, int materialId, short int* const index) -{ - TRACE_FUNCTION(__FUNCTION__); - dgMeshEffect* const meshEffect = (dgMeshEffect*) mesh; - - meshEffect->GetMaterialGetIndexStreamShort ((dgMeshEffect::dgIndexArray*) handle, materialId, index); -} - - -NewtonMesh* NewtonMeshCreateFirstSingleSegment (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgMeshEffect* const effectMesh = (dgMeshEffect*)mesh; - dgPolyhedra segment(effectMesh->GetAllocator()); - - effectMesh->BeginConectedSurface(); - if (effectMesh->GetConectedSurface (segment)) { - dgMeshEffect* const solid = new (effectMesh->GetAllocator()) dgMeshEffect(segment, *((dgMeshEffect*)mesh)); - return (NewtonMesh*)solid; - } else { - return NULL; - } -} - -NewtonMesh* NewtonMeshCreateNextSingleSegment (const NewtonMesh* const mesh, const NewtonMesh* const segment) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgMeshEffect* const effectMesh = (dgMeshEffect*)mesh; - dgPolyhedra nextSegment(effectMesh->GetAllocator()); - - dgAssert (segment); - dgInt32 moreSegments = effectMesh->GetConectedSurface (nextSegment); - - dgMeshEffect* solid; - if (moreSegments) { - solid = new (effectMesh->GetAllocator()) dgMeshEffect(nextSegment, *effectMesh); - } else { - solid = NULL; - effectMesh->EndConectedSurface(); - } - - return (NewtonMesh*)solid; -} - -NewtonMesh* NewtonMeshCreateFirstLayer (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgMeshEffect* const effectMesh = (dgMeshEffect*)mesh; - return (NewtonMesh*) effectMesh->GetFirstLayer (); -} - -NewtonMesh* NewtonMeshCreateNextLayer (const NewtonMesh* const mesh, const NewtonMesh* const segment) -{ - TRACE_FUNCTION(__FUNCTION__); - - dgMeshEffect* const effectMesh = (dgMeshEffect*)mesh; - return (NewtonMesh*) effectMesh->GetNextLayer ((dgMeshEffect*)segment); -} - - - -int NewtonMeshGetTotalFaceCount (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetTotalFaceCount(); -} - -int NewtonMeshGetTotalIndexCount (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetTotalIndexCount(); -} - -void NewtonMeshGetFaces (const NewtonMesh* const mesh, int* const faceIndexCount, int* const faceMaterial, void** const faceIndices) -{ - TRACE_FUNCTION(__FUNCTION__); - ((dgMeshEffect*)mesh)->GetFaces (faceIndexCount, faceMaterial, faceIndices); -} - - -void* NewtonMeshGetFirstVertex (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetFirstVertex (); -} - -void* NewtonMeshGetNextVertex (const NewtonMesh* const mesh, const void* const vertex) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetNextVertex (vertex); -} - -int NewtonMeshGetVertexIndex (const NewtonMesh* const mesh, const void* const vertex) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetVertexIndex (vertex); -} - -void* NewtonMeshGetFirstPoint (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetFirstPoint (); -} -void* NewtonMeshGetNextPoint (const NewtonMesh* const mesh, const void* const point) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetNextPoint (point); -} - -int NewtonMeshGetPointIndex (const NewtonMesh* const mesh, const void* const point) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetPointIndex (point); -} - -int NewtonMeshGetVertexIndexFromPoint (const NewtonMesh* const mesh, const void* const point) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetVertexIndexFromPoint (point); -} - -void* NewtonMeshGetFirstEdge (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetFirstEdge (); -} - -void* NewtonMeshGetNextEdge (const NewtonMesh* const mesh, const void* const edge) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetNextEdge (edge); -} - -void NewtonMeshGetEdgeIndices (const NewtonMesh* const mesh, const void* const edge, int* const v0, int* const v1) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetEdgeIndex (edge, *v0, *v1); -} - - -//void NewtonMeshGetEdgePointIndices (const NewtonMesh* const mesh, const void* const edge, int* const v0, int* const v1) -//{ -// return ((dgMeshEffect*)mesh)->GetEdgeAttributeIndex (edge, *v0, *v1); -//} - -void* NewtonMeshGetFirstFace (const NewtonMesh* const mesh) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetFirstFace (); -} - -void* NewtonMeshGetNextFace (const NewtonMesh* const mesh, const void* const face) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetNextFace (face); -} - -int NewtonMeshIsFaceOpen (const NewtonMesh* const mesh, const void* const face) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->IsFaceOpen (face); -} - -int NewtonMeshGetFaceIndexCount (const NewtonMesh* const mesh, const void* const face) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetFaceIndexCount (face); -} - -int NewtonMeshGetFaceMaterial (const NewtonMesh* const mesh, const void* const face) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->GetFaceMaterial (face); -} - -void NewtonMeshSetFaceMaterial (const NewtonMesh* const mesh, const void* const face, int matId) -{ - TRACE_FUNCTION(__FUNCTION__); - return ((dgMeshEffect*)mesh)->SetFaceMaterial (face, matId); -} - -void NewtonMeshGetFaceIndices (const NewtonMesh* const mesh, const void* const face, int* const indices) -{ - TRACE_FUNCTION(__FUNCTION__); - ((dgMeshEffect*)mesh)->GetFaceIndex (face, indices); -} - -void NewtonMeshGetFacePointIndices (const NewtonMesh* const mesh, const void* const face, int* const indices) -{ - TRACE_FUNCTION(__FUNCTION__); - ((dgMeshEffect*)mesh)->GetFaceAttributeIndex (face, indices); -} - -void NewtonMeshCalculateFaceNormal (const NewtonMesh* const mesh, const void* const face, dFloat64* const normal) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBigVector n (((dgMeshEffect*)mesh)->CalculateFaceNormal (face)); - normal[0] = n.m_x; - normal[1] = n.m_y; - normal[2] = n.m_z; -} - -NewtonCollision* NewtonCreateDeformableSolid(const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, int shapeID) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return (NewtonCollision*) world->CreateDeformableSolid ((dgMeshEffect*)mesh, shapeID); -} - -NewtonCollision* NewtonCreateMassSpringDamperSystem (const NewtonWorld* const newtonWorld, int shapeID, - const dFloat* const points, int pointCount, int strideInBytes, const dFloat* const pointMass, - const int* const links, int linksCount, const dFloat* const linksSpring, const dFloat* const linksDamper) -{ - TRACE_FUNCTION(__FUNCTION__); - Newton* const world = (Newton *)newtonWorld; - return (NewtonCollision*)world->CreateMassSpringDamperSystem (shapeID, pointCount, points, strideInBytes, pointMass, linksCount, links, linksSpring, linksDamper); -} - -int NewtonDeformableMeshGetParticleCount(const NewtonCollision* const deformableMesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*)deformableMesh; - if (collision->IsType(dgCollision::dgCollisionLumpedMass_RTTI)) { - dgCollisionLumpedMassParticles* const deformableShape = (dgCollisionLumpedMassParticles*)collision->GetChildShape(); - return deformableShape->GetCount(); - } - return 0; -} - - -const dFloat* NewtonDeformableMeshGetParticleArray(const NewtonCollision* const deformableMesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*)deformableMesh; - if (collision->IsType(dgCollision::dgCollisionLumpedMass_RTTI)) { - dgCollisionLumpedMassParticles* const deformableShape = (dgCollisionLumpedMassParticles*)collision->GetChildShape(); - const dgVector* const posit = deformableShape->GetPositions(); - return &posit[0].m_x; - } - return NULL; -} - - -int NewtonDeformableMeshGetParticleStrideInBytes(const NewtonCollision* const deformableMesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*)deformableMesh; - if (collision->IsType(dgCollision::dgCollisionLumpedMass_RTTI)) { - dgCollisionLumpedMassParticles* const deformableShape = (dgCollisionLumpedMassParticles*)collision->GetChildShape(); - return deformableShape->GetStrideInByte(); - } - return 0; -} - - - -/* -void NewtonDeformableMeshConstraintParticle(NewtonCollision* const deformableMesh, int particleIndex, const dFloat* const posit, const NewtonBody* const body) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*)deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*)collision->GetChildShape(); - dgVector position(posit[0], posit[1], posit[2], dgFloat32(0.0f)); - deformableShape->ConstraintParticle(particleIndex, position, (dgBody*)body); - } -} - - - -void NewtonDeformableMeshCreateClusters (NewtonCollision* const deformableMesh, int clunsterCount, dFloat overlapingWidth) -{ - dgAssert(0); - - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - deformableShape->CreateClusters(clunsterCount, overlapingWidth); - } - -} - -void NewtonDeformableMeshSetDebugCallback (NewtonCollision* const deformableMesh, NewtonCollisionIterator callback) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - deformableShape->SetOnDebugDisplay((dgCollision::OnDebugCollisionMeshCallback)callback); - } -} - -void NewtonDeformableMeshGetParticlePosition (NewtonCollision* const deformableMesh, int particleIndex, dFloat* const posit) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - dgVector p (deformableShape->GetParticlePosition(particleIndex)); - posit[0] = p[0]; - posit[1] = p[1]; - posit[2] = p[2]; - } -} - -void NewtonDeformableMeshBeginConfiguration (const NewtonCollision* const deformableMesh) -{ -} - -void NewtonDeformableMeshEndConfiguration (const NewtonCollision* const deformableMesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - deformableShape->EndConfiguration(); - } -} - -void NewtonDeformableMeshUnconstraintParticle (NewtonCollision* const deformableMesh, int partivleIndex) -{ -} - - - -void NewtonDeformableMeshSetSkinThickness (NewtonCollision* const deformableMesh, dFloat skinThickness) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - deformableShape->SetSkinThickness(skinThickness); - } -} - -void NewtonDeformableMeshSetPlasticity (NewtonCollision* const deformableMesh, dFloat plasticity) -{ - TRACE_FUNCTION(__FUNCTION__); - dgAssert (0); - - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformable = (dgCollisionDeformableMesh*) collision; - deformable->SetPlasticity (plasticity); - } -} - -void NewtonDeformableMeshSetStiffness (NewtonCollision* const deformableMesh, dFloat stiffness) -{ - TRACE_FUNCTION(__FUNCTION__); - dgAssert (0); - - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformable = (dgCollisionDeformableMesh*) collision; - deformable->SetStiffness(stiffness); - } -} - - -int NewtonDeformableMeshGetVertexCount (const NewtonCollision* const deformableMesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - return deformableShape->GetVisualPointsCount(); - } - return 0; -} - -void NewtonDeformableMeshUpdateRenderNormals (const NewtonCollision* const deformableMesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - deformableShape->UpdateVisualNormals(); - } -} - -void NewtonDeformableMeshGetVertexStreams (const NewtonCollision* const deformableMesh, int vertexStrideInByte, dFloat* const vertex, int normalStrideInByte, dFloat* const normal, int uvStrideInByte0, dFloat* const uv0) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - deformableShape->GetVisualVertexData(vertexStrideInByte, vertex, normalStrideInByte, normal, uvStrideInByte0, uv0); - } -} - -NewtonDeformableMeshSegment* NewtonDeformableMeshGetFirstSegment (const NewtonCollision* const deformableMesh) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - return (NewtonDeformableMeshSegment*) deformableShape->GetFirtVisualSegment(); - } - return NULL; -} - -NewtonDeformableMeshSegment* NewtonDeformableMeshGetNextSegment (const NewtonCollision* const deformableMesh, const NewtonDeformableMeshSegment* const segment) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - return (NewtonDeformableMeshSegment*) deformableShape->GetNextVisualSegment((void*)segment); - } - return NULL; -} - -int NewtonDeformableMeshSegmentGetMaterialID (const NewtonCollision* const deformableMesh, const NewtonDeformableMeshSegment* const segment) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - return deformableShape->GetSegmentMaterial((void*)segment); - } - return 0; -} - -int NewtonDeformableMeshSegmentGetIndexCount (const NewtonCollision* const deformableMesh, const NewtonDeformableMeshSegment* const segment) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - return deformableShape->GetSegmentIndexCount((void*)segment); - } - return 0; -} - -const int* NewtonDeformableMeshSegmentGetIndexList (const NewtonCollision* const deformableMesh, const NewtonDeformableMeshSegment* const segment) -{ - TRACE_FUNCTION(__FUNCTION__); - dgCollisionInstance* const collision = (dgCollisionInstance*) deformableMesh; - if (collision->IsType(dgCollision::dgCollisionDeformableMesh_RTTI)) { - dgCollisionDeformableMesh* const deformableShape = (dgCollisionDeformableMesh*) collision->GetChildShape(); - return deformableShape->GetSegmentIndexList((void*)segment); - } - return NULL; -} -*/ - -/*! @} */ // end of - - -void* NewtonCollisionAggregateCreate(NewtonWorld* const worldPtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgWorld* const world = (dgWorld*) worldPtr; - return world->CreateAggreGate(); -} - -void NewtonCollisionAggregateDestroy(void* const aggregatePtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*) aggregatePtr; - aggregate->m_broadPhase->GetWorld()->DestroyAggregate(aggregate); -} - -void NewtonCollisionAggregateAddBody(void* const aggregatePtr, const NewtonBody* const body) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*) aggregatePtr; - aggregate->AddBody((dgBody*)body); -} - -void NewtonCollisionAggregateRemoveBody(void* const aggregatePtr, const NewtonBody* const body) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*) aggregatePtr; - aggregate->RemoveBody((dgBody*)body); -} - -int NewtonCollisionAggregateGetSelfCollision(void* const aggregatePtr) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*) aggregatePtr; - return aggregate->GetSelfCollision() ? true : false; -} - -void NewtonCollisionAggregateSetSelfCollision(void* const aggregatePtr, int state) -{ - TRACE_FUNCTION(__FUNCTION__); - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*) aggregatePtr; - aggregate->SetSelfCollision(state ? true : false); -} -/*! @} */ // end of - - diff --git a/thirdparty/src/newton/dgNewton/Newton.h b/thirdparty/src/newton/dgNewton/Newton.h deleted file mode 100644 index 1a7f3a039..000000000 --- a/thirdparty/src/newton/dgNewton/Newton.h +++ /dev/null @@ -1,1322 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __NEWTON_H__ -#define __NEWTON_H__ - - -#define NEWTON_MAJOR_VERSION 3 -#define NEWTON_MINOR_VERSION 14 - -#include <dgTypes.h> - -#ifdef _NEWTON_STATIC_LIB - #define NEWTON_API DG_LIBRARY_STATIC -#elif defined(_NEWTON_BUILD_DLL) - #define NEWTON_API DG_LIBRARY_EXPORT -#else - #define NEWTON_API DG_LIBRARY_IMPORT -#endif - - -#ifndef dLong - #define dLong long long -#endif - -#ifndef dFloat - #ifdef _NEWTON_USE_DOUBLE - #define dFloat double - #else - #define dFloat float - #endif -#endif - -#ifndef dFloat32 - #define dFloat32 float -#endif - -#ifndef dFloat64 - #define dFloat64 double -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - #define NEWTON_BROADPHASE_DEFAULT 0 - #define NEWTON_BROADPHASE_PERSINTENT 1 - - #define NEWTON_DYNAMIC_BODY 0 - #define NEWTON_KINEMATIC_BODY 1 - #define NEWTON_DYNAMIC_ASYMETRIC_BODY 2 -// #define NEWTON_DEFORMABLE_BODY 2 - - #define SERIALIZE_ID_SPHERE 0 - #define SERIALIZE_ID_CAPSULE 1 - #define SERIALIZE_ID_CYLINDER 2 - #define SERIALIZE_ID_CHAMFERCYLINDER 3 - #define SERIALIZE_ID_BOX 4 - #define SERIALIZE_ID_CONE 5 - #define SERIALIZE_ID_CONVEXHULL 6 - #define SERIALIZE_ID_NULL 7 - #define SERIALIZE_ID_COMPOUND 8 - #define SERIALIZE_ID_TREE 9 - #define SERIALIZE_ID_HEIGHTFIELD 10 - #define SERIALIZE_ID_CLOTH_PATCH 11 - #define SERIALIZE_ID_DEFORMABLE_SOLID 12 - #define SERIALIZE_ID_USERMESH 13 - #define SERIALIZE_ID_SCENE 14 - #define SERIALIZE_ID_FRACTURED_COMPOUND 15 - -#ifdef __cplusplus - class NewtonMesh; - class NewtonBody; - class NewtonWorld; - class NewtonJoint; - class NewtonMaterial; - class NewtonCollision; - class NewtonDeformableMeshSegment; - class NewtonFracturedCompoundMeshPart; -#else - typedef struct NewtonMesh{} NewtonMesh; - typedef struct NewtonBody{} NewtonBody; - typedef struct NewtonWorld{} NewtonWorld; - typedef struct NewtonJoint{} NewtonJoint; - typedef struct NewtonMaterial{} NewtonMaterial; - typedef struct NewtonCollision{} NewtonCollision; - typedef struct NewtonDeformableMeshSegment{} NewtonDeformableMeshSegment; - typedef struct NewtonFracturedCompoundMeshPart{} NewtonFracturedCompoundMeshPart; -#endif - - typedef union - { - void* m_ptr; - dLong m_int; - dFloat m_float; - } NewtonMaterialData; - - typedef struct NewtonCollisionMaterial - { - dLong m_userId; - NewtonMaterialData m_userData; - NewtonMaterialData m_userParam[6]; - } NewtonCollisionMaterial; - - typedef struct NewtonBoxParam - { - dFloat m_x; - dFloat m_y; - dFloat m_z; - } NewtonBoxParam; - - typedef struct NewtonSphereParam - { - dFloat m_radio; - } NewtonSphereParam; - - - typedef struct NewtonCapsuleParam - { - dFloat m_radio0; - dFloat m_radio1; - dFloat m_height; - } NewtonCapsuleParam; - - typedef struct NewtonCylinderParam - { - dFloat m_radio0; - dFloat m_radio1; - dFloat m_height; - } NewtonCylinderParam; - - typedef struct NewtonConeParam - { - dFloat m_radio; - dFloat m_height; - } NewtonConeParam; - - typedef struct NewtonChamferCylinderParam - { - dFloat m_radio; - dFloat m_height; - } NewtonChamferCylinderParam; - - typedef struct NewtonConvexHullParam - { - int m_vertexCount; - int m_vertexStrideInBytes; - int m_faceCount; - dFloat* m_vertex; - } NewtonConvexHullParam; - - typedef struct NewtonCompoundCollisionParam - { - int m_chidrenCount; - } NewtonCompoundCollisionParam; - - typedef struct NewtonCollisionTreeParam - { - int m_vertexCount; - int m_indexCount; - } NewtonCollisionTreeParam; - - typedef struct NewtonDeformableMeshParam - { - int m_vertexCount; - int m_triangleCount; - int m_vrtexStrideInBytes; - unsigned short *m_indexList; - dFloat *m_vertexList; - } NewtonDeformableMeshParam; - - typedef struct NewtonHeightFieldCollisionParam - { - int m_width; - int m_height; - int m_gridsDiagonals; - int m_elevationDataType; // 0 = 32 bit floats, 1 = unsigned 16 bit integers - dFloat m_verticalScale; - dFloat m_horizonalScale_x; - dFloat m_horizonalScale_z; - void* m_vertialElevation; - char* m_atributes; - } NewtonHeightFieldCollisionParam; - - typedef struct NewtonSceneCollisionParam - { - int m_childrenProxyCount; - } NewtonSceneCollisionParam; - - typedef struct NewtonCollisionInfoRecord - { - dFloat m_offsetMatrix[4][4]; - NewtonCollisionMaterial m_collisionMaterial; - int m_collisionType; // tag id to identify the collision primitive - union { - NewtonBoxParam m_box; - NewtonConeParam m_cone; - NewtonSphereParam m_sphere; - NewtonCapsuleParam m_capsule; - NewtonCylinderParam m_cylinder; - NewtonChamferCylinderParam m_chamferCylinder; - NewtonConvexHullParam m_convexHull; - NewtonDeformableMeshParam m_deformableMesh; - NewtonCompoundCollisionParam m_compoundCollision; - NewtonCollisionTreeParam m_collisionTree; - NewtonHeightFieldCollisionParam m_heightField; - NewtonSceneCollisionParam m_sceneCollision; - dFloat m_paramArray[64]; // user define collision can use this to store information - }; - } NewtonCollisionInfoRecord; - - typedef struct NewtonJointRecord - { - dFloat m_attachmenMatrix_0[4][4]; - dFloat m_attachmenMatrix_1[4][4]; - dFloat m_minLinearDof[3]; - dFloat m_maxLinearDof[3]; - dFloat m_minAngularDof[3]; - dFloat m_maxAngularDof[3]; - const NewtonBody* m_attachBody_0; - const NewtonBody* m_attachBody_1; - dFloat m_extraParameters[64]; - int m_bodiesCollisionOn; - char m_descriptionType[128]; - } NewtonJointRecord; - - typedef struct NewtonUserMeshCollisionCollideDesc - { - dFloat m_boxP0[4]; // lower bounding box of intersection query in local space - dFloat m_boxP1[4]; // upper bounding box of intersection query in local space - dFloat m_boxDistanceTravel[4]; // max distance that box bpxP0 and boxP1 can travel on this timestep, used this for continue collision mode. - int m_threadNumber; // current thread executing this query - int m_faceCount; // the application should set here how many polygons intersect the query box - int m_vertexStrideInBytes; // the application should set here the size of each vertex - dFloat m_skinThickness; // this is the minimum skin separation specified by the material between these two colliding shapes - void* m_userData; // user data passed to the collision geometry at creation time - - NewtonBody* m_objBody; // pointer to the colliding body - NewtonBody* m_polySoupBody; // pointer to the rigid body owner of this collision tree - NewtonCollision* m_objCollision; // collision shape of the colliding body, (no necessarily the collision of m_objBody) - NewtonCollision* m_polySoupCollision; // collision shape of the collision tree, (no necessarily the collision of m_polySoupBody) - - dFloat* m_vertex; // the application should set here the pointer to the global vertex of the mesh. - int* m_faceIndexCount; // the application should set here the pointer to the vertex count of each face. - int* m_faceVertexIndex; // the application should set here the pointer index array for each vertex on a face. - // the format of a face is I0, I1, I2, I3, ..., M, N, E0, E1, E2, ..., A - // I0, I1, I2, .. are the indices to the vertex, relative to m_vertex pointer - // M is the index to the material sub shape id - // N in the index to the vertex normal relative to m_vertex pointer - // E0, E1, E2, ... are the indices of the the face normal that is shared to that face edge, when the edge does not share a face normal then the edge index is set to index N, which the index to the face normal - // A is and estimate of the largest diagonal of the face, this used internally as a hint to improve floating point accuracy and algorithm performance. - } NewtonUserMeshCollisionCollideDesc; - - typedef struct NewtonWorldConvexCastReturnInfo - { - dFloat m_point[4]; // collision point in global space - dFloat m_normal[4]; // surface normal at collision point in global space - //dFloat m_normalOnHitPoint[4]; // surface normal at the surface of the hit body, - // is the same as the normal calculated by a ray cast hitting the body at the hit point - dLong m_contactID; // collision ID at contact point - const NewtonBody* m_hitBody; // body hit at contact point - dFloat m_penetration; // contact penetration at collision point - } NewtonWorldConvexCastReturnInfo; - - typedef struct NewtonUserMeshCollisionRayHitDesc - { - dFloat m_p0[4]; // ray origin in collision local space - dFloat m_p1[4]; // ray destination in collision local space - dFloat m_normalOut[4]; // copy here the normal at the ray intersection - dLong m_userIdOut; // copy here a user defined id for further feedback - void* m_userData; // user data passed to the collision geometry at creation time - } NewtonUserMeshCollisionRayHitDesc; - - typedef struct NewtonHingeSliderUpdateDesc - { - dFloat m_accel; - dFloat m_minFriction; - dFloat m_maxFriction; - dFloat m_timestep; - } NewtonHingeSliderUpdateDesc; - - typedef struct NewtonUserContactPoint - { - dFloat m_point[4]; - dFloat m_normal[4]; - dLong m_shapeId0; - dLong m_shapeId1; - dFloat m_penetration; - int m_unused[3]; - } NewtonUserContactPoint; - - - typedef struct NewtonImmediateModeConstraint - { - dFloat m_jacobian01[8][6]; - dFloat m_jacobian10[8][6]; - dFloat m_minFriction[8]; - dFloat m_maxFriction[8]; - dFloat m_jointAccel[8]; - dFloat m_jointStiffness[8]; - } NewtonConstraintDescriptor; - - - // data structure for interfacing with NewtonMesh - typedef struct NewtonMeshDoubleData - { - dFloat64* m_data; - int* m_indexList; - int m_strideInBytes; - } NewtonMeshDoubleData; - - typedef struct NewtonMeshFloatData - { - dFloat* m_data; - int* m_indexList; - int m_strideInBytes; - } NewtonMeshFloatData; - - typedef struct NewtonMeshVertexFormat - { - int m_faceCount; - int* m_faceIndexCount; - int* m_faceMaterial; - NewtonMeshDoubleData m_vertex; - NewtonMeshFloatData m_normal; - NewtonMeshFloatData m_binormal; - NewtonMeshFloatData m_uv0; - NewtonMeshFloatData m_uv1; - NewtonMeshFloatData m_vertexColor; - } NewtonMeshVertexFormat; - - // Newton callback functions - typedef void* (*NewtonAllocMemory) (int sizeInBytes); - typedef void (*NewtonFreeMemory) (void* const ptr, int sizeInBytes); - - typedef void (*NewtonWorldDestructorCallback) (const NewtonWorld* const world); - typedef void (*NewtonPostUpdateCallback) (const NewtonWorld* const world, dFloat timestep); - - typedef void(*NewtonCreateContactCallback) (const NewtonWorld* const newtonWorld, NewtonJoint* const contact); - typedef void(*NewtonDestroyContactCallback) (const NewtonWorld* const newtonWorld, NewtonJoint* const contact); - - typedef void (*NewtonWorldListenerDebugCallback) (const NewtonWorld* const world, void* const listener, void* const debugContext); - typedef void (*NewtonWorldListenerBodyDestroyCallback) (const NewtonWorld* const world, void* const listenerUserData, NewtonBody* const body); - typedef void (*NewtonWorldUpdateListenerCallback) (const NewtonWorld* const world, void* const listenerUserData, dFloat timestep); - typedef void (*NewtonWorldDestroyListenerCallback) (const NewtonWorld* const world, void* const listenerUserData); - - typedef dLong (*NewtonGetTimeInMicrosencondsCallback) (); - - typedef void (*NewtonSerializeCallback) (void* const serializeHandle, const void* const buffer, int size); - typedef void (*NewtonDeserializeCallback) (void* const serializeHandle, void* const buffer, int size); - - typedef void (*NewtonOnBodySerializationCallback) (NewtonBody* const body, void* const userData, NewtonSerializeCallback function, void* const serializeHandle); - typedef void (*NewtonOnBodyDeserializationCallback) (NewtonBody* const body, void* const userData, NewtonDeserializeCallback function, void* const serializeHandle); - - typedef void (*NewtonOnJointSerializationCallback) (const NewtonJoint* const joint, NewtonSerializeCallback function, void* const serializeHandle); - typedef void (*NewtonOnJointDeserializationCallback) (NewtonBody* const body0, NewtonBody* const body1, NewtonDeserializeCallback function, void* const serializeHandle); - - typedef void (*NewtonOnUserCollisionSerializationCallback) (void* const userData, NewtonSerializeCallback function, void* const serializeHandle); - - // user collision callbacks - typedef void (*NewtonUserMeshCollisionDestroyCallback) (void* const userData); - typedef dFloat (*NewtonUserMeshCollisionRayHitCallback) (NewtonUserMeshCollisionRayHitDesc* const lineDescData); - typedef void (*NewtonUserMeshCollisionGetCollisionInfo) (void* const userData, NewtonCollisionInfoRecord* const infoRecord); - typedef int (*NewtonUserMeshCollisionAABBTest) (void* const userData, const dFloat* const boxP0, const dFloat* const boxP1); - typedef int (*NewtonUserMeshCollisionGetFacesInAABB) (void* const userData, const dFloat* const p0, const dFloat* const p1, - const dFloat** const vertexArray, int* const vertexCount, int* const vertexStrideInBytes, - const int* const indexList, int maxIndexCount, const int* const userDataList); - typedef void (*NewtonUserMeshCollisionCollideCallback) (NewtonUserMeshCollisionCollideDesc* const collideDescData, const void* const continueCollisionHandle); - - typedef int (*NewtonTreeCollisionFaceCallback) (void* const context, const dFloat* const polygon, int strideInBytes, const int* const indexArray, int indexCount); - - typedef dFloat (*NewtonCollisionTreeRayCastCallback) (const NewtonBody* const body, const NewtonCollision* const treeCollision, dFloat intersection, dFloat* const normal, int faceId, void* const usedData); - typedef dFloat (*NewtonHeightFieldRayCastCallback) (const NewtonBody* const body, const NewtonCollision* const heightFieldCollision, dFloat intersection, int row, int col, dFloat* const normal, int faceId, void* const usedData); - - typedef void (*NewtonCollisionCopyConstructionCallback) (const NewtonWorld* const newtonWorld, NewtonCollision* const collision, const NewtonCollision* const sourceCollision); - typedef void (*NewtonCollisionDestructorCallback) (const NewtonWorld* const newtonWorld, const NewtonCollision* const collision); - - // collision tree call back (obsoleted no recommended) - typedef void (*NewtonTreeCollisionCallback) (const NewtonBody* const bodyWithTreeCollision, const NewtonBody* const body, int faceID, - int vertexCount, const dFloat* const vertex, int vertexStrideInBytes); - - typedef void (*NewtonBodyDestructor) (const NewtonBody* const body); - typedef void (*NewtonApplyForceAndTorque) (const NewtonBody* const body, dFloat timestep, int threadIndex); - typedef void (*NewtonSetTransform) (const NewtonBody* const body, const dFloat* const matrix, int threadIndex); - - typedef int (*NewtonIslandUpdate) (const NewtonWorld* const newtonWorld, const void* islandHandle, int bodyCount); - - typedef void (*NewtonFractureCompoundCollisionOnEmitCompoundFractured) (NewtonBody* const fracturedBody); - typedef void (*NewtonFractureCompoundCollisionOnEmitChunk) (NewtonBody* const chunkBody, NewtonFracturedCompoundMeshPart* const fracturexChunkMesh, const NewtonCollision* const fracturedCompountCollision); - typedef void (*NewtonFractureCompoundCollisionReconstructMainMeshCallBack) (NewtonBody* const body, NewtonFracturedCompoundMeshPart* const mainMesh, const NewtonCollision* const fracturedCompountCollision); - - typedef unsigned (*NewtonWorldRayPrefilterCallback)(const NewtonBody* const body, const NewtonCollision* const collision, void* const userData); - typedef dFloat (*NewtonWorldRayFilterCallback)(const NewtonBody* const body, const NewtonCollision* const shapeHit, const dFloat* const hitContact, const dFloat* const hitNormal, dLong collisionID, void* const userData, dFloat intersectParam); - - typedef int (*NewtonOnAABBOverlap) (const NewtonJoint* const contact, dFloat timestep, int threadIndex); - typedef void (*NewtonContactsProcess) (const NewtonJoint* const contact, dFloat timestep, int threadIndex); - typedef int (*NewtonOnCompoundSubCollisionAABBOverlap) (const NewtonJoint* const contact, dFloat timestep, const NewtonBody* const body0, const void* const collisionNode0, const NewtonBody* const body1, const void* const collisionNode1, int threadIndex); - typedef int (*NewtonOnContactGeneration) (const NewtonMaterial* const material, const NewtonBody* const body0, const NewtonCollision* const collision0, const NewtonBody* const body1, const NewtonCollision* const collision1, NewtonUserContactPoint* const contactBuffer, int maxCount, int threadIndex); - - typedef int (*NewtonBodyIterator) (const NewtonBody* const body, void* const userData); - typedef void (*NewtonJointIterator) (const NewtonJoint* const joint, void* const userData); - typedef void (*NewtonCollisionIterator) (void* const userData, int vertexCount, const dFloat* const faceArray, int faceId); - - typedef void (*NewtonBallCallback) (const NewtonJoint* const ball, dFloat timestep); - typedef unsigned (*NewtonHingeCallback) (const NewtonJoint* const hinge, NewtonHingeSliderUpdateDesc* const desc); - typedef unsigned (*NewtonSliderCallback) (const NewtonJoint* const slider, NewtonHingeSliderUpdateDesc* const desc); - typedef unsigned (*NewtonUniversalCallback) (const NewtonJoint* const universal, NewtonHingeSliderUpdateDesc* const desc); - typedef unsigned (*NewtonCorkscrewCallback) (const NewtonJoint* const corkscrew, NewtonHingeSliderUpdateDesc* const desc); - - typedef void (*NewtonUserBilateralCallback) (const NewtonJoint* const userJoint, dFloat timestep, int threadIndex); - typedef void (*NewtonUserBilateralGetInfoCallback) (const NewtonJoint* const userJoint, NewtonJointRecord* const info); - - typedef void (*NewtonConstraintDestructor) (const NewtonJoint* const me); - - typedef void (*NewtonJobTask) (NewtonWorld* const world, void* const userData, int threadIndex); - typedef int (*NewtonReportProgress) (dFloat normalizedProgressPercent, void* const userData); - - // ********************************************************************************************** - // - // world control functions - // - // ********************************************************************************************** - NEWTON_API int NewtonWorldGetVersion (); - NEWTON_API int NewtonWorldFloatSize (); - - NEWTON_API int NewtonGetMemoryUsed (); - NEWTON_API void NewtonSetMemorySystem (NewtonAllocMemory malloc, NewtonFreeMemory free); - - NEWTON_API NewtonWorld* NewtonCreate (); - NEWTON_API void NewtonDestroy (const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonDestroyAllBodies (const NewtonWorld* const newtonWorld); - - NEWTON_API NewtonPostUpdateCallback NewtonGetPostUpdateCallback(const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonSetPostUpdateCallback (const NewtonWorld* const newtonWorld, NewtonPostUpdateCallback callback); - - NEWTON_API void* NewtonAlloc (int sizeInBytes); - NEWTON_API void NewtonFree (void* const ptr); - - NEWTON_API void NewtonLoadPlugins(const NewtonWorld* const newtonWorld, const char* const plugInPath); - NEWTON_API void NewtonUnloadPlugins(const NewtonWorld* const newtonWorld); - NEWTON_API void* NewtonCurrentPlugin(const NewtonWorld* const newtonWorld); - NEWTON_API void* NewtonGetFirstPlugin(const NewtonWorld* const newtonWorld); - NEWTON_API void* NewtonGetPreferedPlugin(const NewtonWorld* const newtonWorld); - NEWTON_API void* NewtonGetNextPlugin(const NewtonWorld* const newtonWorld, const void* const plugin); - NEWTON_API const char* NewtonGetPluginString(const NewtonWorld* const newtonWorld, const void* const plugin); - NEWTON_API void NewtonSelectPlugin(const NewtonWorld* const newtonWorld, const void* const plugin); - - NEWTON_API dFloat NewtonGetContactMergeTolerance (const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonSetContactMergeTolerance (const NewtonWorld* const newtonWorld, dFloat tolerance); - - NEWTON_API void NewtonInvalidateCache (const NewtonWorld* const newtonWorld); - - NEWTON_API void NewtonSetSolverIterations (const NewtonWorld* const newtonWorld, int model); - NEWTON_API int NewtonGetSolverIterations(const NewtonWorld* const newtonWorld); - - NEWTON_API void NewtonSetParallelSolverOnLargeIsland (const NewtonWorld* const newtonWorld, int mode); - NEWTON_API int NewtonGetParallelSolverOnLargeIsland (const NewtonWorld* const newtonWorld); - - NEWTON_API int NewtonGetBroadphaseAlgorithm (const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonSelectBroadphaseAlgorithm (const NewtonWorld* const newtonWorld, int algorithmType); - NEWTON_API void NewtonResetBroadphase(const NewtonWorld* const newtonWorld); - - NEWTON_API void NewtonUpdate (const NewtonWorld* const newtonWorld, dFloat timestep); - NEWTON_API void NewtonUpdateAsync (const NewtonWorld* const newtonWorld, dFloat timestep); - NEWTON_API void NewtonWaitForUpdateToFinish (const NewtonWorld* const newtonWorld); - - NEWTON_API int NewtonGetNumberOfSubsteps (const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonSetNumberOfSubsteps (const NewtonWorld* const newtonWorld, int subSteps); - NEWTON_API dFloat NewtonGetLastUpdateTime (const NewtonWorld* const newtonWorld); - - NEWTON_API void NewtonSerializeToFile (const NewtonWorld* const newtonWorld, const char* const filename, NewtonOnBodySerializationCallback bodyCallback, void* const bodyUserData); - NEWTON_API void NewtonDeserializeFromFile (const NewtonWorld* const newtonWorld, const char* const filename, NewtonOnBodyDeserializationCallback bodyCallback, void* const bodyUserData); - - NEWTON_API void NewtonSerializeScene(const NewtonWorld* const newtonWorld, NewtonOnBodySerializationCallback bodyCallback, void* const bodyUserData, - NewtonSerializeCallback serializeCallback, void* const serializeHandle); - NEWTON_API void NewtonDeserializeScene(const NewtonWorld* const newtonWorld, NewtonOnBodyDeserializationCallback bodyCallback, void* const bodyUserData, - NewtonDeserializeCallback serializeCallback, void* const serializeHandle); - - NEWTON_API NewtonBody* NewtonFindSerializedBody(const NewtonWorld* const newtonWorld, int bodySerializedID); - NEWTON_API void NewtonSetJointSerializationCallbacks (const NewtonWorld* const newtonWorld, NewtonOnJointSerializationCallback serializeJoint, NewtonOnJointDeserializationCallback deserializeJoint); - NEWTON_API void NewtonGetJointSerializationCallbacks (const NewtonWorld* const newtonWorld, NewtonOnJointSerializationCallback* const serializeJoint, NewtonOnJointDeserializationCallback* const deserializeJoint); - - // multi threading interface - NEWTON_API void NewtonWorldCriticalSectionLock (const NewtonWorld* const newtonWorld, int threadIndex); - NEWTON_API void NewtonWorldCriticalSectionUnlock (const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonSetThreadsCount (const NewtonWorld* const newtonWorld, int threads); - NEWTON_API int NewtonGetThreadsCount(const NewtonWorld* const newtonWorld); - NEWTON_API int NewtonGetMaxThreadsCount(const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonDispachThreadJob(const NewtonWorld* const newtonWorld, NewtonJobTask task, void* const usedData, const char* const functionName); - NEWTON_API void NewtonSyncThreadJobs(const NewtonWorld* const newtonWorld); - - // atomic operations - NEWTON_API int NewtonAtomicAdd (int* const ptr, int value); - NEWTON_API int NewtonAtomicSwap (int* const ptr, int value); - NEWTON_API void NewtonYield (); - - NEWTON_API void NewtonSetIslandUpdateEvent (const NewtonWorld* const newtonWorld, NewtonIslandUpdate islandUpdate); - NEWTON_API void NewtonWorldForEachJointDo (const NewtonWorld* const newtonWorld, NewtonJointIterator callback, void* const userData); - NEWTON_API void NewtonWorldForEachBodyInAABBDo (const NewtonWorld* const newtonWorld, const dFloat* const p0, const dFloat* const p1, NewtonBodyIterator callback, void* const userData); - - NEWTON_API void NewtonWorldSetUserData (const NewtonWorld* const newtonWorld, void* const userData); - NEWTON_API void* NewtonWorldGetUserData (const NewtonWorld* const newtonWorld); - - NEWTON_API void* NewtonWorldAddListener (const NewtonWorld* const newtonWorld, const char* const nameId, void* const listenerUserData); - NEWTON_API void* NewtonWorldGetListener (const NewtonWorld* const newtonWorld, const char* const nameId); - - NEWTON_API void NewtonWorldListenerSetDebugCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldListenerDebugCallback callback); - NEWTON_API void NewtonWorldListenerSetPostStepCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldUpdateListenerCallback callback); - NEWTON_API void NewtonWorldListenerSetPreUpdateCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldUpdateListenerCallback callback); - NEWTON_API void NewtonWorldListenerSetPostUpdateCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldUpdateListenerCallback callback); - NEWTON_API void NewtonWorldListenerSetDestructorCallback (const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldDestroyListenerCallback callback); - NEWTON_API void NewtonWorldListenerSetBodyDestroyCallback(const NewtonWorld* const newtonWorld, void* const listener, NewtonWorldListenerBodyDestroyCallback callback); - NEWTON_API void NewtonWorldListenerDebug(const NewtonWorld* const newtonWorld, void* const context); - NEWTON_API void* NewtonWorldGetListenerUserData(const NewtonWorld* const newtonWorld, void* const listener); - NEWTON_API NewtonWorldListenerBodyDestroyCallback NewtonWorldListenerGetBodyDestroyCallback (const NewtonWorld* const newtonWorld, void* const listener); - - NEWTON_API void NewtonWorldSetDestructorCallback (const NewtonWorld* const newtonWorld, NewtonWorldDestructorCallback destructor); - NEWTON_API NewtonWorldDestructorCallback NewtonWorldGetDestructorCallback (const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonWorldSetCollisionConstructorDestructorCallback (const NewtonWorld* const newtonWorld, NewtonCollisionCopyConstructionCallback constructor, NewtonCollisionDestructorCallback destructor); - - NEWTON_API void NewtonWorldSetCreateDestroyContactCallback(const NewtonWorld* const newtonWorld, NewtonCreateContactCallback createContact, NewtonDestroyContactCallback destroyContact); - - NEWTON_API void NewtonWorldRayCast (const NewtonWorld* const newtonWorld, const dFloat* const p0, const dFloat* const p1, NewtonWorldRayFilterCallback filter, void* const userData, NewtonWorldRayPrefilterCallback prefilter, int threadIndex); - NEWTON_API int NewtonWorldConvexCast (const NewtonWorld* const newtonWorld, const dFloat* const matrix, const dFloat* const target, const NewtonCollision* const shape, dFloat* const param, void* const userData, NewtonWorldRayPrefilterCallback prefilter, NewtonWorldConvexCastReturnInfo* const info, int maxContactsCount, int threadIndex); - NEWTON_API int NewtonWorldCollide (const NewtonWorld* const newtonWorld, const dFloat* const matrix, const NewtonCollision* const shape, void* const userData, NewtonWorldRayPrefilterCallback prefilter, NewtonWorldConvexCastReturnInfo* const info, int maxContactsCount, int threadIndex); - - // world utility functions - NEWTON_API int NewtonWorldGetBodyCount(const NewtonWorld* const newtonWorld); - NEWTON_API int NewtonWorldGetConstraintCount(const NewtonWorld* const newtonWorld); - - NEWTON_API NewtonJoint* NewtonWorldFindJoint(const NewtonBody* const body0, const NewtonBody* const body1); - - // ********************************************************************************************** - // - // Simulation islands - // - // ********************************************************************************************** - NEWTON_API NewtonBody* NewtonIslandGetBody (const void* const island, int bodyIndex); - NEWTON_API void NewtonIslandGetBodyAABB (const void* const island, int bodyIndex, dFloat* const p0, dFloat* const p1); - - // ********************************************************************************************** - // - // Physics Material Section - // - // ********************************************************************************************** - NEWTON_API int NewtonMaterialCreateGroupID(const NewtonWorld* const newtonWorld); - NEWTON_API int NewtonMaterialGetDefaultGroupID(const NewtonWorld* const newtonWorld); - NEWTON_API void NewtonMaterialDestroyAllGroupID(const NewtonWorld* const newtonWorld); - - // material definitions that can not be overwritten in function callback - NEWTON_API void* NewtonMaterialGetUserData (const NewtonWorld* const newtonWorld, int id0, int id1); - NEWTON_API void NewtonMaterialSetSurfaceThickness (const NewtonWorld* const newtonWorld, int id0, int id1, dFloat thickness); - -// deprecated, not longer continue collision is set on the material -// NEWTON_API void NewtonMaterialSetContinuousCollisionMode (const NewtonWorld* const newtonWorld, int id0, int id1, int state); - - NEWTON_API void NewtonMaterialSetCallbackUserData (const NewtonWorld* const newtonWorld, int id0, int id1, void* const userData); - NEWTON_API void NewtonMaterialSetContactGenerationCallback (const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnContactGeneration contactGeneration); - NEWTON_API void NewtonMaterialSetCompoundCollisionCallback(const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnCompoundSubCollisionAABBOverlap compoundAabbOverlap); - NEWTON_API void NewtonMaterialSetCollisionCallback (const NewtonWorld* const newtonWorld, int id0, int id1, NewtonOnAABBOverlap aabbOverlap, NewtonContactsProcess process); - - NEWTON_API void NewtonMaterialSetDefaultSoftness (const NewtonWorld* const newtonWorld, int id0, int id1, dFloat value); - NEWTON_API void NewtonMaterialSetDefaultElasticity (const NewtonWorld* const newtonWorld, int id0, int id1, dFloat elasticCoef); - NEWTON_API void NewtonMaterialSetDefaultCollidable (const NewtonWorld* const newtonWorld, int id0, int id1, int state); - NEWTON_API void NewtonMaterialSetDefaultFriction (const NewtonWorld* const newtonWorld, int id0, int id1, dFloat staticFriction, dFloat kineticFriction); - - NEWTON_API void NewtonMaterialJointResetIntraJointCollision (const NewtonWorld* const newtonWorld, int id0, int id1); - NEWTON_API void NewtonMaterialJointResetSelftJointCollision (const NewtonWorld* const newtonWorld, int id0, int id1); - - NEWTON_API NewtonMaterial* NewtonWorldGetFirstMaterial (const NewtonWorld* const newtonWorld); - NEWTON_API NewtonMaterial* NewtonWorldGetNextMaterial (const NewtonWorld* const newtonWorld, const NewtonMaterial* const material); - - NEWTON_API NewtonBody* NewtonWorldGetFirstBody (const NewtonWorld* const newtonWorld); - NEWTON_API NewtonBody* NewtonWorldGetNextBody (const NewtonWorld* const newtonWorld, const NewtonBody* const curBody); - - - // ********************************************************************************************** - // - // Physics Contact control functions - // - // ********************************************************************************************** - NEWTON_API void *NewtonMaterialGetMaterialPairUserData (const NewtonMaterial* const material); - NEWTON_API unsigned NewtonMaterialGetContactFaceAttribute (const NewtonMaterial* const material); - NEWTON_API NewtonCollision* NewtonMaterialGetBodyCollidingShape (const NewtonMaterial* const material, const NewtonBody* const body); - NEWTON_API dFloat NewtonMaterialGetContactNormalSpeed (const NewtonMaterial* const material); - NEWTON_API void NewtonMaterialGetContactForce (const NewtonMaterial* const material, const NewtonBody* const body, dFloat* const force); - NEWTON_API void NewtonMaterialGetContactPositionAndNormal (const NewtonMaterial* const material, const NewtonBody* const body, dFloat* const posit, dFloat* const normal); - NEWTON_API void NewtonMaterialGetContactTangentDirections (const NewtonMaterial* const material, const NewtonBody* const body, dFloat* const dir0, dFloat* const dir1); - NEWTON_API dFloat NewtonMaterialGetContactTangentSpeed (const NewtonMaterial* const material, int index); - NEWTON_API dFloat NewtonMaterialGetContactMaxNormalImpact (const NewtonMaterial* const material); - NEWTON_API dFloat NewtonMaterialGetContactMaxTangentImpact (const NewtonMaterial* const material, int index); - NEWTON_API dFloat NewtonMaterialGetContactPenetration (const NewtonMaterial* const material); - NEWTON_API void NewtonMaterialSetAsSoftContact (const NewtonMaterial* const material, dFloat relaxation); - - NEWTON_API void NewtonMaterialSetContactSoftness (const NewtonMaterial* const material, dFloat softness); - NEWTON_API void NewtonMaterialSetContactThickness (const NewtonMaterial* const material, dFloat thickness); - NEWTON_API void NewtonMaterialSetContactElasticity (const NewtonMaterial* const material, dFloat restitution); - NEWTON_API void NewtonMaterialSetContactFrictionState (const NewtonMaterial* const material, int state, int index); - NEWTON_API void NewtonMaterialSetContactFrictionCoef (const NewtonMaterial* const material, dFloat staticFrictionCoef, dFloat kineticFrictionCoef, int index); - - NEWTON_API void NewtonMaterialSetContactNormalAcceleration (const NewtonMaterial* const material, dFloat accel); - NEWTON_API void NewtonMaterialSetContactNormalDirection (const NewtonMaterial* const material, const dFloat* const directionVector); - NEWTON_API void NewtonMaterialSetContactPosition (const NewtonMaterial* const material, const dFloat* const position); - - NEWTON_API void NewtonMaterialSetContactTangentFriction (const NewtonMaterial* const material, dFloat friction, int index); - NEWTON_API void NewtonMaterialSetContactTangentAcceleration (const NewtonMaterial* const material, dFloat accel, int index); - NEWTON_API void NewtonMaterialContactRotateTangentDirections (const NewtonMaterial* const material, const dFloat* const directionVector); - - //NEWTON_API dFloat NewtonMaterialGetContactPruningTolerance (const NewtonBody* const body0, const NewtonBody* const body1); - //NEWTON_API void NewtonMaterialSetContactPruningTolerance (const NewtonBody* const body0, const NewtonBody* const body1, dFloat tolerance); - NEWTON_API dFloat NewtonMaterialGetContactPruningTolerance(const NewtonJoint* const contactJoint); - NEWTON_API void NewtonMaterialSetContactPruningTolerance(const NewtonJoint* const contactJoint, dFloat tolerance); - - // ********************************************************************************************** - // - // convex collision primitives creation functions - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateNull (const NewtonWorld* const newtonWorld); - NEWTON_API NewtonCollision* NewtonCreateSphere (const NewtonWorld* const newtonWorld, dFloat radius, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateBox (const NewtonWorld* const newtonWorld, dFloat dx, dFloat dy, dFloat dz, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateCone (const NewtonWorld* const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateCapsule (const NewtonWorld* const newtonWorld, dFloat radius0, dFloat radius1, dFloat height, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateCylinder (const NewtonWorld* const newtonWorld, dFloat radio0, dFloat radio1, dFloat height, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateChamferCylinder (const NewtonWorld* const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateConvexHull (const NewtonWorld* const newtonWorld, int count, const dFloat* const vertexCloud, int strideInBytes, dFloat tolerance, int shapeID, const dFloat* const offsetMatrix); - NEWTON_API NewtonCollision* NewtonCreateConvexHullFromMesh (const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, dFloat tolerance, int shapeID); - - NEWTON_API int NewtonCollisionGetMode(const NewtonCollision* const convexCollision); - NEWTON_API void NewtonCollisionSetMode (const NewtonCollision* const convexCollision, int mode); - - NEWTON_API int NewtonConvexHullGetFaceIndices (const NewtonCollision* const convexHullCollision, int face, int* const faceIndices); - NEWTON_API int NewtonConvexHullGetVertexData (const NewtonCollision* const convexHullCollision, dFloat** const vertexData, int* strideInBytes); - - NEWTON_API dFloat NewtonConvexCollisionCalculateVolume (const NewtonCollision* const convexCollision); - NEWTON_API void NewtonConvexCollisionCalculateInertialMatrix (const NewtonCollision* convexCollision, dFloat* const inertia, dFloat* const origin); - NEWTON_API dFloat NewtonConvexCollisionCalculateBuoyancyVolume (const NewtonCollision* const convexCollision, const dFloat* const matrix, const dFloat* const fluidPlane, dFloat* const centerOfBuoyancy); - - NEWTON_API const void* NewtonCollisionDataPointer (const NewtonCollision* const convexCollision); - - // ********************************************************************************************** - // - // compound collision primitives creation functions - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateCompoundCollision (const NewtonWorld* const newtonWorld, int shapeID); - NEWTON_API NewtonCollision* NewtonCreateCompoundCollisionFromMesh (const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, dFloat hullTolerance, int shapeID, int subShapeID); - - NEWTON_API void NewtonCompoundCollisionBeginAddRemove (NewtonCollision* const compoundCollision); - NEWTON_API void* NewtonCompoundCollisionAddSubCollision (NewtonCollision* const compoundCollision, const NewtonCollision* const convexCollision); - NEWTON_API void NewtonCompoundCollisionRemoveSubCollision (NewtonCollision* const compoundCollision, const void* const collisionNode); - NEWTON_API void NewtonCompoundCollisionRemoveSubCollisionByIndex (NewtonCollision* const compoundCollision, int nodeIndex); - NEWTON_API void NewtonCompoundCollisionSetSubCollisionMatrix (NewtonCollision* const compoundCollision, const void* const collisionNode, const dFloat* const matrix); - NEWTON_API void NewtonCompoundCollisionEndAddRemove (NewtonCollision* const compoundCollision); - - NEWTON_API void* NewtonCompoundCollisionGetFirstNode (NewtonCollision* const compoundCollision); - NEWTON_API void* NewtonCompoundCollisionGetNextNode (NewtonCollision* const compoundCollision, const void* const collisionNode); - - NEWTON_API void* NewtonCompoundCollisionGetNodeByIndex (NewtonCollision* const compoundCollision, int index); - NEWTON_API int NewtonCompoundCollisionGetNodeIndex (NewtonCollision* const compoundCollision, const void* const collisionNode); - NEWTON_API NewtonCollision* NewtonCompoundCollisionGetCollisionFromNode (NewtonCollision* const compoundCollision, const void* const collisionNode); - - - // ********************************************************************************************** - // - // Fractured compound collision primitives interface - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateFracturedCompoundCollision (const NewtonWorld* const newtonWorld, const NewtonMesh* const solidMesh, int shapeID, int fracturePhysicsMaterialID, int pointcloudCount, const dFloat* const vertexCloud, int strideInBytes, int materialID, const dFloat* const textureMatrix, - NewtonFractureCompoundCollisionReconstructMainMeshCallBack regenerateMainMeshCallback, - NewtonFractureCompoundCollisionOnEmitCompoundFractured emitFracturedCompound, NewtonFractureCompoundCollisionOnEmitChunk emitFracfuredChunk); - NEWTON_API NewtonCollision* NewtonFracturedCompoundPlaneClip (const NewtonCollision* const fracturedCompound, const dFloat* const plane); - - NEWTON_API void NewtonFracturedCompoundSetCallbacks (const NewtonCollision* const fracturedCompound, NewtonFractureCompoundCollisionReconstructMainMeshCallBack regenerateMainMeshCallback, - NewtonFractureCompoundCollisionOnEmitCompoundFractured emitFracturedCompound, NewtonFractureCompoundCollisionOnEmitChunk emitFracfuredChunk); - - - NEWTON_API int NewtonFracturedCompoundIsNodeFreeToDetach (const NewtonCollision* const fracturedCompound, void* const collisionNode); - NEWTON_API int NewtonFracturedCompoundNeighborNodeList (const NewtonCollision* const fracturedCompound, void* const collisionNode, void** const list, int maxCount); - - - NEWTON_API NewtonFracturedCompoundMeshPart* NewtonFracturedCompoundGetMainMesh (const NewtonCollision* const fracturedCompound); - NEWTON_API NewtonFracturedCompoundMeshPart* NewtonFracturedCompoundGetFirstSubMesh(const NewtonCollision* const fracturedCompound); - NEWTON_API NewtonFracturedCompoundMeshPart* NewtonFracturedCompoundGetNextSubMesh(const NewtonCollision* const fracturedCompound, NewtonFracturedCompoundMeshPart* const subMesh); - - NEWTON_API int NewtonFracturedCompoundCollisionGetVertexCount (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner); - NEWTON_API const dFloat* NewtonFracturedCompoundCollisionGetVertexPositions (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner); - NEWTON_API const dFloat* NewtonFracturedCompoundCollisionGetVertexNormals (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner); - NEWTON_API const dFloat* NewtonFracturedCompoundCollisionGetVertexUVs (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner); - NEWTON_API int NewtonFracturedCompoundMeshPartGetIndexStream (const NewtonCollision* const fracturedCompound, const NewtonFracturedCompoundMeshPart* const meshOwner, const void* const segment, int* const index); - - NEWTON_API void* NewtonFracturedCompoundMeshPartGetFirstSegment (const NewtonFracturedCompoundMeshPart* const fractureCompoundMeshPart); - NEWTON_API void* NewtonFracturedCompoundMeshPartGetNextSegment (const void* const fractureCompoundMeshSegment); - NEWTON_API int NewtonFracturedCompoundMeshPartGetMaterial (const void* const fractureCompoundMeshSegment); - NEWTON_API int NewtonFracturedCompoundMeshPartGetIndexCount (const void* const fractureCompoundMeshSegment); - - - // ********************************************************************************************** - // - // scene collision are static compound collision that can take polygonal static collisions - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateSceneCollision (const NewtonWorld* const newtonWorld, int shapeID); - - NEWTON_API void NewtonSceneCollisionBeginAddRemove (NewtonCollision* const sceneCollision); - NEWTON_API void* NewtonSceneCollisionAddSubCollision (NewtonCollision* const sceneCollision, const NewtonCollision* const collision); - NEWTON_API void NewtonSceneCollisionRemoveSubCollision (NewtonCollision* const compoundCollision, const void* const collisionNode); - NEWTON_API void NewtonSceneCollisionRemoveSubCollisionByIndex (NewtonCollision* const sceneCollision, int nodeIndex); - NEWTON_API void NewtonSceneCollisionSetSubCollisionMatrix (NewtonCollision* const sceneCollision, const void* const collisionNode, const dFloat* const matrix); - NEWTON_API void NewtonSceneCollisionEndAddRemove (NewtonCollision* const sceneCollision); - - NEWTON_API void* NewtonSceneCollisionGetFirstNode (NewtonCollision* const sceneCollision); - NEWTON_API void* NewtonSceneCollisionGetNextNode (NewtonCollision* const sceneCollision, const void* const collisionNode); - - NEWTON_API void* NewtonSceneCollisionGetNodeByIndex (NewtonCollision* const sceneCollision, int index); - NEWTON_API int NewtonSceneCollisionGetNodeIndex (NewtonCollision* const sceneCollision, const void* const collisionNode); - NEWTON_API NewtonCollision* NewtonSceneCollisionGetCollisionFromNode (NewtonCollision* const sceneCollision, const void* const collisionNode); - - - // *********************************************************************************************************** - // - // User Static mesh collision interface - // - // *********************************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateUserMeshCollision (const NewtonWorld* const newtonWorld, const dFloat* const minBox, - const dFloat* const maxBox, void* const userData, NewtonUserMeshCollisionCollideCallback collideCallback, - NewtonUserMeshCollisionRayHitCallback rayHitCallback, NewtonUserMeshCollisionDestroyCallback destroyCallback, - NewtonUserMeshCollisionGetCollisionInfo getInfoCallback, NewtonUserMeshCollisionAABBTest getLocalAABBCallback, - NewtonUserMeshCollisionGetFacesInAABB facesInAABBCallback, NewtonOnUserCollisionSerializationCallback serializeCallback, int shapeID); - - NEWTON_API int NewtonUserMeshCollisionContinuousOverlapTest (const NewtonUserMeshCollisionCollideDesc* const collideDescData, const void* const continueCollisionHandle, const dFloat* const minAabb, const dFloat* const maxAabb); - - // *********************************************************************************************************** - // - // Collision serialization functions - // - // *********************************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateCollisionFromSerialization (const NewtonWorld* const newtonWorld, NewtonDeserializeCallback deserializeFunction, void* const serializeHandle); - NEWTON_API void NewtonCollisionSerialize (const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, NewtonSerializeCallback serializeFunction, void* const serializeHandle); - NEWTON_API void NewtonCollisionGetInfo (const NewtonCollision* const collision, NewtonCollisionInfoRecord* const collisionInfo); - - // ********************************************************************************************** - // - // Static collision shapes functions - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateHeightFieldCollision (const NewtonWorld* const newtonWorld, int width, int height, int gridsDiagonals, int elevationdatType, const void* const elevationMap, const char* const attributeMap, dFloat verticalScale, dFloat horizontalScale_x, dFloat horizontalScale_z, int shapeID); - NEWTON_API void NewtonHeightFieldSetUserRayCastCallback (const NewtonCollision* const heightfieldCollision, NewtonHeightFieldRayCastCallback rayHitCallback); - - NEWTON_API NewtonCollision* NewtonCreateTreeCollision (const NewtonWorld* const newtonWorld, int shapeID); - NEWTON_API NewtonCollision* NewtonCreateTreeCollisionFromMesh (const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, int shapeID); - NEWTON_API void NewtonTreeCollisionSetUserRayCastCallback (const NewtonCollision* const treeCollision, NewtonCollisionTreeRayCastCallback rayHitCallback); - - NEWTON_API void NewtonTreeCollisionBeginBuild (const NewtonCollision* const treeCollision); - NEWTON_API void NewtonTreeCollisionAddFace (const NewtonCollision* const treeCollision, int vertexCount, const dFloat* const vertexPtr, int strideInBytes, int faceAttribute); - NEWTON_API void NewtonTreeCollisionEndBuild (const NewtonCollision* const treeCollision, int optimize); - - NEWTON_API int NewtonTreeCollisionGetFaceAttribute (const NewtonCollision* const treeCollision, const int* const faceIndexArray, int indexCount); - NEWTON_API void NewtonTreeCollisionSetFaceAttribute (const NewtonCollision* const treeCollision, const int* const faceIndexArray, int indexCount, int attribute); - - NEWTON_API void NewtonTreeCollisionForEachFace (const NewtonCollision* const treeCollision, NewtonTreeCollisionFaceCallback forEachFaceCallback, void* const context); - - NEWTON_API int NewtonTreeCollisionGetVertexListTriangleListInAABB (const NewtonCollision* const treeCollision, const dFloat* const p0, const dFloat* const p1, const dFloat** const vertexArray, int* const vertexCount, int* const vertexStrideInBytes, const int* const indexList, int maxIndexCount, const int* const faceAttribute); - - NEWTON_API void NewtonStaticCollisionSetDebugCallback (const NewtonCollision* const staticCollision, NewtonTreeCollisionCallback userCallback); - - // ********************************************************************************************** - // - // General purpose collision library functions - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCollisionCreateInstance (const NewtonCollision* const collision); - NEWTON_API int NewtonCollisionGetType (const NewtonCollision* const collision); - NEWTON_API int NewtonCollisionIsConvexShape (const NewtonCollision* const collision); - NEWTON_API int NewtonCollisionIsStaticShape (const NewtonCollision* const collision); - - // for the end user - NEWTON_API void NewtonCollisionSetUserData (const NewtonCollision* const collision, void* const userData); - NEWTON_API void* NewtonCollisionGetUserData (const NewtonCollision* const collision); - - NEWTON_API void NewtonCollisionSetUserID (const NewtonCollision* const collision, dLong id); - NEWTON_API dLong NewtonCollisionGetUserID (const NewtonCollision* const collision); - - NEWTON_API void NewtonCollisionGetMaterial (const NewtonCollision* const collision, NewtonCollisionMaterial* const userData); - NEWTON_API void NewtonCollisionSetMaterial (const NewtonCollision* const collision, const NewtonCollisionMaterial* const userData); - - NEWTON_API void* NewtonCollisionGetSubCollisionHandle (const NewtonCollision* const collision); - NEWTON_API NewtonCollision* NewtonCollisionGetParentInstance (const NewtonCollision* const collision); - - NEWTON_API void NewtonCollisionSetMatrix (const NewtonCollision* const collision, const dFloat* const matrix); - NEWTON_API void NewtonCollisionGetMatrix (const NewtonCollision* const collision, dFloat* const matrix); - - NEWTON_API void NewtonCollisionSetScale (const NewtonCollision* const collision, dFloat scaleX, dFloat scaleY, dFloat scaleZ); - NEWTON_API void NewtonCollisionGetScale (const NewtonCollision* const collision, dFloat* const scaleX, dFloat* const scaleY, dFloat* const scaleZ); - NEWTON_API void NewtonDestroyCollision (const NewtonCollision* const collision); - - NEWTON_API dFloat NewtonCollisionGetSkinThickness (const NewtonCollision* const collision); - NEWTON_API void NewtonCollisionSetSkinThickness(const NewtonCollision* const collision, dFloat thickness); - - NEWTON_API int NewtonCollisionIntersectionTest (const NewtonWorld* const newtonWorld, - const NewtonCollision* const collisionA, const dFloat* const matrixA, - const NewtonCollision* const collisionB, const dFloat* const matrixB, int threadIndex); - - NEWTON_API int NewtonCollisionPointDistance (const NewtonWorld* const newtonWorld, const dFloat* const point, - const NewtonCollision* const collision, const dFloat* const matrix, dFloat* const contact, dFloat* const normal, int threadIndex); - - NEWTON_API int NewtonCollisionClosestPoint (const NewtonWorld* const newtonWorld, - const NewtonCollision* const collisionA, const dFloat* const matrixA, - const NewtonCollision* const collisionB, const dFloat* const matrixB, - dFloat* const contactA, dFloat* const contactB, dFloat* const normalAB, int threadIndex); - - NEWTON_API int NewtonCollisionCollide (const NewtonWorld* const newtonWorld, int maxSize, - const NewtonCollision* const collisionA, const dFloat* const matrixA, - const NewtonCollision* const collisionB, const dFloat* const matrixB, - dFloat* const contacts, dFloat* const normals, dFloat* const penetration, - dLong* const attributeA, dLong* const attributeB, int threadIndex); - - NEWTON_API int NewtonCollisionCollideContinue (const NewtonWorld* const newtonWorld, int maxSize, dFloat timestep, - const NewtonCollision* const collisionA, const dFloat* const matrixA, const dFloat* const velocA, const dFloat* omegaA, - const NewtonCollision* const collisionB, const dFloat* const matrixB, const dFloat* const velocB, const dFloat* const omegaB, - dFloat* const timeOfImpact, dFloat* const contacts, dFloat* const normals, dFloat* const penetration, - dLong* const attributeA, dLong* const attributeB, int threadIndex); - - NEWTON_API void NewtonCollisionSupportVertex (const NewtonCollision* const collision, const dFloat* const dir, dFloat* const vertex); - NEWTON_API dFloat NewtonCollisionRayCast (const NewtonCollision* const collision, const dFloat* const p0, const dFloat* const p1, dFloat* const normal, dLong* const attribute); - NEWTON_API void NewtonCollisionCalculateAABB (const NewtonCollision* const collision, const dFloat* const matrix, dFloat* const p0, dFloat* const p1); - NEWTON_API void NewtonCollisionForEachPolygonDo (const NewtonCollision* const collision, const dFloat* const matrix, NewtonCollisionIterator callback, void* const userData); - - // ********************************************************************************************** - // - // collision aggregates, are a collision node on eh broad phase the serve as the root nod for a collection of rigid bodies - // that shared the property of being in close proximity all the time, they are similar to compound collision by the group bodies instead of collision instances - // These are good for speeding calculation calculation of rag doll, Vehicles or contractions of rigid bodied lined by joints. - // also for example if you know that many the life time of a group of bodies like the object on a house of a building will be localize to the confide of the building - // then warping the bodies under an aggregate will reduce collision calculation of almost an order of magnitude. - // - // ********************************************************************************************** - NEWTON_API void* NewtonCollisionAggregateCreate (NewtonWorld* const world); - NEWTON_API void NewtonCollisionAggregateDestroy (void* const aggregate); - NEWTON_API void NewtonCollisionAggregateAddBody (void* const aggregate, const NewtonBody* const body); - NEWTON_API void NewtonCollisionAggregateRemoveBody (void* const aggregate, const NewtonBody* const body); - - NEWTON_API int NewtonCollisionAggregateGetSelfCollision (void* const aggregate); - NEWTON_API void NewtonCollisionAggregateSetSelfCollision (void* const aggregate, int state); - - // ********************************************************************************************** - // - // transforms utility functions - // - // ********************************************************************************************** - NEWTON_API void NewtonSetEulerAngle (const dFloat* const eulersAngles, dFloat* const matrix); - NEWTON_API void NewtonGetEulerAngle (const dFloat* const matrix, dFloat* const eulersAngles0, dFloat* const eulersAngles1); - NEWTON_API dFloat NewtonCalculateSpringDamperAcceleration (dFloat dt, dFloat ks, dFloat x, dFloat kd, dFloat s); - - // ********************************************************************************************** - // - // body manipulation functions - // - // ********************************************************************************************** - NEWTON_API NewtonBody* NewtonCreateDynamicBody (const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, const dFloat* const matrix); - NEWTON_API NewtonBody* NewtonCreateKinematicBody (const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, const dFloat* const matrix); - NEWTON_API NewtonBody* NewtonCreateAsymetricDynamicBody(const NewtonWorld* const newtonWorld, const NewtonCollision* const collision, const dFloat* const matrix); - - NEWTON_API void NewtonDestroyBody(const NewtonBody* const body); - - NEWTON_API int NewtonBodyGetSimulationState(const NewtonBody* const body); - NEWTON_API void NewtonBodySetSimulationState(const NewtonBody* const bodyPtr, const int state); - - NEWTON_API int NewtonBodyGetType (const NewtonBody* const body); - NEWTON_API int NewtonBodyGetCollidable (const NewtonBody* const body); - NEWTON_API void NewtonBodySetCollidable (const NewtonBody* const body, int collidableState); - - NEWTON_API void NewtonBodyAddForce (const NewtonBody* const body, const dFloat* const force); - NEWTON_API void NewtonBodyAddTorque (const NewtonBody* const body, const dFloat* const torque); - - NEWTON_API void NewtonBodySetCentreOfMass (const NewtonBody* const body, const dFloat* const com); - NEWTON_API void NewtonBodySetMassMatrix (const NewtonBody* const body, dFloat mass, dFloat Ixx, dFloat Iyy, dFloat Izz); - NEWTON_API void NewtonBodySetFullMassMatrix (const NewtonBody* const body, dFloat mass, const dFloat* const inertiaMatrix); - - NEWTON_API void NewtonBodySetMassProperties (const NewtonBody* const body, dFloat mass, const NewtonCollision* const collision); - NEWTON_API void NewtonBodySetMatrix (const NewtonBody* const body, const dFloat* const matrix); - NEWTON_API void NewtonBodySetMatrixNoSleep (const NewtonBody* const body, const dFloat* const matrix); - NEWTON_API void NewtonBodySetMatrixRecursive (const NewtonBody* const body, const dFloat* const matrix); - - NEWTON_API void NewtonBodySetMaterialGroupID (const NewtonBody* const body, int id); - NEWTON_API void NewtonBodySetContinuousCollisionMode (const NewtonBody* const body, unsigned state); - NEWTON_API void NewtonBodySetJointRecursiveCollision (const NewtonBody* const body, unsigned state); - NEWTON_API void NewtonBodySetOmega (const NewtonBody* const body, const dFloat* const omega); - NEWTON_API void NewtonBodySetOmegaNoSleep (const NewtonBody* const body, const dFloat* const omega); - NEWTON_API void NewtonBodySetVelocity (const NewtonBody* const body, const dFloat* const velocity); - NEWTON_API void NewtonBodySetVelocityNoSleep (const NewtonBody* const body, const dFloat* const velocity); - NEWTON_API void NewtonBodySetForce (const NewtonBody* const body, const dFloat* const force); - NEWTON_API void NewtonBodySetTorque (const NewtonBody* const body, const dFloat* const torque); - - NEWTON_API void NewtonBodySetLinearDamping (const NewtonBody* const body, dFloat linearDamp); - NEWTON_API void NewtonBodySetAngularDamping (const NewtonBody* const body, const dFloat* const angularDamp); - NEWTON_API void NewtonBodySetCollision (const NewtonBody* const body, const NewtonCollision* const collision); - NEWTON_API void NewtonBodySetCollisionScale (const NewtonBody* const body, dFloat scaleX, dFloat scaleY, dFloat scaleZ); - - NEWTON_API int NewtonBodyGetSleepState (const NewtonBody* const body); - NEWTON_API void NewtonBodySetSleepState (const NewtonBody* const body, int state); - - NEWTON_API int NewtonBodyGetAutoSleep (const NewtonBody* const body); - NEWTON_API void NewtonBodySetAutoSleep (const NewtonBody* const body, int state); - - NEWTON_API int NewtonBodyGetFreezeState(const NewtonBody* const body); - NEWTON_API void NewtonBodySetFreezeState (const NewtonBody* const body, int state); - - NEWTON_API int NewtonBodyGetGyroscopicTorque(const NewtonBody* const body); - NEWTON_API void NewtonBodySetGyroscopicTorque(const NewtonBody* const body, int state); - - NEWTON_API void NewtonBodySetDestructorCallback (const NewtonBody* const body, NewtonBodyDestructor callback); - NEWTON_API NewtonBodyDestructor NewtonBodyGetDestructorCallback (const NewtonBody* const body); - - NEWTON_API void NewtonBodySetTransformCallback (const NewtonBody* const body, NewtonSetTransform callback); - NEWTON_API NewtonSetTransform NewtonBodyGetTransformCallback (const NewtonBody* const body); - - NEWTON_API void NewtonBodySetForceAndTorqueCallback (const NewtonBody* const body, NewtonApplyForceAndTorque callback); - NEWTON_API NewtonApplyForceAndTorque NewtonBodyGetForceAndTorqueCallback (const NewtonBody* const body); - - NEWTON_API int NewtonBodyGetID (const NewtonBody* const body); - - NEWTON_API void NewtonBodySetUserData (const NewtonBody* const body, void* const userData); - NEWTON_API void* NewtonBodyGetUserData (const NewtonBody* const body); - - NEWTON_API NewtonWorld* NewtonBodyGetWorld (const NewtonBody* const body); - NEWTON_API NewtonCollision* NewtonBodyGetCollision (const NewtonBody* const body); - NEWTON_API int NewtonBodyGetMaterialGroupID (const NewtonBody* const body); - - NEWTON_API int NewtonBodyGetSerializedID(const NewtonBody* const body); - NEWTON_API int NewtonBodyGetContinuousCollisionMode (const NewtonBody* const body); - NEWTON_API int NewtonBodyGetJointRecursiveCollision (const NewtonBody* const body); - - NEWTON_API void NewtonBodyGetPosition(const NewtonBody* const body, dFloat* const pos); - NEWTON_API void NewtonBodyGetMatrix(const NewtonBody* const body, dFloat* const matrix); - NEWTON_API void NewtonBodyGetRotation(const NewtonBody* const body, dFloat* const rotation); - NEWTON_API void NewtonBodyGetMass (const NewtonBody* const body, dFloat* mass, dFloat* const Ixx, dFloat* const Iyy, dFloat* const Izz); - NEWTON_API void NewtonBodyGetInvMass(const NewtonBody* const body, dFloat* const invMass, dFloat* const invIxx, dFloat* const invIyy, dFloat* const invIzz); - NEWTON_API void NewtonBodyGetInertiaMatrix(const NewtonBody* const body, dFloat* const inertiaMatrix); - NEWTON_API void NewtonBodyGetInvInertiaMatrix(const NewtonBody* const body, dFloat* const invInertiaMatrix); - NEWTON_API void NewtonBodyGetOmega(const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetVelocity(const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetAlpha(const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetAcceleration(const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetForce(const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetTorque(const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetCentreOfMass (const NewtonBody* const body, dFloat* const com); - NEWTON_API void NewtonBodyGetPointVelocity (const NewtonBody* const body, const dFloat* const point, dFloat* const velocOut); - - NEWTON_API void NewtonBodyApplyImpulsePair (const NewtonBody* const body, dFloat* const linearImpulse, dFloat* const angularImpulse, dFloat timestep); - NEWTON_API void NewtonBodyAddImpulse (const NewtonBody* const body, const dFloat* const pointDeltaVeloc, const dFloat* const pointPosit, dFloat timestep); - NEWTON_API void NewtonBodyApplyImpulseArray (const NewtonBody* const body, int impuleCount, int strideInByte, const dFloat* const impulseArray, const dFloat* const pointArray, dFloat timestep); - - NEWTON_API void NewtonBodyIntegrateVelocity (const NewtonBody* const body, dFloat timestep); - - NEWTON_API dFloat NewtonBodyGetLinearDamping (const NewtonBody* const body); - NEWTON_API void NewtonBodyGetAngularDamping (const NewtonBody* const body, dFloat* const vector); - NEWTON_API void NewtonBodyGetAABB (const NewtonBody* const body, dFloat* const p0, dFloat* const p1); - - NEWTON_API NewtonJoint* NewtonBodyGetFirstJoint (const NewtonBody* const body); - NEWTON_API NewtonJoint* NewtonBodyGetNextJoint (const NewtonBody* const body, const NewtonJoint* const joint); - - NEWTON_API NewtonJoint* NewtonBodyGetFirstContactJoint (const NewtonBody* const body); - NEWTON_API NewtonJoint* NewtonBodyGetNextContactJoint (const NewtonBody* const body, const NewtonJoint* const contactJoint); - NEWTON_API NewtonJoint* NewtonBodyFindContact (const NewtonBody* const body0, const NewtonBody* const body1); - - // ********************************************************************************************** - // - // contact joints interface - // - // ********************************************************************************************** - NEWTON_API void* NewtonContactJointGetFirstContact (const NewtonJoint* const contactJoint); - NEWTON_API void* NewtonContactJointGetNextContact (const NewtonJoint* const contactJoint, void* const contact); - - NEWTON_API int NewtonContactJointGetContactCount(const NewtonJoint* const contactJoint); - NEWTON_API void NewtonContactJointRemoveContact(const NewtonJoint* const contactJoint, void* const contact); - - NEWTON_API dFloat NewtonContactJointGetClosestDistance(const NewtonJoint* const contactJoint); - NEWTON_API void NewtonContactJointResetSelftJointCollision(const NewtonJoint* const contactJoint); - NEWTON_API void NewtonContactJointResetIntraJointCollision(const NewtonJoint* const contactJoint); - - NEWTON_API NewtonMaterial* NewtonContactGetMaterial (const void* const contact); - - NEWTON_API NewtonCollision* NewtonContactGetCollision0 (const void* const contact); - NEWTON_API NewtonCollision* NewtonContactGetCollision1 (const void* const contact); - - NEWTON_API void* NewtonContactGetCollisionID0 (const void* const contact); - NEWTON_API void* NewtonContactGetCollisionID1 (const void* const contact); - - - // ********************************************************************************************** - // - // Common joint functions - // - // ********************************************************************************************** - NEWTON_API void* NewtonJointGetUserData (const NewtonJoint* const joint); - NEWTON_API void NewtonJointSetUserData (const NewtonJoint* const joint, void* const userData); - - NEWTON_API NewtonBody* NewtonJointGetBody0 (const NewtonJoint* const joint); - NEWTON_API NewtonBody* NewtonJointGetBody1 (const NewtonJoint* const joint); - - NEWTON_API void NewtonJointGetInfo (const NewtonJoint* const joint, NewtonJointRecord* const info); - NEWTON_API int NewtonJointGetCollisionState (const NewtonJoint* const joint); - NEWTON_API void NewtonJointSetCollisionState (const NewtonJoint* const joint, int state); - - NEWTON_API dFloat NewtonJointGetStiffness (const NewtonJoint* const joint); - NEWTON_API void NewtonJointSetStiffness (const NewtonJoint* const joint, dFloat state); - - NEWTON_API void NewtonDestroyJoint(const NewtonWorld* const newtonWorld, const NewtonJoint* const joint); - NEWTON_API void NewtonJointSetDestructor (const NewtonJoint* const joint, NewtonConstraintDestructor destructor); - - NEWTON_API int NewtonJointIsActive (const NewtonJoint* const joint); - - // ********************************************************************************************** - // - // particle system interface (soft bodies, individual, pressure bodies and cloth) - // - // ********************************************************************************************** - NEWTON_API NewtonCollision* NewtonCreateMassSpringDamperSystem (const NewtonWorld* const newtonWorld, int shapeID, - const dFloat* const points, int pointCount, int strideInBytes, const dFloat* const pointMass, - const int* const links, int linksCount, const dFloat* const linksSpring, const dFloat* const linksDamper); - - NEWTON_API NewtonCollision* NewtonCreateDeformableSolid(const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, int shapeID); - - NEWTON_API int NewtonDeformableMeshGetParticleCount (const NewtonCollision* const deformableMesh); - NEWTON_API int NewtonDeformableMeshGetParticleStrideInBytes (const NewtonCollision* const deformableMesh); - NEWTON_API const dFloat* NewtonDeformableMeshGetParticleArray (const NewtonCollision* const deformableMesh); - -/* - NEWTON_API NewtonCollision* NewtonCreateClothPatch (const NewtonWorld* const newtonWorld, NewtonMesh* const mesh, int shapeID, NewtonClothPatchMaterial* const structuralMaterial, NewtonClothPatchMaterial* const bendMaterial); - NEWTON_API void NewtonDeformableMeshCreateClusters (NewtonCollision* const deformableMesh, int clusterCount, dFloat overlapingWidth); - NEWTON_API void NewtonDeformableMeshSetDebugCallback (NewtonCollision* const deformableMesh, NewtonCollisionIterator callback); - - - NEWTON_API void NewtonDeformableMeshGetParticlePosition (NewtonCollision* const deformableMesh, int particleIndex, dFloat* const posit); - - NEWTON_API void NewtonDeformableMeshBeginConfiguration (const NewtonCollision* const deformableMesh); - NEWTON_API void NewtonDeformableMeshUnconstraintParticle (NewtonCollision* const deformableMesh, int particleIndex); - NEWTON_API void NewtonDeformableMeshConstraintParticle (NewtonCollision* const deformableMesh, int particleIndex, const dFloat* const posit, const NewtonBody* const body); - NEWTON_API void NewtonDeformableMeshEndConfiguration (const NewtonCollision* const deformableMesh); - -// NEWTON_API void NewtonDeformableMeshSetPlasticity (NewtonCollision* const deformableMesh, dFloat plasticity); -// NEWTON_API void NewtonDeformableMeshSetStiffness (NewtonCollision* const deformableMesh, dFloat stiffness); - NEWTON_API void NewtonDeformableMeshSetSkinThickness (NewtonCollision* const deformableMesh, dFloat skinThickness); - - NEWTON_API void NewtonDeformableMeshUpdateRenderNormals (const NewtonCollision* const deformableMesh); - NEWTON_API int NewtonDeformableMeshGetVertexCount (const NewtonCollision* const deformableMesh); - NEWTON_API void NewtonDeformableMeshGetVertexStreams (const NewtonCollision* const deformableMesh, int vertexStrideInByte, dFloat* const vertex, int normalStrideInByte, dFloat* const normal, int uvStrideInByte0, dFloat* const uv0); - NEWTON_API NewtonDeformableMeshSegment* NewtonDeformableMeshGetFirstSegment (const NewtonCollision* const deformableMesh); - NEWTON_API NewtonDeformableMeshSegment* NewtonDeformableMeshGetNextSegment (const NewtonCollision* const deformableMesh, const NewtonDeformableMeshSegment* const segment); - - NEWTON_API int NewtonDeformableMeshSegmentGetMaterialID (const NewtonCollision* const deformableMesh, const NewtonDeformableMeshSegment* const segment); - NEWTON_API int NewtonDeformableMeshSegmentGetIndexCount (const NewtonCollision* const deformableMesh, const NewtonDeformableMeshSegment* const segment); - NEWTON_API const int* NewtonDeformableMeshSegmentGetIndexList (const NewtonCollision* const deformableMesh, const NewtonDeformableMeshSegment* const segment); -*/ - // ********************************************************************************************** - // - // Ball and Socket joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateBall (const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, const NewtonBody* const childBody, const NewtonBody* const parentBody); - NEWTON_API void NewtonBallSetUserCallback (const NewtonJoint* const ball, NewtonBallCallback callback); - NEWTON_API void NewtonBallGetJointAngle (const NewtonJoint* const ball, dFloat* angle); - NEWTON_API void NewtonBallGetJointOmega (const NewtonJoint* const ball, dFloat* omega); - NEWTON_API void NewtonBallGetJointForce (const NewtonJoint* const ball, dFloat* const force); - NEWTON_API void NewtonBallSetConeLimits (const NewtonJoint* const ball, const dFloat* pin, dFloat maxConeAngle, dFloat maxTwistAngle); - - // ********************************************************************************************** - // - // Hinge joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateHinge (const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir, const NewtonBody* const childBody, const NewtonBody* const parentBody); - NEWTON_API void NewtonHingeSetUserCallback (const NewtonJoint* const hinge, NewtonHingeCallback callback); - NEWTON_API dFloat NewtonHingeGetJointAngle (const NewtonJoint* const hinge); - NEWTON_API dFloat NewtonHingeGetJointOmega (const NewtonJoint* const hinge); - NEWTON_API void NewtonHingeGetJointForce (const NewtonJoint* const hinge, dFloat* const force); - NEWTON_API dFloat NewtonHingeCalculateStopAlpha (const NewtonJoint* const hinge, const NewtonHingeSliderUpdateDesc* const desc, dFloat angle); - - // ********************************************************************************************** - // - // Slider joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateSlider (const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir, const NewtonBody* const childBody, const NewtonBody* const parentBody); - NEWTON_API void NewtonSliderSetUserCallback (const NewtonJoint* const slider, NewtonSliderCallback callback); - NEWTON_API dFloat NewtonSliderGetJointPosit (const NewtonJoint* slider); - NEWTON_API dFloat NewtonSliderGetJointVeloc (const NewtonJoint* slider); - NEWTON_API void NewtonSliderGetJointForce (const NewtonJoint* const slider, dFloat* const force); - NEWTON_API dFloat NewtonSliderCalculateStopAccel (const NewtonJoint* const slider, const NewtonHingeSliderUpdateDesc* const desc, dFloat position); - - - // ********************************************************************************************** - // - // Corkscrew joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateCorkscrew (const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir, const NewtonBody* const childBody, const NewtonBody* const parentBody); - NEWTON_API void NewtonCorkscrewSetUserCallback (const NewtonJoint* const corkscrew, NewtonCorkscrewCallback callback); - NEWTON_API dFloat NewtonCorkscrewGetJointPosit (const NewtonJoint* const corkscrew); - NEWTON_API dFloat NewtonCorkscrewGetJointAngle (const NewtonJoint* const corkscrew); - NEWTON_API dFloat NewtonCorkscrewGetJointVeloc (const NewtonJoint* const corkscrew); - NEWTON_API dFloat NewtonCorkscrewGetJointOmega (const NewtonJoint* const corkscrew); - NEWTON_API void NewtonCorkscrewGetJointForce (const NewtonJoint* const corkscrew, dFloat* const force); - NEWTON_API dFloat NewtonCorkscrewCalculateStopAlpha (const NewtonJoint* const corkscrew, const NewtonHingeSliderUpdateDesc* const desc, dFloat angle); - NEWTON_API dFloat NewtonCorkscrewCalculateStopAccel (const NewtonJoint* const corkscrew, const NewtonHingeSliderUpdateDesc* const desc, dFloat position); - - - // ********************************************************************************************** - // - // Universal joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateUniversal (const NewtonWorld* const newtonWorld, const dFloat* pivotPoint, const dFloat* pinDir0, const dFloat* pinDir1, const NewtonBody* const childBody, const NewtonBody* const parentBody); - NEWTON_API void NewtonUniversalSetUserCallback (const NewtonJoint* const universal, NewtonUniversalCallback callback); - NEWTON_API dFloat NewtonUniversalGetJointAngle0 (const NewtonJoint* const universal); - NEWTON_API dFloat NewtonUniversalGetJointAngle1 (const NewtonJoint* const universal); - NEWTON_API dFloat NewtonUniversalGetJointOmega0 (const NewtonJoint* const universal); - NEWTON_API dFloat NewtonUniversalGetJointOmega1 (const NewtonJoint* const universal); - NEWTON_API void NewtonUniversalGetJointForce (const NewtonJoint* const universal, dFloat* const force); - NEWTON_API dFloat NewtonUniversalCalculateStopAlpha0 (const NewtonJoint* const universal, const NewtonHingeSliderUpdateDesc* const desc, dFloat angle); - NEWTON_API dFloat NewtonUniversalCalculateStopAlpha1 (const NewtonJoint* const universal, const NewtonHingeSliderUpdateDesc* const desc, dFloat angle); - - - // ********************************************************************************************** - // - // Up vector joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateUpVector (const NewtonWorld* const newtonWorld, const dFloat* pinDir, const NewtonBody* const body); - NEWTON_API void NewtonUpVectorGetPin (const NewtonJoint* const upVector, dFloat *pin); - NEWTON_API void NewtonUpVectorSetPin (const NewtonJoint* const upVector, const dFloat *pin); - - - // ********************************************************************************************** - // - // User defined bilateral Joint - // - // ********************************************************************************************** - NEWTON_API NewtonJoint* NewtonConstraintCreateUserJoint (const NewtonWorld* const newtonWorld, int maxDOF, NewtonUserBilateralCallback callback, const NewtonBody* const childBody, const NewtonBody* const parentBody) ; - NEWTON_API int NewtonUserJointGetSolverModel(const NewtonJoint* const joint); - NEWTON_API void NewtonUserJointSetSolverModel(const NewtonJoint* const joint, int model); - NEWTON_API void NewtonUserJointMassScale(const NewtonJoint* const joint, dFloat scaleBody0, dFloat scaleBody1); - - NEWTON_API void NewtonUserJointSetFeedbackCollectorCallback (const NewtonJoint* const joint, NewtonUserBilateralCallback getFeedback); - NEWTON_API void NewtonUserJointAddLinearRow (const NewtonJoint* const joint, const dFloat* const pivot0, const dFloat* const pivot1, const dFloat* const dir); - NEWTON_API void NewtonUserJointAddAngularRow (const NewtonJoint* const joint, dFloat relativeAngle, const dFloat* const dir); - NEWTON_API void NewtonUserJointAddGeneralRow (const NewtonJoint* const joint, const dFloat* const jacobian0, const dFloat* const jacobian1); - NEWTON_API void NewtonUserJointSetRowMinimumFriction (const NewtonJoint* const joint, dFloat friction); - NEWTON_API void NewtonUserJointSetRowMaximumFriction (const NewtonJoint* const joint, dFloat friction); - NEWTON_API dFloat NewtonUserJointCalculateRowZeroAcceleration (const NewtonJoint* const joint); - NEWTON_API dFloat NewtonUserJointGetRowAcceleration (const NewtonJoint* const joint); - NEWTON_API void NewtonUserJointGetRowJacobian(const NewtonJoint* const joint, dFloat* const linear0, dFloat* const angula0, dFloat* const linear1, dFloat* const angula1); - NEWTON_API void NewtonUserJointSetRowAcceleration (const NewtonJoint* const joint, dFloat acceleration); - NEWTON_API void NewtonUserJointSetRowSpringDamperAcceleration (const NewtonJoint* const joint, dFloat rowStiffness, dFloat spring, dFloat damper); - NEWTON_API void NewtonUserJointSetRowStiffness (const NewtonJoint* const joint, dFloat stiffness); - NEWTON_API int NewtonUserJoinRowsCount (const NewtonJoint* const joint); - NEWTON_API void NewtonUserJointGetGeneralRow (const NewtonJoint* const joint, int index, dFloat* const jacobian0, dFloat* const jacobian1); - NEWTON_API dFloat NewtonUserJointGetRowForce (const NewtonJoint* const joint, int row); - - // ********************************************************************************************** - // - // Mesh joint functions - // - // ********************************************************************************************** - NEWTON_API NewtonMesh* NewtonMeshCreate(const NewtonWorld* const newtonWorld); - NEWTON_API NewtonMesh* NewtonMeshCreateFromMesh(const NewtonMesh* const mesh); - NEWTON_API NewtonMesh* NewtonMeshCreateFromCollision(const NewtonCollision* const collision); - NEWTON_API NewtonMesh* NewtonMeshCreateTetrahedraIsoSurface(const NewtonMesh* const mesh); - NEWTON_API NewtonMesh* NewtonMeshCreateConvexHull (const NewtonWorld* const newtonWorld, int pointCount, const dFloat* const vertexCloud, int strideInBytes, dFloat tolerance); - NEWTON_API NewtonMesh* NewtonMeshCreateVoronoiConvexDecomposition (const NewtonWorld* const newtonWorld, int pointCount, const dFloat* const vertexCloud, int strideInBytes, int materialID, const dFloat* const textureMatrix); - NEWTON_API NewtonMesh* NewtonMeshCreateFromSerialization (const NewtonWorld* const newtonWorld, NewtonDeserializeCallback deserializeFunction, void* const serializeHandle); - NEWTON_API void NewtonMeshDestroy(const NewtonMesh* const mesh); - - NEWTON_API void NewtonMeshSerialize (const NewtonMesh* const mesh, NewtonSerializeCallback serializeFunction, void* const serializeHandle); - NEWTON_API void NewtonMeshSaveOFF(const NewtonMesh* const mesh, const char* const filename); - NEWTON_API NewtonMesh* NewtonMeshLoadOFF(const NewtonWorld* const newtonWorld, const char* const filename); - NEWTON_API NewtonMesh* NewtonMeshLoadTetrahedraMesh(const NewtonWorld* const newtonWorld, const char* const filename); - - NEWTON_API void NewtonMeshFlipWinding(const NewtonMesh* const mesh); - - NEWTON_API void NewtonMeshApplyTransform (const NewtonMesh* const mesh, const dFloat* const matrix); - NEWTON_API void NewtonMeshCalculateOOBB(const NewtonMesh* const mesh, dFloat* const matrix, dFloat* const x, dFloat* const y, dFloat* const z); - - NEWTON_API void NewtonMeshCalculateVertexNormals(const NewtonMesh* const mesh, dFloat angleInRadians); - NEWTON_API void NewtonMeshApplySphericalMapping(const NewtonMesh* const mesh, int material, const dFloat* const aligmentMatrix); - NEWTON_API void NewtonMeshApplyCylindricalMapping(const NewtonMesh* const mesh, int cylinderMaterial, int capMaterial, const dFloat* const aligmentMatrix); - NEWTON_API void NewtonMeshApplyBoxMapping(const NewtonMesh* const mesh, int frontMaterial, int sideMaterial, int topMaterial, const dFloat* const aligmentMatrix); - NEWTON_API void NewtonMeshApplyAngleBasedMapping(const NewtonMesh* const mesh, int material, NewtonReportProgress reportPrograssCallback, void* const reportPrgressUserData, dFloat* const aligmentMatrix); - - NEWTON_API void NewtonCreateTetrahedraLinearBlendSkinWeightsChannel(const NewtonMesh* const tetrahedraMesh, NewtonMesh* const skinMesh); - - NEWTON_API void NewtonMeshOptimize (const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshOptimizePoints (const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshOptimizeVertex (const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshIsOpenMesh (const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshFixTJoints (const NewtonMesh* const mesh); - - NEWTON_API void NewtonMeshPolygonize (const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshTriangulate (const NewtonMesh* const mesh); - NEWTON_API NewtonMesh* NewtonMeshUnion (const NewtonMesh* const mesh, const NewtonMesh* const clipper, const dFloat* const clipperMatrix); - NEWTON_API NewtonMesh* NewtonMeshDifference (const NewtonMesh* const mesh, const NewtonMesh* const clipper, const dFloat* const clipperMatrix); - NEWTON_API NewtonMesh* NewtonMeshIntersection (const NewtonMesh* const mesh, const NewtonMesh* const clipper, const dFloat* const clipperMatrix); - NEWTON_API void NewtonMeshClip (const NewtonMesh* const mesh, const NewtonMesh* const clipper, const dFloat* const clipperMatrix, NewtonMesh** const topMesh, NewtonMesh** const bottomMesh); - - NEWTON_API NewtonMesh* NewtonMeshConvexMeshIntersection (const NewtonMesh* const mesh, const NewtonMesh* const convexMesh); - - NEWTON_API NewtonMesh* NewtonMeshSimplify (const NewtonMesh* const mesh, int maxVertexCount, NewtonReportProgress reportPrograssCallback, void* const reportPrgressUserData); - NEWTON_API NewtonMesh* NewtonMeshApproximateConvexDecomposition (const NewtonMesh* const mesh, dFloat maxConcavity, dFloat backFaceDistanceFactor, int maxCount, int maxVertexPerHull, NewtonReportProgress reportProgressCallback, void* const reportProgressUserData); - - NEWTON_API void NewtonRemoveUnusedVertices(const NewtonMesh* const mesh, int* const vertexRemapTable); - - NEWTON_API void NewtonMeshBeginBuild(const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshBeginFace(const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshAddPoint(const NewtonMesh* const mesh, dFloat64 x, dFloat64 y, dFloat64 z); - NEWTON_API void NewtonMeshAddLayer(const NewtonMesh* const mesh, int layerIndex); - NEWTON_API void NewtonMeshAddMaterial(const NewtonMesh* const mesh, int materialIndex); - NEWTON_API void NewtonMeshAddNormal(const NewtonMesh* const mesh, dFloat x, dFloat y, dFloat z); - NEWTON_API void NewtonMeshAddBinormal(const NewtonMesh* const mesh, dFloat x, dFloat y, dFloat z); - NEWTON_API void NewtonMeshAddUV0(const NewtonMesh* const mesh, dFloat u, dFloat v); - NEWTON_API void NewtonMeshAddUV1(const NewtonMesh* const mesh, dFloat u, dFloat v); - NEWTON_API void NewtonMeshAddVertexColor(const NewtonMesh* const mesh, dFloat32 r, dFloat32 g, dFloat32 b, dFloat32 a); - NEWTON_API void NewtonMeshEndFace(const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshEndBuild(const NewtonMesh* const mesh); - - NEWTON_API void NewtonMeshClearVertexFormat (NewtonMeshVertexFormat* const format); - NEWTON_API void NewtonMeshBuildFromVertexListIndexList (const NewtonMesh* const mesh, const NewtonMeshVertexFormat* const format); - - NEWTON_API int NewtonMeshGetPointCount (const NewtonMesh* const mesh); - NEWTON_API const int* NewtonMeshGetIndexToVertexMap(const NewtonMesh* const mesh); - - NEWTON_API void NewtonMeshGetVertexDoubleChannel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat64* const outBuffer); - NEWTON_API void NewtonMeshGetVertexChannel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer); - NEWTON_API void NewtonMeshGetNormalChannel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer); - NEWTON_API void NewtonMeshGetBinormalChannel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer); - NEWTON_API void NewtonMeshGetUV0Channel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer); - NEWTON_API void NewtonMeshGetUV1Channel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer); - NEWTON_API void NewtonMeshGetVertexColorChannel (const NewtonMesh* const mesh, int vertexStrideInByte, dFloat* const outBuffer); - - NEWTON_API int NewtonMeshHasNormalChannel(const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshHasBinormalChannel(const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshHasUV0Channel(const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshHasUV1Channel(const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshHasVertexColorChannel(const NewtonMesh* const mesh); - - NEWTON_API void* NewtonMeshBeginHandle (const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshEndHandle (const NewtonMesh* const mesh, void* const handle); - NEWTON_API int NewtonMeshFirstMaterial (const NewtonMesh* const mesh, void* const handle); - NEWTON_API int NewtonMeshNextMaterial (const NewtonMesh* const mesh, void* const handle, int materialId); - NEWTON_API int NewtonMeshMaterialGetMaterial (const NewtonMesh* const mesh, void* const handle, int materialId); - NEWTON_API int NewtonMeshMaterialGetIndexCount (const NewtonMesh* const mesh, void* const handle, int materialId); - NEWTON_API void NewtonMeshMaterialGetIndexStream (const NewtonMesh* const mesh, void* const handle, int materialId, int* const index); - NEWTON_API void NewtonMeshMaterialGetIndexStreamShort (const NewtonMesh* const mesh, void* const handle, int materialId, short int* const index); - - NEWTON_API NewtonMesh* NewtonMeshCreateFirstSingleSegment (const NewtonMesh* const mesh); - NEWTON_API NewtonMesh* NewtonMeshCreateNextSingleSegment (const NewtonMesh* const mesh, const NewtonMesh* const segment); - - NEWTON_API NewtonMesh* NewtonMeshCreateFirstLayer (const NewtonMesh* const mesh); - NEWTON_API NewtonMesh* NewtonMeshCreateNextLayer (const NewtonMesh* const mesh, const NewtonMesh* const segment); - - NEWTON_API int NewtonMeshGetTotalFaceCount (const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshGetTotalIndexCount (const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshGetFaces (const NewtonMesh* const mesh, int* const faceIndexCount, int* const faceMaterial, void** const faceIndices); - - NEWTON_API int NewtonMeshGetVertexCount (const NewtonMesh* const mesh); - NEWTON_API int NewtonMeshGetVertexStrideInByte (const NewtonMesh* const mesh); - NEWTON_API const dFloat64* NewtonMeshGetVertexArray (const NewtonMesh* const mesh); - - NEWTON_API int NewtonMeshGetVertexBaseCount(const NewtonMesh* const mesh); - NEWTON_API void NewtonMeshSetVertexBaseCount(const NewtonMesh* const mesh, int baseCount); - - NEWTON_API void* NewtonMeshGetFirstVertex (const NewtonMesh* const mesh); - NEWTON_API void* NewtonMeshGetNextVertex (const NewtonMesh* const mesh, const void* const vertex); - NEWTON_API int NewtonMeshGetVertexIndex (const NewtonMesh* const mesh, const void* const vertex); - - NEWTON_API void* NewtonMeshGetFirstPoint (const NewtonMesh* const mesh); - NEWTON_API void* NewtonMeshGetNextPoint (const NewtonMesh* const mesh, const void* const point); - NEWTON_API int NewtonMeshGetPointIndex (const NewtonMesh* const mesh, const void* const point); - NEWTON_API int NewtonMeshGetVertexIndexFromPoint (const NewtonMesh* const mesh, const void* const point); - - NEWTON_API void* NewtonMeshGetFirstEdge (const NewtonMesh* const mesh); - NEWTON_API void* NewtonMeshGetNextEdge (const NewtonMesh* const mesh, const void* const edge); - NEWTON_API void NewtonMeshGetEdgeIndices (const NewtonMesh* const mesh, const void* const edge, int* const v0, int* const v1); - //NEWTON_API void NewtonMeshGetEdgePointIndices (const NewtonMesh* const mesh, const void* const edge, int* const v0, int* const v1); - - NEWTON_API void* NewtonMeshGetFirstFace (const NewtonMesh* const mesh); - NEWTON_API void* NewtonMeshGetNextFace (const NewtonMesh* const mesh, const void* const face); - NEWTON_API int NewtonMeshIsFaceOpen (const NewtonMesh* const mesh, const void* const face); - NEWTON_API int NewtonMeshGetFaceMaterial (const NewtonMesh* const mesh, const void* const face); - NEWTON_API int NewtonMeshGetFaceIndexCount (const NewtonMesh* const mesh, const void* const face); - NEWTON_API void NewtonMeshGetFaceIndices (const NewtonMesh* const mesh, const void* const face, int* const indices); - NEWTON_API void NewtonMeshGetFacePointIndices (const NewtonMesh* const mesh, const void* const face, int* const indices); - NEWTON_API void NewtonMeshCalculateFaceNormal (const NewtonMesh* const mesh, const void* const face, dFloat64* const normal); - - NEWTON_API void NewtonMeshSetFaceMaterial (const NewtonMesh* const mesh, const void* const face, int matId); - - -#ifdef __cplusplus -} -#endif -#endif - - - diff --git a/thirdparty/src/newton/dgNewton/NewtonClass.cpp b/thirdparty/src/newton/dgNewton/NewtonClass.cpp deleted file mode 100644 index ef51615c7..000000000 --- a/thirdparty/src/newton/dgNewton/NewtonClass.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "NewtonStdAfx.h" -#include "NewtonClass.h" - - -void* Newton::DefaultAllocMemory (dgInt32 size) -{ - return malloc (size_t (size)); -} - - -void Newton::DefaultFreeMemory (void* const ptr, dgInt32 size) -{ - free (ptr); -} - - -Newton::Newton (dgMemoryAllocator* const allocator) - :dgWorld(allocator) - ,m_destructor(NULL) -{ -} - -Newton::~Newton () -{ - if (m_destructor) { - m_destructor ((NewtonWorld*)this); - } -} - -void Newton::UpdatePhysics (dgFloat32 timestep) -{ - Update (timestep); -} - -void Newton::UpdatePhysicsAsync (dgFloat32 timestep) -{ - UpdateAsync (timestep); -} - -NewtonUserJoint::NewtonUserJoint(NewtonUserBilateralCallback callback, dgBody* const body) - :dgUserConstraint(NULL, body, NULL, 1) - ,m_forceArray(m_jointForce) - ,m_param(NULL) - ,m_rows(0) -{ - m_maxDOF = 6; - m_jacobianFnt = callback; - m_body1 = body->GetWorld()->GetSentinelBody(); -} - -NewtonUserJoint::NewtonUserJoint (dgWorld* const world, dgInt32 maxDof, NewtonUserBilateralCallback callback, dgBody* const dyn0, dgBody* const dyn1) - :dgUserConstraint (world, dyn0, dyn1, 1) - ,m_forceArray(m_jointForce) - ,m_param(NULL) - ,m_rows(0) -{ - m_maxDOF = dgUnsigned8(maxDof); - m_jacobianFnt = callback; - - dgAssert (world); - if (m_maxDOF > DG_BILATERAL_CONTRAINT_DOF) { - m_forceArray = (dgForceImpactPair*) world->GetAllocator()->Malloc (dgInt32 (m_maxDOF * sizeof (dgForceImpactPair))); - } - memset (m_forceArray, 0, m_maxDOF * sizeof (dgFloat32)); -} - -NewtonUserJoint::~NewtonUserJoint () -{ - if (m_forceArray != m_jointForce) { - m_body0->GetWorld()->GetAllocator()->Free (m_forceArray); - } -} - -void NewtonUserJoint::SetMassScale (dgFloat32 scale0, dgFloat32 scale1) -{ - m_massScaleBody0 = scale0; - m_massScaleBody1 = scale1; - - dgWorld* const world = m_body0->GetWorld(); - dgSkeletonList& skelManager = *world; - skelManager.m_skelListIsDirty = true; -} - -dgUnsigned32 NewtonUserJoint::JacobianDerivative (dgContraintDescritor& params) -{ - m_rows = 0; - m_param = ¶ms; - m_jacobianFnt ((NewtonJoint*)this, params.m_timestep, params.m_threadIndex); - return dgUnsigned32 (m_rows); -} - -void NewtonUserJoint::Serialize (dgSerialize serializeCallback, void* const userData) -{ - dgWorld::OnJointSerializationCallback serializeJoint; - dgWorld::OnJointDeserializationCallback deserializeJoint; - - Newton* const world = m_body0 ? (Newton*)m_body0->GetWorld() : (Newton*)m_body1->GetWorld(); - world->GetJointSerializationCallbacks (&serializeJoint, &deserializeJoint); - if (serializeJoint) { - ((NewtonOnJointSerializationCallback)serializeJoint) ((NewtonJoint*)this, (NewtonSerializeCallback)serializeCallback, userData); - } -} - -void NewtonUserJoint::AddLinearRowJacobian (const dgVector& pivot0, const dgVector& pivot1, const dgVector& dir) -{ - dgPointParam pointData; - InitPointParam (pointData, m_defualtDiagonalRegularizer, pivot0, pivot1); - - CalculatePointDerivative (m_rows, *m_param, dir, pointData, &m_forceArray[m_rows]); - m_rows ++; - dgAssert (m_rows <= dgInt32 (m_maxDOF)); -} - -void NewtonUserJoint::AddAngularRowJacobian (const dgVector& dir, dgFloat32 relAngle) -{ - CalculateAngularDerivative (m_rows, *m_param, dir, m_defualtDiagonalRegularizer, relAngle, &m_forceArray[m_rows]); - m_rows ++; - dgAssert (m_rows <= dgInt32 (m_maxDOF)); -} - -void NewtonUserJoint::AddGeneralRowJacobian (const dgFloat32* const jacobian0, const dgFloat32* const jacobian1) -{ - SetJacobianDerivative (m_rows, *m_param, jacobian0, jacobian1, &m_forceArray[m_rows]); - m_rows ++; - dgAssert (m_rows <= dgInt32 (m_maxDOF)); -} - -dgInt32 NewtonUserJoint::GetJacobianCount() const -{ - return m_rows; -} - -void NewtonUserJoint::GetJacobianAt(dgInt32 index, dgFloat32* const jacobian0, dgFloat32* const jacobian1) const -{ - if (index < m_rows) { - for (dgInt32 i = 0; i < 3; i ++) { - jacobian0[i] = m_param->m_jacobian[index].m_jacobianM0.m_linear[i]; - jacobian1[i] = m_param->m_jacobian[index].m_jacobianM1.m_linear[i]; - jacobian0[i + 3] = m_param->m_jacobian[index].m_jacobianM0.m_angular[i]; - jacobian1[i + 3] = m_param->m_jacobian[index].m_jacobianM1.m_angular[i]; - } - } -} - -void NewtonUserJoint::GetJacobian(dgJacobian& jacobian0, dgJacobian& jacobian1) const -{ - dgInt32 index = m_rows - 1; - if ((index >= 0) && (index < dgInt32(m_maxDOF))) { - jacobian0.m_linear = m_param->m_jacobian[index].m_jacobianM0.m_linear; - jacobian0.m_angular = m_param->m_jacobian[index].m_jacobianM0.m_angular; - jacobian1.m_linear = m_param->m_jacobian[index].m_jacobianM1.m_linear; - jacobian1.m_angular = m_param->m_jacobian[index].m_jacobianM1.m_angular; - } -} - - -dFloat NewtonUserJoint::GetAcceleration () const -{ - dgInt32 index = m_rows - 1; - if ((index >= 0) && (index < dgInt32 (m_maxDOF))) { - return GetRowAcceleration (index, *m_param); - } - return 0.0f; -} - - -void NewtonUserJoint::SetAcceleration (dgFloat32 acceleration) -{ - dgInt32 index = m_rows - 1; - if ((index >= 0) && (index < dgInt32 (m_maxDOF))) { - SetMotorAcceleration (index, acceleration, *m_param); - } -} - -dgFloat32 NewtonUserJoint::CalculateZeroMotorAcceleration() const -{ - dgInt32 index = m_rows - 1; - dgFloat32 accel = dgFloat32 (0.0f); - if ((index >= 0) && (index < dgInt32(m_maxDOF))) { - accel = CalculateMotorAcceleration(index, *m_param); - } - return accel; -} - -void NewtonUserJoint::SetSpringDamperAcceleration (dgFloat32 rowStiffness, dFloat spring, dFloat damper) -{ - dgInt32 index = m_rows - 1; - if ((index >= 0) && (index < dgInt32 (m_maxDOF))) { - dgBilateralConstraint::SetSpringDamperAcceleration (index, *m_param, rowStiffness, spring, damper); - } -} - -void NewtonUserJoint::SetHighFriction (dgFloat32 friction) -{ - dgInt32 index = m_rows - 1; - if ((index >= 0) && (index < dgInt32 (m_maxDOF))) { - m_param->m_forceBounds[index].m_upper = dgClamp (friction, dgFloat32(0.001f), dgFloat32(DG_MAX_BOUND)); - dgAssert (m_param->m_forceBounds[index].m_normalIndex == DG_INDEPENDENT_ROW); - - #ifdef _DEBUG - dgInt32 i0 = 0; - dgInt32 i1 = m_rows - 1; - while ((i0 <= i1) && (m_param->m_forceBounds[i0].m_normalIndex == DG_INDEPENDENT_ROW)) i0 ++; - while ((i1 >= i0) && (m_param->m_forceBounds[i1].m_normalIndex != DG_INDEPENDENT_ROW)) i1 --; - dgAssert((i0 - i1) == 1); - if ((i0 - i1) != 1) { - dgTrace(("make sure that friction joint are issue at last\n")); - } - #endif - } -} - -void NewtonUserJoint::SetLowerFriction (dgFloat32 friction) -{ - dgInt32 index = m_rows - 1; - if ((index >= 0) && (index < dgInt32 (m_maxDOF))) { - m_param->m_forceBounds[index].m_low = dgClamp (friction, dgFloat32(DG_MIN_BOUND), dgFloat32(-0.001f)); - dgAssert (m_param->m_forceBounds[index].m_normalIndex == DG_INDEPENDENT_ROW); - - #ifdef _DEBUG - dgInt32 i0 = 0; - dgInt32 i1 = m_rows - 1; - while ((i0 <= i1) && (m_param->m_forceBounds[i0].m_normalIndex == DG_INDEPENDENT_ROW)) i0++; - while ((i1 >= i0) && (m_param->m_forceBounds[i1].m_normalIndex != DG_INDEPENDENT_ROW)) i1--; - dgAssert((i0 - i1) == 1); - if ((i0 - i1) != 1) { - dgTrace(("make sure that friction joint are issue at last\n")); - } - #endif - } -} - -void NewtonUserJoint::SetRowStiffness (dgFloat32 stiffness) -{ - dgInt32 index = m_rows - 1; - if ((index >= 0) && (index < dgInt32 (m_maxDOF))) { - stiffness = dgClamp (stiffness, dgFloat32(0.0f), dgFloat32(1.0f)); - m_param->m_diagonalRegularizer[index] = stiffness; - } -} - -dgFloat32 NewtonUserJoint::GetRowForce (dgInt32 row) const -{ - dgFloat32 force = 0.0f; - if ((row >= 0) && (row < dgInt32 (m_maxDOF))) { - force = m_forceArray[row].m_force; - } - return force; -} - -void NewtonUserJoint::SetUpdateFeedbackFunction (NewtonUserBilateralCallback getFeedback) -{ - dgUserConstraint::SetUpdateFeedbackFunction ((ConstraintsForceFeeback) getFeedback); -} diff --git a/thirdparty/src/newton/dgNewton/NewtonClass.h b/thirdparty/src/newton/dgNewton/NewtonClass.h deleted file mode 100644 index 3e7a3eae5..000000000 --- a/thirdparty/src/newton/dgNewton/NewtonClass.h +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __NewotnClass_H__ -#define __NewotnClass_H__ - -#include "NewtonStdAfx.h" -#include "Newton.h" - -class Newton; - - -class Newton: public dgWorld -{ - public: - DG_CLASS_ALLOCATOR(allocator) - - Newton (dgMemoryAllocator* const allocator); - ~Newton (); - - void UpdatePhysics (dgFloat32 timestep); - void UpdatePhysicsAsync (dgFloat32 timestep); - static void* DefaultAllocMemory (dgInt32 size); - static void DefaultFreeMemory (void* const ptr, dgInt32 size); - - NewtonWorldDestructorCallback m_destructor; -}; - - -class NewtonUserJoint: public dgUserConstraint -{ - public: - NewtonUserJoint (dgWorld* const world, dgInt32 maxDof, NewtonUserBilateralCallback callback, dgBody* const dyn0, dgBody* const dyn1); - ~NewtonUserJoint (); - - dgUnsigned32 JacobianDerivative (dgContraintDescritor& params); - void Serialize (dgSerialize serializeCallback, void* const userData); - - void AddAngularRowJacobian (const dgVector& dir, dgFloat32 relAngle); - void AddGeneralRowJacobian (const dgFloat32* const jacobian0, const dgFloat32* const jacobian1); - void AddLinearRowJacobian (const dgVector& pivot0, const dgVector& pivot1, const dgVector& dir); - - dgInt32 GetJacobianCount () const; - void GetJacobianAt (dgInt32 index, dgFloat32* const jacobian0, dgFloat32* const jacobian1) const; - - dgFloat32 GetRowForce (dgInt32 row) const; - void GetJacobian(dgJacobian& jacobian0, dgJacobian& jacobian1) const; - - void SetHighFriction (dgFloat32 friction); - void SetLowerFriction (dgFloat32 friction); - void SetRowStiffness (dgFloat32 stiffness); - void SetAcceleration (dgFloat32 acceleration); - dgFloat32 GetAcceleration () const; - dgFloat32 CalculateZeroMotorAcceleration() const; - - void SetSpringDamperAcceleration (dgFloat32 rowStiffness, dgFloat32 springK, dgFloat32 springD); - void SetUpdateFeedbackFunction (NewtonUserBilateralCallback getFeedback); - - void SetMassScale (dgFloat32 scale0, dgFloat32 scale1); - - protected: - NewtonUserJoint(NewtonUserBilateralCallback callback, dgBody* const body); - - private: - NewtonUserBilateralCallback m_jacobianFnt; - - dgForceImpactPair* m_forceArray; - dgContraintDescritor* m_param; - dgInt32 m_rows; -}; - -#endif diff --git a/thirdparty/src/newton/dgNewton/NewtonStdAfx.h b/thirdparty/src/newton/dgNewton/NewtonStdAfx.h deleted file mode 100644 index e25f61616..000000000 --- a/thirdparty/src/newton/dgNewton/NewtonStdAfx.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __NEWTON_STDAFX_H__ -#define __NEWTON_STDAFX_H__ - - -#ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include "dg.h" -#include "dgPhysics.h" - -#endif // !defined(AFX_STDAFX_H__7B02FF2D_C0C3_4291_9676_333105355F57_H) - diff --git a/thirdparty/src/newton/dgPhysics/CMakeLists.txt b/thirdparty/src/newton/dgPhysics/CMakeLists.txt deleted file mode 100644 index d214a06c1..000000000 --- a/thirdparty/src/newton/dgPhysics/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (c) <2014-2017> <Newton Game Dynamics> -# -# 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. - -cmake_minimum_required(VERSION 3.4.0) - -set (projectName "dgPhysics") -message (${projectName}) - -if(NEWTON_USE_PLUGIN_DLL) - add_definitions(-DDG_USE_PLUGINS) -endif() - - -#source and header files -file(GLOB CPP_SOURCE - *.h - *.cpp - ../dgMeshUtil/*.h - ../dgMeshUtil/*.cpp -) -#source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/" FILES ${CPP_SOURCE}) - -if (MSVC) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /fp:fast") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /fp:fast") -endif(MSVC) - -if(NEWTON_BUILD_SHARED_LIBS) - if(MSVC) - add_library(${projectName} STATIC ${CPP_SOURCE}) - else() - add_library(${projectName} SHARED ${CPP_SOURCE}) - endif() -else() - add_library(${projectName} STATIC ${CPP_SOURCE}) -endif() - -if (MSVC) - if(CMAKE_VS_MSBUILD_COMMAND OR CMAKE_VS_DEVENV_COMMAND) - set_target_properties(${projectName} PROPERTIES COMPILE_FLAGS "/YudgPhysicsStdafx.h") - set_source_files_properties(dgWorld.cpp PROPERTIES COMPILE_FLAGS "/YcdgPhysicsStdafx.h") - endif() -endif(MSVC) - -target_include_directories(${projectName} PUBLIC . ../dgMeshUtil) -target_link_libraries(${projectName} dgCore) - -install(TARGETS ${projectName} - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin) - -install(FILES ${HEADERS} DESTINATION include/${projectName}) - diff --git a/thirdparty/src/newton/dgPhysics/dgBallConstraint.cpp b/thirdparty/src/newton/dgPhysics/dgBallConstraint.cpp deleted file mode 100644 index 01b76bcd6..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBallConstraint.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgBallConstraint.h" - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -dgBallConstraint::dgBallConstraint () - :dgBilateralConstraint() -{ - dgAssert ((((dgUnsigned64) &m_localMatrix0) & 15) == 0); - - m_localMatrix0 = dgGetIdentityMatrix(); - m_localMatrix1 = dgGetIdentityMatrix(); - - m_maxDOF = 6; - m_jointUserCallback = NULL; - m_constId = m_ballConstraint; - m_ballLimits = 0; - m_angles = dgVector (dgFloat32 (0.0f)); -} - -dgBallConstraint::~dgBallConstraint () -{ -} - -void dgBallConstraint::SetJointParameterCallback (dgBallJointFriction callback) -{ - m_jointUserCallback = callback; -} - -dgVector dgBallConstraint::GetJointAngle ()const -{ - return m_angles; -} - -dgVector dgBallConstraint::GetJointOmega () const -{ - dgAssert (m_body0); - dgAssert (m_body1); - const dgMatrix& matrix = m_body0->GetMatrix(); - - dgVector dir0 (matrix.RotateVector (m_localMatrix0[0])); - dgVector dir1 (matrix.RotateVector (m_localMatrix0[1])); - dgVector dir2 (matrix.RotateVector (m_localMatrix0[2])); - - const dgVector& omega0 = m_body0->GetOmega(); - const dgVector& omega1 = m_body1->GetOmega(); - -// dgVector omega1 (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); -// if (m_body1) { -// omega1 = m_body1->GetOmega(); -// } - - dgVector relOmega (omega0 - omega1); - return dgVector (relOmega.DotProduct(dir0).GetScalar(), relOmega.DotProduct(dir1).GetScalar(), relOmega.DotProduct(dir2).GetScalar(), dgFloat32 (0.0f)); -} - -dgVector dgBallConstraint::GetJointForce () const -{ - dgMatrix matrix0; - dgMatrix matrix1; - - CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1); - return dgVector (matrix0.m_front.Scale (m_jointForce[0].m_force) + matrix0.m_up.Scale (m_jointForce[1].m_force) + matrix0.m_right.Scale (m_jointForce[2].m_force)); -} - -bool dgBallConstraint::GetTwistLimitState () const -{ - return m_twistLimit; -} - -bool dgBallConstraint::GetConeLimitState () const -{ - return m_coneLimit; -} - -bool dgBallConstraint::GetLatealLimitState () const -{ - return m_lateralLimit; -} - -void dgBallConstraint::SetTwistLimitState (bool state) -{ - m_twistLimit = dgUnsigned32 (state); -} - -void dgBallConstraint::SetConeLimitState (bool state) -{ - m_coneLimit = dgUnsigned32 (state); -} - -void dgBallConstraint::SetLatealLimitState (bool state) -{ - m_lateralLimit = dgUnsigned32 (state); -} - -void dgBallConstraint::SetPivotPoint(const dgVector &pivot) -{ - dgAssert (m_body0); - dgAssert (m_body1); - const dgMatrix& matrix = m_body0->GetMatrix(); - - dgVector pin (dgVector::m_triplexMask & (pivot - matrix.m_posit)); - dgAssert (pin.m_w == dgFloat32 (0.0f)); - if (pin.DotProduct(pin).GetScalar() < dgFloat32 (1.0e-3f)) { - pin = matrix.m_front; - } - - SetPivotAndPinDir (pivot, pin, m_localMatrix0, m_localMatrix1); - - dgMatrix matrix0; - dgMatrix matrix1; - CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1); - SetLimits (matrix0.m_front, -dgPi * dgFloat32 (0.5f), dgPi * dgFloat32 (0.5f), dgPi * dgFloat32 (0.5f), matrix0.m_right, dgFloat32 (0.0f), dgFloat32 (0.0f)); -} - -void dgBallConstraint::SetLimits ( - const dgVector& coneDir, - dgFloat32 minConeAngle, - dgFloat32 maxConeAngle, - dgFloat32 maxTwistAngle, - const dgVector& bilateralDir, - dgFloat32 negativeBilateralConeAngle__, - dgFloat32 positiveBilateralConeAngle__) -{ - dgMatrix matrix0; - dgMatrix matrix1; - CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1); - - dgAssert (m_body0); - dgAssert (m_body1); - const dgMatrix& body0_Matrix = m_body0->GetMatrix(); - - dgVector lateralDir (bilateralDir.CrossProduct(coneDir)); - if (lateralDir.DotProduct(lateralDir).GetScalar() < dgFloat32 (1.0e-3f)) { - dgMatrix tmp (coneDir); - lateralDir = tmp.m_up; - } - - - m_localMatrix0.m_front = body0_Matrix.UnrotateVector (coneDir); - m_localMatrix0.m_up = body0_Matrix.UnrotateVector (lateralDir); - m_localMatrix0.m_posit = body0_Matrix.UntransformVector (matrix1.m_posit); - - m_localMatrix0.m_front = m_localMatrix0.m_front.Normalize(); - m_localMatrix0.m_up = m_localMatrix0.m_up.Normalize(); - m_localMatrix0.m_right = m_localMatrix0.m_front.CrossProduct(m_localMatrix0.m_up); - - m_localMatrix0.m_front.m_w = dgFloat32 (0.0f); - m_localMatrix0.m_up.m_w = dgFloat32 (0.0f); - m_localMatrix0.m_right.m_w = dgFloat32 (0.0f); - m_localMatrix0.m_posit.m_w = dgFloat32 (1.0f); - - const dgMatrix& body1_Matrix = m_body1->GetMatrix(); - - m_twistAngle = dgClamp (maxTwistAngle, dgFloat32 (5.0f) * dgDegreeToRad, dgFloat32 (90.0f) * dgDegreeToRad); - m_coneAngle = dgClamp ((maxConeAngle - minConeAngle) * dgFloat32 (0.5f), dgFloat32 (5.0f) * dgDegreeToRad, 175.0f * dgDegreeToRad); - m_coneAngleCos = dgCos (m_coneAngle); - - dgMatrix coneMatrix (dgPitchMatrix((maxConeAngle + minConeAngle) * dgFloat32 (0.5f))); - - m_localMatrix0 = coneMatrix * m_localMatrix0; - - m_localMatrix1 = m_localMatrix0 * body0_Matrix * body1_Matrix.Inverse(); - -} - -dgUnsigned32 dgBallConstraint::JacobianDerivative (dgContraintDescritor& params) -{ - dgMatrix matrix0; - dgMatrix matrix1; - - if (m_jointUserCallback) { - m_jointUserCallback (*this, params.m_timestep); - } - - dgVector angle (CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1)); - m_angles = angle.Scale (-dgFloat32 (1.0f)); - - const dgVector& dir0 = matrix0.m_front; - const dgVector& dir1 = matrix0.m_up; - const dgVector& dir2 = matrix0.m_right; - const dgVector& p0 = matrix0.m_posit; - const dgVector& p1 = matrix1.m_posit; - - - dgPointParam pointData; - InitPointParam (pointData, m_defualtDiagonalRegularizer, p0, p1); - CalculatePointDerivative (0, params, dir0, pointData, &m_jointForce[0]); - CalculatePointDerivative (1, params, dir1, pointData, &m_jointForce[1]); - CalculatePointDerivative (2, params, dir2, pointData, &m_jointForce[2]); - dgInt32 ret = 3; - -// dgAssert (0); -/* - dgFloat32 relVelocErr; - dgFloat32 penetrationErr; - if (m_twistLimit) { - if (angle.m_x > m_twistAngle) { - dgVector q0 (matrix0.m_posit + matrix0.m_up.Scale(MIN_JOINT_PIN_LENGTH)); - InitPointParam (pointData, m_defualtDiagonalRegularizer, q0, q0); - - const dgVector& dir = matrix0.m_right; - CalculatePointDerivative (ret, params, dir, pointData, &m_jointForce[ret]); - - dgVector velocError (pointData.m_veloc1 - pointData.m_veloc0); - relVelocErr = velocError.DotProduct(dir).GetScalar(); - if (relVelocErr > dgFloat32 (1.0e-3f)) { - relVelocErr *= dgFloat32 (1.1f); - } - - penetrationErr = MIN_JOINT_PIN_LENGTH * (angle.m_x - m_twistAngle); - dgAssert (penetrationErr >= dgFloat32 (0.0f)); - - params.m_forceBounds[ret].m_low = dgFloat32 (0.0f); - params.m_forceBounds[ret].m_normalIndex = DG_INDEPENDENT_ROW; - params.m_forceBounds[ret].m_jointForce = &m_jointForce[ret]; - SetMotorAcceleration (ret, (relVelocErr + penetrationErr) * params.m_invTimestep, params); - ret ++; - } else if (angle.m_x < - m_twistAngle) { - dgVector q0 (matrix0.m_posit + matrix0.m_up.Scale(MIN_JOINT_PIN_LENGTH)); - InitPointParam (pointData, m_defualtDiagonalRegularizer, q0, q0); - //dgVector dir (matrix0.m_right.Scale (-dgFloat32 (1.0f))); - dgVector dir (matrix0.m_right * dgVector::m_negOne); - CalculatePointDerivative (ret, params, dir, pointData, &m_jointForce[ret]); - - dgVector velocError (pointData.m_veloc1 - pointData.m_veloc0); - relVelocErr = velocError.DotProduct(dir).GetScalar(); - if (relVelocErr > dgFloat32 (1.0e-3f)) { - relVelocErr *= dgFloat32 (1.1f); - } - - penetrationErr = MIN_JOINT_PIN_LENGTH * (- m_twistAngle - angle.m_x); - dgAssert (penetrationErr >= dgFloat32 (0.0f)); - - params.m_forceBounds[ret].m_low = dgFloat32 (0.0f); - params.m_forceBounds[ret].m_normalIndex = DG_INDEPENDENT_ROW; - params.m_forceBounds[ret].m_jointForce = &m_jointForce[ret]; - SetMotorAcceleration (ret, (relVelocErr + penetrationErr) * params.m_invTimestep, params); - ret ++; - } - } - - if (m_coneLimit) { - - dgFloat32 coneCos; - coneCos = matrix0.m_front.DotProduct(matrix1.m_front).GetScalar(); - if (coneCos < m_coneAngleCos) { - dgVector q0 (matrix0.m_posit + matrix0.m_front.Scale(MIN_JOINT_PIN_LENGTH)); - InitPointParam (pointData, m_defualtDiagonalRegularizer, q0, q0); - - dgVector tangentDir (matrix0.m_front.CrossProduct(matrix1.m_front)); - tangentDir = tangentDir.Normalize()); - CalculatePointDerivative (ret, params, tangentDir, pointData, &m_jointForce[ret]); - ret ++; - - dgVector normalDir (tangentDir.CrossProduct(matrix0.m_front)); - - dgVector velocError (pointData.m_veloc1 - pointData.m_veloc0); - //restitution = contact.m_restitution; - relVelocErr = velocError.DotProduct(normalDir).GetScalar(); - if (relVelocErr > dgFloat32 (1.0e-3f)) { - relVelocErr *= dgFloat32 (1.1f); - } - - penetrationErr = MIN_JOINT_PIN_LENGTH * (dgAcos (dgMax (coneCos, dgFloat32(-0.9999f))) - m_coneAngle); - dgAssert (penetrationErr >= dgFloat32 (0.0f)); - - CalculatePointDerivative (ret, params, normalDir, pointData, &m_jointForce[ret]); - params.m_forceBounds[ret].m_low = dgFloat32 (0.0f); - params.m_forceBounds[ret].m_normalIndex = DG_INDEPENDENT_ROW; - params.m_forceBounds[ret].m_jointForce = &m_jointForce[ret]; - SetMotorAcceleration (ret, (relVelocErr + penetrationErr) * params.m_invTimestep, params); - ret ++; - } - } -*/ - return dgUnsigned32 (ret); -} - diff --git a/thirdparty/src/newton/dgPhysics/dgBallConstraint.h b/thirdparty/src/newton/dgPhysics/dgBallConstraint.h deleted file mode 100644 index a62d50fab..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBallConstraint.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -#if !defined(AFX_DGBALLCONSTRAINT_H__7C9E1F9A_5EC6_48BE_8C9F_FB90132C6619_H) -#define AFX_DGBALLCONSTRAINT_H__7C9E1F9A_5EC6_48BE_8C9F_FB90132C6619_H -#include "dgBilateralConstraint.h" - -#ifdef _WIN_32_VER - #pragma warning (disable: 4201) //nonstandard extension used : nameless struct/union -#endif - - -//template<class T> class dgPool; - -class dgBallConstraint; -typedef dgUnsigned32 (dgApi *dgBallJointFriction) (const dgBallConstraint& ball,dgFloat32 timestep); - -class dgBallConstraint: public dgBilateralConstraint -{ - public: - dgVector GetJointAngle ()const; - dgVector GetJointOmega ()const; - dgVector GetJointForce ()const; - void SetJointParameterCallback (dgBallJointFriction callback); - - bool GetTwistLimitState () const; - void SetTwistLimitState (bool state); - - bool GetConeLimitState () const; - void SetConeLimitState (bool state); - - bool GetLatealLimitState () const; - void SetLatealLimitState (bool state); - - - void SetLimits (const dgVector& coneDir, dgFloat32 minConeAngle, dgFloat32 maxConeAngle, dgFloat32 maxTwistAngle, - const dgVector& bilateralDir, dgFloat32 negativeBilateralConeAngle, dgFloat32 positiveBilateralConeAngle); - - - private: - dgBallConstraint (); - virtual ~dgBallConstraint (); - - void SetPivotPoint (const dgVector& pivot); - virtual dgUnsigned32 JacobianDerivative (dgContraintDescritor& params); - virtual void Serialize (dgSerialize serializeCallback, void* const userData) {dgAssert (0);} - - - dgVector m_angles; - union { - unsigned m_ballLimits; - struct { - dgUnsigned32 m_coneLimit : 1; - dgUnsigned32 m_twistLimit : 1; - dgUnsigned32 m_lateralLimit : 1; - }; - }; - - dgMatrix m_localMatrix0; - dgMatrix m_localMatrix1; - dgFloat32 m_coneAngle; - dgFloat32 m_twistAngle; - dgFloat32 m_coneAngleCos; - dgBallJointFriction m_jointUserCallback; - -// dgUnsigned32 m_reserve[3]; - - friend class dgWorld; -// friend class dgPool<dgBallConstraint>; -}; - -//class dgBallConstraintArray: public dgPoolContainer<dgBallConstraint> -//{ -//}; - - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgBilateralConstraint.cpp b/thirdparty/src/newton/dgPhysics/dgBilateralConstraint.cpp deleted file mode 100644 index 236b49476..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBilateralConstraint.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgConstraint.h" -#include "dgWorldDynamicUpdate.h" -#include "dgBilateralConstraint.h" - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#define DG_VEL_DAMP (dgFloat32(100.0f)) -#define DG_POS_DAMP (dgFloat32(1500.0f)) - - -dgBilateralConstraint::dgBilateralConstraint () - :dgConstraint () - ,m_destructor(NULL) - ,m_jointNode(NULL) -{ - m_maxDOF = 6; - m_isBilateral = true; - m_isActive = true; - m_solverModel = 0; - m_rowIsMotor = 0; - m_massScaleBody0 = dgFloat32 (1.0f); - m_massScaleBody1 = dgFloat32 (1.0f); - m_defualtDiagonalRegularizer = dgFloat32 (0.0f); - SetStiffness (dgFloat32 (0.0f)); - - memset (m_jointForce, 0, sizeof (m_jointForce)); - memset (m_motorAcceleration, 0, sizeof (m_motorAcceleration)); -} - -dgBilateralConstraint::~dgBilateralConstraint () -{ - if (m_destructor) { - m_destructor(*this); - } - - if (m_jointNode) { - dgAssert(m_body0); - dgBilateralConstraintList* const jointList = m_body0->m_world; - jointList->Remove(m_jointNode); - } -} - -void dgBilateralConstraint::AppendToJointList() -{ - dgAssert(m_body0); - dgAssert(!m_jointNode); - - dgBilateralConstraintList* const jointList = m_body0->m_world; - m_jointNode = jointList->Addtop(this); -} - -dgInt32 dgBilateralConstraint::GetSolverModel() const -{ - return m_solverModel; -} - -dgFloat32 dgBilateralConstraint::GetMassScaleBody0() const -{ - return m_massScaleBody0; -} - -dgFloat32 dgBilateralConstraint::GetMassScaleBody1() const -{ - return m_massScaleBody1; -} - -void dgBilateralConstraint::SetSolverModel(dgInt32 model) -{ - m_solverModel = dgClamp(model, 0, 3); -} - -dgFloat32 dgBilateralConstraint::GetStiffness() const -{ - return m_defualtDiagonalRegularizer; -} - -void dgBilateralConstraint::SetStiffness(dgFloat32 stiffness) -{ - m_defualtDiagonalRegularizer = dgClamp (stiffness, dgFloat32(0.0f), dgFloat32(1.0f)); -} - -void dgBilateralConstraint::SetDestructorCallback (OnConstraintDestroy destructor) -{ - m_destructor = destructor; -} - -void dgBilateralConstraint::CalculateMatrixOffset (const dgVector& pivot, const dgVector& dir, dgMatrix& matrix0, dgMatrix& matrix1) const -{ - dgFloat32 length; - dgAssert (m_body0); - dgAssert (m_body1); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - const dgMatrix& body0_Matrix = m_body0->GetMatrix(); - - length = dir.DotProduct(dir).GetScalar(); - length = dgSqrt (length); - dgAssert (length > dgFloat32 (0.0f)); - matrix0 = dgMatrix (body0_Matrix.UnrotateVector (dir.Scale (dgFloat32 (1.0f) / length))); - matrix0.m_posit = body0_Matrix.UntransformVector (pivot); - - matrix0.m_front.m_w = dgFloat32 (0.0f); - matrix0.m_up.m_w = dgFloat32 (0.0f); - matrix0.m_right.m_w = dgFloat32 (0.0f); - matrix0.m_posit.m_w = dgFloat32 (1.0f); - - const dgMatrix& body1_Matrix = m_body1->GetMatrix(); - matrix1 = matrix0 * body0_Matrix * body1_Matrix.Inverse(); -} - - -void dgBilateralConstraint::SetPivotAndPinDir(const dgVector &pivot, const dgVector &pinDirection, dgMatrix& matrix0, dgMatrix& matrix1) const -{ - CalculateMatrixOffset (pivot, pinDirection, matrix0, matrix1); -} - -void dgBilateralConstraint::SetPivotAndPinDir (const dgVector& pivot, const dgVector& pinDirection0, const dgVector& pinDirection1, dgMatrix& matrix0, dgMatrix& matrix1) const -{ - dgAssert (m_body0); - dgAssert (m_body1); - - const dgMatrix& body0_Matrix = m_body0->GetMatrix(); - dgAssert (pinDirection0.m_w == dgFloat32 (0.0f)); - dgAssert ((pinDirection0.DotProduct(pinDirection0).GetScalar()) > dgFloat32 (0.0f)); - - matrix0.m_front = pinDirection0.Scale (dgRsqrt (pinDirection0.DotProduct(pinDirection0).GetScalar())); - matrix0.m_right = matrix0.m_front.CrossProduct(pinDirection1); - matrix0.m_right = matrix0.m_right.Scale (dgRsqrt (matrix0.m_right.DotProduct(matrix0.m_right).GetScalar())); - matrix0.m_up = matrix0.m_right.CrossProduct(matrix0.m_front); - matrix0.m_posit = pivot; - - matrix0.m_front.m_w = dgFloat32 (0.0f); - matrix0.m_up.m_w = dgFloat32 (0.0f); - matrix0.m_right.m_w = dgFloat32 (0.0f); - matrix0.m_posit.m_w = dgFloat32 (1.0f); - - const dgMatrix& body1_Matrix = m_body1->GetMatrix(); - - matrix1 = matrix0 * body1_Matrix.Inverse(); - matrix0 = matrix0 * body0_Matrix.Inverse(); -} - -dgVector dgBilateralConstraint::CalculateGlobalMatrixAndAngle (const dgMatrix& localMatrix0, const dgMatrix& localMatrix1, dgMatrix& globalMatrix0, dgMatrix& globalMatrix1) const -{ - dgAssert (m_body0); - dgAssert (m_body1); - const dgMatrix& body0Matrix = m_body0->GetMatrix(); - const dgMatrix& body1Matrix = m_body1->GetMatrix(); - - globalMatrix0 = localMatrix0 * body0Matrix; - globalMatrix1 = localMatrix1 * body1Matrix; - - dgMatrix relMatrix (globalMatrix1 * globalMatrix0.Inverse()); - - dgAssert (dgAbs (dgFloat32 (1.0f) - (relMatrix.m_front.DotProduct(relMatrix.m_front).GetScalar())) < 1.0e-5f); - dgAssert (dgAbs (dgFloat32 (1.0f) - (relMatrix.m_up.DotProduct(relMatrix.m_up).GetScalar())) < 1.0e-5f); - dgAssert (dgAbs (dgFloat32 (1.0f) - (relMatrix.m_right.DotProduct(relMatrix.m_right).GetScalar())) < 1.0e-5f); - - dgVector euler0; - dgVector euler1; - relMatrix.CalcPitchYawRoll (euler0, euler1); - return euler0; -} - -dgFloat32 dgBilateralConstraint::GetRowAcceleration (dgInt32 index, dgContraintDescritor& desc) const -{ - //return m_motorAcceleration[index]; - return desc.m_penetrationStiffness[index]; -} - -void dgBilateralConstraint::SetMotorAcceleration (dgInt32 index, dgFloat32 acceleration, dgContraintDescritor& desc) -{ - m_rowIsMotor |= (1 << index); - desc.m_flags[index] = 0; - m_motorAcceleration[index] = acceleration; - desc.m_jointAccel[index] = acceleration; - desc.m_penetrationStiffness[index] = acceleration; -} - -void dgBilateralConstraint::SetJacobianDerivative (dgInt32 index, dgContraintDescritor& desc, const dgFloat32* const jacobianA, const dgFloat32* const jacobianB, dgForceImpactPair* const jointForce) -{ - dgJacobian &jacobian0 = desc.m_jacobian[index].m_jacobianM0; - dgJacobian &jacobian1 = desc.m_jacobian[index].m_jacobianM1; - - m_r0[index] = dgVector::m_zero; - jacobian0.m_linear[0] = jacobianA[0]; - jacobian0.m_linear[1] = jacobianA[1]; - jacobian0.m_linear[2] = jacobianA[2]; - jacobian0.m_linear[3] = dgFloat32 (0.0f); - jacobian0.m_angular[0] = jacobianA[3]; - jacobian0.m_angular[1] = jacobianA[4]; - jacobian0.m_angular[2] = jacobianA[5]; - jacobian0.m_angular[3] = dgFloat32 (0.0f); - - m_r1[index] = dgVector::m_zero; - jacobian1.m_linear[0] = jacobianB[0]; - jacobian1.m_linear[1] = jacobianB[1]; - jacobian1.m_linear[2] = jacobianB[2]; - jacobian1.m_linear[3] = dgFloat32 (0.0f); - jacobian1.m_angular[0] = jacobianB[3]; - jacobian1.m_angular[1] = jacobianB[4]; - jacobian1.m_angular[2] = jacobianB[5]; - jacobian1.m_angular[3] = dgFloat32 (0.0f); - - m_rowIsMotor |= (1 << index); - m_motorAcceleration[index] = dgFloat32 (0.0f); - - desc.m_flags[index] = 0; - desc.m_restitution[index] = dgFloat32 (0.0f); - desc.m_jointAccel[index] = dgFloat32 (0.0f); - desc.m_penetration[index] = dgFloat32 (0.0f); - desc.m_penetrationStiffness[index] = dgFloat32 (0.0f); - desc.m_diagonalRegularizer[index] = m_defualtDiagonalRegularizer; - desc.m_forceBounds[index].m_jointForce = jointForce; -} - -void dgBilateralConstraint::SetSpringDamperAcceleration (dgInt32 index, dgContraintDescritor& desc, dgFloat32 rowStiffness, dgFloat32 spring, dgFloat32 damper) -{ - if (desc.m_timestep > dgFloat32 (0.0f)) { - - dgAssert (m_body1); - const dgJacobian &jacobian0 = desc.m_jacobian[index].m_jacobianM0; - const dgJacobian &jacobian1 = desc.m_jacobian[index].m_jacobianM1; - - const dgVector& veloc0 = m_body0->m_veloc; - const dgVector& omega0 = m_body0->m_omega; - const dgVector& veloc1 = m_body1->m_veloc; - const dgVector& omega1 = m_body1->m_omega; - - //dgFloat32 relPosit = (p1Global - p0Global) % jacobian0.m_linear + jointAngle; - dgFloat32 relPosit = desc.m_penetration[index]; - dgFloat32 relVeloc = - (veloc0.DotProduct(jacobian0.m_linear) + veloc1.DotProduct(jacobian1.m_linear) + omega0.DotProduct(jacobian0.m_angular) + omega1.DotProduct(jacobian1.m_angular)).GetScalar(); - - //at = [- ks (x2 - x1) - kd * (v2 - v1) - dt * ks * (v2 - v1)] / [1 + dt * kd + dt * dt * ks] - dgFloat32 dt = desc.m_timestep; - dgFloat32 ks = dgAbs (spring); - dgFloat32 kd = dgAbs (damper); - dgFloat32 ksd = dt * ks; - dgFloat32 num = ks * relPosit + kd * relVeloc + ksd * relVeloc; - dgFloat32 den = dt * kd + dt * ksd; - dgFloat32 accel = num / (dgFloat32 (1.0f) + den); - desc.m_diagonalRegularizer[index] = rowStiffness; - SetMotorAcceleration (index, accel, desc); - } -} - -dgFloat32 dgBilateralConstraint::CalculateMotorAcceleration (dgInt32 index, dgContraintDescritor& desc) const -{ - return desc.m_zeroRowAcceleration[index]; -} - -void dgBilateralConstraint::CalculateAngularDerivative (dgInt32 index, dgContraintDescritor& desc, const dgVector& dir, dgFloat32 stiffness, dgFloat32 jointAngle, dgForceImpactPair* const jointForce) -{ - dgAssert (jointForce); - dgAssert (m_body0); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - - dgJacobian &jacobian0 = desc.m_jacobian[index].m_jacobianM0; - m_r0[index] = dgVector::m_zero; - jacobian0.m_linear = dgVector::m_zero; - jacobian0.m_angular = dir; - dgAssert(jacobian0.m_angular.m_w == dgFloat32(0.0f)); - - dgJacobian &jacobian1 = desc.m_jacobian[index].m_jacobianM1; - dgAssert (m_body1); - m_r1[index] = dgVector::m_zero; - jacobian1.m_linear = dgVector::m_zero; - jacobian1.m_angular = dir * dgVector::m_negOne; - dgAssert(jacobian1.m_angular.m_w == dgFloat32(0.0f)); - - const dgVector& omega0 = m_body0->GetOmega(); - const dgVector& omega1 = m_body1->GetOmega(); - const dgFloat32 relOmega = -(omega0 * jacobian0.m_angular + omega1 * jacobian1.m_angular).AddHorizontal().GetScalar(); - - m_rowIsMotor &= ~(1 << index); - m_motorAcceleration[index] = dgFloat32 (0.0f); - if (desc.m_timestep > dgFloat32 (0.0f)) { - #ifdef _DEBUG - const dgFloat32 relCentr = -(omega0 * omega0.CrossProduct(jacobian0.m_angular) + omega1 * omega1.CrossProduct(jacobian1.m_angular)).AddHorizontal().GetScalar(); - // allow for some large error since this is affected bu numerical precision a lot - dgAssert (dgAbs(relCentr) < dgFloat32 (4.0f)); - #endif - - const dgVector& gyroAlpha0 = m_body0->m_gyroAlpha; - const dgVector& gyroAlpha1 = m_body1->m_gyroAlpha; - const dgFloat32 relGyro = (jacobian0.m_angular * gyroAlpha0 + jacobian1.m_angular * gyroAlpha1).AddHorizontal().GetScalar(); - - //at = [- ks (x2 - x1) - kd * (v2 - v1) - dt * ks * (v2 - v1)] / [1 + dt * kd + dt * dt * ks] - dgFloat32 dt = desc.m_timestep; - dgFloat32 ks = DG_POS_DAMP; - dgFloat32 kd = DG_VEL_DAMP; - dgFloat32 ksd = dt * ks; - dgFloat32 num = ks * jointAngle + kd * relOmega + ksd * relOmega; - dgFloat32 den = dgFloat32 (1.0f) + dt * kd + dt * ksd; - dgFloat32 alphaError = num / den; - - desc.m_flags[index] = 0; - desc.m_penetration[index] = jointAngle; - desc.m_diagonalRegularizer[index] = stiffness; - desc.m_jointAccel[index] = alphaError + relGyro; - desc.m_penetrationStiffness[index] = alphaError + relGyro; - desc.m_restitution[index] = dgFloat32(0.0f); - desc.m_forceBounds[index].m_jointForce = jointForce; - desc.m_zeroRowAcceleration[index] = relOmega * desc.m_invTimestep + relGyro; - - } else { - desc.m_flags[index] = 0; - desc.m_penetration[index] = dgFloat32 (0.0f); - desc.m_restitution[index] = dgFloat32 (0.0f); - desc.m_diagonalRegularizer[index] = stiffness; - desc.m_jointAccel[index] = relOmega; - desc.m_penetrationStiffness[index] = relOmega;; - desc.m_zeroRowAcceleration[index] = dgFloat32 (0.0f); - desc.m_forceBounds[index].m_jointForce = jointForce; - } -} - -void dgBilateralConstraint::CalculatePointDerivative (dgInt32 index, dgContraintDescritor& desc, const dgVector& dir, const dgPointParam& param, dgForceImpactPair* const jointForce) -{ - dgAssert (jointForce); - dgAssert (m_body0); - dgAssert (m_body1); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - - dgJacobian &jacobian0 = desc.m_jacobian[index].m_jacobianM0; - dgVector r0CrossDir (param.m_r0.CrossProduct(dir)); - m_r0[index] = param.m_r0; - jacobian0.m_linear = dir; - jacobian0.m_angular = r0CrossDir; - dgAssert(jacobian0.m_linear.m_w == dgFloat32(0.0f)); - dgAssert(jacobian0.m_angular.m_w == dgFloat32(0.0f)); - - dgJacobian &jacobian1 = desc.m_jacobian[index].m_jacobianM1; - dgVector r1CrossDir (dir.CrossProduct(param.m_r1)); - m_r1[index] = param.m_r1; - jacobian1.m_linear = dir * dgVector::m_negOne; - jacobian1.m_angular = r1CrossDir; - dgAssert(jacobian1.m_linear.m_w == dgFloat32(0.0f)); - dgAssert(jacobian1.m_angular.m_w == dgFloat32(0.0f)); - - m_rowIsMotor &= ~(1 << index); - m_motorAcceleration[index] = dgFloat32 (0.0f); - if (desc.m_timestep > dgFloat32 (0.0f)) { - dgVector positError (param.m_posit1 - param.m_posit0); - dgFloat32 relPosit = positError.DotProduct(dir).GetScalar(); - - const dgVector& veloc0 = m_body0->m_veloc; - const dgVector& veloc1 = m_body1->m_veloc; - const dgVector& omega0 = m_body0->m_omega; - const dgVector& omega1 = m_body1->m_omega; - const dgVector& gyroAlpha0 = m_body0->m_gyroAlpha; - const dgVector& gyroAlpha1 = m_body1->m_gyroAlpha; - const dgVector& centripetal0 (omega0.CrossProduct(omega0.CrossProduct(m_r0[index]))); - const dgVector& centripetal1 (omega1.CrossProduct(omega1.CrossProduct(m_r1[index]))); - - const dgFloat32 relGyro = (jacobian0.m_angular * gyroAlpha0 + jacobian1.m_angular * gyroAlpha1).AddHorizontal().GetScalar(); - const dgFloat32 relCentr = -(jacobian0.m_linear * centripetal0 + jacobian1.m_linear * centripetal1).AddHorizontal().GetScalar(); - const dgFloat32 relVeloc = -(jacobian0.m_linear * veloc0 + jacobian0.m_angular * omega0 + jacobian1.m_linear * veloc1 + jacobian1.m_angular * omega1).AddHorizontal().GetScalar(); - - //at = [- ks (x2 - x1) - kd * (v2 - v1) - dt * ks * (v2 - v1)] / [1 + dt * kd + dt * dt * ks] - const dgFloat32 dt = desc.m_timestep; - const dgFloat32 ks = DG_POS_DAMP; - const dgFloat32 kd = DG_VEL_DAMP; - const dgFloat32 ksd = dt * ks; - const dgFloat32 num = ks * relPosit + kd * relVeloc + ksd * relVeloc; - const dgFloat32 den = dgFloat32 (1.0f) + dt * kd + dt * ksd; - const dgFloat32 accelError = num / den; - - const dgFloat32 relAccel = accelError + relCentr + relGyro; - desc.m_flags[index] = 0; - desc.m_penetration[index] = relPosit; - desc.m_diagonalRegularizer[index] = param.m_defualtDiagonalRegularizer; - desc.m_jointAccel[index] = relAccel; - desc.m_penetrationStiffness[index] = relAccel; - desc.m_restitution[index] = dgFloat32 (0.0f); - desc.m_forceBounds[index].m_jointForce = jointForce; - desc.m_zeroRowAcceleration[index] = relVeloc * desc.m_invTimestep + relGyro; - - } else { - const dgVector& veloc0 = m_body0->m_veloc; - const dgVector& veloc1 = m_body1->m_veloc; - const dgVector& omega0 = m_body0->m_omega; - const dgVector& omega1 = m_body1->m_omega; - const dgFloat32 relVeloc = -(jacobian0.m_linear * veloc0 + jacobian0.m_angular * omega0 + jacobian1.m_linear * veloc1 + jacobian1.m_angular * omega1).AddHorizontal().GetScalar(); - - desc.m_flags[index] = 0; - desc.m_penetration[index] = dgFloat32 (0.0f); - desc.m_diagonalRegularizer[index] = param.m_defualtDiagonalRegularizer; - desc.m_jointAccel[index] = relVeloc; - desc.m_penetrationStiffness[index] = relVeloc; - desc.m_restitution[index] = dgFloat32 (0.0f); - desc.m_zeroRowAcceleration[index] = dgFloat32 (0.0f); - desc.m_forceBounds[index].m_jointForce = jointForce; - } -} - -void dgBilateralConstraint::JointAccelerations(dgJointAccelerationDecriptor* const params) -{ - const dgVector& bodyVeloc0 = m_body0->m_veloc; - const dgVector& bodyOmega0 = m_body0->m_omega; - const dgVector& bodyVeloc1 = m_body1->m_veloc; - const dgVector& bodyOmega1 = m_body1->m_omega; - const dgVector& gyroAlpha0 = m_body0->m_gyroAlpha; - const dgVector& gyroAlpha1 = m_body1->m_gyroAlpha; - - dgRightHandSide* const rhs = params->m_rightHandSide; - const dgLeftHandSide* const row = params->m_leftHandSide; - if (params->m_timeStep > dgFloat32 (0.0f)) { - const dgFloat32 ks = DG_POS_DAMP * dgFloat32 (0.5f); - const dgFloat32 kd = DG_VEL_DAMP * dgFloat32 (4.0f); - const dgFloat32 dt = params->m_timeStep; - for (dgInt32 k = 0; k < params->m_rowsCount; k ++) { - if (m_rowIsMotor & (1 << k)) { - rhs[k].m_coordenateAccel = m_motorAcceleration[k] + rhs[k].m_deltaAccel; - } else { - const dgJacobianPair& Jt = row[k].m_Jt; - - //calculate internal centripetal each sub step - const dgVector& centripetal0(bodyOmega0.CrossProduct(bodyOmega0.CrossProduct(m_r0[k]))); - const dgVector& centripetal1(bodyOmega1.CrossProduct(bodyOmega1.CrossProduct(m_r1[k]))); - - const dgVector relVeloc(Jt.m_jacobianM0.m_linear * bodyVeloc0 + Jt.m_jacobianM0.m_angular * bodyOmega0 + - Jt.m_jacobianM1.m_linear * bodyVeloc1 + Jt.m_jacobianM1.m_angular * bodyOmega1); - const dgFloat32 relGyro = (Jt.m_jacobianM0.m_angular * gyroAlpha0 + Jt.m_jacobianM1.m_angular * gyroAlpha1).AddHorizontal().GetScalar(); - const dgFloat32 relCentr = -(Jt.m_jacobianM0.m_linear * centripetal0 + Jt.m_jacobianM1.m_linear * centripetal1).AddHorizontal().GetScalar(); - - dgFloat32 vRel = relVeloc.AddHorizontal().GetScalar(); - - //at = [- ks (x2 - x1) - kd * (v2 - v1) - dt * ks * (v2 - v1)] / [1 + dt * kd + dt * dt * ks] - //alphaError = num / den; - //at = [- ks (x2 - x1) - kd * (v2 - v1) - dt * ks * (v2 - v1)] / [1 + dt * kd + dt * dt * ks] - //dgFloat32 dt = desc.m_timestep; - //dgFloat32 ks = DG_POS_DAMP; - //dgFloat32 kd = DG_VEL_DAMP; - //dgFloat32 ksd = dt * ks; - //dgFloat32 num = ks * relPosit + kd * relVeloc + ksd * relVeloc; - //dgFloat32 den = dgFloat32 (1.0f) + dt * kd + dt * ksd; - //accelError = num / den; - - dgFloat32 relPosit = rhs[k].m_penetration - vRel * dt * params->m_firstPassCoefFlag; - rhs[k].m_penetration = relPosit; - - dgFloat32 ksd = dt * ks; - dgFloat32 num = ks * relPosit - kd * vRel - ksd * vRel; - dgFloat32 den = dgFloat32(1.0f) + dt * kd + dt * ksd; - dgFloat32 aRelErr = num / den; - rhs[k].m_coordenateAccel = rhs[k].m_deltaAccel + aRelErr + relCentr + relGyro; - } - } - } else { - - for (dgInt32 k = 0; k < params->m_rowsCount; k ++) { - if (m_rowIsMotor & (1 << k)) { - rhs[k].m_coordenateAccel = m_motorAcceleration[k] + rhs[k].m_deltaAccel; - } else { - const dgJacobianPair& Jt = row[k].m_Jt; - dgVector relVeloc (Jt.m_jacobianM0.m_linear * bodyVeloc0 + Jt.m_jacobianM0.m_angular * bodyOmega0 + - Jt.m_jacobianM1.m_linear * bodyVeloc1 + Jt.m_jacobianM1.m_angular * bodyOmega1); - - dgFloat32 vRel = relVeloc.m_x + relVeloc.m_y + relVeloc.m_z; - rhs[k].m_coordenateAccel = rhs[k].m_deltaAccel - vRel; - } - } - } -} - diff --git a/thirdparty/src/newton/dgPhysics/dgBilateralConstraint.h b/thirdparty/src/newton/dgPhysics/dgBilateralConstraint.h deleted file mode 100644 index d2ae8fee2..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBilateralConstraint.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGBILATERALCONSTRAINT_H__ -#define __DGBILATERALCONSTRAINT_H__ - -#include "dgConstraint.h" - -class dgBilateralConstraint; -#define DG_BILATERAL_CONTRAINT_DOF 8 - -class dgBilateralConstraintList: public dgList<dgBilateralConstraint*> -{ - public: - dgBilateralConstraintList(dgMemoryAllocator* const allocator) - :dgList<dgBilateralConstraint*>(allocator) - { - } -}; - -class dgBilateralConstraint: public dgConstraint -{ - public: - virtual void SetDestructorCallback (OnConstraintDestroy destructor); - virtual void Serialize (dgSerialize serializeCallback, void* const userData) = 0; - - bool IsRowMotor(dgInt32 index) const {return m_rowIsMotor & (1 << index) ? true : false; } - - protected: - dgBilateralConstraint (); - virtual ~dgBilateralConstraint (); - - virtual void Init (){dgAssert (0);} - virtual void Remove (dgWorld* world) {dgAssert (0);} - - virtual dgFloat32 GetStiffness() const; - virtual void SetStiffness(dgFloat32 stiffness); - - virtual dgInt32 GetSolverModel() const; - virtual void SetSolverModel(dgInt32 model); - - virtual dgFloat32 GetMassScaleBody0() const; - virtual dgFloat32 GetMassScaleBody1() const; - - void CalculateMatrixOffset (const dgVector& pivot, const dgVector& dir, dgMatrix& matrix0, dgMatrix& matrix1) const; - void SetPivotAndPinDir(const dgVector &pivot, const dgVector &pinDirection, dgMatrix& matrix0, dgMatrix& matrix1) const; - void SetPivotAndPinDir(const dgVector& pivot, const dgVector& pinDirection0, const dgVector& pinDirection1, dgMatrix& matrix0, dgMatrix& matrix1) const; - dgVector CalculateGlobalMatrixAndAngle (const dgMatrix& localMatrix0, const dgMatrix& localMatrix1, dgMatrix& globalMatrix0, dgMatrix& globalMatrix1) const; - - virtual void JointAccelerations(dgJointAccelerationDecriptor* const params); - - dgFloat32 GetRowAcceleration (dgInt32 index, dgContraintDescritor& desc) const; - dgFloat32 CalculateMotorAcceleration (dgInt32 index, dgContraintDescritor& desc) const; - void SetMotorAcceleration (dgInt32 index, dgFloat32 acceleration, dgContraintDescritor& desc); - void SetSpringDamperAcceleration (dgInt32 index, dgContraintDescritor& desc, dgFloat32 rowStiffness, dgFloat32 spring, dgFloat32 damper); - void SetJacobianDerivative (dgInt32 index, dgContraintDescritor& desc, const dgFloat32* const jacobianA, const dgFloat32* const jacobianB, dgForceImpactPair* const jointForce); - void CalculatePointDerivative (dgInt32 index, dgContraintDescritor& desc, const dgVector& normalGlobal, const dgPointParam& param, dgForceImpactPair* const jointForce); - void CalculateAngularDerivative (dgInt32 index, dgContraintDescritor& desc, const dgVector& normalGlobal, dgFloat32 stiffness, dgFloat32 jointAngle, dgForceImpactPair* const jointForce); - - void AppendToJointList(); - - dgVector m_r0[DG_BILATERAL_CONTRAINT_DOF]; - dgVector m_r1[DG_BILATERAL_CONTRAINT_DOF]; - dgForceImpactPair m_jointForce[DG_BILATERAL_CONTRAINT_DOF]; - dgFloat32 m_motorAcceleration[DG_BILATERAL_CONTRAINT_DOF]; - dgFloat32 m_massScaleBody0; - dgFloat32 m_massScaleBody1; - dgFloat32 m_defualtDiagonalRegularizer; - OnConstraintDestroy m_destructor; - dgBilateralConstraintList::dgListNode* m_jointNode; - dgInt8 m_rowIsMotor; - - friend class dgBodyMasterList; - friend class dgWorldDynamicUpdate; -}; - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgBody.cpp b/thirdparty/src/newton/dgPhysics/dgBody.cpp deleted file mode 100644 index c3e1aee73..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBody.cpp +++ /dev/null @@ -1,727 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgCollision.h" -#include "dgCollisionInstance.h" -#include "dgCollisionCompound.h" -#include "dgWorldDynamicUpdate.h" -#include "dgCollisionDeformableMesh.h" -#include "dgCollisionCompoundFractured.h" - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -dgBody::dgBody() - :m_matrix (dgGetIdentityMatrix()) - ,m_rotation() - ,m_invWorldInertiaMatrix(dgGetZeroMatrix()) - ,m_mass(dgFloat32 (DG_INFINITE_MASS * 2.0f), dgFloat32 (DG_INFINITE_MASS * 2.0f), dgFloat32 (DG_INFINITE_MASS * 2.0f), dgFloat32 (DG_INFINITE_MASS * 2.0f)) - ,m_invMass(dgVector::m_zero) - ,m_veloc(dgVector::m_zero) - ,m_omega(dgVector::m_zero) - ,m_accel(dgVector::m_zero) - ,m_alpha(dgVector::m_zero) - ,m_minAABB(dgVector::m_zero) - ,m_maxAABB(dgVector::m_zero) - ,m_localCentreOfMass(dgVector::m_zero) - ,m_globalCentreOfMass(dgVector::m_zero) - ,m_impulseForce(dgVector::m_zero) - ,m_impulseTorque(dgVector::m_zero) - ,m_gyroAlpha(dgVector::m_zero) - ,m_gyroTorque(dgVector::m_zero) - ,m_gyroRotation() - ,m_criticalSectionLock(0) - ,m_flags(0) - ,m_userData(NULL) - ,m_world(NULL) - ,m_collision(NULL) - ,m_broadPhaseNode(NULL) - ,m_masterNode(NULL) - ,m_broadPhaseaggregateNode(NULL) - ,m_destructor(NULL) - ,m_matrixUpdate(NULL) - ,m_index(0) - ,m_uniqueID(0) - ,m_bodyGroupId(0) - ,m_rtti(m_baseBodyRTTI) - ,m_type(0) - ,m_serializedEnum(-1) - ,m_dynamicsLru(0) - ,m_genericLRUMark(0) -{ - m_autoSleep = true; - m_collidable = true; -// m_gyroTorqueOn = true; - m_transformIsDirty = true; - m_collideWithLinkedBodies = true; - m_invWorldInertiaMatrix[3][3] = dgFloat32 (1.0f); - InitJointSet(); -} - -dgBody::dgBody (dgWorld* const world, const dgTree<const dgCollision*, dgInt32>* const collisionCashe, dgDeserialize serializeCallback, void* const userData, dgInt32 revisionNumber) - :m_matrix (dgGetIdentityMatrix()) - ,m_rotation() - ,m_invWorldInertiaMatrix(dgGetZeroMatrix()) - ,m_mass(dgFloat32 (DG_INFINITE_MASS * 2.0f), dgFloat32 (DG_INFINITE_MASS * 2.0f), dgFloat32 (DG_INFINITE_MASS * 2.0f), dgFloat32 (DG_INFINITE_MASS * 2.0f)) - ,m_invMass(dgVector::m_zero) - ,m_veloc(dgVector::m_zero) - ,m_omega(dgVector::m_zero) - ,m_accel(dgVector::m_zero) - ,m_alpha(dgVector::m_zero) - ,m_minAABB(dgVector::m_zero) - ,m_maxAABB(dgVector::m_zero) - ,m_localCentreOfMass(dgVector::m_zero) - ,m_globalCentreOfMass(dgVector::m_zero) - ,m_impulseForce(dgVector::m_zero) - ,m_impulseTorque(dgVector::m_zero) - ,m_gyroAlpha(dgVector::m_zero) - ,m_gyroTorque(dgVector::m_zero) - ,m_gyroRotation() - ,m_criticalSectionLock(0) - ,m_flags(0) - ,m_userData(NULL) - ,m_world(world) - ,m_collision(NULL) - ,m_broadPhaseNode(NULL) - ,m_masterNode(NULL) - ,m_broadPhaseaggregateNode(NULL) - ,m_destructor(NULL) - ,m_matrixUpdate(NULL) - ,m_index(0) - ,m_uniqueID(0) - ,m_bodyGroupId(0) - ,m_rtti(m_baseBodyRTTI) - ,m_type(0) - ,m_serializedEnum(-1) - ,m_dynamicsLru(0) - ,m_genericLRUMark(0) -{ - m_autoSleep = true; - m_collidable = true; - m_transformIsDirty = true; - m_collideWithLinkedBodies = true; - m_invWorldInertiaMatrix[3][3] = dgFloat32 (1.0f); - - serializeCallback (userData, &m_rotation, sizeof (m_rotation)); - serializeCallback (userData, &m_matrix, sizeof (m_matrix)); - serializeCallback (userData, &m_veloc, sizeof (m_veloc)); - serializeCallback (userData, &m_omega, sizeof (m_omega)); - serializeCallback (userData, &m_accel, sizeof (m_veloc)); - serializeCallback (userData, &m_alpha, sizeof (m_omega)); - serializeCallback (userData, &m_localCentreOfMass, sizeof (m_localCentreOfMass)); - serializeCallback (userData, &m_mass, sizeof (m_mass)); - serializeCallback (userData, &m_flags, sizeof (m_flags)); - serializeCallback (userData, &m_serializedEnum, sizeof(dgInt32)); - - dgInt32 id; - serializeCallback (userData, &id, sizeof (id)); - - dgTree<const dgCollision*, dgInt32>::dgTreeNode* const node = collisionCashe->Find(id); - dgAssert (node); - - const dgCollision* const collision = node->GetInfo(); - collision->AddRef(); - - dgCollisionInstance* const instance = new (world->GetAllocator()) dgCollisionInstance (world, serializeCallback, userData, revisionNumber); - instance->m_childShape = collision; - m_collision = instance; - - InitJointSet(); -} - -dgBody::~dgBody() -{ -} - -dgVector dgBody::GetAlpha() const -{ - return dgVector::m_zero; -} -dgVector dgBody::GetAccel() const -{ - return dgVector::m_zero; -} - -void dgBody::SetAlpha(const dgVector& alpha) -{ -} - -void dgBody::SetAccel(const dgVector& accel) -{ -} - -void dgBody::AttachCollision (dgCollisionInstance* const collisionSrc) -{ - dgCollisionInstance* const instance = new (m_world->GetAllocator()) dgCollisionInstance (*collisionSrc); - m_world->GetBroadPhase()->CollisionChange (this, instance); - if (m_collision) { - m_collision->Release(); - } - m_collision = instance; - m_equilibrium = 0; -} - -void dgBody::Serialize (const dgTree<dgInt32, const dgCollision*>& collisionRemapId, dgSerialize serializeCallback, void* const userData) -{ - serializeCallback (userData, &m_rotation, sizeof (m_rotation)); - serializeCallback (userData, &m_matrix, sizeof (m_matrix)); - serializeCallback (userData, &m_veloc, sizeof (m_veloc)); - serializeCallback (userData, &m_omega, sizeof (m_omega)); - serializeCallback (userData, &m_accel, sizeof (m_veloc)); - serializeCallback (userData, &m_alpha, sizeof (m_omega)); - serializeCallback (userData, &m_localCentreOfMass, sizeof (m_localCentreOfMass)); - serializeCallback(userData, &m_mass, sizeof (m_mass)); - serializeCallback (userData, &m_flags, sizeof (m_flags)); - serializeCallback(userData, &m_serializedEnum, sizeof(dgInt32)); - - dgTree<dgInt32, const dgCollision*>::dgTreeNode* const node = collisionRemapId.Find(m_collision->GetChildShape()); - dgAssert (node); - - dgInt32 id = node->GetInfo(); - serializeCallback (userData, &id, sizeof (id)); - m_collision->Serialize(serializeCallback, userData, false); -} - -void dgBody::UpdateLumpedMatrix() -{ - if (m_collision->IsType(dgCollision::dgCollisionLumpedMass_RTTI)) { - dgAssert(IsRTTIType(dgBody::m_dynamicBodyRTTI)); - dgCollisionLumpedMassParticles* const lumpedMass = (dgCollisionLumpedMassParticles*)m_collision->m_childShape; - lumpedMass->SetOwnerAndMassPraperties((dgDynamicBody*) this); - } -} - - -void dgBody::SetMatrix(const dgMatrix& matrix) -{ - SetMatrixOriginAndRotation(matrix); - - if (!m_inCallback) { - UpdateCollisionMatrix (dgFloat32 (0.0f), 0); - } -} - -void dgBody::SetMatrixNoSleep(const dgMatrix& matrix) -{ - SetMatrix(matrix); -} - -void dgBody::SetMatrixResetSleep(const dgMatrix& matrix) -{ - m_sleeping = 0; - m_equilibrium = 0; - SetMatrix(matrix); -} - -void dgBody::UpdateWorlCollisionMatrix() const -{ - m_collision->SetGlobalMatrix (m_collision->GetLocalMatrix() * m_matrix); -} - -void dgBody::UpdateCollisionMatrix (dgFloat32 timestep, dgInt32 threadIndex) -{ - m_transformIsDirty = true; - m_collision->SetGlobalMatrix (m_collision->GetLocalMatrix() * m_matrix); - m_collision->CalcAABB (m_collision->GetGlobalMatrix(), m_minAABB, m_maxAABB); - - if (m_continueCollisionMode) { - dgVector predictiveVeloc (PredictLinearVelocity(timestep)); - dgVector predictiveOmega (PredictAngularVelocity(timestep)); - dgMovingAABB (m_minAABB, m_maxAABB, predictiveVeloc, predictiveOmega, timestep, m_collision->GetBoxMaxRadius(), m_collision->GetBoxMinRadius()); - } - - if (m_broadPhaseNode) { - dgAssert (m_world); - if (!m_equilibrium) { - m_world->GetBroadPhase()->UpdateBody (this, threadIndex); - } - } -} - - -dgFloat32 dgBody::RayCast (const dgLineBox& line, OnRayCastAction filter, OnRayPrecastAction preFilter, void* const userData, dgFloat32 maxT) const -{ - dgAssert (filter); - dgVector l0 (line.m_l0); - dgVector l1 (line.m_l0 + (line.m_l1 - line.m_l0).Scale (dgMin(maxT, dgFloat32 (1.0f)))); - if (dgRayBoxClip (l0, l1, m_minAABB, m_maxAABB)) { -// if (1) { -//l0 = dgVector (-20.3125000f, 3.54991579f, 34.3441200f, 0.0f); -//l1 = dgVector (-19.6875000f, 3.54257250f, 35.2211456f, 0.0f); - - dgContactPoint contactOut; - const dgMatrix& globalMatrix = m_collision->GetGlobalMatrix(); - dgVector localP0 (globalMatrix.UntransformVector (l0)); - dgVector localP1 (globalMatrix.UntransformVector (l1)); - dgVector p1p0 (localP1 - localP0); - dgAssert (p1p0.m_w == dgFloat32 (0.0f)); - if (p1p0.DotProduct(p1p0).GetScalar() > dgFloat32 (1.0e-12f)) { - dgFloat32 t = m_collision->RayCast (localP0, localP1, dgFloat32 (1.0f), contactOut, preFilter, this, userData); - if (t < dgFloat32 (1.0f)) { - dgAssert (localP0.m_w == dgFloat32 (0.0f)); - dgAssert (localP1.m_w == dgFloat32 (0.0f)); - dgVector p (globalMatrix.TransformVector(localP0 + (localP1 - localP0).Scale(t))); - dgVector l1l0 (line.m_l1 - line.m_l0); - dgAssert (l1l0.m_w == dgFloat32 (0.0f)); - t = l1l0.DotProduct(p - line.m_l0).GetScalar() / l1l0.DotProduct(l1l0).GetScalar(); - if (t < maxT) { - dgAssert (t >= dgFloat32 (0.0f)); - dgAssert (t <= dgFloat32 (1.0f)); - contactOut.m_normal = globalMatrix.RotateVector (contactOut.m_normal); - maxT = filter (this, contactOut.m_collision0, p, contactOut.m_normal, contactOut.m_shapeId0, userData, t); - } - } - } - } - return maxT; -} - -void dgBody::IntegrateVelocity (dgFloat32 timestep) -{ -//if (m_uniqueID == 3) -//dgTrace(("%d v(%f %f %f)\n", m_uniqueID, m_veloc.m_x, m_veloc.m_y, m_veloc.m_z)); - - dgAssert (m_veloc.m_w == dgFloat32 (0.0f)); - dgAssert (m_omega.m_w == dgFloat32 (0.0f)); - m_globalCentreOfMass += m_veloc.Scale (timestep); - dgFloat32 omegaMag2 = m_omega.DotProduct(m_omega).GetScalar(); -#ifdef _DEBUG - const dgFloat32 err = dgFloat32(90.0f * dgDegreeToRad); - const dgFloat32 err2 = err * err; - const dgFloat32 step2 = omegaMag2 * timestep * timestep; - const dgFloat32 speed2 = m_veloc.DotProduct(m_veloc).GetScalar() * timestep * timestep;; - if ((step2 > err2) || (speed2 > 100.0f)) { - dgTrace (("warning bodies %d w(%f %f %f) v(%f %f %f) with very high velocity or angular velocity, may be unstable\n", m_uniqueID, - m_omega.m_x, m_omega.m_y, m_omega.m_z, m_veloc.m_x, m_veloc.m_y, m_veloc.m_z)); - //dgAssert(0); - } -#endif - - // this is correct - if (omegaMag2 > ((dgFloat32 (0.0125f) * dgDegreeToRad) * (dgFloat32 (0.0125f) * dgDegreeToRad))) { - dgFloat32 invOmegaMag = dgRsqrt (omegaMag2); - dgVector omegaAxis (m_omega.Scale (invOmegaMag)); - dgFloat32 omegaAngle = invOmegaMag * omegaMag2 * timestep; - dgQuaternion rotation (omegaAxis, omegaAngle); - m_rotation = m_rotation * rotation; - m_rotation.Scale(dgRsqrt (m_rotation.DotProduct (m_rotation))); - m_matrix = dgMatrix (m_rotation, m_matrix.m_posit); - } - - m_matrix.m_posit = m_globalCentreOfMass - m_matrix.RotateVector(m_localCentreOfMass); - dgAssert (m_matrix.TestOrthogonal()); -} - -dgConstraint* dgBody::GetFirstJoint() const -{ - if (m_masterNode) { - for (dgBodyMasterListRow::dgListNode* node = m_masterNode->GetInfo().GetFirst(); node; node = node->GetNext()) { - dgConstraint* const joint = node->GetInfo().m_joint; - if (joint && (joint->GetId() >= dgConstraint::m_unknownConstraint)) { - return joint; - } - } - } - return NULL; -} - -dgConstraint* dgBody::GetNextJoint(dgConstraint* const joint) const -{ - dgBodyMasterListRow::dgListNode* node = joint->GetLink0(); - if (joint->GetBody0() != this) { - node = joint->GetLink1(); - } - - if (node->GetInfo().m_joint == joint) { - for (node = node->GetNext(); node; node = node->GetNext()) { - dgConstraint* const joint1 = node->GetInfo().m_joint; - if (joint1->GetId() >= dgConstraint::m_unknownConstraint) { - return joint1; - } - } - } - - return NULL; -} - - -dgConstraint* dgBody::GetFirstContact() const -{ - if (m_masterNode) { - for (dgBodyMasterListRow::dgListNode* node = m_masterNode->GetInfo().GetFirst(); node; node = node->GetNext()) { - dgConstraint* const joint = node->GetInfo().m_joint; - dgAssert (joint); - if (joint && (joint->GetId() == dgConstraint::m_contactConstraint)) { - dgContact* const contactJoint = (dgContact*) joint; - if (contactJoint->m_isActive) { - return joint; - } - } - } - } - return NULL; -} - -dgConstraint* dgBody::GetNextContact(dgConstraint* const joint) const -{ - dgBodyMasterListRow::dgListNode* node = joint->GetLink0(); - if (joint->GetBody0() != this) { - node = joint->GetLink1(); - } - - if (node->GetInfo().m_joint == joint) { - for (node = node->GetNext(); node; node = node->GetNext()) { - dgConstraint* const joint1 = node->GetInfo().m_joint; - dgAssert (joint1); - if (joint1 && (joint1->GetId() == dgConstraint::m_contactConstraint)) { - dgContact* const contactJoint = (dgContact*) joint1; - if (contactJoint->m_isActive) { - return joint1; - } - } - } - } - - return NULL; -} - -void dgBody::SetFreeze (bool state) -{ - if (state){ - Freeze(); - } else { - Unfreeze(); - } -} - - -void dgBody::Freeze () -{ - if (GetInvMass().m_w > dgFloat32 (0.0f)) { - if (!m_freeze) { - m_freeze = true; - for (dgBodyMasterListRow::dgListNode* node = m_masterNode->GetInfo().GetFirst(); node; node = node->GetNext()) { - dgBody* const body = node->GetInfo().m_bodyNode; - body->Freeze (); - } - } - } -} - -void dgBody::Unfreeze () -{ - if (GetInvMass().m_w > dgFloat32 (0.0f)) { - if (m_freeze) { - m_freeze = false; - for (dgBodyMasterListRow::dgListNode* node = m_masterNode->GetInfo().GetFirst(); node; node = node->GetNext()) { - dgBody* const body = node->GetInfo().m_bodyNode; - body->Unfreeze (); - } - } - } -} - -void dgBody::SetMassMatrix(dgFloat32 mass, const dgMatrix& inertia) -{ - dgFloat32 Ixx = inertia[0][0]; - dgFloat32 Iyy = inertia[1][1]; - dgFloat32 Izz = inertia[2][2]; - mass = dgAbs (mass); - if (m_collision->IsType(dgCollision::dgCollisionMesh_RTTI) || m_collision->IsType(dgCollision::dgCollisionScene_RTTI)) { - mass = DG_INFINITE_MASS * 2.0f; - } - - if (m_collision->IsType(dgCollision::dgCollisionCompound_RTTI)) { - const dgCollision* const childShape = m_collision->GetChildShape(); - if ((childShape->m_inertia.m_x < dgFloat32 (1.0e-5f)) || (childShape->m_inertia.m_y < dgFloat32 (1.0e-5f)) || (childShape->m_inertia.m_z < dgFloat32 (1.0e-5f))){ - mass = DG_INFINITE_MASS * 2.0f; - } - } - - if (mass < DG_MINIMUM_MASS) { - mass = DG_INFINITE_MASS * 2.0f; - } - - //dgAssert (m_masterNode); - m_world->GetBroadPhase()->CheckStaticDynamic(this, mass); - - if (mass >= DG_INFINITE_MASS) { - if (m_masterNode) { - if (m_invMass.m_w != dgFloat32 (0.0f)) { - dgBodyMasterList& masterList (*m_world); - if (masterList.GetFirst() != m_masterNode) { - masterList.InsertAfter (masterList.GetFirst(), m_masterNode); - } - } - } - - m_mass.m_x = DG_INFINITE_MASS; - m_mass.m_y = DG_INFINITE_MASS; - m_mass.m_z = DG_INFINITE_MASS; - m_mass.m_w = DG_INFINITE_MASS; - m_invMass = dgVector::m_zero; - - } else { - Ixx = dgAbs (Ixx); - Iyy = dgAbs (Iyy); - Izz = dgAbs (Izz); - - dgFloat32 Ixx1 = dgClamp (Ixx, dgFloat32 (0.001f) * mass, dgFloat32 (1000.0f) * mass); - dgFloat32 Iyy1 = dgClamp (Iyy, dgFloat32 (0.001f) * mass, dgFloat32 (1000.0f) * mass); - dgFloat32 Izz1 = dgClamp (Izz, dgFloat32 (0.001f) * mass, dgFloat32 (1000.0f) * mass); - - dgAssert (Ixx > dgFloat32 (0.0f)); - dgAssert (Iyy > dgFloat32 (0.0f)); - dgAssert (Izz > dgFloat32 (0.0f)); - - if (m_masterNode) { - if (m_invMass.m_w == dgFloat32 (0.0f)) { - dgBodyMasterList& masterList(*m_world); - masterList.RotateToEnd(m_masterNode); - } - } - - m_mass.m_x = Ixx1; - m_mass.m_y = Iyy1; - m_mass.m_z = Izz1; - m_mass.m_w = mass; - - m_invMass.m_x = dgFloat32 (1.0f) / Ixx1; - m_invMass.m_y = dgFloat32 (1.0f) / Iyy1; - m_invMass.m_z = dgFloat32 (1.0f) / Izz1; - m_invMass.m_w = dgFloat32 (1.0f) / mass; - } - - -//#ifdef _DEBUG -#if 0 - dgBodyMasterList& me = *m_world; - for (dgBodyMasterList::dgListNode* refNode = me.GetFirst(); refNode; refNode = refNode->GetNext()) { - dgBody* const body0 = refNode->GetInfo().GetBody(); - dgVector invMass (body0->GetInvMass()); - if (invMass.m_w != 0.0f) { - for (; refNode; refNode = refNode->GetNext()) { - dgBody* const body1 = refNode->GetInfo().GetBody(); - dgVector invMass1 (body1->GetInvMass()); - dgAssert (invMass1.m_w != 0.0f); - } - break; - } - } -#endif -// UpdateLumpedMatrix(); -} - -void dgBody::SetMassProperties (dgFloat32 mass, const dgCollisionInstance* const collision) -{ - // using general central theorem, to extract the Inertia relative to the center of mass - dgMatrix inertia (collision->CalculateInertia()); - - dgVector origin (inertia.m_posit); - for (dgInt32 i = 0; i < 3; i ++) { - inertia[i] = inertia[i].Scale (mass); - //inertia[i][i] = (inertia[i][i] + origin[i] * origin[i]) * mass; - //for (dgInt32 j = i + 1; j < 3; j ++) { - // dgFloat32 crossIJ = origin[i] * origin[j]; - // inertia[i][j] = (inertia[i][j] + crossIJ) * mass; - // inertia[j][i] = (inertia[j][i] + crossIJ) * mass; - //} - } - - // although the engine fully supports asymmetric inertia, I will ignore cross inertia for now - //SetMassMatrix(mass, inertia[0][0], inertia[1][1], inertia[2][2]); - SetCentreOfMass(origin); - SetMassMatrix(mass, inertia); -} - -dgMatrix dgBody::CalculateLocalInertiaMatrix () const -{ - dgMatrix inertia (dgGetIdentityMatrix()); - inertia[0][0] = m_mass.m_x; - inertia[1][1] = m_mass.m_y; - inertia[2][2] = m_mass.m_z; - return inertia; -} - -dgMatrix dgBody::CalculateInertiaMatrix () const -{ - const dgVector Ixx(m_mass[0]); - const dgVector Iyy(m_mass[1]); - const dgVector Izz(m_mass[2]); - return dgMatrix (m_matrix.m_front.Scale(m_matrix.m_front[0]) * Ixx + - m_matrix.m_up.Scale(m_matrix.m_up[0]) * Iyy + - m_matrix.m_right.Scale(m_matrix.m_right[0]) * Izz, - - m_matrix.m_front.Scale(m_matrix.m_front[1]) * Ixx + - m_matrix.m_up.Scale(m_matrix.m_up[1]) * Iyy + - m_matrix.m_right.Scale(m_matrix.m_right[1]) * Izz, - - m_matrix.m_front.Scale(m_matrix.m_front[2]) * Ixx + - m_matrix.m_up.Scale(m_matrix.m_up[2]) * Iyy + - m_matrix.m_right.Scale(m_matrix.m_right[2]) * Izz, - dgVector::m_wOne); -} - -dgMatrix dgBody::CalculateInvInertiaMatrix () const -{ - const dgVector invIxx(m_invMass[0]); - const dgVector invIyy(m_invMass[1]); - const dgVector invIzz(m_invMass[2]); - return dgMatrix(m_matrix.m_front.Scale(m_matrix.m_front[0]) * invIxx + - m_matrix.m_up.Scale(m_matrix.m_up[0]) * invIyy + - m_matrix.m_right.Scale(m_matrix.m_right[0]) * invIzz, - - m_matrix.m_front.Scale(m_matrix.m_front[1]) * invIxx + - m_matrix.m_up.Scale(m_matrix.m_up[1]) * invIyy + - m_matrix.m_right.Scale(m_matrix.m_right[1]) * invIzz, - - m_matrix.m_front.Scale(m_matrix.m_front[2]) * invIxx + - m_matrix.m_up.Scale(m_matrix.m_up[2]) * invIyy + - m_matrix.m_right.Scale(m_matrix.m_right[2]) * invIzz, - dgVector::m_wOne); -} - -void dgBody::InvalidateCache () -{ - m_sleeping = false; - m_equilibrium = false; - m_genericLRUMark = 0; - dgMatrix matrix (m_matrix); - SetMatrixOriginAndRotation(matrix); -} - -void dgBody::AddImpulse (const dgVector& pointDeltaVeloc, const dgVector& pointPosit, dgFloat32 timestep) -{ - dgMatrix invInertia (CalculateInvInertiaMatrix()); - - // get contact matrix - dgMatrix tmp; - dgVector globalContact (pointPosit - m_globalCentreOfMass); - - tmp[0][0] = dgFloat32 (0.0f); - tmp[0][1] = + globalContact[2]; - tmp[0][2] = - globalContact[1]; - tmp[0][3] = dgFloat32 (0.0f); - - tmp[1][0] = -globalContact[2]; - tmp[1][1] = dgFloat32 (0.0f); - tmp[1][2] = +globalContact[0]; - tmp[1][3] = dgFloat32 (0.0f); - - tmp[2][0] = +globalContact[1]; - tmp[2][1] = -globalContact[0]; - tmp[2][2] = dgFloat32 (0.0f); - tmp[2][3] = dgFloat32 (0.0f); - - tmp[3][0] = dgFloat32 (0.0f); - tmp[3][1] = dgFloat32 (0.0f); - tmp[3][2] = dgFloat32 (0.0f); - tmp[3][3] = dgFloat32 (1.0f); - - dgMatrix contactMatrix (tmp * invInertia * tmp); - for (dgInt32 i = 0; i < 3; i ++) { - for (dgInt32 j = 0; j < 3; j ++) { - contactMatrix[i][j] *= -dgFloat32 (1.0f); - } - } - contactMatrix[0][0] += m_invMass.m_w; - contactMatrix[1][1] += m_invMass.m_w; - contactMatrix[2][2] += m_invMass.m_w; - - contactMatrix = contactMatrix.Inverse4x4 (); - - // change of momentum - dgVector changeOfMomentum (contactMatrix.RotateVector (pointDeltaVeloc)); - - if (changeOfMomentum.DotProduct(changeOfMomentum).GetScalar() > dgFloat32(1.0e-6f)) { - m_impulseForce += changeOfMomentum.Scale(1.0f / timestep); - m_impulseTorque += globalContact.CrossProduct(m_impulseForce); - - m_sleeping = false; - m_equilibrium = false; - Unfreeze(); - } -} - -void dgBody::ApplyImpulsePair (const dgVector& linearImpulseIn, const dgVector& angularImpulseIn, dgFloat32 timestep) -{ - dgAssert(linearImpulseIn.m_w == dgFloat32(0.0f)); - dgAssert(angularImpulseIn.m_w == dgFloat32(0.0f)); - if ((linearImpulseIn.DotProduct(linearImpulseIn).GetScalar() > dgFloat32(1.0e-6f)) || - (angularImpulseIn.DotProduct(angularImpulseIn).GetScalar() > dgFloat32(1.0e-6f))) { - - m_impulseForce += linearImpulseIn.Scale(1.0f / timestep); - m_impulseTorque += angularImpulseIn.Scale(1.0f / timestep); - - m_sleeping = false; - m_equilibrium = false; - Unfreeze(); - } -} - -void dgBody::ApplyImpulsesAtPoint (dgInt32 count, dgInt32 strideInBytes, const dgFloat32* const impulseArray, const dgFloat32* const pointArray, dgFloat32 timestep) -{ - dgInt32 stride = strideInBytes / sizeof (dgFloat32); - - dgVector impulse (dgVector::m_zero); - dgVector angularImpulse (dgVector::m_zero); - - dgVector com (m_globalCentreOfMass); - for (dgInt32 i = 0; i < count; i ++) { - dgInt32 index = i * stride; - dgVector r (pointArray[index], pointArray[index + 1], pointArray[index + 2], dgFloat32 (0.0f)); - dgVector L (impulseArray[index], impulseArray[index + 1], impulseArray[index + 2], dgFloat32 (0.0f)); - dgVector Q ((r - com).CrossProduct(L)); - - impulse += L; - angularImpulse += Q; - } - - if ((impulse.DotProduct(impulse).GetScalar() > dgFloat32(1.0e-6f)) || - (angularImpulse.DotProduct(angularImpulse).GetScalar() > dgFloat32(1.0e-6f))) { - m_impulseForce += impulse.Scale(1.0f / timestep); - m_impulseTorque += angularImpulse.Scale(1.0f / timestep); - - m_sleeping = false; - m_equilibrium = false; - Unfreeze(); - } -} - -void dgBody::SetSleepState(bool state) -{ - m_sleeping = state; - m_equilibrium = state; - if ((m_invMass.m_w > dgFloat32 (0.0f)) && (m_veloc.DotProduct(m_veloc).GetScalar() < dgFloat32(1.0e-10f)) && (m_omega.DotProduct(m_omega).GetScalar() < dgFloat32(1.0e-10f))) { - m_equilibrium = state; - for (dgConstraint* contact = GetFirstContact(); contact; contact = GetNextContact(contact)) { - dgAssert(contact->GetId() == dgConstraint::m_contactConstraint); - dgContact* const contactJoint = (dgContact*)contact; - contactJoint->m_positAcc = dgVector(dgFloat32(10.0f)); - } - } -} diff --git a/thirdparty/src/newton/dgPhysics/dgBody.h b/thirdparty/src/newton/dgPhysics/dgBody.h deleted file mode 100644 index 08c92c21e..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBody.h +++ /dev/null @@ -1,672 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_BODY_H_ -#define _DG_BODY_H_ - -#include "dgPhysicsStdafx.h" -#include "dgCollision.h" -#include "dgBodyMasterList.h" - -class dgLink; -class dgBody; -class dgWorld; -class dgCollision; -class dgBroadPhaseNode; -class dgSkeletonContainer; -class dgCollisionInstance; -class dgBroadPhaseBodyNode; -class dgBroadPhaseAggregate; - - -#define DG_MINIMUM_MASS dgFloat32(1.0e-5f) -#define DG_INFINITE_MASS dgFloat32(1.0e15f) - -#define OverlapTest(body0,body1) dgOverlapTest ((body0)->m_minAABB, (body0)->m_maxAABB, (body1)->m_minAABB, (body1)->m_maxAABB) - - - -DG_MSC_VECTOR_ALIGNMENT -struct dgLineBox -{ - dgVector m_l0; - dgVector m_l1; - dgVector m_boxL0; - dgVector m_boxL1; -} DG_GCC_VECTOR_ALIGNMENT; - - -DG_MSC_VECTOR_ALIGNMENT -class dgBody -{ - public: - typedef void (dgApi *OnBodyDestroy) (dgBody& me); - typedef void (dgApi *OnApplyExtForceAndTorque) (dgBody& me, dgFloat32 timestep, dgInt32 threadIndex); - typedef void (dgApi *OnMatrixUpdateCallback) (const dgBody& me, const dgMatrix& matrix, dgInt32 threadIndex); - - enum dgRTTI - { - m_baseBodyRTTI = 1<<0, - m_dynamicBodyRTTI = 1<<1, - m_kinematicBodyRTTI = 1<<2, - m_dynamicBodyAsymentricRTTI = 1 << 3, - //m_deformableBodyRTTI = 1<<3, - }; - - enum dgType - { - m_dynamicBody = 0, - m_kinematicBody, - m_dynamicBodyAsymatric, - //m_deformableBody, - }; - - class dgSetInfo - { - public: - DG_INLINE dgSetInfo() - { - } - - DG_INLINE void Init(dgBody* const self) - { - m_parent = self; - m_rank = 0; - m_bodyCount = 1; - m_jointCount = 0; - m_rowCount = 0; - } - - dgBody* m_parent; - dgInt32 m_rank; - dgInt32 m_bodyCount; - dgInt32 m_jointCount; - dgInt32 m_rowCount; - }; - - DG_CLASS_ALLOCATOR(allocator) - - dgBody(); - dgBody (dgWorld* const world, const dgTree<const dgCollision*, dgInt32>* const collisionNode, dgDeserialize serializeCallback, void* const userData, dgInt32 revisionNumber); - virtual ~dgBody(); - - dgType GetType () const; - dgInt32 IsRTTIType (dgUnsigned32 rtti) const; - - void* GetUserData() const; - void SetUserData (void* const userData); - dgWorld* GetWorld() const; - - const dgMatrix& GetMatrix() const; - const dgQuaternion& GetRotation() const; - const dgVector& GetPosition() const; - - void SetCentreOfMass (const dgVector& com); - const dgVector& GetCentreOfMass () const; - - void GetAABB (dgVector &p0, dgVector &p1) const; - - const dgVector& GetOmega() const; - const dgVector& GetVelocity() const; - - dgVector GetVelocityAtPoint (const dgVector& point) const; - - void SetOmega (const dgVector& omega); - void SetVelocity (const dgVector& velocity); - - void SetOmegaNoSleep(const dgVector& omega); - void SetVelocityNoSleep(const dgVector& velocity); - - dgUnsigned32 GetGroupID () const; - virtual void SetGroupID (dgUnsigned32 id); - dgInt32 GetUniqueID () const; - - bool GetContinueCollisionMode () const; - void SetContinueCollisionMode (bool mode); - bool GetCollisionWithLinkedBodies () const; - void SetCollisionWithLinkedBodies (bool state); - - void Freeze (); - void Unfreeze (); - bool GetFreeze () const; - void SetFreeze (bool state); - - bool GetSleepState () const; - void SetSleepState (bool state); - - bool GetAutoSleep () const; - void SetAutoSleep (bool state); - - bool GetGyroMode() const; - void SetGyroMode(bool state); - - dgCollisionInstance* GetCollision () const; - dgBodyMasterList::dgListNode* GetMasterList() const; - - OnBodyDestroy GetDestructorCallback () const; - void SetDestructorCallback (OnBodyDestroy destructor); - OnMatrixUpdateCallback GetMatrixUpdateCallback () const; - void SetMatrixUpdateCallback (OnMatrixUpdateCallback callback); - - dgVector GetMass() const; - dgVector GetInvMass() const; - void SetInvMass(const dgVector& invMass); - const dgMatrix& GetInvInertiaMatrix () const; - - bool IsCollidable() const; - void UpdateCollisionMatrix(dgFloat32 timestep, dgInt32 threadIndex); - - virtual dgMatrix CalculateInertiaMatrix () const; - virtual dgMatrix CalculateInvInertiaMatrix () const; - virtual dgMatrix CalculateLocalInertiaMatrix () const; - - virtual dgVector GetAlpha() const; - virtual dgVector GetAccel() const; - - virtual void SetAlpha(const dgVector& alpha); - virtual void SetAccel(const dgVector& accel); - - virtual void SetCollidable (bool state) = 0; - virtual bool IsInEquilibrium () const = 0; - - virtual const dgVector& GetForce() const = 0; - virtual const dgVector& GetTorque() const = 0; - virtual void AddForce (const dgVector& force) = 0; - virtual void AddTorque (const dgVector& torque) = 0; - virtual void SetForce (const dgVector& force) = 0; - virtual void SetTorque (const dgVector& torque) = 0; - - virtual dgFloat32 GetLinearDamping () const = 0; - virtual dgVector GetAngularDamping () const = 0; - virtual void SetLinearDamping (dgFloat32 linearDamp) = 0; - virtual void SetAngularDamping (const dgVector& angularDamp) = 0; - virtual void AddDampingAcceleration(dgFloat32 timestep) = 0; - - virtual void SetMassMatrix (dgFloat32 mass, const dgMatrix& inertia); - virtual void SetMassProperties (dgFloat32 mass, const dgCollisionInstance* const collision); - - virtual dgVector PredictLinearVelocity(dgFloat32 timestep) const = 0; - virtual dgVector PredictAngularVelocity(dgFloat32 timestep) const = 0; - virtual void InvalidateCache(); - - virtual void SetMatrix(const dgMatrix& matrix); - virtual void SetMatrixResetSleep(const dgMatrix& matrix); - virtual void SetMatrixNoSleep(const dgMatrix& matrix); - virtual void IntegrateVelocity (dgFloat32 timestep); - virtual void AttachCollision (dgCollisionInstance* const collision); - - virtual void ApplyExtenalForces (dgFloat32 timestep, dgInt32 threadIndex) = 0; - virtual OnApplyExtForceAndTorque GetExtForceAndTorqueCallback () const = 0; - virtual void SetExtForceAndTorqueCallback (OnApplyExtForceAndTorque callback) = 0; - - virtual dgFloat32 RayCast (const dgLineBox& line, OnRayCastAction filter, OnRayPrecastAction preFilter, void* const userData, dgFloat32 minT) const; - virtual void Serialize (const dgTree<dgInt32, const dgCollision*>& collisionRemapId, dgSerialize serializeCallback, void* const userData); - - virtual dgConstraint* GetFirstJoint() const; - virtual dgConstraint* GetNextJoint(dgConstraint* const joint) const; - virtual dgConstraint* GetFirstContact() const; - virtual dgConstraint* GetNextContact(dgConstraint* const joint) const; - virtual dgSkeletonContainer* GetSkeleton() const; - - void SetMatrixOriginAndRotation(const dgMatrix& matrix); - - dgBroadPhaseBodyNode* GetBroadPhase () const; - void SetBroadPhase(dgBroadPhaseBodyNode* const node); - dgBroadPhaseAggregate* GetBroadPhaseAggregate() const; - void SetBroadPhaseAggregate(dgBroadPhaseAggregate* const aggregate); - - void AddImpulse (const dgVector& pointVeloc, const dgVector& pointPosit, dgFloat32 timestep); - void ApplyImpulsePair (const dgVector& linearImpulse, const dgVector& angularImpulse, dgFloat32 timestep); - void ApplyImpulsesAtPoint (dgInt32 count, dgInt32 strideInBytes, const dgFloat32* const impulseArray, const dgFloat32* const pointArray, dgFloat32 timestep); - - dgInt32 GetSerializedID() const; - void CalcInvInertiaMatrix(); - void UpdateGyroData(); - - void InitJointSet (); - - void SetCollision(dgCollisionInstance* const collision); - - protected: - void UpdateWorlCollisionMatrix() const; - void UpdateLumpedMatrix(); - - dgVector CalculateLinearMomentum() const; - dgVector CalculateAngularMomentum() const; - - dgMatrix m_matrix; - dgQuaternion m_rotation; - dgMatrix m_invWorldInertiaMatrix; - dgVector m_mass; - dgVector m_invMass; - dgVector m_veloc; - dgVector m_omega; - dgVector m_accel; - dgVector m_alpha; - dgVector m_minAABB; - dgVector m_maxAABB; - dgVector m_localCentreOfMass; - dgVector m_globalCentreOfMass; - dgVector m_impulseForce; - dgVector m_impulseTorque; - dgVector m_gyroAlpha; - dgVector m_gyroTorque; - dgQuaternion m_gyroRotation; - - mutable dgInt32 m_criticalSectionLock; - union - { - dgUnsigned32 m_flags; - struct { - dgUnsigned32 m_freeze : 1; - dgUnsigned32 m_resting : 1; - dgUnsigned32 m_sleeping : 1; - dgUnsigned32 m_autoSleep : 1; - dgUnsigned32 m_inCallback : 1; - dgUnsigned32 m_jointSet : 1; - dgUnsigned32 m_collidable : 1; - dgUnsigned32 m_equilibrium : 1; - dgUnsigned32 m_spawnnedFromCallback : 1; - dgUnsigned32 m_continueCollisionMode : 1; - dgUnsigned32 m_collideWithLinkedBodies : 1; - dgUnsigned32 m_transformIsDirty : 1; - dgUnsigned32 m_gyroTorqueOn : 1; - dgUnsigned32 m_isdead : 1; - }; - }; - - void* m_userData; - dgWorld* m_world; - dgCollisionInstance* m_collision; - dgBroadPhaseBodyNode* m_broadPhaseNode; - dgBodyMasterList::dgListNode* m_masterNode; - dgBroadPhaseAggregate* m_broadPhaseaggregateNode; - OnBodyDestroy m_destructor; - OnMatrixUpdateCallback m_matrixUpdate; - - dgSetInfo m_disjointInfo; - dgInt32 m_index; - dgInt32 m_uniqueID; - dgInt32 m_bodyGroupId; - dgInt32 m_rtti; - dgInt32 m_type; - dgInt32 m_serializedEnum; - dgUnsigned32 m_dynamicsLru; - dgUnsigned32 m_genericLRUMark; - - friend class dgWorld; - friend class dgSolver; - friend class dgContact; - friend class dgConstraint; - friend class dgDeadBodies; - friend class dgBroadPhase; - friend class dgCollisionBVH; - friend class dgBroadPhaseNode; - friend class dgBodyMasterList; - friend class dgCollisionScene; - friend class dgCollisionConvex; - friend class dgBroadPhaseMixed; - friend class dgCollisionCompound; - friend class dgCollisionUserMesh; - friend class dgBodyMasterListRow; - friend class dgParallelBodySolver; - friend class dgWorldDynamicUpdate; - friend class dgBroadPhaseBodyNode; - friend class dgBilateralConstraint; - friend class dgBroadPhaseAggregate; - friend class dgBroadPhaseSegregated; - friend class dgCollisionConvexPolygon; - friend class dgCollidingPairCollector; - friend class dgCollisionLumpedMassParticles; - -} DG_GCC_VECTOR_ALIGNMENT; - -// ***************************************************************************** -// -// Implementation -// -// ***************************************************************************** -DG_INLINE const dgMatrix& dgBody::GetInvInertiaMatrix () const -{ - return m_invWorldInertiaMatrix; -} - -DG_INLINE dgVector dgBody::GetInvMass() const -{ - return m_invMass; -} - -DG_INLINE void dgBody::SetInvMass(const dgVector& invMass) -{ - m_invMass = invMass; -} - -DG_INLINE dgVector dgBody::GetMass() const -{ - return m_mass; -} - - -DG_INLINE dgBody::dgType dgBody::GetType () const -{ - return dgType (m_type); -} - -DG_INLINE dgInt32 dgBody::IsRTTIType (dgUnsigned32 rtti) const -{ - return rtti & m_rtti; -} - -DG_INLINE void dgBody::SetUserData(void* const userData) -{ - m_userData = userData; -} - -DG_INLINE void* dgBody::GetUserData() const -{ - return m_userData; -} - -DG_INLINE dgWorld* dgBody::GetWorld() const -{ - return m_world; -} - - -DG_INLINE dgUnsigned32 dgBody::GetGroupID () const -{ - return dgUnsigned32 (m_bodyGroupId); -} - -DG_INLINE void dgBody::SetGroupID (dgUnsigned32 id) -{ - m_bodyGroupId = dgInt32 (id); -} - - - -DG_INLINE dgBodyMasterList::dgListNode* dgBody::GetMasterList() const -{ - return m_masterNode; -} - -DG_INLINE void dgBody::GetAABB (dgVector &p0, dgVector &p1) const -{ - p0.m_x = m_minAABB.m_x; - p0.m_y = m_minAABB.m_y; - p0.m_z = m_minAABB.m_z; - p1.m_x = m_maxAABB.m_x; - p1.m_y = m_maxAABB.m_y; - p1.m_z = m_maxAABB.m_z; -} - -DG_INLINE const dgVector& dgBody::GetOmega() const -{ - return m_omega; -} - -DG_INLINE const dgVector& dgBody::GetVelocity() const -{ - return m_veloc; -} - -DG_INLINE void dgBody::SetOmegaNoSleep(const dgVector& omega) -{ - m_omega = omega; -} - -DG_INLINE void dgBody::SetOmega (const dgVector& omega) -{ - SetOmegaNoSleep(omega); - m_equilibrium = false; -} - -DG_INLINE dgVector dgBody::GetVelocityAtPoint (const dgVector& point) const -{ - return m_veloc + m_omega.CrossProduct(point - m_globalCentreOfMass); -} - -DG_INLINE void dgBody::SetVelocityNoSleep(const dgVector& velocity) -{ - m_veloc = velocity; -} - -DG_INLINE void dgBody::SetVelocity (const dgVector& velocity) -{ - SetVelocityNoSleep(velocity); - m_equilibrium = false; -} - -DG_INLINE const dgMatrix& dgBody::GetMatrix() const -{ - return m_matrix; -} - -DG_INLINE const dgVector& dgBody::GetPosition() const -{ - return m_matrix.m_posit; -} - -DG_INLINE const dgQuaternion& dgBody::GetRotation() const -{ - return m_rotation; -} - -DG_INLINE const dgVector& dgBody::GetCentreOfMass () const -{ - return m_localCentreOfMass; -} - -DG_INLINE void dgBody::SetCentreOfMass (const dgVector& com) -{ - m_localCentreOfMass.m_x = com.m_x; - m_localCentreOfMass.m_y = com.m_y; - m_localCentreOfMass.m_z = com.m_z; - m_localCentreOfMass.m_w = dgFloat32 (1.0f); - m_globalCentreOfMass = m_matrix.TransformVector (m_localCentreOfMass); -} - - -DG_INLINE dgInt32 dgBody::GetUniqueID () const -{ - return m_uniqueID; -} - -DG_INLINE void dgBody::SetDestructorCallback (OnBodyDestroy destructor) -{ - m_destructor = destructor; -} - -DG_INLINE dgBody::OnBodyDestroy dgBody::GetDestructorCallback () const -{ - return m_destructor; -} - -DG_INLINE void dgBody::SetMatrixUpdateCallback (OnMatrixUpdateCallback callback) -{ - m_matrixUpdate = callback; -} - -DG_INLINE dgBody::OnMatrixUpdateCallback dgBody::GetMatrixUpdateCallback () const -{ - return m_matrixUpdate; -} - -DG_INLINE dgCollisionInstance* dgBody::GetCollision () const -{ - return m_collision; -} - -DG_INLINE void dgBody::SetContinueCollisionMode (bool mode) -{ - m_continueCollisionMode = dgUnsigned32 (mode); -} - -DG_INLINE bool dgBody::GetContinueCollisionMode () const -{ - return m_continueCollisionMode; -} - -DG_INLINE void dgBody::SetCollisionWithLinkedBodies (bool state) -{ - m_collideWithLinkedBodies = dgUnsigned32 (state); -} - -DG_INLINE bool dgBody::GetCollisionWithLinkedBodies () const -{ - return m_collideWithLinkedBodies; -} - -DG_INLINE bool dgBody::GetFreeze () const -{ - return m_freeze; -} - - -DG_INLINE void dgBody::SetAutoSleep (bool state) -{ - SetSleepState(false); - m_autoSleep = dgUnsigned32 (state); -} - -DG_INLINE bool dgBody::GetAutoSleep () const -{ - return m_autoSleep; -} - -DG_INLINE bool dgBody::GetSleepState () const -{ -// return m_equilibrium; - return m_sleeping; -} - -DG_INLINE bool dgBody::GetGyroMode() const -{ - return m_gyroTorqueOn; -} - -DG_INLINE void dgBody::SetGyroMode(bool state) -{ - m_gyroTorqueOn = state; -} - -DG_INLINE bool dgBody::IsCollidable() const -{ - return m_collidable; -} - - -DG_INLINE void dgBody::SetMatrixOriginAndRotation(const dgMatrix& matrix) -{ - m_matrix = matrix; - dgAssert (m_matrix.TestOrthogonal(dgFloat32 (1.0e-4f))); - - m_rotation = dgQuaternion (m_matrix); - m_globalCentreOfMass = m_matrix.TransformVector (m_localCentreOfMass); - UpdateLumpedMatrix(); -} - - -DG_INLINE void dgBody::SetBroadPhase(dgBroadPhaseBodyNode* const node) -{ - m_broadPhaseNode = node; -} - -DG_INLINE dgBroadPhaseBodyNode* dgBody::GetBroadPhase() const -{ - return m_broadPhaseNode; -} - -DG_INLINE dgBroadPhaseAggregate* dgBody::GetBroadPhaseAggregate() const -{ - return m_broadPhaseaggregateNode; -} - -DG_INLINE void dgBody::SetBroadPhaseAggregate(dgBroadPhaseAggregate* const aggregate) -{ - m_broadPhaseaggregateNode = aggregate; -} - -DG_INLINE dgVector dgBody::CalculateLinearMomentum() const -{ - return dgVector(m_veloc.Scale(m_mass.m_w)); -} - -DG_INLINE dgVector dgBody::CalculateAngularMomentum() const -{ - dgVector localOmega(m_matrix.UnrotateVector(m_omega)); - dgVector localAngularMomentum(m_mass * localOmega); - return m_matrix.RotateVector(localAngularMomentum); -} - -DG_INLINE void dgBody::UpdateGyroData() -{ - if (m_gyroTorqueOn) { - m_gyroTorque = m_omega.CrossProduct(CalculateAngularMomentum()); - m_gyroAlpha = m_invWorldInertiaMatrix.RotateVector(m_gyroTorque); - } else { - dgVector zero(0.0f); - m_gyroTorque = zero; - m_gyroAlpha = zero; - } -} - -DG_INLINE void dgBody::CalcInvInertiaMatrix () -{ - dgAssert (m_invWorldInertiaMatrix[0][3] == dgFloat32 (0.0f)); - dgAssert (m_invWorldInertiaMatrix[1][3] == dgFloat32 (0.0f)); - dgAssert (m_invWorldInertiaMatrix[2][3] == dgFloat32 (0.0f)); - dgAssert (m_invWorldInertiaMatrix[3][3] == dgFloat32 (1.0f)); - - m_invWorldInertiaMatrix = CalculateInvInertiaMatrix (); - - dgAssert (m_invWorldInertiaMatrix[0][3] == dgFloat32 (0.0f)); - dgAssert (m_invWorldInertiaMatrix[1][3] == dgFloat32 (0.0f)); - dgAssert (m_invWorldInertiaMatrix[2][3] == dgFloat32 (0.0f)); - dgAssert (m_invWorldInertiaMatrix[3][3] == dgFloat32 (1.0f)); - - UpdateGyroData(); -} - -DG_INLINE dgSkeletonContainer* dgBody::GetSkeleton() const -{ - return NULL; -} - -DG_INLINE dgInt32 dgBody::GetSerializedID() const -{ - return m_serializedEnum; -} - -DG_INLINE void dgBody::InitJointSet () -{ - m_index = -1; - m_jointSet = 1; - m_disjointInfo.Init (this); -} - -DG_INLINE void dgBody::SetCollision(dgCollisionInstance* const collision) -{ - m_collision = collision; -} - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgBodyMasterList.cpp b/thirdparty/src/newton/dgPhysics/dgBodyMasterList.cpp deleted file mode 100644 index 55c80c091..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBodyMasterList.cpp +++ /dev/null @@ -1,339 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgConstraint.h" -#include "dgDynamicBody.h" -#include "dgBodyMasterList.h" -#include "dgSkeletonContainer.h" - -dgBodyMasterListRow::dgBodyMasterListRow () - :dgList<dgBodyMasterListCell>(NULL) - ,m_body (NULL) -{ -} - -dgBodyMasterListRow::~dgBodyMasterListRow() -{ - dgAssert (GetCount() == 0); -} - -DG_INLINE dgBodyMasterListRow::dgListNode* dgBodyMasterListRow::AddContactJoint (dgContact* const joint, dgBody* const body) -{ - dgListNode* const node = Addtop(); - node->GetInfo().m_joint = joint; - node->GetInfo().m_bodyNode = body; - return node; -} - -dgBodyMasterListRow::dgListNode* dgBodyMasterListRow::AddBilateralJoint (dgConstraint* const joint, dgBody* const body) -{ - dgScopeSpinLock lock(&m_body->m_criticalSectionLock); - dgListNode* const node = Append(); - - node->GetInfo().m_joint = joint; - node->GetInfo().m_bodyNode = body; - return node; -} - -void dgBodyMasterListRow::RemoveAllJoints () -{ - dgWorld* const world = m_body->GetWorld(); - - for (dgListNode* node = GetFirst(); node; ) { - dgConstraint* const constraint = node->GetInfo().m_joint; - node = node->GetNext(); - world->DestroyConstraint (constraint); - } -} - -void dgBodyMasterListRow::RemoveContactJoint (dgListNode* const link) -{ - dgScopeSpinLock lock(&m_body->m_criticalSectionLock); - m_body->m_world->GlobalLock(); - Remove(link); - m_body->m_world->GlobalUnlock(); -} - -void dgBodyMasterListRow::RemoveBilateralJoint (dgListNode* const link) -{ - dgScopeSpinLock lock(&m_body->m_criticalSectionLock); - m_body->m_world->GlobalLock(); - Remove(link); - m_body->m_world->GlobalUnlock(); -} - -DG_INLINE dgBilateralConstraint* dgBodyMasterListRow::FindBilateralJoint (const dgBody* const otherBody) const -{ - for (dgBodyMasterListRow::dgListNode* link = GetLast(); link && (link->GetInfo().m_joint->GetId() != dgConstraint::m_contactConstraint); link = link->GetPrev()) { - if (link->GetInfo().m_bodyNode == otherBody) { - dgAssert (link->GetInfo().m_joint->IsBilateral()); - return (dgBilateralConstraint*) link->GetInfo().m_joint; - } - } - return NULL; -} - -void dgBodyMasterListRow::SortList() -{ - dgScopeSpinLock lock(&m_body->m_criticalSectionLock); - if (GetFirst()) { - dgAssert (GetFirst()->GetInfo().m_joint->GetId() != dgConstraint::m_contactConstraint); - dgListNode* nextKeyNode = NULL; - for (dgListNode* keyNode = GetFirst()->GetNext(); keyNode; keyNode = nextKeyNode) { - nextKeyNode = keyNode->GetNext(); - dgAssert (keyNode->GetInfo().m_joint->GetId() != dgConstraint::m_contactConstraint); - dgInt32 key = keyNode->GetInfo().m_bodyNode->GetUniqueID(); - - dgListNode* ptr0 = NULL; - for (dgListNode* ptr = GetFirst(); ptr != keyNode; ptr = ptr->GetNext()) { - dgInt32 key1 = ptr->GetInfo().m_bodyNode->GetUniqueID(); - if (key1 > key) { - break; - } - ptr0 = ptr; - } - dgAssert (ptr0 != keyNode); - if (!ptr0) { - RotateToBegin (keyNode); - } else { - InsertAfter(ptr0, keyNode); - } - } - } -} - -dgBodyMasterList::dgBodyMasterList (dgMemoryAllocator* const allocator) - :dgList<dgBodyMasterListRow>(allocator) - ,m_disableBodies(allocator) - ,m_constraintCount (0) -{ -} - -dgBodyMasterList::~dgBodyMasterList(void) -{ -} - -void dgBodyMasterList::AddBody (dgBody* const body) -{ - dgListNode* const node = Append(); - body->m_masterNode = node; - node->GetInfo().SetAllocator (body->GetWorld()->GetAllocator()); - node->GetInfo().SetBody(body); - - if ((body->m_invMass.m_w == dgFloat32 (0.0f)) && (GetFirst() != node)) { - InsertAfter (GetFirst(), node); - } -} - -void dgBodyMasterList::RemoveBody (dgBody* const body) -{ - dgListNode* const node = body->m_masterNode; - dgAssert (node); - - node->GetInfo().RemoveAllJoints(); - dgAssert (node->GetInfo().GetCount() == 0); - - Remove (node); - body->m_masterNode = NULL; -} - -dgBodyMasterListRow::dgListNode* dgBodyMasterList::FindConstraintLink (const dgBody* const body0, const dgBody* const body1) const -{ - dgAssert (body0); - dgAssert (body1); - dgAssert (body0->m_masterNode); - - for (dgBodyMasterListRow::dgListNode* node = body0->m_masterNode->GetInfo().GetFirst(); node; node = node->GetNext()) { - if (node->GetInfo().m_bodyNode == body1) { - return node; - } - } - return NULL; -} - - -dgBilateralConstraint* dgBodyMasterList::FindBilateralJoint (const dgBody* body0, const dgBody* body1) const -{ - return body0->m_masterNode->GetInfo().FindBilateralJoint (body1); -} - -void dgBodyMasterList::AttachConstraint(dgConstraint* const constraint, dgBody* const body0, dgBody* const otherBody) -{ - dgAssert (body0); - dgBody* body1 = otherBody; - if (!body1) { - body1 = body0->GetWorld()->GetSentinelBody(); - } - dgAssert (body1); - - #ifdef _DEBUG - if (FindBilateralJoint(body0, body1)) - { - dgTrace (("warning!! bilateral joint duplication between bodied: %d and %d\n", body0->m_uniqueID, body1->m_uniqueID)); - } - #endif - - constraint->m_body0 = body0; - constraint->m_body1 = body1; - - dgAssert(constraint->GetId() != dgConstraint::m_contactConstraint); - - dgBilateralConstraint* const bilateralJoint = constraint->IsBilateral() ? (dgBilateralConstraint*)constraint : NULL; - dgAssert (bilateralJoint); - if (bilateralJoint) { - bilateralJoint->AppendToJointList(); - } - - dgWorld* const world = body0->GetWorld(); - world->m_skelListIsDirty = world->m_skelListIsDirty || (constraint->m_solverModel != 2); - - body0->m_equilibrium = body0->GetInvMass().m_w ? false : true; - body1->m_equilibrium = body1->GetInvMass().m_w ? false : true; - constraint->m_link0 = body0->m_masterNode->GetInfo().AddBilateralJoint (constraint, body1); - constraint->m_link1 = body1->m_masterNode->GetInfo().AddBilateralJoint (constraint, body0); - dgAtomicExchangeAndAdd((dgInt32*) &m_constraintCount, 1); -} - -void dgBodyMasterList::RemoveConstraint (dgConstraint* const constraint) -{ - dgAtomicExchangeAndAdd((dgInt32*) &m_constraintCount, -1); - dgAssert (((dgInt32)m_constraintCount) >= 0); - - dgBody* const body0 = constraint->m_body0; - dgBody* const body1 = constraint->m_body1; - dgAssert (body0); - dgAssert (body1); - dgAssert (body0 == constraint->m_link1->GetInfo().m_bodyNode); - dgAssert (body1 == constraint->m_link0->GetInfo().m_bodyNode); - - dgBodyMasterListRow& row0 = body0->m_masterNode->GetInfo(); - dgBodyMasterListRow& row1 = body1->m_masterNode->GetInfo(); - - if (body0->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - dgDynamicBody* const dynBody0 = (dgDynamicBody*)body0; - dynBody0->m_savedExternalForce = dgVector(dgFloat32(0.0f)); - dynBody0->m_savedExternalTorque = dgVector(dgFloat32(0.0f)); - } - - if (body1->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - dgDynamicBody* const dynBody1 = (dgDynamicBody*)body1; - dynBody1->m_savedExternalForce = dgVector(dgFloat32(0.0f)); - dynBody1->m_savedExternalTorque = dgVector(dgFloat32(0.0f)); - } - - if (constraint->GetId() == dgConstraint::m_contactConstraint) { - dgConstraint* const contact = (dgConstraint*) constraint; - if (contact->m_maxDOF) { - body0->m_equilibrium = body0->GetInvMass().m_w ? false : true; - body1->m_equilibrium = body1->GetInvMass().m_w ? false : true; - } - row0.RemoveContactJoint(constraint->m_link0); - row1.RemoveContactJoint(constraint->m_link1); - } else { - dgWorld* const world = body0->GetWorld(); - world->m_skelListIsDirty = true; - - if (body0->GetSkeleton()) { - world->DestroySkeletonContainer (body0->GetSkeleton()); - } - if (body1->GetSkeleton()) { - world->DestroySkeletonContainer(body1->GetSkeleton()); - } - - body0->m_equilibrium = body0->GetInvMass().m_w ? false : true; - body1->m_equilibrium = body1->GetInvMass().m_w ? false : true; - row0.RemoveBilateralJoint(constraint->m_link0); - row1.RemoveBilateralJoint(constraint->m_link1); - } -} - -void dgBodyMasterList::AttachContact(dgContact* const contact) -{ - dgBody* const body0 = contact->m_body0; - dgBody* const body1 = contact->m_body1; - contact->m_link0 = body0->m_masterNode->GetInfo().AddContactJoint(contact, body1); - contact->m_link1 = body1->m_masterNode->GetInfo().AddContactJoint(contact, body0); - m_constraintCount++; -} - -void dgBodyMasterList::RemoveContact(dgContact* const contact) -{ - m_constraintCount --; - dgAssert(((dgInt32)m_constraintCount) >= 0); - dgAssert(contact->GetId() == dgConstraint::m_contactConstraint); - //dgAssert(!contact->m_maxDOF); - - dgBody* const body0 = contact->m_body0; - dgBody* const body1 = contact->m_body1; - dgAssert(body0); - dgAssert(body1); - dgAssert(body0 == contact->m_link1->GetInfo().m_bodyNode); - dgAssert(body1 == contact->m_link0->GetInfo().m_bodyNode); - - dgBodyMasterListRow& row0 = body0->m_masterNode->GetInfo(); - dgBodyMasterListRow& row1 = body1->m_masterNode->GetInfo(); - - row0.Remove(contact->m_link0); - row1.Remove(contact->m_link1); -} - -DG_INLINE dgUnsigned32 dgBodyMasterList::MakeSortMask(const dgBody* const body) const -{ - dgUnsigned32 val0 = body->IsRTTIType(dgBody::m_dynamicBodyRTTI) ? (body->GetInvMass().m_w > 0.0f) << 30 : 0; - dgUnsigned32 val1 = body->IsRTTIType(dgBody::m_kinematicBodyRTTI) ? 1<<29 : 0; - return body->m_uniqueID | val0 | val1; -} - -void dgBodyMasterList::SortMasterList() -{ - GetFirst()->GetInfo().SortList(); - for (dgListNode* node = GetFirst()->GetNext(); node; ) { - node->GetInfo().SortList(); - dgBody* const body1 = node->GetInfo().GetBody(); - - dgAssert (GetFirst() != node); - - body1->InvalidateCache (); - - dgInt32 key1 = MakeSortMask (body1); - dgListNode* const entry = node; - node = node->GetNext(); - dgListNode* prev = entry->GetPrev(); - for (; prev != GetFirst(); prev = prev->GetPrev()) { - dgBody* const body0 = prev->GetInfo().GetBody(); - - dgInt32 key0 = MakeSortMask (body0); - if (key0 < key1) { - break; - } - } - - if (!prev) { - dgAssert (entry == GetFirst()); - RotateToBegin (entry); - } else { - InsertAfter (prev, entry); - } - } -} diff --git a/thirdparty/src/newton/dgPhysics/dgBodyMasterList.h b/thirdparty/src/newton/dgPhysics/dgBodyMasterList.h deleted file mode 100644 index 1f25142ac..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBodyMasterList.h +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGBODYMASTER_LIST__ -#define __DGBODYMASTER_LIST__ - -class dgBody; -class dgContact; -class dgConstraint; -class dgBilateralConstraint; - -class dgBodyMasterListCell -{ - public: - dgConstraint* m_joint; - dgBody* m_bodyNode; -}; - -class dgBodyMasterListRow: public dgList<dgBodyMasterListCell> -{ - public: - dgBodyMasterListRow (); - ~dgBodyMasterListRow (); - - dgBody* GetBody() const { return m_body;} - - private: - void SortList(); - void SetBody(dgBody* const body) {m_body = body;} - - dgBilateralConstraint* FindBilateralJoint (const dgBody* const body) const; - dgListNode* AddContactJoint (dgContact* const contact, dgBody* const body); - dgListNode* AddBilateralJoint (dgConstraint* const joint, dgBody* const body); - - void RemoveContactJoint (dgListNode* const link); - void RemoveBilateralJoint (dgListNode* const link); - void RemoveAllJoints (); - - dgBody* m_body; - friend class dgBodyMasterList; -}; - -class dgBodyMasterList: public dgList<dgBodyMasterListRow> -{ - public: - dgBodyMasterList (dgMemoryAllocator* const allocator); - ~dgBodyMasterList (); - - void AddBody (dgBody* const body); - void RemoveBody (dgBody* const body); - void RemoveConstraint (dgConstraint* const constraint); - void AttachConstraint (dgConstraint* const constraint, dgBody* const body0, dgBody* const body1); - - void AttachContact(dgContact* const contact); - void RemoveContact(dgContact* const contact); - - dgBilateralConstraint* FindBilateralJoint (const dgBody* body0, const dgBody* body1) const; - dgBodyMasterListRow::dgListNode* FindConstraintLink (const dgBody* const body0, const dgBody* const body1) const; - dgUnsigned32 MakeSortMask(const dgBody* const body) const; - void SortMasterList(); - - public: - dgTree<int, dgBody*> m_disableBodies; - dgUnsigned32 m_constraintCount; -}; - -#endif diff --git a/thirdparty/src/newton/dgPhysics/dgBroadPhase.cpp b/thirdparty/src/newton/dgPhysics/dgBroadPhase.cpp deleted file mode 100644 index 407959dd0..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBroadPhase.cpp +++ /dev/null @@ -1,1776 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgBroadPhase.h" -#include "dgDynamicBody.h" -#include "dgCollisionConvex.h" -#include "dgCollisionInstance.h" -#include "dgWorldDynamicUpdate.h" -#include "dgBilateralConstraint.h" -#include "dgBroadPhaseAggregate.h" -#include "dgCollisionLumpedMassParticles.h" -//#include "dgCollisionLumpedMassParticles.h" - -#define DG_CONVEX_CAST_POOLSIZE 32 -#define DG_BROADPHASE_AABB_SCALE dgFloat32 (8.0f) -#define DG_BROADPHASE_AABB_INV_SCALE (dgFloat32 (1.0f) / DG_BROADPHASE_AABB_SCALE) -#define DG_CONTACT_TRANSLATION_ERROR dgFloat32 (1.0e-3f) -#define DG_CONTACT_ANGULAR_ERROR (dgFloat32 (0.25f * dgDegreeToRad)) -#define DG_NARROW_PHASE_DIST dgFloat32 (0.2f) -#define DG_CONTACT_DELAY_FRAMES 4 - -//#define DG_USE_OLD_SCANNER - -dgVector dgBroadPhase::m_velocTol(dgFloat32(1.0e-16f)); -dgVector dgBroadPhase::m_angularContactError2(DG_CONTACT_ANGULAR_ERROR * DG_CONTACT_ANGULAR_ERROR); -dgVector dgBroadPhase::m_linearContactError2(DG_CONTACT_TRANSLATION_ERROR * DG_CONTACT_TRANSLATION_ERROR); - -dgVector dgBroadPhaseNode::m_broadPhaseScale (DG_BROADPHASE_AABB_SCALE, DG_BROADPHASE_AABB_SCALE, DG_BROADPHASE_AABB_SCALE, dgFloat32 (0.0f)); -dgVector dgBroadPhaseNode::m_broadInvPhaseScale (DG_BROADPHASE_AABB_INV_SCALE, DG_BROADPHASE_AABB_INV_SCALE, DG_BROADPHASE_AABB_INV_SCALE, dgFloat32 (0.0f)); - - -class dgBroadPhase::dgSpliteInfo -{ - public: - dgSpliteInfo (dgBroadPhaseNode** const boxArray, dgInt32 boxCount) - { - dgVector minP ( dgFloat32 (1.0e15f)); - dgVector maxP (-dgFloat32 (1.0e15f)); - - if (boxCount == 2) { - m_axis = 1; - for (dgInt32 i = 0; i < boxCount; i ++) { - dgBroadPhaseNode* const node = boxArray[i]; - dgAssert (node->IsLeafNode()); - minP = minP.GetMin (node->m_minBox); - maxP = maxP.GetMax (node->m_maxBox); - } - } else { - dgVector median (dgFloat32 (0.0f)); - dgVector varian (dgFloat32 (0.0f)); - for (dgInt32 i = 0; i < boxCount; i ++) { - dgBroadPhaseNode* const node = boxArray[i]; - dgAssert (node->IsLeafNode()); - minP = minP.GetMin (node->m_minBox); - maxP = maxP.GetMax (node->m_maxBox); - dgVector p (dgVector::m_half * (node->m_minBox + node->m_maxBox)); - median += p; - varian += p * p; - } - - varian = varian.Scale (dgFloat32 (boxCount)) - median * median; - - dgInt32 index = 0; - dgFloat32 maxVarian = dgFloat32 (-1.0e10f); - for (dgInt32 i = 0; i < 3; i ++) { - if (varian[i] > maxVarian) { - index = i; - maxVarian = varian[i]; - } - } - - dgVector center = median.Scale (dgFloat32 (1.0f) / dgFloat32 (boxCount)); - - dgFloat32 test = center[index]; - - dgInt32 i0 = 0; - dgInt32 i1 = boxCount - 1; - do { - for (; i0 <= i1; i0 ++) { - dgBroadPhaseNode* const node = boxArray[i0]; - dgFloat32 val = (node->m_minBox[index] + node->m_maxBox[index]) * dgFloat32 (0.5f); - if (val > test) { - break; - } - } - - for (; i1 >= i0; i1 --) { - dgBroadPhaseNode* const node = boxArray[i1]; - dgFloat32 val = (node->m_minBox[index] + node->m_maxBox[index]) * dgFloat32 (0.5f); - if (val < test) { - break; - } - } - - if (i0 < i1) { - dgSwap(boxArray[i0], boxArray[i1]); - i0++; - i1--; - } - - } while (i0 <= i1); - - if (i0 > 0){ - i0 --; - } - if ((i0 + 1) >= boxCount) { - i0 = boxCount - 2; - } - m_axis = i0 + 1; - } - - dgAssert (maxP.m_x - minP.m_x >= dgFloat32 (0.0f)); - dgAssert (maxP.m_y - minP.m_y >= dgFloat32 (0.0f)); - dgAssert (maxP.m_z - minP.m_z >= dgFloat32 (0.0f)); - m_p0 = minP; - m_p1 = maxP; - } - - dgInt32 m_axis; - dgVector m_p0; - dgVector m_p1; -}; - - -dgBroadPhase::dgBroadPhase(dgWorld* const world) - :m_world(world) - ,m_rootNode(NULL) - ,m_generatedBodies(world->GetAllocator()) - ,m_updateList(world->GetAllocator()) - ,m_aggregateList(world->GetAllocator()) - ,m_lru(DG_CONTACT_DELAY_FRAMES) - ,m_contactCache(world->GetAllocator()) - ,m_pendingSoftBodyCollisions(world->GetAllocator(), 64) - ,m_pendingSoftBodyPairsCount(0) - ,m_criticalSectionLock(0) -{ -} - -dgBroadPhase::~dgBroadPhase() -{ -} - - -void dgBroadPhase::MoveNodes (dgBroadPhase* const dst) -{ - const dgBodyMasterList* const masterList = m_world; - for (dgBodyMasterList::dgListNode* node = masterList->GetFirst(); node; node = node->GetNext()) { - dgBody* const body = node->GetInfo().GetBody(); - if (body->GetBroadPhase() && !body->GetBroadPhaseAggregate()) { - Remove(body); - dst->Add(body); - } - } - - dgList<dgBroadPhaseAggregate*>::dgListNode* next; - for (dgList<dgBroadPhaseAggregate*>::dgListNode* ptr = m_aggregateList.GetFirst(); ptr; ptr = next) { - next = ptr->GetNext(); - dgBroadPhaseAggregate* const aggregate = ptr->GetInfo(); - m_aggregateList.Remove (aggregate->m_myAggregateNode); - m_updateList.Remove(aggregate->m_updateNode); - aggregate->m_updateNode = NULL; - aggregate->m_myAggregateNode = NULL; - UnlinkAggregate(aggregate); - dst->LinkAggregate(aggregate); - } -} - -dgBroadPhaseTreeNode* dgBroadPhase::InsertNode(dgBroadPhaseNode* const root, dgBroadPhaseNode* const node) -{ - dgVector p0; - dgVector p1; - - dgBroadPhaseNode* sibling = root; - dgFloat32 surfaceArea = CalculateSurfaceArea(node, sibling, p0, p1); - while (!sibling->IsLeafNode()) { - - if (surfaceArea > sibling->m_surfaceArea) { - break; - } - - sibling->m_minBox = p0; - sibling->m_maxBox = p1; - sibling->m_surfaceArea = surfaceArea; - - dgVector leftP0; - dgVector leftP1; - dgFloat32 leftSurfaceArea = CalculateSurfaceArea(node, sibling->GetLeft(), leftP0, leftP1); - - dgVector rightP0; - dgVector rightP1; - dgFloat32 rightSurfaceArea = CalculateSurfaceArea(node, sibling->GetRight(), rightP0, rightP1); - - if (leftSurfaceArea < rightSurfaceArea) { - sibling = sibling->GetLeft(); - p0 = leftP0; - p1 = leftP1; - surfaceArea = leftSurfaceArea; - } else { - sibling = sibling->GetRight(); - p0 = rightP0; - p1 = rightP1; - surfaceArea = rightSurfaceArea; - } - } - - dgBroadPhaseTreeNode* const parent = new (m_world->GetAllocator()) dgBroadPhaseTreeNode(sibling, node); - return parent; -} - -void dgBroadPhase::UpdateAggregateEntropyKernel(void* const context, void* const node, dgInt32 threadID) -{ - D_TRACKTIME(); - dgBroadphaseSyncDescriptor* const descriptor = (dgBroadphaseSyncDescriptor*)context; - dgWorld* const world = descriptor->m_world; - dgBroadPhase* const broadPhase = world->GetBroadPhase(); - broadPhase->UpdateAggregateEntropy(descriptor, (dgList<dgBroadPhaseAggregate*>::dgListNode*) node, threadID); -} - -void dgBroadPhase::ForceAndToqueKernel(void* const context, void* const node, dgInt32 threadID) -{ - D_TRACKTIME(); - dgBroadphaseSyncDescriptor* const descriptor = (dgBroadphaseSyncDescriptor*)context; - dgWorld* const world = descriptor->m_world; - dgBroadPhase* const broadPhase = world->GetBroadPhase(); - broadPhase->ApplyForceAndtorque(descriptor, (dgBodyMasterList::dgListNode*) node, threadID); -} - -void dgBroadPhase::SleepingStateKernel(void* const context, void* const node, dgInt32 threadID) -{ - D_TRACKTIME(); - dgBroadphaseSyncDescriptor* const descriptor = (dgBroadphaseSyncDescriptor*)context; - dgWorld* const world = descriptor->m_world; - dgBroadPhase* const broadPhase = world->GetBroadPhase(); - broadPhase->SleepingState(descriptor, (dgBodyMasterList::dgListNode*) node, threadID); -} - -bool dgBroadPhase::DoNeedUpdate(dgBodyMasterList::dgListNode* const node) const -{ - dgBody* const body = node->GetInfo().GetBody(); - - bool state = body->GetInvMass().m_w != dgFloat32 (0.0f); - state = state || !body->m_equilibrium || (body->GetExtForceAndTorqueCallback() != NULL); - return state; -} - -void dgBroadPhase::UpdateAggregateEntropy (dgBroadphaseSyncDescriptor* const descriptor, dgList<dgBroadPhaseAggregate*>::dgListNode* node, dgInt32 threadID) -{ - DG_TRACKTIME(); - const dgInt32 threadCount = m_world->GetThreadCount(); - while (node) { - node->GetInfo()->ImproveEntropy(); - for (dgInt32 i = 0; i < threadCount; i++) { - node = node ? node->GetNext() : NULL; - } - } -} - -void dgBroadPhase::ApplyForceAndtorque(dgBroadphaseSyncDescriptor* const descriptor, dgBodyMasterList::dgListNode* node, dgInt32 threadID) -{ - dgFloat32 timestep = descriptor->m_timestep; - - const dgInt32 threadCount = m_world->GetThreadCount(); - while (node) { - dgBody* const body = node->GetInfo().GetBody(); - body->InitJointSet(); - if (DoNeedUpdate(node)) { - if (body->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - dgDynamicBody* const dynamicBody = (dgDynamicBody*)body; - dynamicBody->ApplyExtenalForces(timestep, threadID); - } - } - - for (dgInt32 i = 0; i < threadCount; i++) { - node = node ? node->GetNext() : NULL; - } - } -} - -void dgBroadPhase::SleepingState(dgBroadphaseSyncDescriptor* const descriptor, dgBodyMasterList::dgListNode* node, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgFloat32 timestep = descriptor->m_timestep; - - const dgInt32 threadCount = m_world->GetThreadCount(); - dgBodyInfo* const pendingBodies = &m_world->m_bodiesMemory[0]; - - dgInt32* const atomicBodiesCount = &descriptor->m_atomicDynamicsCount; - dgInt32* const atomicPendingBodiesCount = &descriptor->m_atomicPendingBodiesCount; - - while (node) { - if (DoNeedUpdate(node)) { - dgBody* const body = node->GetInfo().GetBody(); - - if (body->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - dgDynamicBody* const dynamicBody = (dgDynamicBody*)body; - - if (!dynamicBody->m_equilibrium && (dynamicBody->GetInvMass().m_w == dgFloat32(0.0f))) { - descriptor->m_fullScan = true; - } - if (dynamicBody->GetInvMass().m_w) { - dgAtomicExchangeAndAdd(atomicBodiesCount, 1); - } - - if (dynamicBody->GetInvMass().m_w == dgFloat32(0.0f) || body->m_collision->IsType(dgCollision::dgCollisionMesh_RTTI)) { - dynamicBody->m_sleeping = true; - dynamicBody->m_autoSleep = true; - dynamicBody->m_equilibrium = true; - } - - if (dynamicBody->IsInEquilibrium()) { - dynamicBody->m_equilibrium = true; - dynamicBody->m_sleeping = dynamicBody->m_autoSleep; - } else { - dynamicBody->m_sleeping = false; - dynamicBody->m_equilibrium = false; - if (dynamicBody->GetBroadPhase()) { - dynamicBody->UpdateCollisionMatrix(timestep, threadID); - dgInt32 pendingBodyIndex = dgAtomicExchangeAndAdd(atomicPendingBodiesCount, 1); - pendingBodies[pendingBodyIndex].m_body = dynamicBody; - } - } - - dynamicBody->m_savedExternalForce = dynamicBody->m_externalForce; - dynamicBody->m_savedExternalTorque = dynamicBody->m_externalTorque; - } else { - dgAssert(body->IsRTTIType(dgBody::m_kinematicBodyRTTI)); - - // kinematic bodies are always sleeping (skip collision with kinematic bodies) - bool isResting = (body->m_omega.DotProduct(body->m_omega).GetScalar() < dgFloat32 (1.0e-6f)) && (body->m_veloc.DotProduct(body->m_veloc).GetScalar() < dgFloat32(1.0e-4f)); - if (body->IsCollidable()) { - body->m_sleeping = false; - body->m_autoSleep = false; - } else { - body->m_autoSleep = true; - body->m_sleeping = isResting; - descriptor->m_fullScan = !isResting; - } - body->m_equilibrium = isResting; - - // update collision matrix by calling the transform callback for all kinematic bodies - if (body->GetBroadPhase()) { - body->UpdateCollisionMatrix(timestep, threadID); - } - } - } - - for (dgInt32 i = 0; i < threadCount; i++) { - node = node ? node->GetNext() : NULL; - } - } -} - - -void dgBroadPhase::ForEachBodyInAABB(const dgBroadPhaseNode** stackPool, dgInt32 stack, const dgVector& minBox, const dgVector& maxBox, OnBodiesInAABB callback, void* const userData) const -{ - while (stack) { - stack--; - const dgBroadPhaseNode* const rootNode = stackPool[stack]; - if (dgOverlapTest(rootNode->m_minBox, rootNode->m_maxBox, minBox, maxBox)) { - - dgBody* const body = rootNode->GetBody(); - if (body) { - if (!body->m_isdead && dgOverlapTest(body->m_minAABB, body->m_maxAABB, minBox, maxBox)) { - if (!callback(body, userData)) { - break; - } - } - } else if (rootNode->IsAggregate()) { - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*)rootNode; - if (aggregate->m_root) { - stackPool[stack] = aggregate->m_root; - stack++; - dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH); - } - - } else { - dgAssert (!rootNode->IsLeafNode()); - dgBroadPhaseTreeNode* const node = (dgBroadPhaseTreeNode*)rootNode; - stackPool[stack] = node->m_left; - stack++; - dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH); - - stackPool[stack] = node->m_right; - stack++; - dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH); - } - } - } -} - -dgInt32 dgBroadPhase::ConvexCast(const dgBroadPhaseNode** stackPool, dgFloat32* const distance, dgInt32 stack, const dgVector& velocA, const dgVector& velocB, dgFastRayTest& ray, - dgCollisionInstance* const shape, const dgMatrix& matrix, const dgVector& target, dgFloat32* const param, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const -{ - dgVector boxP0; - dgVector boxP1; - dgTriplex points[DG_CONVEX_CAST_POOLSIZE]; - dgTriplex normals[DG_CONVEX_CAST_POOLSIZE]; - dgFloat32 penetration[DG_CONVEX_CAST_POOLSIZE]; - dgInt64 attributeA[DG_CONVEX_CAST_POOLSIZE]; - dgInt64 attributeB[DG_CONVEX_CAST_POOLSIZE]; - dgInt32 totalCount = 0; - - dgAssert(matrix.TestOrthogonal()); - shape->CalcAABB(matrix, boxP0, boxP1); - - maxContacts = dgMin (maxContacts, DG_CONVEX_CAST_POOLSIZE); - dgAssert (!maxContacts || (maxContacts && info)); - dgFloat32 maxParam = *param; - dgFloat32 timeToImpact = *param; - while (stack) { - stack--; - - dgFloat32 dist = distance[stack]; - - if (dist > maxParam) { - break; - } else { - const dgBroadPhaseNode* const me = stackPool[stack]; - - dgBody* const body = me->GetBody(); - if (body) { - if (!body->m_isdead && !PREFILTER_RAYCAST(prefilter, body, body->m_collision, userData)) { - dgInt32 count = m_world->CollideContinue(shape, matrix, velocA, velocB, body->m_collision, body->m_matrix, velocB, velocB, timeToImpact, points, normals, penetration, attributeA, attributeB, maxContacts, threadIndex); - - if (timeToImpact < maxParam) { - if ((timeToImpact - maxParam) < dgFloat32(-1.0e-3f)) { - totalCount = 0; - } - maxParam = timeToImpact; - if (count >= (maxContacts - totalCount)) { - count = maxContacts - totalCount; - } - - for (dgInt32 i = 0; i < count; i++) { - info[totalCount].m_point[0] = points[i].m_x; - info[totalCount].m_point[1] = points[i].m_y; - info[totalCount].m_point[2] = points[i].m_z; - info[totalCount].m_point[3] = dgFloat32(0.0f); - info[totalCount].m_normal[0] = normals[i].m_x; - info[totalCount].m_normal[1] = normals[i].m_y; - info[totalCount].m_normal[2] = normals[i].m_z; - info[totalCount].m_normal[3] = dgFloat32(0.0f); - info[totalCount].m_penetration = penetration[i]; - info[totalCount].m_contaID = attributeB[i]; - - info[totalCount].m_hitBody = body; - totalCount++; - } - } - if (maxParam < 1.0e-8f) { - break; - } - } - } else if (me->IsAggregate()) { - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*)me; - const dgBroadPhaseNode* const node = aggregate->m_root; - if (node) { - dgVector minBox(node->m_minBox - boxP1); - dgVector maxBox(node->m_maxBox - boxP0); - dgFloat32 dist1 = ray.BoxIntersect(minBox, maxBox); - if (dist1 < maxParam) { - dgInt32 j = stack; - for (; j && (dist1 > distance[j - 1]); j--) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - stackPool[j] = node; - distance[j] = dist1; - stack++; - dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH); - } - } - - } else { - dgBroadPhaseTreeNode* const node = (dgBroadPhaseTreeNode*)me; - const dgBroadPhaseNode* const left = node->m_left; - dgAssert(left); - dgVector minBox(left->m_minBox - boxP1); - dgVector maxBox(left->m_maxBox - boxP0); - dgFloat32 dist1 = ray.BoxIntersect(minBox, maxBox); - if (dist1 < maxParam) { - dgInt32 j = stack; - for (; j && (dist1 > distance[j - 1]); j--) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - stackPool[j] = left; - distance[j] = dist1; - stack++; - dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH); - } - - const dgBroadPhaseNode* const right = node->m_right; - dgAssert(right); - minBox = right->m_minBox - boxP1; - maxBox = right->m_maxBox - boxP0; - dist1 = ray.BoxIntersect(minBox, maxBox); - if (dist1 < maxParam) { - dgInt32 j = stack; - for (; j && (dist1 > distance[j - 1]); j--) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - stackPool[j] = right; - distance[j] = dist1; - stack++; - dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH); - } - } - } - } - *param = maxParam; - return totalCount; -} - -dgInt32 dgBroadPhase::Collide(const dgBroadPhaseNode** stackPool, dgInt32* const ovelapStack, dgInt32 stack, const dgVector& boxP0, const dgVector& boxP1, dgCollisionInstance* const shape, const dgMatrix& matrix, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const -{ - dgTriplex points[DG_CONVEX_CAST_POOLSIZE]; - dgTriplex normals[DG_CONVEX_CAST_POOLSIZE]; - dgFloat32 penetration[DG_CONVEX_CAST_POOLSIZE]; - dgInt64 attributeA[DG_CONVEX_CAST_POOLSIZE]; - dgInt64 attributeB[DG_CONVEX_CAST_POOLSIZE]; - - dgInt32 totalCount = 0; - while (stack) { - stack--; - - dgInt32 test = ovelapStack[stack]; - if (test) { - const dgBroadPhaseNode* const me = stackPool[stack]; - - dgBody* const body = me->GetBody(); - if (body) { - if (!body->m_isdead && !PREFILTER_RAYCAST(prefilter, body, body->m_collision, userData)) { - dgInt32 count = m_world->Collide(shape, matrix, body->m_collision, body->m_matrix, points, normals, penetration, attributeA, attributeB, DG_CONVEX_CAST_POOLSIZE, threadIndex); - - if (count) { - bool teminate = false; - if (count >= (maxContacts - totalCount)) { - count = maxContacts - totalCount; - teminate = true; - } - - for (dgInt32 i = 0; i < count; i++) { - info[totalCount].m_point[0] = points[i].m_x; - info[totalCount].m_point[1] = points[i].m_y; - info[totalCount].m_point[2] = points[i].m_z; - info[totalCount].m_point[3] = dgFloat32(0.0f); - info[totalCount].m_normal[0] = normals[i].m_x; - info[totalCount].m_normal[1] = normals[i].m_y; - info[totalCount].m_normal[2] = normals[i].m_z; - info[totalCount].m_normal[3] = dgFloat32(0.0f); - info[totalCount].m_penetration = penetration[i]; - info[totalCount].m_contaID = attributeB[i]; - info[totalCount].m_hitBody = body; - totalCount++; - } - - if (teminate) { - break; - } - } - } - } else if (me->IsAggregate()) { - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*)me; - const dgBroadPhaseNode* const node = aggregate->m_root; - if (node) { - stackPool[stack] = node; - ovelapStack[stack] = dgOverlapTest(node->m_minBox, node->m_maxBox, boxP0, boxP1); - stack++; - dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH); - } - - } else { - dgBroadPhaseTreeNode* const node = (dgBroadPhaseTreeNode*)me; - const dgBroadPhaseNode* const left = node->m_left; - stackPool[stack] = left; - ovelapStack[stack] = dgOverlapTest(left->m_minBox, left->m_maxBox, boxP0, boxP1); - stack ++; - dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH); - - const dgBroadPhaseNode* const right = node->m_right; - stackPool[stack] = right; - ovelapStack[stack] = dgOverlapTest(right->m_minBox, right->m_maxBox, boxP0, boxP1); - stack++; - dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH); - } - } - } - return totalCount; -} - -void dgBroadPhase::RayCast(const dgBroadPhaseNode** stackPool, dgFloat32* const distance, dgInt32 stack, const dgVector& l0, const dgVector& l1, dgFastRayTest& ray, OnRayCastAction filter, OnRayPrecastAction prefilter, void* const userData) const -{ - dgLineBox line; - line.m_l0 = l0; - line.m_l1 = l1; - dgVector test(line.m_l0 <= line.m_l1); - - dgFloat32 maxParam = dgFloat32 (1.2f); - - //line.m_boxL0 = (line.m_l0 & test) | line.m_l1.AndNot(test); - //line.m_boxL1 = (line.m_l1 & test) | line.m_l0.AndNot(test); - line.m_boxL0 = line.m_l1.Select(line.m_l0, test); - line.m_boxL1 = line.m_l0.Select(line.m_l1, test); - - while (stack) { - stack--; - dgFloat32 dist = distance[stack]; - if (dist > maxParam) { - break; - } else { - const dgBroadPhaseNode* const me = stackPool[stack]; - dgAssert(me); - dgBody* const body = me->GetBody(); - if (body) { - if (!body->m_isdead) { - dgAssert(!me->GetLeft()); - dgAssert(!me->GetRight()); - dgFloat32 param = body->RayCast(line, filter, prefilter, userData, maxParam); - if (param < maxParam) { - maxParam = param; - if (maxParam < dgFloat32(1.0e-8f)) { - break; - } - } - } - } else if (me->IsAggregate()) { - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*) me; - if (aggregate->m_root) { - const dgBroadPhaseNode* const child = aggregate->m_root; - dgAssert(child); - dgFloat32 dist1 = ray.BoxIntersect(child->m_minBox, child->m_maxBox); - if (dist1 < maxParam) { - dgInt32 j = stack; - for (; j && (dist1 > distance[j - 1]); j--) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - stackPool[j] = child; - distance[j] = dist1; - stack++; - dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH); - } - } - } else { - const dgBroadPhaseNode* const left = me->GetLeft(); - dgAssert(left); - dgFloat32 dist1 = ray.BoxIntersect(left->m_minBox, left->m_maxBox); - if (dist1 < maxParam) { - dgInt32 j = stack; - for (; j && (dist1 > distance[j - 1]); j--) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - stackPool[j] = left; - distance[j] = dist1; - stack++; - dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH); - } - - const dgBroadPhaseNode* const right = me->GetRight(); - dgAssert(right); - dist1 = ray.BoxIntersect(right->m_minBox, right->m_maxBox); - if (dist1 < maxParam) { - dgInt32 j = stack; - for (; j && (dist1 > distance[j - 1]); j--) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - stackPool[j] = right; - distance[j] = dist1; - stack++; - dgAssert(stack < DG_BROADPHASE_MAX_STACK_DEPTH); - } - } - } - } -} - -void dgBroadPhase::CollisionChange (dgBody* const body, dgCollisionInstance* const collision) -{ - dgCollisionInstance* const bodyCollision = body->GetCollision(); - if (bodyCollision) { - if (bodyCollision->IsType (dgCollision::dgCollisionNull_RTTI) && !collision->IsType (dgCollision::dgCollisionNull_RTTI)) { - dgAssert (!body->GetBroadPhase()); - body->m_collision = m_world->m_pointCollision; - Add (body); - body->m_collision = bodyCollision; - } else if (!bodyCollision->IsType (dgCollision::dgCollisionNull_RTTI) && collision->IsType (dgCollision::dgCollisionNull_RTTI)) { - Remove(body); - } - } -} - -void dgBroadPhase::UpdateBody(dgBody* const body, dgInt32 threadIndex) -{ - if (m_rootNode && body->m_masterNode) { - dgBroadPhaseBodyNode* const node = body->GetBroadPhase(); - dgBody* const body1 = node->GetBody(); - dgAssert(body1 == body); - dgAssert(!body1->m_equilibrium); - dgAssert(!node->GetLeft()); - dgAssert(!node->GetRight()); - dgAssert(!body1->GetCollision()->IsType(dgCollision::dgCollisionNull_RTTI)); - - if (body1->GetBroadPhaseAggregate()) { - dgBroadPhaseAggregate* const aggregate = body1->GetBroadPhaseAggregate(); - dgScopeSpinPause lock(&aggregate->m_criticalSectionLock); - aggregate->m_isInEquilibrium = body1->m_equilibrium; - } - - if (!dgBoxInclusionTest(body1->m_minAABB, body1->m_maxAABB, node->m_minBox, node->m_maxBox)) { - dgAssert(!node->IsAggregate()); - node->SetAABB(body1->m_minAABB, body1->m_maxAABB); - - if (!m_rootNode->IsLeafNode()) { - const dgBroadPhaseNode* const root = (m_rootNode->GetLeft() && m_rootNode->GetRight()) ? NULL : m_rootNode; - for (dgBroadPhaseNode* parent = node->m_parent; parent != root; parent = parent->m_parent) { - dgScopeSpinPause lock(&parent->m_criticalSectionLock); - if (!parent->IsAggregate()) { - dgVector minBox; - dgVector maxBox; - dgFloat32 area = CalculateSurfaceArea(parent->GetLeft(), parent->GetRight(), minBox, maxBox); - if (dgBoxInclusionTest(minBox, maxBox, parent->m_minBox, parent->m_maxBox)) { - break; - } - parent->m_minBox = minBox; - parent->m_maxBox = maxBox; - parent->m_surfaceArea = area; - } else { - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*)parent; - aggregate->m_minBox = aggregate->m_root->m_minBox; - aggregate->m_maxBox = aggregate->m_root->m_maxBox; - aggregate->m_surfaceArea = aggregate->m_root->m_surfaceArea; - } - } - } - } - } -} - -dgBroadPhaseNode* dgBroadPhase::BuildTopDown(dgBroadPhaseNode** const leafArray, dgInt32 firstBox, dgInt32 lastBox, dgFitnessList::dgListNode** const nextNode) -{ - dgAssert(firstBox >= 0); - dgAssert(lastBox >= 0); - - if (lastBox == firstBox) { - return leafArray[firstBox]; - } else { - dgSpliteInfo info(&leafArray[firstBox], lastBox - firstBox + 1); - - dgBroadPhaseTreeNode* const parent = (*nextNode)->GetInfo(); - parent->m_parent = NULL; - *nextNode = (*nextNode)->GetNext(); - - parent->SetAABB(info.m_p0, info.m_p1); - - parent->m_left = BuildTopDown(leafArray, firstBox, firstBox + info.m_axis - 1, nextNode); - parent->m_left->m_parent = parent; - - parent->m_right = BuildTopDown(leafArray, firstBox + info.m_axis, lastBox, nextNode); - parent->m_right->m_parent = parent; - return parent; - } -} - - -dgBroadPhaseNode* dgBroadPhase::BuildTopDownBig(dgBroadPhaseNode** const leafArray, dgInt32 firstBox, dgInt32 lastBox, dgFitnessList::dgListNode** const nextNode) -{ - if (lastBox == firstBox) { - return BuildTopDown(leafArray, firstBox, lastBox, nextNode); - } - - dgInt32 midPoint = -1; - const dgFloat32 scale = dgFloat32 (1.0f / 64.0f); - const dgBroadPhaseNode* const node0 = leafArray[firstBox]; - const dgInt32 count = lastBox - firstBox; - dgFloat32 area0 = scale * node0->m_surfaceArea; - for (dgInt32 i = 1; i <= count; i++) { - const dgBroadPhaseNode* const node1 = leafArray[firstBox + i]; - dgFloat32 area1 = node1->m_surfaceArea; - if (area0 > area1) { - midPoint = i - 1; - break; - } - } - - if (midPoint == -1) { - return BuildTopDown(leafArray, firstBox, lastBox, nextNode); - } else { - dgBroadPhaseTreeNode* const parent = (*nextNode)->GetInfo(); - - parent->m_parent = NULL; - *nextNode = (*nextNode)->GetNext(); - - parent->m_right = BuildTopDown(leafArray, firstBox, firstBox + midPoint, nextNode); - parent->m_right->m_parent = parent; - - parent->m_left = BuildTopDownBig(leafArray, firstBox + midPoint + 1, lastBox, nextNode); - parent->m_left->m_parent = parent; - - dgVector minP (parent->m_left->m_minBox.GetMin(parent->m_right->m_minBox)); - dgVector maxP (parent->m_left->m_maxBox.GetMax(parent->m_right->m_maxBox)); - parent->SetAABB(minP, maxP); - - return parent; - } -} - - -dgInt32 dgBroadPhase::CompareNodes(const dgBroadPhaseNode* const nodeA, const dgBroadPhaseNode* const nodeB, void* const) -{ - dgFloat32 areaA = nodeA->m_surfaceArea; - dgFloat32 areaB = nodeB->m_surfaceArea; - if (areaA < areaB) { - return 1; - } - if (areaA > areaB) { - return -1; - } - return 0; -} - - -void dgBroadPhase::ImproveFitness(dgFitnessList& fitness, dgFloat64& oldEntropy, dgBroadPhaseNode** const root) -{ - if (*root) { - DG_TRACKTIME(); - dgBroadPhaseNode* const parent = (*root)->m_parent; - (*root)->m_parent = NULL; - dgFloat64 entropy = CalculateEntropy(fitness, root); - - if ((entropy > oldEntropy * dgFloat32(1.5f)) || (entropy < oldEntropy * dgFloat32(0.75f))) { - if (fitness.GetFirst()) { - m_world->m_solverJacobiansMemory.ResizeIfNecessary ((fitness.GetCount() * 2 + 16) * sizeof (dgBroadPhaseNode*)); - dgBroadPhaseNode** const leafArray = (dgBroadPhaseNode**)&m_world->m_solverJacobiansMemory[0]; - - dgInt32 leafNodesCount = 0; - for (dgFitnessList::dgListNode* nodePtr = fitness.GetFirst(); nodePtr; nodePtr = nodePtr->GetNext()) { - dgBroadPhaseNode* const node = nodePtr->GetInfo(); - dgBroadPhaseNode* const leftNode = node->GetLeft(); - dgBody* const leftBody = leftNode->GetBody(); - if (leftBody) { - node->SetAABB(leftBody->m_minAABB, leftBody->m_maxAABB); - leafArray[leafNodesCount] = leftNode; - leafNodesCount++; - } else if (leftNode->IsAggregate()) { - leafArray[leafNodesCount] = leftNode; - leafNodesCount++; - } - dgBroadPhaseNode* const rightNode = node->GetRight(); - dgBody* const rightBody = rightNode->GetBody(); - if (rightBody) { - rightNode->SetAABB(rightBody->m_minAABB, rightBody->m_maxAABB); - leafArray[leafNodesCount] = rightNode; - leafNodesCount++; - } else if (rightNode->IsAggregate()) { - leafArray[leafNodesCount] = rightNode; - leafNodesCount++; - } - } - - dgFitnessList::dgListNode* nodePtr = fitness.GetFirst(); - - dgSortIndirect(leafArray, leafNodesCount, CompareNodes); - *root = BuildTopDownBig(leafArray, 0, leafNodesCount - 1, &nodePtr); - dgAssert(!(*root)->m_parent); - //entropy = CalculateEntropy(fitness, root); - entropy = fitness.TotalCost(); - fitness.m_prevCost = entropy; - } - oldEntropy = entropy; - } - (*root)->m_parent = parent; - } -} - - -void dgBroadPhase::RotateLeft (dgBroadPhaseTreeNode* const node, dgBroadPhaseNode** const root) -{ - dgVector cost1P0; - dgVector cost1P1; - - dgBroadPhaseTreeNode* const parent = (dgBroadPhaseTreeNode*)node->m_parent; - dgAssert(parent && !parent->IsLeafNode()); - dgFloat32 cost1 = CalculateSurfaceArea(node->m_left, parent->m_left, cost1P0, cost1P1); - - dgVector cost2P0; - dgVector cost2P1; - dgFloat32 cost2 = CalculateSurfaceArea(node->m_right, parent->m_left, cost2P0, cost2P1); - - dgFloat32 cost0 = node->m_surfaceArea; - if ((cost1 <= cost0) && (cost1 <= cost2)) { - //dgBroadPhaseNode* const parent = node->m_parent; - node->m_minBox = parent->m_minBox; - node->m_maxBox = parent->m_maxBox; - node->m_surfaceArea = parent->m_surfaceArea; - - dgBroadPhaseTreeNode* const grandParent = (dgBroadPhaseTreeNode*) parent->m_parent; - if (grandParent) { - if (grandParent->m_left == parent) { - grandParent->m_left = node; - } else { - dgAssert(grandParent->m_right == parent); - grandParent->m_right = node; - } - } else { - (*root) = node; - } - - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_left->m_parent = parent; - parent->m_right = node->m_left; - node->m_left = parent; - - parent->m_minBox = cost1P0; - parent->m_maxBox = cost1P1; - parent->m_surfaceArea = cost1; - - } else if ((cost2 <= cost0) && (cost2 <= cost1)) { - //dgBroadPhaseNode* const parent = node->m_parent; - node->m_minBox = parent->m_minBox; - node->m_maxBox = parent->m_maxBox; - node->m_surfaceArea = parent->m_surfaceArea; - - dgBroadPhaseTreeNode* const grandParent = (dgBroadPhaseTreeNode*) parent->m_parent; - if (grandParent) { - if (grandParent->m_left == parent) { - grandParent->m_left = node; - } else { - dgAssert(grandParent->m_right == parent); - grandParent->m_right = node; - } - } else { - (*root) = node; - } - - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_right->m_parent = parent; - parent->m_right = node->m_right; - node->m_right = parent; - - parent->m_minBox = cost2P0; - parent->m_maxBox = cost2P1; - parent->m_surfaceArea = cost2; - } -} - -void dgBroadPhase::RotateRight (dgBroadPhaseTreeNode* const node, dgBroadPhaseNode** const root) -{ - dgVector cost1P0; - dgVector cost1P1; - - dgBroadPhaseTreeNode* const parent = (dgBroadPhaseTreeNode*) node->m_parent; - dgAssert (parent && !parent->IsLeafNode()); - - dgFloat32 cost1 = CalculateSurfaceArea(node->m_right, parent->m_right, cost1P0, cost1P1); - - dgVector cost2P0; - dgVector cost2P1; - dgFloat32 cost2 = CalculateSurfaceArea(node->m_left, parent->m_right, cost2P0, cost2P1); - - dgFloat32 cost0 = node->m_surfaceArea; - if ((cost1 <= cost0) && (cost1 <= cost2)) { - //dgBroadPhaseNode* const parent = node->m_parent; - node->m_minBox = parent->m_minBox; - node->m_maxBox = parent->m_maxBox; - node->m_surfaceArea = parent->m_surfaceArea; - - dgBroadPhaseTreeNode* const grandParent = (dgBroadPhaseTreeNode*) parent->m_parent; - if (grandParent) { - dgAssert (!grandParent->IsLeafNode()); - if (grandParent->m_left == parent) { - grandParent->m_left = node; - } else { - dgAssert(grandParent->m_right == parent); - grandParent->m_right = node; - } - } else { - (*root) = node; - } - - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_right->m_parent = parent; - parent->m_left = node->m_right; - node->m_right = parent; - parent->m_minBox = cost1P0; - parent->m_maxBox = cost1P1; - parent->m_surfaceArea = cost1; - - } else if ((cost2 <= cost0) && (cost2 <= cost1)) { - //dgBroadPhaseNode* const parent = node->m_parent; - node->m_minBox = parent->m_minBox; - node->m_maxBox = parent->m_maxBox; - node->m_surfaceArea = parent->m_surfaceArea; - - dgBroadPhaseTreeNode* const grandParent = (dgBroadPhaseTreeNode*) parent->m_parent; - if (parent->m_parent) { - if (grandParent->m_left == parent) { - grandParent->m_left = node; - } else { - dgAssert(grandParent->m_right == parent); - grandParent->m_right = node; - } - } else { - (*root) = node; - } - - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_left->m_parent = parent; - parent->m_left = node->m_left; - node->m_left = parent; - - parent->m_minBox = cost2P0; - parent->m_maxBox = cost2P1; - parent->m_surfaceArea = cost2; - } -} - -DG_INLINE bool dgBroadPhase::ValidateContactCache(dgContact* const contact, const dgVector& timestep) const -{ - dgAssert(contact && (contact->GetId() == dgConstraint::m_contactConstraint)); - - dgBody* const body0 = contact->GetBody0(); - dgBody* const body1 = contact->GetBody1(); - if (!contact->m_material->m_contactGeneration) { - dgVector positStep(timestep * (body0->m_veloc - body1->m_veloc)); - positStep = ((positStep.DotProduct(positStep)) > m_velocTol) & positStep; - contact->m_positAcc += positStep; - - dgVector positError2(contact->m_positAcc.DotProduct(contact->m_positAcc)); - if ((positError2 < m_linearContactError2).GetSignMask()) { - dgVector rotationStep(timestep * (body0->m_omega - body1->m_omega)); - rotationStep = ((rotationStep.DotProduct(rotationStep)) > m_velocTol) & rotationStep; - contact->m_rotationAcc = contact->m_rotationAcc * dgQuaternion(dgFloat32(1.0f), rotationStep.m_x, rotationStep.m_y, rotationStep.m_z); - - dgVector angle(contact->m_rotationAcc.m_x, contact->m_rotationAcc.m_y, contact->m_rotationAcc.m_z, dgFloat32(0.0f)); - dgVector rotatError2(angle.DotProduct(angle)); - if ((rotatError2 < m_angularContactError2).GetSignMask()) { - return true; - } - } - } - return false; -} - -void dgBroadPhase::CalculatePairContacts (dgPair* const pair, dgInt32 threadID) -{ - dgContactPoint contacts[DG_MAX_CONTATCS]; - - pair->m_cacheIsValid = false; - pair->m_contactBuffer = contacts; - m_world->CalculateContacts(pair, threadID, false, false); - - if (pair->m_contactCount) { - dgAssert(pair->m_contactCount <= (DG_CONSTRAINT_MAX_ROWS / 3)); - m_world->ProcessContacts(pair, threadID); - KinematicBodyActivation(pair->m_contact); - } else { - if (pair->m_cacheIsValid) { - KinematicBodyActivation(pair->m_contact); - } else { - pair->m_contact->m_maxDOF = 0; - } - } -} - -void dgBroadPhase::AddPair (dgContact* const contact, dgFloat32 timestep, dgInt32 threadIndex) -{ - //DG_TRACKTIME(); - dgWorld* const world = (dgWorld*) m_world; - dgBody* const body0 = contact->m_body0; - dgBody* const body1 = contact->m_body1; - - dgAssert (body0 != m_world->m_sentinelBody); - dgAssert (body1 != m_world->m_sentinelBody); - dgAssert (contact->GetId() == dgConstraint::m_contactConstraint); - dgAssert (body0->GetWorld()); - dgAssert (body1->GetWorld()); - dgAssert (body0->GetWorld() == world); - dgAssert (body1->GetWorld() == world); - if (!(body0->m_collideWithLinkedBodies & body1->m_collideWithLinkedBodies)) { - if (world->AreBodyConnectedByJoints (body0, body1)) { - return; - } - } - - const dgContactMaterial* const material = contact->m_material; - if (material->m_flags & dgContactMaterial::m_collisionEnable) { - dgInt32 processContacts = 1; - if (material->m_aabbOverlap) { - processContacts = material->m_aabbOverlap(*contact, timestep, threadIndex); - } - if (processContacts) { - dgPair pair; - dgAssert (!body0->m_collision->IsType (dgCollision::dgCollisionNull_RTTI)); - dgAssert (!body1->m_collision->IsType (dgCollision::dgCollisionNull_RTTI)); - - pair.m_contact = contact; - pair.m_timestep = timestep; - CalculatePairContacts (&pair, threadIndex); - } - } -} - -bool dgBroadPhase::TestOverlaping(const dgBody* const body0, const dgBody* const body1, dgFloat32 timestep) const -{ - bool mass0 = (body0->m_invMass.m_w != dgFloat32(0.0f)); - bool mass1 = (body1->m_invMass.m_w != dgFloat32(0.0f)); - bool isDynamic0 = body0->IsRTTIType(dgBody::m_dynamicBodyRTTI) != 0; - bool isDynamic1 = body1->IsRTTIType(dgBody::m_dynamicBodyRTTI) != 0; - bool isKinematic0 = body0->IsRTTIType(dgBody::m_kinematicBodyRTTI) != 0; - bool isKinematic1 = body1->IsRTTIType(dgBody::m_kinematicBodyRTTI) != 0; - - dgAssert(!body0->GetCollision()->IsType(dgCollision::dgCollisionNull_RTTI)); - dgAssert(!body1->GetCollision()->IsType(dgCollision::dgCollisionNull_RTTI)); - - const dgBroadPhaseAggregate* const agreggate0 = body0->GetBroadPhaseAggregate(); - const dgBroadPhaseAggregate* const agreggate1 = body1->GetBroadPhaseAggregate(); - - bool tier1 = true; - bool tier2 = !(body0->m_sleeping & body1->m_sleeping); - bool tier3 = (agreggate0 != agreggate1) || !agreggate0 || (agreggate0 && agreggate0->GetSelfCollision()); - bool tier4 = isDynamic0 & mass0; - bool tier5 = isDynamic1 & mass1; - bool tier6 = isKinematic0 & mass1; - bool tier7 = isKinematic1 & mass0; - bool ret = tier1 & tier2 & tier3 & (tier4 | tier5 | tier6 | tier7); - - if (ret) { - const dgCollisionInstance* const instance0 = body0->GetCollision(); - const dgCollisionInstance* const instance1 = body1->GetCollision(); - - if (body0->m_continueCollisionMode | body1->m_continueCollisionMode) { - dgVector velRelative(body1->GetVelocity() - body0->GetVelocity()); - if (velRelative.DotProduct(velRelative).GetScalar() > dgFloat32(0.25f)) { - dgVector box0_p0; - dgVector box0_p1; - dgVector box1_p0; - dgVector box1_p1; - - instance0->CalcAABB(instance0->GetGlobalMatrix(), box0_p0, box0_p1); - instance1->CalcAABB(instance1->GetGlobalMatrix(), box1_p0, box1_p1); - - dgVector boxp0(box0_p0 - box1_p1); - dgVector boxp1(box0_p1 - box1_p0); - dgFastRayTest ray(dgVector::m_zero, velRelative.Scale(timestep * dgFloat32(4.0f))); - dgFloat32 distance = ray.BoxIntersect(boxp0, boxp1); - ret = (distance < dgFloat32(1.0f)); - } else { - ret = dgOverlapTest(body0->m_minAABB, body0->m_maxAABB, body1->m_minAABB, body1->m_maxAABB) ? 1 : 0; - } - } else { - ret = dgOverlapTest(body0->m_minAABB, body0->m_maxAABB, body1->m_minAABB, body1->m_maxAABB) ? 1 : 0; - } - } - return ret; -} - -void dgBroadPhase::AddPair (dgBody* const body0, dgBody* const body1, const dgFloat32 timestep, dgInt32 threadID) -{ - dgAssert(body0); - dgAssert(body1); - const bool test = TestOverlaping (body0, body1, timestep); - if (test) { - dgContact* contact = m_contactCache.FindContactJoint(body0, body1); - if (!contact) { - const dgBilateralConstraint* const bilateral = m_world->FindBilateralJoint (body0, body1); - const bool isCollidable = bilateral ? bilateral->IsCollidable() : true; - - if (isCollidable) { - dgUnsigned32 group0_ID = dgUnsigned32 (body0->m_bodyGroupId); - dgUnsigned32 group1_ID = dgUnsigned32 (body1->m_bodyGroupId); - - if (group1_ID < group0_ID) { - dgSwap (group0_ID, group1_ID); - } - - dgUnsigned32 key = (group1_ID << 16) + group0_ID; - const dgBodyMaterialList* const materialList = m_world; - dgAssert (materialList->Find (key)); - const dgContactMaterial* const material = &materialList->Find (key)->GetInfo(); - - if (material->m_flags & dgContactMaterial::m_collisionEnable) { - - dgInt32 isBody0Kinematic = body0->IsRTTIType(dgBody::m_kinematicBodyRTTI); - dgInt32 isBody1Kinematic = body1->IsRTTIType(dgBody::m_kinematicBodyRTTI); - - const dgInt32 kinematicTest = !((isBody0Kinematic && isBody1Kinematic) || ((isBody0Kinematic && body0->IsCollidable()) || (isBody1Kinematic && body1->IsCollidable()))); - const dgInt32 collisionTest = kinematicTest && !(body0->m_isdead | body1->m_isdead) && !(body0->m_equilibrium & body1->m_equilibrium); - if (collisionTest) { - const dgInt32 isSofBody0 = body0->m_collision->IsType(dgCollision::dgCollisionLumpedMass_RTTI); - const dgInt32 isSofBody1 = body1->m_collision->IsType(dgCollision::dgCollisionLumpedMass_RTTI); - - if (isSofBody0 || isSofBody1) { - m_pendingSoftBodyCollisions[m_pendingSoftBodyPairsCount].m_body0 = body0; - m_pendingSoftBodyCollisions[m_pendingSoftBodyPairsCount].m_body1 = body1; - m_pendingSoftBodyPairsCount++; - } else { - dgContactList& contactList = *m_world; - dgAtomicExchangeAndAdd(&contactList.m_contactCountReset, 1); - if (contactList.m_contactCount < contactList.GetElementsCapacity()) { - contact = new (m_world->m_allocator) dgContact(m_world, material, body0, body1); - dgAssert(contact); - contactList.Push(contact); - } - } - } - } - } - } - } -} - -void dgBroadPhase::FindGeneratedBodiesCollidingPairs(dgBroadphaseSyncDescriptor* const descriptor, dgInt32 threadID) -{ -dgAssert (0); -/* - dgList<dgBody*>::dgListNode* node = NULL; - { - dgThreadHiveScopeLock lock(m_world, &m_criticalSectionLock, false); - node = descriptor->m_newBodiesNodes; - if (node) { - descriptor->m_newBodiesNodes = node->GetNext(); - } - } - - dgVector timestep2(descriptor->m_timestep * descriptor->m_timestep * dgFloat32(4.0f)); - while (node) { - dgBody* const body = node->GetInfo(); - dgBroadPhaseNode* const breadPhaseNode = body->GetBroadPhase(); - if (breadPhaseNode) { - if (!body->m_collision->IsType(dgCollision::dgCollisionNull_RTTI)) { - for (dgBroadPhaseNode* ptr = breadPhaseNode; ptr->m_parent; ptr = ptr->m_parent) { - dgBroadPhaseNode* const sibling = ptr->m_parent->m_right; - if (sibling != ptr) { - dgAssert(0); - //SubmitPairs (bodyNode, sibling, timestep2, threadID); - } - else { - dgAssert(0); - //dgNode* const sibling = ptr->m_parent->m_left; - //dgAssert (sibling); - //dgAssert (sibling != ptr); - //dgAssert (0); - //SubmitPairs (bodyNode, sibling, timestep2, threadID); - } - } - } - } - - dgThreadHiveScopeLock lock(m_world, &m_criticalSectionLock, false); - node = descriptor->m_newBodiesNodes; - if (node) { - descriptor->m_newBodiesNodes = node->GetNext(); - } - } -*/ -} - - -void dgBroadPhase::SubmitPairs(dgBroadPhaseNode* const leafNode, dgBroadPhaseNode* const node, dgFloat32 timestep, dgInt32 threadCount, dgInt32 threadID) -{ - dgBroadPhaseNode* pool[DG_BROADPHASE_MAX_STACK_DEPTH]; - pool[0] = node; - dgInt32 stack = 1; - - dgAssert (leafNode->IsLeafNode()); - dgBody* const body0 = leafNode->GetBody(); - - const dgVector boxP0 (body0 ? body0->m_minAABB : leafNode->m_minBox); - const dgVector boxP1 (body0 ? body0->m_maxAABB : leafNode->m_maxBox); - - const bool test0 = body0 ? (body0->GetInvMass().m_w != dgFloat32(0.0f)) : true; - - while (stack) { - stack--; - dgBroadPhaseNode* const rootNode = pool[stack]; - if (dgOverlapTest(rootNode->m_minBox, rootNode->m_maxBox, boxP0, boxP1)) { - if (rootNode->IsLeafNode()) { - dgAssert(!rootNode->GetRight()); - dgAssert(!rootNode->GetLeft()); - dgBody* const body1 = rootNode->GetBody(); - if (body0) { - if (body1) { - if (test0 || (body1->GetInvMass().m_w != dgFloat32(0.0f))) { - AddPair(body0, body1, timestep, threadID); - } - } else { - dgAssert (rootNode->IsAggregate()); - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*) rootNode; - aggregate->SummitPairs(body0, timestep, threadID); - } - } else { - dgAssert (leafNode->IsAggregate()); - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*) leafNode; - if (body1) { - aggregate->SummitPairs(body1, timestep, threadID); - } else { - dgAssert (rootNode->IsAggregate()); - aggregate->SummitPairs((dgBroadPhaseAggregate*) rootNode, timestep, threadID); - } - } - } else { - dgBroadPhaseTreeNode* const tmpNode = (dgBroadPhaseTreeNode*) rootNode; - dgAssert (tmpNode->m_left); - dgAssert (tmpNode->m_right); - - pool[stack] = tmpNode->m_left; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - - pool[stack] = tmpNode->m_right; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - } - } - } -} - -void dgBroadPhase::ImproveNodeFitness(dgBroadPhaseTreeNode* const node, dgBroadPhaseNode** const root) -{ - dgAssert(node->GetLeft()); - dgAssert(node->GetRight()); - - dgBroadPhaseNode* const parent = node->m_parent; - if (parent && parent->m_parent) { - dgAssert (!parent->IsLeafNode()); - if (parent->GetLeft() == node) { - RotateRight(node, root); - } else { - RotateLeft(node, root); - } - } - dgAssert(!m_rootNode->m_parent); -} - -dgFloat64 dgBroadPhase::CalculateEntropy (dgFitnessList& fitness, dgBroadPhaseNode** const root) -{ - DG_TRACKTIME(); -#if 0 - dgFloat64 cost0 = fitness.TotalCost(); - dgFloat64 cost1 = cost0; - do { - cost0 = cost1; - for (dgFitnessList::dgListNode* node = fitness.GetFirst(); node; node = node->GetNext()) { - ImproveNodeFitness(node->GetInfo(), root); - } - cost1 = fitness.TotalCost(); - } while (cost1 < (dgFloat32(0.99f)) * cost0); - return cost1; -#else - dgFloat64 cost = dgFloat32 (0.0f); - if (fitness.GetCount() < 32) { - for (dgFitnessList::dgListNode* node = fitness.GetFirst(); node; node = node->GetNext()) { - ImproveNodeFitness(node->GetInfo(), root); - } - cost = fitness.TotalCost(); - fitness.m_prevCost = cost; - } else { - const dgInt32 mod = 16; - cost = fitness.m_prevCost; - dgFitnessList::dgListNode* node = fitness.GetFirst(); - for (dgInt32 i = 0; i < fitness.m_index; i++) { - node = node->GetNext(); - } - - do { - ImproveNodeFitness(node->GetInfo(), root); - for (dgInt32 i = 0; i < mod; i++) { - node = node ? node->GetNext() : NULL; - } - } while (node); - - if (!fitness.m_index) { - cost = fitness.TotalCost(); - fitness.m_prevCost = cost; - } - fitness.m_index = (fitness.m_index + 1) % mod; - } - return cost; -#endif -} - -void dgBroadPhase::KinematicBodyActivation (dgContact* const contatJoint) const -{ - dgBody* const body0 = contatJoint->GetBody0(); - dgBody* const body1 = contatJoint->GetBody1(); - if (body0->IsCollidable() | body1->IsCollidable()) { - if (body0->IsRTTIType(dgBody::m_kinematicBodyRTTI)) { - if (body1->IsRTTIType(dgBody::m_dynamicBodyRTTI) && (body1->GetInvMass().m_w > dgFloat32 (0.0f))) { - if (body1->m_equilibrium) { - dgVector relVeloc (body0->m_veloc - body1->m_veloc); - dgVector relOmega (body0->m_omega - body1->m_omega); - dgVector mask2 ((relVeloc.DotProduct(relVeloc) < dgDynamicBody::m_equilibriumError2) & (relOmega.DotProduct(relOmega) < dgDynamicBody::m_equilibriumError2)); - - dgScopeSpinPause lock(&body1->m_criticalSectionLock); - body1->m_sleeping = false; - body1->m_equilibrium = mask2.GetSignMask() ? true : false; - } - } - } else if (body1->IsRTTIType(dgBody::m_kinematicBodyRTTI)) { - if (body0->IsRTTIType(dgBody::m_dynamicBodyRTTI) && (body0->GetInvMass().m_w > dgFloat32 (0.0f))) { - if (body0->m_equilibrium) { - dgVector relVeloc (body0->m_veloc - body1->m_veloc); - dgVector relOmega (body0->m_omega - body1->m_omega); - dgVector mask2 ((relVeloc.DotProduct(relVeloc) < dgDynamicBody::m_equilibriumError2) & (relOmega.DotProduct(relOmega) < dgDynamicBody::m_equilibriumError2)); - - dgScopeSpinPause lock(&body1->m_criticalSectionLock); - body0->m_sleeping = false; - body0->m_equilibrium = mask2.GetSignMask() ? true : false; - } - } - } - } -} - -void dgBroadPhase::CollidingPairsKernel(void* const context, void* const node, dgInt32 threadID) -{ - D_TRACKTIME(); - dgBroadphaseSyncDescriptor* const descriptor = (dgBroadphaseSyncDescriptor*)context; - dgWorld* const world = descriptor->m_world; - dgBroadPhase* const broadPhase = world->GetBroadPhase(); - broadPhase->FindCollidingPairs(descriptor, (dgList<dgBroadPhaseNode*>::dgListNode*) node, threadID); -} - -void dgBroadPhase::AddGeneratedBodiesContactsKernel (void* const context, void* const worldContext, dgInt32 threadID) -{ - D_TRACKTIME(); - dgBroadphaseSyncDescriptor* const descriptor = (dgBroadphaseSyncDescriptor*) context; - dgWorld* const world = (dgWorld*) worldContext; - dgBroadPhase* const broadPhase = world->GetBroadPhase(); - broadPhase->FindGeneratedBodiesCollidingPairs (descriptor, threadID); -} - -void dgBroadPhase::UpdateSoftBodyContactKernel(void* const context, void* const worldContext, dgInt32 threadID) -{ - D_TRACKTIME(); - dgBroadphaseSyncDescriptor* const descriptor = (dgBroadphaseSyncDescriptor*)context; - dgWorld* const world = descriptor->m_world; - dgBroadPhase* const broadPhase = world->GetBroadPhase(); - broadPhase->UpdateSoftBodyContacts(descriptor, descriptor->m_timestep, threadID); -} - -void dgBroadPhase::UpdateRigidBodyContactKernel(void* const context, void* const , dgInt32 threadID) -{ - D_TRACKTIME(); - dgBroadphaseSyncDescriptor* const descriptor = (dgBroadphaseSyncDescriptor*)context; - dgWorld* const world = descriptor->m_world; - dgBroadPhase* const broadPhase = world->GetBroadPhase(); - broadPhase->UpdateRigidBodyContacts(descriptor, descriptor->m_timestep, threadID); -} - -void dgBroadPhase::UpdateSoftBodyContacts(dgBroadphaseSyncDescriptor* const descriptor, dgFloat32 timeStep, dgInt32 threadID) -{ - dgAssert(0); -/* - const dgInt32 count = m_pendingSoftBodyPairsCount; - for (dgInt32 i = dgAtomicExchangeAndAdd(&descriptor->m_pairsAtomicCounter, 1); i < count; i = dgAtomicExchangeAndAdd(&descriptor->m_pairsAtomicCounter, 1)) { - dgPendingCollisionSoftBodies& pair = m_pendingSoftBodyCollisions[i]; - if (pair.m_body0->m_collision->IsType(dgCollision::dgCollisionLumpedMass_RTTI)) { - dgCollisionLumpedMassParticles* const lumpedMassShape = (dgCollisionLumpedMassParticles*)pair.m_body0->m_collision->GetChildShape(); - dgAssert(pair.m_body0->IsRTTIType(dgBody::m_dynamicBodyRTTI)); - dgAssert (pair.m_body0 == lumpedMassShape->GetOwner ()); - lumpedMassShape->RegisterCollision(pair.m_body1); - } else if (pair.m_body1->m_collision->IsType(dgCollision::dgCollisionLumpedMass_RTTI)) { - dgCollisionLumpedMassParticles* const lumpedMassShape = (dgCollisionLumpedMassParticles*)pair.m_body1->m_collision->GetChildShape(); - dgAssert(pair.m_body1->IsRTTIType(dgBody::m_dynamicBodyRTTI)); - dgAssert (pair.m_body1 == lumpedMassShape->GetOwner ()); - lumpedMassShape->RegisterCollision(pair.m_body0); - } - } -*/ -} - -void dgBroadPhase::UpdateRigidBodyContacts(dgBroadphaseSyncDescriptor* const descriptor, dgFloat32 timeStep, dgInt32 threadID) -{ - DG_TRACKTIME(); - - dgContactList& contactList = *m_world; - const dgFloat32 timestep = descriptor->m_timestep; - const dgInt32 threadCount = m_world->GetThreadCount(); - const dgUnsigned32 lru = m_lru - DG_CONTACT_DELAY_FRAMES; - - const dgInt32 contactCount = contactList.m_contactCount; - dgContact** const contactArray = &contactList[0]; - - dgVector deltaTime(timestep); - for (dgInt32 i = threadID; i < contactCount; i += threadCount) { - dgContact* const contact = contactArray[i]; - dgAssert (contact); - - dgBody* const body0 = contact->GetBody0(); - dgBody* const body1 = contact->GetBody1(); - - if (!(contact->m_killContact | (body0->m_equilibrium & body1->m_equilibrium))) { - dgAssert(!contact->m_killContact); - - bool isActive = contact->m_isActive; - if (ValidateContactCache(contact, deltaTime)) { - contact->m_broadphaseLru = m_lru; - contact->m_timeOfImpact = dgFloat32(1.0e10f); - } else { - contact->m_isActive = 0; - contact->m_positAcc = dgVector::m_zero; - contact->m_rotationAcc = dgQuaternion(); - - dgFloat32 distance = contact->m_separationDistance; - if (distance >= DG_NARROW_PHASE_DIST) { - const dgVector veloc0 (body0->GetVelocity()); - const dgVector veloc1 (body1->GetVelocity()); - - const dgVector veloc(veloc1 - veloc0); - const dgVector omega0 (body0->GetOmega()); - const dgVector omega1 (body1->GetOmega()); - const dgCollisionInstance* const collision0 = body0->GetCollision(); - const dgCollisionInstance* const collision1 = body1->GetCollision(); - const dgVector scale(dgFloat32(1.0f), dgFloat32(3.5f) * collision0->GetBoxMaxRadius(), dgFloat32(3.5f) * collision1->GetBoxMaxRadius(), dgFloat32(0.0f)); - const dgVector velocMag2(veloc.DotProduct(veloc).GetScalar(), omega0.DotProduct(omega0).GetScalar(), omega1.DotProduct(omega1).GetScalar(), dgFloat32(0.0f)); - const dgVector velocMag(velocMag2.GetMax(dgVector::m_epsilon).InvSqrt() * velocMag2 * scale); - const dgFloat32 speed = velocMag.AddHorizontal().GetScalar() + dgFloat32(0.5f); - - distance -= speed * timestep; - contact->m_separationDistance = distance; - } - if (distance < DG_NARROW_PHASE_DIST) { - AddPair(contact, timestep, threadID); - if (contact->m_maxDOF) { - contact->m_timeOfImpact = dgFloat32(1.0e10f); - } - contact->m_broadphaseLru = m_lru; - } else { - dgAssert (contact->m_maxDOF == 0); - const dgBroadPhaseNode* const bodyNode0 = contact->GetBody0()->m_broadPhaseNode; - const dgBroadPhaseNode* const bodyNode1 = contact->GetBody1()->m_broadPhaseNode; - if (dgOverlapTest(bodyNode0->m_minBox, bodyNode0->m_maxBox, bodyNode1->m_minBox, bodyNode1->m_maxBox)) { - contact->m_broadphaseLru = m_lru; - } else if (contact->m_broadphaseLru < lru) { - contact->m_killContact = 1; - } - } - } - - if (isActive ^ contact->m_isActive) { - if (body0->GetInvMass().m_w) { - body0->m_equilibrium = false; - } - if (body1->GetInvMass().m_w) { - body1->m_equilibrium = false; - } - } - - } else { - contact->m_broadphaseLru = m_lru; - } - - contact->m_killContact = contact->m_killContact | (body0->m_equilibrium & body1->m_equilibrium & !contact->m_isActive); - } -} - -bool dgBroadPhase::SanityCheck() const -{ -#ifdef _DEBUG - class dgKey - { - public: - dgKey (dgContact* const contact) - :m_low(dgMin (contact->GetBody0()->m_uniqueID, contact->GetBody1()->m_uniqueID)) - ,m_high(dgMax (contact->GetBody0()->m_uniqueID, contact->GetBody1()->m_uniqueID)) - { - } - - bool operator> (const dgKey& key) const - { - return m_key > key.m_key; - } - - bool operator< (const dgKey& key) const - { - return m_key < key.m_key; - } - - union - { - dgUnsigned64 m_key; - struct - { - dgInt32 m_low; - dgInt32 m_high; - }; - }; - }; - - dgTree<dgInt32, dgKey> filter (m_world->GetAllocator()); - - const dgContactList& contactList = *m_world; - for (dgInt32 i = contactList.m_contactCount - 1; i >= 0; i--) { - dgContact* const contact = contactList[i]; - dgAssert (!contact->m_killContact); - dgAssert (filter.Insert(0, dgKey(contact))); - } -#endif - return true; -} - -void dgBroadPhase::AttachNewContact(dgInt32 startCount) -{ - DG_TRACKTIME(); - dgContactList& contactList = *m_world; - if (contactList.m_contactCountReset > contactList.m_contactCount) { - contactList.Resize(contactList.GetElementsCapacity() * 2); - } - - dgContact** const contactArray = &contactList[0]; - for (dgInt32 i = contactList.m_contactCount - 1; i >= startCount; i--) { - dgContact* const contact = contactArray[i]; - if (m_contactCache.AddContactJoint(contact)) { - m_world->AttachContact(contact); - } else { - contactList.m_contactCount--; - contactArray[i] = contactList[contactList.m_contactCount]; - delete contact; - } - } -} - -void dgBroadPhase::DeleteDeadContact(dgFloat32 timestep) -{ - DG_TRACKTIME(); - dgInt32 activeCount = 0; - dgContactList& contactList = *m_world; - dgContact** const contactArray = &contactList[0]; - dgArray<dgJointInfo>& constraintArray = m_world->m_jointsMemory; - for (dgInt32 i = contactList.m_contactCount - 1; i >= 0; i--) { - dgContact* const contact = contactArray[i]; - if (contact->m_killContact) { - m_contactCache.RemoveContactJoint(contact); - m_world->RemoveContact(contact); - contactList.m_contactCount--; - contactArray[i] = contactList[contactList.m_contactCount]; - delete contact; - } else if (contact->m_isActive && contact->m_maxDOF){ - constraintArray[activeCount].m_joint = contact; - activeCount++; - } else if (contact->m_body0->m_continueCollisionMode | contact->m_body1->m_continueCollisionMode){ - if (contact->EstimateCCD(timestep)) { - constraintArray[activeCount].m_joint = contact; - activeCount++; - } - } - } - dgAssert(SanityCheck()); - contactList.m_activeContactCount = activeCount; - //dgTrace (("%d %d\n", contactList.m_activeContactCount, contactList.m_contactCount)); -} - -void dgBroadPhase::UpdateContacts(dgFloat32 timestep) -{ - D_TRACKTIME(); - m_lru = m_lru + 1; - m_pendingSoftBodyPairsCount = 0; - - const dgInt32 threadsCount = m_world->GetThreadCount(); - - const dgBodyMasterList* const masterList = m_world; - - m_world->m_bodiesMemory.ResizeIfNecessary(masterList->GetCount()); - dgBroadphaseSyncDescriptor syncPoints(timestep, m_world); - - dgBodyMasterList::dgListNode* node = masterList->GetFirst()->GetNext(); - for (dgInt32 i = 0; i < threadsCount; i++) { - m_world->QueueJob(ForceAndToqueKernel, &syncPoints, node, "dgBroadPhase::ForceAndToque"); - node = node ? node->GetNext() : NULL; - } - m_world->SynchronizationBarrier(); - - // update pre-listeners after the force and torque are applied - if (m_world->m_listeners.GetCount()) { - for (dgWorld::dgListenerList::dgListNode* node1 = m_world->m_listeners.GetFirst(); node1; node1 = node1->GetNext()) { - dgWorld::dgListener& listener = node1->GetInfo(); - if (listener.m_onPreUpdate) { - listener.m_onPreUpdate(m_world, listener.m_userData, timestep); - } - } - } - - // check for sleeping bodies states - node = masterList->GetFirst()->GetNext(); - for (dgInt32 i = 0; i < threadsCount; i++) { - m_world->QueueJob(SleepingStateKernel, &syncPoints, node, "dgBroadPhase::SleepingState"); - node = node ? node->GetNext() : NULL; - } - m_world->SynchronizationBarrier(); - - // this will move to an asynchronous thread - dgList<dgBroadPhaseAggregate*>::dgListNode* aggregateNode = m_aggregateList.GetFirst(); - for (dgInt32 i = 0; i < threadsCount; i++) { - m_world->QueueJob(UpdateAggregateEntropyKernel, &syncPoints, aggregateNode, "dgBroadPhase::UpdateAggregateEntropy"); - aggregateNode = aggregateNode ? aggregateNode->GetNext() : NULL; - } - m_world->SynchronizationBarrier(); - - UpdateFitness(); - - dgContactList& contactList = *m_world; - contactList.m_contactCountReset = contactList.m_contactCount; - syncPoints.m_contactStart = contactList.m_contactCount; - - syncPoints.m_fullScan = syncPoints.m_fullScan || (syncPoints.m_atomicPendingBodiesCount >= (syncPoints.m_atomicDynamicsCount / 2)); - dgList<dgBroadPhaseNode*>::dgListNode* broadPhaseNode = m_updateList.GetFirst(); - for (dgInt32 i = 0; i < threadsCount; i++) { - m_world->QueueJob(CollidingPairsKernel, &syncPoints, broadPhaseNode, "dgBroadPhase::CollidingPairs"); - broadPhaseNode = broadPhaseNode ? broadPhaseNode->GetNext() : NULL; - } - m_world->SynchronizationBarrier(); - - AttachNewContact(syncPoints.m_contactStart); - for (dgInt32 i = 0; i < threadsCount; i++) { - m_world->QueueJob(UpdateRigidBodyContactKernel, &syncPoints, NULL, "dgBroadPhase::UpdateRigidBodyContact"); - } - m_world->SynchronizationBarrier(); - - if (m_pendingSoftBodyPairsCount) { - dgAssert (0); - //for (dgInt32 i = 0; i < threadsCount; i++) { - // m_world->QueueJob(UpdateSoftBodyContactKernel, &syncPoints, contactListNode, "dgBroadPhase::UpdateSoftBodyContact"); - //} - //m_world->SynchronizationBarrier(); - } - - // m_recursiveChunks = false; - if (m_generatedBodies.GetCount()) { - dgAssert(0); - //syncPoints.m_newBodiesNodes = m_generatedBodies.GetFirst(); - //for (dgInt32 i = 0; i < threadsCount; i++) { - // m_world->QueueJob(AddGeneratedBodiesContactsKernel, &syncPoints, m_world); - //} - //m_world->SynchronizationBarrier(); - // - //for (dgInt32 i = 0; i < threadsCount; i++) { - // m_world->QueueJob(UpdateContactsKernel, &syncPoints, m_world); - //} - //m_world->SynchronizationBarrier(); - // - //m_generatedBodies.RemoveAll(); - } - - DeleteDeadContact(timestep); -} diff --git a/thirdparty/src/newton/dgPhysics/dgBroadPhase.h b/thirdparty/src/newton/dgPhysics/dgBroadPhase.h deleted file mode 100644 index 31e95404e..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBroadPhase.h +++ /dev/null @@ -1,603 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DG_BROADPHASE_H_ -#define __DG_BROADPHASE_H_ - -#include "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgBodyMasterList.h" - -class dgBody; -class dgWorld; -class dgContact; -class dgCollision; -class dgDynamicBody; -class dgCollisionInstance; -class dgBroadPhaseAggregate; - - -#define DG_CACHE_DIST_TOL dgFloat32 (1.0e-3f) -#define DG_BROADPHASE_MAX_STACK_DEPTH 256 - -class dgConvexCastReturnInfo -{ - public: - dgFloat32 m_point[4]; // collision point in global space - dgFloat32 m_normal[4]; // surface normal at collision point in global space - //dgFloat32 m_normalOnHitPoint[4]; // surface normal at the surface of the hit body, - // is the same as the normal calculate by a raycast passing by the hit point in the direction of the cast - dgInt64 m_contaID; // collision ID at contact point - const dgBody* m_hitBody; // body hit at contact point - dgFloat32 m_penetration; // contact penetration at collision point -}; - - -DG_MSC_VECTOR_ALIGNMENT -class dgBroadPhaseNode -{ - public: - DG_CLASS_ALLOCATOR(allocator) - dgBroadPhaseNode(dgBroadPhaseNode* const parent) - :m_minBox(dgFloat32(-1.0e15f)) - ,m_maxBox(dgFloat32(1.0e15f)) - ,m_parent(parent) - ,m_surfaceArea(dgFloat32(1.0e20f)) - ,m_criticalSectionLock(0) - { - } - - virtual ~dgBroadPhaseNode() - { - } - - virtual bool IsSegregatedRoot() const - { - return false; - } - - virtual bool IsLeafNode() const - { - return false; - } - - virtual bool IsAggregate() const - { - return false; - } - - void SetAABB(const dgVector& minBox, const dgVector& maxBox) - { - dgAssert(minBox.m_x <= maxBox.m_x); - dgAssert(minBox.m_y <= maxBox.m_y); - dgAssert(minBox.m_z <= maxBox.m_z); - - dgVector p0(minBox * m_broadPhaseScale); - dgVector p1(maxBox * m_broadPhaseScale + dgVector::m_one); - - m_minBox = p0.Floor() * m_broadInvPhaseScale; - m_maxBox = p1.Floor() * m_broadInvPhaseScale; - - dgAssert(m_minBox.m_w == dgFloat32(0.0f)); - dgAssert(m_maxBox.m_w == dgFloat32(0.0f)); - - dgVector side0(m_maxBox - m_minBox); - m_surfaceArea = side0.DotProduct(side0.ShiftTripleRight()).m_x; - } - - virtual dgBody* GetBody() const - { - return NULL; - } - - virtual dgBroadPhaseNode* GetLeft() const - { - return NULL; - } - - virtual dgBroadPhaseNode* GetRight() const - { - return NULL; - } - - dgVector m_minBox; - dgVector m_maxBox; - dgBroadPhaseNode* m_parent; - dgFloat32 m_surfaceArea; - dgInt32 m_criticalSectionLock; - - static dgVector m_broadPhaseScale; - static dgVector m_broadInvPhaseScale; -} DG_GCC_VECTOR_ALIGNMENT; - - -class dgBroadPhaseBodyNode: public dgBroadPhaseNode -{ - public: - dgBroadPhaseBodyNode(dgBody* const body) - :dgBroadPhaseNode(NULL) - ,m_body(body) - ,m_updateNode(NULL) - { - SetAABB(body->m_minAABB, body->m_maxAABB); - m_body->SetBroadPhase(this); - } - - virtual ~dgBroadPhaseBodyNode() - { - m_body->SetBroadPhase(NULL); - } - - virtual bool IsLeafNode() const - { - return true; - } - - virtual dgBody* GetBody() const - { - return m_body; - } - - dgBody* m_body; - dgList<dgBroadPhaseNode*>::dgListNode* m_updateNode; -}; - -class dgBroadPhaseTreeNode: public dgBroadPhaseNode -{ - public: - dgBroadPhaseTreeNode() - :dgBroadPhaseNode(NULL) - ,m_left(NULL) - ,m_right(NULL) - ,m_fitnessNode(NULL) - { - } - - dgBroadPhaseTreeNode(dgBroadPhaseNode* const sibling, dgBroadPhaseNode* const myNode) - :dgBroadPhaseNode(sibling->m_parent) - ,m_left(sibling) - ,m_right(myNode) - ,m_fitnessNode(NULL) - { - if (m_parent) { - dgBroadPhaseTreeNode* const myParent = (dgBroadPhaseTreeNode*)m_parent; - if (myParent->m_left == sibling) { - myParent->m_left = this; - } else { - dgAssert(myParent->m_right == sibling); - myParent->m_right = this; - } - } - - sibling->m_parent = this; - myNode->m_parent = this; - - dgBroadPhaseNode* const left = m_left; - dgBroadPhaseNode* const right = m_right; - - m_minBox = left->m_minBox.GetMin(right->m_minBox); - m_maxBox = left->m_maxBox.GetMax(right->m_maxBox); - dgVector side0(m_maxBox - m_minBox); - m_surfaceArea = side0.DotProduct(side0.ShiftTripleRight()).m_x; - } - - virtual ~dgBroadPhaseTreeNode() - { - if (m_left) { - delete m_left; - } - if (m_right) { - delete m_right; - } - } - - virtual dgBroadPhaseNode* GetLeft() const - { - return m_left; - } - - virtual dgBroadPhaseNode* GetRight() const - { - return m_right; - } - - dgBroadPhaseNode* m_left; - dgBroadPhaseNode* m_right; - dgList<dgBroadPhaseTreeNode*>::dgListNode* m_fitnessNode; -} DG_GCC_VECTOR_ALIGNMENT; - -#define DG_CONTACT_CACHE_LINE_SIZE 4 - -class dgBroadPhase -{ - protected: - - class CacheEntryTag - { - public: - DG_INLINE CacheEntryTag() {} - DG_INLINE CacheEntryTag(dgUnsigned32 tag0, dgUnsigned32 tag1) - :m_tagLow(dgMin(tag0, tag1)) - ,m_tagHigh(dgMax(tag0, tag1)) - { - } - - DG_INLINE dgUnsigned32 GetHash() const - { - return m_tagHigh * 31415821u + m_tagLow; - } - - union - { - dgUnsigned64 m_tag; - struct - { - dgUnsigned32 m_tagLow; - dgUnsigned32 m_tagHigh; - }; - }; - }; - - class dgContactCacheLine - { - public: - DG_INLINE dgContactCacheLine() - { - } - - dgInt32 m_count; - dgUnsigned32 m_key; - dgContact* m_contact[DG_CONTACT_CACHE_LINE_SIZE]; - dgInt32 m_hashKey[DG_CONTACT_CACHE_LINE_SIZE]; - CacheEntryTag m_tags[DG_CONTACT_CACHE_LINE_SIZE]; - }; - - class dgContactCache: public dgArray<dgContactCacheLine> - { - public: - dgContactCache (dgMemoryAllocator* const allocator) - :dgArray<dgContactCacheLine>(allocator) - ,m_count(1<<10) - { - Init(); - } - - void Flush() - { - Clear(); - Init(); - } - - void Init() - { - m_count = 1 << 10; - ResizeIfNecessary(m_count); - dgContactCacheLine* const cache = &(*this)[0]; - memset(cache, 0, m_count * sizeof(dgContactCacheLine)); - } - - DG_INLINE dgContact* FindContactJoint(const dgBody* const body0, const dgBody* const body1) const - { - CacheEntryTag tag(body0->m_uniqueID, body1->m_uniqueID); - dgUnsigned32 hash = tag.GetHash(); - - dgInt32 entry = hash & (m_count - 1); - - const dgContactCacheLine& cacheLine = (*this)[entry]; - for (dgInt32 i = 0; i < cacheLine.m_count; i++) { - if (cacheLine.m_tags[i].m_tag == tag.m_tag) { - return cacheLine.m_contact[i]; - } - } - return NULL; - } - - DG_INLINE bool AddContactJoint(dgContact* const joint) - { - // note this function is not thread safe - CacheEntryTag tag(joint->GetBody0()->m_uniqueID, joint->GetBody1()->m_uniqueID); - dgUnsigned32 hash = tag.GetHash(); - - dgInt32 entry = hash & (m_count - 1); - dgContactCacheLine* cacheLine = &(*this)[entry]; - - for (dgInt32 i = cacheLine->m_count - 1; i >= 0; i--) { - if (cacheLine->m_tags[i].m_tag == tag.m_tag) { - return false; - } - } - - while (cacheLine->m_count == 4) { - Rehash(); - entry = hash & (m_count - 1); - cacheLine = &(*this)[entry]; - } - if (cacheLine->m_count == 0) { - cacheLine->m_key = hash; - } - - const dgInt32 index = cacheLine->m_count; - cacheLine->m_count++; - cacheLine->m_tags[index] = tag; - cacheLine->m_hashKey[index] = hash; - cacheLine->m_contact[index] = joint; - return true; - } - - DG_INLINE void RemoveContactJoint(dgContact* const joint) - { - CacheEntryTag tag(joint->GetBody0()->m_uniqueID, joint->GetBody1()->m_uniqueID); - dgUnsigned32 hash = tag.GetHash(); - - dgInt32 entry = hash & (m_count - 1); - dgContactCacheLine* const cacheLine = &(*this)[entry]; - for (dgInt32 i = cacheLine->m_count - 1; i >= 0 ; i--) { - if (cacheLine->m_tags[i].m_tag == tag.m_tag) { - cacheLine->m_count--; - const dgInt32 index = cacheLine->m_count; - cacheLine->m_tags[i] = cacheLine->m_tags[index]; - cacheLine->m_hashKey[i] = cacheLine->m_hashKey[index]; - cacheLine->m_contact[i] = cacheLine->m_contact[index]; - break; - } - } - } - - private: - void Rehash() - { - const dgInt32 newCount = m_count * 2; - ResizeIfNecessary(newCount); - dgContactCacheLine* const cache0 = &(*this)[0]; - dgContactCacheLine* const cache1 = &cache0[m_count]; - - const dgInt32 mask = newCount - 1; - for (dgInt32 i = 0; i < m_count; i++) { - dgContactCacheLine* const src = &cache0[i]; - dgContactCacheLine* const dst = &cache1[i]; - dst->m_count = 0; - for (dgInt32 j = src->m_count - 1; j >= 0; j--) { - dgInt32 entry = src->m_hashKey[j] & mask; - if (entry >= m_count) { - const dgInt32 dstIndex = dst->m_count; - dst->m_count++; - dst->m_tags[dstIndex] = src->m_tags[j]; - dst->m_hashKey[dstIndex] = src->m_hashKey[j]; - dst->m_contact[dstIndex] = src->m_contact[j]; - - src->m_count--; - const dgInt32 srcIndex = src->m_count; - src->m_tags[j] = src->m_tags[srcIndex]; - src->m_hashKey[j] = src->m_hashKey[srcIndex]; - src->m_contact[j] = src->m_contact[srcIndex]; - } - } - } - m_count = newCount; - } - - dgInt32 m_count; - }; - - class dgSpliteInfo; - class dgBroadphaseSyncDescriptor - { - public: - dgBroadphaseSyncDescriptor(dgFloat32 timestep, dgWorld* const world) - :m_world(world) - ,m_timestep(timestep) - ,m_atomicIndex(0) - ,m_contactStart(0) - ,m_atomicDynamicsCount(0) - ,m_atomicPendingBodiesCount(0) - ,m_fullScan(false) - { - } - - dgWorld* m_world; - dgFloat32 m_timestep; - dgInt32 m_atomicIndex; - dgInt32 m_contactStart; - dgInt32 m_atomicDynamicsCount; - dgInt32 m_atomicPendingBodiesCount; - bool m_fullScan; - }; - - class dgFitnessList: public dgList <dgBroadPhaseTreeNode*> - { - public: - dgFitnessList(dgMemoryAllocator* const allocator) - :dgList <dgBroadPhaseTreeNode*>(allocator) - ,m_index(0) - ,m_prevCost(dgFloat32 (0.0f)) - { - } - - dgFloat64 TotalCost() const - { - dgFloat64 cost = dgFloat32(0.0f); - for (dgListNode* node = GetFirst(); node; node = node->GetNext()) { - dgBroadPhaseNode* const box = node->GetInfo(); - cost += box->m_surfaceArea; - } - return cost; - } - - dgInt32 m_index; - dgFloat64 m_prevCost; - }; - - public: - enum dgContactCode - { - m_close, - m_persist, - m_separated, - }; - - class dgPair - { - public: - dgContact* m_contact; - dgContactPoint* m_contactBuffer; - dgFloat32 m_timestep; - dgInt32 m_contactCount : 16; - dgInt32 m_cacheIsValid : 1; - dgInt32 m_flipContacts : 1; - }; - - dgBroadPhase(dgWorld* const world); - virtual ~dgBroadPhase(); - - DG_INLINE dgUnsigned32 GetLRU() const - { - return m_lru; - } - - DG_INLINE dgFloat32 CalculateSurfaceArea(const dgBroadPhaseNode* const node0, const dgBroadPhaseNode* const node1, dgVector& minBox, dgVector& maxBox) const - { - minBox = node0->m_minBox.GetMin(node1->m_minBox); - maxBox = node0->m_maxBox.GetMax(node1->m_maxBox); - dgVector side0(maxBox - minBox); - return side0.DotProduct(side0.ShiftTripleRight()).GetScalar(); - } - - dgWorld* GetWorld() const { return m_world;} - - virtual dgInt32 GetType() const = 0; - - virtual void Add(dgBody* const body) = 0; - virtual void Remove(dgBody* const body) = 0; - - virtual void ResetEntropy() = 0; - virtual void UpdateFitness() = 0; - virtual void InvalidateCache() = 0; - virtual dgBroadPhaseAggregate* CreateAggregate() = 0; - virtual void DestroyAggregate(dgBroadPhaseAggregate* const aggregate) = 0; - - virtual void CheckStaticDynamic(dgBody* const body, dgFloat32 mass) = 0; - virtual void ForEachBodyInAABB (const dgVector& minBox, const dgVector& maxBox, OnBodiesInAABB callback, void* const userData) const = 0; - virtual void RayCast (const dgVector& p0, const dgVector& p1, OnRayCastAction filter, OnRayPrecastAction prefilter, void* const userData) const = 0; - virtual dgInt32 Collide(dgCollisionInstance* const shape, const dgMatrix& matrix, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const = 0; - virtual dgInt32 ConvexCast (dgCollisionInstance* const shape, const dgMatrix& matrix, const dgVector& target, dgFloat32* const param, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const = 0; - virtual void FindCollidingPairs (dgBroadphaseSyncDescriptor* const descriptor, dgList<dgBroadPhaseNode*>::dgListNode* const node, dgInt32 threadID) = 0; - - void UpdateBody(dgBody* const body, dgInt32 threadIndex); - void AddInternallyGeneratedBody(dgBody* const body) - { - m_generatedBodies.Append(body); - } - - void UpdateContacts(dgFloat32 timestep); - void CollisionChange (dgBody* const body, dgCollisionInstance* const collisionSrc); - - void MoveNodes (dgBroadPhase* const dest); - - protected: - virtual void LinkAggregate (dgBroadPhaseAggregate* const aggregate) = 0; - virtual void UnlinkAggregate (dgBroadPhaseAggregate* const aggregate) = 0; - - bool DoNeedUpdate(dgBodyMasterList::dgListNode* const node) const; - dgFloat64 CalculateEntropy (dgFitnessList& fitness, dgBroadPhaseNode** const root); - dgBroadPhaseTreeNode* InsertNode (dgBroadPhaseNode* const root, dgBroadPhaseNode* const node); - - void RotateLeft(dgBroadPhaseTreeNode* const node, dgBroadPhaseNode** const root); - void RotateRight(dgBroadPhaseTreeNode* const node, dgBroadPhaseNode** const root); - void ImproveNodeFitness(dgBroadPhaseTreeNode* const node, dgBroadPhaseNode** const root); - void ImproveFitness(dgFitnessList& fitness, dgFloat64& oldEntropy, dgBroadPhaseNode** const root); - - void CalculatePairContacts (dgPair* const pair, dgInt32 threadID); - void AddPair (dgContact* const contact, dgFloat32 timestep, dgInt32 threadIndex); - void AddPair (dgBody* const body0, dgBody* const body1, dgFloat32 timestep, dgInt32 threadID); - - bool TestOverlaping(const dgBody* const body0, const dgBody* const body1, dgFloat32 timestep) const; - - void ForEachBodyInAABB (const dgBroadPhaseNode** stackPool, dgInt32 stack, const dgVector& minBox, const dgVector& maxBox, OnBodiesInAABB callback, void* const userData) const; - void RayCast (const dgBroadPhaseNode** stackPool, dgFloat32* const distance, dgInt32 stack, const dgVector& l0, const dgVector& l1, dgFastRayTest& ray, OnRayCastAction filter, OnRayPrecastAction prefilter, void* const userData) const; - - dgInt32 ConvexCast (const dgBroadPhaseNode** stackPool, dgFloat32* const distance, dgInt32 stack, const dgVector& velocA, const dgVector& velocB, dgFastRayTest& ray, - dgCollisionInstance* const shape, const dgMatrix& matrix, const dgVector& target, dgFloat32* const param, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const; - - dgInt32 Collide(const dgBroadPhaseNode** stackPool, dgInt32* const overlap, dgInt32 stack, const dgVector& p0, const dgVector& p1, - dgCollisionInstance* const shape, const dgMatrix& matrix, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const; - - void SleepingState (dgBroadphaseSyncDescriptor* const descriptor, dgBodyMasterList::dgListNode* node, dgInt32 threadID); - void ApplyForceAndtorque (dgBroadphaseSyncDescriptor* const descriptor, dgBodyMasterList::dgListNode* node, dgInt32 threadID); - - void UpdateAggregateEntropy (dgBroadphaseSyncDescriptor* const descriptor, dgList<dgBroadPhaseAggregate*>::dgListNode* node, dgInt32 threadID); - - dgBroadPhaseNode* BuildTopDown(dgBroadPhaseNode** const leafArray, dgInt32 firstBox, dgInt32 lastBox, dgFitnessList::dgListNode** const nextNode); - dgBroadPhaseNode* BuildTopDownBig(dgBroadPhaseNode** const leafArray, dgInt32 firstBox, dgInt32 lastBox, dgFitnessList::dgListNode** const nextNode); - - void KinematicBodyActivation (dgContact* const contatJoint) const; - - void FindGeneratedBodiesCollidingPairs (dgBroadphaseSyncDescriptor* const descriptor, dgInt32 threadID); - void UpdateSoftBodyContacts(dgBroadphaseSyncDescriptor* const descriptor, dgFloat32 timeStep, dgInt32 threadID); - void UpdateRigidBodyContacts (dgBroadphaseSyncDescriptor* const descriptor, dgFloat32 timeStep, dgInt32 threadID); - void SubmitPairs (dgBroadPhaseNode* const body, dgBroadPhaseNode* const node, dgFloat32 timestep, dgInt32 threaCount, dgInt32 threadID); - - bool SanityCheck() const; - void AttachNewContact(dgInt32 startCount); - void DeleteDeadContact(dgFloat32 timestep); - - DG_INLINE bool ValidateContactCache(dgContact* const contact, const dgVector& timestep) const; - - static void SleepingStateKernel(void* const descriptor, void* const worldContext, dgInt32 threadID); - static void ForceAndToqueKernel(void* const descriptor, void* const worldContext, dgInt32 threadID); - static void CollidingPairsKernel(void* const descriptor, void* const worldContext, dgInt32 threadID); - static void UpdateAggregateEntropyKernel(void* const descriptor, void* const worldContext, dgInt32 threadID); - static void AddGeneratedBodiesContactsKernel(void* const descriptor, void* const worldContext, dgInt32 threadID); - static void UpdateRigidBodyContactKernel(void* const descriptor, void* const worldContext, dgInt32 threadID); - static void UpdateSoftBodyContactKernel(void* const descriptor, void* const worldContext, dgInt32 threadID); - static dgInt32 CompareNodes(const dgBroadPhaseNode* const nodeA, const dgBroadPhaseNode* const nodeB, void* const notUsed); - - class dgPendingCollisionSoftBodies - { - public: - dgBody* m_body0; - dgBody* m_body1; - }; - - dgWorld* m_world; - dgBroadPhaseNode* m_rootNode; - dgList<dgBody*> m_generatedBodies; - dgList<dgBroadPhaseNode*> m_updateList; - dgList<dgBroadPhaseAggregate*> m_aggregateList; - dgUnsigned32 m_lru; - dgContactCache m_contactCache; - dgArray<dgPendingCollisionSoftBodies> m_pendingSoftBodyCollisions; - dgInt32 m_pendingSoftBodyPairsCount; - dgInt32 m_criticalSectionLock; - - static dgVector m_velocTol; - static dgVector m_linearContactError2; - static dgVector m_angularContactError2; - - friend class dgBody; - friend class dgWorld; - friend class dgDeadBodies; - friend class dgWorldDynamicUpdate; - friend class dgBroadPhaseAggregate; - friend class dgCollisionCompoundFractured; -}; - - -#endif diff --git a/thirdparty/src/newton/dgPhysics/dgBroadPhaseAggregate.cpp b/thirdparty/src/newton/dgPhysics/dgBroadPhaseAggregate.cpp deleted file mode 100644 index 54fcc2d50..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBroadPhaseAggregate.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgBroadPhaseAggregate.h" - - -dgBroadPhaseAggregate::dgBroadPhaseAggregate(dgBroadPhase* const broadPhase) - :dgBroadPhaseNode(NULL) - ,m_root(NULL) - ,m_broadPhase(broadPhase) - ,m_updateNode(NULL) - ,m_myAggregateNode(NULL) - ,m_fitnessList(broadPhase->m_world->GetAllocator()) - ,m_treeEntropy(dgFloat32(0.0f)) - ,m_isInEquilibrium(false) - ,m_isSelfCollidable(true) -{ - m_minBox = dgVector(dgFloat32(0.0f)); - m_maxBox = dgVector(dgFloat32(0.0f)); - m_surfaceArea = dgFloat32(0.0f); -} - -dgBroadPhaseAggregate::~dgBroadPhaseAggregate() -{ - if (m_root) { - dgBody* buffer[2040]; - - dgBroadPhaseNode* pool[DG_BROADPHASE_MAX_STACK_DEPTH]; - pool[0] = m_root; - dgInt32 stack = 1; - - dgInt32 count = 0; - while (stack) { - stack--; - dgBroadPhaseNode* const rootNode = pool[stack]; - if (rootNode->IsLeafNode()) { - buffer[count] = rootNode->GetBody();; - count ++; - } else { - dgBroadPhaseTreeNode* const tmpNode = (dgBroadPhaseTreeNode*)rootNode; - dgAssert(tmpNode->m_left); - dgAssert(tmpNode->m_right); - - pool[stack] = tmpNode->m_left; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - pool[stack] = tmpNode->m_right; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - } - } - - for (dgInt32 i = 0; i < count; i ++) { - RemoveBody(buffer[i]); - } - dgAssert (!m_root); - } -} - -void dgBroadPhaseAggregate::AddBody(dgBody* const body) -{ - dgAssert(body->GetBroadPhase()); - m_broadPhase->Remove(body); - - dgBroadPhaseBodyNode* const newNode = new (m_broadPhase->GetWorld()->GetAllocator()) dgBroadPhaseBodyNode(body); - if (!m_root) { - m_root = newNode; - newNode->m_parent = this; - } else { - dgBroadPhaseTreeNode* const tmp = m_broadPhase->InsertNode(m_root, newNode); - dgList<dgBroadPhaseTreeNode*>::dgListNode* const link = m_fitnessList.Append(tmp); - tmp->m_fitnessNode = link; - } - body->m_broadPhaseaggregateNode = this; - SetAABB (m_root->m_minBox, m_root->m_maxBox); - for (dgBroadPhaseNode* ptr = this; ptr->m_parent; ptr = ptr->m_parent) { - if (dgBoxInclusionTest(ptr->m_minBox, ptr->m_maxBox, ptr->m_parent->m_minBox, ptr->m_parent->m_maxBox)) { - break; - } - dgVector minBox; - dgVector maxBox; - dgFloat32 area; - area = m_broadPhase->CalculateSurfaceArea(ptr->m_parent, ptr, minBox, maxBox); - ptr->m_parent->m_minBox = minBox; - ptr->m_parent->m_maxBox = maxBox; - ptr->m_parent->m_surfaceArea = area; - } -} - -void dgBroadPhaseAggregate::RemoveBody(dgBody* const body) -{ - dgAssert(body->GetBroadPhase()); - m_broadPhase->Remove(body); - m_broadPhase->Add(body); -} - - -void dgBroadPhaseAggregate::ImproveEntropy() -{ - if (m_root) { - if (m_root->IsLeafNode()) { - dgAssert (m_root->GetBody()); - m_isInEquilibrium = m_root->GetBody()->m_equilibrium; - } else if (!m_isInEquilibrium) { - - bool equlibrium = true; - dgFloat64 entropy = dgFloat32(0.0f); - for (dgList<dgBroadPhaseTreeNode*>::dgListNode* ptr = m_fitnessList.GetFirst(); ptr; ptr = ptr->GetNext()) { - dgBroadPhaseTreeNode* const tmpNode = ptr->GetInfo(); - entropy += tmpNode->m_surfaceArea; - const dgBody* const leftBody = tmpNode->m_left->GetBody(); - const dgBody* const rightBody = tmpNode->m_right->GetBody(); - equlibrium &= (!leftBody || leftBody->m_equilibrium) ? true : false; - equlibrium &= (!rightBody ||rightBody->m_equilibrium) ? true : false; - } - - m_isInEquilibrium = equlibrium; - if (!m_isInEquilibrium && ((entropy > m_treeEntropy * dgFloat32(2.0f)) || (entropy < m_treeEntropy * dgFloat32(0.5f)))) { - m_root->m_parent = NULL; - dgFloat64 cost0 = entropy; - dgFloat64 cost1 = cost0; - do { - cost0 = cost1; - for (dgList<dgBroadPhaseTreeNode*>::dgListNode* ptr = m_fitnessList.GetFirst(); ptr; ptr = ptr->GetNext()) { - dgBroadPhaseTreeNode* const tmpNode = ptr->GetInfo(); - m_broadPhase->ImproveNodeFitness(tmpNode, &m_root); - } - cost1 = dgFloat32(0.0f); - for (dgList<dgBroadPhaseTreeNode*>::dgListNode* ptr = m_fitnessList.GetFirst(); ptr; ptr = ptr->GetNext()) { - dgBroadPhaseTreeNode* const tmpNode = ptr->GetInfo(); - cost1 += tmpNode->m_surfaceArea; - } - } while (cost1 < (dgFloat32(0.99f)) * cost0); - - m_treeEntropy = cost1; - m_root->m_parent = this; - m_minBox = m_root->m_minBox; - m_maxBox = m_root->m_maxBox; - m_surfaceArea = m_root->m_surfaceArea; - } - } - } -} - -void dgBroadPhaseAggregate::SummitPairs(dgBroadPhaseAggregate* const aggregate, dgFloat32 timestep, dgInt32 threadID) const -{ - if (m_root && aggregate->m_root && !(m_isInEquilibrium & aggregate->m_isInEquilibrium)) { - SubmitSelfPairs(m_root, aggregate->m_root, timestep, threadID); - } -} - -void dgBroadPhaseAggregate::SubmitSelfPairs(dgFloat32 timestep, dgInt32 threadID) const -{ - if (m_root && !m_root->IsLeafNode()) { - if (!m_isInEquilibrium & m_isSelfCollidable) { - SubmitSelfPairs(m_root->GetLeft(), m_root->GetRight(), timestep, threadID); - } - } -} - -void dgBroadPhaseAggregate::SummitPairs(dgBody* const body, dgFloat32 timestep, dgInt32 threadID) const -{ - if (m_root) { - if (m_root->IsLeafNode()) { - dgAssert (m_root->GetBody()); - m_broadPhase->AddPair(body, m_root->GetBody(), timestep, threadID); - } else if (!(m_isInEquilibrium & body->m_equilibrium)) { - dgBroadPhaseNode* pool[DG_BROADPHASE_MAX_STACK_DEPTH/2]; - pool[0] = m_root; - dgInt32 stack = 1; - - const dgVector& boxP0 = body->m_minAABB; - const dgVector& boxP1 = body->m_maxAABB; - - while (stack) { - stack--; - dgBroadPhaseNode* const rootNode = pool[stack]; - if (dgOverlapTest(rootNode->m_minBox, rootNode->m_maxBox, boxP0, boxP1)) { - if (rootNode->IsLeafNode()) { - dgBody* const body1 = rootNode->GetBody(); - dgAssert (body1); - m_broadPhase->AddPair(body, body1, timestep, threadID); - } else { - dgBroadPhaseTreeNode* const tmpNode = (dgBroadPhaseTreeNode*)rootNode; - dgAssert(tmpNode->m_left); - dgAssert(tmpNode->m_right); - - pool[stack] = tmpNode->m_left; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - - pool[stack] = tmpNode->m_right; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - } - } - } - } - } -} - -void dgBroadPhaseAggregate::SubmitSelfPairs(dgBroadPhaseNode* const node0, dgBroadPhaseNode* const node1, dgFloat32 timestep, dgInt32 threadID) const -{ -/* - dgInt32 stack = 1; - dgBroadPhaseNode* pool[DG_BROADPHASE_MAX_STACK_DEPTH][2]; - - pool[0][0] = node0; - pool[0][1] = node1; - while (stack) { - stack--; - dgBroadPhaseNode* const root0 = pool[stack][0]; - dgBroadPhaseNode* const root1 = pool[stack][1]; - if (dgOverlapTest(root0->m_minBox, root0->m_maxBox, root1->m_minBox, root1->m_maxBox)) { - if (root0->IsLeafNode()) { - if (root1->IsLeafNode()) { - dgBody* const body0 = root0->GetBody(); - dgBody* const body1 = root1->GetBody(); - dgAssert(body0); - dgAssert(body1); - m_broadPhase->AddPair(body0, body1, timestep, threadID); - } else { - dgBroadPhaseTreeNode* const tmpNode1 = (dgBroadPhaseTreeNode*)root1; - dgAssert(tmpNode1->m_left); - dgAssert(tmpNode1->m_right); - - pool[stack][0] = root0; - pool[stack][1] = tmpNode1->m_left; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - - pool[stack][0] = root0; - pool[stack][1] = tmpNode1->m_right; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - } - } else if (root1->IsLeafNode()) { - dgBroadPhaseTreeNode* const tmpNode0 = (dgBroadPhaseTreeNode*)root0; - dgAssert(tmpNode0->m_left); - dgAssert(tmpNode0->m_right); - - pool[stack][0] = root1; - pool[stack][1] = tmpNode0->m_left; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - - pool[stack][0] = root1; - pool[stack][1] = tmpNode0->m_right; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - } else { - - dgBroadPhaseTreeNode* const tmpNode0 = (dgBroadPhaseTreeNode*)root0; - dgBroadPhaseTreeNode* const tmpNode1 = (dgBroadPhaseTreeNode*)root1; - dgAssert(tmpNode0->m_left); - dgAssert(tmpNode0->m_right); - dgAssert(tmpNode1->m_left); - dgAssert(tmpNode1->m_right); - - pool[stack][0] = tmpNode0->m_left; - pool[stack][1] = tmpNode1->m_left; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - - pool[stack][0] = tmpNode0->m_left; - pool[stack][1] = tmpNode1->m_right; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - - pool[stack][0] = tmpNode0->m_right; - pool[stack][1] = tmpNode1->m_left; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - - pool[stack][0] = tmpNode0->m_right; - pool[stack][1] = tmpNode1->m_right; - stack++; - dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0]))); - } - } - } -*/ - - const dgBroadPhaseNode* pool[DG_BROADPHASE_MAX_STACK_DEPTH][2]; - pool[0][0] = node0; - pool[0][1] = node1; - dgInt32 stack = 1; - - while (stack) { - stack--; - - const dgBroadPhaseNode* const left = pool[stack][0]; - const dgBroadPhaseNode* const right = pool[stack][1]; - - if (left->IsLeafNode() && right->IsLeafNode()) { - dgBody* const body0 = left->GetBody(); - dgBody* const body1 = right->GetBody(); - if (dgOverlapTest(body0->m_minAABB, body0->m_maxAABB, body1->m_minAABB, body1->m_maxAABB)) { - m_broadPhase->AddPair(body0, body1, timestep, threadID); - } - } else { - if (left->m_parent == right->m_parent) { - if (!left->IsLeafNode()) { - pool[stack][0] = left->GetLeft(); - pool[stack][1] = left->GetRight(); - stack++; - dgAssert(stack < sizeof(pool) / sizeof(pool[0])); - } - if (!right->IsLeafNode()) { - pool[stack][0] = right->GetLeft(); - pool[stack][1] = right->GetRight(); - stack++; - dgAssert(stack < sizeof(pool) / sizeof(pool[0])); - } - } - - const dgBroadPhaseNode* leftPool[2]; - const dgBroadPhaseNode* rightPool[2]; - dgInt32 leftCount = 2; - dgInt32 rightCount = 2; - if (left->IsLeafNode()) { - leftCount = 1; - dgAssert(!right->IsLeafNode()); - leftPool[0] = left; - rightPool[0] = right->GetLeft(); - rightPool[1] = right->GetRight(); - } else if (right->IsLeafNode()) { - rightCount = 1; - dgAssert(!left->IsLeafNode()); - leftPool[0] = left->GetLeft(); - leftPool[1] = left->GetRight(); - rightPool[0] = right; - } - else { - leftPool[0] = left->GetLeft(); - leftPool[1] = left->GetRight(); - rightPool[0] = right->GetLeft(); - rightPool[1] = right->GetRight(); - } - - for (dgInt32 i = 0; i < leftCount; i++) { - for (dgInt32 j = 0; j < rightCount; j++) { - if (dgOverlapTest(leftPool[i]->m_minBox, leftPool[i]->m_maxBox, rightPool[j]->m_minBox, rightPool[j]->m_maxBox)) { - pool[stack][0] = leftPool[i]; - pool[stack][1] = rightPool[j]; - stack++; - dgAssert(stack < sizeof (pool) / sizeof (pool[0])); - } - } - } - } - } -} diff --git a/thirdparty/src/newton/dgPhysics/dgBroadPhaseAggregate.h b/thirdparty/src/newton/dgPhysics/dgBroadPhaseAggregate.h deleted file mode 100644 index 0adfb87c7..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBroadPhaseAggregate.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DG_BROADPHASE_AGGREGATE_H__ -#define __DG_BROADPHASE_AGGREGATE_H__ - -#include "dgPhysicsStdafx.h" -#include "dgBroadPhase.h" - -class dgBroadPhaseAggregate: public dgBroadPhaseNode -{ - public: - dgBroadPhaseAggregate (dgBroadPhase* const broadPhase); - virtual ~dgBroadPhaseAggregate();; - - virtual bool IsLeafNode() const - { - return true; - } - - virtual bool IsAggregate() const - { - return true; - } - - bool GetSelfCollision() const - { - return m_isSelfCollidable ? true : false; - } - - void SetSelfCollision(bool state) - { - m_isSelfCollidable = state; - } - - void AddBody (dgBody* const body); - void RemoveBody (dgBody* const body); - - void ImproveEntropy (); - void SubmitSelfPairs(dgFloat32 timestep, dgInt32 threadID) const; - void SummitPairs(dgBody* const body, dgFloat32 timestep, dgInt32 threadID) const; - void SummitPairs(dgBroadPhaseAggregate* const aggregate, dgFloat32 timestep, dgInt32 threadID) const; - private: - void SubmitSelfPairs(dgBroadPhaseNode* const node0, dgBroadPhaseNode* const node1, dgFloat32 timestep, dgInt32 threadID) const; - - public: - dgBroadPhaseNode* m_root; - dgBroadPhase* m_broadPhase; - dgList<dgBroadPhaseNode*>::dgListNode* m_updateNode; - dgList<dgBroadPhaseAggregate*>::dgListNode* m_myAggregateNode; - dgList<dgBroadPhaseTreeNode*> m_fitnessList; - dgFloat64 m_treeEntropy; - bool m_isInEquilibrium; - bool m_isSelfCollidable; -}; - -#endif diff --git a/thirdparty/src/newton/dgPhysics/dgBroadPhaseMixed.cpp b/thirdparty/src/newton/dgPhysics/dgBroadPhaseMixed.cpp deleted file mode 100644 index 93dcd8c79..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBroadPhaseMixed.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgCollisionInstance.h" -#include "dgBroadPhaseMixed.h" -#include "dgBroadPhaseAggregate.h" - - -dgBroadPhaseMixed::dgBroadPhaseMixed(dgWorld* const world) - :dgBroadPhase(world) - ,m_treeEntropy(dgFloat32(0.0f)) - ,m_fitness(world->GetAllocator()) -{ -} - -dgBroadPhaseMixed::~dgBroadPhaseMixed() -{ - if (m_rootNode) { - delete m_rootNode; - } - m_rootNode = NULL; -} - -dgInt32 dgBroadPhaseMixed::GetType() const -{ - return dgWorld::m_broadphaseMixed; -} - -void dgBroadPhaseMixed::ResetEntropy() -{ - m_treeEntropy = dgFloat32(0.0f); -} - -void dgBroadPhaseMixed::UpdateFitness() -{ - ImproveFitness(m_fitness, m_treeEntropy, &m_rootNode); -} - -void dgBroadPhaseMixed::InvalidateCache() -{ - ResetEntropy(); - ImproveFitness(m_fitness, m_treeEntropy, &m_rootNode); - m_contactCache.Flush(); -} - -void dgBroadPhaseMixed::ForEachBodyInAABB(const dgVector& minBox, const dgVector& maxBox, OnBodiesInAABB callback, void* const userData) const -{ - if (m_rootNode) { - const dgBroadPhaseNode* stackPool[DG_BROADPHASE_MAX_STACK_DEPTH]; - stackPool[0] = m_rootNode; - dgBroadPhase::ForEachBodyInAABB(stackPool, 1, minBox, maxBox, callback, userData); - } -} - - -void dgBroadPhaseMixed::RayCast(const dgVector& l0, const dgVector& l1, OnRayCastAction filter, OnRayPrecastAction prefilter, void* const userData) const -{ - if (filter && m_rootNode) { - dgVector segment(l1 - l0); - dgAssert (segment.m_w == dgFloat32 (0.0f)); - dgFloat32 dist2 = segment.DotProduct(segment).GetScalar(); - if (dist2 > dgFloat32(1.0e-8f)) { - - dgFloat32 distance[DG_BROADPHASE_MAX_STACK_DEPTH]; - const dgBroadPhaseNode* stackPool[DG_BROADPHASE_MAX_STACK_DEPTH]; - - dgFastRayTest ray(l0, l1); - - stackPool[0] = m_rootNode; - distance[0] = ray.BoxIntersect(m_rootNode->m_minBox, m_rootNode->m_maxBox); - dgBroadPhase::RayCast(stackPool, distance, 1, l0, l1, ray, filter, prefilter, userData); - } - } -} - -dgInt32 dgBroadPhaseMixed::ConvexCast(dgCollisionInstance* const shape, const dgMatrix& matrix, const dgVector& target, dgFloat32* const param, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const -{ - dgInt32 totalCount = 0; - if (m_rootNode) { - dgVector boxP0; - dgVector boxP1; - dgAssert(matrix.TestOrthogonal()); - shape->CalcAABB(matrix, boxP0, boxP1); - - dgFloat32 distance[DG_BROADPHASE_MAX_STACK_DEPTH]; - const dgBroadPhaseNode* stackPool[DG_BROADPHASE_MAX_STACK_DEPTH]; - - dgVector velocA((target - matrix.m_posit) & dgVector::m_triplexMask); - dgVector velocB(dgFloat32(0.0f)); - dgFastRayTest ray(dgVector(dgFloat32(0.0f)), velocA); - - dgVector minBox(m_rootNode->m_minBox - boxP1); - dgVector maxBox(m_rootNode->m_maxBox - boxP0); - stackPool[0] = m_rootNode; - distance[0] = ray.BoxIntersect(minBox, maxBox); - - *param = dgFloat32 (1.0f); - totalCount = dgBroadPhase::ConvexCast(stackPool, distance, 1, velocA, velocB, ray, shape, matrix, target, param, prefilter, userData, info, maxContacts, threadIndex); - } - - return totalCount; -} - -dgInt32 dgBroadPhaseMixed::Collide(dgCollisionInstance* const shape, const dgMatrix& matrix, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const -{ - dgInt32 totalCount = 0; - if (m_rootNode) { - dgVector boxP0; - dgVector boxP1; - dgAssert(matrix.TestOrthogonal()); - shape->CalcAABB(shape->GetLocalMatrix() * matrix, boxP0, boxP1); - - dgInt32 overlaped[DG_BROADPHASE_MAX_STACK_DEPTH]; - const dgBroadPhaseNode* stackPool[DG_BROADPHASE_MAX_STACK_DEPTH]; - - stackPool[0] = m_rootNode; - overlaped[0] = dgOverlapTest(m_rootNode->m_minBox, m_rootNode->m_maxBox, boxP0, boxP1); - - totalCount = dgBroadPhase::Collide(stackPool, overlaped, 1, boxP0, boxP1, shape, matrix, prefilter, userData, info, maxContacts, threadIndex); - } - - return totalCount; -} - -void dgBroadPhaseMixed::AddNode(dgBroadPhaseNode* const newNode) -{ - if (!m_rootNode) { - m_rootNode = newNode; - } else { - dgBroadPhaseTreeNode* const node = InsertNode(m_rootNode, newNode); - node->m_fitnessNode = m_fitness.Append(node); - if (!node->m_parent) { - m_rootNode = node; - } - } -} - -void dgBroadPhaseMixed::Add(dgBody* const body) -{ - // create a new leaf node; - dgAssert (!body->GetCollision()->IsType (dgCollision::dgCollisionNull_RTTI)); - dgBroadPhaseBodyNode* const bodyNode = new (m_world->GetAllocator()) dgBroadPhaseBodyNode(body); - bodyNode->m_updateNode = m_updateList.Append(bodyNode); - AddNode(bodyNode); -} - -dgBroadPhaseAggregate* dgBroadPhaseMixed::CreateAggregate() -{ - dgBroadPhaseAggregate* const aggregate = new (m_world->GetAllocator()) dgBroadPhaseAggregate(m_world->GetBroadPhase()); - LinkAggregate (aggregate); - return aggregate; -} - -void dgBroadPhaseMixed::LinkAggregate(dgBroadPhaseAggregate* const aggregate) -{ - AddNode(aggregate); - aggregate->m_broadPhase = this; - aggregate->m_updateNode = m_updateList.Append(aggregate); - aggregate->m_myAggregateNode = m_aggregateList.Append(aggregate); -} - -void dgBroadPhaseMixed::RemoveNode(dgBroadPhaseNode* const node) -{ - if (node->m_parent) { - if (!node->m_parent->IsAggregate()) { - dgBroadPhaseTreeNode* const parent = (dgBroadPhaseTreeNode*)node->m_parent; - if (parent->m_parent) { - if (parent->m_parent->IsAggregate()) { - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*)parent->m_parent; - if (parent->m_left == node) { - dgAssert(parent->m_right); - aggregate->m_root = parent->m_right; - parent->m_right->m_parent = aggregate; - parent->m_right = NULL; - } else { - dgAssert(parent->m_right == node); - aggregate->m_root = parent->m_left; - parent->m_left->m_parent = aggregate; - parent->m_left = NULL; - } - parent->m_parent = NULL; - } else { - dgBroadPhaseTreeNode* const grandParent = (dgBroadPhaseTreeNode*)parent->m_parent; - if (grandParent->m_left == parent) { - if (parent->m_right == node) { - grandParent->m_left = parent->m_left; - parent->m_left->m_parent = grandParent; - parent->m_left = NULL; - parent->m_parent = NULL; - } else { - grandParent->m_left = parent->m_right; - parent->m_right->m_parent = grandParent; - parent->m_right = NULL; - parent->m_parent = NULL; - } - } else { - if (parent->m_right == node) { - grandParent->m_right = parent->m_left; - parent->m_left->m_parent = grandParent; - parent->m_left = NULL; - parent->m_parent = NULL; - } else { - grandParent->m_right = parent->m_right; - parent->m_right->m_parent = grandParent; - parent->m_right = NULL; - parent->m_parent = NULL; - } - } - } - } else { - dgAssert(!node->m_parent->IsLeafNode()); - dgBroadPhaseTreeNode* const parent1 = (dgBroadPhaseTreeNode*)node->m_parent; - if (parent1->m_right == node) { - m_rootNode = parent1->m_left; - m_rootNode->m_parent = NULL; - parent1->m_left = NULL; - } else { - m_rootNode = parent1->m_right; - m_rootNode->m_parent = NULL; - parent1->m_right = NULL; - } - } - - if (parent->m_fitnessNode) { - dgBody* const body = node->GetBody(); - if (body && body->GetBroadPhaseAggregate()) { - body->GetBroadPhaseAggregate()->m_fitnessList.Remove(parent->m_fitnessNode); - body->SetBroadPhaseAggregate(NULL); - } else { - m_fitness.Remove(parent->m_fitnessNode); - } - } - delete parent; - } else { - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*)node->m_parent; - dgBody* const body = node->GetBody(); - dgAssert (body); - dgAssert(body->GetBroadPhaseAggregate() == aggregate); - body->SetBroadPhaseAggregate(NULL); - aggregate->m_root = NULL; - node->m_parent = NULL; - delete node; - } - } else { - delete node; - m_rootNode = NULL; - } -} - -void dgBroadPhaseMixed::UnlinkAggregate(dgBroadPhaseAggregate* const aggregate) -{ - dgAssert (m_rootNode); - if (m_rootNode == aggregate) { - m_rootNode = NULL; - } else if (aggregate->m_parent == m_rootNode) { - dgBroadPhaseTreeNode* const parent = (dgBroadPhaseTreeNode*)aggregate->m_parent; - if (parent->m_left == aggregate) { - m_rootNode = parent->m_right; - } else { - dgAssert(parent->m_right == aggregate); - m_rootNode = parent->m_left; - } - m_rootNode->m_parent = NULL; - - parent->m_left = NULL; - parent->m_right = NULL; - parent->m_parent = NULL; - delete parent; - } else { - dgBroadPhaseTreeNode* const parent = (dgBroadPhaseTreeNode*)aggregate->m_parent; - dgBroadPhaseTreeNode* const grandParent = (dgBroadPhaseTreeNode*)parent->m_parent; - if (grandParent->m_left == parent) { - if (parent->m_left == aggregate) { - grandParent->m_left = parent->m_right; - parent->m_right->m_parent = grandParent; - } else { - dgAssert (parent->m_right == aggregate); - grandParent->m_left = parent->m_left; - parent->m_left->m_parent = grandParent; - } - } else { - dgAssert (grandParent->m_right == parent); - if (parent->m_left == aggregate) { - grandParent->m_right = parent->m_right; - parent->m_right->m_parent = grandParent; - } else { - dgAssert(parent->m_right == aggregate); - grandParent->m_right = parent->m_left; - parent->m_left->m_parent = grandParent; - } - } - parent->m_left = NULL; - parent->m_right = NULL; - parent->m_parent = NULL; - delete parent; - } - aggregate->m_parent = NULL; -} - - -void dgBroadPhaseMixed::Remove(dgBody* const body) -{ - if (body->GetBroadPhase()) { - dgBroadPhaseBodyNode* const node = (dgBroadPhaseBodyNode*)body->GetBroadPhase(); - if (node->m_updateNode) { - m_updateList.Remove(node->m_updateNode); - } - RemoveNode(node); - } -} - - -void dgBroadPhaseMixed::DestroyAggregate(dgBroadPhaseAggregate* const aggregate) -{ - m_updateList.Remove(aggregate->m_updateNode); - m_aggregateList.Remove(aggregate->m_myAggregateNode); - RemoveNode(aggregate); -} - -void dgBroadPhaseMixed::FindCollidingPairs(dgBroadphaseSyncDescriptor* const descriptor, dgList<dgBroadPhaseNode*>::dgListNode* const nodePtr, dgInt32 threadID) -{ - DG_TRACKTIME(); - const dgFloat32 timestep = descriptor->m_timestep; - - dgList<dgBroadPhaseNode*>::dgListNode* node = nodePtr; - const dgInt32 threadCount = descriptor->m_world->GetThreadCount(); - - if (descriptor->m_fullScan) { - while (node) { - dgBroadPhaseNode* const broadPhaseNode = node->GetInfo(); - dgAssert(broadPhaseNode->IsLeafNode()); - - dgBody* const body = broadPhaseNode->GetBody(); - dgAssert(!body || (body->GetBroadPhase() == broadPhaseNode)); - - if (!(body && body->m_isdead)) { - if (broadPhaseNode->IsAggregate()) { - ((dgBroadPhaseAggregate*)broadPhaseNode)->SubmitSelfPairs(timestep, threadID); - } - - for (dgBroadPhaseNode* ptr = broadPhaseNode; ptr->m_parent; ptr = ptr->m_parent) { - dgBroadPhaseTreeNode* const parent = (dgBroadPhaseTreeNode*)ptr->m_parent; - dgAssert(!parent->IsLeafNode()); - dgBroadPhaseNode* const sibling = parent->m_right; - if (sibling != ptr) { - SubmitPairs(broadPhaseNode, sibling, timestep, 0, threadID); - } - } - } - - for (dgInt32 i = 0; i < threadCount; i++) { - node = node ? node->GetNext() : NULL; - } - } - - } else { - const dgBodyInfo* const bodyArray = &m_world->m_bodiesMemory[0]; - const dgInt32 bodyCount = descriptor->m_atomicPendingBodiesCount; - dgInt32* const atomicIndex = &descriptor->m_atomicIndex; - - for (dgInt32 i = dgAtomicExchangeAndAdd(atomicIndex, 1); i < bodyCount; i = dgAtomicExchangeAndAdd(atomicIndex, 1)) { - dgBroadPhaseNode* const broadPhaseNode = bodyArray[i].m_body->GetBroadPhase(); - dgAssert(broadPhaseNode->IsLeafNode()); - dgAssert(!broadPhaseNode->GetBody() || (broadPhaseNode->GetBody()->GetBroadPhase() == broadPhaseNode)); - - for (dgBroadPhaseNode* ptr = broadPhaseNode; ptr->m_parent; ptr = ptr->m_parent) { - dgBroadPhaseTreeNode* const parent = (dgBroadPhaseTreeNode*)ptr->m_parent; - if (!parent->IsAggregate()) { - dgAssert(!parent->IsLeafNode()); - dgBroadPhaseNode* const rightSibling = parent->m_right; - if (rightSibling != ptr) { - SubmitPairs(broadPhaseNode, rightSibling, timestep, threadCount, threadID); - } else { - SubmitPairs(broadPhaseNode, parent->m_left, timestep, threadCount, threadID); - } - } - } - } - } -} - diff --git a/thirdparty/src/newton/dgPhysics/dgBroadPhaseMixed.h b/thirdparty/src/newton/dgPhysics/dgBroadPhaseMixed.h deleted file mode 100644 index 4bdfbb83b..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBroadPhaseMixed.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __AFX_BROADPHASE_DEFAULT_H_ -#define __AFX_BROADPHASE_DEFAULT_H_ - -#include "dgPhysicsStdafx.h" -#include "dgBroadPhase.h" - - -class dgBroadPhaseMixed: public dgBroadPhase -{ - public: - DG_CLASS_ALLOCATOR(allocator); - - dgBroadPhaseMixed(dgWorld* const world); - virtual ~dgBroadPhaseMixed(); - - protected: - virtual dgInt32 GetType() const; - virtual void Add(dgBody* const body); - virtual void Remove(dgBody* const body); - virtual void UpdateFitness(); - virtual void InvalidateCache(); - virtual dgBroadPhaseAggregate* CreateAggregate(); - virtual void DestroyAggregate(dgBroadPhaseAggregate* const aggregate); - - virtual void LinkAggregate (dgBroadPhaseAggregate* const aggregate); - virtual void UnlinkAggregate (dgBroadPhaseAggregate* const aggregate); - virtual void CheckStaticDynamic(dgBody* const body, dgFloat32 mass) {} - virtual void FindCollidingPairs (dgBroadphaseSyncDescriptor* const descriptor, dgList<dgBroadPhaseNode*>::dgListNode* const node, dgInt32 threadID); - - void RayCast (const dgVector& p0, const dgVector& p1, OnRayCastAction filter, OnRayPrecastAction prefilter, void* const userData) const; - dgInt32 Collide(dgCollisionInstance* const shape, const dgMatrix& matrix, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const; - dgInt32 ConvexCast (dgCollisionInstance* const shape, const dgMatrix& p0, const dgVector& p1, dgFloat32* const param, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const; - void ForEachBodyInAABB (const dgVector& q0, const dgVector& q1, OnBodiesInAABB callback, void* const userData) const; - - void ResetEntropy (); - void AddNode(dgBroadPhaseNode* const node); - void RemoveNode(dgBroadPhaseNode* const node); - - void ApplyDeformableForceAndtorque (dgBroadphaseSyncDescriptor* const descriptor, dgInt32 threadID); - - dgFloat64 m_treeEntropy; - dgFitnessList m_fitness; - -}; - - -#endif diff --git a/thirdparty/src/newton/dgPhysics/dgBroadPhaseSegregated.cpp b/thirdparty/src/newton/dgPhysics/dgBroadPhaseSegregated.cpp deleted file mode 100644 index b155f013f..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBroadPhaseSegregated.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgCollisionInstance.h" -#include "dgBroadPhaseAggregate.h" -#include "dgBroadPhaseSegregated.h" - - -class dgBroadPhaseSegregatedRootNode: public dgBroadPhaseTreeNode -{ - public: - dgBroadPhaseSegregatedRootNode() - :dgBroadPhaseTreeNode() - { - } - - virtual bool IsSegregatedRoot() const - { - return true; - } - - void SetBox () - { - if (m_right && m_left) { - dgVector minBox (m_right->m_minBox.GetMin(m_left->m_minBox)); - dgVector maxBox (m_right->m_maxBox.GetMin(m_left->m_maxBox)); - SetAABB(minBox, maxBox); - } else if (m_right) { - SetAABB(m_right->m_minBox, m_right->m_maxBox); - } else if (m_left) { - SetAABB(m_left->m_minBox, m_left->m_maxBox); - } - } -}; - -dgBroadPhaseSegregated::dgBroadPhaseSegregated (dgWorld* const world) - :dgBroadPhase(world) - ,m_staticEntropy(dgFloat32 (0.0f)) - ,m_dynamicsEntropy(dgFloat32 (0.0f)) - ,m_staticFitness(world->GetAllocator()) - ,m_dynamicsFitness(world->GetAllocator()) - ,m_staticNeedsUpdate(true) -{ - m_rootNode = new (world->GetAllocator()) dgBroadPhaseSegregatedRootNode(); -} - -dgBroadPhaseSegregated::~dgBroadPhaseSegregated () -{ - delete m_rootNode; -} - -dgInt32 dgBroadPhaseSegregated::GetType() const -{ - return dgWorld::m_broadphaseSegregated; -} - -void dgBroadPhaseSegregated::CheckStaticDynamic(dgBody* const body, dgFloat32 mass1) -{ - dgBroadPhaseNode* const node = body->GetBroadPhase(); - if (node) { - const dgFloat32 mass0 = body->GetMass().m_w; - const bool m0 = (mass0 >= DG_INFINITE_MASS); - const bool m1 = (mass1 >= DG_INFINITE_MASS); - if (m0 ^ m1) { - Remove(body); - if (m1) { - AddStaticBody (body); - } else { - AddDynamicBody (body); - } - } - } -} - -void dgBroadPhaseSegregated::AddStaticBody(dgBody* const body) -{ - dgBroadPhaseSegregatedRootNode* const root = (dgBroadPhaseSegregatedRootNode*)m_rootNode; - dgAssert(m_rootNode->IsSegregatedRoot()); - - m_staticNeedsUpdate = true; - dgBroadPhaseBodyNode* const bodyNode = new (m_world->GetAllocator()) dgBroadPhaseBodyNode(body); - if (root->m_right) { - dgBroadPhaseTreeNode* const node = InsertNode(root->m_right, bodyNode); - node->m_fitnessNode = m_staticFitness.Append(node); - } else { - root->m_right = bodyNode; - root->m_right->m_parent = root; - } -} - -void dgBroadPhaseSegregated::AddDynamicBody(dgBody* const body) -{ - dgBroadPhaseSegregatedRootNode* const root = (dgBroadPhaseSegregatedRootNode*)m_rootNode; - dgAssert(m_rootNode->IsSegregatedRoot()); - - dgBroadPhaseBodyNode* const newNode = new (m_world->GetAllocator()) dgBroadPhaseBodyNode(body); - if (root->m_left) { - dgBroadPhaseTreeNode* const node = InsertNode(root->m_left, newNode); - node->m_fitnessNode = m_dynamicsFitness.Append(node); - } else { - root->m_left = newNode; - root->m_left->m_parent = root; - } - newNode->m_updateNode = m_updateList.Append(newNode); -} - - -void dgBroadPhaseSegregated::Add(dgBody* const body) -{ - dgAssert (!body->GetCollision()->IsType (dgCollision::dgCollisionNull_RTTI)); - dgAssert (((dgBroadPhaseSegregatedRootNode*)m_rootNode)->IsSegregatedRoot()); - - if (body->GetCollision()->IsType(dgCollision::dgCollisionMesh_RTTI) || (body->GetInvMass().m_w == dgFloat32(0.0f))) { - AddStaticBody(body); - } else { - AddDynamicBody(body); - } -} - -dgBroadPhaseAggregate* dgBroadPhaseSegregated::CreateAggregate() -{ - dgBroadPhaseAggregate* const aggregate = new (m_world->GetAllocator()) dgBroadPhaseAggregate(m_world->GetBroadPhase()); - LinkAggregate(aggregate); - return aggregate; -} - -void dgBroadPhaseSegregated::LinkAggregate(dgBroadPhaseAggregate* const aggregate) -{ - dgAssert(m_rootNode->IsSegregatedRoot()); - dgBroadPhaseSegregatedRootNode* const root = (dgBroadPhaseSegregatedRootNode*)m_rootNode; - - aggregate->m_broadPhase = this; - if (root->m_left) { - dgBroadPhaseTreeNode* const node = InsertNode(root->m_left, aggregate); - node->m_fitnessNode = m_dynamicsFitness.Append(node); - } else { - root->m_left = aggregate; - root->m_left->m_parent = m_rootNode; - } - aggregate->m_updateNode = m_updateList.Append(aggregate); - aggregate->m_myAggregateNode = m_aggregateList.Append(aggregate); -} - -void dgBroadPhaseSegregated::DestroyAggregate(dgBroadPhaseAggregate* const aggregate) -{ - m_updateList.Remove(aggregate->m_updateNode); - m_aggregateList.Remove(aggregate->m_myAggregateNode); - RemoveNode(aggregate); -} - -void dgBroadPhaseSegregated::RemoveNode(dgBroadPhaseNode* const node) -{ - dgAssert (node->m_parent); - - if (node->m_parent->IsSegregatedRoot()) { - dgBroadPhaseSegregatedRootNode* const parent = (dgBroadPhaseSegregatedRootNode*)m_rootNode; - dgAssert(parent == node->m_parent); - - if (parent->m_right == node) { - m_staticNeedsUpdate = true; - parent->m_right = NULL; - } else { - dgAssert(parent->m_left == node); - parent->m_left = NULL; - } - node->m_parent = NULL; - delete node; - } else if (node->m_parent->IsAggregate()) { - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*)node->m_parent; - dgBody* const body = node->GetBody(); - dgAssert(body); - dgAssert(body->GetBroadPhaseAggregate() == aggregate); - body->SetBroadPhaseAggregate(NULL); - aggregate->m_root = NULL; - node->m_parent = NULL; - delete node; - } else { - dgBroadPhaseTreeNode* const parent = (dgBroadPhaseTreeNode*)node->m_parent; - if (parent->m_parent->IsAggregate()) { - dgBroadPhaseAggregate* const aggregate = (dgBroadPhaseAggregate*)parent->m_parent; - if (parent->m_left == node) { - dgAssert(parent->m_right); - aggregate->m_root = parent->m_right; - parent->m_right->m_parent = aggregate; - parent->m_right = NULL; - } else { - dgAssert(parent->m_right == node); - aggregate->m_root = parent->m_left; - parent->m_left->m_parent = aggregate; - parent->m_left = NULL; - } - parent->m_parent = NULL; - - if (parent->m_fitnessNode) { - dgBody* const body = node->GetBody(); - if (body && body->GetBroadPhaseAggregate()) { - body->GetBroadPhaseAggregate()->m_fitnessList.Remove(parent->m_fitnessNode); - body->SetBroadPhaseAggregate(NULL); - } else { - m_dynamicsFitness.Remove(parent->m_fitnessNode); - } - } - - delete parent; - - } else if (parent->m_parent->IsSegregatedRoot()) { - dgBroadPhaseSegregatedRootNode* const grandParent = (dgBroadPhaseSegregatedRootNode*) parent->m_parent; - if (grandParent->m_right == parent) { - m_staticNeedsUpdate = true; - if (parent->m_right == node) { - grandParent->m_right = parent->m_left; - parent->m_left->m_parent = grandParent; - parent->m_left = NULL; - parent->m_parent = NULL; - } else { - grandParent->m_right = parent->m_right; - parent->m_right->m_parent = grandParent; - parent->m_right = NULL; - parent->m_parent = NULL; - } - m_staticFitness.Remove(parent->m_fitnessNode); - delete parent; - } else { - dgAssert (grandParent->m_left == parent); - if (parent->m_right == node) { - grandParent->m_left = parent->m_left; - parent->m_left->m_parent = grandParent; - parent->m_left = NULL; - parent->m_parent = NULL; - } else { - grandParent->m_left = parent->m_right; - parent->m_right->m_parent = grandParent; - parent->m_right = NULL; - parent->m_parent = NULL; - } - m_dynamicsFitness.Remove(parent->m_fitnessNode); - delete parent; - } - } else { - dgBroadPhaseTreeNode* const grandParent = (dgBroadPhaseTreeNode*)parent->m_parent; - dgAssert (grandParent->GetLeft()); - dgAssert (grandParent->GetRight()); - if (grandParent->m_left == parent) { - if (parent->m_right == node) { - grandParent->m_left = parent->m_left; - parent->m_left->m_parent = grandParent; - parent->m_left = NULL; - parent->m_parent = NULL; - } else { - grandParent->m_left = parent->m_right; - parent->m_right->m_parent = grandParent; - parent->m_right = NULL; - parent->m_parent = NULL; - } - } else { - if (parent->m_right == node) { - grandParent->m_right = parent->m_left; - parent->m_left->m_parent = grandParent; - parent->m_left = NULL; - parent->m_parent = NULL; - } else { - grandParent->m_right = parent->m_right; - parent->m_right->m_parent = grandParent; - parent->m_right = NULL; - parent->m_parent = NULL; - } - } - - dgBody* const body = node->GetBody(); - if (body) { - if (body->GetInvMass().m_w == dgFloat32(0.0f)) { - m_staticNeedsUpdate = true; - m_staticFitness.Remove(parent->m_fitnessNode); - } else if (body->GetBroadPhaseAggregate()) { - body->GetBroadPhaseAggregate()->m_fitnessList.Remove(parent->m_fitnessNode); - body->SetBroadPhaseAggregate(NULL); - } else { - m_dynamicsFitness.Remove(parent->m_fitnessNode); - } - } else { - dgAssert (node->IsAggregate()); - m_dynamicsFitness.Remove(parent->m_fitnessNode); - } - - delete parent; - } - } -} - -void dgBroadPhaseSegregated::UnlinkAggregate (dgBroadPhaseAggregate* const aggregate) -{ - dgBroadPhaseSegregatedRootNode* const root = (dgBroadPhaseSegregatedRootNode*)m_rootNode; - dgAssert (root && root->m_left); - if (aggregate->m_parent == root) { - root->m_left = NULL; - } else { - dgBroadPhaseTreeNode* const parent = (dgBroadPhaseTreeNode*)aggregate->m_parent; - dgBroadPhaseTreeNode* const grandParent = (dgBroadPhaseTreeNode*)parent->m_parent; - if (grandParent->m_left == parent) { - if (parent->m_left == aggregate) { - grandParent->m_left = parent->m_right; - parent->m_right->m_parent = grandParent; - } else { - dgAssert(parent->m_right == aggregate); - grandParent->m_left = parent->m_left; - parent->m_left->m_parent = grandParent; - } - } else { - dgAssert(grandParent->m_right == parent); - if (parent->m_left == aggregate) { - grandParent->m_right = parent->m_right; - parent->m_right->m_parent = grandParent; - } else { - dgAssert(parent->m_right == aggregate); - grandParent->m_right = parent->m_left; - parent->m_left->m_parent = grandParent; - } - } - parent->m_left = NULL; - parent->m_right = NULL; - parent->m_parent = NULL; - delete parent; - } - aggregate->m_parent = NULL; -} - -void dgBroadPhaseSegregated::Remove(dgBody* const body) -{ - if (body->GetBroadPhase()) { - dgBroadPhaseBodyNode* const node = body->GetBroadPhase(); - if (node->m_updateNode) { - m_updateList.Remove(node->m_updateNode); - } - RemoveNode(node); - } -} - -void dgBroadPhaseSegregated::ResetEntropy() -{ - m_staticNeedsUpdate = true; - m_staticEntropy = dgFloat32(0.0f); - m_dynamicsEntropy = dgFloat32(0.0f); -} - - -void dgBroadPhaseSegregated::InvalidateCache() -{ - ResetEntropy(); - m_staticNeedsUpdate = false; - dgAssert (m_rootNode->IsSegregatedRoot()); - dgBroadPhaseSegregatedRootNode* const root = (dgBroadPhaseSegregatedRootNode*)m_rootNode; - ImproveFitness(m_staticFitness, m_staticEntropy, &root->m_right); - ImproveFitness(m_dynamicsFitness, m_dynamicsEntropy, &root->m_left); - root->SetBox (); - m_contactCache.Flush(); -} - -void dgBroadPhaseSegregated::UpdateFitness() -{ - dgBroadPhaseSegregatedRootNode* const root = (dgBroadPhaseSegregatedRootNode*)m_rootNode; - if (m_staticNeedsUpdate) { - m_staticNeedsUpdate = false; - ImproveFitness(m_staticFitness, m_staticEntropy, &root->m_right); - } - ImproveFitness(m_dynamicsFitness, m_dynamicsEntropy, &root->m_left); - root->SetBox (); -} - -void dgBroadPhaseSegregated::ForEachBodyInAABB(const dgVector& minBox, const dgVector& maxBox, OnBodiesInAABB callback, void* const userData) const -{ - dgBroadPhaseSegregatedRootNode* const root = (dgBroadPhaseSegregatedRootNode*)m_rootNode; - const dgBroadPhaseNode* stackPool[DG_BROADPHASE_MAX_STACK_DEPTH]; - - dgInt32 stack = 0; - if (root->m_left) { - stackPool[stack] = root->m_left; - stack++; - } - - if (root->m_right) { - stackPool[stack] = root->m_right; - stack++; - } - dgBroadPhase::ForEachBodyInAABB(stackPool, stack, minBox, maxBox, callback, userData); -} - -void dgBroadPhaseSegregated::RayCast(const dgVector& l0, const dgVector& l1, OnRayCastAction filter, OnRayPrecastAction prefilter, void* const userData) const -{ - dgBroadPhaseSegregatedRootNode* const root = (dgBroadPhaseSegregatedRootNode*)m_rootNode; - if (filter && (root->m_left || root->m_right)) { - dgVector segment(l1 - l0); - dgAssert (segment.m_w == dgFloat32 (0.0f)); - dgFloat32 dist2 = segment.DotProduct(segment).GetScalar(); - if (dist2 > dgFloat32(1.0e-8f)) { - - dgFloat32 distance[DG_BROADPHASE_MAX_STACK_DEPTH]; - const dgBroadPhaseNode* stackPool[DG_BROADPHASE_MAX_STACK_DEPTH]; - - dgFastRayTest ray(l0, l1); - - dgInt32 stack = 0; - if (root->m_left) { - stackPool[stack] = root->m_left; - distance[stack] = ray.BoxIntersect(root->m_left->m_minBox, root->m_left->m_maxBox); - stack++; - } - if (root->m_right) { - stackPool[stack] = root->m_right; - distance[stack] = ray.BoxIntersect(root->m_right->m_minBox, root->m_right->m_maxBox); - stack++; - } - if (stack == 2) { - if (distance[0] < distance[1]) { - dgSwap(distance[0], distance[1]); - dgSwap(stackPool[0], stackPool[1]); - } - } - - dgBroadPhase::RayCast(stackPool, distance, stack, l0, l1, ray, filter, prefilter, userData); - } - } -} - -dgInt32 dgBroadPhaseSegregated::ConvexCast(dgCollisionInstance* const shape, const dgMatrix& matrix, const dgVector& target, dgFloat32* const param, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const -{ - dgInt32 totalCount = 0; - if (m_rootNode) { - dgVector boxP0; - dgVector boxP1; - dgAssert(matrix.TestOrthogonal()); - shape->CalcAABB(matrix, boxP0, boxP1); - - dgFloat32 distance[DG_BROADPHASE_MAX_STACK_DEPTH]; - const dgBroadPhaseNode* stackPool[DG_BROADPHASE_MAX_STACK_DEPTH]; - - dgVector velocA((target - matrix.m_posit) & dgVector::m_triplexMask); - dgVector velocB(dgFloat32(0.0f)); - dgFastRayTest ray(dgVector(dgFloat32(0.0f)), velocA); - - dgInt32 stack = 0; - dgBroadPhaseSegregatedRootNode* const root = (dgBroadPhaseSegregatedRootNode*)m_rootNode; - if (root->m_left) { - dgVector minBox(root->m_left->m_minBox - boxP1); - dgVector maxBox(root->m_left->m_maxBox - boxP0); - stackPool[stack] = root->m_left; - distance[stack] = ray.BoxIntersect(minBox, maxBox); - stack++; - } - if (root->m_right) { - dgVector minBox(root->m_right->m_minBox - boxP1); - dgVector maxBox(root->m_right->m_maxBox - boxP0); - - stackPool[stack] = root->m_right; - distance[stack] = ray.BoxIntersect(minBox, maxBox); - stack++; - } - if (stack == 2) { - if (distance[0] < distance[1]) { - dgSwap(distance[0], distance[1]); - dgSwap(stackPool[0], stackPool[1]); - } - } - - *param = dgFloat32 (1.0f); - totalCount = dgBroadPhase::ConvexCast(stackPool, distance, 2, velocA, velocB, ray, shape, matrix, target, param, prefilter, userData, info, maxContacts, threadIndex); - } - return totalCount; -} - -dgInt32 dgBroadPhaseSegregated::Collide(dgCollisionInstance* const shape, const dgMatrix& matrix, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const -{ - dgInt32 totalCount = 0; - if (m_rootNode) { - dgVector boxP0; - dgVector boxP1; - dgAssert(matrix.TestOrthogonal()); - shape->CalcAABB(shape->GetLocalMatrix() * matrix, boxP0, boxP1); - - dgInt32 overlaped[DG_BROADPHASE_MAX_STACK_DEPTH]; - const dgBroadPhaseNode* stackPool[DG_BROADPHASE_MAX_STACK_DEPTH]; - - dgInt32 stack = 0; - dgBroadPhaseSegregatedRootNode* const root = (dgBroadPhaseSegregatedRootNode*)m_rootNode; - if (dgOverlapTest(m_rootNode->m_minBox, m_rootNode->m_maxBox, boxP0, boxP1)) { - if (root->m_left) { - stackPool[stack] = root->m_left; - overlaped[stack] = dgOverlapTest(root->m_left->m_minBox, root->m_left->m_maxBox, boxP0, boxP1); - stack ++; - } - if (root->m_right) { - stackPool[stack] = root->m_right; - overlaped[stack] = dgOverlapTest(root->m_right->m_minBox, root->m_right->m_maxBox, boxP0, boxP1); - stack++; - } - totalCount = dgBroadPhase::Collide(stackPool, overlaped, stack, boxP0, boxP1, shape, matrix, prefilter, userData, info, maxContacts, threadIndex); - } - } - - return totalCount; -} - -void dgBroadPhaseSegregated::FindCollidingPairs (dgBroadphaseSyncDescriptor* const descriptor, dgList<dgBroadPhaseNode*>::dgListNode* const nodePtr, dgInt32 threadID) -{ - DG_TRACKTIME(); - const dgFloat32 timestep = descriptor->m_timestep; - - dgList<dgBroadPhaseNode*>::dgListNode* node = nodePtr; - const dgInt32 threadCount = descriptor->m_world->GetThreadCount(); - - if (descriptor->m_fullScan) { - while (node) { - dgBroadPhaseNode* const broadPhaseNode = node->GetInfo(); - dgAssert(broadPhaseNode->IsLeafNode()); - - dgBody* const body = broadPhaseNode->GetBody(); - dgAssert(!body || (body->GetBroadPhase() == broadPhaseNode)); - - if (!(body && body->m_isdead)) { - if (broadPhaseNode->IsAggregate()) { - ((dgBroadPhaseAggregate*)broadPhaseNode)->SubmitSelfPairs(timestep, threadID); - } - - for (dgBroadPhaseNode* ptr = broadPhaseNode; ptr->m_parent; ptr = ptr->m_parent) { - dgBroadPhaseTreeNode* const parent = (dgBroadPhaseTreeNode*)ptr->m_parent; - dgAssert(!parent->IsLeafNode()); - dgBroadPhaseNode* const sibling = parent->m_right; - if (sibling && (sibling != ptr)) { - SubmitPairs(broadPhaseNode, sibling, timestep, 0, threadID); - } - } - } - - for (dgInt32 i = 0; i < threadCount; i++) { - dgBroadPhaseNode* const info = node ? node->GetInfo() : NULL; - node = (info && ((info->GetBody() && (info->GetBody()->GetInvMass().m_w != dgFloat32(0.0f))) || info->IsAggregate())) ? node->GetNext() : NULL; - } - } - - } else { - const dgBodyInfo* const bodyArray = &m_world->m_bodiesMemory[0]; - const dgInt32 bodyCount = descriptor->m_atomicPendingBodiesCount; - dgInt32* const atomicIndex = &descriptor->m_atomicIndex; - - for (dgInt32 i = dgAtomicExchangeAndAdd(atomicIndex, 1); i < bodyCount; i = dgAtomicExchangeAndAdd(atomicIndex, 1)) { - dgBroadPhaseNode* const broadPhaseNode = bodyArray[i].m_body->GetBroadPhase(); - - dgAssert(broadPhaseNode->IsLeafNode()); - dgAssert(!broadPhaseNode->GetBody() || (broadPhaseNode->GetBody()->GetBroadPhase() == broadPhaseNode)); - - for (dgBroadPhaseNode* ptr = broadPhaseNode; ptr->m_parent; ptr = ptr->m_parent) { - dgBroadPhaseTreeNode* const parent = (dgBroadPhaseTreeNode*)ptr->m_parent; - if (!parent->IsAggregate()) { - dgAssert(!parent->IsLeafNode()); - dgBroadPhaseNode* const rightSibling = parent->m_right; - if (rightSibling && (rightSibling != ptr)) { - SubmitPairs(broadPhaseNode, rightSibling, timestep, 0, threadID); - } - - dgBroadPhaseNode* const leftSibling = parent->m_left; - if (leftSibling && (leftSibling != ptr)) { - SubmitPairs(broadPhaseNode, leftSibling, timestep, threadCount, threadID); - } - } - } - } - } -} - diff --git a/thirdparty/src/newton/dgPhysics/dgBroadPhaseSegregated.h b/thirdparty/src/newton/dgPhysics/dgBroadPhaseSegregated.h deleted file mode 100644 index fd8a4af7e..000000000 --- a/thirdparty/src/newton/dgPhysics/dgBroadPhaseSegregated.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __AFX_BROADPHASE_PERSINTENT_H_ -#define __AFX_BROADPHASE_PERSINTENT_H_ - -#include "dgPhysicsStdafx.h" -#include "dgBroadPhase.h" - - -class dgBroadPhaseSegregated : public dgBroadPhase -{ - public: - DG_CLASS_ALLOCATOR(allocator); - - dgBroadPhaseSegregated (dgWorld* const world); - virtual ~dgBroadPhaseSegregated (); - - protected: - virtual dgInt32 GetType() const; - virtual void Add(dgBody* const body); - virtual void Remove(dgBody* const body); - virtual void InvalidateCache(); - virtual dgBroadPhaseAggregate* CreateAggregate(); - virtual void DestroyAggregate(dgBroadPhaseAggregate* const aggregate); - - virtual void CheckStaticDynamic(dgBody* const body, dgFloat32 mass); - virtual void LinkAggregate(dgBroadPhaseAggregate* const aggregate); - virtual void UnlinkAggregate(dgBroadPhaseAggregate* const aggregate); - virtual void FindCollidingPairs (dgBroadphaseSyncDescriptor* const descriptor, dgList<dgBroadPhaseNode*>::dgListNode* const node, dgInt32 threadID); - - virtual void ResetEntropy(); - virtual void UpdateFitness(); - virtual void ForEachBodyInAABB(const dgVector& minBox, const dgVector& maxBox, OnBodiesInAABB callback, void* const userData) const; - virtual void RayCast(const dgVector& p0, const dgVector& p1, OnRayCastAction filter, OnRayPrecastAction prefilter, void* const userData) const; - virtual dgInt32 Collide(dgCollisionInstance* const shape, const dgMatrix& matrix, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const; - virtual dgInt32 ConvexCast(dgCollisionInstance* const shape, const dgMatrix& matrix, const dgVector& target, dgFloat32* const param, OnRayPrecastAction prefilter, void* const userData, dgConvexCastReturnInfo* const info, dgInt32 maxContacts, dgInt32 threadIndex) const; - void RemoveNode(dgBroadPhaseNode* const node); - - private: - void AddStaticBody(dgBody* const body); - void AddDynamicBody(dgBody* const body); - - dgFloat64 m_staticEntropy; - dgFloat64 m_dynamicsEntropy; - dgFitnessList m_staticFitness; - dgFitnessList m_dynamicsFitness; - bool m_staticNeedsUpdate; -}; -#endif diff --git a/thirdparty/src/newton/dgPhysics/dgCollision.cpp b/thirdparty/src/newton/dgPhysics/dgCollision.cpp deleted file mode 100644 index 4f8353ce4..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollision.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgCollision.h" - -dgVector dgCollision::m_flushZero (dgFloat32 (1.0e-7f)); - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -dgCollision::dgCollision(dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgCollisionID id) - :m_inertia(dgVector::m_zero) - ,m_crossInertia(dgVector::m_zero) - ,m_centerOfMass(dgVector::m_zero) - ,m_boxSize (dgVector::m_zero) - ,m_boxOrigin (dgVector::m_zero) - ,m_rtti(0) - ,m_refCount(1) - ,m_signature(signature) - ,m_collisionId(id) - ,m_allocator(allocator) -{ -} - -dgCollision::dgCollision (const dgCollision& source) - :m_inertia(source.m_inertia) - ,m_crossInertia(source.m_crossInertia) - ,m_centerOfMass(source.m_centerOfMass) - ,m_boxSize(source.m_boxSize) - ,m_boxOrigin (source.m_boxOrigin) - ,m_rtti(source.m_rtti) - ,m_refCount(1) - ,m_signature(source.m_signature) - ,m_collisionId(source.m_collisionId) - ,m_allocator(source.m_allocator) -{ -} - -dgCollision::dgCollision (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revision) - :m_inertia(dgVector::m_zero) - ,m_crossInertia(dgVector::m_zero) - ,m_centerOfMass(dgVector::m_zero) - ,m_boxSize (dgVector::m_zero) - ,m_boxOrigin (dgVector::m_zero) - ,m_rtti(0) - ,m_refCount(1) - ,m_signature(0) - ,m_collisionId(dgCollisionID(0)) - ,m_allocator(world->GetAllocator()) -{ - dgInt32 collisionId; - deserialization (userData, &m_inertia, sizeof (m_inertia)); - deserialization (userData, &m_crossInertia, sizeof (m_crossInertia)); - deserialization (userData, &m_centerOfMass, sizeof (m_centerOfMass)); - deserialization (userData, &m_boxSize, sizeof (m_boxSize)); - deserialization (userData, &m_boxOrigin, sizeof (m_boxOrigin)); - deserialization (userData, &m_rtti, sizeof (m_rtti)); - deserialization (userData, &m_signature, sizeof (m_signature)); - deserialization (userData, &collisionId, sizeof (collisionId)); - m_collisionId = dgCollisionID(collisionId); -} - -dgCollision::~dgCollision() -{ -} - -dgUnsigned32 dgCollision::Quantize(dgFloat32 value) -{ - return dgUnsigned32 (value * 1024.0f); -} - -dgUnsigned32 dgCollision::Quantize(const void* const buffer, int size) -{ - dgUnsigned32 crc = dgCRC (buffer, size); - return crc; -} - -void dgCollision::MassProperties () -{ - // using general central theorem, to extract the Inertia relative to the center of mass - //IImatrix = IIorigin + unitmass * [(displacemnet % displacemnet) * identityMatrix - transpose(displacement) * displacement)]; - - dgMatrix inertia (dgGetIdentityMatrix()); - inertia[0][0] = m_inertia[0]; - inertia[1][1] = m_inertia[1]; - inertia[2][2] = m_inertia[2]; - inertia[0][1] = m_crossInertia[2]; - inertia[1][0] = m_crossInertia[2]; - inertia[0][2] = m_crossInertia[1]; - inertia[2][0] = m_crossInertia[1]; - inertia[1][2] = m_crossInertia[0]; - inertia[2][1] = m_crossInertia[0]; - - dgVector origin (m_centerOfMass); - dgFloat32 originMag2 = origin.DotProduct(origin & dgVector::m_triplexMask).GetScalar(); - - dgMatrix Covariance (origin, origin); - dgMatrix parallel (dgGetIdentityMatrix()); - for (dgInt32 i = 0; i < 3; i ++ ) { - parallel[i][i] = originMag2; - inertia[i] += (parallel[i] - Covariance[i]); - dgAssert (inertia[i][i] > dgFloat32 (0.0f)); - } - - m_inertia[0] = inertia[0][0]; - m_inertia[1] = inertia[1][1]; - m_inertia[2] = inertia[2][2]; - m_crossInertia[0] = inertia[2][1]; - m_crossInertia[1] = inertia[2][0]; - m_crossInertia[2] = inertia[1][0]; -} - - -void dgCollision::GetCollisionInfo(dgCollisionInfo* const info) const -{ - info->m_collisionType = m_collisionId; -} - -void dgCollision::SerializeLow (dgSerialize callback, void* const userData) const -{ - dgInt32 collisionId = m_collisionId; - callback (userData, &m_inertia, sizeof (m_inertia)); - callback (userData, &m_crossInertia, sizeof (m_crossInertia)); - callback (userData, &m_centerOfMass, sizeof (m_centerOfMass)); - callback (userData, &m_boxSize, sizeof (m_boxSize)); - callback (userData, &m_boxOrigin, sizeof (m_boxOrigin)); - callback (userData, &m_rtti, sizeof (m_rtti)); - callback (userData, &m_signature, sizeof (m_signature)); - callback (userData, &collisionId, sizeof (collisionId)); -} - diff --git a/thirdparty/src/newton/dgPhysics/dgCollision.h b/thirdparty/src/newton/dgPhysics/dgCollision.h deleted file mode 100644 index d9cd8f2c0..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollision.h +++ /dev/null @@ -1,397 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_COLLISION_H_ -#define _DG_COLLISION_H_ - - -class dgBody; -class dgWorld; -class dgCollision; -class dgMeshEffect; -class dgContactPoint; -class dgPolygonSoupDesc; -class dgCollisionConvex; -class dgPolygonMeshDesc; -class dgCollisionInstance; -class dgCollisionConvexHull; -class dgPolygonSoupRayHitDesc; - -#ifdef _DEBUG -// #define DG_DEBUG_AABB -#endif - -#define PREFILTER_RAYCAST(filter,body,collision,userData) (filter && !filter(body,collision,userData)) - -typedef dgInt32(dgApi *OnBodiesInAABB) (dgBody* body, void* const userData); -typedef dgUnsigned32(dgApi *OnRayPrecastAction) (const dgBody* const body, const dgCollisionInstance* const collision, void* const userData); -typedef dgFloat32(dgApi *OnRayCastAction) (const dgBody* const body, const dgCollisionInstance* const collision, const dgVector& contact, const dgVector& normal, dgInt64 collisionID, void* const userData, dgFloat32 intersetParam); - - -enum dgCollisionID -{ - // do not change the order of these enum - m_sphereCollision = 0, - m_capsuleCollision, - m_cylinderCollision, - m_chamferCylinderCollision, - m_boxCollision, - m_coneCollision, - m_convexHullCollision, - // this must be the last convex shape ID - m_nullCollision, - - m_compoundCollision, - m_boundingBoxHierachy, - m_heightField, - m_deformableClothPatch, - m_deformableSolidMesh, - m_userMesh, - m_sceneCollision, - m_compoundFracturedCollision, - - // these are for internal use only - m_contactCloud, - m_polygonCollision, - m_lumpedMassCollision -}; - - -DG_MSC_VECTOR_ALIGNMENT -class dgCollisionInfo -{ - public: - class dgInstanceMaterial - { - public: - dgInstanceMaterial() - { - memset(this, 0, sizeof (dgInstanceMaterial)); - } - - dgInt64 m_userId; - union { - void* m_userData; - dgUnsigned64 m_alignPad; - }; - union { - dgUnsigned64 m_intData; - dgFloat32 m_floatData; - } m_userParam[6]; - }; - - struct dgBoxData - { - dgFloat32 m_x; - dgFloat32 m_y; - dgFloat32 m_z; - } ; - - struct dgSphereData - { - dgFloat32 m_radius; - } ; - - struct dgCylinderData - { - dgFloat32 m_radio0; - dgFloat32 m_radio1; - dgFloat32 m_height; - }; - - struct dgCapsuleData - { - dgFloat32 m_radio0; - dgFloat32 m_radio1; - dgFloat32 m_height; - }; - - struct dgConeData - { - dgFloat32 m_r; - dgFloat32 m_height; - }; - - struct dgChamferCylinderData - { - dgFloat32 m_r; - dgFloat32 m_height; - }; - - struct dgConvexHullData - { - dgInt32 m_vertexCount; - dgInt32 m_strideInBytes; - dgInt32 m_faceCount; - dgVector* m_vertex; - }; - - struct dgConvexModifierData - { - dgCollision* m_child; - }; - - struct dgCoumpountCollisionData - { - dgInt32 m_chidrenCount; - //dgCollision** m_chidren; - }; - - struct dgCollisionBVHData - { - dgInt32 m_vertexCount; - dgInt32 m_indexCount; - }; - - struct dgDeformableMeshData - { - dgInt32 m_vertexCount; - dgInt32 m_triangleCount; - dgInt32 m_vertexStrideInBytes; - dgUnsigned16* m_indexList; - dgFloat32* m_vertexList; - }; - - struct dgHeightMapCollisionData - { - dgInt32 m_width; - dgInt32 m_height; - dgInt32 m_gridsDiagonals; - dgInt32 m_elevationDataType; // 0 = 32 bit floats, 1 = unsigned 16 bit intergers - dgFloat32 m_verticalScale; - dgFloat32 m_horizonalScale_x; - dgFloat32 m_horizonalScale_z; - void* m_elevation; - dgInt8* m_atributes; - }; - - struct dgSceneData - { - dgInt32 m_childrenProxyCount; - }; - - dgMatrix m_offsetMatrix; - dgInstanceMaterial m_collisionMaterial; - dgInt32 m_collisionType; - union - { - dgBoxData m_box; - dgConeData m_cone; - dgSphereData m_sphere; - dgCapsuleData m_capsule; - dgCylinderData m_cylinder; - dgChamferCylinderData m_chamferCylinder; - dgConvexHullData m_convexHull; - dgDeformableMeshData m_deformableMesh; - dgConvexModifierData m_convexModifierData; - dgCoumpountCollisionData m_compoundCollision; - dgCollisionBVHData m_bvhCollision; - dgHeightMapCollisionData m_heightFieldCollision; - dgSceneData m_sceneCollision; - dgFloat32 m_paramArray[32]; - }; -}DG_GCC_VECTOR_ALIGNMENT; - -DG_MSC_VECTOR_ALIGNMENT -class dgCollision -{ - public: - typedef void (dgApi *OnDebugCollisionMeshCallback) (void* userData, int vertexCount, const dgFloat32* faceArray, int faceId); - - enum dgRTTI { - dgCollisionNull_RTTI = 1<<0, - dgCollisionBox_RTTI = 1<<1, - dgCollisionCone_RTTI = 1<<2, - dgCollisionSphere_RTTI = 1<<3, - dgCollisionCapsule_RTTI = 1<<4, - dgCollisionCylinder_RTTI = 1<<5, - dgCollisionConvexHull_RTTI = 1<<6, - dgCollisionChamferCylinder_RTTI = 1<<7, - dgCollisionConvexPolygon_RTTI = 1<<8, - dgCollisionConvexShape_RTTI = 1<<9, - dgCollisionCompound_RTTI = 1<<10, - dgCollisionBVH_RTTI = 1<<11, - dgCollisionMesh_RTTI = 1<<12, - dgCollisionLumpedMass_RTTI = 1<<13, - dgCollisionDeformableMesh_RTTI = 1<<14, - dgCollisionDeformableSolidMesh_RTTI = 1<<15, - dgCollisionMassSpringDamperSystem_RTTI = 1<<16, - dgCollisionIncompressibleParticles_RTTI = 1<<17, - dgCollisionUserMesh_RTTI = 1<<18, - dgCollisionHeightField_RTTI = 1<<19, - dgCollisionScene_RTTI = 1<<20, - dgCollisionCompoundBreakable_RTTI = 1<<21, - }; - - DG_CLASS_ALLOCATOR(allocator) - static dgUnsigned32 Quantize (dgFloat32 value); - static dgUnsigned32 Quantize(const void* const buffer, int size); - - // these function should be be virtual - dgInt32 IsType (dgRTTI type) const; - dgUnsigned32 GetSignature () const; - dgCollisionID GetCollisionPrimityType () const; - - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const = 0; - virtual dgVector SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const = 0; - virtual dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinSkinThickness, dgInt32* const vertexIndex) const = 0; - - virtual dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const = 0; - - virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1) = 0; - virtual void CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const = 0; - - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const = 0; - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const = 0; - - virtual dgFloat32 GetVolume () const = 0; - - virtual void MassProperties (); - virtual dgFloat32 CalculateMassProperties (const dgMatrix& offset, dgVector& inertia, dgVector& crossInertia, dgVector& centerOfMass) const {dgAssert (0); return 0;} - virtual dgMatrix CalculateInertiaAndCenterOfMass (const dgMatrix& m_alignMatrix, const dgVector& localScale, const dgMatrix& matrix) const {dgAssert (0); return dgGetZeroMatrix();} - - virtual dgFloat32 GetBoxMinRadius () const = 0; - virtual dgFloat32 GetBoxMaxRadius () const = 0; - - virtual dgVector CalculateVolumeIntegral (const dgMatrix& globalMatrix, const dgVector& globalPlane, const dgCollisionInstance& parentScale) const = 0; - virtual void Serialize(dgSerialize callback, void* const userData) const = 0; - - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - virtual void SerializeLow(dgSerialize callback, void* const userData) const; - - virtual void CalculateImplicitContacts(dgInt32 count, dgContactPoint* const contactPoints) const {dgAssert (0);} - - - virtual dgInt32 GetConvexVertexCount() const; - - const dgCollision* AddRef () const; - dgInt32 GetRefCount() const; - virtual dgInt32 Release () const; - - const dgVector& GetObbOrigin() const; - virtual dgVector GetObbSize() const; - - dgFloat32 GetUmbraClipSize () const; - dgMemoryAllocator* GetAllocator() const; - - protected: - dgCollision (const dgCollision& source); - dgCollision (dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgCollisionID id); - dgCollision (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revision); - virtual ~dgCollision(); - - void SetSignature (dgInt32 signature); - virtual dgInt32 CalculateSignature () const = 0; - - dgVector m_inertia; - dgVector m_crossInertia; - dgVector m_centerOfMass; - dgVector m_boxSize; - dgVector m_boxOrigin; - dgInt32 m_rtti; - mutable dgInt32 m_refCount; - dgUnsigned32 m_signature; - dgCollisionID m_collisionId; - dgMemoryAllocator* m_allocator; - - static dgVector m_flushZero; - friend class dgBody; - friend class dgWorld; - friend class dgMinkowskiConv; - friend class dgCollisionInstance; - friend class dgCollisionCompound; -}DG_GCC_VECTOR_ALIGNMENT; - -DG_INLINE dgCollisionID dgCollision::GetCollisionPrimityType () const -{ - return m_collisionId; -} - -DG_INLINE dgUnsigned32 dgCollision::GetSignature () const -{ - return m_signature; -} - -DG_INLINE void dgCollision::SetSignature (dgInt32 signature) -{ - m_signature = dgUnsigned32 (signature); -} - - -DG_INLINE const dgCollision* dgCollision::AddRef () const -{ - dgAtomicExchangeAndAdd (&m_refCount, 1); - return this; -} - -DG_INLINE dgInt32 dgCollision::Release () const -{ - dgAtomicExchangeAndAdd (&m_refCount, -1); - if (m_refCount) { - return m_refCount; - } - delete this; - return 0; -} - -DG_INLINE dgInt32 dgCollision::GetRefCount() const -{ - dgAssert (0); - return m_refCount; -} - - -DG_INLINE dgMemoryAllocator* dgCollision::GetAllocator() const -{ - return m_allocator; -} - - -DG_INLINE dgFloat32 dgCollision::GetUmbraClipSize () const -{ -// return GetMax (GetBoxMaxRadius() * dgFloat32 (2.0f) + dgFloat32 (1.0f), dgFloat32 (16.0f)); - return dgFloat32 (3.0f) * GetBoxMaxRadius(); -} - -DG_INLINE dgInt32 dgCollision::GetConvexVertexCount() const -{ - return 0; -} - -DG_INLINE dgInt32 dgCollision::IsType (dgRTTI type) const -{ - return type & m_rtti; -} - -DG_INLINE dgVector dgCollision::GetObbSize() const -{ - return m_boxSize; -} - -DG_INLINE const dgVector& dgCollision::GetObbOrigin() const -{ - return m_boxOrigin; -} - - -#endif - - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionBVH.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionBVH.cpp deleted file mode 100644 index d772d6764..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionBVH.cpp +++ /dev/null @@ -1,422 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgCollisionBVH.h" - - -dgCollisionBVH::dgCollisionBVH(dgWorld* const world) - :dgCollisionMesh (world, m_boundingBoxHierachy), dgAABBPolygonSoup() - ,m_trianglesCount(0) -{ - m_rtti |= dgCollisionBVH_RTTI; - m_builder = NULL; - m_userRayCastCallback = NULL; -} - -dgCollisionBVH::dgCollisionBVH (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionMesh (world, deserialization, userData, revisionNumber) - ,dgAABBPolygonSoup() - ,m_trianglesCount(0) -{ - dgAssert (m_rtti | dgCollisionBVH_RTTI); - m_builder = NULL;; - m_userRayCastCallback = NULL; - - dgAABBPolygonSoup::Deserialize (deserialization, userData, revisionNumber); - - dgVector p0; - dgVector p1; - GetAABB (p0, p1); - SetCollisionBBox(p0, p1); - - deserialization(userData, &m_trianglesCount, sizeof (dgInt32)); -} - -dgCollisionBVH::~dgCollisionBVH(void) -{ -} - -void dgCollisionBVH::Serialize(dgSerialize callback, void* const userData) const -{ - SerializeLow(callback, userData); - dgAABBPolygonSoup::Serialize ((dgSerialize) callback, userData); - callback(userData, &m_trianglesCount, sizeof (dgInt32)); -} - -void dgCollisionBVH::BeginBuild() -{ - m_builder = new (m_allocator) dgPolygonSoupDatabaseBuilder(m_allocator); - m_builder->Begin(); -} - -void dgCollisionBVH::AddFace(dgInt32 vertexCount, const dgFloat32* const vertexPtr, dgInt32 strideInBytes, dgInt32 faceAttribute) -{ - dgInt32 faceArray; - dgInt32 indexList[256]; - - faceArray = vertexCount; - dgAssert (vertexCount < dgInt32 (sizeof (indexList) / sizeof (indexList[0]))); - for (dgInt32 i = 0; i < vertexCount; i ++) { - indexList[i] = i; - } - m_builder->AddMesh (vertexPtr, vertexCount, strideInBytes, 1, &faceArray, indexList, &faceAttribute, dgGetIdentityMatrix()); -} - -void dgCollisionBVH::SetCollisionRayCastCallback (dgCollisionBVHUserRayCastCallback rayCastCallback) -{ - m_userRayCastCallback = rayCastCallback; -} - -void dgCollisionBVH::EndBuild(dgInt32 optimize) -{ - dgVector p0; - dgVector p1; - - bool state = optimize ? true : false; - -#ifdef _DEBUG - if (state && (optimize >> 1)) { - char debugMesh[256]; - sprintf (debugMesh, "debugMesh_%d.ply", optimize-1); - m_builder->SavePLY(debugMesh); - } -#endif - - m_builder->End(state); - Create (*m_builder, state); - CalculateAdjacendy(); - - GetAABB (p0, p1); - SetCollisionBBox (p0, p1); - - delete m_builder; - m_builder = NULL; - - dgMeshVertexListIndexList data; - data.m_indexList = NULL; - data.m_userDataList = NULL; - data.m_maxIndexCount = 1000000000; - data.m_triangleCount = 0; - dgVector zero (dgFloat32 (0.0f)); - dgFastAABBInfo box (dgGetIdentityMatrix(), dgVector (dgFloat32 (1.0e15f))); - ForAllSectors (box, zero, dgFloat32 (1.0f), GetTriangleCount, &data); - m_trianglesCount = data.m_triangleCount; -} - - -void dgCollisionBVH::GetCollisionInfo(dgCollisionInfo* const info) const -{ - dgCollision::GetCollisionInfo(info); - - info->m_bvhCollision.m_vertexCount = GetVertexCount(); - info->m_bvhCollision.m_indexCount = m_trianglesCount * 3; -} - -void dgCollisionBVH::ForEachFace (dgAABBIntersectCallback callback, void* const context) const -{ - dgVector p0 (-1.0e10f, -1.0e10f, -1.0e10f, 1.0f); - dgVector p1 ( 1.0e10f, 1.0e10f, 1.0e10f, 1.0f); - dgVector zero (dgFloat32 (0.0f)); - dgFastAABBInfo box (dgGetIdentityMatrix(), dgVector (dgFloat32 (1.0e15f))); - //ForAllSectors (p0, p1, zero, dgFloat32 (1.0f), callback, context); - ForAllSectors (box, zero, dgFloat32 (1.0f), callback, context); -} - - -dgIntersectStatus dgCollisionBVH::CollectVertexListIndexList (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance) -{ - dgMeshVertexListIndexList& data = (*(dgMeshVertexListIndexList*) context); - - if ((data.m_triangleCount + indexCount - 2) * 3 > data.m_maxIndexCount) { - return t_StopSearh; - } - - dgInt32 k = data.m_triangleCount; - dgInt32 j = data.m_triangleCount * 3; - dgInt32 index0 = indexArray[0]; - dgInt32 index1 = indexArray[1]; - dgInt32 attribute = indexArray[indexCount]; - for (dgInt32 i = 2; i < indexCount; i ++) { - dgInt32 index2 = indexArray[i]; - data.m_indexList[j + 0] = index0; - data.m_indexList[j + 1] = index1; - data.m_indexList[j + 2] = index2; - data.m_userDataList[k] = attribute; - index1 = index2; - k ++; - j += 3; - } - - dgAssert (j <= data.m_maxIndexCount); - data.m_triangleCount = k; - dgAssert ((data.m_triangleCount * 3) <= data.m_maxIndexCount); - - return t_ContinueSearh; -} - - - -dgIntersectStatus dgCollisionBVH::GetTriangleCount (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance) -{ - dgMeshVertexListIndexList& data = (*(dgMeshVertexListIndexList*) context); - - if ((data.m_triangleCount + indexCount - 2) * 3 > data.m_maxIndexCount) { - return t_StopSearh; - } - - data.m_triangleCount += (indexCount - 2); - dgAssert ((data.m_triangleCount * 3) <= data.m_maxIndexCount); - return t_ContinueSearh; -} - - -void dgCollisionBVH::GetVertexListIndexList (const dgVector& p0, const dgVector& p1, dgMeshVertexListIndexList &data) const -{ - dgFastAABBInfo box (p0, p1); - ForAllSectors (box, dgVector (dgFloat32 (0.0f)), dgFloat32 (1.0f), CollectVertexListIndexList, &data); - - data.m_veterxArray = GetLocalVertexPool(); - data.m_vertexCount = GetVertexCount(); - data.m_vertexStrideInBytes = GetStrideInBytes(); - -} - - - -dgFloat32 dgCollisionBVH::RayHit (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount) -{ - dgBVHRay& me = *((dgBVHRay*) context); - dgVector normal (&polygon[indexArray[indexCount + 1] * (strideInBytes / sizeof (dgFloat32))]); - normal = normal & dgVector::m_triplexMask; - dgFloat32 t = me.PolygonIntersect (normal, me.m_t, polygon, strideInBytes, indexArray, indexCount); - if (t <= (me.m_t * dgFloat32 (1.0001f))) { -// if ((t * dgFloat32 (1.0001f)) >= me.m_t) { -// dgFloat32 dist0; -// dgFloat32 dist1; -// dist0 = me.m_diff % normal; -// dist1 = me.m_diff % me.m_normal; -// if (dist0 < dist1) { -// me.m_t = t; -// me.m_normal = normal; -// me.m_id = me.m_me->GetTagId(indexArray, indexCount); -// } else { -// t = me.m_t; -// } -// } else { - me.m_t = t; - me.m_normal = normal; - me.m_id = me.m_me->GetTagId(indexArray, indexCount); -// } - } - return t; -} - -dgFloat32 dgCollisionBVH::RayHitUser (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount) -{ - dgAssert (0); - dgFloat32 t = dgFloat32 (1.2f); - dgBVHRay& me = *((dgBVHRay*) context); - dgVector normal (&polygon[indexArray[indexCount + 1] * (strideInBytes / sizeof (dgFloat32))]); - normal = normal & dgVector::m_triplexMask; -dgAssert (0); - t = me.PolygonIntersect (normal, me.m_t, polygon, strideInBytes, indexArray, indexCount); - if (t < dgFloat32 (1.0f)) { - if (t < me.m_t) { - me.m_t = t; - me.m_normal = normal; - me.m_id = me.m_me->GetTagId(indexArray, indexCount); - } - normal = me.m_matrix.RotateVector(normal); - t = me.m_me->GetDebugRayCastCallback() (me.m_myBody, me.m_me, t, &normal[0], dgInt32 (me.m_me->GetTagId(indexArray, indexCount)), me.m_userData); - } - return t; -} - - - -dgFloat32 dgCollisionBVH::RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const -{ - dgBVHRay ray (localP0, localP1); - ray.m_t = dgMin(maxT, dgFloat32 (1.0f)); - ray.m_me = this; - ray.m_userData = userData; - if (!m_userRayCastCallback) { - ForAllSectorsRayHit (ray, maxT, RayHit, &ray); - if (ray.m_t < maxT) { - maxT = ray.m_t; - dgAssert (ray.m_normal.m_w == dgFloat32 (0.0f)); - dgAssert (ray.m_normal.DotProduct(ray.m_normal).GetScalar() > dgFloat32(0.0f)); - //contactOut.m_normal = ray.m_normal.Scale (dgRsqrt (ray.m_normal.DotProduct(ray.m_normal).GetScalar() + dgFloat32 (1.0e-8f))); - contactOut.m_normal = ray.m_normal.Normalize(); - //contactOut.m_userId = ray.m_id; - contactOut.m_shapeId0 = ray.m_id; - contactOut.m_shapeId1 = ray.m_id; - } - } else { - if (body) { - //ray.m_matrix = body->m_collisionWorldMatrix; - ray.m_matrix = body->m_collision->GetGlobalMatrix(); - } - - ForAllSectorsRayHit (ray, maxT, RayHitUser, &ray); - if (ray.m_t < dgFloat32 (1.0f)) { - maxT = ray.m_t; - dgAssert(ray.m_normal.m_w == dgFloat32(0.0f)); - dgAssert(ray.m_normal.DotProduct(ray.m_normal).GetScalar() > dgFloat32(0.0f)); - //contactOut.m_normal = ray.m_normal.Scale (dgRsqrt (ray.m_normal.DotProduct(ray.m_normal).GetScalar() + dgFloat32 (1.0e-8f))); - contactOut.m_normal = ray.m_normal.Normalize(); - //contactOut.m_userId = ray.m_id; - contactOut.m_shapeId0 = ray.m_id; - contactOut.m_shapeId1 = ray.m_id; - } - } - return maxT; -} - -dgIntersectStatus dgCollisionBVH::GetPolygon (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance) -{ - dgPolygonMeshDesc& data = (*(dgPolygonMeshDesc*) context); - if (data.m_faceCount >= DG_MAX_COLLIDING_FACES) { - dgTrace (("buffer Over float, try using a lower resolution mesh for collision\n")); - return t_StopSearh; - } - if ((data.m_globalIndexCount + indexCount * 2 + 3) >= DG_MAX_COLLIDING_INDICES) { - dgTrace (("buffer Over float, try using a lower resolution mesh for collision\n")); - return t_StopSearh; - } - - if (data.m_me->GetDebugCollisionCallback()) { - dgTriplex triplex[128]; - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat32)); - const dgVector scale = data.m_polySoupInstance->GetScale(); - dgMatrix matrix (data.m_polySoupInstance->GetLocalMatrix() * data.m_polySoupBody->GetMatrix()); - for (dgInt32 i = 0; i < indexCount; i ++ ) { - dgVector p (matrix.TransformVector(scale * (dgVector(&polygon[indexArray[i] * stride]) & dgVector::m_triplexMask))); - triplex[i].m_x = p.m_x; - triplex[i].m_y = p.m_y; - triplex[i].m_z = p.m_z; - } - if (data.m_polySoupBody) { - data.m_me->GetDebugCollisionCallback() (data.m_polySoupBody, data.m_objBody, indexArray[indexCount], indexCount, &triplex[0].m_x, sizeof (dgTriplex)); - } - } - - dgAssert (data.m_vertex == polygon); - dgInt32 count = indexCount * 2 + 3; - - data.m_faceIndexCount[data.m_faceCount] = indexCount; -// data.m_faceIndexStart[data.m_faceCount] = data.m_faceCount ? (data.m_faceIndexStart[data.m_faceCount - 1] + data.m_faceIndexCount[data.m_faceCount - 1]) : 0; - data.m_faceIndexStart[data.m_faceCount] = data.m_globalIndexCount; - data.m_hitDistance[data.m_faceCount] = hitDistance; - data.m_faceCount ++; - dgInt32* const dst = &data.m_faceVertexIndex[data.m_globalIndexCount]; - - //the docks say memcpy is an intrinsic function but as usual this is another Microsoft lied - //memcpy (dst, indexArray, sizeof (dgInt32) * count); - for (dgInt32 i = 0; i < count; i ++) { - dst[i] = indexArray[i]; - } - - data.m_globalIndexCount += count; - - return t_ContinueSearh; -} - -void dgCollisionBVH::GetCollidingFaces (dgPolygonMeshDesc* const data) const -{ - data->m_me = this; - data->m_vertex = GetLocalVertexPool(); - data->m_vertexStrideInBytes = GetStrideInBytes(); - - data->m_faceCount = 0; - data->m_globalIndexCount = 0; - data->m_faceIndexCount = data->m_meshData.m_globalFaceIndexCount; - data->m_faceIndexStart = data->m_meshData.m_globalFaceIndexStart; - data->m_faceVertexIndex = data->m_globalFaceVertexIndex; - data->m_hitDistance = data->m_meshData.m_globalHitDistance; - ForAllSectors (*data, data->m_boxDistanceTravelInMeshSpace, data->m_maxT, GetPolygon, data); -} - - -dgVector dgCollisionBVH::SupportVertex (const dgVector& dir) const -{ - return ForAllSectorsSupportVectex (dir); -} - -dgVector dgCollisionBVH::SupportVertex(const dgVector& dir, dgInt32* const vertexIndex) const -{ - return ForAllSectorsSupportVectex(dir); -} - -dgVector dgCollisionBVH::SupportVertexSpecial(const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - dgAssert(0); - return SupportVertex(dir, vertexIndex); -} - - - -void dgCollisionBVH::GetLocalAABB (const dgVector& p0, const dgVector& p1, dgVector& boxP0, dgVector& boxP1) const -{ - dgAssert (0); -} - -struct dgCollisionBVHShowPolyContext -{ - dgMatrix m_matrix; - void* m_userData; - dgCollision::OnDebugCollisionMeshCallback m_callback; -}; - -dgIntersectStatus dgCollisionBVH::ShowDebugPolygon (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance) -{ - dgTriplex triplex[128]; - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat32)); - - dgCollisionBVHShowPolyContext& data = *(dgCollisionBVHShowPolyContext*) context; - for (dgInt32 i = 0; i < indexCount; i ++ ) { - dgVector p (&polygon[indexArray[i] * stride]); - p = p & dgVector::m_triplexMask; - p = data.m_matrix.TransformVector(p); - triplex[i].m_x = p.m_x; - triplex[i].m_y = p.m_y; - triplex[i].m_z = p.m_z; - } -// data.m_callback (data.m_userData, indexCount, &triplex[0].m_x, indexArray[-1]); - data.m_callback (data.m_userData, indexCount, &triplex[0].m_x, indexArray[indexCount]); - - return t_ContinueSearh; -} - -void dgCollisionBVH::DebugCollision (const dgMatrix& matrixPtr, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - dgCollisionBVHShowPolyContext context; - - context.m_matrix = matrixPtr; - context.m_userData = userData;; - context.m_callback = callback; - - dgFastAABBInfo box (dgGetIdentityMatrix(), dgVector (1.0e15f)); - ForAllSectors (box, dgVector(dgFloat32 (0.0f)), dgFloat32 (1.0f), ShowDebugPolygon, &context); -} diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionBVH.h b/thirdparty/src/newton/dgPhysics/dgCollisionBVH.h deleted file mode 100644 index 755c8e494..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionBVH.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGCOLLISION_BVH__ -#define __DGCOLLISION_BVH__ - -#include "dgCollision.h" -#include "dgCollisionMesh.h" - -class dgCollisionBVH; - -typedef dgFloat32 (*dgCollisionBVHUserRayCastCallback) (const dgBody* const body, const dgCollisionBVH* const heightFieldCollision, dgFloat32 interception, dgFloat32* normal, dgInt32 faceId, void* usedData); - -class dgCollisionBVH: public dgCollisionMesh, public dgAABBPolygonSoup -{ - public: - DG_MSC_VECTOR_ALIGNMENT - class dgBVHRay: public dgFastRayTest - { - public: - dgBVHRay(const dgVector& l0, const dgVector& l1) - :dgFastRayTest (l0, l1) - { - } - - dgMatrix m_matrix; - dgVector m_normal; - dgUnsigned32 m_id; - dgFloat32 m_t; - void* m_userData; - const dgBody* m_myBody; - const dgCollisionBVH* m_me; - } DG_GCC_VECTOR_ALIGNMENT; - - dgCollisionBVH(dgWorld* const world); - dgCollisionBVH (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionBVH(void); - - void BeginBuild(); - void AddFace (dgInt32 vertexCount, const dgFloat32* const vertexPtr, dgInt32 strideInBytes, dgInt32 faceAttribute); - void EndBuild(dgInt32 optimize); - - void SetCollisionRayCastCallback (dgCollisionBVHUserRayCastCallback rayCastCallback); - dgCollisionBVHUserRayCastCallback GetDebugRayCastCallback() const { return m_userRayCastCallback;} - void GetVertexListIndexList (const dgVector& p0, const dgVector& p1, dgMeshVertexListIndexList &data) const; - - void ForEachFace (dgAABBIntersectCallback callback, void* const context) const; - - private: - static dgFloat32 RayHit (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount); - static dgFloat32 RayHitUser (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount); - static dgIntersectStatus GetPolygon (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance); - static dgIntersectStatus ShowDebugPolygon (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance); - static dgIntersectStatus GetTriangleCount (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance); - static dgIntersectStatus CollectVertexListIndexList (void* const context, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount, dgFloat32 hitDistance); - - void Serialize(dgSerialize callback, void* const userData) const; - virtual dgVector SupportVertex (const dgVector& dir) const; - - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const; - virtual void GetCollidingFaces (dgPolygonMeshDesc* const data) const; - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - - virtual void GetLocalAABB (const dgVector& p0, const dgVector& p1, dgVector& boxP0, dgVector& boxP1) const; - virtual void DebugCollision (const dgMatrix& matrixPtr, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const {return point;} - - dgPolygonSoupDatabaseBuilder* m_builder; - dgCollisionBVHUserRayCastCallback m_userRayCastCallback; - - dgInt32 m_trianglesCount; - friend class dgCollisionCompound; - friend class dgCollisionDeformableMesh; -}; - - -#endif diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionBox.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionBox.cpp deleted file mode 100644 index 581140cb7..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionBox.cpp +++ /dev/null @@ -1,471 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgCollisionBox.h" - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -dgInt32 dgCollisionBox::m_initSimplex = 0; -dgCollisionConvex::dgConvexSimplexEdge dgCollisionBox::m_edgeArray[24]; -dgCollisionConvex::dgConvexSimplexEdge* dgCollisionBox::m_edgeEdgeMap[12]; -dgCollisionConvex::dgConvexSimplexEdge* dgCollisionBox::m_vertexToEdgeMap[8]; -dgInt32 dgCollisionBox::m_faces[][4] = -{ - {0, 1, 3, 2}, - {0, 4, 5, 1}, - {1, 5, 7, 3}, - {0, 2, 6, 4}, - {2, 3, 7, 6}, - {4, 6, 7, 5}, -}; - -dgVector dgCollisionBox::m_indexMark (dgFloat32 (1.0f), dgFloat32 (2.0f), dgFloat32 (4.0f), dgFloat32 (0.0f)); -dgVector dgCollisionBox::m_penetrationTol (DG_PENETRATION_TOL, DG_PENETRATION_TOL, DG_PENETRATION_TOL, dgFloat32 (0.0f)); - -dgCollisionBox::dgCollisionBox(dgMemoryAllocator* allocator, dgUnsigned32 signature, dgFloat32 size_x, dgFloat32 size_y, dgFloat32 size_z) - :dgCollisionConvex(allocator, signature, m_boxCollision) -{ - Init (size_x, size_y, size_z); -} - -dgCollisionBox::dgCollisionBox(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionConvex (world, deserialization, userData, revisionNumber) -{ - dgVector size; - deserialization (userData, &size, sizeof (dgVector)); - Init (size.m_x, size.m_y, size.m_z); -} - -void dgCollisionBox::Init (dgFloat32 size_x, dgFloat32 size_y, dgFloat32 size_z) -{ - m_rtti |= dgCollisionBox_RTTI; - m_size[0].m_x = dgMax (dgAbs (size_x) * dgFloat32 (0.5f), D_MIN_CONVEX_SHAPE_SIZE); - m_size[0].m_y = dgMax (dgAbs (size_y) * dgFloat32 (0.5f), D_MIN_CONVEX_SHAPE_SIZE); - m_size[0].m_z = dgMax (dgAbs (size_z) * dgFloat32 (0.5f), D_MIN_CONVEX_SHAPE_SIZE); - m_size[0].m_w = dgFloat32 (0.0f); - - m_size[1].m_x = - m_size[0].m_x; - m_size[1].m_y = - m_size[0].m_y; - m_size[1].m_z = - m_size[0].m_z; - m_size[1].m_w = dgFloat32 (0.0f); - - m_edgeCount = 24; - m_vertexCount = 8; - - m_vertex[0] = dgVector ( m_size[0].m_x, m_size[0].m_y, m_size[0].m_z, dgFloat32 (0.0f)); - m_vertex[1] = dgVector (-m_size[0].m_x, m_size[0].m_y, m_size[0].m_z, dgFloat32 (0.0f)); - m_vertex[2] = dgVector ( m_size[0].m_x, -m_size[0].m_y, m_size[0].m_z, dgFloat32 (0.0f)); - m_vertex[3] = dgVector (-m_size[0].m_x, -m_size[0].m_y, m_size[0].m_z, dgFloat32 (0.0f)); - - m_vertex[4] = dgVector ( m_size[0].m_x, m_size[0].m_y, -m_size[0].m_z, dgFloat32 (0.0f)); - m_vertex[5] = dgVector (-m_size[0].m_x, m_size[0].m_y, -m_size[0].m_z, dgFloat32 (0.0f)); - m_vertex[6] = dgVector ( m_size[0].m_x, -m_size[0].m_y, -m_size[0].m_z, dgFloat32 (0.0f)); - m_vertex[7] = dgVector (-m_size[0].m_x, -m_size[0].m_y, -m_size[0].m_z, dgFloat32 (0.0f)); - - dgCollisionConvex::m_vertex = m_vertex; - dgCollisionConvex::m_simplex = m_edgeArray; - - if (!m_initSimplex) { - dgPolyhedra polyhedra (GetAllocator()); - polyhedra.BeginFace(); - for (dgInt32 i = 0; i < 6; i ++) { - polyhedra.AddFace (4, &m_faces[i][0]); - } - polyhedra.EndFace(); - - int index = 0; - dgInt32 mark = polyhedra.IncLRU();; - dgPolyhedra::Iterator iter (polyhedra); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if (edge->m_mark != mark) { - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr->m_userData = index; - index ++; - ptr = ptr->m_twin->m_next; - } while (ptr != edge) ; - } - } - dgAssert (index == 24); - - polyhedra.IncLRU(); - mark = polyhedra.IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - dgEdge *ptr = edge; - do { - ptr->m_mark = mark; - dgConvexSimplexEdge* const simplexPtr = &m_simplex[ptr->m_userData]; - simplexPtr->m_vertex = ptr->m_incidentVertex; - simplexPtr->m_next = &m_simplex[ptr->m_next->m_userData]; - simplexPtr->m_prev = &m_simplex[ptr->m_prev->m_userData]; - simplexPtr->m_twin = &m_simplex[ptr->m_twin->m_userData]; - ptr = ptr->m_twin->m_next; - } while (ptr != edge) ; - } - - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - m_vertexToEdgeMap[edge->m_incidentVertex] = &m_simplex[edge->m_userData]; - } - - dgInt32 count = 0; - mark = polyhedra.IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if (edge->m_mark != mark) { - edge->m_mark = mark; - edge->m_twin->m_mark = mark; - m_edgeEdgeMap[count] = &m_simplex[edge->m_userData]; - count ++; - dgAssert (count <= 12); - } - } - - m_initSimplex = 1; - } - - SetVolumeAndCG (); -} - -dgCollisionBox::~dgCollisionBox() -{ - dgCollisionConvex::m_simplex = NULL; - dgCollisionConvex::m_vertex = NULL; -} - - -void dgCollisionBox::SetCollisionBBox (const dgVector& p0__, const dgVector& p1__) -{ - dgAssert (0); -} - -dgInt32 dgCollisionBox::CalculateSignature (dgFloat32 dx, dgFloat32 dy, dgFloat32 dz) -{ - dgUnsigned32 buffer[4]; - - dx = dgAbs (dx); - dy = dgAbs (dy); - dz = dgAbs (dz); - buffer[0] = m_boxCollision; - buffer[1] = Quantize (dx * dgFloat32 (0.5f)); - buffer[2] = Quantize (dy * dgFloat32 (0.5f)); - buffer[3] = Quantize (dz * dgFloat32 (0.5f)); - return Quantize(buffer, sizeof (buffer)); -} - -dgInt32 dgCollisionBox::CalculateSignature () const -{ - return CalculateSignature(m_size[0].m_x, m_size[0].m_y, m_size[0].m_z); -} - -dgVector dgCollisionBox::SupportVertex (const dgVector& dir0, dgInt32* const vertexIndex) const -{ - dgVector mask0(dir0.Abs() > m_flushZero); - dgVector dir(dir0 & mask0); - - dgAssert (dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f)); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgVector mask(dir < dgVector::m_zero); - if (vertexIndex) { - dgVector index (m_indexMark * (mask & dgVector::m_one)); - index = (index.AddHorizontal()).GetInt(); - *vertexIndex = dgInt32 (index.m_ix); - } - return m_size[0].Select(m_size[1], mask); -} - -dgVector dgCollisionBox::SupportVertexSpecial(const dgVector& dir0, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - dgVector mask0(dir0.Abs() > m_flushZero); - dgVector dir(dir0 & mask0); - - dgAssert(dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-3f)); - dgAssert(dir.m_w == dgFloat32(0.0f)); -// dgVector mask(dir < dgVector(dgFloat32(0.0f))); - dgVector mask(dir < dgVector::m_zero); - if (vertexIndex) { - dgVector index(m_indexMark * (mask & dgVector::m_one)); - index = (index.AddHorizontal()).GetInt(); - *vertexIndex = dgInt32 (index.m_ix); - } - - //dgVector padd (DG_PENETRATION_TOL); - //padd = padd & dgVector::m_triplexMask; - dgVector size0 (m_size[0] - m_penetrationTol); - dgVector size1 (m_size[1] + m_penetrationTol); - return size0.Select(size1, mask); -} - -dgVector dgCollisionBox::SupportVertexSpecialProjectPoint(const dgVector& point, const dgVector& dir0) const -{ - dgVector mask0(dir0.Abs() > m_flushZero); - dgVector dir(dir0 & mask0); - dgAssert(dgAbs((dir.DotProduct(dir).GetScalar() - dgFloat32(1.0f))) < dgFloat32(1.0e-3f)); - return point + dir.Scale (DG_PENETRATION_TOL); -} - -void dgCollisionBox::CalcAABB (const dgMatrix& matrix, dgVector &p0, dgVector &p1) const -{ - dgVector size (matrix[0].Abs().Scale(m_size[0].m_x) + matrix[1].Abs().Scale(m_size[0].m_y) + matrix[2].Abs().Scale(m_size[0].m_z)); - p0 = (matrix[3] - size) & dgVector::m_triplexMask; - p1 = (matrix[3] + size) & dgVector::m_triplexMask; -} - - -dgFloat32 dgCollisionBox::RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const -{ - dgAssert (localP0.m_w == dgFloat32 (0.0f)); - dgAssert (localP1.m_w == dgFloat32 (0.0f)); - - dgInt32 index = 0; - dgFloat32 signDir = dgFloat32 (0.0f); - dgFloat32 tmin = dgFloat32 (0.0f); - dgFloat32 tmax = dgFloat32 (1.0f); - for (dgInt32 i = 0; i < 3; i++) { - dgFloat32 dp = localP1[i] - localP0[i]; - if (dgAbs (dp) < dgFloat32 (1.0e-8f)) { - if (localP0[i] <= m_size[1][i] || localP0[i] >= m_size[0][i]) { - return dgFloat32 (1.2f); - } - } else { - dp = dgFloat32 (1.0f) / dp; - dgFloat32 t1 = (m_size[1][i] - localP0[i]) * dp; - dgFloat32 t2 = (m_size[0][i] - localP0[i]) * dp; - - dgFloat32 sign = dgFloat32 (-1.0f); - if (t1 > t2) { - sign = 1; - dgSwap(t1, t2); - } - if (t1 > tmin) { - signDir = sign; - index = i; - tmin = t1; - } - if (t2 < tmax) { - tmax = t2; - } - if (tmin > tmax) { - return dgFloat32 (1.2f); - } - } - } - - if (tmin > dgFloat32 (0.0f)) { - dgAssert (tmin <= 1.0f); - contactOut.m_normal = dgVector (dgFloat32 (0.0f)); - contactOut.m_normal[index] = signDir; - //contactOut.m_userId = SetUserDataID(); - } else { - tmin = dgFloat32 (1.2f); - } - return tmin; -} - -void dgCollisionBox::MassProperties () -{ - m_centerOfMass = dgVector::m_zero; - m_crossInertia = dgVector::m_zero; - dgFloat32 volume = dgFloat32 (8.0f) * m_size[0].m_x * m_size[0].m_y * m_size[0].m_z; - m_inertia = dgVector (dgFloat32 (1.0f / 3.0f) * (m_size[0].m_y * m_size[0].m_y + m_size[0].m_z * m_size[0].m_z), - dgFloat32 (1.0f / 3.0f) * (m_size[0].m_x * m_size[0].m_x + m_size[0].m_z * m_size[0].m_z), - dgFloat32 (1.0f / 3.0f) * (m_size[0].m_x * m_size[0].m_x + m_size[0].m_y * m_size[0].m_y), - dgFloat32 (0.0f)); - m_centerOfMass.m_w = volume; -} - -void dgCollisionBox::GetCollisionInfo(dgCollisionInfo* const info) const -{ - dgCollisionConvex::GetCollisionInfo(info); - - info->m_box.m_x = m_size[0].m_x * dgFloat32 (2.0f); - info->m_box.m_y = m_size[0].m_y * dgFloat32 (2.0f); - info->m_box.m_z = m_size[0].m_z * dgFloat32 (2.0f); -} - -void dgCollisionBox::Serialize(dgSerialize callback, void* const userData) const -{ - SerializeLow(callback, userData); - dgVector size (m_size[0].Scale (dgFloat32 (2.0f))); - callback (userData, &size, sizeof (dgVector)); -} - -const dgCollisionConvex::dgConvexSimplexEdge** dgCollisionBox::GetVertexToEdgeMapping() const -{ - return (const dgConvexSimplexEdge**)&m_vertexToEdgeMap[0]; -} - - - -dgInt32 dgCollisionBox::CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const -{ - dgVector support[4]; - dgInt32 featureCount = 3; - - const dgConvexSimplexEdge** const vertToEdgeMapping = GetVertexToEdgeMapping(); - if (vertToEdgeMapping) { - dgInt32 edgeIndex; - support[0] = SupportVertex (normal, &edgeIndex); - - dgFloat32 dist = normal.DotProduct(support[0] - point).GetScalar(); - if (dist <= DG_PENETRATION_TOL) { - dgVector normalAlgin (normal.Abs()); - if (!((normalAlgin.m_x > dgFloat32 (0.9999f)) || (normalAlgin.m_y > dgFloat32 (0.9999f)) || (normalAlgin.m_z > dgFloat32 (0.9999f)))) { - // 0.25 degrees - const dgFloat32 tiltAngle = dgFloat32 (0.005f); - const dgFloat32 tiltAngle2 = tiltAngle * tiltAngle ; - dgPlane testPlane (normal, - (normal.DotProduct(support[0]).GetScalar())); - - featureCount = 1; - const dgConvexSimplexEdge* const edge = vertToEdgeMapping[edgeIndex]; - const dgConvexSimplexEdge* ptr = edge; - do { - const dgVector& p = m_vertex[ptr->m_twin->m_vertex]; - dgFloat32 test1 = testPlane.Evalue(p); - dgVector dist1 (p - support[0]); - dgFloat32 angle2 = test1 * test1 / (dist1.DotProduct(dist1).GetScalar()); - if (angle2 < tiltAngle2) { - support[featureCount] = p; - featureCount ++; - } - ptr = ptr->m_twin->m_next; - } while ((ptr != edge) && (featureCount < 3)); - } - } - } - - dgInt32 count = 0; - switch (featureCount) - { - case 1: - { - contactsOut[0] = support[0] - normal * normal.DotProduct(support[0] - point); - count = 1; - break; - } - - case 2: - { - contactsOut[0] = support[0] - normal * normal.DotProduct(support[0] - point); - contactsOut[1] = support[1] - normal * normal.DotProduct(support[1] - point); - count = 2; - break; - } - - default: - { - dgFloat32 test[8]; - dgAssert(normal.m_w == dgFloat32(0.0f)); - dgPlane plane(normal, -(normal.DotProduct(point).GetScalar())); - for (dgInt32 i = 0; i < 8; i++) { - dgAssert(m_vertex[i].m_w == dgFloat32(0.0f)); - test[i] = plane.DotProduct(m_vertex[i] | dgVector::m_wOne).m_x; - } - - dgConvexSimplexEdge* edge = NULL; - for (dgInt32 i = 0; i < dgInt32 (sizeof (m_edgeEdgeMap) / sizeof (m_edgeEdgeMap[0])); i ++) { - dgConvexSimplexEdge* const ptr = m_edgeEdgeMap[i]; - dgFloat32 side0 = test[ptr->m_vertex]; - dgFloat32 side1 = test[ptr->m_twin->m_vertex]; - if ((side0 * side1) < dgFloat32 (0.0f)) { - edge = ptr; - break; - } - } - - if (edge) { - if (test[edge->m_vertex] < dgFloat32 (0.0f)) { - edge = edge->m_twin; - } - dgAssert (test[edge->m_vertex] > dgFloat32 (0.0f)); - - dgConvexSimplexEdge* ptr = edge; - dgConvexSimplexEdge* firstEdge = NULL; - dgFloat32 side0 = test[edge->m_vertex]; - do { - dgAssert (m_vertex[ptr->m_twin->m_vertex].m_w == dgFloat32 (0.0f)); - dgFloat32 side1 = test[ptr->m_twin->m_vertex]; - if (side1 < side0) { - if (side1 < dgFloat32 (0.0f)) { - firstEdge = ptr; - break; - } - - side0 = side1; - edge = ptr->m_twin; - ptr = edge; - } - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - - if (firstEdge) { - edge = firstEdge; - ptr = edge; - do { - dgVector dp (m_vertex[ptr->m_twin->m_vertex] - m_vertex[ptr->m_vertex]); - dgFloat32 t = plane.DotProduct(dp).m_x; - if (t >= dgFloat32 (-1.e-24f)) { - t = dgFloat32 (0.0f); - } else { - t = test[ptr->m_vertex] / t; - if (t > dgFloat32 (0.0f)) { - t = dgFloat32 (0.0f); - } - if (t < dgFloat32 (-1.0f)) { - t = dgFloat32 (-1.0f); - } - } - - dgAssert (t <= dgFloat32 (0.01f)); - dgAssert (t >= dgFloat32 (-1.05f)); - contactsOut[count] = m_vertex[ptr->m_vertex] - dp.Scale (t); - count ++; - - dgConvexSimplexEdge* ptr1 = ptr->m_next; - for (; ptr1 != ptr; ptr1 = ptr1->m_next) { - dgInt32 index0 = ptr1->m_twin->m_vertex; - if (test[index0] >= dgFloat32 (0.0f)) { - dgAssert (test[ptr1->m_vertex] <= dgFloat32 (0.0f)); - break; - } - } - dgAssert (ptr != ptr1); - ptr = ptr1->m_twin; - - } while ((ptr != edge) && (count < 8)); - } - } - } - } - - if (count > 2) { - count = RectifyConvexSlice (count, normal, contactsOut); - } - return count; -} diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionBox.h b/thirdparty/src/newton/dgPhysics/dgCollisionBox.h deleted file mode 100644 index 0520d798b..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionBox.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_BOX_H_ -#define _DG_BOX_H_ - - -#include "dgCollisionConvex.h" - - -class dgCollisionBox: public dgCollisionConvex -{ - public: - - dgCollisionBox(dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgFloat32 size_x, dgFloat32 size_y, dgFloat32 size_z); - dgCollisionBox(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionBox(); - - protected: - void Init (dgFloat32 size_x, dgFloat32 size_y, dgFloat32 size_z); - virtual void CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const; - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const; - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecial(const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecialProjectPoint(const dgVector& point, const dgVector& dir) const; - virtual dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const; - virtual const dgConvexSimplexEdge** GetVertexToEdgeMapping() const; - - virtual dgInt32 CalculateSignature () const; - virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1); - virtual void MassProperties (); - - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - virtual void Serialize(dgSerialize callback, void* const userData) const; - - static dgInt32 CalculateSignature (dgFloat32 dx, dgFloat32 dy, dgFloat32 dz); - - dgVector m_size[2]; - dgVector m_vertex[8]; - static dgInt32 m_initSimplex; - static dgInt32 m_faces[][4]; - static dgVector m_indexMark; - static dgVector m_penetrationTol; - static dgConvexSimplexEdge m_edgeArray[]; - static dgConvexSimplexEdge* m_edgeEdgeMap[]; - static dgConvexSimplexEdge* m_vertexToEdgeMap[]; - friend class dgWorld; -}; - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionCapsule.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionCapsule.cpp deleted file mode 100644 index 24e591acf..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionCapsule.cpp +++ /dev/null @@ -1,532 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgCollisionCapsule.h" - -#define DG_CAPSULE_SEGMENTS 10 -#define DG_CAPSULE_CAP_SEGMENTS 12 - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -dgCollisionCapsule::dgCollisionCapsule(dgMemoryAllocator* allocator, dgUnsigned32 signature, dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height) - :dgCollisionConvex(allocator, signature, m_capsuleCollision) -{ - Init (radio0, radio1, height); -} - -dgCollisionCapsule::dgCollisionCapsule(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionConvex (world, deserialization, userData, revisionNumber) -{ - dgVector size; - deserialization(userData, &size, sizeof (dgVector)); - Init (size.m_x, size.m_y, size.m_z * dgFloat32 (2.0f)); -} - - -dgCollisionCapsule::~dgCollisionCapsule() -{ -} - -void dgCollisionCapsule::Init (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height) -{ - m_rtti |= dgCollisionCapsule_RTTI; - - radio0 = dgMax (dgAbs (radio0), D_MIN_CONVEX_SHAPE_SIZE); - radio1 = dgMax (dgAbs (radio1), D_MIN_CONVEX_SHAPE_SIZE); - height = dgMax (dgAbs (height), D_MIN_CONVEX_SHAPE_SIZE); - - m_transform = dgVector (dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)); - if (radio0 > radio1) { - m_transform.m_x = dgFloat32 (-1.0f); - m_transform.m_y = dgFloat32 (-1.0f); - dgSwap(radio0, radio1); - } - - m_radio0 = radio0; - m_radio1 = radio1; - m_height = height * dgFloat32 (0.5f); - - m_p0 = dgVector (- m_height, m_radio0, dgFloat32 (0.0f), dgFloat32 (0.0f)); - m_p1 = dgVector ( m_height, m_radio1, dgFloat32 (0.0f), dgFloat32 (0.0f)); - m_normal = dgVector (dgFloat32 (0.0f), dgFloat32 (1.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector side (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)); - - for (int i = 0; i < 16; i ++) { - dgVector p1p0 (m_p1 - m_p0); - //dgVector dir(side.CrossProduct(p1p0)); - m_normal = side.CrossProduct(p1p0).Normalize(); - dgVector support0(m_normal.Scale(m_radio0)); - dgVector support1(m_normal.Scale(m_radio1)); - support0.m_x -= m_height; - support1.m_x += m_height; - dgFloat32 distance0 = support0.DotProduct(m_normal).GetScalar(); - dgFloat32 distance1 = support1.DotProduct(m_normal).GetScalar(); - - if (distance1 > distance0) { - m_p1 = support1; - } else if (distance1 < distance0) { - m_p0 = support0; - } else { - i = 1000; - } - } - - dgVector tempVertex[4 * DG_CAPSULE_CAP_SEGMENTS * DG_CAPSULE_SEGMENTS + 100]; - dgInt32 index = 0; - dgInt32 dx0 = dgInt32(dgFloor(DG_CAPSULE_SEGMENTS * ((m_p0.m_x + m_height + m_radio0) / m_radio0)) + dgFloat32(1.0f)); - dgFloat32 step = m_radio0 / DG_CAPSULE_SEGMENTS; - dgFloat32 x0 = m_p0.m_x - step * dx0; - for (dgInt32 j = 0; j < dx0; j++) { - x0 += step; - dgFloat32 x = x0 + m_height; - dgFloat32 arg = dgMax (m_radio0 * m_radio0 - x * x, dgFloat32 (1.0e-3f)); - dgFloat32 r0 = dgSqrt (arg); - - dgFloat32 angle = dgFloat32(0.0f); - for (dgInt32 i = 0; i < DG_CAPSULE_CAP_SEGMENTS; i++) { - dgFloat32 z = dgSin(angle); - dgFloat32 y = dgCos(angle); - tempVertex[index] = dgVector(x0, y * r0, z * r0, dgFloat32(0.0f)); - index++; - angle += dgPI2 / DG_CAPSULE_CAP_SEGMENTS; - dgAssert(index < sizeof (tempVertex) / sizeof (tempVertex[0])); - } - } - - dgFloat32 x1 = m_p1.m_x; - dgInt32 dx1 = dgInt32 (dgFloor (DG_CAPSULE_SEGMENTS * ((m_height + m_radio1 - m_p1.m_x) / m_radio1)) + dgFloat32 (1.0f)); - step = m_radio1 / DG_CAPSULE_SEGMENTS; - for (dgInt32 j = 0; j < dx1; j ++) { - dgFloat32 x = x1 - m_height; - dgFloat32 arg = dgMax (m_radio1 * m_radio1 - x * x, dgFloat32 (1.0e-3f)); - dgFloat32 r1 = dgSqrt (arg); - dgFloat32 angle = dgFloat32 (0.0f); - for (dgInt32 i = 0; i < DG_CAPSULE_CAP_SEGMENTS; i ++) { - dgFloat32 z = dgSin (angle); - dgFloat32 y = dgCos (angle); - tempVertex[index] = dgVector ( x1, y * r1, z * r1, dgFloat32 (0.0f)); - index ++; - angle += dgPI2 / DG_CAPSULE_CAP_SEGMENTS; - dgAssert (index < sizeof (tempVertex) / sizeof (tempVertex[0])); - } - x1 += step; - } - - m_vertexCount = dgInt16 (index); - dgCollisionConvex::m_vertex = (dgVector*) m_allocator->Malloc (dgInt32 (m_vertexCount * sizeof (dgVector))); - memcpy (dgCollisionConvex::m_vertex, tempVertex, m_vertexCount * sizeof (dgVector)); - - dgPolyhedra polyhedra(m_allocator); - polyhedra.BeginFace (); - - dgInt32 wireframe[DG_CAPSULE_SEGMENTS + 10]; - - dgInt32 i1 = 0; - dgInt32 i0 = DG_CAPSULE_CAP_SEGMENTS - 1; - const dgInt32 n = index / DG_CAPSULE_CAP_SEGMENTS - 1; - for (dgInt32 j = 0; j < n; j ++) { - for (dgInt32 i = 0; i < DG_CAPSULE_CAP_SEGMENTS; i ++) { - wireframe[0] = i0; - wireframe[1] = i1; - wireframe[2] = i1 + DG_CAPSULE_CAP_SEGMENTS; - wireframe[3] = i0 + DG_CAPSULE_CAP_SEGMENTS; - i0 = i1; - i1 ++; - polyhedra.AddFace (4, wireframe); - } - i0 = i1 + DG_CAPSULE_CAP_SEGMENTS - 1; - } - - for (dgInt32 i = 0; i < DG_CAPSULE_CAP_SEGMENTS; i ++) { - wireframe[i] = DG_CAPSULE_CAP_SEGMENTS - i - 1; - } - polyhedra.AddFace (DG_CAPSULE_CAP_SEGMENTS, wireframe); - - for (dgInt32 i = 0; i < DG_CAPSULE_CAP_SEGMENTS; i ++) { - wireframe[i] = index - DG_CAPSULE_CAP_SEGMENTS + i; - } - polyhedra.AddFace (DG_CAPSULE_CAP_SEGMENTS, wireframe); - polyhedra.EndFace (); - - dgAssert (SanityCheck (polyhedra)); - - m_edgeCount = dgInt16 (polyhedra.GetEdgeCount()); - m_simplex = (dgConvexSimplexEdge*) m_allocator->Malloc (dgInt32 (m_edgeCount * sizeof (dgConvexSimplexEdge))); - - dgUnsigned64 i = 0; - dgPolyhedra::Iterator iter (polyhedra); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - edge->m_userData = i; - i ++; - } - - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - - dgConvexSimplexEdge* const ptr = &m_simplex[edge->m_userData]; - - ptr->m_vertex = edge->m_incidentVertex; - ptr->m_next = &m_simplex[edge->m_next->m_userData]; - ptr->m_prev = &m_simplex[edge->m_prev->m_userData]; - ptr->m_twin = &m_simplex[edge->m_twin->m_userData]; - } - SetVolumeAndCG (); -} - - -dgInt32 dgCollisionCapsule::CalculateSignature (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height) -{ - dgUnsigned32 buffer[4]; - - buffer[0] = m_capsuleCollision; - buffer[1] = Quantize (radio0); - buffer[2] = Quantize (radio1); - buffer[3] = Quantize (height); - return Quantize(buffer, sizeof (buffer)); -} - -dgInt32 dgCollisionCapsule::CalculateSignature () const -{ - return CalculateSignature (m_radio0, m_radio1, m_height); -} - - -void dgCollisionCapsule::TesselateTriangle(dgInt32 level, const dgVector& p0, const dgVector& p1, const dgVector& p2, dgInt32& count, dgVector* ouput) const -{ - if (level) { - dgAssert(dgAbs(p0.DotProduct(p0).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p1.DotProduct(p1).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p2.DotProduct(p2).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgVector p01(p0 + p1); - dgVector p12(p1 + p2); - dgVector p20(p2 + p0); - - p01 = p01.Scale(dgRsqrt(p01.DotProduct(p01).GetScalar())); - p12 = p12.Scale(dgRsqrt(p12.DotProduct(p12).GetScalar())); - p20 = p20.Scale(dgRsqrt(p20.DotProduct(p20).GetScalar())); - - dgAssert(dgAbs(p01.DotProduct(p01).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p12.DotProduct(p12).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - dgAssert(dgAbs(p20.DotProduct(p20).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - - TesselateTriangle(level - 1, p0, p01, p20, count, ouput); - TesselateTriangle(level - 1, p1, p12, p01, count, ouput); - TesselateTriangle(level - 1, p2, p20, p12, count, ouput); - TesselateTriangle(level - 1, p01, p12, p20, count, ouput); - - } else { - ouput[count + 0] = p0.Scale(m_radio0); - ouput[count + 1] = p1.Scale(m_radio0); - ouput[count + 2] = p2.Scale(m_radio0); - count += 3; - } -} - - -void dgCollisionCapsule::DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - if (m_radio0 == m_radio1) { - #define POWER 2 - dgVector tmpVectex[512]; - - dgVector p0(dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p1(-dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p2(dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p3(dgFloat32(0.0f), -dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p4(dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f)); - dgVector p5(dgFloat32(0.0f), dgFloat32(0.0f), -dgFloat32(1.0f), dgFloat32(0.0f)); - - dgInt32 count = 0; - TesselateTriangle(POWER, p0, p2, p4, count, tmpVectex); - TesselateTriangle(POWER, p0, p4, p3, count, tmpVectex); - TesselateTriangle(POWER, p0, p3, p5, count, tmpVectex); - TesselateTriangle(POWER, p0, p5, p2, count, tmpVectex); - - TesselateTriangle(POWER, p1, p4, p2, count, tmpVectex); - TesselateTriangle(POWER, p1, p3, p4, count, tmpVectex); - TesselateTriangle(POWER, p1, p5, p3, count, tmpVectex); - TesselateTriangle(POWER, p1, p2, p5, count, tmpVectex); - - for (dgInt32 i = 0; i < count; i += 3) { - int positive = 0; - for (int j = 0; j < 3; j++) { - if (tmpVectex[i + j].m_x > dgFloat32(0.0f)) { - positive++; - } - } - - if (positive) { - dgVector face[4]; - face[0] = tmpVectex[i + 0]; - face[1] = tmpVectex[i + 1]; - face[2] = tmpVectex[i + 2]; - face[0].m_x += m_height; - face[1].m_x += m_height; - face[2].m_x += m_height; - matrix.TransformTriplex(&face[0].m_x, sizeof (dgTriplex), &face[0].m_x, sizeof (dgVector), 3); - callback(userData, 3, &face[0].m_x, 0); - } else { - dgVector face[4]; - face[0] = tmpVectex[i + 0]; - face[1] = tmpVectex[i + 1]; - face[2] = tmpVectex[i + 2]; - face[0].m_x -= m_height; - face[1].m_x -= m_height; - face[2].m_x -= m_height; - matrix.TransformTriplex(&face[0].m_x, sizeof (dgTriplex), &face[0].m_x, sizeof (dgVector), 3); - callback(userData, 3, &face[0].m_x, 0); - } - if (positive == 1) { - dgVector q0(tmpVectex[i + 0]); - dgVector q1(tmpVectex[i + 1]); - if ((tmpVectex[i + 1].m_x == dgFloat32(0.0f)) && (tmpVectex[i + 2].m_x == dgFloat32(0.0f))) { - q0 = tmpVectex[i + 1]; - q1 = tmpVectex[i + 2]; - } - else if ((tmpVectex[i + 2].m_x == dgFloat32(0.0f)) && (tmpVectex[i + 0].m_x == dgFloat32(0.0f))) { - q0 = tmpVectex[i + 2]; - q1 = tmpVectex[i + 0]; - } - - dgVector face[4]; - face[0] = q1; - face[1] = q0; - face[2] = q0; - face[3] = q1; - face[0].m_x += m_height; - face[1].m_x += m_height; - face[2].m_x -= m_height; - face[3].m_x -= m_height; - matrix.TransformTriplex(&face[0].m_x, sizeof (dgTriplex), &face[0].m_x, sizeof (dgVector), 4); - callback(userData, 4, &face[0].m_x, 0); - } - } - } else { - dgMatrix transform (matrix); - transform[0] = transform[0].Scale(m_transform.m_x); - transform[1] = transform[1].Scale(m_transform.m_y); - transform[2] = transform[2].Scale(m_transform.m_z); - dgCollisionConvex::DebugCollision (transform, callback, userData); - } -} - - -void dgCollisionCapsule::SetCollisionBBox (const dgVector& p0__, const dgVector& p1__) -{ - dgAssert (0); -} - - -dgVector dgCollisionCapsule::SupportVertex (const dgVector& direction, dgInt32* const vertexIndex) const -{ - dgVector dir (direction * m_transform); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert (dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f)); - - dgVector p0(dir.Scale (m_radio0)); - dgVector p1(dir.Scale (m_radio1)); - p0.m_x -= m_height; - p1.m_x += m_height; - dgFloat32 dir0 = p0.DotProduct(dir).GetScalar(); - dgFloat32 dir1 = p1.DotProduct(dir).GetScalar(); - if (dir1 > dir0) { - p0 = p1; - } - return p0 * m_transform; -} - -dgVector dgCollisionCapsule::SupportVertexSpecial(const dgVector& direction, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - dgVector dir(direction * m_transform); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert(dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-3f)); - - dgVector p0(dgVector::m_zero); - dgVector p1(dir.Scale(m_radio1 - m_radio0)); - p0.m_x -= m_height; - p1.m_x += m_height; - dgFloat32 dir0 = p0.DotProduct(dir).GetScalar(); - dgFloat32 dir1 = p1.DotProduct(dir).GetScalar(); - if (dir1 > dir0) { - p0 = p1; - } - return p0 * m_transform; -} - - -dgVector dgCollisionCapsule::SupportVertexSpecialProjectPoint (const dgVector& testPoint, const dgVector& direction) const -{ - dgVector dir(direction * m_transform); - dgVector point(testPoint * m_transform); - point += dir.Scale(m_radio0 - DG_PENETRATION_TOL); - return m_transform * point; -} - - -dgFloat32 dgCollisionCapsule::CalculateMassProperties (const dgMatrix& offset, dgVector& inertia, dgVector& crossInertia, dgVector& centerOfMass) const -{ - return dgCollisionConvex::CalculateMassProperties (offset, inertia, crossInertia, centerOfMass); -} - -void dgCollisionCapsule::GetCollisionInfo(dgCollisionInfo* const info) const -{ - dgCollisionConvex::GetCollisionInfo(info); - - info->m_capsule.m_radio0 = m_radio0; - info->m_capsule.m_radio1 = m_radio1; - info->m_capsule.m_height = dgFloat32 (2.0f) * m_height; - - if (m_transform.m_x < dgFloat32 (0.0f)) { - dgSwap(info->m_capsule.m_radio0, info->m_capsule.m_radio1); - } -} - -void dgCollisionCapsule::Serialize(dgSerialize callback, void* const userData) const -{ - SerializeLow(callback, userData); - dgVector size(m_radio0, m_radio1, m_height, dgFloat32 (0.0f)); - callback (userData, &size, sizeof (dgVector)); -} - - -dgInt32 dgCollisionCapsule::CalculatePlaneIntersection (const dgVector& direction, const dgVector& point, dgVector* const contactsOut) const -{ - dgVector normal(direction * m_transform); - dgVector origin(point * m_transform); - - dgInt32 count = 0; - dgVector p0 (-m_height, dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector dir0 (p0 - origin); - dgFloat32 dist0 = dir0.DotProduct(normal).GetScalar(); - if ((dist0 * dist0 - dgFloat32 (5.0e-5f)) < (m_radio0 * m_radio0)) { - contactsOut[count] = m_transform * (p0 - normal.Scale (dist0)); - count ++; - } - - dgVector p1 (m_height, dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector dir1 (p1 - origin); - dgFloat32 dist1 = dir1.DotProduct(normal).GetScalar(); - if ((dist1 * dist1 - dgFloat32 (5.0e-5f)) < (m_radio1 * m_radio1)) { - contactsOut[count] = m_transform * (p1 - normal.Scale (dist1)); - count ++; - } - return count; -} - -dgFloat32 dgCollisionCapsule::RayCast (const dgVector& r0, const dgVector& r1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const -{ - dgVector q0(r0 * m_transform); - dgVector q1(r1 * m_transform); - - dgVector origin0 (-m_height, dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector origin1 ( m_height, dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgFloat32 t0 = dgRayCastSphere (q0, q1, origin0, m_radio0); - dgFloat32 t1 = dgRayCastSphere (q0, q1, origin1, m_radio1); - if ((t0 < maxT) && (t1 < maxT)) { - if (t0 < t1) { - dgVector q (q0 + (q1 - q0).Scale (t0)); - dgVector n(q - origin0); - dgAssert(n.m_w == dgFloat32(0.0f)); - //contactOut.m_normal = m_transform * n * n.DotProduct(n).InvSqrt(); - contactOut.m_normal = m_transform * n.Normalize(); - return t0; - } else { - dgVector q (q0 + (q1 - q0).Scale (t1)); - dgVector n(q - origin1); - dgAssert(n.m_w == dgFloat32(0.0f)); - //contactOut.m_normal = m_transform * n * n.DotProduct(n).InvSqrt(); - contactOut.m_normal = m_transform * n.Normalize(); - return t1; - } - } else if (t1 < maxT) { - dgVector q (q0 + (q1 - q0).Scale (t1)); - if (q.m_x >= m_p1.m_x) { - dgVector n (q - origin1); - dgAssert (n.m_w == dgFloat32 (0.0f)); - //contactOut.m_normal = m_transform * n * n.DotProduct(n).InvSqrt(); - contactOut.m_normal = m_transform * n.Normalize(); - return t1; - } - } else if (t0 < maxT) { - dgVector q (q0 + (q1 - q0).Scale (t0)); - if (q.m_x <= m_p0.m_x) { - dgVector n (q - origin0); - dgAssert (n.m_w == dgFloat32 (0.0f)); - //contactOut.m_normal = m_transform * n * n.DotProduct(n).InvSqrt(); - contactOut.m_normal = m_transform * n.Normalize(); - return t0; - } - } - - dgFloat32 ret = dgCollisionConvex::RayCast (q0, q1, maxT, contactOut, body, NULL, NULL); - if (ret <= dgFloat32 (1.0f)) { - contactOut.m_normal = m_transform * contactOut.m_normal; - } - return ret; -} - - -void dgCollisionCapsule::CalculateImplicitContacts(dgInt32 count, dgContactPoint* const contactPoints) const -{ - for (dgInt32 i = 0; i < count; i++) { - contactPoints[i].m_point = contactPoints[i].m_point * m_transform; - if (contactPoints[i].m_point.m_x <= m_p0.m_x) { - dgVector normal(contactPoints[i].m_point); - normal.m_x += m_height; - dgAssert(normal.DotProduct(normal).GetScalar() > dgFloat32(0.0f)); - normal = normal.Normalize(); - contactPoints[i].m_normal = normal * dgVector::m_negOne; - contactPoints[i].m_point = normal.Scale(m_radio0); - contactPoints[i].m_point.m_x -= m_height; - } else if (contactPoints[i].m_point.m_x >= m_p1.m_x) { - dgVector normal(contactPoints[i].m_point); - normal.m_x -= m_height; - dgAssert(normal.DotProduct(normal).GetScalar() > dgFloat32(0.0f)); - normal = normal.Normalize(); - contactPoints[i].m_normal = normal * dgVector::m_negOne; - contactPoints[i].m_point = normal.Scale(m_radio1); - contactPoints[i].m_point.m_x += m_height; - } else { - dgVector normal(contactPoints[i].m_point); - normal.m_x = dgFloat32(0.0f); - normal.m_w = dgFloat32(0.0f); - dgAssert(normal.DotProduct(normal).GetScalar() > dgFloat32(0.0f)); - normal = normal.Normalize(); - - dgFloat32 h = m_p0.m_y + dgFloat32(0.5f) * (m_p1.m_y - m_p0.m_y) * contactPoints[i].m_point.m_x / m_height; - dgVector point(normal.Scale(h)); - contactPoints[i].m_point.m_y = point.m_y; - contactPoints[i].m_point.m_z = point.m_z; - - contactPoints[i].m_normal.m_x = -m_normal.m_x; - contactPoints[i].m_normal.m_y = -m_normal.m_y * normal.m_y; - contactPoints[i].m_normal.m_z = -m_normal.m_y * normal.m_z; - } - contactPoints[i].m_point = contactPoints[i].m_point * m_transform; - contactPoints[i].m_normal = contactPoints[i].m_normal * m_transform; - } -} diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionCapsule.h b/thirdparty/src/newton/dgPhysics/dgCollisionCapsule.h deleted file mode 100644 index de1a77aaf..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionCapsule.h +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_COLLISION_CAPSULE_H_ -#define _DG_COLLISION_CAPSULE_H_ - - -#include "dgCollisionConvex.h" - -class dgCollisionCapsule: public dgCollisionConvex -{ - public: - dgCollisionCapsule (dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height); - dgCollisionCapsule(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionCapsule(); - - private: - void Init (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height); - - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const; - - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - - virtual dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const; - - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - - virtual dgInt32 CalculateSignature () const; - virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1); - virtual dgFloat32 CalculateMassProperties (const dgMatrix& offset, dgVector& inertia, dgVector& crossInertia, dgVector& centerOfMass) const; - - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - virtual void Serialize(dgSerialize callback, void* const userData) const; - - static dgInt32 CalculateSignature(dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height); - - virtual void CalculateImplicitContacts(dgInt32 count, dgContactPoint* const contactPoints) const; - virtual dgVector SupportVertexSpecialProjectPoint(const dgVector& point, const dgVector& dir) const; - virtual dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; - - void TesselateTriangle(dgInt32 level, const dgVector& p0, const dgVector& p1, const dgVector& p2, dgInt32& count, dgVector* ouput) const; - - dgVector m_p0; - dgVector m_p1; - dgVector m_normal; - dgVector m_transform; - dgFloat32 m_height; - dgFloat32 m_radio0; - dgFloat32 m_radio1; - - friend class dgWorld; -}; - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionChamferCylinder.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionChamferCylinder.cpp deleted file mode 100644 index 6691c4071..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionChamferCylinder.cpp +++ /dev/null @@ -1,414 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgContact.h" -#include "dgCollisionChamferCylinder.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - - -dgInt32 dgCollisionChamferCylinder::m_shapeRefCount = 0; -dgVector dgCollisionChamferCylinder::m_yzMask (0, 0xffffffff, 0xffffffff, 0); -dgVector dgCollisionChamferCylinder::m_shapesDirs[DG_MAX_CHAMFERCYLINDER_DIR_COUNT]; -dgCollisionConvex::dgConvexSimplexEdge dgCollisionChamferCylinder::m_edgeArray[(4 * DG_CHAMFERCYLINDER_SLICES + 2)* DG_CHAMFERCYLINDER_BRAKES]; - -dgCollisionChamferCylinder::dgCollisionChamferCylinder(dgMemoryAllocator* allocator, dgUnsigned32 signature, dgFloat32 radius, dgFloat32 height) - :dgCollisionConvex(allocator, signature, m_chamferCylinderCollision) -{ - Init (radius, height); -} - -dgCollisionChamferCylinder::dgCollisionChamferCylinder(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionConvex (world, deserialization, userData, revisionNumber) -{ - dgVector size; - deserialization (userData, &size, sizeof (dgVector)); - Init (size.m_x, size.m_y); -} - - -dgCollisionChamferCylinder::~dgCollisionChamferCylinder() -{ - m_shapeRefCount --; - dgAssert (m_shapeRefCount >= 0); - - dgCollisionConvex::m_simplex = NULL; - dgCollisionConvex::m_vertex = NULL; -} - - -void dgCollisionChamferCylinder::Init (dgFloat32 radius, dgFloat32 height) -{ - m_rtti |= dgCollisionChamferCylinder_RTTI; - - m_radius = dgMax (dgAbs (radius), D_MIN_CONVEX_SHAPE_SIZE); - m_height = dgMax (dgAbs (height * dgFloat32 (0.5f)), D_MIN_CONVEX_SHAPE_SIZE); - - dgFloat32 sliceAngle = dgFloat32 (0.0f); - dgFloat32 sliceStep = dgPi / DG_CHAMFERCYLINDER_SLICES; - dgFloat32 breakStep = dgPI2 / DG_CHAMFERCYLINDER_BRAKES; - - dgMatrix rot (dgPitchMatrix (breakStep)); - dgInt32 index = 0; - for (dgInt32 j = 0; j <= DG_CHAMFERCYLINDER_SLICES; j ++) { - dgVector p0 (-m_height * dgCos(sliceAngle), dgFloat32 (0.0f), m_radius + m_height * dgSin(sliceAngle), dgFloat32 (0.0f)); - sliceAngle += sliceStep; - for (dgInt32 i = 0; i < DG_CHAMFERCYLINDER_BRAKES; i ++) { - m_vertex[index] = p0; - index ++; - p0 = rot.UnrotateVector (p0); - } - } - - m_edgeCount = (4 * DG_CHAMFERCYLINDER_SLICES + 2)* DG_CHAMFERCYLINDER_BRAKES; - m_vertexCount = DG_CHAMFERCYLINDER_BRAKES * (DG_CHAMFERCYLINDER_SLICES + 1); - dgCollisionConvex::m_vertex = m_vertex; - - if (!m_shapeRefCount) { - dgPolyhedra polyhedra(m_allocator); - dgInt32 wireframe[DG_CHAMFERCYLINDER_SLICES + 10]; - - for (dgInt32 i = 0; i < DG_MAX_CHAMFERCYLINDER_DIR_COUNT; i ++) { - dgMatrix matrix (dgPitchMatrix (dgFloat32 (dgPI2 * i) / DG_MAX_CHAMFERCYLINDER_DIR_COUNT)); - m_shapesDirs[i] = matrix.RotateVector (dgVector (dgFloat32 (0.0f), dgFloat32 (1.0f), dgFloat32 (0.0f), dgFloat32 (0.0f))); - } - - - dgInt32 index0 = 0; - for (dgInt32 j = 0; j < DG_CHAMFERCYLINDER_SLICES; j ++) { - dgInt32 index1 = index0 + DG_CHAMFERCYLINDER_BRAKES - 1; - for (dgInt32 i = 0; i < DG_CHAMFERCYLINDER_BRAKES; i ++) { - wireframe[0] = index0; - wireframe[1] = index1; - wireframe[2] = index1 + DG_CHAMFERCYLINDER_BRAKES; - wireframe[3] = index0 + DG_CHAMFERCYLINDER_BRAKES; - - index1 = index0; - index0 ++; - polyhedra.AddFace (4, wireframe); - } - } - - for (dgInt32 i = 0; i < DG_CHAMFERCYLINDER_BRAKES; i ++) { - wireframe[i] = i; - } - polyhedra.AddFace (DG_CHAMFERCYLINDER_BRAKES, wireframe); - - for (dgInt32 i = 0; i < DG_CHAMFERCYLINDER_BRAKES; i ++) { - wireframe[i] = DG_CHAMFERCYLINDER_BRAKES * (DG_CHAMFERCYLINDER_SLICES + 1) - i - 1; - } - polyhedra.AddFace (DG_CHAMFERCYLINDER_BRAKES, wireframe); - polyhedra.EndFace (); - - dgAssert (SanityCheck (polyhedra)); - - dgUnsigned64 i = 0; - dgPolyhedra::Iterator iter (polyhedra); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - edge->m_userData = i; - i ++; - } - - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - - dgConvexSimplexEdge* const ptr = &m_edgeArray[edge->m_userData]; - ptr->m_vertex = edge->m_incidentVertex; - ptr->m_next = &m_edgeArray[edge->m_next->m_userData]; - ptr->m_prev = &m_edgeArray[edge->m_prev->m_userData]; - ptr->m_twin = &m_edgeArray[edge->m_twin->m_userData]; - } - } - - m_shapeRefCount ++; - dgCollisionConvex::m_simplex = m_edgeArray; - - SetVolumeAndCG (); -} - - -void dgCollisionChamferCylinder::DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - dgInt32 slices = 12; - dgInt32 brakes = 24; - dgFloat32 sliceAngle = dgFloat32 (0.0f); - dgFloat32 sliceStep = dgPi / slices; - dgFloat32 breakStep = dgPI2 / brakes; - - dgTriplex pool[24 * (12 + 1)]; - - dgMatrix rot (dgPitchMatrix (breakStep)); - dgInt32 index = 0; - for (dgInt32 j = 0; j <= slices; j ++) { - dgVector p0 (-m_height * dgCos(sliceAngle), dgFloat32 (0.0f), m_radius + m_height * dgSin(sliceAngle), dgFloat32 (0.0f)); - sliceAngle += sliceStep; - for (dgInt32 i = 0; i < brakes; i ++) { - pool[index].m_x = p0.m_x; - pool[index].m_y = p0.m_y; - pool[index].m_z = p0.m_z; - index ++; - p0 = rot.UnrotateVector (p0); - } - } - - matrix.TransformTriplex (&pool[0].m_x, sizeof (dgTriplex), &pool[0].m_x, sizeof (dgTriplex), 24 * (12 + 1)); - - dgTriplex face[32]; - - index = 0; - for (dgInt32 j = 0; j < slices; j ++) { - dgInt32 index0 = index + brakes - 1; - for (dgInt32 i = 0; i < brakes; i ++) { - face[0] = pool[index]; - face[1] = pool[index0]; - face[2] = pool[index0 + brakes]; - face[3] = pool[index + brakes]; - index0 = index; - index ++; - callback (userData, 4, &face[0].m_x, 0); - } - } - - for (dgInt32 i = 0; i < brakes; i ++) { - face[i] = pool[i]; - } - callback (userData, 24, &face[0].m_x, 0); - - for (dgInt32 i = 0; i < brakes; i ++) { - face[i] = pool[brakes * (slices + 1) - i - 1]; - } - callback (userData, 24, &face[0].m_x, 0); -} - - -dgInt32 dgCollisionChamferCylinder::CalculateSignature (dgFloat32 radius, dgFloat32 height) -{ - dgUnsigned32 buffer[3]; - - memset (buffer, 0, sizeof (buffer)); - buffer[0] = m_chamferCylinderCollision; - buffer[1] = dgCollision::Quantize (radius); - buffer[2] = dgCollision::Quantize (height); - return dgInt32 (dgCollision::Quantize(buffer, sizeof (buffer))); -} - -dgInt32 dgCollisionChamferCylinder::CalculateSignature () const -{ - return CalculateSignature (m_radius, m_height); -} - - -void dgCollisionChamferCylinder::SetCollisionBBox (const dgVector& p0__, const dgVector& p1__) -{ - dgAssert (0); -} - - -void dgCollisionChamferCylinder::GetCollisionInfo(dgCollisionInfo* const info) const -{ - dgCollisionConvex::GetCollisionInfo(info); - - info->m_chamferCylinder.m_r = m_radius; - info->m_chamferCylinder.m_height = m_height * dgFloat32 (2.0f); -} - -void dgCollisionChamferCylinder::Serialize(dgSerialize callback, void* const userData) const -{ - dgVector size (m_radius, m_height * dgFloat32 (2.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - - SerializeLow(callback, userData); - callback (userData, &size, sizeof (dgVector)); -} - - - -dgFloat32 dgCollisionChamferCylinder::RayCast(const dgVector& q0, const dgVector& q1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const -{ - if (q0.m_x > m_height) { - if (q1.m_x < m_height) { - dgFloat32 t1 = (m_height - q0.m_x) / (q1.m_x - q0.m_x); - dgFloat32 y = q0.m_y + (q1.m_y - q0.m_y) * t1; - dgFloat32 z = q0.m_z + (q1.m_z - q0.m_z) * t1; - if ((y * y + z * z) < m_radius * m_radius) { - contactOut.m_normal = dgVector(dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - return t1; - } - } - } - - if (q0.m_x < -m_height) { - if (q1.m_x > -m_height) { - dgFloat32 t1 = (-m_height - q0.m_x) / (q1.m_x - q0.m_x); - dgFloat32 y = q0.m_y + (q1.m_y - q0.m_y) * t1; - dgFloat32 z = q0.m_z + (q1.m_z - q0.m_z) * t1; - if ((y * y + z * z) < m_radius * m_radius) { - contactOut.m_normal = dgVector(dgFloat32(-1.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - return t1; - } - } - } - - dgVector dq((q1 - q0) & dgVector::m_triplexMask); - - // avoid NaN as a result of a division by zero - if (dq.DotProduct(dq).GetScalar() <= 0.0f) { - return dgFloat32(1.2f); - } - - //dgVector dir(dq * dq.InvMagSqrt()); - dgVector dir(dq.Normalize()); - if (dgAbs(dir.m_x) > 0.9999f) { - return dgCollisionConvex::RayCast(q0, q1, maxT, contactOut, body, NULL, NULL); - } - - dgVector p0(q0 & dgVector::m_triplexMask); - dgVector p1(q1 & dgVector::m_triplexMask); - - p0.m_x = dgFloat32 (0.0f); - p1.m_x = dgFloat32 (0.0f); - - dgVector dp (p1 - p0); - dgFloat32 a = dp.DotProduct(dp).GetScalar(); - dgFloat32 b = dgFloat32 (2.0f) * dp.DotProduct(p0).GetScalar(); - dgFloat32 c = p0.DotProduct(p0).GetScalar() - m_radius * m_radius; - - dgFloat32 disc = b * b - dgFloat32 (4.0f) * a * c; - if (disc >= dgFloat32 (0.0f)) { - disc = dgSqrt (disc); - dgVector origin0(p0 + dp.Scale ((-b + disc) / (dgFloat32 (2.0f) * a))); - dgVector origin1(p0 + dp.Scale ((-b - disc) / (dgFloat32 (2.0f) * a))); - dgFloat32 t0 = dgRayCastSphere(q0, q1, origin0, m_height); - dgFloat32 t1 = dgRayCastSphere(q0, q1, origin1, m_height); - if(t1 < t0) { - t0 = t1; - origin0 = origin1; - } - - if ((t0 >= 0.0f) && (t0 <= 1.0f)) { - contactOut.m_normal = q0 + dq.Scale(t0) - origin0; - dgAssert(contactOut.m_normal.m_w == dgFloat32(0.0f)); - - //contactOut.m_normal = contactOut.m_normal * contactOut.m_normal.DotProduct(contactOut.m_normal).InvSqrt(); - contactOut.m_normal = contactOut.m_normal.Normalize(); - return t0; - } - } else { - dgVector origin0 (dgPointToRayDistance (dgVector::m_zero, p0, p1)); - origin0 = origin0.Scale(m_radius / dgSqrt(origin0.DotProduct(origin0).GetScalar())); - dgFloat32 t0 = dgRayCastSphere(q0, q1, origin0, m_height); - if ((t0 >= 0.0f) && (t0 <= 1.0f)) { - contactOut.m_normal = q0 + dq.Scale(t0) - origin0; - dgAssert(contactOut.m_normal.m_w == dgFloat32(0.0f)); - - //contactOut.m_normal = contactOut.m_normal * contactOut.m_normal.DotProduct(contactOut.m_normal).InvSqrt(); - contactOut.m_normal = contactOut.m_normal.Normalize(); - return t0; - } - } - return dgFloat32(1.2f); -} - -dgVector dgCollisionChamferCylinder::SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert (dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f)); - - dgFloat32 x = dir.GetScalar(); - if (dgAbs (x) > dgFloat32 (0.9999f)) { - return dgVector (dgSign (x) * m_height, m_radius, dgFloat32 (0.0f), dgFloat32 (0.0f)); - } - - dgVector sideDir (m_yzMask & dir); - sideDir = sideDir.Normalize(); - return sideDir.Scale(m_radius) + dir.Scale (m_height); -} - -dgVector dgCollisionChamferCylinder::SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert (dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f)); - - dgFloat32 x = dir.GetScalar(); - if (dgAbs (x) > dgFloat32 (0.99995f)) { - return dgVector (dgFloat32 (0.0f), m_radius, dgFloat32 (0.0f), dgFloat32 (0.0f)); - } - - dgVector sideDir (m_yzMask & dir); - dgAssert (sideDir.DotProduct(sideDir).GetScalar() > dgFloat32 (0.0f)); - return sideDir.Normalize().Scale(m_radius); -} - -dgVector dgCollisionChamferCylinder::SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const -{ - dgAssert (dir.m_w == 0.0f); - return point + dir.Scale(m_height - DG_PENETRATION_TOL); -} - -dgInt32 dgCollisionChamferCylinder::CalculatePlaneIntersection (const dgVector& normal, const dgVector& origin, dgVector* const contactsOut) const -{ - dgInt32 count = 0; - const dgFloat32 inclination = dgFloat32 (0.9999f); - if (normal.m_x < -inclination) { - dgMatrix matrix(normal); - dgFloat32 x = dgSqrt (dgMax (m_height * m_height - origin.m_x * origin.m_x, dgFloat32 (0.0f))); - matrix.m_posit.m_x = origin.m_x; - count = BuildCylinderCapPoly (m_radius + x, matrix, contactsOut); - //count = RectifyConvexSlice(n, normal, contactsOut); - } else if (normal.m_x > inclination) { - dgMatrix matrix(normal); - dgFloat32 x = dgSqrt (dgMax (m_height * m_height - origin.m_x * origin.m_x, dgFloat32 (0.0f))); - matrix.m_posit.m_x = origin.m_x; - count = BuildCylinderCapPoly (m_radius + x, matrix, contactsOut); - //count = RectifyConvexSlice(n, normal, contactsOut); - } else { - count = 1; - contactsOut[0] = SupportVertex (normal, NULL); - } - return count; -} - -void dgCollisionChamferCylinder::CalculateImplicitContacts(dgInt32 count, dgContactPoint* const contactPoints) const -{ - for (dgInt32 i = 0; i < count; i ++) { - dgVector diskPoint (contactPoints[i].m_point); - diskPoint.m_x = dgFloat32 (0.0f); - diskPoint.m_w = dgFloat32 (0.0f); - dgAssert(diskPoint.DotProduct(diskPoint).GetScalar() > dgFloat32(0.0f)); - dgFloat32 r2 = diskPoint.DotProduct(diskPoint).GetScalar(); - if (r2 >= m_radius * m_radius) { - diskPoint = diskPoint.Normalize().Scale (m_radius); - dgVector normal (contactPoints[i].m_point - diskPoint); - normal = normal.Normalize(); - contactPoints[i].m_point = diskPoint + normal.Scale (m_height); - contactPoints[i].m_normal = normal * dgVector::m_negOne; - } else { - contactPoints[i].m_normal = dgVector::m_zero; - contactPoints[i].m_normal.m_x = dgSign(contactPoints[i].m_point.m_x); - contactPoints[i].m_point.m_x = dgSign(contactPoints[i].m_normal.m_x) * m_height; - } - } -} \ No newline at end of file diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionChamferCylinder.h b/thirdparty/src/newton/dgPhysics/dgCollisionChamferCylinder.h deleted file mode 100644 index b8f80befd..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionChamferCylinder.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -#if !defined(AFX_DGCOLLISIONCHAMFERCYLINDER_H__AS235640FER_H) -#define AFX_DGCOLLISIONCHAMFERCYLINDER_H__AS235640FER_H - -#include "dgCollisionConvex.h" - -#define DG_CHAMFERCYLINDER_SLICES 4 -#define DG_CHAMFERCYLINDER_BRAKES 8 -#define DG_MAX_CHAMFERCYLINDER_DIR_COUNT 8 - - -class dgCollisionChamferCylinder: public dgCollisionConvex -{ - public: - dgCollisionChamferCylinder(dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgFloat32 radius, dgFloat32 height); - dgCollisionChamferCylinder(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionChamferCylinder(); - - protected: - void Init (dgFloat32 radius, dgFloat32 height); - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - virtual dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& origin, dgVector* const contactsOut) const; - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const; - - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - virtual dgInt32 CalculateSignature () const; - virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1); - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - virtual void Serialize(dgSerialize callback, void* const userData) const; - - static dgInt32 CalculateSignature (dgFloat32 radius, dgFloat32 height); - - virtual void CalculateImplicitContacts(dgInt32 count, dgContactPoint* const contactPoints) const; - virtual dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const; - - private: - dgFloat32 m_height; - dgFloat32 m_radius; - - dgVector m_vertex[DG_CHAMFERCYLINDER_BRAKES * (DG_CHAMFERCYLINDER_SLICES + 1)]; - static dgInt32 m_shapeRefCount; - static dgConvexSimplexEdge m_edgeArray[]; - static dgVector m_shapesDirs[]; - static dgVector m_yzMask; - - friend class dgWorld; -}; - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionCompound.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionCompound.cpp deleted file mode 100644 index 0a5fcc943..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionCompound.cpp +++ /dev/null @@ -1,3065 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgWorld.h" -#include "dgCollisionBVH.h" -#include "dgCollisionConvex.h" -#include "dgCollisionCompound.h" -#include "dgCollisionInstance.h" -#include "dgCollisionUserMesh.h" -#include "dgCollisionHeightField.h" - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#define DG_MAX_MIN_VOLUME dgFloat32 (1.0e-3f) - - -dgVector dgCollisionCompound::m_padding (dgFloat32 (1.0e-3f)); -dgVector dgCollisionCompound::dgOOBBTestData::m_maxDist (dgFloat32 (1.0e10f)); - -class dgCollisionCompound::dgHeapNodePair -{ - public: - dgNodeBase* m_nodeA; - dgNodeBase* m_nodeB; -}; - - -dgCollisionCompound::dgTreeArray::dgTreeArray (dgMemoryAllocator* const allocator) - :dgTree<dgNodeBase*, dgInt32>(allocator) -{ -} - -void dgCollisionCompound::dgTreeArray::AddNode (dgNodeBase* const node, dgInt32 index, const dgCollisionInstance* const parent) -{ - dgTreeNode* const myNode = dgTree<dgNodeBase*, dgInt32>::Insert(node, index); - node->m_myNode = myNode; - node->m_shape->m_parent = parent; - node->m_shape->m_subCollisionHandle = myNode; -} - - -dgCollisionCompound::dgOOBBTestData::dgOOBBTestData (const dgMatrix& matrix) - :m_matrix (matrix) - ,m_separatingDistance(dgFloat32 (1.0e10f)) -{ - m_absMatrix[0] = m_matrix[0].Abs(); - m_absMatrix[1] = m_matrix[1].Abs(); - m_absMatrix[2] = m_matrix[2].Abs(); - m_absMatrix[3] = dgVector::m_wOne; - - dgInt32 index = 0; - for (dgInt32 i = 0; i < 3; i ++) { - dgVector dir(dgFloat32 (0.0f)); - dir[i] = dgFloat32 (1.0f); - for (dgInt32 j = 0; j < 3; j ++) { - dgVector axis (dir.CrossProduct(m_matrix[j])); - m_crossAxis[index] = axis; - m_crossAxisAbs[index] = axis.Abs(); - m_crossAxisDotAbs[index] = matrix.UnrotateVector (axis).Abs(); - index ++; - } - } - - dgVector tmp; - dgVector::Transpose4x4 (m_crossAxis[0], m_crossAxis[1], m_crossAxis[2], m_crossAxis[3], m_crossAxis[0], m_crossAxis[1], m_crossAxis[2], m_crossAxis[3]); - dgVector::Transpose4x4 (m_crossAxis[3], m_crossAxis[4], m_crossAxis[5], m_crossAxis[6], m_crossAxis[4], m_crossAxis[5], m_crossAxis[6], m_crossAxis[7]); - dgVector::Transpose4x4 (m_crossAxis[6], m_crossAxis[7], m_crossAxis[8], tmp, m_crossAxis[8], m_crossAxis[8], m_crossAxis[8], m_crossAxis[8]); - - dgVector::Transpose4x4 (m_crossAxisAbs[0], m_crossAxisAbs[1], m_crossAxisAbs[2], m_crossAxisAbs[3], m_crossAxisAbs[0], m_crossAxisAbs[1], m_crossAxisAbs[2], m_crossAxisAbs[3]); - dgVector::Transpose4x4 (m_crossAxisAbs[3], m_crossAxisAbs[4], m_crossAxisAbs[5], m_crossAxisAbs[6], m_crossAxisAbs[4], m_crossAxisAbs[5], m_crossAxisAbs[6], m_crossAxisAbs[7]); - dgVector::Transpose4x4 (m_crossAxisAbs[6], m_crossAxisAbs[7], m_crossAxisAbs[8], tmp, m_crossAxisAbs[8], m_crossAxisAbs[8], m_crossAxisAbs[8], m_crossAxisAbs[8]); - - dgVector::Transpose4x4 (m_crossAxisDotAbs[0], m_crossAxisDotAbs[1], m_crossAxisDotAbs[2], m_crossAxisDotAbs[3], m_crossAxisDotAbs[0], m_crossAxisDotAbs[1], m_crossAxisDotAbs[2], m_crossAxisDotAbs[3]); - dgVector::Transpose4x4 (m_crossAxisDotAbs[3], m_crossAxisDotAbs[4], m_crossAxisDotAbs[5], m_crossAxisDotAbs[6], m_crossAxisDotAbs[4], m_crossAxisDotAbs[5], m_crossAxisDotAbs[6], m_crossAxisDotAbs[7]); - dgVector::Transpose4x4 (m_crossAxisDotAbs[6], m_crossAxisDotAbs[7], m_crossAxisDotAbs[8], tmp, m_crossAxisDotAbs[8], m_crossAxisDotAbs[8], m_crossAxisDotAbs[8], m_crossAxisDotAbs[8]); -} - - -dgCollisionCompound::dgOOBBTestData::dgOOBBTestData (const dgMatrix& matrix, const dgVector& localOrigin, const dgVector& localSize) - :m_matrix (matrix) - ,m_origin(localOrigin) - ,m_size(localSize) - ,m_localP0 (localOrigin - localSize) - ,m_localP1 (localOrigin + localSize) - ,m_separatingDistance(dgFloat32 (1.0e10f)) -{ - m_absMatrix[0] = m_matrix[0].Abs(); - m_absMatrix[1] = m_matrix[1].Abs(); - m_absMatrix[2] = m_matrix[2].Abs(); - m_absMatrix[3] = dgVector::m_wOne; - - dgInt32 index = 0; - for (dgInt32 i = 0; i < 3; i ++) { - dgVector dir(dgFloat32 (0.0f)); - dir[i] = dgFloat32 (1.0f); - for (dgInt32 j = 0; j < 3; j ++) { - m_crossAxis[index] = dir.CrossProduct(m_matrix[j]); - index ++; - } - } - - dgVector size (m_absMatrix.RotateVector(m_size)); - dgVector origin (m_matrix.TransformVector (m_origin)); - m_aabbP0 = origin - size; - m_aabbP1 = origin + size; - - index = 0; - dgVector extends[9]; - for (dgInt32 i = 0; i < 3; i ++) { - for (dgInt32 j = 0; j < 3; j ++) { - const dgVector& axis = m_crossAxis[index]; - dgAssert (axis.m_w == dgFloat32 (0.0f)); - dgVector tmp (m_matrix.UnrotateVector(axis)); - dgVector d (m_size.DotProduct(tmp.Abs()) + m_padding); - dgVector c (origin.DotProduct(axis)); - dgVector diff (c - d); - dgVector sum (c + d); - extends[index] = dgVector (diff.m_x, sum.m_x, diff.m_y, sum.m_y); - m_crossAxisAbs[index] = axis.Abs(); - index ++; - } - } - - dgVector tmp; - dgVector::Transpose4x4 (m_crossAxis[0], m_crossAxis[1], m_crossAxis[2], m_crossAxis[3], m_crossAxis[0], m_crossAxis[1], m_crossAxis[2], m_crossAxis[3]); - dgVector::Transpose4x4 (m_crossAxis[3], m_crossAxis[4], m_crossAxis[5], m_crossAxis[6], m_crossAxis[4], m_crossAxis[5], m_crossAxis[6], m_crossAxis[7]); - dgVector::Transpose4x4 (m_crossAxis[6], m_crossAxis[7], m_crossAxis[8], tmp, m_crossAxis[8], m_crossAxis[8], m_crossAxis[8], m_crossAxis[8]); - - dgVector::Transpose4x4 (m_crossAxisAbs[0], m_crossAxisAbs[1], m_crossAxisAbs[2], m_crossAxisAbs[3], m_crossAxisAbs[0], m_crossAxisAbs[1], m_crossAxisAbs[2], m_crossAxisAbs[3]); - dgVector::Transpose4x4 (m_crossAxisAbs[3], m_crossAxisAbs[4], m_crossAxisAbs[5], m_crossAxisAbs[6], m_crossAxisAbs[4], m_crossAxisAbs[5], m_crossAxisAbs[6], m_crossAxisAbs[7]); - dgVector::Transpose4x4 (m_crossAxisAbs[6], m_crossAxisAbs[7], m_crossAxisAbs[8], tmp, m_crossAxisAbs[8], m_crossAxisAbs[8], m_crossAxisAbs[8], m_crossAxisAbs[8]); - - dgVector::Transpose4x4 (m_extendsMinX[0], m_extendsMaxX[0], tmp, tmp, extends[0], extends[1], extends[2], extends[3]); - dgVector::Transpose4x4 (m_extendsMinX[1], m_extendsMaxX[1], tmp, tmp, extends[4], extends[5], extends[6], extends[7]); - dgVector::Transpose4x4 (m_extendsMinX[2], m_extendsMaxX[2], tmp, tmp, extends[8], extends[8], extends[8], extends[8]); -} - - -dgCollisionCompound::dgNodeBase::dgNodeBase () - :m_left(NULL) - ,m_right(NULL) - ,m_parent(NULL) - ,m_shape(NULL) - ,m_myNode(NULL) -{ -} - -dgCollisionCompound::dgNodeBase::dgNodeBase (const dgNodeBase& copyFrom) - :m_p0(copyFrom.m_p0) - ,m_p1(copyFrom.m_p1) - ,m_size(copyFrom.m_size) - ,m_origin(copyFrom.m_origin) - ,m_area(copyFrom.m_area) - ,m_type(copyFrom.m_type) - ,m_left(NULL) - ,m_right(NULL) - ,m_parent(NULL) - ,m_shape(copyFrom.m_shape) - ,m_myNode(NULL) -{ - dgAssert (!copyFrom.m_shape); -} - - -dgCollisionCompound::dgNodeBase::dgNodeBase (dgCollisionInstance* const instance) - :m_type(m_leaf) - ,m_left(NULL) - ,m_right(NULL) - ,m_parent(NULL) - ,m_shape(new (instance->GetAllocator()) dgCollisionInstance (*instance)) - ,m_myNode(NULL) -{ - CalculateAABB(); -} - - -dgCollisionCompound::dgNodeBase::dgNodeBase (dgNodeBase* const left, dgNodeBase* const right) - :m_type(m_node) - ,m_left(left) - ,m_right(right) - ,m_parent(NULL) - ,m_shape(NULL) - ,m_myNode(NULL) -{ - m_left->m_parent = this; - m_right->m_parent = this; - - dgVector p0 (left->m_p0.GetMin(right->m_p0)); - dgVector p1 (left->m_p1.GetMax(right->m_p1)); - SetBox(p0, p1); -} - -dgCollisionCompound::dgNodeBase::~dgNodeBase() -{ - if (m_shape) { - m_shape->Release (); - } - if (m_left) { - delete m_left; - } - if (m_right) { - delete m_right; - } -} - - -void dgCollisionCompound::dgNodeBase::SetBox (const dgVector& p0, const dgVector& p1) -{ - m_p0 = p0; - m_p1 = p1; - dgAssert (m_p0.m_w == dgFloat32 (0.0f)); - dgAssert (m_p1.m_w == dgFloat32 (0.0f)); - m_size = dgVector::m_half * (m_p1 - m_p0); - m_origin = dgVector::m_half * (m_p1 + m_p0); - m_area = m_size.DotProduct(m_size.ShiftTripleRight()).m_x; -} - -void dgCollisionCompound::dgNodeBase::CalculateAABB() -{ - dgVector p0; - dgVector p1; - m_shape->CalcAABB(m_shape->GetLocalMatrix (), p0, p1); - SetBox (p0, p1); -} - -bool dgCollisionCompound::dgNodeBase::BoxTest (const dgOOBBTestData& data) const -{ - dgFloat32 separatingDistance = data.UpdateSeparatingDistance (data.m_aabbP0, data.m_aabbP1, m_p0, m_p1); - if (dgOverlapTest (data.m_aabbP0, data.m_aabbP1, m_p0, m_p1)) { - // this assert is in fact a bug - //dgAssert (separatingDistance > dgFloat32 (1000.0f)); - dgVector origin (data.m_matrix.UntransformVector(m_origin)); - dgVector size (data.m_absMatrix.UnrotateVector(m_size)); - dgVector p0 (origin - size); - dgVector p1 (origin + size); - data.m_separatingDistance = dgMin(data.m_separatingDistance, data.UpdateSeparatingDistance (p0, p1, data.m_localP0, data.m_localP1)); - if (dgOverlapTest (p0, p1, data.m_localP0, data.m_localP1)) { - dgVector size_x (m_size.m_x); - dgVector size_y (m_size.m_y); - dgVector size_z (m_size.m_z); - - dgVector origin_x (m_origin.m_x); - dgVector origin_y (m_origin.m_y); - dgVector origin_z (m_origin.m_z); - - bool ret = true; - for (dgInt32 i = 0; (i < 3) && ret; i ++) { - const dgInt32 j = i * 3; - dgVector c (origin_x * data.m_crossAxis[j + 0] + origin_y * data.m_crossAxis[j + 1] + origin_z * data.m_crossAxis[j + 2]); - dgVector d (size_x * data.m_crossAxisAbs[j + 0] + size_y * data.m_crossAxisAbs[j + 1] + size_z * data.m_crossAxisAbs[j + 2] + m_padding); - dgVector x0 (c - d); - dgVector x1 (c + d); - dgVector box0 (x0 - data.m_extendsMaxX[i]); - dgVector box1 (x1 - data.m_extendsMinX[i]); - dgVector test (box0 * box1); - ret = (test.GetSignMask() & 0x0f) == 0x0f; - } - return ret; - } - } - data.m_separatingDistance = dgMin(data.m_separatingDistance, separatingDistance); - return false; -} - - -bool dgCollisionCompound::dgNodeBase::BoxTest (const dgOOBBTestData& data, const dgNodeBase* const otherNode) const -{ - dgVector otherOrigin (data.m_matrix.TransformVector(otherNode->m_origin)); - dgVector otherSize (data.m_absMatrix.RotateVector(otherNode->m_size)); - dgVector otherP0 ((otherOrigin - otherSize) & dgVector::m_triplexMask); - dgVector otherP1 ((otherOrigin + otherSize) & dgVector::m_triplexMask); - - dgFloat32 separatingDistance = data.UpdateSeparatingDistance (m_p0, m_p1, otherP0, otherP1); - if (dgOverlapTest (m_p0, m_p1, otherP0, otherP1)) { - dgAssert (separatingDistance > dgFloat32 (1000.0f)); - dgVector origin (data.m_matrix.UntransformVector(m_origin)); - dgVector size (data.m_absMatrix.UnrotateVector(m_size)); - dgVector p0 (origin - size); - dgVector p1 (origin + size); - data.m_separatingDistance = dgMin(data.m_separatingDistance, data.UpdateSeparatingDistance (p0, p1, otherNode->m_p0, otherNode->m_p1)); - if (dgOverlapTest (p0, p1, otherNode->m_p0, otherNode->m_p1)) { - dgVector size0_x (m_size.m_x); - dgVector size0_y (m_size.m_y); - dgVector size0_z (m_size.m_z); - - dgVector origin0_x (m_origin.m_x); - dgVector origin0_y (m_origin.m_y); - dgVector origin0_z (m_origin.m_z); - - dgVector size1_x (otherNode->m_size.m_x); - dgVector size1_y (otherNode->m_size.m_y); - dgVector size1_z (otherNode->m_size.m_z); - - dgVector origin1_x (otherOrigin.m_x); - dgVector origin1_y (otherOrigin.m_y); - dgVector origin1_z (otherOrigin.m_z); - - bool ret = true; - for (dgInt32 j = 0; (j < 9) && ret; j += 3) { - dgVector c0 (origin0_x * data.m_crossAxis[j + 0] + origin0_y * data.m_crossAxis[j + 1] + origin0_z * data.m_crossAxis[j + 2]); - dgVector d0 (size0_x * data.m_crossAxisAbs[j + 0] + size0_y * data.m_crossAxisAbs[j + 1] + size0_z * data.m_crossAxisAbs[j + 2] + m_padding); - dgVector x0 (c0 - d0); - dgVector x1 (c0 + d0); - - dgVector c1 (origin1_x * data.m_crossAxis[j + 0] + origin1_y * data.m_crossAxis[j + 1] + origin1_z * data.m_crossAxis[j + 2]); - dgVector d1 (size1_x * data.m_crossAxisDotAbs[j + 0] + size1_y * data.m_crossAxisDotAbs[j + 1] + size1_z * data.m_crossAxisDotAbs[j + 2] + m_padding); - dgVector z0 (c1 - d1); - dgVector z1 (c1 + d1); - - dgVector box0 (x0 - z1); - dgVector box1 (x1 - z0); - dgVector test (box0 * box1); - ret = (test.GetSignMask() & 0x0f) == 0x0f; - } - return ret; - } - } - data.m_separatingDistance = dgMin(data.m_separatingDistance, separatingDistance); - return false; -} - -dgFloat32 dgCollisionCompound::dgNodeBase::RayBoxDistance (const dgOOBBTestData& data, const dgFastRayTest& myRay, const dgFastRayTest& otherRay, const dgNodeBase* const otherNode) const -{ - dgVector otherOrigin (data.m_matrix.TransformVector(otherNode->m_origin)); - dgVector otherSize (data.m_absMatrix.RotateVector(otherNode->m_size)); - dgVector otherP0 ((otherOrigin - otherSize) & dgVector::m_triplexMask); - dgVector otherP1 ((otherOrigin + otherSize) & dgVector::m_triplexMask); - dgVector minBox (m_p0 - otherP1); - dgVector maxBox (m_p1 - otherP0); - dgFloat32 dist = myRay.BoxIntersect (minBox, maxBox); - if (dist <= 1.0f) { - dgVector origin (data.m_matrix.UntransformVector(m_origin)); - dgVector size (data.m_absMatrix.UnrotateVector(m_size)); - dgVector p0 (origin - size); - dgVector p1 (origin + size); - dgVector minBox1 (p0 - otherNode->m_p1); - dgVector maxBox1 (p1 - otherNode->m_p0); - dgFloat32 dist1 = otherRay.BoxIntersect (minBox1, maxBox1); - dist = dgMax(dist, dist1); - } - - return dist; -} - -class dgCollisionCompound::dgSpliteInfo -{ - public: - dgSpliteInfo (dgNodeBase** const boxArray, dgInt32 boxCount) - { - dgVector minP ( dgFloat32 (1.0e15f)); - dgVector maxP (-dgFloat32 (1.0e15f)); - - if (boxCount == 2) { - m_axis = 1; - for (dgInt32 i = 0; i < boxCount; i ++) { - dgNodeBase* const node = boxArray[i]; - dgAssert (node->m_type == m_leaf); - minP = minP.GetMin (node->m_p0); - maxP = maxP.GetMax (node->m_p1); - } - } else { - dgVector median (dgFloat32 (0.0f)); - dgVector varian (dgFloat32 (0.0f)); - - for (dgInt32 i = 0; i < boxCount; i ++) { - dgNodeBase* const node = boxArray[i]; - dgAssert (node->m_type == m_leaf); - minP = minP.GetMin (node->m_p0); - maxP = maxP.GetMax (node->m_p1); - dgVector p (dgVector::m_half * (node->m_p0 + node->m_p1)); - median += p; - varian += p * p; - } - - varian = varian.Scale (dgFloat32 (boxCount)) - median * median; - - dgInt32 index = 0; - dgFloat32 maxVarian = dgFloat32 (-1.0e10f); - for (dgInt32 i = 0; i < 3; i ++) { - if (varian[i] > maxVarian) { - index = i; - maxVarian = varian[i]; - } - } - - dgVector center = median.Scale (dgFloat32 (1.0f) / dgFloat32 (boxCount)); - - dgFloat32 test = center[index]; - - dgInt32 i0 = 0; - dgInt32 i1 = boxCount - 1; - do { - for (; i0 <= i1; i0 ++) { - dgNodeBase* const node = boxArray[i0]; - dgFloat32 val = (node->m_p0[index] + node->m_p1[index]) * dgFloat32 (0.5f); - if (val > test) { - break; - } - } - - for (; i1 >= i0; i1 --) { - dgNodeBase* const node = boxArray[i1]; - dgFloat32 val = (node->m_p0[index] + node->m_p1[index]) * dgFloat32 (0.5f); - if (val < test) { - break; - } - } - - if (i0 < i1) { - dgSwap(boxArray[i0], boxArray[i1]); - i0++; - i1--; - } - - } while (i0 <= i1); - - if (i0 > 0){ - i0 --; - } - if ((i0 + 1) >= boxCount) { - i0 = boxCount - 2; - } - - m_axis = i0 + 1; - } - - dgAssert (maxP.m_x - minP.m_x >= dgFloat32 (0.0f)); - dgAssert (maxP.m_y - minP.m_y >= dgFloat32 (0.0f)); - dgAssert (maxP.m_z - minP.m_z >= dgFloat32 (0.0f)); - m_p0 = minP; - m_p1 = maxP; - } - - dgInt32 m_axis; - dgVector m_p0; - dgVector m_p1; -}; - - -dgCollisionCompound::dgCollisionCompound(dgWorld* const world) - :dgCollision (world->GetAllocator(), 0, m_compoundCollision) - ,m_world(world) - ,m_root(NULL) - ,m_myInstance(NULL) - ,m_array (world->GetAllocator()) - ,m_treeEntropy (dgFloat32 (0.0f)) - ,m_boxMinRadius(dgFloat32(0.0f)) - ,m_boxMaxRadius(dgFloat32(0.0f)) - ,m_idIndex(0) - ,m_criticalSectionLock(0) -{ - m_rtti |= dgCollisionCompound_RTTI; -} - -dgCollisionCompound::dgCollisionCompound (const dgCollisionCompound& source, const dgCollisionInstance* const myInstance) - :dgCollision (source) - ,m_world (source.m_world) - ,m_root(NULL) - ,m_myInstance(myInstance) - ,m_array (source.GetAllocator()) - ,m_treeEntropy(source.m_treeEntropy) - ,m_boxMinRadius(source.m_boxMinRadius) - ,m_boxMaxRadius(source.m_boxMaxRadius) - ,m_idIndex(source.m_idIndex) - ,m_criticalSectionLock(0) -{ - m_rtti |= dgCollisionCompound_RTTI; - - dgTreeArray::Iterator iter (source.m_array); - for (iter.Begin(); iter; iter ++) { - dgNodeBase* const node = iter.GetNode()->GetInfo(); - dgNodeBase* const newNode = new (m_allocator) dgNodeBase (node->GetShape()); - m_array.AddNode(newNode, iter.GetNode()->GetKey(), m_myInstance); - } - - if (source.m_root) { - dgNodeBase* pool[DG_COMPOUND_STACK_DEPTH]; - dgNodeBase* parents[DG_COMPOUND_STACK_DEPTH]; - pool[0] = source.m_root; - parents[0] = NULL; - dgInt32 stack = 1; - while (stack) { - stack --; - dgNodeBase* const sourceNode = pool [stack]; - - dgNodeBase* parent = NULL; - if (sourceNode->m_type == m_node) { - parent = new (m_allocator) dgNodeBase (*sourceNode); - if (!sourceNode->m_parent) { - m_root = parent; - } else { - parent->m_parent = parents[stack]; - if (parent->m_parent) { - if (sourceNode->m_parent->m_left == sourceNode) { - parent->m_parent->m_left = parent; - } else { - dgAssert (sourceNode->m_parent->m_right == sourceNode); - parent->m_parent->m_right = parent; - } - } - } - } else { - //dgNodeBase* const node = m_array.Find (sourceNode->m_shape)->GetInfo(); - dgNodeBase* const node = m_array.Find (sourceNode->m_myNode->GetKey())->GetInfo(); - dgAssert (node); - node->m_parent = parents[stack]; - if (node->m_parent) { - if (sourceNode->m_parent->m_left == sourceNode) { - node->m_parent->m_left = node; - } else { - dgAssert (sourceNode->m_parent->m_right == sourceNode); - node->m_parent->m_right = node; - } - } else { - m_root = node; - } - } - - if (sourceNode->m_left) { - parents[stack] = parent; - pool[stack] = sourceNode->m_left; - stack ++; - dgAssert (stack < DG_COMPOUND_STACK_DEPTH); - } - - if (sourceNode->m_right) { - parents[stack] = parent; - pool[stack] = sourceNode->m_right; - stack ++; - dgAssert (stack < DG_COMPOUND_STACK_DEPTH); - } - } - } -} - -dgCollisionCompound::dgCollisionCompound (dgWorld* const world, dgDeserialize deserialization, void* const userData, const dgCollisionInstance* const myInstance, dgInt32 revisionNumber) - :dgCollision (world, deserialization, userData, revisionNumber) - ,m_world(world) - ,m_root(NULL) - ,m_myInstance(myInstance) - ,m_array (world->GetAllocator()) - ,m_treeEntropy(dgFloat32(0.0f)) - ,m_boxMinRadius(dgFloat32(0.0f)) - ,m_boxMaxRadius(dgFloat32(0.0f)) - ,m_idIndex(0) - ,m_criticalSectionLock(0) -{ - dgAssert (m_rtti | dgCollisionCompound_RTTI); - - dgInt32 count; - deserialization (userData, &count, sizeof (count)); - BeginAddRemove (); - for (dgInt32 i = 0; i < count; i ++) { - dgCollisionInstance* const collision = new (world->GetAllocator()) dgCollisionInstance (world, deserialization, userData, revisionNumber); - AddCollision (collision); - collision->Release(); - } - EndAddRemove(); -} - - -dgCollisionCompound::~dgCollisionCompound() -{ - if (m_root) { - delete m_root; - } -} - -void dgCollisionCompound::SetParent (const dgCollisionInstance* const instance) -{ - m_myInstance = instance; -} - -void dgCollisionCompound::SetCollisionBBox (const dgVector& p0__, const dgVector& p1__) -{ - dgAssert (0); -} - -void dgCollisionCompound::GetAABB (dgVector& boxMin, dgVector& boxMax) const -{ - if (m_root) { - boxMin = m_root->m_p0; - boxMax = m_root->m_p1; - } else { - boxMin = dgVector (dgFloat32 (0.0f)); - boxMax = dgVector (dgFloat32 (0.0f)); - } -} - - -dgInt32 dgCollisionCompound::CalculateSignature () const -{ - dgAssert (0); - return 0; -} - - - -void dgCollisionCompound::CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const -{ - if (m_root) { - dgVector origin (matrix.TransformVector(m_root->m_origin)); - dgVector size (matrix.m_front.Abs().Scale(m_root->m_size.m_x) + matrix.m_up.Abs().Scale(m_root->m_size.m_y) + matrix.m_right.Abs().Scale(m_root->m_size.m_z)); - - size -= dgCollisionInstance::m_padding; - p0 = (origin - size) & dgVector::m_triplexMask; - p1 = (origin + size) & dgVector::m_triplexMask; - } else { - p0 = dgVector (dgFloat32 (0.0f)); - p1 = dgVector (dgFloat32 (0.0f)); - } -} - -dgInt32 dgCollisionCompound::CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const -{ - return 0; -} - -void dgCollisionCompound::DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - dgTreeArray::Iterator iter (m_array); - for (iter.Begin(); iter; iter ++) { - dgCollisionInstance* const collision = iter.GetNode()->GetInfo()->GetShape(); - collision->DebugCollision (matrix, callback, userData); - } -} - -dgFloat32 dgCollisionCompound::RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const -{ - if (!m_root) { - return dgFloat32 (1.2f); - } - - dgFloat32 distance[DG_COMPOUND_STACK_DEPTH]; - const dgNodeBase* stackPool[DG_COMPOUND_STACK_DEPTH]; - -// dgFloat32 maxParam = maxT; - dgFastRayTest ray (localP0, localP1); - - dgInt32 stack = 1; - stackPool[0] = m_root; - distance[0] = ray.BoxIntersect(m_root->m_p0, m_root->m_p1); - while (stack) { - stack --; - dgFloat32 dist = distance[stack]; - - if (dist > maxT) { - break; - } else { - const dgNodeBase* const me = stackPool[stack]; - dgAssert (me); - if (me->m_type == m_leaf) { - dgContactPoint tmpContactOut; - dgCollisionInstance* const shape = me->GetShape(); - dgVector p0 (shape->GetLocalMatrix().UntransformVector (localP0)); - dgVector p1 (shape->GetLocalMatrix().UntransformVector (localP1)); - dgFloat32 param = shape->RayCast (p0, p1, maxT, tmpContactOut, preFilter, body, userData); - if (param < maxT) { - maxT = param; - contactOut.m_normal = shape->GetLocalMatrix().RotateVector (tmpContactOut.m_normal); - contactOut.m_shapeId0 = tmpContactOut.m_shapeId0; - contactOut.m_shapeId1 = tmpContactOut.m_shapeId0; - contactOut.m_collision0 = tmpContactOut.m_collision0; - contactOut.m_collision1 = tmpContactOut.m_collision1; - } - - } else { - dgAssert (me->m_type == m_node); - const dgNodeBase* const left = me->m_left; - dgAssert (left); - dgFloat32 dist1 = ray.BoxIntersect(left->m_p0, left->m_p1); - if (dist1 < maxT) { - dgInt32 j = stack; - for ( ; j && (dist1 > distance[j - 1]); j --) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - stackPool[j] = left; - distance[j] = dist1; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (stackPool[0]))); - } - - const dgNodeBase* const right = me->m_right; - dgAssert (right); - dist1 = ray.BoxIntersect(right->m_p0, right->m_p1); - if (dist1 < maxT) { - dgInt32 j = stack; - for ( ; j && (dist1 > distance[j - 1]); j --) { - stackPool[j] = stackPool[j - 1]; - distance[j] = distance[j - 1]; - } - stackPool[j] = right; - distance[j] = dist1; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (stackPool[0]))); - } - } - } - } - return maxT; -} - -dgFloat32 dgCollisionCompound::GetVolume () const -{ - dgFloat32 volume = dgFloat32 (0.0f); - dgTreeArray::Iterator iter (m_array); - for (iter.Begin(); iter; iter ++) { - dgCollisionConvex* const collision = (dgCollisionConvex*)iter.GetNode()->GetInfo()->GetShape()->GetChildShape(); - volume += collision->GetVolume(); - } - return volume; -} - -dgFloat32 dgCollisionCompound::GetBoxMinRadius () const -{ - return m_boxMinRadius; -} - -dgFloat32 dgCollisionCompound::GetBoxMaxRadius () const -{ - return m_boxMaxRadius; -} - - - -dgVector dgCollisionCompound::CalculateVolumeIntegral (const dgMatrix& globalMatrix, const dgVector& plane, const dgCollisionInstance& parentScale) const -{ - dgVector totalVolume (dgVector::m_zero); - dgTreeArray::Iterator iter (m_array); - for (iter.Begin(); iter; iter ++) { - const dgCollisionInstance* const childInstance = iter.GetNode()->GetInfo()->GetShape(); - dgCollisionConvex* const collision = (dgCollisionConvex*)childInstance->GetChildShape(); - dgMatrix matrix (childInstance->m_localMatrix * globalMatrix); - dgVector vol (collision->CalculateVolumeIntegral (matrix, plane, *childInstance)); - totalVolume.m_x += vol.m_x * vol.m_w; - totalVolume.m_y += vol.m_y * vol.m_w; - totalVolume.m_z += vol.m_z * vol.m_w; - totalVolume.m_w += vol.m_w; - } - - dgFloat32 scale = dgFloat32 (0.0f); - if (m_root) { - scale = dgFloat32 (1.0f) / (totalVolume.m_w + dgFloat32 (1.0e-6f)); - } - totalVolume.m_x *= scale; - totalVolume.m_y *= scale; - totalVolume.m_z *= scale; - - return totalVolume; -} - -dgFloat32 dgCollisionCompound::CalculateMassProperties (const dgMatrix& offset, dgVector& inertia, dgVector& crossInertia, dgVector& centerOfMass) const -{ - dgPolyhedraMassProperties localData; - DebugCollision (offset, CalculateInertia, &localData); - return localData.MassProperties (centerOfMass, inertia, crossInertia); -} - - -dgMatrix dgCollisionCompound::CalculateInertiaAndCenterOfMass (const dgMatrix& m_alignMatrix, const dgVector& localScale, const dgMatrix& matrix) const -{ - dgVector inertiaII; - dgVector crossInertia; - dgVector centerOfMass; - dgMatrix scaledMatrix(matrix); - scaledMatrix[0] = scaledMatrix[0].Scale(localScale.m_x); - scaledMatrix[1] = scaledMatrix[1].Scale(localScale.m_y); - scaledMatrix[2] = scaledMatrix[2].Scale(localScale.m_z); - scaledMatrix = m_alignMatrix * scaledMatrix; - - dgFloat32 volume = CalculateMassProperties (scaledMatrix, inertiaII, crossInertia, centerOfMass); - if (volume < DG_MAX_MIN_VOLUME) { - volume = DG_MAX_MIN_VOLUME; - } - - dgFloat32 invVolume = dgFloat32 (1.0f) / volume; - centerOfMass = centerOfMass.Scale(invVolume); - inertiaII = inertiaII.Scale (invVolume); - crossInertia = crossInertia.Scale (invVolume); - dgMatrix inertia (dgGetIdentityMatrix()); - inertia[0][0] = inertiaII[0]; - inertia[1][1] = inertiaII[1]; - inertia[2][2] = inertiaII[2]; - inertia[0][1] = crossInertia[2]; - inertia[1][0] = crossInertia[2]; - inertia[0][2] = crossInertia[1]; - inertia[2][0] = crossInertia[1]; - inertia[1][2] = crossInertia[0]; - inertia[2][1] = crossInertia[0]; - inertia[3] = centerOfMass; - return inertia; -} - - -void dgCollisionCompound::CalculateInertia (void* userData, int indexCount, const dgFloat32* const faceVertex, int faceId) -{ - dgPolyhedraMassProperties& localData = *((dgPolyhedraMassProperties*) userData); - localData.AddInertiaAndCrossFace(indexCount, faceVertex); -} - - -void dgCollisionCompound::MassProperties () -{ -#ifdef _DEBUG -// dgVector origin_ (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); -// dgVector inertia_ (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); -// dgVector crossInertia_ (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); -// dgPolyhedraMassProperties localData; -// DebugCollision (dgGetIdentityMatrix(), CalculateInertia, &localData); -// dgFloat32 volume_ = localData.MassProperties (origin_, inertia_, crossInertia_); -// dgAssert (volume_ > dgFloat32 (0.0f)); -// dgFloat32 invVolume_ = dgFloat32 (1.0f)/volume_; -// m_centerOfMass = origin_.Scale (invVolume_); -// m_centerOfMass.m_w = volume_; -// m_inertia = inertia_.Scale (invVolume_); -// m_crossInertia = crossInertia_.Scale(invVolume_); -#endif - - - dgFloat32 volume = dgFloat32 (0.0f); - dgVector origin (dgFloat32 (0.0f)); - dgVector inertiaII (dgFloat32 (0.0f)); - dgVector inertiaIJ (dgFloat32 (0.0f)); - dgTreeArray::Iterator iter (m_array); - for (iter.Begin(); iter; iter ++) { - dgCollisionInstance* const collision = iter.GetNode()->GetInfo()->GetShape(); - dgMatrix shapeInertia (collision->CalculateInertia()); - dgFloat32 shapeVolume = collision->GetVolume(); - - volume += shapeVolume; - origin += shapeInertia.m_posit.Scale(shapeVolume); - inertiaII += dgVector (shapeInertia[0][0], shapeInertia[1][1], shapeInertia[2][2], dgFloat32 (0.0f)).Scale (shapeVolume); - inertiaIJ += dgVector (shapeInertia[1][2], shapeInertia[0][2], shapeInertia[0][1], dgFloat32 (0.0f)).Scale (shapeVolume); - } - if (volume > dgFloat32 (0.0f)) { - dgFloat32 invVolume = dgFloat32 (1.0f)/volume; - m_inertia = inertiaII.Scale (invVolume); - m_crossInertia = inertiaIJ.Scale (invVolume); - m_centerOfMass = origin.Scale (invVolume); - m_centerOfMass.m_w = volume; - } - - dgCollision::MassProperties (); -} - -void dgCollisionCompound::ApplyScale (const dgVector& scale) -{ - dgTreeArray::Iterator iter (m_array); - for (iter.Begin(); iter; iter ++) { - dgNodeBase* const node = iter.GetNode()->GetInfo(); - dgCollisionInstance* const collision = node->GetShape(); - collision->SetGlobalScale (scale); - } - m_treeEntropy = dgFloat32 (0.0f); - EndAddRemove (); -} - - -void dgCollisionCompound::BeginAddRemove () -{ -} - - -dgCollisionCompound::dgNodeBase* dgCollisionCompound::BuildTopDown (dgNodeBase** const leafArray, dgInt32 firstBox, dgInt32 lastBox, dgList<dgNodeBase*>::dgListNode** const nextNode) -{ - dgAssert (firstBox >= 0); - dgAssert (lastBox >= 0); - - if (lastBox == firstBox) { - return leafArray[firstBox]; - } else { - dgSpliteInfo info (&leafArray[firstBox], lastBox - firstBox + 1); - - dgNodeBase* const parent = (*nextNode)->GetInfo(); - parent->m_parent = NULL; - *nextNode = (*nextNode)->GetNext(); - - parent->SetBox (info.m_p0, info.m_p1); - parent->m_right = BuildTopDown (leafArray, firstBox + info.m_axis, lastBox, nextNode); - parent->m_right->m_parent = parent; - - parent->m_left = BuildTopDown (leafArray, firstBox, firstBox + info.m_axis - 1, nextNode); - parent->m_left->m_parent = parent; - return parent; - } -} - -dgCollisionCompound::dgNodeBase* dgCollisionCompound::BuildTopDownBig (dgNodeBase** const leafArray, dgInt32 firstBox, dgInt32 lastBox, dgList<dgNodeBase*>::dgListNode** const nextNode) -{ - if (lastBox == firstBox) { - return BuildTopDown (leafArray, firstBox, lastBox, nextNode); - } - - dgInt32 midPoint = -1; - const dgFloat32 scale = dgFloat32 (10.0f); - const dgFloat32 scale2 = dgFloat32 (3.0f) * scale * scale; - const dgInt32 count = lastBox - firstBox; - for (dgInt32 i = 0; i < count; i ++) { - const dgNodeBase* const node0 = leafArray[firstBox + i]; - const dgNodeBase* const node1 = leafArray[firstBox + i + 1]; - if (node1->m_area > (scale2 * node0->m_area)) { - midPoint = i; - break; - } - } - - if (midPoint == -1) { - return BuildTopDown (leafArray, firstBox, lastBox, nextNode); - } else { - dgNodeBase* const parent = (*nextNode)->GetInfo(); - - parent->m_parent = NULL; - *nextNode = (*nextNode)->GetNext(); - - dgVector minP ( dgFloat32 (1.0e15f)); - dgVector maxP (-dgFloat32 (1.0e15f)); - for (dgInt32 i = 0; i <= count; i ++) { - const dgNodeBase* const node = leafArray[firstBox + i]; - dgAssert (node->m_shape); - minP = minP.GetMin (node->m_p0); - maxP = maxP.GetMax (node->m_p1); - } - - parent->SetBox (minP, maxP); - parent->m_left = BuildTopDown (leafArray, firstBox, firstBox + midPoint, nextNode); - parent->m_left->m_parent = parent; - - parent->m_right = BuildTopDownBig (leafArray, firstBox + midPoint + 1, lastBox, nextNode); - parent->m_right->m_parent = parent; - return parent; - } -} - -dgInt32 dgCollisionCompound::CompareNodes (const dgNodeBase* const nodeA, const dgNodeBase* const nodeB, void* ) -{ - dgFloat32 areaA = nodeA->m_area; - dgFloat32 areaB = nodeB->m_area; - if (areaA < areaB) { - return -1; - } - if (areaA > areaB) { - return 1; - } - return 0; -} - - -dgFloat64 dgCollisionCompound::CalculateEntropy (dgList<dgNodeBase*>& list) -{ - dgFloat64 cost0 = dgFloat32 (1.0e20f); - dgFloat64 cost1 = cost0; - do { - cost1 = cost0; - for (dgList<dgNodeBase*>::dgListNode* listNode = list.GetFirst(); listNode; listNode = listNode->GetNext()) { - dgNodeBase* const node = listNode->GetInfo(); - ImproveNodeFitness (node); - } - - cost0 = dgFloat32 (0.0f); - for (dgList<dgNodeBase*>::dgListNode* listNode = list.GetFirst(); listNode; listNode = listNode->GetNext()) { - dgNodeBase* const node = listNode->GetInfo(); - cost0 += node->m_area; - } - } while (cost0 < (cost1 * dgFloat32 (0.9999f))); - return cost0; -} - -void dgCollisionCompound::EndAddRemove (bool flushCache) -{ - if (m_root) { - //dgWorld* const world = m_world; - //dgThreadHiveScopeLock lock (world, &m_criticalSectionLock); - dgScopeSpinLock lock(&m_criticalSectionLock); - - dgTreeArray::Iterator iter (m_array); - for (iter.Begin(); iter; iter ++) { - dgNodeBase* const node = iter.GetNode()->GetInfo(); - node->CalculateAABB(); - } - - dgList<dgNodeBase*> list (GetAllocator()); - dgList<dgNodeBase*> stack (GetAllocator()); - stack.Append(m_root); - while (stack.GetCount()) { - dgList<dgNodeBase*>::dgListNode* const stackNode = stack.GetLast(); - dgNodeBase* const node = stackNode->GetInfo(); - stack.Remove(stackNode); - - //if (node->m_type == m_node) { - // list.Append(node); - //} - - if (node->m_type == m_node) { - list.Append(node); - stack.Append(node->m_right); - stack.Append(node->m_left); - } - } - - if (list.GetCount()) { - dgFloat64 cost = CalculateEntropy (list); - if ((cost > m_treeEntropy * dgFloat32 (2.0f)) || (cost < m_treeEntropy * dgFloat32 (0.5f))) { - dgInt32 count = list.GetCount() * 2 + 12; - dgInt32 leafNodesCount = 0; - dgStack<dgNodeBase*> leafArray(count); - for (dgList<dgNodeBase*>::dgListNode* listNode = list.GetFirst(); listNode; listNode = listNode->GetNext()) { - dgNodeBase* const node = listNode->GetInfo(); - if (node->m_left->m_type == m_leaf) { - leafArray[leafNodesCount] = node->m_left; - leafNodesCount ++; - } - if (node->m_right->m_type == m_leaf) { - leafArray[leafNodesCount] = node->m_right; - leafNodesCount ++; - } - } - - dgList<dgNodeBase*>::dgListNode* nodePtr = list.GetFirst(); - - dgSortIndirect (&leafArray[0], leafNodesCount, CompareNodes); - - m_root = BuildTopDownBig (&leafArray[0], 0, leafNodesCount - 1, &nodePtr); - m_treeEntropy = CalculateEntropy (list); - } - while (m_root->m_parent) { - m_root = m_root->m_parent; - } - } else { - m_treeEntropy = dgFloat32 (2.0f); - } - - dgAssert (m_root->m_size.m_w == dgFloat32 (0.0f)); - m_boxMinRadius = dgMin(m_root->m_size.m_x, m_root->m_size.m_y, m_root->m_size.m_z); - m_boxMaxRadius = dgSqrt (m_root->m_size.DotProduct(m_root->m_size).GetScalar()); - - m_boxSize = m_root->m_size; - m_boxOrigin = m_root->m_origin; - MassProperties (); - - if (flushCache) { - m_world->FlushCache (); - } - } -} - -dgTree<dgCollisionCompound::dgNodeBase*, dgInt32>::dgTreeNode* dgCollisionCompound::AddCollision (dgCollisionInstance* const shape) -{ - dgNodeBase* const newNode = new (m_allocator) dgNodeBase (shape); - m_array.AddNode(newNode, m_idIndex, m_myInstance); - - m_idIndex ++; - - if (!m_root) { - m_root = newNode; - } else { - dgVector p0; - dgVector p1; - dgNodeBase* sibling = m_root; - dgFloat32 surfaceArea = CalculateSurfaceArea (newNode, sibling, p0, p1); - while(sibling->m_left && sibling->m_right) { - - if (surfaceArea > sibling->m_area) { - break; - } - - sibling->SetBox (p0, p1); - - dgVector leftP0; - dgVector leftP1; - dgFloat32 leftSurfaceArea = CalculateSurfaceArea (newNode, sibling->m_left, leftP0, leftP1); - - dgVector rightP0; - dgVector rightP1; - dgFloat32 rightSurfaceArea = CalculateSurfaceArea (newNode, sibling->m_right, rightP0, rightP1); - - if (leftSurfaceArea < rightSurfaceArea) { - sibling = sibling->m_left; - p0 = leftP0; - p1 = leftP1; - surfaceArea = leftSurfaceArea; - } else { - sibling = sibling->m_right; - p0 = rightP0; - p1 = rightP1; - surfaceArea = rightSurfaceArea; - } - } - - if (!sibling->m_parent) { - m_root = new (m_world->GetAllocator()) dgNodeBase (sibling, newNode); - } else { - dgNodeBase* const parent = sibling->m_parent; - if (parent->m_left == sibling) { - dgNodeBase* const node = new (m_world->GetAllocator()) dgNodeBase (sibling, newNode); - parent->m_left = node; - node->m_parent = parent; - } else { - dgAssert (parent->m_right == sibling); - dgNodeBase* const node = new (m_world->GetAllocator()) dgNodeBase (sibling, newNode); - parent->m_right = node; - node->m_parent = parent; - } - } - } - - return newNode->m_myNode; -} - - -void dgCollisionCompound::RemoveCollision (dgTreeArray::dgTreeNode* const node) -{ - if (node) { - dgCollisionInstance* const instance = node->GetInfo()->GetShape(); - instance->AddRef(); - RemoveCollision (node->GetInfo()); - instance->Release(); - m_array.Remove(node); - } -} - -void dgCollisionCompound::SetCollisionMatrix (dgTreeArray::dgTreeNode* const node, const dgMatrix& matrix) -{ - if (node) { - - //dgWorld* const world = m_world; - dgNodeBase* const baseNode = node->GetInfo(); - dgCollisionInstance* const instance = baseNode->GetShape(); - - dgVector scale; - dgMatrix localMatrix; - matrix.PolarDecomposition(localMatrix, scale, instance->m_aligmentMatrix); - -// instance->SetLocalMatrix(matrix); - instance->SetLocalMatrix(localMatrix); - instance->SetScale(scale); - - dgVector p0; - dgVector p1; - instance->CalcAABB(instance->GetLocalMatrix (), p0, p1); - - //dgThreadHiveScopeLock lock (world, &m_criticalSectionLock); - dgScopeSpinLock lock(&m_criticalSectionLock); - - baseNode->SetBox (p0, p1); - for (dgNodeBase* parent = baseNode->m_parent; parent; parent = parent->m_parent) { - dgVector minBox; - dgVector maxBox; - CalculateSurfaceArea (parent->m_left, parent->m_right, minBox, maxBox); - if (dgBoxInclusionTest (minBox, maxBox, parent->m_p0, parent->m_p1)) { - break; - } - parent->SetBox (minBox, maxBox); - } - } -} - - -void dgCollisionCompound::RemoveCollision (dgNodeBase* const treeNode) -{ - if (!treeNode->m_parent) { - delete (m_root); - m_root = NULL; - } else if (!treeNode->m_parent->m_parent) { - dgNodeBase* const root = m_root; - if (treeNode->m_parent->m_left == treeNode) { - m_root = treeNode->m_parent->m_right; - treeNode->m_parent->m_right = NULL; - } else { - dgAssert (treeNode->m_parent->m_right == treeNode); - m_root = treeNode->m_parent->m_left; - treeNode->m_parent->m_left= NULL; - } - m_root->m_parent = NULL; - delete (root); - - } else { - dgNodeBase* const root = treeNode->m_parent->m_parent; - if (treeNode->m_parent == root->m_left) { - if (treeNode->m_parent->m_right == treeNode) { - root->m_left = treeNode->m_parent->m_left; - treeNode->m_parent->m_left = NULL; - } else { - dgAssert (treeNode->m_parent->m_left == treeNode); - root->m_left = treeNode->m_parent->m_right; - treeNode->m_parent->m_right = NULL; - } - root->m_left->m_parent = root; - } else { - if (treeNode->m_parent->m_right == treeNode) { - root->m_right = treeNode->m_parent->m_left; - treeNode->m_parent->m_left = NULL; - } else { - dgAssert (treeNode->m_parent->m_left == treeNode); - root->m_right = treeNode->m_parent->m_right; - treeNode->m_parent->m_right = NULL; - } - root->m_right->m_parent = root; - } - delete (treeNode->m_parent); - } -} - -dgInt32 dgCollisionCompound::GetNodeIndex(dgTreeArray::dgTreeNode* const node) const -{ - return node->GetKey(); -} - -dgTree<dgCollisionCompound::dgNodeBase*, dgInt32>::dgTreeNode* dgCollisionCompound::FindNodeByIndex (dgInt32 index) const -{ - return m_array.Find (index); -} - -dgTree<dgCollisionCompound::dgNodeBase*, dgInt32>::dgTreeNode* dgCollisionCompound::GetFirstNode () const -{ - dgTreeArray::Iterator iter (m_array); - iter.Begin(); - - dgTreeArray::dgTreeNode* node = NULL; - if (iter) { - node = iter.GetNode(); - } - return node; -} - -dgTree<dgCollisionCompound::dgNodeBase*, dgInt32>::dgTreeNode* dgCollisionCompound::GetNextNode (dgTree<dgCollisionCompound::dgNodeBase*, dgInt32>::dgTreeNode* const node) const -{ - dgTreeArray::Iterator iter (m_array); - iter.Set (node); - iter ++; - dgTreeArray::dgTreeNode* nextNode = NULL; - if (iter) { - nextNode = iter.GetNode(); - } - return nextNode; -} - -dgCollisionInstance* dgCollisionCompound::GetCollisionFromNode (dgTree<dgCollisionCompound::dgNodeBase*, dgInt32>::dgTreeNode* const node) const -{ - dgAssert (node->GetInfo()); - dgAssert (node->GetInfo()->GetShape()); - return node->GetInfo()->GetShape(); -} - - -dgVector dgCollisionCompound::SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgFloat32 aabbProjection[DG_COMPOUND_STACK_DEPTH]; - const dgNodeBase* stackPool[DG_COMPOUND_STACK_DEPTH]; - - dgInt32 stack = 1; - stackPool[0] = m_root; - aabbProjection[0] = dgFloat32 (1.0e10f); - - dgFloat32 maxProj = dgFloat32 (-1.0e20f); - //dgVector searchDir (m_offset.UnrotateVector(dir)); - - dgInt32 ix = (dir[0] > dgFloat32 (0.0f)) ? 1 : 0; - dgInt32 iy = (dir[1] > dgFloat32 (0.0f)) ? 1 : 0; - dgInt32 iz = (dir[2] > dgFloat32 (0.0f)) ? 1 : 0; - dgVector supportVertex (dgFloat32 (0.0f)); - - dgAssert (dir.m_w == dgFloat32 (0.0f)); - while (stack) { - - stack--; - dgFloat32 boxSupportValue = aabbProjection[stack]; - if (boxSupportValue > maxProj) { - const dgNodeBase* const me = stackPool[stack]; - - if (me->m_type == m_leaf) { - //dgInt32 index; - dgCollisionInstance* const subShape = me->GetShape(); - const dgMatrix& matrix = subShape->GetLocalMatrix(); - dgVector newDir (matrix.UnrotateVector(dir)); - dgVector vertex (matrix.TransformVector (subShape->SupportVertex(newDir))); - dgFloat32 dist = dir.DotProduct(vertex).GetScalar(); - if (dist > maxProj) { - maxProj = dist; - supportVertex = vertex; - } - - } else { - const dgNodeBase* const left = me->m_left; - const dgNodeBase* const right = me->m_right; - - const dgVector* const box0 = &left->m_p0; - dgVector p0 (box0[ix].m_x, box0[iy].m_y, box0[iz].m_z, dgFloat32 (0.0f)); - - const dgVector* const box1 = &right->m_p0; - dgVector p1 (box1[ix].m_x, box1[iy].m_y, box1[iz].m_z, dgFloat32 (0.0f)); - - dgFloat32 dist0 = p0.DotProduct(dir).GetScalar(); - dgFloat32 dist1 = p1.DotProduct(dir).GetScalar(); - if (dist0 > dist1) { - stackPool[stack] = right; - aabbProjection[stack] = dist1; - stack ++; - - stackPool[stack] = left; - aabbProjection[stack] = dist0; - stack ++; - } else { - stackPool[stack] = left; - aabbProjection[stack] = dist0; - stack ++; - - stackPool[stack] = right; - aabbProjection[stack] = dist1; - stack ++; - } - } - } - } - -// return m_offset.TransformVector (supportVertex); - return supportVertex; -} - -dgVector dgCollisionCompound::SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - dgAssert (0); - return SupportVertex (dir, vertexIndex); -} - - -void dgCollisionCompound::GetCollisionInfo(dgCollisionInfo* const info) const -{ - dgCollision::GetCollisionInfo(info); - - info->m_compoundCollision.m_chidrenCount = m_array.GetCount(); - info->m_collisionType = m_compoundCollision; -} - -void dgCollisionCompound::Serialize(dgSerialize callback, void* const userData) const -{ - SerializeLow(callback, userData); - - dgInt32 count = m_array.GetCount(); - callback (userData, &count, sizeof (count)); - dgTreeArray::Iterator iter (m_array); - for (iter.Begin(); iter; iter ++) { - dgCollisionInstance* const collision = iter.GetNode()->GetInfo()->GetShape(); - collision->Serialize(callback, userData); - } -} - -DG_INLINE dgFloat32 dgCollisionCompound::CalculateSurfaceArea (dgNodeBase* const node0, dgNodeBase* const node1, dgVector& minBox, dgVector& maxBox) const -{ - minBox = node0->m_p0.GetMin(node1->m_p0); - maxBox = node0->m_p1.GetMax(node1->m_p1); - dgVector side0 (dgVector::m_half * (maxBox - minBox)); - return side0.DotProduct(side0.ShiftTripleRight()).GetScalar(); -} - -void dgCollisionCompound::ImproveNodeFitness (dgNodeBase* const node) const -{ - dgAssert (node->m_left); - dgAssert (node->m_right); - - if (node->m_parent) { - if (node->m_parent->m_left == node) { - dgFloat32 cost0 = node->m_area; - - dgVector cost1P0; - dgVector cost1P1; - dgFloat32 cost1 = CalculateSurfaceArea (node->m_right, node->m_parent->m_right, cost1P0, cost1P1); - - dgVector cost2P0; - dgVector cost2P1; - dgFloat32 cost2 = CalculateSurfaceArea (node->m_left, node->m_parent->m_right, cost2P0, cost2P1); - - dgAssert (node->m_parent->m_p0.m_w == dgFloat32 (0.0f)); - dgAssert (node->m_parent->m_p1.m_w == dgFloat32 (0.0f)); - - if ((cost1 <= cost0) && (cost1 <= cost2)) { - dgNodeBase* const parent = node->m_parent; - node->m_p0 = parent->m_p0; - node->m_p1 = parent->m_p1; - node->m_area = parent->m_area; - node->m_size = parent->m_size; - node->m_origin = parent->m_origin; - - if (parent->m_parent) { - if (parent->m_parent->m_left == parent) { - parent->m_parent->m_left = node; - } else { - dgAssert (parent->m_parent->m_right == parent); - parent->m_parent->m_right = node; - } - } - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_right->m_parent = parent; - parent->m_left = node->m_right; - node->m_right = parent; - parent->m_p0 = cost1P0; - parent->m_p1 = cost1P1; - parent->m_area = cost1; - parent->m_size = (parent->m_p1 - parent->m_p0) * dgVector::m_half; - parent->m_origin = (parent->m_p1 + parent->m_p0) * dgVector::m_half; - - } else if ((cost2 <= cost0) && (cost2 <= cost1)) { - dgNodeBase* const parent = node->m_parent; - node->m_p0 = parent->m_p0; - node->m_p1 = parent->m_p1; - node->m_area = parent->m_area; - node->m_size = parent->m_size; - node->m_origin = parent->m_origin; - - if (parent->m_parent) { - if (parent->m_parent->m_left == parent) { - parent->m_parent->m_left = node; - } else { - dgAssert (parent->m_parent->m_right == parent); - parent->m_parent->m_right = node; - } - } - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_left->m_parent = parent; - parent->m_left = node->m_left; - node->m_left = parent; - - parent->m_p0 = cost2P0; - parent->m_p1 = cost2P1; - parent->m_area = cost2; - parent->m_size = (parent->m_p1 - parent->m_p0) * dgVector::m_half; - parent->m_origin = (parent->m_p1 + parent->m_p0) * dgVector::m_half; - } - } else { - dgFloat32 cost0 = node->m_area; - - dgVector cost1P0; - dgVector cost1P1; - dgFloat32 cost1 = CalculateSurfaceArea (node->m_left, node->m_parent->m_left, cost1P0, cost1P1); - - dgVector cost2P0; - dgVector cost2P1; - dgFloat32 cost2 = CalculateSurfaceArea (node->m_right, node->m_parent->m_left, cost2P0, cost2P1); - - if ((cost1 <= cost0) && (cost1 <= cost2)) { - - dgNodeBase* const parent = node->m_parent; - node->m_p0 = parent->m_p0; - node->m_p1 = parent->m_p1; - node->m_area = parent->m_area; - node->m_size = parent->m_size; - node->m_origin = parent->m_origin; - - if (parent->m_parent) { - if (parent->m_parent->m_left == parent) { - parent->m_parent->m_left = node; - } else { - dgAssert (parent->m_parent->m_right == parent); - parent->m_parent->m_right = node; - } - } - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_left->m_parent = parent; - parent->m_right = node->m_left; - node->m_left = parent; - - parent->m_p0 = cost1P0; - parent->m_p1 = cost1P1; - parent->m_area = cost1; - parent->m_size = (parent->m_p1 - parent->m_p0) * dgVector::m_half; - parent->m_origin = (parent->m_p1 + parent->m_p0) * dgVector::m_half; - - } else if ((cost2 <= cost0) && (cost2 <= cost1)) { - dgNodeBase* const parent = node->m_parent; - node->m_p0 = parent->m_p0; - node->m_p1 = parent->m_p1; - node->m_area = parent->m_area; - node->m_size = parent->m_size; - node->m_origin = parent->m_origin; - - if (parent->m_parent) { - if (parent->m_parent->m_left == parent) { - parent->m_parent->m_left = node; - } else { - dgAssert (parent->m_parent->m_right == parent); - parent->m_parent->m_right = node; - } - } - node->m_parent = parent->m_parent; - parent->m_parent = node; - node->m_right->m_parent = parent; - parent->m_right = node->m_right; - node->m_right = parent; - - parent->m_p0 = cost2P0; - parent->m_p1 = cost2P1; - parent->m_area = cost2; - parent->m_size = (parent->m_p1 - parent->m_p0) * dgVector::m_half; - parent->m_origin = (parent->m_p1 + parent->m_p0) * dgVector::m_half; - } - } - } else { - // in the future I can handle this but it is too much work for little payoff - } -} - - - -dgInt32 dgCollisionCompound::CalculateContacts (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - dgInt32 contactCount = 0; - if (m_root) { - dgAssert (IsType (dgCollision::dgCollisionCompound_RTTI)); - dgContact* const constraint = pair->m_contact; - dgBody* const body1 = constraint->GetBody1(); - - if (proxy.m_continueCollision) { - if (body1->m_collision->IsType (dgCollision::dgCollisionConvexShape_RTTI)) { - contactCount = CalculateContactsToSingleContinue (pair, proxy); - } else if (body1->m_collision->IsType (dgCollision::dgCollisionCompound_RTTI)) { - contactCount = CalculateContactsToCompoundContinue (pair, proxy); - } else if (body1->m_collision->IsType (dgCollision::dgCollisionBVH_RTTI)) { - contactCount = CalculateContactsToCollisionTreeContinue (pair, proxy); - } else if (body1->m_collision->IsType (dgCollision::dgCollisionHeightField_RTTI)) { - dgAssert (0); -// contactCount = CalculateContactsToHeightField (pair, proxy); - } else { - dgAssert (0); - dgAssert (body1->m_collision->IsType (dgCollision::dgCollisionUserMesh_RTTI)); -// contactCount = CalculateContactsUserDefinedCollision (pair, proxy); - } - - } else { - if (body1->m_collision->IsType (dgCollision::dgCollisionConvexShape_RTTI)) { - contactCount = CalculateContactsToSingle (pair, proxy); - } else if (body1->m_collision->IsType (dgCollision::dgCollisionCompound_RTTI)) { - contactCount = CalculateContactsToCompound (pair, proxy); - } else if (body1->m_collision->IsType (dgCollision::dgCollisionBVH_RTTI)) { - contactCount = CalculateContactsToCollisionTree (pair, proxy); - } else if (body1->m_collision->IsType (dgCollision::dgCollisionHeightField_RTTI)) { - contactCount = CalculateContactsToHeightField (pair, proxy); - } else { - dgAssert (body1->m_collision->IsType (dgCollision::dgCollisionUserMesh_RTTI)); - contactCount = CalculateContactsUserDefinedCollision (pair, proxy); - } - } - } - pair->m_contactCount = contactCount; - return contactCount; -} - - -dgInt32 dgCollisionCompound::ClosestDistance (dgCollisionParamProxy& proxy) const -{ - int count = 0; - if (m_root) { - if (proxy.m_instance1->IsType (dgCollision::dgCollisionConvexShape_RTTI)) { - count = ClosestDistanceToConvex (proxy); - } else if (proxy.m_instance1->IsType (dgCollision::dgCollisionCompound_RTTI)) { - count = ClosestDistanceToCompound (proxy); - } else if (proxy.m_instance1->IsType (dgCollision::dgCollisionBVH_RTTI)) { - dgAssert(0); - } else { - dgAssert(0); - } - } - - return count; -} - - -dgInt32 dgCollisionCompound::ClosestDistanceToConvex (dgCollisionParamProxy& proxy) const -{ - dgInt32 retFlag = 0; - - dgCollisionInstance* const compoundInstance = proxy.m_instance0; - dgCollisionInstance* const otherInstance = proxy.m_instance1; - - const dgMatrix myMatrix = compoundInstance->GetGlobalMatrix(); - dgMatrix matrix (otherInstance->GetGlobalMatrix() * myMatrix.Inverse()); - - dgVector p0; - dgVector p1; - otherInstance->CalcAABB(matrix, p0, p1); - - dgUnsigned8 pool[64 * (sizeof (dgNodeBase*) + sizeof (dgFloat32))]; - dgUpHeap<dgNodeBase*, dgFloat32> heap (pool, sizeof (pool)); - - dgNodeBase* node = m_root; - dgVector boxP0 (p0 - m_root->m_p1); - dgVector boxP1 (p1 - m_root->m_p0); - heap.Push(node, dgBoxDistanceToOrigin2 (boxP0, boxP1)); - - dgContactPoint contact0; - dgContactPoint contact1; - dgFloat32 minDist2 = dgFloat32 (1.0e10f); - while (heap.GetCount() && (heap.Value() <= minDist2)) { - const dgNodeBase* const node1 = heap[0]; - heap.Pop(); - if (node1->m_type == m_leaf) { - dgCollisionInstance* const subShape = node1->GetShape(); - dgCollisionInstance childInstance (*subShape, subShape->GetChildShape()); - - childInstance.m_globalMatrix = childInstance.GetLocalMatrix() * myMatrix; - proxy.m_instance0 = &childInstance; - dgInt32 flag = m_world->ClosestPoint (proxy); - - childInstance.m_material.m_userData = NULL; - - if (flag) { - retFlag = 1; - dgFloat32 dist2 = proxy.m_contactJoint->m_closestDistance * proxy.m_contactJoint->m_closestDistance; - if (dist2 < minDist2) { - minDist2 = dist2; - contact0 = proxy.m_contacts[0]; - contact1 = proxy.m_contacts[1]; - } - } else { - break; - } - - } else { - dgNodeBase* left = node1->m_left; - dgNodeBase* right = node1->m_right; - - dgVector leftBoxP0 (p0 - left->m_p1); - dgVector leftBoxP1 (p1 - left->m_p0); - heap.Push(left, dgBoxDistanceToOrigin2 (leftBoxP0, leftBoxP1)); - - dgVector rightBoxP0 (p0 - right->m_p1); - dgVector rightBoxP1 (p1 - right->m_p0); - heap.Push(right, dgBoxDistanceToOrigin2 (rightBoxP0, rightBoxP1)); - } - } - - if (retFlag) { - proxy.m_contacts[0] = contact0; - proxy.m_contacts[1] = contact1; - proxy.m_contactJoint->m_closestDistance = dgSqrt (minDist2); - } - return retFlag; -} - -DG_INLINE void dgCollisionCompound::PushNode (const dgMatrix& matrix, dgUpHeap<dgHeapNodePair, dgFloat32>& heap, dgNodeBase* const myNode, dgNodeBase* const otherNode) const -{ - dgVector p0; - dgVector p1; - dgHeapNodePair pair; - pair.m_nodeA = myNode; - pair.m_nodeB = otherNode; - matrix.TransformBBox (otherNode->m_p0, otherNode->m_p1, p0, p1); - dgVector boxP0 (p0 - myNode->m_p1); - dgVector boxP1 (p1 - myNode->m_p0); - heap.Push(pair, dgBoxDistanceToOrigin2(boxP0, boxP1)); -} - -dgInt32 dgCollisionCompound::ClosestDistanceToCompound (dgCollisionParamProxy& proxy) const -{ - dgInt32 retFlag = 0; - - dgUnsigned8 pool[128 * (sizeof (dgHeapNodePair) + sizeof (dgFloat32))]; - dgUpHeap<dgHeapNodePair, dgFloat32> heap (pool, sizeof (pool)); - - dgCollisionInstance* const compoundInstance = proxy.m_instance0; - dgCollisionInstance* const otherCompoundInstance = proxy.m_instance1; - - const dgMatrix& myMatrix = compoundInstance->GetGlobalMatrix(); - const dgMatrix& otherMatrix = otherCompoundInstance->GetGlobalMatrix(); - dgMatrix matrix (otherMatrix * myMatrix.Inverse()); - - const dgCollisionCompound* const otherShape = (dgCollisionCompound*)otherCompoundInstance->GetChildShape(); - PushNode (matrix, heap, m_root, otherShape->m_root); - - dgContactPoint contact0; - dgContactPoint contact1; - dgFloat32 minDist2 = dgFloat32 (1.0e10f); - while (heap.GetCount() && (heap.Value() <= minDist2)) { - - dgHeapNodePair pair = heap[0]; - heap.Pop(); - - if ((pair.m_nodeA->m_type == m_leaf) && (pair.m_nodeB->m_type == m_leaf)) { - dgCollisionInstance* const mySubShape = pair.m_nodeA->GetShape(); - dgCollisionInstance myChildInstance (*mySubShape, mySubShape->GetChildShape()); - myChildInstance.m_globalMatrix = myChildInstance.GetLocalMatrix() * myMatrix; - proxy.m_instance0 = &myChildInstance; - - dgCollisionInstance* const otherSubShape = pair.m_nodeB->GetShape(); - dgCollisionInstance otherChildInstance (*otherSubShape, otherSubShape->GetChildShape()); - otherChildInstance.m_globalMatrix = otherChildInstance.GetLocalMatrix() * otherMatrix; - proxy.m_instance1 = &otherChildInstance; - - dgInt32 flag = m_world->ClosestPoint (proxy); - - myChildInstance.m_material.m_userData = NULL; - otherChildInstance.m_material.m_userData = NULL; - if (flag) { - retFlag = 1; - dgFloat32 dist2 = proxy.m_contactJoint->m_closestDistance * proxy.m_contactJoint->m_closestDistance; - if (dist2 < minDist2) { - minDist2 = dist2; - contact0 = proxy.m_contacts[0]; - contact1 = proxy.m_contacts[1]; - } - } else { - break; - } - - - } else if (pair.m_nodeA->m_type == m_leaf) { - PushNode (matrix, heap, pair.m_nodeA, pair.m_nodeB->m_left); - PushNode (matrix, heap, pair.m_nodeA, pair.m_nodeB->m_right); - - } else if (pair.m_nodeB->m_type == m_leaf) { - PushNode (matrix, heap, pair.m_nodeA->m_left, pair.m_nodeB); - PushNode (matrix, heap, pair.m_nodeA->m_right, pair.m_nodeB); - - } else { - PushNode (matrix, heap, pair.m_nodeA->m_left, pair.m_nodeB->m_left); - PushNode (matrix, heap, pair.m_nodeA->m_left, pair.m_nodeB->m_right); - PushNode (matrix, heap, pair.m_nodeA->m_right, pair.m_nodeB->m_left); - PushNode (matrix, heap, pair.m_nodeA->m_right, pair.m_nodeB->m_right); - } - } - - if (retFlag) { - proxy.m_contacts[0] = contact0; - proxy.m_contacts[1] = contact1; - proxy.m_contactJoint->m_closestDistance = dgSqrt (minDist2); - } - return retFlag; -} - - - -dgInt32 dgCollisionCompound::CalculateContactsToCompound (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - dgContactPoint* const contacts = proxy.m_contacts; - const dgNodeBase* stackPool[4 * DG_COMPOUND_STACK_DEPTH][2]; - - dgInt32 contactCount = 0; - dgContact* const contactJoint = pair->m_contact; - dgBody* const myBody = contactJoint->GetBody0(); - dgBody* const otherBody = contactJoint->GetBody1(); - - dgCollisionInstance* const myCompoundInstance = myBody->m_collision; - dgCollisionInstance* const otherCompoundInstance = otherBody->m_collision; - - dgAssert (myCompoundInstance->GetChildShape() == this); - dgAssert (otherCompoundInstance->IsType (dgCollision::dgCollisionCompound_RTTI)); - dgCollisionCompound* const otherCompound = (dgCollisionCompound*)otherCompoundInstance->GetChildShape(); - - proxy.m_body0 = myBody; - proxy.m_body1 = otherBody; - - const dgMatrix& myMatrix = myCompoundInstance->GetGlobalMatrix(); - const dgMatrix& otherMatrix = otherCompoundInstance->GetGlobalMatrix(); - dgOOBBTestData data (otherMatrix * myMatrix.Inverse()); - - dgInt32 stack = 1; - stackPool[0][0] = m_root; - stackPool[0][1] = otherCompound->m_root; - const dgContactMaterial* const material = contactJoint->GetMaterial(); - - dgAssert ((contacts != NULL) ^ proxy.m_intersectionTestOnly); - - dgFloat32 timestep = pair->m_timestep; - dgFloat32 closestDist = dgFloat32 (1.0e10f); - while (stack) { - stack --; - const dgNodeBase* const me = stackPool[stack][0]; - const dgNodeBase* const other = stackPool[stack][1]; - - dgAssert (me && other); - - if (me->BoxTest (data, other)) { - - if ((me->m_type == m_leaf) && (other->m_type == m_leaf)) { - bool processContacts = true; - if (material->m_compoundAABBOverlap) { - processContacts = material->m_compoundAABBOverlap (*contactJoint, timestep, myBody, me->m_myNode, otherBody, other->m_myNode, proxy.m_threadIndex); - } - if (processContacts) { - if (me->GetShape()->GetCollisionMode() & other->GetShape()->GetCollisionMode()) { - const dgCollisionInstance* const subShape = me->GetShape(); - const dgCollisionInstance* const otherSubShape = other->GetShape(); - - dgCollisionInstance childInstance (*subShape, subShape->GetChildShape()); - childInstance.m_globalMatrix = childInstance.GetLocalMatrix() * myMatrix; - proxy.m_instance0 = &childInstance; - - dgCollisionInstance otherChildInstance (*otherSubShape, otherSubShape->GetChildShape()); - otherChildInstance.m_globalMatrix = otherChildInstance.GetLocalMatrix() * otherMatrix; - proxy.m_instance1 = &otherChildInstance; - - proxy.m_maxContacts = DG_MAX_CONTATCS - contactCount; - proxy.m_contacts = contacts ? &contacts[contactCount] : contacts; - - dgInt32 count = m_world->CalculateConvexToConvexContacts (proxy); - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - - if (!proxy.m_intersectionTestOnly) { - for (dgInt32 i = 0; i < count; i ++) { - dgAssert (contacts[contactCount + i].m_collision0 == &childInstance); - dgAssert (contacts[contactCount + i].m_collision1 == &otherChildInstance); - contacts[contactCount + i].m_collision0 = subShape; - contacts[contactCount + i].m_collision1 = otherSubShape; - } - contactCount += count; - if (contactCount > (DG_MAX_CONTATCS - 2 * (DG_CONSTRAINT_MAX_ROWS / 3))) { - contactCount = m_world->PruneContacts(contactCount, contacts, proxy.m_contactJoint->GetPruningTolerance(), 16); - } - } else if (count == -1) { - contactCount = -1; - break; - } - childInstance.m_material.m_userData = NULL; - otherChildInstance.m_material.m_userData = NULL; - - proxy.m_instance0 = NULL; - proxy.m_instance1 = NULL; - } - } - - } else if (me->m_type == m_leaf) { - dgAssert (other->m_type == m_node); - - stackPool[stack][0] = me; - stackPool[stack][1] = other->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me; - stackPool[stack][1] = other->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - - } else if (other->m_type == m_leaf) { - dgAssert (me->m_type == m_node); - - stackPool[stack][0] = me->m_left; - stackPool[stack][1] = other; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me->m_right; - stackPool[stack][1] = other; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - } else { - dgAssert (me->m_type == m_node); - dgAssert (other->m_type == m_node); - - stackPool[stack][0] = me->m_left; - stackPool[stack][1] = other->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me->m_left; - stackPool[stack][1] = other->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me->m_right; - stackPool[stack][1] = other->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me->m_right; - stackPool[stack][1] = other->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - } - } - } - - contactJoint->m_closestDistance = closestDist; - proxy.m_contacts = contacts; - return contactCount; -} - -dgInt32 dgCollisionCompound::CalculateContactsToHeightField (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - dgContactPoint* const contacts = proxy.m_contacts; - - const dgNodeBase* stackPool[DG_COMPOUND_STACK_DEPTH]; - - dgInt32 contactCount = 0; - dgContact* const contactJoint = pair->m_contact; - dgBody* const myBody = contactJoint->GetBody0(); - dgBody* const terrainBody = contactJoint->GetBody1(); - - dgCollisionInstance* const compoundInstance = myBody->m_collision; - dgCollisionInstance* const terrainInstance = terrainBody->m_collision; - - dgAssert (compoundInstance->GetChildShape() == this); - dgAssert (terrainInstance->IsType (dgCollision::dgCollisionHeightField_RTTI)); - dgCollisionHeightField* const terrainCollision = (dgCollisionHeightField*)terrainInstance->GetChildShape(); - - proxy.m_body0 = myBody; - proxy.m_body1 = terrainBody; - - proxy.m_instance1 = terrainInstance; - const dgMatrix& compoundMatrix = compoundInstance->GetGlobalMatrix(); - const dgMatrix& hieghFieldMatrix = terrainInstance->GetGlobalMatrix(); - dgOOBBTestData data (hieghFieldMatrix * compoundMatrix.Inverse()); - - dgInt32 stack = 1; - stackPool[0] = m_root; - - dgNodeBase nodeProxi; - nodeProxi.m_left = NULL; - nodeProxi.m_right = NULL; - const dgContactMaterial* const material = contactJoint->GetMaterial(); - - dgAssert ((contacts != NULL) ^ proxy.m_intersectionTestOnly); - - dgFloat32 timestep = pair->m_timestep; - dgFloat32 closestDist = dgFloat32 (1.0e10f); - - const dgVector heighFieldScale(terrainInstance->GetScale()); - const dgVector heighFieldInvScale(terrainInstance->GetInvScale()); - while (stack) { - stack --; - const dgNodeBase* const me = stackPool[stack]; - - dgVector origin (heighFieldInvScale * data.m_matrix.UntransformVector(me->m_origin)); - dgVector size (heighFieldInvScale * data.m_absMatrix.UnrotateVector(me->m_size)); - dgVector p0 (origin - size); - dgVector p1 (origin + size); - terrainCollision->GetLocalAABB (p0, p1, nodeProxi.m_p0, nodeProxi.m_p1); - nodeProxi.m_p0 *= heighFieldScale; - nodeProxi.m_p1 *= heighFieldScale; - nodeProxi.m_size = dgVector::m_half * (nodeProxi.m_p1 - nodeProxi.m_p0); - nodeProxi.m_origin = dgVector::m_half * (nodeProxi.m_p1 + nodeProxi.m_p0); - if (me->BoxTest (data, &nodeProxi)) { - if (me->m_type == m_leaf) { - dgCollisionInstance* const subShape = me->GetShape(); - if (subShape->GetCollisionMode()) { - bool processContacts = true; - if (material->m_compoundAABBOverlap) { - processContacts = material->m_compoundAABBOverlap (*contactJoint, timestep, myBody, me->m_myNode, terrainBody, NULL, proxy.m_threadIndex); - } - if (processContacts) { - dgCollisionInstance childInstance (*subShape, subShape->GetChildShape()); - childInstance.m_globalMatrix = childInstance.GetLocalMatrix() * compoundMatrix; - proxy.m_instance0 = &childInstance; - - proxy.m_maxContacts = DG_MAX_CONTATCS - contactCount; - proxy.m_contacts = contacts ? &contacts[contactCount] : contacts; - - dgInt32 count = 0; - count += m_world->CalculateConvexToNonConvexContacts (proxy); - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - - if (!proxy.m_intersectionTestOnly) { - for (dgInt32 i = 0; i < count; i ++) { - dgAssert (contacts[contactCount + i].m_collision0 == &childInstance); - contacts[contactCount + i].m_collision0 = subShape; - } - contactCount += count; - - if (contactCount > (DG_MAX_CONTATCS - 2 * (DG_CONSTRAINT_MAX_ROWS / 3))) { - contactCount = m_world->PruneContacts(contactCount, contacts, proxy.m_contactJoint->GetPruningTolerance(), 16); - } - } else if (count == -1) { - contactCount = -1; - break; - } - childInstance.m_material.m_userData = NULL; - proxy.m_instance0 = NULL; - } - } - - } else { - dgAssert (me->m_type == m_node); - stackPool[stack] = me->m_left; - stack++; - - stackPool[stack] = me->m_right; - stack++; - } - } - } - - contactJoint->m_closestDistance = closestDist; - proxy.m_contacts = contacts; - return contactCount; -} - - -dgInt32 dgCollisionCompound::CalculateContactsUserDefinedCollision (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - dgContactPoint* const contacts = proxy.m_contacts; - - const dgNodeBase* stackPool[DG_COMPOUND_STACK_DEPTH]; - - dgInt32 contactCount = 0; - dgContact* const contactJoint = pair->m_contact; - dgBody* const myBody = contactJoint->GetBody0(); - dgBody* const userBody = contactJoint->GetBody1(); - - dgCollisionInstance* const compoundInstance = myBody->m_collision; - dgCollisionInstance* const userMeshInstance = userBody->m_collision; - - dgAssert (compoundInstance->GetChildShape() == this); - dgAssert (userMeshInstance->IsType (dgCollision::dgCollisionUserMesh_RTTI)); - dgCollisionUserMesh* const userMeshCollision = (dgCollisionUserMesh*)userMeshInstance->GetChildShape(); - - proxy.m_body0 = myBody; - proxy.m_body1 = userBody; - - proxy.m_instance1 = userMeshInstance; - const dgMatrix& myMatrix = compoundInstance->GetGlobalMatrix(); - dgOOBBTestData data (userMeshInstance->GetGlobalMatrix() * myMatrix.Inverse()); - - dgInt32 stack = 1; - stackPool[0] = m_root; - - dgNodeBase nodeProxi; - nodeProxi.m_left = NULL; - nodeProxi.m_right = NULL; - const dgContactMaterial* const material = contactJoint->GetMaterial(); - - dgAssert ((contacts != NULL) ^ proxy.m_intersectionTestOnly); - - dgFloat32 timestep = pair->m_timestep; - dgFloat32 closestDist = dgFloat32 (1.0e10f); - while (stack) { - stack --; - const dgNodeBase* const me = stackPool[stack]; - - dgVector origin (data.m_matrix.UntransformVector(me->m_origin)); - dgVector size (data.m_absMatrix.UnrotateVector(me->m_size)); - dgVector p0 (origin - size); - dgVector p1 (origin + size); - - if (userMeshCollision->AABBOvelapTest (p0, p1)) { - if (me->m_type == m_leaf) { - dgCollisionInstance* const subShape = me->GetShape(); - if (subShape->GetCollisionMode()) { - bool processContacts = true; - if (material->m_compoundAABBOverlap) { - processContacts = material->m_compoundAABBOverlap (*contactJoint, timestep, myBody, me->m_myNode, userBody, NULL, proxy.m_threadIndex); - } - if (processContacts) { - dgCollisionInstance childInstance (*subShape, subShape->GetChildShape()); - childInstance.m_globalMatrix = childInstance.GetLocalMatrix() * myMatrix; - proxy.m_instance0 = &childInstance; - - proxy.m_maxContacts = DG_MAX_CONTATCS - contactCount; - proxy.m_contacts = contacts ? &contacts[contactCount] : contacts; - - dgInt32 count = 0; - count += m_world->CalculateConvexToNonConvexContacts (proxy); - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - - if (!proxy.m_intersectionTestOnly) { - for (dgInt32 i = 0; i < count; i ++) { - dgAssert (contacts[contactCount + i].m_collision0 == &childInstance); - contacts[contactCount + i].m_collision0 = subShape; - } - contactCount += count; - - if (contactCount > (DG_MAX_CONTATCS - 2 * (DG_CONSTRAINT_MAX_ROWS / 3))) { - contactCount = m_world->PruneContacts(contactCount, contacts, proxy.m_contactJoint->GetPruningTolerance(), 16); - } - } else if (count == -1) { - contactCount = -1; - break; - } - childInstance.m_material.m_userData = NULL; - proxy.m_instance0 = NULL; - } - } - - } else { - dgAssert (me->m_type == m_node); - stackPool[stack] = me->m_left; - stack++; - - stackPool[stack] = me->m_right; - stack++; - } - } - } - - contactJoint->m_closestDistance = closestDist; - proxy.m_contacts = contacts; - return contactCount; -} - - -dgInt32 dgCollisionCompound::CalculateContactsToSingle (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - dgContactPoint* const contacts = proxy.m_contacts; - const dgNodeBase* stackPool[DG_COMPOUND_STACK_DEPTH]; - - dgContact* const contactJoint = pair->m_contact; - - dgBody* const compoundBody = contactJoint->GetBody0(); - dgBody* const otherBody = contactJoint->GetBody1(); - - dgCollisionInstance* const compoundInstance = compoundBody->m_collision; - dgCollisionInstance* const otherInstance = otherBody->m_collision; - - dgAssert (compoundInstance->GetChildShape() == this); - dgAssert (otherInstance->IsType (dgCollision::dgCollisionConvexShape_RTTI)); - - proxy.m_body0 = compoundBody; - - proxy.m_body1 = otherBody; - proxy.m_instance1 = otherBody->m_collision; - - dgInt32 contactCount = 0; - const dgMatrix& myMatrix = compoundInstance->GetGlobalMatrix(); - dgMatrix matrix (otherBody->m_collision->GetGlobalMatrix() * myMatrix.Inverse()); - - dgVector size; - dgVector origin; - otherInstance->CalcObb (origin, size); - dgOOBBTestData data (matrix, origin, size); - - dgInt32 stack = 1; - stackPool[0] = m_root; - const dgContactMaterial* const material = contactJoint->GetMaterial(); - - dgAssert ((contacts != NULL) ^ proxy.m_intersectionTestOnly); - - dgFloat32 timestep = pair->m_timestep; - dgFloat32 closestDist = dgFloat32 (1.0e10f); - while (stack) { - stack --; - const dgNodeBase* const me = stackPool[stack]; - dgAssert (me); - - if (me->BoxTest (data)) { - if (me->m_type == m_leaf) { - dgCollisionInstance* const subShape = me->GetShape(); - if (subShape->GetCollisionMode()) { - bool processContacts = true; - if (material->m_compoundAABBOverlap) { - processContacts = material->m_compoundAABBOverlap (*contactJoint, timestep, compoundBody, me->m_myNode, otherBody, NULL, proxy.m_threadIndex); - } - if (processContacts) { - dgCollisionInstance childInstance (*subShape, subShape->GetChildShape()); - childInstance.m_globalMatrix = childInstance.GetLocalMatrix() * myMatrix; - proxy.m_instance0 = &childInstance; - - proxy.m_maxContacts = DG_MAX_CONTATCS - contactCount; - proxy.m_contacts = contacts ? &contacts[contactCount] : contacts; - - dgInt32 count = m_world->CalculateConvexToConvexContacts (proxy); - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - if (!proxy.m_intersectionTestOnly) { - for (dgInt32 i = 0; i < count; i ++) { - dgAssert (contacts[contactCount + i].m_collision0 == &childInstance); - contacts[contactCount + i].m_collision0 = subShape; - } - contactCount += count; - if (contactCount > (DG_MAX_CONTATCS - 2 * (DG_CONSTRAINT_MAX_ROWS / 3))) { - contactCount = m_world->PruneContacts(contactCount, contacts, proxy.m_contactJoint->GetPruningTolerance(), 16); - } - } else if (count == -1) { - contactCount = -1; - break; - } - childInstance.m_material.m_userData = NULL; - proxy.m_instance0 = NULL; - } - } - - } else { - dgAssert (me->m_type == m_node); - stackPool[stack] = me->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack] = me->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - } - } - } - - contactJoint->m_closestDistance = closestDist; - proxy.m_contacts = contacts; - return contactCount; -} - - -dgInt32 dgCollisionCompound::CalculateContactsToCollisionTree (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - dgContactPoint* const contacts = proxy.m_contacts; - - dgNodePairs stackPool[4 * DG_COMPOUND_STACK_DEPTH]; - - dgInt32 contactCount = 0; - - dgContact* const contactJoint = pair->m_contact; - dgBody* const myBody = contactJoint->GetBody0(); - dgBody* const treeBody = contactJoint->GetBody1(); - - dgCollisionInstance* const compoundInstance = myBody->m_collision; - dgCollisionInstance* const treeCollisionInstance = treeBody->m_collision; - - dgAssert (compoundInstance->GetChildShape() == this); - dgAssert (treeCollisionInstance->IsType (dgCollision::dgCollisionBVH_RTTI)); - dgCollisionBVH* const treeCollision = (dgCollisionBVH*)treeCollisionInstance->GetChildShape(); - - proxy.m_body0 = myBody; - proxy.m_body1 = treeBody; - proxy.m_instance1 = treeCollisionInstance; - - const dgMatrix& myMatrix (compoundInstance->GetGlobalMatrix()); - dgOOBBTestData data (treeCollisionInstance->GetGlobalMatrix() * myMatrix.Inverse()); - - dgInt32 stack = 1; - stackPool[0].m_myNode = m_root; - stackPool[0].m_treeNode = treeCollision->GetRootNode(); - stackPool[0].m_treeNodeIsLeaf = 0; - - dgNodeBase nodeProxi; - nodeProxi.m_left = NULL; - nodeProxi.m_right = NULL; - - const dgContactMaterial* const material = contactJoint->GetMaterial(); - const dgVector& treeScale = treeCollisionInstance->GetScale(); - - dgAssert ((contacts != NULL) ^ proxy.m_intersectionTestOnly); - - dgFloat32 timestep = pair->m_timestep; - dgFloat32 closestDist = dgFloat32 (1.0e10f); - while (stack) { - - stack --; - const dgNodePairs* const stackEntry = &stackPool[stack]; - - dgNodeBase* const me = stackEntry->m_myNode; - const void* const other = stackEntry->m_treeNode; - dgInt32 treeNodeIsLeaf = stackEntry->m_treeNodeIsLeaf; - - dgAssert (me && other); - dgVector p0; - dgVector p1; - - treeCollision->GetNodeAABB(other, p0, p1); - nodeProxi.m_p0 = p0 * treeScale; - nodeProxi.m_p1 = p1 * treeScale; - - p0 = nodeProxi.m_p0 * dgVector::m_half; - p1 = nodeProxi.m_p1 * dgVector::m_half; - nodeProxi.m_size = p1 - p0; - nodeProxi.m_origin = p1 + p0; - nodeProxi.m_area = nodeProxi.m_size.ShiftTripleRight().DotProduct(nodeProxi.m_size).GetScalar(); - - if (me->BoxTest (data, &nodeProxi)) { - if ((me->m_type == m_leaf) && treeNodeIsLeaf) { - dgCollisionInstance* const subShape = me->GetShape(); - if (subShape->GetCollisionMode()) { - bool processContacts = true; - if (material->m_compoundAABBOverlap) { - processContacts = material->m_compoundAABBOverlap (*contactJoint, timestep, myBody, me->m_myNode, treeBody, NULL, proxy.m_threadIndex); - } - if (processContacts) { - dgCollisionInstance childInstance (*subShape, subShape->GetChildShape()); - childInstance.m_globalMatrix = childInstance.GetLocalMatrix() * myMatrix; - proxy.m_instance0 = &childInstance; - - proxy.m_maxContacts = DG_MAX_CONTATCS - contactCount; - proxy.m_contacts = contacts ? &contacts[contactCount] : contacts; - - dgInt32 count = m_world->CalculateConvexToNonConvexContacts (proxy); - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - - if (!proxy.m_intersectionTestOnly) { - for (dgInt32 i = 0; i < count; i ++) { - dgAssert (contacts[contactCount + i].m_collision0 == &childInstance); - contacts[contactCount + i].m_collision0 = subShape; - } - contactCount += count; - if (contactCount > (DG_MAX_CONTATCS - 2 * (DG_CONSTRAINT_MAX_ROWS / 3))) { - contactCount = m_world->PruneContacts(contactCount, contacts, proxy.m_contactJoint->GetPruningTolerance(), 16); - } - } else if (count == -1) { - contactCount = -1; - break; - } - //childInstance.SetUserData(NULL); - - childInstance.m_material.m_userData = NULL; - proxy.m_instance0 = NULL; - } - } - - } else if (me->m_type == m_leaf) { - void* const frontNode = treeCollision->GetFrontNode(other); - void* const backNode = treeCollision->GetBackNode(other); - if (backNode && frontNode) { - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = backNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = frontNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - } else if (backNode && !frontNode) { - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = backNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - - stack++; - - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - - } else if (!backNode && frontNode) { - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = frontNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - - } else { - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - } - - } else if (treeNodeIsLeaf) { - stackPool[stack].m_myNode = me->m_left; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack].m_myNode = me->m_right; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - } else if (nodeProxi.m_area > me->m_area) { - dgAssert (me->m_type == m_node); - void* const frontNode = treeCollision->GetFrontNode(other); - void* const backNode = treeCollision->GetBackNode(other); - if (backNode && frontNode) { - stackPool[stack].m_myNode = (dgNodeBase*) me; - stackPool[stack].m_treeNode = backNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - stackPool[stack].m_myNode = (dgNodeBase*) me; - stackPool[stack].m_treeNode = frontNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - } else if (backNode && !frontNode) { - stackPool[stack].m_myNode = (dgNodeBase*) me; - stackPool[stack].m_treeNode = backNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - stackPool[stack].m_myNode = me->m_left; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - - stackPool[stack].m_myNode = me->m_right; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - - } else if (!backNode && frontNode) { - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = frontNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - stackPool[stack].m_myNode = me->m_left; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - - stackPool[stack].m_myNode = me->m_right; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - - } else { - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - } - - } else { - dgAssert (me->m_type == m_node); - stackPool[stack].m_myNode = me->m_left; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = treeNodeIsLeaf; - stack++; - - stackPool[stack].m_myNode = me->m_right; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = treeNodeIsLeaf; - stack++; - } - } - } - - contactJoint->m_closestDistance = closestDist; - proxy.m_contacts = contacts; - return contactCount; -} - - - -dgInt32 dgCollisionCompound::CalculateContactsToSingleContinue(dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - if (proxy.m_timestep < dgFloat32 (1.0e-4f)) { - return 0; - } - dgContactPoint* const contacts = proxy.m_contacts; - const dgNodeBase* stackPool[DG_COMPOUND_STACK_DEPTH]; - dgContact* const contactJoint = pair->m_contact; - - dgBody* const compoundBody = contactJoint->GetBody0(); - dgBody* const otherBody = contactJoint->GetBody1(); - - dgCollisionInstance* const compoundInstance = compoundBody->m_collision; - dgCollisionInstance* const otherInstance = otherBody->m_collision; - - dgAssert (compoundInstance->GetChildShape() == this); - dgAssert (otherInstance->IsType (dgCollision::dgCollisionConvexShape_RTTI)); - - proxy.m_body0 = compoundBody; - - proxy.m_body1 = otherBody; - proxy.m_instance1 = otherBody->m_collision; - - dgInt32 contactCount = 0; - - const dgMatrix myMatrix = compoundInstance->GetGlobalMatrix(); - dgMatrix matrix (otherBody->m_collision->GetGlobalMatrix() * myMatrix.Inverse()); - - dgVector boxP0; - dgVector boxP1; - otherInstance->CalcAABB(matrix, boxP0, boxP1); - dgVector relVeloc (myMatrix.UnrotateVector (otherBody->GetVelocity() - compoundBody->GetVelocity())); - dgFastRayTest ray (dgVector (dgFloat32 (0.0f)), relVeloc); - - dgInt32 stack = 1; - stackPool[0] = m_root; - const dgContactMaterial* const material = contactJoint->GetMaterial(); - - dgFloat32 maxParam = proxy.m_timestep; - dgFloat32 invMaxParam = dgFloat32 (1.0f) / maxParam; - - dgVector n(dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p(dgFloat32(0.0f)); - dgVector q(dgFloat32(0.0f)); - - dgFloat32 timestep = pair->m_timestep; - dgFloat32 closestDist = dgFloat32 (1.0e10f); - while (stack) { - stack --; - const dgNodeBase* const me = stackPool[stack]; - dgAssert (me); - - dgVector minBox (me->m_p0 - boxP1); - dgVector maxBox (me->m_p1 - boxP0); - if (ray.BoxTest (minBox, maxBox)) { - if (me->m_type == m_leaf) { - dgCollisionInstance* const subShape = me->GetShape(); - - if (subShape->GetCollisionMode()) { - bool processContacts = true; - if (material->m_compoundAABBOverlap) { - processContacts = material->m_compoundAABBOverlap (*contactJoint, timestep, compoundBody, me->m_myNode, otherBody, NULL, proxy.m_threadIndex); - } - if (processContacts) { - dgCollisionInstance childInstance (*subShape, subShape->GetChildShape()); - childInstance.m_globalMatrix = childInstance.GetLocalMatrix() * myMatrix; - proxy.m_instance0 = &childInstance; - - proxy.m_maxContacts = DG_MAX_CONTATCS - contactCount; - proxy.m_contacts = contacts ? &contacts[contactCount] : contacts; - - dgInt32 count = m_world->CalculateConvexToConvexContacts (proxy); - - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - dgFloat32 param = proxy.m_timestep; - dgAssert (param >= dgFloat32 (0.0f)); - if (param < maxParam) { - n = proxy.m_normal; - p = proxy.m_closestPointBody0; - q = proxy.m_closestPointBody1; - - if (proxy.m_intersectionTestOnly) { - maxParam = param; - if (count == -1) { - contactCount = -1; - break; - } - - } else { - if (contactCount && ((param - maxParam) * invMaxParam) < dgFloat32(-1.0e-3f)) { - for (dgInt32 i = 0; i < count; i ++) { - contacts[i] = contacts[contactCount + i]; - } - contactCount = 0; - } - maxParam = param; - - for (dgInt32 i = 0; i < count; i ++) { - dgAssert (contacts[contactCount + i].m_collision0 == &childInstance); - contacts[contactCount + i].m_collision0 = subShape; - } - contactCount += count; - - if (contactCount > (DG_MAX_CONTATCS - 2 * (DG_CONSTRAINT_MAX_ROWS / 3))) { - contactCount = m_world->PruneContacts(contactCount, contacts, proxy.m_contactJoint->GetPruningTolerance(), 16); - } - - if (maxParam == dgFloat32 (0.0f)) { - break; - } - } - } - - childInstance.m_material.m_userData = NULL; - proxy.m_instance0 = NULL; - } - } - } else { - dgAssert (me->m_type == m_node); - stackPool[stack] = me->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack] = me->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - } - } - } - - proxy.m_normal = n; - proxy.m_closestPointBody0 = p; - proxy.m_closestPointBody1 = q; - proxy.m_timestep = maxParam; - contactJoint->m_closestDistance = closestDist; - proxy.m_contacts = contacts; - return contactCount; -} - - -dgInt32 dgCollisionCompound::CalculateContactsToCompoundContinue(dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - if (proxy.m_timestep < dgFloat32 (1.0e-4f)) { - return 0; - } - - dgInt32 contactCount = 0; - dgContactPoint* const contacts = proxy.m_contacts; - const dgNodeBase* stackPool[4 * DG_COMPOUND_STACK_DEPTH][2]; - dgContact* const contactJoint = pair->m_contact; - - dgBody* const compoundBody = contactJoint->GetBody0(); - dgBody* const otherCompoundBody = contactJoint->GetBody1(); - - dgCollisionInstance* const compoundInstance = compoundBody->m_collision; - dgCollisionInstance* const otherCompoundInstance = otherCompoundBody->m_collision; - - dgCollisionCompound* const otherCompound = (dgCollisionCompound*)otherCompoundInstance->GetChildShape(); - - dgAssert (compoundInstance->GetChildShape() == this); - dgAssert (otherCompoundInstance->IsType (dgCollision::dgCollisionCompound_RTTI)); - - proxy.m_body0 = compoundBody; - proxy.m_body1 = otherCompoundBody; - - const dgMatrix& myMatrix = compoundInstance->GetGlobalMatrix(); - const dgMatrix& otherMatrix = otherCompoundInstance->GetGlobalMatrix(); - dgOOBBTestData data (otherMatrix * myMatrix.Inverse()); - - dgVector relVeloc (myMatrix.UnrotateVector (otherCompoundBody->GetVelocity() - compoundBody->GetVelocity())); - dgFastRayTest myCompoundRay (dgVector (dgFloat32 (0.0f)), relVeloc); - dgFastRayTest otherCompoundRay (dgVector (dgFloat32 (0.0f)), data.m_matrix.UnrotateVector(relVeloc)); - - dgInt32 stack = 1; - stackPool[0][0] = m_root; - stackPool[0][1] = otherCompound->m_root; - const dgContactMaterial* const material = contactJoint->GetMaterial(); - - dgVector n(dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p(dgFloat32(0.0f)); - dgVector q(dgFloat32(0.0f)); - - dgFloat32 maxParam = proxy.m_timestep; - dgFloat32 invMaxParam = dgFloat32 (1.0f) / maxParam; - - dgFloat32 upperBound = dgFloat32 (1.0f); - - dgFloat32 timestep = pair->m_timestep; - dgFloat32 closestDist = dgFloat32 (1.0e10f); - - while (stack) { - stack --; - const dgNodeBase* const me = stackPool[stack][0]; - const dgNodeBase* const other = stackPool[stack][1]; - dgAssert (me && other); - - dgFloat32 dist = me->RayBoxDistance (data, myCompoundRay, otherCompoundRay, other); - if (dist <= upperBound) { - if ((me->m_type == m_leaf) && (other->m_type == m_leaf)) { - dgCollisionInstance* const subShape = me->GetShape(); - dgCollisionInstance* const otherSubShape = other->GetShape(); - - if (subShape->GetCollisionMode() & otherSubShape->GetCollisionMode()) { - - bool processContacts = true; - if (material->m_compoundAABBOverlap) { - processContacts = material->m_compoundAABBOverlap (*contactJoint, timestep, compoundBody, me->m_myNode, otherCompoundBody, other->m_myNode, proxy.m_threadIndex); - } - - if (processContacts) { - - dgCollisionInstance childInstance (*subShape, subShape->GetChildShape()); - childInstance.m_globalMatrix = childInstance.GetLocalMatrix() * myMatrix; - proxy.m_instance0 = &childInstance; - - dgCollisionInstance otherChildInstance (*otherSubShape, otherSubShape->GetChildShape()); - otherChildInstance.m_globalMatrix = otherChildInstance.GetLocalMatrix() * otherMatrix; - proxy.m_instance1 = &otherChildInstance; - - proxy.m_maxContacts = DG_MAX_CONTATCS - contactCount; - proxy.m_contacts = contacts ? &contacts[contactCount] : contacts; - - dgInt32 count = m_world->CalculateConvexToConvexContacts (proxy); - - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - - dgFloat32 param = proxy.m_timestep; - dgAssert (param >= dgFloat32 (0.0f)); - if (param < maxParam) { - n = proxy.m_normal; - p = proxy.m_closestPointBody0; - q = proxy.m_closestPointBody1; - - upperBound = param * invMaxParam; - if (proxy.m_intersectionTestOnly) { - maxParam = param; - if (count == -1) { - contactCount = -1; - break; - } - - } else { - if (contactCount && ((param - maxParam) * invMaxParam) < dgFloat32(-1.0e-3f)) { - for (dgInt32 i = 0; i < count; i ++) { - contacts[i] = contacts[contactCount + i]; - } - contactCount = 0; - } - maxParam = param; - - for (dgInt32 i = 0; i < count; i ++) { - dgAssert (contacts[contactCount + i].m_collision0 == &childInstance); - contacts[contactCount + i].m_collision0 = subShape; - } - contactCount += count; - - if (contactCount > (DG_MAX_CONTATCS - 2 * (DG_CONSTRAINT_MAX_ROWS / 3))) { - contactCount = m_world->PruneContacts(contactCount, contacts, proxy.m_contactJoint->GetPruningTolerance(), 16); - } - - if (maxParam == dgFloat32 (0.0f)) { - break; - } - } - } - - childInstance.m_material.m_userData = NULL; - otherChildInstance.m_material.m_userData = NULL; - - proxy.m_instance0 = NULL; - proxy.m_instance1 = NULL; - } - } - } else if (me->m_type == m_leaf) { - dgAssert (other->m_type == m_node); - stackPool[stack][0] = me; - stackPool[stack][1] = other->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me; - stackPool[stack][1] = other->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - } else if (other->m_type == m_leaf) { - dgAssert (me->m_type == m_node); - stackPool[stack][0] = me->m_left; - stackPool[stack][1] = other; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me->m_right; - stackPool[stack][1] = other; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - } else { - dgAssert (me->m_type == m_node); - dgAssert (other->m_type == m_node); - - stackPool[stack][0] = me->m_left; - stackPool[stack][1] = other->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me->m_left; - stackPool[stack][1] = other->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me->m_right; - stackPool[stack][1] = other->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me->m_right; - stackPool[stack][1] = other->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - } - } - } - - proxy.m_normal = n; - proxy.m_closestPointBody0 = p; - proxy.m_closestPointBody1 = q; - proxy.m_timestep = maxParam; - - contactJoint->m_closestDistance = closestDist; - proxy.m_contacts = contacts; - return contactCount; -} - -dgInt32 dgCollisionCompound::CalculateContactsToCollisionTreeContinue (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - if (proxy.m_timestep < dgFloat32 (1.0e-4f)) { - return 0; - } - - dgContactPoint* const contacts = proxy.m_contacts; - - dgNodePairs stackPool[4 * DG_COMPOUND_STACK_DEPTH]; - - dgInt32 contactCount = 0; - - dgContact* const contactJoint = pair->m_contact; - dgBody* const myBody = contactJoint->GetBody0(); - dgBody* const treeBody = contactJoint->GetBody1(); - - dgCollisionInstance* const compoundInstance = myBody->m_collision; - dgCollisionInstance* const treeCollisionInstance = treeBody->m_collision; - - dgAssert (compoundInstance->GetChildShape() == this); - dgAssert (treeCollisionInstance->IsType (dgCollision::dgCollisionBVH_RTTI)); - dgCollisionBVH* const treeCollision = (dgCollisionBVH*)treeCollisionInstance->GetChildShape(); - - proxy.m_body0 = myBody; - proxy.m_body1 = treeBody; - proxy.m_instance1 = treeCollisionInstance; - - const dgMatrix& myMatrix = compoundInstance->GetGlobalMatrix(); - const dgMatrix& otherMatrix = treeCollisionInstance->GetGlobalMatrix(); - dgOOBBTestData data (otherMatrix * myMatrix.Inverse()); - - dgVector relVeloc (myMatrix.UnrotateVector (treeBody->GetVelocity() - myBody->GetVelocity())); - dgFastRayTest myCompoundRay (dgVector (dgFloat32 (0.0f)), relVeloc); - dgFastRayTest otherTreedRay (dgVector (dgFloat32 (0.0f)), data.m_matrix.UnrotateVector(relVeloc)); - - dgInt32 stack = 1; - stackPool[0].m_myNode = m_root; - stackPool[0].m_treeNode = treeCollision->GetRootNode(); - stackPool[0].m_treeNodeIsLeaf = 0; - - dgNodeBase nodeProxi; - nodeProxi.m_left = NULL; - nodeProxi.m_right = NULL; - - const dgVector& treeScale = treeCollisionInstance->GetScale(); - const dgContactMaterial* const material = contactJoint->GetMaterial(); - - dgVector n(dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p(dgFloat32(0.0f)); - dgVector q(dgFloat32(0.0f)); - - dgFloat32 maxParam = proxy.m_timestep; - dgFloat32 invMaxParam = dgFloat32 (1.0f) / maxParam; - - dgFloat32 upperBound = dgFloat32 (1.0f); - - dgFloat32 timestep = pair->m_timestep; - dgFloat32 closestDist = dgFloat32 (1.0e10f); - while (stack) { - - stack --; - const dgNodePairs* const stackEntry = &stackPool[stack]; - - dgNodeBase* const me = stackEntry->m_myNode; - const void* const other = stackEntry->m_treeNode; - dgInt32 treeNodeIsLeaf = stackEntry->m_treeNodeIsLeaf; - - dgAssert (me && other); - - dgVector p0; - dgVector p1; - - treeCollision->GetNodeAABB(other, p0, p1); - nodeProxi.m_p0 = p0 * treeScale; - nodeProxi.m_p1 = p1 * treeScale; - - p0 = nodeProxi.m_p0 * dgVector::m_half; - p1 = nodeProxi.m_p1 * dgVector::m_half; - nodeProxi.m_size = p1 - p0; - nodeProxi.m_origin = p1 + p0; - nodeProxi.m_area = nodeProxi.m_size.ShiftTripleRight().DotProduct(nodeProxi.m_size).GetScalar(); - - dgFloat32 dist = me->RayBoxDistance (data, myCompoundRay, otherTreedRay, &nodeProxi); - if (dist <= upperBound) { - if ((me->m_type == m_leaf) && treeNodeIsLeaf) { - dgCollisionInstance* const subShape = me->GetShape(); - if (subShape->GetCollisionMode()) { - bool processContacts = true; - if (material->m_compoundAABBOverlap) { - processContacts = material->m_compoundAABBOverlap (*contactJoint, timestep, myBody, me->m_myNode, treeBody, NULL, proxy.m_threadIndex); - } - if (processContacts) { - - dgCollisionInstance childInstance (*subShape, subShape->GetChildShape()); - childInstance.m_globalMatrix = childInstance.GetLocalMatrix() * myMatrix; - proxy.m_instance0 = &childInstance; - - proxy.m_maxContacts = DG_MAX_CONTATCS - contactCount; - proxy.m_contacts = contacts ? &contacts[contactCount] : contacts; - - dgInt32 count = m_world->CalculateConvexToNonConvexContacts (proxy); - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - - dgFloat32 param = proxy.m_timestep; - dgAssert (param >= dgFloat32 (0.0f)); - if (param < maxParam) { - n = proxy.m_normal; - p = proxy.m_closestPointBody0; - q = proxy.m_closestPointBody1; - - upperBound = param * invMaxParam; - if (proxy.m_intersectionTestOnly) { - maxParam = param; - if (count == -1) { - contactCount = -1; - break; - } - - } else { - if (contactCount && ((param - maxParam) * invMaxParam) < dgFloat32(-1.0e-3f)) { - for (dgInt32 i = 0; i < count; i ++) { - contacts[i] = contacts[contactCount + i]; - } - contactCount = 0; - } - maxParam = param; - - for (dgInt32 i = 0; i < count; i ++) { - dgAssert (contacts[contactCount + i].m_collision0 == &childInstance); - contacts[contactCount + i].m_collision0 = subShape; - } - contactCount += count; - - if (contactCount > (DG_MAX_CONTATCS - 2 * (DG_CONSTRAINT_MAX_ROWS / 3))) { - contactCount = m_world->PruneContacts(contactCount, contacts, proxy.m_contactJoint->GetPruningTolerance(), 16); - } - - if (maxParam == dgFloat32 (0.0f)) { - break; - } - } - } - childInstance.m_material.m_userData = NULL; - proxy.m_instance0 = NULL; - } - } - - } else if (me->m_type == m_leaf) { - void* const frontNode = treeCollision->GetFrontNode(other); - void* const backNode = treeCollision->GetBackNode(other); - - if (backNode && frontNode) { - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = backNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = frontNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - } else if (backNode && !frontNode) { - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = backNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - } else if (!backNode && frontNode) { - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = frontNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - } else { - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - } - - } else if (treeNodeIsLeaf) { - - stackPool[stack].m_myNode = me->m_left; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack].m_myNode = me->m_right; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - } else if (nodeProxi.m_area > me->m_area) { - - dgAssert (me->m_type == m_node); - void* const frontNode = treeCollision->GetFrontNode(other); - void* const backNode = treeCollision->GetBackNode(other); - if (backNode && frontNode) { - stackPool[stack].m_myNode = (dgNodeBase*) me; - stackPool[stack].m_treeNode = backNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - stackPool[stack].m_myNode = (dgNodeBase*) me; - stackPool[stack].m_treeNode = frontNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - } else if (backNode && !frontNode) { - stackPool[stack].m_myNode = (dgNodeBase*) me; - stackPool[stack].m_treeNode = backNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - stackPool[stack].m_myNode = me->m_left; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - - stackPool[stack].m_myNode = me->m_right; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - - } else if (!backNode && frontNode) { - - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = frontNode; - stackPool[stack].m_treeNodeIsLeaf = 0; - stack++; - - stackPool[stack].m_myNode = me->m_left; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - - stackPool[stack].m_myNode = me->m_right; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - - } else { - stackPool[stack].m_myNode = me; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = 1; - stack++; - } - - } else { - dgAssert (me->m_type == m_node); - stackPool[stack].m_myNode = me->m_left; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = treeNodeIsLeaf; - stack++; - - stackPool[stack].m_myNode = me->m_right; - stackPool[stack].m_treeNode = other; - stackPool[stack].m_treeNodeIsLeaf = treeNodeIsLeaf; - stack++; - } - } - } - - proxy.m_normal = n; - proxy.m_closestPointBody0 = p; - proxy.m_closestPointBody1 = q; - proxy.m_timestep = maxParam; - - contactJoint->m_closestDistance = closestDist; - proxy.m_contacts = contacts; - return contactCount; -} diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionCompound.h b/thirdparty/src/newton/dgPhysics/dgCollisionCompound.h deleted file mode 100644 index c32568d13..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionCompound.h +++ /dev/null @@ -1,252 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGCOLLISIONCOMPOUND_H__ -#define __DGCOLLISIONCOMPOUND_H__ - - -#include "dgCollision.h" - -class dgFastRayTest; -class dgCollisionBVH; -class dgCollisionInstance; - - -#define DG_COMPOUND_STACK_DEPTH 256 - -class dgCollisionCompound: public dgCollision -{ - protected: - enum dgNodeType - { - m_leaf, - m_node, - }; - - public: - - class dgNodeBase; - class dgTreeArray: public dgTree<dgNodeBase*, dgInt32> - { - public: - dgTreeArray (dgMemoryAllocator* const allocator); - void AddNode (dgNodeBase* const node, dgInt32 index, const dgCollisionInstance* const parent); - }; - - DG_MSC_VECTOR_ALIGNMENT - class dgOOBBTestData - { - public: - dgOOBBTestData (const dgMatrix& matrix); - dgOOBBTestData (const dgMatrix& matrix, const dgVector& origin, const dgVector& size); - - DG_INLINE dgFloat32 UpdateSeparatingDistance(const dgVector& box0Min, const dgVector& box0Max, const dgVector& box1Min, const dgVector& box1Max) const; - - dgMatrix m_matrix; - dgMatrix m_absMatrix; - dgVector m_origin; - dgVector m_size; - dgVector m_localP0; - dgVector m_localP1; - dgVector m_aabbP0; - dgVector m_aabbP1; - - dgVector m_crossAxis[9]; - dgVector m_crossAxisAbs[9]; - dgVector m_crossAxisDotAbs[9]; - dgVector m_extendsMinX[3]; - dgVector m_extendsMaxX[3]; - mutable dgFloat32 m_separatingDistance; - static dgVector m_maxDist; - } DG_GCC_VECTOR_ALIGNMENT; - - - DG_MSC_VECTOR_ALIGNMENT - class dgNodeBase - { - public: - DG_CLASS_ALLOCATOR(allocator) - dgNodeBase (); - dgNodeBase (const dgNodeBase& copyFrom); - dgNodeBase (dgCollisionInstance* const instance); - dgNodeBase (dgNodeBase* const left, dgNodeBase* const right); - ~dgNodeBase(); - - void CalculateAABB(); - void SetBox (const dgVector& p0, const dgVector& p1); - bool BoxTest (const dgOOBBTestData& data) const; - bool BoxTest (const dgOOBBTestData& data, const dgNodeBase* const otherNode) const; - dgFloat32 RayBoxDistance (const dgOOBBTestData& data, const dgFastRayTest& myRay, const dgFastRayTest& otherRay, const dgNodeBase* const otherNode) const; - - DG_INLINE dgCollisionInstance* GetShape() const - { - return m_shape; - } - - DG_INLINE dgInt32 BoxIntersect (const dgFastRayTest& ray, const dgVector& boxP0, const dgVector& boxP1) const - { - dgVector minBox (m_p0 - boxP1); - dgVector maxBox (m_p1 - boxP0); - return ray.BoxTest(minBox, maxBox); - } - - dgVector m_p0; - dgVector m_p1; - dgVector m_size; - dgVector m_origin; - dgFloat32 m_area; - dgInt32 m_type; - dgNodeBase* m_left; - dgNodeBase* m_right; - dgNodeBase* m_parent; - dgCollisionInstance* m_shape; - dgTreeArray::dgTreeNode* m_myNode; - } DG_GCC_VECTOR_ALIGNMENT; - - protected: - class dgNodePairs - { - public: - const void* m_treeNode; - dgNodeBase* m_myNode; - dgInt32 m_treeNodeIsLeaf; - }; - - class dgSpliteInfo; - class dgHeapNodePair; - - public: - dgCollisionCompound (dgWorld* const world); - dgCollisionCompound (const dgCollisionCompound& source, const dgCollisionInstance* const myInstance); - dgCollisionCompound (dgWorld* const world, dgDeserialize deserialization, void* const userData, const dgCollisionInstance* const myInstance, dgInt32 revisionNumber); - - void SetParent (const dgCollisionInstance* const myInstance); - virtual ~dgCollisionCompound(); - - virtual void BeginAddRemove (); - virtual dgTreeArray::dgTreeNode* AddCollision (dgCollisionInstance* const part); - virtual void RemoveCollision (dgTreeArray::dgTreeNode* const node); - virtual void SetCollisionMatrix (dgTreeArray::dgTreeNode* const node, const dgMatrix& matrix); - virtual void EndAddRemove (bool flushCache = true); - - void ApplyScale (const dgVector& scale); - void GetAABB (dgVector& p0, dgVector& p1) const; - - dgInt32 GetNodeIndex(dgTreeArray::dgTreeNode* const node) const; - dgTreeArray::dgTreeNode* FindNodeByIndex (dgInt32 index) const; - - dgTreeArray::dgTreeNode* GetFirstNode () const; - dgTreeArray::dgTreeNode* GetNextNode (dgTreeArray::dgTreeNode* const node) const; - dgCollisionInstance* GetCollisionFromNode (dgTreeArray::dgTreeNode* const node) const; - - protected: - void RemoveCollision (dgNodeBase* const node); - virtual dgFloat32 GetVolume () const; - virtual dgFloat32 GetBoxMinRadius () const; - virtual dgFloat32 GetBoxMaxRadius () const; - - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const {return point;} - - virtual void CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const; - - static void CalculateInertia (void* userData, int vertexCount, const dgFloat32* const FaceArray, int faceId); - - virtual void MassProperties (); - dgMatrix CalculateInertiaAndCenterOfMass (const dgMatrix& m_alignMatrix, const dgVector& localScale, const dgMatrix& matrix) const; - dgFloat32 CalculateMassProperties (const dgMatrix& offset, dgVector& inertia, dgVector& crossInertia, dgVector& centerOfMass) const; - virtual dgVector CalculateVolumeIntegral (const dgMatrix& globalMatrix, const dgVector& plane, const dgCollisionInstance& parentScale) const; - - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const; - - virtual dgInt32 CalculateSignature () const; - virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1); - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - virtual void Serialize(dgSerialize callback, void* const userData) const; - virtual dgInt32 CalculateContacts (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - - dgInt32 CalculateContactsToSingle (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - dgInt32 CalculateContactsToSingleContinue (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - dgInt32 CalculateContactsToCompound (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - dgInt32 CalculateContactsToCompoundContinue (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - dgInt32 CalculateContactsToCollisionTree (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - dgInt32 CalculateContactsToCollisionTreeContinue (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - dgInt32 CalculateContactsToHeightField (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - dgInt32 CalculateContactsUserDefinedCollision (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - dgInt32 ClosestDistance (dgCollisionParamProxy& proxy) const; - dgInt32 ClosestDistanceToConvex (dgCollisionParamProxy& proxy) const; - dgInt32 ClosestDistanceToCompound (dgCollisionParamProxy& proxy) const; - -#ifdef _DEBUG - dgVector InternalSupportVertex (const dgVector& dir) const; -#endif - - dgNodeBase* BuildTopDown (dgNodeBase** const leafArray, dgInt32 firstBox, dgInt32 lastBox, dgList<dgNodeBase*>::dgListNode** const nextNode); - dgNodeBase* BuildTopDownBig (dgNodeBase** const leafArray, dgInt32 firstBox, dgInt32 lastBox, dgList<dgNodeBase*>::dgListNode** const nextNode); - - dgFloat64 CalculateEntropy (dgList<dgNodeBase*>& list); - - void ImproveNodeFitness (dgNodeBase* const node) const; - DG_INLINE dgFloat32 CalculateSurfaceArea (dgNodeBase* const node0, dgNodeBase* const node1, dgVector& minBox, dgVector& maxBox) const; - - dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const; - - void PushNode (const dgMatrix& matrix, dgUpHeap<dgHeapNodePair, dgFloat32>& heap, dgNodeBase* const myNode, dgNodeBase* const otehrNode) const; - - static dgInt32 CompareNodes (const dgNodeBase* const nodeA, const dgNodeBase* const nodeB, void* notUsed); - - - dgWorld* m_world; - dgNodeBase* m_root; - const dgCollisionInstance* m_myInstance; - dgTreeArray m_array; - dgFloat64 m_treeEntropy; - dgFloat32 m_boxMinRadius; - dgFloat32 m_boxMaxRadius; - dgInt32 m_idIndex; - dgInt32 m_criticalSectionLock; - - static dgVector m_padding; - friend class dgBody; - friend class dgWorld; - friend class dgCollisionScene; -}; - -DG_INLINE dgFloat32 dgCollisionCompound::dgOOBBTestData::UpdateSeparatingDistance(const dgVector& box0Min, const dgVector& box0Max, const dgVector& box1Min, const dgVector& box1Max) const -{ - const dgVector minBox(box0Min - box1Max); - const dgVector maxBox(box0Max - box1Min); - const dgVector mask((minBox * maxBox) < dgVector::m_zero); - const dgVector boxDist ((maxBox.Abs()).GetMin(minBox.Abs())); - - //dgVector dist((mask & m_maxDist) | boxDist.AndNot(mask)); - dgVector dist(boxDist.Select(m_maxDist, mask)); - - dist = dist.GetMin(dist.ShiftTripleRight()); - dist = dist.GetMin(dist.ShiftTripleRight()); - return dist.GetScalar(); -} - - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionCompoundFractured.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionCompoundFractured.cpp deleted file mode 100644 index 2cd3e03bf..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionCompoundFractured.cpp +++ /dev/null @@ -1,1758 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgWorld.h" -#include "dgMeshEffect.h" -#include "dgDynamicBody.h" -#include "dgCollisionInstance.h" -#include "dgCollisionConvexHull.h" -#include "dgCollisionCompoundFractured.h" - - -#define DG_FRACTURE_AABB_GUARD_DISTANCE 1.0f -#define DG_FRACTURE_MAX_METERIAL_COUNT 256 - -dgCollisionCompoundFractured::dgConectivityGraph::dgConectivityGraph (dgMemoryAllocator* const allocator) - :dgGraph<dgDebriNodeInfo, dgSharedNodeMesh>(allocator) -{ -} - -dgCollisionCompoundFractured::dgConectivityGraph::dgConectivityGraph (const dgConectivityGraph& source) - :dgGraph<dgDebriNodeInfo, dgSharedNodeMesh>(source.GetAllocator()) -{ - dgTree<dgListNode*, dgListNode*> filter(GetAllocator()); - - for (dgConectivityGraph::dgListNode* node = source.GetFirst(); node != source.GetLast(); node = node->GetNext() ) { - dgListNode* const newNode = dgGraph<dgDebriNodeInfo, dgSharedNodeMesh>::AddNode(); - - dgDebriNodeInfo& srcData = node->GetInfo().m_nodeData; - dgDebriNodeInfo& data = newNode->GetInfo().m_nodeData; - data.m_mesh = srcData.m_mesh; - data.m_mesh->AddRef(); - - filter.Insert(newNode, node); - } - - for (dgListNode* node = source.GetFirst(); node != source.GetLast(); node = node->GetNext()) { - dgListNode* const myNode = filter.Find(node)->GetInfo(); - for (dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* edgeNode = node->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - dgListNode* const otherNode = filter.Find(edgeNode->GetInfo().m_node)->GetInfo(); - dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* const myEdgeNode = myNode->GetInfo().AddEdge (otherNode); - myEdgeNode->GetInfo().m_edgeData.m_normal = edgeNode->GetInfo().m_edgeData.m_normal; - } - } -} - - -dgCollisionCompoundFractured::dgConectivityGraph::~dgConectivityGraph () -{ -} - -void dgCollisionCompoundFractured::dgConectivityGraph::Serialize(dgSerialize callback, void* const userData) const -{ - dgInt32 count = GetCount(); - - dgInt32 index = 0; - dgTree<dgInt32, dgListNode*> enumMap (GetAllocator()); - callback (userData, &count, dgInt32 (sizeof (dgInt32))); - for (dgConectivityGraph::dgListNode* node = GetFirst(); node != GetLast(); node = node->GetNext() ) { - enumMap.Insert(index, node); - index ++; - - dgDebriNodeInfo& data = node->GetInfo().m_nodeData; - dgInt32 nodeIndex = data.m_shapeNode->GetKey(); - callback (userData, &nodeIndex, dgInt32 (sizeof (dgInt32))); - data.m_mesh->Serialize(callback, userData); - } - - dgListNode* const lastNode = GetLast(); - dgDebriNodeInfo& data = lastNode->GetInfo().m_nodeData; - data.m_mesh->Serialize(callback, userData); - - for (dgListNode* node = GetFirst(); node != GetLast(); node = node->GetNext()) { - dgInt32 count1 = node->GetInfo().GetCount(); - callback (userData, &count1, dgInt32 (sizeof (dgInt32))); - for (dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* edgeNode = node->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - dgListNode* const otherNode = edgeNode->GetInfo().m_node; - dgInt32 index1 = enumMap.Find(otherNode)->GetInfo(); - dgVector normal (edgeNode->GetInfo().m_edgeData.m_normal); - callback (userData, &index1, dgInt32 (sizeof (dgInt32))); - callback (userData, &normal, dgInt32 (sizeof (dgVector))); - } - } -} - -void dgCollisionCompoundFractured::dgConectivityGraph::Deserialize (dgCollisionCompoundFractured* const source, dgDeserialize callback, void* const userData) -{ - dgInt32 count = 0; - callback (userData, &count, dgInt32 (sizeof (dgInt32))); - - dgTree<dgListNode*, dgInt32> enumMap (GetAllocator()); - for (dgInt32 i = 0; i < count - 1; i ++) { - - dgListNode* const node = dgGraph<dgDebriNodeInfo, dgSharedNodeMesh>::AddNode(); - enumMap.Insert(node, i); - - dgDebriNodeInfo& data = node->GetInfo().m_nodeData; - dgInt32 nodeIndex; - callback (userData, &nodeIndex, dgInt32 (sizeof (dgInt32))); - data.m_shapeNode = source->FindNodeByIndex (nodeIndex); - dgAssert (data.m_shapeNode); - data.m_mesh = new (GetAllocator()) dgMesh (GetAllocator(), callback, userData); - } - - dgListNode* const nodePtr = dgGraph<dgDebriNodeInfo, dgSharedNodeMesh>::AddNode(); - dgDebriNodeInfo& data = nodePtr->GetInfo().m_nodeData; - data.m_mesh = new (GetAllocator()) dgMesh (GetAllocator(), callback, userData); - - for (dgListNode* node = GetFirst(); node != GetLast(); node = node->GetNext()) { - dgInt32 count1; - callback (userData, &count1, dgInt32 (sizeof (dgInt32))); - - for (dgInt32 i = 0; i < count1; i ++) { - dgInt32 index; - dgVector normal; - callback (userData, &index, dgInt32 (sizeof (dgInt32))); - callback (userData, &normal, dgInt32 (sizeof (dgVector))); - - dgListNode* const otherNode = enumMap.Find(index)->GetInfo(); - dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* const edgeNode = node->GetInfo().AddEdge (otherNode); - edgeNode->GetInfo().m_edgeData.m_normal = normal; - } - } -} - - - -class dgCollisionCompoundFractured::dgFractureBuilder: public dgTree<dgMeshEffect*, dgInt32> -{ - public: - class dgPerimenterEdge - { - public: - dgPerimenterEdge* m_next; - dgPerimenterEdge* m_prev; - const dgBigVector* m_vertex; - }; - - class dgFractureConectivity: public dgGraph<dgInt32, dgInt32> - { - public: - dgFractureConectivity(dgMemoryAllocator* const allocator) - :dgGraph<int, int> (allocator) - { - } - }; - - class dgConvexSolidVertices: public dgList<dgInt32> - { - public: - dgConvexSolidVertices(dgMemoryAllocator* const allocator) - :dgList<dgInt32> (allocator) - { - } - }; - - class dgConvexSolidArray: public dgTree<dgConvexSolidVertices, dgInt32> - { - public: - dgConvexSolidArray(dgMemoryAllocator* const allocator) - :dgTree<dgConvexSolidVertices, dgInt32> (allocator) - { - } - }; - - - dgFractureBuilder (dgMemoryAllocator* const allocator, dgMeshEffect* const solidMesh, dgInt32 pointcloudCount, const dgFloat32* const vertexCloud, dgInt32 strideInBytes, int materialId, const dgMatrix& textureProjectionMatrix) - :dgTree<dgMeshEffect*, dgInt32>(allocator) - ,m_conectivity(allocator) - { - dgAssert (0); -/* - dgStack<dgBigVector> buffer(pointcloudCount + 16); - dgBigVector* const pool = &buffer[0]; - dgFloat64 quantizeFactor = dgFloat64 (16.0f); - dgFloat64 invQuantizeFactor = dgFloat64 (1.0f) / quantizeFactor; - dgInt32 stride = strideInBytes / sizeof (dgFloat32); - - dgBigVector minAABB; - dgBigVector maxAABB; - solidMesh->CalculateAABB (minAABB, maxAABB); - for (dgInt32 i = 0; i < pointcloudCount; i ++) { - dgFloat64 x = vertexCloud[i * stride + 0]; - dgFloat64 y = vertexCloud[i * stride + 1]; - dgFloat64 z = vertexCloud[i * stride + 2]; - x = floor (x * quantizeFactor) * invQuantizeFactor; - y = floor (y * quantizeFactor) * invQuantizeFactor; - z = floor (z * quantizeFactor) * invQuantizeFactor; - pool[i] = dgBigVector (x, y, z, dgFloat64 (0.0f)); - } - - // add the bbox as a barrier - int count = pointcloudCount; - pool[count + 0] = dgBigVector ( minAABB.m_x, minAABB.m_y, minAABB.m_z, dgFloat64 (0.0f)); - pool[count + 1] = dgBigVector ( maxAABB.m_x, minAABB.m_y, minAABB.m_z, dgFloat64 (0.0f)); - pool[count + 2] = dgBigVector ( minAABB.m_x, maxAABB.m_y, minAABB.m_z, dgFloat64 (0.0f)); - pool[count + 3] = dgBigVector ( maxAABB.m_x, maxAABB.m_y, minAABB.m_z, dgFloat64 (0.0f)); - pool[count + 4] = dgBigVector ( minAABB.m_x, minAABB.m_y, maxAABB.m_z, dgFloat64 (0.0f)); - pool[count + 5] = dgBigVector ( maxAABB.m_x, minAABB.m_y, maxAABB.m_z, dgFloat64 (0.0f)); - pool[count + 6] = dgBigVector ( minAABB.m_x, maxAABB.m_y, maxAABB.m_z, dgFloat64 (0.0f)); - pool[count + 7] = dgBigVector ( maxAABB.m_x, maxAABB.m_y, maxAABB.m_z, dgFloat64 (0.0f)); - count += 8; - - dgStack<dgInt32> indexList(count); - count = dgVertexListToIndexList(&pool[0].m_x, sizeof (dgBigVector), 3, count, &indexList[0], dgFloat64 (5.0e-2f)); - dgAssert (count >= 8); - - dgFloat64 maxSize = dgMax(maxAABB.m_x - minAABB.m_x, maxAABB.m_y - minAABB.m_y, maxAABB.m_z - minAABB.m_z); - minAABB -= dgBigVector (maxSize, maxSize, maxSize, dgFloat64 (0.0f)); - maxAABB += dgBigVector (maxSize, maxSize, maxSize, dgFloat64 (0.0f)); - - // add the a guard zone, so that we do not have to clip - dgInt32 guadVertexKey = count; - pool[count + 0] = dgBigVector ( minAABB.m_x, minAABB.m_y, minAABB.m_z, dgFloat64 (0.0f)); - pool[count + 1] = dgBigVector ( maxAABB.m_x, minAABB.m_y, minAABB.m_z, dgFloat64 (0.0f)); - pool[count + 2] = dgBigVector ( minAABB.m_x, maxAABB.m_y, minAABB.m_z, dgFloat64 (0.0f)); - pool[count + 3] = dgBigVector ( maxAABB.m_x, maxAABB.m_y, minAABB.m_z, dgFloat64 (0.0f)); - pool[count + 4] = dgBigVector ( minAABB.m_x, minAABB.m_y, maxAABB.m_z, dgFloat64 (0.0f)); - pool[count + 5] = dgBigVector ( maxAABB.m_x, minAABB.m_y, maxAABB.m_z, dgFloat64 (0.0f)); - pool[count + 6] = dgBigVector ( minAABB.m_x, maxAABB.m_y, maxAABB.m_z, dgFloat64 (0.0f)); - pool[count + 7] = dgBigVector ( maxAABB.m_x, maxAABB.m_y, maxAABB.m_z, dgFloat64 (0.0f)); - count += 8; - - dgDelaunayTetrahedralization delaunayTetrahedras (allocator, &pool[0].m_x, count, sizeof (dgBigVector), dgFloat32 (0.0f)); - delaunayTetrahedras.RemoveUpperHull (); - - dgInt32 tetraCount = delaunayTetrahedras.GetCount(); - dgStack<dgBigVector> voronoiPoints(tetraCount + 32); - dgStack<dgDelaunayTetrahedralization::dgListNode*> tetradrumNode(tetraCount); - - dgConvexSolidArray delanayNodes (allocator); - dgTree<dgTree<dgConvexSolidArray::dgTreeNode*, dgConvexSolidArray::dgTreeNode*>, dgConvexSolidArray::dgTreeNode*> adjacentCell(allocator); - - dgInt32 index = 0; - const dgHullVector* const delanayPoints = delaunayTetrahedras.GetHullVertexArray(); - for (dgDelaunayTetrahedralization::dgListNode* node = delaunayTetrahedras.GetFirst(); node; node = node->GetNext()) { - dgConvexHull4dTetraherum& tetra = node->GetInfo(); - voronoiPoints[index] = tetra.CircumSphereCenter (delanayPoints); - tetradrumNode[index] = node; - - dgConvexSolidArray::dgTreeNode* array[4]; - for (dgInt32 i = 0; i < 4; i ++) { - dgConvexSolidArray::dgTreeNode* header = delanayNodes.Find(tetra.m_faces[0].m_index[i]); - if (!header) { - dgConvexSolidVertices list (allocator); - header = delanayNodes.Insert(list, tetra.m_faces[0].m_index[i]); - } - header->GetInfo().Append (index); - array[i] = header; - } - - for (dgInt32 i = 0; i < 4; i ++) { - dgTree<dgTree<dgConvexSolidArray::dgTreeNode*, dgConvexSolidArray::dgTreeNode*>, dgConvexSolidArray::dgTreeNode*>::dgTreeNode* header = adjacentCell.Find (array[i]); - if (!header) { - dgTree<dgConvexSolidArray::dgTreeNode*, dgConvexSolidArray::dgTreeNode*> list (allocator); - header = adjacentCell.Insert(list, array[i]); - } - - for (dgInt32 j = 0; j < 4; j ++) { - if (i != j) { - header->GetInfo().Insert(array[j], array[j]); - } - } - } - - index ++; - } - - dgConvexSolidArray::Iterator iter (delanayNodes); - dgFloat32 normalAngleInRadians = 30.0f * dgDEG2RAD; - - dgTree<dgFractureConectivity::dgListNode*, dgConvexSolidArray::dgTreeNode*> graphMap(allocator); - for (iter.Begin(); iter; iter ++) { - - dgConvexSolidArray::dgTreeNode* const nodeNode = iter.GetNode(); - const dgList<dgInt32>& list = nodeNode->GetInfo(); - dgInt32 key = nodeNode->GetKey(); - if (key < guadVertexKey) { - dgBigVector pointArray[512]; - dgInt32 indexArray[512]; - - dgInt32 count = 0; - for (dgList<dgInt32>::dgListNode* ptr = list.GetFirst(); ptr; ptr = ptr->GetNext()) { - dgInt32 i = ptr->GetInfo(); - pointArray[count] = voronoiPoints[i]; - count ++; - dgAssert (count < dgInt32 (sizeof (pointArray) / sizeof (pointArray[0]))); - } - - count = dgVertexListToIndexList(&pointArray[0].m_x, sizeof (dgBigVector), 3, count, &indexArray[0], dgFloat64 (1.0e-3f)); - if (count >= 4) { - dgMeshEffect* const convexMesh = new (allocator) dgMeshEffect (allocator, &pointArray[0].m_x, count, sizeof (dgBigVector), dgFloat64 (0.0f)); - if (convexMesh->GetCount()) { - convexMesh->AddRef(); - Insert (convexMesh, key); - - convexMesh->CalculateNormals(normalAngleInRadians); - convexMesh->UniformBoxMapping (materialId, textureProjectionMatrix); - - dgInt32 vCount = convexMesh->GetVertexCount(); - for (dgInt32 i = 0; i < vCount; i ++) { - dgBigVector& point = convexMesh->GetVertex (i); - point.m_w = key; - } - dgInt32 aCount = convexMesh->GetPropertiesCount(); - for (dgInt32 i = 0; i < aCount; i ++) { - dgMeshEffect::dgVertexAtribute& attib = convexMesh->GetAttribute (i); - attib.m_vertex.m_w = key; - } - - dgFractureConectivity::dgListNode* const node = m_conectivity.AddNode (); - node->GetInfo().m_nodeData = key; - graphMap.Insert(node, nodeNode); - } - convexMesh->Release(); - } - } - } - - - dgTree<dgTree<dgConvexSolidArray::dgTreeNode*, dgConvexSolidArray::dgTreeNode*>, dgConvexSolidArray::dgTreeNode*>::Iterator adjacentIter (adjacentCell); - for (adjacentIter.Begin(); adjacentIter; adjacentIter++) { - dgConvexSolidArray::dgTreeNode* const solidTree0 = adjacentIter.GetKey(); - - dgTree<dgFractureConectivity::dgListNode*, dgConvexSolidArray::dgTreeNode*>::dgTreeNode* const mapNode0 = graphMap.Find(solidTree0); - if (mapNode0) { - dgFractureConectivity::dgListNode* const node0 = mapNode0->GetInfo(); - - const dgTree<dgConvexSolidArray::dgTreeNode*, dgConvexSolidArray::dgTreeNode*>& cell = adjacentIter.GetNode()->GetInfo(); - dgTree<dgConvexSolidArray::dgTreeNode*, dgConvexSolidArray::dgTreeNode*>::Iterator iter (cell); - for (iter.Begin(); iter; iter ++) { - dgConvexSolidArray::dgTreeNode* const solidTree1 = iter.GetNode()->GetInfo(); - dgTree<dgFractureConectivity::dgListNode*, dgConvexSolidArray::dgTreeNode*>::dgTreeNode* const mapNode1 = graphMap.Find(solidTree1); - if (mapNode1) { - dgFractureConectivity::dgListNode* const node1 = mapNode1->GetInfo(); - if (!IsPairConnected (node0, node1)) { - node0->GetInfo().AddEdge(node1); - node1->GetInfo().AddEdge(node0); - } - } - } - } - } - - dgAssert (SanityCheck()); - ClipFractureParts (solidMesh); - - for (dgFractureConectivity::dgListNode* node = m_conectivity.GetFirst(); node; node = node->GetNext()) { - dgInt32 index0 = node->GetInfo().m_nodeData; - - dgGraphNode<dgInt32, dgInt32>::dgListNode* nextEdge; - for (dgGraphNode<dgInt32, dgInt32>::dgListNode* edgeNode = node->GetInfo().GetFirst(); edgeNode; edgeNode = nextEdge) { - nextEdge = edgeNode->GetNext(); - dgFractureConectivity::dgListNode* const otherNode = edgeNode->GetInfo().m_node; - dgInt32 index1 = otherNode->GetInfo().m_nodeData; - if (!AreSolidNeigborg (index0, index1)) { - node->GetInfo().DeleteEdge(edgeNode); - } - } - } - -#if 0 -for (dgFractureConectivity::dgListNode* node = m_conectivity.GetFirst(); node; node = node->GetNext()) { - dgInt32 index = node->GetInfo().m_nodeData; - dgTrace (("node %d: ", index)); - for (dgGraphNode<int, int>::dgListNode* edge = node->GetInfo().GetFirst(); edge; edge = edge->GetNext()) { - dgFractureConectivity::dgListNode* const otherNode = edge->GetInfo().m_node; - dgInt32 index1 = otherNode->GetInfo().m_nodeData; - dgTrace (("%d ", index1)); - } - dgTrace (("\n")); -} -#endif -*/ - dgAssert (SanityCheck()); - } - - ~dgFractureBuilder() - { - Iterator iter (*this); - for (iter.Begin(); iter; iter ++) { - dgMeshEffect* const mesh = iter.GetNode()->GetInfo(); - mesh->Release(); - } - } - - - bool IsPairConnected (dgFractureConectivity::dgListNode* const nodeA, dgFractureConectivity::dgListNode* const nodeB) const - { - for (dgGraphNode<int, int>::dgListNode* edgeNodeAB = nodeA->GetInfo().GetFirst(); edgeNodeAB; edgeNodeAB = edgeNodeAB->GetNext()) { - dgFractureConectivity::dgListNode* const otherNode = edgeNodeAB->GetInfo().m_node; - if (otherNode == nodeB) - return true; - } - return false; - } - - bool ArePlaneCoplanar (dgMeshEffect* const meshA, void* faceA, const dgBigVector& planeA, dgMeshEffect* const meshB, void* faceB, const dgBigVector& planeB) const - { - if ((planeA.DotProduct(planeB & dgBigVector::m_triplexMask).GetScalar() < dgFloat64(-1.0 + 1.0e-6f)) && ((fabs(planeA.m_w + planeB.m_w) < dgFloat64(1.0e-6f)))) { - const dgBigVector* const pointsA = (dgBigVector*)meshA->GetVertexPool(); - const dgBigVector* const pointsB = (dgBigVector*)meshB->GetVertexPool(); - - dgInt32 indexA[128]; - dgInt32 indexB[128]; - - dgInt32 indexCountA = meshA->GetFaceIndexCount(faceA); - dgInt32 indexCountB = meshB->GetFaceIndexCount(faceB); - dgAssert(indexCountA < sizeof (indexA) / sizeof(indexA[0])); - dgAssert(indexCountB < sizeof (indexB) / sizeof(indexB[0])); - - meshA->GetFaceIndex(faceA, indexA); - meshA->GetFaceIndex(faceB, indexB); - - //dgTrace (("faceA:\n")); - dgPerimenterEdge subdivision[256]; - dgAssert((2 * (indexCountA + indexCountB)) < dgInt32(sizeof (subdivision) / sizeof (subdivision[0]))); - for (dgInt32 i = 1; i < indexCountB; i++) { - subdivision[i].m_vertex = &pointsB[indexB[i]]; - subdivision[i].m_prev = &subdivision[i - 1]; - subdivision[i].m_next = &subdivision[i + 1]; - - //dgTrace (("%f %f %f\n", pointsB[indexB[i]].m_x, pointsB[indexB[i]].m_y, pointsB[indexB[i]].m_z)); - } - subdivision[0].m_vertex = &pointsB[indexB[0]]; - subdivision[0].m_next = &subdivision[1]; - subdivision[0].m_prev = &subdivision[indexCountB - 1]; - - subdivision[indexCountB - 1].m_next = &subdivision[0]; - - dgInt32 edgeIndex = indexCountB; - - dgBigVector outputPool[128]; - dgPerimenterEdge* edgeClipped[2]; - dgBigVector* output = &outputPool[0]; - edgeClipped[0] = NULL; - edgeClipped[1] = NULL; - - //dgTrace (("faceB:\n")); - dgPerimenterEdge* poly = &subdivision[0]; - dgInt32 i0 = indexCountA - 1; - for (dgInt32 i1 = 0; i1 < indexCountA; i1++) { - const dgBigVector& q0 = pointsA[indexA[i0]]; - const dgBigVector& q1 = pointsA[indexA[i1]]; - dgBigVector n(planeA.CrossProduct(q1 - q0)); - dgAssert(n.m_w == dgFloat32(0.0f)); - dgBigPlane plane(n, -n.DotProduct(q0).GetScalar()); - i0 = i1; - //dgTrace (("%f %f %f\n", q0.m_x, q0.m_y, q0.m_z)); - - dgInt32 count = 0; - dgPerimenterEdge* tmp = poly; - dgInt32 isInside = 0; - dgFloat64 test0 = plane.Evalue(*tmp->m_vertex); - do { - dgFloat64 test1 = plane.Evalue(*tmp->m_next->m_vertex); - if (test0 >= dgFloat32(0.0f)) { - isInside |= 1; - if (test1 < dgFloat32(0.0f)) { - const dgBigVector& p0 = *tmp->m_vertex; - const dgBigVector& p1 = *tmp->m_next->m_vertex; - - dgBigVector dp(p1 - p0); - dgAssert(dp.m_w == dgFloat32(0.0f)); - dgFloat64 den = plane.DotProduct(dp).GetScalar(); - if (fabs(den) < dgFloat32(1.0e-24f)) { - den = (den >= dgFloat32(0.0f)) ? dgFloat32(1.0e-24f) : dgFloat32(-1.0e-24f); - } - - den = test0 / den; - if (den >= dgFloat32(0.0f)) { - den = dgFloat32(0.0f); - } else if (den <= -1.0f) { - den = dgFloat32(-1.0f); - } - output[0] = p0 - dp.Scale(den); - edgeClipped[0] = tmp; - count++; - } - } else if (test1 >= dgFloat32(0.0f)) { - const dgBigVector& p0 = *tmp->m_vertex; - const dgBigVector& p1 = *tmp->m_next->m_vertex; - isInside |= 1; - dgBigVector dp(p1 - p0); - dgAssert(dp.m_w == dgFloat32(0.0f)); - dgFloat64 den = plane.DotProduct(dp).GetScalar(); - if (fabs(den) < dgFloat32(1.0e-24f)) { - den = (den >= dgFloat32(0.0f)) ? dgFloat32(1.0e-24f) : dgFloat32(-1.0e-24f); - } - den = test0 / den; - if (den >= dgFloat32(0.0f)) { - den = dgFloat32(0.0f); - } else if (den <= -1.0f) { - den = dgFloat32(-1.0f); - } - output[1] = p0 - dp.Scale(den); - edgeClipped[1] = tmp; - count++; - } - test0 = test1; - tmp = tmp->m_next; - } while ((tmp != poly) && count < 2); - - if (!isInside) { - return false; - } - - if (count == 2) { - dgPerimenterEdge* const newEdge = &subdivision[edgeIndex]; - newEdge->m_next = edgeClipped[1]; - newEdge->m_prev = edgeClipped[0]; - edgeClipped[0]->m_next = newEdge; - edgeClipped[1]->m_prev = newEdge; - - newEdge->m_vertex = &output[0]; - edgeClipped[1]->m_vertex = &output[1]; - poly = newEdge; - - output += 2; - edgeIndex++; - dgAssert(edgeIndex < dgInt32(sizeof (subdivision) / sizeof (subdivision[0]))); - } - } - //dgTrace (("\n")); - dgAssert(poly); - dgBigVector area(dgFloat32(0.0f)); - dgBigVector r0(*poly->m_vertex); - dgBigVector r1(*poly->m_next->m_vertex); - dgBigVector r1r0(r1 - r0); - dgPerimenterEdge* polyPtr = poly->m_next->m_next; - do { - dgBigVector r2(*polyPtr->m_vertex); - dgBigVector r2r0(r2 - r0); - area += r2r0.CrossProduct(r1r0); - r1r0 = r2r0; - polyPtr = polyPtr->m_next; - } while (polyPtr != poly); - dgAssert(area.m_w == dgFloat32(0.0f)); - return fabs(area.DotProduct(planeA).GetScalar()) > dgFloat32(1.0e-5f); - } - - return false; - } - - bool AreSolidNeigborg (int indexA, int indexB) const - { - dgMeshEffect* const meshA = Find(indexA)->GetInfo(); - dgMeshEffect* const meshB = Find(indexB)->GetInfo(); - - const dgBigVector* const pointsA = (dgBigVector*)meshA->GetVertexPool(); - const dgBigVector* const pointsB = (dgBigVector*)meshB->GetVertexPool(); - - dgBigVector planeB_array[512]; - - dgInt32 planeB_Count = 0; - for (void* faceB = meshB->GetFirstFace(); faceB; faceB = meshB->GetNextFace(faceB)) { - if (!meshB->IsFaceOpen(faceB)) { - dgInt32 vertexIndexB = meshB->GetVertexIndex(faceB); - dgBigVector planeB(meshB->CalculateFaceNormal(faceB)); - planeB.m_w = -planeB.DotProduct(pointsB[vertexIndexB]).GetScalar(); - planeB_array[planeB_Count] = planeB; - planeB_Count++; - dgAssert(planeB_Count < sizeof (planeB_array) / sizeof (planeB_array[0])); - } - } - - for (void* faceA = meshA->GetFirstFace(); faceA; faceA = meshA->GetNextFace(faceA)) { - if (!meshA->IsFaceOpen(faceA)) { - dgInt32 vertexIndexA = meshA->GetVertexIndex(faceA); - dgBigVector planeA(meshA->CalculateFaceNormal(faceA)); - planeA.m_w = -planeA.DotProduct(pointsA[vertexIndexA]).GetScalar(); - - dgInt32 index = 0; - for (void* faceB = meshB->GetFirstFace(); faceB; faceB = meshB->GetNextFace(faceB)) { - if (!meshB->IsFaceOpen(faceB)) { - if (ArePlaneCoplanar(meshA, faceA, planeA, meshB, faceB, planeB_array[index])) { - return true; - } - index++; - } - } - } - } - return false; - } - - void ClipFractureParts (dgMeshEffect* const solidMesh) - { - dgFractureBuilder::dgFractureConectivity::dgListNode* nextNode; - for (dgFractureConectivity::dgListNode* node = m_conectivity.GetFirst(); node; node = nextNode) { - nextNode = node->GetNext(); - dgInt32 index = node->GetInfo().m_nodeData; - dgTreeNode* const fractureNode = Find(index); - dgAssert (fractureNode); - dgMeshEffect* const voronoiConvex = fractureNode->GetInfo(); - dgMeshEffect* const fracturePiece = solidMesh->ConvexMeshIntersection (voronoiConvex); - if (fracturePiece) { - voronoiConvex->Release(); - fractureNode->GetInfo() = fracturePiece; - } else { - m_conectivity.DeleteNode(node); - } - } - } - - bool SanityCheck() const - { - for (dgFractureConectivity::dgListNode* rootNode = m_conectivity.GetFirst(); rootNode; rootNode = rootNode->GetNext() ) { - dgTree<dgFractureConectivity::dgListNode*, dgFractureConectivity::dgListNode*> filter(GetAllocator()); - for (dgGraphNode<int, int>::dgListNode* edgeNode = rootNode->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - dgFractureConectivity::dgListNode* node = edgeNode->GetInfo().m_node; - dgAssert (!filter.Find(node)); - filter.Insert(node, node); - } - } - return true; - } - - dgFractureConectivity m_conectivity; -}; - - - -dgCollisionCompoundFractured::dgDebriNodeInfo::dgDebriNodeInfo () - :m_mesh(NULL) - ,m_shapeNode(NULL) - ,m_lru(0) -{ -} - -dgCollisionCompoundFractured::dgDebriNodeInfo::~dgDebriNodeInfo () -{ - if (m_mesh) { - m_mesh->Release(); - } -} - - -dgCollisionCompoundFractured::dgVertexBuffer::dgVertexBuffer(dgInt32 vertsCount, dgMemoryAllocator* allocator) - :m_allocator(allocator) - ,m_vertexCount(vertsCount) -{ - m_uv = (dgFloat32 *) m_allocator->Malloc (2 * vertsCount * dgInt32 (sizeof (dgFloat32))); - m_vertex = (dgFloat32 *) m_allocator->Malloc (3 * vertsCount * dgInt32 (sizeof (dgFloat32))); - m_normal = (dgFloat32 *) m_allocator->Malloc (3 * vertsCount * dgInt32 (sizeof (dgFloat32))); -} - -dgCollisionCompoundFractured::dgVertexBuffer::~dgVertexBuffer () -{ - m_allocator->Free (m_normal); - m_allocator->Free (m_vertex); - m_allocator->Free (m_uv); -} - -dgCollisionCompoundFractured::dgVertexBuffer::dgVertexBuffer (dgMemoryAllocator* const allocator, dgDeserialize callback, void* const userData) -{ - m_allocator = allocator; - callback (userData, &m_vertexCount, dgInt32 (sizeof (dgInt32))); - - m_uv = (dgFloat32 *) m_allocator->Malloc (2 * m_vertexCount * dgInt32 (sizeof (dgFloat32))); - m_vertex = (dgFloat32 *) m_allocator->Malloc (3 * m_vertexCount * dgInt32 (sizeof (dgFloat32))); - m_normal = (dgFloat32 *) m_allocator->Malloc (3 * m_vertexCount * dgInt32 (sizeof (dgFloat32))); - - callback (userData, m_vertex, size_t (3 * m_vertexCount * dgInt32 (sizeof (dgFloat32)))); - callback (userData, m_normal, size_t (3 * m_vertexCount * dgInt32 (sizeof (dgFloat32)))); - callback (userData, m_uv, size_t (2 * m_vertexCount * dgInt32 (sizeof (dgFloat32)))); -} - -void dgCollisionCompoundFractured::dgVertexBuffer::Serialize(dgSerialize callback, void* const userData) const -{ - callback (userData, &m_vertexCount, dgInt32 (sizeof (dgInt32))); - callback (userData, m_vertex, size_t (3 * m_vertexCount * dgInt32 (sizeof (dgFloat32)))); - callback (userData, m_normal, size_t (3 * m_vertexCount * dgInt32 (sizeof (dgFloat32)))); - callback (userData, m_uv, size_t (2 * m_vertexCount * dgInt32 (sizeof (dgFloat32)))); -} - - -dgCollisionCompoundFractured::dgSubMesh::dgSubMesh (dgMemoryAllocator* const allocator) - :m_indexes(NULL) - ,m_allocator(allocator) - ,m_material(0) - ,m_faceCount(0) - ,m_materialOrdinal(0) - ,m_visibleFaces(true) -{ -} - -dgCollisionCompoundFractured::dgSubMesh::~dgSubMesh () -{ - if (m_indexes) { - m_allocator->Free (m_indexes); - } -} - -void dgCollisionCompoundFractured::dgSubMesh::Serialize(dgSerialize callback, void* const userData) const -{ - dgInt32 visible = m_visibleFaces ? 1 : 0; - callback (userData, &m_material, dgInt32 (sizeof (dgInt32))); - callback (userData, &m_materialOrdinal, dgInt32 (sizeof (dgInt32))); - callback (userData, &m_faceCount, dgInt32 (sizeof (dgInt32))); - callback (userData, &visible, dgInt32 (sizeof (dgInt32))); - callback (userData, m_indexes, size_t (3 * m_faceCount * dgInt32 (sizeof (dgInt32)))); -} - -dgCollisionCompoundFractured::dgSharedNodeMesh::dgSharedNodeMesh () -{ -} - -dgCollisionCompoundFractured::dgSharedNodeMesh::~dgSharedNodeMesh () -{ -} - - -dgCollisionCompoundFractured::dgMesh::dgMesh(dgMemoryAllocator* const allocator) - :dgList<dgSubMesh>(allocator) - ,m_vertexOffsetStart(0) - ,m_vertexCount(0) - ,m_isVisible(false) -{ -} - -dgCollisionCompoundFractured::dgMesh::~dgMesh() -{ -} - -dgCollisionCompoundFractured::dgMesh::dgMesh (dgMemoryAllocator* const allocator, dgDeserialize callback, void* const userData) - :dgList<dgSubMesh>(allocator), dgRefCounter () -{ - dgInt32 count; - dgInt32 isVisible; - callback (userData, &m_vertexOffsetStart, dgInt32 (sizeof (m_vertexOffsetStart))); - callback (userData, &m_vertexCount, dgInt32 (sizeof (m_vertexCount))); - callback (userData, &isVisible, dgInt32 (sizeof (m_vertexCount))); - callback (userData, &count, dgInt32 (sizeof (dgInt32))); - m_isVisible = isVisible ? true : false; - - for (dgInt32 i = 0; i < count; i ++) { - dgInt32 visible; - dgInt32 material; - dgInt32 faceCount; - dgInt32 materialOrdinal; - - callback (userData, &material, dgInt32 (sizeof (dgInt32))); - callback (userData, &materialOrdinal, dgInt32 (sizeof (dgInt32))); - callback (userData, &faceCount, dgInt32 (sizeof (dgInt32))); - callback (userData, &visible, dgInt32 (sizeof (dgInt32))); - - dgSubMesh* const subMesh = AddgSubMesh (faceCount * 3, material); - subMesh->m_faceCount = faceCount; - subMesh->m_material = material; - subMesh->m_materialOrdinal = materialOrdinal; - subMesh->m_visibleFaces = visible ? true : false; - callback (userData, subMesh->m_indexes, size_t (3 * faceCount * dgInt32 (sizeof (dgInt32)))); - } -} - -void dgCollisionCompoundFractured::dgMesh::Serialize(dgSerialize callback, void* const userData) const -{ - dgInt32 count = GetCount(); - dgInt32 visible = m_isVisible ? 1 : 0; - - callback (userData, &m_vertexOffsetStart, dgInt32 (sizeof (m_vertexOffsetStart))); - callback (userData, &m_vertexCount, dgInt32 (sizeof (m_vertexCount))); - callback (userData, &visible, dgInt32 (sizeof (m_vertexCount))); - callback (userData, &count, dgInt32 (sizeof (dgInt32))); - for (dgListNode* node = GetFirst(); node; node = node->GetNext()) { - dgSubMesh& subMesh = node->GetInfo(); - subMesh.Serialize(callback, userData); - } -} - -dgCollisionCompoundFractured::dgSubMesh* dgCollisionCompoundFractured::dgMesh::AddgSubMesh(dgInt32 indexCount, dgInt32 material) -{ - dgSubMesh tmp (GetAllocator()); - dgSubMesh& subMesh = Append(tmp)->GetInfo(); - - subMesh.m_visibleFaces = true; - - subMesh.m_material = material; - subMesh.m_faceCount = indexCount / 3; - - subMesh.m_indexes = (dgInt32 *) subMesh.m_allocator->Malloc (indexCount * dgInt32 (sizeof (dgInt32))); - return &subMesh; -} - - - dgCollisionCompoundFractured::dgConectivityGraph::dgListNode* dgCollisionCompoundFractured::dgConectivityGraph::AddNode (dgFlatVertexArray& vertexArray, dgMeshEffect* const factureVisualMesh, dgTreeArray::dgTreeNode* const collisionNode, dgInt32 interiorMaterialBase) -{ - dgListNode* const node = dgGraph<dgDebriNodeInfo, dgSharedNodeMesh>::AddNode (); - dgDebriNodeInfo& data = node->GetInfo().m_nodeData; - - data.m_mesh = new (GetAllocator()) dgMesh(GetAllocator()); - data.m_shapeNode = collisionNode; - - dgInt32 vertexCount = factureVisualMesh->GetPropertiesCount(); - - dgStack<dgVector>vertex (vertexCount); - dgStack<dgVector>normal (vertexCount); - dgStack<dgVector>uv0 (vertexCount); - dgStack<dgVector>uv1 (vertexCount); - dgAssert (0); -// factureVisualMesh->GetVertexStreams (sizeof (dgVector), &vertex[0].m_x, sizeof (dgVector), &normal[0].m_x, sizeof (dgVector), &uv0[0].m_x, sizeof (dgVector), &uv1[0].m_x); - - // extract the materials index array for mesh - dgInt32 baseVertexCount = vertexArray.m_count; - data.m_mesh->m_vertexOffsetStart = baseVertexCount; - - vertexArray[baseVertexCount + vertexCount].m_point[0] = 0.0f; - for (dgInt32 i = 0; i < vertexCount; i ++) { - dgInt32 j = baseVertexCount + i; - vertexArray[j].m_point[0] = vertex[i].m_x; - vertexArray[j].m_point[1] = vertex[i].m_y; - vertexArray[j].m_point[2] = vertex[i].m_z; - vertexArray[j].m_point[3] = normal[i].m_x; - vertexArray[j].m_point[4] = normal[i].m_y; - vertexArray[j].m_point[5] = normal[i].m_z; - vertexArray[j].m_point[6] = uv0[i].m_x; - vertexArray[j].m_point[7] = uv0[i].m_y; - vertexArray[j].m_point[8] = uv1[i].m_x; - vertexArray[j].m_point[9] = uv1[i].m_y; - } - - - dgStack<dgInt32> indexBuffer (vertexCount); - data.m_mesh->m_vertexCount = dgVertexListToIndexList (&vertexArray[baseVertexCount].m_point[0], sizeof (dgFlatVertex), sizeof (dgFlatVertex), 0, vertexCount, &indexBuffer[0], dgFloat32 (1.0e-6f)); - vertexArray.m_count += data.m_mesh->m_vertexCount; - - dgMeshEffect::dgIndexArray* const geometryHandle = factureVisualMesh->MaterialGeometryBegin(); - for (dgInt32 handle = factureVisualMesh->GetFirstMaterial (geometryHandle); handle != -1; handle = factureVisualMesh->GetNextMaterial (geometryHandle, handle)) { - dgInt32 material = factureVisualMesh->GetMaterialID (geometryHandle, handle); - - bool isVisible = (material < interiorMaterialBase) ? true : false; - data.m_mesh->m_isVisible |= isVisible; - - dgInt32 indexCount = factureVisualMesh->GetMaterialIndexCount (geometryHandle, handle); - dgSubMesh* const segment = data.m_mesh->AddgSubMesh(indexCount, isVisible ? material : material - interiorMaterialBase); - - segment->m_visibleFaces = isVisible; - - factureVisualMesh->GetMaterialGetIndexStream (geometryHandle, handle, segment->m_indexes); - - for (dgInt32 i = 0; i < indexCount; i++) { - dgInt32 j = segment->m_indexes[i]; - segment->m_indexes[i] = indexBuffer[j]; - } - } - factureVisualMesh->MaterialGeomteryEnd(geometryHandle); - return node; -} - - -dgCollisionCompoundFractured::dgCollisionCompoundFractured (const dgCollisionCompoundFractured& source, const dgCollisionInstance* const myInstance) - :dgCollisionCompound(source, myInstance) - ,m_conectivity(source.m_conectivity) - ,m_conectivityMap (source.m_conectivityMap) - ,m_vertexBuffer(source.m_vertexBuffer) - ,m_impulseStrengthPerUnitMass(source.m_impulseStrengthPerUnitMass) - ,m_impulseAbsortionFactor(source.m_impulseAbsortionFactor) - ,m_density(dgFloat32 (-1.0f)) - ,m_lru(0) - ,m_materialCount(source.m_materialCount) - ,m_emitFracturedChunk(source.m_emitFracturedChunk) - ,m_emitFracturedCompound(source.m_emitFracturedCompound) - ,m_reconstructMainMesh(source.m_reconstructMainMesh) -{ - m_rtti |= dgCollisionCompoundBreakable_RTTI; - - m_vertexBuffer->AddRef(); - - dgTree<dgInt32, dgTreeArray::dgTreeNode*> nodeMap(m_allocator); - dgTreeArray::Iterator iter (source.m_array); - for (iter.Begin(); iter; iter ++) { - nodeMap.Insert(iter.GetKey(), iter.GetNode()); - } - - dgConectivityGraph::dgListNode* myNode = m_conectivity.GetFirst(); - for (dgConectivityGraph::dgListNode* node = source.m_conectivity.GetFirst(); node != source.m_conectivity.GetLast(); myNode = myNode->GetNext(), node = node->GetNext() ) { - dgDebriNodeInfo& nodeInfo = node->GetInfo().m_nodeData; - dgTreeArray::dgTreeNode* const nodeBase = nodeInfo.m_shapeNode; - - dgAssert (nodeMap.Find(nodeBase)); - dgInt32 index = nodeMap.Find(nodeBase)->GetInfo(); - - dgAssert (m_array.Find(index)); - dgDebriNodeInfo& myNodeInfo = myNode->GetInfo().m_nodeData; - myNodeInfo.m_shapeNode = m_array.Find(index); - } - - dgMesh* const mainMesh = new (m_world->GetAllocator()) dgMesh(m_world->GetAllocator()); - dgConectivityGraph::dgListNode* const mainNode = m_conectivity.dgGraph<dgDebriNodeInfo, dgSharedNodeMesh>::AddNode (); - dgDebriNodeInfo& mainNodeData = mainNode->GetInfo().m_nodeData; - mainNodeData.m_mesh = mainMesh; - - BuildMainMeshSubMehes(); - m_conectivityMap.Pupolate(m_conectivity); - - m_density = -dgFloat32 (1.0f) / GetVolume(); - dgAssert (SanityCheck()); -} - -dgCollisionCompoundFractured::dgCollisionCompoundFractured (dgCollisionCompoundFractured& source, const dgList<dgConectivityGraph::dgListNode*>& island) - :dgCollisionCompound(source.m_world, NULL) - ,m_conectivity(source.GetAllocator()) - ,m_conectivityMap (source.GetAllocator()) - ,m_vertexBuffer(source.m_vertexBuffer) - ,m_impulseStrengthPerUnitMass(source.m_impulseStrengthPerUnitMass) - ,m_impulseAbsortionFactor(source.m_impulseAbsortionFactor) - ,m_density(source.m_density) - ,m_lru(0) - ,m_materialCount(source.m_materialCount) - ,m_emitFracturedChunk(source.m_emitFracturedChunk) - ,m_emitFracturedCompound(source.m_emitFracturedCompound) - ,m_reconstructMainMesh(source.m_reconstructMainMesh) -{ - m_collisionId = m_compoundFracturedCollision; - m_rtti |= dgCollisionCompoundBreakable_RTTI; - - m_vertexBuffer->AddRef(); - - dgCollisionCompound::BeginAddRemove (); - for (dgList<dgConectivityGraph::dgListNode*>::dgListNode* node = island.GetFirst(); node; node = node->GetNext()) { - dgConectivityGraph::dgListNode* const chunkNode = node->GetInfo(); - dgDebriNodeInfo& nodeInfo = chunkNode->GetInfo().m_nodeData; - - dgCollisionInstance* const chunkCollision = nodeInfo.m_shapeNode->GetInfo()->GetShape(); - dgTreeArray::dgTreeNode* const treeNode = dgCollisionCompound::AddCollision (chunkCollision); - - source.m_conectivityMap.Remove (chunkCollision); - source.dgCollisionCompound::RemoveCollision (nodeInfo.m_shapeNode); - source.m_conectivity.Unlink(chunkNode); - - m_conectivity.Append(chunkNode); - nodeInfo.m_shapeNode = treeNode; - } - dgCollisionCompound::EndAddRemove(false); - - dgMesh* const mainMesh = new (m_world->GetAllocator()) dgMesh(m_world->GetAllocator()); - dgConectivityGraph::dgListNode* const mainNode = m_conectivity.dgGraph<dgDebriNodeInfo, dgSharedNodeMesh>::AddNode (); - dgDebriNodeInfo& mainNodeData = mainNode->GetInfo().m_nodeData; - mainNodeData.m_mesh = mainMesh; - - BuildMainMeshSubMehes(); - m_conectivityMap.Pupolate(m_conectivity); - - m_density = -dgFloat32 (1.0f) / GetVolume(); - dgAssert (SanityCheck()); -} - -dgCollisionCompoundFractured::dgCollisionCompoundFractured (dgWorld* const world, dgDeserialize deserialization, void* const userData, const dgCollisionInstance* const myInstance, dgInt32 revisionNumber) - :dgCollisionCompound (world, deserialization, userData, myInstance, revisionNumber) - ,m_conectivity (world->GetAllocator()) - ,m_conectivityMap (world->GetAllocator()) -{ - m_conectivity.Deserialize(this, deserialization, userData); - m_vertexBuffer = new (m_world->GetAllocator()) dgVertexBuffer(m_world->GetAllocator(), deserialization, userData); - - deserialization (userData, &m_impulseStrengthPerUnitMass, sizeof (m_impulseStrengthPerUnitMass)); - deserialization (userData, &m_impulseAbsortionFactor, sizeof (m_impulseAbsortionFactor)); - deserialization (userData, &m_density, sizeof (m_density)); - deserialization (userData, &m_materialCount, sizeof (m_materialCount)); -} - - -dgCollisionCompoundFractured::dgCollisionCompoundFractured ( - dgWorld* const world, dgMeshEffect* const solidMesh, int fracturePhysicsMaterialID, int pointcloudCount, const dgFloat32* const vertexCloud, int strideInBytes, int materialID, const dgMatrix& offsetMatrix, - OnEmitFractureChunkCallBack emitFracturedChunk, OnEmitNewCompundFractureCallBack emitNewCompoundFactured, OnReconstructFractureMainMeshCallBack reconstructMainMesh) - :dgCollisionCompound (world) - ,m_conectivity(world->GetAllocator()) - ,m_conectivityMap (world->GetAllocator()) - ,m_vertexBuffer(NULL) - ,m_impulseStrengthPerUnitMass(10.0f) - ,m_impulseAbsortionFactor(0.5f) - ,m_density(dgFloat32 (-1.0f)) - ,m_lru(0) - ,m_materialCount(0) - ,m_emitFracturedChunk(emitFracturedChunk) - ,m_emitFracturedCompound(emitNewCompoundFactured) - ,m_reconstructMainMesh(reconstructMainMesh) -{ - m_collisionId = m_compoundFracturedCollision; - m_rtti |= dgCollisionCompoundBreakable_RTTI; - - dgInt32 interiorMaterialBase = 1000; - dgFractureBuilder fractureBuilder (GetAllocator(), solidMesh, pointcloudCount, vertexCloud, strideInBytes, materialID + interiorMaterialBase, offsetMatrix); - - dgFlatVertexArray vertexArray(m_world->GetAllocator()); - dgTree<dgConectivityGraph::dgListNode*, dgInt32> conectinyMap(GetAllocator()); - - dgCollisionCompound::BeginAddRemove (); - for (dgFractureBuilder::dgFractureConectivity::dgListNode* node = fractureBuilder.m_conectivity.GetFirst(); node; node = node->GetNext()) { - dgInt32 index = node->GetInfo().m_nodeData; - dgFractureBuilder::dgTreeNode* const fractureNode = fractureBuilder.Find(index); - dgAssert (fractureNode); - dgMeshEffect* const fractureSubMesh = fractureNode->GetInfo(); - dgCollisionInstance* const collisionInstance = fractureSubMesh->CreateConvexCollision(world, dgFloat32 (1.0e-5f), fracturePhysicsMaterialID); - dgTreeArray::dgTreeNode* const shapeNode = AddCollision (collisionInstance); - dgConectivityGraph::dgListNode* const conectivityNode = m_conectivity.AddNode(vertexArray, fractureSubMesh, shapeNode, interiorMaterialBase); - conectinyMap.Insert(conectivityNode, index); - collisionInstance->Release(); - } - dgCollisionCompound::EndAddRemove (); - - for (dgFractureBuilder::dgFractureConectivity::dgListNode* node = fractureBuilder.m_conectivity.GetFirst(); node; node = node->GetNext()) { - dgInt32 index0 = node->GetInfo().m_nodeData; - dgConectivityGraph::dgListNode* const conectivityNode0 = conectinyMap.Find(index0)->GetInfo(); - for (dgGraphNode<int, int>::dgListNode* edge = node->GetInfo().GetFirst(); edge; edge = edge->GetNext()) { - dgFractureBuilder::dgFractureConectivity::dgListNode* const otherNode = edge->GetInfo().m_node; - dgInt32 index1 = otherNode->GetInfo().m_nodeData; - dgConectivityGraph::dgListNode* const conectivityNode1 = conectinyMap.Find(index1)->GetInfo(); - dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* const edgeNode = conectivityNode0->GetInfo().AddEdge(conectivityNode1); - - dgDebriNodeInfo& nodeInfo0 = conectivityNode0->GetInfo().m_nodeData; - dgDebriNodeInfo& nodeInfo1 = conectivityNode1->GetInfo().m_nodeData; - dgCollisionInstance* const chunkCollision0 = nodeInfo0.m_shapeNode->GetInfo()->GetShape(); - dgCollisionInstance* const chunkCollision1 = nodeInfo1.m_shapeNode->GetInfo()->GetShape(); - - dgMatrix inertia0 (chunkCollision0->CalculateInertia()); - dgMatrix inertia1 (chunkCollision1->CalculateInertia()); - dgVector normal (inertia1.m_posit - inertia0.m_posit); - normal = normal.Normalize(); - edgeNode->GetInfo().m_edgeData.m_normal = normal; - } - } - - m_vertexBuffer = new (m_world->GetAllocator()) dgVertexBuffer(vertexArray.m_count, m_world->GetAllocator()); - for (dgInt32 i = 0; i < vertexArray.m_count; i ++) { - m_vertexBuffer->m_vertex[i * 3 + 0] = vertexArray[i].m_point[0]; - m_vertexBuffer->m_vertex[i * 3 + 1] = vertexArray[i].m_point[1]; - m_vertexBuffer->m_vertex[i * 3 + 2] = vertexArray[i].m_point[2]; - m_vertexBuffer->m_normal[i * 3 + 0] = vertexArray[i].m_point[3]; - m_vertexBuffer->m_normal[i * 3 + 1] = vertexArray[i].m_point[4]; - m_vertexBuffer->m_normal[i * 3 + 2] = vertexArray[i].m_point[5]; - m_vertexBuffer->m_uv[i * 2 + 0] = vertexArray[i].m_point[6]; - m_vertexBuffer->m_uv[i * 2 + 1] = vertexArray[i].m_point[7]; - } - - dgTree<dgInt32, dgInt32> materailOrdinalMap(GetAllocator()); - for (dgConectivityGraph::dgListNode* node = m_conectivity.GetFirst(); node; node = node->GetNext()) { - dgDebriNodeInfo& data = node->GetInfo().m_nodeData; - for (dgMesh::dgListNode* meshSegment = data.m_mesh->GetFirst(); meshSegment; meshSegment = meshSegment->GetNext()) { - dgSubMesh* const subMesh = &meshSegment->GetInfo(); - dgTree<dgInt32, dgInt32>::dgTreeNode* node1 = materailOrdinalMap.Find(subMesh->m_material); - if (!node1) { - node1 = materailOrdinalMap.Insert(m_materialCount, subMesh->m_material); - m_materialCount ++; - dgAssert (m_materialCount < DG_FRACTURE_MAX_METERIAL_COUNT); - } - - dgInt32 materialIndex = node1->GetInfo(); - subMesh->m_materialOrdinal = materialIndex; - } - } - - dgMesh* const mainMesh = new (m_world->GetAllocator()) dgMesh(m_world->GetAllocator()); - dgConectivityGraph::dgListNode* const mainNode = m_conectivity.dgGraph<dgDebriNodeInfo, dgSharedNodeMesh>::AddNode (); - dgDebriNodeInfo& mainNodeData = mainNode->GetInfo().m_nodeData; - mainNodeData.m_mesh = mainMesh; - - BuildMainMeshSubMehes(); - m_conectivityMap.Pupolate(m_conectivity); - m_density = -dgFloat32 (1.0f) / GetVolume(); - - dgAssert (SanityCheck()); -} - -dgCollisionCompoundFractured::~dgCollisionCompoundFractured(void) -{ - if (m_vertexBuffer) { - m_vertexBuffer->Release(); - } -} - -void dgCollisionCompoundFractured::Serialize(dgSerialize callback, void* const userData) const -{ - dgCollisionCompound::Serialize(callback, userData); - m_conectivity.Serialize(callback, userData); - m_vertexBuffer->Serialize(callback, userData); - - callback (userData, &m_impulseStrengthPerUnitMass, sizeof (m_impulseStrengthPerUnitMass)); - callback (userData, &m_impulseAbsortionFactor, sizeof (m_impulseAbsortionFactor)); - callback (userData, &m_density, sizeof (m_density)); - callback (userData, &m_materialCount, sizeof (m_materialCount)); -} - -void dgCollisionCompoundFractured::SetCallbacks(OnEmitFractureChunkCallBack emitFracturedChunk, OnEmitNewCompundFractureCallBack emitNewCompoundFactured, OnReconstructFractureMainMeshCallBack reconstructMainMesh) -{ - m_emitFracturedChunk = emitFracturedChunk; - m_reconstructMainMesh = reconstructMainMesh; - m_emitFracturedCompound = emitNewCompoundFactured; -} - -void dgCollisionCompoundFractured::BuildMainMeshSubMehes() const -{ - dgConectivityGraph::dgListNode* const mainNode = m_conectivity.GetLast(); - dgMesh* const mainMesh = mainNode->GetInfo().m_nodeData.m_mesh; - - mainMesh->RemoveAll(); - - dgAssert (mainMesh->m_vertexOffsetStart == 0); - mainMesh->m_vertexCount = m_vertexBuffer->m_vertexCount; - - dgInt32 histogram[DG_FRACTURE_MAX_METERIAL_COUNT]; - dgInt32 materials[DG_FRACTURE_MAX_METERIAL_COUNT]; - memset (histogram, 0, m_materialCount * sizeof (dgInt32)); - - for (dgConectivityGraph::dgListNode* node = m_conectivity.GetFirst(); node != mainNode; node = node->GetNext() ) { - dgDebriNodeInfo& data = node->GetInfo().m_nodeData; - for (dgMesh::dgListNode* meshSegment = data.m_mesh->GetFirst(); meshSegment; meshSegment = meshSegment->GetNext()) { - dgSubMesh* const subMesh = &meshSegment->GetInfo(); - if (subMesh->m_visibleFaces) { - dgInt32 index = subMesh->m_materialOrdinal; - histogram[index] += subMesh->m_faceCount; - materials[index] = subMesh->m_material; - } - } - } - - dgSubMesh* mainSubMeshes[DG_FRACTURE_MAX_METERIAL_COUNT]; - for (dgInt32 i = 0; i < m_materialCount; i ++) { - if (histogram[i]) { - mainSubMeshes[i] = mainMesh->AddgSubMesh (histogram[i] * 3, materials[i]); - } - } - - dgInt32 faceIndexIndexOffset[DG_FRACTURE_MAX_METERIAL_COUNT]; - memset (faceIndexIndexOffset, 0, m_materialCount * sizeof (dgInt32)); - - for (dgConectivityGraph::dgListNode* node = m_conectivity.GetFirst(); node != mainNode; node = node->GetNext() ) { - dgDebriNodeInfo& data = node->GetInfo().m_nodeData; - const dgInt32 vertexOffsetStart = data.m_mesh->m_vertexOffsetStart; - for (dgMesh::dgListNode* meshSegment = data.m_mesh->GetFirst(); meshSegment; meshSegment = meshSegment->GetNext()) { - dgSubMesh* const subMesh = &meshSegment->GetInfo(); - if (subMesh->m_visibleFaces) { - dgInt32 index = subMesh->m_materialOrdinal; - dgInt32 base = faceIndexIndexOffset[index]; - dgSubMesh* const mainSubMesh = mainSubMeshes[index]; - const dgInt32 count = 3 * subMesh->m_faceCount; - for (dgInt32 i = 0; i < count; i ++) { - mainSubMesh->m_indexes[base + i] = subMesh->m_indexes[i] + vertexOffsetStart; - } - faceIndexIndexOffset[index] += count; - dgAssert (faceIndexIndexOffset[index] <= histogram[index] * 3); - } - } - } -} - -bool dgCollisionCompoundFractured::SanityCheck() const -{ - for (dgConectivityGraph::dgListNode* rootNode = m_conectivity.GetFirst(); rootNode; rootNode = rootNode->GetNext() ) { - dgTree<dgConectivityGraph::dgListNode*, dgConectivityGraph::dgListNode*> filter(GetAllocator()); - for (dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* edgeNode = rootNode->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - dgConectivityGraph::dgListNode* const node = edgeNode->GetInfo().m_node; - dgAssert (!filter.Find(node)); - filter.Insert(node, node); - } - } - - return true; -} - - -dgCollisionCompoundFractured::dgConectivityGraph::dgListNode* dgCollisionCompoundFractured::GetMainMesh() const -{ - return m_conectivity.GetLast(); -} - -dgCollisionCompoundFractured::dgConectivityGraph::dgListNode* dgCollisionCompoundFractured::GetFirstMesh() const -{ - return m_conectivity.GetFirst(); -} - -dgCollisionCompoundFractured::dgConectivityGraph::dgListNode* dgCollisionCompoundFractured::GetNextMesh (dgConectivityGraph::dgListNode* const mesNodeh) const -{ - return (mesNodeh->GetNext() != m_conectivity.GetLast()) ? mesNodeh->GetNext() : NULL; -} - -dgInt32 dgCollisionCompoundFractured::GetVertecCount(dgConectivityGraph::dgListNode* const node) const -{ - dgMesh* const mesh = node->GetInfo().m_nodeData.m_mesh; - return mesh->m_vertexCount; -} - -const dgFloat32* dgCollisionCompoundFractured::GetVertexPositions (dgConectivityGraph::dgListNode* const node) const -{ - dgMesh* const mesh = node->GetInfo().m_nodeData.m_mesh; - return m_vertexBuffer->GetVertexPositions() + mesh->m_vertexOffsetStart * 3; -} - - -const dgFloat32* dgCollisionCompoundFractured::GetVertexNormal (dgConectivityGraph::dgListNode* const node) const -{ - dgMesh* const mesh = node->GetInfo().m_nodeData.m_mesh; - return m_vertexBuffer->GetVertexNormals() + mesh->m_vertexOffsetStart * 3; -} - - -const dgFloat32* dgCollisionCompoundFractured::GetVertexUVs (dgConectivityGraph::dgListNode* const node) const -{ - dgMesh* const mesh = node->GetInfo().m_nodeData.m_mesh; - return m_vertexBuffer->GetVertexUVs() + mesh->m_vertexOffsetStart * 2; -} - -dgInt32 dgCollisionCompoundFractured::GetSegmentIndexStream (dgConectivityGraph::dgListNode* const node___, dgMesh::dgListNode* const subMeshNode, dgInt32* const index) const -{ - dgSubMesh* const subMesh = &subMeshNode->GetInfo(); - const dgInt32* const indexes = subMesh->m_indexes; - memcpy (index, indexes, 3 * subMesh->m_faceCount * sizeof(dgInt32)); - return subMesh->m_faceCount * 3; -} - - -void dgCollisionCompoundFractured::SetImpulseStrength(dgFloat32 impulseStrength) -{ - m_impulseStrengthPerUnitMass = dgMax (impulseStrength, dgFloat32 (0.0f), impulseStrength) ; -} - -dgFloat32 dgCollisionCompoundFractured::GetImpulseStrength() const -{ - return m_impulseStrengthPerUnitMass; -} - -void dgCollisionCompoundFractured::SetImpulsePropgationFactor(dgFloat32 factor) -{ - m_impulseAbsortionFactor = dgClamp(factor, dgFloat32 (0.0f), dgFloat32 (1.0f)); -} - -dgFloat32 dgCollisionCompoundFractured::GetSetImpulsePropgationFactor() const -{ - return m_impulseAbsortionFactor; -} - - - -dgVector dgCollisionCompoundFractured::GetObbSize() const -{ - return dgCollisionCompound::GetObbSize() + (dgVector (DG_FRACTURE_AABB_GUARD_DISTANCE) & dgVector::m_triplexMask); -} - - -void dgCollisionCompoundFractured::CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const -{ - dgCollisionCompound::CalcAABB (matrix, p0, p1); - p0 -= (dgVector (DG_FRACTURE_AABB_GUARD_DISTANCE) & dgVector::m_triplexMask); - p1 += (dgVector (DG_FRACTURE_AABB_GUARD_DISTANCE) & dgVector::m_triplexMask); -} - - -dgInt32 dgCollisionCompoundFractured::CalculateContacts (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - dgAssert (0); - return 0; -/* - dgBroadPhase* const broaphaPhase = m_world->GetBroadPhase(); - dgInt32 count = dgCollisionCompound::CalculateContacts (pair, proxy); - - if (!count && broaphaPhase->m_recursiveChunks && m_emitFracturedChunk && m_root) { - dgContact* const constraint = pair->m_contact; - dgBody* const myBody = constraint->GetBody0(); - dgBody* const otherBody = constraint->GetBody1(); - dgVector relVeloc (otherBody->GetVelocity() - myBody->GetVelocity()); - dgAssert (relVeloc.m_w == dgFloat32 (0.0f)); - dgVector impulseStimate (relVeloc.Scale (dgFloat32 (1.0f) / (myBody->GetInvMass().m_w + otherBody->GetInvMass().m_w))); - dgFloat32 impulseStimate2 = impulseStimate.DotProduct(impulseStimate).m_w; - dgFloat32 impulseStrength = m_impulseStrengthPerUnitMass * myBody->GetMass().m_w; - - if (impulseStimate2 > (impulseStrength * impulseStrength)) { - dgCollisionInstance* const myInstance = myBody->GetCollision(); - dgCollisionInstance* const otherInstance = otherBody->GetCollision(); - dgAssert (myInstance->GetChildShape() == this); - dgContactPoint contactOut; - dgAssert (0); -// dgFloat32 dist = ConvexRayCast (otherInstance, otherInstance->GetGlobalMatrix(), relVeloc, proxy.m_timestep, contactOut, myBody, myInstance, NULL, proxy.m_threadIndex); - dgFloat32 dist = 0; - if (dist < proxy.m_timestep) { - dgAssert (m_conectivityMap.Find(contactOut.m_collision0)); - dgConectivityGraph::dgListNode* const rootNode = m_conectivityMap.Find(contactOut.m_collision0)->GetInfo(); - dgDebriNodeInfo& nodeInfo = rootNode->GetInfo().m_nodeData; - nodeInfo.m_lru = 1; - dgCollisionCompoundFractured* const me = (dgCollisionCompoundFractured*)this; - - m_world->GlobalLock(true); - if (me->SpawnChunks (myBody, myInstance, rootNode, impulseStimate2, impulseStrength * impulseStrength)) { - me->SpawnDisjointChunks (myBody, myInstance, rootNode, impulseStimate2, impulseStrength * impulseStrength); - - BuildMainMeshSubMehes(); - m_reconstructMainMesh (myBody, m_conectivity.GetLast(), myInstance); - if (m_root) { - me->MassProperties (); - dgFloat32 mass = m_centerOfMass.m_w * m_density; - myBody->SetMassProperties(mass, myInstance); - } else { - myBody->SetMassProperties(dgFloat32 (0.0f), myInstance); - } - } - m_world->GlobalUnlock(); - } - } - } - return count; -*/ -} - -void dgCollisionCompoundFractured::BeginAddRemove () -{ - dgCollisionCompound::BeginAddRemove (); -} - -void dgCollisionCompoundFractured::EndAddRemove (bool flushCache) -{ - dgCollisionCompound::EndAddRemove (flushCache); - BuildMainMeshSubMehes(); -} - -void dgCollisionCompoundFractured::RemoveCollision (dgTreeArray::dgTreeNode* const node) -{ - dgConectivityGraphMap::dgTreeNode* const mapNode = m_conectivityMap.Find(node->GetInfo()->GetShape()); - dgAssert (mapNode); - - dgConectivityGraph::dgListNode* const chunkNode = mapNode->GetInfo(); - - for (dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* edgeNode = chunkNode->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - dgConectivityGraph::dgListNode* const node1 = edgeNode->GetInfo().m_node; - dgDebriNodeInfo& childNodeInfo = node1->GetInfo().m_nodeData; - childNodeInfo.m_mesh->m_isVisible = true; - for (dgMesh::dgListNode* meshSegment = childNodeInfo.m_mesh->GetFirst(); meshSegment; meshSegment = meshSegment->GetNext()) { - dgSubMesh* const subMesh = &meshSegment->GetInfo(); - subMesh->m_visibleFaces = true; - } - } - - dgDebriNodeInfo& nodeInfo = chunkNode->GetInfo().m_nodeData; - dgCollisionInstance* const chunkCollision = nodeInfo.m_shapeNode->GetInfo()->GetShape(); - - m_conectivityMap.Remove (chunkCollision); - m_conectivity.DeleteNode(chunkNode); - dgCollisionCompound::RemoveCollision (node); -} - -bool dgCollisionCompoundFractured::IsNodeSaseToDetach(dgTreeArray::dgTreeNode* const node) const -{ - dgConectivityGraphMap::dgTreeNode* const mapNode = m_conectivityMap.Find(node->GetInfo()->GetShape()); - dgAssert (mapNode); - return mapNode ? CanChunk (mapNode->GetInfo()) : false; -} - -int dgCollisionCompoundFractured::GetFirstNiegborghArray (dgTreeArray::dgTreeNode* const node, dgTreeArray::dgTreeNode** const nodesArray, int maxCount) const -{ - int count = 0; - dgConectivityGraphMap::dgTreeNode* const mapNode = m_conectivityMap.Find(node->GetInfo()->GetShape()); - dgAssert (mapNode); - - dgConectivityGraph::dgListNode* const chunkNode = mapNode->GetInfo(); - for (dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* edgeNode = chunkNode->GetInfo().GetFirst(); edgeNode && (count < maxCount); edgeNode = edgeNode->GetNext()) { - dgConectivityGraph::dgListNode* const node1 = edgeNode->GetInfo().m_node; - dgDebriNodeInfo& childNodeInfo = node1->GetInfo().m_nodeData; - nodesArray[count] = childNodeInfo.m_shapeNode; - count ++; - } - - return count; -} - -bool dgCollisionCompoundFractured::CanChunk (dgConectivityGraph::dgListNode* const chunkNode) const -{ - dgVector directionsMap[32]; - dgInt32 count = 0; - for (dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* edgeNode = chunkNode->GetInfo().GetFirst(); edgeNode && (count < dgInt32 (sizeof (directionsMap)/sizeof (directionsMap[0]))); edgeNode = edgeNode->GetNext()) { - directionsMap[count] = edgeNode->GetInfo().m_edgeData.m_normal; - count ++; - } - - dgVector error (dgFloat32 (1.0e-3f)); - dgVector himespherePlane (directionsMap[0]); - for (dgInt32 i = 1; i < count; i ++) { - dgVector projection (himespherePlane.DotProduct(directionsMap[i])); - dgInt32 sign = (projection < error).GetSignMask(); - if (sign & 0x0f) { -// dgFloat32 val; -// projection.StoreScalar(&val); - dgFloat32 val = projection.GetScalar(); - dgAssert (val > dgFloat32 (-1.0f)); - dgFloat32 angle = dgAcos (val) - dgFloat32 (90.0f * dgDegreeToRad) + dgFloat32 (15.0f * dgDegreeToRad); - dgVector axis (himespherePlane.CrossProduct(directionsMap[i])); - axis = axis.Normalize(); - dgQuaternion rot (axis, angle); - himespherePlane = dgMatrix (rot, dgVector::m_wOne).RotateVector(himespherePlane); - - for (dgInt32 j = 0; j < i; j ++) { - dgVector projection1 (himespherePlane.DotProduct(directionsMap[j])); - dgInt32 sign1 = (projection1 < error).GetSignMask(); - if (sign1 & 0x0f) { - return false; - } - } - } - } - return true; -} - - - - -bool dgCollisionCompoundFractured::IsBelowPlane (dgConectivityGraph::dgListNode* const node, const dgVector& plane) const -{ - dgDebriNodeInfo& nodeInfo = node->GetInfo().m_nodeData; - dgCollisionInstance* const instance = nodeInfo.m_shapeNode->GetInfo()->GetShape(); - - dgVector dir (plane & dgVector::m_triplexMask); - - const dgMatrix& matrix = instance->GetLocalMatrix(); - dgVector support (matrix.TransformVector(instance->SupportVertex(matrix.UnrotateVector(dir)))); - - dgFloat32 dist = (support.DotProduct(plane)).GetScalar(); - return dist < dgFloat32 (0.0f); -} - -bool dgCollisionCompoundFractured::IsAbovePlane (dgConectivityGraph::dgListNode* const node, const dgVector& plane) const -{ - dgDebriNodeInfo& nodeInfo = node->GetInfo().m_nodeData; - dgCollisionInstance* const instance = nodeInfo.m_shapeNode->GetInfo()->GetShape(); - - dgVector dir (dgVector::m_negOne * (plane & dgVector::m_triplexMask)); - - const dgMatrix& matrix = instance->GetLocalMatrix(); - dgVector support (matrix.TransformVector(instance->SupportVertex(matrix.UnrotateVector(dir)))); - - dgFloat32 dist = (support.DotProduct(plane)).GetScalar(); - return dist > dgFloat32 (0.0f); -} - -dgCollisionCompoundFractured::dgConectivityGraph::dgListNode* dgCollisionCompoundFractured::FirstAcrossPlane (dgConectivityGraph::dgListNode* const nodeBelowPlane, const dgVector& plane) const -{ - dgDebriNodeInfo& nodeInfo = nodeBelowPlane->GetInfo().m_nodeData; - dgCollisionInstance* const instance = nodeInfo.m_shapeNode->GetInfo()->GetShape(); - - dgVector dir (plane & dgVector::m_triplexMask); - - const dgMatrix& matrix = instance->GetLocalMatrix(); - dgVector support (matrix.TransformVector(instance->SupportVertex(matrix.UnrotateVector(dir)))); - - dgFloat32 dist = (support.DotProduct(plane)).GetScalar(); - dgAssert (dist < dgFloat32 (0.0f)); - - dgConectivityGraph::dgListNode* startNode = nodeBelowPlane; - for (bool foundBetterNode = true; foundBetterNode; ) { - foundBetterNode = false; - for (dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* edgeNode = startNode->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - dgConectivityGraph::dgListNode* const node = edgeNode->GetInfo().m_node; - dgDebriNodeInfo& neighborgInfo = node->GetInfo().m_nodeData; - dgCollisionInstance* const instance1 = neighborgInfo.m_shapeNode->GetInfo()->GetShape(); - - const dgMatrix& matrix1 = instance1->GetLocalMatrix(); - dgVector support1 (matrix1.TransformVector(instance1->SupportVertex(matrix1.UnrotateVector(dir)))); - dgFloat32 dist1 = (support1.DotProduct(plane)).GetScalar(); - if (dist1 > dist) { - dist = dist1; - foundBetterNode = true; - startNode = node; - if (dist > dgFloat32 (0.0f)) { - foundBetterNode = false; - return startNode; - } - } - } - } - - return NULL; -} - -dgCollisionCompoundFractured* dgCollisionCompoundFractured::PlaneClip (const dgVector& plane) -{ - dgConectivityGraph::dgListNode* startNode = m_conectivity.GetFirst(); - if (IsAbovePlane (startNode, plane)) { - startNode = FirstAcrossPlane (startNode, plane * dgVector::m_negOne); - } else if (IsBelowPlane (startNode, plane)) { - startNode = FirstAcrossPlane (startNode, plane); - } - - if (startNode) { - dgVector posgDir (plane & dgVector::m_triplexMask); - dgVector negDir (posgDir * dgVector::m_negOne); - dgTree<dgConectivityGraph::dgListNode*, dgConectivityGraph::dgListNode*> upperSide (GetAllocator()); - - dgInt32 stack = 1; - dgConectivityGraph::dgListNode* pool[512]; - pool[0] = startNode; - m_lru += 2; - while (stack) { - stack --; - dgConectivityGraph::dgListNode* const planeNode = pool[stack]; - dgDebriNodeInfo& nodeInfo = planeNode->GetInfo().m_nodeData; - - if (nodeInfo.m_lru != m_lru) { - - nodeInfo.m_lru = m_lru; - - dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* nextEdge; - for (dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* edgeNode = planeNode->GetInfo().GetFirst(); edgeNode; edgeNode = nextEdge) { - nextEdge = edgeNode->GetNext(); - - dgConectivityGraph::dgListNode* const node = edgeNode->GetInfo().m_node; - dgDebriNodeInfo& neighborgInfo = node->GetInfo().m_nodeData; - if (neighborgInfo.m_lru != m_lru) { - dgCollisionInstance* const instance = neighborgInfo.m_shapeNode->GetInfo()->GetShape(); - const dgMatrix& matrix = instance->GetLocalMatrix(); - - dgVector support (matrix.TransformVector(instance->SupportVertex(matrix.UnrotateVector(negDir)))); - dgFloat32 dist = (support.DotProduct(plane)).GetScalar(); - if (dist > dgFloat32 (0.0f)) { - upperSide.Insert(node, node); - planeNode->GetInfo().DeleteEdge (edgeNode); - node->GetInfo().m_nodeData.m_mesh->m_isVisible = true; - planeNode->GetInfo().m_nodeData.m_mesh->m_isVisible = true; - - for (dgMesh::dgListNode* meshSegment = node->GetInfo().m_nodeData.m_mesh->GetFirst(); meshSegment; meshSegment = meshSegment->GetNext()) { - dgSubMesh* const subMesh = &meshSegment->GetInfo(); - subMesh->m_visibleFaces = true; - } - - for (dgMesh::dgListNode* meshSegment = planeNode->GetInfo().m_nodeData.m_mesh->GetFirst(); meshSegment; meshSegment = meshSegment->GetNext()) { - dgSubMesh* const subMesh = &meshSegment->GetInfo(); - subMesh->m_visibleFaces = true; - } - - - } else { - dgVector support1 (matrix.TransformVector(instance->SupportVertex(matrix.UnrotateVector(posgDir)))); - dgFloat32 dist1 = (support1.DotProduct(plane)).GetScalar(); - if (dist1 > dgFloat32 (0.0f)) { - pool[stack] = node; - stack ++; - dgAssert (stack < sizeof (pool) / sizeof (pool[0])); - } - } - } - } - } - } - } - - return NULL; -} - -bool dgCollisionCompoundFractured::SpawnChunks (dgBody* const myBody, const dgCollisionInstance* const myInstance, dgConectivityGraph::dgListNode* const rootNode, dgFloat32 impulseStimate2, dgFloat32 impulseStimateCut2) -{ - dgFloat32 strengthPool[512]; - dgConectivityGraph::dgListNode* pool[512]; - - dgVector massMatrix (myBody->GetMass()); - if (m_density < dgFloat32 (0.0f)) { - m_density = dgAbs (massMatrix.m_w * m_density); - } - - dgFloat32 attenuation = m_impulseAbsortionFactor; - m_lru ++; - pool[0] = rootNode; - strengthPool[0] = impulseStimate2; - - dgInt32 stack = 1; - bool spawned = false; - while (stack) { - stack --; - dgFloat32 strenght = strengthPool[stack] * attenuation; - dgConectivityGraph::dgListNode* const chunkNode = pool[stack]; - - if ((strenght > impulseStimateCut2) && CanChunk (chunkNode)) { - spawned = true; - dgDebriNodeInfo& nodeInfo = chunkNode->GetInfo().m_nodeData; - - nodeInfo.m_mesh->m_isVisible = true; - for (dgMesh::dgListNode* meshSegment = nodeInfo.m_mesh->GetFirst(); meshSegment; meshSegment = meshSegment->GetNext()) { - dgSubMesh* const subMesh = &meshSegment->GetInfo(); - subMesh->m_visibleFaces = true; - } - - for (dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* edgeNode = chunkNode->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - dgConectivityGraph::dgListNode* const node = edgeNode->GetInfo().m_node; - dgDebriNodeInfo& childNodeInfo = node->GetInfo().m_nodeData; - childNodeInfo.m_mesh->m_isVisible = true; - for (dgMesh::dgListNode* meshSegment = childNodeInfo.m_mesh->GetFirst(); meshSegment; meshSegment = meshSegment->GetNext()) { - dgSubMesh* const subMesh = &meshSegment->GetInfo(); - subMesh->m_visibleFaces = true; - } - } - - for (dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* edgeNode = chunkNode->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - dgConectivityGraph::dgListNode* const node = edgeNode->GetInfo().m_node; - dgDebriNodeInfo& childNodeInfo = node->GetInfo().m_nodeData; - if (childNodeInfo.m_lru != m_lru) { - childNodeInfo.m_lru = m_lru; - strengthPool[stack] = strenght; - pool[stack] = node; - stack ++; - dgAssert (stack < sizeof (pool)/sizeof (pool[0])); - } - } - SpawnSingleChunk (myBody, myInstance, chunkNode); - } - } - return spawned; -} - -void dgCollisionCompoundFractured::ColorDisjoinChunksIsland () -{ - dgInt32 stack = 1; - dgConectivityGraph::dgListNode* pool[512]; - - dgInt32 stackMark = m_lru + 1; - m_lru += 2; - pool[0] = m_conectivity.GetFirst(); - stack = 1; - while (stack) { - stack --; - dgConectivityGraph::dgListNode* const node = pool[stack]; - dgDebriNodeInfo& nodeInfo = node->GetInfo().m_nodeData; - if (nodeInfo.m_lru <= stackMark) { - nodeInfo.m_lru = m_lru; - for (dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* edgeNode = node->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - dgConectivityGraph::dgListNode* const node1 = edgeNode->GetInfo().m_node; - dgDebriNodeInfo& childNodeInfo1 = node1->GetInfo().m_nodeData; - if (childNodeInfo1.m_lru < stackMark) { - childNodeInfo1.m_lru = stackMark; - pool[stack] = node1; - stack ++; - dgAssert (stack < sizeof (pool)/sizeof (pool[0])); - } - } - } - } -} - -void dgCollisionCompoundFractured::SpawnDisjointChunks (dgBody* const myBody, const dgCollisionInstance* const myInstance, dgConectivityGraph::dgListNode* const rootNode, dgFloat32 impulseStimate2, dgFloat32 impulseStimateCut2) -{ - if (m_conectivity.GetFirst() != m_conectivity.GetLast()) { - ColorDisjoinChunksIsland (); - dgConectivityGraph::dgListNode* nextNode; - for (dgConectivityGraph::dgListNode* node = m_conectivity.GetFirst(); node != m_conectivity.GetLast(); node = nextNode) { - nextNode = node->GetNext(); - dgDebriNodeInfo& nodeInfo = node->GetInfo().m_nodeData; - if (nodeInfo.m_lru != m_lru) { - if (node->GetInfo().GetCount() == 0) { - SpawnSingleChunk (myBody, myInstance, node); - } else { - do { - nextNode = nextNode->GetPrev(); - } while (nextNode && (nextNode->GetInfo().m_nodeData.m_lru != m_lru)); - dgAssert (nextNode); - SpawnComplexChunk (myBody, myInstance, node); - } - } - } - } - -} - - -void dgCollisionCompoundFractured::SpawnSingleChunk (dgBody* const myBody, const dgCollisionInstance* const myInstance, dgConectivityGraph::dgListNode* const chunkNode) -{ - const dgMatrix& matrix = myBody->GetMatrix(); - const dgVector& veloc = myBody->GetVelocity(); - const dgVector& omega = myBody->GetOmega(); - dgVector com (matrix.TransformVector(myBody->GetCentreOfMass())); - - dgDebriNodeInfo& nodeInfo = chunkNode->GetInfo().m_nodeData; - dgCollisionInstance* const chunkCollision = nodeInfo.m_shapeNode->GetInfo()->GetShape(); - dgDynamicBody* const chunkBody = m_world->CreateDynamicBody (chunkCollision, matrix); - chunkBody->SetMassProperties(chunkCollision->GetVolume() * m_density, chunkBody->GetCollision()); - m_world->GetBroadPhase()->AddInternallyGeneratedBody(chunkBody); - - // calculate debris initial velocity - dgVector chunkOrigin (matrix.TransformVector(chunkCollision->GetLocalMatrix().m_posit)); - dgVector chunkVeloc (veloc + omega.CrossProduct(chunkOrigin - com)); - - chunkBody->SetOmega(omega); - chunkBody->SetVelocity(chunkVeloc); - chunkBody->SetGroupID(int (chunkCollision->GetUserDataID())); - - m_emitFracturedChunk(chunkBody, chunkNode, myInstance); - - m_conectivityMap.Remove (chunkCollision); - dgCollisionCompound::RemoveCollision (nodeInfo.m_shapeNode); - m_conectivity.DeleteNode(chunkNode); -} - -void dgCollisionCompoundFractured::SpawnComplexChunk (dgBody* const myBody, const dgCollisionInstance* const parentInstance, dgConectivityGraph::dgListNode* const chunkNode) -{ - dgInt32 stack = 1; - dgConectivityGraph::dgListNode* pool[512]; - - dgList<dgConectivityGraph::dgListNode*> islanList (GetAllocator()); - dgInt32 stackMark = m_lru - 1; - pool[0] = chunkNode; - stack = 1; - while (stack) { - stack --; - dgConectivityGraph::dgListNode* const node = pool[stack]; - dgDebriNodeInfo& nodeInfo = node->GetInfo().m_nodeData; - if (nodeInfo.m_lru <= stackMark) { - islanList.Append(node); - - nodeInfo.m_lru = m_lru; - for (dgGraphNode<dgDebriNodeInfo, dgSharedNodeMesh>::dgListNode* edgeNode = node->GetInfo().GetFirst(); edgeNode; edgeNode = edgeNode->GetNext()) { - dgConectivityGraph::dgListNode* const node1 = edgeNode->GetInfo().m_node; - dgDebriNodeInfo& childNodeInfo1 = node1->GetInfo().m_nodeData; - if (childNodeInfo1.m_lru < stackMark) { - childNodeInfo1.m_lru = stackMark; - pool[stack] = node1; - stack ++; - dgAssert (stack < sizeof (pool)/sizeof (pool[0])); - } - } - } - } - - const dgMatrix& matrix = myBody->GetMatrix(); - const dgVector& veloc = myBody->GetVelocity(); - const dgVector& omega = myBody->GetOmega(); - dgVector com (matrix.TransformVector(myBody->GetCentreOfMass())); - - dgCollisionCompoundFractured* const childStructureCollision = new (GetAllocator()) dgCollisionCompoundFractured (*this, islanList); - dgCollisionInstance* const childStructureInstance = m_world->CreateInstance (childStructureCollision, int (parentInstance->GetUserDataID()), parentInstance->GetLocalMatrix()); - childStructureCollision->m_myInstance = childStructureInstance; - childStructureCollision->Release(); - - dgDynamicBody* const chunkBody = m_world->CreateDynamicBody (childStructureInstance, matrix); - chunkBody->SetMassProperties(childStructureInstance->GetVolume() * m_density, chunkBody->GetCollision()); - m_world->GetBroadPhase()->AddInternallyGeneratedBody(chunkBody); - - // calculate debris initial velocity - dgVector chunkOrigin (matrix.TransformVector(childStructureInstance->GetLocalMatrix().m_posit)); - dgVector chunkVeloc (veloc + omega.CrossProduct(chunkOrigin - com)); - - chunkBody->SetOmega(omega); - chunkBody->SetVelocity(chunkVeloc); - chunkBody->SetGroupID(int (childStructureInstance->GetUserDataID())); - - m_emitFracturedCompound (chunkBody); - childStructureInstance->Release(); -} diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionCompoundFractured.h b/thirdparty/src/newton/dgPhysics/dgCollisionCompoundFractured.h deleted file mode 100644 index 2ec7fada1..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionCompoundFractured.h +++ /dev/null @@ -1,233 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 DG_COLLISION_COMPOUND_FRACTURED_H -#define DG_COLLISION_COMPOUND_FRACTURED_H - -#include "dgCollisionCompound.h" - - -class dgMeshEffect; - - - -class dgCollisionCompoundFractured: public dgCollisionCompound -{ - class dgFractureBuilder; - - public: - class dgFlatVertex - { - public: - dgFloat32 m_point[10]; // 3 point, 3 normal. 2 uv0, 2 uv1 - }; - - class dgFlatVertexArray: public dgArray<dgFlatVertex> - { - public: - dgFlatVertexArray(dgMemoryAllocator* const allocator) - :dgArray<dgFlatVertex> (allocator) - { - dgAssert(0); - m_count = 0; - } - - dgInt32 m_count; - }; - - class dgVertexBuffer: public dgRefCounter - { - public: - DG_CLASS_ALLOCATOR(allocator) - dgVertexBuffer (dgInt32 count, dgMemoryAllocator* allocator); - dgVertexBuffer (dgMemoryAllocator* const allocator, dgDeserialize deserialization, void* const userData); - ~dgVertexBuffer (); - - void Serialize(dgSerialize callback, void* const userData) const; - const dgFloat32* GetVertexPositions() const {return m_vertex;}; - const dgFloat32* GetVertexNormals() const {return m_normal;}; - const dgFloat32* GetVertexUVs() const {return m_uv;}; - - dgFloat32 *m_uv; - dgFloat32 *m_vertex; - dgFloat32 *m_normal; - dgMemoryAllocator* m_allocator; - dgInt32 m_vertexCount; - }; - - class dgSubMesh - { - public: - dgSubMesh (dgMemoryAllocator* const allocator); - ~dgSubMesh (); - void Serialize(dgSerialize callback, void* const userData) const; - - dgInt32 *m_indexes; - dgMemoryAllocator* m_allocator; - dgInt32 m_material; - dgInt32 m_faceCount; - dgInt32 m_materialOrdinal; - bool m_visibleFaces; - }; - - class dgMesh: public dgList<dgSubMesh>, public dgRefCounter - { - public: - dgMesh(dgMemoryAllocator* const allocator); - dgMesh (dgMemoryAllocator* const allocator, dgDeserialize deserialization, void* const userData); - ~dgMesh(); - void Serialize (dgSerialize callback, void* const userData) const; - dgSubMesh* AddgSubMesh (dgInt32 indexCount, dgInt32 material); - - dgInt32 m_vertexOffsetStart; - dgInt32 m_vertexCount; - bool m_isVisible; - }; - - class dgDebriNodeInfo - { - public: - dgDebriNodeInfo (); - ~dgDebriNodeInfo (); - - dgMesh* m_mesh; - dgTreeArray::dgTreeNode* m_shapeNode; - dgInt32 m_lru; - }; - - - class dgSharedNodeMesh - { - public: - dgSharedNodeMesh (); - ~dgSharedNodeMesh (); - dgVector m_normal; - }; - - class dgConectivityGraph: public dgGraph<dgDebriNodeInfo, dgSharedNodeMesh> - { - public: - dgConectivityGraph (dgMemoryAllocator* const allocator); - dgConectivityGraph (const dgConectivityGraph& source); - ~dgConectivityGraph (); - - dgListNode* AddNode (dgFlatVertexArray& vertexArray, dgMeshEffect* const factureVisualMesh, dgTreeArray::dgTreeNode* const collisionNode, dgInt32 interiorMaterialBase); - void Serialize(dgSerialize callback, void* const userData) const; - void Deserialize (dgCollisionCompoundFractured* const source, dgDeserialize callback, void* const userData); - }; - - class dgConectivityGraphMap: public dgTree<dgConectivityGraph::dgListNode*, const dgCollisionInstance*> - { - public: - dgConectivityGraphMap (const dgConectivityGraphMap& source) - :dgTree<dgConectivityGraph::dgListNode*, const dgCollisionInstance*>(source.GetAllocator()) - { - } - - dgConectivityGraphMap (dgMemoryAllocator* const allocator) - :dgTree<dgConectivityGraph::dgListNode*, const dgCollisionInstance*>(allocator) - { - } - - void Pupolate(const dgConectivityGraph& graph) - { - for (dgConectivityGraph::dgListNode* node = graph.GetFirst(); node != graph.GetLast(); node = node->GetNext() ) { - dgDebriNodeInfo& nodeInfo = node->GetInfo().m_nodeData; - Insert(node, nodeInfo.m_shapeNode->GetInfo()->GetShape()); - } - } - }; - - public: - typedef void (*OnEmitNewCompundFractureCallBack) (dgBody* const body); - typedef void (*OnEmitFractureChunkCallBack) (dgBody* const body, dgConectivityGraph::dgListNode* const chunkMeshNode, const dgCollisionInstance* const myInstance); - typedef void (*OnReconstructFractureMainMeshCallBack) (dgBody* const body, dgConectivityGraph::dgListNode* const mainMeshNode, const dgCollisionInstance* const myInstance); - - dgCollisionCompoundFractured (const dgCollisionCompoundFractured& source, const dgCollisionInstance* const myInstance); - dgCollisionCompoundFractured (dgCollisionCompoundFractured& source, const dgList<dgConectivityGraph::dgListNode*>& island); - dgCollisionCompoundFractured (dgWorld* const world, dgMeshEffect* const solidMesh, dgInt32 fracturePhysicsMaterialID, int pointcloudCount, const dgFloat32* const vertexCloud, int strideInBytes, int materialID, const dgMatrix& offsetMatrix, - OnEmitFractureChunkCallBack emitFracturedChunk, OnEmitNewCompundFractureCallBack emitNewCompoundFactured, OnReconstructFractureMainMeshCallBack reconstructMainMesh); - - dgCollisionCompoundFractured (dgWorld* const world, dgDeserialize deserialization, void* const userData, const dgCollisionInstance* const myInstance, dgInt32 revisionNumber); - virtual ~dgCollisionCompoundFractured(void); - - void SetCallbacks(OnEmitFractureChunkCallBack emitFracturedChunk, OnEmitNewCompundFractureCallBack emitNewCompoundFactured, OnReconstructFractureMainMeshCallBack reconstructMainMesh); - - dgConectivityGraph::dgListNode* GetMainMesh() const; - dgConectivityGraph::dgListNode* GetFirstMesh() const; - dgConectivityGraph::dgListNode* GetNextMesh(dgConectivityGraph::dgListNode* const mesh) const; - - dgInt32 GetVertecCount(dgConectivityGraph::dgListNode* const node) const; - const dgFloat32* GetVertexPositions (dgConectivityGraph::dgListNode* const node) const; - const dgFloat32* GetVertexNormal (dgConectivityGraph::dgListNode* const node) const; - const dgFloat32* GetVertexUVs (dgConectivityGraph::dgListNode* const node) const; - dgInt32 GetSegmentIndexStream (dgConectivityGraph::dgListNode* const node, dgMesh::dgListNode* const segment, dgInt32* const index) const; - - void SetImpulseStrength(dgFloat32 impulseStrength); - dgFloat32 GetImpulseStrength() const; - - void SetImpulsePropgationFactor(dgFloat32 factor); - dgFloat32 GetSetImpulsePropgationFactor() const; - - virtual void BeginAddRemove (); - virtual void RemoveCollision (dgTreeArray::dgTreeNode* const node); - virtual void EndAddRemove (bool flushCache = true); - bool IsNodeSaseToDetach (dgTreeArray::dgTreeNode* const node) const; - - int GetFirstNiegborghArray (dgTreeArray::dgTreeNode* const node, dgTreeArray::dgTreeNode** const nodesArray, int maxCount) const; - - dgCollisionCompoundFractured* PlaneClip (const dgVector& plane); - - private: - void BuildMainMeshSubMehes() const; - dgVector GetObbSize() const; - - virtual void Serialize(dgSerialize callback, void* const userData) const; - virtual void CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const; - dgInt32 CalculateContacts (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - - void ColorDisjoinChunksIsland (); - bool SpawnChunks (dgBody* const myBody, const dgCollisionInstance* const myInstance, dgConectivityGraph::dgListNode* const rootNode, dgFloat32 impulseStimate2, dgFloat32 impulseStimateCut2); - void SpawnDisjointChunks (dgBody* const myBody, const dgCollisionInstance* const myInstance, dgConectivityGraph::dgListNode* const rootNode, dgFloat32 impulseStimate2, dgFloat32 impulseStimateCut2); - - void SpawnSingleChunk (dgBody* const myBody, const dgCollisionInstance* const myInstance, dgConectivityGraph::dgListNode* const chunkNode); - void SpawnComplexChunk (dgBody* const myBody, const dgCollisionInstance* const myInstance, dgConectivityGraph::dgListNode* const chunkNode); - bool CanChunk (dgConectivityGraph::dgListNode* const node) const; - - bool SanityCheck() const; - - inline bool IsAbovePlane (dgConectivityGraph::dgListNode* const node, const dgVector& plane) const; - inline bool IsBelowPlane (dgConectivityGraph::dgListNode* const node, const dgVector& plane) const; - inline dgConectivityGraph::dgListNode* FirstAcrossPlane (dgConectivityGraph::dgListNode* const node, const dgVector& plane) const; - - dgConectivityGraph m_conectivity; - dgConectivityGraphMap m_conectivityMap; - dgVertexBuffer* m_vertexBuffer; - dgFloat32 m_impulseStrengthPerUnitMass; - dgFloat32 m_impulseAbsortionFactor; - dgFloat32 m_density; - dgInt32 m_lru; - dgInt32 m_materialCount; - OnEmitFractureChunkCallBack m_emitFracturedChunk; - OnEmitNewCompundFractureCallBack m_emitFracturedCompound; - OnReconstructFractureMainMeshCallBack m_reconstructMainMesh; -}; -#endif diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionCone.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionCone.cpp deleted file mode 100644 index 39c6275e2..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionCone.cpp +++ /dev/null @@ -1,371 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgContact.h" -#include "dgCollisionCone.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -dgInt32 dgCollisionCone::m_shapeRefCount = 0; -dgCollisionConvex::dgConvexSimplexEdge dgCollisionCone::m_edgeArray[DG_CONE_SEGMENTS * 4]; - -dgCollisionCone::dgCollisionCone(dgMemoryAllocator* allocator, dgUnsigned32 signature, dgFloat32 radius, dgFloat32 height) - :dgCollisionConvex(allocator, signature, m_coneCollision) -{ - Init (radius, height); -} - -dgCollisionCone::dgCollisionCone(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionConvex (world, deserialization, userData, revisionNumber) -{ - dgVector size; - deserialization (userData, &size, sizeof (dgVector)); - Init (size.m_x, size.m_y); -} - - -dgCollisionCone::~dgCollisionCone() -{ - m_shapeRefCount --; - dgAssert (m_shapeRefCount >= 0); - - dgCollisionConvex::m_simplex = NULL; - dgCollisionConvex::m_vertex = NULL; -} - -void dgCollisionCone::Init (dgFloat32 radius, dgFloat32 height) -{ - m_rtti |= dgCollisionCone_RTTI; - - m_radius = dgMax(dgAbs(radius), D_MIN_CONVEX_SHAPE_SIZE); - m_height = dgMax (dgAbs (height * dgFloat32 (0.5f)), D_MIN_CONVEX_SHAPE_SIZE); - - dgFloat32 angle = dgFloat32(0.0f); - for (dgInt32 i = 0; i < DG_CONE_SEGMENTS; i++) { - dgFloat32 sinAngle = dgSin(angle); - dgFloat32 cosAngle = dgCos(angle); - m_vertex[i] = dgVector(-m_height, m_radius * cosAngle, m_radius * sinAngle, dgFloat32(0.0f)); - angle += dgPI2 / DG_CONE_SEGMENTS; - } - m_vertex[DG_CONE_SEGMENTS] = dgVector (m_height, dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - - m_edgeCount = DG_CONE_SEGMENTS * 4; - m_vertexCount = DG_CONE_SEGMENTS + 1; - dgCollisionConvex::m_vertex = m_vertex; - - if (!m_shapeRefCount) { - dgPolyhedra polyhedra(m_allocator); - dgInt32 wireframe[DG_CONE_SEGMENTS]; - - dgInt32 j = DG_CONE_SEGMENTS - 1; - polyhedra.BeginFace (); - for (dgInt32 i = 0; i < DG_CONE_SEGMENTS; i ++) { - wireframe[0] = j; - wireframe[1] = i; - wireframe[2] = DG_CONE_SEGMENTS; - j = i; - polyhedra.AddFace (3, wireframe); - } - - for (dgInt32 i = 0; i < DG_CONE_SEGMENTS; i ++) { - wireframe[i] = DG_CONE_SEGMENTS - 1 - i; - } - polyhedra.AddFace (DG_CONE_SEGMENTS, wireframe); - polyhedra.EndFace (); - - dgAssert (SanityCheck (polyhedra)); - - dgUnsigned64 i = 0; - dgPolyhedra::Iterator iter (polyhedra); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - edge->m_userData = i; - i ++; - } - - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - - dgConvexSimplexEdge* const ptr = &m_edgeArray[edge->m_userData]; - - ptr->m_vertex = edge->m_incidentVertex; - ptr->m_next = &m_edgeArray[edge->m_next->m_userData]; - ptr->m_prev = &m_edgeArray[edge->m_prev->m_userData]; - ptr->m_twin = &m_edgeArray[edge->m_twin->m_userData]; - } - } - - m_profile[0] = dgVector(m_height, dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - m_profile[1] = dgVector(-m_height, m_radius, dgFloat32(0.0f), dgFloat32(0.0f)); - m_profile[2] = dgVector(-m_height, -m_radius, dgFloat32(0.0f), dgFloat32(0.0f)); - - m_shapeRefCount ++; - dgCollisionConvex::m_simplex = m_edgeArray; - - SetVolumeAndCG (); -} - -dgInt32 dgCollisionCone::CalculateSignature (dgFloat32 radius, dgFloat32 height) -{ - dgUnsigned32 buffer[3]; - - memset (buffer, 0, sizeof (buffer)); - buffer[0] = m_coneCollision; - buffer[1] = dgCollision::Quantize (radius); - buffer[2] = dgCollision::Quantize (height); - return dgInt32 (dgCollision::Quantize(buffer, sizeof (buffer))); -} - -dgInt32 dgCollisionCone::CalculateSignature () const -{ - return CalculateSignature (m_radius, m_height); -} - - -void dgCollisionCone::DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - #define NUMBER_OF_DEBUG_SEGMENTS 40 - dgTriplex pool[NUMBER_OF_DEBUG_SEGMENTS + 1]; - dgTriplex face[NUMBER_OF_DEBUG_SEGMENTS]; - - dgFloat32 angle = dgFloat32 (0.0f); - for (dgInt32 i = 0; i < NUMBER_OF_DEBUG_SEGMENTS; i ++) { - dgFloat32 z = dgSin (angle) * m_radius; - dgFloat32 y = dgCos (angle) * m_radius; - pool[i].m_x = -m_height; - pool[i].m_y = y; - pool[i].m_z = z; - angle += dgPI2 / dgFloat32 (NUMBER_OF_DEBUG_SEGMENTS); - } - - pool[NUMBER_OF_DEBUG_SEGMENTS].m_x = m_height; - pool[NUMBER_OF_DEBUG_SEGMENTS].m_y = dgFloat32 (0.0f); - pool[NUMBER_OF_DEBUG_SEGMENTS].m_z = dgFloat32 (0.0f); - - matrix.TransformTriplex (&pool[0].m_x, sizeof (dgTriplex), &pool[0].m_x, sizeof (dgTriplex), NUMBER_OF_DEBUG_SEGMENTS + 1); - dgInt32 j = NUMBER_OF_DEBUG_SEGMENTS - 1; - for (dgInt32 i = 0; i < NUMBER_OF_DEBUG_SEGMENTS; i ++) { - face[0] = pool[j]; - face[1] = pool[i]; - face[2] = pool[NUMBER_OF_DEBUG_SEGMENTS]; - j = i; - callback (userData, 3, &face[0].m_x, 0); - } - - for (dgInt32 i = 0; i < NUMBER_OF_DEBUG_SEGMENTS; i ++) { - face[i] = pool[NUMBER_OF_DEBUG_SEGMENTS - 1 - i]; - } - callback (userData, NUMBER_OF_DEBUG_SEGMENTS, &face[0].m_x, 0); -} - -void dgCollisionCone::SetCollisionBBox (const dgVector& p0__, const dgVector& p1__) -{ - dgAssert (0); -} - - -dgVector dgCollisionCone::SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert(dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-3f)); - - if (dir.m_x < dgFloat32(-0.9999f)) { - return dgVector(-m_height, dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - } else if (dir.m_x > dgFloat32(0.9999f)) { - return dgVector(m_height, dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - } else { - dgVector dir_yz(dir); - dir_yz.m_x = dgFloat32(0.0f); - dgFloat32 mag2 = dir_yz.DotProduct(dir_yz).GetScalar(); - dgAssert(mag2 > dgFloat32(0.0f)); - dir_yz = dir_yz.Scale(dgFloat32(1.0f) / dgSqrt(mag2)); - - dgVector p0(dir_yz.Scale(m_radius)); - dgVector p1(dgVector::m_zero); - - p0.m_x = -m_height; - p1.m_x = m_height; - - dgFloat32 dist0 = dir.DotProduct(p0).GetScalar(); - dgFloat32 dist1 = dir.DotProduct(p1).GetScalar(); - - if (dist1 >= dist0) { - p0 = p1; - } - return p0; - } -} - -dgVector dgCollisionCone::SupportVertexSpecial(const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert(dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-3f)); - - if (dir.m_x < dgFloat32(-0.9999f)) { - return dgVector(-(m_height - DG_PENETRATION_TOL), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - } else if (dir.m_x > dgFloat32(0.9999f)) { - return dgVector(m_height - DG_PENETRATION_TOL, dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - } else { - dgVector dir_yz(dir); - dir_yz.m_x = dgFloat32(0.0f); - dgFloat32 mag2 = dir_yz.DotProduct(dir_yz).GetScalar(); - dgAssert(mag2 > dgFloat32(0.0f)); - dir_yz = dir_yz.Scale(dgFloat32(1.0f) / dgSqrt(mag2)); - - dgVector p0(dir_yz.Scale(m_radius - DG_PENETRATION_TOL)); - dgVector p1(dgVector::m_zero); - - p0.m_x = -(m_height - DG_PENETRATION_TOL); - p1.m_x = m_height - DG_PENETRATION_TOL; - - dgFloat32 dist0 = dir.DotProduct(p0).GetScalar(); - dgFloat32 dist1 = dir.DotProduct(p1).GetScalar(); - - if (dist1 >= dist0) { - p0 = p1; - } - return p0; - } -} - -dgVector dgCollisionCone::SupportVertexSpecialProjectPoint(const dgVector& point, const dgVector& dir) const -{ - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert(dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-3f)); - return point + dir.Scale(DG_PENETRATION_TOL); -} - -void dgCollisionCone::MassProperties () -{ - m_centerOfMass = dgVector (-dgFloat32 (1.0f/2.0f) * m_height, dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - m_crossInertia = dgVector (dgFloat32 (0.0f)); - - dgFloat32 volume = dgFloat32 (dgPi * 2.0f / 3.0f) * m_radius * m_radius * m_height; - dgFloat32 inertiaxx = dgFloat32 (3.0f / 10.0f) * m_radius * m_radius; - dgFloat32 inertiayyzz = (dgFloat32 (3.0f / 20.0f) * m_radius * m_radius + dgFloat32 (3.0f / 20.0f) * m_height * m_height); - - m_inertia[0] = inertiaxx; - m_inertia[1] = inertiayyzz; - m_inertia[2] = inertiayyzz; - m_centerOfMass.m_w = volume; -} - -dgInt32 dgCollisionCone::CalculatePlaneIntersection (const dgVector& normal, const dgVector& origin, dgVector* const contactsOut) const -{ - dgInt32 count = 0; - if (normal.m_x > dgFloat32(0.99f)) { - contactsOut[0] = dgVector(m_height, dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - count = 1; - } else if (normal.m_x < dgFloat32(-0.995f)) { - const dgFloat32 inclination = dgFloat32(0.9998f); - if (normal.m_x < -inclination) { - dgMatrix matrix(normal); - matrix.m_posit.m_x = origin.m_x; - count = BuildCylinderCapPoly (m_radius, matrix, contactsOut); - //count = RectifyConvexSlice(n, normal, contactsOut); - } else { - dgFloat32 magInv = dgRsqrt(normal.m_y * normal.m_y + normal.m_z * normal.m_z); - dgFloat32 cosAng = normal.m_y * magInv; - dgFloat32 sinAng = normal.m_z * magInv; - - dgAssert(dgAbs(normal.m_z * cosAng - normal.m_y * sinAng) < dgFloat32(1.0e-4f)); - dgVector normal1(normal.m_x, normal.m_y * cosAng + normal.m_z * sinAng, dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector origin1(origin.m_x, origin.m_y * cosAng + origin.m_z * sinAng, origin.m_z * cosAng - origin.m_y * sinAng, dgFloat32(0.0f)); - - count = dgCollisionConvex::CalculatePlaneIntersection(normal1, origin1, contactsOut); - if (count > 6) { - dgInt32 dy = 2 * 6; - dgInt32 dx = 2 * count; - dgInt32 acc = dy - count; - dgInt32 index = 0; - for (dgInt32 i = 0; i < count; i++) { - if (acc > 0) { - contactsOut[index] = contactsOut[i]; - index++; - acc -= dx; - } - acc += dy; - } - count = index; - } - - for (dgInt32 i = 0; i < count; i++) { - dgFloat32 y = contactsOut[i].m_y; - dgFloat32 z = contactsOut[i].m_z; - contactsOut[i].m_y = y * cosAng - z * sinAng; - contactsOut[i].m_z = z * cosAng + y * sinAng; - } - } - } else { - dgFloat32 magInv = dgRsqrt(normal.m_y * normal.m_y + normal.m_z * normal.m_z); - dgFloat32 cosAng = normal.m_y * magInv; - dgFloat32 sinAng = normal.m_z * magInv; - - dgAssert(dgAbs(normal.m_z * cosAng - normal.m_y * sinAng) < dgFloat32(1.0e-4f)); - dgVector normal1(normal.m_x, normal.m_y * cosAng + normal.m_z * sinAng, dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector origin1(origin.m_x, origin.m_y * cosAng + origin.m_z * sinAng, origin.m_z * cosAng - origin.m_y * sinAng, dgFloat32(0.0f)); - - count = 0; - int i0 = 2; - dgVector test0((m_profile[i0] - origin1).DotProduct(normal1)); - for (int i = 0; (i < 3) && (count < 2); i++) { - dgVector test1((m_profile[i] - origin1).DotProduct(normal1)); - dgVector acrossPlane(test0 * test1); - if (acrossPlane.m_x < 0.0f) { - dgVector step(m_profile[i] - m_profile[i0]); - contactsOut[count] = m_profile[i0] - step.Scale(test0.m_x / (step.DotProduct(normal1).m_x)); - count++; - } - i0 = i; - test0 = test1; - } - - for (dgInt32 i = 0; i < count; i++) { - dgFloat32 y = contactsOut[i].m_y; - dgFloat32 z = contactsOut[i].m_z; - contactsOut[i].m_y = y * cosAng - z * sinAng; - contactsOut[i].m_z = z * cosAng + y * sinAng; - } - } - - return count; -} - - - -void dgCollisionCone::GetCollisionInfo(dgCollisionInfo* const info) const -{ - dgCollisionConvex::GetCollisionInfo(info); - - info->m_cone.m_r = m_radius; - info->m_cone.m_height = m_height * dgFloat32 (2.0f); -} - -void dgCollisionCone::Serialize(dgSerialize callback, void* const userData) const -{ - dgVector size (m_radius, m_height * dgFloat32 (2.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - SerializeLow(callback, userData); - callback (userData, &size, sizeof (dgVector)); -} diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionCone.h b/thirdparty/src/newton/dgPhysics/dgCollisionCone.h deleted file mode 100644 index accc521b2..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionCone.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -#if !defined(AFX_DGCOLLISIONCONE_H__AS235640FER_H) -#define AFX_DGCOLLISIONCONE_H__AS235640FER_H - -#include "dgCollisionConvex.h" - -#define DG_CONE_SEGMENTS 12 - - -class dgCollisionCone: public dgCollisionConvex -{ - public: - dgCollisionCone (dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgFloat32 radius, dgFloat32 height); - dgCollisionCone(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionCone(); - - private: - void Init (dgFloat32 radius, dgFloat32 height); - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const; - - virtual dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& origin, dgVector* const contactsOut) const; - - virtual void MassProperties (); - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - - virtual dgInt32 CalculateSignature () const; - virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1); - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - virtual void Serialize(dgSerialize callback, void* const userData) const; - - static dgInt32 CalculateSignature (dgFloat32 radius, dgFloat32 height); - - dgVector m_profile[3]; - dgFloat32 m_height; - dgFloat32 m_radius; - dgVector m_vertex[DG_CONE_SEGMENTS + 1]; - static dgInt32 m_shapeRefCount; - static dgConvexSimplexEdge m_edgeArray[]; - - friend class dgWorld; -}; - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionConvex.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionConvex.cpp deleted file mode 100644 index 833036563..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionConvex.cpp +++ /dev/null @@ -1,938 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgContactSolver.h" -#include "dgCollisionMesh.h" -#include "dgCollisionConvex.h" -#include "dgCollisionInstance.h" -#include "dgCollisionConvexHull.h" -#include "dgCollisionConvexPolygon.h" - -#define DG_MAX_MIN_VOLUME dgFloat32 (1.0e-6f) -#define DG_MAX_VERTEX_CLIP_FACE 16 - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -dgCollisionConvex::dgCollisionConvex (dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgCollisionID id) - :dgCollision(allocator, signature, id) - ,m_vertex (NULL) - ,m_simplex (NULL) - ,m_boxMinRadius (dgFloat32 (0.0f)) - ,m_boxMaxRadius (dgFloat32 (0.0f)) - ,m_simplexVolume (dgFloat32 (0.0f)) - ,m_edgeCount (0) - ,m_vertexCount (0) -{ - m_rtti |= dgCollisionConvexShape_RTTI; -} - - -dgCollisionConvex::dgCollisionConvex (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollision (world, deserialization, userData, revisionNumber) - ,m_vertex (NULL) - ,m_simplex (NULL) - ,m_boxMinRadius (dgFloat32 (0.0f)) - ,m_boxMaxRadius (dgFloat32 (0.0f)) - ,m_simplexVolume (dgFloat32 (0.0f)) - ,m_edgeCount (0) - ,m_vertexCount (0) -{ - dgAssert (m_rtti | dgCollisionConvexShape_RTTI); -} - - -dgCollisionConvex::~dgCollisionConvex () -{ - if (m_vertex) { - m_allocator->Free (m_vertex); - } - - if (m_simplex) { - m_allocator->Free (m_simplex); - } -} - -void dgCollisionConvex::SerializeLow(dgSerialize callback, void* const userData) const -{ - dgCollision::SerializeLow(callback, userData); -} - - -void dgCollisionConvex::SetVolumeAndCG () -{ - dgVector faceVertex[DG_MAX_EDGE_COUNT]; - dgStack<dgInt8> edgeMarks (m_edgeCount); - memset (&edgeMarks[0], 0, sizeof (dgInt8) * m_edgeCount); - - dgPolyhedraMassProperties localData; - for (dgInt32 i = 0; i < m_edgeCount; i ++) { - dgConvexSimplexEdge* const face = &m_simplex[i]; - if (!edgeMarks[i]) { - dgConvexSimplexEdge* edge = face; - dgInt32 count = 0; - do { - dgAssert ((edge - m_simplex) >= 0); - edgeMarks[dgInt32 (edge - m_simplex)] = '1'; - faceVertex[count] = m_vertex[edge->m_vertex]; - count ++; - dgAssert (count < dgInt32 (sizeof (faceVertex) / sizeof (faceVertex[0]))); - edge = edge->m_next; - } while (edge != face); - localData.AddCGFace (count, faceVertex); - } - } - - dgVector origin; - dgVector inertia; - dgVector crossInertia; - dgFloat32 volume = localData.MassProperties (origin, inertia, crossInertia); - m_simplexVolume = volume; - - // calculate the origin of the bound box of this primitive - dgVector p0(dgFloat32 (0.0f)); - dgVector p1(dgFloat32 (0.0f)); - for (dgInt32 i = 0; i < 3; i ++) { - dgVector dir (dgFloat32 (0.0f)); - dir[i] = dgFloat32 (-1.0f); - p0[i] = SupportVertex(dir, NULL)[i]; - - dir[i] = dgFloat32 (1.0f); - p1[i] = SupportVertex(dir, NULL)[i]; - } - - dgAssert (p0.m_w == dgFloat32 (0.0f)); - dgAssert (p1.m_w == dgFloat32 (0.0f)); - m_boxSize = (p1 - p0) * dgVector::m_half; - m_boxOrigin = (p1 + p0) * dgVector::m_half; - m_boxMinRadius = dgMin(m_boxSize.m_x, m_boxSize.m_y, m_boxSize.m_z); - m_boxMaxRadius = dgSqrt ((m_boxSize.DotProduct(m_boxSize)).GetScalar()); - - MassProperties (); -} - -bool dgCollisionConvex::SanityCheck (dgPolyhedra& hull) const -{ - dgPolyhedra::Iterator iter (hull); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if (edge->m_incidentFace < 0) { - return false; - } - dgEdge* ptr = edge; - dgVector p0 (m_vertex[edge->m_incidentVertex]); - ptr = ptr->m_next; - dgVector p1 (m_vertex[ptr->m_incidentVertex]); - dgVector e1 (p1 - p0); - dgVector n0 (dgFloat32 (0.0f)); - for (ptr = ptr->m_next; ptr != edge; ptr = ptr->m_next) { - dgVector p2 (m_vertex[ptr->m_incidentVertex]); - dgVector e2 (p2 - p0); - n0 += e1.CrossProduct(e2); - e1 = e2; - } - - dgAssert (n0.m_w == dgFloat32 (0.0f)); - ptr = edge; - do { - dgVector q0 (m_vertex[ptr->m_twin->m_incidentVertex]); - for (dgEdge* neiborg = ptr->m_twin->m_next->m_next; neiborg != ptr->m_twin; neiborg = neiborg->m_next) { - dgVector q1 (m_vertex[neiborg->m_incidentVertex]); - dgVector q1q0 (q1 - q0); - dgFloat32 project = q1q0.DotProduct(n0).GetScalar(); - if (project > dgFloat32 (1.0e-5f)) { - return false; - } - } - - ptr = ptr->m_next; - } while (ptr != edge); - } - - return true; -} - -void dgCollisionConvex::DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - dgInt8 mark[DG_MAX_EDGE_COUNT]; - dgVector tmp[DG_MAX_EDGE_COUNT]; - dgTriplex vertex[DG_MAX_EDGE_COUNT]; - - matrix.TransformTriplex (&tmp[0].m_x, sizeof (dgVector), &m_vertex[0].m_x, sizeof (dgVector), m_vertexCount); - - memset (mark, 0, sizeof (mark)); - for (dgInt32 i = 0; i < m_edgeCount; i ++) { - if (!mark[i]) { - dgConvexSimplexEdge* const face = &m_simplex[i]; - dgConvexSimplexEdge* edge = face; - dgInt32 count = 0; - do { - mark[edge - m_simplex] = '1'; - dgInt32 index = edge->m_vertex; - vertex[count].m_x = tmp[index].m_x; - vertex[count].m_y = tmp[index].m_y; - vertex[count].m_z = tmp[index].m_z; - count ++; - edge = edge->m_next; - } while (edge != face); - callback (userData, count, &vertex[0].m_x, 0); - } - } -} - -void dgCollisionConvex::CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const -{ - dgVector origin (matrix.TransformVector(m_boxOrigin)); - dgVector size (matrix.m_front.Abs().Scale(m_boxSize.m_x) + matrix.m_up.Abs().Scale(m_boxSize.m_y) + matrix.m_right.Abs().Scale(m_boxSize.m_z)); - - p0 = (origin - size) & dgVector::m_triplexMask; - p1 = (origin + size) & dgVector::m_triplexMask; -} - -void dgCollisionConvex::CalculateInertia (void* userData, int indexCount, const dgFloat32* const faceVertex, int faceId) -{ - dgPolyhedraMassProperties& localData = *((dgPolyhedraMassProperties*) userData); - localData.AddInertiaAndCrossFace(indexCount, faceVertex); -} - -dgFloat32 dgCollisionConvex::CalculateMassProperties (const dgMatrix& offset, dgVector& inertia, dgVector& crossInertia, dgVector& centerOfMass) const -{ - dgPolyhedraMassProperties localData; - DebugCollision (offset, CalculateInertia, &localData); - return localData.MassProperties (centerOfMass, inertia, crossInertia); -} - -void dgCollisionConvex::MassProperties () -{ - dgFloat32 volume = dgCollisionConvex::CalculateMassProperties (dgGetIdentityMatrix(), m_inertia, m_crossInertia, m_centerOfMass); - if (volume < DG_MAX_MIN_VOLUME) { - volume = DG_MAX_MIN_VOLUME; - } - dgFloat32 invVolume = dgFloat32 (1.0f) / volume; - m_inertia = m_inertia.Scale (invVolume); - m_crossInertia = m_crossInertia.Scale (invVolume); - m_centerOfMass = m_centerOfMass.Scale (invVolume); - m_centerOfMass.m_w = volume; - - // complete the calculation - dgCollision::MassProperties (); -} - -dgMatrix dgCollisionConvex::CalculateInertiaAndCenterOfMass (const dgMatrix& alignMatrix, const dgVector& localScale, const dgMatrix& matrix) const -{ - if ((dgAbs (localScale.m_x - localScale.m_y) < dgFloat32 (1.0e-5f)) && (dgAbs (localScale.m_x - localScale.m_z) < dgFloat32 (1.0e-5f))) { - dgAssert (alignMatrix[0][0] == dgFloat32(1.0f)); - dgAssert (alignMatrix[1][1] == dgFloat32(1.0f)); - dgAssert (alignMatrix[2][2] == dgFloat32(1.0f)); - - // using general central theorem, is much faster and more accurate; - //IImatrix = IIorigin + mass * [(displacemnet % displacemnet) * identityMatrix - transpose(displacement) * displacement)]; - dgFloat32 mag2 = localScale.m_x * localScale.m_x; - dgMatrix inertia (dgGetIdentityMatrix()); - inertia[0][0] = m_inertia[0] * mag2; - inertia[1][1] = m_inertia[1] * mag2; - inertia[2][2] = m_inertia[2] * mag2; - inertia[0][1] = m_crossInertia[2] * mag2; - inertia[1][0] = m_crossInertia[2] * mag2; - inertia[0][2] = m_crossInertia[1] * mag2; - inertia[2][0] = m_crossInertia[1] * mag2; - inertia[1][2] = m_crossInertia[0] * mag2; - inertia[2][1] = m_crossInertia[0] * mag2; - inertia = matrix.Inverse() * inertia * matrix; - - dgAssert (localScale.m_w == dgFloat32 (0.0f)); - dgVector origin (matrix.TransformVector (m_centerOfMass * localScale)); - - origin.m_w = dgFloat32 (0.0f); - dgFloat32 originMag2 = origin.DotProduct(origin).GetScalar(); - dgMatrix Covariance(origin, origin); - dgMatrix parallel(dgGetIdentityMatrix()); - for (dgInt32 i = 0; i < 3; i++) { - parallel[i][i] = originMag2; - inertia[i] += (parallel[i] - Covariance[i]); - dgAssert(inertia[i][i] > dgFloat32(0.0f)); - } - - inertia.m_posit = origin; - inertia.m_posit.m_w = 1.0f; - return inertia; - } else { - // for non uniform scale we need to the general divergence theorem - dgVector inertiaII; - dgVector crossInertia; - dgVector centerOfMass; - dgMatrix scaledMatrix(matrix); - scaledMatrix[0] = scaledMatrix[0].Scale(localScale.m_x); - scaledMatrix[1] = scaledMatrix[1].Scale(localScale.m_y); - scaledMatrix[2] = scaledMatrix[2].Scale(localScale.m_z); - scaledMatrix = alignMatrix * scaledMatrix; - - dgFloat32 volume = CalculateMassProperties (scaledMatrix, inertiaII, crossInertia, centerOfMass); - if (volume < DG_MAX_MIN_VOLUME) { - volume = DG_MAX_MIN_VOLUME; - } - - dgFloat32 invVolume = dgFloat32 (1.0f) / volume; - centerOfMass = centerOfMass.Scale(invVolume); - inertiaII = inertiaII.Scale (invVolume); - crossInertia = crossInertia.Scale (invVolume); - dgMatrix inertia (dgGetIdentityMatrix()); - inertia[0][0] = inertiaII[0]; - inertia[1][1] = inertiaII[1]; - inertia[2][2] = inertiaII[2]; - inertia[0][1] = crossInertia[2]; - inertia[1][0] = crossInertia[2]; - inertia[0][2] = crossInertia[1]; - inertia[2][0] = crossInertia[1]; - inertia[1][2] = crossInertia[0]; - inertia[2][1] = crossInertia[0]; - inertia[3] = centerOfMass; - return inertia; - } -} - - -dgFloat32 dgCollisionConvex::GetVolume () const -{ - return m_centerOfMass.m_w; -} - -dgFloat32 dgCollisionConvex::GetBoxMinRadius () const -{ - return m_boxMinRadius; -} - -dgFloat32 dgCollisionConvex::GetBoxMaxRadius () const -{ - return m_boxMaxRadius; -} - -dgVector dgCollisionConvex::CalculateVolumeIntegral (const dgMatrix& globalMatrix, const dgVector& globalPlane, const dgCollisionInstance& parentScale) const -{ - dgPlane localPlane (globalMatrix.UntransformPlane (globalPlane)); - - const dgVector& scale = parentScale.m_scale; - switch (parentScale.m_scaleType) - { - case dgCollisionInstance::m_unit: - break; - - case dgCollisionInstance::m_uniform: - { - localPlane.m_w *= parentScale.m_invScale.m_x; - break; - } - - case dgCollisionInstance::m_nonUniform: - { - localPlane = localPlane * (scale | dgVector::m_wOne); - dgFloat32 mag2 = localPlane.DotProduct(localPlane & dgVector::m_triplexMask).GetScalar(); - localPlane = localPlane.Scale (dgRsqrt(mag2)); - break; - } - - default: - { - localPlane = localPlane * (scale | dgVector::m_wOne); - dgFloat32 mag2 = localPlane.DotProduct(localPlane & dgVector::m_triplexMask).GetScalar(); - localPlane = localPlane.Scale (dgRsqrt(mag2)); - localPlane = parentScale.m_aligmentMatrix.UntransformPlane (localPlane); - } - } - - dgVector cg (CalculateVolumeIntegral (localPlane)); - - dgFloat32 volume = cg.m_w * scale.m_x * scale.m_y * scale.m_z; - cg = parentScale.m_aligmentMatrix.RotateVector (cg); - cg = cg * scale; - cg = globalMatrix.TransformVector (cg); - cg.m_w = volume; - return cg; -} - -dgVector dgCollisionConvex::CalculateVolumeIntegral (const dgPlane& plane) const -{ - dgInt8 mark[DG_MAX_EDGE_COUNT]; - dgFloat32 test[DG_MAX_EDGE_COUNT]; - dgVector faceVertex[DG_MAX_EDGE_COUNT]; - - dgInt32 positive = 0; - dgInt32 negative = 0; - for (dgInt32 i = 0; i < m_vertexCount; i ++) { - test[i] = plane.Evalue (m_vertex[i]); - if (test[i] > dgFloat32 (1.0e-5f)) { - positive ++; - } else if (test[i] < -dgFloat32 (1.0e-5f)) { - negative ++; - } else { - test[i] = dgFloat32 (0.0f); - } - } - - if (positive == m_vertexCount) { - return dgVector::m_zero; - } - - if (negative == m_vertexCount) { - return m_centerOfMass; - } - - dgPolyhedraMassProperties localData; - dgConvexSimplexEdge* capEdge = NULL; - - dgVector cg (dgVector::m_zero); - memset (mark, 0, sizeof (mark)); - for (dgInt32 i = 0; i < m_edgeCount; i ++) { - if (!mark[i]) { - dgConvexSimplexEdge* const face = &m_simplex[i]; - dgConvexSimplexEdge* edge = face; - dgInt32 count = 0; - dgFloat32 size0 = test[edge->m_prev->m_vertex]; - do { - //edge->m_mark = m_mark; - mark[edge - m_simplex] = '1'; - dgFloat32 size1 = test[edge->m_vertex]; - if (size0 <= dgFloat32 (0.0f)) { - faceVertex[count] = m_vertex[edge->m_prev->m_vertex]; - count ++; - if (size1 > dgFloat32 (0.0f)) { - dgVector dp (m_vertex[edge->m_vertex] - m_vertex[edge->m_prev->m_vertex]); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - faceVertex[count] = m_vertex[edge->m_prev->m_vertex] - dp.Scale (size0 / dp.DotProduct(plane).GetScalar()); - count ++; - } - } else if (size1 < dgFloat32 (0.0f)) { - dgVector dp (m_vertex[edge->m_vertex] - m_vertex[edge->m_prev->m_vertex]); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - faceVertex[count] = m_vertex[edge->m_prev->m_vertex] - dp.Scale (size0 / dp.DotProduct(plane).GetScalar()); - count ++; - dgAssert (count < dgInt32 (sizeof (faceVertex) / sizeof (faceVertex[0]))); - } - - if (!capEdge) { - if ((size1 > dgFloat32 (0.0f)) && (size0 < dgFloat32 (0.0f))) { - capEdge = edge->m_prev->m_twin; - } - } - - size0 = size1; - edge = edge->m_next; - } while (edge != face); - - if (count) { - localData.AddCGFace(count, faceVertex); - } - } - } - - if (capEdge) { - dgInt32 count = 0; - dgConvexSimplexEdge* edge = capEdge; - dgConvexSimplexEdge* ptr = NULL; - do { - dgVector dp (m_vertex[edge->m_twin->m_vertex] - m_vertex[edge->m_vertex]); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - faceVertex[count] = m_vertex[edge->m_vertex] - dp.Scale (test[edge->m_vertex] / dp.DotProduct(plane).GetScalar()); - count ++; - if (count == 127) { - // something is wrong return zero - return dgVector (dgFloat32 (0.0f)); - } - - for (ptr = edge->m_next; ptr != edge; ptr = ptr->m_next) { - dgInt32 index0 = ptr->m_twin->m_vertex; - if (test[index0] > dgFloat32 (0.0f)) { - index0 = ptr->m_vertex; - if (test[index0] < dgFloat32 (0.0f)) { - break; - } - } - } - edge = ptr->m_twin; - } while (edge != capEdge); - localData.AddCGFace(count, faceVertex); - } - - dgVector inertia; - dgVector crossInertia; - dgFloat32 volume = localData.MassProperties (cg, inertia, crossInertia); - cg = cg.Scale (dgFloat32 (1.0f) / dgMax (volume, dgFloat32 (1.0e-6f))); - cg.m_w = volume; - return cg; -} - -dgVector dgCollisionConvex::SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert (dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f)); - - dgInt16 cache[16]; - memset (cache, -1, sizeof (cache)); - dgConvexSimplexEdge* edge = &m_simplex[0]; - - dgInt32 index = edge->m_vertex; - dgFloat32 side0 = m_vertex[index].DotProduct(dir).GetScalar(); - - cache [index & (sizeof (cache) / sizeof (cache[0]) - 1)] = dgInt16 (index); - dgConvexSimplexEdge* ptr = edge; - dgInt32 maxCount = 128; - do { - dgInt32 index1 = ptr->m_twin->m_vertex; - if (cache [index1 & (sizeof (cache) / sizeof (cache[0]) - 1)] != index1) { - cache [index1 & (sizeof (cache) / sizeof (cache[0]) - 1)] = dgInt16 (index1); - dgFloat32 side1 = m_vertex[index1].DotProduct(dir).GetScalar(); - if (side1 > side0) { - index = index1; - side0 = side1; - edge = ptr->m_twin; - ptr = edge; - } - } - ptr = ptr->m_twin->m_next; - maxCount --; - } while ((ptr != edge) && maxCount); - dgAssert (maxCount); - - dgAssert (index != -1); - return m_vertex[index]; -} - - -bool dgCollisionConvex::SanityCheck(dgInt32 count, const dgVector& normal, dgVector* const contactsOut) const -{ - if (count > 1) { - dgInt32 j = count - 1; - for (dgInt32 i = 0; i < count; i ++) { - dgVector error (contactsOut[i] - contactsOut[j]); - dgAssert (error.m_w == dgFloat32 (0.0f)); - if (error.DotProduct(error).GetScalar() <= dgFloat32 (1.0e-20f)) { - return false; - } - j = i; - } - - if (count >= 3) { - dgVector n (dgFloat32 (0.0f)); - dgVector e0 (contactsOut[1] - contactsOut[0]); - for (dgInt32 i = 2; i < count; i ++) { - dgVector e1 (contactsOut[i] - contactsOut[0]); - n += e0.CrossProduct(e1); - e0 = e1; - } - dgAssert (n.m_w == dgFloat32 (0.0f)); - dgAssert (n.DotProduct(n).GetScalar() > dgFloat32 (0.0f)); - n = n.Scale (dgRsqrt(n.DotProduct(n).GetScalar())); - dgFloat32 projection; - projection = n.DotProduct(normal).GetScalar(); - dgAssert (projection > dgFloat32 (0.9f)); - if (projection < dgFloat32 (0.9f)) { - return false; - } - - e0 = contactsOut[count-1] - contactsOut[count-2]; - j = count - 1; - for (dgInt32 i = 0; i < count; i ++) { - dgVector e1 (contactsOut[i] - contactsOut[j]); - dgVector n1 (e0.CrossProduct(e1)); - dgAssert (n1.m_w == dgFloat32 (0.0f)); - dgFloat32 error = n1.DotProduct(normal).GetScalar(); - dgAssert (error >= dgFloat32 (-1.0e-4f)); - if (error < dgFloat32 (-1.0e-4f)) { - return false; - } - j = i; - e0 = e1; - } - } - } - return true; -} - -dgInt32 dgCollisionConvex::RectifyConvexSlice (dgInt32 count, const dgVector& normal, dgVector* const contactsOut) const -{ - class dgConveFaceNode - { - public: - dgInt32 m_vertexIndex; - dgConveFaceNode* m_next; - dgConveFaceNode* m_prev; - dgInt32 m_mask; - }; - - dgConveFaceNode convexHull[DG_MAX_CONTATCS + 1]; - char buffer[DG_MAX_CONTATCS * (sizeof (void*) + sizeof (dgFloat32))]; - - dgInt32 start = count; - dgInt32 i0 = count - 1; - for (dgInt32 i = 0; i < count; i ++) { - convexHull[i].m_vertexIndex = i; - convexHull[i].m_next = &convexHull[i + 1]; - convexHull[i].m_prev = &convexHull[i0]; - i0 = i; - } - convexHull[count - 1].m_next = &convexHull[0]; - - dgVector hullArea (dgVector::m_zero); - dgVector edge0 (contactsOut[1] - contactsOut[0]); - for (dgInt32 i = 2; i < count; i ++) { - dgVector edge1 (contactsOut[i] - contactsOut[0]); - hullArea += edge1.CrossProduct(edge0); - edge0 = edge1; - } - - dgFloat32 totalArea = dgAbs (hullArea.DotProduct(normal).GetScalar()); - if (totalArea < dgFloat32 (1.0e-5f)) { - return 1; - } - dgConveFaceNode* hullPoint = &convexHull[0]; - - bool hasLinearCombination = true; - dgUpHeap<dgConveFaceNode*, dgFloat32> sortHeap(buffer, sizeof (buffer)); - while (hasLinearCombination) { - hasLinearCombination = false; - sortHeap.Flush(); - dgConveFaceNode* ptr = hullPoint; - dgVector e0(contactsOut[ptr->m_next->m_vertexIndex] - contactsOut[ptr->m_vertexIndex]); - do { - dgVector e1(contactsOut[ptr->m_next->m_next->m_vertexIndex] - contactsOut[ptr->m_next->m_vertexIndex]); - dgFloat32 area = dgAbs (e0.CrossProduct(e1).DotProduct(normal).GetScalar()); - sortHeap.Push(ptr->m_next, area); - e0 = e1; - ptr->m_mask = 1; - ptr = ptr->m_next; - } while (ptr != hullPoint); - - while (sortHeap.GetCount() && (sortHeap.Value() * dgFloat32(32.0f) < totalArea)) { - dgConveFaceNode* const corner = sortHeap[0]; - if (corner->m_mask && corner->m_prev->m_mask) { - if (hullPoint == corner) { - hullPoint = corner->m_prev; - } - count --; - hasLinearCombination = true; - corner->m_prev->m_mask = 0; - corner->m_next->m_prev = corner->m_prev; - corner->m_prev->m_next = corner->m_next; - } - sortHeap.Pop(); - } - } - - const dgInt32 maxVertexCount = DG_MAX_VERTEX_CLIP_FACE; - while (count > maxVertexCount) { - sortHeap.Flush(); - dgConveFaceNode* ptr = hullPoint; - dgVector e0(contactsOut[ptr->m_next->m_vertexIndex] - contactsOut[ptr->m_vertexIndex]); - do { - dgVector e1(contactsOut[ptr->m_next->m_next->m_vertexIndex] - contactsOut[ptr->m_next->m_vertexIndex]); - dgFloat32 area = dgAbs(e0.CrossProduct(e1).DotProduct(normal).GetScalar()); - sortHeap.Push(ptr->m_next, area); - e0 = e1; - ptr->m_mask = 1; - ptr = ptr->m_next; - } while (ptr != hullPoint); - - while (sortHeap.GetCount() && (count > maxVertexCount)) { - dgConveFaceNode* const corner = sortHeap[0]; - if (corner->m_mask && corner->m_prev->m_mask) { - if (hullPoint == corner) { - hullPoint = corner->m_prev; - } - count--; - corner->m_prev->m_mask = 0; - corner->m_next->m_prev = corner->m_prev; - corner->m_prev->m_next = corner->m_next; - } - sortHeap.Pop(); - } - } - - dgInt32 index = start; - dgConveFaceNode* ptr = hullPoint; - do { - contactsOut[index] = contactsOut[ptr->m_vertexIndex]; - index ++; - ptr = ptr->m_next; - } while (ptr != hullPoint); - memcpy (contactsOut, &contactsOut[start], count * sizeof (dgVector)); - - dgAssert (SanityCheck(count, normal, contactsOut)); - return count; -} - -dgVector dgCollisionConvex::SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - return SupportVertex(dir, vertexIndex); -} - -dgVector dgCollisionConvex::SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const - { - return point; - } - - -dgFloat32 dgCollisionConvex::RayCast(const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const -{ - dgCollisionInstance instance(*body->GetCollision(), this); - dgContactSolver rayCaster(&instance); - instance.m_material.m_userData = NULL; - return rayCaster.RayCast(localP0, localP1, maxT, contactOut); -} - -dgInt32 dgCollisionConvex::CalculatePlaneIntersection (const dgVector& normal, const dgVector& origin, dgVector* const contactsOut) const -{ - dgVector support[4]; - dgInt32 featureCount = 3; - const dgConvexSimplexEdge* edge = &m_simplex[0]; - const dgConvexSimplexEdge** const vertToEdgeMapping = GetVertexToEdgeMapping(); - dgAssert (normal.m_w == dgFloat32 (0.0f)); - if (vertToEdgeMapping) { - dgInt32 edgeIndex; - featureCount = 1; - support[0] = SupportVertex (normal, &edgeIndex); - edge = vertToEdgeMapping[edgeIndex]; - - // 5 degrees - const dgFloat32 tiltAngle = dgFloat32 (0.087f); - const dgFloat32 tiltAngle2 = tiltAngle * tiltAngle ; - dgPlane testPlane (normal, - (normal.DotProduct(support[0]).GetScalar())); - const dgConvexSimplexEdge* ptr = edge; - do { - const dgVector& p = m_vertex[ptr->m_twin->m_vertex]; - dgFloat32 test = testPlane.Evalue(p); - dgVector dist (p - support[0]); - dgAssert (dist.m_w == dgFloat32 (0.0f)); - dgFloat32 angle2 = test * test / (dist.DotProduct(dist).GetScalar()); - - if (angle2 < tiltAngle2) { - support[featureCount] = p; - featureCount ++; - } - ptr = ptr->m_twin->m_next; - } while ((ptr != edge) && (featureCount < 3)); - } - - dgInt32 count = 0; - dgPlane plane (normal, - normal.DotProduct(origin).GetScalar()); - switch (featureCount) - { - case 1: - contactsOut[0] = support[0] - normal * normal.DotProduct(support[0] - origin); - count = 1; - break; - - case 2: - contactsOut[0] = support[0] - normal * normal.DotProduct(support[0] - origin); - contactsOut[1] = support[1] - normal * normal.DotProduct(support[1] - origin); - count = 2; - break; - - default: - { - dgFloat32 side0 = plane.Evalue(m_vertex[edge->m_vertex]); - dgFloat32 side1 = side0; - const dgConvexSimplexEdge* firstEdge = NULL; - if (side0 > dgFloat32 (0.0f)) { - const dgConvexSimplexEdge* ptr = edge; - do { - dgAssert (m_vertex[ptr->m_twin->m_vertex].m_w == dgFloat32 (0.0f)); - side1 = plane.Evalue (m_vertex[ptr->m_twin->m_vertex]); - if (side1 < side0) { - if (side1 < dgFloat32 (0.0f)) { - firstEdge = ptr; - break; - } - - side0 = side1; - edge = ptr->m_twin; - ptr = edge; - } - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - - - if (!firstEdge) { - // we may have a local minimal in the convex hull do to a big flat face - for (dgInt32 i = 0; i < m_edgeCount; i ++) { - ptr = &m_simplex[i]; - side0 = plane.Evalue (m_vertex[ptr->m_vertex]); - side1 = plane.Evalue (m_vertex[ptr->m_twin->m_vertex]); - if ((side1 < dgFloat32 (0.0f)) && (side0 > dgFloat32 (0.0f))){ - firstEdge = ptr; - break; - } - } - } - - } else if (side0 < dgFloat32 (0.0f)) { - const dgConvexSimplexEdge* ptr = edge; - do { - dgAssert (m_vertex[ptr->m_twin->m_vertex].m_w == dgFloat32 (0.0f)); - side1 = plane.Evalue (m_vertex[ptr->m_twin->m_vertex]); - if (side1 > side0) { - if (side1 >= dgFloat32 (0.0f)) { - side0 = side1; - firstEdge = ptr->m_twin; - break; - } - - side0 = side1; - edge = ptr->m_twin; - ptr = edge; - } - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - - if (!firstEdge) { - // we may have a local minimal in the convex hull due to a big flat face - for (dgInt32 i = 0; i < m_edgeCount; i ++) { - ptr = &m_simplex[i]; - side0 = plane.Evalue (m_vertex[ptr->m_vertex]); - //dgFloat32 side1 = plane.Evalue (m_vertex[ptr->m_twin->m_vertex]); - side1 = plane.Evalue(m_vertex[ptr->m_twin->m_vertex]); - if ((side1 < dgFloat32 (0.0f)) && (side0 > dgFloat32 (0.0f))){ - firstEdge = ptr; - break; - } - } - } - } - - if (firstEdge) { - dgAssert (side0 >= dgFloat32 (0.0f)); - dgAssert ((side1 = plane.Evalue (m_vertex[firstEdge->m_vertex])) >= dgFloat32 (0.0f)); - dgAssert ((side1 = plane.Evalue (m_vertex[firstEdge->m_twin->m_vertex])) < dgFloat32 (0.0f)); - dgAssert (dgAbs (side0 - plane.Evalue (m_vertex[firstEdge->m_vertex])) < dgFloat32 (1.0e-5f)); - - dgInt32 maxCount = 0; - const dgConvexSimplexEdge* ptr = firstEdge; - do { - if (side0 > dgFloat32 (0.0f)) { - dgAssert (plane.Evalue (m_vertex[ptr->m_vertex]) > dgFloat32 (0.0f)); - dgAssert (plane.Evalue (m_vertex[ptr->m_twin->m_vertex]) < dgFloat32 (0.0f)); - - dgVector dp (m_vertex[ptr->m_twin->m_vertex] - m_vertex[ptr->m_vertex]); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - dgFloat32 t = plane.DotProduct(dp).GetScalar(); - if (t >= dgFloat32 (-1.e-24f)) { - t = dgFloat32 (0.0f); - } else { - t = side0 / t; - if (t > dgFloat32 (0.0f)) { - t = dgFloat32 (0.0f); - } - if (t < dgFloat32 (-1.0f)) { - t = dgFloat32 (-1.0f); - } - } - - dgAssert (t <= dgFloat32 (0.01f)); - dgAssert (t >= dgFloat32 (-1.05f)); - contactsOut[count] = m_vertex[ptr->m_vertex] - dp.Scale (t); - - dgConvexSimplexEdge* ptr1 = ptr->m_next; - for (; ptr1 != ptr; ptr1 = ptr1->m_next) { - dgAssert (m_vertex[ptr->m_twin->m_vertex].m_w == dgFloat32 (0.0f)); - side0 = plane.Evalue (m_vertex[ptr1->m_twin->m_vertex]); - if (side0 >= dgFloat32 (0.0f)) { - break; - } - } - dgAssert (ptr1 != ptr); - ptr = ptr1->m_twin; - } else { - contactsOut[count] = m_vertex[ptr->m_vertex]; - dgConvexSimplexEdge* ptr1 = ptr->m_next; - for (; ptr1 != ptr; ptr1 = ptr1->m_next) { - dgAssert (m_vertex[ptr1->m_twin->m_vertex].m_w == dgFloat32 (0.0f)); - side0 = plane.Evalue (m_vertex[ptr1->m_twin->m_vertex]); - if (side0 >= dgFloat32 (0.0f)) { - break; - } - } - - if (ptr1 == ptr) { - ptr = ptr1->m_prev->m_twin; - } else { - ptr = ptr1->m_twin; - } - } - - count ++; - maxCount ++; - if (count >= DG_CLIP_MAX_POINT_COUNT) { - for (count = 0; count < (DG_CLIP_MAX_POINT_COUNT >> 1); count ++) { - contactsOut[count] = contactsOut[count * 2]; - } - } - - } while ((ptr != firstEdge) && (maxCount < DG_CLIP_MAX_COUNT)); - dgAssert (maxCount < DG_CLIP_MAX_COUNT); - - if (count > 2) { - count = RectifyConvexSlice (count, normal, contactsOut); - } - } - } - } - return count; -} - -dgInt32 dgCollisionConvex::BuildCylinderCapPoly (dgFloat32 radius, const dgMatrix& transform, dgVector* const vertexOut) const -{ -/* - dgFloat32 h = 2.0; - dgInt32 n = 8; - dgFloat32 a0 = h * h * (dgPi / n); - - dgFloat32 h0 = h * dgSin (0.5 * dgPI2 / n); - dgFloat32 h1 = h * dgCos (0.5 * dgPI2 / n); - dgFloat32 a1 = h * h * (dgSin (0.5 * dgPI2 / n) * dgCos (0.5 * dgPI2 / n)); - - dgFloat32 a = h * h * (dgPi / n - 0.5f * dgSin (dgPI2 / n)); - - for (int i = 8; i < 16; i ++) { - dgFloat32 den = dgPi / i - 0.5f * dgSin (dgPI2 / i); - dgFloat32 h1 = dgSqrt (a / den); - dgFloat32 h2 = dgSqrt (a / den); - } -*/ - - dgInt32 count = (radius < dgFloat32 (1.0f)) ? 8 : ((radius < dgFloat32 (2.0f)) ? 12 : 16); - - dgFloat32 angle = dgPI2 / count; - dgVector r (dgFloat32 (0.0f), dgFloat32 (0.0f), radius, dgFloat32 (0.0f)); - dgMatrix rotation (dgPitchMatrix(angle)); - - for (dgInt32 i = 0; i < count; i++) { - vertexOut[i] = transform.TransformVector(r); - r = rotation.RotateVector(r); - } - - return count; -} \ No newline at end of file diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionConvex.h b/thirdparty/src/newton/dgPhysics/dgCollisionConvex.h deleted file mode 100644 index c3914356f..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionConvex.h +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_CONVEX_COLLISION_H__ -#define _DG_CONVEX_COLLISION_H__ - -#include "dgCollision.h" - -#define DG_CLIP_MAX_COUNT 512 -#define DG_CLIP_MAX_POINT_COUNT 64 -#define D_MIN_CONVEX_SHAPE_SIZE dgFloat32 (1.0f/128.0f) - - -DG_MSC_VECTOR_ALIGNMENT -class dgCollisionConvex: public dgCollision -{ - public: - class dgConvexSimplexEdge - { - public: - dgConvexSimplexEdge* m_twin; - dgConvexSimplexEdge* m_next; - dgConvexSimplexEdge* m_prev; - dgInt32 m_vertex; - }; - - virtual dgInt32 GetConvexVertexCount() const { return m_vertexCount;} - virtual void CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const; - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - virtual dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const; - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const; - - bool IntesectionTest (dgCollisionParamProxy& proxy) const; - - protected: - dgCollisionConvex (dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgCollisionID id); - dgCollisionConvex (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - ~dgCollisionConvex (); - - virtual void SerializeLow(dgSerialize callback, void* const userData) const; - - virtual dgVector CalculateVolumeIntegral (const dgMatrix& globalMatrix, const dgVector& plane, const dgCollisionInstance& parentScale) const; - static void CalculateInertia (void *userData, int vertexCount, const dgFloat32* const FaceArray, int faceId); - - virtual dgFloat32 GetVolume () const; - - virtual dgFloat32 GetBoxMinRadius () const; - virtual dgFloat32 GetBoxMaxRadius () const; - - dgInt32 RayCastClosestFace (dgVector* tetrahedrum, const dgVector& origin, dgFloat32& pointDist) const; - dgVector CalculateVolumeIntegral (const dgPlane& plane) const; - - void SetVolumeAndCG (); - bool SanityCheck (dgPolyhedra& hull) const; - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - - virtual void MassProperties (); - virtual dgMatrix CalculateInertiaAndCenterOfMass (const dgMatrix& m_alignMatrix, const dgVector& localScale, const dgMatrix& matrix) const; - virtual dgFloat32 CalculateMassProperties (const dgMatrix& offset, dgVector& inertia, dgVector& crossInertia, dgVector& centerOfMass) const; - - bool SanityCheck(dgInt32 count, const dgVector& normal, dgVector* const contactsOut) const; - - dgInt32 RectifyConvexSlice (dgInt32 count, const dgVector& normal, dgVector* const contactsOut) const; - - virtual dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const; - virtual const dgConvexSimplexEdge** GetVertexToEdgeMapping() const {return NULL;} - - dgInt32 BuildCylinderCapPoly (dgFloat32 radius, const dgMatrix& transform, dgVector* const vertexOut) const; - - dgVector* m_vertex; - dgConvexSimplexEdge* m_simplex; - - dgFloat32 m_boxMinRadius; - dgFloat32 m_boxMaxRadius; - dgFloat32 m_simplexVolume; - - dgUnsigned16 m_edgeCount; - dgUnsigned16 m_vertexCount; - - friend class dgWorld; - friend class dgBroadPhase; - friend class dgMinkowskiConv; - friend class dgCollisionCompound; - friend class dgCollisionConvexModifier; -} DG_GCC_VECTOR_ALIGNMENT; - - - -#endif //AFX_DGCONVEXCOLLISION_H__57E159CE_6B6F_42DE_891C_1F6C38EB9D29_H - - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionConvexHull.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionConvexHull.cpp deleted file mode 100644 index 45edb170b..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionConvexHull.cpp +++ /dev/null @@ -1,1046 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgContact.h" -#include "dgMeshEffect.h" -#include "dgCollisionConvexHull.h" - - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#define DG_CONVEX_VERTEX_BOX_CELL_SIZE (1<<3) -#define DG_CONVEX_VERTEX_SPLITE_SIZE (DG_CONVEX_VERTEX_BOX_CELL_SIZE * 3) - -DG_MSC_VECTOR_ALIGNMENT -class dgCollisionConvexHull::dgSOAVectorArray -{ - public: - dgVector m_x[DG_CONVEX_VERTEX_SPLITE_SIZE/4]; - dgVector m_y[DG_CONVEX_VERTEX_SPLITE_SIZE/4]; - dgVector m_z[DG_CONVEX_VERTEX_SPLITE_SIZE/4]; - dgVector m_index[DG_CONVEX_VERTEX_SPLITE_SIZE/4]; -} DG_GCC_VECTOR_ALIGNMENT; - -DG_MSC_VECTOR_ALIGNMENT -class dgCollisionConvexHull::dgConvexBox -{ - public: - dgVector m_box[2]; - dgInt32 m_vertexStart; - dgInt32 m_vertexCount; - dgInt32 m_leftBox; - dgInt32 m_rightBox; -} DG_GCC_VECTOR_ALIGNMENT; - -dgCollisionConvexHull::dgCollisionConvexHull(dgMemoryAllocator* const allocator, dgUnsigned32 signature) - :dgCollisionConvex(allocator, signature, m_convexHullCollision) - ,m_supportTree(NULL) - ,m_faceArray(NULL) - ,m_soaVertexArray(NULL) - ,m_vertexToEdgeMapping(NULL) - ,m_faceCount(0) - ,m_soaVertexCount(0) - ,m_supportTreeCount(0) -{ - m_edgeCount = 0; - m_vertexCount = 0; - m_vertex = NULL; - m_simplex = NULL; - m_rtti |= dgCollisionConvexHull_RTTI; -} - -dgCollisionConvexHull::dgCollisionConvexHull(dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgInt32 count, dgInt32 strideInBytes, dgFloat32 tolerance, const dgFloat32* const vertexArray) - :dgCollisionConvex(allocator, signature, m_convexHullCollision) - ,m_supportTree(NULL) - ,m_faceArray(NULL) - ,m_soaVertexArray(NULL) - ,m_vertexToEdgeMapping(NULL) - ,m_faceCount(0) - ,m_soaVertexCount(0) - ,m_supportTreeCount(0) -{ - m_edgeCount = 0; - m_vertexCount = 0; - m_vertex = NULL; - m_simplex = NULL; - m_rtti |= dgCollisionConvexHull_RTTI; - - BuildHull (count, strideInBytes, tolerance, vertexArray); -} - -dgCollisionConvexHull::dgCollisionConvexHull(dgWorld* const world, dgDeserialize callback, void* const userData, dgInt32 revisionNumber) - :dgCollisionConvex (world, callback, userData, revisionNumber) - ,m_supportTree(NULL) - ,m_faceArray(NULL) - ,m_soaVertexArray(NULL) - ,m_vertexToEdgeMapping(NULL) - ,m_faceCount(0) - ,m_soaVertexCount(0) - ,m_supportTreeCount(0) -{ - m_rtti |= dgCollisionConvexHull_RTTI; - - dgInt32 edgeCount; - dgInt32 vertexCount; - callback(userData, &vertexCount, sizeof(dgInt32)); - callback(userData, &edgeCount, sizeof(dgInt32)); - callback(userData, &m_faceCount, sizeof(dgInt32)); - callback(userData, &m_supportTreeCount, sizeof(dgInt32)); - - m_edgeCount = dgUnsigned16(edgeCount); - m_vertexCount = dgUnsigned16 (vertexCount); - - m_vertex = (dgVector*) m_allocator->Malloc (dgInt32 (m_vertexCount * sizeof (dgVector))); - m_simplex = (dgConvexSimplexEdge*) m_allocator->Malloc (dgInt32 (m_edgeCount * sizeof (dgConvexSimplexEdge))); - m_faceArray = (dgConvexSimplexEdge **) m_allocator->Malloc(dgInt32 (m_faceCount * sizeof(dgConvexSimplexEdge *))); - m_vertexToEdgeMapping = (const dgConvexSimplexEdge **) m_allocator->Malloc(dgInt32 (m_vertexCount * sizeof(dgConvexSimplexEdge *))); - - callback(userData, m_vertex, m_vertexCount * sizeof(dgVector)); - - if (m_supportTreeCount) { - m_supportTree = (dgConvexBox *) m_allocator->Malloc(dgInt32 (m_supportTreeCount * sizeof(dgConvexBox))); - callback (userData, m_supportTree, m_supportTreeCount * sizeof(dgConvexBox)); - } - - for (dgInt32 i = 0; i < m_edgeCount; i ++) { - dgInt32 serialization[4]; - callback (userData, serialization, sizeof (serialization)); - - m_simplex[i].m_vertex = serialization[0]; - m_simplex[i].m_twin = m_simplex + serialization[1]; - m_simplex[i].m_next = m_simplex + serialization[2]; - m_simplex[i].m_prev = m_simplex + serialization[3]; - } - - for (dgInt32 i = 0; i < m_faceCount; i ++) { - dgInt32 faceOffset; - callback (userData, &faceOffset, sizeof (dgInt32)); - m_faceArray[i] = m_simplex + faceOffset; - } - - for (dgInt32 i = 0; i < m_vertexCount; i ++) { - dgInt32 faceOffset; - callback (userData, &faceOffset, sizeof (dgInt32)); - m_vertexToEdgeMapping[i] = m_simplex + faceOffset; - } - - if (vertexCount <= DG_CONVEX_VERTEX_SPLITE_SIZE) { - CreateSOAdata(); - } - - SetVolumeAndCG (); -} - -dgCollisionConvexHull::~dgCollisionConvexHull() -{ - if (m_vertexToEdgeMapping) { - m_allocator->Free(m_vertexToEdgeMapping); - } - - if (m_faceArray) { - m_allocator->Free(m_faceArray); - } - - if (m_supportTree) { - m_allocator->Free(m_supportTree); - } - - if (m_soaVertexArray) { - m_allocator->Free(m_soaVertexArray); - } -} - -void dgCollisionConvexHull::Serialize(dgSerialize callback, void* const userData) const -{ - SerializeLow(callback, userData); - - dgInt32 edgeCount = m_edgeCount; - dgInt32 vertexCount = m_vertexCount; - callback(userData, &vertexCount, sizeof(dgInt32)); - callback(userData, &edgeCount, sizeof(dgInt32)); - callback(userData, &m_faceCount, sizeof(dgInt32)); - callback(userData, &m_supportTreeCount, sizeof(dgInt32)); - - callback(userData, m_vertex, m_vertexCount * sizeof(dgVector)); - - if (m_supportTreeCount) { - callback(userData, m_supportTree, m_supportTreeCount * sizeof(dgConvexBox)); - } - - for (dgInt32 i = 0; i < m_edgeCount; i++) { - dgInt32 serialization[4]; - serialization[0] = m_simplex[i].m_vertex; - serialization[1] = dgInt32(m_simplex[i].m_twin - m_simplex); - serialization[2] = dgInt32(m_simplex[i].m_next - m_simplex); - serialization[3] = dgInt32(m_simplex[i].m_prev - m_simplex); - callback(userData, serialization, sizeof(serialization)); - } - - for (dgInt32 i = 0; i < m_faceCount; i++) { - dgInt32 faceOffset; - faceOffset = dgInt32(m_faceArray[i] - m_simplex); - callback(userData, &faceOffset, sizeof(dgInt32)); - } - - for (dgInt32 i = 0; i < m_vertexCount; i++) { - dgInt32 faceOffset; - faceOffset = dgInt32(m_vertexToEdgeMapping[i] - m_simplex); - callback(userData, &faceOffset, sizeof(dgInt32)); - } -} - -void dgCollisionConvexHull::BuildHull (dgInt32 count, dgInt32 strideInBytes, dgFloat32 tolerance, const dgFloat32* const vertexArray) -{ - Create (count, strideInBytes, vertexArray, tolerance); -} - -void dgCollisionConvexHull::MassProperties () -{ - dgFloat32 volume = dgCollisionConvex::CalculateMassProperties(dgGetIdentityMatrix(), m_inertia, m_crossInertia, m_centerOfMass); - if (volume < dgFloat32 (1.0e-6f)) { - volume = dgFloat32 (1.0e-6f); - } - dgFloat32 invVolume = dgFloat32(1.0f) / volume; - m_inertia = m_inertia.Scale(invVolume); - m_crossInertia = m_crossInertia.Scale(invVolume); - m_centerOfMass = m_centerOfMass.Scale(invVolume); - m_centerOfMass.m_w = volume; - - - dgMatrix inertia(dgGetIdentityMatrix()); - inertia[0][0] = m_inertia[0]; - inertia[1][1] = m_inertia[1]; - inertia[2][2] = m_inertia[2]; - inertia[0][1] = m_crossInertia[2]; - inertia[1][0] = m_crossInertia[2]; - inertia[0][2] = m_crossInertia[1]; - inertia[2][0] = m_crossInertia[1]; - inertia[1][2] = m_crossInertia[0]; - inertia[2][1] = m_crossInertia[0]; - - dgVector origin(m_centerOfMass); - dgFloat32 originMag2 = origin.DotProduct(origin & dgVector::m_triplexMask).GetScalar(); - - dgMatrix Covariance(origin, origin); - dgMatrix parallel(dgGetIdentityMatrix()); - for (dgInt32 i = 0; i < 3; i++) { - parallel[i][i] = originMag2; - inertia[i] -= (parallel[i] - Covariance[i]); - dgAssert(inertia[i][i] > dgFloat32(0.0f)); - } - - m_inertia[0] = inertia[0][0]; - m_inertia[1] = inertia[1][1]; - m_inertia[2] = inertia[2][2]; - m_crossInertia[0] = inertia[2][1]; - m_crossInertia[1] = inertia[2][0]; - m_crossInertia[2] = inertia[1][0]; -} - -dgInt32 dgCollisionConvexHull::GetFaceIndices (dgInt32 index, dgInt32* const indices) const -{ - dgInt32 count = 0; - const dgConvexSimplexEdge* face = m_faceArray[index]; - do { - indices [count] = face->m_vertex; - count ++; - face = face->m_next; - } while (face != m_faceArray[index]); - - return count; -} - -dgBigVector dgCollisionConvexHull::FaceNormal (const dgEdge *face, const dgBigVector* const pool) const -{ - const dgEdge* edge = face; - dgBigVector p0 (pool[edge->m_incidentVertex]); - edge = edge->m_next; - - dgBigVector p1 (pool[edge->m_incidentVertex]); - dgBigVector e1 (p1 - p0); - - dgBigVector normal (dgFloat32 (0.0f)); - for (edge = edge->m_next; edge != face; edge = edge->m_next) { - dgBigVector p2 (pool[edge->m_incidentVertex]); - dgBigVector e2 (p2 - p0); - dgBigVector n1 (e1.CrossProduct(e2)); -#ifdef _DEBUG - dgAssert(n1.m_w == dgFloat32(0.0f)); - dgFloat64 mag = normal.DotProduct(n1).GetScalar(); - dgAssert ( mag >= -dgFloat32 (0.1f)); -#endif - normal += n1; - e1 = e2; - } - - dgFloat64 den = sqrt (normal.DotProduct(normal).GetScalar()) + dgFloat64 (1.0e-24f); - normal = normal.Scale (dgFloat64 (1.0f)/ den); - -#ifdef _DEBUG - edge = face; - dgBigVector e0 (pool[edge->m_incidentVertex] - pool[edge->m_prev->m_incidentVertex]); - do { - dgBigVector de1 (pool[edge->m_next->m_incidentVertex] - pool[edge->m_incidentVertex]); - dgBigVector dn1 (e0.CrossProduct(de1)); - dgFloat64 x = normal.DotProduct(dn1).GetScalar(); - dgAssert (x > -dgFloat64 (0.01f)); - e0 = de1; - edge = edge->m_next; - } while (edge != face); -#endif - return normal; -} - -bool dgCollisionConvexHull::RemoveCoplanarEdge (dgPolyhedra& polyhedra, const dgBigVector* const hullVertexArray) const -{ - bool removeEdge = false; - // remove coplanar edges - dgInt32 mark = polyhedra.IncLRU(); - dgPolyhedra::Iterator iter (polyhedra); - for (iter.Begin(); iter; ) { - dgEdge* edge0 = &(*iter); - iter ++; - - if (edge0->m_incidentFace != -1) { - - if (edge0->m_mark < mark) { - edge0->m_mark = mark; - edge0->m_twin->m_mark = mark; - dgBigVector normal0 (FaceNormal (edge0, &hullVertexArray[0])); - dgBigVector normal1 (FaceNormal (edge0->m_twin, &hullVertexArray[0])); - - dgFloat64 test = normal0.DotProduct(normal1).GetScalar(); - if (test > dgFloat64 (0.99995f)) { - - if ((edge0->m_twin->m_next->m_twin->m_next != edge0) && (edge0->m_next->m_twin->m_next != edge0->m_twin)) { - #define DG_MAX_EDGE_ANGLE dgFloat32 (1.0e-3f) - - if (edge0->m_twin == &(*iter)) { - if (iter) { - iter ++; - } - } - - dgBigVector e1 (hullVertexArray[edge0->m_twin->m_next->m_next->m_incidentVertex] - hullVertexArray[edge0->m_incidentVertex]); - dgBigVector e0 (hullVertexArray[edge0->m_incidentVertex] - hullVertexArray[edge0->m_prev->m_incidentVertex]); - - dgAssert(e0.m_w == dgFloat64(0.0f)); - dgAssert(e1.m_w == dgFloat64(0.0f)); - dgAssert (e0.DotProduct(e0).GetScalar() >= dgFloat64 (0.0f)); - dgAssert (e1.DotProduct(e1).GetScalar() >= dgFloat64 (0.0f)); - - e0 = e0.Scale (dgFloat64 (1.0f) / sqrt (e0.DotProduct(e0).GetScalar())); - e1 = e1.Scale (dgFloat64 (1.0f) / sqrt (e1.DotProduct(e1).GetScalar())); - dgBigVector n1 (e0.CrossProduct(e1)); - - dgFloat64 projection = n1.DotProduct(normal0).GetScalar(); - if (projection >= DG_MAX_EDGE_ANGLE) { - - dgBigVector e11 (hullVertexArray[edge0->m_next->m_next->m_incidentVertex] - hullVertexArray[edge0->m_twin->m_incidentVertex]); - dgBigVector e00 (hullVertexArray[edge0->m_twin->m_incidentVertex] - hullVertexArray[edge0->m_twin->m_prev->m_incidentVertex]); - dgAssert (e00.m_w == dgFloat64 (0.0f)); - dgAssert (e11.m_w == dgFloat64 (0.0f)); - dgAssert (e00.DotProduct(e00).GetScalar() >= dgFloat64 (0.0f)); - dgAssert (e11.DotProduct(e11).GetScalar() >= dgFloat64 (0.0f)); - e00 = e00.Scale(dgFloat64(1.0f) / sqrt(e00.DotProduct(e00).GetScalar())); - e11 = e11.Scale(dgFloat64(1.0f) / sqrt(e11.DotProduct(e11).GetScalar())); - - dgBigVector n11 (e00.CrossProduct(e11)); - projection = n11.DotProduct(normal0).GetScalar(); - if (projection >= DG_MAX_EDGE_ANGLE) { - dgAssert (&(*iter) != edge0); - dgAssert (&(*iter) != edge0->m_twin); - polyhedra.DeleteEdge(edge0); - removeEdge = true; - } - } - - } else { - dgEdge* next = edge0->m_next; - dgEdge* prev = edge0->m_prev; - polyhedra.DeleteEdge(edge0); - for (edge0 = next; edge0->m_prev->m_twin == edge0; edge0 = next) { - next = edge0->m_next; - polyhedra.DeleteEdge(edge0); - } - - for (edge0 = prev; edge0->m_next->m_twin == edge0; edge0 = prev) { - prev = edge0->m_prev; - polyhedra.DeleteEdge(edge0); - } - iter.Begin(); - removeEdge = true; - } - } - } - } - } - - return removeEdge; -} - - -bool dgCollisionConvexHull::CheckConvex (dgPolyhedra& polyhedra1, const dgBigVector* hullVertexArray) const -{ - dgPolyhedra polyhedra(polyhedra1); - - dgPolyhedra::Iterator iter (polyhedra); - dgBigVector center (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - - dgInt32 count = 0; - dgInt32 mark = polyhedra.IncLRU(); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - if (edge->m_mark < mark) { - count ++; - center += hullVertexArray[edge->m_incidentVertex]; - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr = ptr->m_twin->m_next; - } while (ptr != edge); - } - } - center = center.Scale (dgFloat64 (1.0f) / dgFloat64 (count)); - - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - dgBigVector normal0 (FaceNormal (edge, hullVertexArray)); - dgBigVector normal1 (FaceNormal (edge->m_twin, hullVertexArray)); - - dgBigPlane plane0 (normal0, - normal0.DotProduct(hullVertexArray[edge->m_incidentVertex]).GetScalar()); - dgBigPlane plane1 (normal1, - normal1.DotProduct(hullVertexArray[edge->m_twin->m_incidentVertex]).GetScalar()); - dgFloat64 test0 = plane0.Evalue(center); - if (test0 > dgFloat64 (1.0e-3f)) { - return false; - } - dgFloat64 test1 = plane1.Evalue(center); -// if (test1 > dgFloat64 (0.0f)) { - if (test1 > dgFloat64 (1.0e-3f)) { - return false; - } - } - return true; -} - -bool dgCollisionConvexHull::Create (dgInt32 count, dgInt32 strideInBytes, const dgFloat32* const vertexArray, dgFloat32 tolerance) -{ - dgInt32 stride = strideInBytes / sizeof (dgFloat32); - dgStack<dgFloat64> buffer(3 * 2 * count); - for (dgInt32 i = 0; i < count; i ++) { - buffer[i * 3 + 0] = vertexArray[i * stride + 0]; - buffer[i * 3 + 1] = vertexArray[i * stride + 1]; - buffer[i * 3 + 2] = vertexArray[i * stride + 2]; - } - - dgConvexHull3d* convexHull = new (GetAllocator()) dgConvexHull3d (GetAllocator(), &buffer[0], 3 * sizeof (dgFloat64), count, tolerance); - if (!convexHull->GetCount()) { - // this is a degenerated hull hull to add some thickness and for a thick plane - delete convexHull; - - dgStack<dgVector> tmp(3 * count); - for (dgInt32 i = 0; i < count; i ++) { - tmp[i][0] = dgFloat32 (buffer[i*3 + 0]); - tmp[i][1] = dgFloat32 (buffer[i*3 + 1]); - tmp[i][2] = dgFloat32 (buffer[i*3 + 2]); - tmp[i][2] = dgFloat32 (0.0f); - } - - dgObb sphere; - sphere.SetDimensions (&tmp[0][0], sizeof (dgVector), count); - - dgInt32 index = 0; - dgFloat32 size = dgFloat32 (1.0e10f); - for (dgInt32 i = 0; i < 3; i ++) { - if (sphere.m_size[i] < size) { - index = i; - size = sphere.m_size[i]; - } - } - dgVector normal (dgFloat32 (0.0f)); - normal[index] = dgFloat32 (1.0f); - dgVector step = sphere.RotateVector (normal.Scale (dgFloat32 (0.05f))); - for (dgInt32 i = 0; i < count; i ++) { - dgVector p1 (tmp[i] + step); - dgVector p2 (tmp[i] - step); - - buffer[i * 3 + 0] = p1.m_x; - buffer[i * 3 + 1] = p1.m_y; - buffer[i * 3 + 2] = p1.m_z; - buffer[(i + count) * 3 + 0] = p2.m_x; - buffer[(i + count) * 3 + 1] = p2.m_y; - buffer[(i + count) * 3 + 2] = p2.m_z; - } - count *= 2; - convexHull = new (GetAllocator()) dgConvexHull3d (GetAllocator(), &buffer[0], 3 * sizeof (dgFloat64), count, tolerance); - if (!convexHull->GetCount()) { - delete convexHull; - return false; - } - } - - // check for degenerated faces - for (bool success = false; !success; ) { - success = true; - const dgBigVector* const hullVertexArray = convexHull->GetVertexPool(); - - dgStack<dgInt8> mask(convexHull->GetVertexCount()); - memset (&mask[0], 1, mask.GetSizeInBytes()); - for (dgConvexHull3d::dgListNode* node = convexHull->GetFirst(); node; node = node->GetNext()) { - dgConvexHull3DFace& face = node->GetInfo(); - const dgBigVector& p0 = hullVertexArray[face.m_index[0]]; - const dgBigVector& p1 = hullVertexArray[face.m_index[1]]; - const dgBigVector& p2 = hullVertexArray[face.m_index[2]]; - dgAssert(p0.m_w == p1.m_w); - dgAssert(p0.m_w == p2.m_w); - dgBigVector p1p0 (p1 - p0); - dgBigVector p2p0 (p2 - p0); - dgBigVector normal (p2p0.CrossProduct(p1p0)); - dgFloat64 mag2 = normal.DotProduct(normal).GetScalar(); - if (mag2 < dgFloat64 (1.0e-6f * 1.0e-6f)) { - success = false; - dgInt32 index = -1; - dgBigVector p2p1 (p2 - p1); - dgFloat64 dist10 = p1p0.DotProduct(p1p0).GetScalar(); - dgFloat64 dist20 = p2p0.DotProduct(p2p0).GetScalar(); - dgFloat64 dist21 = p2p1.DotProduct(p2p1).GetScalar(); - if ((dist10 >= dist20) && (dist10 >= dist21)) { - index = 2; - } else if ((dist20 >= dist10) && (dist20 >= dist21)) { - index = 1; - } else if ((dist21 >= dist10) && (dist21 >= dist20)) { - index = 0; - } - dgAssert (index != -1); - mask[face.m_index[index]] = 0; - } - } - if (!success) { - dgInt32 count1 = 0; - dgInt32 vertexCount = convexHull->GetVertexCount(); - for (dgInt32 i = 0; i < vertexCount; i ++) { - if (mask[i]) { - buffer[count1 * 3 + 0] = hullVertexArray[i].m_x; - buffer[count1 * 3 + 1] = hullVertexArray[i].m_y; - buffer[count1 * 3 + 2] = hullVertexArray[i].m_z; - count1 ++; - } - } - delete convexHull; - convexHull = new (GetAllocator()) dgConvexHull3d (GetAllocator(), &buffer[0], 3 * sizeof (dgFloat64), count1, tolerance); - } - } - - dgAssert (convexHull); - dgInt32 vertexCount = convexHull->GetVertexCount(); - if (vertexCount < 4) { - delete convexHull; - return false; - } - - const dgBigVector* const hullVertexArray = convexHull->GetVertexPool(); - dgPolyhedra polyhedra (GetAllocator()); - polyhedra.BeginFace(); - for (dgConvexHull3d::dgListNode* node = convexHull->GetFirst(); node; node = node->GetNext()) { - dgConvexHull3DFace& face = node->GetInfo(); - polyhedra.AddFace (face.m_index[0], face.m_index[1], face.m_index[2]); - } - polyhedra.EndFace(); - - if (vertexCount > 4) { - while (RemoveCoplanarEdge (polyhedra, hullVertexArray)); - } - - dgStack<dgInt32> vertexMap(vertexCount); - memset (&vertexMap[0], -1, vertexCount * sizeof (dgInt32)); - - dgInt32 mark = polyhedra.IncLRU(); - dgPolyhedra::Iterator iter (polyhedra); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if (edge->m_mark != mark) { - if (vertexMap[edge->m_incidentVertex] == -1) { - vertexMap[edge->m_incidentVertex] = m_vertexCount; - m_vertexCount ++; - } - dgEdge* ptr = edge; - do { - ptr->m_mark = mark; - ptr->m_userData = m_edgeCount; - m_edgeCount ++; - ptr = ptr->m_twin->m_next; - } while (ptr != edge) ; - } - } - - m_vertex = (dgVector*) m_allocator->Malloc (dgInt32 (m_vertexCount * sizeof (dgVector))); - m_simplex = (dgConvexSimplexEdge*) m_allocator->Malloc (dgInt32 (m_edgeCount * sizeof (dgConvexSimplexEdge))); - m_vertexToEdgeMapping = (const dgConvexSimplexEdge**) m_allocator->Malloc (dgInt32 (m_vertexCount * sizeof (dgConvexSimplexEdge*))); - - for (dgInt32 i = 0; i < vertexCount; i ++) { - if (vertexMap[i] != -1) { - m_vertex[vertexMap[i]] = hullVertexArray[i]; - m_vertex[vertexMap[i]].m_w = dgFloat32 (0.0f); - } - } - delete convexHull; - - vertexCount = m_vertexCount; - mark = polyhedra.IncLRU();; - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &iter.GetNode()->GetInfo(); - if (edge->m_mark != mark) { - dgEdge *ptr = edge; - do { - ptr->m_mark = mark; - dgConvexSimplexEdge* const simplexPtr = &m_simplex[ptr->m_userData]; - simplexPtr->m_vertex = vertexMap[ptr->m_incidentVertex]; - simplexPtr->m_next = &m_simplex[ptr->m_next->m_userData]; - simplexPtr->m_prev = &m_simplex[ptr->m_prev->m_userData]; - simplexPtr->m_twin = &m_simplex[ptr->m_twin->m_userData]; - - ptr = ptr->m_twin->m_next; - } while (ptr != edge) ; - } - } - - - m_faceCount = 0; - dgStack<char> faceMarks (m_edgeCount); - memset (&faceMarks[0], 0, m_edgeCount * sizeof (dgInt8)); - - dgStack<dgConvexSimplexEdge*> faceArray (m_edgeCount); - for (dgInt32 i = 0; i < m_edgeCount; i ++) { - dgConvexSimplexEdge* const face = &m_simplex[i]; - if (!faceMarks[i]) { - dgConvexSimplexEdge* ptr = face; - do { - dgAssert ((ptr - m_simplex) >= 0); - faceMarks[dgInt32 (ptr - m_simplex)] = '1'; - ptr = ptr->m_next; - } while (ptr != face); - - faceArray[m_faceCount] = face; - m_faceCount ++; - } - } - m_faceArray = (dgConvexSimplexEdge **) m_allocator->Malloc(dgInt32 (m_faceCount * sizeof(dgConvexSimplexEdge *))); - memcpy (m_faceArray, &faceArray[0], m_faceCount * sizeof(dgConvexSimplexEdge *)); - - if (vertexCount > DG_CONVEX_VERTEX_SPLITE_SIZE) { - // create a face structure for support vertex - dgStack<dgConvexBox> boxTree (vertexCount); - dgTree<dgVector,dgInt32> sortTree(GetAllocator()); - dgStack<dgTree<dgVector,dgInt32>::dgTreeNode*> vertexNodeList(vertexCount); - - dgVector boxP0 ( dgFloat32 (1.0e15f)); - dgVector boxP1 (-dgFloat32 (1.0e15f)); - for (dgInt32 i = 0; i < vertexCount; i ++) { - const dgVector& p = m_vertex[i]; - vertexNodeList[i] = sortTree.Insert (p, i); - boxP0 = boxP0.GetMin(p); - boxP1 = boxP1.GetMax(p); - } - - boxTree[0].m_box[0] = boxP0 & dgVector::m_triplexMask; - boxTree[0].m_box[1] = boxP1 & dgVector::m_triplexMask; - boxTree[0].m_leftBox = -1; - boxTree[0].m_rightBox = -1; - boxTree[0].m_vertexStart = 0; - boxTree[0].m_vertexCount = vertexCount; - dgInt32 boxCount = 1; - - dgInt32 stack = 1; - dgInt32 stackBoxPool[64]; - stackBoxPool[0] = 0; - - while (stack) { - stack --; - dgInt32 boxIndex = stackBoxPool[stack]; - dgConvexBox& box = boxTree[boxIndex]; - if (box.m_vertexCount > DG_CONVEX_VERTEX_BOX_CELL_SIZE) { - dgVector median (dgFloat32 (0.0f)); - dgVector varian (dgFloat32 (0.0f)); - for (dgInt32 i = 0; i < box.m_vertexCount; i ++) { - dgVector& p = vertexNodeList[box.m_vertexStart + i]->GetInfo(); - boxP0 = boxP0.GetMin(p); - boxP1 = boxP1.GetMax(p); - median += p; - varian += p * p; - } - - varian = varian.Scale (dgFloat32 (box.m_vertexCount)) - median * median; - dgInt32 index = 0; - dgFloat64 maxVarian = dgFloat64 (-1.0e10f); - for (dgInt32 i = 0; i < 3; i ++) { - if (varian[i] > maxVarian) { - index = i; - maxVarian = varian[i]; - } - } - dgVector center = median.Scale (dgFloat32 (1.0f) / dgFloat32 (box.m_vertexCount)); - dgFloat32 test = center[index]; - - dgInt32 i0 = 0; - dgInt32 i1 = box.m_vertexCount - 1; - do { - for (; i0 <= i1; i0 ++) { - dgFloat32 val = vertexNodeList[box.m_vertexStart + i0]->GetInfo()[index]; - if (val > test) { - break; - } - } - - for (; i1 >= i0; i1 --) { - dgFloat32 val = vertexNodeList[box.m_vertexStart + i1]->GetInfo()[index]; - if (val < test) { - break; - } - } - - if (i0 < i1) { - dgSwap(vertexNodeList[box.m_vertexStart + i0], vertexNodeList[box.m_vertexStart + i1]); - i0++; - i1--; - } - } while (i0 <= i1); - - if (i0 == 0){ - i0 = box.m_vertexCount / 2; - } - if (i0 >= (box.m_vertexCount - 1)){ - i0 = box.m_vertexCount / 2; - } - - { - // insert right branch AABB - dgVector rightBoxP0 ( dgFloat32 (1.0e15f)); - dgVector rightBoxP1 (-dgFloat32 (1.0e15f)); - for (dgInt32 i = i0; i < box.m_vertexCount; i ++) { - const dgVector& p = vertexNodeList[box.m_vertexStart + i]->GetInfo(); - rightBoxP0 = rightBoxP0.GetMin(p); - rightBoxP1 = rightBoxP1.GetMax(p); - } - - box.m_rightBox = boxCount; - boxTree[boxCount].m_box[0] = rightBoxP0 & dgVector::m_triplexMask; - boxTree[boxCount].m_box[1] = rightBoxP1 & dgVector::m_triplexMask; - boxTree[boxCount].m_leftBox = -1; - boxTree[boxCount].m_rightBox = -1; - boxTree[boxCount].m_vertexStart = box.m_vertexStart + i0; - boxTree[boxCount].m_vertexCount = box.m_vertexCount - i0; - stackBoxPool[stack] = boxCount; - stack ++; - boxCount ++; - } - - { - // insert left branch AABB - dgVector leftBoxP0 ( dgFloat32 (1.0e15f)); - dgVector leftBoxP1 (-dgFloat32 (1.0e15f)); - for (dgInt32 i = 0; i < i0; i ++) { - const dgVector& p = vertexNodeList[box.m_vertexStart + i]->GetInfo(); - leftBoxP0 = leftBoxP0.GetMin(p); - leftBoxP1 = leftBoxP1.GetMax(p); - } - - box.m_leftBox = boxCount; - boxTree[boxCount].m_box[0] = leftBoxP0 & dgVector::m_triplexMask;; - boxTree[boxCount].m_box[1] = leftBoxP1 & dgVector::m_triplexMask;; - boxTree[boxCount].m_leftBox = -1; - boxTree[boxCount].m_rightBox = -1; - boxTree[boxCount].m_vertexStart = box.m_vertexStart; - boxTree[boxCount].m_vertexCount = i0; - stackBoxPool[stack] = boxCount; - stack ++; - boxCount ++; - } - } - } - - for (dgInt32 i = 0; i < m_vertexCount; i ++) { - m_vertex[i] = vertexNodeList[i]->GetInfo(); - vertexNodeList[i]->GetInfo().m_w = dgFloat32 (i); - } - - m_supportTreeCount = boxCount; - m_supportTree = (dgConvexBox*) m_allocator->Malloc(dgInt32 (boxCount * sizeof(dgConvexBox))); - memcpy (m_supportTree, &boxTree[0], boxCount * sizeof(dgConvexBox)); - - for (dgInt32 i = 0; i < m_edgeCount; i ++) { - dgConvexSimplexEdge* const ptr = &m_simplex[i]; - dgTree<dgVector,dgInt32>::dgTreeNode* const node = sortTree.Find(ptr->m_vertex); - dgInt32 index = dgInt32 (node->GetInfo().m_w); - ptr->m_vertex = dgInt16 (index); - } - } else { - CreateSOAdata(); - } - - for (dgInt32 i = 0; i < m_edgeCount; i ++) { - dgConvexSimplexEdge* const edge = &m_simplex[i]; - m_vertexToEdgeMapping[edge->m_vertex] = edge; - } - - SetVolumeAndCG (); - return true; -} - -dgInt32 dgCollisionConvexHull::CalculateSignature (dgInt32 vertexCount, const dgFloat32* const vertexArray, dgInt32 strideInBytes) -{ - dgStack<dgUnsigned32> buffer(1 + 3 * vertexCount); - dgInt32 stride = dgInt32 (strideInBytes / sizeof (dgFloat32)); - - memset (&buffer[0], 0, size_t (buffer.GetSizeInBytes())); - buffer[0] = m_convexHullCollision; - - for (dgInt32 i = 0; i < vertexCount; i ++) { - buffer[1 + i * 3 + 0] = dgCollision::Quantize (vertexArray[i * stride + 0]); - buffer[1 + i * 3 + 1] = dgCollision::Quantize (vertexArray[i * stride + 1]); - buffer[1 + i * 3 + 2] = dgCollision::Quantize (vertexArray[i * stride + 2]); - } - return Quantize(&buffer[0], buffer.GetSizeInBytes()); -} - -dgInt32 dgCollisionConvexHull::CalculateSignature () const -{ - return dgInt32 (GetSignature()); -// return CalculateSignature (m_vertexCount, &m_vertex[0].m_x, sizeof (dgVector)); -} - - - -void dgCollisionConvexHull::SetCollisionBBox (const dgVector& p0__, const dgVector& p1__) -{ - dgAssert (0); -} - - - -void dgCollisionConvexHull::DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - dgTriplex vertex[256]; - for (dgInt32 i = 0; i < m_faceCount; i ++) { - dgConvexSimplexEdge* const face = m_faceArray[i]; - dgConvexSimplexEdge* ptr = face; - dgInt32 count = 0; - do { - vertex[count].m_x = m_vertex[ptr->m_vertex].m_x; - vertex[count].m_y = m_vertex[ptr->m_vertex].m_y; - vertex[count].m_z = m_vertex[ptr->m_vertex].m_z; - count ++; - dgAssert (count < sizeof (vertex)/ sizeof (vertex[0])); - ptr = ptr->m_next; - } while (ptr != face); - matrix.TransformTriplex (&vertex[0].m_x, sizeof (dgTriplex), &vertex[0].m_x, sizeof (dgTriplex), count); - callback (userData, count, &vertex[0].m_x, 0); - } -} - -void dgCollisionConvexHull::GetCollisionInfo(dgCollisionInfo* const info) const -{ - dgCollisionConvex::GetCollisionInfo(info); - - info->m_convexHull.m_vertexCount = m_vertexCount; - info->m_convexHull.m_strideInBytes = sizeof (dgVector); - info->m_convexHull.m_faceCount = m_faceCount; - info->m_convexHull.m_vertex = &m_vertex[0]; -} - -void dgCollisionConvexHull::CreateSOAdata() -{ - m_soaVertexArray = (dgSOAVectorArray*)m_allocator->Malloc(sizeof(dgSOAVectorArray)); - - m_soaVertexCount = ((m_vertexCount + 7) & -8) / 8; - dgVector array[DG_CONVEX_VERTEX_SPLITE_SIZE]; - for (dgInt32 i = 0; i < m_vertexCount; i++) { - array[i] = m_vertex[i]; - } - - for (dgInt32 i = m_vertexCount; i < DG_CONVEX_VERTEX_SPLITE_SIZE; i++) { - array[i] = array[0]; - } - - dgVector step(dgFloat32(4.0f)); - dgVector index(dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(2.0f), dgFloat32(3.0f)); - for (dgInt32 i = 0; i < DG_CONVEX_VERTEX_SPLITE_SIZE; i += 4) { - dgVector temp; - dgInt32 j = i / 4; - dgVector::Transpose4x4(m_soaVertexArray->m_x[j], m_soaVertexArray->m_y[j], m_soaVertexArray->m_z[j], temp, - m_vertex[i + 0], m_vertex[i + 1], m_vertex[i + 2], m_vertex[i + 3]); - m_soaVertexArray->m_index[j] = index; - index += step; - } - - dgFloat32* const indexPtr = &m_soaVertexArray->m_index[0][0]; - for (dgInt32 i = m_vertexCount; i < DG_CONVEX_VERTEX_SPLITE_SIZE; i++) { - indexPtr[i] = dgFloat32(0.0f); - } -} - -dgVector dgCollisionConvexHull::SupportVertex(const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgAssert(dir.m_w == dgFloat32(0.0f)); - dgInt32 index = -1; - dgVector maxProj(dgFloat32(-1.0e20f)); - if (m_vertexCount > DG_CONVEX_VERTEX_SPLITE_SIZE) { - dgFloat32 distPool[32]; - const dgConvexBox* stackPool[32]; - - dgInt32 ix = (dir[0] > dgFloat64(0.0f)) ? 1 : 0; - dgInt32 iy = (dir[1] > dgFloat64(0.0f)) ? 1 : 0; - dgInt32 iz = (dir[2] > dgFloat64(0.0f)) ? 1 : 0; - - const dgConvexBox& leftBox = m_supportTree[m_supportTree[0].m_leftBox]; - const dgConvexBox& rightBox = m_supportTree[m_supportTree[0].m_rightBox]; - - dgVector leftP(leftBox.m_box[ix][0], leftBox.m_box[iy][1], leftBox.m_box[iz][2], dgFloat32(0.0f)); - dgVector rightP(rightBox.m_box[ix][0], rightBox.m_box[iy][1], rightBox.m_box[iz][2], dgFloat32(0.0f)); - - dgFloat32 leftDist = leftP.DotProduct(dir).GetScalar(); - dgFloat32 rightDist = rightP.DotProduct(dir).GetScalar(); - if (rightDist >= leftDist) { - distPool[0] = leftDist; - stackPool[0] = &leftBox; - - distPool[1] = rightDist; - stackPool[1] = &rightBox; - } else { - distPool[0] = rightDist; - stackPool[0] = &rightBox; - - distPool[1] = leftDist; - stackPool[1] = &leftBox; - } - - dgInt32 stack = 2; - - while (stack) { - stack--; - dgFloat32 dist = distPool[stack]; - if (dist > maxProj.m_x) { - const dgConvexBox& box = *stackPool[stack]; - - if (box.m_leftBox > 0) { - dgAssert(box.m_rightBox > 0); - const dgConvexBox& leftBox1 = m_supportTree[box.m_leftBox]; - const dgConvexBox& rightBox1 = m_supportTree[box.m_rightBox]; - - dgVector leftBoxP(leftBox1.m_box[ix][0], leftBox1.m_box[iy][1], leftBox1.m_box[iz][2], dgFloat32(0.0f)); - dgVector rightBoxP(rightBox1.m_box[ix][0], rightBox1.m_box[iy][1], rightBox1.m_box[iz][2], dgFloat32(0.0f)); - - dgFloat32 leftBoxDist = leftBoxP.DotProduct(dir).GetScalar(); - dgFloat32 rightBoxDist = rightBoxP.DotProduct(dir).GetScalar(); - if (rightBoxDist >= leftBoxDist) { - distPool[stack] = leftBoxDist; - stackPool[stack] = &leftBox1; - stack++; - dgAssert(stack < sizeof (distPool) / sizeof (distPool[0])); - - distPool[stack] = rightBoxDist; - stackPool[stack] = &rightBox1; - stack++; - dgAssert(stack < sizeof (distPool) / sizeof (distPool[0])); - - } else { - distPool[stack] = rightBoxDist; - stackPool[stack] = &rightBox1; - stack++; - dgAssert(stack < sizeof (distPool) / sizeof (distPool[0])); - - distPool[stack] = leftBoxDist; - stackPool[stack] = &leftBox1; - stack++; - dgAssert(stack < sizeof (distPool) / sizeof (distPool[0])); - } - } else { - for (dgInt32 i = 0; i < box.m_vertexCount; i++) { - const dgVector& p = m_vertex[box.m_vertexStart + i]; - dgAssert(p.m_x >= box.m_box[0].m_x); - dgAssert(p.m_x <= box.m_box[1].m_x); - dgAssert(p.m_y >= box.m_box[0].m_y); - dgAssert(p.m_y <= box.m_box[1].m_y); - dgAssert(p.m_z >= box.m_box[0].m_z); - dgAssert(p.m_z <= box.m_box[1].m_z); - dgVector projectionDist(p.DotProduct(dir)); - dgVector mask(projectionDist > maxProj); - dgInt32 intMask = *((dgInt32*)&mask.m_x); - index = ((box.m_vertexStart + i) & intMask) | (index & ~intMask); - maxProj = maxProj.GetMax(projectionDist); - } - } - } - } - } else { -#if 0 - for (dgInt32 i = 0; i < m_vertexCount; i++) { - const dgVector& p = m_vertex[i]; - dgVector dist(p.DotProduct(dir)); - dgVector mask(dist > maxProj); - dgInt32 intMask = *((dgInt32*)&mask.m_x); - index = (i & intMask) | (index & ~intMask); - maxProj = maxProj.GetMax(dist); - } -#else - const dgVector x(dir.m_x); - const dgVector y(dir.m_y); - const dgVector z(dir.m_z); - dgVector support (dgVector::m_negOne); - for (dgInt32 i = 0; i < m_soaVertexCount; i+=2) { - dgVector dot (m_soaVertexArray->m_x[i] * x + - m_soaVertexArray->m_y[i] * y + - m_soaVertexArray->m_z[i] * z); - support = support.Select (m_soaVertexArray->m_index[i], dot > maxProj); - maxProj = maxProj.GetMax(dot); - - dot = m_soaVertexArray->m_x[i + 1] * x + - m_soaVertexArray->m_y[i + 1] * y + - m_soaVertexArray->m_z[i + 1] * z; - support = support.Select(m_soaVertexArray->m_index[i + 1], dot > maxProj); - maxProj = maxProj.GetMax(dot); - } - - dgVector dot (maxProj.ShiftRight().ShiftRight()); - dgVector support1 (support.ShiftRight().ShiftRight()); - support = support.Select(support1, dot > maxProj); - maxProj = maxProj.GetMax(dot); - - dot = dgVector (maxProj.ShiftRight()); - support1 = dgVector (support.ShiftRight()); - support = support.Select(support1, dot > maxProj); - - index = dgInt32 (support.GetScalar()); -#endif - } - - if (vertexIndex) { - *vertexIndex = index; - } - dgAssert(index != -1); - return m_vertex[index]; -} - - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionConvexHull.h b/thirdparty/src/newton/dgPhysics/dgCollisionConvexHull.h deleted file mode 100644 index 837d33d72..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionConvexHull.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DG_COLLISIONCONVEXHULL_H__ -#define __DG_COLLISIONCONVEXHULL_H__ - -#include "dgCollisionConvex.h" - -class dgCollisionConvexHull: public dgCollisionConvex -{ - public: - class dgConvexBox; - class dgSOAVectorArray; - - dgCollisionConvexHull(dgMemoryAllocator* const allocator, dgUnsigned32 signature); - dgCollisionConvexHull(dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgInt32 count, dgInt32 strideInBytes, dgFloat32 tolerance, const dgFloat32* const vertexArray); - dgCollisionConvexHull(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionConvexHull(); - - dgInt32 GetFaceIndices (dgInt32 index, dgInt32* const indices) const; - - static dgInt32 CalculateSignature (dgInt32 vertexCount, const dgFloat32* const vertexArray, dgInt32 strideInBytes); - - protected: - void BuildHull (dgInt32 count, dgInt32 strideInBytes, dgFloat32 tolerance, const dgFloat32* const vertexArray); - bool Create (dgInt32 count, dgInt32 strideInBytes, const dgFloat32* const vertexArray, dgFloat32 tolerance); - - bool RemoveCoplanarEdge (dgPolyhedra& convex, const dgBigVector* const hullVertexArray) const; - dgBigVector FaceNormal (const dgEdge *face, const dgBigVector* const pool) const; - bool CheckConvex (dgPolyhedra& polyhedra, const dgBigVector* hullVertexArray) const; - - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - - virtual dgInt32 CalculateSignature () const; - virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1); - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - virtual void Serialize(dgSerialize callback, void* const userData) const; - - void MassProperties (); - virtual const dgConvexSimplexEdge** GetVertexToEdgeMapping() const {return m_vertexToEdgeMapping;} - - void CreateSOAdata(); - - dgConvexBox* m_supportTree; - dgConvexSimplexEdge** m_faceArray; - dgSOAVectorArray* m_soaVertexArray; - const dgConvexSimplexEdge** m_vertexToEdgeMapping; - dgInt32 m_faceCount; - dgInt32 m_soaVertexCount; - dgInt32 m_supportTreeCount; - - friend class dgWorld; - friend class dgCollisionConvex; -}; - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionConvexPolygon.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionConvexPolygon.cpp deleted file mode 100644 index 7e370831b..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionConvexPolygon.cpp +++ /dev/null @@ -1,776 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgContactSolver.h" -#include "dgCollisionInstance.h" -#include "dgCollisionConvexPolygon.h" - -#define DG_CONVEX_POLYGON_CRC 0x12341234 -#define DG_CONVEX_POLYGON_SKIRT_LENGTH dgFloat32 (0.025f) - -dgCollisionConvexPolygon::dgCollisionConvexPolygon (dgMemoryAllocator* const allocator) - :dgCollisionConvex (allocator, DG_CONVEX_POLYGON_CRC, m_polygonCollision) - ,m_count(0) - ,m_paddedCount(0) - ,m_stride(0) - ,m_faceNormalIndex(0) - ,m_faceClipSize(0) - ,m_vertex(NULL) - ,m_vertexIndex(NULL) - ,m_adjacentFaceEdgeNormalIndex(NULL) -{ - m_rtti |= dgCollisionConvexPolygon_RTTI; -} - -dgCollisionConvexPolygon::~dgCollisionConvexPolygon () -{ -} - -dgInt32 dgCollisionConvexPolygon::CalculateSignature () const -{ - return DG_CONVEX_POLYGON_CRC; -} - -void dgCollisionConvexPolygon::SetCollisionBBox (const dgVector& p0__, const dgVector& p1__) -{ - dgAssert (0); -} - -void dgCollisionConvexPolygon::Serialize(dgSerialize callback, void* const userData) const -{ - dgAssert (0); -} - - -dgFloat32 dgCollisionConvexPolygon::RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* userData, OnRayPrecastAction preFilter) const -{ - dgAssert (0); - return dgFloat32 (1.2f); -} - - -dgFloat32 dgCollisionConvexPolygon::GetVolume () const -{ - dgAssert (0); - return dgFloat32 (0.0f); -} - -dgFloat32 dgCollisionConvexPolygon::GetBoxMinRadius () const -{ - return m_faceClipSize; -} - -dgFloat32 dgCollisionConvexPolygon::GetBoxMaxRadius () const -{ - return GetBoxMinRadius (); -} - -dgVector dgCollisionConvexPolygon::SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgAssert (dgAbs(dir.m_w) == dgFloat32(0.0f)); - dgAssert (dgAbs (dir.DotProduct(dir).GetScalar() - 1.0f) < dgFloat32 (1.0e-2f)); - - dgInt32 index = 0; - dgFloat32 val = m_localPoly[0].DotProduct(dir).GetScalar(); -// for (dgInt32 i = 1; i < m_count; i ++) { - for (dgInt32 i = 1; i < m_paddedCount; i++) { - dgFloat32 val1 = m_localPoly[i].DotProduct(dir).GetScalar(); - if (val1 > val) { - val = val1; - index = i; - } - } - - dgAssert (vertexIndex == NULL); - return m_localPoly[index]; -} - -bool dgCollisionConvexPolygon::BeamClipping (const dgVector& origin, dgFloat32 dist, const dgCollisionInstance* const parentMesh) -{ - dgPlane planes[4]; - dgVector points[128]; - - dgClippedFaceEdge clippedFace [2 * sizeof (m_localPoly) / sizeof (m_localPoly[0]) + 8]; - - dgVector dir (m_localPoly[1] - m_localPoly[0]); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert (dir.DotProduct(dir).GetScalar() > dgFloat32 (1.0e-8f)); - dir = dir.Normalize(); - - dgFloat32 distH = origin.DotProduct(dir).GetScalar(); - planes[0] = dgPlane (dir, dist - distH); - planes[2] = dgPlane (dir * dgVector::m_negOne, dist + distH); - - dir = m_normal.CrossProduct(dir); - dgFloat32 distV = origin.DotProduct(dir).GetScalar(); - planes[1] = dgPlane (dir, dist - distV); - planes[3] = dgPlane (dir * dgVector::m_negOne, dist + distV); - - for (dgInt32 i = 0; i < m_count; i ++) { - dgInt32 j = i << 1; - dgAssert (j < sizeof (clippedFace) / sizeof (clippedFace[0])); - - points[i] = m_localPoly[i]; - - clippedFace[j + 0].m_twin = &clippedFace[j + 1]; - clippedFace[j + 0].m_next = &clippedFace[j + 2]; - clippedFace[j + 0].m_incidentVertex = i; - clippedFace[j + 0].m_incidentNormal = m_adjacentFaceEdgeNormalIndex[i]; - - clippedFace[j + 1].m_twin = &clippedFace[j + 0]; - clippedFace[j + 1].m_next = &clippedFace[j - 2]; - clippedFace[j + 1].m_incidentVertex = i + 1; - clippedFace[j + 1].m_incidentNormal = -1; - } - - clippedFace[1].m_next = &clippedFace[m_count * 2 - 2 + 1]; - dgAssert ((m_count * 2 - 2) >= 0); - clippedFace[m_count * 2 - 2].m_next = &clippedFace[0]; - clippedFace[m_count * 2 - 2 + 1].m_incidentVertex = 0; - - const dgFloat32 tol = dgFloat32 (1.0e-5f); - dgInt32 edgeCount = m_count * 2; - dgInt32 indexCount = m_count; - dgClippedFaceEdge* first = &clippedFace[0]; - for (dgInt32 i = 0; i < 4; i ++) { - const dgPlane& plane = planes[i]; - - dgInt32 conectCount = 0; - dgClippedFaceEdge* connect[2]; - dgClippedFaceEdge* ptr = first; - dgClippedFaceEdge* newFirst = first; - dgFloat32 test0 = plane.Evalue(points[ptr->m_incidentVertex]); - do { - dgFloat32 test1 = plane.Evalue(points[ptr->m_next->m_incidentVertex]); - - if (test0 > tol) { - if (test1 <= - tol) { - const dgVector& p0 = points[ptr->m_incidentVertex]; - const dgVector& p1 = points[ptr->m_next->m_incidentVertex]; - dgVector dp (p1 - p0); - points[indexCount] = p0 - dp.Scale (test0 / dp.DotProduct(plane).GetScalar()); - - dgClippedFaceEdge* const newEdge = &clippedFace[edgeCount]; - newEdge->m_twin = newEdge + 1; - newEdge->m_twin->m_twin = newEdge; - - newEdge->m_twin->m_incidentNormal = ptr->m_incidentNormal; - newEdge->m_incidentNormal = ptr->m_incidentNormal; - - newEdge->m_incidentVertex = indexCount; - newEdge->m_twin->m_incidentVertex = ptr->m_next->m_incidentVertex; - ptr->m_twin->m_incidentVertex = indexCount; - - newEdge->m_next = ptr->m_next; - ptr->m_next->m_twin->m_next = newEdge->m_twin; - newEdge->m_twin->m_next = ptr->m_twin; - ptr->m_next = newEdge; - - connect[conectCount] = ptr; - conectCount ++; - indexCount ++; - edgeCount += 2; - ptr = newEdge; - dgAssert (indexCount < sizeof (points)/sizeof (points[0])); - } - } else { - if ((test1 > tol) && (test0 * test1) < dgFloat32 (0.0f)) { - newFirst = ptr->m_next; - - const dgVector& p0 = points[ptr->m_incidentVertex]; - const dgVector& p1 = points[ptr->m_next->m_incidentVertex]; - dgVector dp (p1 - p0); - points[indexCount] = p0 - dp.Scale (test0 / dp.DotProduct(plane).GetScalar()); - - dgClippedFaceEdge* const newEdge = &clippedFace[edgeCount]; - newEdge->m_twin = newEdge + 1; - newEdge->m_twin->m_twin = newEdge; - - newEdge->m_twin->m_incidentNormal = ptr->m_incidentNormal;; - newEdge->m_incidentNormal = ptr->m_incidentNormal; - - newEdge->m_incidentVertex = indexCount; - newEdge->m_twin->m_incidentVertex = ptr->m_next->m_incidentVertex; - ptr->m_twin->m_incidentVertex = indexCount; - - newEdge->m_next = ptr->m_next; - ptr->m_next->m_twin->m_next = newEdge->m_twin; - newEdge->m_twin->m_next = ptr->m_twin; - ptr->m_next = newEdge; - - connect[conectCount] = ptr; - conectCount ++; - indexCount ++; - edgeCount += 2; - - ptr = newEdge; - dgAssert (indexCount < sizeof (points)/sizeof (points[0])); - } - } - - test0 = test1; - ptr = ptr->m_next; - } while (ptr != first); - - if(conectCount > 1) { - first = newFirst; - dgAssert (conectCount == 2); - - dgClippedFaceEdge* const newEdge = &clippedFace[edgeCount]; - newEdge->m_twin = newEdge + 1; - newEdge->m_twin->m_twin = newEdge; - - newEdge->m_incidentNormal = m_faceNormalIndex;; - newEdge->m_incidentVertex = connect[0]->m_next->m_incidentVertex; - newEdge->m_twin->m_next = connect[0]->m_next; - connect[0]->m_next = newEdge; - - newEdge->m_twin->m_incidentNormal = m_faceNormalIndex;; - newEdge->m_twin->m_incidentVertex = connect[1]->m_next->m_incidentVertex; - newEdge->m_next = connect[1]->m_next; - connect[1]->m_next = newEdge->m_twin; - - edgeCount += 2; - } - } - - dgClippedFaceEdge* ptr = first; - do { - dgVector dist1 (points[ptr->m_next->m_incidentVertex] - points[ptr->m_incidentVertex]); - dgAssert (dist1.m_w == dgFloat32 (0.0f)); - dgFloat32 error = dist1.DotProduct(dist1).GetScalar(); - if (error < dgFloat32 (1.0e-6f)) { - ptr->m_next = ptr->m_next->m_next; - first = ptr; - } - ptr = ptr->m_next; - } while (ptr != first); - - dgInt32 count = 0; - m_adjacentFaceEdgeNormalIndex = &m_clippEdgeNormal[0]; - do { - m_clippEdgeNormal[count] = ptr->m_incidentNormal; - m_localPoly[count] = points[ptr->m_incidentVertex]; - count ++; - ptr = ptr->m_next; - dgAssert (m_count < DG_CONVEX_POLYGON_MAX_VERTEX_COUNT); - } while (ptr != first); - - m_count = count; - - if (m_count >= 3) { - dgInt32 i0 = m_count - 1; - for (dgInt32 i = 0; i < m_count; i++) { - dgVector edge(m_localPoly[i] - m_localPoly[i0]); - dgAssert(edge.DotProduct(edge).GetScalar() > dgFloat32(0.0f)); - edge = edge.Normalize(); - const dgInt32 adjacentNormalIndex = m_adjacentFaceEdgeNormalIndex[i0]; - dgVector localAdjacentNormal(&m_vertex[adjacentNormalIndex * m_stride]); - dgVector adjacentNormal(CalculateGlobalNormal(parentMesh, localAdjacentNormal & dgVector::m_triplexMask)); - dgVector edgeSkirt(edge.CrossProduct(adjacentNormal).Scale(DG_CONVEX_POLYGON_SKIRT_LENGTH)); - - m_localPoly[count + 0] = m_localPoly[i] + edgeSkirt; - m_localPoly[count + 1] = m_localPoly[i0] + edgeSkirt; - count += 2; - i0 = i; - } - - m_paddedCount = count; - } - - return (m_count >= 3); -} - -dgInt32 dgCollisionConvexPolygon::CalculatePlaneIntersection (const dgVector& normalIn, const dgVector& origin, dgVector* const contactsOut) const -{ - dgAssert (normalIn.m_w == dgFloat32 (0.0f)); - dgVector normal(normalIn); - dgInt32 count = 0; - dgFloat32 maxDist = dgFloat32 (1.0f); - dgFloat32 projectFactor = m_normal.DotProduct(normal).GetScalar(); - if (projectFactor < dgFloat32 (0.0f)) { - projectFactor *= dgFloat32 (-1.0f); - normal = normal * dgVector::m_negOne; - } - - if (projectFactor > dgFloat32 (0.9999f)) { - for (dgInt32 i = 0; i < m_count; i ++) { - contactsOut[count] = m_localPoly[i]; - count ++; - } - - #ifdef _DEBUG - dgInt32 j = count - 1; - for (dgInt32 i = 0; i < count; i ++) { - dgVector error (contactsOut[i] - contactsOut[j]); - dgAssert (error.m_w == dgFloat32 (0.0f)); - dgAssert (error.DotProduct(error).GetScalar() > dgFloat32 (1.0e-20f)); - j = i; - } - #endif - - } else if (projectFactor > dgFloat32 (0.1736f)) { - maxDist = dgFloat32 (0.0f); - dgPlane plane (normal, - normal.DotProduct(origin).GetScalar()); - - dgVector p0 (m_localPoly[m_count - 1]); - dgFloat32 side0 = plane.Evalue (p0); - for (dgInt32 i = 0; i < m_count; i ++) { - dgVector p1 (m_localPoly[i]); - dgFloat32 side1 = plane.Evalue (p1); - - if (side0 > dgFloat32 (0.0f)) { - maxDist = dgMax (maxDist, side0); - contactsOut[count] = p0 - normal.Scale (side0); - count ++; - if (count > 1) { - dgVector edgeSegment (contactsOut[count - 1] - contactsOut[count - 2]); - dgAssert (edgeSegment.m_w == dgFloat32 (0.0f)); - dgFloat32 error = edgeSegment.DotProduct(edgeSegment).GetScalar(); - if (error < dgFloat32 (1.0e-8f)) { - count --; - } - } - - if (side1 <= dgFloat32 (0.0f)) { - dgVector dp (p1 - p0); - dgFloat32 t = normal.DotProduct(dp).GetScalar(); - dgAssert (dgAbs (t) >= dgFloat32 (0.0f)); - if (dgAbs (t) < dgFloat32 (1.0e-8f)) { - t = dgSign(t) * dgFloat32 (1.0e-8f); - } - contactsOut[count] = p0 - dp.Scale (side0 / t); - count ++; - if (count > 1) { - dgVector edgeSegment (contactsOut[count - 1] - contactsOut[count - 2]); - dgAssert (edgeSegment.m_w == dgFloat32 (0.0f)); - dgFloat32 error = edgeSegment.DotProduct(edgeSegment).GetScalar(); - if (error < dgFloat32 (1.0e-8f)) { - count --; - } - } - } - } else if (side1 > dgFloat32 (0.0f)) { - dgVector dp (p1 - p0); - dgFloat32 t = normal.DotProduct(dp).GetScalar(); - dgAssert (dgAbs (t) >= dgFloat32 (0.0f)); - if (dgAbs (t) < dgFloat32 (1.0e-8f)) { - t = dgSign(t) * dgFloat32 (1.0e-8f); - } - contactsOut[count] = p0 - dp.Scale (side0 / t); - count ++; - if (count > 1) { - dgVector edgeSegment (contactsOut[count - 1] - contactsOut[count - 2]); - dgAssert (edgeSegment.m_w == dgFloat32 (0.0f)); - dgFloat32 error = edgeSegment.DotProduct(edgeSegment).GetScalar(); - if (error < dgFloat32 (1.0e-8f)) { - count --; - } - } - } - - side0 = side1; - p0 = p1; - } - } else { - maxDist = dgFloat32 (1.0e10f); - dgPlane plane (normal, - normal.DotProduct(origin).GetScalar()); - - dgVector p0 (m_localPoly[m_count - 1]); - dgFloat32 side0 = plane.Evalue (p0); - for (dgInt32 i = 0; i < m_count; i ++) { - dgVector p1 (m_localPoly[i]); - dgFloat32 side1 = plane.Evalue (p1); - - if ((side0 * side1) < dgFloat32 (0.0f)) { - dgVector dp (p1 - p0); - dgFloat32 t = normal.DotProduct(dp).GetScalar(); - dgAssert (dgAbs (t) >= dgFloat32 (0.0f)); - if (dgAbs (t) < dgFloat32 (1.0e-8f)) { - t = dgSign(t) * dgFloat32 (1.0e-8f); - } - contactsOut[count] = p0 - dp.Scale (side0 / t); - count ++; - if (count > 1) { - dgVector edgeSegment (contactsOut[count - 1] - contactsOut[count - 2]); - dgAssert (edgeSegment.m_w == dgFloat32 (0.0f)); - dgFloat32 error = edgeSegment.DotProduct(edgeSegment).GetScalar(); - if (error < dgFloat32 (1.0e-8f)) { - count --; - } - } - } - side0 = side1; - p0 = p1; - } - } - - - if (count > 1) { - if (maxDist < dgFloat32 (1.0e-3f)) { - dgVector maxPoint (contactsOut[0]); - dgVector minPoint (contactsOut[0]); - dgVector lineDir (m_normal.CrossProduct(normal)); - - dgAssert (lineDir.m_w == dgFloat32 (0.0f)); - dgFloat32 proj = contactsOut[0].DotProduct(lineDir).GetScalar(); - dgFloat32 maxProjection = proj; - dgFloat32 minProjection = proj; - for (dgInt32 i = 1; i < count; i ++) { - proj = contactsOut[i].DotProduct(lineDir).GetScalar(); - if (proj > maxProjection) { - maxProjection = proj; - maxPoint = contactsOut[i]; - } - if (proj < minProjection) { - minProjection = proj; - minPoint = contactsOut[i]; - } - } - - contactsOut[0] = maxPoint; - contactsOut[1] = minPoint; - count = 2; - } - - - dgVector error (contactsOut[count - 1] - contactsOut[0]); - dgAssert (error.m_w == dgFloat32 (0.0f)); - if (error.DotProduct(error).GetScalar() < dgFloat32 (1.0e-8f)) { - count --; - } - } - - #ifdef _DEBUG - if (count > 1) { - dgInt32 j = count - 1; - for (dgInt32 i = 0; i < count; i ++) { - dgVector error (contactsOut[i] - contactsOut[j]); - dgAssert (error.m_w == dgFloat32 (0.0f)); - dgAssert (error.DotProduct(error).GetScalar() > dgFloat32 (1.0e-20f)); - j = i; - } - - if (count >= 3) { - dgVector n (dgFloat32 (0.0f)); - dgVector e0 (contactsOut[1] - contactsOut[0]); - for (dgInt32 i = 2; i < count; i ++) { - dgVector e1 (contactsOut[i] - contactsOut[0]); - n += e0.CrossProduct(e1); - e0 = e1; - } - dgAssert (n.m_w == dgFloat32 (0.0f)); - n = n.Normalize(); - dgAssert (n.DotProduct(normal).GetScalar() > dgFloat32 (0.9f)); - } - } - #endif - return count; -} - -dgVector dgCollisionConvexPolygon::CalculateGlobalNormal (const dgCollisionInstance* const parentMesh, const dgVector& localNormal) const -{ - const dgVector& invScale = parentMesh->GetInvScale(); - const dgMatrix& globalMatrix = parentMesh->m_globalMatrix; - const dgMatrix& aligmentMatrix = parentMesh->m_aligmentMatrix; - - dgVector normal (aligmentMatrix.RotateVector(localNormal)); - normal = normal * invScale; - dgAssert(normal.m_w == dgFloat32(0.0f)); - normal = normal.Normalize(); - return globalMatrix.RotateVector(normal); -} - -dgInt32 dgCollisionConvexPolygon::CalculateContactToConvexHullContinue(const dgWorld* const world, const dgCollisionInstance* const parentMesh, dgCollisionParamProxy& proxy) -{ - dgAssert(proxy.m_instance0->IsType(dgCollision::dgCollisionConvexShape_RTTI)); - dgAssert(proxy.m_instance1->IsType(dgCollision::dgCollisionConvexPolygon_RTTI)); - - dgAssert(this == proxy.m_instance1->GetChildShape()); - dgAssert(m_count); - dgAssert(m_count < dgInt32(sizeof (m_localPoly) / sizeof (m_localPoly[0]))); - - const dgBody* const body0 = proxy.m_body0; - const dgBody* const body1 = proxy.m_body1; - - dgAssert (proxy.m_instance1->GetGlobalMatrix().TestIdentity()); - - dgVector relativeVelocity (body0->m_veloc - body1->m_veloc); - dgAssert (relativeVelocity.m_w == dgFloat32 (0.0f)); - if (relativeVelocity.DotProduct(relativeVelocity).GetScalar() < dgFloat32 (1.0e-4f)) { - return 0; - } - - dgFloat32 den = m_normal.DotProduct(relativeVelocity).GetScalar(); - if (den > dgFloat32 (-1.0e-10f)) { - return 0; - } - - dgContact* const contactJoint = proxy.m_contactJoint; - contactJoint->m_closestDistance = dgFloat32(1.0e10f); - - dgMatrix polygonMatrix; - dgVector right (m_localPoly[1] - m_localPoly[0]); - polygonMatrix[0] = right.Normalize(); - polygonMatrix[1] = m_normal; - polygonMatrix[2] = polygonMatrix[0].CrossProduct(m_normal); - polygonMatrix[3] = m_localPoly[0]; - polygonMatrix[3].m_w = dgFloat32 (1.0f); - dgAssert (polygonMatrix.TestOrthogonal()); - - dgVector polyBoxP0(dgFloat32(1.0e15f)); - dgVector polyBoxP1(dgFloat32(-1.0e15f)); - for (dgInt32 i = 0; i < m_count; i++) { - dgVector point (polygonMatrix.UntransformVector(m_localPoly[i])); - polyBoxP0 = polyBoxP0.GetMin(point); - polyBoxP1 = polyBoxP1.GetMax(point); - } - - dgVector hullBoxP0; - dgVector hullBoxP1; - dgMatrix hullMatrix (proxy.m_instance0->m_globalMatrix * polygonMatrix.Inverse()); - proxy.m_instance0->CalcAABB(hullMatrix, hullBoxP0, hullBoxP1); - dgVector minBox(polyBoxP0 - hullBoxP1); - dgVector maxBox(polyBoxP1 - hullBoxP0); - - dgVector relStep (relativeVelocity.Scale(dgMax (proxy.m_timestep, dgFloat32 (1.0e-12f)))); - dgFastRayTest ray(dgVector(dgFloat32(0.0f)), polygonMatrix.UnrotateVector(relStep)); - dgFloat32 distance = ray.BoxIntersect(minBox, maxBox); - - dgInt32 count = 0; - if (distance < dgFloat32(1.0f)) { - bool inside = false; - - dgVector sphOrigin(polygonMatrix.TransformVector((hullBoxP1 + hullBoxP0) * dgVector::m_half)); - dgVector pointInPlane (sphOrigin - relStep.Scale (m_normal.DotProduct(sphOrigin - m_localPoly[0]).GetScalar() / m_normal.DotProduct(relStep).GetScalar())); - - dgVector sphRadius(dgVector::m_half * (hullBoxP1 - hullBoxP0)); - dgFloat32 radius = dgSqrt(sphRadius.DotProduct(sphRadius).GetScalar()); - dgVector planeMinkStep (m_normal.Scale (radius)); - sphOrigin -= planeMinkStep; - dgVector supportPoint (sphOrigin - relStep.Scale (m_normal.DotProduct(sphOrigin - m_localPoly[0]).GetScalar() / m_normal.DotProduct(relStep).GetScalar())); - - supportPoint -= pointInPlane; - dgAssert (supportPoint.m_w == dgFloat32 (0.0f)); - radius = dgMax (dgSqrt (supportPoint.DotProduct(supportPoint).GetScalar()), radius); - -// if (!proxy.m_intersectionTestOnly) { - inside = true; - dgInt32 i0 = m_count - 1; - - for (dgInt32 i = 0; i < m_count; i++) { - dgVector e(m_localPoly[i] - m_localPoly[i0]); - dgVector n((e.CrossProduct(m_normal) & dgVector::m_triplexMask).Normalize()); - dgFloat32 dist1 = n.DotProduct(pointInPlane - m_localPoly[i0]).GetScalar(); - - if (dist1 > radius) { - return 0; - } - inside &= (dist1 <= dgFloat32 (0.0f)); - i0 = i; - } -// } - - dgFloat32 convexSphapeUmbra = dgMax (proxy.m_instance0->GetUmbraClipSize(), radius); - if (m_faceClipSize > convexSphapeUmbra) { - BeamClipping(pointInPlane, convexSphapeUmbra, parentMesh); - m_faceClipSize = proxy.m_instance0->m_childShape->GetBoxMaxRadius(); - } - - const dgInt64 hullId = proxy.m_instance0->GetUserDataID(); - if (inside & !proxy.m_intersectionTestOnly) { - const dgMatrix& matrixInstance0 = proxy.m_instance0->m_globalMatrix; - dgVector normalInHull(matrixInstance0.UnrotateVector(m_normal.Scale(dgFloat32(-1.0f)))); - dgVector pointInHull(proxy.m_instance0->SupportVertex(normalInHull)); - dgVector p0 (matrixInstance0.TransformVector(pointInHull)); - - dgFloat32 timetoImpact = dgFloat32(0.0f); - dgAssert (m_normal.m_w == dgFloat32 (0.0f)); - dgFloat32 penetration = m_normal.DotProduct(m_localPoly[0] - p0).GetScalar() + proxy.m_skinThickness; - if (penetration < dgFloat32(0.0f)) { - timetoImpact = penetration / relativeVelocity.DotProduct(m_normal).GetScalar(); - dgAssert(timetoImpact >= dgFloat32(0.0f)); - } - - if (timetoImpact <= proxy.m_timestep) { - dgVector contactPoints[64]; - contactJoint->m_closestDistance = penetration; - proxy.m_timestep = timetoImpact; - proxy.m_normal = m_normal; - proxy.m_closestPointBody0 = p0; - proxy.m_closestPointBody1 = p0 + m_normal.Scale(penetration); - - if (!proxy.m_intersectionTestOnly) { - //dgAssert (0); - //pointInHull -= normalInHull.Scale (DG_ROBUST_PLANE_CLIP); - pointInHull -= normalInHull.Scale (DG_PENETRATION_TOL); - count = proxy.m_instance0->CalculatePlaneIntersection(normalInHull, pointInHull, contactPoints); - - dgVector step(relativeVelocity.Scale(timetoImpact)); - penetration = dgMax(penetration, dgFloat32(0.0f)); - dgContactPoint* const contactsOut = proxy.m_contacts; - for (dgInt32 i = 0; i < count; i++) { - contactsOut[i].m_point = matrixInstance0.TransformVector(contactPoints[i]) + step; - contactsOut[i].m_normal = m_normal; - contactsOut[i].m_shapeId0 = hullId; - contactsOut[i].m_shapeId1 = m_faceId; - contactsOut[i].m_penetration = penetration; - } - } - } - } else { - m_vertexCount = dgUnsigned16 (m_count); - count = world->CalculateConvexToConvexContacts(proxy); - //dgTrace (("dt %f\n", proxy.m_timestep)); - //proxy.m_closestPointBody0.Trace("p0"); - //proxy.m_closestPointBody1.Trace("p1"); - if (count >= 1) { - dgContactPoint* const contactsOut = proxy.m_contacts; - for (dgInt32 i = 0; i < count; i++) { - contactsOut[i].m_shapeId0 = hullId; - contactsOut[i].m_shapeId1 = m_faceId; - } - } - } - } - return count; -} - -dgInt32 dgCollisionConvexPolygon::CalculateContactToConvexHullDescrete(const dgWorld* const world, const dgCollisionInstance* const parentMesh, dgCollisionParamProxy& proxy) -{ - dgInt32 count = 0; - - dgAssert(proxy.m_instance0->IsType(dgCollision::dgCollisionConvexShape_RTTI)); - dgAssert(proxy.m_instance1->IsType(dgCollision::dgCollisionConvexPolygon_RTTI)); - dgAssert (proxy.m_instance1->GetGlobalMatrix().TestIdentity()); - - dgAssert(this == proxy.m_instance1->GetChildShape()); - dgAssert(m_count); - dgAssert(m_count < dgInt32(sizeof (m_localPoly) / sizeof (m_localPoly[0]))); - - const dgMatrix& hullMatrix = proxy.m_instance0->m_globalMatrix; - dgContact* const contactJoint = proxy.m_contactJoint; - const dgCollisionInstance* const hull = proxy.m_instance0; - - dgAssert(m_normal.m_w == dgFloat32(0.0f)); - //const dgFloat32 shapeSide = m_normal.DotProduct(hullMatrix.m_posit - m_localPoly[0]).GetScalar(); - const dgVector obbOrigin(hullMatrix.TransformVector(proxy.m_instance0->GetChildShape()->GetObbOrigin())); - const dgFloat32 shapeSide = m_normal.DotProduct(obbOrigin - m_localPoly[0]).GetScalar(); - if (shapeSide < dgFloat32(0.0f)) { - //dgTrace(("normal face away (%f %f %f)\n", m_normal[0], m_normal[1], m_normal[2])); - return 0; - } - - dgVector normalInHull(hullMatrix.UnrotateVector(m_normal)); - dgVector pointInHull(hull->SupportVertex(normalInHull.Scale(dgFloat32(-1.0f)))); - dgVector p0(hullMatrix.TransformVector(pointInHull)); - - dgFloat32 penetration = m_normal.DotProduct(m_localPoly[0] - p0).GetScalar() + proxy.m_skinThickness; - - //if (penetration < dgFloat32(-1.0e-5f)) { - if (penetration < -(DG_PENETRATION_TOL * dgFloat32 (5.0f))) { - return 0; - } - - dgVector p1(hullMatrix.TransformVector(hull->SupportVertex(normalInHull))); - contactJoint->m_closestDistance = dgFloat32(0.0f); - dgFloat32 distance = m_normal.DotProduct(m_localPoly[0] - p1).GetScalar(); - if (distance >= dgFloat32(0.0f)) { - return 0; - } - - dgVector boxSize; - dgVector boxOrigin; - hull->CalcObb(boxOrigin, boxSize); - boxOrigin += dgVector::m_wOne; - - bool inside = true; - dgInt32 i0 = m_count - 1; - for (dgInt32 i = 0; i < m_count; i++) { - dgVector e(m_localPoly[i] - m_localPoly[i0]); - dgVector edgeBoundaryNormal(m_normal.CrossProduct(e)); - dgAssert (edgeBoundaryNormal.m_w == dgFloat32 (0.0f)); - dgPlane plane(edgeBoundaryNormal, - m_localPoly[i0].DotProduct (edgeBoundaryNormal).GetScalar()); - plane = hullMatrix.UntransformPlane(plane); - - dgFloat32 supportDist = boxSize.DotProduct (plane.Abs()).GetScalar(); - dgFloat32 centerDist = plane.DotProduct (boxOrigin).GetScalar(); - - if ((centerDist + supportDist) < dgFloat32(0.0f)) { - return 0; - } - - if ((centerDist - supportDist) < dgFloat32(0.0f)) { - inside = false; - break; - } - i0 = i; - } - - dgFloat32 convexSphapeUmbra = hull->GetUmbraClipSize(); - if (m_faceClipSize > convexSphapeUmbra) { - dgVector boxP0; - dgVector boxP1; - hull->CalcAABB (hullMatrix, boxP0, boxP1); - dgVector origin (dgVector::m_half * (boxP1 + boxP1)); - - if (!BeamClipping(origin, convexSphapeUmbra, parentMesh)) { - return 0; - } - m_faceClipSize = hull->m_childShape->GetBoxMaxRadius(); - } - - const dgInt64 hullId = hull->GetUserDataID(); - if (inside & !proxy.m_intersectionTestOnly) { - penetration = dgMax(dgFloat32(0.0f), penetration); - dgAssert(penetration >= dgFloat32(0.0f)); - dgVector contactPoints[128]; - dgVector point(pointInHull + normalInHull.Scale(penetration - DG_PENETRATION_TOL)); - - count = hull->CalculatePlaneIntersection(normalInHull.Scale(dgFloat32(-1.0f)), point, contactPoints); - dgVector step(normalInHull.Scale((proxy.m_skinThickness - penetration) * dgFloat32(0.5f))); - - dgContactPoint* const contactsOut = proxy.m_contacts; - for (dgInt32 i = 0; i < count; i++) { - contactsOut[i].m_point = hullMatrix.TransformVector(contactPoints[i] + step); - contactsOut[i].m_normal = m_normal; - contactsOut[i].m_shapeId0 = hullId; - contactsOut[i].m_shapeId1 = m_faceId; - contactsOut[i].m_penetration = penetration; - } - } else { - m_vertexCount = dgUnsigned16(m_count); - count = world->CalculateConvexToConvexContacts(proxy); - dgAssert(proxy.m_intersectionTestOnly || (count >= 0)); - if (count >= 1) { - dgContactPoint* const contactsOut = proxy.m_contacts; - for (dgInt32 i = 0; i < count; i++) { - contactsOut[i].m_shapeId0 = hullId; - contactsOut[i].m_shapeId1 = m_faceId; - } - } - } - return count; -} diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionConvexPolygon.h b/thirdparty/src/newton/dgPhysics/dgCollisionConvexPolygon.h deleted file mode 100644 index 01318b4aa..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionConvexPolygon.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_COLLISION_CONVEX_POLYGON_H_ -#define _DG_COLLISION_CONVEX_POLYGON_H_ - -#include "dgCollisionConvexHull.h" - - -#define DG_CONVEX_POLYGON_MAX_VERTEX_COUNT 64 - -DG_MSC_VECTOR_ALIGNMENT -class dgCollisionConvexPolygon: public dgCollisionConvex -{ - public: - class dgClippedFaceEdge - { - public: - dgClippedFaceEdge* m_next; - dgClippedFaceEdge* m_twin; - dgInt32 m_incidentNormal; - dgInt32 m_incidentVertex; - }; - - public: - dgCollisionConvexPolygon (dgMemoryAllocator* const allocator); - ~dgCollisionConvexPolygon (); - - virtual dgInt32 CalculateSignature () const; - virtual void Serialize(dgSerialize callback, void* const userData) const; - virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1); - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const; - - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - - virtual dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const; - - virtual dgFloat32 GetVolume () const; - virtual dgFloat32 GetBoxMinRadius () const; - virtual dgFloat32 GetBoxMaxRadius () const; - - bool BeamClipping (const dgVector& origin, dgFloat32 size, const dgCollisionInstance* const parentMesh); - dgVector CalculateGlobalNormal (const dgCollisionInstance* const parentMesh, const dgVector& localNormal) const; - dgInt32 CalculateContactToConvexHullDescrete(const dgWorld* const world, const dgCollisionInstance* const parentMesh, dgCollisionParamProxy& proxy); - dgInt32 CalculateContactToConvexHullContinue (const dgWorld* const world, const dgCollisionInstance* const parentMesh, dgCollisionParamProxy& proxy); - - dgVector m_normal; - dgVector m_localPoly[DG_CONVEX_POLYGON_MAX_VERTEX_COUNT]; - dgInt32 m_clippEdgeNormal[DG_CONVEX_POLYGON_MAX_VERTEX_COUNT]; - dgInt32 m_count; - dgInt32 m_paddedCount; - dgInt32 m_faceId; - dgInt32 m_stride; - dgInt32 m_faceNormalIndex; - dgFloat32 m_faceClipSize; - const dgFloat32* m_vertex; - const dgInt32* m_vertexIndex; - const dgInt32* m_adjacentFaceEdgeNormalIndex; -} DG_GCC_VECTOR_ALIGNMENT; - -#endif \ No newline at end of file diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionCylinder.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionCylinder.cpp deleted file mode 100644 index 28eb3a1b3..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionCylinder.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgCollisionConvexPolygon.h" -#include "dgCollisionCylinder.h" - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////// - -dgInt32 dgCollisionCylinder::m_shapeRefCount = 0; -dgCollisionConvex::dgConvexSimplexEdge dgCollisionCylinder::m_edgeArray[DG_TAPED_CYLINDER_SEGMENTS * 2 * 3]; - -dgCollisionCylinder::dgCollisionCylinder(dgMemoryAllocator* allocator, dgUnsigned32 signature, dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height) - :dgCollisionConvex(allocator, signature, m_cylinderCollision) -{ - Init (radio0, radio1, height); -} - - -dgCollisionCylinder::dgCollisionCylinder(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionConvex (world, deserialization, userData, revisionNumber) -{ - dgVector size; - deserialization (userData, &size, sizeof (dgVector)); - Init (size.m_x, size.m_y, size.m_z); -} - -void dgCollisionCylinder::Init (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height) -{ - m_rtti |= dgCollisionCylinder_RTTI; - m_radio0 = dgMax (dgAbs (radio0), D_MIN_CONVEX_SHAPE_SIZE); - m_radio1 = dgMax (dgAbs (radio1), D_MIN_CONVEX_SHAPE_SIZE); - m_height = dgMax (dgAbs (height * dgFloat32 (0.5f)), D_MIN_CONVEX_SHAPE_SIZE); - - dgFloat32 angle = dgFloat32 (0.0f); - for (dgInt32 i = 0; i < DG_TAPED_CYLINDER_SEGMENTS; i ++) { - dgFloat32 sinAngle = dgSin (angle); - dgFloat32 cosAngle = dgCos (angle); - m_vertex[i ] = dgVector (- m_height, m_radio0 * cosAngle, m_radio0 * sinAngle, dgFloat32 (0.0f)); - m_vertex[i + DG_TAPED_CYLINDER_SEGMENTS] = dgVector ( m_height, m_radio1 * cosAngle, m_radio1 * sinAngle, dgFloat32 (0.0f)); - angle += dgPI2 / DG_TAPED_CYLINDER_SEGMENTS; - } - - m_edgeCount = DG_TAPED_CYLINDER_SEGMENTS * 6; - m_vertexCount = DG_TAPED_CYLINDER_SEGMENTS * 2; - dgCollisionConvex::m_vertex = m_vertex; - - if (!m_shapeRefCount) { - dgPolyhedra polyhedra(m_allocator); - dgInt32 wireframe[DG_TAPED_CYLINDER_SEGMENTS]; - - dgInt32 j = DG_TAPED_CYLINDER_SEGMENTS - 1; - polyhedra.BeginFace (); - for (dgInt32 i = 0; i < DG_TAPED_CYLINDER_SEGMENTS; i ++) { - wireframe[0] = j; - wireframe[1] = i; - wireframe[2] = i + DG_TAPED_CYLINDER_SEGMENTS; - wireframe[3] = j + DG_TAPED_CYLINDER_SEGMENTS; - j = i; - polyhedra.AddFace (4, wireframe); - } - - for (dgInt32 i = 0; i < DG_TAPED_CYLINDER_SEGMENTS; i ++) { - wireframe[i] = DG_TAPED_CYLINDER_SEGMENTS - 1 - i; - } - polyhedra.AddFace (DG_TAPED_CYLINDER_SEGMENTS, wireframe); - - for (dgInt32 i = 0; i < DG_TAPED_CYLINDER_SEGMENTS; i ++) { - wireframe[i] = i + DG_TAPED_CYLINDER_SEGMENTS; - } - polyhedra.AddFace (DG_TAPED_CYLINDER_SEGMENTS, wireframe); - polyhedra.EndFace (); - - dgAssert (SanityCheck (polyhedra)); - - dgUnsigned64 i = 0; - dgPolyhedra::Iterator iter (polyhedra); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - edge->m_userData = i; - i ++; - } - - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - - dgConvexSimplexEdge* const ptr = &m_edgeArray[edge->m_userData]; - ptr->m_vertex = edge->m_incidentVertex; - ptr->m_next = &m_edgeArray[edge->m_next->m_userData]; - ptr->m_prev = &m_edgeArray[edge->m_prev->m_userData]; - ptr->m_twin = &m_edgeArray[edge->m_twin->m_userData]; - } - } - - m_profile[0] = dgVector( m_height, m_radio1, dgFloat32 (0.0f), dgFloat32 (0.0f)); - m_profile[1] = dgVector(-m_height, m_radio0, dgFloat32 (0.0f), dgFloat32 (0.0f)); - m_profile[2] = dgVector(-m_height, -m_radio0, dgFloat32 (0.0f), dgFloat32 (0.0f)); - m_profile[3] = dgVector(m_height, -m_radio1, dgFloat32 (0.0f), dgFloat32 (0.0f)); - - m_shapeRefCount ++; - dgCollisionConvex::m_simplex = m_edgeArray; - - SetVolumeAndCG (); -} - -dgCollisionCylinder::~dgCollisionCylinder() -{ - m_shapeRefCount --; - dgAssert (m_shapeRefCount >= 0); - - dgCollisionConvex::m_simplex = NULL; - dgCollisionConvex::m_vertex = NULL; -} - -dgInt32 dgCollisionCylinder::CalculateSignature (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height) -{ - dgUnsigned32 buffer[4]; - - buffer[0] = m_cylinderCollision; - buffer[1] = Quantize (radio0); - buffer[2] = Quantize (radio1); - buffer[3] = Quantize (height); - return Quantize(buffer, sizeof (buffer)); -} - -dgInt32 dgCollisionCylinder::CalculateSignature () const -{ - return CalculateSignature (m_radio0, m_radio1, m_height); -} - - -void dgCollisionCylinder::SetCollisionBBox (const dgVector& p0, const dgVector& p1) -{ - dgAssert (0); -} - -void dgCollisionCylinder::DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - dgTriplex pool[24 * 2]; - - dgFloat32 angle = dgFloat32 (0.0f); - for (dgInt32 i = 0; i < 24; i ++) { - dgFloat32 z = dgSin (angle); - dgFloat32 y = dgCos (angle); - pool[i].m_x = - m_height; - pool[i].m_y = y * m_radio0; - pool[i].m_z = z * m_radio0; - pool[i + 24].m_x = m_height; - pool[i + 24].m_y = y * m_radio1; - pool[i + 24].m_z = z * m_radio1; - angle += dgPI2 / dgFloat32 (24.0f); - } - - matrix.TransformTriplex (&pool[0].m_x, sizeof (dgTriplex), &pool[0].m_x, sizeof (dgTriplex), 24 * 2); - - dgTriplex face[24]; - - dgInt32 j = 24 - 1; - for (dgInt32 i = 0; i < 24; i ++) { - face[0] = pool[j]; - face[1] = pool[i]; - face[2] = pool[i + 24]; - face[3] = pool[j + 24]; - j = i; - callback (userData, 4, &face[0].m_x, 0); - } - - for (dgInt32 i = 0; i < 24; i ++) { - face[i] = pool[24 - 1 - i]; - } - callback (userData, 24, &face[0].m_x, 0); - - for (dgInt32 i = 0; i < 24; i ++) { - face[i] = pool[i + 24]; - } - callback (userData, 24, &face[0].m_x, 0); -} - -void dgCollisionCylinder::MassProperties() -{ -// dgFloat32 Ixx = (1.0f / 2.0f) * m_radio0 * m_radio0; -// dgFloat32 Iyy= (1.0f / 12.0f) * (3.0f * m_radio0 * m_radio0 + 4.0f * m_height * m_height); - dgCollisionConvex::MassProperties(); - -// m_centerOfMass = dgVector::m_zero; -// m_crossInertia = dgVector::m_zero; -// dgFloat32 volume = dgFloat32(2.0f * dgPI) * m_radius * m_radius * m_height; -// dgFloat32 II = (1.0f / 2.0f) * m_radio0 * m_radio0; -// dgFloat32 JJ = (1.0f / 12.0f) * (3.0f * m_radio0 * m_radio0 + 4.0f * m_height * m_height); -// m_inertia = dgVector(II, JJ, JJ, dgFloat32(0.0f)); -// m_centerOfMass.m_w = volume; -} - -dgVector dgCollisionCylinder::SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert (dgAbs (dir.DotProduct(dir).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f)); - - if (dir.m_x < dgFloat32(-0.9999f)) { - return dgVector(-m_height, dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - } else if (dir.m_x > dgFloat32(0.9999f)) { - return dgVector(m_height, dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - } else { - dgVector dir_yz (dir); - dir_yz.m_x = dgFloat32 (0.0f); - dgFloat32 mag2 = dir_yz.DotProduct(dir_yz).GetScalar(); - dgAssert (mag2 > dgFloat32 (0.0f)); - dir_yz = dir_yz.Scale (dgFloat32 (1.0f) / dgSqrt (mag2)); - dgVector p0 (dir_yz.Scale (m_radio0)); - dgVector p1 (dir_yz.Scale (m_radio1)); - - p0.m_x = -m_height; - p1.m_x = m_height; - - dgFloat32 dist0 = dir.DotProduct(p0).GetScalar(); - dgFloat32 dist1 = dir.DotProduct(p1).GetScalar(); - - if (dist1 >= dist0) { - p0 = p1; - } - return p0; - } -} - - -dgVector dgCollisionCylinder::SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert(dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-3f)); - - const dgFloat32 thickness = DG_PENETRATION_TOL + skinThickness; - if (dir.m_x < dgFloat32 (-0.9999f)) { - return dgVector (-(m_height - thickness), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - } else if (dir.m_x > dgFloat32 (0.9999f)) { - return dgVector ( m_height - thickness, dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - } else { - dgVector dir_yz(dir); - dir_yz.m_x = dgFloat32(0.0f); - dgFloat32 mag2 = dir_yz.DotProduct(dir_yz).GetScalar(); - dgAssert (mag2 > dgFloat32 (0.0f)); - dir_yz = dir_yz.Scale(dgFloat32(1.0f) / dgSqrt(mag2)); - dgVector p0(dir_yz.Scale(m_radio0 - thickness)); - dgVector p1(dir_yz.Scale(m_radio1 - thickness)); - - p0.m_x = - (m_height - thickness); - p1.m_x = m_height - thickness; - - dgFloat32 dist0 = dir.DotProduct(p0).GetScalar(); - dgFloat32 dist1 = dir.DotProduct(p1).GetScalar(); - - if (dist1 >= dist0) { - p0 = p1; - } - return p0; - } -} - -dgVector dgCollisionCylinder::SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const -{ - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert(dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-3f)); - return point + dir.Scale (DG_PENETRATION_TOL); -} - -dgFloat32 dgCollisionCylinder::CalculateMassProperties (const dgMatrix& offset, dgVector& inertia, dgVector& crossInertia, dgVector& centerOfMass) const -{ - return dgCollisionConvex::CalculateMassProperties (offset, inertia, crossInertia, centerOfMass); -} - -dgInt32 dgCollisionCylinder::CalculatePlaneIntersection (const dgVector& normal, const dgVector& origin, dgVector* const contactsOut) const -{ - dgInt32 count = 0; - const dgFloat32 inclination = dgFloat32(0.9998f); - if (normal.m_x < dgFloat32 (-0.995f)) { - if (normal.m_x < -inclination) { - dgMatrix matrix(normal); - matrix.m_posit.m_x = origin.m_x; - count = BuildCylinderCapPoly (m_radio0, matrix, contactsOut); - //count = RectifyConvexSlice(n, normal, contactsOut); - } else { - dgFloat32 magInv = dgRsqrt(normal.m_y * normal.m_y + normal.m_z * normal.m_z); - dgFloat32 cosAng = normal.m_y * magInv; - dgFloat32 sinAng = normal.m_z * magInv; - - dgAssert(dgAbs(normal.m_z * cosAng - normal.m_y * sinAng) < dgFloat32(1.0e-4f)); - dgVector normal1(normal.m_x, normal.m_y * cosAng + normal.m_z * sinAng, dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector origin1(origin.m_x, origin.m_y * cosAng + origin.m_z * sinAng, origin.m_z * cosAng - origin.m_y * sinAng, dgFloat32(0.0f)); - - count = dgCollisionConvex::CalculatePlaneIntersection(normal1, origin1, contactsOut); - if (count > 6) { - dgInt32 dy = 2 * 6; - dgInt32 dx = 2 * count; - dgInt32 acc = dy - count; - dgInt32 index = 0; - for (dgInt32 i = 0; i < count; i++) { - if (acc > 0) { - contactsOut[index] = contactsOut[i]; - index++; - acc -= dx; - } - acc += dy; - } - count = index; - } - - for (dgInt32 i = 0; i < count; i++) { - dgFloat32 y = contactsOut[i].m_y; - dgFloat32 z = contactsOut[i].m_z; - contactsOut[i].m_y = y * cosAng - z * sinAng; - contactsOut[i].m_z = z * cosAng + y * sinAng; - } - } - } else if (normal.m_x > dgFloat32 (0.995f)) { - if (normal.m_x > inclination) { - dgMatrix matrix(normal); - matrix.m_posit.m_x = origin.m_x; - count = BuildCylinderCapPoly (m_radio1, matrix, contactsOut); - //count = RectifyConvexSlice(n, normal, contactsOut); - } else { - dgFloat32 magInv = dgRsqrt(normal.m_y * normal.m_y + normal.m_z * normal.m_z); - dgFloat32 cosAng = normal.m_y * magInv; - dgFloat32 sinAng = normal.m_z * magInv; - - dgAssert(dgAbs(normal.m_z * cosAng - normal.m_y * sinAng) < dgFloat32(1.0e-4f)); - dgVector normal1(normal.m_x, normal.m_y * cosAng + normal.m_z * sinAng, dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector origin1(origin.m_x, origin.m_y * cosAng + origin.m_z * sinAng, origin.m_z * cosAng - origin.m_y * sinAng, dgFloat32(0.0f)); - - count = dgCollisionConvex::CalculatePlaneIntersection(normal1, origin1, contactsOut); - if (count > 6) { - dgInt32 dy = 2 * 6; - dgInt32 dx = 2 * count; - dgInt32 acc = dy - count; - dgInt32 index = 0; - for (dgInt32 i = 0; i < count; i++) { - if (acc > 0) { - contactsOut[index] = contactsOut[i]; - index++; - acc -= dx; - } - acc += dy; - } - count = index; - } - - for (dgInt32 i = 0; i < count; i++) { - dgFloat32 y = contactsOut[i].m_y; - dgFloat32 z = contactsOut[i].m_z; - contactsOut[i].m_y = y * cosAng - z * sinAng; - contactsOut[i].m_z = z * cosAng + y * sinAng; - } - } - } else { - dgFloat32 magInv = dgRsqrt(normal.m_y * normal.m_y + normal.m_z * normal.m_z); - dgFloat32 cosAng = normal.m_y * magInv; - dgFloat32 sinAng = normal.m_z * magInv; - - dgAssert(dgAbs(normal.m_z * cosAng - normal.m_y * sinAng) < dgFloat32(1.0e-4f)); - dgVector normal1(normal.m_x, normal.m_y * cosAng + normal.m_z * sinAng, dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector origin1(origin.m_x, origin.m_y * cosAng + origin.m_z * sinAng, origin.m_z * cosAng - origin.m_y * sinAng, dgFloat32(0.0f)); - - count = 0; - int i0 = 3; - dgVector test0((m_profile[i0] - origin1).DotProduct(normal1)); - for (int i = 0; (i < 4) && (count < 2); i++) { - dgVector test1((m_profile[i] - origin1).DotProduct(normal1)); - dgVector acrossPlane(test0 * test1); - if (acrossPlane.m_x < 0.0f) { - dgVector step(m_profile[i] - m_profile[i0]); - contactsOut[count] = m_profile[i0] - step.Scale(test0.m_x / (step.DotProduct(normal1).m_x)); - count++; - } - i0 = i; - test0 = test1; - } - - for (dgInt32 i = 0; i < count; i++) { - dgFloat32 y = contactsOut[i].m_y; - dgFloat32 z = contactsOut[i].m_z; - contactsOut[i].m_y = y * cosAng - z * sinAng; - contactsOut[i].m_z = z * cosAng + y * sinAng; - } - } - return count; -} - - -void dgCollisionCylinder::GetCollisionInfo(dgCollisionInfo* const info) const -{ - dgCollisionConvex::GetCollisionInfo(info); - - info->m_cylinder.m_radio0 = m_radio0; - info->m_cylinder.m_radio1 = m_radio1; - info->m_cylinder.m_height = m_height * dgFloat32 (2.0f); -} - - -void dgCollisionCylinder::Serialize(dgSerialize callback, void* const userData) const -{ - dgVector size (m_radio0, m_radio1, m_height * dgFloat32 (2.0f), dgFloat32 (0.0f)); - SerializeLow(callback, userData); - callback (userData, &size, sizeof (dgVector)); -} - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionCylinder.h b/thirdparty/src/newton/dgPhysics/dgCollisionCylinder.h deleted file mode 100644 index 8d7ae92d5..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionCylinder.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_COLLISION_TAPERED_CYLINDER_H__ -#define _DG_COLLISION_TAPERED_CYLINDER_H__ - -#include "dgCollisionConvex.h" - -#define DG_TAPED_CYLINDER_SEGMENTS 12 - - -class dgCollisionCylinder: public dgCollisionConvex -{ - public: - dgCollisionCylinder(dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height); - dgCollisionCylinder(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionCylinder(); - - - private: - void Init (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height); - - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - - virtual dgFloat32 CalculateMassProperties (const dgMatrix& offset, dgVector& inertia, dgVector& crossInertia, dgVector& centerOfMass) const; - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - - virtual dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const; - - virtual dgInt32 CalculateSignature () const; - virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1); - - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - virtual void Serialize(dgSerialize callback, void* const userData) const; - - static dgInt32 CalculateSignature (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height); - - virtual dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const; - - virtual void MassProperties(); - - dgVector m_profile[4]; - dgVector m_vertex[DG_TAPED_CYLINDER_SEGMENTS * 2]; - dgFloat32 m_radio0; - dgFloat32 m_radio1; - dgFloat32 m_height; - - static dgInt32 m_shapeRefCount; - static dgConvexSimplexEdge m_edgeArray[]; - - friend class dgWorld; -}; - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionDeformableMesh.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionDeformableMesh.cpp deleted file mode 100644 index 559f9fa40..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionDeformableMesh.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" - -#include "dgWorld.h" -#include "dgContact.h" -#include "dgMeshEffect.h" -#include "dgDynamicBody.h" -#include "dgCollisionDeformableMesh.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#define DG_SMALLEST_SPRING_LENGTH dgFloat32 (1.0e-3f) - -dgVector dgCollisionDeformableMesh::m_smallestLenght2 (DG_SMALLEST_SPRING_LENGTH * DG_SMALLEST_SPRING_LENGTH); - -dgCollisionDeformableMesh::dgCollisionDeformableMesh(dgWorld* const world, dgCollisionID collisionID) - :dgCollisionLumpedMassParticles(world, collisionID) - ,m_linkList(world->GetAllocator()) - ,m_linksCount(0) -{ - m_rtti |= dgCollisionDeformableMesh_RTTI; -} - -dgCollisionDeformableMesh::dgCollisionDeformableMesh(const dgCollisionDeformableMesh& source) - :dgCollisionLumpedMassParticles(source) - ,m_linkList(source.m_linkList, source.m_linksCount) - ,m_linksCount(source.m_linksCount) -{ - m_rtti = source.m_rtti; -} - -dgCollisionDeformableMesh::dgCollisionDeformableMesh(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionLumpedMassParticles(world, deserialization, userData, revisionNumber) - ,m_linkList(world->GetAllocator()) - ,m_linksCount(0) -{ - dgAssert(0); -} - -dgCollisionDeformableMesh::~dgCollisionDeformableMesh(void) -{ -} - -void dgCollisionDeformableMesh::FinalizeBuild() -{ - dgCollisionLumpedMassParticles::FinalizeBuild(); -} - -void dgCollisionDeformableMesh::Serialize(dgSerialize callback, void* const userData) const -{ - dgAssert(0); -} - - -dgInt32 dgCollisionDeformableMesh::GetLinksCount() const -{ - return m_linksCount; -} - -void dgCollisionDeformableMesh::DisableInactiveLinks () -{ - dgAssert (0); -/* - for (dgInt32 i = 0; i < m_linksCount; i ++) { - dgInt32 v0 = m_linkList[i].m_v0; - dgInt32 v1 = m_linkList[i].m_v1; - if ((m_unitMassScaler[v0] == dgFloat32 (0.0f)) && (m_unitMassScaler[v1] == dgFloat32 (0.0f))) { - m_linksCount --; - dgSwap(m_linkList[m_linksCount], m_linkList[i]); - i --; - } - } -*/ -} - -const dgInt16* dgCollisionDeformableMesh::GetLinks() const -{ - return &m_linkList[0].m_m0; -} - - - -void dgCollisionDeformableMesh::ConstraintParticle(dgInt32 particleIndex, const dgVector& posit, const dgBody* const body) -{ - dgAssert(0); -} - - -void dgCollisionDeformableMesh::DebugCollision(const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - const dgVector* const posit = &m_posit[0]; - const dgSpringDamperLink* const links = &m_linkList[0]; - for (dgInt32 i = 0; i < m_linksCount; i++) { - const dgInt32 j0 = links[i].m_m0; - const dgInt32 j1 = links[i].m_m1; - dgVector p0(matrix.TransformVector(posit[j0])); - dgVector p1(matrix.TransformVector(posit[j1])); - dgTriplex points[2]; - points[0].m_x = p0.m_x; - points[0].m_y = p0.m_y; - points[0].m_z = p0.m_z; - points[1].m_x = p1.m_x; - points[1].m_y = p1.m_y; - points[1].m_z = p1.m_z; - callback(userData, 2, &points[0].m_x, 0); - } -} - - -void dgCollisionDeformableMesh::IntegrateForces(dgFloat32 timestep) -{ - dgAssert(m_body->m_invMass.m_w > dgFloat32(0.0f)); - - // calculate particles accelerations - CalculateAcceleration (timestep); -#ifdef _DEBUG - const dgMatrix& matrix = m_body->GetCollision()->GetGlobalMatrix(); - dgAssert (matrix[0][0] == dgFloat32 (1.0f)); - dgAssert (matrix[1][1] == dgFloat32 (1.0f)); - dgAssert (matrix[2][2] == dgFloat32 (1.0f)); -#endif - -dgAssert (0); -// dgVector damp(dgFloat32(1.0f)); -// if (m_body->m_linearDampOn) { -// const dgFloat32 tau = dgFloat32(1.0f) / (dgFloat32(60.0f) * timestep); -// damp = dgVector(dgPow(dgFloat32(1.0f) - m_body->m_dampCoef.m_w, tau)); -// } - - // rigid body dynamic state - dgVector timeV (timestep); - dgVector invTimestep (dgFloat32 (1.0f) / timestep); - - dgVector comVeloc(dgFloat32(0.0f)); - dgVector xMassSum(dgFloat32(0.0f)); - //dgVector origin(m_body->m_localCentreOfMass + matrix.m_posit); - - dgVector* const posit = &m_posit[0]; - dgVector* const veloc = &m_veloc[0]; - const dgFloat32* const mass = &m_mass[0]; - for (dgInt32 i = 0; i < m_particlesCount; i++) { - comVeloc += veloc[i].Scale(mass[i]); - xMassSum += posit[i].Scale(mass[i]); - } - - dgVector invMass(dgFloat32(1.0f / m_totalMass)); - comVeloc = comVeloc * invMass; - m_body->m_accel = invTimestep * (comVeloc - m_body->m_veloc); - m_body->m_veloc = comVeloc; - m_body->m_alpha = dgVector::m_zero; - m_body->m_omega = dgVector::m_zero; - m_body->m_invWorldInertiaMatrix = dgGetIdentityMatrix(); - - dgVector localCom(xMassSum * invMass); - for (dgInt32 i = 0; i < m_particlesCount; i++) { - posit[i] -= localCom; - } -} - - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionDeformableMesh.h b/thirdparty/src/newton/dgPhysics/dgCollisionDeformableMesh.h deleted file mode 100644 index 1ef260e89..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionDeformableMesh.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGCOLLISION_DEFORMABLE_MESH_H__ -#define __DGCOLLISION_DEFORMABLE_MESH_H__ - -#include "dgCollision.h" -#include "dgCollisionLumpedMassParticles.h" - - -class dgCollisionDeformableMesh: public dgCollisionLumpedMassParticles -{ - public: - dgCollisionDeformableMesh (const dgCollisionDeformableMesh& source); - dgCollisionDeformableMesh (dgWorld* const world, dgCollisionID collisionID); - dgCollisionDeformableMesh (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionDeformableMesh(void); - - dgInt32 GetLinksCount() const; - const dgInt16* GetLinks() const; - - virtual void ConstraintParticle(dgInt32 particleIndex, const dgVector& posit, const dgBody* const body); - - void DisableInactiveLinks (); - - protected: - class dgSpringDamperLink - { - public: - dgFloat32 m_spring; - dgFloat32 m_damper; - dgFloat32 m_restlength; - dgInt16 m_m0; - dgInt16 m_m1; - }; - - - virtual void CalculateAcceleration(dgFloat32 timestep) = 0; - - virtual void FinalizeBuild(); - virtual void Serialize(dgSerialize callback, void* const userData) const; - virtual void IntegrateForces(dgFloat32 timestep); - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - - dgArray<dgSpringDamperLink> m_linkList; - dgInt32 m_linksCount; - - static dgVector m_smallestLenght2; -}; - - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionDeformableSolidMesh.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionDeformableSolidMesh.cpp deleted file mode 100644 index 49c9a70de..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionDeformableSolidMesh.cpp +++ /dev/null @@ -1,372 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgMeshEffect.h" -#include "dgDynamicBody.h" -#include "dgCollisionDeformableSolidMesh.h" - - -dgCollisionDeformableSolidMesh::dgCollisionDeformableSolidMesh(dgWorld* const world, dgMeshEffect* const mesh) - :dgCollisionDeformableMesh(world, m_deformableSolidMesh) - ,m_finiteElements(world->GetAllocator()) - ,m_finiteElementsCount(0) -{ - m_rtti |= dgCollisionDeformableSolidMesh_RTTI; - - dgAssert (0); -/* - dgInt32 count = mesh->GetVertexCount(); - dgVector* const points = dgAlloca (dgVector, count); - - dgAssert (mesh->HasLayers()); - for (dgInt32 i = 0; i < count; i++) { - dgBigVector p(mesh->GetVertex(i)); - points[i] = p; - m_finiteElementsCount = dgMax (mesh->GetVertexLayer(i), m_finiteElementsCount); - } - m_finiteElementsCount ++; - - m_indexToVertexCount = count; - m_indexToVertexMap.Resize(count); - dgInt32* const indexToVertexMap = &m_indexToVertexMap[0]; - m_particlesCount = dgVertexListToIndexList (&points[0].m_x, sizeof (dgVector), 3 * sizeof (dgFloat32), 0, count, indexToVertexMap, dgFloat32 (1.0e-5f)); - for (dgInt32 i = 0; i < m_particlesCount; i++) { - m_posit[i] = points[i]; - } - - dgInt32 edgeCount = 0; - dgSoftLink* const links = dgAlloca (dgSoftLink, mesh->GetCount() / 2); - for (void* edgePtr = mesh->GetFirstEdge(); edgePtr; edgePtr = mesh->GetNextEdge(edgePtr)) { - dgInt32 v0; - dgInt32 v1; - mesh->GetEdgeIndex(edgePtr, v0, v1); - v0 = indexToVertexMap[v0]; - v1 = indexToVertexMap[v1]; - links[edgeCount].m_m0 = dgInt16(dgMin (v0, v1)); - links[edgeCount].m_m1 = dgInt16(dgMax (v0, v1)); - edgeCount ++; - } - dgAssert(edgeCount == mesh->GetCount() / 2); - dgSort(links, edgeCount, CompareEdges); - - dgInt32 uniqueEdgeCount = 0; - for (dgInt32 i = 1; i < edgeCount; i ++) { - if (CompareEdges (&links[i], &links[uniqueEdgeCount], NULL) > 0) { - uniqueEdgeCount++; - links[uniqueEdgeCount] = links[i]; - } - } - uniqueEdgeCount++; - m_linksCount = uniqueEdgeCount; - m_linkList.Resize(m_linksCount); - for (dgInt32 i = 0; i < m_linksCount; i ++) { - m_linkList[i] = links[i]; - } - FinalizeBuild(); - - m_finiteElements.Resize(m_finiteElementsCount); - - dgInt32 elementIndex = 0; - dgInt32 mark = mesh->IncLRU(); - dgMeshEffect::Iterator iter(*mesh); - for (iter.Begin (); iter; iter ++) { - dgEdge* const edge = &(*iter); - dgAssert (edge->m_incidentFace > 0); - if ((edge->m_mark < mark) && (edge->m_incidentFace > 0)) { - dgEdge* edgeStack[32]; - dgFiniteElementCell& fem = m_finiteElements[elementIndex]; - dgAssert (elementIndex < m_finiteElementsCount); - elementIndex ++; - - dgInt32 tetraVertex = 0; - dgInt32 stackIndex = 1; - edgeStack[0] = edge; - while (stackIndex){ - stackIndex --; - dgEdge* const pointEdge = edgeStack[stackIndex]; - dgAssert (pointEdge->m_incidentFace > 0); - if ((pointEdge->m_mark < mark) && (pointEdge->m_incidentFace > 0)) { - fem.m_index[tetraVertex] = dgInt16 (m_indexToVertexMap[pointEdge->m_incidentVertex]); - dgAssert (tetraVertex < 4); - tetraVertex ++; - dgEdge* edgePtr = pointEdge; - do { - dgAssert (mesh->GetVertexLayer(edge->m_incidentVertex) == mesh->GetVertexLayer(edgePtr->m_incidentVertex)); - if (edgePtr->m_mark != mark) { - edgePtr->m_mark = mark; - edgeStack[stackIndex] = edgePtr->m_twin; - stackIndex ++; - } - edgePtr = edgePtr->m_twin->m_next; - } while (edgePtr != pointEdge); - } - } - } - } - dgAssert (elementIndex == m_finiteElementsCount); - - for (dgInt32 i = 0; i < m_finiteElementsCount; i ++) { - dgFiniteElementCell& fem = m_finiteElements[i]; - const dgVector& p0 = points[fem.m_index[0]]; - const dgVector& p1 = points[fem.m_index[1]]; - const dgVector& p2 = points[fem.m_index[2]]; - const dgVector& p3 = points[fem.m_index[3]]; - - dgVector p01 (p0 - p1); - dgVector p12 (p1 - p2); - dgVector p23 (p2 - p3); - dgFloat32 volume = (p01.DotProduct(p12.CrossProduct(p23))).GetScalar(); - if (volume < dgFloat32 (0.0f)) { - volume = -volume; - dgSwap(fem.m_index[0], fem.m_index[1]); - } - fem.m_restVolume = volume; - } -*/ -} - -dgCollisionDeformableSolidMesh::dgCollisionDeformableSolidMesh(const dgCollisionDeformableSolidMesh& source) - :dgCollisionDeformableMesh(source) - ,m_finiteElements(source.m_finiteElements, source.m_finiteElementsCount) - ,m_finiteElementsCount(source.m_finiteElementsCount) -{ - m_rtti = source.m_rtti; -} - -dgCollisionDeformableSolidMesh::dgCollisionDeformableSolidMesh(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionDeformableMesh(world, deserialization, userData, revisionNumber) - ,m_finiteElements(world->GetAllocator()) - ,m_finiteElementsCount(0) -{ - dgAssert (0); -} - - -dgCollisionDeformableSolidMesh::~dgCollisionDeformableSolidMesh(void) -{ - -} - -dgInt32 dgCollisionDeformableSolidMesh::GetMemoryBufferSizeInBytes() const -{ - dgInt32 sizeInByte = 0; - sizeInByte += 3 * m_linksCount * sizeof (dgVector); - sizeInByte += 2 * m_linksCount * sizeof (dgFloat32); - sizeInByte += 2 * m_particlesCount * sizeof (dgVector); - sizeInByte += 1 * m_particlesCount * sizeof (dgFloat32); - return sizeInByte; -} - - -void dgCollisionDeformableSolidMesh::CalculateAcceleration(dgFloat32 timestep) -{ - dgAssert (0); -/* -// Ks is in [sec^-2] a spring constant unit acceleration, not a spring force acceleration. -// Kc is in [sec^-1] a damper constant unit velocity, not a damper force acceleration. - -// for now make a share value for all springs. later this is a per material feature. -dgFloat32 kSpring = dgFloat32(1000.0f); -dgFloat32 kDamper = dgFloat32(30.0f); -//dgFloat32 kVolumetricStiffness = dgFloat32(200000.0f); -dgFloat32 kVolumetricStiffness = dgFloat32(20000000.0f); -//dgFloat32 kVolumetricStiffness = dgFloat32(1000.0f); -//kVolumetricStiffness = 0.0f; - - dgInt32 iter = 4; - dgVector* const accel = &m_accel[0]; - dgVector* const veloc = &m_veloc[0]; - dgVector* const posit = &m_posit[0]; - const dgFloat32* const restLenght = &m_restlength[0]; - const dgFiniteElementCell* const finiteElements = &m_finiteElements[0]; - -// dgVector* const dx = dgAlloca(dgVector, m_linksCount); -// dgVector* const dv = dgAlloca(dgVector, m_linksCount); -// dgVector* const dpdv = dgAlloca(dgVector, m_linksCount); -// dgVector* const normalAccel = dgAlloca(dgVector, m_particlesCount); -// dgVector* const normalDir = dgAlloca(dgVector, m_particlesCount); -// dgVector* const volumeAccel = dgAlloca(dgVector, m_particlesCount); -// dgFloat32* const spring_A01 = dgAlloca(dgFloat32, m_linksCount); -// dgFloat32* const spring_B01 = dgAlloca(dgFloat32, m_linksCount); -// dgFloat32* const frictionCoeffecient = dgAlloca(dgFloat32, m_particlesCount); - - dgWorld* const world = m_body->GetWorld(); - world->m_solverJacobiansMemory.ResizeIfNecessary (GetMemoryBufferSizeInBytes() + 1024); - dgVector* const dx = (dgVector*)&world->m_solverJacobiansMemory[0]; - dgVector* const dv = &dx[m_linksCount]; - dgVector* const dpdv = &dv[m_linksCount]; - dgVector* const normalAccel = &dpdv[m_linksCount]; - dgVector* const normalDir = &normalAccel[m_particlesCount]; - dgVector* const volumeAccel = &normalDir[m_particlesCount]; - dgFloat32* const spring_A01 = (dgFloat32*) &volumeAccel[m_particlesCount]; - dgFloat32* const spring_B01 = &spring_A01[m_linksCount]; - dgFloat32* const frictionCoeffecient = &spring_B01[m_linksCount]; - - -// dgVector* const collisionDir1 = dgAlloca(dgVector, m_particlesCount); -// dgVector* const collisionDir2 = dgAlloca(dgVector, m_particlesCount); -// dgVector* const tmp1 = dgAlloca(dgVector, m_particlesCount); -// dgVector* const tmp2 = dgAlloca(dgVector, m_particlesCount); -// dgVector* const diag = dgAlloca(dgVector, m_particlesCount); -// dgVector* const offDiag = dgAlloca(dgVector, m_particlesCount); -// dgFloat32* const damper_A01 = dgAlloca(dgFloat32, m_linksCount); -// dgFloat32* const damper_B01 = dgAlloca(dgFloat32, m_linksCount); -// dgFloat32* const damper_C01 = dgAlloca(dgFloat32, m_linksCount); - - - - - dgVector unitAccel(m_body->m_externalForce * m_body->m_invMass.m_w); - dgVector deltaOmega(m_body->m_invWorldInertiaMatrix.RotateVector (m_body->m_externalTorque.Scale (timestep))); - - m_body->m_alpha = dgVector::m_zero; - m_body->m_omega = dgVector::m_zero; - m_body->m_externalForce = dgVector::m_zero; - m_body->m_externalTorque = dgVector::m_zero; - - // here I need to add all other external acceleration like wind and pressure, friction and collision. - for (dgInt32 i = 0; i < m_particlesCount; i++) { - m_externalAccel[i] = unitAccel; - veloc[i] += deltaOmega.CrossProduct(m_posit[i]); - } - - const dgSpringDamperLink* const links = &m_linkList[0]; - dgFloat32 ks_dt = - timestep * kSpring; -// dgFloat32 kd_dt0 = -timestep * kDamper; -// dgFloat32 kd_dt1 = -timestep * kDamper * dgFloat32(2.0f); - - dgVector dtRK4 (timestep / iter); - dgVector volumetricStiffness (-kVolumetricStiffness); - dgVector epsilon (dgFloat32 (1.0e-14f)); - - dtRK4 = dtRK4 & dgVector::m_triplexMask; - HandleCollision (timestep, normalDir, normalAccel, frictionCoeffecient); - for (dgInt32 k = 0; k < iter; k ++) { - - for (dgInt32 i = 0; i < m_particlesCount; i++) { - accel[i] = m_externalAccel[i]; - volumeAccel[i] = dgVector::m_zero; - } - - for (dgInt32 i = 0; i < m_finiteElementsCount; i++) { - const dgFiniteElementCell& fem = finiteElements[i]; - const dgInt32 i0 = fem.m_index[0]; - const dgInt32 i1 = fem.m_index[1]; - const dgInt32 i2 = fem.m_index[2]; - const dgInt32 i3 = fem.m_index[3]; - const dgVector& p0 = posit[i0]; - const dgVector& p1 = posit[i1]; - const dgVector& p2 = posit[i2]; - const dgVector& p3 = posit[i3]; - - const dgVector p01(p0 - p1); - const dgVector p12(p1 - p2); - const dgVector p23(p2 - p3); - - dgVector area123(p12.CrossProduct(p23)); - dgVector area0123(p23.CrossProduct(p01)); - dgVector area012(p12.CrossProduct(p01)); - - dgFloat32 volume = (p01.DotProduct(area123)).GetScalar(); - dgVector deltaVolume(volume - fem.m_restVolume); - dgVector a0(deltaVolume * area123); - dgVector a1(deltaVolume * area0123); - dgVector a3(deltaVolume * area012); - dgAssert (a0.m_w == dgFloat32 (0.0f)); - dgAssert (a1.m_w == dgFloat32 (0.0f)); - dgAssert (a3.m_w == dgFloat32 (0.0f)); - - volumeAccel[i0] += a0; - volumeAccel[i1] += a1 - a0; - volumeAccel[i2] -= a1 + a3; - volumeAccel[i3] += a3; - } - - for (dgInt32 i = 0; i < m_linksCount; i++) { - const dgInt32 j0 = links[i].m_m0; - const dgInt32 j1 = links[i].m_m1; - dv[i] = veloc[j0] - veloc[j1]; - dx[i] = posit[j0] - posit[j1]; - - const dgVector p0p1 (dx[i]); - const dgVector v0v1 (dv[i]); - const dgVector length2(p0p1.DotProduct(p0p1)); - const dgVector mask(length2 > m_smallestLenght2); - - const dgVector lenght2 ((length2 & mask) | length2.And__Not(mask)); - const dgFloat32 length = (lenght2.Sqrt()).GetScalar(); - const dgFloat32 den = dgFloat32 (1.0f) / length; - const dgFloat32 lenghtRatio = restLenght[i] * den; - const dgFloat32 compression = dgFloat32(1.0f) - lenghtRatio; - const dgVector fs(p0p1.Scale(kSpring * compression)); - const dgVector fd(p0p1.Scale(kDamper * den * den * (v0v1.DotProduct(p0p1)).GetScalar())); - - dgAssert(fs.m_w == dgFloat32(0.0f)); - dgAssert(fs.m_w == dgFloat32(0.0f)); - dgAssert(p0p1.m_w == dgFloat32(0.0f)); - - dpdv[i] = p0p1 * v0v1; - accel[j0] -= (fs + fd); - accel[j1] += (fs + fd); - - spring_A01[i] = ks_dt * compression; - spring_B01[i] = ks_dt * lenghtRatio * den * den; - } - - for (dgInt32 i = 0; i < m_linksCount; i++) { - const dgVector dv0 (dv[i]); - const dgVector A01(spring_A01[i]); - const dgVector B01(spring_B01[i]); - const dgVector dfdx (A01 * dv0 + B01 * dx[i] * dpdv[i]); - - const dgInt32 j0 = links[i].m_m0; - const dgInt32 j1 = links[i].m_m1; - - dgAssert (dfdx.m_w == dgFloat32 (0.0f)); - accel[j0] += dfdx; - accel[j1] -= dfdx; - } - - for (dgInt32 i = 0; i < m_particlesCount; i++) { - accel[i] += volumetricStiffness * volumeAccel[i]; - dgVector normalDirAccel (normalDir[i] * accel[i].DotProduct(normalDir[i])); - - //dgVector dirAccel1 (collisionDir1[i] * accel[i].DotProduct(collisionDir1[i])); - //dgVector dirAccel2 (collisionDir2[i] * accel[i].DotProduct(collisionDir2[i])); - //tmp0[i] = accel[i] + collidingAccel[i] - dirAccel0 - dirAccel1 - dirAccel2; - - dgVector tangentDir (veloc[i] - normalDir[i] * normalDir[i].DotProduct(veloc[i])); - dgVector mag (tangentDir.DotProduct(tangentDir) + epsilon); - - dgFloat32 tangentFrictionAccel = dgAbs (accel[i].DotProduct(normalDir[i]).GetScalar()); - dgVector friction (tangentDir.Scale (frictionCoeffecient[i] * tangentFrictionAccel / dgSqrt (mag.GetScalar()))); - - accel[i] += (normalAccel[i] - normalDirAccel - friction); - veloc[i] += accel[i] * dtRK4; - posit[i] += veloc[i] * dtRK4; - } - } -*/ -} diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionDeformableSolidMesh.h b/thirdparty/src/newton/dgPhysics/dgCollisionDeformableSolidMesh.h deleted file mode 100644 index 3d7486e05..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionDeformableSolidMesh.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGCOLLISION_DEFORMABLE_SOLID_MESH_H__ -#define __DGCOLLISION_DEFORMABLE_SOLID_MESH_H__ - - -#include "dgCollision.h" -#include "dgCollisionConvex.h" -#include "dgCollisionDeformableMesh.h" - - - -class dgCollisionDeformableSolidMesh: public dgCollisionDeformableMesh -{ - public: - class dgFiniteElementCell - { - public: - dgFloat32 m_restVolume; - dgInt16 m_index[4]; - }; - - dgCollisionDeformableSolidMesh (const dgCollisionDeformableSolidMesh& source); - dgCollisionDeformableSolidMesh (dgWorld* const world, dgMeshEffect* const mesh); - dgCollisionDeformableSolidMesh (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionDeformableSolidMesh(void); - - virtual void CalculateAcceleration(dgFloat32 timestep); - - dgInt32 GetMemoryBufferSizeInBytes() const; - - dgArray<dgFiniteElementCell> m_finiteElements; - dgInt32 m_finiteElementsCount; -}; - - - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionHeightField.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionHeightField.cpp deleted file mode 100644 index 806bc1972..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionHeightField.cpp +++ /dev/null @@ -1,1220 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgCollisionHeightField.h" - - -#define DG_HIGHTFIELD_DATA_ID 0x45AF5E07 - -dgVector dgCollisionHeightField::m_yMask (0xffffffff, 0, 0xffffffff, 0); -dgVector dgCollisionHeightField::m_padding (dgFloat32 (0.25f), dgFloat32 (0.25f), dgFloat32 (0.25f), dgFloat32 (0.0f)); -dgVector dgCollisionHeightField::m_elevationPadding (dgFloat32 (0.0f), dgFloat32 (1.0e10f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - -dgInt32 dgCollisionHeightField::m_cellIndices[][4] = -{ - {0, 1, 2, 3}, - {1, 3, 0, 2} -}; - -dgInt32 dgCollisionHeightField::m_verticalEdgeMap[][7] = -{ - {1 * 9 + 1, 0 * 9 + 0, 1 * 9 + 4, 1 * 9 + 6, 0 * 9 + 6, 1 * 9 + 4, 0 * 9 + 4}, - {1 * 9 + 2, 0 * 9 + 1, 1 * 9 + 4, 1 * 9 + 6, 0 * 9 + 7, 1 * 9 + 4, 0 * 9 + 4}, - {1 * 9 + 2, 0 * 9 + 0, 1 * 9 + 4, 1 * 9 + 7, 0 * 9 + 6, 1 * 9 + 4, 0 * 9 + 4}, - {1 * 9 + 0, 0 * 9 + 1, 1 * 9 + 4, 1 * 9 + 7, 0 * 9 + 7, 1 * 9 + 4, 0 * 9 + 4} -}; - -dgInt32 dgCollisionHeightField::m_horizontalEdgeMap[][7] = -{ - {1 * 9 + 0, 2 * 9 + 1, 1 * 9 + 4, 1 * 9 + 7, 2 * 9 + 7, 1 * 9 + 4, 2 * 9 + 4}, - {1 * 9 + 0, 3 * 9 + 0, 1 * 9 + 4, 1 * 9 + 7, 3 * 9 + 6, 1 * 9 + 4, 3 * 9 + 4}, - {0 * 9 + 1, 2 * 9 + 1, 0 * 9 + 4, 1 * 9 + 7, 2 * 9 + 7, 0 * 9 + 4, 2 * 9 + 4}, - {0 * 9 + 1, 3 * 9 + 0, 0 * 9 + 4, 0 * 9 + 6, 3 * 9 + 6, 0 * 9 + 4, 3 * 9 + 4} -}; - - -dgCollisionHeightField::dgCollisionHeightField( - dgWorld* const world, dgInt32 width, dgInt32 height, dgInt32 contructionMode, - const void* const elevationMap, dgElevationType elevationDataType, dgFloat32 verticalScale, - const dgInt8* const atributeMap, dgFloat32 horizontalScale_x, dgFloat32 horizontalScale_z) - :dgCollisionMesh (world, m_heightField) - ,m_width(width) - ,m_height(height) - ,m_diagonalMode (dgCollisionHeightFieldGridConstruction (dgClamp (contructionMode, dgInt32 (m_normalDiagonals), dgInt32 (m_starInvertexDiagonals)))) - ,m_verticalScale(verticalScale) - ,m_horizontalScale_x(horizontalScale_x) - ,m_horizontalScaleInv_x (dgFloat32 (1.0f) / m_horizontalScale_x) - ,m_horizontalScale_z(horizontalScale_z) - ,m_horizontalScaleInv_z(dgFloat32(1.0f) / m_horizontalScale_z) - ,m_userRayCastCallback(NULL) - ,m_elevationDataType(elevationDataType) -{ - m_rtti |= dgCollisionHeightField_RTTI; - - switch (m_elevationDataType) - { - case m_float32Bit: - { - m_elevationMap = dgMallocStack(m_width * m_height * sizeof (dgFloat32)); - memcpy (m_elevationMap, elevationMap, m_width * m_height * sizeof (dgFloat32)); - break; - } - - case m_unsigned16Bit: - { - m_elevationMap = dgMallocStack(m_width * m_height * sizeof (dgUnsigned16)); - memcpy (m_elevationMap, elevationMap, m_width * m_height * sizeof (dgUnsigned16)); - } - } - - dgInt32 attibutePaddedMapSize = (m_width * m_height + 4) & -4; - m_atributeMap = (dgInt8 *)dgMallocStack(attibutePaddedMapSize * sizeof (dgInt8)); - m_diagonals = (dgInt8 *)dgMallocStack(attibutePaddedMapSize * sizeof (dgInt8)); - - switch (m_diagonalMode) - { - case m_normalDiagonals: - { - memset (m_diagonals, 0, m_width * m_height * sizeof (dgInt8)); - break; - } - case m_invertedDiagonals: - { - memset (m_diagonals, 1, m_width * m_height * sizeof (dgInt8)); - break; - } - - case m_alternateOddRowsDiagonals: - { - for (dgInt32 j = 0; j < m_height; j += 2) { - dgInt32 index = j * m_width; - for (dgInt32 i = 0; i < m_width; i ++) { - m_diagonals[index + i] = 0; - } - } - - for (dgInt32 j = 1; j < m_height; j += 2) { - dgInt32 index = j * m_width; - for (dgInt32 i = 0; i < m_width; i ++) { - m_diagonals[index + i] = 1; - } - } - break; - } - - case m_alternateEvenRowsDiagonals: - { - for (dgInt32 j = 0; j < m_height; j += 2) { - dgInt32 index = j * m_width; - for (dgInt32 i = 0; i < m_width; i ++) { - m_diagonals[index + i] = 1; - } - } - - for (dgInt32 j = 1; j < m_height; j += 2) { - dgInt32 index = j * m_width; - for (dgInt32 i = 0; i < m_width; i ++) { - m_diagonals[index + i] = 0; - } - } - break; - } - - - case m_alternateOddColumsDiagonals: - { - for (dgInt32 j = 0; j < m_height; j ++) { - dgInt32 index = j * m_width; - for (dgInt32 i = 0; i < m_width; i += 2) { - m_diagonals[index + i] = 0; - } - - for (dgInt32 i = 1; i < m_width; i += 2) { - m_diagonals[index + i] = 1; - } - } - break; - } - - case m_alternateEvenColumsDiagonals: - { - for (dgInt32 j = 0; j < m_height; j ++) { - dgInt32 index = j * m_width; - for (dgInt32 i = 0; i < m_width; i += 2) { - m_diagonals[index + i] = 1; - } - - for (dgInt32 i = 1; i < m_width; i += 2) { - m_diagonals[index + i] = 0; - } - } - break; - } - - case m_starDiagonals: - { - for (dgInt32 j = 0; j < m_height; j += 2) { - dgInt32 index = j * m_width; - for (dgInt32 i = 0; i < m_width; i += 2) { - m_diagonals[index + i] = 0; - } - for (dgInt32 i = 1; i < m_width; i += 2) { - m_diagonals[index + i] = 1; - } - } - - for (dgInt32 j = 1; j < m_height; j += 2) { - dgInt32 index = j * m_width; - for (dgInt32 i = 0; i < m_width; i += 2) { - m_diagonals[index + i] = 1; - } - for (dgInt32 i = 1; i < m_width; i += 2) { - m_diagonals[index + i] = 0; - } - } - break; - } - - case m_starInvertexDiagonals: - { - for (dgInt32 j = 0; j < m_height; j += 2) { - dgInt32 index = j * m_width; - for (dgInt32 i = 0; i < m_width; i += 2) { - m_diagonals[index + i] = 1; - } - for (dgInt32 i = 1; i < m_width; i += 2) { - m_diagonals[index + i] = 0; - } - } - - for (dgInt32 j = 1; j < m_height; j += 2) { - dgInt32 index = j * m_width; - for (dgInt32 i = 0; i < m_width; i += 2) { - m_diagonals[index + i] = 0; - } - for (dgInt32 i = 1; i < m_width; i += 2) { - m_diagonals[index + i] = 1; - } - } - - break; - } - - default: - dgAssert (0); - - } - memcpy (m_atributeMap, atributeMap, m_width * m_height * sizeof (dgInt8)); - - dgTree<void*, unsigned>::dgTreeNode* nodeData = world->m_perInstanceData.Find(DG_HIGHTFIELD_DATA_ID); - if (!nodeData) { - m_instanceData = (dgPerIntanceData*) new dgPerIntanceData(); - m_instanceData->m_refCount = 0; - m_instanceData->m_world = world; - for (dgInt32 i = 0 ; i < DG_MAX_THREADS_HIVE_COUNT; i ++) { - m_instanceData->m_vertex[i] = NULL; - m_instanceData->m_vertexCount[i] = 0; - m_instanceData->m_vertex[i].SetAllocator(world->GetAllocator()); - AllocateVertex(world, i); - } - nodeData = world->m_perInstanceData.Insert (m_instanceData, DG_HIGHTFIELD_DATA_ID); - } - m_instanceData = (dgPerIntanceData*) nodeData->GetInfo(); - - m_instanceData->m_refCount ++; - - CalculateAABB(); - SetCollisionBBox(m_minBox, m_maxBox); -} - -dgCollisionHeightField::dgCollisionHeightField (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionMesh (world, deserialization, userData, revisionNumber) -{ - dgAssert (m_rtti | dgCollisionHeightField_RTTI); - - dgInt32 elevationDataType; - - m_userRayCastCallback = NULL; - deserialization (userData, &m_width, sizeof (dgInt32)); - deserialization (userData, &m_height, sizeof (dgInt32)); - deserialization (userData, &m_diagonalMode, sizeof (dgInt32)); - deserialization (userData, &elevationDataType, sizeof (dgInt32)); - deserialization (userData, &m_verticalScale, sizeof (dgFloat32)); - deserialization (userData, &m_horizontalScale_x, sizeof (dgFloat32)); - deserialization (userData, &m_horizontalScale_z, sizeof (dgFloat32)); - deserialization (userData, &m_minBox.m_x, sizeof (dgVector)); - deserialization (userData, &m_maxBox.m_x, sizeof (dgVector)); - - m_elevationDataType = dgElevationType (elevationDataType); - - dgInt32 attibutePaddedMapSize = (m_width * m_height + 4) & -4; - m_atributeMap = (dgInt8 *)dgMallocStack(attibutePaddedMapSize * sizeof (dgInt8)); - m_diagonals = (dgInt8 *)dgMallocStack(attibutePaddedMapSize * sizeof (dgInt8)); - - switch (m_elevationDataType) - { - case m_float32Bit: - { - m_elevationMap = dgMallocStack(m_width * m_height * sizeof (dgFloat32)); - deserialization (userData, m_elevationMap, m_width * m_height * sizeof (dgFloat32)); - break; - } - - case m_unsigned16Bit: - { - m_elevationMap = dgMallocStack(m_width * m_height * sizeof (dgUnsigned16)); - deserialization (userData, m_elevationMap, m_width * m_height * sizeof (dgUnsigned16)); - break; - } - } - deserialization (userData, m_atributeMap, attibutePaddedMapSize * sizeof (dgInt8)); - deserialization (userData, m_diagonals, attibutePaddedMapSize * sizeof (dgInt8)); - - m_horizontalScaleInv_x = dgFloat32 (1.0f) / m_horizontalScale_x; - m_horizontalScaleInv_z = dgFloat32 (1.0f) / m_horizontalScale_z; - - dgTree<void*, unsigned>::dgTreeNode* nodeData = world->m_perInstanceData.Find(DG_HIGHTFIELD_DATA_ID); - if (!nodeData) { - m_instanceData = (dgPerIntanceData*) new dgPerIntanceData(); - m_instanceData->m_refCount = 0; - m_instanceData->m_world = world; - for (dgInt32 i = 0; i < DG_MAX_THREADS_HIVE_COUNT; i++) { - m_instanceData->m_vertex[i] = NULL; - m_instanceData->m_vertexCount[i] = 0; - m_instanceData->m_vertex[i].SetAllocator(world->GetAllocator()); - AllocateVertex(world, i); - } - nodeData = world->m_perInstanceData.Insert(m_instanceData, DG_HIGHTFIELD_DATA_ID); - } - m_instanceData = (dgPerIntanceData*)nodeData->GetInfo(); - - m_instanceData->m_refCount ++; - SetCollisionBBox(m_minBox, m_maxBox); -} - -dgCollisionHeightField::~dgCollisionHeightField(void) -{ - m_instanceData->m_refCount --; - if (!m_instanceData->m_refCount) { - dgWorld* const world = m_instanceData->m_world; - delete m_instanceData; - world->m_perInstanceData.Remove(DG_HIGHTFIELD_DATA_ID); - } - dgFreeStack(m_elevationMap); - dgFreeStack(m_atributeMap); - dgFreeStack(m_diagonals); -} - -void dgCollisionHeightField::Serialize(dgSerialize callback, void* const userData) const -{ - SerializeLow(callback, userData); - - dgInt32 elevationDataType = m_elevationDataType; - - callback (userData, &m_width, sizeof (dgInt32)); - callback (userData, &m_height, sizeof (dgInt32)); - callback (userData, &m_diagonalMode, sizeof (dgInt32)); - callback (userData, &elevationDataType, sizeof (dgInt32)); - callback (userData, &m_verticalScale, sizeof (dgFloat32)); - callback (userData, &m_horizontalScale_x, sizeof (dgFloat32)); - callback (userData, &m_horizontalScale_z, sizeof (dgFloat32)); - callback (userData, &m_minBox.m_x, sizeof (dgVector)); - callback (userData, &m_maxBox.m_x, sizeof (dgVector)); - - switch (m_elevationDataType) - { - case m_float32Bit: - { - callback (userData, m_elevationMap, m_width * m_height * sizeof (dgFloat32)); - break; - } - case m_unsigned16Bit: - { - callback (userData, m_elevationMap, m_width * m_height * sizeof (dgUnsigned16)); - break; - } - } - - dgInt32 attibutePaddedMapSize = (m_width * m_height + 4) & -4; - callback (userData, m_atributeMap, attibutePaddedMapSize * sizeof (dgInt8)); - callback (userData, m_diagonals, attibutePaddedMapSize * sizeof (dgInt8)); -} - -void dgCollisionHeightField::SetCollisionRayCastCallback (dgCollisionHeightFieldRayCastCallback rayCastCallback) -{ - m_userRayCastCallback = rayCastCallback; -} - -void dgCollisionHeightField::AllocateVertex(dgWorld* const world, dgInt32 threadIndex) const -{ - m_instanceData->m_vertex[threadIndex].Resize (m_instanceData->m_vertex[threadIndex].GetElementsCapacity() * 2); - m_instanceData->m_vertexCount[threadIndex] = m_instanceData->m_vertex[threadIndex].GetElementsCapacity(); -} - -DG_INLINE void dgCollisionHeightField::CalculateMinExtend2d(const dgVector& p0, const dgVector& p1, dgVector& boxP0, dgVector& boxP1) const -{ - dgVector scale (m_horizontalScale_x, dgFloat32 (0.0f), m_horizontalScale_z, dgFloat32 (0.0f)); - dgVector q0(p0.GetMin(p1) - m_padding); - dgVector q1(p0.GetMax(p1) + scale + m_padding); - - dgVector invScale (m_horizontalScaleInv_x, dgFloat32 (0.0f), m_horizontalScaleInv_z, dgFloat32 (0.0f)); - boxP0 = (((q0 * invScale).Floor() * scale) & m_yMask) - m_elevationPadding; - boxP1 = (((q1 * invScale).Floor() * scale + scale) & m_yMask) + m_elevationPadding; - dgAssert (boxP0.m_w == dgFloat32 (0.0f)); - dgAssert (boxP1.m_w == dgFloat32 (0.0f)); - -// dgVector minBox((m_minBox & m_yMask) + boxP0.AndNot(m_yMask)); -// dgVector maxBox((m_maxBox & m_yMask) + boxP1.AndNot(m_yMask)); - dgVector minBox(boxP0.Select(m_minBox, m_yMask)); - dgVector maxBox(boxP1.Select(m_maxBox, m_yMask)); - - boxP0 = boxP0.GetMax(minBox); - boxP1 = boxP1.GetMin(maxBox); -} - -DG_INLINE void dgCollisionHeightField::CalculateMinExtend3d(const dgVector& p0, const dgVector& p1, dgVector& boxP0, dgVector& boxP1) const -{ - dgAssert(p0.m_x <= p1.m_x); - dgAssert(p0.m_y <= p1.m_y); - dgAssert(p0.m_z <= p1.m_z); - dgAssert(p0.m_w == dgFloat32(0.0f)); - dgAssert(p1.m_w == dgFloat32(0.0f)); - - dgVector scale (m_horizontalScale_x, dgFloat32 (0.0f), m_horizontalScale_z, dgFloat32 (0.0f)); - dgVector q0(p0.GetMin(p1) - m_padding); - dgVector q1(p0.GetMax(p1) + scale + m_padding); - - dgVector invScale(m_horizontalScaleInv_x, dgFloat32(0.0f), m_horizontalScaleInv_z, dgFloat32(0.0f)); - - boxP0 = q0.Select((q0 * invScale).Floor() * scale, m_yMask); - boxP1 = q1.Select((q1 * invScale).Floor() * scale + scale, m_yMask); - - dgVector minBox(boxP0.Select(m_minBox, m_yMask)); - dgVector maxBox(boxP1.Select(m_maxBox, m_yMask)); - - boxP0 = boxP0.GetMax(minBox); - boxP1 = boxP1.GetMin(maxBox); -} - -void dgCollisionHeightField::CalculateAABB() -{ - dgFloat32 y0 = dgFloat32 (dgFloat32 (1.0e10f)); - dgFloat32 y1 = dgFloat32 (-dgFloat32 (1.0e10f)); - switch (m_elevationDataType) - { - case m_float32Bit: - { - const dgFloat32* const elevation = (dgFloat32*)m_elevationMap; - for (dgInt32 i = 0; i < m_width * m_height; i ++) { - y0 = dgMin(y0, elevation[i]); - y1 = dgMax(y1, elevation[i]); - } - break; - } - - case m_unsigned16Bit: - { - const dgUnsigned16* const elevation = (dgUnsigned16*)m_elevationMap; - for (dgInt32 i = 0; i < m_width * m_height; i ++) { - y0 = dgMin(y0, dgFloat32 (elevation[i])); - y1 = dgMax(y1, dgFloat32 (elevation[i])); - } - } - } - - m_minBox = dgVector (dgFloat32 (dgFloat32 (0.0f)), y0 * m_verticalScale, dgFloat32 (dgFloat32 (0.0f)), dgFloat32 (0.0f)); - m_maxBox = dgVector (dgFloat32 (m_width - 1) * m_horizontalScale_x, y1 * m_verticalScale, dgFloat32 (m_height-1) * m_horizontalScale_z, dgFloat32 (0.0f)); -} - -void dgCollisionHeightField::GetCollisionInfo(dgCollisionInfo* const info) const -{ - dgCollision::GetCollisionInfo(info); - - dgCollisionInfo::dgHeightMapCollisionData& data = info->m_heightFieldCollision; - data.m_width = m_width; - data.m_height = m_height; - data.m_gridsDiagonals = m_diagonalMode; - data.m_elevationDataType = m_elevationDataType; - data.m_verticalScale = m_verticalScale; - data.m_horizonalScale_x = m_horizontalScale_x; - data.m_horizonalScale_z = m_horizontalScale_z; - data.m_atributes = m_atributeMap; - data.m_elevation = m_elevationMap; -} - -dgFloat32 dgCollisionHeightField::RayCastCell (const dgFastRayTest& ray, dgInt32 xIndex0, dgInt32 zIndex0, dgVector& normalOut, dgFloat32 maxT) const -{ - dgVector points[4]; - dgInt32 triangle[3]; - - // get the 3d point at the corner of the cell - if ((xIndex0 < 0) || (zIndex0 < 0) || (xIndex0 >= (m_width - 1)) || (zIndex0 >= (m_height - 1))) { - return dgFloat32 (1.2f); - } - - dgAssert (maxT <= 1.0); - - dgInt32 base = zIndex0 * m_width + xIndex0; - - switch (m_elevationDataType) - { - case m_float32Bit: - { - const dgFloat32* const elevation = (dgFloat32*)m_elevationMap; - points[0 * 2 + 0] = dgVector ((xIndex0 + 0) * m_horizontalScale_x, m_verticalScale * elevation[base], (zIndex0 + 0) * m_horizontalScale_z, dgFloat32 (0.0f)); - points[0 * 2 + 1] = dgVector ((xIndex0 + 1) * m_horizontalScale_x, m_verticalScale * elevation[base + 1], (zIndex0 + 0) * m_horizontalScale_z, dgFloat32 (0.0f)); - points[1 * 2 + 1] = dgVector ((xIndex0 + 1) * m_horizontalScale_x, m_verticalScale * elevation[base + m_width + 1], (zIndex0 + 1) * m_horizontalScale_z, dgFloat32 (0.0f)); - points[1 * 2 + 0] = dgVector ((xIndex0 + 0) * m_horizontalScale_x, m_verticalScale * elevation[base + m_width + 0], (zIndex0 + 1) * m_horizontalScale_z, dgFloat32 (0.0f)); - break; - } - - case m_unsigned16Bit: - default: - { - const dgUnsigned16* const elevation = (dgUnsigned16*)m_elevationMap; - points[0 * 2 + 0] = dgVector ((xIndex0 + 0) * m_horizontalScale_x, m_verticalScale * dgFloat32 (elevation[base]), (zIndex0 + 0) * m_horizontalScale_z, dgFloat32 (0.0f)); - points[0 * 2 + 1] = dgVector ((xIndex0 + 1) * m_horizontalScale_x, m_verticalScale * dgFloat32 (elevation[base + 1]), (zIndex0 + 0) * m_horizontalScale_z, dgFloat32 (0.0f)); - points[1 * 2 + 1] = dgVector ((xIndex0 + 1) * m_horizontalScale_x, m_verticalScale * dgFloat32 (elevation[base + m_width + 1]), (zIndex0 + 1) * m_horizontalScale_z, dgFloat32 (0.0f)); - points[1 * 2 + 0] = dgVector ((xIndex0 + 0) * m_horizontalScale_x, m_verticalScale * dgFloat32 (elevation[base + m_width + 0]), (zIndex0 + 1) * m_horizontalScale_z, dgFloat32 (0.0f)); - break; - } - } - - dgFloat32 t = dgFloat32 (1.2f); - if (!m_diagonals[base]) { - triangle[0] = 1; - triangle[1] = 2; - triangle[2] = 3; - - dgVector e10 (points[2] - points[1]); - dgVector e20 (points[3] - points[1]); - dgVector normal (e10.CrossProduct(e20)); - normal = normal.Normalize(); - t = ray.PolygonIntersect (normal, maxT, &points[0].m_x, sizeof (dgVector), triangle, 3); - if (t < maxT){ - normalOut = normal; - return t; - } - - triangle[0] = 1; - triangle[1] = 0; - triangle[2] = 2; - - dgVector e30 (points[0] - points[1]); - normal = e30.CrossProduct(e10); - normal = normal.Normalize(); - t = ray.PolygonIntersect (normal, maxT, &points[0].m_x, sizeof (dgVector), triangle, 3); - if (t < maxT){ - normalOut = normal; - return t; - } - - } else { - triangle[0] = 0; - triangle[1] = 2; - triangle[2] = 3; - - dgVector e10 (points[2] - points[0]); - dgVector e20 (points[3] - points[0]); - dgVector normal (e10.CrossProduct(e20)); - normal = normal.Normalize(); - t = ray.PolygonIntersect (normal, maxT, &points[0].m_x, sizeof (dgVector), triangle, 3); - if (t < maxT){ - normalOut = normal; - return t; - } - - triangle[0] = 0; - triangle[1] = 3; - triangle[2] = 1; - - dgVector e30 (points[1] - points[0]); - normal = e20.CrossProduct(e30); - normal = normal.Normalize(); - t = ray.PolygonIntersect (normal, maxT, &points[0].m_x, sizeof (dgVector), triangle, 3); - if (t < maxT){ - normalOut = normal; - return t; - } - } - return t; -} - -dgFloat32 dgCollisionHeightField::RayCast (const dgVector& q0, const dgVector& q1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const -{ - dgVector boxP0; - dgVector boxP1; - - // calculate the ray bounding box - CalculateMinExtend2d (q0, q1, boxP0, boxP1); - - dgVector p0 (q0); - dgVector p1 (q1); - - // clip the line against the bounding box - if (dgRayBoxClip (p0, p1, boxP0, boxP1)) { - dgVector dp (p1 - p0); - dgVector normalOut (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - - dgFloat32 scale_x = m_horizontalScale_x; - dgFloat32 invScale_x = m_horizontalScaleInv_x; - dgFloat32 scale_z = m_horizontalScale_z; - dgFloat32 invScale_z = m_horizontalScaleInv_z; - dgInt32 ix0 = dgFastInt (p0.m_x * invScale_x); - dgInt32 iz0 = dgFastInt (p0.m_z * invScale_z); - - // implement a 3ddda line algorithm - dgInt32 xInc; - dgFloat32 tx; - dgFloat32 stepX; - if (dp.m_x > dgFloat32 (0.0f)) { - xInc = 1; - dgFloat32 val = dgFloat32 (1.0f) / dp.m_x; - stepX = scale_x * val; - tx = (scale_x * (ix0 + dgFloat32 (1.0f)) - p0.m_x) * val; - } else if (dp.m_x < dgFloat32 (0.0f)) { - xInc = -1; - dgFloat32 val = -dgFloat32 (1.0f) / dp.m_x; - stepX = scale_x * val; - tx = -(scale_x * ix0 - p0.m_x) * val; - } else { - xInc = 0; - stepX = dgFloat32 (0.0f); - tx = dgFloat32 (1.0e10f); - } - - dgInt32 zInc; - dgFloat32 tz; - dgFloat32 stepZ; - if (dp.m_z > dgFloat32 (0.0f)) { - zInc = 1; - dgFloat32 val = dgFloat32 (1.0f) / dp.m_z; - stepZ = scale_z * val; - tz = (scale_z * (iz0 + dgFloat32 (1.0f)) - p0.m_z) * val; - } else if (dp.m_z < dgFloat32 (0.0f)) { - zInc = -1; - dgFloat32 val = -dgFloat32 (1.0f) / dp.m_z; - stepZ = scale_z * val; - tz = -(scale_z * iz0 - p0.m_z) * val; - } else { - zInc = 0; - stepZ = dgFloat32 (0.0f); - tz = dgFloat32 (1.0e10f); - } - - dgFloat32 txAcc = tx; - dgFloat32 tzAcc = tz; - dgInt32 xIndex0 = ix0; - dgInt32 zIndex0 = iz0; - dgFastRayTest ray (q0, q1); - - // for each cell touched by the line - do { - dgFloat32 t = RayCastCell (ray, xIndex0, zIndex0, normalOut, maxT); - if (t < maxT) { - // bail out at the first intersection and copy the data into the descriptor - dgAssert (normalOut.m_w == dgFloat32 (0.0f)); - contactOut.m_normal = normalOut.Normalize(); - contactOut.m_shapeId0 = m_atributeMap[zIndex0 * m_width + xIndex0]; - contactOut.m_shapeId1 = m_atributeMap[zIndex0 * m_width + xIndex0]; - - if (m_userRayCastCallback) { - dgVector normal (body->GetCollision()->GetGlobalMatrix().RotateVector (contactOut.m_normal)); - m_userRayCastCallback (body, this, t, xIndex0, zIndex0, &normal, dgInt32 (contactOut.m_shapeId0), userData); - } - - return t; - } - - if (txAcc < tzAcc) { - xIndex0 += xInc; - tx = txAcc; - txAcc += stepX; - } else { - zIndex0 += zInc; - tz = tzAcc; - tzAcc += stepZ; - } - } while ((tx <= dgFloat32 (1.0f)) || (tz <= dgFloat32 (1.0f))); - } - - // if no cell was hit, return a large value - return dgFloat32 (1.2f); -} - - -void dgCollisionHeightField::GetVertexListIndexList (const dgVector& p0, const dgVector& p1, dgMeshVertexListIndexList &data) const -{ - dgAssert (0); - data.m_vertexCount = 0; -} - -struct dgCollisionHeightFieldShowPolyContext -{ - dgMatrix m_matrix; - void* m_userData; - dgCollision::OnDebugCollisionMeshCallback m_callback; -}; - -dgVector dgCollisionHeightField::SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgFloat32 maxProject (dgFloat32 (-1.e-20f)); - dgVector support (dgFloat32 (0.0f)); - if (m_elevationDataType == m_float32Bit) { - const dgFloat32* const elevation = (dgFloat32*)m_elevationMap; - for (dgInt32 z = 0; z < m_height - 1; z ++) { - dgInt32 base = z * m_width; - dgFloat32 zVal = m_horizontalScale_z * z; - for (dgInt32 x = 0; x < m_width; x ++) { - dgVector p (m_horizontalScale_x * x, m_verticalScale * elevation[base + x], zVal, dgFloat32 (0.0f)); - dgFloat32 project = dir.DotProduct(p).m_x; - if (project > maxProject) { - maxProject = project; - support = p; - } - } - } - - } else { - const dgUnsigned16* const elevation = (dgUnsigned16*)m_elevationMap; - for (dgInt32 z = 0; z < m_height - 1; z ++) { - dgInt32 base = z * m_width; - dgFloat32 zVal = m_horizontalScale_z * z; - for (dgInt32 x = 0; x < m_width; x ++) { - dgVector p (m_horizontalScale_x * x, m_verticalScale * elevation[base + x], zVal, dgFloat32 (0.0f)); - dgFloat32 project = dir.DotProduct(p).m_x; - if (project > maxProject) { - maxProject = project; - support = p; - } - } - } - } - return support; -} - -dgVector dgCollisionHeightField::SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - dgAssert (0); - return SupportVertex (dir, vertexIndex); -} - -void dgCollisionHeightField::DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - dgVector points[4]; - - dgInt32 base = 0; - for (dgInt32 z = 0; z < m_height - 1; z ++) { - switch (m_elevationDataType) - { - case m_float32Bit: - { - const dgFloat32* const elevation = (dgFloat32*)m_elevationMap; - points[0 * 2 + 0] = dgVector ((0 + 0) * m_horizontalScale_x, m_verticalScale * elevation[base + 0 ], (z + 0) * m_horizontalScale_z, dgFloat32 (0.0f)); - points[1 * 2 + 0] = dgVector ((0 + 0) * m_horizontalScale_x, m_verticalScale * elevation[base + 0 + m_width + 0], (z + 1) * m_horizontalScale_z, dgFloat32 (0.0f)); - break; - } - - case m_unsigned16Bit: - { - const dgUnsigned16* const elevation = (dgUnsigned16*)m_elevationMap; - points[0 * 2 + 0] = dgVector ((0 + 0) * m_horizontalScale_x, m_verticalScale * dgFloat32 (elevation[base + 0 ]), (z + 0) * m_horizontalScale_z, dgFloat32 (0.0f)); - points[1 * 2 + 0] = dgVector ((0 + 0) * m_horizontalScale_x, m_verticalScale * dgFloat32 (elevation[base + 0 + m_width + 0]), (z + 1) * m_horizontalScale_z, dgFloat32 (0.0f)); - break; - } - } - - points[0 * 2 + 0] = matrix.TransformVector(points[0 * 2 + 0]); - points[1 * 2 + 0] = matrix.TransformVector(points[1 * 2 + 0]); - - for (dgInt32 x = 0; x < m_width - 1; x ++) { - dgTriplex triangle[3]; - switch (m_elevationDataType) - { - case m_float32Bit: - { - const dgFloat32* const elevation = (dgFloat32*)m_elevationMap; - points[0 * 2 + 1] = dgVector ((x + 1) * m_horizontalScale_x, m_verticalScale * elevation[base + x + 1], (z + 0) * m_horizontalScale_z, dgFloat32 (0.0f)); - points[1 * 2 + 1] = dgVector ((x + 1) * m_horizontalScale_x, m_verticalScale * elevation[base + x + m_width + 1], (z + 1) * m_horizontalScale_z, dgFloat32 (0.0f)); - break; - } - - case m_unsigned16Bit: - { - const dgUnsigned16* const elevation = (dgUnsigned16*)m_elevationMap; - points[0 * 2 + 1] = dgVector ((x + 1) * m_horizontalScale_x, m_verticalScale * dgFloat32 (elevation[base + x + 1]), (z + 0) * m_horizontalScale_z, dgFloat32 (0.0f)); - points[1 * 2 + 1] = dgVector ((x + 1) * m_horizontalScale_x, m_verticalScale * dgFloat32 (elevation[base + x + m_width + 1]), (z + 1) * m_horizontalScale_z, dgFloat32 (0.0f)); - break; - } - } - - points[0 * 2 + 1] = matrix.TransformVector(points[0 * 2 + 1]); - points[1 * 2 + 1] = matrix.TransformVector(points[1 * 2 + 1]); - - const dgInt32* const indirectIndex = &m_cellIndices[dgInt32 (m_diagonals[z * m_width + x])][0]; - - dgInt32 i0 = indirectIndex[0]; - dgInt32 i1 = indirectIndex[1]; - dgInt32 i2 = indirectIndex[2]; - dgInt32 i3 = indirectIndex[3]; - - triangle[0].m_x = points[i1].m_x; - triangle[0].m_y = points[i1].m_y; - triangle[0].m_z = points[i1].m_z; - - triangle[1].m_x = points[i0].m_x; - triangle[1].m_y = points[i0].m_y; - triangle[1].m_z = points[i0].m_z; - - triangle[2].m_x = points[i2].m_x; - triangle[2].m_y = points[i2].m_y; - triangle[2].m_z = points[i2].m_z; - callback (userData, 3, &triangle[0].m_x, m_atributeMap[base]); - - triangle[0].m_x = points[i1].m_x; - triangle[0].m_y = points[i1].m_y; - triangle[0].m_z = points[i1].m_z; - - triangle[1].m_x = points[i2].m_x; - triangle[1].m_y = points[i2].m_y; - triangle[1].m_z = points[i2].m_z; - - triangle[2].m_x = points[i3].m_x; - triangle[2].m_y = points[i3].m_y; - triangle[2].m_z = points[i3].m_z; - callback (userData, 3, &triangle[0].m_x, m_atributeMap[base]); - - points[0 * 2 + 0] = points[0 * 2 + 1]; - points[1 * 2 + 0] = points[1 * 2 + 1]; - } - base += m_width; - } -} - -void dgCollisionHeightField::CalculateMinAndMaxElevation(dgInt32 x0, dgInt32 x1, dgInt32 z0, dgInt32 z1, const dgFloat32* const elevation, dgFloat32& minHeight, dgFloat32& maxHeight) const -{ - dgInt32 base = z0 * m_width; - for (dgInt32 z = z0; z <= z1; z++) { - for (dgInt32 x = x0; x <= x1; x++) { - dgFloat32 high = elevation[base + x]; - minHeight = dgMin(high, minHeight); - maxHeight = dgMax(high, maxHeight); - } - base += m_width; - } -} - -void dgCollisionHeightField::CalculateMinAndMaxElevation(dgInt32 x0, dgInt32 x1, dgInt32 z0, dgInt32 z1, const dgUnsigned16* const elevation, dgFloat32& minHeight, dgFloat32& maxHeight) const -{ - dgInt32 base = z0 * m_width; - for (dgInt32 z = z0; z <= z1; z++) { - for (dgInt32 x = x0; x <= x1; x++) { - dgFloat32 high = dgFloat32 (elevation[base + x]); - minHeight = dgMin(high, minHeight); - maxHeight = dgMax(high, maxHeight); - } - base += m_width; - } -} - - -void dgCollisionHeightField::GetLocalAABB (const dgVector& q0, const dgVector& q1, dgVector& boxP0, dgVector& boxP1) const -{ - // the user data is the pointer to the collision geometry - CalculateMinExtend3d (q0, q1, boxP0, boxP1); - - dgVector p0 (boxP0.Scale(m_horizontalScaleInv_x).GetInt()); - dgVector p1 (boxP1.Scale(m_horizontalScaleInv_x).GetInt()); - - dgAssert (p0.m_ix == dgFastInt (boxP0.m_x * m_horizontalScaleInv_x)); - dgAssert (p0.m_iz == dgFastInt (boxP0.m_z * m_horizontalScaleInv_x)); - dgAssert (p1.m_ix == dgFastInt (boxP1.m_x * m_horizontalScaleInv_x)); - dgAssert (p1.m_iz == dgFastInt (boxP1.m_z * m_horizontalScaleInv_x)); - - dgInt32 x0 = dgInt32 (p0.m_ix); - dgInt32 x1 = dgInt32 (p1.m_ix); - dgInt32 z0 = dgInt32 (p0.m_iz); - dgInt32 z1 = dgInt32 (p1.m_iz); - - dgFloat32 minHeight = dgFloat32 (1.0e10f); - dgFloat32 maxHeight = dgFloat32 (-1.0e10f); - //dgInt32 base = z0 * m_width; - switch (m_elevationDataType) - { - case m_float32Bit: - { - CalculateMinAndMaxElevation(x0, x1, z0, z1, (dgFloat32*)m_elevationMap, minHeight, maxHeight); - break; - } - - case m_unsigned16Bit: - { - CalculateMinAndMaxElevation(x0, x1, z0, z1, (dgUnsigned16*)m_elevationMap, minHeight, maxHeight); - break; - } - } - - boxP0.m_y = m_verticalScale * minHeight; - boxP1.m_y = m_verticalScale * maxHeight; -} - -void dgCollisionHeightField::GetCollidingFaces (dgPolygonMeshDesc* const data) const -{ - dgVector boxP0; - dgVector boxP1; - - dgWorld* const world = data->m_objBody->GetWorld(); - - // the user data is the pointer to the collision geometry - CalculateMinExtend3d (data->m_p0, data->m_p1, boxP0, boxP1); - boxP0 += data->m_boxDistanceTravelInMeshSpace & (data->m_boxDistanceTravelInMeshSpace < dgVector::m_zero); - boxP1 += data->m_boxDistanceTravelInMeshSpace & (data->m_boxDistanceTravelInMeshSpace > dgVector::m_zero); - - //boxP0 = (boxP0.GetMax(dgVector::m_zero) & m_yMask) + boxP0.AndNot(m_yMask); - //boxP1 = (boxP1.GetMax(dgVector::m_zero) & m_yMask) + boxP1.AndNot(m_yMask); - boxP0 = boxP0.Select(boxP0.GetMax(dgVector::m_zero), m_yMask); - boxP1 = boxP1.Select(boxP1.GetMax(dgVector::m_zero), m_yMask); - - dgVector p0 (boxP0.Scale(m_horizontalScaleInv_x).GetInt()); - dgVector p1 (boxP1.Scale(m_horizontalScaleInv_x).GetInt()); - - dgAssert (p0.m_ix == dgFastInt (boxP0.m_x * m_horizontalScaleInv_x)); - dgAssert (p0.m_iz == dgFastInt (boxP0.m_z * m_horizontalScaleInv_x)); - dgAssert (p1.m_ix == dgFastInt (boxP1.m_x * m_horizontalScaleInv_x)); - dgAssert (p1.m_iz == dgFastInt (boxP1.m_z * m_horizontalScaleInv_x)); - - dgInt32 x0 = dgInt32 (p0.m_ix); - dgInt32 x1 = dgInt32 (p1.m_ix); - dgInt32 z0 = dgInt32 (p0.m_iz); - dgInt32 z1 = dgInt32 (p1.m_iz); - - data->m_separationDistance = dgFloat32 (0.0f); - dgFloat32 minHeight = dgFloat32 (1.0e10f); - dgFloat32 maxHeight = dgFloat32 (-1.0e10f); -// dgInt32 base = z0 * m_width; - switch (m_elevationDataType) - { - case m_float32Bit: - { - CalculateMinAndMaxElevation(x0, x1, z0, z1, (dgFloat32*)m_elevationMap, minHeight, maxHeight); - break; - } - - case m_unsigned16Bit: - { - CalculateMinAndMaxElevation(x0, x1, z0, z1, (dgUnsigned16*)m_elevationMap, minHeight, maxHeight); - break; - } - } - - minHeight *= m_verticalScale; - maxHeight *= m_verticalScale; - - if (!((maxHeight < boxP0.m_y) || (minHeight > boxP1.m_y))) { - // scan the vertices's intersected by the box extend - dgInt32 base = (z1 - z0 + 1) * (x1 - x0 + 1) + 2 * (z1 - z0) * (x1 - x0); - while (base > m_instanceData->m_vertexCount[data->m_threadNumber]) { - AllocateVertex(world, data->m_threadNumber); - } - - dgInt32 vertexIndex = 0; - base = z0 * m_width; - dgVector* const vertex = &m_instanceData->m_vertex[data->m_threadNumber][0]; - - switch (m_elevationDataType) - { - case m_float32Bit: - { - const dgFloat32* const elevation = (dgFloat32*)m_elevationMap; - for (dgInt32 z = z0; z <= z1; z ++) { - dgFloat32 zVal = m_horizontalScale_z * z; - for (dgInt32 x = x0; x <= x1; x ++) { - vertex[vertexIndex] = dgVector(m_horizontalScale_x * x, m_verticalScale * elevation[base + x], zVal, dgFloat32 (0.0f)); - vertexIndex ++; - dgAssert (vertexIndex <= m_instanceData->m_vertexCount[data->m_threadNumber]); - } - base += m_width; - } - break; - } - - case m_unsigned16Bit: - { - const dgUnsigned16* const elevation = (dgUnsigned16*)m_elevationMap; - for (dgInt32 z = z0; z <= z1; z ++) { - dgFloat32 zVal = m_horizontalScale_z * z; - for (dgInt32 x = x0; x <= x1; x ++) { - vertex[vertexIndex] = dgVector(m_horizontalScale_x * x, m_verticalScale * dgFloat32 (elevation[base + x]), zVal, dgFloat32 (0.0f)); - vertexIndex ++; - dgAssert (vertexIndex <= m_instanceData->m_vertexCount[data->m_threadNumber]); - } - base += m_width; - } - break; - } - } - - dgInt32 normalBase = vertexIndex; - vertexIndex = 0; - dgInt32 index = 0; - dgInt32 faceCount = 0; - dgInt32 step = x1 - x0 + 1; - dgInt32* const indices = data->m_globalFaceVertexIndex; - dgInt32* const faceIndexCount = data->m_meshData.m_globalFaceIndexCount; - dgInt32 faceSize = dgInt32 (dgMax (m_horizontalScale_x, m_horizontalScale_z) * dgFloat32 (2.0f)); - - for (dgInt32 z = z0; (z < z1) && (faceCount < DG_MAX_COLLIDING_FACES); z ++) { - dgInt32 zStep = z * m_width; - for (dgInt32 x = x0; (x < x1) && (faceCount < DG_MAX_COLLIDING_FACES); x ++) { - const dgInt32* const indirectIndex = &m_cellIndices[dgInt32 (m_diagonals[zStep + x])][0]; - - dgInt32 vIndex[4]; - vIndex[0] = vertexIndex; - vIndex[1] = vertexIndex + 1; - vIndex[2] = vertexIndex + step; - vIndex[3] = vertexIndex + step + 1; - - const dgInt32 i0 = vIndex[indirectIndex[0]]; - const dgInt32 i1 = vIndex[indirectIndex[1]]; - const dgInt32 i2 = vIndex[indirectIndex[2]]; - const dgInt32 i3 = vIndex[indirectIndex[3]]; - - const dgVector e0 (vertex[i0] - vertex[i1]); - const dgVector e1 (vertex[i2] - vertex[i1]); - const dgVector e2 (vertex[i3] - vertex[i1]); - dgVector n0 (e0.CrossProduct(e1)); - dgVector n1 (e1.CrossProduct(e2)); - dgAssert (n0.m_w == dgFloat32 (0.0f)); - dgAssert (n1.m_w == dgFloat32 (0.0f)); - - dgAssert (n0.DotProduct(n0).GetScalar() > dgFloat32 (0.0f)); - dgAssert (n1.DotProduct(n1).GetScalar() > dgFloat32 (0.0f)); - - //normalBase - const dgInt32 normalIndex0 = normalBase; - const dgInt32 normalIndex1 = normalBase + 1; - vertex[normalIndex0] = n0.Normalize(); - vertex[normalIndex1] = n1.Normalize(); - - faceIndexCount[faceCount] = 3; - indices[index + 0 + 0] = i2; - indices[index + 0 + 1] = i1; - indices[index + 0 + 2] = i0; - indices[index + 0 + 3] = m_atributeMap[zStep + x]; - indices[index + 0 + 4] = normalIndex0; - indices[index + 0 + 5] = normalIndex0; - indices[index + 0 + 6] = normalIndex0; - indices[index + 0 + 7] = normalIndex0; - indices[index + 0 + 8] = faceSize; - - faceIndexCount[faceCount + 1] = 3; - indices[index + 9 + 0] = i1; - indices[index + 9 + 1] = i2; - indices[index + 9 + 2] = i3; - indices[index + 9 + 3] = m_atributeMap[zStep + x]; - indices[index + 9 + 4] = normalIndex1; - indices[index + 9 + 5] = normalIndex1; - indices[index + 9 + 6] = normalIndex1; - indices[index + 9 + 7] = normalIndex1; - indices[index + 9 + 8] = faceSize; - - dgVector dp (vertex[i3] - vertex[i1]); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - dgFloat32 dist (vertex[normalIndex0].DotProduct(dp).GetScalar()); - if (dist < -dgFloat32 (1.0e-3f)) { - indices[index + 0 + 5] = normalIndex1; - indices[index + 9 + 5] = normalIndex0; - } - - index += 9 * 2; - normalBase += 2; - faceCount += 2; - vertexIndex ++; - } - vertexIndex ++; - } - - #ifdef _DEBUG - dgAssert (faceCount < DG_MAX_COLLIDING_FACES); - if (faceCount >= DG_MAX_COLLIDING_FACES) { - dgTrace (("buffer Over float, try using a lower resolution mesh for collision\n")); - } - #endif - - const int maxIndex = index; - dgInt32 stepBase = (x1 - x0) * (2 * 9); - for (dgInt32 z = z0; z < z1; z ++) { - const dgInt32 diagBase = m_width * z; - const dgInt32 triangleIndexBase = (z - z0) * stepBase; - for (dgInt32 x = x0; x < (x1 - 1); x ++) { - dgInt32 index1 = (x - x0) * (2 * 9) + triangleIndexBase; - if (index1 < maxIndex) { - const dgInt32 code = (m_diagonals[diagBase + x] << 1) + m_diagonals[diagBase + x + 1]; - const dgInt32* const edgeMap = &m_horizontalEdgeMap[code][0]; - - dgInt32* const triangles = &indices[index1]; - const dgInt32 i0 = triangles[edgeMap[0]]; - const dgInt32 i1 = triangles[edgeMap[1]]; - const dgInt32 i2 = triangles[edgeMap[2]]; - - const dgVector& origin = vertex[i0]; - const dgVector& testPoint = vertex[i1]; - const dgVector& normal = vertex[i2]; - dgAssert (normal.m_w == dgFloat32 (0.0f)); - dgFloat32 dist (normal.DotProduct(testPoint - origin).GetScalar()); - - if (dist < -dgFloat32 (1.0e-3f)) { - const dgInt32 i3 = edgeMap[3]; - const dgInt32 i4 = edgeMap[4]; - const dgInt32 i5 = edgeMap[5]; - const dgInt32 i6 = edgeMap[6]; - triangles[i3] = triangles[i6]; - triangles[i4] = triangles[i5]; - } - } - } - } - - for (dgInt32 x = x0; x < x1; x ++) { - const dgInt32 triangleIndexBase = (x - x0) * (2 * 9); - for (dgInt32 z = z0; z < (z1 - 1); z ++) { - dgInt32 index1 = (z - z0) * stepBase + triangleIndexBase; - if (index1 < maxIndex) { - const dgInt32 diagBase = m_width * z; - const dgInt32 code = (m_diagonals[diagBase + x] << 1) + m_diagonals[diagBase + m_width + x]; - const dgInt32* const edgeMap = &m_verticalEdgeMap[code][0]; - - dgInt32* const triangles = &indices[index1]; - const dgInt32 i0 = triangles[edgeMap[0]]; - const dgInt32 i1 = triangles[edgeMap[1] + stepBase]; - const dgInt32 i2 = triangles[edgeMap[2]]; - - const dgVector& origin = vertex[i0]; - const dgVector& testPoint = vertex[i1]; - const dgVector& normal = vertex[i2]; - dgAssert (normal.m_w == dgFloat32 (0.0f)); - dgFloat32 dist (normal.DotProduct(testPoint - origin).GetScalar()); - - if (dist < -dgFloat32 (1.0e-3f)) { - const dgInt32 i3 = edgeMap[3]; - const dgInt32 i4 = edgeMap[4] + stepBase; - const dgInt32 i5 = edgeMap[5]; - const dgInt32 i6 = edgeMap[6] + stepBase; - triangles[i3] = triangles[i6]; - triangles[i4] = triangles[i5]; - } - } - } - } - - dgInt32 stride = sizeof (dgVector) / sizeof (dgFloat32); - dgInt32 faceCount0 = 0; - dgInt32 faceIndexCount0 = 0; - dgInt32 faceIndexCount1 = 0; - - dgInt32* const address = data->m_meshData.m_globalFaceIndexStart; - dgFloat32* const hitDistance = data->m_meshData.m_globalHitDistance; - - if (data->m_doContinuesCollisionTest) { - dgFastRayTest ray (dgVector (dgFloat32 (0.0f)), data->m_boxDistanceTravelInMeshSpace); - for (dgInt32 i = 0; i < faceCount; i ++) { - const dgInt32* const indexArray = &indices[faceIndexCount1]; - const dgVector& faceNormal = vertex[indexArray[4]]; - dgFloat32 dist = data->PolygonBoxRayDistance (faceNormal, 3, indexArray, stride, &vertex[0].m_x, ray); - if (dist < dgFloat32 (1.0f)) { - hitDistance[faceCount0] = dist; - address[faceCount0] = faceIndexCount0; - memcpy (&indices[faceIndexCount0], indexArray, 9 * sizeof (dgInt32)); - faceCount0 ++; - faceIndexCount0 += 9; - } - faceIndexCount1 += 9; - } - } else { - for (dgInt32 i = 0; i < faceCount; i ++) { - const dgInt32* const indexArray = &indices[faceIndexCount1]; - const dgVector& faceNormal = vertex[indexArray[4]]; - dgFloat32 dist = data->PolygonBoxDistance (faceNormal, 3, indexArray, stride, &vertex[0].m_x); - if (dist > dgFloat32 (0.0f)) { - hitDistance[faceCount0] = dist; - address[faceCount0] = faceIndexCount0; - memcpy (&indices[faceIndexCount0], indexArray, 9 * sizeof (dgInt32)); - faceCount0 ++; - faceIndexCount0 += 9; - } - faceIndexCount1 += 9; - } - } - - if (faceCount0) { - // initialize the callback data structure - data->m_faceCount = faceCount0; - data->m_vertex = &vertex[0].m_x; - data->m_faceVertexIndex = indices; - data->m_faceIndexStart = address; - data->m_hitDistance = hitDistance; - data->m_faceIndexCount = faceIndexCount; - data->m_vertexStrideInBytes = sizeof (dgVector); - - if (GetDebugCollisionCallback()) { - dgTriplex triplex[3]; - const dgVector scale = data->m_polySoupInstance->GetScale(); - dgMatrix matrix(data->m_polySoupInstance->GetLocalMatrix() * data->m_polySoupBody->GetMatrix()); - - for (dgInt32 i = 0; i < data->m_faceCount; i ++) { - dgInt32 base1 = address[i]; - for (dgInt32 j = 0; j < 3; j ++) { - dgInt32 index1 = data->m_faceVertexIndex[base1 + j]; - dgVector p (matrix.TransformVector(scale * dgVector(vertex[index1]))); - triplex[j].m_x = p.m_x; - triplex[j].m_y = p.m_y; - triplex[j].m_z = p.m_z; - } - GetDebugCollisionCallback() (data->m_polySoupBody, data->m_objBody, data->m_faceVertexIndex[base1 + 4], 3, &triplex[0].m_x, sizeof (dgTriplex)); - } - } - } - - #ifdef _DEBUG - for (dgInt32 i = 0; i < data->m_faceCount; i ++) { - dgInt32 base1 = address[i]; - const dgInt32* const localIndexArray = &data->m_faceVertexIndex[base1]; - - dgInt32 index1 = data->GetNormalIndex (localIndexArray, 3); - dgVector n (vertex[index1]); - dgVector q0 (vertex[data->m_faceVertexIndex[base1 + 0]]); - dgVector q1 (vertex[data->m_faceVertexIndex[base1 + 1]]); - dgVector q2 (vertex[data->m_faceVertexIndex[base1 + 2]]); - - dgMatrix polygonMatrix; - polygonMatrix[0] = q1 - q0; - polygonMatrix[0] = polygonMatrix[0].Normalize(); - polygonMatrix[1] = n.CrossProduct(polygonMatrix[0]); - polygonMatrix[2] = n; - polygonMatrix[3] = dgVector::m_wOne; - dgAssert (polygonMatrix.TestOrthogonal()); - } - #endif - } -} diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionHeightField.h b/thirdparty/src/newton/dgPhysics/dgCollisionHeightField.h deleted file mode 100644 index f9b7e0667..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionHeightField.h +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGCOLLISION_HEIGHT_FIELD__ -#define __DGCOLLISION_HEIGHT_FIELD__ - -#include "dgCollision.h" -#include "dgCollisionMesh.h" - -class dgCollisionHeightField; -typedef dgFloat32 (*dgCollisionHeightFieldRayCastCallback) (const dgBody* const body, const dgCollisionHeightField* const heightFieldCollision, dgFloat32 interception, dgInt32 row, dgInt32 col, dgVector* const normal, int faceId, void* const usedData); - - -class dgCollisionHeightField: public dgCollisionMesh -{ - public: - enum dgElevationType - { - m_float32Bit = 0, - m_unsigned16Bit, - }; - - enum dgCollisionHeightFieldGridConstruction - { - m_normalDiagonals = 0, - m_invertedDiagonals, - m_alternateOddRowsDiagonals, - m_alternateEvenRowsDiagonals, - m_alternateOddColumsDiagonals, - m_alternateEvenColumsDiagonals, - m_starDiagonals, - m_starInvertexDiagonals, - }; - dgCollisionHeightField (dgWorld* const world, dgInt32 width, dgInt32 height, dgInt32 contructionMode, - const void* const elevationMap, dgElevationType elevationDataType, dgFloat32 verticalScale, - const dgInt8* const atributeMap, dgFloat32 horizontalScale_x, dgFloat32 horizontalScale_z); - - dgCollisionHeightField (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - - virtual ~dgCollisionHeightField(void); - - void SetCollisionRayCastCallback (dgCollisionHeightFieldRayCastCallback rayCastCallback); - dgCollisionHeightFieldRayCastCallback GetDebugRayCastCallback() const { return m_userRayCastCallback;} - - private: - class dgPerIntanceData - { - public: - dgWorld* m_world; - dgInt32 m_refCount; - dgInt32 m_vertexCount[DG_MAX_THREADS_HIVE_COUNT]; - dgArray<dgVector> m_vertex[DG_MAX_THREADS_HIVE_COUNT]; - }; - - void CalculateAABB(); - void CalculateMinAndMaxElevation(dgInt32 x0, dgInt32 x1, dgInt32 z0, dgInt32 z1, const dgUnsigned16* const elevation, dgFloat32& minHeight, dgFloat32& maxHeight) const; - void CalculateMinAndMaxElevation(dgInt32 x0, dgInt32 x1, dgInt32 z0, dgInt32 z1, const dgFloat32* const elevation, dgFloat32& minHeight, dgFloat32& maxHeight) const; - - void AllocateVertex(dgWorld* const world, dgInt32 thread) const; - void CalculateMinExtend2d (const dgVector& p0, const dgVector& p1, dgVector& boxP0, dgVector& boxP1) const; - void CalculateMinExtend3d (const dgVector& p0, const dgVector& p1, dgVector& boxP0, dgVector& boxP1) const; - dgFloat32 RayCastCell (const dgFastRayTest& ray, dgInt32 xIndex0, dgInt32 zIndex0, dgVector& normalOut, dgFloat32 maxT) const; - - virtual void Serialize(dgSerialize callback, void* const userData) const; - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const; - virtual void GetCollidingFaces (dgPolygonMeshDesc* const data) const; - - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const {return point;}; - - virtual void DebugCollision (const dgMatrix& matrixPtr, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - void GetVertexListIndexList (const dgVector& p0, const dgVector& p1, dgMeshVertexListIndexList &data) const; - void GetLocalAABB (const dgVector& p0, const dgVector& p1, dgVector& boxP0, dgVector& boxP1) const; - - DG_INLINE dgInt32 dgFastInt(dgFloat32 x) const - { - dgInt32 i = dgInt32(x); - if (dgFloat32(i) > x) { - i--; - } - return i; - } - - dgVector m_minBox; - dgVector m_maxBox; - - dgInt32 m_width; - dgInt32 m_height; - dgInt32 m_diagonalMode; - dgInt8* m_atributeMap; - dgInt8* m_diagonals; - void* m_elevationMap; - dgFloat32 m_verticalScale; - dgFloat32 m_horizontalScale_x; - dgFloat32 m_horizontalScaleInv_x; - dgFloat32 m_horizontalScale_z; - dgFloat32 m_horizontalScaleInv_z; - dgCollisionHeightFieldRayCastCallback m_userRayCastCallback; - dgElevationType m_elevationDataType; - - - static dgVector m_yMask; - static dgVector m_padding; - static dgVector m_elevationPadding; - static dgInt32 m_cellIndices[][4]; - static dgInt32 m_verticalEdgeMap[][7]; - static dgInt32 m_horizontalEdgeMap[][7]; - - dgPerIntanceData* m_instanceData; - friend class dgCollisionCompound; -}; - - - -#endif diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionIncompressibleParticles.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionIncompressibleParticles.cpp deleted file mode 100644 index e14f2b6d4..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionIncompressibleParticles.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgMeshEffect.h" -#include "dgDynamicBody.h" -#include "dgCollisionIncompressibleParticles.h" - - -dgCollisionIncompressibleParticles::dgCollisionIncompressibleParticles(dgWorld* const world, dgMeshEffect* const mesh) - :dgCollisionLumpedMassParticles(world, m_deformableSolidMesh) -{ - m_rtti |= dgCollisionIncompressibleParticles_RTTI; - -/* - dgInt32 count = mesh->GetVertexCount(); - dgVector* const points = dgAlloca(dgVector, count); - - for (dgInt32 i = 0; i < count; i++) { - dgBigVector p(mesh->GetVertex(i)); - points[i] = p; - } - - m_indexToVertexCount = count; - m_indexToVertexMap.Resize(count); - dgInt32* const indexToVertexMap = &m_indexToVertexMap[0]; - m_particlesCount = dgVertexListToIndexList(&points[0].m_x, sizeof(dgVector), 3 * sizeof(dgFloat32), 0, count, indexToVertexMap, dgFloat32(1.0e-5f)); - for (dgInt32 i = 0; i < m_particlesCount; i++) { - m_posit[i] = points[i]; - } - - - dgInt32 edgeCount = 0; - dgSoftLink* const links = dgAlloca(dgSoftLink, mesh->GetCount() / 2); - for (void* edgePtr = mesh->GetFirstEdge(); edgePtr; edgePtr = mesh->GetNextEdge(edgePtr)) { - const dgEdge* const edge = mesh->GetPolyhedraEdgeFromNode(edgePtr); - - dgInt32 v0 = indexToVertexMap[edge->m_incidentVertex]; - dgInt32 v1 = indexToVertexMap[edge->m_twin->m_incidentVertex]; - links[edgeCount].m_m0 = dgInt16(dgMin(v0, v1)); - links[edgeCount].m_m1 = dgInt16(dgMax(v0, v1)); - edgeCount++; - if ((edge->m_incidentFace > 0) && (edge->m_twin->m_incidentFace > 0)) { - v0 = indexToVertexMap[edge->m_prev->m_incidentVertex]; - v1 = indexToVertexMap[edge->m_twin->m_prev->m_incidentVertex]; - links[edgeCount].m_m0 = dgInt16(dgMin(v0, v1)); - links[edgeCount].m_m1 = dgInt16(dgMax(v0, v1)); - edgeCount++; - } - } - dgSort(links, edgeCount, CompareEdges); - - dgInt32 uniqueEdgeCount = 0; - for (dgInt32 i = 1; i < edgeCount; i++) { - if (CompareEdges(&links[i], &links[uniqueEdgeCount], NULL) > 0) { - uniqueEdgeCount++; - links[uniqueEdgeCount] = links[i]; - } - } - uniqueEdgeCount++; - m_linksCount = uniqueEdgeCount; - m_linkList.Resize(m_linksCount); - for (dgInt32 i = 0; i < m_linksCount; i++) { - m_linkList[i] = links[i]; - } - FinalizeBuild(); -*/ -} - - -dgCollisionIncompressibleParticles::dgCollisionIncompressibleParticles(const dgCollisionIncompressibleParticles& source) - :dgCollisionLumpedMassParticles(source) -{ - m_rtti |= source.m_rtti; -} - -dgCollisionIncompressibleParticles::dgCollisionIncompressibleParticles(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionLumpedMassParticles(world, deserialization, userData, revisionNumber) -{ -} - -dgCollisionIncompressibleParticles::~dgCollisionIncompressibleParticles(void) -{ -} - - -void dgCollisionIncompressibleParticles::CalculateAcceleration(dgFloat32 timestep) -{ - dgAssert(0); -} diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionIncompressibleParticles.h b/thirdparty/src/newton/dgPhysics/dgCollisionIncompressibleParticles.h deleted file mode 100644 index 324fd34c7..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionIncompressibleParticles.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGCOLLISION_INCOMPRESSIBLE_PARTICLES_H__ -#define __DGCOLLISION_INCOMPRESSIBLE_PARTICLES_H__ - - -#include "dgCollision.h" -#include "dgCollisionLumpedMassParticles.h" - - -class dgCollisionIncompressibleParticles: public dgCollisionLumpedMassParticles -{ - public: - dgCollisionIncompressibleParticles (const dgCollisionIncompressibleParticles& source); - dgCollisionIncompressibleParticles (dgWorld* const world, dgMeshEffect* const mesh); - dgCollisionIncompressibleParticles (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - - virtual ~dgCollisionIncompressibleParticles(void); - virtual void CalculateAcceleration(dgFloat32 timestep); -}; - - - - - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionInstance.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionInstance.cpp deleted file mode 100644 index 01fc92f6a..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionInstance.cpp +++ /dev/null @@ -1,689 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgCollisionBox.h" -#include "dgCollisionBVH.h" -#include "dgCollisionMesh.h" -#include "dgCollisionNull.h" -#include "dgCollisionCone.h" -#include "dgCollisionSphere.h" -#include "dgCollisionCapsule.h" -#include "dgCollisionCylinder.h" -#include "dgCollisionInstance.h" -#include "dgCollisionCompound.h" -#include "dgCollisionHeightField.h" -#include "dgCollisionConvexPolygon.h" -#include "dgCollisionChamferCylinder.h" -#include "dgCollisionCompoundFractured.h" -#include "dgCollisionDeformableSolidMesh.h" -#include "dgCollisionMassSpringDamperSystem.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -dgVector dgCollisionInstance::m_padding (DG_MAX_COLLISION_AABB_PADDING, DG_MAX_COLLISION_AABB_PADDING, DG_MAX_COLLISION_AABB_PADDING, dgFloat32 (0.0f)); - -dgCollisionInstance::dgCollisionInstance() - :m_globalMatrix(dgGetIdentityMatrix()) - ,m_localMatrix (dgGetIdentityMatrix()) - ,m_aligmentMatrix (dgGetIdentityMatrix()) - ,m_scale(dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)) - ,m_invScale(dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)) - ,m_maxScale(dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)) - ,m_material() - ,m_world(NULL) - ,m_childShape (NULL) - ,m_subCollisionHandle(NULL) - ,m_parent(NULL) - ,m_skinThickness(dgFloat32 (0.0f)) - ,m_collisionMode(1) - ,m_refCount(1) - ,m_scaleType(m_unit) - ,m_isExternal(true) -{ -} - -dgCollisionInstance::dgCollisionInstance(const dgWorld* const world, const dgCollision* const childCollision, dgInt32 shapeID, const dgMatrix& matrix) - :m_globalMatrix(matrix) - ,m_localMatrix (matrix) - ,m_aligmentMatrix (dgGetIdentityMatrix()) - ,m_scale(dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)) - ,m_invScale(dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)) - ,m_maxScale(dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)) - ,m_material() - ,m_world(world) - ,m_childShape (childCollision) - ,m_subCollisionHandle(NULL) - ,m_parent(NULL) - ,m_skinThickness(dgFloat32 (0.0f)) - ,m_collisionMode(1) - ,m_refCount(1) - ,m_scaleType(m_unit) - ,m_isExternal(true) -{ - m_material.m_userId = shapeID; - m_childShape->AddRef(); -} - -dgCollisionInstance::dgCollisionInstance(const dgCollisionInstance& instance) - :m_globalMatrix(instance.m_globalMatrix) - ,m_localMatrix (instance.m_localMatrix) - ,m_aligmentMatrix (instance.m_aligmentMatrix) - ,m_scale(instance.m_scale) - ,m_invScale(instance.m_invScale) - ,m_maxScale(instance.m_maxScale) - ,m_material(instance.m_material) - ,m_world(instance.m_world) - ,m_childShape (instance.m_childShape) - ,m_subCollisionHandle(NULL) - ,m_parent(NULL) - ,m_skinThickness(instance.m_skinThickness) - ,m_collisionMode(instance.m_collisionMode) - ,m_refCount(1) - ,m_scaleType(instance.m_scaleType) - ,m_isExternal(true) -{ - if (m_childShape->IsType (dgCollision::dgCollisionCompound_RTTI)) { - if (m_childShape->IsType (dgCollision::dgCollisionCompoundBreakable_RTTI)) { - dgCollisionCompoundFractured* const compound = (dgCollisionCompoundFractured*) m_childShape; - m_childShape = new (m_world->GetAllocator()) dgCollisionCompoundFractured (*compound, this); - } else if (m_childShape->IsType (dgCollision::dgCollisionScene_RTTI)) { - dgCollisionScene* const scene = (dgCollisionScene*) m_childShape; - m_childShape = new (m_world->GetAllocator()) dgCollisionScene (*scene, this); - } else { - dgCollisionCompound *const compound = (dgCollisionCompound*) m_childShape; - m_childShape = new (m_world->GetAllocator()) dgCollisionCompound (*compound, this); - } - } else if (m_childShape->IsType (dgCollision::dgCollisionMassSpringDamperSystem_RTTI)) { - dgCollisionMassSpringDamperSystem* const deformable = (dgCollisionMassSpringDamperSystem*) m_childShape; - m_childShape = new (m_world->GetAllocator()) dgCollisionMassSpringDamperSystem (*deformable); - } else if (m_childShape->IsType (dgCollision::dgCollisionDeformableSolidMesh_RTTI)) { - dgCollisionDeformableSolidMesh* const deformable = (dgCollisionDeformableSolidMesh*) m_childShape; - m_childShape = new (m_world->GetAllocator()) dgCollisionDeformableSolidMesh (*deformable); - } else { - m_childShape->AddRef(); - } - - if (m_world->m_onCollisionInstanceCopyConstrutor) { - m_world->m_onCollisionInstanceCopyConstrutor (m_world, this, &instance); - } -} - -dgCollisionInstance::dgCollisionInstance(const dgWorld* const constWorld, dgDeserialize serialize, void* const userData, dgInt32 revisionNumber) - :m_globalMatrix(dgGetIdentityMatrix()) - ,m_localMatrix (dgGetIdentityMatrix()) - ,m_aligmentMatrix (dgGetIdentityMatrix()) - ,m_scale(dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)) - ,m_invScale(dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)) - ,m_maxScale(dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)) - ,m_material() - ,m_world(constWorld) - ,m_childShape (NULL) - ,m_subCollisionHandle(NULL) - ,m_parent(NULL) - ,m_skinThickness(dgFloat32 (0.0f)) - ,m_collisionMode(1) - ,m_refCount(1) - ,m_scaleType(m_unit) - ,m_isExternal(true) -{ - dgInt32 saved; - dgInt32 signature; - dgInt32 primitive; - dgInt32 scaleType; - - serialize (userData, &m_globalMatrix, sizeof (m_globalMatrix)); - serialize (userData, &m_localMatrix, sizeof (m_localMatrix)); - serialize (userData, &m_aligmentMatrix, sizeof (m_aligmentMatrix)); - serialize (userData, &m_scale, sizeof (m_scale)); - serialize (userData, &m_invScale, sizeof (m_invScale)); - serialize (userData, &m_maxScale, sizeof (m_maxScale)); - serialize (userData, &m_skinThickness, sizeof (m_skinThickness)); - serialize (userData, &m_material, sizeof (m_material)); - serialize (userData, &m_collisionMode, sizeof (m_collisionMode)); - serialize (userData, &scaleType, sizeof (scaleType)); - serialize (userData, &primitive, sizeof (primitive)); - serialize (userData, &signature, sizeof (signature)); - serialize (userData, &saved, sizeof (saved)); - - m_scaleType = dgScaleType(scaleType); - - dgWorld* const world = (dgWorld*) constWorld; - if (saved) { - const dgCollision* collision = NULL; - dgBodyCollisionList::dgTreeNode* node = world->dgBodyCollisionList::Find (dgUnsigned32 (signature)); - - if (node) { - collision = node->GetInfo(); - collision->AddRef(); - - } else { - - dgCollisionID primitiveType = dgCollisionID(primitive); - - dgMemoryAllocator* const allocator = world->GetAllocator(); - switch (primitiveType) - { - case m_heightField: - { - collision = new (allocator) dgCollisionHeightField (world, serialize, userData, revisionNumber); - break; - } - - case m_boundingBoxHierachy: - { - collision = new (allocator) dgCollisionBVH (world, serialize, userData, revisionNumber); - break; - } - - case m_compoundCollision: - { - collision = new (allocator) dgCollisionCompound (world, serialize, userData, this, revisionNumber); - break; - } - - case m_compoundFracturedCollision: - { - collision = new (allocator) dgCollisionCompoundFractured (world, serialize, userData, this, revisionNumber); - break; - } - - case m_sceneCollision: - { - collision = new (allocator) dgCollisionScene (world, serialize, userData, this, revisionNumber); - break; - } - - - case m_sphereCollision: - { - collision = new (allocator) dgCollisionSphere (world, serialize, userData, revisionNumber); - node = world->dgBodyCollisionList::Insert (collision, collision->GetSignature()); - collision->AddRef(); - break; - } - - case m_boxCollision: - { - collision = new (allocator) dgCollisionBox (world, serialize, userData, revisionNumber); - node = world->dgBodyCollisionList::Insert (collision, collision->GetSignature()); - collision->AddRef(); - break; - } - - case m_coneCollision: - { - collision = new (allocator) dgCollisionCone (world, serialize, userData, revisionNumber); - node = world->dgBodyCollisionList::Insert (collision, collision->GetSignature()); - collision->AddRef(); - break; - } - - case m_capsuleCollision: - { - collision = new (allocator) dgCollisionCapsule (world, serialize, userData, revisionNumber); - node = world->dgBodyCollisionList::Insert (collision, collision->GetSignature()); - collision->AddRef(); - break; - } - - case m_cylinderCollision: - { - collision = new (allocator) dgCollisionCylinder (world, serialize, userData, revisionNumber); - node = world->dgBodyCollisionList::Insert (collision, collision->GetSignature()); - collision->AddRef(); - break; - } - - case m_chamferCylinderCollision: - { - collision = new (allocator) dgCollisionChamferCylinder (world, serialize, userData, revisionNumber); - node = world->dgBodyCollisionList::Insert (collision, collision->GetSignature()); - collision->AddRef(); - break; - } - - case m_convexHullCollision: - { - collision = new (allocator) dgCollisionConvexHull (world, serialize, userData, revisionNumber); - node = world->dgBodyCollisionList::Insert (collision, collision->GetSignature()); - collision->AddRef(); - break; - } - - case m_nullCollision: - { - collision = new (allocator) dgCollisionNull (world, serialize, userData, revisionNumber); - node = world->dgBodyCollisionList::Insert (collision, collision->GetSignature()); - collision->AddRef(); - break; - } - -// case m_deformableMesh: -// { -// dgAssert (0); -// return NULL; -// } - - default: - dgAssert (0); - } - } - m_childShape = collision; - } - dgDeserializeMarker (serialize, userData); -} - -dgCollisionInstance::~dgCollisionInstance() -{ - if (m_world->m_onCollisionInstanceDestruction && m_isExternal) { - m_world->m_onCollisionInstanceDestruction (m_world, this); - } - dgWorld* const world = (dgWorld*)m_world; - world->ReleaseCollision(m_childShape); -} - -void dgCollisionInstance::Serialize(dgSerialize serialize, void* const userData, bool saveShape) const -{ - dgInt32 save = saveShape ? 1 : 0; - dgInt32 primitiveType = m_childShape->GetCollisionPrimityType(); - dgInt32 signature = m_childShape->GetSignature(); - dgInt32 scaleType = m_scaleType; - - serialize (userData, &m_globalMatrix, sizeof (m_globalMatrix)); - serialize (userData, &m_localMatrix, sizeof (m_localMatrix)); - serialize (userData, &m_aligmentMatrix, sizeof (m_aligmentMatrix)); - serialize (userData, &m_scale, sizeof (m_scale)); - serialize (userData, &m_invScale, sizeof (m_invScale)); - serialize (userData, &m_maxScale, sizeof (m_maxScale)); - serialize (userData, &m_skinThickness, sizeof (m_skinThickness)); - serialize (userData, &m_material, sizeof (m_material)); - serialize (userData, &m_collisionMode, sizeof (m_collisionMode)); - serialize (userData, &scaleType, sizeof (scaleType)); - serialize (userData, &primitiveType, sizeof (primitiveType)); - serialize (userData, &signature, sizeof (signature)); - serialize (userData, &save, sizeof (save)); - if (saveShape) { - m_childShape->Serialize(serialize, userData); - } - dgSerializeMarker(serialize, userData); -} - - -void dgCollisionInstance::SetScale (const dgVector& scale) -{ - dgFloat32 scaleX = dgAbs (scale.m_x); - dgFloat32 scaleY = dgAbs (scale.m_y); - dgFloat32 scaleZ = dgAbs (scale.m_z); - dgAssert (scaleX > dgFloat32 (0.0f)); - dgAssert (scaleY > dgFloat32 (0.0f)); - dgAssert (scaleZ > dgFloat32 (0.0f)); - - if (IsType(dgCollision::dgCollisionCompound_RTTI)) { - dgAssert (m_scaleType == m_unit); - dgCollisionCompound* const compound = (dgCollisionCompound*) m_childShape; - compound->ApplyScale(scale); - } else if ((dgAbs (scaleX - scaleY) < dgFloat32 (1.0e-4f)) && (dgAbs (scaleX - scaleZ) < dgFloat32 (1.0e-4f))) { - if ((dgAbs (scaleX - dgFloat32 (1.0f)) < dgFloat32 (1.0e-4f))) { - m_scaleType = m_unit; - m_scale = dgVector (dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)); - m_maxScale = m_scale; - m_invScale = m_scale; - } else { - m_scaleType = m_uniform; - m_scale = dgVector (scaleX, scaleX, scaleX, dgFloat32 (0.0f)); - m_maxScale = m_scale; - m_invScale = dgVector (dgFloat32 (1.0f) / scaleX, dgFloat32 (1.0f) / scaleX, dgFloat32 (1.0f) / scaleX, dgFloat32 (0.0f)); - } - } else { - m_scaleType = m_nonUniform; - m_maxScale = dgMax(scaleX, scaleY, scaleZ); - m_scale = dgVector (scaleX, scaleY, scaleZ, dgFloat32 (0.0f)); - m_invScale = dgVector (dgFloat32 (1.0f) / scaleX, dgFloat32 (1.0f) / scaleY, dgFloat32 (1.0f) / scaleZ, dgFloat32 (0.0f)); - } -} - -void dgCollisionInstance::SetGlobalScale (const dgVector& scale) -{ - // calculate current matrix - dgMatrix matrix(dgGetIdentityMatrix()); - matrix[0][0] = m_scale.m_x; - matrix[1][1] = m_scale.m_y; - matrix[2][2] = m_scale.m_z; - matrix = m_aligmentMatrix * matrix * m_localMatrix; - - // extract the original local matrix - dgMatrix transpose (matrix.Transpose()); - dgVector globalScale (dgSqrt (transpose[0].DotProduct(transpose[0]).GetScalar()), dgSqrt (transpose[1].DotProduct(transpose[1]).GetScalar()), dgSqrt (transpose[2].DotProduct(transpose[2]).GetScalar()), dgFloat32 (1.0f)); - dgVector invGlobalScale (dgFloat32 (1.0f) / globalScale.m_x, dgFloat32 (1.0f) / globalScale.m_y, dgFloat32 (1.0f) / globalScale.m_z, dgFloat32 (1.0f)); - dgMatrix localMatrix (m_aligmentMatrix.Transpose() * m_localMatrix); - localMatrix.m_posit = matrix.m_posit * invGlobalScale; - dgAssert (localMatrix.m_posit.m_w == dgFloat32 (1.0f)); - - if ((dgAbs (scale[0] - scale[1]) < dgFloat32 (1.0e-4f)) && (dgAbs (scale[0] - scale[2]) < dgFloat32 (1.0e-4f))) { - m_localMatrix = localMatrix; - m_localMatrix.m_posit = m_localMatrix.m_posit * scale | dgVector::m_wOne; - m_aligmentMatrix = dgGetIdentityMatrix(); - SetScale (scale); - } else { - - // create a new scale matrix - localMatrix[0] = localMatrix[0] * scale; - localMatrix[1] = localMatrix[1] * scale; - localMatrix[2] = localMatrix[2] * scale; - localMatrix[3] = localMatrix[3] * scale; - localMatrix[3][3] = dgFloat32 (1.0f); - - // decompose into to align * scale * local - localMatrix.PolarDecomposition (m_localMatrix, m_scale, m_aligmentMatrix); - - m_localMatrix = m_aligmentMatrix * m_localMatrix; - m_aligmentMatrix = m_aligmentMatrix.Transpose(); - - dgAssert (m_localMatrix.TestOrthogonal()); - dgAssert (m_aligmentMatrix.TestOrthogonal()); - -//dgMatrix xxx1 (dgGetIdentityMatrix()); -//xxx1[0][0] = m_scale.m_x; -//xxx1[1][1] = m_scale.m_y; -//xxx1[2][2] = m_scale.m_z; -//dgMatrix xxx (m_aligmentMatrix * xxx1 * m_localMatrix); - - bool isIdentity = true; - for (dgInt32 i = 0; i < 3; i ++) { - isIdentity &= dgAbs (m_aligmentMatrix[i][i] - dgFloat32 (1.0f)) < dgFloat32 (1.0e-5f); - isIdentity &= dgAbs (m_aligmentMatrix[3][i]) < dgFloat32 (1.0e-5f); - } - m_scaleType = isIdentity ? m_nonUniform : m_global; - - m_maxScale = dgMax(m_scale[0], m_scale[1], m_scale[2]); - m_invScale = dgVector (dgFloat32 (1.0f) / m_scale[0], dgFloat32 (1.0f) / m_scale[1], dgFloat32 (1.0f) / m_scale[2], dgFloat32 (0.0f)); - } -} - - -void dgCollisionInstance::SetLocalMatrix (const dgMatrix& matrix) -{ - m_localMatrix = matrix; - m_localMatrix[0][3] = dgFloat32 (0.0f); - m_localMatrix[1][3] = dgFloat32 (0.0f); - m_localMatrix[2][3] = dgFloat32 (0.0f); - m_localMatrix[3][3] = dgFloat32 (1.0f); - dgAssert(m_localMatrix.TestOrthogonal()); -} - - -void dgCollisionInstance::DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - m_childShape->DebugCollision (GetScaledTransform(matrix), callback, userData); -} - - -dgMatrix dgCollisionInstance::CalculateInertia () const -{ - if (IsType(dgCollision::dgCollisionMesh_RTTI)) { - return dgGetZeroMatrix(); - } else { - return m_childShape->CalculateInertiaAndCenterOfMass (m_aligmentMatrix, m_scale, m_localMatrix); - } -} - - -dgInt32 dgCollisionInstance::CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const -{ - dgInt32 count = 0; - dgAssert(normal.m_w == dgFloat32 (0.0f)); - switch (m_scaleType) - { - case m_unit: - { - count = m_childShape->CalculatePlaneIntersection (normal, point, contactsOut); - break; - } - case m_uniform: - { - dgVector point1 (m_invScale * point); - count = m_childShape->CalculatePlaneIntersection (normal, point1, contactsOut); - for (dgInt32 i = 0; i < count; i ++) { - contactsOut[i] = m_scale * contactsOut[i]; - } - break; - } - - case m_nonUniform: - { - // support((p * S), n) = S * support (p, n * transp(S)) - dgVector point1 (m_invScale * point); - dgVector normal1 (m_scale * normal); - normal1 = normal1.Normalize(); - count = m_childShape->CalculatePlaneIntersection (normal1, point1, contactsOut); - for (dgInt32 i = 0; i < count; i ++) { - contactsOut[i] = m_scale * contactsOut[i]; - } - break; - } - - case m_global: - default: - { - dgVector point1 (m_aligmentMatrix.UntransformVector (m_invScale * point)); - dgVector normal1 (m_aligmentMatrix.UntransformVector (m_scale * normal)); - normal1 = normal1.Normalize(); - count = m_childShape->CalculatePlaneIntersection (normal1, point1, contactsOut); - for (dgInt32 i = 0; i < count; i ++) { - contactsOut[i] = m_scale * m_aligmentMatrix.TransformVector(contactsOut[i]); - } - } - } - return count; -} - - -void dgCollisionInstance::CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const -{ - switch (m_scaleType) - { - case m_unit: - { - m_childShape->CalcAABB (matrix, p0, p1); - p0 -= m_padding; - p1 += m_padding; - break; - } - - case m_uniform: - case m_nonUniform: - { - dgMatrix matrix1 (matrix); - matrix1[0] = matrix1[0].Scale(m_scale.m_x); - matrix1[1] = matrix1[1].Scale(m_scale.m_y); - matrix1[2] = matrix1[2].Scale(m_scale.m_z); - m_childShape->CalcAABB (matrix1, p0, p1); - p0 -= m_padding; - p1 += m_padding; - break; - } - - case m_global: - default: - { - dgMatrix matrix1 (matrix); - matrix1[0] = matrix1[0].Scale(m_scale.m_x); - matrix1[1] = matrix1[1].Scale(m_scale.m_y); - matrix1[2] = matrix1[2].Scale(m_scale.m_z); - m_childShape->CalcAABB (m_aligmentMatrix * matrix1, p0, p1); - p0 -= m_padding; - p1 += m_padding; - break; - } - } - - dgAssert (p0.m_w == dgFloat32 (0.0f)); - dgAssert (p1.m_w == dgFloat32 (0.0f)); -} - -dgFloat32 dgCollisionInstance::RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, OnRayPrecastAction preFilter, const dgBody* const body, void* const userData) const -{ - if (!preFilter || preFilter(body, this, userData)) { - switch(m_scaleType) - { - case m_unit: - { - dgFloat32 t = m_childShape->RayCast (localP0, localP1, maxT, contactOut, body, userData, preFilter); - if (t <= maxT) { - if (!(m_childShape->IsType(dgCollision::dgCollisionMesh_RTTI) || m_childShape->IsType(dgCollision::dgCollisionCompound_RTTI))) { - contactOut.m_shapeId0 = GetUserDataID(); - contactOut.m_shapeId1 = GetUserDataID(); - } - if (!m_childShape->IsType(dgCollision::dgCollisionCompound_RTTI)) { - contactOut.m_collision0 = this; - contactOut.m_collision1 = this; - } - } - return t; - } - - case m_uniform: - { - dgVector p0 (localP0 * m_invScale); - dgVector p1 (localP1 * m_invScale); - dgFloat32 t = m_childShape->RayCast (p0, p1, maxT, contactOut, body, userData, preFilter); - if (t <= maxT) { - if (!(m_childShape->IsType(dgCollision::dgCollisionMesh_RTTI) || m_childShape->IsType(dgCollision::dgCollisionCompound_RTTI))) { - contactOut.m_shapeId0 = GetUserDataID(); - contactOut.m_shapeId1 = GetUserDataID(); - } - if (!m_childShape->IsType(dgCollision::dgCollisionCompound_RTTI)) { - contactOut.m_collision0 = this; - contactOut.m_collision1 = this; - } - } - return t; - } - - case m_nonUniform: - { - dgVector p0 (localP0 * m_invScale); - dgVector p1 (localP1 * m_invScale); - dgFloat32 t = m_childShape->RayCast (p0, p1, maxT, contactOut, body, userData, preFilter); - if (t <= maxT) { - if (!(m_childShape->IsType(dgCollision::dgCollisionMesh_RTTI) || m_childShape->IsType(dgCollision::dgCollisionCompound_RTTI))) { - contactOut.m_shapeId0 = GetUserDataID(); - contactOut.m_shapeId1 = GetUserDataID(); - dgVector n (m_invScale * contactOut.m_normal); - contactOut.m_normal = n.Normalize(); - } - if (!m_childShape->IsType(dgCollision::dgCollisionCompound_RTTI)) { - contactOut.m_collision0 = this; - contactOut.m_collision1 = this; - } - } - return t; - } - - case m_global: - default: - { - dgVector p0 (m_aligmentMatrix.UntransformVector (localP0 * m_invScale)); - dgVector p1 (m_aligmentMatrix.UntransformVector (localP1 * m_invScale)); - dgFloat32 t = m_childShape->RayCast (p0, p1, maxT, contactOut, body, userData, preFilter); - if (t <= maxT) { - if (!(m_childShape->IsType(dgCollision::dgCollisionMesh_RTTI) || m_childShape->IsType(dgCollision::dgCollisionCompound_RTTI))) { - contactOut.m_shapeId0 = GetUserDataID(); - contactOut.m_shapeId1 = GetUserDataID(); - dgVector n (m_aligmentMatrix.RotateVector(m_invScale * contactOut.m_normal)); - contactOut.m_normal = n.Normalize(); - } - if (!(m_childShape->IsType(dgCollision::dgCollisionCompound_RTTI))) { - contactOut.m_collision0 = this; - contactOut.m_collision1 = this; - } - } - return t; - } - } - } - return dgFloat32 (1.2f); -} - -void dgCollisionInstance::CalculateImplicitContacts(dgInt32 count, dgContactPoint* const contactPoints) const -{ - switch (m_scaleType) - { - case m_unit: - { - for (dgInt32 i = 0; i < count; i++) { - contactPoints[i].m_point = m_globalMatrix.UntransformVector(contactPoints[i].m_point); - } - m_childShape->CalculateImplicitContacts(count, contactPoints); - for (dgInt32 i = 0; i < count; i++) { - contactPoints[i].m_point = m_globalMatrix.TransformVector(contactPoints[i].m_point); - contactPoints[i].m_normal = m_globalMatrix.RotateVector(contactPoints[i].m_normal); - } - break; - } - - case m_uniform: - { - for (dgInt32 i = 0; i < count; i++) { - contactPoints[i].m_point = m_invScale * m_globalMatrix.UntransformVector(contactPoints[i].m_point); - } - m_childShape->CalculateImplicitContacts(count, contactPoints); - for (dgInt32 i = 0; i < count; i++) { - contactPoints[i].m_point = m_globalMatrix.TransformVector(contactPoints[i].m_point * m_scale); - contactPoints[i].m_normal = m_globalMatrix.RotateVector(contactPoints[i].m_normal); - } - break; - } - - case m_nonUniform: - { - for (dgInt32 i = 0; i < count; i++) { - contactPoints[i].m_point = m_invScale * m_globalMatrix.UntransformVector(contactPoints[i].m_point); - } - m_childShape->CalculateImplicitContacts(count, contactPoints); - for (dgInt32 i = 0; i < count; i++) { - contactPoints[i].m_point = m_globalMatrix.TransformVector(contactPoints[i].m_point * m_scale); - contactPoints[i].m_normal = m_globalMatrix.RotateVector(contactPoints[i].m_normal * m_invScale).Normalize(); - } - break; - } - - case m_global: - default: - { - for (dgInt32 i = 0; i < count; i++) { - contactPoints[i].m_point = m_invScale * m_globalMatrix.UntransformVector(m_aligmentMatrix.UntransformVector(contactPoints[i].m_point)); - } - m_childShape->CalculateImplicitContacts(count, contactPoints); - for (dgInt32 i = 0; i < count; i++) { - contactPoints[i].m_point = m_globalMatrix.TransformVector(m_aligmentMatrix.TransformVector(contactPoints[i].m_point) * m_scale); - contactPoints[i].m_normal = m_globalMatrix.RotateVector(m_aligmentMatrix.RotateVector(contactPoints[i].m_normal) * m_invScale).Normalize(); - } - } - } -} \ No newline at end of file diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionInstance.h b/thirdparty/src/newton/dgPhysics/dgCollisionInstance.h deleted file mode 100644 index 64b033365..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionInstance.h +++ /dev/null @@ -1,589 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_COLLISION_INSTANCE_H_ -#define _DG_COLLISION_INSTANCE_H_ - - -#define DG_MAX_COLLISION_AABB_PADDING dgFloat32 (1.0f / 16.0f) - -#include "dgCollision.h" - -class dgCollisionInstance -{ - public: - enum dgScaleType - { - m_unit, - m_uniform, - m_nonUniform, - m_global, - }; - - DG_CLASS_ALLOCATOR(allocator) - dgCollisionInstance(); - dgCollisionInstance(const dgCollisionInstance& instance); - dgCollisionInstance(const dgCollisionInstance& meshInstance, const dgCollision* const shape); - dgCollisionInstance(const dgWorld* const world, const dgCollision* const childCollision, dgInt32 shapeID, const dgMatrix& matrix); - dgCollisionInstance(const dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - ~dgCollisionInstance(); - - dgCollisionInstance* AddRef (); - dgInt32 Release (); - - void SetScale (const dgVector& scale); - const dgVector& GetScale () const; - const dgVector& GetInvScale () const; - - void SetGlobalScale (const dgVector& scale); - - dgScaleType GetScaleType() const; - dgScaleType GetCombinedScaleType(dgScaleType type) const; - - const dgMatrix& GetLocalMatrix () const; - const dgMatrix& GetGlobalMatrix () const; - const dgMatrix& GetAlignMatrix () const; - void SetLocalMatrix (const dgMatrix& matrix); - void SetGlobalMatrix (const dgMatrix& matrix); - - dgUnsigned64 GetUserDataID () const; - void SetUserDataID (dgUnsigned64 userData); - - void* GetUserData () const; - void SetUserData (void* const userData); - - dgCollisionInfo::dgInstanceMaterial GetMaterial () const; - void SetMaterial (const dgCollisionInfo::dgInstanceMaterial& userData); - - const void* GetCollisionHandle () const; - const dgCollisionInstance* GetParent () const; - - dgVector GetBoxSize() const; - dgVector GetBoxOrigin() const; - - dgFloat32 GetUmbraClipSize () const; - - const dgWorld* GetWorld() const; - const dgCollision* GetChildShape() const; - - void SetWorld (dgWorld* const world); - void SetChildShape (dgCollision* const shape); - - dgFloat32 GetVolume () const; - void GetCollisionInfo(dgCollisionInfo* const info) const; - - dgInt32 IsType (dgCollision::dgRTTI type) const; - dgMemoryAllocator* GetAllocator() const; - - bool GetCollisionMode() const; - void SetCollisionMode(bool mode); - - void SetBreakImpulse(dgFloat32 force); - dgFloat32 GetBreakImpulse() const; - - dgUnsigned32 GetSignature () const; - dgCollisionID GetCollisionPrimityType () const; - - void CalcObb (dgVector& origin, dgVector& size) const; - void CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const; - dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, OnRayPrecastAction preFilter, const dgBody* const body, void* const userData) const; - - dgFloat32 GetBoxMinRadius () const; - dgFloat32 GetBoxMaxRadius () const; - - dgMatrix CalculateInertia () const; - dgMatrix GetScaledTransform(const dgMatrix& matrix) const; - void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - - dgVector SupportVertex (const dgVector& dir) const; - dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const; - - dgInt32 CalculateSignature () const; - void SetCollisionBBox (const dgVector& p0, const dgVector& p1); - - dgInt32 GetConvexVertexCount() const; - - void Serialize(dgSerialize callback, void* const userData, bool saveShape = true) const; - dgVector CalculateBuoyancyVolume (const dgMatrix& matrix, const dgVector& fluidPlane) const; - - dgVector SupportVertexSpecial (const dgVector& dir, dgInt32* const vertexIndex) const; - dgVector SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const; - - dgFloat32 GetSkinThickness() const; - void SetSkinThickness(dgFloat32 thickness); - - void CalculateImplicitContacts(dgInt32 count, dgContactPoint* const contactPoints) const; - - dgMatrix m_globalMatrix; - dgMatrix m_localMatrix; - dgMatrix m_aligmentMatrix; - dgVector m_scale; - dgVector m_invScale; - dgVector m_maxScale; - dgCollisionInfo::dgInstanceMaterial m_material; - const dgWorld* m_world; - const dgCollision* m_childShape; - const void* m_subCollisionHandle; - const dgCollisionInstance* m_parent; - dgFloat32 m_skinThickness; - dgInt32 m_collisionMode; - dgInt32 m_refCount; - dgScaleType m_scaleType; - bool m_isExternal; - - static dgVector m_padding; -}; - -DG_INLINE dgCollisionInstance::dgCollisionInstance(const dgCollisionInstance& meshInstance, const dgCollision* const shape) - :m_globalMatrix(meshInstance.m_globalMatrix) - ,m_localMatrix (meshInstance.m_localMatrix) - ,m_aligmentMatrix (meshInstance.m_aligmentMatrix) - ,m_scale(meshInstance.m_scale) - ,m_invScale(meshInstance.m_invScale) - ,m_maxScale(meshInstance.m_maxScale) - ,m_material(meshInstance.m_material) - ,m_world(meshInstance.m_world) - ,m_childShape (shape) - ,m_subCollisionHandle(NULL) - ,m_parent(NULL) - ,m_skinThickness(meshInstance.m_skinThickness) - ,m_collisionMode(meshInstance.m_collisionMode) - ,m_refCount(1) - ,m_scaleType(meshInstance.m_scaleType) - ,m_isExternal(false) -{ - if (m_childShape) { - m_childShape->AddRef(); - } -} - -DG_INLINE dgCollisionInstance* dgCollisionInstance::AddRef () -{ - m_refCount ++; - return this; -} - -DG_INLINE dgInt32 dgCollisionInstance::Release () -{ - m_refCount --; - if (m_refCount) { - return m_refCount; - } - delete this; - return 0; -} - -DG_INLINE dgInt32 dgCollisionInstance::IsType (dgCollision::dgRTTI type) const -{ - return m_childShape->IsType (type); -} - -DG_INLINE const dgWorld* dgCollisionInstance::GetWorld() const -{ - return m_world; -} - -DG_INLINE const dgCollision* dgCollisionInstance::GetChildShape() const -{ - return m_childShape; -} - -DG_INLINE void dgCollisionInstance::SetWorld (dgWorld* const world) -{ - m_world = world; -} - -DG_INLINE void dgCollisionInstance::SetChildShape (dgCollision* const shape) -{ - shape->AddRef(); - if (m_childShape) { - m_childShape->Release(); - } - - m_childShape = shape; -} - -DG_INLINE void dgCollisionInstance::GetCollisionInfo(dgCollisionInfo* const info) const -{ - info->m_offsetMatrix = m_localMatrix; - info->m_collisionMaterial = m_material; - m_childShape->GetCollisionInfo(info); -} - -DG_INLINE const dgVector& dgCollisionInstance::GetScale () const -{ - return m_scale; -} - -DG_INLINE const dgVector& dgCollisionInstance::GetInvScale () const -{ - return m_invScale; -} - -DG_INLINE const dgMatrix& dgCollisionInstance::GetLocalMatrix () const -{ - return m_localMatrix; -} - -DG_INLINE const dgMatrix& dgCollisionInstance::GetGlobalMatrix () const -{ - return m_globalMatrix; -} - -DG_INLINE const dgMatrix& dgCollisionInstance::GetAlignMatrix () const -{ - return m_aligmentMatrix; -} - -DG_INLINE void dgCollisionInstance::SetGlobalMatrix (const dgMatrix& matrix) -{ - m_globalMatrix = matrix; -} - -DG_INLINE dgMemoryAllocator* dgCollisionInstance::GetAllocator() const -{ - return m_childShape->GetAllocator(); -} - -DG_INLINE dgFloat32 dgCollisionInstance::GetVolume () const -{ - return m_childShape->GetVolume() * m_scale.m_x * m_scale.m_y * m_scale.m_z; -} - -DG_INLINE bool dgCollisionInstance::GetCollisionMode() const -{ - return m_collisionMode ? true : false; -} - -DG_INLINE void dgCollisionInstance::SetCollisionMode(bool mode) -{ - m_collisionMode = mode ? 1 : 0; -} - - -DG_INLINE void dgCollisionInstance::SetBreakImpulse(dgFloat32 force) -{ - dgAssert (0); -// m_destructionImpulse = force; -} - -DG_INLINE dgFloat32 dgCollisionInstance::GetBreakImpulse() const -{ -// return m_destructionImpulse; - return dgFloat32 (1.0e20f); -} - -DG_INLINE const void* dgCollisionInstance::GetCollisionHandle () const -{ - return m_subCollisionHandle; -} - -DG_INLINE const dgCollisionInstance* dgCollisionInstance::GetParent () const -{ - return m_parent; -} - -DG_INLINE dgUnsigned64 dgCollisionInstance::GetUserDataID () const -{ - return m_material.m_userId; -} - -DG_INLINE void dgCollisionInstance::SetUserDataID (dgUnsigned64 userDataId) -{ - m_material.m_userId = userDataId; -} - -DG_INLINE void* dgCollisionInstance::GetUserData () const -{ - return m_material.m_userData; -} - -DG_INLINE void dgCollisionInstance::SetUserData (void* const userData) -{ - m_material.m_userData = userData; -} - -DG_INLINE dgCollisionInfo::dgInstanceMaterial dgCollisionInstance::GetMaterial () const -{ - return m_material; -} - -DG_INLINE void dgCollisionInstance::SetMaterial(const dgCollisionInfo::dgInstanceMaterial& userData) -{ - m_material = userData; -} - -DG_INLINE dgUnsigned32 dgCollisionInstance::GetSignature () const -{ - return m_childShape->GetSignature(); -} - -DG_INLINE dgCollisionID dgCollisionInstance::GetCollisionPrimityType () const -{ - return m_childShape->GetCollisionPrimityType(); -} - -DG_INLINE dgFloat32 dgCollisionInstance::GetBoxMinRadius () const -{ - return m_childShape->GetBoxMinRadius() * m_maxScale.m_x; -} - -DG_INLINE dgFloat32 dgCollisionInstance::GetBoxMaxRadius () const -{ - return m_childShape->GetBoxMaxRadius() * m_maxScale.m_x; -} - -DG_INLINE dgVector dgCollisionInstance::SupportVertex(const dgVector& dir) const -{ - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert (dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-2f)); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - switch (m_scaleType) - { - case m_unit: - { - return m_childShape->SupportVertex (dir, NULL); - } - case m_uniform: - { - return m_scale * m_childShape->SupportVertex (dir, NULL); - } - case m_nonUniform: - { - // support((p * S), n) = S * support (p, n * transp(S)) - dgVector dir1 ((m_scale * dir).Normalize()); - return m_scale * m_childShape->SupportVertex (dir1, NULL); - } - - case m_global: - default: - { - dgVector dir1 (m_aligmentMatrix.UnrotateVector((m_scale * dir).Normalize())); - return m_scale * m_aligmentMatrix.TransformVector (m_childShape->SupportVertex (dir1, NULL)); - } - } -} - -DG_INLINE dgVector dgCollisionInstance::SupportVertexSpecial (const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert(dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-2f)); - dgAssert(dir.m_w == dgFloat32(0.0f)); - switch (m_scaleType) - { - case m_unit: - { - return m_childShape->SupportVertexSpecial(dir, m_skinThickness, vertexIndex); - } - case m_uniform: - { - return m_scale * m_childShape->SupportVertexSpecial(dir, m_skinThickness, vertexIndex); - } - - default: - return SupportVertex(dir); - -/* - case m_nonUniform: - { - // support((p * S), n) = S * support (p, n * transp(S)) - dgVector dir1((m_scale * dir).Normalize()); - return m_scale * m_childShape->SupportVertexSpecial(dir1, m_skinThickness, vertexIndex); - } - - default: - { - dgVector dir1(m_aligmentMatrix.UnrotateVector((m_scale * dir).Normalize())); - return m_scale * m_aligmentMatrix.TransformVector(m_childShape->SupportVertexSpecial(dir1, vertexIndex)); - } -*/ - } -} - -DG_INLINE dgVector dgCollisionInstance::SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const -{ - dgAssert(dir.m_w == dgFloat32(0.0f)); - dgAssert(dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-2f)); - switch (m_scaleType) - { - case m_unit: - { - return m_childShape->SupportVertexSpecialProjectPoint(point, dir); - } - case m_uniform: - { - return m_scale * m_childShape->SupportVertexSpecialProjectPoint(point * m_invScale, dir); - } - - default: - return point; - -/* - case m_nonUniform: - { - // support((p * S), n) = S * support (p/S, n * transp(S)) - dgVector dir1((m_scale * dir).Normalize()); - return m_scale * m_childShape->SupportVertexSpecialProjectPoint(point * m_invScale, dir1); - } - - case m_global: - default: - { - dgVector dir1(m_aligmentMatrix.UnrotateVector((m_scale * dir).Normalize())); - return m_scale * m_aligmentMatrix.TransformVector(m_childShape->SupportVertexSpecialProjectPoint(m_aligmentMatrix.UntransformVector(point * m_invScale), dir1)); - } -*/ - } -} - -DG_INLINE void dgCollisionInstance::SetCollisionBBox (const dgVector& p0, const dgVector& p1) -{ - dgAssert (0); -} - -DG_INLINE dgInt32 dgCollisionInstance::CalculateSignature () const -{ - dgAssert (0); - return 0; -} - - -DG_INLINE dgInt32 dgCollisionInstance::GetConvexVertexCount() const -{ - return m_childShape->GetConvexVertexCount(); -} - - -DG_INLINE dgVector dgCollisionInstance::GetBoxSize() const -{ - switch (m_scaleType) - { - case m_unit: - case m_uniform: - case m_nonUniform: - return m_childShape->m_boxSize * m_scale; - - case m_global: - default: - return m_childShape->m_boxSize * m_maxScale; - } -} - -DG_INLINE dgVector dgCollisionInstance::GetBoxOrigin() const -{ - switch (m_scaleType) - { - case m_unit: - case m_uniform: - case m_nonUniform: - return m_childShape->m_boxOrigin * m_scale; - - case m_global: - default: - return m_aligmentMatrix.TransformVector(m_childShape->m_boxOrigin) * m_scale; - } -} - -DG_INLINE dgFloat32 dgCollisionInstance::GetUmbraClipSize () const -{ - return m_childShape->GetUmbraClipSize() * m_maxScale.m_x; -} - -DG_INLINE dgCollisionInstance::dgScaleType dgCollisionInstance::GetScaleType() const -{ - return m_scaleType; -} - -DG_INLINE dgCollisionInstance::dgScaleType dgCollisionInstance::GetCombinedScaleType(dgCollisionInstance::dgScaleType type) const -{ - dgAssert (0); - return dgMax(m_scaleType, type); -} - -DG_INLINE dgMatrix dgCollisionInstance::GetScaledTransform(const dgMatrix& matrix) const -{ - dgMatrix scaledMatrix(m_localMatrix * matrix); - scaledMatrix[0] = scaledMatrix[0].Scale(m_scale[0]); - scaledMatrix[1] = scaledMatrix[1].Scale(m_scale[1]); - scaledMatrix[2] = scaledMatrix[2].Scale(m_scale[2]); - return m_aligmentMatrix * scaledMatrix; -} - -DG_INLINE void dgCollisionInstance::CalcObb (dgVector& origin, dgVector& size) const -{ - size = m_childShape->GetObbSize(); - origin = m_childShape->GetObbOrigin(); - - switch (m_scaleType) - { - case m_unit: - { - size += m_padding; - break; - } - - case m_uniform: - case m_nonUniform: - { - size = size * m_scale + m_padding; - origin = origin * m_scale; - break; - } - case m_global: - { -// dgMatrix matrix1 (matrix); -// matrix1[0] = matrix1[0].Scale(m_scale.m_x); -// matrix1[1] = matrix1[1].Scale(m_scale.m_y); -// matrix1[2] = matrix1[2].Scale(m_scale.m_z); -// m_childShape->CalcAABB (m_aligmentMatrix * matrix1, p0, p1); -// p0 -= m_padding; -// p1 += m_padding; - - dgVector p0; - dgVector p1; - m_childShape->CalcAABB(m_aligmentMatrix, p0, p1); - size = (dgVector::m_half * (p1 - p0) * m_scale + m_padding) & dgVector::m_triplexMask; - origin = (dgVector::m_half * (p1 + p0) * m_scale) & dgVector::m_triplexMask;; - break; - } - } - - dgAssert (size.m_w == dgFloat32 (0.0f)); - dgAssert (origin.m_w == dgFloat32 (0.0f)); -} - -DG_INLINE dgFloat32 dgCollisionInstance::GetSkinThickness() const -{ - return m_skinThickness; -} - -DG_INLINE void dgCollisionInstance::SetSkinThickness(dgFloat32 thickness) -{ - m_skinThickness = dgAbs (thickness); -} - -DG_INLINE dgVector dgCollisionInstance::CalculateBuoyancyVolume(const dgMatrix& matrix, const dgVector& fluidPlane) const -{ - return m_childShape->CalculateVolumeIntegral(m_localMatrix * matrix, fluidPlane, *this); -} - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionLumpedMassParticles.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionLumpedMassParticles.cpp deleted file mode 100644 index b51dd9f9a..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionLumpedMassParticles.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgCollision.h" -#include "dgMeshEffect.h" -#include "dgDynamicBody.h" -#include "dgCollisionLumpedMassParticles.h" - - -#define DG_MINIMIM_ZERO_SPEED dgFloat32 (1.0e-3f) -#define DG_MINIMIM_PARTCLE_RADIUS dgFloat32 (1.0f/16.0f) -#define DG_MINIMIM_ZERO_SURFACE (DG_MINIMIM_PARTCLE_RADIUS * dgFloat32 (0.25f)) - - -dgCollisionLumpedMassParticles::dgCollisionLumpedMassParticles(dgWorld* const world, dgCollisionID collisionID) - :dgCollisionConvex(world->GetAllocator(), 0, collisionID) - ,m_posit(world->GetAllocator()) - ,m_veloc(world->GetAllocator()) - ,m_accel(world->GetAllocator()) - ,m_externalAccel(world->GetAllocator()) - ,m_mass(world->GetAllocator()) - ,m_invMass(world->GetAllocator()) - ,m_body(NULL) - ,m_totalMass(dgFloat32(1.0f)) - ,m_particleRadius(DG_MINIMIM_PARTCLE_RADIUS) - ,m_particlesCount(0) -{ - m_rtti |= dgCollisionLumpedMass_RTTI; -} - -dgCollisionLumpedMassParticles::dgCollisionLumpedMassParticles (const dgCollisionLumpedMassParticles& source) - :dgCollisionConvex(source) - ,m_posit(source.m_posit, source.m_particlesCount) - ,m_veloc(source.m_veloc, source.m_particlesCount) - ,m_accel(source.m_accel, source.m_particlesCount) - ,m_externalAccel(source.m_externalAccel, source.m_particlesCount) - ,m_mass(source.m_mass, source.m_particlesCount) - ,m_invMass(source.m_invMass, source.m_particlesCount) - ,m_body(NULL) - ,m_totalMass(source.m_totalMass) - ,m_particleRadius(source.m_particleRadius) - ,m_particlesCount(source.m_particlesCount) -{ - m_rtti |= dgCollisionLumpedMass_RTTI; -} - - -dgCollisionLumpedMassParticles::dgCollisionLumpedMassParticles (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionConvex(world, deserialization, userData, revisionNumber) - ,m_posit(world->GetAllocator()) - ,m_veloc(world->GetAllocator()) - ,m_accel(world->GetAllocator()) - ,m_externalAccel(world->GetAllocator()) - ,m_mass(world->GetAllocator()) - ,m_invMass(world->GetAllocator()) - ,m_body(NULL) - ,m_totalMass(dgFloat32(1.0f)) - ,m_particleRadius (DG_MINIMIM_PARTCLE_RADIUS) - ,m_particlesCount(0) -{ - m_rtti |= dgCollisionLumpedMass_RTTI; - dgAssert (0); -} - -dgCollisionLumpedMassParticles::~dgCollisionLumpedMassParticles(void) -{ -} - -void dgCollisionLumpedMassParticles::FinalizeBuild() -{ - m_veloc.Resize(m_particlesCount); - m_accel.Resize(m_particlesCount); - m_externalAccel.Resize(m_particlesCount); - - dgVector com(dgFloat32(0.0f)); - dgVector* const posit = &m_posit[0]; - - dgVector minp(dgFloat32 (1.0e10f)); - dgVector maxp(dgFloat32 (-1.0e10f)); - for (dgInt32 i = 0; i < m_particlesCount; i++) { - minp = minp.GetMin(posit[i]); - maxp = maxp.GetMax(posit[i]); - m_accel[i] = dgVector::m_zero; - m_veloc[i] = dgVector::m_zero; - m_externalAccel[i] = dgVector::m_zero; - } - - // for now use a fix size box - m_boxSize = dgVector::m_half * (maxp - minp); - m_boxOrigin = dgVector::m_half * (maxp + minp); -} - -void dgCollisionLumpedMassParticles::DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - dgAssert (0); -} - -void dgCollisionLumpedMassParticles::SetOwnerAndMassPraperties (dgDynamicBody* const body) -{ - m_body = body; - - dgMatrix matrix (body->GetMatrix()); - dgVector position (matrix.m_posit); - matrix.m_posit = dgVector::m_wOne; - - dgVector* const posit = &m_posit[0]; - const dgFloat32* const mass = &m_mass[0]; - - dgVector xMassSum(dgFloat32(0.0f)); -// dgVector xyMassSum(dgFloat32(0.0f)); -// dgVector xxMassSum(dgFloat32(0.0f)); - dgFloat32 massSum = dgFloat32 (0.0f); -// dgFloat32 inertiaSum = dgFloat32 (0.0f); -// dgFloat32 radius2 = m_particleRadius * m_particleRadius * dgFloat32 (2.0f / 5.0f); - dgMatrix scaledTranform (body->m_collision->GetScaledTransform(matrix)); - for (dgInt32 i = 0; i < m_particlesCount; i++) { - massSum += mass[i]; - //inertiaSum += mass[i] * radius2; - posit[i] = scaledTranform.TransformVector(posit[i]) & dgVector::m_triplexMask; - xMassSum += posit[i].Scale (mass[i]); - //xxMassSum += posit[i] * posit[i].Scale (mass[i]); - //xyMassSum += posit[i] * (posit[i].ShiftTripleRight()).Scale (mass[i]); - } - m_totalMass = massSum; - dgFloat32 invMass = dgFloat32(1.0f) / massSum; - - body->m_collision->SetScale(dgVector (dgFloat32 (1.0f))); - body->m_collision->SetLocalMatrix (dgGetIdentityMatrix()); - matrix.m_posit = position; - body->m_matrix = matrix; - body->m_localCentreOfMass = xMassSum * invMass; - - //dgVector inertia (xxMassSum.Scale(invMass) - body->m_localCentreOfMass); - //inertia += dgVector (inertiaSum); - //inertia.m_w = massSum; - //body->m_mass = inertia; - body->m_mass = dgVector(dgFloat32(1.0f), dgFloat32(1.0f), dgFloat32(1.0f), m_totalMass); - body->m_invMass = dgVector(dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), invMass); - -// dgVector yySum(xxSum.ShiftTripleRight()); -// dgVector com(xxSum * den + origin); -// dgVector pxx0(origin - com); -// dgVector pxy0(pxx0.ShiftTripleRight()); -// dgVector Ixx(unitMass * (xxSum2 + xxSum * pxx0 * dgVector::m_two) + pxx0 * pxx0.Scale(m_body->m_mass.m_w)); -// dgVector Ixy(unitMass * (xySum + xxSum * pxy0 + yySum * pxx0) + pxx0 * pxy0.Scale(m_body->m_mass.m_w)); -// dgVector com2(body->m_localCentreOfMass * body->m_localCentreOfMass); -} - -int dgCollisionLumpedMassParticles::GetCount() const -{ - return m_particlesCount; -} - -dgInt32 dgCollisionLumpedMassParticles::GetStrideInByte() const -{ - return sizeof (dgVector); -} - -const dgVector* dgCollisionLumpedMassParticles::GetVelocity() const -{ - return &m_veloc[0]; -} - -const dgVector* dgCollisionLumpedMassParticles::GetPositions() const -{ - return &m_posit[0]; -} - -const dgVector* dgCollisionLumpedMassParticles::GetAcceleration() const -{ - return &m_accel[0]; -} - -dgInt32 dgCollisionLumpedMassParticles::CalculateSignature() const -{ - dgAssert (0); - return 0; -} - -void dgCollisionLumpedMassParticles::SetCollisionBBox(const dgVector& p0, const dgVector& p1) -{ - dgAssert (0); -} - -void dgCollisionLumpedMassParticles::Serialize(dgSerialize callback, void* const userData) const -{ - dgAssert (0); -} - -void dgCollisionLumpedMassParticles::RegisterCollision(const dgBody* const otherBody) -{ -// dgAssert (0); -} - -void dgCollisionLumpedMassParticles::CalcAABB(const dgMatrix& matrix, dgVector& p0, dgVector& p1) const -{ - dgVector origin(matrix.TransformVector(m_boxOrigin)); - dgVector size(matrix.m_front.Abs().Scale(m_boxSize.m_x) + matrix.m_up.Abs().Scale(m_boxSize.m_y) + matrix.m_right.Abs().Scale(m_boxSize.m_z)); - p0 = (origin - size) & dgVector::m_triplexMask; - p1 = (origin + size) & dgVector::m_triplexMask; -} - -dgFloat32 dgCollisionLumpedMassParticles::RayCast(const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const -{ - // for now brute force ray cast - dgVector p (m_posit[0]); - dgFloat32 distance2 = dgFloat32 (0.1f); - for (dgInt32 i = 0; i < m_particlesCount; i ++) { - dgVector posit (dgPointToRayDistance (m_posit[i], localP0, localP1)); - dgVector step (posit - m_posit[i]); - dgAssert (step.m_w == dgFloat32 (0.0f)); - dgFloat32 dist2 = step.DotProduct(step).GetScalar(); - if (dist2 < distance2) { - distance2 = dist2; - p = m_posit[i]; - } - } - - dgFloat32 dist = dgFloat32(1.0e10f); - if (distance2 < dgFloat32(0.1f)) { - contactOut.m_point = p; - contactOut.m_normal = dgVector(dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector num(p - localP0); - dgVector den(localP1 - localP0); - dgAssert (den.m_w == dgFloat32 (0.0f)); - dist = num.DotProduct(den).GetScalar() / den.DotProduct(den).GetScalar(); - } - return dist; -} - -dgMatrix dgCollisionLumpedMassParticles::CalculateInertiaAndCenterOfMass(const dgMatrix& m_alignMatrix, const dgVector& localScale, const dgMatrix& matrix) const -{ -dgAssert (0); - dgVector com(dgFloat32(0.0f)); - for (dgInt32 i = 0; i < m_particlesCount; i++) { - com = matrix.RotateVector(m_posit[i] * localScale); - } - dgVector den(dgFloat32(1.0f / m_particlesCount)); - dgMatrix inertia(dgGetIdentityMatrix()); - inertia.m_posit = com * den; - inertia.m_posit.m_w = dgFloat32(1.0f); - return inertia; -} - -/* -dgFloat32 dgCollisionLumpedMassParticles::CalculaleContactPenetration(const dgVector& point, const dgVector& normal) const -{ - dgVector otherPoint (point); - otherPoint.m_y = dgFloat32 (0.0f); - dgFloat32 penetration = normal.DotProduct(point - otherPoint).GetScalar(); - return penetration; -} -*/ - -dgVector dgCollisionLumpedMassParticles::CalculateContactNormalAndPenetration(const dgVector& worldPosition) const -{ - dgVector contactNormal(dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector otherPoint(worldPosition); - otherPoint.m_y = dgFloat32(0.0f); - dgVector point(worldPosition - contactNormal.Scale (m_particleRadius)); - contactNormal.m_w = contactNormal.DotProduct(otherPoint - point).GetScalar(); - - return contactNormal; -} - -void dgCollisionLumpedMassParticles::HandleCollision(dgFloat32 timestep, dgVector* const normalDir, dgVector* const normalAccel, dgFloat32* const frictionCoefficient) -{ - const dgMatrix& matrix = m_body->GetCollision()->GetGlobalMatrix(); - dgVector origin(matrix.m_posit); - - dgFloat32 coeficientOfFriction = dgFloat32(0.6f); - dgFloat32 coeficientOfPenetration = dgFloat32(0.1f); -coeficientOfPenetration *= 1.0f; - - dgVector timestepV(timestep); - dgFloat32 invTimeStep = dgFloat32 (1.0f) / timestep; - dgVector* const veloc = &m_veloc[0]; - const dgVector* const accel = &m_accel[0]; - const dgVector* const posit = &m_posit[0]; - const dgVector* const extAccel = &m_externalAccel[0]; - -static int xxx; -xxx ++; -//dgTrace (("%d %f %f\n", xxx, externAccel[0].m_y, veloc[0].m_y)); - - for (dgInt32 i = 0; i < m_particlesCount; i++) { - dgVector normal(dgVector::m_zero); - dgVector accel1(dgVector::m_zero); - dgVector tangent0(dgVector::m_zero); - dgVector tangent1(dgVector::m_zero); - - dgVector contactPosition(origin + posit[i]); - dgVector contactNormal(CalculateContactNormalAndPenetration (contactPosition)); - - dgFloat32 frictionCoef = dgFloat32(0.0f); - if (contactNormal.m_w > dgFloat32 (0.0f)) { - dgVector projectedVelocity(veloc[i] + timestepV * (accel[i] + extAccel[i])); - dgAssert (projectedVelocity.m_w == dgFloat32 (0.0f)); - dgFloat32 projectedNormalSpeed = contactNormal.DotProduct(projectedVelocity).GetScalar(); - if (projectedNormalSpeed < DG_MINIMIM_ZERO_SPEED) { - if (contactNormal.m_w > DG_MINIMIM_ZERO_SURFACE) { - normal = contactNormal & dgVector::m_triplexMask; - dgFloat32 penetration = dgClamp(contactNormal.m_w - DG_MINIMIM_ZERO_SURFACE, dgFloat32(0.0f), dgFloat32(0.125f)); - dgFloat32 s = dgFloat32 (2.0f) * invTimeStep * penetration; - dgFloat32 a = -s * invTimeStep; - veloc[i] += normal.Scale (s - veloc[i].DotProduct(normal).GetScalar()); - //dgVector penetrationSpeed(invTimeStep.Scale(coeficientOfPenetration * penetration)); - //dgVector normalSpeed(normal.DotProduct(veloc[i] * dgVector::m_negOne)); - //dgVector restoringSpeed(normalSpeed.GetMax(penetrationSpeed)); - //dgVector normalVelocity(normal * restoringSpeed); - //accel1 = invTimeStep * normalVelocity; - accel1 = normal.Scale(a); - frictionCoef = coeficientOfFriction; - } - } - } - - normalDir[i] = normal; - normalAccel[i] = accel1; - frictionCoefficient[i] = frictionCoef; - } -} - - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionLumpedMassParticles.h b/thirdparty/src/newton/dgPhysics/dgCollisionLumpedMassParticles.h deleted file mode 100644 index 7736ba5a6..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionLumpedMassParticles.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGCOLLISION_LUMPED_MASS_PARTICLES_H__ -#define __DGCOLLISION_LUMPED_MASS_PARTICLES_H__ - - -#include "dgCollision.h" -#include "dgCollisionConvex.h" - - -class dgCollisionLumpedMassParticles: public dgCollisionConvex -{ - public: - dgCollisionLumpedMassParticles (const dgCollisionLumpedMassParticles& source); - dgCollisionLumpedMassParticles (dgWorld* const world, dgCollisionID collisionID); - dgCollisionLumpedMassParticles (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionLumpedMassParticles(void); - - dgInt32 GetCount() const; - dgInt32 GetStrideInByte() const; - const dgVector* GetVelocity() const; - const dgVector* GetPositions() const; - const dgVector* GetAcceleration() const; - - dgDynamicBody* GetOwner () const; - void SetOwnerAndMassPraperties (dgDynamicBody* const body); - virtual void IntegrateForces (dgFloat32 timestep) = 0; - - protected: - virtual void FinalizeBuild(); - virtual dgInt32 CalculateSignature() const; - virtual void RegisterCollision(const dgBody* const otherBody); - virtual void SetCollisionBBox(const dgVector& p0, const dgVector& p1); - virtual void Serialize(dgSerialize callback, void* const userData) const; - virtual void CalcAABB(const dgMatrix& matrix, dgVector& p0, dgVector& p1) const; - virtual dgMatrix CalculateInertiaAndCenterOfMass(const dgMatrix& m_alignMatrix, const dgVector& localScale, const dgMatrix& matrix) const; - - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - dgFloat32 RayCast(const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const; - - //dgFloat32 CalculaleContactPenetration(const dgVector& point, const dgVector& normal) const; - dgVector CalculateContactNormalAndPenetration(const dgVector& worldPosition) const; - virtual void HandleCollision (dgFloat32 timestep, dgVector* const normalDir, dgVector* const normalAccel, dgFloat32* const frictionCoefficient); - - virtual dgInt32 GetMemoryBufferSizeInBytes() const = 0; - - dgArray<dgVector> m_posit; - dgArray<dgVector> m_veloc; - dgArray<dgVector> m_accel; - dgArray<dgVector> m_externalAccel; - dgArray<dgFloat32> m_mass; - dgArray<dgFloat32> m_invMass; - dgDynamicBody* m_body; - dgFloat32 m_totalMass; - dgFloat32 m_particleRadius; - dgInt32 m_particlesCount; - - friend class dgBroadPhase; - friend class dgDynamicBody; - friend class dgWorldDynamicUpdate; -}; - -inline dgDynamicBody* dgCollisionLumpedMassParticles::GetOwner () const -{ - return m_body; -} -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionMassSpringDamperSystem.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionMassSpringDamperSystem.cpp deleted file mode 100644 index 6e5ce0b44..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionMassSpringDamperSystem.cpp +++ /dev/null @@ -1,385 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgMeshEffect.h" -#include "dgDynamicBody.h" -#include "dgCollisionMassSpringDamperSystem.h" - - -dgCollisionMassSpringDamperSystem::dgCollisionMassSpringDamperSystem (dgWorld* const world, dgInt32 shapeID, dgInt32 pointCount, const dgFloat32* const points, dgInt32 strideInBytes, const dgFloat32* const pointsMasses, dgInt32 linksCount, const dgInt32* const links, const dgFloat32* const linksSpring, const dgFloat32* const LinksDamper) - :dgCollisionDeformableMesh(world, m_deformableSolidMesh) -{ - m_rtti |= dgCollisionMassSpringDamperSystem_RTTI; - - m_particlesCount = pointCount; - m_posit.Resize(m_particlesCount); - m_mass.Resize(m_particlesCount); - m_invMass.Resize(m_particlesCount); - const dgInt32 stride = strideInBytes / sizeof (dgFloat32); - m_totalMass = dgFloat32(0.0f); - for (dgInt32 i = 0; i < pointCount; i++) { - m_totalMass += m_totalMass; - m_mass[i] = pointsMasses[i]; - m_invMass[i] = dgFloat32(1.0f / pointsMasses[i]); - m_posit[i] = dgVector(points[i * stride + 0], points[i * stride + 1], points[i * stride + 2], dgFloat32(0.0f)); - } - - m_linksCount = linksCount; - m_linkList.Resize(linksCount); - for (dgInt32 i = 0; i < linksCount; i++) { - dgInt32 v0 = links[i * 2 + 0]; - dgInt32 v1 = links[i * 2 + 1]; - dgAssert(v0 != v1); - dgAssert(v0 >= 0); - dgAssert(v1 >= 0); - dgAssert(v0 < pointCount); - dgAssert(v1 < pointCount); - m_linkList[i].m_m0 = dgInt16(dgMin(v0, v1)); - m_linkList[i].m_m1 = dgInt16(dgMax(v0, v1)); - m_linkList[i].m_spring = linksSpring[i]; - m_linkList[i].m_damper = LinksDamper[i]; - - const dgVector& p0 = m_posit[v0]; - const dgVector& p1 = m_posit[v1]; - dgVector dp(p0 - p1); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - m_linkList[i].m_restlength = dgSqrt(dp.DotProduct(dp).GetScalar()); - dgAssert(m_linkList[i].m_restlength > dgFloat32(1.0e-2f)); - } - - FinalizeBuild(); -} - - -dgCollisionMassSpringDamperSystem::dgCollisionMassSpringDamperSystem(const dgCollisionMassSpringDamperSystem& source) - :dgCollisionDeformableMesh(source) -{ - m_rtti |= source.m_rtti; -} - -dgCollisionMassSpringDamperSystem::dgCollisionMassSpringDamperSystem(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionDeformableMesh(world, deserialization, userData, revisionNumber) -{ -} - -dgCollisionMassSpringDamperSystem::~dgCollisionMassSpringDamperSystem(void) -{ -} - -dgInt32 dgCollisionMassSpringDamperSystem::GetMemoryBufferSizeInBytes() const -{ - dgInt32 sizeInByte = 0; - sizeInByte += 3 * m_particlesCount * sizeof (dgVector); - sizeInByte += 1 * m_particlesCount * sizeof (dgFloat32); - return sizeInByte; -} - -#if 0 -void dgCollisionMassSpringDamperSystem::CalculateAcceleration(dgFloat32 timestep) -{ - // Ks is in [sec^-2] a spring constant unit acceleration, not a spring force acceleration. - // Kc is in [sec^-1] a damper constant unit velocity, not a damper force acceleration. - - dgInt32 iter = 4; - dgVector* const accel = &m_accel[0]; - dgVector* const veloc = &m_veloc[0]; - dgVector* const posit = &m_posit[0]; - dgVector* const extAccel = &m_externalAccel[0]; - const dgSpringDamperLink* const links = &m_linkList[0]; - - dgVector* const dx = dgAlloca(dgVector, m_linksCount); - dgVector* const dv = dgAlloca(dgVector, m_linksCount); - dgVector* const dpdv = dgAlloca(dgVector, m_linksCount); - - dgVector* const normalDir = dgAlloca(dgVector, m_particlesCount); - dgVector* const normalAccel = dgAlloca(dgVector, m_particlesCount); - dgFloat32* const spring_A01 = dgAlloca(dgFloat32, m_linksCount); - dgFloat32* const spring_B01 = dgAlloca(dgFloat32, m_linksCount); - dgFloat32* const frictionCoeffecient = dgAlloca(dgFloat32, m_particlesCount); - - // dgFloat32* const damper_A01 = dgAlloca(dgFloat32, m_linksCount); - // dgFloat32* const damper_B01 = dgAlloca(dgFloat32, m_linksCount); - // dgFloat32* const damper_C01 = dgAlloca(dgFloat32, m_linksCount); - // dgVector* const collisionDir1 = dgAlloca(dgVector, m_particlesCount); - // dgVector* const collisionDir2 = dgAlloca(dgVector, m_particlesCount); - // dgVector* const tmp1 = dgAlloca(dgVector, m_particlesCount); - // dgVector* const tmp2 = dgAlloca(dgVector, m_particlesCount); - // dgVector* const diag = dgAlloca(dgVector, m_particlesCount); - // dgVector* const offDiag = dgAlloca(dgVector, m_particlesCount); - - dgVector unitAccel(m_body->m_externalForce * Scale (m_body->m_invMass.m_w)); - dgVector deltaOmega(m_body->m_invWorldInertiaMatrix.RotateVector(m_body->m_externalTorque.Scale(timestep))); - - m_body->m_alpha = dgVector::m_zero; - m_body->m_omega = dgVector::m_zero; - m_body->m_externalForce = dgVector::m_zero; - m_body->m_externalTorque = dgVector::m_zero; - - // here I need to add all other external acceleration like wind and pressure, friction and collision. - for (dgInt32 i = 0; i < m_particlesCount; i++) { - extAccel[i] = unitAccel; - } - - //dgFloat32 ks_dt = -timestep * kSpring; - //dgFloat32 kd_dt0 = -timestep * kDamper; - //dgFloat32 kd_dt1 = -timestep * kDamper * dgFloat32(2.0f); - - dgVector dtRK4(timestep / iter); - dgVector epsilon(dgFloat32(1.0e-14f)); - - dtRK4 = dtRK4 & dgVector::m_triplexMask; - HandleCollision(timestep, normalDir, normalAccel, frictionCoeffecient); - for (dgInt32 k = 0; k < iter; k++) { - - for (dgInt32 i = 0; i < m_particlesCount; i++) { - accel[i] = dgVector::m_zero; - } - - for (dgInt32 i = 0; i < m_linksCount; i++) { - const dgInt32 j0 = links[i].m_m0; - const dgInt32 j1 = links[i].m_m1; - dv[i] = veloc[j0] - veloc[j1]; - dx[i] = posit[j0] - posit[j1]; - - const dgVector p0p1(dx[i]); - const dgVector v0v1(dv[i]); - const dgVector length2(p0p1.DotProduct(p0p1)); - const dgVector mask(length2 > m_smallestLenght2); - - const dgVector lenght2((length2 & mask) | length2.And__Not(mask)); - const dgFloat32 length = (lenght2.Sqrt()).GetScalar(); - const dgFloat32 den = dgFloat32(1.0f) / length; - const dgFloat32 lenghtRatio = links[i].m_restlength * den; - const dgFloat32 compression = dgFloat32(1.0f) - lenghtRatio; - const dgVector fs(p0p1.Scale(links[i].m_spring * compression)); - const dgVector fd(p0p1.Scale(links[i].m_damper * den * den * (v0v1.DotProduct(p0p1)).GetScalar())); - - dgAssert(fs.m_w == dgFloat32(0.0f)); - dgAssert(fs.m_w == dgFloat32(0.0f)); - dgAssert(p0p1.m_w == dgFloat32(0.0f)); - - dpdv[i] = p0p1 * v0v1; - accel[j0] -= (fs + fd); - accel[j1] += (fs + fd); - - dgFloat32 ks_dt = -dtRK4.GetScalar() * links[i].m_spring; - spring_A01[i] = ks_dt * compression; - spring_B01[i] = ks_dt * lenghtRatio * den * den; - } - - for (dgInt32 i = 0; i < m_linksCount; i++) { - const dgVector dv0(dv[i]); - const dgVector A01(spring_A01[i]); - const dgVector B01(spring_B01[i]); - const dgVector dfdx(A01 * dv0 + B01 * dx[i] * dpdv[i]); - - const dgInt32 j0 = links[i].m_m0; - const dgInt32 j1 = links[i].m_m1; - - dgAssert(dfdx.m_w == dgFloat32(0.0f)); - accel[j0] += dfdx; - accel[j1] -= dfdx; - } - - for (dgInt32 i = 0; i < m_particlesCount; i++) { - //dgVector dirAccel1 (collisionDir1[i] * accel[i].DotProduct(collisionDir1[i])); - //dgVector dirAccel2 (collisionDir2[i] * accel[i].DotProduct(collisionDir2[i])); - //tmp0[i] = accel[i] + collidingAccel[i] - dirAccel0 - dirAccel1 - dirAccel2; - - dgVector netAccel (accel[i] + extAccel[i]); - dgVector tangentDir(veloc[i] - normalDir[i] * normalDir[i].DotProduct(veloc[i])); - dgVector mag(tangentDir.DotProduct(tangentDir) + epsilon); - - dgFloat32 tangentFrictionAccel = dgAbs(netAccel.DotProduct(normalDir[i]).GetScalar()); - dgVector friction(tangentDir.Scale(frictionCoeffecient[i] * tangentFrictionAccel / dgSqrt(mag.GetScalar()))); - - //dgVector particleAccel (accel[i] + normalAccel[i] - normalDirAccel); - dgVector normalDirAccel(normalDir[i] * netAccel.DotProduct(normalDir[i])); - //accel[i] = accel[i] + normalAccel[i] - normalDirAccel - friction; - netAccel = netAccel + normalAccel[i] - normalDirAccel - friction; - veloc[i] += netAccel * dtRK4; - posit[i] += veloc[i] * dtRK4; - } - } -} - - -#else -void dgCollisionMassSpringDamperSystem::CalculateAcceleration(dgFloat32 timestep) -{ - // Ks is in [sec^-2] a spring constant unit acceleration, not a spring force acceleration. - // Kc is in [sec^-1] a damper constant unit velocity, not a damper force acceleration. - - dgInt32 iter = 4; - dgVector* const accel = &m_accel[0]; - dgVector* const veloc = &m_veloc[0]; - dgVector* const posit = &m_posit[0]; - dgVector* const extAccel = &m_externalAccel[0]; - const dgSpringDamperLink* const links = &m_linkList[0]; -/* - - dgVector* const dx = dgAlloca(dgVector, m_linksCount); - dgVector* const dv = dgAlloca(dgVector, m_linksCount); - dgVector* const dpdv = dgAlloca(dgVector, m_linksCount); - - dgVector* const normalDir = dgAlloca(dgVector, m_particlesCount); - dgVector* const normalAccel = dgAlloca(dgVector, m_particlesCount); - dgFloat32* const spring_A01 = dgAlloca(dgFloat32, m_linksCount); - dgFloat32* const spring_B01 = dgAlloca(dgFloat32, m_linksCount); - dgFloat32* const frictionCoeffecient = dgAlloca(dgFloat32, m_particlesCount); -*/ - // dgFloat32* const damper_A01 = dgAlloca(dgFloat32, m_linksCount); - // dgFloat32* const damper_B01 = dgAlloca(dgFloat32, m_linksCount); - // dgFloat32* const damper_C01 = dgAlloca(dgFloat32, m_linksCount); - // dgVector* const collisionDir1 = dgAlloca(dgVector, m_particlesCount); - // dgVector* const collisionDir2 = dgAlloca(dgVector, m_particlesCount); - // dgVector* const tmp1 = dgAlloca(dgVector, m_particlesCount); - // dgVector* const tmp2 = dgAlloca(dgVector, m_particlesCount); - // dgVector* const diag = dgAlloca(dgVector, m_particlesCount); - // dgVector* const offDiag = dgAlloca(dgVector, m_particlesCount); - //dgVector deltaOmega(m_body->m_invWorldInertiaMatrix.RotateVector(m_body->m_externalTorque.Scale(timestep))); - - dgWorld* const world = m_body->GetWorld(); - world->m_solverJacobiansMemory.ResizeIfNecessary(GetMemoryBufferSizeInBytes() + 1024); - - dgVector* const normalAccel = (dgVector*)&world->m_solverJacobiansMemory[0]; - dgVector* const normalDir = &normalAccel[m_particlesCount]; - dgVector* const diagonal = &normalDir[m_particlesCount]; - dgFloat32* const frictionCoeffecient = (dgFloat32*)&diagonal[m_particlesCount]; - - dgVector unitAccel(m_body->m_externalForce * dgVector(m_body->m_invMass.m_w)); - - // here I need to add all other external acceleration like wind and pressure, friction and collision. - for (dgInt32 i = 0; i < m_particlesCount; i++) { - extAccel[i] = unitAccel; - } - - dgAssert(m_body->IsRTTIType(dgBody::m_dynamicBodyRTTI)); - m_body->m_alpha = dgVector::m_zero; - m_body->m_omega = dgVector::m_zero; - m_body->m_externalForce = dgVector::m_zero; - m_body->m_externalTorque = dgVector::m_zero; - - //dgFloat32 ks_dt = -timestep * kSpring; - //dgFloat32 kd_dt0 = -timestep * kDamper; - //dgFloat32 kd_dt1 = -timestep * kDamper * dgFloat32(2.0f); - - //dgFloat32 dtRK4__ = timestep / iter; - dgVector dtRK4 (timestep / iter); - dgVector epsilon(dgFloat32(1.0e-14f)); - -// dtRK4 = dtRK4 & dgVector::m_triplexMask; - HandleCollision(timestep, normalDir, normalAccel, frictionCoeffecient); - for (dgInt32 k = 0; k < iter; k++) { - for (dgInt32 i = 0; i < m_particlesCount; i++) { - accel[i] = dgVector::m_zero; - diagonal[i] = dgVector::m_zero; - } -/* - for (dgInt32 i = 0; i < m_linksCount; i++) { - const dgInt32 j0 = links[i].m_m0; - const dgInt32 j1 = links[i].m_m1; - - const dgVector p0p1(posit[j0] - posit[j1]); - const dgVector v0v1(veloc[j0] - veloc[j1]); - const dgVector dpdv(p0p1 * v0v1); - - const dgVector mag2(p0p1.DotProduct(p0p1)); - const dgVector mask(mag2 > m_smallestLenght2); - - const dgVector lenght2((mag2 & mask) | mag2.And__Not(mask)); - const dgFloat32 length = (lenght2.Sqrt()).GetScalar(); - const dgFloat32 invDen = dgFloat32(1.0f) / length; - const dgFloat32 lenghtRatio = restLenght[i] * invDen; - const dgFloat32 compression = dgFloat32(1.0f) - lenghtRatio; - const dgVector fs(p0p1.Scale(kSpring * compression)); - const dgVector fd(p0p1.Scale(kDamper * invDen * invDen * (v0v1.DotProduct(p0p1)).GetScalar())); - const dgVector dfsdx(v0v1.Scale (ks_dt * compression) + ((p0p1 * dpdv).Scale (ks_dt * lenghtRatio * invDen * invDen))); - dgAssert(fs.m_w == dgFloat32(0.0f)); - dgAssert(fs.m_w == dgFloat32(0.0f)); - dgAssert(p0p1.m_w == dgFloat32(0.0f)); - dgAssert(dfsdx.m_w == dgFloat32(0.0f)); - - const dgVector nextAccel(fs + fd - dfsdx); - accel[j0] -= nextAccel; - accel[j1] += nextAccel; - } -*/ - - for (dgInt32 i = 0; i < m_linksCount; i++) { - const dgInt32 j0 = links[i].m_m0; - const dgInt32 j1 = links[i].m_m1; - const dgVector p0p1(posit[j0] - posit[j1]); - const dgVector v0v1(veloc[j0] - veloc[j1]); - const dgVector dvdp(v0v1 * p0p1); - - const dgVector p0p1Mag2(p0p1.DotProduct(p0p1)); - const dgVector p0p1Mask(p0p1Mag2 > m_smallestLenght2); - //const dgVector p0p1Lenght2((p0p1Mag2 & p0p1Mask) | m_smallestLenght2.AndNot(p0p1Mask)); - const dgVector p0p1Lenght2(m_smallestLenght2.Select (p0p1Mag2, p0p1Mask)); - - const dgFloat32 p0p1Length = p0p1Lenght2.Sqrt().GetScalar(); - const dgFloat32 p0p1InvMag = dgFloat32 (1.0f) / p0p1Length; - - const dgFloat32 k01 = -links[i].m_spring * (p0p1Length - links[i].m_restlength) * p0p1InvMag; - const dgFloat32 d01 = -links[i].m_damper * dvdp.GetScalar() * p0p1InvMag * p0p1InvMag; - const dgFloat32 h01dt = - dtRK4.GetScalar() * links[i].m_spring * links[i].m_restlength * p0p1InvMag * p0p1InvMag * p0p1InvMag; - - const dgVector diag ((p0p1 * p0p1).Scale(h01dt * dtRK4.GetScalar())); - - const dgFloat32 dtdfp0dx0 = h01dt * v0v1.DotProduct(p0p1).GetScalar(); - const dgVector netForce (p0p1.Scale(k01 + d01 + dtdfp0dx0)); - - - diagonal[j0] -= diag; - diagonal[j1] -= diag; - accel[j0] += netForce; - accel[j1] -= netForce; - } - - - for (dgInt32 i = 0; i < m_particlesCount; i++) { - //dgVector dirAccel1 (collisionDir1[i] * accel[i].DotProduct(collisionDir1[i])); - //dgVector dirAccel2 (collisionDir2[i] * accel[i].DotProduct(collisionDir2[i])); - //tmp0[i] = accel[i] + collidingAccel[i] - dirAccel0 - dirAccel1 - dirAccel2; - - dgVector netAccel (accel[i] + extAccel[i]); - dgVector tangentDir(veloc[i] - normalDir[i] * (normalDir[i].DotProduct(veloc[i]))); - dgVector mag(tangentDir.DotProduct(tangentDir) + epsilon); - - dgFloat32 tangentFrictionAccel = dgAbs(netAccel.DotProduct(normalDir[i]).GetScalar()); - dgVector friction(tangentDir.Scale(frictionCoeffecient[i] * tangentFrictionAccel / dgSqrt(mag.GetScalar()))); - - //dgVector particleAccel (accel[i] + normalAccel[i] - normalDirAccel); - dgVector normalDirAccel(normalDir[i] * (netAccel.DotProduct(normalDir[i]))); - //accel[i] = accel[i] + normalAccel[i] - normalDirAccel - friction; - netAccel = netAccel + normalAccel[i] - normalDirAccel - friction; - veloc[i] += netAccel * dtRK4; - posit[i] += veloc[i] * dtRK4; - } - } -} - -#endif \ No newline at end of file diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionMassSpringDamperSystem.h b/thirdparty/src/newton/dgPhysics/dgCollisionMassSpringDamperSystem.h deleted file mode 100644 index 324dc41e1..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionMassSpringDamperSystem.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGCOLLISION_DEFORMABLE_CLOTH_PATCH_MESH_H__ -#define __DGCOLLISION_DEFORMABLE_CLOTH_PATCH_MESH_H__ - - -#include "dgCollision.h" -#include "dgCollisionConvex.h" -#include "dgCollisionDeformableMesh.h" - - -class dgCollisionMassSpringDamperSystem: public dgCollisionDeformableMesh -{ - public: - dgCollisionMassSpringDamperSystem (const dgCollisionMassSpringDamperSystem& source); - dgCollisionMassSpringDamperSystem (dgWorld* const world, dgInt32 shapeID, dgInt32 pointCount, const dgFloat32* const points, dgInt32 strideInBytes, const dgFloat32* const pointsMasses, dgInt32 linksCount, const dgInt32* const links, const dgFloat32* const linksSpring, const dgFloat32* const LinksDamper); - dgCollisionMassSpringDamperSystem (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - - virtual ~dgCollisionMassSpringDamperSystem(void); - virtual void CalculateAcceleration(dgFloat32 timestep); - - dgInt32 GetMemoryBufferSizeInBytes() const; -}; - - - - - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionMesh.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionMesh.cpp deleted file mode 100644 index 177ecf8e2..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionMesh.cpp +++ /dev/null @@ -1,359 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgCollisionMesh.h" -#include "dgCollisionConvexPolygon.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -dgPolygonMeshDesc::dgPolygonMeshDesc(dgCollisionParamProxy& proxy, void* const userData) - :dgFastAABBInfo() - ,m_boxDistanceTravelInMeshSpace(dgFloat32 (0.0f)) - ,m_threadNumber(proxy.m_threadIndex) - ,m_faceCount(0) - ,m_vertexStrideInBytes(0) - ,m_skinThickness(proxy.m_skinThickness) - ,m_userData (userData) - ,m_objBody (proxy.m_body0) - ,m_polySoupBody(proxy.m_body1) - ,m_convexInstance(proxy.m_instance0) - ,m_polySoupInstance(proxy.m_instance1) - ,m_vertex(NULL) - ,m_faceIndexCount(NULL) - ,m_faceVertexIndex(NULL) - ,m_faceIndexStart(NULL) - ,m_hitDistance(NULL) - ,m_maxT(dgFloat32 (1.0f)) - ,m_doContinuesCollisionTest(proxy.m_continueCollision) -{ - dgAssert (m_polySoupInstance->IsType (dgCollision::dgCollisionMesh_RTTI)); - dgAssert (m_convexInstance->IsType (dgCollision::dgCollisionConvexShape_RTTI)); - - const dgMatrix& hullMatrix = m_convexInstance->GetGlobalMatrix(); - const dgMatrix& soupMatrix = m_polySoupInstance->GetGlobalMatrix(); - - dgMatrix& matrix = *this; - matrix = hullMatrix * soupMatrix.Inverse(); - dgMatrix convexMatrix (dgGetIdentityMatrix()); - - switch (m_polySoupInstance->GetScaleType()) - { - case dgCollisionInstance::m_unit: - { - break; - } - - case dgCollisionInstance::m_uniform: - { - const dgVector& invScale = m_polySoupInstance->GetInvScale(); - convexMatrix[0][0] = invScale.GetScalar(); - convexMatrix[1][1] = invScale.GetScalar(); - convexMatrix[2][2] = invScale.GetScalar(); - matrix.m_posit = matrix.m_posit * (invScale | dgVector::m_wOne); - break; - } - - case dgCollisionInstance::m_nonUniform: - { - const dgVector& invScale = m_polySoupInstance->GetInvScale(); - dgMatrix tmp (matrix[0] * invScale, matrix[1] * invScale, matrix[2] * invScale, dgVector::m_wOne); - convexMatrix = tmp * matrix.Inverse(); - convexMatrix.m_posit = dgVector::m_wOne; - matrix.m_posit = matrix.m_posit * (invScale | dgVector::m_wOne); - break; - } - - case dgCollisionInstance::m_global: - default: - { - dgAssert (0); - } - } - - dgMatrix fullMatrix (convexMatrix * matrix); - m_convexInstance->CalcAABB(fullMatrix, m_p0, m_p1); - - dgVector p0; - dgVector p1; - SetTransposeAbsMatrix(matrix); - m_convexInstance->CalcAABB(convexMatrix, p0, p1); - m_size = dgVector::m_half * (p1 - p0); - m_posit = matrix.TransformVector(dgVector::m_half * (p1 + p0)); - dgAssert (m_posit.m_w == dgFloat32 (1.0f)); -} - -void dgPolygonMeshDesc::SortFaceArray () -{ - dgInt32 stride = 8; - if (m_faceCount >= 8) { - dgInt32 stack[DG_MAX_COLLIDING_FACES][2]; - - stack[0][0] = 0; - stack[0][1] = m_faceCount - 1; - dgInt32 stackIndex = 1; - while (stackIndex) { - stackIndex --; - dgInt32 lo = stack[stackIndex][0]; - dgInt32 hi = stack[stackIndex][1]; - if ((hi - lo) > stride) { - dgInt32 i = lo; - dgInt32 j = hi; - dgFloat32 dist = m_hitDistance[(lo + hi) >> 1]; - do { - while (m_hitDistance[i] < dist) i ++; - while (m_hitDistance[j] > dist) j --; - - if (i <= j) { - dgSwap (m_hitDistance[i], m_hitDistance[j]); - dgSwap (m_faceIndexStart[i], m_faceIndexStart[j]); - dgSwap (m_faceIndexCount[i], m_faceIndexCount[j]); - i++; - j--; - } - } while (i <= j); - - if (i < hi) { - stack[stackIndex][0] = i; - stack[stackIndex][1] = hi; - stackIndex ++; - } - if (lo < j) { - stack[stackIndex][0] = lo; - stack[stackIndex][1] = j; - stackIndex ++; - } - dgAssert (stackIndex < dgInt32 (sizeof (stack) / (2 * sizeof (stack[0][0])))); - } - } - } - - stride = stride * 2; - if (m_faceCount < stride) { - stride = m_faceCount; - } - for (dgInt32 i = 1; i < stride; i ++) { - if (m_hitDistance[i] < m_hitDistance[0]) { - dgSwap (m_hitDistance[i], m_hitDistance[0]); - dgSwap (m_faceIndexStart[i], m_faceIndexStart[0]); - dgSwap (m_faceIndexCount[i], m_faceIndexCount[0]); - } - } - - for (dgInt32 i = 1; i < m_faceCount; i ++) { - dgInt32 j = i; - dgInt32 ptr = m_faceIndexStart[i]; - dgInt32 count = m_faceIndexCount[i]; - dgFloat32 dist = m_hitDistance[i]; - for ( ; dist < m_hitDistance[j - 1]; j --) { - dgAssert (j > 0); - m_hitDistance[j] = m_hitDistance [j-1]; - m_faceIndexStart[j] = m_faceIndexStart[j-1]; - m_faceIndexCount[j] = m_faceIndexCount[j-1]; - } - m_hitDistance[j] = dist; - m_faceIndexStart[j] = ptr; - m_faceIndexCount[j] = count; - } - -#ifdef _DEBUG - for (dgInt32 i = 0; i < m_faceCount - 1; i ++) { - dgAssert (m_hitDistance[i] <= m_hitDistance[i+1]); - } -#endif -} - - -dgCollisionMesh::dgCollisionMesh(dgWorld* const world, dgCollisionID type) - :dgCollision(world->GetAllocator(), 0, type) -{ - m_rtti |= dgCollisionMesh_RTTI; - m_debugCallback = NULL; - SetCollisionBBox (dgVector (dgFloat32 (0.0f)), dgVector (dgFloat32 (0.0f))); -} - -dgCollisionMesh::dgCollisionMesh (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollision(world, deserialization, userData, revisionNumber) -{ - dgAssert (m_rtti | dgCollisionMesh_RTTI); - - m_debugCallback = NULL; - SetCollisionBBox (dgVector (dgFloat32 (0.0f)), dgVector (dgFloat32 (0.0f))); -} - -dgCollisionMesh::~dgCollisionMesh() -{ -} - -void dgCollisionMesh::SetCollisionBBox (const dgVector& p0, const dgVector& p1) -{ - dgAssert (p0.m_x <= p1.m_x); - dgAssert (p0.m_y <= p1.m_y); - dgAssert (p0.m_z <= p1.m_z); - - m_boxSize = (p1 - p0).Scale (dgFloat32 (0.5f)) & dgVector::m_triplexMask; - m_boxOrigin = (p1 + p0).Scale (dgFloat32 (0.5f)) & dgVector::m_triplexMask; -} - -dgInt32 dgCollisionMesh::CalculateSignature () const -{ - dgAssert (0); - return 0; -} - - -dgInt32 dgCollisionMesh::CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const -{ - return 0; -} - -void dgCollisionMesh::SetDebugCollisionCallback (dgCollisionMeshCollisionCallback debugCallback) -{ - m_debugCallback = debugCallback; -} - - - - -#ifdef DG_DEBUG_AABB -dgVector dgCollisionMesh::BoxSupportMapping (const dgVector& dir) const -{ - return dgVector (dir.m_x < dgFloat32 (0.0f) ? m_p0.m_x : m_p1.m_x, - dir.m_y < dgFloat32 (0.0f) ? m_p0.m_y : m_p1.m_y, - dir.m_z < dgFloat32 (0.0f) ? m_p0.m_z : m_p1.m_z, dgFloat32 (0.0f)); -} -#endif - - - - -dgVector dgCollisionMesh::CalculateVolumeIntegral (const dgMatrix& globalMatrix, const dgVector& plane, const dgCollisionInstance& parentScale) const -{ - return dgVector (dgFloat32 (0.0f)); -} - - -void dgCollisionMesh::DebugCollision (const dgMatrix& matrixPtr, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - dgAssert (0); -} - - -dgFloat32 dgCollisionMesh::GetVolume () const -{ -// dgAssert (0); - return dgFloat32 (0.0f); -} - -dgFloat32 dgCollisionMesh::GetBoxMinRadius () const -{ - return dgFloat32 (0.0f); -} - -dgFloat32 dgCollisionMesh::GetBoxMaxRadius () const -{ - return dgFloat32 (0.0f); -} - - - -void dgCollisionMesh::GetCollisionInfo(dgCollisionInfo* const info) const -{ - dgAssert (0); - dgCollision::GetCollisionInfo(info); -// info->m_offsetMatrix = GetLocalMatrix(); -} - -void dgCollisionMesh::Serialize(dgSerialize callback, void* const userData) const -{ - dgAssert (0); -} - -dgVector dgCollisionMesh::SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgAssert (0); - return dgVector (0, 0, 0, 0); -} - - -void dgCollisionMesh::CalcAABB(const dgMatrix& matrix, dgVector &p0, dgVector &p1) const -{ - dgVector origin (matrix.TransformVector(m_boxOrigin)); - dgVector size (matrix.m_front.Abs().Scale(m_boxSize.m_x) + matrix.m_up.Abs().Scale(m_boxSize.m_y) + matrix.m_right.Abs().Scale(m_boxSize.m_z)); - - p0 = (origin - size) & dgVector::m_triplexMask; - p1 = (origin + size) & dgVector::m_triplexMask; -} - - -dgInt32 dgCollisionMesh::CalculatePlaneIntersection (const dgFloat32* const vertex, const dgInt32* const index, dgInt32 indexCount, dgInt32 stride, const dgPlane& localPlane, dgVector* const contactsOut) const -{ - dgInt32 count = 0; - dgInt32 j = index[indexCount - 1] * stride; - dgVector p0 (&vertex[j]); - p0 = p0 & dgVector::m_triplexMask; - dgFloat32 side0 = localPlane.Evalue (p0); - for (dgInt32 i = 0; i < indexCount; i ++) { - j = index[i] * stride; - dgVector p1 (&vertex[j]); - p1 = p1 & dgVector::m_triplexMask; - dgFloat32 side1 = localPlane.Evalue (p1); - - if (side0 < dgFloat32 (0.0f)) { - if (side1 >= dgFloat32 (0.0f)) { - dgVector dp (p1 - p0); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - dgFloat32 t = localPlane.DotProduct(dp).GetScalar(); - dgAssert (dgAbs (t) >= dgFloat32 (0.0f)); - if (dgAbs (t) < dgFloat32 (1.0e-8f)) { - t = dgSign(t) * dgFloat32 (1.0e-8f); - } - dgAssert (0); - contactsOut[count] = p0 - dp.Scale (side0 / t); - count ++; - - } - } else if (side1 <= dgFloat32 (0.0f)) { - dgVector dp (p1 - p0); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - dgFloat32 t = localPlane.DotProduct(dp).GetScalar(); - dgAssert (dgAbs (t) >= dgFloat32 (0.0f)); - if (dgAbs (t) < dgFloat32 (1.0e-8f)) { - t = dgSign(t) * dgFloat32 (1.0e-8f); - } - dgAssert (0); - contactsOut[count] = p0 - dp.Scale (side0 / t); - count ++; - } - - side0 = side1; - p0 = p1; - } - - return count; -} - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionMesh.h b/thirdparty/src/newton/dgPhysics/dgCollisionMesh.h deleted file mode 100644 index 3d11dd2ea..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionMesh.h +++ /dev/null @@ -1,220 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGCOLLISION_MESH_H__ -#define __DGCOLLISION_MESH_H__ - - -#include "dgCollision.h" -#include "dgCollisionConvex.h" -#include "dgCollisionInstance.h" - - -#define DG_MAX_COLLIDING_FACES 512 -#define DG_MAX_COLLIDING_INDICES (DG_MAX_COLLIDING_FACES * (4 * 2 + 3)) - - -class dgCollisionMesh; -typedef void (*dgCollisionMeshCollisionCallback) (const dgBody* const bodyWithTreeCollision, const dgBody* const body, dgInt32 faceID, - dgInt32 vertexCount, const dgFloat32* const vertex, dgInt32 vertexStrideInBytes); - - -DG_MSC_VECTOR_ALIGNMENT -class dgPolygonMeshDesc: public dgFastAABBInfo -{ - public: - class dgMesh - { - public: - dgInt32 m_globalFaceIndexCount[DG_MAX_COLLIDING_FACES]; - dgInt32 m_globalFaceIndexStart[DG_MAX_COLLIDING_FACES]; - dgFloat32 m_globalHitDistance[DG_MAX_COLLIDING_FACES]; - }; - - // colliding box in polygonSoup local space - DG_INLINE dgPolygonMeshDesc() - :dgFastAABBInfo() - ,m_boxDistanceTravelInMeshSpace(dgFloat32 (0.0f)) - ,m_maxT(dgFloat32 (1.0f)) - ,m_doContinuesCollisionTest(false) - { - } - - dgPolygonMeshDesc(dgCollisionParamProxy& proxy, void* const userData); - - DG_INLINE void SetDistanceTravel (const dgVector& distanceInGlobalSpace) - { - const dgMatrix& soupMatrix = m_polySoupInstance->GetGlobalMatrix(); - m_boxDistanceTravelInMeshSpace = m_polySoupInstance->GetInvScale() * soupMatrix.UnrotateVector(distanceInGlobalSpace * m_convexInstance->GetInvScale()); - if (m_boxDistanceTravelInMeshSpace.DotProduct(m_boxDistanceTravelInMeshSpace).GetScalar() < dgFloat32 (1.0e-2f)) { - m_doContinuesCollisionTest = false; - } - } - - DG_INLINE dgInt32 GetFaceIndexCount(dgInt32 indexCount) const - { - return indexCount * 2 + 3; - } - - DG_INLINE const dgInt32* GetAdjacentFaceEdgeNormalArray(const dgInt32* const faceIndexArray, dgInt32 indexCount) const - { - return &faceIndexArray[indexCount + 2]; - } - - - DG_INLINE dgInt32 GetNormalIndex(const dgInt32* const faceIndexArray, dgInt32 indexCount) const - { - return faceIndexArray[indexCount + 1]; - } - - DG_INLINE dgInt32 GetFaceId(const dgInt32* const faceIndexArray, dgInt32 indexCount) const - { - return faceIndexArray[indexCount]; - } - - DG_INLINE dgFloat32 GetFaceSize(const dgInt32* const faceIndexArray, dgInt32 indexCount) const - { - dgInt32 size = faceIndexArray[indexCount * 2 + 2]; - return dgFloat32 ((size >= 1) ? size : dgFloat32 (1.0f)); - } - - DG_INLINE dgFloat32 GetSeparetionDistance() const - { - return m_separationDistance[0] * m_polySoupInstance->GetScale().GetScalar(); - } - - - void SortFaceArray (); - - dgVector m_boxDistanceTravelInMeshSpace; - dgInt32 m_threadNumber; - dgInt32 m_faceCount; - dgInt32 m_vertexStrideInBytes; - dgFloat32 m_skinThickness; - void* m_userData; - dgBody *m_objBody; - dgBody *m_polySoupBody; - dgCollisionInstance* m_convexInstance; - dgCollisionInstance* m_polySoupInstance; - dgFloat32* m_vertex; - dgInt32* m_faceIndexCount; - dgInt32* m_faceVertexIndex; - - // private data; - dgInt32* m_faceIndexStart; - dgFloat32* m_hitDistance; - const dgCollisionMesh* m_me; - dgInt32 m_globalIndexCount; - dgFloat32 m_maxT; - bool m_doContinuesCollisionTest; - dgInt32 m_globalFaceVertexIndex[DG_MAX_COLLIDING_INDICES]; - dgMesh m_meshData; -} DG_GCC_VECTOR_ALIGNMENT; - -DG_MSC_VECTOR_ALIGNMENT -class dgCollisionMeshRayHitDesc -{ - public: - dgCollisionMeshRayHitDesc () - :m_matrix (dgGetIdentityMatrix()) - { - } - - dgVector m_localP0; - dgVector m_localP1; - dgVector m_normal; - dgUnsigned64 m_userId; - void* m_userData; - void* m_altenateUserData; - dgMatrix m_matrix; -}DG_GCC_VECTOR_ALIGNMENT; - - - -class dgCollisionMesh: public dgCollision -{ - public: - - DG_MSC_VECTOR_ALIGNMENT - class dgMeshVertexListIndexList - { - public: - dgInt32* m_indexList; - dgInt32* m_userDataList; - dgFloat32* m_veterxArray; - dgInt32 m_triangleCount; - dgInt32 m_maxIndexCount; - dgInt32 m_vertexCount; - dgInt32 m_vertexStrideInBytes; - }DG_GCC_VECTOR_ALIGNMENT; - - - dgCollisionMesh (dgWorld* const world, dgCollisionID type); - dgCollisionMesh (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionMesh(); - - virtual dgFloat32 GetVolume () const; - virtual dgFloat32 GetBoxMinRadius () const; - virtual dgFloat32 GetBoxMaxRadius () const; - virtual void GetVertexListIndexList (const dgVector& p0, const dgVector& p1, dgMeshVertexListIndexList &data) const = 0; - - virtual void GetCollidingFaces (dgPolygonMeshDesc* const data) const = 0; - - void SetDebugCollisionCallback (dgCollisionMeshCollisionCallback debugCallback); - dgCollisionMeshCollisionCallback GetDebugCollisionCallback() const { return m_debugCallback;} - - protected: - virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1); - - private: - virtual dgInt32 CalculateSignature () const; - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - - virtual void CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const; - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - - virtual dgVector CalculateVolumeIntegral (const dgMatrix& globalMatrix, const dgVector& plane, const dgCollisionInstance& parentScale) const; - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const = 0; - - dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const; - dgInt32 CalculatePlaneIntersection (const dgFloat32* const vertex, const dgInt32* const index, dgInt32 indexCount, dgInt32 strideInFloat, const dgPlane& localPlane, dgVector* const contactsOut) const; - - - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - virtual void Serialize(dgSerialize callback, void* const userData) const; - - -#ifdef DG_DEBUG_AABB - dgVector BoxSupportMapping (const dgVector& dir) const; -#endif - - protected: - dgCollisionMeshCollisionCallback m_debugCallback; - - - friend class dgWorld; - friend class dgCollisionInstance; -}; - - - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionNull.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionNull.cpp deleted file mode 100644 index 1f9af6088..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionNull.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgContact.h" -#include "dgCollisionNull.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -dgCollisionNull::dgCollisionNull(dgMemoryAllocator* const allocator, dgUnsigned32 signature) - :dgCollisionConvex(allocator, signature, m_nullCollision) -{ - m_rtti |= dgCollisionNull_RTTI; - m_inertia = dgVector (dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)); -} - -dgCollisionNull::dgCollisionNull(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionConvex (world, deserialization, userData, revisionNumber) -{ - m_rtti |= dgCollisionNull_RTTI; -} - -void dgCollisionNull::Serialize(dgSerialize callback, void* const userData) const -{ - SerializeLow(callback, userData); -} - -dgCollisionNull::~dgCollisionNull() -{ -} - -void dgCollisionNull::SetCollisionBBox (const dgVector& p0, const dgVector& p1) -{ - dgAssert (0); -} - -void dgCollisionNull::DebugCollision (const dgMatrix& matrixPtr, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ -} - -dgInt32 dgCollisionNull::CalculateSignature () const -{ - return dgInt32 (GetSignature()); -} - -void dgCollisionNull::CalcAABB (const dgMatrix& matrix, dgVector &p0, dgVector &p1) const -{ - p0 = matrix[3] & dgVector::m_triplexMask; - p1 = matrix[3] & dgVector::m_triplexMask; -} - -dgVector dgCollisionNull::SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgAssert (0); - return dgVector::m_zero; -} - -dgVector dgCollisionNull::SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - dgAssert(0); - return dgVector::m_zero; -} - -dgFloat32 dgCollisionNull::GetVolume () const -{ - return dgFloat32 (0.0f); -} - -dgFloat32 dgCollisionNull::RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const -{ - return dgFloat32 (1.2f); -} - - -dgVector dgCollisionNull::CalculateVolumeIntegral (const dgMatrix& globalMatrix, const dgVector& plane, const dgCollisionInstance& parentScale) const -{ - dgAssert (0); - return dgVector::m_zero; -} - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionNull.h b/thirdparty/src/newton/dgPhysics/dgCollisionNull.h deleted file mode 100644 index ca527f10f..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionNull.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _dgCollisionNull_H__ -#define _dgCollisionNull_H__ - - -#include "dgCollisionConvex.h" - -class dgCollisionNull: public dgCollisionConvex -{ - public: - dgCollisionNull(dgMemoryAllocator* const allocator, dgUnsigned32 signature); - dgCollisionNull(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionNull(); - - - protected: - virtual dgFloat32 GetVolume () const; - virtual void CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const; - - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; - - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - - virtual dgVector CalculateVolumeIntegral (const dgMatrix& globalMatrix, const dgVector& plane, const dgCollisionInstance& parentScale) const; - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const; - - private: - virtual dgInt32 CalculateSignature () const; - virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1); - - virtual void Serialize(dgSerialize callback, void* const userData) const; - - - friend class dgWorld; -}; - - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionScene.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionScene.cpp deleted file mode 100644 index c6444f2ae..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionScene.cpp +++ /dev/null @@ -1,399 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgIntersections.h" -#include "dgCollisionScene.h" -#include "dgCollisionInstance.h" - - -dgCollisionScene::dgCollisionScene (dgWorld* const world) - :dgCollisionCompound(world) -{ - m_collisionId = m_sceneCollision; - m_rtti |= dgCollisionScene_RTTI; -} - -dgCollisionScene::dgCollisionScene (const dgCollisionScene& source, const dgCollisionInstance* const myInstance) - :dgCollisionCompound(source, myInstance) -{ - m_rtti |= dgCollisionScene_RTTI; -} - -dgCollisionScene::dgCollisionScene (dgWorld* const world, dgDeserialize deserialization, void* const userData, const dgCollisionInstance* const myInstance, dgInt32 revisionNumber) - :dgCollisionCompound(world, deserialization, userData, myInstance, revisionNumber) -{ - dgAssert (m_rtti | dgCollisionScene_RTTI); -} - -dgCollisionScene::~dgCollisionScene() -{ -} - -dgFloat32 dgCollisionScene::GetBoxMinRadius () const -{ - return dgFloat32 (0.0f); -} - -dgFloat32 dgCollisionScene::GetBoxMaxRadius () const -{ - return dgFloat32 (0.0f); -} - - -void dgCollisionScene::MassProperties () -{ - m_inertia = dgVector::m_zero; - m_centerOfMass = dgVector::m_zero; - m_crossInertia = dgVector::m_zero; -} - -void dgCollisionScene::CollidePair (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - const dgNodeBase* stackPool[DG_COMPOUND_STACK_DEPTH]; - - dgAssert (proxy.m_contactJoint == pair->m_contact); - dgContact* const contactJoint = pair->m_contact; - dgBody* const otherBody = contactJoint->GetBody0(); - dgBody* const sceneBody = contactJoint->GetBody1(); - dgAssert (sceneBody->GetCollision()->GetChildShape() == this); - dgAssert (sceneBody->GetCollision()->IsType(dgCollision::dgCollisionScene_RTTI)); - - dgCollisionInstance* const sceneInstance = sceneBody->m_collision; - dgCollisionInstance* const otherInstance = otherBody->m_collision; - - dgAssert (sceneInstance->GetChildShape() == this); - dgAssert (otherInstance->IsType (dgCollision::dgCollisionConvexShape_RTTI)); - - const dgContactMaterial* const material = contactJoint->GetMaterial(); - - const dgMatrix& myMatrix = sceneInstance->GetGlobalMatrix(); - const dgMatrix& otherMatrix = otherInstance->GetGlobalMatrix(); - dgMatrix matrix (otherMatrix * myMatrix.Inverse()); - - const dgVector& hullVeloc = otherBody->m_veloc; - dgAssert (hullVeloc.m_w == dgFloat32 (0.0f)); - dgFloat32 baseLinearSpeed = dgSqrt (hullVeloc.DotProduct(hullVeloc).GetScalar()); - - dgFloat32 timestep = pair->m_timestep; - dgFloat32 closestDist = dgFloat32 (1.0e10f); - dgFloat32 separatingDist = dgFloat32 (1.0e10f); - if (proxy.m_continueCollision && (baseLinearSpeed > dgFloat32 (1.0e-6f))) { - dgVector p0; - dgVector p1; - otherInstance->CalcAABB (matrix, p0, p1); - - const dgVector& hullOmega = otherBody->m_omega; - dgAssert (hullOmega.m_w == dgFloat32 (0.0f)); - - dgFloat32 minRadius = otherInstance->GetBoxMinRadius(); - dgFloat32 maxAngularSpeed = dgSqrt (hullOmega.DotProduct(hullOmega).GetScalar()); - dgFloat32 angularSpeedBound = maxAngularSpeed * (otherInstance->GetBoxMaxRadius() - minRadius); - - dgFloat32 upperBoundSpeed = baseLinearSpeed + dgSqrt (angularSpeedBound); - dgVector upperBoundVeloc (hullVeloc.Scale (proxy.m_timestep * upperBoundSpeed / baseLinearSpeed)); - - dgVector boxDistanceTravelInMeshSpace (myMatrix.UnrotateVector(upperBoundVeloc * otherInstance->m_invScale)); - - dgInt32 stack = 1; - stackPool[0] = m_root; - dgFastRayTest ray (dgVector (dgFloat32 (0.0f)), boxDistanceTravelInMeshSpace); - - dgFloat32 maxParam = proxy.m_timestep; - while (stack) { - stack--; - const dgNodeBase* const me = stackPool[stack]; - dgAssert (me); - - if (me->BoxIntersect (ray, p0, p1)) { - if (me->m_type == m_leaf) { - dgAssert (!me->m_right); - bool processContacts = true; - if (material->m_compoundAABBOverlap) { - //processContacts = material->m_compoundAABBOverlap (*material, sceneBody, me->m_myNode, otherBody, NULL, proxy.m_threadIndex); - processContacts = material->m_compoundAABBOverlap(*contactJoint, timestep, sceneBody, me->m_myNode, otherBody, NULL, proxy.m_threadIndex); - } - - if (processContacts) { - const dgCollisionInstance* const myInstance = me->GetShape(); - dgCollisionInstance childInstance (*myInstance, myInstance->GetChildShape()); - childInstance.SetGlobalMatrix(childInstance.GetLocalMatrix() * myMatrix); - proxy.m_instance1 = &childInstance; - dgInt32 count = pair->m_contactCount; - - proxy.m_timestep = maxParam; - m_world->SceneChildContacts (pair, proxy); - // remember to update separating distance - //data.m_separatingDistance = dgMin(proxy.m_contactJoint->m_separationDistance, data.m_separatingDistance); - separatingDist = dgMin(proxy.m_contactJoint->m_separationDistance, separatingDist); - dgFloat32 param = proxy.m_timestep; - dgAssert(param >= dgFloat32(0.0f)); - if (param < maxParam) { - maxParam = param; - } - - if (pair->m_contactCount > count) { - dgContactPoint* const buffer = proxy.m_contacts; - for (dgInt32 i = count; i < pair->m_contactCount; i ++) { - dgAssert (buffer[i].m_collision0 == proxy.m_instance0); - if (buffer[i].m_collision1->GetChildShape() == myInstance->GetChildShape()) { - buffer[i].m_collision1 = myInstance; - } - } - } - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - } - - } else { - dgAssert (me->m_type == m_node); - stackPool[stack] = me->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack] = me->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - } - } - } - - proxy.m_timestep = maxParam; - } else { - dgVector size; - dgVector origin; - - otherInstance->CalcObb(origin, size); - dgOOBBTestData data (matrix, origin, size); - dgInt32 stack = 1; - stackPool[0] = m_root; - while (stack) { - - stack --; - const dgNodeBase* const me = stackPool[stack]; - dgAssert (me); - - if (me->BoxTest (data)) { - if (me->m_type == m_leaf) { - dgAssert (!me->m_right); - bool processContacts = true; - if (material->m_compoundAABBOverlap) { - processContacts = material->m_compoundAABBOverlap (*contactJoint, timestep, sceneBody, me->m_myNode, otherBody, NULL, proxy.m_threadIndex); - } - - if (processContacts) { - const dgCollisionInstance* const myInstance = me->GetShape(); - dgCollisionInstance childInstance (*myInstance, myInstance->GetChildShape()); - childInstance.SetGlobalMatrix(childInstance.GetLocalMatrix() * myMatrix); - proxy.m_instance1 = &childInstance; - dgInt32 count = pair->m_contactCount; - m_world->SceneChildContacts (pair, proxy); - data.m_separatingDistance = dgMin(proxy.m_contactJoint->m_separationDistance, data.m_separatingDistance); - if (pair->m_contactCount > count) { - dgContactPoint* const buffer = proxy.m_contacts; - for (dgInt32 i = count; i < pair->m_contactCount; i ++) { - dgAssert (buffer[i].m_collision0 == proxy.m_instance0); - if (buffer[i].m_collision1->GetChildShape() == myInstance->GetChildShape()) { - buffer[i].m_collision1 = myInstance; - } - } - } else if (pair->m_contactCount == -1) { - break; - } - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - } - - } else { - dgAssert (me->m_type == m_node); - stackPool[stack] = me->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack] = me->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - } - } - } - separatingDist = dgMin (separatingDist, data.m_separatingDistance); - } - contactJoint->m_closestDistance = closestDist; - contactJoint->m_separationDistance = separatingDist; -} - - -void dgCollisionScene::CollideCompoundPair (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - const dgNodeBase* stackPool[4 * DG_COMPOUND_STACK_DEPTH][2]; - - dgContact* const contactJoint = pair->m_contact; - dgBody* const myBody = contactJoint->GetBody1(); - dgBody* const otherBody = contactJoint->GetBody0(); - - dgAssert (myBody == proxy.m_body1); - dgAssert (otherBody == proxy.m_body0); - - dgCollisionInstance* const myCompoundInstance = myBody->m_collision; - dgCollisionInstance* const otherCompoundInstance = otherBody->m_collision; - - dgAssert (myCompoundInstance->GetChildShape() == this); - dgAssert (otherCompoundInstance->IsType (dgCollision::dgCollisionCompound_RTTI)); - dgCollisionCompound* const otherCompound = (dgCollisionCompound*)otherCompoundInstance->GetChildShape(); - - const dgContactMaterial* const material = contactJoint->GetMaterial(); - - dgMatrix myMatrix (myCompoundInstance->GetLocalMatrix() * myBody->m_matrix); - dgMatrix otherMatrix (otherCompoundInstance->GetLocalMatrix() * otherBody->m_matrix); - dgOOBBTestData data (otherMatrix * myMatrix.Inverse()); - - dgInt32 stack = 1; - stackPool[0][0] = m_root; - stackPool[0][1] = otherCompound->m_root; - - const dgVector& hullVeloc = otherBody->m_veloc; - dgAssert (hullVeloc.m_w == dgFloat32 (0.0f)); - dgFloat32 baseLinearSpeed = dgSqrt (hullVeloc.DotProduct(hullVeloc).GetScalar()); - - dgFloat32 timestep = pair->m_timestep; - dgFloat32 closestDist = dgFloat32 (1.0e10f); - dgFloat32 separatingDist = dgFloat32 (1.0e10f); -// if (proxy.m_continueCollision && (baseLinearSpeed > dgFloat32 (1.0e-6f))) { -// dgAssert (0); -// } else { -if (proxy.m_continueCollision && (baseLinearSpeed > dgFloat32 (1.0e-6f))) { -dgTrace (("Warning scene continue collision not implemented, using descrete collision instead\n")); -} - - - while (stack) { - stack --; - const dgNodeBase* const me = stackPool[stack][0]; - const dgNodeBase* const other = stackPool[stack][1]; - - dgAssert (me && other); - - if (me->BoxTest (data, other)) { - - if ((me->m_type == m_leaf) && (other->m_type == m_leaf)) { - dgAssert (!me->m_right); - - bool processContacts = true; - if (material->m_compoundAABBOverlap) { - processContacts = material->m_compoundAABBOverlap (*contactJoint, timestep, myBody, me->m_myNode, otherBody, other->m_myNode, proxy.m_threadIndex); - } - - if (processContacts) { - const dgCollisionInstance* const mySrcInstance = me->GetShape(); - const dgCollisionInstance* const otherSrcInstance = other->GetShape(); - dgCollisionInstance childInstance (*me->GetShape(), me->GetShape()->GetChildShape()); - dgCollisionInstance otherInstance (*other->GetShape(), other->GetShape()->GetChildShape()); - - childInstance.SetGlobalMatrix(childInstance.GetLocalMatrix() * myMatrix); - otherInstance.SetGlobalMatrix(otherInstance.GetLocalMatrix() * otherMatrix); - proxy.m_instance1 = &childInstance; - proxy.m_instance0 = &otherInstance; - - dgInt32 count = pair->m_contactCount; - m_world->SceneChildContacts (pair, proxy); - if (pair->m_contactCount > count) { - dgContactPoint* const buffer = proxy.m_contacts; - for (dgInt32 i = count; i < pair->m_contactCount; i ++) { - if (buffer[i].m_collision1->GetChildShape() == otherSrcInstance->GetChildShape()) { - dgAssert(buffer[i].m_collision0->GetChildShape() == mySrcInstance->GetChildShape()); - buffer[i].m_collision0 = mySrcInstance; - buffer[i].m_collision1 = otherSrcInstance; - } else { - dgAssert(buffer[i].m_collision1->GetChildShape() == mySrcInstance->GetChildShape()); - buffer[i].m_collision1 = mySrcInstance; - buffer[i].m_collision0 = otherSrcInstance; - } - } - } - - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - data.m_separatingDistance = dgMin(proxy.m_contactJoint->m_separationDistance, data.m_separatingDistance); - } - - } else if (me->m_type == m_leaf) { - dgAssert (other->m_type == m_node); - - stackPool[stack][0] = me; - stackPool[stack][1] = other->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me; - stackPool[stack][1] = other->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - - } else if (other->m_type == m_leaf) { - dgAssert (me->m_type == m_node); - - stackPool[stack][0] = me->m_left; - stackPool[stack][1] = other; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me->m_right; - stackPool[stack][1] = other; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - } else { - dgAssert (me->m_type == m_node); - dgAssert (other->m_type == m_node); - - stackPool[stack][0] = me->m_left; - stackPool[stack][1] = other->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me->m_left; - stackPool[stack][1] = other->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me->m_right; - stackPool[stack][1] = other->m_left; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - - stackPool[stack][0] = me->m_right; - stackPool[stack][1] = other->m_right; - stack++; - dgAssert (stack < dgInt32 (sizeof (stackPool) / sizeof (dgNodeBase*))); - } - } - } - separatingDist = dgMin (separatingDist, data.m_separatingDistance); -// } - contactJoint->m_closestDistance = closestDist; - contactJoint->m_separationDistance = separatingDist; -} - - -void dgCollisionScene::Serialize(dgSerialize callback, void* const userData) const -{ - dgCollisionCompound::Serialize(callback, userData); -} \ No newline at end of file diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionScene.h b/thirdparty/src/newton/dgPhysics/dgCollisionScene.h deleted file mode 100644 index 1474f9480..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionScene.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DGCOLLISIONSCENE_H_ -#define _DGCOLLISIONSCENE_H_ - - -#include "dgCollision.h" -#include "dgCollisionCompound.h" - - -class dgCollisionScene: public dgCollisionCompound -{ - public: - dgCollisionScene(dgWorld* const world); - dgCollisionScene (const dgCollisionScene& source, const dgCollisionInstance* const myInstance); - dgCollisionScene(dgWorld* const world, dgDeserialize deserialization, void* const userData, const dgCollisionInstance* const myInstance, dgInt32 revisionNumber); - virtual ~dgCollisionScene(); - - void CollidePair (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - void CollideCompoundPair (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - virtual void MassProperties (); - virtual void Serialize(dgSerialize callback, void* const userData) const; - - dgFloat32 GetBoxMinRadius () const; - dgFloat32 GetBoxMaxRadius () const; -}; - -#endif diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionSphere.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionSphere.cpp deleted file mode 100644 index 0640beab0..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionSphere.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgCollisionSphere.h" -#include "dgCollisionConvexPolygon.h" - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -#define DG_SPHERE_EDGE_COUNT 96 - -dgInt32 dgCollisionSphere::m_shapeRefCount = 0; -dgVector dgCollisionSphere::m_unitSphere[DG_SPHERE_VERTEX_COUNT]; -dgCollisionConvex::dgConvexSimplexEdge dgCollisionSphere::m_edgeArray[DG_SPHERE_EDGE_COUNT]; - -dgCollisionSphere::dgCollisionSphere(dgMemoryAllocator* const allocator, dgUnsigned32 signature, dgFloat32 radii) - :dgCollisionConvex(allocator, signature, m_sphereCollision) -{ - Init (radii, allocator); -} - -dgCollisionSphere::dgCollisionSphere(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionConvex (world, deserialization, userData, revisionNumber) -{ - dgFloat32 radios; - deserialization (userData, &radios, sizeof (radios)); - Init (radios, world->GetAllocator()); -} - -dgCollisionSphere::~dgCollisionSphere() -{ - m_shapeRefCount --; - dgAssert (m_shapeRefCount >= 0); - - dgCollisionConvex::m_simplex = NULL; - dgCollisionConvex::m_vertex = NULL; -} - - -void dgCollisionSphere::Init (dgFloat32 radius, dgMemoryAllocator* allocator) -{ - m_rtti |= dgCollisionSphere_RTTI; - m_radius = dgMax (dgAbs (radius), D_MIN_CONVEX_SHAPE_SIZE); - - m_edgeCount = DG_SPHERE_EDGE_COUNT; - m_vertexCount = DG_SPHERE_VERTEX_COUNT; - dgCollisionConvex::m_vertex = m_vertex; - - if (!m_shapeRefCount) { - - dgInt32 indexList[256]; - dgVector tmpVectex[256]; - - dgVector p0 ( dgFloat32 (1.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector p1 (-dgFloat32 (1.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector p2 ( dgFloat32 (0.0f), dgFloat32 (1.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector p3 ( dgFloat32 (0.0f),-dgFloat32 (1.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector p4 ( dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)); - dgVector p5 ( dgFloat32 (0.0f), dgFloat32 (0.0f),-dgFloat32 (1.0f), dgFloat32 (0.0f)); - - dgInt32 index = 1; - dgInt32 count = 0; - TesselateTriangle (index, p4, p0, p2, count, tmpVectex); - TesselateTriangle (index, p4, p2, p1, count, tmpVectex); - TesselateTriangle (index, p4, p1, p3, count, tmpVectex); - TesselateTriangle (index, p4, p3, p0, count, tmpVectex); - TesselateTriangle (index, p5, p2, p0, count, tmpVectex); - TesselateTriangle (index, p5, p1, p2, count, tmpVectex); - TesselateTriangle (index, p5, p3, p1, count, tmpVectex); - TesselateTriangle (index, p5, p0, p3, count, tmpVectex); - - //dgAssert (count == EDGE_COUNT); - dgInt32 vertexCount = dgVertexListToIndexList (&tmpVectex[0].m_x, sizeof (dgVector), 3 * sizeof (dgFloat32), 0, count, indexList, 0.001f); - - dgAssert (vertexCount == DG_SPHERE_VERTEX_COUNT); - for (dgInt32 i = 0; i < vertexCount; i ++) { - m_unitSphere[i] = tmpVectex[i]; - } - dgPolyhedra polyhedra(m_allocator); - - polyhedra.BeginFace(); - for (dgInt32 i = 0; i < count; i += 3) { -#ifdef _DEBUG - dgEdge* const edge = polyhedra.AddFace (indexList[i], indexList[i + 1], indexList[i + 2]); - dgAssert (edge); -#else - polyhedra.AddFace (indexList[i], indexList[i + 1], indexList[i + 2]); -#endif - } - polyhedra.EndFace(); - - dgUnsigned64 i1 = 0; - dgPolyhedra::Iterator iter (polyhedra); - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - edge->m_userData = i1; - i1 ++; - } - - for (iter.Begin(); iter; iter ++) { - dgEdge* const edge = &(*iter); - - dgConvexSimplexEdge* const ptr = &m_edgeArray[edge->m_userData]; - - ptr->m_vertex = edge->m_incidentVertex; - ptr->m_next = &m_edgeArray[edge->m_next->m_userData]; - ptr->m_prev = &m_edgeArray[edge->m_prev->m_userData]; - ptr->m_twin = &m_edgeArray[edge->m_twin->m_userData]; - } - } - - for (dgInt32 i = 0; i < DG_SPHERE_VERTEX_COUNT; i ++) { - m_vertex[i] = m_unitSphere[i].Scale (m_radius); - } - - m_shapeRefCount ++; - dgCollisionConvex::m_simplex = m_edgeArray; - SetVolumeAndCG (); -} - -dgVector dgCollisionSphere::SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgAssert (dir.m_w == dgFloat32 (0.0f)); - dgAssert (dgAbs(dir.DotProduct(dir).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f)); - dgAssert (dir.m_w == 0.0f); - return dir.Scale (m_radius); -} - -void dgCollisionSphere::TesselateTriangle (dgInt32 level, const dgVector& p0, const dgVector& p1, const dgVector& p2, dgInt32& count, dgVector* const ouput) const -{ - if (level) { - dgAssert (dgAbs (p0.DotProduct(p0).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-4f)); - dgAssert (dgAbs (p1.DotProduct(p1).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-4f)); - dgAssert (dgAbs (p2.DotProduct(p2).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-4f)); - dgVector p01 (p0 + p1); - dgVector p12 (p1 + p2); - dgVector p20 (p2 + p0); - - //p01 = p01 * p01.InvMagSqrt(); - //p12 = p12 * p12.InvMagSqrt(); - //p20 = p20 * p20.InvMagSqrt(); - - p01 = p01.Normalize(); - p12 = p12.Normalize(); - p20 = p20.Normalize(); - - dgAssert (dgAbs (p01.DotProduct(p01).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-4f)); - dgAssert (dgAbs (p12.DotProduct(p12).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-4f)); - dgAssert (dgAbs (p20.DotProduct(p20).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-4f)); - - TesselateTriangle (level - 1, p0, p01, p20, count, ouput); - TesselateTriangle (level - 1, p1, p12, p01, count, ouput); - TesselateTriangle (level - 1, p2, p20, p12, count, ouput); - TesselateTriangle (level - 1, p01, p12, p20, count, ouput); - - } else { - ouput[count ++] = p0; - ouput[count ++] = p1; - ouput[count ++] = p2; - } -} - -void dgCollisionSphere::SetCollisionBBox (const dgVector& p0__, const dgVector& p1__) -{ - dgAssert (0); -} - -dgInt32 dgCollisionSphere::CalculateSignature (dgFloat32 radius) -{ - dgUnsigned32 buffer[2]; - radius = dgAbs (radius); - - buffer[0] = m_sphereCollision; - buffer[1] = Quantize (radius); - return Quantize(buffer, sizeof (buffer)); -} - -dgInt32 dgCollisionSphere::CalculateSignature () const -{ - return CalculateSignature(m_radius); -} - -void dgCollisionSphere::CalcAABB (const dgMatrix& matrix, dgVector &p0, dgVector &p1) const -{ - dgVector size (matrix.m_front.Abs().Scale(m_radius) + matrix.m_up.Abs().Scale(m_radius) + matrix.m_right.Abs().Scale(m_radius)); - p0 = (matrix[3] - size) & dgVector::m_triplexMask; - p1 = (matrix[3] + size) & dgVector::m_triplexMask; -} - -dgInt32 dgCollisionSphere::CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const -{ - dgAssert (normal.m_w == 0.0f); - dgAssert (normal.DotProduct(normal).GetScalar() > dgFloat32 (0.999f)); - contactsOut[0] = normal * normal.DotProduct(point); - return 1; -} - -void dgCollisionSphere::DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ - dgTriplex pool[1024 * 2]; - dgVector tmpVectex[1024 * 2]; - - dgVector p0 ( dgFloat32 (1.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector p1 (-dgFloat32 (1.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector p2 ( dgFloat32 (0.0f), dgFloat32 (1.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector p3 ( dgFloat32 (0.0f),-dgFloat32 (1.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - dgVector p4 ( dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (1.0f), dgFloat32 (0.0f)); - dgVector p5 ( dgFloat32 (0.0f), dgFloat32 (0.0f),-dgFloat32 (1.0f), dgFloat32 (0.0f)); - - dgInt32 index = 3; - dgInt32 count = 0; - TesselateTriangle (index, p4, p0, p2, count, tmpVectex); - TesselateTriangle (index, p4, p2, p1, count, tmpVectex); - TesselateTriangle (index, p4, p1, p3, count, tmpVectex); - TesselateTriangle (index, p4, p3, p0, count, tmpVectex); - TesselateTriangle (index, p5, p2, p0, count, tmpVectex); - TesselateTriangle (index, p5, p1, p2, count, tmpVectex); - TesselateTriangle (index, p5, p3, p1, count, tmpVectex); - TesselateTriangle (index, p5, p0, p3, count, tmpVectex); - - for (dgInt32 i = 0; i < count; i ++) { - tmpVectex[i] = tmpVectex[i].Scale (m_radius); - } - - //dgMatrix matrix (GetLocalMatrix() * matrixPtr); - matrix.TransformTriplex (&pool[0].m_x, sizeof (dgTriplex), &tmpVectex[0].m_x, sizeof (dgVector), count); - for (dgInt32 i = 0; i < count; i += 3) { - callback (userData, 3, &pool[i].m_x, 0); - } -} - -dgFloat32 dgCollisionPoint::GetVolume () const -{ - dgAssert (0); - return dgFloat32 (0.0f); -} - -dgVector dgCollisionPoint::SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const -{ - return dgVector (dgFloat32 (0.0f)); -} - -dgVector dgCollisionPoint::SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - return dgVector (dgFloat32 (0.0f)); -} - -dgFloat32 dgCollisionSphere::RayCast (const dgVector& p0, const dgVector& p1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const -{ - dgFloat32 t = dgRayCastSphere (p0, p1, dgVector (dgFloat32 (0.0f)), m_radius); - if (t < maxT) { - dgVector contact (p0 + (p1 - p0).Scale (t)); - dgAssert (contact.m_w == dgFloat32 (0.0f)); - //contactOut.m_normal = contact.Scale (dgRsqrt (contact.DotProduct(contact).GetScalar())); - contactOut.m_normal = contact.Normalize(); - //contactOut.m_userId = SetUserDataID(); - } - return t; -} - -void dgCollisionSphere::MassProperties () -{ - m_centerOfMass = dgVector::m_zero; - m_crossInertia = dgVector::m_zero; - dgFloat32 volume = dgFloat32 (4.0f * dgPi / 3.0f) * m_radius * m_radius * m_radius; - dgFloat32 II = dgFloat32 (2.0f / 5.0f) * m_radius * m_radius; - m_inertia = dgVector (II, II, II, dgFloat32 (0.0f)); - m_centerOfMass.m_w = volume; -} - -void dgCollisionSphere::GetCollisionInfo(dgCollisionInfo* const info) const -{ - dgCollisionConvex::GetCollisionInfo(info); - info->m_sphere.m_radius = m_radius; -} - -void dgCollisionSphere::Serialize(dgSerialize callback, void* const userData) const -{ - SerializeLow(callback, userData); - callback (userData, &m_radius, sizeof (m_radius)); -} - -dgVector dgCollisionSphere::SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - return dgVector (dgFloat32 (0.0f)); -} - -dgVector dgCollisionSphere::SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const -{ - return dir.Scale (m_radius - DG_PENETRATION_TOL); -} - -void dgCollisionSphere::CalculateImplicitContacts(dgInt32 count, dgContactPoint* const contactPoints) const -{ - for (dgInt32 i = 0; i < count; i++) { - dgVector normal(contactPoints[i].m_point & dgVector::m_triplexMask); - dgAssert(normal.DotProduct(normal).GetScalar() > dgFloat32(0.0f)); - normal = normal.Normalize(); - contactPoints[i].m_normal = normal * dgVector::m_negOne; - contactPoints[i].m_point = normal.Scale(m_radius); - } -} \ No newline at end of file diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionSphere.h b/thirdparty/src/newton/dgPhysics/dgCollisionSphere.h deleted file mode 100644 index 94496c56f..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionSphere.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_COLLISION_SPHERE_H__ -#define _DG_COLLISION_SPHERE_H__ - - -#include "dgCollisionConvex.h" - -#define DG_SPHERE_VERTEX_COUNT 18 - -class dgCollisionSphere: public dgCollisionConvex -{ - public: - dgCollisionSphere(dgMemoryAllocator* allocator, dgUnsigned32 signature, dgFloat32 radius); - dgCollisionSphere(dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionSphere(); - - protected: - void Init (dgFloat32 radius, dgMemoryAllocator* allocator); - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - - virtual void CalcAABB (const dgMatrix& matrix, dgVector& p0, dgVector& p1) const; - virtual void DebugCollision (const dgMatrix& matrix, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const; - - void TesselateTriangle (dgInt32 level, const dgVector& p0, const dgVector& p1, const dgVector& p2, dgInt32& count, dgVector* const ouput) const; - static dgInt32 CalculateSignature (dgFloat32 radius); - - virtual dgInt32 CalculateSignature () const; - virtual void SetCollisionBBox (const dgVector& p0, const dgVector& p1); - - virtual void MassProperties (); - - virtual dgInt32 CalculatePlaneIntersection (const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const; - - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - virtual void Serialize(dgSerialize callback, void* const userData) const; - - virtual void CalculateImplicitContacts(dgInt32 count, dgContactPoint* const contactPoints) const; - virtual dgVector SupportVertexSpecialProjectPoint(const dgVector& point, const dgVector& dir) const; - virtual dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; - - dgFloat32 m_radius; - dgVector m_vertex[DG_SPHERE_VERTEX_COUNT]; - - static dgInt32 m_shapeRefCount; - static dgVector m_unitSphere[]; - static dgConvexSimplexEdge m_edgeArray[]; - - friend class dgWorld; -}; - - -class dgCollisionPoint: public dgCollisionSphere -{ - public: - dgCollisionPoint (dgMemoryAllocator* const allocator) - :dgCollisionSphere(allocator, 0x12344321, dgFloat32 (0.25f)) - { - } - - virtual dgFloat32 GetVolume () const; - virtual dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - virtual dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; -}; - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionUserMesh.cpp b/thirdparty/src/newton/dgPhysics/dgCollisionUserMesh.cpp deleted file mode 100644 index 52fc1c4ea..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionUserMesh.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgCollisionUserMesh.h" - - -dgCollisionUserMesh::dgCollisionUserMesh(dgWorld* const world, const dgVector& boxP0, const dgVector& boxP1, const dgUserMeshCreation& data) - :dgCollisionMesh (world, m_userMesh) -{ - m_rtti |= dgCollisionUserMesh_RTTI; - - m_userData = data.m_userData; - m_getInfoCallback = data.m_getInfoCallback; - m_faceInAABBCalback = data.m_faceInAABBCallback; - m_rayHitCallback = data.m_rayHitCallback; - m_collideCallback = data.m_collideCallback; - m_destroyCallback = data.m_destroyCallback; - m_serializeCallback = data.m_serializeCallback; - m_getAABBOvelapTestCallback = data.m_getAABBOvelapTestCallback; - - SetCollisionBBox(boxP0, boxP1); -} - -dgCollisionUserMesh::dgCollisionUserMesh (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber) - :dgCollisionMesh (world, deserialization, userData, revisionNumber) -{ -dgAssert (0); - m_rtti |= dgCollisionUserMesh_RTTI; - -/* - dgAABBPolygonSoup::Deserialize (deserialization, userData); - - dgVector p0; - dgVector p1; - GetAABB (p0, p1); - SetCollisionBBox(p0, p1); -*/ -} - -dgCollisionUserMesh::~dgCollisionUserMesh(void) -{ - if (m_destroyCallback) { - m_destroyCallback (m_userData); - } -} - -void dgCollisionUserMesh::Serialize(dgSerialize callback, void* const userData) const -{ - SerializeLow(callback, userData); - if (m_serializeCallback) { - m_serializeCallback (m_userData, callback, userData); - } -} - - -void dgCollisionUserMesh::GetVertexListIndexList (const dgVector& p0, const dgVector& p1, dgMeshVertexListIndexList &data) const -{ - if (m_faceInAABBCalback) { - return m_faceInAABBCalback (m_userData, &p0[0], &p1[0], (const dgFloat32**) &data.m_veterxArray, &data.m_vertexCount, &data.m_vertexStrideInBytes, - data.m_indexList, data.m_maxIndexCount, data.m_userDataList); - - } else { - data.m_triangleCount = 0; - } -} - -void dgCollisionUserMesh::GetCollisionInfo(dgCollisionInfo* const info) const -{ - dgCollision::GetCollisionInfo(info); - if (m_getInfoCallback) { - m_getInfoCallback (m_userData, info); - } -} - -bool dgCollisionUserMesh::AABBOvelapTest (const dgVector& boxP0, const dgVector& boxP1) const -{ - return (m_getAABBOvelapTestCallback && m_getAABBOvelapTestCallback (m_userData, boxP0, boxP1)) ? true : false; -} - - -dgFloat32 dgCollisionUserMesh::RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const -{ - dgFloat32 param = dgFloat32 (1.2f); - if (m_rayHitCallback) { - dgCollisionMeshRayHitDesc data; - data.m_localP0 = localP0; - data.m_localP1 = localP1; - data.m_userId = body->m_collision->GetUserDataID(); - data.m_userData = m_userData; - data.m_altenateUserData = userData; - if (body) { - data.m_matrix = body->m_collision->GetGlobalMatrix(); - } - - dgFloat32 t = m_rayHitCallback (data); - if ((t < dgFloat32 (1.0f)) && (t > dgFloat32 (0.0f))) { - param = t; - contactOut.m_normal = data.m_normal; -// contactOut.m_userId = data.m_userId; - contactOut.m_shapeId0 = dgInt64 (data.m_userId); - } - } - return param; -} - - -dgVector dgCollisionUserMesh::SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const -{ - dgAssert (0); - return dgVector::m_zero; -} - -dgVector dgCollisionUserMesh::SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const -{ - dgAssert(0); - return dgVector::m_zero; -} - -void dgCollisionUserMesh::GetCollidingFacesContinue(dgPolygonMeshDesc* const data) const -{ - data->m_me = this; - data->m_faceCount = 0; - data->m_userData = m_userData; - data->m_separationDistance = dgFloat32(0.0f); - - dgFastRayTest ray(dgVector(dgFloat32(0.0f)), data->m_boxDistanceTravelInMeshSpace); - m_collideCallback(&data->m_p0, &ray); - - dgInt32 faceCount0 = 0; - dgInt32 faceIndexCount0 = 0; - dgInt32 faceIndexCount1 = 0; - dgInt32 stride = data->m_vertexStrideInBytes / sizeof(dgFloat32); - dgFloat32* const vertex = data->m_vertex; - dgInt32* const address = data->m_meshData.m_globalFaceIndexStart; - dgFloat32* const hitDistance = data->m_meshData.m_globalHitDistance; - const dgInt32* const srcIndices = data->m_faceVertexIndex; - dgInt32* const dstIndices = data->m_globalFaceVertexIndex; - dgInt32* const faceIndexCountArray = data->m_faceIndexCount; - - for (dgInt32 i = 0; (i < data->m_faceCount) && (faceIndexCount0 < (DG_MAX_COLLIDING_INDICES - 32)); i++) { - dgInt32 indexCount = faceIndexCountArray[i]; - const dgInt32* const indexArray = &srcIndices[faceIndexCount1]; - - dgInt32 normalIndex = data->GetNormalIndex(indexArray, indexCount); - dgVector faceNormal(&vertex[normalIndex * stride]); - faceNormal = faceNormal & dgVector::m_triplexMask; - dgFloat32 dist = data->PolygonBoxRayDistance(faceNormal, indexCount, indexArray, stride, vertex, ray); - - const dgInt32 faceIndexCount = data->GetFaceIndexCount(indexCount); - if (dist < dgFloat32(1.0f)) { - hitDistance[faceCount0] = dist; - address[faceCount0] = faceIndexCount0; - faceIndexCountArray[faceCount0] = indexCount; - memcpy(&dstIndices[faceIndexCount0], indexArray, faceIndexCount * sizeof(dgInt32)); - faceCount0++; - faceIndexCount0 += faceIndexCount; - } - faceIndexCount1 += faceIndexCount; - } - - data->m_faceCount = 0; - if (faceCount0) { - data->m_faceCount = faceCount0; - data->m_faceIndexStart = address; - data->m_hitDistance = hitDistance; - data->m_faceVertexIndex = dstIndices; - - if (GetDebugCollisionCallback()) { - dgTriplex triplex[32]; - //const dgMatrix& matrix = data->m_polySoupInstance->GetGlobalMatrix(); - const dgVector scale = data->m_polySoupInstance->GetScale(); - dgMatrix matrix(data->m_polySoupInstance->GetLocalMatrix() * data->m_polySoupBody->GetMatrix()); - - for (dgInt32 i = 0; i < data->m_faceCount; i++) { - dgInt32 base = address[i]; - dgInt32 indexCount = faceIndexCountArray[i]; - const dgInt32* const vertexFaceIndex = &data->m_faceVertexIndex[base]; - for (dgInt32 j = 0; j < indexCount; j++) { - dgInt32 index = vertexFaceIndex[j]; - dgVector q(&vertex[index * stride]); - q = q & dgVector::m_triplexMask; - //dgVector p(matrix.TransformVector(scale * dgVector(&vertex[index * stride]))); - dgVector p(matrix.TransformVector(scale * q)); - triplex[j].m_x = p.m_x; - triplex[j].m_y = p.m_y; - triplex[j].m_z = p.m_z; - } - dgInt32 faceId = data->GetFaceId(vertexFaceIndex, indexCount); - GetDebugCollisionCallback() (data->m_polySoupBody, data->m_objBody, faceId, indexCount, &triplex[0].m_x, sizeof(dgTriplex)); - } - } - } -} - -void dgCollisionUserMesh::GetCollidingFacesDescrete(dgPolygonMeshDesc* const data) const -{ - data->m_me = this; - data->m_faceCount = 0; - data->m_userData = m_userData; - data->m_separationDistance = dgFloat32(0.0f); - - m_collideCallback(&data->m_p0, NULL); - - dgInt32 faceCount0 = 0; - dgInt32 faceIndexCount0 = 0; - dgInt32 faceIndexCount1 = 0; - dgInt32 stride = data->m_vertexStrideInBytes / sizeof(dgFloat32); - dgFloat32* const vertex = data->m_vertex; - dgInt32* const address = data->m_meshData.m_globalFaceIndexStart; - dgFloat32* const hitDistance = data->m_meshData.m_globalHitDistance; - const dgInt32* const srcIndices = data->m_faceVertexIndex; - dgInt32* const dstIndices = data->m_globalFaceVertexIndex; - dgInt32* const faceIndexCountArray = data->m_faceIndexCount; - - for (dgInt32 i = 0; (i < data->m_faceCount) && (faceIndexCount0 < (DG_MAX_COLLIDING_INDICES - 32)); i++) { - dgInt32 indexCount = faceIndexCountArray[i]; - const dgInt32* const indexArray = &srcIndices[faceIndexCount1]; - - dgInt32 normalIndex = data->GetNormalIndex(indexArray, indexCount); - dgVector faceNormal(&vertex[normalIndex * stride]); - faceNormal = faceNormal & dgVector::m_triplexMask; - dgFloat32 dist = data->PolygonBoxDistance(faceNormal, indexCount, indexArray, stride, vertex); - - const dgInt32 faceIndexCount = data->GetFaceIndexCount(indexCount); - if (dist > dgFloat32(0.0f)) { - hitDistance[faceCount0] = dist; - address[faceCount0] = faceIndexCount0; - faceIndexCountArray[faceCount0] = indexCount; - memcpy(&dstIndices[faceIndexCount0], indexArray, faceIndexCount * sizeof(dgInt32)); - faceCount0++; - faceIndexCount0 += faceIndexCount; - } - faceIndexCount1 += faceIndexCount; - } - - data->m_faceCount = 0; - if (faceCount0) { - data->m_faceCount = faceCount0; - data->m_faceIndexStart = address; - data->m_hitDistance = hitDistance; - data->m_faceVertexIndex = dstIndices; - - if (GetDebugCollisionCallback()) { - dgTriplex triplex[32]; - //const dgMatrix& matrix = data->m_polySoupInstance->GetGlobalMatrix(); - const dgVector scale = data->m_polySoupInstance->GetScale(); - dgMatrix matrix(data->m_polySoupInstance->GetLocalMatrix() * data->m_polySoupBody->GetMatrix()); - - for (dgInt32 i = 0; i < data->m_faceCount; i++) { - dgInt32 base = address[i]; - dgInt32 indexCount = faceIndexCountArray[i]; - const dgInt32* const vertexFaceIndex = &data->m_faceVertexIndex[base]; - for (dgInt32 j = 0; j < indexCount; j++) { - dgInt32 index = vertexFaceIndex[j]; - dgVector q(&vertex[index * stride]); - q = q & dgVector::m_triplexMask; - //dgVector p(matrix.TransformVector(scale * dgVector(&vertex[index * stride]))); - dgVector p(matrix.TransformVector(scale * q)); - triplex[j].m_x = p.m_x; - triplex[j].m_y = p.m_y; - triplex[j].m_z = p.m_z; - } - dgInt32 faceId = data->GetFaceId(vertexFaceIndex, indexCount); - GetDebugCollisionCallback() (data->m_polySoupBody, data->m_objBody, faceId, indexCount, &triplex[0].m_x, sizeof(dgTriplex)); - } - } - } -} - -void dgCollisionUserMesh::GetCollidingFaces (dgPolygonMeshDesc* const data) const -{ - if (m_collideCallback) { - if (data->m_doContinuesCollisionTest) { - GetCollidingFacesContinue(data); - } else { - GetCollidingFacesDescrete(data); - } - } -} - -void dgCollisionUserMesh::DebugCollision (const dgMatrix& matrixPtr, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const -{ -/* - dgCollisionUserMeshShowPolyContext context; - - context.m_matrix = matrixPtr; - context.m_userData = userData;; - context.m_callback = callback; - - dgVector p0 (dgFloat32 (-1.0e20f), dgFloat32 (-1.0e20f), dgFloat32 (-1.0e20f), dgFloat32 (0.0f)); - dgVector p1 (dgFloat32 ( 1.0e20f), dgFloat32 ( 1.0e20f), dgFloat32 ( 1.0e20f), dgFloat32 (0.0f)); - ForAllSectors (p0, p1, ShowDebugPolygon, &context); -*/ -} diff --git a/thirdparty/src/newton/dgPhysics/dgCollisionUserMesh.h b/thirdparty/src/newton/dgPhysics/dgCollisionUserMesh.h deleted file mode 100644 index 29bba4d0d..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCollisionUserMesh.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGCOLLISION_USERMESH__ -#define __DGCOLLISION_USERMESH__ - -#include "dgCollision.h" -#include "dgCollisionMesh.h" - - - -class dgCollisionUserMesh: public dgCollisionMesh -{ - public: - typedef void (dgApi *OnUserMeshDestroyCallback) (void* const userData); - typedef dgFloat32 (dgApi *OnUserMeshRayHitCallback) (dgCollisionMeshRayHitDesc& rayHitdata); - typedef void (dgApi *OnUserMeshCollisionInfo) (void* userData, dgCollisionInfo* infoRecord); - typedef void (dgApi *OnUserMeshCollideCallback) (void* const collideData, const void* const continueHandle); - typedef dgInt32 (dgApi *OnUserMeshAABBOverlapTest) (void* const userData, const dgVector& boxP0, const dgVector& boxP1); - typedef void (dgApi *OnUserMeshSerialize) (void* const userSerializeData, dgSerialize function, void* const serilalizeObject); - typedef void (dgApi *OnUserMeshFacesInAABB) (void* userData, const dgFloat32* p0, const dgFloat32* p1, const dgFloat32** vertexArray, dgInt32* vertexCount, dgInt32* vertexStrideInBytes, const dgInt32* indexList, dgInt32 maxIndexCount, const dgInt32* faceAttribute); - - dgCollisionUserMesh(dgWorld* const world, const dgVector& boxP0, const dgVector& boxP1, const dgUserMeshCreation& data); - dgCollisionUserMesh (dgWorld* const world, dgDeserialize deserialization, void* const userData, dgInt32 revisionNumber); - virtual ~dgCollisionUserMesh(void); - - void GetVertexListIndexList (const dgVector& p0, const dgVector& p1, dgMeshVertexListIndexList &data) const; - - bool AABBOvelapTest (const dgVector& boxP0, const dgVector& boxP1) const; - - private: - void Serialize(dgSerialize callback, void* const userData) const; - - dgVector SupportVertex (const dgVector& dir, dgInt32* const vertexIndex) const; - dgVector SupportVertexSpecial (const dgVector& dir, dgFloat32 skinThickness, dgInt32* const vertexIndex) const; - dgVector SupportVertexSpecialProjectPoint (const dgVector& point, const dgVector& dir) const {return point;} - - virtual void GetCollisionInfo(dgCollisionInfo* const info) const; - virtual dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const; - virtual void GetCollidingFaces (dgPolygonMeshDesc* const data) const; - virtual void DebugCollision (const dgMatrix& matrixPtr, dgCollision::OnDebugCollisionMeshCallback callback, void* const userData) const; - - void GetCollidingFacesContinue(dgPolygonMeshDesc* const data) const; - void GetCollidingFacesDescrete(dgPolygonMeshDesc* const data) const; - - void* m_userData; - OnUserMeshSerialize m_serializeCallback; - OnUserMeshCollisionInfo m_getInfoCallback; - OnUserMeshFacesInAABB m_faceInAABBCalback; - OnUserMeshRayHitCallback m_rayHitCallback; - OnUserMeshCollideCallback m_collideCallback; - OnUserMeshDestroyCallback m_destroyCallback; - OnUserMeshAABBOverlapTest m_getAABBOvelapTestCallback; -}; - -class dgUserMeshCreation -{ - public: - void* m_userData; - dgCollisionUserMesh::OnUserMeshSerialize m_serializeCallback; - dgCollisionUserMesh::OnUserMeshCollideCallback m_collideCallback; - dgCollisionUserMesh::OnUserMeshRayHitCallback m_rayHitCallback; - dgCollisionUserMesh::OnUserMeshDestroyCallback m_destroyCallback; - dgCollisionUserMesh::OnUserMeshCollisionInfo m_getInfoCallback; - dgCollisionUserMesh::OnUserMeshFacesInAABB m_faceInAABBCallback; - dgCollisionUserMesh::OnUserMeshAABBOverlapTest m_getAABBOvelapTestCallback; -}; - - -#endif diff --git a/thirdparty/src/newton/dgPhysics/dgConstraint.cpp b/thirdparty/src/newton/dgPhysics/dgConstraint.cpp deleted file mode 100644 index 5b16bba14..000000000 --- a/thirdparty/src/newton/dgPhysics/dgConstraint.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgConstraint.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -void* dgConstraint::GetUserData () const -{ - return m_userData; -} - -void dgConstraint::SetUserData (void *userData) -{ - m_userData = userData; -} - -dgFloat32 dgConstraint::GetMassScaleBody0() const -{ - return dgFloat32(1.0f); -} - -dgFloat32 dgConstraint::GetMassScaleBody1() const -{ - return dgFloat32(1.0f); -} - -void dgConstraint::InitPointParam (dgPointParam& param, dgFloat32 stiffness, const dgVector& p0Global, const dgVector& p1Global) const -{ - dgAssert (m_body0); - dgAssert (m_body1); - param.m_defualtDiagonalRegularizer = stiffness; - - param.m_posit0 = p0Global; - param.m_posit1 = p1Global; - - param.m_r0 = (p0Global - m_body0->m_globalCentreOfMass) & dgVector::m_triplexMask; - param.m_r1 = (p1Global - m_body1->m_globalCentreOfMass) & dgVector::m_triplexMask; -} - -void dgConstraint::InitInfo (dgConstraintInfo* const info) const -{ - info->m_attachBody_0 = GetBody0(); - dgAssert (info->m_attachBody_0); - dgWorld* const world = info->m_attachBody_0->GetWorld(); - if (info->m_attachBody_0 == (dgBody*)world->GetSentinelBody()) { - info->m_attachBody_0 = NULL; - } - - info->m_attachBody_1 = GetBody1(); - if (info->m_attachBody_1 == (dgBody*)world->GetSentinelBody()) { - info->m_attachBody_1 = NULL; - } - - info->m_attachMatrix_0 = dgGetIdentityMatrix(); - info->m_attachMatrix_1 = dgGetIdentityMatrix(); - - info->m_discriptionType[0] = 0; - -} - - diff --git a/thirdparty/src/newton/dgPhysics/dgConstraint.h b/thirdparty/src/newton/dgPhysics/dgConstraint.h deleted file mode 100644 index 345ede45d..000000000 --- a/thirdparty/src/newton/dgPhysics/dgConstraint.h +++ /dev/null @@ -1,423 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGCONSTRAINT_H__ -#define __DGCONSTRAINT_H__ - -#include "dgBodyMasterList.h" - -#define DG_MAX_BOUND dgFloat32 (1.0e15f) -#define DG_MIN_BOUND (-DG_MAX_BOUND) -#define DG_INDEPENDENT_ROW -1 -#define DG_CONSTRAINT_MAX_ROWS (3 * 16) -#define MIN_JOINT_PIN_LENGTH dgFloat32 (50.0f) - -class dgBody; -class dgWorld; -class dgConstraint; -class dgBilateralBounds; - -typedef void (dgApi *ConstraintsForceFeeback) (const dgConstraint& me, dgFloat32 timestep, dgInt32 threadIndex); - -class dgConstraintInfo -{ - public: - dgMatrix m_attachMatrix_0; - dgMatrix m_attachMatrix_1; - dgFloat32 m_minLinearDof[3]; - dgFloat32 m_maxLinearDof[3]; - dgFloat32 m_minAngularDof[3]; - dgFloat32 m_maxAngularDof[3]; - dgBody* m_attachBody_0; - dgBody* m_attachBody_1; - dgFloat32 m_extraParameters[64]; - dgInt32 m_collideCollisionOn; - char m_discriptionType[64]; -}; - - -class dgJointCallbackParam -{ - public: - dgFloat32 m_accel; - dgFloat32 m_minFriction; - dgFloat32 m_maxFriction; - dgFloat32 m_timestep; -}; - -class dgForceImpactPair -{ - public: - void Clear() - { - m_force = dgFloat32 (0.0f); - m_impact = dgFloat32(0.0f); - for (dgInt32 i = 0; i < sizeof(m_initialGuess) / sizeof(m_initialGuess[0]); i++) { - m_initialGuess[i] = dgFloat32(0.0f); - } - } - - void Push(dgFloat32 val) - { - for (dgInt32 i = 1; i < sizeof(m_initialGuess) / sizeof(m_initialGuess[0]); i++) { - m_initialGuess[i - 1] = m_initialGuess[i]; - } - m_initialGuess[sizeof(m_initialGuess) / sizeof(m_initialGuess[0]) - 1] = val; - } - - dgFloat32 GetInitiailGuess() const - { - dgFloat32 value = dgFloat32(0.0f); - dgFloat32 smallest = dgFloat32(1.0e15f); - for (dgInt32 i = 0; i < sizeof(m_initialGuess) / sizeof(m_initialGuess[0]); i++) - { - dgFloat32 mag = dgAbs(m_initialGuess[i]); - if (mag < smallest) { - smallest = mag; - value = m_initialGuess[i]; - } - } - return value; - } - - dgFloat32 m_force; - dgFloat32 m_impact; - dgFloat32 m_initialGuess[4]; -}; - -class dgBilateralBounds -{ - public: - dgForceImpactPair* m_jointForce; - dgFloat32 m_low; - dgFloat32 m_upper; - dgInt32 m_normalIndex; -}; - -DG_MSC_VECTOR_ALIGNMENT -class dgJacobian -{ - public: - dgVector m_linear; - dgVector m_angular; -} DG_GCC_VECTOR_ALIGNMENT; - -DG_MSC_VECTOR_ALIGNMENT -class dgJacobianPair -{ - public: - dgJacobian m_jacobianM0; - dgJacobian m_jacobianM1; -} DG_GCC_VECTOR_ALIGNMENT; - -class dgLeftHandSide; -class dgRightHandSide; - -class dgJointAccelerationDecriptor -{ - public: - dgInt32 m_rowsCount; - dgFloat32 m_timeStep; - dgFloat32 m_invTimeStep; - dgFloat32 m_firstPassCoefFlag; - dgRightHandSide* m_rightHandSide; - const dgLeftHandSide* m_leftHandSide; -}; - -DG_MSC_VECTOR_ALIGNMENT -class dgContraintDescritor -{ - public: - dgJacobianPair m_jacobian[DG_CONSTRAINT_MAX_ROWS]; - dgBilateralBounds m_forceBounds[DG_CONSTRAINT_MAX_ROWS]; - dgFloat32 m_jointAccel[DG_CONSTRAINT_MAX_ROWS]; - dgFloat32 m_restitution[DG_CONSTRAINT_MAX_ROWS]; - dgFloat32 m_penetration[DG_CONSTRAINT_MAX_ROWS]; - dgFloat32 m_diagonalRegularizer[DG_CONSTRAINT_MAX_ROWS]; - dgFloat32 m_penetrationStiffness[DG_CONSTRAINT_MAX_ROWS]; - dgFloat32 m_zeroRowAcceleration[DG_CONSTRAINT_MAX_ROWS]; - dgInt8 m_flags[DG_CONSTRAINT_MAX_ROWS]; - dgWorld* m_world; - dgInt32 m_threadIndex; - dgFloat32 m_timestep; - dgFloat32 m_invTimestep; -} DG_GCC_VECTOR_ALIGNMENT; - - -typedef void (dgApi *OnConstraintDestroy) (dgConstraint& me); - -DG_MSC_VECTOR_ALIGNMENT -class dgConstraint -{ - public: - DG_CLASS_ALLOCATOR(allocator) - - enum dgConstraintID - { - m_ballConstraint, - m_hingeConstraint, - m_sliderConstraint, - m_contactConstraint, - m_upVectorConstraint, - m_universalConstraint, - m_corkScrewConstraint, - m_unknownConstraint - }; - - dgUnsigned32 GetId () const; - dgBody* GetBody0 () const; - dgBody* GetBody1 () const; - - dgBodyMasterListRow::dgListNode* GetLink0() const; - dgBodyMasterListRow::dgListNode* GetLink1() const; - void* GetUserData () const; - - bool IsActive() const; - bool IsCollidable () const; - bool IsBilateral () const; - bool IsSkeleton () const; - bool IsSkeletonLoop () const; - - dgInt32 GetMaxDOF() const; - virtual void ResetMaxDOF(); - virtual dgFloat32 GetImpulseContactSpeed() const; - virtual void SetImpulseContactSpeed(dgFloat32 speed); - - virtual dgFloat32 GetMassScaleBody0 () const; - virtual dgFloat32 GetMassScaleBody1 () const; - - void SetUserData (void *userData); - void SetCollidable (bool state); - virtual void SetDestructorCallback (OnConstraintDestroy destructor) = 0; - - virtual dgFloat32 GetStiffness() const; - virtual void SetStiffness(dgFloat32 stiffness); - - virtual dgInt32 GetSolverModel() const; - virtual void SetSolverModel(dgInt32 model); - - virtual void GetInfo (dgConstraintInfo* const info) const; - - ConstraintsForceFeeback GetUpdateFeedbackFunction (); - virtual void JointAccelerations(dgJointAccelerationDecriptor* const params) = 0; - - void SetIndex (dgInt32 index); - - class dgPointParam - { - public: - dgVector m_r0; - dgVector m_r1; - dgVector m_posit0; - dgVector m_posit1; - dgFloat32 m_defualtDiagonalRegularizer; - }; - - protected: - dgConstraint(); - virtual ~dgConstraint(); - - virtual dgUnsigned32 JacobianDerivative (dgContraintDescritor& params) = 0; - - void SetUpdateFeedbackFunction (ConstraintsForceFeeback function); - void InitPointParam (dgPointParam& param, dgFloat32 stiffness, const dgVector& p0Global, const dgVector& p1Global) const; - void InitInfo (dgConstraintInfo* const info) const; - - void* m_userData; - dgBody* m_body0; - dgBody* m_body1; - dgBodyMasterListRow::dgListNode* m_link0; - dgBodyMasterListRow::dgListNode* m_link1; - ConstraintsForceFeeback m_updaFeedbackCallback; - dgInt32 m_clusterLRU; - dgUnsigned32 m_index; - dgUnsigned32 m_impulseLru; - dgUnsigned32 m_dynamicsLru; - dgUnsigned32 m_maxDOF : 6; - dgUnsigned32 m_constId : 6; - dgUnsigned32 m_solverModel : 2; - dgUnsigned32 m_enableCollision : 1; - dgUnsigned32 m_isActive : 1; - dgUnsigned32 m_isBilateral : 1; - dgUnsigned32 m_graphTagged : 1; - dgUnsigned32 m_isInSkeleton : 1; - dgUnsigned32 m_isInSkeletonLoop : 1; - - friend class dgWorld; - friend class dgJacobianMemory; - friend class dgBodyMasterList; - friend class dgSkeletonContainer; - friend class dgWorldDynamicUpdate; - friend class dgParallelBodySolver; - friend class dgParallelSolverJointAcceleration; - friend class dgParallelSolverInitFeedbackUpdate; - friend class dgParallelSolverBuildJacobianMatrix; - friend class dgBroadPhaseMaterialCallbackWorkerThread; -} DG_GCC_VECTOR_ALIGNMENT; - -DG_INLINE dgConstraint::dgConstraint() - :m_userData(NULL) - ,m_body0(NULL) - ,m_body1(NULL) - ,m_link0(NULL) - ,m_link1(NULL) - ,m_updaFeedbackCallback(NULL) - ,m_clusterLRU(-1) - ,m_index(0) - ,m_impulseLru(0) - ,m_dynamicsLru(0) - ,m_maxDOF(6) - ,m_constId(m_unknownConstraint) - ,m_solverModel(2) - ,m_enableCollision(false) - ,m_isActive(false) - ,m_isBilateral(false) - ,m_graphTagged(false) - ,m_isInSkeleton(false) - ,m_isInSkeletonLoop(false) -{ - dgAssert ((((dgUnsigned64) this) & 15) == 0); -} - -DG_INLINE dgConstraint::~dgConstraint() -{ -} - -DG_INLINE ConstraintsForceFeeback dgConstraint::GetUpdateFeedbackFunction () -{ - return m_updaFeedbackCallback; -} - -DG_INLINE void dgConstraint::SetUpdateFeedbackFunction (ConstraintsForceFeeback function) -{ - m_updaFeedbackCallback = function; -} - -DG_INLINE bool dgConstraint::IsBilateral() const -{ - return m_isBilateral ? true : false; -} - -DG_INLINE bool dgConstraint::IsSkeleton () const -{ - return m_isInSkeleton ? true : false; -} - -DG_INLINE bool dgConstraint::IsSkeletonLoop () const -{ - return m_isInSkeletonLoop ? true : false; -} - -DG_INLINE bool dgConstraint::IsCollidable () const -{ - return m_enableCollision ? true : false; -} - -DG_INLINE void dgConstraint::SetCollidable (bool state) -{ - m_enableCollision = dgUnsigned32 (state); -} - -DG_INLINE dgUnsigned32 dgConstraint::GetId () const -{ - return m_constId; -} - -DG_INLINE dgBody* dgConstraint::GetBody0 () const -{ - return m_body0; -} - -DG_INLINE dgBody* dgConstraint::GetBody1 () const -{ - return m_body1; -} - -//DG_INLINE void dgConstraint::SetBodies (dgBody* const body0, dgBody* const body1) -//{ -// m_body0 = body0; -// m_body1 = body1; -//} - -DG_INLINE dgBodyMasterListRow::dgListNode* dgConstraint::GetLink0() const -{ - return m_link0; -} -DG_INLINE dgBodyMasterListRow::dgListNode* dgConstraint::GetLink1() const -{ - return m_link1; -} - - -DG_INLINE dgFloat32 dgConstraint::GetStiffness() const -{ - return dgFloat32 (1.0f); -} - -DG_INLINE void dgConstraint::SetStiffness(dgFloat32 stiffness) -{ -} - -DG_INLINE dgInt32 dgConstraint::GetSolverModel() const -{ - return m_solverModel; -} - -DG_INLINE void dgConstraint::SetSolverModel(dgInt32 model) -{ - m_solverModel = dgClamp(model, 0, 2); -} - -DG_INLINE void dgConstraint::ResetMaxDOF() -{ -} - -DG_INLINE void dgConstraint::SetImpulseContactSpeed(dgFloat32 speed) -{ -} - -DG_INLINE dgFloat32 dgConstraint::GetImpulseContactSpeed() const -{ - return dgFloat32 (0.0f); -} - -DG_INLINE dgInt32 dgConstraint::GetMaxDOF() const -{ - return dgInt32 (m_maxDOF); -} - -DG_INLINE bool dgConstraint::IsActive() const -{ - return m_isActive ? true : false; -} - -DG_INLINE void dgConstraint::SetIndex (dgInt32 index) -{ - m_index = index; -} - -DG_INLINE void dgConstraint::GetInfo(dgConstraintInfo* const info) const -{ - dgAssert(0); -} - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgContact.cpp b/thirdparty/src/newton/dgPhysics/dgContact.cpp deleted file mode 100644 index 3f487bed5..000000000 --- a/thirdparty/src/newton/dgPhysics/dgContact.cpp +++ /dev/null @@ -1,495 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgCollisionInstance.h" -#include "dgWorldDynamicUpdate.h" - -#define REST_RELATIVE_VELOCITY dgFloat32 (1.0e-3f) -#define MAX_DYNAMIC_FRICTION_SPEED dgFloat32 (0.3f) -#define MAX_PENETRATION_STIFFNESS dgFloat32 (50.0f) -#define DG_DIAGONAL_REGULARIZER dgFloat32 (1.0e-3f) - -//#define DG_NEW_RESTITUTION_METHOD - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -dgContactMaterial::dgContactMaterial() - :m_dir0 (dgFloat32 (0.0f)) - ,m_dir1 (dgFloat32 (0.0f)) - ,m_userData(NULL) - ,m_aabbOverlap(NULL) - ,m_processContactPoint(NULL) - ,m_contactGeneration(NULL) - ,m_compoundAABBOverlap(NULL) -{ - // dgAssert ( dgInt32 (sizeof (dgContactMaterial) & 15) == 0); - dgAssert ((((dgUnsigned64) this) & 15) == 0); - m_point = dgVector (dgFloat32 (0.0f)); - m_softness = dgFloat32 (0.1f); - m_restitution = dgFloat32 (0.4f); - m_skinThickness = dgFloat32 (0.0f); - - m_staticFriction0 = dgFloat32 (0.9f); - m_staticFriction1 = dgFloat32 (0.9f); - m_dynamicFriction0 = dgFloat32 (0.5f); - m_dynamicFriction1 = dgFloat32 (0.5f); - m_dir0_Force.Clear(); - m_dir1_Force.Clear(); - m_normal_Force.Clear(); - m_flags = m_collisionEnable | m_friction0Enable | m_friction1Enable; -} - -dgContact::dgContact(dgWorld* const world, const dgContactMaterial* const material, dgBody* const body0, dgBody* const body1) - :dgConstraint() - ,dgList<dgContactMaterial>(world->GetAllocator()) - ,m_positAcc(dgFloat32 (10.0f)) - ,m_rotationAcc () - ,m_material(material) - ,m_closestDistance (dgFloat32 (0.0f)) - ,m_separationDistance(dgFloat32 (0.0f)) - ,m_timeOfImpact(dgFloat32 (1.0e10f)) - ,m_impulseSpeed (dgFloat32 (0.0f)) - ,m_contactPruningTolereance(world->GetContactMergeTolerance()) - ,m_broadphaseLru(0) - ,m_killContact(0) - ,m_isNewContact(1) - ,m_skeletonIntraCollision(1) - ,m_skeletonSelftCollision(1) -{ - dgAssert ((((dgUnsigned64) this) & 15) == 0); - m_maxDOF = 0; - m_isActive = 0; - m_enableCollision = true; - m_constId = m_contactConstraint; - - dgAssert (!body0->m_isdead); - dgAssert (!body1->m_isdead); - - if (body0->m_invMass.m_w > dgFloat32(0.0f)) { - m_body0 = body0; - m_body1 = body1; - } else { - m_body0 = body1; - m_body1 = body0; - } - - if (world->m_onCreateContact) { - world->m_onCreateContact(world, this); - } -} - -dgContact::dgContact(dgContact* const clone) - :dgConstraint(*clone) - ,dgList<dgContactMaterial>(clone->GetAllocator()) - ,m_positAcc(clone->m_positAcc) - ,m_rotationAcc(clone->m_rotationAcc) - ,m_separtingVector (clone->m_separtingVector) - ,m_material(clone->m_material) - ,m_closestDistance(clone->m_closestDistance) - ,m_separationDistance(clone->m_separationDistance) - ,m_timeOfImpact(clone->m_timeOfImpact) - ,m_impulseSpeed (clone->m_impulseSpeed) - ,m_contactPruningTolereance(clone->m_contactPruningTolereance) - ,m_broadphaseLru(clone->m_broadphaseLru) - ,m_killContact(clone->m_killContact) - ,m_isNewContact(clone->m_isNewContact) - ,m_skeletonIntraCollision(clone->m_skeletonIntraCollision) - ,m_skeletonSelftCollision(clone->m_skeletonSelftCollision) -{ - dgAssert((((dgUnsigned64) this) & 15) == 0); - m_body0 = clone->m_body0; - m_body1 = clone->m_body1; - m_maxDOF = clone->m_maxDOF; - m_constId = m_contactConstraint; - m_isActive = clone->m_isActive; - m_enableCollision = clone->m_enableCollision; - Merge (*clone); - - dgAssert(!m_body0->m_isdead); - dgAssert(!m_body1->m_isdead); - - if (m_body0->m_world->m_onCreateContact) { - dgAssert(clone->m_body0); - m_body0->m_world->m_onCreateContact(clone->m_body0->m_world, this); - } -} - -dgContact::~dgContact() -{ - dgAssert(m_body0); - if (m_body0->m_world && m_body0->m_world->m_onDestroyContact) { - m_body0->m_world->m_onDestroyContact(m_body0->m_world, this); - } - - dgList<dgContactMaterial>::RemoveAll(); -} - -void dgContact::SwapBodies() -{ - dgSwap (m_body0, m_body1); - dgSwap (m_link0, m_link1); -} - -void dgContact::GetInfo (dgConstraintInfo* const info) const -{ - memset (info, 0, sizeof (dgConstraintInfo)); - InitInfo (info); - info->m_collideCollisionOn = GetCount(); - strcpy (info->m_discriptionType, "contact"); -} - -void dgContact::CalculatePointDerivative (dgInt32 index, dgContraintDescritor& desc, const dgVector& dir, const dgPointParam& param) const -{ - dgAssert (m_body0); - dgAssert (m_body1); - - dgJacobian &jacobian0 = desc.m_jacobian[index].m_jacobianM0; - dgJacobian &jacobian1 = desc.m_jacobian[index].m_jacobianM1; - jacobian0.m_linear = dir; - jacobian1.m_linear = dir * dgVector::m_negOne; - - jacobian0.m_angular = param.m_r0.CrossProduct(dir); - jacobian1.m_angular = dir.CrossProduct(param.m_r1); - - dgAssert(jacobian0.m_linear.m_w == dgFloat32(0.0f)); - dgAssert(jacobian0.m_angular.m_w == dgFloat32(0.0f)); - dgAssert(jacobian1.m_linear.m_w == dgFloat32(0.0f)); - dgAssert(jacobian1.m_angular.m_w == dgFloat32(0.0f)); -} - -bool dgContact::EstimateCCD (dgFloat32 timestep) const -{ -//return false; - dgAssert (m_body0->m_continueCollisionMode | m_body1->m_continueCollisionMode); - const dgVector& veloc0 = m_body0->m_veloc; - const dgVector& veloc1 = m_body1->m_veloc; - const dgVector& omega0 = m_body0->m_omega; - const dgVector& omega1 = m_body1->m_omega; - const dgVector& com0 = m_body0->m_globalCentreOfMass; - const dgVector& com1 = m_body1->m_globalCentreOfMass; - const dgCollisionInstance* const collision0 = m_body0->m_collision; - const dgCollisionInstance* const collision1 = m_body1->m_collision; - const dgFloat32 dist = dgMax(m_body0->m_collision->GetBoxMinRadius(), m_body1->m_collision->GetBoxMinRadius()) * dgFloat32(0.25f); - - const dgVector relVeloc(veloc1 - veloc0); - const dgVector relOmega(omega1 - omega0); - const dgFloat32 relVelocMag2(relVeloc.DotProduct(relVeloc).GetScalar()); - const dgFloat32 relOmegaMag2(relOmega.DotProduct(relOmega).GetScalar()); - - if ((relOmegaMag2 > dgFloat32(1.0f)) || ((relVelocMag2 * timestep * timestep) > (dist * dist))) { - dgWorld* const world = m_body0->GetWorld(); - dgTriplex normals[16]; - dgTriplex points[16]; - dgInt64 attrib0[16]; - dgInt64 attrib1[16]; - dgFloat32 penetrations[16]; - dgFloat32 timeToImpact = timestep; - dgTrace (("function %s on file %s is too slow, consider using supsteps\n", __FILE__, __FUNCTION__)); - - const dgInt32 ccdContactCount = world->CollideContinue( - collision0, m_body0->m_matrix, veloc0, omega0, collision1, m_body1->m_matrix, veloc1, omega1, - timeToImpact, points, normals, penetrations, attrib0, attrib1, 6, 0); - - for (dgInt32 j = 0; j < ccdContactCount; j++) { - dgVector point(&points[j].m_x); - dgVector normal(&normals[j].m_x); - point = point & dgVector::m_triplexMask; - normal = normal & dgVector::m_triplexMask; - dgVector vel0(veloc0 + omega0 * (point - com0)); - dgVector vel1(veloc1 + omega1 * (point - com1)); - dgVector vRel(vel1 - vel0); - dgFloat32 contactDistTravel = vRel.DotProduct(normal).GetScalar() * timestep; - if (contactDistTravel > dist) { - return true; - } - } - } - - return false; -} - -dgUnsigned32 dgContact::JacobianDerivative (dgContraintDescritor& params) -{ - dgInt32 frictionIndex = 0; - m_impulseSpeed = dgFloat32 (0.0f); - if (m_maxDOF) { - dgInt32 i = 0; - frictionIndex = GetCount(); - for (dgList<dgContactMaterial>::dgListNode* node = GetFirst(); node; node = node->GetNext()) { - const dgContactMaterial& contact = node->GetInfo(); - JacobianContactDerivative (params, contact, i, frictionIndex); - i ++; - } - } - - return dgUnsigned32 (frictionIndex); -} - -void dgContact::JacobianContactDerivative (dgContraintDescritor& params, const dgContactMaterial& contact, dgInt32 normalIndex, dgInt32& frictionIndex) -{ - dgPointParam pointData; - InitPointParam (pointData, dgFloat32 (1.0f), contact.m_point, contact.m_point); - CalculatePointDerivative (normalIndex, params, contact.m_normal, pointData); - - const dgVector veloc0 = m_body0->m_veloc; - const dgVector omega0 = m_body0->m_omega; - const dgVector veloc1 = m_body1->m_veloc; - const dgVector omega1 = m_body1->m_omega; - - const dgVector gyroAlpha0(m_body0->m_gyroAlpha); - const dgVector gyroAlpha1(m_body1->m_gyroAlpha); - - dgAssert(contact.m_normal.m_w == dgFloat32(0.0f)); - const dgJacobian &normalJacobian0 = params.m_jacobian[normalIndex].m_jacobianM0; - const dgJacobian &normalJacobian1 = params.m_jacobian[normalIndex].m_jacobianM1; - - const dgFloat32 impulseOrForceScale = (params.m_timestep > dgFloat32(0.0f)) ? params.m_invTimestep : dgFloat32(1.0f); - const dgFloat32 restitutionCoefficient = contact.m_restitution; - -#ifdef DG_NEW_RESTITUTION_METHOD - const dgFloat32 relSpeed = -(normalJacobian0.m_linear * veloc0 + normalJacobian0.m_angular * omega0 + normalJacobian1.m_linear * veloc1 + normalJacobian1.m_angular * omega1).AddHorizontal().GetScalar(); - const dgFloat32 penetrationStiffness = MAX_PENETRATION_STIFFNESS * contact.m_softness; - const dgFloat32 penetration = dgClamp(contact.m_penetration - DG_RESTING_CONTACT_PENETRATION, dgFloat32(0.0f), dgFloat32(0.5f)); - - const dgFloat32 penetrationSpeed = penetration * penetrationStiffness; - - dgFloat32 jointSpeed = dgFloat32(0.0f); - if (relSpeed >= dgFloat32(0.0f)) { - const dgFloat32 restitutionSpeed = restitutionCoefficient * relSpeed; - const dgFloat32 bounceSpeed = dgMax(restitutionSpeed, penetrationSpeed); - jointSpeed = bounceSpeed + dgMax(relSpeed, dgFloat32(0.0f)); - } else { - const dgFloat32 restitutionSpeed = relSpeed + penetrationSpeed; - jointSpeed = dgMax(restitutionSpeed, dgFloat32(0.0f)); - } - - const dgFloat32 relGyro = (normalJacobian0.m_angular * m_body0->m_gyroAlpha + normalJacobian1.m_angular * m_body1->m_gyroAlpha).AddHorizontal().GetScalar(); - - params.m_jointAccel[normalIndex] = relGyro + jointSpeed * impulseOrForceScale; - if (contact.m_flags & dgContactMaterial::m_overrideNormalAccel) { - params.m_jointAccel[normalIndex] += contact.m_normal_Force.m_force; - } - - const bool isHardContact = !(contact.m_flags & dgContactMaterial::m_isSoftContact); - - params.m_flags[normalIndex] = contact.m_flags & dgContactMaterial::m_isSoftContact; - params.m_penetration[normalIndex] = penetration; - params.m_restitution[normalIndex] = restitutionCoefficient; - params.m_penetrationStiffness[normalIndex] = penetrationStiffness; - params.m_forceBounds[normalIndex].m_low = dgFloat32(0.0f); - params.m_forceBounds[normalIndex].m_normalIndex = DG_INDEPENDENT_ROW; - params.m_forceBounds[normalIndex].m_jointForce = (dgForceImpactPair*)&contact.m_normal_Force; - params.m_diagonalRegularizer[normalIndex] = isHardContact ? DG_DIAGONAL_REGULARIZER : dgMax(DG_DIAGONAL_REGULARIZER, contact.m_skinThickness); - -#else - - dgFloat32 relSpeed = -(normalJacobian0.m_linear * veloc0 + normalJacobian0.m_angular * omega0 + normalJacobian1.m_linear * veloc1 + normalJacobian1.m_angular * omega1).AddHorizontal().GetScalar(); - dgFloat32 penetration = dgClamp(contact.m_penetration - DG_RESTING_CONTACT_PENETRATION, dgFloat32(0.0f), dgFloat32(0.5f)); - params.m_flags[normalIndex] = contact.m_flags & dgContactMaterial::m_isSoftContact; - params.m_penetration[normalIndex] = penetration; - params.m_restitution[normalIndex] = restitutionCoefficient; - params.m_forceBounds[normalIndex].m_low = dgFloat32(0.0f); - params.m_forceBounds[normalIndex].m_normalIndex = DG_INDEPENDENT_ROW; - params.m_forceBounds[normalIndex].m_jointForce = (dgForceImpactPair*)&contact.m_normal_Force; - - const dgFloat32 restitutionVelocity = (relSpeed > REST_RELATIVE_VELOCITY) ? relSpeed * restitutionCoefficient : dgFloat32(0.0f); - m_impulseSpeed = dgMax(m_impulseSpeed, restitutionVelocity); - - dgFloat32 penetrationStiffness = MAX_PENETRATION_STIFFNESS * contact.m_softness; - dgFloat32 penetrationVeloc = penetration * penetrationStiffness; - dgAssert(dgAbs(penetrationVeloc - MAX_PENETRATION_STIFFNESS * contact.m_softness * penetration) < dgFloat32(1.0e-6f)); - params.m_penetrationStiffness[normalIndex] = penetrationStiffness; - relSpeed += dgMax(restitutionVelocity, penetrationVeloc); - - const bool isHardContact = !(contact.m_flags & dgContactMaterial::m_isSoftContact); - params.m_diagonalRegularizer[normalIndex] = isHardContact ? DG_DIAGONAL_REGULARIZER : dgMax (DG_DIAGONAL_REGULARIZER, contact.m_skinThickness); - const dgFloat32 relGyro = (normalJacobian0.m_angular * m_body0->m_gyroAlpha + normalJacobian1.m_angular * m_body1->m_gyroAlpha).AddHorizontal().GetScalar(); - - params.m_jointAccel[normalIndex] = relGyro + relSpeed * impulseOrForceScale; - if (contact.m_flags & dgContactMaterial::m_overrideNormalAccel) { - params.m_jointAccel[normalIndex] += contact.m_normal_Force.m_force; - } -#endif - - // first dir friction force - if (contact.m_flags & dgContactMaterial::m_friction0Enable) { - dgInt32 jacobIndex = frictionIndex; - frictionIndex += 1; - dgAssert (contact.m_dir0.m_w == dgFloat32 (0.0f)); - CalculatePointDerivative (jacobIndex, params, contact.m_dir0, pointData); - - const dgJacobian &jacobian0 = params.m_jacobian[jacobIndex].m_jacobianM0; - const dgJacobian &jacobian1 = params.m_jacobian[jacobIndex].m_jacobianM1; - dgFloat32 relVelocErr = -(jacobian0.m_linear * veloc0 + jacobian0.m_angular * omega0 + jacobian1.m_linear * veloc1 + jacobian1.m_angular * omega1).AddHorizontal().GetScalar(); - - params.m_flags[jacobIndex] = 0; - params.m_forceBounds[jacobIndex].m_normalIndex = dgInt16 ((contact.m_flags & dgContactMaterial::m_override0Friction) ? DG_INDEPENDENT_ROW : normalIndex); - params.m_diagonalRegularizer[jacobIndex] = DG_DIAGONAL_REGULARIZER; - - params.m_restitution[jacobIndex] = dgFloat32(0.0f); - params.m_penetration[jacobIndex] = dgFloat32(0.0f); - - params.m_penetrationStiffness[jacobIndex] = dgFloat32 (0.0f); - if (contact.m_flags & dgContactMaterial::m_override0Accel) { - // note: using restitution been negative to indicate that the acceleration was override - params.m_restitution[jacobIndex] = dgFloat32 (-1.0f); - params.m_jointAccel[jacobIndex] = contact.m_dir0_Force.m_force; - } else { - const dgFloat32 relFrictionGyro = (jacobian0.m_angular * gyroAlpha0 + jacobian1.m_angular * gyroAlpha1).AddHorizontal().GetScalar(); - params.m_restitution[jacobIndex] = dgFloat32 (0.0f); - params.m_jointAccel[jacobIndex] = relFrictionGyro + relVelocErr * impulseOrForceScale; - } - if (dgAbs (relVelocErr) > MAX_DYNAMIC_FRICTION_SPEED) { - params.m_forceBounds[jacobIndex].m_low = -contact.m_dynamicFriction0; - params.m_forceBounds[jacobIndex].m_upper = contact.m_dynamicFriction0; - } else { - params.m_forceBounds[jacobIndex].m_low = -contact.m_staticFriction0; - params.m_forceBounds[jacobIndex].m_upper = contact.m_staticFriction0; - } - params.m_forceBounds[jacobIndex].m_jointForce = (dgForceImpactPair*)&contact.m_dir0_Force; - } - - if (contact.m_flags & dgContactMaterial::m_friction1Enable) { - dgInt32 jacobIndex = frictionIndex; - frictionIndex += 1; - dgAssert (contact.m_dir1.m_w == dgFloat32 (0.0f)); - CalculatePointDerivative (jacobIndex, params, contact.m_dir1, pointData); - - const dgJacobian &jacobian0 = params.m_jacobian[jacobIndex].m_jacobianM0; - const dgJacobian &jacobian1 = params.m_jacobian[jacobIndex].m_jacobianM1; - dgFloat32 relVelocErr = -(jacobian0.m_linear * veloc0 + jacobian0.m_angular * omega0 + jacobian1.m_linear * veloc1 + jacobian1.m_angular * omega1).AddHorizontal().GetScalar(); - - params.m_flags[jacobIndex] = 0; - params.m_forceBounds[jacobIndex].m_normalIndex = dgInt16 ((contact.m_flags & dgContactMaterial::m_override1Friction) ? DG_INDEPENDENT_ROW : normalIndex); - params.m_diagonalRegularizer[jacobIndex] = DG_DIAGONAL_REGULARIZER; - - params.m_restitution[jacobIndex] = dgFloat32 (0.0f); - params.m_penetration[jacobIndex] = dgFloat32 (0.0f); - params.m_penetrationStiffness[jacobIndex] = dgFloat32 (0.0f); - if (contact.m_flags & dgContactMaterial::m_override1Accel) { - // note: using restitution been negative to indicate that the acceleration was override - params.m_restitution[jacobIndex] = dgFloat32 (-1.0f); - params.m_jointAccel[jacobIndex] = contact.m_dir1_Force.m_force; - } else { - const dgFloat32 relFrictionGyro = (jacobian0.m_angular * gyroAlpha0 + jacobian1.m_angular * gyroAlpha1).AddHorizontal().GetScalar(); - params.m_restitution[jacobIndex] = dgFloat32 (0.0f); - params.m_jointAccel[jacobIndex] = relFrictionGyro + relVelocErr * impulseOrForceScale; - } - if (dgAbs (relVelocErr) > MAX_DYNAMIC_FRICTION_SPEED) { - params.m_forceBounds[jacobIndex].m_low = - contact.m_dynamicFriction1; - params.m_forceBounds[jacobIndex].m_upper = contact.m_dynamicFriction1; - } else { - params.m_forceBounds[jacobIndex].m_low = - contact.m_staticFriction1; - params.m_forceBounds[jacobIndex].m_upper = contact.m_staticFriction1; - } - params.m_forceBounds[jacobIndex].m_jointForce = (dgForceImpactPair*)&contact.m_dir1_Force; - } -} - -void dgContact::JointAccelerations(dgJointAccelerationDecriptor* const params) -{ - const dgVector& bodyVeloc0 = m_body0->m_veloc; - const dgVector& bodyOmega0 = m_body0->m_omega; - const dgVector& bodyVeloc1 = m_body1->m_veloc; - const dgVector& bodyOmega1 = m_body1->m_omega; - - const dgInt32 count = params->m_rowsCount; - - dgFloat32 timestep = dgFloat32 (1.0f); - dgFloat32 invTimestep = dgFloat32 (1.0f); - if (params->m_timeStep > dgFloat32 (0.0f)) { - timestep = params->m_timeStep; - invTimestep = params->m_invTimeStep; - } - - dgRightHandSide* const rightHandSide = params->m_rightHandSide; - const dgLeftHandSide* const leftHandSide = params->m_leftHandSide; - - const dgVector gyroAlpha0(m_body0->m_gyroAlpha); - const dgVector gyroAlpha1(m_body1->m_gyroAlpha); - - for (dgInt32 k = 0; k < count; k ++) { - // note: using restitution been negative to indicate that the acceleration was override - dgRightHandSide* const rhs = &rightHandSide[k]; - if (rhs->m_restitution >= dgFloat32 (0.0f)) { - const dgLeftHandSide* const row = &leftHandSide[k]; - const dgJacobian &jacobian0 = row->m_Jt.m_jacobianM0; - const dgJacobian &jacobian1 = row->m_Jt.m_jacobianM1; - - dgVector relVeloc (jacobian0.m_linear * bodyVeloc0 + jacobian0.m_angular * bodyOmega0 + jacobian1.m_linear * bodyVeloc1 + jacobian1.m_angular * bodyOmega1); - dgFloat32 vRel = relVeloc.AddHorizontal().GetScalar(); - dgFloat32 aRel = rhs->m_deltaAccel; - - if (rhs->m_normalForceIndex == DG_INDEPENDENT_ROW) { - dgAssert (rhs->m_restitution >= 0.0f); - dgAssert (rhs->m_restitution <= 2.0f); - - #ifdef DG_NEW_RESTITUTION_METHOD - //const dgFloat32 penetration = rhs->m_penetration; - if (vRel < dgFloat32(0.0f)) { - const dgFloat32 restitutionSpeed = rhs->m_restitution * vRel; - const dgFloat32 penetrationSpeed = - rhs->m_penetration * rhs->m_penetrationStiffness; - const dgFloat32 penetrationCorrection = -vRel * timestep * rhs->m_restitution; - if (penetrationCorrection > rhs->m_penetration) { - rhs->m_penetration = dgFloat32(0.001f); - } - const dgFloat32 bounceSpeed = dgMin(restitutionSpeed, penetrationSpeed); - vRel += bounceSpeed; - } else { - const dgFloat32 penetrationSpeed = rhs->m_penetration * rhs->m_penetrationStiffness; - const dgFloat32 penetrationCorrection = vRel * timestep * rhs->m_restitution; - if (penetrationCorrection > rhs->m_penetration) { - rhs->m_penetration = dgFloat32(0.001f); - } - vRel = (vRel < penetrationSpeed) ? penetrationSpeed : dgFloat32 (0.0f); - } - - #else - dgFloat32 penetrationVeloc = dgFloat32 (0.0f); - dgFloat32 restitution = (vRel <= dgFloat32 (0.0f)) ? (dgFloat32 (1.0f) + rhs->m_restitution) : dgFloat32 (1.0f); - if (rhs->m_penetration > DG_RESTING_CONTACT_PENETRATION * dgFloat32 (0.125f)) { - if (vRel > dgFloat32 (0.0f)) { - dgFloat32 penetrationCorrection = vRel * timestep; - dgAssert (penetrationCorrection >= dgFloat32 (0.0f)); - rhs->m_penetration = dgMax (dgFloat32 (0.0f), rhs->m_penetration - penetrationCorrection); - } else { - dgFloat32 penetrationCorrection = -vRel * timestep * rhs->m_restitution * dgFloat32 (8.0f); - if (penetrationCorrection > rhs->m_penetration) { - rhs->m_penetration = dgFloat32 (0.001f); - } - } - penetrationVeloc = -(rhs->m_penetration * rhs->m_penetrationStiffness); - } - vRel = vRel * restitution + penetrationVeloc; - #endif - } - - const dgFloat32 relGyro = (jacobian0.m_angular * gyroAlpha0 + jacobian1.m_angular * gyroAlpha1).AddHorizontal().GetScalar(); - rhs->m_coordenateAccel = relGyro + aRel - vRel * invTimestep; - } - } -} - diff --git a/thirdparty/src/newton/dgPhysics/dgContact.h b/thirdparty/src/newton/dgPhysics/dgContact.h deleted file mode 100644 index e01d6bb68..000000000 --- a/thirdparty/src/newton/dgPhysics/dgContact.h +++ /dev/null @@ -1,380 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGCONTACT_H__ -#define __DGCONTACT_H__ - -#include "dgConstraint.h" -#include "dgContactSolver.h" - -class dgBody; -class dgWorld; -class dgContact; -class dgContactPoint; -class dgContactMaterial; -class dgPolygonMeshDesc; -class dgCollisionInstance; - - -#define DG_MAX_CONTATCS 128 -#define DG_RESTING_CONTACT_PENETRATION (DG_PENETRATION_TOL + dgFloat32 (1.0f / 1024.0f)) -#define DG_DIAGONAL_PRECONDITIONER dgFloat32 (25.0f) - -class dgContactList: public dgArray<dgContact*> -{ - public: - dgContactList(dgMemoryAllocator* const allocator) - :dgArray<dgContact*>(allocator) - ,m_contactCount(0) - ,m_contactCountReset(0) - ,m_activeContactCount(0) - { - Resize (1024 * 32); - } - - ~dgContactList() - { - } - - void Push (dgContact* const contact) - { - dgInt32 index = dgAtomicExchangeAndAdd(&m_contactCount, 1); - dgAssert (index < GetElementsCapacity()); - (*this)[index] = contact; - } - - dgInt32 m_contactCount; - dgInt32 m_contactCountReset; - dgInt32 m_activeContactCount; -}; - -DG_MSC_VECTOR_ALIGNMENT -class dgCollisionParamProxy -{ - public: - dgCollisionParamProxy(dgContact* const contact, dgContactPoint* const contactBuffer, dgInt32 threadIndex, bool ccdMode, bool intersectionTestOnly) - :m_normal(dgVector::m_zero) - ,m_closestPointBody0(dgVector::m_zero) - ,m_closestPointBody1(dgVector::m_zero) - ,m_contactJoint(contact) - ,m_contacts(contactBuffer) - ,m_polyMeshData(NULL) - ,m_threadIndex(threadIndex) - ,m_continueCollision(ccdMode) - ,m_intersectionTestOnly(intersectionTestOnly) - { - } - - dgVector m_normal; - dgVector m_closestPointBody0; - dgVector m_closestPointBody1; - dgContact* m_contactJoint; - dgBody* m_body0; - dgBody* m_body1; - dgCollisionInstance* m_instance0; - dgCollisionInstance* m_instance1; - dgContactPoint* m_contacts; - dgPolygonMeshDesc* m_polyMeshData; - - dgFloat32 m_timestep; - dgFloat32 m_skinThickness; - dgInt32 m_threadIndex; - dgInt32 m_maxContacts; - bool m_continueCollision; - bool m_intersectionTestOnly; -} DG_GCC_VECTOR_ALIGNMENT; - - -DG_MSC_VECTOR_ALIGNMENT -class dgContactPoint -{ - public: - dgVector m_point; - dgVector m_normal; - const dgBody* m_body0; - const dgBody* m_body1; - const dgCollisionInstance* m_collision0; - const dgCollisionInstance* m_collision1; - dgInt64 m_shapeId0; - dgInt64 m_shapeId1; - dgFloat32 m_penetration; -}DG_GCC_VECTOR_ALIGNMENT; - - -DG_MSC_VECTOR_ALIGNMENT -class dgContactMaterial: public dgContactPoint -{ - public: - enum { - m_isSoftContact = 1<<0, - m_collisionEnable = 1<<1, - m_friction0Enable = 1<<2, - m_friction1Enable = 1<<3, - m_override0Accel = 1<<4, - m_override1Accel = 1<<5, - m_override0Friction = 1<<6, - m_override1Friction = 1<<7, - m_overrideNormalAccel = 1<<8, - m_resetSkeletonSelfCollision = 1<<9, - m_resetSkeletonIntraCollision = 1<<10, - }; - - DG_MSC_VECTOR_ALIGNMENT - class dgUserContactPoint - { - public: - dgVector m_point; - dgVector m_normal; - dgUnsigned64 m_shapeId0; - dgUnsigned64 m_shapeId1; - dgFloat32 m_penetration; - dgUnsigned32 m_unused[3]; - } DG_GCC_VECTOR_ALIGNMENT; - - typedef bool (dgApi *OnAABBOverlap) (dgContact& contactJoint, dgFloat32 timestep, dgInt32 threadIndex); - typedef void (dgApi *OnContactCallback) (dgContact& contactJoint, dgFloat32 timestep, dgInt32 threadIndex); - typedef bool (dgApi *OnCompoundCollisionPrefilter) (dgContact& contactJoint, dgFloat32 timestep, const dgBody* bodyA, const void* collisionNodeA, const dgBody* bodyB, const void* collisionNodeB, dgInt32 threadIndex); - typedef bool (dgApi *OnContactGeneration) (const dgContactMaterial& material, const dgBody& body0, const dgCollisionInstance* collisionIntance0, const dgBody& body1, const dgCollisionInstance* collisionIntance1, dgUserContactPoint* const contacts, dgInt32 maxCount, dgInt32 threadIndex); - - dgContactMaterial(); - void* GetUserData () const; - void SetUserData (void* const userData); - void SetAsSoftContact (dgFloat32 regularizer); - void SetCollisionGenerationCallback (OnContactGeneration contactGeneration); - void SetCollisionCallback (OnAABBOverlap abbOvelap, OnContactCallback callback); - void SetCompoundCollisionCallback (OnCompoundCollisionPrefilter abbCompounndOvelap); - - dgVector m_dir0; - dgVector m_dir1; - dgForceImpactPair m_normal_Force; - dgForceImpactPair m_dir0_Force; - dgForceImpactPair m_dir1_Force; - dgFloat32 m_restitution; - dgFloat32 m_staticFriction0; - dgFloat32 m_staticFriction1; - dgFloat32 m_dynamicFriction0; - dgFloat32 m_dynamicFriction1; - dgFloat32 m_softness; - dgFloat32 m_skinThickness; - dgInt32 m_flags; - - private: - void *m_userData; - OnAABBOverlap m_aabbOverlap; - OnContactCallback m_processContactPoint; - OnContactGeneration m_contactGeneration; - OnCompoundCollisionPrefilter m_compoundAABBOverlap; - - friend class dgWorld; - friend class dgBroadPhase; - friend class dgCollisionScene; - friend class dgCollisionCompound; - friend class dgWorldDynamicUpdate; - friend class dgSolverWorlkerThreads; - friend class dgCollidingPairCollector; - friend class dgBroadPhaseMaterialCallbackWorkerThread; - -}DG_GCC_VECTOR_ALIGNMENT; - - -DG_MSC_VECTOR_ALIGNMENT -class dgContact: public dgConstraint, public dgList<dgContactMaterial> -{ - public: - void ResetSkeletonSelftCollision(); - void ResetSkeletonIntraCollision(); - dgFloat32 GetTimeOfImpact() const; - dgFloat32 GetClosestDistance() const; - void SetTimeOfImpact(dgFloat32 timetoImpact); - const dgContactMaterial* GetMaterial() const; - - dgFloat32 GetPruningTolerance() const; - void SetPruningTolerance(dgFloat32 tolerance); - - protected: - dgContact(dgContact* const clone); - dgContact(dgWorld* const world, const dgContactMaterial* const material, dgBody* const body0, dgBody* const body1); - virtual ~dgContact(); - - DG_CLASS_ALLOCATOR(allocator) - - virtual void ResetMaxDOF(); - virtual dgFloat32 GetImpulseContactSpeed() const; - virtual void SetImpulseContactSpeed(dgFloat32 speed); - virtual void GetInfo (dgConstraintInfo* const info) const; - virtual dgUnsigned32 JacobianDerivative (dgContraintDescritor& params); - virtual void JointAccelerations (dgJointAccelerationDecriptor* const params); - virtual bool IsDeformable() const ; - virtual void SetDestructorCallback (OnConstraintDestroy destructor); - - bool IsSkeletonIntraCollision() const; - bool IsSkeletonSelftCollision() const; - - void JacobianContactDerivative (dgContraintDescritor& params, const dgContactMaterial& contact, dgInt32 normalIndex, dgInt32& frictionIndex); - void CalculatePointDerivative (dgInt32 index, dgContraintDescritor& desc, const dgVector& dir, const dgPointParam& param) const; - - void SwapBodies(); - bool EstimateCCD (dgFloat32 timestep) const; - - dgVector m_positAcc; - dgQuaternion m_rotationAcc; - dgVector m_separtingVector; - const dgContactMaterial* m_material; - dgFloat32 m_closestDistance; - dgFloat32 m_separationDistance; - dgFloat32 m_timeOfImpact; - dgFloat32 m_impulseSpeed; - dgFloat32 m_contactPruningTolereance; - dgUnsigned32 m_broadphaseLru; - dgUnsigned32 m_killContact : 1; - dgUnsigned32 m_isNewContact : 1; - dgUnsigned32 m_skeletonIntraCollision : 1; - dgUnsigned32 m_skeletonSelftCollision : 1; - - friend class dgBody; - friend class dgWorld; - friend class dgDeadBodies; - friend class dgBroadPhase; - friend class dgContactList; - friend class dgContactSolver; - friend class dgCollisionScene; - friend class dgCollisionConvex; - friend class dgCollisionCompound; - friend class dgBodyMasterListRow; - friend class dgWorldDynamicUpdate; - friend class dgSolverWorlkerThreads; - friend class dgCollisionConvexPolygon; - friend class dgCollidingPairCollector; - -}DG_GCC_VECTOR_ALIGNMENT; - -DG_INLINE void dgContactMaterial::SetCollisionCallback (OnAABBOverlap aabbOverlap, OnContactCallback contact) -{ - m_aabbOverlap = aabbOverlap; - m_processContactPoint = contact; -} - -DG_INLINE void dgContactMaterial::SetCollisionGenerationCallback (OnContactGeneration contactGeneration) -{ - m_contactGeneration = contactGeneration; -} - -DG_INLINE void dgContactMaterial::SetCompoundCollisionCallback (OnCompoundCollisionPrefilter aabbOverlap) -{ - m_compoundAABBOverlap = aabbOverlap; -} - -DG_INLINE void* dgContactMaterial::GetUserData () const -{ - return m_userData; -} - -DG_INLINE void dgContactMaterial::SetUserData (void* const userData) -{ - m_userData = userData; -} - -DG_INLINE void dgContactMaterial::SetAsSoftContact(dgFloat32 regularizer) -{ - dgAssert(regularizer >= dgFloat32 (0.0f)); - dgAssert(regularizer <= dgFloat32 (1.0f)); - // re purpose some of the variable to store parameter for soft contact - m_flags |= m_isSoftContact; - m_skinThickness = regularizer; -} - -DG_INLINE const dgContactMaterial* dgContact::GetMaterial() const -{ - return m_material; -} - -DG_INLINE bool dgContact::IsDeformable() const -{ - return false; -} - -DG_INLINE void dgContact::SetDestructorCallback (OnConstraintDestroy destructor) -{ -} - -DG_INLINE void dgContact::SetTimeOfImpact(dgFloat32 timetoImpact) -{ - m_timeOfImpact = timetoImpact; -} - -DG_INLINE dgFloat32 dgContact::GetTimeOfImpact() const -{ - return m_timeOfImpact; -} - -DG_INLINE dgFloat32 dgContact::GetClosestDistance() const -{ - return m_closestDistance; -} - -DG_INLINE void dgContact::ResetMaxDOF() -{ - m_maxDOF = 0; -} - -DG_INLINE dgFloat32 dgContact::GetPruningTolerance() const -{ - return m_contactPruningTolereance; -} - -DG_INLINE void dgContact::SetPruningTolerance(dgFloat32 tolerance) -{ - m_contactPruningTolereance = dgAbs (tolerance); -} - -DG_INLINE void dgContact::ResetSkeletonIntraCollision() -{ - m_skeletonIntraCollision = 0; -} - -DG_INLINE bool dgContact::IsSkeletonIntraCollision() const -{ - return m_skeletonIntraCollision; -} - -DG_INLINE void dgContact::ResetSkeletonSelftCollision() -{ - m_skeletonSelftCollision = 0; -} - -DG_INLINE bool dgContact::IsSkeletonSelftCollision() const -{ - return m_skeletonSelftCollision; -} - -DG_INLINE dgFloat32 dgContact::GetImpulseContactSpeed() const -{ - return m_impulseSpeed; -} - -DG_INLINE void dgContact::SetImpulseContactSpeed(dgFloat32 speed) -{ - m_impulseSpeed = speed; -} - - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgContactSolver.cpp b/thirdparty/src/newton/dgPhysics/dgContactSolver.cpp deleted file mode 100644 index 277f0402a..000000000 --- a/thirdparty/src/newton/dgPhysics/dgContactSolver.cpp +++ /dev/null @@ -1,1511 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgContactSolver.h" -#include "dgCollisionMesh.h" -#include "dgCollisionConvex.h" -#include "dgCollisionInstance.h" -#include "dgCollisionConvexHull.h" -#include "dgCollisionConvexPolygon.h" - -dgVector dgContactSolver::m_hullDirs[] = -{ - dgVector(dgFloat32(0.577350f), dgFloat32(-0.577350f), dgFloat32(0.577350f), dgFloat32(0.0f)), - dgVector(dgFloat32(-0.577350f), dgFloat32(-0.577350f), dgFloat32(-0.577350f), dgFloat32(0.0f)), - dgVector(dgFloat32(0.577350f), dgFloat32(-0.577350f), dgFloat32(-0.577350f), dgFloat32(0.0f)), - dgVector(dgFloat32(-0.577350f), dgFloat32(0.577350f), dgFloat32(0.577350f), dgFloat32(0.0f)), - dgVector(dgFloat32(0.577350f), dgFloat32(0.577350f), dgFloat32(-0.577350f), dgFloat32(0.0f)), - dgVector(dgFloat32(-0.577350f), dgFloat32(0.577350f), dgFloat32(-0.577350f), dgFloat32(0.0f)), - dgVector(dgFloat32(-0.577350f), dgFloat32(-0.577350f), dgFloat32(0.577350f), dgFloat32(0.0f)), - dgVector(dgFloat32(0.577350f), dgFloat32(0.577350f), dgFloat32(0.577350f), dgFloat32(0.0f)), - dgVector(dgFloat32(0.000000f), dgFloat32(-1.000000f), dgFloat32(0.000000f), dgFloat32(0.0f)), - dgVector(dgFloat32(0.000000f), dgFloat32(1.000000f), dgFloat32(0.000000f), dgFloat32(0.0f)), - dgVector(dgFloat32(1.000000f), dgFloat32(0.000000f), dgFloat32(0.000000f), dgFloat32(0.0f)), - dgVector(dgFloat32(-1.000000f), dgFloat32(0.000000f), dgFloat32(0.000000f), dgFloat32(0.0f)), - dgVector(dgFloat32(0.000000f), dgFloat32(0.000000f), dgFloat32(1.000000f), dgFloat32(0.0f)), - dgVector(dgFloat32(0.000000f), dgFloat32(0.000000f), dgFloat32(-1.000000f), dgFloat32(0.0f)), -}; - -dgInt32 dgContactSolver::m_rayCastSimplex[4][4] = -{ - { 0, 1, 2, 3 }, - { 0, 2, 3, 1 }, - { 2, 1, 3, 0 }, - { 1, 0, 3, 2 }, -}; - -dgContactSolver::dgContactSolver(dgCollisionInstance* const instance) - :dgDownHeap<dgMinkFace*, dgFloat32>(m_heapBuffer, sizeof (m_heapBuffer)) - ,m_proxy (NULL) - ,m_instance0(instance) - ,m_instance1(instance) - ,m_vertexIndex(0) -{ -} - -dgContactSolver::dgContactSolver(dgCollisionParamProxy* const proxy) - :dgDownHeap<dgMinkFace*, dgFloat32>(m_heapBuffer, sizeof (m_heapBuffer)) - ,m_normal (proxy->m_contactJoint->m_separtingVector) - ,m_proxy (proxy) - ,m_instance0(proxy->m_instance0) - ,m_instance1(proxy->m_instance1) - ,m_vertexIndex(0) -{ -} - -DG_INLINE void dgContactSolver::SupportVertex(const dgVector& dir0, dgInt32 vertexIndex) -{ - dgAssert(dir0.m_w == dgFloat32(0.0f)); - dgAssert(dgAbs(dir0.DotProduct(dir0).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-3f)); - dgVector dir1 (dir0.Scale(dgFloat32 (-1.0f))); - - const dgMatrix& matrix0 = m_instance0->m_globalMatrix; - const dgMatrix& matrix1 = m_instance1->m_globalMatrix; - dgVector p(matrix0.TransformVector(m_instance0->SupportVertexSpecial(matrix0.UnrotateVector (dir0), NULL)) & dgVector::m_triplexMask); - dgVector q(matrix1.TransformVector(m_instance1->SupportVertexSpecial(matrix1.UnrotateVector (dir1), NULL)) & dgVector::m_triplexMask); - m_hullDiff[vertexIndex] = p - q; - m_hullSum[vertexIndex] = p + q; -} - - -DG_INLINE dgBigVector dgContactSolver::ReduceLine(dgInt32& indexOut) -{ - const dgBigVector p0(m_hullDiff[0]); - const dgBigVector p1(m_hullDiff[1]); - const dgBigVector dp(p1 - p0); - dgBigVector v; - - const dgFloat64 mag2 = dp.DotProduct(dp).GetScalar(); - dgAssert (mag2 > dgFloat64 (0.0f)); - if (mag2 < dgFloat32(1.0e-24f)) { - v = p0; - indexOut = 1; - } else { - const dgFloat64 alpha0 = - p0.DotProduct(dp).GetScalar(); - if (alpha0 > mag2) { - v = p1; - indexOut = 1; - m_hullSum[0] = m_hullSum[1]; - m_hullDiff[0] = m_hullDiff[1]; - } else if (alpha0 < dgFloat64(0.0f)) { - v = p0; - indexOut = 1; - } else { - v = p0 + dp.Scale(alpha0 / mag2); - } - } - return v; -} - -DG_INLINE dgBigVector dgContactSolver::ReduceTriangle (dgInt32& indexOut) -{ - const dgBigVector p0(m_hullDiff[0]); - const dgBigVector p1(m_hullDiff[1]); - const dgBigVector p2(m_hullDiff[2]); - const dgBigVector e10 (p1 - p0); - const dgBigVector e20 (p2 - p0); - const dgFloat64 a00 = e10.DotProduct(e10).GetScalar(); - const dgFloat64 a11 = e20.DotProduct(e20).GetScalar(); - const dgFloat64 a01 = e10.DotProduct(e20).GetScalar(); - - const dgFloat64 det = a00 * a11 - a01 * a01; - dgAssert(det >= dgFloat32(0.0f)); - if (dgAbs(det) > dgFloat32(1.0e-24f)) { - const dgFloat64 b0 = -e10.DotProduct(p0).GetScalar(); - const dgFloat64 b1 = -e20.DotProduct(p0).GetScalar(); - - const dgFloat64 u2 = b1 * a00 - a01 * b0; - const dgFloat64 u1 = b0 * a11 - a01 * b1; - - if (u2 < dgFloat32(0.0f)) { - // this looks funny but it is correct - } else if (u1 < dgFloat32(0.0f)) { - m_hullSum[1] = m_hullSum[2]; - m_hullDiff[1] = m_hullDiff[2]; - } else if ((u1 + u2) > det) { - m_hullSum[0] = m_hullSum[2]; - m_hullDiff[0] = m_hullDiff[2]; - } else { - return p0 + (e10.Scale(u1) + e20.Scale(u2)).Scale(dgFloat64(1.0f) / det); - } - indexOut = 2; - return ReduceLine(indexOut); - } - // this is a degenerated triangle. this should never happens - dgAssert(0); - return dgBigVector::m_zero; -} - -DG_INLINE dgBigVector dgContactSolver::ReduceTetrahedrum (dgInt32& indexOut) -{ - const dgBigVector p0(m_hullDiff[0]); - const dgBigVector p1(m_hullDiff[1]); - const dgBigVector p2(m_hullDiff[2]); - const dgBigVector p3(m_hullDiff[3]); - const dgBigVector e10(p1 - p0); - const dgBigVector e20(p2 - p0); - const dgBigVector e30(p3 - p0); - - const dgFloat64 d0 = sqrt (e10.DotProduct(e10).GetScalar()); - if (d0 > dgFloat64(0.0f)) { - const dgFloat64 invd0 = dgFloat64(1.0f) / d0; - const dgFloat64 l10 = e20.DotProduct(e10).GetScalar() * invd0; - const dgFloat64 l20 = e30.DotProduct(e10).GetScalar() * invd0; - const dgFloat64 desc11 = e20.DotProduct(e20).GetScalar() - l10 * l10; - if (desc11 > dgFloat64(0.0f)) { - const dgFloat64 d1 = sqrt(desc11); - const dgFloat64 invd1 = dgFloat64(1.0f) / d1; - const dgFloat64 l21 = (e30.DotProduct(e20).GetScalar() - l20 * l10) * invd1; - const dgFloat64 desc22 = e30.DotProduct(e30).GetScalar() - l20 * l20 - l21 * l21; - if (desc22 > dgFloat64(0.0f)) { - const dgFloat64 d2 = sqrt(desc22); - const dgFloat64 invd2 = dgFloat64(1.0f) / d2; - const dgFloat64 b0 = -e10.DotProduct(p0).GetScalar(); - const dgFloat64 b1 = -e20.DotProduct(p0).GetScalar(); - const dgFloat64 b2 = -e30.DotProduct(p0).GetScalar(); - - dgFloat64 u1 = b0 * invd0; - dgFloat64 u2 = (b1 - l10 * u1) * invd1; - dgFloat64 u3 = (b2 - l20 * u1 - l21 * u2) * invd2 * invd2; - u2 = (u2 - l21 * u3) * invd1; - u1 = (u1 - l10 * u2 - l20 * u3) * invd0; - if (u3 < dgFloat64(0.0f)) { - // this looks funny but it is correct - } else if (u2 < dgFloat64(0.0f)) { - m_hullSum[2] = m_hullSum[3]; - m_hullDiff[2] = m_hullDiff[3]; - } else if (u1 < dgFloat64(0.0f)) { - m_hullSum[1] = m_hullSum[3]; - m_hullDiff[1] = m_hullDiff[3]; - } else if (u1 + u2 + u3 > dgFloat64(1.0f)) { - m_hullSum[0] = m_hullSum[3]; - m_hullDiff[0] = m_hullDiff[3]; - } else { - return dgBigVector::m_zero; - } - indexOut = 3; - return ReduceTriangle(indexOut); - } - } - } - // this is a degenerated tetra. this should never happens. - // it seems this does happens about once per several millions calls, - // I will assume is acceptable. No fall back needed - //dgAssert (0); - return dgBigVector::m_zero; -} - - -//DG_INLINE dgInt32 dgContactSolver::CalculateClosestSimplex () -dgInt32 dgContactSolver::CalculateClosestSimplex() -{ - dgBigVector v(dgFloat32 (0.0f)); - dgInt32 index = 1; - if (m_vertexIndex <= 0) { - SupportVertex (m_proxy->m_contactJoint->m_separtingVector, 0); - v = m_hullDiff[0]; - } else { - switch (m_vertexIndex) - { - case 1: - { - v = m_hullDiff[0]; - break; - } - - case 2: - { - v = ReduceLine (m_vertexIndex); - break; - } - - case 3: - { - v = ReduceTriangle (m_vertexIndex); - break; - } - - case 4: - { - v = ReduceTetrahedrum (m_vertexIndex); - break; - } - } - index = m_vertexIndex; - } - - dgVector bestNormal (m_normal); - - dgInt32 iter = 0; - dgInt32 cycling = 0; - dgFloat64 minDist = dgFloat32 (1.0e20f); - dgFloat64 bestNormalDist = dgFloat32 (1.0e20f); - do { - dgFloat64 dist = v.DotProduct(v).GetScalar(); - if (dist < dgFloat32 (1.0e-9f)) { - // very deep penetration, resolve with generic Minkowsky solver - return -index; - } - - if (dist < minDist) { - minDist = dist; - cycling = -1; - } - cycling ++; - if (cycling > 4) { - // for now return -1 - return -index; - } - - const dgVector dir (v.Scale (-dgRsqrt(dist))); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - SupportVertex (dir, index); - - const dgBigVector w (m_hullDiff[index]); - const dgVector wv (w - v); - dgAssert (wv.m_w == dgFloat32 (0.0f)); - const dgFloat64 dist1 = dir.DotProduct(wv).GetScalar(); - if (dist1 < dgFloat64 (1.0e-3f)) { - m_normal = dir; - return index; - } - - if (dist1 < bestNormalDist) { - bestNormal = dir; - bestNormalDist = dist1; - } - - index ++; - switch (index) - { - case 2: - { - v = ReduceLine (index); - break; - } - - case 3: - { - v = ReduceTriangle (index); - break; - } - - case 4: - { - v = ReduceTetrahedrum (index); - break; - } - } - - iter ++; - } while (iter < DG_CONNICS_CONTATS_ITERATIONS); - m_normal = bestNormal; - return (index < 4) ? index : -4; -} - - -DG_INLINE dgMinkFace* dgContactSolver::NewFace() -{ - dgMinkFace* face = (dgMinkFace*)m_freeFace; - if (m_freeFace) { - m_freeFace = m_freeFace->m_next; - } else { - face = &m_facePool[m_faceIndex]; - m_faceIndex++; - if (m_faceIndex >= DG_CONVEX_MINK_MAX_FACES) { - return NULL; - } - } - -#ifdef _DEBUG - memset(face, 0, sizeof (dgMinkFace)); -#endif - return face; -} - -DG_INLINE dgMinkFace* dgContactSolver::AddFace(dgInt32 v0, dgInt32 v1, dgInt32 v2) -{ - dgMinkFace* const face = NewFace(); - face->m_mark = 0; - face->m_vertex[0] = dgInt16(v0); - face->m_vertex[1] = dgInt16(v1); - face->m_vertex[2] = dgInt16(v2); - return face; -} - -DG_INLINE void dgContactSolver::DeleteFace(dgMinkFace* const face) -{ - dgFaceFreeList* const freeFace = (dgFaceFreeList*)face; - freeFace->m_next = m_freeFace; - m_freeFace = freeFace; -} - - -DG_INLINE void dgContactSolver::PushFace(dgMinkFace* const face) -{ - dgInt32 i0 = face->m_vertex[0]; - dgInt32 i1 = face->m_vertex[1]; - dgInt32 i2 = face->m_vertex[2]; - - dgPlane plane(m_hullDiff[i0], m_hullDiff[i1], m_hullDiff[i2]); - dgFloat32 mag2 = plane.DotProduct(plane & dgVector::m_triplexMask).GetScalar(); - face->m_alive = 1; - if (mag2 > dgFloat32(1.0e-16f)) { - face->m_plane = plane.Scale(dgRsqrt(mag2)); - dgMinkFace* face1 = face; - Push(face1, face->m_plane.m_w); - } else { - face->m_plane = dgPlane(dgVector::m_zero); - } -} - -dgInt32 dgContactSolver::CalculateIntersectingPlane(dgInt32 count) -{ - dgAssert(count >= 1); - if (count == 1) { - SupportVertex(m_proxy->m_contactJoint->m_separtingVector.Scale(dgFloat32(-1.0f)), 1); - dgVector err(m_hullDiff[1] - m_hullDiff[0]); - dgAssert (err.m_w == dgFloat32 (0.0f)); - if (err.DotProduct(err).GetScalar() < dgFloat32(1.0e-8f)) { - return -1; - } - count = 2; - } - - if (count == 2) { - dgVector e0(m_hullDiff[1] - m_hullDiff[0]); - dgAssert (e0.m_w == dgFloat32 (0.0f)); - dgAssert(e0.DotProduct(e0).GetScalar() > dgFloat32(0.0f)); - dgMatrix matrix(e0.Scale(dgRsqrt(e0.DotProduct(e0).GetScalar()))); - dgMatrix rotation(dgPitchMatrix(dgFloat32(45.0f * dgDegreeToRad))); - dgFloat32 maxArea = dgFloat32(0.0f); - for (dgInt32 i = 0; i < 8; i++) { - SupportVertex(matrix[1], 3); - dgVector e1(m_hullDiff[3] - m_hullDiff[0]); - dgAssert (e1.m_w == dgFloat32 (0.0f)); - dgVector area(e0.CrossProduct(e1)); - dgFloat32 area2 = area.DotProduct(area).GetScalar(); - if (area2 > maxArea) { - m_hullSum[2] = m_hullSum[3]; - m_hullDiff[2] = m_hullDiff[3]; - maxArea = area2; - } - matrix = rotation * matrix; - } - if (dgAbs (maxArea) < dgFloat32(1e-15f)) { - return -1; - } - dgAssert(maxArea > dgFloat32(0.0f)); - count++; - } - - dgFloat32 volume = dgFloat32(0.0f); - if (count == 3) { - dgVector e10(m_hullDiff[1] - m_hullDiff[0]); - dgVector e20(m_hullDiff[2] - m_hullDiff[0]); - dgVector normal(e10.CrossProduct(e20)); - dgAssert (normal.m_w == dgFloat32 (0.0f)); - dgFloat32 mag2 = normal.DotProduct(normal).GetScalar(); - dgAssert(mag2 > dgFloat32(0.0f)); - normal = normal.Scale(dgRsqrt(mag2)); - SupportVertex(normal, 3); - volume = normal.DotProduct(m_hullDiff[3] - m_hullDiff[0]).GetScalar(); - if (dgAbs(volume) < dgFloat32(1.0e-10f)) { - normal = normal.Scale(dgFloat32(-1.0f)); - SupportVertex(normal, 3); - volume = - normal.DotProduct(m_hullDiff[3] - m_hullDiff[0]).GetScalar(); - if (dgAbs(volume) < dgFloat32(1.0e-10f)) { - volume = dgFloat32(0.0f); - } - } - count = 4; - } else if (count == 4) { - dgVector e0(m_hullDiff[1] - m_hullDiff[0]); - dgVector e1(m_hullDiff[2] - m_hullDiff[0]); - dgVector e2(m_hullDiff[3] - m_hullDiff[0]); - dgVector n(e1.CrossProduct(e2)); - dgAssert (n.m_w == dgFloat32 (0.0f)); - volume = e0.DotProduct(n).GetScalar(); - } - - - dgAssert(count == 4); - if (volume > dgFloat32(0.0f)) { - dgSwap(m_hullSum[1], m_hullSum[0]); - dgSwap(m_hullDiff[1], m_hullDiff[0]); - } - - if (dgAbs(volume) < dgFloat32(1e-15f)) { - - // this volume is unrealizable, let us build a different tetrahedron using the method of core 200 - dgVector e1; - dgVector e2; - dgVector e3; - dgVector normal(dgFloat32(0.0f)); - - const dgInt32 nCount = dgInt32(sizeof(m_hullDirs) / sizeof(m_hullDirs[0])); - const dgFloat32 DG_CALCULATE_SEPARATING_PLANE_ERROR = dgFloat32(1.0f / 1024.0f); - - dgFloat32 error2 = dgFloat32(0.0f); - SupportVertex(m_hullDirs[0], 0); - - dgInt32 i = 1; - for (; i < nCount; i++) { - SupportVertex(m_hullDirs[i], 1); - e1 = m_hullDiff[1] - m_hullDiff[0]; - dgAssert (e1.m_w == dgFloat32 (0.0f)); - error2 = e1.DotProduct(e1).GetScalar(); - if (error2 > DG_CALCULATE_SEPARATING_PLANE_ERROR) { - break; - } - } - - for (i++; i < nCount; i++) { - SupportVertex(m_hullDirs[i], 2); - e2 = m_hullDiff[2] - m_hullDiff[0]; - normal = e1.CrossProduct(e2); - dgAssert (normal.m_w == dgFloat32 (0.0f)); - error2 = normal.DotProduct(normal).GetScalar(); - if (error2 > DG_CALCULATE_SEPARATING_PLANE_ERROR) { - break; - } - } - - error2 = dgFloat32(0.0f); - for (i++; i < nCount; i++) { - SupportVertex(m_hullDirs[i], 3); - e3 = m_hullDiff[3] - m_hullDiff[0]; - dgAssert (normal.m_w == dgFloat32 (0.0f)); - error2 = normal.DotProduct(e3).GetScalar(); - if (dgAbs(error2) > DG_CALCULATE_SEPARATING_PLANE_ERROR) { - break; - } - } - - if (i >= nCount) { -// dgAssert(0); - return -1; - } - - if (error2 > dgFloat32(0.0f)) { - dgSwap(m_hullSum[1], m_hullSum[2]); - dgSwap(m_hullDiff[1], m_hullDiff[2]); - } - -#ifdef _DEBUG - { - dgVector f0(m_hullDiff[1] - m_hullDiff[0]); - dgVector f1(m_hullDiff[2] - m_hullDiff[0]); - dgVector f2(m_hullDiff[3] - m_hullDiff[0]); - dgVector n(f1.CrossProduct(f2)); - dgAssert (n.m_w == dgFloat32 (0.0f)); - dgFloat32 volume1 = f0.DotProduct(n).GetScalar(); - dgAssert(volume1 < dgFloat32(0.0f)); - } -#endif - } - - // clear the face cache!! - Flush(); - m_faceIndex = 0; - m_vertexIndex = 4; - m_freeFace = NULL; - - dgMinkFace* const f0 = AddFace(0, 1, 2); - dgMinkFace* const f1 = AddFace(0, 2, 3); - dgMinkFace* const f2 = AddFace(2, 1, 3); - dgMinkFace* const f3 = AddFace(1, 0, 3); - - f0->m_twin[0] = f3; - f0->m_twin[1] = f2; - f0->m_twin[2] = f1; - - f1->m_twin[0] = f0; - f1->m_twin[1] = f2; - f1->m_twin[2] = f3; - - f2->m_twin[0] = f0; - f2->m_twin[1] = f3; - f2->m_twin[2] = f1; - - f3->m_twin[0] = f0; - f3->m_twin[1] = f1; - f3->m_twin[2] = f2; - - PushFace(f0); - PushFace(f1); - PushFace(f2); - PushFace(f3); - - dgInt32 cycling = 0; - dgInt32 iterCount = 0; - dgFloat32 cyclingMem[4]; - cyclingMem[0] = dgFloat32(1.0e10f); - cyclingMem[1] = dgFloat32(1.0e10f); - cyclingMem[2] = dgFloat32(1.0e10f); - cyclingMem[3] = dgFloat32(1.0e10f); - - const dgFloat32 resolutionScale = dgFloat32(0.125f); - const dgFloat32 minTolerance = DG_PENETRATION_TOL; - - while (GetCount()) { - dgMinkFace* const faceNode = (*this)[0]; - Pop(); - - if (faceNode->m_alive) { - SupportVertex(faceNode->m_plane & dgVector::m_triplexMask, m_vertexIndex); - const dgVector& p = m_hullDiff[m_vertexIndex]; - dgFloat32 dist = faceNode->m_plane.Evalue(p); - dgFloat32 distTolerance = dgMax(dgAbs(faceNode->m_plane.m_w) * resolutionScale, minTolerance); - - if (dist < distTolerance) { - dgVector sum[3]; - dgVector diff[3]; - m_normal = faceNode->m_plane & dgVector::m_triplexMask; - for (dgInt32 i = 0; i < 3; i++) { - dgInt32 j = faceNode->m_vertex[i]; - sum[i] = m_hullSum[j]; - diff[i] = m_hullDiff[j]; - } - for (dgInt32 i = 0; i < 3; i++) { - m_hullSum[i] = sum[i]; - m_hullDiff[i] = diff[i]; - } - return 3; - } - - iterCount++; - bool isCycling = false; - cyclingMem[cycling] = dist; - if (iterCount > 10) { - dgInt32 cyclingIndex = cycling; - for (dgInt32 i = 0; i < 3; i++) { - dgInt32 cyclingIndex0 = (cyclingIndex - 1) & 3; - if (((cyclingMem[cyclingIndex0] - cyclingMem[cyclingIndex]) < dgFloat32(-1.0e-5f))) { - isCycling = true; - cyclingMem[0] = dgFloat32(1.0e10f); - cyclingMem[1] = dgFloat32(1.0e10f); - cyclingMem[2] = dgFloat32(1.0e10f); - cyclingMem[3] = dgFloat32(1.0e10f); - break; - } - cyclingIndex = cyclingIndex0; - } - } - cycling = (cycling + 1) & 3; - - if (!isCycling) { - m_faceStack[0] = faceNode; - dgInt32 stackIndex = 1; - dgInt32 deletedCount = 0; - - while (stackIndex) { - stackIndex--; - dgMinkFace* const face = m_faceStack[stackIndex]; - - if (!face->m_mark && (face->m_plane.Evalue(p) > dgFloat32(0.0f))) { -#ifdef _DEBUG - for (dgInt32 i = 0; i < deletedCount; i++) { - dgAssert(m_deletedFaceList[i] != face); - } -#endif - - m_deletedFaceList[deletedCount] = face; - deletedCount++; - dgAssert(deletedCount < sizeof (m_deletedFaceList) / sizeof (m_deletedFaceList[0])); - face->m_mark = 1; - - for (dgInt32 i = 0; i < 3; i++) { - dgMinkFace* const twinFace = face->m_twin[i]; - if (twinFace && !twinFace->m_mark) { - m_faceStack[stackIndex] = twinFace; - stackIndex++; - dgAssert(stackIndex < sizeof (m_faceStack) / sizeof (m_faceStack[0])); - } - } - } - } - - //dgAssert (SanityCheck()); - dgInt32 newCount = 0; - for (dgInt32 i = 0; i < deletedCount; i++) { - dgMinkFace* const face = m_deletedFaceList[i]; - face->m_alive = 0; - dgAssert(face->m_mark == 1); - dgInt32 j0 = 2; - for (dgInt32 j1 = 0; j1 < 3; j1++) { - dgMinkFace* const twinFace = face->m_twin[j0]; - if (twinFace && !twinFace->m_mark) { - //dgMinkFace* const newFace = AddFace(m_vertexIndex, face->m_vertex[j0], face->m_vertex[j1]); - dgMinkFace* const newFace = NewFace(); - if (newFace) { - newFace->m_mark = 0; - newFace->m_vertex[0] = dgInt16(m_vertexIndex); - newFace->m_vertex[1] = dgInt16(face->m_vertex[j0]); - newFace->m_vertex[2] = dgInt16(face->m_vertex[j1]); - PushFace(newFace); - - newFace->m_twin[1] = twinFace; - dgInt32 index = (twinFace->m_twin[0] == face) ? 0 : ((twinFace->m_twin[1] == face) ? 1 : 2); - twinFace->m_twin[index] = newFace; - - m_coneFaceList[newCount] = newFace; - newCount++; - dgAssert(newCount < sizeof(m_coneFaceList) / sizeof(m_coneFaceList[0])); - } else { - // this is very rare but is does happend with some degenerated faces. - return -1; - } - } - j0 = j1; - } - } - - dgInt32 i0 = newCount - 1; - for (dgInt32 i1 = 0; i1 < newCount; i1++) { - dgMinkFace* const faceA = m_coneFaceList[i0]; - dgAssert(faceA->m_mark == 0); - - dgInt32 j0 = newCount - 1; - for (dgInt32 j1 = 0; j1 < newCount; j1++) { - if (i0 != j0) { - dgMinkFace* const faceB = m_coneFaceList[j0]; - dgAssert(faceB->m_mark == 0); - if (faceA->m_vertex[2] == faceB->m_vertex[1]) { - faceA->m_twin[2] = faceB; - faceB->m_twin[0] = faceA; - break; - } - } - j0 = j1; - } - i0 = i1; - } - - m_vertexIndex++; - dgAssert(m_vertexIndex < sizeof (m_hullDiff) / sizeof (m_hullDiff[0])); - - //dgAssert(SanityCheck()); - } - } else { - DeleteFace(faceNode); - } - } - - return -1; -} - -DG_INLINE void dgContactSolver::CalculateContactFromFeacture(dgInt32 featureType) -{ - dgVector d; - dgVector s; - switch (featureType) - { - case 1: - { - s = m_hullSum[0]; - d = m_hullDiff[0]; - break; - } - case 2: - { - const dgVector& p0 = m_hullDiff[0]; - const dgVector& p1 = m_hullDiff[1]; - dgVector dp(p1 - p0); - dgAssert(dp.m_w == dgFloat32 (0.0f)); - dgAssert(dp.DotProduct(dp).GetScalar() > dgFloat32(0.0f)); - dgFloat32 alpha0 = - p0.DotProduct(dp).GetScalar() / dp.DotProduct(dp).GetScalar(); - dgAssert(alpha0 <= dgFloat32(1.01f)); - dgAssert(alpha0 >= dgFloat32(-0.01f)); - d = p0 + dp.Scale(alpha0); - s = m_hullSum[0] + (m_hullSum[1] - m_hullSum[0]).Scale(alpha0); - break; - } - - case 3: - default: - { - dgVector e10(m_hullDiff[1] - m_hullDiff[0]); - dgVector e20(m_hullDiff[2] - m_hullDiff[0]); - dgVector normal(e10.CrossProduct(e20)); - dgAssert(normal.m_w == dgFloat32 (0.0f)); - dgAssert(normal.DotProduct(normal).GetScalar() > dgFloat32(0.0f)); - - dgFloat32 alphas[3]; - for (dgInt32 i0 = 2, i1 = 0; i1 < 3; i1++) { - const dgVector& p1p0 = m_hullDiff[i0]; - const dgVector& p2p0 = m_hullDiff[i1]; - alphas[i0] = normal.DotProduct(p1p0.CrossProduct(p2p0)).GetScalar(); - i0 = i1; - } - - dgFloat32 alphaDen = alphas[0] + alphas[1] + alphas[2]; - if (alphaDen > dgFloat32(1.0e-16f)) { - dgAssert(alphaDen > dgFloat32(0.0f)); - - alphaDen = dgFloat32(1.0f / alphaDen); - alphas[0] *= alphaDen; - alphas[1] *= alphaDen; - alphas[2] *= alphaDen; - s = m_hullSum[0].Scale(alphas[1]) + m_hullSum[1].Scale(alphas[2]) + m_hullSum[2].Scale(alphas[0]); - d = m_hullDiff[0].Scale(alphas[1]) + m_hullDiff[1].Scale(alphas[2]) + m_hullDiff[2].Scale(alphas[0]); - } else { - // this is a degenerated face that is so small that lose accuracy in 32 bit floats - // get the closest point from the longest edge - - dgAssert(e10.m_w == dgFloat32 (0.0f)); - dgAssert(e20.m_w == dgFloat32 (0.0f)); - dgVector dir((e10.DotProduct(e10).GetScalar() > e20.DotProduct(e20).GetScalar()) ? e10 : e20); - dgInt32 i0 = 0; - dgInt32 i1 = 0; - dgFloat32 dist0 = dir.DotProduct(m_hullDiff[0]).GetScalar(); - dgFloat32 dist1 = -dist0; - for (dgInt32 i = 1; i < 3; i++) { - dgFloat32 test = dir.DotProduct(m_hullDiff[i]).GetScalar(); - if (test > dist0) { - i0 = i; - dist0 = test; - } - test *= dgFloat32(-1.0f); - if (test > dist1) { - i1 = i; - dist1 = test; - } - } - - if (i0 != i1) { - const dgVector& p0 = m_hullDiff[i0]; - const dgVector& p1 = m_hullDiff[i1]; - dgVector dp(p1 - p0); - dgAssert(dp.m_w == dgFloat32 (0.0f)); - dgAssert(dp.DotProduct(dp).GetScalar() > dgFloat32(0.0f)); - dgFloat32 alpha0 = - p0.DotProduct(dp).GetScalar() / dp.DotProduct(dp).GetScalar(); - dgAssert(alpha0 <= dgFloat32(1.01f)); - dgAssert(alpha0 >= dgFloat32(-0.01f)); - d = p0 + dp.Scale(alpha0); - s = m_hullSum[0] + (m_hullSum[i1] - m_hullSum[i0]).Scale(alpha0); - } else { - s = m_hullSum[i0]; - d = m_hullDiff[i0]; - } - } - } - } - - m_closestPoint0 = dgVector::m_half * (s + d); - m_closestPoint1 = dgVector::m_half * (s - d); - dgAssert(m_normal.m_w == dgFloat32 (0.0f)); - dgAssert(dgAbs(m_normal.DotProduct(m_normal).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - m_proxy->m_contactJoint->m_separtingVector = m_normal; -} - - -bool dgContactSolver::SanityCheck() const -{ - for (dgInt32 i = 0; i < m_faceIndex; i++) { - const dgMinkFace* const face = &m_facePool[i]; - if (face->m_alive) { - for (dgInt32 j = 0; j < 3; j++) { - dgMinkFace* const twin = face->m_twin[j]; - if (!twin) { - return false; - } - - if (!twin->m_alive) { - return false; - } - - bool pass = false; - for (dgInt32 k = 0; k < 3; k++) { - if (twin->m_twin[k] == face) { - pass = true; - break; - } - } - if (!pass) { - return pass; - } - } - } - } - return true; -} - - -bool dgContactSolver::CalculateClosestPoints() -{ - dgInt32 simplexPointCount = CalculateClosestSimplex(); - if (simplexPointCount < 0) { - simplexPointCount = CalculateIntersectingPlane(-simplexPointCount); - } - - if (simplexPointCount > 0) { - dgAssert((simplexPointCount > 0) && (simplexPointCount <= 3)); - CalculateContactFromFeacture(simplexPointCount); - - const dgMatrix& matrix0 = m_instance0->m_globalMatrix; - const dgMatrix& matrix1 = m_instance1->m_globalMatrix; - m_closestPoint0 = matrix0.TransformVector(m_instance0->SupportVertexSpecialProjectPoint(matrix0.UntransformVector(m_closestPoint0), matrix0.UnrotateVector(m_normal))); - m_closestPoint1 = matrix1.TransformVector(m_instance1->SupportVertexSpecialProjectPoint(matrix1.UntransformVector(m_closestPoint1), matrix1.UnrotateVector(m_normal.Scale(-1.0f)))); - m_vertexIndex = simplexPointCount; - } - return simplexPointCount >= 0; -} - -dgInt32 dgContactSolver::ConvexPolygonToLineIntersection(const dgVector& normal, dgInt32 count1, dgVector* const shape1, dgInt32 count2, dgVector* const shape2, dgVector* const contactOut, dgVector* const mem) const -{ - dgInt32 count = 0; - dgVector* output = mem; - - dgAssert(count1 >= 3); - dgAssert(count2 <= 2); - dgAssert(normal.m_w == dgFloat32 (0.0f)); - - dgVector* ptr = NULL; - // face line intersection - if (count2 == 2) { - ptr = (dgVector*)&shape2[0]; - dgInt32 i0 = count1 - 1; - for (dgInt32 i1 = 0; i1 < count1; i1++) { - dgVector n(normal.CrossProduct(shape1[i1] - shape1[i0])); - dgAssert(n.m_w == dgFloat32 (0.0f)); - dgAssert(n.DotProduct(n).GetScalar() > dgFloat32(0.0f)); - dgPlane plane(n, - n.DotProduct(shape1[i0]).GetScalar()); - - dgFloat32 test0 = plane.Evalue(ptr[0]); - dgFloat32 test1 = plane.Evalue(ptr[1]); - if (test0 >= dgFloat32(0.0f)) { - if (test1 >= dgFloat32(0.0f)) { - output[count + 0] = ptr[0]; - output[count + 1] = ptr[1]; - count += 2; - } else { - dgVector dp(ptr[1] - ptr[0]); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - dgFloat32 den = plane.DotProduct(dp).GetScalar(); - if (dgAbs(den) < 1.0e-10f) { - den = 1.0e-10f; - } - output[count + 0] = ptr[0]; - dgAssert (dp.m_w == dgFloat32 (0.0f)); - output[count + 1] = ptr[0] - dp.Scale(test0 / den); - count += 2; - } - } else if (test1 >= dgFloat32(0.0f)) { - dgVector dp(ptr[1] - ptr[0]); - dgAssert (dp.m_w == dgFloat32 (0.0f)); - dgFloat32 den = plane.DotProduct(dp).GetScalar(); - if (dgAbs(den) < 1.0e-10f) { - den = 1.0e-10f; - } - dgAssert (dp.m_w == dgFloat32 (0.0f)); - output[count] = ptr[0] - dp.Scale(test0 / den); - count++; - output[count] = ptr[1]; - count++; - } else { - return 0; - } - - - count2 = count; - ptr = output; - output = &output[count]; - count = 0; - i0 = i1; - //dgAssert (output < &pool[sizeof (pool)/sizeof (pool[0])]); - } - } else if (count2 == 1) { - const dgVector& p = shape2[0]; - dgInt32 i0 = count1 - 1; - for (dgInt32 i1 = 0; i1 < count1; i1++) { - dgVector n(normal.CrossProduct(shape1[i1] - shape1[i0])); - dgAssert(n.m_w == dgFloat32 (0.0f)); - dgAssert(n.DotProduct(n).GetScalar() > dgFloat32(0.0f)); - dgPlane plane(n, - n.DotProduct(shape1[i0]).GetScalar()); - dgFloat32 test0 = plane.Evalue(p); - if (test0 < dgFloat32(-1.e-3f)) { - return 0; - } - i0 = i1; - } - ptr = output; - output[count] = p; - count++; - - } else { - count2 = 0; - } - - for (dgInt32 i0 = 0; i0 < count2; i0++) { - contactOut[i0] = ptr[i0]; - } - return count2; -} - -dgInt32 dgContactSolver::ConvexPolygonsIntersection(const dgVector& normal, dgInt32 count0, dgVector* const shape0, dgInt32 count1, dgVector* const shape1, dgVector* const contactOut, dgInt32 maxContacts) const -{ - dgInt32 count = 0; - if (count1 <= 2) { - count = ConvexPolygonToLineIntersection(normal.Scale (dgFloat32 (-1.0f)), count0, shape0, count1, shape1, contactOut, &contactOut[count0 + count1 + maxContacts]); - } else if (count0 <= 2) { - count = ConvexPolygonToLineIntersection(normal, count1, shape1, count0, shape0, contactOut, &contactOut[count0 + count1 + maxContacts]); - } else { - dgAssert(count0 >= 3); - dgAssert(count1 >= 3); - - dgPerimenterEdge subdivision[128]; - dgAssert((2 * (count0 + count1)) < dgInt32(sizeof (subdivision) / sizeof (subdivision[0]))); - - for (dgInt32 i0 = 1; i0 < count1; i0++) { - subdivision[i0].m_vertex = &shape1[i0]; - subdivision[i0].m_prev = &subdivision[i0 - 1]; - subdivision[i0].m_next = &subdivision[i0 + 1]; - } - subdivision[0].m_vertex = &shape1[0]; - subdivision[0].m_prev = &subdivision[count1 - 1]; - subdivision[0].m_next = &subdivision[1]; - - subdivision[count1 - 1].m_next = &subdivision[0]; - - dgPerimenterEdge* edgeClipped[2]; - dgVector* output = &contactOut[count0 + count1 + maxContacts]; - - edgeClipped[0] = NULL; - edgeClipped[1] = NULL; - dgInt32 j0 = 0; - dgInt32 edgeIndex = count1; - dgPerimenterEdge* poly = &subdivision[0]; - for (dgInt32 j1 = count0 - 1; j1 >= 0; j1--) { - dgVector n(normal.CrossProduct(shape0[j1] - shape0[j0])); - dgAssert(n.m_w == 0.0f); - dgPlane plane(n, - n.DotProduct(shape0[j0]).GetScalar()); - j0 = j1; - count = 0; - dgPerimenterEdge* tmp = poly; - dgInt32 isInside = 0; - dgFloat32 test0 = plane.Evalue(*tmp->m_vertex); - do { - dgFloat32 test1 = plane.Evalue(*tmp->m_next->m_vertex); - - if (test0 >= dgFloat32(0.0f)) { - isInside |= 1; - if (test1 < dgFloat32(0.0f)) { - const dgVector& p0 = *tmp->m_vertex; - const dgVector& p1 = *tmp->m_next->m_vertex; - dgVector dp(p1 - p0); - dgAssert(dp.m_w == 0.0f); - dgFloat32 den = plane.DotProduct(dp).GetScalar(); - if (dgAbs(den) < dgFloat32(1.0e-24f)) { - den = (den >= dgFloat32(0.0f)) ? dgFloat32(1.0e-24f) : dgFloat32(-1.0e-24f); - } - - den = test0 / den; - if (den >= dgFloat32(0.0f)) { - den = dgFloat32(0.0f); - } else if (den <= -1.0f) { - den = dgFloat32(-1.0f); - } - dgAssert (dp.m_w == dgFloat32 (0.0f)); - output[0] = p0 - dp.Scale(den); - edgeClipped[0] = tmp; - count++; - } - } else if (test1 >= dgFloat32(0.0f)) { - const dgVector& p0 = *tmp->m_vertex; - const dgVector& p1 = *tmp->m_next->m_vertex; - isInside |= 1; - dgVector dp(p1 - p0); - dgAssert(dp.m_w == 0.0f); - dgFloat32 den = plane.DotProduct(dp).GetScalar(); - if (dgAbs(den) < dgFloat32(1.0e-24f)) { - den = (den >= dgFloat32(0.0f)) ? dgFloat32(1.0e-24f) : dgFloat32(-1.0e-24f); - } - den = test0 / den; - if (den >= dgFloat32(0.0f)) { - den = dgFloat32(0.0f); - } else if (den <= -1.0f) { - den = dgFloat32(-1.0f); - } - dgAssert (dp.m_w == dgFloat32 (0.0f)); - output[1] = p0 - dp.Scale(den); - edgeClipped[1] = tmp; - count++; - } - - test0 = test1; - tmp = tmp->m_next; - } while (tmp != poly && (count < 2)); - - if (!isInside) { - return 0; - } - - if (count == 2) { - dgPerimenterEdge* const newEdge = &subdivision[edgeIndex]; - newEdge->m_next = edgeClipped[1]; - newEdge->m_prev = edgeClipped[0]; - edgeClipped[0]->m_next = newEdge; - edgeClipped[1]->m_prev = newEdge; - - newEdge->m_vertex = &output[0]; - edgeClipped[1]->m_vertex = &output[1]; - poly = newEdge; - - output += 2; - edgeIndex++; - //dgAssert (output < &pool[sizeof (pool)/sizeof (pool[0])]); - dgAssert(edgeIndex < dgInt32(sizeof (subdivision) / sizeof (subdivision[0]))); - } - } - - dgAssert(poly); - count = 0; - dgPerimenterEdge* intersection = poly; - do { - contactOut[count] = *intersection->m_vertex; - count++; - intersection = intersection->m_next; - } while (intersection != poly); - } - return count; -} - -dgFloat32 dgContactSolver::RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut) -{ - dgVector normal(dgFloat32 (0.0f)); - dgVector point (localP0); - dgVector point0 (localP0); - dgVector p0p1 (localP0 - localP1); - - // avoid NaN as a result of a division by zero - if ((p0p1.TestZero().GetSignMask() & 7) == 7) { - return dgFloat32(1.2f); - } - - dgFloat32 param = dgFloat32 (0.0f); - - dgInt32 index = 0; - memset (m_hullSum, 0, 4 * sizeof (m_hullSum[0])); - const dgCollisionConvex* const collision = (dgCollisionConvex*)m_instance0->GetChildShape(); - - dgVector dir1 (p0p1.Normalize()); - m_hullDiff[0] = collision->SupportVertex (dir1, NULL) - point; - dgBigVector v (m_hullDiff[0]); - index = 1; - do { - dgInt32 iter = 0; - dgInt32 cycling = 0; - dgFloat64 minDist = dgFloat32 (1.0e20f); - - do { - dgAssert (v.m_w == dgFloat32 (0.0f)); - const dgFloat64 distance = v.DotProduct(v).GetScalar(); - if (distance < dgFloat32 (1.0e-9f)) { - index = -1; - break; - } - - if (distance < minDist) { - minDist = distance; - cycling = -1; - } - cycling ++; - if (cycling > 4) { - //dgAssert (0); - index = -1; - break; - } - - dgVector dir (v.Scale (-dgRsqrt(dgFloat32 (distance)))); - dgAssert (dir.m_w == dgFloat32 (0.0f)); - m_hullDiff[index] = collision->SupportVertex (dir, NULL) - point; - const dgBigVector w (m_hullDiff[index]); - const dgVector wv (w - v); - dgAssert (wv.m_w == dgFloat32 (0.0f)); - const dgFloat32 distance1 = dir.DotProduct(wv).GetScalar(); - if (distance1 < dgFloat64 (1.0e-3f)) { - normal = dir; - break; - } - - index ++; - switch (index) - { - case 2: - { - v = ReduceLine (index); - break; - } - - case 3: - { - v = ReduceTriangle (index); - break; - } - - case 4: - { - v = ReduceTetrahedrum (index); - break; - } - } - - iter ++; - } while (iter < DG_CONNICS_CONTATS_ITERATIONS); - - dgAssert (index); - if (index > 0) { - dgVector q (v + point); - dgFloat32 den = normal.DotProduct(p0p1).GetScalar(); - if (dgAbs (den) < dgFloat32(1.0e-12f)) { - den = dgSign(den) * dgFloat32(1.0e-12f); - } - dgAssert (normal.m_w == dgFloat32 (0.0f)); - dgFloat32 t1 = normal.DotProduct(localP0 - q).GetScalar() / den; - - if (t1 < param) { - index = -1; - t1 = dgFloat32 (0.0f); - } else if (t1 > maxT) { - index = -1; - t1 = dgFloat32 (1.0f); - } - param = t1; - - point = localP0 - p0p1.Scale (param); - dgVector step (point0 - point); - point0 = point; - for(dgInt32 i = 0; i < index; i ++) { - m_hullDiff[i] += step; - } - - switch (index) - { - case 1: - { - v = m_hullDiff[0]; - break; - } - - case 2: - { - v = ReduceLine (index); - break; - } - - case 3: - { - v = ReduceTriangle (index); - break; - } - - case 4: - { - v = ReduceTetrahedrum (index); - break; - } - } - } - } while (index >= 0); - - if ((param > dgFloat32 (0.0f)) && (param < maxT)) { - contactOut.m_normal = normal; - } else { - param = dgFloat32 (1.2f); - } - - return param; -} - - -DG_INLINE void dgContactSolver::TranslateSimplex(const dgVector& step) -{ - m_instance1->m_globalMatrix.m_posit -= step; - for (dgInt32 i = 0; i < m_vertexIndex; i++) { - m_hullSum[i] -= step; - m_hullDiff[i] += step; - } -} - -dgInt32 dgContactSolver::CalculateConvexCastContacts() -{ - dgInt32 iter = 0; - dgInt32 count = 0; - - dgFloat32 tacc = dgFloat32(0.0f); - dgFloat32 timestep = m_proxy->m_timestep; - m_proxy->m_contactJoint->m_closestDistance = dgFloat32(1.0e10f); - - dgVector savedPosition1 (m_instance1->m_globalMatrix.m_posit); - - dgVector relVeloc (m_proxy->m_body0->GetVelocity() - m_proxy->m_body1->GetVelocity()); - do { - bool state = CalculateClosestPoints(); - if (!state) { - break; - } - dgAssert(m_normal.m_w == dgFloat32(0.0f)); - dgFloat32 den = m_normal.DotProduct(relVeloc).GetScalar(); - if (den <= dgFloat32(1.0e-6f)) { - // bodies are residing from each other, even if they are touching they are not considered to be colliding because the motion will move them apart - // get the closet point and the normal at contact point - m_proxy->m_timestep = dgFloat32 (1.0e10f); - m_proxy->m_normal = m_normal.Scale(-1.0f); - m_proxy->m_closestPointBody0 = m_closestPoint0; - m_proxy->m_closestPointBody1 = m_closestPoint1; - break; - } - - dgFloat32 num = m_normal.DotProduct(m_closestPoint1 - m_closestPoint0).GetScalar() - m_proxy->m_skinThickness; - if ((num <= dgFloat32(1.0e-5f)) && (tacc <= timestep)) { - // bodies collide at time tacc, but we do not set it yet - dgVector step(relVeloc.Scale(tacc)); - m_proxy->m_timestep = tacc; - m_proxy->m_closestPointBody0 = m_closestPoint0 + step; - m_proxy->m_closestPointBody1 = m_closestPoint1 + step; - m_proxy->m_normal = m_normal.Scale (dgFloat32 (-1.0f)); - m_proxy->m_contactJoint->m_closestDistance = m_proxy->m_normal.DotProduct(m_closestPoint0 - m_closestPoint1).GetScalar(); - dgFloat32 penetration = dgMax(num * dgFloat32(-1.0f) + DG_PENETRATION_TOL, dgFloat32(0.0f)); - m_proxy->m_contactJoint->m_closestDistance = penetration; - if (m_proxy->m_contacts && !m_proxy->m_intersectionTestOnly) { - if (m_proxy->m_instance0->GetCollisionMode() & m_proxy->m_instance1->GetCollisionMode()) { - - m_normal = m_normal.Scale (dgFloat32 (-1.0f)); - m_proxy->m_contactJoint->m_isActive = 1; - count = CalculateContacts(m_closestPoint0, m_closestPoint1, m_normal); - if (count) { - count = dgMin(m_proxy->m_maxContacts, count); - dgContactPoint* const contactOut = m_proxy->m_contacts; - - for (int i = 0; i < count; i++) { - contactOut[i].m_point = m_hullDiff[i] + step; - contactOut[i].m_normal = m_normal; - contactOut[i].m_penetration = penetration; - } - } - } - } - break; - } - - dgAssert (den > dgFloat32 (0.0f)); - dgFloat32 dt = num / den; - if ((tacc + dt) >= timestep) { - // object do not collide on this timestep - m_proxy->m_timestep = tacc + dt; - m_proxy->m_normal = m_normal.Scale (dgFloat32 (-1.0f)); - m_proxy->m_closestPointBody0 = m_closestPoint0; - m_proxy->m_closestPointBody1 = m_closestPoint1; - break; - } - - tacc += dt; - dgVector step(relVeloc.Scale(dt)); - TranslateSimplex(step); - - iter++; - } while (iter < DG_SEPARATION_PLANES_ITERATIONS); - - m_instance1->m_globalMatrix.m_posit = savedPosition1; - return count; -} - - -dgInt32 dgContactSolver::CalculateConvexToConvexContacts () -{ - dgInt32 count = 0; - if (m_proxy->m_intersectionTestOnly) { - CalculateClosestPoints(); - dgFloat32 penetration = m_normal.DotProduct(m_closestPoint1 - m_closestPoint0).GetScalar() - m_proxy->m_skinThickness - DG_PENETRATION_TOL; - dgInt32 retVal = (penetration <= dgFloat32(0.0f)) ? -1 : 0; - m_proxy->m_contactJoint->m_isActive = retVal; - return retVal; - } else { - bool colliding = CalculateClosestPoints(); - if (colliding) { - dgFloat32 penetration = m_normal.DotProduct(m_closestPoint1 - m_closestPoint0).GetScalar() - m_proxy->m_skinThickness - DG_PENETRATION_TOL; - if (penetration <= dgFloat32(1.0e-5f)) { - m_proxy->m_contactJoint->m_isActive = 1; - if (m_instance0->GetCollisionMode() & m_instance1->GetCollisionMode()) { - count = CalculateContacts(m_closestPoint0, m_closestPoint1, m_normal.Scale(-1.0f)); - } - } - - m_proxy->m_closestPointBody0 = m_closestPoint0; - m_proxy->m_closestPointBody1 = m_closestPoint1; - m_proxy->m_contactJoint->m_closestDistance = penetration; - m_proxy->m_contactJoint->m_separationDistance = penetration; - - m_normal = m_normal.Scale (dgFloat32 (-1.0f)); - penetration = -penetration; - m_proxy->m_normal = m_normal; - count = dgMin(m_proxy->m_maxContacts, count); - dgContactPoint* const contactOut = m_proxy->m_contacts; - - for (int i = 0; i < count; i ++) { - contactOut[i].m_point = m_hullDiff[i]; - contactOut[i].m_normal = m_normal; - contactOut[i].m_penetration = penetration; - } - } - } - - return count; -} - -dgInt32 dgContactSolver::CalculateContacts(const dgVector& point0, const dgVector& point1, const dgVector& normal) -{ - dgInt32 count = 0; - - const dgInt32 baseCount = 16; - - dgVector* const contactsOut = &m_hullDiff[0]; - dgAssert(m_instance1->IsType(dgCollision::dgCollisionConvexShape_RTTI)); - dgAssert(m_instance0->IsType(dgCollision::dgCollisionConvexShape_RTTI)); - - dgInt32 count1 = 0; - dgVector* const shape1 = &contactsOut[baseCount]; - - dgAssert(normal.m_w == dgFloat32(0.0f)); - - dgVector origin((point0 + point1).Scale(dgFloat32(0.5f))); - const dgMatrix& matrix1 = m_instance1->m_globalMatrix; - dgVector ponintOnInstance1(matrix1.UntransformVector(origin)); - dgVector normalOnInstance1(matrix1.UnrotateVector(normal)); - dgFloat32 dist = (normal.DotProduct(point0 - point1)).GetScalar(); - if (dist < dgFloat32(0.0f)) { - count1 = m_instance1->CalculatePlaneIntersection(normalOnInstance1, ponintOnInstance1, shape1); - } - if (!count1) { - dgVector step(normal.Scale(DG_PENETRATION_TOL * dgFloat32(2.0f))); - dgVector alternatePoint(point1); - for (dgInt32 i = 0; (i < 3) && !count1; i++) { - alternatePoint -= step; - dgVector alternatePointOnInstance1(matrix1.UntransformVector(alternatePoint)); - count1 = m_instance1->CalculatePlaneIntersection(normalOnInstance1, alternatePointOnInstance1, shape1); - } - //dgAssert(count1); - step = matrix1.UnrotateVector(normal * ((alternatePoint - origin).DotProduct(normal))); - for (dgInt32 i = 0; i < count1; i++) { - shape1[i] -= step; - } - } - - if (count1) { - for (int i = 0; i < count1; i++) { - shape1[i] = matrix1.TransformVector(shape1[i]); - } - - dgInt32 count0 = 0; - dgVector* const shape0 = &contactsOut[baseCount + count1]; - - const dgMatrix& matrix0 = m_instance0->m_globalMatrix; - dgVector pointOnInstance0(matrix0.UntransformVector(origin)); - dgVector normalOnInstance0(matrix0.UnrotateVector(normal.Scale(dgFloat32(-1.0f)))); - if (dist < dgFloat32(0.0f)) { - count0 = m_instance0->CalculatePlaneIntersection(normalOnInstance0, pointOnInstance0, shape0); - } - if (!count0) { - dgVector step(normal.Scale(DG_PENETRATION_TOL * dgFloat32(2.0f))); - dgVector alternatePoint(point0); - for (dgInt32 i = 0; (i < 3) && !count0; i++) { - alternatePoint += step; - dgVector alternatePointOnInstance0(matrix0.UntransformVector(alternatePoint)); - count0 = m_instance0->CalculatePlaneIntersection(normalOnInstance0, alternatePointOnInstance0, shape0); - } - //dgTrace (("If this is a frequent event, this routine should return the translation distance as the contact point\n")) - //dgAssert(count0); - step = matrix0.UnrotateVector(normal * ((alternatePoint - origin).DotProduct(normal))); - for (dgInt32 i = 0; i < count0; i++) { - shape0[i] -= step; - } - } - - if (count0) { - for (dgInt32 i = 0; i < count0; i++) { - shape0[i] = matrix0.TransformVector(shape0[i]); - } - - if (count1 == 1) { - count = 1; - contactsOut[0] = shape1[0]; - } else if (count0 == 1) { - count = 1; - contactsOut[0] = shape0[0]; - } else if ((count1 == 2) && (count0 == 2)) { - dgVector p0(shape1[0]); - dgVector p1(shape1[1]); - const dgVector& q0 = shape0[0]; - const dgVector& q1 = shape0[1]; - dgVector p10(p1 - p0); - dgVector q10(q1 - q0); - dgAssert(p10.m_w == dgFloat32(0.0f)); - dgAssert(q10.m_w == dgFloat32(0.0f)); - p10 = p10.Scale(dgRsqrt(p10.DotProduct(p10).GetScalar() + dgFloat32(1.0e-8f))); - q10 = q10.Scale(dgRsqrt(q10.DotProduct(q10).GetScalar() + dgFloat32(1.0e-8f))); - dgFloat32 dot = q10.DotProduct(p10).GetScalar(); - if (dgAbs(dot) > dgFloat32(0.998f)) { - dgFloat32 pl0 = p0.DotProduct(p10).GetScalar(); - dgFloat32 pl1 = p1.DotProduct(p10).GetScalar(); - dgFloat32 ql0 = q0.DotProduct(p10).GetScalar(); - dgFloat32 ql1 = q1.DotProduct(p10).GetScalar(); - if (pl0 > pl1) { - dgSwap(pl0, pl1); - dgSwap(p0, p1); - p10 = p10.Scale(dgFloat32(-1.0f)); - } - if (ql0 > ql1) { - dgSwap(ql0, ql1); - } - if (!((ql0 > pl1) && (ql1 < pl0))) { - dgFloat32 clip0 = (ql0 > pl0) ? ql0 : pl0; - dgFloat32 clip1 = (ql1 < pl1) ? ql1 : pl1; - - count = 2; - contactsOut[0] = p0 + p10.Scale(clip0 - pl0); - contactsOut[1] = p0 + p10.Scale(clip1 - pl0); - } - } else { - count = 1; - dgVector c0; - dgVector c1; - dgRayToRayDistance(p0, p1, q0, q1, c0, c1); - contactsOut[0] = (c0 + c1).Scale(dgFloat32(0.5f)); - } - } else { - dgAssert((count1 >= 2) && (count0 >= 2)); - count = ConvexPolygonsIntersection(normal, count0, shape0, count1, shape1, contactsOut, baseCount); - } - } - } - - if (!count && m_proxy->m_continueCollision) { - count = 1; - contactsOut[0] = origin; - } - - return count; -} diff --git a/thirdparty/src/newton/dgPhysics/dgContactSolver.h b/thirdparty/src/newton/dgPhysics/dgContactSolver.h deleted file mode 100644 index 0b9e20d4f..000000000 --- a/thirdparty/src/newton/dgPhysics/dgContactSolver.h +++ /dev/null @@ -1,132 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_CONTACT_SOLVER_H__ -#define _DG_CONTACT_SOLVER_H__ - -#include "dgCollision.h" -#include "dgCollisionInstance.h" - -DG_MSC_VECTOR_ALIGNMENT -class dgMinkFace -{ - public: - dgPlane m_plane; - dgMinkFace* m_twin[3]; - dgInt16 m_vertex[3]; - dgInt8 m_mark; - dgInt8 m_alive; -} DG_GCC_VECTOR_ALIGNMENT; - -#define DG_SEPARATION_PLANES_ITERATIONS 8 -#define DG_CONVEX_MINK_STACK_SIZE 64 -#define DG_CONNICS_CONTATS_ITERATIONS 32 -#define DG_CONVEX_MINK_MAX_FACES 512 -#define DG_CONVEX_MINK_MAX_POINTS 256 -#define DG_MAX_EDGE_COUNT 2048 -#define DG_PENETRATION_TOL dgFloat32 (1.0f / 1024.0f) -#define DG_MINK_VERTEX_ERR (dgFloat32 (1.0e-3f)) -#define DG_MINK_VERTEX_ERR2 (DG_MINK_VERTEX_ERR * DG_MINK_VERTEX_ERR) - - -class dgCollisionParamProxy; - -DG_MSC_VECTOR_ALIGNMENT -class dgContactSolver: public dgDownHeap<dgMinkFace *, dgFloat32> -{ - public: - dgContactSolver(dgCollisionParamProxy* const proxy); - dgContactSolver(dgCollisionInstance* const instance0); - - bool CalculateClosestPoints(); - dgInt32 CalculateConvexCastContacts(); - dgInt32 CalculateConvexToConvexContacts(); - dgFloat32 RayCast (const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut); - - const dgVector& GetNormal() const {return m_normal;} - const dgVector& GetPoint0() const {return m_closestPoint0;} - const dgVector& GetPoint1() const {return m_closestPoint1;} - - private: - class dgPerimenterEdge - { - public: - const dgVector* m_vertex; - dgPerimenterEdge* m_next; - dgPerimenterEdge* m_prev; - }; - - class dgFaceFreeList - { - public: - dgFaceFreeList* m_next; - }; - - DG_INLINE dgMinkFace* NewFace(); - DG_INLINE void PushFace(dgMinkFace* const face); - DG_INLINE void DeleteFace(dgMinkFace* const face); - DG_INLINE dgMinkFace* AddFace(dgInt32 v0, dgInt32 v1, dgInt32 v2); - DG_INLINE void SupportVertex(const dgVector& dir, dgInt32 vertexIndex); - - DG_INLINE void TranslateSimplex(const dgVector& step); - - DG_INLINE void CalculateContactFromFeacture(dgInt32 featureType); - DG_INLINE dgBigVector ReduceLine(dgInt32& indexOut); - DG_INLINE dgBigVector ReduceTriangle (dgInt32& indexOut); - DG_INLINE dgBigVector ReduceTetrahedrum (dgInt32& indexOut); - - DG_INLINE dgPerimenterEdge* OldReduceContacts(dgPerimenterEdge* poly, dgInt32 maxCount) const; - - - bool SanityCheck() const; - dgInt32 ConvexPolygonsIntersection(const dgVector& normal, dgInt32 count1, dgVector* const shape1, dgInt32 count2, dgVector* const shape2, dgVector* const contactOut, dgInt32 maxContacts) const; - dgInt32 ConvexPolygonToLineIntersection(const dgVector& normal, dgInt32 count1, dgVector* const shape1, dgInt32 count2, dgVector* const shape2, dgVector* const contactOut, dgVector* const mem) const; - dgInt32 CalculateContacts (const dgVector& point0, const dgVector& point1, const dgVector& normal); - dgInt32 CalculateClosestSimplex (); - dgInt32 CalculateIntersectingPlane(dgInt32 count); - - dgVector m_normal; - dgVector m_closestPoint0; - dgVector m_closestPoint1; - dgCollisionParamProxy* m_proxy; - dgCollisionInstance* m_instance0; - dgCollisionInstance* m_instance1; - - dgFaceFreeList* m_freeFace; - dgInt32 m_vertexIndex; - dgInt32 m_faceIndex; - - dgVector m_hullDiff[DG_CONVEX_MINK_MAX_POINTS]; - dgVector m_hullSum[DG_CONVEX_MINK_MAX_POINTS]; - dgMinkFace* m_faceStack[DG_CONVEX_MINK_STACK_SIZE]; - dgMinkFace* m_coneFaceList[DG_CONVEX_MINK_STACK_SIZE]; - dgMinkFace* m_deletedFaceList[DG_CONVEX_MINK_STACK_SIZE]; - dgMinkFace m_facePool[DG_CONVEX_MINK_MAX_FACES]; - dgInt8 m_heapBuffer[DG_CONVEX_MINK_MAX_FACES * (sizeof (dgFloat32) + sizeof (dgMinkFace *))]; - - static dgVector m_hullDirs[14]; - static dgInt32 m_rayCastSimplex[4][4]; -}DG_GCC_VECTOR_ALIGNMENT; - - -#endif - - diff --git a/thirdparty/src/newton/dgPhysics/dgCorkscrewConstraint.cpp b/thirdparty/src/newton/dgPhysics/dgCorkscrewConstraint.cpp deleted file mode 100644 index 5ccabff7d..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCorkscrewConstraint.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgCorkscrewConstraint.h" - - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -dgCorkscrewConstraint::dgCorkscrewConstraint () - :dgBilateralConstraint() -{ - dgAssert ((((dgUnsigned64) &m_localMatrix0) & 15) == 0); - - m_localMatrix0 = dgGetIdentityMatrix(); - m_localMatrix1 = dgGetIdentityMatrix(); - - m_maxDOF = 6; - m_constId = m_corkScrewConstraint; - m_posit = dgFloat32 (0.0f); - m_angle = dgFloat32 (0.0f); - m_jointAccelFnt = NULL; -} - -dgCorkscrewConstraint::~dgCorkscrewConstraint () -{ -} - -/* -dgCorkscrewConstraint* dgCorkscrewConstraint::Create(dgWorld* world) -{ - dgCorkscrewConstraint* constraint; - -// constraint = dgCorkscrewConstraintArray::GetPool().GetElement(); - dgCorkscrewConstraintArray& array = * world; - constraint = array.GetElement(); - - dgAssert ((((dgUnsigned64) &constraint->m_localMatrix0) & 15) == 0); - constraint->Init (); - constraint->m_maxDOF = 6; - constraint->m_constId = dgCorkscrewConstraintId; - - constraint->m_posit = dgFloat32 (0.0f); - constraint->m_angle = dgFloat32 (0.0f); - constraint->m_jointAccelFnt = NULL; - return constraint; -} - -void dgCorkscrewConstraint::Remove(dgWorld* world) -{ - dgCorkscrewConstraintArray& array = * world; - - dgBilateralConstraint::Remove (world); -// dgCorkscrewConstraintArray::GetPool().RemoveElement (this); - array.RemoveElement (this); -} -*/ - -void dgCorkscrewConstraint::SetJointParameterCallback (dgCorkscrewJointAcceleration callback) -{ - m_jointAccelFnt = callback; -} - -dgFloat32 dgCorkscrewConstraint::GetJointAngle () const -{ - return m_angle; -} - -dgFloat32 dgCorkscrewConstraint::GetJointPosit () const -{ - return m_posit; -} - - -dgFloat32 dgCorkscrewConstraint::GetJointOmega () const -{ - dgAssert (m_body0); - dgAssert (m_body1); - dgVector dir (m_body0->GetMatrix().RotateVector (m_localMatrix0[0])); - const dgVector& omega0 = m_body0->GetOmega(); - const dgVector& omega1 = m_body1->GetOmega(); - -// dgVector omega1 (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); -// if (m_body1) { -// omega1 = m_body1->GetOmega(); -// } - return dir.DotProduct(omega0 - omega1).GetScalar(); -} - -dgFloat32 dgCorkscrewConstraint::GetJointVeloc () const -{ - dgAssert (m_body0); - dgAssert (m_body1); - dgVector dir (m_body0->GetMatrix().RotateVector (m_localMatrix0[0])); - const dgVector& veloc0 = m_body0->GetVelocity(); - const dgVector& veloc1 = m_body1->GetVelocity(); - -// dgVector veloc1 (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); -// if (m_body1) { -// veloc1 = m_body1->GetVelocity(); -// } - return dir.DotProduct(veloc0 - veloc1).GetScalar(); -} - - -dgFloat32 dgCorkscrewConstraint::CalculateStopAlpha (dgFloat32 angle, const dgJointCallbackParam* param) const -{ - dgFloat32 alpha; - dgFloat32 omega; - dgFloat32 penetrationErr; - - alpha = dgFloat32 (0.0f); - if (m_angle > angle) { - omega = GetJointOmega (); - if (omega < dgFloat32 (0.0f)) { - omega = dgFloat32 (0.0f); - } - penetrationErr = angle - m_angle; - alpha = dgFloat32 (100.0f) * penetrationErr - omega * dgFloat32 (1.01f) / param->m_timestep; - - } else if (m_angle < angle) { - omega = GetJointOmega (); - if (omega > dgFloat32 (0.0f)) { - omega = dgFloat32 (0.0f); - } - - penetrationErr = angle - m_angle; - alpha = dgFloat32 (100.0f) * penetrationErr - omega * dgFloat32 (1.01f) / param->m_timestep; - } - return alpha; -} - -dgFloat32 dgCorkscrewConstraint::CalculateStopAccel (dgFloat32 distance, const dgJointCallbackParam* param) const -{ - dgFloat32 accel; - dgFloat32 speed; - dgFloat32 penetrationErr; - - accel = dgFloat32 (0.0f); - if (m_posit > distance) { - speed = GetJointVeloc (); - if (speed < dgFloat32 (0.0f)) { - speed = dgFloat32 (0.0f); - } - penetrationErr = (distance - m_posit); - accel = dgFloat32 (100.0f) * penetrationErr - speed * dgFloat32 (1.01f) / param->m_timestep; - - } else if (m_posit < distance) { - speed = GetJointVeloc (); - if (speed > dgFloat32 (0.0f)) { - speed = dgFloat32 (0.0f); - } - penetrationErr = distance - m_posit; - dgAssert (penetrationErr >= dgFloat32 (0.0f)); - accel = dgFloat32 (100.0f) * penetrationErr - speed * dgFloat32 (1.01f) / param->m_timestep; - } - return accel; -} - - -dgVector dgCorkscrewConstraint::GetJointForce () const -{ - dgMatrix matrix0; - dgMatrix matrix1; - - CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1); - - return dgVector (matrix0.m_up.Scale (m_jointForce[0].m_force) + - matrix0.m_right.Scale (m_jointForce[1].m_force) + - matrix0.m_up.Scale (m_jointForce[2].m_force) + - matrix0.m_right.Scale (m_jointForce[3].m_force)); - -} - -dgUnsigned32 dgCorkscrewConstraint::JacobianDerivative (dgContraintDescritor& params) -{ - dgMatrix matrix0; - dgMatrix matrix1; - - dgVector angle (CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1)); - - m_angle = -angle.m_x; - m_posit = matrix0.m_front.DotProduct(matrix0.m_posit - matrix1.m_posit).GetScalar(); - matrix1.m_posit += matrix1.m_front.Scale (m_posit); - - dgAssert (dgAbs (dgFloat32 (1.0f) - matrix0.m_front.DotProduct(matrix0.m_front).GetScalar()) < dgFloat32 (1.0e-5f)); - dgAssert (dgAbs (dgFloat32 (1.0f) - matrix0.m_up.DotProduct(matrix0.m_up).GetScalar()) < dgFloat32 (1.0e-5f)); - dgAssert (dgAbs (dgFloat32 (1.0f) - matrix0.m_right.DotProduct(matrix0.m_right).GetScalar()) < dgFloat32 (1.0e-5f)); - - const dgVector& dir1 = matrix0.m_up; - const dgVector& dir2 = matrix0.m_right; - -// const dgVector& p0 = matrix0.m_posit; -// const dgVector& p1 = matrix1.m_posit; - dgVector p0 (matrix0.m_posit); - dgVector p1 (matrix1.m_posit + matrix1.m_front.Scale (matrix1.m_front.DotProduct(p0 - matrix1.m_posit).GetScalar())); - - dgVector q0 (p0 + matrix0.m_front.Scale(MIN_JOINT_PIN_LENGTH)); - dgVector q1 (p1 + matrix1.m_front.Scale(MIN_JOINT_PIN_LENGTH)); - - dgPointParam pointDataP; - dgPointParam pointDataQ; - InitPointParam (pointDataP, m_defualtDiagonalRegularizer, p0, p1); - InitPointParam (pointDataQ, m_defualtDiagonalRegularizer, q0, q1); - - CalculatePointDerivative (0, params, dir1, pointDataP, &m_jointForce[0]); - CalculatePointDerivative (1, params, dir2, pointDataP, &m_jointForce[1]); - CalculatePointDerivative (2, params, dir1, pointDataQ, &m_jointForce[2]); - CalculatePointDerivative (3, params, dir2, pointDataQ, &m_jointForce[3]); - - dgInt32 ret = 4; - if (m_jointAccelFnt) { - dgUnsigned32 code; - dgJointCallbackParam axisParam[2]; - - // linear acceleration - axisParam[0].m_accel = dgFloat32 (0.0f); - axisParam[0].m_timestep = params.m_timestep; - axisParam[0].m_minFriction = DG_MIN_BOUND; - axisParam[0].m_maxFriction = DG_MAX_BOUND; - - // angular acceleration - axisParam[1].m_accel = dgFloat32 (0.0f); - axisParam[1].m_timestep = params.m_timestep; - axisParam[1].m_minFriction = DG_MIN_BOUND; - axisParam[1].m_maxFriction = DG_MAX_BOUND; - - code = m_jointAccelFnt (*this, axisParam); - if (code & 1) { - if ((axisParam[0].m_minFriction > DG_MIN_BOUND) || (axisParam[0].m_maxFriction < DG_MAX_BOUND)) { - params.m_forceBounds[ret].m_low = axisParam[0].m_minFriction; - params.m_forceBounds[ret].m_upper = axisParam[0].m_maxFriction; - params.m_forceBounds[ret].m_normalIndex = DG_INDEPENDENT_ROW; - } - - CalculatePointDerivative (ret, params, matrix0.m_front, pointDataP, &m_jointForce[ret]); - SetMotorAcceleration (ret, axisParam[0].m_accel, params); - ret ++; - } - - - if (code & 2) { - if ((axisParam[1].m_minFriction > DG_MIN_BOUND) || (axisParam[1].m_maxFriction < DG_MAX_BOUND)) { - params.m_forceBounds[ret].m_low = axisParam[1].m_minFriction; - params.m_forceBounds[ret].m_upper = axisParam[1].m_maxFriction; - params.m_forceBounds[ret].m_normalIndex = DG_INDEPENDENT_ROW; - } - - CalculateAngularDerivative (ret, params, matrix0.m_front, m_defualtDiagonalRegularizer, dgFloat32 (0.0f), &m_jointForce[ret]); - SetMotorAcceleration (ret, axisParam[1].m_accel, params); - ret ++; - } - } - - return dgUnsigned32 (ret); -} - - - diff --git a/thirdparty/src/newton/dgPhysics/dgCorkscrewConstraint.h b/thirdparty/src/newton/dgPhysics/dgCorkscrewConstraint.h deleted file mode 100644 index d3b68dbfd..000000000 --- a/thirdparty/src/newton/dgPhysics/dgCorkscrewConstraint.h +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -#if !defined(AFX_DGCORKSCREWCONSTRAINT_H__GRT672DF293FR_H) -#define AFX_DGCORKSCREWCONSTRAINT_H__GRT672DF293FR_H -#include "dgBilateralConstraint.h" - -//template<class T> class dgPool; - -class dgCorkscrewConstraint; - - -typedef dgUnsigned32 (dgApi *dgCorkscrewJointAcceleration) (const dgCorkscrewConstraint& hinge, dgJointCallbackParam* param); - -class dgCorkscrewConstraint: public dgBilateralConstraint -{ - public: - dgFloat32 GetJointAngle () const; - dgFloat32 GetJointOmega () const; - dgFloat32 GetJointPosit () const; - dgFloat32 GetJointVeloc () const; - - dgVector GetJointForce () const; - dgFloat32 CalculateStopAlpha (dgFloat32 angle, const dgJointCallbackParam* param) const; - dgFloat32 CalculateStopAccel (dgFloat32 distance, const dgJointCallbackParam* param) const; - void SetJointParameterCallback (dgCorkscrewJointAcceleration callback); - - - private: - virtual dgUnsigned32 JacobianDerivative (dgContraintDescritor& params); - virtual void Serialize (dgSerialize serializeCallback, void* const userData) {dgAssert (0);} - - dgCorkscrewConstraint(); - virtual ~dgCorkscrewConstraint(); - - dgMatrix m_localMatrix0; - dgMatrix m_localMatrix1; - - dgFloat32 m_angle; - dgFloat32 m_posit; - dgCorkscrewJointAcceleration m_jointAccelFnt; -// dgUnsigned32 m_reserve[1]; - -//#ifdef _NEWTON_USE_DOUBLE -// dgUnsigned32 m_reserve[3]; -//#else -// dgUnsigned32 m_reserve[1]; -//#endif - - friend class dgWorld; -// friend class dgPool<dgCorkscrewConstraint>; -}; - -//class dgCorkscrewConstraintArray: public dgPoolContainer<dgCorkscrewConstraint> -//{ -//}; - -#endif // !defined(AFX_DGCORKSCREWCONSTRAINT_H__GRT672DF293FR_H) - diff --git a/thirdparty/src/newton/dgPhysics/dgDynamicBody.cpp b/thirdparty/src/newton/dgPhysics/dgDynamicBody.cpp deleted file mode 100644 index e24fb7d2c..000000000 --- a/thirdparty/src/newton/dgPhysics/dgDynamicBody.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgWorld.h" -#include "dgDynamicBody.h" -#include "dgCollisionInstance.h" -#include "dgCollisionLumpedMassParticles.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -dgVector dgDynamicBody::m_equilibriumError2 (DG_ERR_TOLERANCE2); - - -dgDynamicBodyAsymetric::dgDynamicBodyAsymetric() - :dgDynamicBody() - , m_principalAxis(dgGetIdentityMatrix()) -{ - m_type = m_dynamicBody; - m_rtti |= m_dynamicBodyAsymentricRTTI; - dgAssert(dgInt32(sizeof(dgDynamicBody) & 0x0f) == 0); - -} - -dgDynamicBodyAsymetric::dgDynamicBodyAsymetric(dgWorld* const world, const dgTree<const dgCollision*, dgInt32>* const collisionNode, dgDeserialize serializeCallback, void* const userData, dgInt32 revisionNumber) - :dgDynamicBody(world, collisionNode, serializeCallback, userData, revisionNumber) - , m_principalAxis(dgGetIdentityMatrix()) -{ - m_type = m_dynamicBody; - m_rtti |= m_dynamicBodyRTTI; - serializeCallback(userData, &m_principalAxis, sizeof(m_principalAxis)); -} - -void dgDynamicBodyAsymetric::Serialize(const dgTree<dgInt32, const dgCollision*>& collisionRemapId, dgSerialize serializeCallback, void* const userData) -{ - dgDynamicBody::Serialize(collisionRemapId, serializeCallback, userData); - serializeCallback(userData, &m_principalAxis, sizeof(m_principalAxis)); -} - - -void dgDynamicBodyAsymetric::SetMassMatrix(dgFloat32 mass, const dgMatrix& inertia) -{ - //dgVector II; - m_principalAxis = inertia; - dgVector II (m_principalAxis.EigenVectors()); - dgMatrix massMatrix(dgGetIdentityMatrix()); - massMatrix[0][0] = II[0]; - massMatrix[1][1] = II[1]; - massMatrix[2][2] = II[2]; - dgBody::SetMassMatrix(mass, massMatrix); -} - -dgMatrix dgDynamicBodyAsymetric::CalculateLocalInertiaMatrix() const -{ - dgMatrix matrix(m_principalAxis); - matrix.m_posit = dgVector::m_wOne; - dgMatrix diagonal(dgGetIdentityMatrix()); - diagonal[0][0] = m_mass[0]; - diagonal[1][1] = m_mass[1]; - diagonal[2][2] = m_mass[2]; - return matrix * diagonal * matrix.Inverse(); -} - -dgMatrix dgDynamicBodyAsymetric::CalculateInertiaMatrix() const -{ - dgMatrix matrix(m_principalAxis * m_matrix); - matrix.m_posit = dgVector::m_wOne; - dgMatrix diagonal(dgGetIdentityMatrix()); - diagonal[0][0] = m_mass[0]; - diagonal[1][1] = m_mass[1]; - diagonal[2][2] = m_mass[2]; - return matrix * diagonal * matrix.Inverse(); -} - -dgMatrix dgDynamicBodyAsymetric::CalculateInvInertiaMatrix() const -{ - dgMatrix matrix(m_principalAxis * m_matrix); - matrix.m_posit = dgVector::m_wOne; - dgMatrix diagonal(dgGetIdentityMatrix()); - diagonal[0][0] = m_invMass[0]; - diagonal[1][1] = m_invMass[1]; - diagonal[2][2] = m_invMass[2]; - return matrix * diagonal * matrix.Inverse(); -} - -void dgDynamicBodyAsymetric::IntegrateOpenLoopExternalForce(dgFloat32 timestep) -{ - dgDynamicBody::IntegrateOpenLoopExternalForce(timestep); -} - - -dgDynamicBody::dgDynamicBody() - :dgBody() - ,m_externalForce(dgVector::m_zero) - ,m_externalTorque(dgVector::m_zero) - ,m_savedExternalForce(dgVector::m_zero) - ,m_savedExternalTorque(dgVector::m_zero) - ,m_dampCoef(dgVector::m_zero) - ,m_cachedDampCoef(dgVector::m_zero) - ,m_cachedTimeStep(dgFloat32(0.0f)) - ,m_sleepingCounter(0) - ,m_isInDestructionArrayLRU(0) - ,m_skeleton(NULL) - ,m_applyExtForces(NULL) -{ - m_type = m_dynamicBody; - m_rtti |= m_dynamicBodyRTTI; - dgAssert ( dgInt32 (sizeof (dgDynamicBody) & 0x0f) == 0); -} - -dgDynamicBody::dgDynamicBody (dgWorld* const world, const dgTree<const dgCollision*, dgInt32>* const collisionCashe, dgDeserialize serializeCallback, void* const userData, dgInt32 revisionNumber) - :dgBody(world, collisionCashe, serializeCallback, userData, revisionNumber) - ,m_externalForce(dgVector::m_zero) - ,m_externalTorque(dgVector::m_zero) - ,m_savedExternalForce(dgVector::m_zero) - ,m_savedExternalTorque(dgVector::m_zero) - ,m_dampCoef(dgVector::m_zero) - ,m_cachedDampCoef(dgVector::m_zero) - ,m_cachedTimeStep(dgFloat32(0.0f)) - ,m_sleepingCounter(0) - ,m_isInDestructionArrayLRU(0) - ,m_skeleton(NULL) - ,m_applyExtForces(NULL) -{ - m_type = m_dynamicBody; - m_rtti |= m_dynamicBodyRTTI; - - m_invWorldInertiaMatrix[3][3] = dgFloat32 (1.0f); - serializeCallback (userData, &m_mass, sizeof (m_mass)); - serializeCallback (userData, &m_invMass, sizeof (m_invMass)); - serializeCallback (userData, &m_dampCoef, sizeof (m_dampCoef)); -} - -dgDynamicBody::~dgDynamicBody() -{ - if (m_skeleton) { - dgSkeletonContainer* const skel = m_skeleton; - m_skeleton = NULL; - m_world->DestroySkeletonContainer(skel); - } -} - -void dgDynamicBody::Serialize (const dgTree<dgInt32, const dgCollision*>& collisionRemapId, dgSerialize serializeCallback, void* const userData) -{ - dgBody::Serialize (collisionRemapId, serializeCallback, userData); - - serializeCallback (userData, &m_mass, sizeof (m_mass)); - serializeCallback (userData, &m_invMass, sizeof (m_invMass)); - serializeCallback (userData, &m_dampCoef, sizeof (m_dampCoef)); -} - - -void dgDynamicBody::SetMatrixResetSleep(const dgMatrix& matrix) -{ - dgBody::SetMatrixResetSleep(matrix); - m_savedExternalForce = dgVector::m_zero; - m_savedExternalTorque = dgVector::m_zero; - CalcInvInertiaMatrix(); -} - -void dgDynamicBody::SetMatrixNoSleep(const dgMatrix& matrix) -{ - dgBody::SetMatrixNoSleep(matrix); - CalcInvInertiaMatrix(); -} - -void dgDynamicBody::AttachCollision (dgCollisionInstance* const collision) -{ - dgBody::AttachCollision(collision); - if (m_collision->IsType(dgCollision::dgCollisionMesh_RTTI) || m_collision->IsType(dgCollision::dgCollisionScene_RTTI)) { - //SetMassMatrix (m_mass.m_w, m_mass.m_x, m_mass.m_y, m_mass.m_z); - SetMassMatrix (m_mass.m_w, CalculateLocalInertiaMatrix()); - } -} - - -dgVector dgDynamicBody::GetAlpha() const -{ - return m_alpha; -} - -dgVector dgDynamicBody::GetAccel() const -{ - return m_accel; -} - -void dgDynamicBody::SetAlpha(const dgVector& alpha) -{ - m_alpha = alpha; -} - -void dgDynamicBody::SetAccel(const dgVector& accel) -{ - m_accel = accel; -} - - -bool dgDynamicBody::IsInEquilibrium() const -{ - if (m_equilibrium) { - dgVector deltaAccel((m_externalForce - m_savedExternalForce).Scale(m_invMass.m_w)); - dgAssert(deltaAccel.m_w == dgFloat32 (0.0f)); - dgFloat32 deltaAccel2 = deltaAccel.DotProduct(deltaAccel).GetScalar(); - if (deltaAccel2 > DG_ERR_TOLERANCE2) { - return false; - } - dgVector deltaAlpha(m_matrix.UnrotateVector(m_externalTorque - m_savedExternalTorque) * m_invMass); - dgAssert(deltaAlpha.m_w == dgFloat32 (0.0f)); - dgFloat32 deltaAlpha2 = deltaAlpha.DotProduct(deltaAlpha).GetScalar(); - if (deltaAlpha2 > DG_ERR_TOLERANCE2) { - return false; - } - return true; - } - return false; -} - -void dgDynamicBody::ApplyExtenalForces (dgFloat32 timestep, dgInt32 threadIndex) -{ - m_externalForce = dgVector::m_zero; - m_externalTorque = dgVector::m_zero; - if (m_applyExtForces) { - m_applyExtForces(*this, timestep, threadIndex); - } - - m_gyroRotation = m_rotation; - m_gyroTorque = dgVector::m_zero; - - m_externalForce += m_impulseForce; - m_externalTorque += m_impulseTorque; - m_impulseForce = dgVector::m_zero; - m_impulseTorque = dgVector::m_zero; -} - -void dgDynamicBody::AddDampingAcceleration(dgFloat32 timestep) -{ - dgVector damp (GetDampCoeffcient (timestep)); - dgVector omegaDamp(damp & dgVector::m_triplexMask); - dgVector omega(m_matrix.UnrotateVector(m_omega) * omegaDamp); - - m_veloc = m_veloc.Scale(damp.m_w); - m_omega = m_matrix.RotateVector(omega); -} - -void dgDynamicBody::InvalidateCache () -{ - m_sleepingCounter = 0; - m_savedExternalForce = dgVector::m_zero; - m_savedExternalTorque = dgVector::m_zero; - dgBody::InvalidateCache (); -} - -void dgDynamicBody::IntegrateImplicit(dgFloat32 timestep) -{ - // using simple backward Euler or implicit integration, this is. - // f'(t + dt) = (f(t + dt) - f(t)) / dt - - // therefore: - // f(t + dt) = f(t) + f'(t + dt) * dt - - // approximate f'(t + dt) by expanding the Taylor of f(w + dt) - // f(w + dt) = f(w) + f'(w) * dt + f''(w) * dt^2 / 2! + .... - - // assume dt^2 is negligible, therefore we can truncate the expansion to - // f(w + dt) ~= f(w) + f'(w) * dt - - // calculating dw as the f'(w) = d(wx, wy, wz) | dt - // dw/dt = a = (Tl - (wl x (wl * Il)) * Il^1 - - // expanding f(w) - // f'(wx) = Ix * ax = Tx - (Iz - Iy) * wy * wz - // f'(wy) = Iy * ay = Ty - (Ix - Iz) * wz * wx - // f'(wz) = Iz * az = Tz - (Iy - Ix) * wx * wy - // - // calculation the expansion - // Ix * ax = (Tx - (Iz - Iy) * wy * wz) - ((Iz - Iy) * wy * az + (Iz - Iy) * ay * wz) * dt - // Iy * ay = (Ty - (Ix - Iz) * wz * wx) - ((Ix - Iz) * wz * ax + (Ix - Iz) * az * wx) * dt - // Iz * az = (Tz - (Iy - Ix) * wx * wy) - ((Iy - Ix) * wx * ay + (Iy - Ix) * ax * wy) * dt - // - // factorizing a we get - // Ix * ax + (Iz - Iy) * dwy * az + (Iz - Iy) * dwz * ay = Tx - (Iz - Iy) * wy * wz - // Iy * ay + (Ix - Iz) * dwz * ax + (Ix - Iz) * dwx * az = Ty - (Ix - Iz) * wz * wx - // Iz * az + (Iy - Ix) * dwx * ay + (Iy - Ix) * dwy * ax = Tz - (Iy - Ix) * wx * wy - - dgVector localOmega(m_matrix.UnrotateVector(m_omega)); - dgVector localTorque(m_matrix.UnrotateVector(m_externalTorque - m_gyroTorque)); - - // and solving for alpha we get the angular acceleration at t + dt - // calculate gradient at a full time step - dgVector gradientStep(localTorque.Scale(timestep)); - - // derivative at half time step. (similar to midpoint Euler so that it does not loses too much energy) - dgVector dw(localOmega.Scale(dgFloat32(0.5f) * timestep)); - //dgVector dw(localOmega.Scale(dgFloat32(1.0f) * timestep)); - - // calculates Jacobian matrix ( - // dWx / dwx, dWx / dwy, dWx / dwz - // dWy / dwx, dWy / dwy, dWy / dwz - // dWz / dwx, dWz / dwy, dWz / dwz - // - // dWx / dwx = Ix, dWx / dwy = (Iz - Iy) * wz * dt, dWx / dwz = (Iz - Iy) * wy * dt) - // dWy / dwx = (Ix - Iz) * wz * dt, dWy / dwy = Iy, dWy / dwz = (Ix - Iz) * wx * dt - // dWz / dwx = (Iy - Ix) * wy * dt, dWz / dwy = (Iy - Ix) * wx * dt, dWz / dwz = Iz - dgMatrix jacobianMatrix( - dgVector(m_mass[0], (m_mass[2] - m_mass[1]) * dw[2], (m_mass[2] - m_mass[1]) * dw[1], dgFloat32(0.0f)), - dgVector((m_mass[0] - m_mass[2]) * dw[2], m_mass[1], (m_mass[0] - m_mass[2]) * dw[0], dgFloat32(0.0f)), - dgVector((m_mass[1] - m_mass[0]) * dw[1], (m_mass[1] - m_mass[0]) * dw[0], m_mass[2], dgFloat32(0.0f)), - dgVector::m_wOne); - - gradientStep = jacobianMatrix.SolveByGaussianElimination(gradientStep); - - localOmega += gradientStep; - - m_accel = m_externalForce.Scale(m_invMass.m_w); - m_alpha = m_matrix.RotateVector(localTorque * m_invMass); - - m_veloc += m_accel.Scale(timestep); - m_omega = m_matrix.RotateVector(localOmega); -} - -dgJacobian dgDynamicBody::IntegrateForceAndToque(const dgVector& force, const dgVector& torque, const dgVector& timestep) -{ - dgJacobian velocStep; - if (m_gyroTorqueOn) { - dgVector dtHalf(timestep * dgVector::m_half); - dgMatrix matrix(m_gyroRotation, dgVector::m_wOne); - - dgVector localOmega(matrix.UnrotateVector(m_omega)); - dgVector localTorque(matrix.UnrotateVector(torque - m_gyroTorque)); - - // derivative at half time step. (similar to midpoint Euler so that it does not loses too much energy) - dgVector dw(localOmega * dtHalf); - dgMatrix jacobianMatrix( - dgVector(m_mass[0], (m_mass[2] - m_mass[1]) * dw[2], (m_mass[2] - m_mass[1]) * dw[1], dgFloat32(0.0f)), - dgVector((m_mass[0] - m_mass[2]) * dw[2], m_mass[1], (m_mass[0] - m_mass[2]) * dw[0], dgFloat32(1.0f)), - dgVector((m_mass[1] - m_mass[0]) * dw[1], (m_mass[1] - m_mass[0]) * dw[0], m_mass[2], dgFloat32(1.0f)), - dgVector::m_wOne); - - // and solving for alpha we get the angular acceleration at t + dt - // calculate gradient at a full time step - //dgVector gradientStep(localTorque * timestep); - dgVector gradientStep(jacobianMatrix.SolveByGaussianElimination(localTorque * timestep)); - - dgVector omega(matrix.RotateVector(localOmega + gradientStep)); - dgAssert(omega.m_w == dgFloat32(0.0f)); - - // integrate rotation here - dgFloat32 omegaMag2 = omega.DotProduct(omega).GetScalar() + dgFloat32(1.0e-12f); - dgFloat32 invOmegaMag = dgRsqrt(omegaMag2); - dgVector omegaAxis(omega.Scale(invOmegaMag)); - dgFloat32 omegaAngle = invOmegaMag * omegaMag2 * timestep.GetScalar(); - dgQuaternion deltaRotation(omegaAxis, omegaAngle); - m_gyroRotation = m_gyroRotation * deltaRotation; - dgAssert((m_gyroRotation.DotProduct(m_gyroRotation) - dgFloat32(1.0f)) < dgFloat32(1.0e-5f)); - - matrix = dgMatrix(m_gyroRotation, dgVector::m_wOne); - localOmega = matrix.UnrotateVector(omega); - //dgVector angularMomentum(inertia * localOmega); - //body->m_gyroTorque = matrix.RotateVector(localOmega.CrossProduct(angularMomentum)); - //body->m_gyroAlpha = body->m_invWorldInertiaMatrix.RotateVector(body->m_gyroTorque); - dgVector localGyroTorque(localOmega.CrossProduct(m_mass * localOmega)); - m_gyroTorque = matrix.RotateVector(localGyroTorque); - m_gyroAlpha = matrix.RotateVector(localGyroTorque * m_invMass); - - velocStep.m_angular = matrix.RotateVector(gradientStep); - } else { - velocStep.m_angular = m_invWorldInertiaMatrix.RotateVector(torque) * timestep; - //velocStep.m_angular = velocStep.m_angular * dgVector::m_half; - } - - velocStep.m_linear = force.Scale(m_invMass.m_w) * timestep; - return velocStep; -} - -void dgDynamicBody::IntegrateOpenLoopExternalForce(dgFloat32 timestep) -{ - if (!m_equilibrium) { - if (!m_collision->IsType(dgCollision::dgCollisionLumpedMass_RTTI)) { - IntegrateImplicit(timestep); - } else { - dgCollisionLumpedMassParticles* const lumpedMassShape = (dgCollisionLumpedMassParticles*)m_collision->m_childShape; - lumpedMassShape->IntegrateForces(timestep); - } - } else { - m_accel = dgVector::m_zero; - m_alpha = dgVector::m_zero; - } -} - - diff --git a/thirdparty/src/newton/dgPhysics/dgDynamicBody.h b/thirdparty/src/newton/dgPhysics/dgDynamicBody.h deleted file mode 100644 index 724e131f2..000000000 --- a/thirdparty/src/newton/dgPhysics/dgDynamicBody.h +++ /dev/null @@ -1,258 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_DYNAMIC_BODY_H_ -#define _DG_DYNAMIC_BODY_H_ - -#include "dgPhysicsStdafx.h" -#include "dgBody.h" - -#define DG_MAX_SPEED_ATT dgFloat32(0.02f) -//#define DG_FREEZE_ACCEL dgFloat32(0.1f) -#define DG_FREEZE_ACCEL dgFloat32(1.0f) -#define DG_FREEZE_SPEED dgFloat32(0.032f) - -#define DG_FREEZE_ACCEL2 (DG_FREEZE_ACCEL * DG_FREEZE_ACCEL) -#define DG_FREEZE_SPEED2 (DG_FREEZE_SPEED * DG_FREEZE_SPEED) - -#define DG_FREEZE_MAG DG_FREEZE_ACCEL -#define DG_FREEZE_MAG2 (DG_FREEZE_MAG * DG_FREEZE_MAG) - -#define DG_ERR_TOLERANCE dgFloat32(1.0e-2f) -#define DG_ERR_TOLERANCE2 (DG_ERR_TOLERANCE * DG_ERR_TOLERANCE) - -class dgSkeletonContainer; - -DG_MSC_VECTOR_ALIGNMENT -class dgDynamicBody : public dgBody -{ - public: - dgDynamicBody(); - dgDynamicBody (dgWorld* const world, const dgTree<const dgCollision*, dgInt32>* const collisionNode, dgDeserialize serializeCallback, void* const userData, dgInt32 revisionNumber); - virtual ~dgDynamicBody (); - - virtual const dgVector& GetForce() const; - virtual const dgVector& GetTorque() const; - - virtual void AddForce (const dgVector& force); - virtual void AddTorque (const dgVector& torque); - virtual void SetForce (const dgVector& force); - virtual void SetTorque (const dgVector& torque); - - virtual dgFloat32 GetLinearDamping () const; - virtual dgVector GetAngularDamping () const; - virtual void SetLinearDamping (dgFloat32 linearDamp); - virtual void SetAngularDamping (const dgVector& angularDamp); - - virtual void AttachCollision (dgCollisionInstance* const collision); - virtual dgVector PredictLinearVelocity(dgFloat32 timestep) const; - virtual dgVector PredictAngularVelocity(dgFloat32 timestep) const; - - virtual void InvalidateCache(); - virtual void SetMatrixResetSleep(const dgMatrix& matrix); - virtual void SetMatrixNoSleep(const dgMatrix& matrix); - - virtual bool IsInEquilibrium () const; - virtual void SetCollidable (bool state) {} - - virtual void ApplyExtenalForces (dgFloat32 timestep, dgInt32 threadIndex); - virtual OnApplyExtForceAndTorque GetExtForceAndTorqueCallback () const; - virtual void SetExtForceAndTorqueCallback (OnApplyExtForceAndTorque callback); - virtual void Serialize (const dgTree<dgInt32, const dgCollision*>& collisionRemapId, dgSerialize serializeCallback, void* const userData); - - virtual dgSkeletonContainer* GetSkeleton() const; - void SetSkeleton(dgSkeletonContainer* const skeleton); - - void IntegrateImplicit(dgFloat32 timeStep); - virtual void IntegrateOpenLoopExternalForce(dgFloat32 timeStep); - const dgVector& GetDampCoeffcient (dgFloat32 timestep); - - virtual dgJacobian IntegrateForceAndToque(const dgVector& force, const dgVector& torque, const dgVector& timestep); - - private: - virtual void AddDampingAcceleration(dgFloat32 timestep); - - virtual dgVector GetAlpha() const; - virtual dgVector GetAccel() const; - virtual void SetAlpha(const dgVector& alpha); - virtual void SetAccel(const dgVector& accel); - - dgVector m_externalForce; - dgVector m_externalTorque; - dgVector m_savedExternalForce; - dgVector m_savedExternalTorque; - dgVector m_dampCoef; - dgVector m_cachedDampCoef; - dgFloat32 m_cachedTimeStep; - dgInt32 m_sleepingCounter; - dgUnsigned32 m_isInDestructionArrayLRU; - dgSkeletonContainer* m_skeleton; - OnApplyExtForceAndTorque m_applyExtForces; - static dgVector m_equilibriumError2; - - friend class dgWorld; - friend class dgSolver; - friend class dgBroadPhase; - friend class dgBodyMasterList; - friend class dgSkeletonContainer; - friend class dgWorldDynamicUpdate; - friend class dgParallelBodySolver; - friend class dgCollisionDeformableMesh; - friend class dgCollisionDeformableSolidMesh; - friend class dgCollisionMassSpringDamperSystem; -} DG_GCC_VECTOR_ALIGNMENT; - - -DG_MSC_VECTOR_ALIGNMENT -class dgDynamicBodyAsymetric: public dgDynamicBody -{ - public: - dgDynamicBodyAsymetric(); - dgDynamicBodyAsymetric(dgWorld* const world, const dgTree<const dgCollision*, dgInt32>* const collisionNode, dgDeserialize serializeCallback, void* const userData, dgInt32 revisionNumber); - - virtual void Serialize(const dgTree<dgInt32, const dgCollision*>& collisionRemapId, dgSerialize serializeCallback, void* const userData); - - virtual dgMatrix CalculateInertiaMatrix() const; - virtual dgMatrix CalculateLocalInertiaMatrix() const; - virtual dgMatrix CalculateInvInertiaMatrix() const; - virtual void SetMassMatrix(dgFloat32 mass, const dgMatrix& inertia); - virtual void IntegrateOpenLoopExternalForce(dgFloat32 timestep); - - dgMatrix m_principalAxis; -} DG_GCC_VECTOR_ALIGNMENT; - - - -DG_INLINE const dgVector& dgDynamicBody::GetForce() const -{ - return m_externalForce; -} - -DG_INLINE const dgVector& dgDynamicBody::GetTorque() const -{ - return m_externalTorque; -} - - -DG_INLINE dgFloat32 dgDynamicBody::GetLinearDamping () const -{ - return m_dampCoef.m_w / DG_MAX_SPEED_ATT; -} - -DG_INLINE dgVector dgDynamicBody::GetAngularDamping () const -{ - return dgVector (m_dampCoef.m_x / DG_MAX_SPEED_ATT, - m_dampCoef.m_y / DG_MAX_SPEED_ATT, - m_dampCoef.m_z / DG_MAX_SPEED_ATT, dgFloat32 (0.0f)); -} - -DG_INLINE void dgDynamicBody::SetLinearDamping (dgFloat32 linearDamp) -{ - linearDamp = dgClamp (linearDamp, dgFloat32(0.0f), dgFloat32(1.0f)); - m_dampCoef.m_w = DG_MAX_SPEED_ATT * linearDamp; - m_cachedTimeStep = dgFloat32(0.0f); -} - -DG_INLINE void dgDynamicBody::SetAngularDamping (const dgVector& angularDamp) -{ - dgFloat32 tmp = dgClamp (angularDamp.m_x, dgFloat32(0.0f), dgFloat32(1.0f)); - m_dampCoef.m_x = DG_MAX_SPEED_ATT * tmp; - - tmp = dgClamp (angularDamp.m_y, dgFloat32(0.0f), dgFloat32(1.0f)); - m_dampCoef.m_y = DG_MAX_SPEED_ATT * tmp; - - tmp = dgClamp (angularDamp.m_z, dgFloat32(0.0f), dgFloat32(1.0f)); - m_dampCoef.m_z = DG_MAX_SPEED_ATT * tmp; - - m_cachedTimeStep = dgFloat32(0.0f); -} - -DG_INLINE void dgDynamicBody::AddForce (const dgVector& force) -{ - SetForce (m_externalForce + force); -} - -DG_INLINE void dgDynamicBody::AddTorque (const dgVector& torque) -{ - SetTorque (torque + m_externalTorque); -} - - -DG_INLINE void dgDynamicBody::SetForce (const dgVector& force) -{ - m_externalForce = force; -} - -DG_INLINE void dgDynamicBody::SetTorque (const dgVector& torque) -{ - m_externalTorque = torque; -} - - -DG_INLINE dgVector dgDynamicBody::PredictLinearVelocity(dgFloat32 timestep) const -{ - return m_veloc + m_externalForce.Scale (timestep * m_invMass.m_w); -} - -DG_INLINE dgVector dgDynamicBody::PredictAngularVelocity(dgFloat32 timestep) const -{ - return m_omega + m_invWorldInertiaMatrix.RotateVector(m_externalTorque).Scale (timestep); -} - - -DG_INLINE dgBody::OnApplyExtForceAndTorque dgDynamicBody::GetExtForceAndTorqueCallback () const -{ - return m_applyExtForces; -} - -DG_INLINE void dgDynamicBody::SetExtForceAndTorqueCallback (OnApplyExtForceAndTorque callback) -{ - m_applyExtForces = callback; -} - -DG_INLINE dgSkeletonContainer* dgDynamicBody::GetSkeleton() const -{ - return m_skeleton; -} - -DG_INLINE void dgDynamicBody::SetSkeleton(dgSkeletonContainer* const skeleton) -{ - dgAssert (!(m_skeleton && skeleton)); - m_skeleton = skeleton; -} - -DG_INLINE const dgVector& dgDynamicBody::GetDampCoeffcient (dgFloat32 timestep) -{ - if (dgAbs(m_cachedTimeStep - timestep) > dgFloat32(1.0e-6f)) { - m_cachedTimeStep = timestep; - const dgFloat32 tau = dgFloat32(60.0f) * timestep; - m_cachedDampCoef.m_x = dgPow(dgFloat32(1.0f) - m_dampCoef.m_x, tau); - m_cachedDampCoef.m_y = dgPow(dgFloat32(1.0f) - m_dampCoef.m_y, tau); - m_cachedDampCoef.m_z = dgPow(dgFloat32(1.0f) - m_dampCoef.m_z, tau); - m_cachedDampCoef.m_w = dgPow(dgFloat32(1.0f) - m_dampCoef.m_w, tau); - } - return m_cachedDampCoef; -} - - -#endif - - diff --git a/thirdparty/src/newton/dgPhysics/dgHingeConstraint.cpp b/thirdparty/src/newton/dgPhysics/dgHingeConstraint.cpp deleted file mode 100644 index f9f8ada0a..000000000 --- a/thirdparty/src/newton/dgPhysics/dgHingeConstraint.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgHingeConstraint.h" - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -dgHingeConstraint::dgHingeConstraint () - :dgBilateralConstraint() -{ - dgAssert ((((dgUnsigned64) &m_localMatrix0) & 15) == 0); -// constraint->Init (); - - m_localMatrix0 = dgGetIdentityMatrix(); - m_localMatrix1 = dgGetIdentityMatrix(); - - m_maxDOF = 6; - m_jointAccelFnt = NULL; - m_constId = m_hingeConstraint; - m_angle = dgFloat32 (dgFloat32 (0.0f)); -} - -dgHingeConstraint::~dgHingeConstraint () -{ -} - -/* -dgHingeConstraint* dgHingeConstraint::Create(dgWorld* world) -{ - dgHingeConstraint* constraint; - - //constraint = dgHingeConstraintArray::GetPool().GetElement(); - dgHingeConstraintArray& array = *world; - constraint = array.GetElement(); - - dgAssert ((((dgUnsigned64) &constraint->m_localMatrix0) & 15) == 0); - constraint->Init (); - constraint->m_maxDOF = 6; - constraint->m_constId = dgHingeConstraintId; - - constraint->m_angle = dgFloat32 (0.0f); - constraint->m_jointAccelFnt = NULL; - return constraint; -} - -void dgHingeConstraint::Remove(dgWorld* world) -{ - dgHingeConstraintArray& array = *world; - dgBilateralConstraint::Remove (world); - //dgHingeConstraintArray::GetPool().RemoveElement (this); - array.RemoveElement (this); -} -*/ - -void dgHingeConstraint::SetJointParameterCallback (dgHingeJointAcceleration callback) -{ - m_jointAccelFnt = callback; -} - -dgFloat32 dgHingeConstraint::GetJointAngle () const -{ - return m_angle; -} - -dgFloat32 dgHingeConstraint::GetJointOmega () const -{ - dgAssert (m_body0); - dgAssert (m_body1); - dgVector dir (m_body0->GetMatrix().RotateVector (m_localMatrix0[0])); - const dgVector& omega0 = m_body0->GetOmega(); - const dgVector& omega1 = m_body1->GetOmega(); - return dir.DotProduct(omega0 - omega1).GetScalar(); -} - -dgFloat32 dgHingeConstraint::CalculateStopAlpha (dgFloat32 angle, const dgJointCallbackParam* param) const -{ - dgFloat32 alpha; - dgFloat32 omega; - dgFloat32 penetrationErr; - - alpha = dgFloat32 (0.0f); - if (m_angle > angle) { - omega = GetJointOmega (); - if (omega < dgFloat32 (0.0f)) { - omega = dgFloat32 (0.0f); - } - penetrationErr = (angle - m_angle); - alpha = dgFloat32 (100.0f) * penetrationErr - omega * dgFloat32 (1.01f) / param->m_timestep; - - } else if (m_angle < angle) { - omega = GetJointOmega (); - if (omega > dgFloat32 (0.0f)) { - omega = dgFloat32 (0.0f); - } - - penetrationErr = MIN_JOINT_PIN_LENGTH * (angle - m_angle); - alpha = dgFloat32 (100.0f) * penetrationErr - omega * dgFloat32 (1.01f) / param->m_timestep; - } - return alpha; -} - -dgVector dgHingeConstraint::GetJointForce () const -{ - dgMatrix matrix0; - dgMatrix matrix1; - - CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1); - return dgVector (matrix0.m_front.Scale (m_jointForce[0].m_force) + - matrix0.m_up.Scale (m_jointForce[1].m_force) + - matrix0.m_right.Scale (m_jointForce[2].m_force) + - matrix0.m_up.Scale (m_jointForce[3].m_force) + - matrix0.m_right.Scale (m_jointForce[4].m_force)); -} - - -dgUnsigned32 dgHingeConstraint::JacobianDerivative (dgContraintDescritor& params) -{ - dgMatrix matrix0; - dgMatrix matrix1; - dgVector angle (CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1)); - - m_angle = -angle.m_x; - - dgAssert (dgAbs (1.0f - matrix0.m_front.DotProduct(matrix0.m_front).GetScalar()) < dgFloat32 (1.0e-5f)); - dgAssert (dgAbs (1.0f - matrix0.m_up.DotProduct(matrix0.m_up).GetScalar()) < dgFloat32 (1.0e-5f)); - dgAssert (dgAbs (1.0f - matrix0.m_right.DotProduct(matrix0.m_right).GetScalar()) < dgFloat32 (1.0e-5f)); - - const dgVector& dir0 = matrix0.m_front; - const dgVector& dir1 = matrix0.m_up; - const dgVector& dir2 = matrix0.m_right; - - const dgVector& p0 = matrix0.m_posit; - const dgVector& p1 = matrix1.m_posit; - dgVector q0 (p0 + matrix0.m_front.Scale(MIN_JOINT_PIN_LENGTH)); - dgVector q1 (p1 + matrix1.m_front.Scale(MIN_JOINT_PIN_LENGTH)); - -// dgAssert (((p1 - p0) % (p1 - p0)) < 1.0e-2f); - - dgPointParam pointDataP; - dgPointParam pointDataQ; - InitPointParam (pointDataP, m_defualtDiagonalRegularizer, p0, p1); - InitPointParam (pointDataQ, m_defualtDiagonalRegularizer, q0, q1); - - CalculatePointDerivative (0, params, dir0, pointDataP, &m_jointForce[0]); - CalculatePointDerivative (1, params, dir1, pointDataP, &m_jointForce[1]); - CalculatePointDerivative (2, params, dir2, pointDataP, &m_jointForce[2]); - CalculatePointDerivative (3, params, dir1, pointDataQ, &m_jointForce[3]); - CalculatePointDerivative (4, params, dir2, pointDataQ, &m_jointForce[4]); - - dgInt32 ret = 5; - if (m_jointAccelFnt) { - dgJointCallbackParam axisParam; - axisParam.m_accel = dgFloat32 (0.0f); - axisParam.m_timestep = params.m_timestep; - axisParam.m_minFriction = DG_MIN_BOUND; - axisParam.m_maxFriction = DG_MAX_BOUND; - - if (m_jointAccelFnt (*this, &axisParam)) { - if ((axisParam.m_minFriction > DG_MIN_BOUND) || (axisParam.m_maxFriction < DG_MAX_BOUND)) { - params.m_forceBounds[5].m_low = axisParam.m_minFriction; - params.m_forceBounds[5].m_upper = axisParam.m_maxFriction; - params.m_forceBounds[5].m_normalIndex = DG_INDEPENDENT_ROW; - } - - CalculateAngularDerivative (5, params, dir0, m_defualtDiagonalRegularizer, dgFloat32 (0.0f), &m_jointForce[5]); - SetMotorAcceleration (5, axisParam.m_accel, params); - ret = 6; - } - } - - return dgUnsigned32 (ret); -} - - - diff --git a/thirdparty/src/newton/dgPhysics/dgHingeConstraint.h b/thirdparty/src/newton/dgPhysics/dgHingeConstraint.h deleted file mode 100644 index 4fb1ef969..000000000 --- a/thirdparty/src/newton/dgPhysics/dgHingeConstraint.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -#if !defined(AFX_DGHINGECONSTRAINT_H__3FF7D7AA_90CC_4BA5_B2A4_D3BA51AD2FFD_H) -#define AFX_DGHINGECONSTRAINT_H__3FF7D7AA_90CC_4BA5_B2A4_D3BA51AD2FFD_H -#include "dgBilateralConstraint.h" - -//template<class T> class dgPool; - -class dgHingeConstraint; - - -typedef dgUnsigned32 (dgApi *dgHingeJointAcceleration) (const dgHingeConstraint& hinge, dgJointCallbackParam* param); - -class dgHingeConstraint: public dgBilateralConstraint -{ - public: - dgFloat32 GetJointAngle () const; - dgFloat32 GetJointOmega () const; - dgVector GetJointForce () const; - dgFloat32 CalculateStopAlpha (dgFloat32 angle, const dgJointCallbackParam* param) const; - void SetJointParameterCallback (dgHingeJointAcceleration callback); - - private: - virtual dgUnsigned32 JacobianDerivative (dgContraintDescritor& params); - virtual void Serialize (dgSerialize serializeCallback, void* const userData) {dgAssert (0);} - - dgHingeConstraint(); - virtual ~dgHingeConstraint(); - - dgMatrix m_localMatrix0; - dgMatrix m_localMatrix1; - - dgFloat32 m_angle; - dgHingeJointAcceleration m_jointAccelFnt; - - -//#ifdef _NEWTON_USE_DOUBLE -// dgUnsigned32 m_reserve[1]; -//#else -// dgUnsigned32 m_reserve[2]; -//#endif - - friend class dgWorld; -// friend class dgPool<dgHingeConstraint>; -}; - -//class dgHingeConstraintArray: public dgPoolContainer<dgHingeConstraint> -//{ -//}; - - -#endif // !defined(AFX_DGHINGECONSTRAINT_H__3FF7D7AA_90CC_4BA5_B2A4_D3BA51AD2FFD_H) - diff --git a/thirdparty/src/newton/dgPhysics/dgKinematicBody.cpp b/thirdparty/src/newton/dgPhysics/dgKinematicBody.cpp deleted file mode 100644 index 1ca81df3a..000000000 --- a/thirdparty/src/newton/dgPhysics/dgKinematicBody.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgKinematicBody.h" - - -dgVector dgKinematicBody::m_dummy (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); - - -dgKinematicBody::dgKinematicBody() - :dgBody() -{ - m_collidable = false; - m_type = m_kinematicBody; - m_rtti |= m_kinematicBodyRTTI; -} - -dgKinematicBody::dgKinematicBody (dgWorld* const world, const dgTree<const dgCollision*, dgInt32>* const collisionNode, dgDeserialize serializeCallback, void* const userData, dgInt32 revisionNumber) - :dgBody (world, collisionNode, serializeCallback, userData, revisionNumber) -{ - m_collidable = false; - m_type = m_kinematicBody; - m_rtti |= m_kinematicBodyRTTI; -} - -dgKinematicBody::~dgKinematicBody () -{ -} - -void dgKinematicBody::Serialize (const dgTree<dgInt32, const dgCollision*>& collisionRemapId, dgSerialize serializeCallback, void* const userData) -{ - dgBody::Serialize (collisionRemapId, serializeCallback, userData); -} - diff --git a/thirdparty/src/newton/dgPhysics/dgKinematicBody.h b/thirdparty/src/newton/dgPhysics/dgKinematicBody.h deleted file mode 100644 index 0ffafe814..000000000 --- a/thirdparty/src/newton/dgPhysics/dgKinematicBody.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_KINEMATIC_BODY_H_ -#define _DG_KINEMATIC_BODY_H_ - -#include "dgPhysicsStdafx.h" -#include "dgBody.h" - - -DG_MSC_VECTOR_ALIGNMENT -class dgKinematicBody: public dgBody -{ - public: - dgKinematicBody(); - dgKinematicBody (dgWorld* const world, const dgTree<const dgCollision*, dgInt32>* const collisionNode, dgDeserialize serializeCallback, void* const userData, dgInt32 revisionNumber); - virtual ~dgKinematicBody (); - - virtual const dgVector& GetForce() const {return m_dummy;} - virtual const dgVector& GetTorque() const {return m_dummy;} - - virtual void AddForce (const dgVector& force) {} - virtual void AddTorque (const dgVector& torque) {} - virtual void SetForce (const dgVector& force) {} - virtual void SetTorque (const dgVector& torque) {} - virtual void ApplyExtenalForces (dgFloat32 timestep, dgInt32 threadIndex) {} - virtual OnApplyExtForceAndTorque GetExtForceAndTorqueCallback () const {return NULL;} - virtual void SetExtForceAndTorqueCallback (OnApplyExtForceAndTorque callback) {} - - virtual dgFloat32 GetLinearDamping () const {return dgFloat32 (0.0f);} - virtual dgVector GetAngularDamping () const {return m_dummy;} - virtual void SetLinearDamping (dgFloat32 linearDamp) {} - virtual void SetAngularDamping (const dgVector& angularDamp) {} - - virtual dgVector PredictLinearVelocity(dgFloat32 timestep) const {return m_veloc;} - virtual dgVector PredictAngularVelocity(dgFloat32 timestep) const {return m_omega;} - - virtual bool IsInEquilibrium () const {return true;} - virtual void SetCollidable (bool state) {m_collidable = state;} - virtual void Serialize (const dgTree<dgInt32, const dgCollision*>& collisionRemapId, dgSerialize serializeCallback, void* const userData); - virtual void AddDampingAcceleration(dgFloat32 timestep) {} - - static dgVector m_dummy; - - friend class dgWorld; - friend class dgBroadPhase; - friend class dgWorldDynamicUpdate; -} DG_GCC_VECTOR_ALIGNMENT; - - - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgNarrowPhaseCollision.cpp b/thirdparty/src/newton/dgPhysics/dgNarrowPhaseCollision.cpp deleted file mode 100644 index e441ee1ee..000000000 --- a/thirdparty/src/newton/dgPhysics/dgNarrowPhaseCollision.cpp +++ /dev/null @@ -1,2077 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" - -#include "dgWorld.h" -#include "dgCollision.h" -#include "dgMeshEffect.h" -#include "dgDynamicBody.h" -#include "dgCollisionBVH.h" -#include "dgCollisionBox.h" -#include "dgContactSolver.h" -#include "dgKinematicBody.h" -#include "dgCollisionCone.h" -#include "dgCollisionNull.h" -#include "dgBodyMasterList.h" -#include "dgCollisionScene.h" -#include "dgCollisionSphere.h" -#include "dgCollisionCapsule.h" -#include "dgCollisionCylinder.h" -#include "dgCollisionCompound.h" -#include "dgCollisionUserMesh.h" -#include "dgCollisionInstance.h" -#include "dgWorldDynamicUpdate.h" -#include "dgCollisionConvexHull.h" -#include "dgCollisionHeightField.h" -#include "dgCollisionConvexPolygon.h" -#include "dgCollisionDeformableMesh.h" -#include "dgCollisionChamferCylinder.h" -#include "dgCollisionCompoundFractured.h" -#include "dgCollisionDeformableSolidMesh.h" -#include "dgCollisionMassSpringDamperSystem.h" -#include "dgCollisionIncompressibleParticles.h" - - -DG_MSC_VECTOR_ALIGNMENT -class dgCollisionContactCloud: public dgCollisionConvex -{ - public: - dgCollisionContactCloud(dgMemoryAllocator* const allocator, dgInt32 count, const dgContactPoint* const contacts) - :dgCollisionConvex(allocator, 0, m_contactCloud) - ,m_contacts(contacts) - ,m_count(count) - { - } - ~dgCollisionContactCloud() - { - } - - dgInt32 CalculateSignature() const - { - dgAssert (0); - return 0; - } - void Serialize(dgSerialize callback, void* const userData) const - { - dgAssert (0); - } - void SetCollisionBBox(const dgVector& p0, const dgVector& p1) - { - dgAssert (0); - } - dgFloat32 RayCast(const dgVector& localP0, const dgVector& localP1, dgFloat32 maxT, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const - { - dgAssert (0); - return 0; - } - - dgVector SupportVertex(const dgVector& dir, dgInt32* const vertexIndex) const - { - dgInt32 index = 0; - dgFloat32 dist = dgFloat32 (-1.0e10f); - for (dgInt32 i = 0; i < m_count; i ++) { - dgFloat32 dist1 = dir.DotProduct(m_contacts[i].m_point).GetScalar(); - if (dist1 > dist) { - index = i; - dist = dist1; - } - } - return m_contacts[index].m_point; - } - - dgInt32 CalculatePlaneIntersection(const dgVector& normal, const dgVector& point, dgVector* const contactsOut) const - { - *contactsOut = point; - return 1; - } - - dgFloat32 GetVolume() const - { - dgAssert (0); - return 0; - } - dgFloat32 GetBoxMinRadius() const - { - dgAssert (0); - return 0; - } - dgFloat32 GetBoxMaxRadius() const - { - dgAssert(0); - return 0; - } - - const dgContactPoint* m_contacts; - dgInt32 m_count; - - static dgVector m_pruneUpDir; - static dgVector m_pruneSupportX; - -} DG_GCC_VECTOR_ALIGNMENT; - -dgVector dgCollisionContactCloud::m_pruneUpDir(dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f)); -dgVector dgCollisionContactCloud::m_pruneSupportX(dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - - -dgCollisionInstance* dgWorld::CreateNull () -{ - dgUnsigned32 crc = dgCollision::dgCollisionNull_RTTI; - dgBodyCollisionList::dgTreeNode* node = dgBodyCollisionList::Find (crc); - if (!node) { - dgCollision* const collision = new (m_allocator) dgCollisionNull (m_allocator, crc); - node = dgBodyCollisionList::Insert (collision, crc); - } - return CreateInstance (node->GetInfo(), 0, dgGetIdentityMatrix()); -} - -dgCollisionInstance* dgWorld::CreateSphere(dgFloat32 radii, dgInt32 shapeID, const dgMatrix& offsetMatrix) -{ - dgUnsigned32 crc = dgCollisionSphere::CalculateSignature (radii); - dgBodyCollisionList::dgTreeNode* node = dgBodyCollisionList::Find (crc); - if (!node) { - dgCollision* const collision = new (m_allocator) dgCollisionSphere (m_allocator, crc, dgAbs(radii)); - node = dgBodyCollisionList::Insert (collision, crc); - } - return CreateInstance (node->GetInfo(), shapeID, offsetMatrix); -} - -dgCollisionInstance* dgWorld::CreateBox(dgFloat32 dx, dgFloat32 dy, dgFloat32 dz, dgInt32 shapeID, const dgMatrix& offsetMatrix) -{ - dgUnsigned32 crc = dgCollisionBox::CalculateSignature(dx, dy, dz); - dgBodyCollisionList::dgTreeNode* node = dgBodyCollisionList::Find (crc); - if (!node) { - dgCollision* const collision = new (m_allocator) dgCollisionBox (m_allocator, crc, dx, dy, dz); - node = dgBodyCollisionList::Insert (collision, crc); - } - return CreateInstance (node->GetInfo(), shapeID, offsetMatrix); -} - -dgCollisionInstance* dgWorld::CreateCapsule (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix) -{ - dgUnsigned32 crc = dgCollisionCapsule::CalculateSignature(dgAbs (radio0), dgAbs (radio1), dgAbs (height) * dgFloat32 (0.5f)); - - dgBodyCollisionList::dgTreeNode* node = dgBodyCollisionList::Find (crc); - if (!node) { - dgCollision* collision = new (m_allocator) dgCollisionCapsule (m_allocator, crc, radio0, radio1, height); - node = dgBodyCollisionList::Insert (collision, crc); - } - return CreateInstance (node->GetInfo(), shapeID, offsetMatrix); -} - -dgCollisionInstance* dgWorld::CreateCylinder (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix) -{ - dgUnsigned32 crc = dgCollisionCylinder::CalculateSignature(dgAbs (radio0), dgAbs (radio1), dgAbs (height) * dgFloat32 (0.5f)); - - dgBodyCollisionList::dgTreeNode* node = dgBodyCollisionList::Find (crc); - if (!node) { - dgCollision* collision = new (m_allocator) dgCollisionCylinder (m_allocator, crc, radio0, radio1, height); - node = dgBodyCollisionList::Insert (collision, crc); - } - return CreateInstance (node->GetInfo(), shapeID, offsetMatrix); -} - -dgCollisionInstance* dgWorld::CreateChamferCylinder (dgFloat32 radius, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix) -{ - dgUnsigned32 crc = dgCollisionChamferCylinder::CalculateSignature(dgAbs (radius), dgAbs (height) * dgFloat32 (0.5f)); - - dgBodyCollisionList::dgTreeNode* node = dgBodyCollisionList::Find (crc); - if (!node) { - dgCollision* collision = new (m_allocator) dgCollisionChamferCylinder (m_allocator, crc, radius, height); - node = dgBodyCollisionList::Insert (collision, crc); - } - return CreateInstance (node->GetInfo(), shapeID, offsetMatrix); -} - -dgCollisionInstance* dgWorld::CreateCone (dgFloat32 radius, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix) -{ - dgUnsigned32 crc = dgCollisionCone::CalculateSignature (dgAbs (radius), dgAbs (height) * dgFloat32 (0.5f)); - dgBodyCollisionList::dgTreeNode* node = dgBodyCollisionList::Find (crc); - if (!node) { - dgCollision* const collision = new (m_allocator) dgCollisionCone (m_allocator, crc, radius, height); - node = dgBodyCollisionList::Insert (collision, crc); - } - return CreateInstance (node->GetInfo(), shapeID, offsetMatrix); -} - -dgCollisionInstance* dgWorld::CreateConvexHull (dgInt32 count, const dgFloat32* const vertexArray, dgInt32 strideInBytes, dgFloat32 tolerance, dgInt32 shapeID, const dgMatrix& offsetMatrix) -{ - dgUnsigned32 crc = dgCollisionConvexHull::CalculateSignature (count, vertexArray, strideInBytes); - - dgBodyCollisionList::dgTreeNode* node = dgBodyCollisionList::Find (crc); - - if (!node) { - // shape not found create a new one and add to the cache - dgCollisionConvexHull* const collision = new (m_allocator) dgCollisionConvexHull (m_allocator, crc, count, strideInBytes, tolerance, vertexArray); - if (collision->GetConvexVertexCount()) { - node = dgBodyCollisionList::Insert (collision, crc); - } else { - //most likely the point cloud is a plane or a line - //could not make the shape destroy the shell and return NULL - //note this is the only newton shape that can return NULL; - collision->Release(); - return NULL; - } - } - - // add reference to the shape and return the collision pointer - return CreateInstance (node->GetInfo(), shapeID, offsetMatrix); -} - -dgCollisionInstance* dgWorld::CreateCompound () -{ - // compound collision are not cached - dgCollisionCompound* const collision = new (m_allocator) dgCollisionCompound (this); - dgCollisionInstance* const instance = CreateInstance (collision, 0, dgGetIdentityMatrix()); - collision->SetParent(instance); - collision->Release(); - return instance; -} - -dgCollisionInstance* dgWorld::CreateScene () -{ - dgCollisionScene* const collision = new (m_allocator) dgCollisionScene(this); - dgCollisionInstance* const instance = CreateInstance (collision, 0, dgGetIdentityMatrix()); - collision->SetParent(instance); - collision->Release(); - return instance; -} - -dgCollisionInstance* dgWorld::CreateFracturedCompound (dgMeshEffect* const solidMesh, int shapeID, int fracturePhysicsMaterialID, int pointcloudCount, const dgFloat32* const vertexCloud, int strideInBytes, int materialID, const dgMatrix& textureMatrix, - dgCollisionCompoundFractured::OnEmitFractureChunkCallBack emitFracfuredChunk, - dgCollisionCompoundFractured::OnEmitNewCompundFractureCallBack emitFracturedCompound, - dgCollisionCompoundFractured::OnReconstructFractureMainMeshCallBack reconstructMainMesh) -{ - dgCollisionCompoundFractured* const collision = new (m_allocator) dgCollisionCompoundFractured (this, solidMesh, fracturePhysicsMaterialID, pointcloudCount, vertexCloud, strideInBytes, materialID, textureMatrix, emitFracfuredChunk, emitFracturedCompound, reconstructMainMesh); - dgCollisionInstance* const instance = CreateInstance (collision, shapeID, dgGetIdentityMatrix()); - collision->SetParent(instance); - collision->Release(); - return instance; -} - -dgCollisionInstance* dgWorld::CreateMassSpringDamperSystem (dgInt32 shapeID, dgInt32 pointCount, const dgFloat32* const points, dgInt32 strideInBytes, const dgFloat32* const pointsMass, dgInt32 linksCount, const dgInt32* const links, const dgFloat32* const linksSpring, const dgFloat32* const LinksDamper) -{ - dgCollision* const collision = new (m_allocator)dgCollisionMassSpringDamperSystem(this, shapeID, pointCount, points, strideInBytes, pointsMass, linksCount, links, linksSpring, LinksDamper); - dgCollisionInstance* const instance = CreateInstance(collision, shapeID, dgGetIdentityMatrix()); - collision->Release(); - return instance; -} - -dgCollisionInstance* dgWorld::CreateDeformableSolid (dgMeshEffect* const mesh, dgInt32 shapeID) -{ - dgAssert (m_allocator == mesh->GetAllocator()); - dgCollision* const collision = new (m_allocator) dgCollisionDeformableSolidMesh (this, mesh); - dgCollisionInstance* const instance = CreateInstance (collision, shapeID, dgGetIdentityMatrix()); - collision->Release(); - return instance; -} - -dgCollisionInstance* dgWorld::CreateBVH () -{ - // collision tree are not cached - dgCollision* const collision = new (m_allocator) dgCollisionBVH (this); - dgCollisionInstance* const instance = CreateInstance (collision, 0, dgGetIdentityMatrix()); - collision->Release(); - return instance; -} - -dgCollisionInstance* dgWorld::CreateStaticUserMesh (const dgVector& boxP0, const dgVector& boxP1, const dgUserMeshCreation& data) -{ - dgCollision* const collision = new (m_allocator) dgCollisionUserMesh(this, boxP0, boxP1, data); - dgCollisionInstance* const instance = CreateInstance (collision, 0, dgGetIdentityMatrix()); - collision->Release(); - return instance; - -} - -dgCollisionInstance* dgWorld::CreateHeightField( - dgInt32 width, dgInt32 height, dgInt32 contructionMode, dgInt32 elevationDataType, - const void* const elevationMap, const dgInt8* const atributeMap, - dgFloat32 verticalScale, dgFloat32 horizontalScale_x, dgFloat32 horizontalScale_z) -{ - dgCollision* const collision = new (m_allocator) dgCollisionHeightField (this, width, height, contructionMode, elevationMap, - elevationDataType ? dgCollisionHeightField::m_unsigned16Bit : dgCollisionHeightField::m_float32Bit, - verticalScale, atributeMap, horizontalScale_x, horizontalScale_z); - dgCollisionInstance* const instance = CreateInstance (collision, 0, dgGetIdentityMatrix()); - collision->Release(); - return instance; -} - -dgCollisionInstance* dgWorld::CreateInstance (const dgCollision* const child, dgInt32 shapeID, const dgMatrix& offsetMatrix) -{ - dgAssert (dgAbs (offsetMatrix[0].DotProduct(offsetMatrix[0]).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-5f)); - dgAssert (dgAbs (offsetMatrix[1].DotProduct(offsetMatrix[1]).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-5f)); - dgAssert (dgAbs (offsetMatrix[2].DotProduct(offsetMatrix[2]).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-5f)); - dgAssert (dgAbs (offsetMatrix[2].DotProduct(offsetMatrix[0].CrossProduct(offsetMatrix[1])).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-5f)); - - dgAssert (offsetMatrix[0][3] == dgFloat32 (0.0f)); - dgAssert (offsetMatrix[1][3] == dgFloat32 (0.0f)); - dgAssert (offsetMatrix[2][3] == dgFloat32 (0.0f)); - dgAssert (offsetMatrix[3][3] == dgFloat32 (1.0f)); - dgCollisionInstance* const instance = new (m_allocator) dgCollisionInstance (this, child, shapeID, offsetMatrix); - return instance; -} - -void dgWorld::SerializeCollision(dgCollisionInstance* const shape, dgSerialize serialization, void* const userData) const -{ - dgSerializeMarker(serialization, userData); - shape->Serialize(serialization, userData); -} - -dgCollisionInstance* dgWorld::CreateCollisionFromSerialization (dgDeserialize deserialization, void* const userData) -{ - dgInt32 revision = dgDeserializeMarker (deserialization, userData); - dgCollisionInstance* const instance = new (m_allocator) dgCollisionInstance (this, deserialization, userData, revision); - return instance; -} - -dgContactMaterial* dgWorld::GetMaterial (dgUnsigned32 bodyGroupId0, dgUnsigned32 bodyGroupId1) const -{ - if (bodyGroupId0 > bodyGroupId1) { - dgSwap (bodyGroupId0, bodyGroupId1); - } - - dgUnsigned32 key = (bodyGroupId1 << 16) + bodyGroupId0; - dgBodyMaterialList::dgTreeNode *const node = dgBodyMaterialList::Find (key); - - return node ? &node->GetInfo() : NULL; -} - -dgContactMaterial* dgWorld::GetFirstMaterial () const -{ - dgBodyMaterialList::dgTreeNode *const node = dgBodyMaterialList::Minimum(); - dgAssert (node); - return &node->GetInfo(); -} - -dgContactMaterial* dgWorld::GetNextMaterial (dgContactMaterial* material) const -{ - dgBodyMaterialList::dgTreeNode *const thisNode = dgBodyMaterialList::GetNodeFromInfo (*material); - dgAssert (thisNode); - dgBodyMaterialList::dgTreeNode *const node = (dgBodyMaterialList::dgTreeNode *)thisNode->Next(); - if (node) { - return &node->GetInfo(); - } - - return NULL; -} - -dgUnsigned32 dgWorld::GetDefualtBodyGroupID() const -{ - return m_defualtBodyGroupID; -} - -dgUnsigned32 dgWorld::CreateBodyGroupID() -{ - dgContactMaterial pairMaterial; - - pairMaterial.m_aabbOverlap = NULL; - pairMaterial.m_processContactPoint = NULL; - pairMaterial.m_compoundAABBOverlap = NULL; - - dgUnsigned32 newId = m_bodyGroupID; - m_bodyGroupID += 1; - for (dgUnsigned32 i = 0; i < m_bodyGroupID ; i ++) { - dgUnsigned32 key = (newId << 16) + i; - - dgBodyMaterialList::Insert(pairMaterial, key); - } - - return newId; -} - -void dgWorld::ReleaseCollision(const dgCollision* const collision) -{ - dgInt32 ref = collision->Release(); - if (ref == 1) { - dgBodyCollisionList::dgTreeNode* const node = dgBodyCollisionList::Find (collision->m_signature); - if (node) { - dgAssert (node->GetInfo() == collision); - collision->Release(); - dgBodyCollisionList::Remove (node); - } - } -} - -// ******************************************************************************** -// -// separate collision system -// -// ******************************************************************************** -dgInt32 dgWorld::ClosestPoint (dgTriplex& point, const dgCollisionInstance* const collision, const dgMatrix& matrix, dgTriplex& contact, dgTriplex& normal, dgInt32 threadIndex) -{ - dgTriplex contactA; - dgMatrix pointMatrix (dgGetIdentityMatrix()); - - contact = point; - pointMatrix.m_posit.m_x = point.m_x; - pointMatrix.m_posit.m_y = point.m_y; - pointMatrix.m_posit.m_z = point.m_z; - return ClosestPoint(collision, matrix, m_pointCollision, pointMatrix, contact, contactA, normal, threadIndex); -} - -dgInt32 dgWorld::ClosestPoint(const dgCollisionInstance* const collisionSrcA, const dgMatrix& matrixA, - const dgCollisionInstance* const collisionSrcB, const dgMatrix& matrixB, - dgTriplex& contactA, dgTriplex& contactB, dgTriplex& normalAB,dgInt32 threadIndex) -{ - dgKinematicBody collideBodyA; - dgKinematicBody collideBodyB; - dgContactPoint contacts[DG_MAX_CONTATCS]; - - dgCollisionInstance collisionA(*collisionSrcA, collisionSrcA->GetChildShape()); - dgCollisionInstance collisionB(*collisionSrcB, collisionSrcB->GetChildShape()); - - collideBodyA.m_matrix = matrixA; - collideBodyA.m_collision = &collisionA; - collisionA.SetGlobalMatrix(collisionA.GetLocalMatrix() * matrixA); - - collideBodyB.m_matrix = matrixB; - collideBodyB.m_collision = &collisionB; - collisionB.SetGlobalMatrix (collisionB.GetLocalMatrix() * matrixB); - - dgContactMaterial material; - material.m_penetration = dgFloat32 (0.0f); - dgContact contactJoint (this, &material, &collideBodyB, &collideBodyA); - dgCollisionParamProxy proxy(&contactJoint, contacts, threadIndex, false, false); - - proxy.m_body0 = &collideBodyA; - proxy.m_instance0 = collideBodyA.m_collision; - proxy.m_body1 = &collideBodyB; - proxy.m_instance1 = collideBodyB.m_collision; - proxy.m_timestep = dgFloat32 (0.0f); - proxy.m_skinThickness = dgFloat32 (0.0f); - proxy.m_maxContacts = 16; - - dgInt32 flag = 0; - if (collisionA.IsType (dgCollision::dgCollisionCompound_RTTI)) { - flag = ClosestCompoundPoint (proxy); - } else if (collisionB.IsType (dgCollision::dgCollisionCompound_RTTI)) { - dgSwap (proxy.m_body0, proxy.m_body1); - dgSwap (proxy.m_instance0, proxy.m_instance1); - flag = ClosestCompoundPoint (proxy); - normalAB.m_x *= dgFloat32 (-1.0f); - normalAB.m_y *= dgFloat32 (-1.0f); - normalAB.m_z *= dgFloat32 (-1.0f); - } else if (collisionA.IsType (dgCollision::dgCollisionConvexShape_RTTI) && collisionB.IsType (dgCollision::dgCollisionConvexShape_RTTI)) { - flag = ClosestPoint (proxy); - } - - if (flag) { - contactA.m_x = contacts[0].m_point.m_x; - contactA.m_y = contacts[0].m_point.m_y; - contactA.m_z = contacts[0].m_point.m_z; - contactB.m_x = contacts[1].m_point.m_x; - contactB.m_y = contacts[1].m_point.m_y; - contactB.m_z = contacts[1].m_point.m_z; - normalAB.m_x = contacts[0].m_normal.m_x; - normalAB.m_y = contacts[0].m_normal.m_y; - normalAB.m_z = contacts[0].m_normal.m_z; - } - return flag; -} - - -bool dgWorld::IntersectionTest (const dgCollisionInstance* const collisionSrcA, const dgMatrix& matrixA, - const dgCollisionInstance* const collisionSrcB, const dgMatrix& matrixB, - dgInt32 threadIndex) -{ - dgKinematicBody collideBodyA; - dgKinematicBody collideBodyB; - dgCollisionInstance collisionA(*collisionSrcA, collisionSrcA->GetChildShape()); - dgCollisionInstance collisionB(*collisionSrcB, collisionSrcB->GetChildShape()); - - collideBodyA.m_world = this; - collideBodyA.SetContinueCollisionMode(false); - collideBodyA.m_matrix = matrixA; - collideBodyA.m_collision = &collisionA; - collideBodyA.UpdateCollisionMatrix(dgFloat32 (0.0f), 0); - - collideBodyB.m_world = this; - collideBodyB.SetContinueCollisionMode(false); - collideBodyB.m_matrix = matrixB; - collideBodyB.m_collision = &collisionB; - collideBodyB.UpdateCollisionMatrix(dgFloat32 (0.0f), 0); - - dgContactMaterial material; - material.m_penetration = dgFloat32 (0.0f); - dgContact contactJoint (this, &material, &collideBodyB, &collideBodyA); - - dgBroadPhase::dgPair pair; - pair.m_contactCount = 0; - pair.m_contact = &contactJoint; - pair.m_contactBuffer = NULL; - pair.m_timestep = dgFloat32 (0.0f); - pair.m_cacheIsValid = 0; - CalculateContacts (&pair, threadIndex, false, true); - return (pair.m_contactCount == -1) ? true : false; -} - -dgInt32 dgWorld::ClosestCompoundPoint (dgCollisionParamProxy& proxy) const -{ - dgCollisionInstance* const instance = proxy.m_instance0; - dgAssert (instance->IsType(dgCollision::dgCollisionCompound_RTTI)); - dgCollisionCompound* const collision = (dgCollisionCompound*) instance->GetChildShape(); - return collision->ClosestDistance (proxy); -} - -// ********************************************************************************** -// -// dynamics collision system -// -// ********************************************************************************** -static inline dgInt32 CompareContact (const dgContactPoint* const contactA, const dgContactPoint* const contactB, void* dommy) -{ - if (contactA->m_point[0] < contactB->m_point[0]) { - return -1; - } else if (contactA->m_point[0] > contactB->m_point[0]) { - return 1; - } else { - return 0; - } -} - -DG_INLINE dgInt32 dgWorld::PruneSupport(dgInt32 count, const dgVector& dir, const dgVector* points) const -{ - dgInt32 index = 0; - dgFloat32 maxVal = dgFloat32(-1.0e20f); - for (dgInt32 i = 0; i < count; i++) { - dgFloat32 dist = dir.DotProduct(points[i]).GetScalar(); - if (dist > maxVal) { - index = i; - maxVal = dist; - } - } - return index; -} - -dgInt32 dgWorld::Prune2dContacts(const dgMatrix& matrix, dgInt32 count, dgContactPoint* const contactArray, int maxCount, dgFloat32 tol) const -{ - class dgConvexFaceNode - { - public: - dgVector m_point2d; - dgContactPoint m_contact; - dgConvexFaceNode* m_next; - dgConvexFaceNode* m_prev; - dgInt32 m_mask; - }; - - class dgHullStackSegment - { - public: - dgVector m_p0; - dgVector m_p1; - dgConvexFaceNode* m_edgeP0; - }; - - dgVector xyMask(dgVector::m_xMask | dgVector::m_yMask); - - dgVector array[DG_MAX_CONTATCS]; - dgHullStackSegment stack[DG_MAX_CONTATCS]; - - dgConvexFaceNode convexHull[32]; - dgContactPoint buffer[32]; - - // it is a big mistake to set contact to deepest penetration because si cause unwanted pops. - // is better to present the original contact penetrations - //dgFloat32 maxPenetration = dgFloat32(0.0f); - for (dgInt32 i = 0; i < count; i++) { - array[i] = matrix.UntransformVector(contactArray[i].m_point) & xyMask; - } - - dgInt32 i0 = PruneSupport(count, dgCollisionContactCloud::m_pruneSupportX, array); - count--; - convexHull[0].m_point2d = array[i0]; - convexHull[0].m_contact = contactArray[i0]; - stack[0].m_p0 = array[i0]; - array[i0] = array[count]; - contactArray[i0] = contactArray[count]; - - dgInt32 i1 = PruneSupport(count, dgCollisionContactCloud::m_pruneSupportX.Scale(dgFloat32(-1.0f)), array); - count--; - convexHull[1].m_point2d = array[i1]; - convexHull[1].m_contact = contactArray[i1]; - stack[0].m_p1 = array[i1]; - array[i1] = array[count]; - contactArray[i1] = contactArray[count]; - - stack[0].m_edgeP0 = &convexHull[0]; - convexHull[0].m_next = &convexHull[1]; - convexHull[0].m_prev = &convexHull[1]; - convexHull[1].m_next = &convexHull[0]; - convexHull[1].m_prev = &convexHull[0]; - - stack[1].m_edgeP0 = &convexHull[1]; - stack[1].m_p0 = stack[0].m_p1; - stack[1].m_p1 = stack[0].m_p0; - - int hullCount = 2; - dgInt32 stackIndex = 2; - dgFloat32 totalArea = dgFloat32 (0.0f); - while (stackIndex && count && (hullCount < sizeof (convexHull)/sizeof (convexHull[0]))) { - stackIndex--; - - dgHullStackSegment segment(stack[stackIndex]); - dgVector p1p0((segment.m_p1 - segment.m_p0)); - dgFloat32 mag2 = p1p0.DotProduct(p1p0).GetScalar(); - if (mag2 > dgFloat32 (1.0e-5f)) { - dgVector dir(dgCollisionContactCloud::m_pruneUpDir.CrossProduct(p1p0)); - dgInt32 newIndex = PruneSupport(count, dir, array); - - dgVector edge(array[newIndex] - segment.m_p0); - dgVector normal(p1p0.CrossProduct(edge)); - if (normal.m_z > dgFloat32(1.e-4f)) { - totalArea += normal.m_z; - dgAssert(stackIndex < (DG_MAX_CONTATCS - 2)); - convexHull[hullCount].m_point2d = array[newIndex]; - convexHull[hullCount].m_contact = contactArray[newIndex]; - convexHull[hullCount].m_next = segment.m_edgeP0->m_next; - segment.m_edgeP0->m_next->m_prev = &convexHull[hullCount]; - - convexHull[hullCount].m_prev = segment.m_edgeP0; - segment.m_edgeP0->m_next = &convexHull[hullCount]; - - stack[stackIndex + 0].m_p0 = segment.m_p0; - stack[stackIndex + 0].m_p1 = array[newIndex]; - stack[stackIndex + 0].m_edgeP0 = segment.m_edgeP0; - - stack[stackIndex + 1].m_p0 = array[newIndex]; - stack[stackIndex + 1].m_p1 = segment.m_p1; - stack[stackIndex + 1].m_edgeP0 = &convexHull[hullCount]; - - hullCount++; - stackIndex += 2; - count--; - array[newIndex] = array[count]; - contactArray[newIndex] = contactArray[count]; - } - } - } - dgAssert (hullCount < sizeof (convexHull)/sizeof (convexHull[0])); - - dgUpHeap<dgConvexFaceNode*, dgFloat32> sortHeap(array, sizeof (array)); - dgConvexFaceNode* hullPoint = &convexHull[0]; - - bool hasLinearCombination = true; - while (hasLinearCombination) { - sortHeap.Flush(); - hasLinearCombination = false; - dgConvexFaceNode* ptr = hullPoint; - dgVector e0 (ptr->m_next->m_point2d - ptr->m_point2d); - do { - dgVector e1(ptr->m_next->m_next->m_point2d - ptr->m_next->m_point2d); - dgFloat32 area = e0.m_y * e1.m_x - e0.m_x * e1.m_y; - sortHeap.Push(ptr->m_next, area); - e0 = e1; - ptr->m_mask = 1; - ptr = ptr->m_next; - } while (ptr != hullPoint); - - while (sortHeap.GetCount() && (sortHeap.Value() * dgFloat32 (16.0f) < totalArea)) { - dgConvexFaceNode* const corner = sortHeap[0]; - if (corner->m_mask && corner->m_prev->m_mask) { - if (hullPoint == corner) { - hullPoint = corner->m_prev; - } - hullCount --; - hasLinearCombination = true; - corner->m_prev->m_mask = 0; - corner->m_next->m_prev = corner->m_prev; - corner->m_prev->m_next = corner->m_next; - } - sortHeap.Pop(); - } - } - - while (hullCount > maxCount) { - sortHeap.Flush(); - dgConvexFaceNode* ptr = hullPoint; - dgVector e0(ptr->m_next->m_point2d - ptr->m_point2d); - do { - dgVector e1(ptr->m_next->m_next->m_point2d - ptr->m_next->m_point2d); - dgFloat32 area = e0.m_y * e1.m_x - e0.m_x * e1.m_y; - sortHeap.Push(ptr->m_next, area); - e0 = e1; - ptr->m_mask = 1; - ptr = ptr->m_next; - } while (ptr != hullPoint); - - while (sortHeap.GetCount() && (hullCount > maxCount)) { - dgConvexFaceNode* const corner = sortHeap[0]; - if (corner->m_mask && corner->m_prev->m_mask) { - if (hullPoint == corner) { - hullPoint = corner->m_prev; - } - hullCount--; - hasLinearCombination = true; - corner->m_prev->m_mask = 0; - corner->m_next->m_prev = corner->m_prev; - corner->m_prev->m_next = corner->m_next; - } - sortHeap.Pop(); - } - } - - hullCount = 0; - dgConvexFaceNode* ptr = hullPoint; - do { - contactArray[hullCount] = ptr->m_contact; - hullCount ++; - ptr = ptr->m_next; - } while (ptr != hullPoint); - return hullCount; -} - -dgInt32 dgWorld::Prune3dContacts(const dgMatrix& matrix, dgInt32 count, dgContactPoint* const contactArray, int maxCount, dgFloat32 distTol) const -{ - dgVector array[DG_MAX_CONTATCS]; - dgFloat32 max_x = dgFloat32 (1.0e20f); - dgInt32 maxIndex = 0; - for (dgInt32 i = 0; i < count; i++) { - array[i] = matrix.UntransformVector(contactArray[i].m_point); - array[i].m_w = dgFloat32 (i); - if (array[i].m_x < max_x) { - maxIndex = i; - max_x = array[i].m_x; - } - } - dgSwap (array[0], array[maxIndex]); - - for (dgInt32 i = 2; i < count; i++) { - dgInt32 j = i; - dgVector tmp (array[i]); - for (; array[j - 1].m_x > tmp.m_x; j--) { - dgAssert(j > 0); - array[j] = array[j - 1]; - } - array[j] = tmp; - } - - dgFloat32 window = dgFloat32 (2.5e-3f); - do { - dgInt32 packContacts = 0; - window *= dgFloat32 (2.0f); - const dgFloat32 window2 = window * window; - - dgUnsigned8 mask[DG_MAX_CONTATCS]; - memset (mask, 0, count * sizeof (dgUnsigned8)); - for (dgInt32 i = 0; i < count; i++) { - if (!mask[i]) { - const dgFloat32 val = array[i].m_x + window; - for (dgInt32 j = i + 1; (j < count) && (array[j].m_x < val); j++) { - if (!mask[j]) { - dgVector dp((array[j] - array[i]) & dgVector::m_triplexMask); - dgAssert(dp.m_w == dgFloat32(0.0f)); - dgFloat32 dist2 = dp.DotProduct(dp).GetScalar(); - if (dist2 < window2) { - mask[j] = 1; - packContacts = 1; - } - } - } - } - } - - if (packContacts) { - dgInt32 j = 0; - for (dgInt32 i = 0; i < count; i++) { - if (!mask[i]) { - array[j] = array[i]; - j++; - } - } - count = j; - } - } while (count > maxCount); - - dgContactPoint tmpContact [16]; - for (dgInt32 i = 0; i < count; i++) { - dgInt32 index = dgInt32 (array[i].m_w); - tmpContact[i] = contactArray[index]; - } - - memcpy (contactArray, tmpContact, count * sizeof (dgContactPoint)); - return count; -} - -dgInt32 dgWorld::PruneContacts (dgInt32 count, dgContactPoint* const contactArray, dgFloat32 distTolerenace, dgInt32 maxCount) const -{ - dgVector origin(dgVector::m_zero); - for (dgInt32 i = 0; i < count; i++) { - origin += contactArray[i].m_point; - } - dgVector scale (dgFloat32(1.0f) / count); - origin = origin * scale; - origin.m_w = dgFloat32 (1.0f); - - dgMatrix covariance(dgGetZeroMatrix()); - for (dgInt32 i = 0; i < count; i++) { - dgVector p (contactArray[i].m_point - origin); - dgAssert (p.m_w == dgFloat32 (0.0f)); - dgMatrix matrix(p, p); - covariance.m_front += matrix.m_front; - covariance.m_up += matrix.m_up; - covariance.m_right += matrix.m_right; - } - - for (dgInt32 i = 0; i < 3; i++) { - if (dgAbs(covariance[i][i]) < (1.0e-6f)) { - for (dgInt32 j = 0; j < 3; j++) { - covariance[i][j] = dgFloat32(0.0f); - covariance[j][i] = dgFloat32(0.0f); - } - } - } - dgVector eigen (covariance.EigenVectors()); - covariance.m_posit = origin; - - if (eigen[1] < eigen[2]) { - dgSwap(eigen[1], eigen[2]); - dgSwap(covariance[1], covariance[2]); - } - if (eigen[0] < eigen[1]) { - dgSwap(eigen[0], eigen[1]); - dgSwap(covariance[0], covariance[1]); - } - if (eigen[1] < eigen[2]) { - dgSwap(eigen[1], eigen[2]); - dgSwap(covariance[1], covariance[2]); - } - - const dgFloat32 eigenValueError = dgFloat32 (1.0e-4f); - if (eigen[2] > eigenValueError) { - // 3d convex Hull - return Prune3dContacts(covariance, count, contactArray, maxCount, distTolerenace); - } else if (eigen[1] > eigenValueError) { - // is a 2d or 1d convex hull - return Prune2dContacts(covariance, count, contactArray, maxCount, distTolerenace); - } else if (eigen[0] > eigenValueError) { - // is a 1d or 1d convex hull - if (count > 2) { - dgFloat32 maxValue = dgFloat32(-1.0e10f); - dgFloat32 minValue = dgFloat32(-1.0e10f); - dgInt32 j0 = 0; - dgInt32 j1 = 0; - for (dgInt32 i = 0; i < count; i++) { - dgFloat32 dist = contactArray[i].m_point.DotProduct(covariance.m_front).GetScalar(); - if (dist > maxValue) { - j0 = i; - maxValue = dist; - } - if (-dist > minValue) { - j1 = i; - minValue = -dist; - } - } - dgContactPoint c0(contactArray[j0]); - dgContactPoint c1(contactArray[j1]); - contactArray[0] = c0; - contactArray[1] = c1; - } - return 2; - } - return 1; -} - -dgInt32 dgWorld::PruneContactsByRank(dgInt32 count, dgCollisionParamProxy& proxy, dgInt32 maxCount) const -{ - dgJacobian jt[DG_CONSTRAINT_MAX_ROWS / 3]; - dgFloat32 massMatrix[DG_CONSTRAINT_MAX_ROWS * DG_CONSTRAINT_MAX_ROWS / 9]; - - dgAssert (count > maxCount); - const dgBody* const body = proxy.m_body0; - dgVector com(body->m_globalCentreOfMass); - for (dgInt32 i = 0; i < count; i++) { - jt[i].m_linear = proxy.m_contacts[i].m_normal; - jt[i].m_angular = (proxy.m_contacts[i].m_point - com).CrossProduct(proxy.m_contacts[i].m_normal); - } - - - dgInt32 index = 0; - for (dgInt32 i = 0; i < count; i++) { - dgFloat32* const row = &massMatrix[index]; - const dgJacobian& gInvMass = jt[i]; - dgVector aii(gInvMass.m_linear * jt[i].m_linear + gInvMass.m_angular * jt[i].m_angular); - row[i] = aii.AddHorizontal().GetScalar() * dgFloat32(1.0001f); - for (dgInt32 j = i + 1; j < count; j++) { - dgVector aij(gInvMass.m_linear * jt[j].m_linear + gInvMass.m_angular * jt[j].m_angular); - dgFloat32 b = aij.AddHorizontal().GetScalar(); - row[j] = b; - massMatrix[j * count + i] = b; - } - index += count; - } - - dgFloat32 eigenValues[DG_CONSTRAINT_MAX_ROWS / 3]; - dgEigenValues(count, count, massMatrix, eigenValues); - - for (dgInt32 i = 1; i < count; i++) { - dgFloat32 value = eigenValues[i]; - dgContactPoint point (proxy.m_contacts[i]); - - dgInt32 j = i - 1; - for (; (j >= 0) && (eigenValues[j] < value); j--) { - eigenValues[j + 1] = eigenValues[j]; - proxy.m_contacts[j + 1] = proxy.m_contacts[j]; - } - eigenValues[j + 1] = value; - proxy.m_contacts[j + 1] = point; - } - - return maxCount; -} - -void dgWorld::PopulateContacts (dgBroadPhase::dgPair* const pair, dgInt32 threadIndex) -{ - dgContact* const contact = pair->m_contact; - dgBody* const body0 = contact->m_body0; - dgBody* const body1 = contact->m_body1; - dgAssert (body0 != body1); - dgAssert (body0); - dgAssert (body1); - dgAssert (contact->m_body0 == body0); - dgAssert (contact->m_body1 == body1); - - const dgContactMaterial* const material = contact->m_material; - const dgContactPoint* const contactArray = pair->m_contactBuffer; - - if (material->m_flags & dgContactMaterial::m_resetSkeletonSelfCollision) { - contact->ResetSkeletonSelftCollision(); - } - - if (material->m_flags & dgContactMaterial::m_resetSkeletonIntraCollision) { - contact->ResetSkeletonIntraCollision(); - } - - dgInt32 contactCount = pair->m_contactCount; - dgList<dgContactMaterial>& list = *contact; - - contact->m_timeOfImpact = pair->m_timestep; - - dgInt32 count = 0; - dgVector cachePosition [DG_MAX_CONTATCS]; - dgList<dgContactMaterial>::dgListNode *nodes[DG_MAX_CONTATCS]; - - for (dgList<dgContactMaterial>::dgListNode *contactNode = list.GetFirst(); contactNode; contactNode = contactNode->GetNext()) { - - nodes[count] = contactNode; - cachePosition[count] = contactNode->GetInfo().m_point; - count ++; - } - - const dgVector& v0 = body0->m_veloc; - const dgVector& w0 = body0->m_omega; - const dgVector& com0 = body0->m_globalCentreOfMass; - - const dgVector& v1 = body1->m_veloc; - const dgVector& w1 = body1->m_omega; - const dgVector& com1 = body1->m_globalCentreOfMass; - - dgVector controlDir0 (dgFloat32 (0.0f)); - dgVector controlDir1 (dgFloat32 (0.0f)); - dgVector controlNormal (contactArray[0].m_normal); - dgVector vel0 (v0 + w0.CrossProduct(contactArray[0].m_point - com0)); - dgVector vel1 (v1 + w1.CrossProduct(contactArray[0].m_point - com1)); - dgVector vRel (vel1 - vel0); - dgAssert (controlNormal.m_w == dgFloat32 (0.0f)); - dgVector tangDir (vRel - controlNormal * vRel.DotProduct(controlNormal)); - dgAssert (tangDir.m_w == dgFloat32 (0.0f)); - dgFloat32 diff = tangDir.DotProduct(tangDir).GetScalar(); - - dgInt32 staticMotion = 0; - if (diff <= dgFloat32 (1.0e-2f)) { - staticMotion = 1; - if (dgAbs (controlNormal.m_z) > dgFloat32 (0.577f)) { - tangDir = dgVector (-controlNormal.m_y, controlNormal.m_z, dgFloat32 (0.0f), dgFloat32 (0.0f)); - } else { - tangDir = dgVector (-controlNormal.m_y, controlNormal.m_x, dgFloat32 (0.0f), dgFloat32 (0.0f)); - } - controlDir0 = controlNormal.CrossProduct(tangDir); - dgAssert (controlDir0.m_w == dgFloat32 (0.0f)); - dgAssert (controlDir0.DotProduct(controlDir0).GetScalar() > dgFloat32 (1.0e-8f)); - controlDir0 = controlDir0.Normalize(); - controlDir1 = controlNormal.CrossProduct(controlDir0); - dgAssert (dgAbs(controlNormal.DotProduct(controlDir0.CrossProduct(controlDir1)).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f)); - } - -//if (body0->m_uniqueID == 7) -//dgTrace (("frame:%d body:%d\n", GetFrameNumber(), body0->m_uniqueID)); - - dgFloat32 maxImpulse = dgFloat32 (-1.0f); - for (dgInt32 i = 0; i < contactCount; i ++) { - dgList<dgContactMaterial>::dgListNode* contactNode = NULL; - dgFloat32 min = dgFloat32 (1.0e20f); - dgInt32 index = -1; - for (dgInt32 j = 0; j < count; j ++) { - dgVector v (cachePosition[j] - contactArray[i].m_point); - dgAssert (v.m_w == dgFloat32 (0.0f)); - diff = v.DotProduct(v).GetScalar(); - if (diff < min) { - min = diff; - index = j; - contactNode = nodes[j]; - } - } - - if (contactNode) { - count --; - dgAssert (index != -1); - nodes[index] = nodes[count]; - cachePosition[index] = cachePosition[count]; - } else { - GlobalLock(); - contactNode = list.Append (); - GlobalUnlock(); - } - - dgContactMaterial* const contactMaterial = &contactNode->GetInfo(); - - dgAssert (dgCheckFloat(contactArray[i].m_point.m_x)); - dgAssert (dgCheckFloat(contactArray[i].m_point.m_y)); - dgAssert (dgCheckFloat(contactArray[i].m_point.m_z)); - dgAssert (contactArray[i].m_body0); - dgAssert (contactArray[i].m_body1); - dgAssert (contactArray[i].m_collision0); - dgAssert (contactArray[i].m_collision1); - dgAssert (contactArray[i].m_body0 == body0); - dgAssert (contactArray[i].m_body1 == body1); - -//if (body0->m_uniqueID == 7) -//dgTrace(("penetration(%f) point(%f %f %f)\n", -//contactArray[i].m_penetration, -//contactArray[i].m_point.m_x, contactArray[i].m_point.m_y, contactArray[i].m_point.m_z)); - - contactMaterial->m_point = contactArray[i].m_point; - contactMaterial->m_normal = contactArray[i].m_normal; - contactMaterial->m_penetration = contactArray[i].m_penetration; - contactMaterial->m_body0 = contactArray[i].m_body0; - contactMaterial->m_body1 = contactArray[i].m_body1; - contactMaterial->m_collision0 = contactArray[i].m_collision0; - contactMaterial->m_collision1 = contactArray[i].m_collision1; - contactMaterial->m_shapeId0 = contactArray[i].m_shapeId0; - contactMaterial->m_shapeId1 = contactArray[i].m_shapeId1; - contactMaterial->m_softness = material->m_softness; - contactMaterial->m_skinThickness = material->m_skinThickness; - contactMaterial->m_restitution = material->m_restitution; - contactMaterial->m_staticFriction0 = material->m_staticFriction0; - contactMaterial->m_staticFriction1 = material->m_staticFriction1; - contactMaterial->m_dynamicFriction0 = material->m_dynamicFriction0; - contactMaterial->m_dynamicFriction1 = material->m_dynamicFriction1; - - dgAssert (dgAbs(contactMaterial->m_normal.DotProduct(contactMaterial->m_normal).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-1f)); - - contactMaterial->m_flags = dgContactMaterial::m_collisionEnable | (material->m_flags & (dgContactMaterial::m_friction0Enable | dgContactMaterial::m_friction1Enable)); - contactMaterial->m_userData = material->m_userData; - - if (staticMotion) { - if (contactMaterial->m_normal.DotProduct(controlNormal).GetScalar() > dgFloat32 (0.9995f)) { - contactMaterial->m_dir0 = controlDir0; - contactMaterial->m_dir1 = controlDir1; - } else { - if (dgAbs (contactMaterial->m_normal.m_z) > dgFloat32 (0.577f)) { - tangDir = dgVector (-contactMaterial->m_normal.m_y, contactMaterial->m_normal.m_z, dgFloat32 (0.0f), dgFloat32 (0.0f)); - } else { - tangDir = dgVector (-contactMaterial->m_normal.m_y, contactMaterial->m_normal.m_x, dgFloat32 (0.0f), dgFloat32 (0.0f)); - } - contactMaterial->m_dir0 = contactMaterial->m_normal.CrossProduct(tangDir); - dgAssert (contactMaterial->m_dir0.m_w == dgFloat32 (0.0f)); - dgAssert (contactMaterial->m_dir0.DotProduct(contactMaterial->m_dir0).GetScalar() > dgFloat32 (1.0e-8f)); - contactMaterial->m_dir0 = contactMaterial->m_dir0.Normalize(); - contactMaterial->m_dir1 = contactMaterial->m_normal.CrossProduct(contactMaterial->m_dir0); - dgAssert (dgAbs(contactMaterial->m_normal.DotProduct(contactMaterial->m_dir0.CrossProduct(contactMaterial->m_dir1)).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f)); - } - } else { - dgVector veloc0 (v0 + w0.CrossProduct(contactMaterial->m_point - com0)); - dgVector veloc1 (v1 + w1.CrossProduct(contactMaterial->m_point - com1)); - dgVector relReloc (veloc1 - veloc0); - - dgAssert (contactMaterial->m_normal.m_w == dgFloat32 (0.0f)); - dgFloat32 impulse = relReloc.DotProduct(contactMaterial->m_normal).GetScalar(); - if (dgAbs (impulse) > maxImpulse) { - maxImpulse = dgAbs (impulse); - } - - dgVector tangentDir (relReloc - contactMaterial->m_normal.Scale (impulse)); - dgAssert (tangentDir.m_w == dgFloat32 (0.0f)); - diff = tangentDir.DotProduct(tangentDir).GetScalar(); - if (diff > dgFloat32 (1.0e-2f)) { - dgAssert (tangentDir.m_w == dgFloat32 (0.0f)); - //contactMaterial->m_dir0 = tangentDir.Scale (dgRsqrt (diff)); - contactMaterial->m_dir0 = tangentDir.Normalize(); - } else { - if (dgAbs (contactMaterial->m_normal.m_z) > dgFloat32 (0.577f)) { - tangentDir = dgVector (-contactMaterial->m_normal.m_y, contactMaterial->m_normal.m_z, dgFloat32 (0.0f), dgFloat32 (0.0f)); - } else { - tangentDir = dgVector (-contactMaterial->m_normal.m_y, contactMaterial->m_normal.m_x, dgFloat32 (0.0f), dgFloat32 (0.0f)); - } - contactMaterial->m_dir0 = contactMaterial->m_normal.CrossProduct(tangentDir); - dgAssert (contactMaterial->m_dir0.m_w == dgFloat32 (0.0f)); - dgAssert (contactMaterial->m_dir0.DotProduct(contactMaterial->m_dir0).GetScalar() > dgFloat32 (1.0e-8f)); - contactMaterial->m_dir0 = contactMaterial->m_dir0.Normalize(); - } - contactMaterial->m_dir1 = contactMaterial->m_normal.CrossProduct(contactMaterial->m_dir0); - dgAssert (dgAbs(contactMaterial->m_normal.DotProduct(contactMaterial->m_dir0.CrossProduct(contactMaterial->m_dir1)).GetScalar() - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f)); - } - dgAssert (contactMaterial->m_dir0.m_w == dgFloat32 (0.0f)); - dgAssert (contactMaterial->m_dir0.m_w == dgFloat32 (0.0f)); - dgAssert (contactMaterial->m_normal.m_w == dgFloat32 (0.0f)); - } - - if (count) { - GlobalLock(); - for (dgInt32 i = 0; i < count; i ++) { - list.Remove(nodes[i]); - } - GlobalUnlock(); - } - - contact->m_maxDOF = dgUnsigned32 (3 * contact->GetCount()); - if (material->m_processContactPoint) { - material->m_processContactPoint(*contact, pair->m_timestep, threadIndex); - } -} - -void dgWorld::ProcessContacts (dgBroadPhase::dgPair* const pair, dgInt32 threadIndex) -{ - dgAssert (pair->m_contact); - dgAssert (pair->m_contact->m_body0); - dgAssert (pair->m_contact->m_body1); - dgAssert (pair->m_contact->m_body0 != pair->m_contact->m_body1); - - pair->m_contact->m_positAcc = dgVector::m_zero; - pair->m_contact->m_rotationAcc = dgQuaternion(); - PopulateContacts (pair, threadIndex); -} - -void dgWorld::ConvexContacts (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - dgContact* const constraint = pair->m_contact; - - dgBody* const otherBody = constraint->m_body1; - dgBody* const convexBody = constraint->m_body0; - - proxy.m_body1 = otherBody; - proxy.m_body0 = convexBody; - proxy.m_instance0 = proxy.m_body0->m_collision; - proxy.m_instance1 = proxy.m_body1->m_collision; - dgAssert (proxy.m_instance0->IsType (dgCollision::dgCollisionConvexShape_RTTI)); - if (proxy.m_instance1->IsType (dgCollision::dgCollisionConvexShape_RTTI)) { - dgAssert (convexBody->m_collision->IsType (dgCollision::dgCollisionConvexShape_RTTI)); - dgAssert (otherBody->m_collision->IsType (dgCollision::dgCollisionConvexShape_RTTI)); - pair->m_contactCount = CalculateConvexToConvexContacts (proxy); - } else { - dgAssert (constraint->m_body0->m_collision->IsType (dgCollision::dgCollisionConvexShape_RTTI)); - dgAssert (convexBody->m_collision->IsType (dgCollision::dgCollisionConvexShape_RTTI)); - pair->m_contactCount = CalculateConvexToNonConvexContacts (proxy); - } -} - -void dgWorld::CompoundContacts (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - dgContact* const constraint = pair->m_contact; - pair->m_contactCount = 0; - - dgCollisionInstance* const instance = constraint->m_body0->GetCollision(); - dgCollisionCompound* const compound = (dgCollisionCompound*) instance->GetChildShape(); - dgAssert (compound->IsType(dgCollision::dgCollisionCompound_RTTI)); - compound->CalculateContacts (pair, proxy); - - proxy.m_contactJoint->m_separationDistance = dgFloat32 (0.0f); -} - -void dgWorld::SceneChildContacts (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - dgAssert (pair->m_contact->GetBody1()->GetCollision()->IsType(dgCollision::dgCollisionScene_RTTI)); - dgContactPoint* const savedBuffer = proxy.m_contacts; - - proxy.m_maxContacts = ((DG_MAX_CONTATCS - pair->m_contactCount) > 32) ? 32 : DG_MAX_CONTATCS - pair->m_contactCount; - proxy.m_contacts = &savedBuffer[pair->m_contactCount]; - - if (proxy.m_instance1->IsType (dgCollision::dgCollisionConvexShape_RTTI)) { - pair->m_contactCount += CalculateConvexToConvexContacts (proxy); - } else { - pair->m_contactCount += CalculateConvexToNonConvexContacts (proxy); - } - - proxy.m_contacts = savedBuffer; - if (pair->m_contactCount > (DG_MAX_CONTATCS - 2 * (DG_CONSTRAINT_MAX_ROWS / 3))) { - pair->m_contactCount = PruneContacts(pair->m_contactCount, proxy.m_contacts, proxy.m_contactJoint->GetPruningTolerance(), 16); - } -} - -void dgWorld::SceneContacts (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const -{ - dgContact* const constraint = pair->m_contact; - pair->m_contactCount = 0; - - dgBody* const sceneBody = constraint->m_body1; - dgBody* const otherBody = constraint->m_body0; - - dgCollisionInstance* const sceneInstance = sceneBody->GetCollision(); - dgCollisionInstance* const otherInstance = otherBody->GetCollision(); - dgAssert (sceneInstance->IsType(dgCollision::dgCollisionScene_RTTI)); - dgAssert (!otherInstance->IsType(dgCollision::dgCollisionScene_RTTI)); - if (otherInstance->IsType (dgCollision::dgCollisionConvexShape_RTTI)) { - proxy.m_body0 = otherBody; - proxy.m_body1 = sceneBody; - proxy.m_instance0 = otherBody->m_collision; - proxy.m_instance1 = NULL; - - dgCollisionScene* const scene = (dgCollisionScene*)sceneInstance->GetChildShape(); - scene->CollidePair (pair, proxy); - } else if (otherInstance->IsType (dgCollision::dgCollisionCompound_RTTI) & ~otherInstance->IsType (dgCollision::dgCollisionScene_RTTI)) { - proxy.m_body0 = otherBody; - proxy.m_body1 = sceneBody; - proxy.m_instance0 = NULL; - proxy.m_instance1 = NULL; - - dgCollisionScene* const scene = (dgCollisionScene*)sceneInstance->GetChildShape(); - scene->CollideCompoundPair (pair, proxy); - } else { - dgAssert (0); - } -} - - -void dgWorld::CalculateContacts (dgBroadPhase::dgPair* const pair, dgInt32 threadIndex, bool ccdMode, bool intersectionTestOnly) -{ - dgContact* const contact = pair->m_contact; - dgBody* const body0 = contact->m_body0; - dgBody* const body1 = contact->m_body1; - const dgContactMaterial* const material = contact->m_material; - dgCollisionParamProxy proxy(contact, pair->m_contactBuffer, threadIndex, ccdMode, intersectionTestOnly); - - pair->m_flipContacts = false; - proxy.m_timestep = pair->m_timestep; - proxy.m_maxContacts = DG_MAX_CONTATCS; - proxy.m_skinThickness = material->m_skinThickness; - - if (body1->m_collision->IsType(dgCollision::dgCollisionScene_RTTI)) { - dgAssert(contact->m_body1->GetInvMass().m_w == dgFloat32(0.0f)); - SceneContacts(pair, proxy); - } else if (body0->m_collision->IsType (dgCollision::dgCollisionScene_RTTI)) { - contact->SwapBodies(); - pair->m_flipContacts = -1; - dgAssert(contact->m_body1->GetInvMass().m_w == dgFloat32(0.0f)); - SceneContacts (pair, proxy); - } else if (body0->m_collision->IsType (dgCollision::dgCollisionCompound_RTTI)) { - CompoundContacts (pair, proxy); - } else if (body1->m_collision->IsType (dgCollision::dgCollisionCompound_RTTI)) { - contact->SwapBodies(); - pair->m_flipContacts = -1; - CompoundContacts (pair, proxy); - } else if (body0->m_collision->IsType (dgCollision::dgCollisionConvexShape_RTTI)) { - ConvexContacts (pair, proxy); - } else if (body1->m_collision->IsType (dgCollision::dgCollisionConvexShape_RTTI)) { - contact->SwapBodies(); - pair->m_flipContacts = -1; - ConvexContacts (pair, proxy); - } - - if (pair->m_contactCount > 1) { - pair->m_contactCount = PruneContacts (pair->m_contactCount, pair->m_contactBuffer, contact->GetPruningTolerance(), 16); - } - pair->m_timestep = proxy.m_timestep; -} - -dgFloat32 dgWorld::CalculateTimeToImpact (dgContact* const contact, dgFloat32 timestep, dgInt32 threadIndex, dgVector& p, dgVector& q, dgVector& normal, dgFloat32 dist) const -{ - dgBroadPhase::dgPair pair; - - dgInt32 isActive = contact->m_isActive; - dgInt32 contactCount = contact->m_maxDOF; - dgFloat32 separationDistance = contact->m_separationDistance; - - contact->m_maxDOF = 0; - pair.m_contact = contact; - pair.m_cacheIsValid = false; - pair.m_contactBuffer = NULL; - - dgBody* const body0 = contact->m_body0; - dgBody* const body1 = contact->m_body1; -// const dgContactMaterial* const material = contact->m_material; - dgCollisionParamProxy proxy(contact, NULL, threadIndex, true, true); - - proxy.m_maxContacts = 0; - proxy.m_timestep = timestep; -// proxy.m_skinThickness = material->m_skinThickness; - proxy.m_skinThickness = dist; - - if (body0->m_collision->IsType (dgCollision::dgCollisionScene_RTTI)) { - contact->SwapBodies(); - SceneContacts (&pair, proxy); - } else if (body1->m_collision->IsType (dgCollision::dgCollisionScene_RTTI)) { - SceneContacts (&pair, proxy); - } else if (body0->m_collision->IsType (dgCollision::dgCollisionCompound_RTTI)) { - CompoundContacts (&pair, proxy); - } else if (body1->m_collision->IsType (dgCollision::dgCollisionCompound_RTTI)) { - contact->SwapBodies(); - CompoundContacts (&pair, proxy); - } else if (body0->m_collision->IsType (dgCollision::dgCollisionConvexShape_RTTI)) { - ConvexContacts (&pair, proxy); - } else if (body1->m_collision->IsType (dgCollision::dgCollisionConvexShape_RTTI)) { - contact->SwapBodies(); - ConvexContacts (&pair, proxy); - } - - if (contact->m_body0 == body0) { - normal = proxy.m_normal; - p = proxy.m_closestPointBody0; - q = proxy.m_closestPointBody1; - } else { - contact->m_body0 = body0; - contact->m_body1 = body1; - //normal = proxy.m_normal.Scale(dgFloat32 (-1.0f)); - normal = proxy.m_normal * dgVector::m_negOne; - p = proxy.m_closestPointBody1; - q = proxy.m_closestPointBody0; - } - - contact->m_maxDOF = contactCount; - contact->m_isActive = isActive; - contact->m_separationDistance = separationDistance; - return proxy.m_timestep; -} - - -dgInt32 dgWorld::CollideContinue ( - const dgCollisionInstance* const collisionSrcA, const dgMatrix& matrixA, const dgVector& velocA, const dgVector& omegaA, - const dgCollisionInstance* const collisionSrcB, const dgMatrix& matrixB, const dgVector& velocB, const dgVector& omegaB, - dgFloat32& retTimeStep, dgTriplex* const points, dgTriplex* const normals, dgFloat32* const penetration, - dgInt64* const attibuteA, dgInt64* const attibuteB, dgInt32 maxContacts, dgInt32 threadIndex) -{ - dgKinematicBody collideBodyA; - dgKinematicBody collideBodyB; - dgCollisionInstance collisionA(*collisionSrcA, collisionSrcA->GetChildShape()); - dgCollisionInstance collisionB(*collisionSrcB, collisionSrcB->GetChildShape()); - - dgContactPoint contacts[DG_MAX_CONTATCS]; - - dgInt32 count = 0; - maxContacts = dgMin (DG_MAX_CONTATCS, maxContacts); - - collideBodyA.m_world = this; - collideBodyA.SetContinueCollisionMode(true); - collideBodyA.m_matrix = matrixA; - collideBodyA.m_collision = &collisionA; - collideBodyA.m_masterNode = NULL; - collideBodyA.m_broadPhaseNode = NULL; - collideBodyA.m_veloc = dgVector (velocA[0], velocA[1], velocA[2], dgFloat32 (0.0f)); - collideBodyA.m_omega = dgVector (omegaA[0], omegaA[1], omegaA[2], dgFloat32 (0.0f)); - collisionA.SetGlobalMatrix(collisionA.GetLocalMatrix() * matrixA); - - collideBodyB.m_world = this; - collideBodyB.SetContinueCollisionMode(true); - collideBodyB.m_matrix = matrixB; - collideBodyB.m_collision = &collisionB; - collideBodyB.m_masterNode = NULL; - collideBodyB.m_broadPhaseNode = NULL; - collideBodyB.m_veloc = dgVector (velocB[0], velocB[1], velocB[2], dgFloat32 (0.0f)); - collideBodyB.m_omega = dgVector (omegaB[0], omegaB[1], omegaB[2], dgFloat32 (0.0f)); - collisionB.SetGlobalMatrix(collisionB.GetLocalMatrix() * matrixB); - - dgContactMaterial material; - material.m_penetration = dgFloat32 (0.0f); - dgContact contactJoint (this, &material, &collideBodyB, &collideBodyA); - - dgBroadPhase::dgPair pair; - pair.m_contact = &contactJoint; - pair.m_contactBuffer = contacts; - pair.m_timestep = retTimeStep; - pair.m_contactCount = 0; - pair.m_cacheIsValid = 0; - CalculateContacts (&pair, threadIndex, true, maxContacts ? false : true); - - if (pair.m_timestep < retTimeStep) { - retTimeStep = pair.m_timestep; - } - - count = pair.m_contactCount; - if (count) { - if (count > maxContacts) { - count = PruneContacts (count, contacts, contactJoint.GetPruningTolerance(), maxContacts); - } - count = dgMin(count, maxContacts); - - if (pair.m_flipContacts) { - for (dgInt32 i = 0; i < count; i++) { - dgVector step ((collideBodyA.m_veloc - collideBodyB.m_veloc).Scale (pair.m_timestep)); - points[i].m_x = contacts[i].m_point.m_x + step.m_x; - points[i].m_y = contacts[i].m_point.m_y + step.m_y; - points[i].m_z = contacts[i].m_point.m_z + step.m_z; - normals[i].m_x = -contacts[i].m_normal.m_x; - normals[i].m_y = -contacts[i].m_normal.m_y; - normals[i].m_z = -contacts[i].m_normal.m_z; - penetration[i] = contacts[i].m_penetration; - attibuteA[i] = contacts[i].m_shapeId1; - attibuteB[i] = contacts[i].m_shapeId0; - } - } else { - for (dgInt32 i = 0; i < count; i ++) { - points[i].m_x = contacts[i].m_point.m_x; - points[i].m_y = contacts[i].m_point.m_y; - points[i].m_z = contacts[i].m_point.m_z; - normals[i].m_x = contacts[i].m_normal.m_x; - normals[i].m_y = contacts[i].m_normal.m_y; - normals[i].m_z = contacts[i].m_normal.m_z; - penetration[i] = contacts[i].m_penetration; - attibuteA[i] = contacts[i].m_shapeId0; - attibuteB[i] = contacts[i].m_shapeId1; - } - } - } - return count; -} - -dgInt32 dgWorld::Collide ( - const dgCollisionInstance* const collisionSrcA, const dgMatrix& matrixA, - const dgCollisionInstance* const collisionSrcB, const dgMatrix& matrixB, - dgTriplex* const points, dgTriplex* const normals, dgFloat32* const penetration, - dgInt64* const attibuteA, dgInt64* const attibuteB, dgInt32 maxContacts, dgInt32 threadIndex) -{ - dgKinematicBody collideBodyA; - dgKinematicBody collideBodyB; - dgCollisionInstance collisionA(*collisionSrcA, collisionSrcA->GetChildShape()); - dgCollisionInstance collisionB(*collisionSrcB, collisionSrcB->GetChildShape()); - - collisionA.SetCollisionMode(true); - collisionB.SetCollisionMode(true); - - dgContactPoint contacts[DG_MAX_CONTATCS]; - - dgInt32 count = 0; - maxContacts = dgMin (DG_MAX_CONTATCS, maxContacts); - - collideBodyA.m_world = this; - collideBodyA.SetContinueCollisionMode(false); - collideBodyA.m_matrix = matrixA; - collideBodyA.m_collision = &collisionA; - collideBodyA.UpdateCollisionMatrix(dgFloat32 (0.0f), 0); - - collideBodyB.m_world = this; - collideBodyB.SetContinueCollisionMode(false); - collideBodyB.m_matrix = matrixB; - collideBodyB.m_collision = &collisionB; - collideBodyB.UpdateCollisionMatrix(dgFloat32 (0.0f), 0); - - dgContactMaterial material; - material.m_penetration = dgFloat32 (0.0f); - - dgContact contactJoint (this, &material, &collideBodyB, &collideBodyA); -// contactJoint.SetBodies (&collideBodyA, &collideBodyB); - - dgBroadPhase::dgPair pair; - pair.m_contactCount = 0; - pair.m_contact = &contactJoint; - pair.m_contactBuffer = contacts; - pair.m_timestep = dgFloat32 (0.0f); - pair.m_cacheIsValid = 0; - CalculateContacts (&pair, threadIndex, false, false); - - count = pair.m_contactCount; - if (count > maxContacts) { - count = PruneContacts(count, contacts, contactJoint.GetPruningTolerance(), maxContacts); - } - count = dgMin(count, maxContacts); - - dgFloat32 swapContactScale = (contactJoint.GetBody0() != &collideBodyA) ? dgFloat32 (-1.0f) : dgFloat32 (1.0f); - for (dgInt32 i = 0; i < count; i ++) { - points[i].m_x = contacts[i].m_point.m_x; - points[i].m_y = contacts[i].m_point.m_y; - points[i].m_z = contacts[i].m_point.m_z; - normals[i].m_x = contacts[i].m_normal.m_x * swapContactScale; - normals[i].m_y = contacts[i].m_normal.m_y * swapContactScale; - normals[i].m_z = contacts[i].m_normal.m_z * swapContactScale; - penetration[i] = contacts[i].m_penetration; - attibuteA[i] = contacts[i].m_shapeId0; - attibuteB[i] = contacts[i].m_shapeId1; - } - - return count; -} - - - - -// ************************************************************************* -// -// -// ************************************************************************* - -dgInt32 dgWorld::ClosestPoint (dgCollisionParamProxy& proxy) const -{ - dgCollisionInstance* const collision0 = proxy.m_instance0; - dgCollisionInstance* const collision1 = proxy.m_instance1; - - if (!(collision0->GetConvexVertexCount() && collision1->GetConvexVertexCount())) { - return 0; - } - - dgAssert(collision0->GetCollisionPrimityType() < m_nullCollision); - dgAssert(collision1->GetCollisionPrimityType() < m_nullCollision); - dgAssert(proxy.m_instance1->IsType(dgCollision::dgCollisionConvexShape_RTTI)); - - dgContact* const contactJoint = proxy.m_contactJoint; - dgAssert(contactJoint); - contactJoint->m_closestDistance = dgFloat32(1.0e10f); - contactJoint->m_separationDistance = dgFloat32(0.0f); - - dgCollisionInstance instance0(*collision0, collision0->m_childShape); - dgCollisionInstance instance1(*collision1, collision1->m_childShape); - proxy.m_instance0 = &instance0; - proxy.m_instance1 = &instance1; - - dgVector origin(instance0.m_globalMatrix.m_posit & dgVector::m_triplexMask); - instance0.m_globalMatrix.m_posit = dgVector::m_wOne; - instance1.m_globalMatrix.m_posit -= origin; - - contactJoint->m_separtingVector = collision0->GetGlobalMatrix().m_up; - - dgContactSolver contactSolver(&proxy); - bool retVal = contactSolver.CalculateClosestPoints(); - if (retVal) { - proxy.m_closestPointBody0 = contactSolver.GetPoint0() + origin; - proxy.m_closestPointBody1 = contactSolver.GetPoint1() + origin; - proxy.m_normal = contactSolver.GetNormal().Scale(-1.0f); - - dgContactPoint* const contactOut = proxy.m_contacts; - contactOut[0].m_normal = proxy.m_normal; - contactOut[0].m_point = proxy.m_closestPointBody0; - - contactOut[1].m_normal = contactSolver.GetNormal(); - contactOut[1].m_point = proxy.m_closestPointBody1; - - contactJoint->m_closestDistance = (contactOut[1].m_point - contactOut[0].m_point).DotProduct(contactSolver.GetNormal()).GetScalar(); - contactJoint->m_separationDistance = dgFloat32(0.0f); - - instance0.m_material.m_userData = NULL; - instance1.m_material.m_userData = NULL; - proxy.m_instance0 = collision0; - proxy.m_instance1 = collision1; - retVal = contactJoint->m_closestDistance >= dgFloat32(0.0f); - } - return retVal ? 1 : 0; -} - -dgInt32 dgWorld::CalculateUserContacts(dgCollisionParamProxy& proxy) const -{ - dgContactMaterial::dgUserContactPoint buffer[16]; - dgContact* const contactJoint = proxy.m_contactJoint; - int count = contactJoint->m_material->m_contactGeneration(*contactJoint->m_material, *proxy.m_body0, proxy.m_instance0, *proxy.m_body1, proxy.m_instance1, buffer, sizeof (buffer) / sizeof (buffer[0]), proxy.m_threadIndex); - if (count) { - proxy.m_contactJoint->m_isActive = 1; - dgContactPoint* const contactOut = proxy.m_contacts; - for (dgInt32 i = 0; i < count; i++) { - dgAssert (buffer[i].m_normal.m_w == dgFloat32 (0.0f)); - dgAssert(dgAbs(buffer[i].m_normal.DotProduct(buffer[i].m_normal).GetScalar() - dgFloat32(1.0f)) < dgFloat32(1.0e-4f)); - contactOut[i].m_point = buffer[i].m_point; - contactOut[i].m_normal = buffer[i].m_normal; - contactOut[i].m_penetration = buffer[i].m_penetration; - contactOut[i].m_shapeId0 = buffer[i].m_shapeId0; - contactOut[i].m_shapeId1 = buffer[i].m_shapeId1; - contactOut[i].m_body0 = proxy.m_body0; - contactOut[i].m_body1 = proxy.m_body1; - contactOut[i].m_collision0 = proxy.m_instance0; - contactOut[i].m_collision1 = proxy.m_instance1; - } - } - return count; -} - - -dgInt32 dgWorld::CalculateConvexToConvexContacts(dgCollisionParamProxy& proxy) const -{ - dgInt32 count = 0; - dgContact* const contactJoint = proxy.m_contactJoint; - dgAssert(contactJoint); - - dgCollisionInstance* const collision0 = proxy.m_instance0; - dgCollisionInstance* const collision1 = proxy.m_instance1; - dgAssert(collision0->IsType(dgCollision::dgCollisionConvexShape_RTTI)); - dgAssert(collision1->IsType(dgCollision::dgCollisionConvexShape_RTTI)); - contactJoint->m_closestDistance = dgFloat32(1.0e10f); - contactJoint->m_separationDistance = dgFloat32(0.0f); - - if (!(collision0->GetConvexVertexCount() && collision1->GetConvexVertexCount())) { - return count; - } - - dgAssert(collision0->GetCollisionPrimityType() != m_nullCollision); - dgAssert(collision1->GetCollisionPrimityType() != m_nullCollision); - dgAssert(proxy.m_instance1->IsType(dgCollision::dgCollisionConvexShape_RTTI)); - - if (!contactJoint->m_material->m_contactGeneration) { - dgCollisionInstance instance0(*collision0, collision0->m_childShape); - dgCollisionInstance instance1(*collision1, collision1->m_childShape); - - proxy.m_instance0 = &instance0; - proxy.m_instance1 = &instance1; - - dgVector origin(instance0.m_globalMatrix.m_posit & dgVector::m_triplexMask); - instance0.m_globalMatrix.m_posit = dgVector::m_wOne; - instance1.m_globalMatrix.m_posit -= origin; - - if (instance0.GetCollisionPrimityType() == instance1.GetCollisionPrimityType()) { - switch (instance0.GetCollisionPrimityType()) - { - case m_sphereCollision: - { - dgVector diff(instance1.GetGlobalMatrix().m_posit - instance0.GetGlobalMatrix().m_posit); - dgFloat32 mag2 = diff.DotProduct(diff).GetScalar(); - if (mag2 < dgFloat32(1.0e-6f)) { - dgMatrix tmp(instance1.GetGlobalMatrix()); - tmp.m_posit.m_x += dgFloat32(1.0e-3f); - instance1.SetGlobalMatrix(tmp); - } - break; - } - case m_capsuleCollision: - { - dgMatrix diff(instance1.GetGlobalMatrix() * instance0.GetGlobalMatrix().Inverse()); - if (dgAbs(diff[0][0]) > dgFloat32(0.9999f)) { - if (dgAbs(diff.m_posit.m_x) < dgFloat32(1.0e-3f)) { - diff.m_posit.m_y += dgFloat32(1.0e-3f); - instance1.SetGlobalMatrix(diff * instance0.GetGlobalMatrix()); - } - } - break; - } - case m_chamferCylinderCollision: - { - dgMatrix diff(instance1.GetGlobalMatrix() * instance0.GetGlobalMatrix().Inverse()); - if (dgAbs(diff[0][0]) > dgFloat32(0.9999f)) { - if (dgAbs(diff.m_posit.m_x) < dgFloat32(1.0e-3f)) { - diff.m_posit.m_x += dgFloat32(1.0e-3f); - instance1.SetGlobalMatrix(diff * instance0.GetGlobalMatrix()); - } - } - break; - } - default:; - } - } - if (contactJoint->m_isNewContact) { - contactJoint->m_isNewContact = false; - dgVector v((proxy.m_instance0->m_globalMatrix.m_posit - proxy.m_instance1->m_globalMatrix.m_posit) & dgVector::m_triplexMask); - dgFloat32 mag2 = v.DotProduct(v).m_x; - if (mag2 > dgFloat32(0.0f)) { - contactJoint->m_separtingVector = v.Scale(dgRsqrt(mag2)); - } else { - contactJoint->m_separtingVector = proxy.m_instance0->m_globalMatrix.m_up; - } - } - - dgContactSolver contactSolver(&proxy); - if (proxy.m_continueCollision) { - count = contactSolver.CalculateConvexCastContacts(); - } else { - count = contactSolver.CalculateConvexToConvexContacts(); - } - - proxy.m_closestPointBody0 += origin; - proxy.m_closestPointBody1 += origin; - dgContactPoint* const contactOut = proxy.m_contacts; - for (dgInt32 i = 0; i < count; i++) { - contactOut[i].m_point += origin; - contactOut[i].m_body0 = proxy.m_body0; - contactOut[i].m_body1 = proxy.m_body1; - contactOut[i].m_collision0 = collision0; - contactOut[i].m_collision1 = collision1; - contactOut[i].m_shapeId0 = collision0->GetUserDataID(); - contactOut[i].m_shapeId1 = collision1->GetUserDataID(); - } - - instance0.m_material.m_userData = NULL; - instance1.m_material.m_userData = NULL; - proxy.m_instance0 = collision0; - proxy.m_instance1 = collision1; - - } else { - count = CalculateUserContacts(proxy); - dgContactPoint* const contactOut = proxy.m_contacts; - for (dgInt32 i = 0; i < count; i++) { - contactOut[i].m_body0 = proxy.m_body0; - contactOut[i].m_body1 = proxy.m_body1; - contactOut[i].m_collision0 = collision0; - contactOut[i].m_collision1 = collision1; - contactOut[i].m_shapeId0 = collision0->GetUserDataID(); - contactOut[i].m_shapeId1 = collision1->GetUserDataID(); - } - } - - return count; -} - -dgInt32 dgWorld::CalculateConvexToNonConvexContacts(dgCollisionParamProxy& proxy) const -{ - dgInt32 count = 0; - dgContact* const contactJoint = proxy.m_contactJoint; - dgAssert(contactJoint); - - dgCollisionInstance* const collision0 = proxy.m_instance0; - dgCollisionInstance* const collision1 = proxy.m_instance1; - dgAssert(collision1->IsType(dgCollision::dgCollisionMesh_RTTI)); - dgAssert(collision0->IsType(dgCollision::dgCollisionConvexShape_RTTI)); - contactJoint->m_closestDistance = dgFloat32(1.0e10f); - if (!collision0->GetConvexVertexCount()) { - return count; - } - - dgFloat32 separationDistance = dgFloat32 (0.0f); - if (!contactJoint->m_material->m_contactGeneration) { - dgCollisionInstance instance0(*collision0, collision0->m_childShape); - dgCollisionInstance instance1(*collision1, collision1->m_childShape); - proxy.m_instance0 = &instance0; - proxy.m_instance1 = &instance1; - - dgVector origin(instance0.m_globalMatrix.m_posit & dgVector::m_triplexMask); - instance0.m_globalMatrix.m_posit = dgVector::m_wOne; - instance1.m_globalMatrix.m_posit -= origin; - - dgAssert(proxy.m_timestep <= dgFloat32(2.0f)); - dgAssert(proxy.m_timestep >= dgFloat32(0.0f)); - - dgPolygonMeshDesc data(proxy, NULL); - if (proxy.m_continueCollision) { - data.m_doContinuesCollisionTest = true; - - const dgVector& hullVeloc = data.m_objBody->m_veloc; - const dgVector& hullOmega = data.m_objBody->m_omega; - - dgFloat32 baseLinearSpeed = dgSqrt(hullVeloc.DotProduct(hullVeloc).GetScalar()); - if (baseLinearSpeed > dgFloat32(1.0e-6f)) { - const dgFloat32 minRadius = instance0.GetBoxMinRadius(); - const dgFloat32 maxRadius = instance0.GetBoxMaxRadius(); - dgFloat32 maxAngularSpeed = dgSqrt(hullOmega.DotProduct(hullOmega).GetScalar()); - dgFloat32 angularSpeedBound = maxAngularSpeed * (maxRadius - minRadius); - - dgFloat32 upperBoundSpeed = baseLinearSpeed + dgSqrt(angularSpeedBound); - dgVector upperBoundVeloc(hullVeloc.Scale(proxy.m_timestep * upperBoundSpeed / baseLinearSpeed)); - data.SetDistanceTravel(upperBoundVeloc); - } - } - - dgCollisionMesh* const polysoup = (dgCollisionMesh *)data.m_polySoupInstance->GetChildShape(); - polysoup->GetCollidingFaces(&data); - - if (data.m_faceCount) { - proxy.m_polyMeshData = &data; - - if (proxy.m_continueCollision) { - count = CalculateConvexToNonConvexContactsContinue(proxy); - } else { - count = CalculatePolySoupToHullContactsDescrete(proxy); - } - - if (count > 0) { - proxy.m_contactJoint->m_isActive = 1; - } - } - - proxy.m_closestPointBody0 += origin; - proxy.m_closestPointBody1 += origin; - separationDistance = data.GetSeparetionDistance(); - dgContactPoint* const contactOut = proxy.m_contacts; - for (dgInt32 i = 0; i < count; i++) { - contactOut[i].m_point += origin; - contactOut[i].m_body0 = proxy.m_body0; - contactOut[i].m_body1 = proxy.m_body1; - contactOut[i].m_collision0 = collision0; - contactOut[i].m_collision1 = collision1; - contactOut[i].m_shapeId0 = collision0->GetUserDataID(); - //contactOut[i].m_shapeId1 = collision1->GetUserDataID(); - } - - instance0.m_material.m_userData = NULL; - instance1.m_material.m_userData = NULL; - proxy.m_instance0 = collision0; - proxy.m_instance1 = collision1; - } else { - count = CalculateUserContacts(proxy); - - dgContactPoint* const contactOut = proxy.m_contacts; - for (dgInt32 i = 0; i < count; i++) { - contactOut[i].m_body0 = proxy.m_body0; - contactOut[i].m_body1 = proxy.m_body1; - contactOut[i].m_collision0 = collision0; - contactOut[i].m_collision1 = collision1; - contactOut[i].m_shapeId0 = collision0->GetUserDataID(); - //contactOut[i].m_shapeId1 = collision1->GetUserDataID(); - } - } - - contactJoint->m_separationDistance = separationDistance; - return count; -} - -dgInt32 dgWorld::CalculatePolySoupToHullContactsDescrete (dgCollisionParamProxy& proxy) const -{ - dgAssert (proxy.m_instance1->IsType (dgCollision::dgCollisionMesh_RTTI)); - dgAssert (proxy.m_instance0->IsType (dgCollision::dgCollisionConvexShape_RTTI)); - - dgCollisionInstance* const polySoupInstance = proxy.m_instance1; - dgPolygonMeshDesc& data = *proxy.m_polyMeshData; - - dgAssert (data.m_faceCount); - - dgCollisionConvexPolygon polygon (m_allocator); - dgCollisionInstance polyInstance (*polySoupInstance, &polygon); - polyInstance.SetScale(dgVector (dgFloat32 (1.0f))); - polyInstance.m_localMatrix = dgGetIdentityMatrix(); - polyInstance.m_globalMatrix = dgGetIdentityMatrix(); - - proxy.m_instance1 = &polyInstance; - polygon.m_vertex = data.m_vertex; - polygon.m_stride = dgInt32 (data.m_vertexStrideInBytes / sizeof (dgFloat32)); - - dgInt32 count = 0; - dgInt32 maxContacts = proxy.m_maxContacts; - dgInt32 maxReduceLimit = maxContacts - 16; - dgInt32 countleft = maxContacts; - - const dgVector& polygonInstanceScale = polySoupInstance->GetScale(); - const dgMatrix polySoupGlobalMatrix = polySoupInstance->m_globalMatrix; - const dgMatrix polySoupGlobalAligmentMatrix = polySoupInstance->m_aligmentMatrix; - - dgMatrix polySoupScaledMatrix (polySoupGlobalAligmentMatrix[0] * polygonInstanceScale, - polySoupGlobalAligmentMatrix[1] * polygonInstanceScale, - polySoupGlobalAligmentMatrix[2] * polygonInstanceScale, - polySoupGlobalAligmentMatrix[3]); - polySoupScaledMatrix = polySoupScaledMatrix * polySoupGlobalMatrix; - - dgAssert (proxy.m_contactJoint); - dgVector separatingVector (proxy.m_instance0->m_globalMatrix.m_up); - - const dgInt32 stride = polygon.m_stride; - const dgFloat32* const vertex = polygon.m_vertex; - dgAssert (polyInstance.m_scaleType == dgCollisionInstance::m_unit); - dgFloat32 closestDist = dgFloat32 (1.0e10f); - dgContactPoint* const contactOut = proxy.m_contacts; - dgContact* const contactJoint = proxy.m_contactJoint; - dgInt32* const indexArray = (dgInt32*)data.m_faceVertexIndex; - data.SortFaceArray(); - - for (dgInt32 i = data.m_faceCount - 1; (i >= 0) && (count < 32); i --) { - dgInt32 address = data.m_faceIndexStart[i]; - const dgInt32* const localIndexArray = &indexArray[address]; - polygon.m_vertexIndex = localIndexArray; - polygon.m_count = data.m_faceIndexCount[i]; - polygon.m_paddedCount = polygon.m_count; - polygon.m_adjacentFaceEdgeNormalIndex = data.GetAdjacentFaceEdgeNormalArray (localIndexArray, polygon.m_count); - polygon.m_faceId = data.GetFaceId (localIndexArray, polygon.m_count); - polygon.m_faceClipSize = data.GetFaceSize (localIndexArray, polygon.m_count); - polygon.m_faceNormalIndex = data.GetNormalIndex (localIndexArray, polygon.m_count); - polygon.m_normal = polygon.CalculateGlobalNormal (polySoupInstance, dgVector (&vertex[polygon.m_faceNormalIndex * stride]) & dgVector::m_triplexMask); - dgAssert (polygon.m_normal.m_w == dgFloat32 (0.0f)); - for (dgInt32 j = 0; j < polygon.m_count; j++) { - polygon.m_localPoly[j] = polySoupScaledMatrix.TransformVector(dgVector(&vertex[localIndexArray[j] * stride]) & dgVector::m_triplexMask); - } - contactJoint->m_separtingVector = separatingVector; - proxy.m_maxContacts = countleft; - proxy.m_contacts = &contactOut[count]; - dgInt32 count1 = polygon.CalculateContactToConvexHullDescrete (this, polySoupInstance, proxy); - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - - if (count1 > 0) { - count += count1; - countleft -= count1; - dgAssert (countleft >= 0); - if (count >= maxReduceLimit) { - count = PruneContacts(count, contactOut, dgFloat32 (1.0e-2f), 16); - countleft = maxContacts - count; - dgAssert (countleft >= 0); - proxy.m_maxContacts = countleft; - } - } else if (count1 == -1) { - count = -1; - break; - } - } - - contactJoint->m_closestDistance = closestDist; - - if (count) { - switch (proxy.m_instance0->GetCollisionPrimityType()) - { - case m_sphereCollision: - case m_capsuleCollision: - case m_chamferCylinderCollision: - proxy.m_instance0->CalculateImplicitContacts(count, contactOut); - break; - - default: - { - bool contactsValid = true; - - for (dgInt32 i = 0; (i < count) && contactsValid; i++) { - const dgVector& normal = contactOut[i].m_normal; - for (dgInt32 j = i + 1; (j < count) && contactsValid; j++) { - const dgFloat32 project = (normal.DotProduct(contactOut[j].m_normal)).GetScalar(); - contactsValid = contactsValid && (project > dgFloat32(-0.1f)); - } - } - - if (!contactsValid) { - dgCollisionContactCloud contactCloud(GetAllocator(), count, contactOut); - dgCollisionInstance cloudInstance(*polySoupInstance, &contactCloud); - cloudInstance.m_globalMatrix = dgGetIdentityMatrix(); - cloudInstance.SetScale(dgVector::m_one); - bool saveintersectionTestOnly = proxy.m_intersectionTestOnly; - proxy.m_instance1 = &cloudInstance; - proxy.m_intersectionTestOnly = true; - dgContactSolver contactSolver(&proxy); - contactSolver.CalculateConvexToConvexContacts(); - dgVector normal(contactSolver.GetNormal() * dgVector::m_negOne); - for (dgInt32 i = 0; i < count; i++) { - contactOut[i].m_normal = normal; - } - - proxy.m_intersectionTestOnly = saveintersectionTestOnly; - cloudInstance.m_material.m_userData = NULL; - } - } - } - } - - proxy.m_contacts = contactOut; - - // restore the pointer - polyInstance.m_material.m_userData = NULL; - proxy.m_instance1 = polySoupInstance; - return count; -} - -dgInt32 dgWorld::CalculateConvexToNonConvexContactsContinue(dgCollisionParamProxy& proxy) const -{ - dgAssert(proxy.m_instance1->IsType(dgCollision::dgCollisionMesh_RTTI)); - dgAssert(proxy.m_instance0->IsType(dgCollision::dgCollisionConvexShape_RTTI)); - - dgCollisionInstance* const polySoupInstance = proxy.m_instance1; - dgPolygonMeshDesc& data = *proxy.m_polyMeshData; - - dgAssert(data.m_faceCount); - - dgCollisionConvexPolygon polygon(m_allocator); - dgCollisionInstance polyInstance(*polySoupInstance, &polygon); - polyInstance.SetScale(dgVector(dgFloat32(1.0f))); - polyInstance.m_localMatrix = dgGetIdentityMatrix(); - polyInstance.m_globalMatrix = dgGetIdentityMatrix(); - - proxy.m_instance1 = &polyInstance; - polygon.m_vertex = data.m_vertex; - polygon.m_stride = dgInt32(data.m_vertexStrideInBytes / sizeof (dgFloat32)); - - dgInt32 count = 0; - dgInt32 maxContacts = proxy.m_maxContacts; - dgInt32 maxReduceLimit = maxContacts >> 2; - dgInt32 countleft = maxContacts; - - const dgVector& polygonInstanceScale = polySoupInstance->GetScale(); - const dgMatrix polySoupGlobalMatrix = polySoupInstance->m_globalMatrix; - const dgMatrix polySoupGlobalAligmentMatrix = polySoupInstance->m_aligmentMatrix; - - dgMatrix polySoupScaledMatrix (polySoupGlobalAligmentMatrix[0] * polygonInstanceScale, - polySoupGlobalAligmentMatrix[1] * polygonInstanceScale, - polySoupGlobalAligmentMatrix[2] * polygonInstanceScale, - polySoupGlobalAligmentMatrix[3]); - polySoupScaledMatrix = polySoupScaledMatrix * polySoupGlobalMatrix; - - dgAssert (proxy.m_contactJoint); - dgVector separatingVector (proxy.m_instance0->m_globalMatrix.m_up); - - const dgInt32 stride = polygon.m_stride; - const dgFloat32* const vertex = polygon.m_vertex; - dgAssert(polyInstance.m_scaleType == dgCollisionInstance::m_unit); - - dgContactPoint* const contactOut = proxy.m_contacts; - dgContact* const contactJoint = proxy.m_contactJoint; - dgInt32* const indexArray = (dgInt32*)data.m_faceVertexIndex; - data.SortFaceArray(); - - dgVector n(dgFloat32(0.0f), dgFloat32(1.0f), dgFloat32(0.0f), dgFloat32(0.0f)); - dgVector p(dgFloat32(0.0f)); - dgVector q(dgFloat32(0.0f)); - dgFloat32 closestDist = dgFloat32(1.0e10f); - dgFloat32 minTimeStep = proxy.m_timestep; - - dgFloat32 timeNormalizer = proxy.m_timestep; - dgFloat32 epsilon = dgFloat32(-1.0e-3f) * proxy.m_timestep; - - for (dgInt32 i = 0; (i < data.m_faceCount) && (proxy.m_timestep >= (data.m_hitDistance[i] * timeNormalizer)); i++) { - dgInt32 address = data.m_faceIndexStart[i]; - const dgInt32* const localIndexArray = &indexArray[address]; - polygon.m_vertexIndex = localIndexArray; - polygon.m_count = data.m_faceIndexCount[i]; - polygon.m_paddedCount = polygon.m_count; - polygon.m_adjacentFaceEdgeNormalIndex = data.GetAdjacentFaceEdgeNormalArray(localIndexArray, polygon.m_count); - polygon.m_faceId = data.GetFaceId(localIndexArray, polygon.m_count); - polygon.m_faceClipSize = data.GetFaceSize(localIndexArray, polygon.m_count); - polygon.m_faceNormalIndex = data.GetNormalIndex(localIndexArray, polygon.m_count); - polygon.m_normal = polygon.CalculateGlobalNormal(polySoupInstance, dgVector(&vertex[polygon.m_faceNormalIndex * stride]) & dgVector::m_triplexMask); - dgAssert(polygon.m_normal.m_w == dgFloat32(0.0f)); - for (dgInt32 j = 0; j < polygon.m_count; j++) { - polygon.m_localPoly[j] = polySoupScaledMatrix.TransformVector(dgVector(&vertex[localIndexArray[j] * stride]) & dgVector::m_triplexMask); - } - contactJoint->m_separtingVector = separatingVector; - proxy.m_timestep = minTimeStep; - proxy.m_maxContacts = countleft; - proxy.m_contacts = &contactOut[count]; - - dgInt32 count1 = polygon.CalculateContactToConvexHullContinue(this, polySoupInstance, proxy); - - if (count1 > 0) { - dgFloat32 error = proxy.m_timestep - minTimeStep; - if (error < epsilon) { - count = 0; - countleft = maxContacts; - for (dgInt32 j = 0; j < count1; j++) { - contactOut[j] = proxy.m_contacts[j]; - } - } - count += count1; - countleft -= count1; - dgAssert(countleft >= 0); - if (count >= maxReduceLimit) { - count = PruneContacts(count, contactOut, dgFloat32(1.0e-2f), 16); - countleft = maxContacts - count; - dgAssert(countleft >= 0); - } - } - - closestDist = dgMin(closestDist, contactJoint->m_closestDistance); - if (proxy.m_timestep <= minTimeStep) { - minTimeStep = proxy.m_timestep; - n = proxy.m_normal; - p = proxy.m_closestPointBody0; - q = proxy.m_closestPointBody1; - } - } - - polyInstance.m_material.m_userData = NULL; - proxy.m_contacts = contactOut; - - proxy.m_normal = n; - proxy.m_closestPointBody0 = p; - proxy.m_closestPointBody1 = q; - proxy.m_timestep = minTimeStep; - return count; -} - diff --git a/thirdparty/src/newton/dgPhysics/dgPhysics.h b/thirdparty/src/newton/dgPhysics/dgPhysics.h deleted file mode 100644 index 30b46fb10..000000000 --- a/thirdparty/src/newton/dgPhysics/dgPhysics.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGPHYSICS_H__ -#define __DGPHYSICS_H__ - -#include <dg.h> -#include "dgBody.h" -#include "dgWorld.h" -#include "dgContact.h" -#include "dgCollision.h" -#include "dgMeshEffect.h" -#include "dgConstraint.h" -#include "dgDynamicBody.h" -#include "dgWorldPlugins.h" -#include "dgCollisionBVH.h" -#include "dgContactSolver.h" -#include "dgKinematicBody.h" -#include "dgCollisionMesh.h" -#include "dgCollisionScene.h" -#include "dgBodyMasterList.h" -#include "dgUserConstraint.h" -#include "dgBallConstraint.h" -#include "dgHingeConstraint.h" -#include "dgSkeletonContainer.h" -#include "dgCollisionInstance.h" -#include "dgCollisionUserMesh.h" -#include "dgSlidingConstraint.h" -#include "dgUpVectorConstraint.h" -#include "dgCollisionConvexHull.h" -#include "dgUniversalConstraint.h" -#include "dgCorkscrewConstraint.h" -#include "dgBroadPhaseAggregate.h" -#include "dgCollisionHeightField.h" -#include "dgCollisionConvexPolygon.h" -#include "dgCollisionDeformableMesh.h" -#include "dgCollisionCompoundFractured.h" -#include "dgCollisionLumpedMassParticles.h" - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgPhysicsStdafx.h b/thirdparty/src/newton/dgPhysics/dgPhysicsStdafx.h deleted file mode 100644 index 23fc3a4b9..000000000 --- a/thirdparty/src/newton/dgPhysics/dgPhysicsStdafx.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#ifndef _DG_PHYSICS_STDAFX_H__ -#define _DG_PHYSICS_STDAFX_H__ - - -#ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#endif - -#include <dg.h> - - - -//#define DG_PROFILE_PHYSICS - - - - - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgSkeletonContainer.cpp b/thirdparty/src/newton/dgPhysics/dgSkeletonContainer.cpp deleted file mode 100644 index d3c9fba7d..000000000 --- a/thirdparty/src/newton/dgPhysics/dgSkeletonContainer.cpp +++ /dev/null @@ -1,1385 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgConstraint.h" -#include "dgDynamicBody.h" -#include "dgSkeletonContainer.h" -#include "dgWorldDynamicUpdate.h" -#include "dgBilateralConstraint.h" - - - -class dgSkeletonContainer::dgNodePair -{ - public: - dgInt32 m_m0; - dgInt32 m_m1; -}; - -DG_MSC_VECTOR_ALIGNMENT -class dgSkeletonContainer::dgForcePair -{ - public: - dgSpatialVector m_joint; - dgSpatialVector m_body; -} DG_GCC_VECTOR_ALIGNMENT; - -DG_MSC_VECTOR_ALIGNMENT -class dgSkeletonContainer::dgMatriData -{ - public: - dgSpatialMatrix m_jt; - dgSpatialMatrix m_invMass; -} DG_GCC_VECTOR_ALIGNMENT; - -DG_MSC_VECTOR_ALIGNMENT -class dgSkeletonContainer::dgBodyJointMatrixDataPair -{ - public: - dgMatriData m_body; - dgMatriData m_joint; -} DG_GCC_VECTOR_ALIGNMENT; - - -class dgSkeletonContainer::dgNode -{ - public: - - DG_CLASS_ALLOCATOR(allocator) - dgNode(dgDynamicBody* const body) - :m_body (body) - ,m_joint(NULL) - ,m_parent(NULL) - ,m_child(NULL) - ,m_sibling(NULL) - ,m_index(0) - ,m_dof(0) - ,m_swapJacobianBodiesIndex(0) - { - } - - dgNode (dgBilateralConstraint* const joint, dgNode* const parent) - :m_body ((dgDynamicBody*) ((joint->GetBody0() == parent->m_body) ? joint->GetBody1() : joint->GetBody0())) - ,m_joint (joint) - ,m_parent(parent) - ,m_child(NULL) - ,m_sibling(NULL) - ,m_index(0) - ,m_dof(0) - ,m_swapJacobianBodiesIndex(joint->GetBody0() == parent->m_body) - { - dgAssert (m_parent); - dgAssert (m_body->GetInvMass().m_w != dgFloat32 (0.0f)); - if (m_parent->m_child) { - m_sibling = m_parent->m_child; - } - m_parent->m_child = this; - } - - DG_INLINE ~dgNode() - { - m_body->SetSkeleton(NULL); - - dgNode* next; - for (dgNode* ptr = m_child; ptr; ptr = next) { - next = ptr->m_sibling; - delete ptr; - } - } - - DG_INLINE void CalculateInertiaMatrix(dgSpatialMatrix* const bodyMassArray) const - { - dgSpatialMatrix& bodyMass = bodyMassArray[m_index]; - - bodyMass = dgSpatialMatrix(dgFloat32(0.0f)); - if (m_body->GetInvMass().m_w != dgFloat32(0.0f)) { - const dgFloat32 mass = m_body->GetMass().m_w; - dgMatrix inertia(m_body->CalculateInertiaMatrix()); - for (dgInt32 i = 0; i < 3; i++) { - bodyMass[i][i] = mass; - for (dgInt32 j = 0; j < 3; j++) { - bodyMass[i + 3][j + 3] = inertia[i][j]; - } - } - } - } - - DG_INLINE void GetJacobians(const dgJointInfo* const jointInfo, const dgLeftHandSide* const leftHandSide, const dgRightHandSide* const rightHandSide, dgSpatialMatrix* const jointMassArray) - { - dgAssert(m_parent); - dgAssert(jointInfo->m_joint == m_joint); - - dgSpatialMatrix& bodyJt = m_data.m_body.m_jt; - dgSpatialMatrix& jointJ = m_data.m_joint.m_jt; - dgSpatialMatrix& jointMass = jointMassArray[m_index]; - - const dgInt32 start = jointInfo->m_pairStart; - const dgSpatialVector zero (dgSpatialVector::m_zero); - if (!m_swapJacobianBodiesIndex) { - for (dgInt32 i = 0; i < m_dof; i++) { - const dgInt32 k = m_sourceJacobianIndex[i]; - const dgRightHandSide* const rhs = &rightHandSide[start + k]; - const dgLeftHandSide* const row = &leftHandSide[start + k]; - jointMass[i] = zero; - jointMass[i][i] = -rhs->m_diagDamp; - bodyJt[i] = dgSpatialVector (row->m_Jt.m_jacobianM0.m_linear * dgVector::m_negOne, row->m_Jt.m_jacobianM0.m_angular * dgVector::m_negOne); - jointJ[i] = dgSpatialVector (row->m_Jt.m_jacobianM1.m_linear * dgVector::m_negOne, row->m_Jt.m_jacobianM1.m_angular * dgVector::m_negOne); - } - } else { - for (dgInt32 i = 0; i < m_dof; i++) { - const dgInt32 k = m_sourceJacobianIndex[i]; - const dgRightHandSide* const rhs = &rightHandSide[start + k]; - const dgLeftHandSide* const row = &leftHandSide[start + k]; - jointMass[i] = zero; - jointMass[i][i] = -rhs->m_diagDamp; - bodyJt[i] = dgSpatialVector(row->m_Jt.m_jacobianM1.m_linear * dgVector::m_negOne, row->m_Jt.m_jacobianM1.m_angular * dgVector::m_negOne); - jointJ[i] = dgSpatialVector(row->m_Jt.m_jacobianM0.m_linear * dgVector::m_negOne, row->m_Jt.m_jacobianM0.m_angular * dgVector::m_negOne); - } - } - } - - dgInt32 Factorize(const dgJointInfo* const jointInfoArray, const dgLeftHandSide* const leftHandSide, const dgRightHandSide* const rightHandSide, dgSpatialMatrix* const bodyMassArray, dgSpatialMatrix* const jointMassArray) - { - CalculateInertiaMatrix(bodyMassArray); - - m_ordinals = m_ordinalInit; - dgInt32 boundedDof = 0; - if (m_joint) { - dgAssert (m_parent); - const dgJointInfo* const jointInfo = &jointInfoArray[m_joint->m_index]; - dgAssert(jointInfo->m_joint == m_joint); - - m_dof = 0; - dgInt32 count = jointInfo->m_pairCount; - const dgInt32 first = jointInfo->m_pairStart; - for (dgInt32 i = 0; i < count; i++) { - dgInt32 k = m_sourceJacobianIndex[i]; - const dgRightHandSide* const rhs = &rightHandSide[k + first]; - if ((rhs->m_lowerBoundFrictionCoefficent <= dgFloat32 (-DG_LCP_MAX_VALUE)) && (rhs->m_upperBoundFrictionCoefficent >= dgFloat32 (DG_LCP_MAX_VALUE))) { - m_dof ++; - } else { - dgSwap(m_sourceJacobianIndex[i], m_sourceJacobianIndex[count - 1]); - i--; - count--; - } - } - dgAssert (m_dof > 0); - dgAssert (m_dof <= 6); - boundedDof += jointInfo->m_pairCount - count; - GetJacobians(jointInfo, leftHandSide, rightHandSide, jointMassArray); - } - - dgSpatialMatrix& bodyInvMass = m_data.m_body.m_invMass; - const dgSpatialMatrix& bodyMass = bodyMassArray[m_index]; - if (m_body->GetInvMass().m_w != dgFloat32(0.0f)) { - for (dgNode* child = m_child; child; child = child->m_sibling) { - CalculateBodyDiagonal(child, bodyMassArray, jointMassArray); - } - bodyInvMass = bodyMass.Inverse(6); - } else { - bodyInvMass = dgSpatialMatrix(dgFloat32(0.0f)); - } - - if (m_joint) { - dgSpatialMatrix& bodyJt = m_data.m_body.m_jt; - dgAssert(m_parent); - for (dgInt32 i = 0; i < m_dof; i++) { - bodyJt[i] = bodyInvMass.VectorTimeMatrix(bodyJt[i]); - } - CalculateJointDiagonal(bodyMassArray, jointMassArray); - CalculateJacobianBlock(); - } - return boundedDof; - } - - DG_INLINE void CalculateBodyDiagonal(dgNode* const child, dgSpatialMatrix* const bodyMassArray, const dgSpatialMatrix* const jointMassArray) - { - dgAssert(child->m_joint); - - dgSpatialMatrix copy (dgFloat32(0.0f)); - const dgInt32 dof = child->m_dof; - const dgSpatialMatrix& jacobianMatrix = child->m_data.m_joint.m_jt; - const dgSpatialMatrix& childDiagonal = jointMassArray[child->m_index]; - for (dgInt32 i = 0; i < dof ; i++) { - const dgSpatialVector& jacobian = jacobianMatrix[i]; - for (dgInt32 j = 0; j < dof ; j++) { - dgAssert(dgAreEqual (dgFloat64(childDiagonal[i][j]), dgFloat64(childDiagonal[j][i]), dgFloat64(1.0e-5f))); - dgFloat64 val = childDiagonal[i][j]; - copy[j] = copy[j] + jacobian.Scale(val); - } - } - - dgSpatialMatrix& bodyMass = bodyMassArray[m_index]; - for (dgInt32 i = 0; i < dof; i++) { - const dgSpatialVector& Jacobian = copy[i]; - const dgSpatialVector& JacobianTranspose = jacobianMatrix[i]; - for (dgInt32 j = 0; j < 6; j++) { - dgFloat64 val = -Jacobian[j]; - bodyMass[j] = bodyMass[j] + JacobianTranspose.Scale(val); - } - } - } - - DG_INLINE void CalculateJointDiagonal (const dgSpatialMatrix* const bodyMassArray, dgSpatialMatrix* const jointMassArray) - { - const dgSpatialMatrix& bodyMass = bodyMassArray[m_index]; - const dgSpatialMatrix& bodyJt = m_data.m_body.m_jt; - - dgSpatialMatrix tmp; - for (dgInt32 i = 0; i < m_dof; i++) { - tmp[i] = bodyMass.VectorTimeMatrix(bodyJt[i]); - } - - dgSpatialMatrix& jointMass = jointMassArray[m_index]; - for (dgInt32 i = 0; i < m_dof; i++) { - dgFloat64 a = bodyJt[i].DotProduct(tmp[i]); - jointMass[i][i] -= a; - for (dgInt32 j = i + 1; j < m_dof; j++) { - a = - bodyJt[i].DotProduct(tmp[j]); - jointMass[i][j] = a; - jointMass[j][i] = a; - } - } - - dgSpatialMatrix& jointInvMass = m_data.m_joint.m_invMass; - jointInvMass = jointMass.Inverse(m_dof); - } - - DG_INLINE void CalculateJacobianBlock() - { - dgSpatialMatrix& jointJ = m_data.m_joint.m_jt; - - dgSpatialMatrix copy; - const dgSpatialVector zero (dgSpatialVector::m_zero); - for (dgInt32 i = 0; i < m_dof; i++) { - copy[i] = jointJ[i]; - jointJ[i] = zero; - } - - const dgSpatialMatrix& jointInvMass = m_data.m_joint.m_invMass; - for (dgInt32 i = 0; i < m_dof; i++) { - const dgSpatialVector& jacobian = copy[i]; - const dgSpatialVector& invDiagonalRow = jointInvMass[i]; - for (dgInt32 j = 0; j < m_dof; j++) { - dgFloat64 val = invDiagonalRow[j]; - jointJ[j] = jointJ[j] + jacobian.Scale(val); - } - } - } - - DG_INLINE void JointJacobianTimeMassForward (dgForcePair& force) - { - const dgSpatialMatrix& bodyJt = m_data.m_body.m_jt; - for (dgInt32 i = 0; i < m_dof; i++) { - force.m_joint[i] -= bodyJt[i].DotProduct(force.m_body); - } - } - - DG_INLINE void BodyJacobianTimeMassForward(const dgForcePair& force, dgForcePair& parentForce) const - { - const dgSpatialMatrix& jointJ = m_data.m_joint.m_jt; - for (dgInt32 i = 0; i < m_dof; i++) { - parentForce.m_body = parentForce.m_body + jointJ[i].Scale(-force.m_joint[i]); - } - } - - DG_INLINE void JointJacobianTimeSolutionBackward(dgForcePair& force, const dgForcePair& parentForce) - { - const dgSpatialMatrix& jointJ = m_data.m_joint.m_jt; - const dgSpatialVector& f = parentForce.m_body; - for (dgInt32 i = 0; i < m_dof; i++) { - force.m_joint[i] -= f.DotProduct(jointJ[i]); - } - } - - DG_INLINE void BodyJacobianTimeSolutionBackward(dgForcePair& force) - { - const dgSpatialMatrix& bodyJt = m_data.m_body.m_jt; - for (dgInt32 i = 0; i < m_dof; i++) { - force.m_body = force.m_body + bodyJt[i].Scale(-force.m_joint[i]); - } - } - - DG_INLINE void BodyDiagInvTimeSolution(dgForcePair& force) - { - const dgSpatialMatrix& bodyInvMass = m_data.m_body.m_invMass; - force.m_body = bodyInvMass.VectorTimeMatrix(force.m_body); - } - - DG_INLINE void JointDiagInvTimeSolution(dgForcePair& force) - { - const dgSpatialMatrix& jointInvMass = m_data.m_joint.m_invMass; - force.m_joint = jointInvMass.VectorTimeMatrix(force.m_joint, m_dof); - } - - DG_INLINE dgInt32 GetAuxiliaryRows(const dgJointInfo* const jointInfoArray, const dgRightHandSide* const rightHandSide) const - { - dgInt32 rowCount = 0; - if (m_joint) { - dgAssert(m_parent); - const dgJointInfo* const jointInfo = &jointInfoArray[m_joint->m_index]; - dgAssert(jointInfo->m_joint == m_joint); - dgInt32 count = jointInfo->m_pairCount; - const dgInt32 first = jointInfo->m_pairStart; - for (dgInt32 i = 0; i < count; i++) { - const dgRightHandSide* const rhs = &rightHandSide[i + first]; - if (!((rhs->m_lowerBoundFrictionCoefficent <= dgFloat32 (-DG_LCP_MAX_VALUE)) && (rhs->m_upperBoundFrictionCoefficent >= dgFloat32 (DG_LCP_MAX_VALUE)))) { - rowCount++; - } - } - } - return rowCount; - } - - dgBodyJointMatrixDataPair m_data; - dgDynamicBody* m_body; - dgBilateralConstraint* m_joint; - dgNode* m_parent; - dgNode* m_child; - dgNode* m_sibling; - union - { - dgInt64 m_ordinals; - dgInt8 m_sourceJacobianIndex[8]; - }; - dgInt16 m_index; - dgInt8 m_dof; - dgInt8 m_swapJacobianBodiesIndex; - static dgInt64 m_ordinalInit; -}; - -dgInt64 dgSkeletonContainer::dgNode::m_ordinalInit = 0x050403020100ll; - -dgSkeletonContainer::dgSkeletonContainer(dgWorld* const world, dgDynamicBody* const rootBody) - :m_world(world) - ,m_skeleton(new (world->GetAllocator()) dgNode(rootBody)) - ,m_nodesOrder(NULL) - ,m_pairs(NULL) - ,m_deltaForce(NULL) - ,m_massMatrix11(NULL) - ,m_massMatrix10(NULL) - ,m_rightHandSide(NULL) - ,m_leftHandSide(NULL) - ,m_frictionIndex(NULL) - ,m_matrixRowsIndex(NULL) - ,m_listNode(NULL) - ,m_loopingJoints(world->GetAllocator()) - ,m_auxiliaryMemoryBuffer(world->GetAllocator()) - ,m_lru(0) - ,m_blockSize(0) - ,m_nodeCount(1) - ,m_loopCount(0) - ,m_dynamicsLoopCount(0) - ,m_rowCount(0) - ,m_loopRowCount(0) - ,m_auxiliaryRowCount(0) - ,m_consideredCloseLoop(1) -{ - if (rootBody->GetInvMass().m_w != dgFloat32 (0.0f)) { - rootBody->SetSkeleton(this); - } -} - -dgSkeletonContainer::~dgSkeletonContainer() -{ - for (dgInt32 i = 0; i < m_loopCount; i++) { - dgConstraint* const joint = m_loopingJoints[i]; - joint->m_isInSkeleton = false; - } - - for (dgInt32 i = 0; i < m_nodeCount - 1; i ++) { - m_nodesOrder[i]->m_joint->m_isInSkeleton = false; - } - - dgMemoryAllocator* const allocator = m_world->GetAllocator(); - if (m_nodesOrder) { - allocator->Free(m_nodesOrder); - } - - delete m_skeleton; -} - -dgSkeletonContainer::dgNode* dgSkeletonContainer::GetRoot () const -{ - return m_skeleton; -} - -dgSkeletonContainer::dgNode* dgSkeletonContainer::GetParent (dgNode* const node) const -{ - return node->m_parent; -} - -dgDynamicBody* dgSkeletonContainer::GetBody(dgSkeletonContainer::dgNode* const node) const -{ - return node->m_body; -} - -dgBilateralConstraint* dgSkeletonContainer::GetJoint(dgSkeletonContainer::dgNode* const node) const -{ - return node->m_joint; -} - -dgSkeletonContainer::dgNode* dgSkeletonContainer::GetFirstChild(dgSkeletonContainer::dgNode* const parent) const -{ - return parent->m_child; -} - -dgSkeletonContainer::dgNode* dgSkeletonContainer::GetNextSiblingChild(dgSkeletonContainer::dgNode* const sibling) const -{ - return sibling->m_sibling; -} - -dgWorld* dgSkeletonContainer::GetWorld() const -{ - return m_world; -} - -void dgSkeletonContainer::ClearSelfCollision() -{ - m_dynamicsLoopCount = 0; -} - -void dgSkeletonContainer::AddSelfCollisionJoint(dgConstraint* const joint) -{ - m_world->GlobalLock(); - m_loopingJoints[m_loopCount + m_dynamicsLoopCount] = joint; - m_dynamicsLoopCount++; - m_world->GlobalUnlock(); -} - -void dgSkeletonContainer::SortGraph(dgNode* const root, dgInt32& index) -{ - for (dgNode* node = root->m_child; node; node = node->m_sibling) { - SortGraph(node, index); - } - - dgAssert((m_nodeCount - index - 1) >= 0); - m_nodesOrder[index] = root; - root->m_index = dgInt16(index); - index++; - dgAssert(index <= m_nodeCount); -} - -dgSkeletonContainer::dgNode* dgSkeletonContainer::FindNode(dgDynamicBody* const body) const -{ - dgInt32 stack = 1; - dgNode* stackPool[1024]; - - stackPool[0] = m_skeleton; - while (stack) { - stack--; - dgNode* const node = stackPool[stack]; - if (node->m_body == body) { - return node; - } - - for (dgNode* ptr = node->m_child; ptr; ptr = ptr->m_sibling) { - stackPool[stack] = ptr; - stack++; - dgAssert(stack < dgInt32(sizeof (stackPool) / sizeof (stackPool[0]))); - } - } - return NULL; -} - -dgSkeletonContainer::dgNode* dgSkeletonContainer::AddChild(dgBilateralConstraint* const joint, dgNode* const parent) -{ - dgAssert (m_skeleton->m_body); - dgMemoryAllocator* const allocator = m_world->GetAllocator(); - dgNode* const node = new (allocator)dgNode(joint, parent); - m_nodeCount ++; - - joint->m_isInSkeleton = true; - dgAssert (m_world->GetSentinelBody() != node->m_body); - node->m_body->SetSkeleton(this); - return node; -} - -void dgSkeletonContainer::RemoveLoopJoint(dgBilateralConstraint* const joint) -{ - for (dgInt32 i = 0; i < m_loopCount; i++) { - if (m_loopingJoints[i] == joint) { - joint->m_isInSkeleton = false; - m_loopCount--; - m_loopingJoints[i] = m_loopingJoints[m_loopCount]; - break; - } - } -} - -void dgSkeletonContainer::Finalize(dgInt32 loopJointsCount, dgBilateralConstraint** const loopJointArray) -{ - dgAssert(m_nodeCount >= 1); - - const dgDynamicBody* const rootBody = m_skeleton->m_body; - dgAssert (((rootBody->GetInvMass().m_w == dgFloat32 (0.0f)) && (m_skeleton->m_child->m_sibling == NULL)) || (m_skeleton->m_body->GetInvMass().m_w != dgFloat32 (0.0f))); - - dgMemoryAllocator* const allocator = rootBody->GetWorld()->GetAllocator(); - m_nodesOrder = (dgNode**)allocator->Malloc(m_nodeCount * sizeof (dgNode*)); - - dgInt32 index = 0; - SortGraph(m_skeleton, index); - dgAssert(index == m_nodeCount); - - if (loopJointsCount) { - for (dgInt32 i = 0; i < loopJointsCount; i++) { - dgBilateralConstraint* const joint = loopJointArray[i]; - dgAssert(joint->GetBody0()->IsRTTIType(dgBody::m_dynamicBodyRTTI)); - dgAssert(joint->GetBody1()->IsRTTIType(dgBody::m_dynamicBodyRTTI)); - dgAssert((FindNode((dgDynamicBody*)joint->GetBody0()) || FindNode((dgDynamicBody*)joint->GetBody1()))); - joint->m_isInSkeleton = true; - - m_loopingJoints[m_loopCount] = joint; - m_loopCount++; - } - } -} - -void dgSkeletonContainer::FactorizeMatrix(dgInt32 size, dgInt32 stride, dgFloat32* const matrix, dgFloat32* const diagDamp) const -{ - DG_TRACKTIME(); - bool isPsdMatrix = false; - dgFloat32* const backupMatrix = dgAlloca(dgFloat32, size * stride); - do { - { - dgInt32 srcLine = 0; - dgInt32 dstLine = 0; - for (dgInt32 i = 0; i < size; i++) { - memcpy(&backupMatrix[dstLine], &matrix[srcLine], size * sizeof(dgFloat32)); - srcLine += size; - dstLine += stride; - } - } - isPsdMatrix = dgCholeskyFactorization(size, stride, matrix); - if (!isPsdMatrix) { - dgInt32 srcLine = 0; - dgInt32 dstLine = 0; - for (dgInt32 i = 0; i < size; i++) { - memcpy(&matrix[dstLine], &backupMatrix[srcLine], size * sizeof(dgFloat32)); - diagDamp[i] *= dgFloat32(4.0f); - matrix[dstLine + i] += diagDamp[i]; - dstLine += size; - srcLine += stride; - } - } - } while (!isPsdMatrix); -} -void dgSkeletonContainer::CalculateLoopMassMatrixCoefficients(dgFloat32* const diagDamp) -{ - DG_TRACKTIME(); - const dgInt32 primaryCount = m_rowCount - m_auxiliaryRowCount; - for (dgInt32 index = 0; index < m_auxiliaryRowCount; index ++) { - const dgInt32 ii = m_matrixRowsIndex[primaryCount + index]; - const dgLeftHandSide* const row_i = &m_leftHandSide[ii]; - const dgRightHandSide* const rhs_i = &m_rightHandSide[ii]; - const dgJacobian JMinvM0(row_i->m_JMinv.m_jacobianM0); - const dgJacobian JMinvM1(row_i->m_JMinv.m_jacobianM1); - const dgVector element( - JMinvM0.m_linear * row_i->m_Jt.m_jacobianM0.m_linear + JMinvM0.m_angular * row_i->m_Jt.m_jacobianM0.m_angular + - JMinvM1.m_linear * row_i->m_Jt.m_jacobianM1.m_linear + JMinvM1.m_angular * row_i->m_Jt.m_jacobianM1.m_angular); - - // I know I am doubling the matrix regularizer, but this makes the solution more robust. - dgFloat32* const matrixRow11 = &m_massMatrix11[m_auxiliaryRowCount * index]; - dgFloat32 diagonal = element.AddHorizontal().GetScalar() + rhs_i->m_diagDamp; - matrixRow11[index] = diagonal + rhs_i->m_diagDamp; - //diagDamp[index] = matrixRow11[index] * (DG_PSD_DAMP_TOL * dgFloat32(4.0f)); - diagDamp[index] = matrixRow11[index] * dgFloat32(4.0e-3f); - - const dgInt32 m0_i = m_pairs[primaryCount + index].m_m0; - const dgInt32 m1_i = m_pairs[primaryCount + index].m_m1; - for (dgInt32 j = index + 1; j < m_auxiliaryRowCount; j++) { - const dgInt32 jj = m_matrixRowsIndex[primaryCount + j]; - const dgLeftHandSide* const row_j = &m_leftHandSide[jj]; - - const dgInt32 k = primaryCount + j; - dgVector acc(dgVector::m_zero); - const dgInt32 m0_j = m_pairs[k].m_m0; - const dgInt32 m1_j = m_pairs[k].m_m1; - bool hasEffect = false; - if (m0_i == m0_j) { - hasEffect = true; - acc += JMinvM0.m_linear * row_j->m_Jt.m_jacobianM0.m_linear + JMinvM0.m_angular * row_j->m_Jt.m_jacobianM0.m_angular; - } else if (m0_i == m1_j) { - hasEffect = true; - acc += JMinvM0.m_linear * row_j->m_Jt.m_jacobianM1.m_linear + JMinvM0.m_angular * row_j->m_Jt.m_jacobianM1.m_angular; - } - - if (m1_i == m1_j) { - hasEffect = true; - acc += JMinvM1.m_linear * row_j->m_Jt.m_jacobianM1.m_linear + JMinvM1.m_angular * row_j->m_Jt.m_jacobianM1.m_angular; - } else if (m1_i == m0_j) { - hasEffect = true; - acc += JMinvM1.m_linear * row_j->m_Jt.m_jacobianM0.m_linear + JMinvM1.m_angular * row_j->m_Jt.m_jacobianM0.m_angular; - } - - if (hasEffect) { - acc = acc.AddHorizontal(); - dgFloat32 offDiagValue = acc.GetScalar(); - matrixRow11[j] = offDiagValue; - m_massMatrix11[j * m_auxiliaryRowCount + index] = offDiagValue; - } - } - - dgFloat32* const matrixRow10 = &m_massMatrix10[primaryCount * index]; - for (dgInt32 j = 0; j < primaryCount; j++) { - const dgInt32 jj = m_matrixRowsIndex[j]; - const dgLeftHandSide* const row_j = &m_leftHandSide[jj]; - - const dgInt32 m0_j = m_pairs[j].m_m0; - const dgInt32 m1_j = m_pairs[j].m_m1; - dgVector acc(dgVector::m_zero); - bool hasEffect = false; - if (m0_i == m0_j) { - hasEffect = true; - acc += JMinvM0.m_linear * row_j->m_Jt.m_jacobianM0.m_linear + JMinvM0.m_angular * row_j->m_Jt.m_jacobianM0.m_angular; - } else if (m0_i == m1_j) { - hasEffect = true; - acc += JMinvM0.m_linear * row_j->m_Jt.m_jacobianM1.m_linear + JMinvM0.m_angular * row_j->m_Jt.m_jacobianM1.m_angular; - } - - if (m1_i == m1_j) { - hasEffect = true; - acc += JMinvM1.m_linear * row_j->m_Jt.m_jacobianM1.m_linear + JMinvM1.m_angular * row_j->m_Jt.m_jacobianM1.m_angular; - } else if (m1_i == m0_j) { - hasEffect = true; - acc += JMinvM1.m_linear * row_j->m_Jt.m_jacobianM0.m_linear + JMinvM1.m_angular * row_j->m_Jt.m_jacobianM0.m_angular; - } - - if (hasEffect) { - acc = acc.AddHorizontal(); - dgFloat32 val = acc.GetScalar(); - matrixRow10[j] = val; - } - } - } -} - -void dgSkeletonContainer::ConditionMassMatrix () const -{ - DG_TRACKTIME(); - dgForcePair* const forcePair = dgAlloca(dgForcePair, m_nodeCount); -// dgForcePair* const accelPair = dgAlloca(dgForcePair, m_nodeCount); - const dgSpatialVector zero(dgSpatialVector::m_zero); -// accelPair[m_nodeCount - 1].m_body = zero; -// accelPair[m_nodeCount - 1].m_joint = zero; - - const dgInt32 primaryCount = m_rowCount - m_auxiliaryRowCount; - for (dgInt32 i = 0; i < m_auxiliaryRowCount; i ++) { - dgInt32 entry0 = 0; - dgInt32 startjoint = m_nodeCount; - const dgFloat32* const matrixRow10 = &m_massMatrix10[i * primaryCount]; - for (dgInt32 j = 0; j < m_nodeCount - 1; j++) { - const dgNode* const node = m_nodesOrder[j]; - const dgInt32 index = node->m_index; - //accelPair[index].m_body = zero; - //dgSpatialVector& a = accelPair[index].m_joint; - forcePair[index].m_body = zero; - dgSpatialVector& a = forcePair[index].m_joint; - - const int count = node->m_dof; - for (dgInt32 k = 0; k < count; k++) { - const dgFloat32 value = matrixRow10[entry0]; - a[k] = value; - startjoint = (value == 0.0f) ? startjoint : dgMin(startjoint, index); - entry0++; - } - } - - startjoint = (startjoint == m_nodeCount) ? 0 : startjoint; - dgAssert(startjoint < m_nodeCount); - //SolveForward(forcePair, accelPair, startjoint); - forcePair[m_nodeCount - 1].m_body = zero; - forcePair[m_nodeCount - 1].m_joint = zero; - SolveForward(forcePair, forcePair, startjoint); - SolveBackward(forcePair); - - dgInt32 entry1 = 0; - dgFloat32* const deltaForcePtr = &m_deltaForce[i * primaryCount]; - for (dgInt32 j = 0; j < m_nodeCount - 1; j++) { - const dgNode* const node = m_nodesOrder[j]; - const dgInt32 index = node->m_index; - const dgSpatialVector& f = forcePair[index].m_joint; - const int count = node->m_dof; - for (dgInt32 k = 0; k < count; k++) { - deltaForcePtr[entry1] = dgFloat32(f[k]); - entry1++; - } - } - } -} - -void dgSkeletonContainer::RebuildMassMatrix(const dgFloat32* const diagDamp) const -{ - DG_TRACKTIME(); - const dgInt32 primaryCount = m_rowCount - m_auxiliaryRowCount; - dgInt16* const indexList = dgAlloca(dgInt16, primaryCount); - for (dgInt32 i = 0; i < m_auxiliaryRowCount; i ++) { - const dgFloat32* const matrixRow10 = &m_massMatrix10[i * primaryCount]; - dgFloat32* const matrixRow11 = &m_massMatrix11[i * m_auxiliaryRowCount]; - - dgInt32 indexCount = 0; - for (dgInt32 k = 0; k < primaryCount; k++) { - indexList[indexCount] = dgInt16(k); - indexCount += (matrixRow10[k] != dgFloat32(0.0f)) ? 1 : 0; - } - - for (dgInt32 j = i; j < m_auxiliaryRowCount; j++) { - dgFloat32 offDiagonal = matrixRow11[j]; - const dgFloat32* const row10 = &m_deltaForce[j * primaryCount]; - for (dgInt32 k = 0; k < indexCount; k++) { - dgInt32 index = indexList[k]; - offDiagonal += matrixRow10[index] * row10[index]; - } - matrixRow11[j] = offDiagonal; - m_massMatrix11[j * m_auxiliaryRowCount + i] = offDiagonal; - } - - matrixRow11[i] = dgMax(matrixRow11[i], diagDamp[i]); - } -} - -void dgSkeletonContainer::InitLoopMassMatrix(const dgJointInfo* const jointInfoArray) -{ - const dgInt32 primaryCount = m_rowCount - m_auxiliaryRowCount; - dgInt8* const memoryBuffer = CalculateBufferSizeInBytes(jointInfoArray); - - m_frictionIndex = (dgInt32*)memoryBuffer; - m_matrixRowsIndex = (dgInt32*)&m_frictionIndex[m_rowCount]; - m_pairs = (dgNodePair*)&m_matrixRowsIndex[m_rowCount]; - m_massMatrix11 = (dgFloat32*)&m_pairs[m_rowCount]; - m_massMatrix10 = (dgFloat32*)&m_massMatrix11[m_auxiliaryRowCount * m_auxiliaryRowCount]; - m_deltaForce = &m_massMatrix10[m_auxiliaryRowCount * primaryCount]; - - dgFloat32* const diagDamp = dgAlloca(dgFloat32, m_auxiliaryRowCount); - dgInt32* const boundRow = dgAlloca(dgInt32, m_auxiliaryRowCount); - - m_blockSize = 0; - dgInt32 primaryIndex = 0; - dgInt32 auxiliaryIndex = 0; - for (dgInt32 i = 0; i < m_nodeCount - 1; i++) { - const dgNode* const node = m_nodesOrder[i]; - const dgJointInfo* const jointInfo = &jointInfoArray[node->m_joint->m_index]; - - const dgInt32 m0 = jointInfo->m_m0; - const dgInt32 m1 = jointInfo->m_m1; - - const dgInt32 primaryDof = node->m_dof; - const dgInt32 first = jointInfo->m_pairStart; - - for (dgInt32 j = 0; j < primaryDof; j++) { - const dgInt32 index = node->m_sourceJacobianIndex[j]; - m_pairs[primaryIndex].m_m0 = m0; - m_pairs[primaryIndex].m_m1 = m1; - m_frictionIndex[primaryIndex] = 0; - m_matrixRowsIndex[primaryIndex] = first + index; - primaryIndex++; - } - - const dgInt32 auxiliaryDof = jointInfo->m_pairCount - primaryDof; - for (dgInt32 j = 0; j < auxiliaryDof; j++) { - const dgInt32 index = node->m_sourceJacobianIndex[primaryDof + j]; - const dgRightHandSide* const rhs = &m_rightHandSide[first + index]; - - m_pairs[auxiliaryIndex + primaryCount].m_m0 = m0; - m_pairs[auxiliaryIndex + primaryCount].m_m1 = m1; - m_frictionIndex[auxiliaryIndex + primaryCount] = 0; - m_matrixRowsIndex[auxiliaryIndex + primaryCount] = first + index; - const dgInt32 boundIndex = (rhs->m_lowerBoundFrictionCoefficent <= dgFloat32(-DG_LCP_MAX_VALUE)) && (rhs->m_upperBoundFrictionCoefficent >= dgFloat32(DG_LCP_MAX_VALUE)) ? 1 : 0; - boundRow[auxiliaryIndex] = boundIndex; - m_blockSize += boundIndex; - auxiliaryIndex++; - } - } - dgAssert (m_loopRowCount == (m_auxiliaryRowCount - auxiliaryIndex)); - - const dgInt32 loopCount = m_loopCount + m_dynamicsLoopCount; - for (dgInt32 j = 0; j < loopCount; j ++) { - const dgConstraint* const joint = m_loopingJoints[j]; - const dgJointInfo* const jointInfo = &jointInfoArray[joint->m_index]; - - const dgInt32 m0 = jointInfo->m_m0; - const dgInt32 m1 = jointInfo->m_m1; - const dgInt32 first = jointInfo->m_pairStart; - const dgInt32 auxiliaryDof = jointInfo->m_pairCount; - - for (dgInt32 i = 0; i < auxiliaryDof; i++) { - const dgRightHandSide* const rhs = &m_rightHandSide[first + i]; - m_pairs[auxiliaryIndex + primaryCount].m_m0 = m0; - m_pairs[auxiliaryIndex + primaryCount].m_m1 = m1; - m_frictionIndex[auxiliaryIndex + primaryCount] = (rhs->m_normalForceIndex < 0) ? 0 : rhs->m_normalForceIndex - i; - m_matrixRowsIndex[auxiliaryIndex + primaryCount] = first + i; - const dgInt32 boundIndex = (rhs->m_lowerBoundFrictionCoefficent <= dgFloat32(-DG_LCP_MAX_VALUE)) && (rhs->m_upperBoundFrictionCoefficent >= dgFloat32(DG_LCP_MAX_VALUE)) ? 1 : 0; - boundRow[auxiliaryIndex] = boundIndex; - m_blockSize += boundIndex; - auxiliaryIndex++; - } - } - - dgAssert(primaryIndex == primaryCount); - dgAssert(auxiliaryIndex == m_auxiliaryRowCount); - - for (dgInt32 i = 1; i < auxiliaryIndex; i++) { - dgInt32 j = i; - dgInt32 tmpBoundRow = boundRow[j]; - dgNodePair tmpPair(m_pairs[primaryCount + j]); - dgInt32 tmpFrictionIndex = m_frictionIndex[primaryCount + j]; - dgInt32 tmpMatrixRowsIndex = m_matrixRowsIndex[primaryCount + j]; - - for (; j && (boundRow[j - 1] < tmpBoundRow); j--) { - dgAssert(j > 0); - boundRow[j] = boundRow[j - 1]; - m_pairs[primaryCount + j] = m_pairs[primaryCount + j - 1]; - m_frictionIndex[primaryCount + j] = m_frictionIndex[primaryCount + j - 1]; - m_matrixRowsIndex[primaryCount + j] = m_matrixRowsIndex[primaryCount + j - 1]; - } - boundRow[j] = tmpBoundRow; - m_pairs[primaryCount + j] = tmpPair; - m_frictionIndex[primaryCount + j] = tmpFrictionIndex; - m_matrixRowsIndex[primaryCount + j] = tmpMatrixRowsIndex; - } - - memset(m_massMatrix10, 0, primaryCount * m_auxiliaryRowCount * sizeof(dgFloat32)); - memset(m_massMatrix11, 0, m_auxiliaryRowCount * m_auxiliaryRowCount * sizeof(dgFloat32)); - - CalculateLoopMassMatrixCoefficients(diagDamp); - ConditionMassMatrix (); - RebuildMassMatrix(diagDamp); - - if (m_blockSize) { - FactorizeMatrix(m_blockSize, m_auxiliaryRowCount, m_massMatrix11, diagDamp); - const int boundedSize = m_auxiliaryRowCount - m_blockSize; - dgFloat32* const acc = dgAlloca(dgFloat32, m_auxiliaryRowCount); - dgInt32 rowStart = 0; - for (dgInt32 i = 0; i < m_blockSize; i++) { - memset(acc, 0, boundedSize * sizeof (dgFloat32)); - const dgFloat32* const row = &m_massMatrix11[rowStart]; - for (dgInt32 j = 0; j < i; j++) { - const dgFloat32 s = row[j]; - const dgFloat32* const x = &m_massMatrix11[j * m_auxiliaryRowCount + m_blockSize]; - for (dgInt32 k = 0; k < boundedSize; k++) { - acc[k] += s * x[k]; - } - } - - dgFloat32* const x = &m_massMatrix11[rowStart + m_blockSize]; - const dgFloat32 den = -dgFloat32(1.0f) / row[i]; - for (dgInt32 j = 0; j < boundedSize; j++) { - x[j] = (x[j] + acc[j]) * den; - } - rowStart += m_auxiliaryRowCount; - } - - for (dgInt32 i = m_blockSize - 1; i >= 0; i--) { - memset(acc, 0, boundedSize * sizeof (dgFloat32)); - for (dgInt32 j = i + 1; j < m_blockSize; j++) { - const dgFloat32 s = m_massMatrix11[j * m_auxiliaryRowCount + i]; - const dgFloat32* const x = &m_massMatrix11[j * m_auxiliaryRowCount + m_blockSize]; - for (dgInt32 k = 0; k < boundedSize; k++) { - acc[k] += s * x[k]; - } - } - - dgFloat32* const x = &m_massMatrix11[i * m_auxiliaryRowCount + m_blockSize]; - const dgFloat32 den = dgFloat32(1.0f) / m_massMatrix11[i * m_auxiliaryRowCount + i]; - for (dgInt32 j = 0; j < boundedSize; j++) { - x[j] = (x[j] - acc[j]) * den; - } - } - - for (dgInt32 i = 0; i < boundedSize; i++) { - for (int j = 0; j < m_blockSize; j++) { - acc[j] = m_massMatrix11[j * m_auxiliaryRowCount + m_blockSize + i]; - } - - dgFloat32* const arow = &m_massMatrix11[(m_blockSize + i) * m_auxiliaryRowCount + m_blockSize]; - for (int j = i; j < boundedSize; j++) { - const dgFloat32* const row1 = &m_massMatrix11[(m_blockSize + j) * m_auxiliaryRowCount]; - dgFloat32 elem = row1[m_blockSize + i] + dgDotProduct(m_blockSize, acc, row1); - arow[j] = elem; - m_massMatrix11[(m_blockSize + j) * m_auxiliaryRowCount + m_blockSize + i] = elem; - } - arow[i] += diagDamp[m_blockSize + i]; - } - dgAssert (dgTestPSDmatrix(m_auxiliaryRowCount - m_blockSize, m_auxiliaryRowCount, &m_massMatrix11[m_auxiliaryRowCount * m_blockSize + m_blockSize])); - } -} - -bool dgSkeletonContainer::SanityCheck(const dgForcePair* const force, const dgForcePair* const accel) const -{ - return true; -} - -DG_INLINE void dgSkeletonContainer::SolveForward(dgForcePair* const force, const dgForcePair* const accel, dgInt32 startNode) const -{ - dgSpatialVector zero (dgSpatialVector::m_zero); - for (dgInt32 i = 0; i < startNode; i++) { - force[i].m_body = zero; - force[i].m_joint = zero; - } - for (dgInt32 i = startNode; i < m_nodeCount - 1; i++) { - dgNode* const node = m_nodesOrder[i]; - dgAssert(node->m_joint); - dgAssert(node->m_index == i); - dgForcePair& f = force[i]; - const dgForcePair& a = accel[i]; - f.m_body = a.m_body; - f.m_joint = a.m_joint; - for (dgNode* child = node->m_child; child; child = child->m_sibling) { - dgAssert(child->m_joint); - dgAssert(child->m_parent->m_index == i); - child->BodyJacobianTimeMassForward(force[child->m_index], f); - } - node->JointJacobianTimeMassForward(f); - } - - force[m_nodeCount - 1] = accel[m_nodeCount - 1]; - for (dgNode* child = m_nodesOrder[m_nodeCount - 1]->m_child; child; child = child->m_sibling) { - child->BodyJacobianTimeMassForward(force[child->m_index], force[child->m_parent->m_index]); - } - - for (dgInt32 i = startNode; i < m_nodeCount - 1; i++) { - dgNode* const node = m_nodesOrder[i]; - dgForcePair& f = force[i]; - node->BodyDiagInvTimeSolution(f); - node->JointDiagInvTimeSolution(f); - } - m_nodesOrder[m_nodeCount - 1]->BodyDiagInvTimeSolution(force[m_nodeCount - 1]); -} - -DG_INLINE void dgSkeletonContainer::SolveBackward(dgForcePair* const force) const -{ - for (dgInt32 i = m_nodeCount - 2; i >= 0; i--) { - dgNode* const node = m_nodesOrder[i]; - dgAssert(node->m_index == i); - dgForcePair& f = force[i]; - node->JointJacobianTimeSolutionBackward(f, force[node->m_parent->m_index]); - node->BodyJacobianTimeSolutionBackward(f); - } -} - -DG_INLINE void dgSkeletonContainer::CalculateForce (dgForcePair* const force, const dgForcePair* const accel) const -{ - SolveForward(force, accel); - SolveBackward(force); -} - -DG_INLINE void dgSkeletonContainer::UpdateForces (dgJointInfo* const jointInfoArray, dgJacobian* const internalForces, const dgForcePair* const force) const -{ - dgVector zero (dgVector::m_zero); - for (dgInt32 i = 0; i < (m_nodeCount - 1) ; i ++) { - dgNode* const node = m_nodesOrder[i]; - const dgJointInfo* const jointInfo = &jointInfoArray[node->m_joint->m_index]; - - dgJacobian y0; - dgJacobian y1; - y0.m_linear = zero; - y0.m_angular = zero; - y1.m_linear = zero; - y1.m_angular = zero; - dgAssert(i == node->m_index); - - const dgSpatialVector& f = force[i].m_joint; - dgAssert(jointInfo->m_joint == node->m_joint); - const dgInt32 first = jointInfo->m_pairStart; - const dgInt32 count = node->m_dof; - for (dgInt32 j = 0; j < count; j ++) { - const dgInt32 k = node->m_sourceJacobianIndex[j]; - dgRightHandSide* const rhs = &m_rightHandSide[first + k]; - const dgLeftHandSide* const row = &m_leftHandSide[first + k]; - - rhs->m_force += dgFloat32(f[j]); - dgVector jointForce = dgFloat32 (f[j]); - y0.m_linear += row->m_Jt.m_jacobianM0.m_linear * jointForce; - y0.m_angular += row->m_Jt.m_jacobianM0.m_angular * jointForce; - y1.m_linear += row->m_Jt.m_jacobianM1.m_linear * jointForce; - y1.m_angular += row->m_Jt.m_jacobianM1.m_angular * jointForce; - } - - const dgInt32 m0 = jointInfo->m_m0; - const dgInt32 m1 = jointInfo->m_m1; - internalForces[m0].m_linear += y0.m_linear; - internalForces[m0].m_angular += y0.m_angular; - internalForces[m1].m_linear += y1.m_linear; - internalForces[m1].m_angular += y1.m_angular; - } -} - -DG_INLINE void dgSkeletonContainer::CalculateJointAccel(dgJointInfo* const jointInfoArray, const dgJacobian* const internalForces, dgForcePair* const accel) const -{ - const dgSpatialVector zero (dgSpatialVector::m_zero); - for (dgInt32 i = 0; i < m_nodeCount - 1; i++) { - dgNode* const node = m_nodesOrder[i]; - dgAssert(i == node->m_index); - - dgForcePair& a = accel[i]; - dgAssert(node->m_body); - a.m_body = zero; - a.m_joint = zero; - - dgAssert(node->m_joint); - const dgJointInfo* const jointInfo = &jointInfoArray[node->m_joint->m_index]; - dgAssert(jointInfo->m_joint == node->m_joint); - - const dgInt32 first = jointInfo->m_pairStart; - const dgInt32 dof = jointInfo->m_pairCount; - const dgInt32 m0 = jointInfo->m_m0; - const dgInt32 m1 = jointInfo->m_m1; - const dgJacobian& y0 = internalForces[m0]; - const dgJacobian& y1 = internalForces[m1]; - - for (dgInt32 j = 0; j < dof; j++) { - const dgInt32 k = node->m_sourceJacobianIndex[j]; - const dgLeftHandSide* const row = &m_leftHandSide[first + k]; - const dgRightHandSide* const rhs = &m_rightHandSide[first + k]; - dgVector diag(row->m_JMinv.m_jacobianM0.m_linear * y0.m_linear + row->m_JMinv.m_jacobianM0.m_angular * y0.m_angular + - row->m_JMinv.m_jacobianM1.m_linear * y1.m_linear + row->m_JMinv.m_jacobianM1.m_angular * y1.m_angular); - a.m_joint[j] = -(rhs->m_coordenateAccel - rhs->m_force * rhs->m_diagDamp - diag.AddHorizontal().GetScalar()); - } - } - dgAssert((m_nodeCount - 1) == m_nodesOrder[m_nodeCount - 1]->m_index); - accel[m_nodeCount - 1].m_body = zero; - accel[m_nodeCount - 1].m_joint = zero; -} - -void dgSkeletonContainer::SolveLcp(dgInt32 stride, dgInt32 size, const dgFloat32* const matrix, const dgFloat32* const x0, dgFloat32* const x, const dgFloat32* const b, const dgFloat32* const low, const dgFloat32* const high, const dgInt32* const normalIndex) const -{ - D_TRACKTIME(); - if (m_world->GetCurrentPlugin()) { - dgWorldPlugin* const plugin = m_world->GetCurrentPlugin()->GetInfo().m_plugin; - plugin->SolveDenseLcp(stride, size, matrix, x0, x, b, low, high, normalIndex); - } else { -#if 0 - // sequential Sidle iteration - const dgFloat32 sor = dgFloat32(1.125f); - const dgFloat32 tol2 = dgFloat32(0.25f); - const dgInt32 maxIterCount = 64; - - dgFloat32* const invDiag1 = dgAlloca(dgFloat32, size); - - int rowStart = 0; - for (dgInt32 i = 0; i < size; i++) { - const int index = normalIndex[i]; - const dgFloat32 coefficient = index ? (x[i + index] + x0[i + index]) : 1.0f; - const dgFloat32 l = low[i] * coefficient - x0[i]; - const dgFloat32 h = high[i] * coefficient - x0[i];; - x[i] = dgClamp(dgFloat32(0.0f), l, h); - invDiag1[i] = dgFloat32(1.0f) / matrix[rowStart + i]; - rowStart += stride; - } - - dgFloat32 tolerance(tol2 * dgFloat32(2.0f)); - const dgFloat32* const invDiag = invDiag1; - - dgInt32 iterCount = 0; - for (dgInt32 k = 0; (k < maxIterCount) && (tolerance > tol2); k++) { - iterCount++; - dgInt32 base = 0; - tolerance = dgFloat32(0.0f); - for (dgInt32 i = 0; i < size; i++) { - const dgFloat32* const row = &matrix[base]; - dgFloat32 r = b[i] - dgDotProduct(size, row, x); - - const int index = normalIndex[i]; - const dgFloat32 coefficient = index ? (x[i + index] + x0[i + index]) : dgFloat32(1.0f); - const dgFloat32 l = low[i] * coefficient - x0[i]; - const dgFloat32 h = high[i] * coefficient - x0[i]; - - dgFloat32 f = x[i] + ((r + row[i] * x[i]) * invDiag[i] - x[i]) * sor; - if (f > h) { - f = h; - } else if (f < l) { - f = l; - } else { - tolerance += r * r; - } - x[i] = f; - base += stride; - } - } -#else - // ready for parallelization - const dgFloat32 sor = dgFloat32(1.125f); - const dgFloat32 tol2 = dgFloat32(0.25f); - const dgInt32 maxIterCount = 64; - - dgFloat32* const invDiag1 = dgAlloca(dgFloat32, size); - dgFloat32* const residual = dgAlloca(dgFloat32, size); - - dgInt32 rowStart = 0; - for (dgInt32 i = 0; i < size; i++) { - const int index = normalIndex[i]; - const dgFloat32 coefficient = index ? (x[i + index] + x0[i + index]) : 1.0f; - const dgFloat32 l = low[i] * coefficient - x0[i]; - const dgFloat32 h = high[i] * coefficient - x0[i];; - x[i] = dgClamp(dgFloat32(0.0f), l, h); - invDiag1[i] = dgFloat32(1.0f) / matrix[rowStart + i]; - rowStart += stride; - } - - dgInt32 base = 0; - for (dgInt32 i = 0; i < size; i++) { - const dgFloat32* const row = &matrix[base]; - residual[i] = b[i] - dgDotProduct(size, row, x); - base += stride; - } - - dgInt32 iterCount = 0; - dgFloat32 tolerance(tol2 * dgFloat32(2.0f)); - const dgFloat32* const invDiag = invDiag1; - const dgFloat32 one = dgFloat32(1.0f); - for (dgInt32 k = 0; (k < maxIterCount) && (tolerance > tol2); k++) { - base = 0; - iterCount++; - tolerance = dgFloat32(0.0f); - for (dgInt32 i = 0; i < size; i++) { - const dgFloat32 r = residual[i]; - const int index = normalIndex[i]; - const dgFloat32 coefficient = index ? x[i + index] + x0[i + index] : one; - const dgFloat32 l = low[i] * coefficient - x0[i]; - const dgFloat32 h = high[i] * coefficient - x0[i]; - - const dgFloat32* const row = &matrix[base]; -#if 0 - dgFloat32 f = x[i] + ((r + row[i] * x[i]) * invDiag[i] - x[i]) * sor; - if (f > h) { - f = h; - } else if (f < l) { - f = l; - } else { - tolerance += r * r; - } - const dgFloat32 dx = f - x[i]; -#else - const dgFloat32 f = dgClamp(x[i] + ((r + row[i] * x[i]) * invDiag[i] - x[i]) * sor, l, h); - const dgFloat32 dx = f - x[i]; - const dgFloat32 dr = dx * row[i]; - tolerance += dr * dr; -#endif - x[i] = f; - if (dgAbs (dx) > dgFloat32 (1.0e-6f)) { - for (dgInt32 j = 0; j < size; j++) { - residual[j] -= row[j] * dx; - } - } - base += stride; - } - } -#endif - } -} - -void dgSkeletonContainer::SolveBlockLcp(dgInt32 size, dgInt32 blockSize, const dgFloat32* const x0, dgFloat32* const x, dgFloat32* const b, const dgFloat32* const low, const dgFloat32* const high, const dgInt32* const normalIndex) const -{ - if (blockSize) { - dgSolveCholesky(blockSize, size, m_massMatrix11, x, b); - if (blockSize != size) { - - dgInt32 base = blockSize * size; - for (dgInt32 i = blockSize; i < size; i++) { - b[i] -= dgDotProduct(blockSize, &m_massMatrix11[base], x); - base += size; - } - - const int boundedSize = size - blockSize; - SolveLcp( - size, boundedSize, &m_massMatrix11[blockSize * size + blockSize], - &x0[blockSize], &x[blockSize], &b[blockSize], &low[blockSize], &high[blockSize], &normalIndex[blockSize]); - - for (dgInt32 j = 0; j < blockSize; j++) { - const dgFloat32* const row = &m_massMatrix11[j * size + blockSize]; - dgFloat32 acc = dgFloat32 (0.0f); - for (dgInt32 i = 0; i < boundedSize; i++) { - acc += x[blockSize + i] * row[i]; - } - x[j] += acc; - } - } - } else { - SolveLcp(size, size, m_massMatrix11, x0, x, b, low, high, normalIndex); - } -} - -void dgSkeletonContainer::SolveAuxiliary(const dgJointInfo* const jointInfoArray, dgJacobian* const internalForces, const dgForcePair* const accel, dgForcePair* const force) const -{ - dgFloat32* const f = dgAlloca(dgFloat32, m_rowCount); - dgFloat32* const u = dgAlloca(dgFloat32, m_auxiliaryRowCount); - dgFloat32* const b = dgAlloca(dgFloat32, m_auxiliaryRowCount); - dgFloat32* const u0 = dgAlloca(dgFloat32, m_auxiliaryRowCount); - dgFloat32* const low = dgAlloca(dgFloat32, m_auxiliaryRowCount); - dgFloat32* const high = dgAlloca(dgFloat32, m_auxiliaryRowCount); - dgInt32* const normalIndex = dgAlloca(dgInt32, m_auxiliaryRowCount); - - dgInt32 primaryIndex = 0; - const dgInt32 primaryCount = m_rowCount - m_auxiliaryRowCount; - - for (dgInt32 i = 0; i < m_nodeCount - 1; i++) { - const dgNode* const node = m_nodesOrder[i]; - const dgInt32 primaryDof = node->m_dof; - const dgSpatialVector& forceSpatial = force[i].m_joint; - - for (dgInt32 j = 0; j < primaryDof; j++) { - f[primaryIndex] = dgFloat32(forceSpatial[j]); - primaryIndex++; - } - } - - dgAssert (primaryIndex == primaryCount); - for (dgInt32 i = 0; i < m_auxiliaryRowCount; i++) { - const int index = m_matrixRowsIndex[primaryCount + i]; - const dgLeftHandSide* const row = &m_leftHandSide[index]; - const dgRightHandSide* const rhs = &m_rightHandSide[index]; - - const int m0 = m_pairs[primaryCount + i].m_m0; - const int m1 = m_pairs[primaryCount + i].m_m1; - - const dgJacobian& y0 = internalForces[m0]; - const dgJacobian& y1 = internalForces[m1]; - - f[primaryCount + i] = dgFloat32(0.0f); - - dgVector acc(row->m_JMinv.m_jacobianM0.m_linear * y0.m_linear + row->m_JMinv.m_jacobianM0.m_angular * y0.m_angular + - row->m_JMinv.m_jacobianM1.m_linear * y1.m_linear + row->m_JMinv.m_jacobianM1.m_angular * y1.m_angular); - b[i] = rhs->m_coordenateAccel - acc.AddHorizontal().GetScalar(); - - normalIndex[i] = m_frictionIndex[primaryCount + i]; - u0[i] = rhs->m_force; - low[i] = rhs->m_lowerBoundFrictionCoefficent; - high[i] = rhs->m_upperBoundFrictionCoefficent; - } - - for (dgInt32 i = 0; i < m_auxiliaryRowCount; i++) { - dgFloat32* const matrixRow10 = &m_massMatrix10[i * primaryCount]; - b[i] -= dgDotProduct(primaryCount, matrixRow10, f); - } - - SolveBlockLcp(m_auxiliaryRowCount, m_blockSize, u0, u, b, low, high, normalIndex); - - for (dgInt32 i = 0; i < m_auxiliaryRowCount; i++) { - const dgFloat32 s = u[i]; - f[primaryCount + i] = s; - dgMulAdd(primaryCount, f, f, &m_deltaForce[i * primaryCount], s); - } - - for (dgInt32 i = 0; i < m_rowCount; i++) { - dgInt32 index = m_matrixRowsIndex[i]; - dgRightHandSide* const rhs = &m_rightHandSide[index]; - const dgLeftHandSide* const row = &m_leftHandSide[index]; - const dgInt32 m0 = m_pairs[i].m_m0; - const dgInt32 m1 = m_pairs[i].m_m1; - - rhs->m_force += f[i]; - dgVector jointForce(f[i]); - internalForces[m0].m_linear += row->m_Jt.m_jacobianM0.m_linear * jointForce; - internalForces[m0].m_angular += row->m_Jt.m_jacobianM0.m_angular * jointForce; - internalForces[m1].m_linear += row->m_Jt.m_jacobianM1.m_linear * jointForce; - internalForces[m1].m_angular += row->m_Jt.m_jacobianM1.m_angular * jointForce; - } -} - -dgInt8* dgSkeletonContainer::CalculateBufferSizeInBytes (const dgJointInfo* const jointInfoArray) -{ - dgInt32 rowCount = 0; - dgInt32 auxiliaryRowCount = 0; - if (m_nodesOrder) { - for (dgInt32 i = 0; i < m_nodeCount - 1; i++) { - dgNode* const node = m_nodesOrder[i]; - rowCount += jointInfoArray[node->m_joint->m_index].m_pairCount; - auxiliaryRowCount += node->GetAuxiliaryRows(jointInfoArray, m_rightHandSide); - } - } - - dgInt32 extraAuxiliaryRows = 0; - const dgInt32 loopCount = m_loopCount + m_dynamicsLoopCount; - for (dgInt32 j = 0; j < loopCount; j++) { - const dgConstraint* const joint = m_loopingJoints[j]; - extraAuxiliaryRows += jointInfoArray[joint->m_index].m_pairCount; - } - rowCount += extraAuxiliaryRows; - auxiliaryRowCount+= extraAuxiliaryRows; - - dgInt32 size = sizeof (dgInt32) * rowCount; - size += sizeof (dgInt32) * rowCount; - size += sizeof (dgNodePair) * rowCount; - size += sizeof(dgFloat32) * auxiliaryRowCount * auxiliaryRowCount; // matrix11[auxiliaryRowCount * auxiliaryRowCount] - size += sizeof (dgFloat32) * auxiliaryRowCount * (rowCount - auxiliaryRowCount); - size += sizeof (dgFloat32) * auxiliaryRowCount * (rowCount - auxiliaryRowCount); - size = (size + 1024) & -0x10; - m_auxiliaryMemoryBuffer.ResizeIfNecessary((size + 1024) & -0x10); - return &m_auxiliaryMemoryBuffer[0]; -} - -void dgSkeletonContainer::InitMassMatrix(const dgJointInfo* const jointInfoArray, const dgLeftHandSide* const leftHandSide, dgRightHandSide* const rightHandSide, bool consideredCloseLoop) -{ - D_TRACKTIME(); - dgInt32 rowCount = 0; - dgInt32 auxiliaryCount = 0; - m_leftHandSide = leftHandSide; - m_rightHandSide = rightHandSide; - m_consideredCloseLoop = consideredCloseLoop ? 1 : 0; - - dgSpatialMatrix* const bodyMassArray = dgAlloca (dgSpatialMatrix, m_nodeCount); - dgSpatialMatrix* const jointMassArray = dgAlloca (dgSpatialMatrix, m_nodeCount); - - if (m_nodesOrder) { - for (dgInt32 i = 0; i < m_nodeCount - 1; i++) { - dgNode* const node = m_nodesOrder[i]; - const dgJointInfo& info = jointInfoArray[node->m_joint->m_index]; - rowCount += info.m_pairCount; - auxiliaryCount += node->Factorize(jointInfoArray, leftHandSide, rightHandSide, bodyMassArray, jointMassArray); - } - m_nodesOrder[m_nodeCount - 1]->Factorize(jointInfoArray, leftHandSide, rightHandSide, bodyMassArray, jointMassArray); - } - m_rowCount = dgInt16 (rowCount); - m_auxiliaryRowCount = dgInt16 (auxiliaryCount); - - dgInt32 loopRowCount = 0; - const dgInt32 loopCount = m_loopCount + m_dynamicsLoopCount; - for (dgInt32 j = 0; j < loopCount; j++) { - const dgConstraint* const joint = m_loopingJoints[j]; - loopRowCount += jointInfoArray[joint->m_index].m_pairCount; - } - m_loopRowCount = dgInt16 (loopRowCount); - m_rowCount += m_loopRowCount; - m_auxiliaryRowCount += m_loopRowCount; - - if (m_auxiliaryRowCount && m_consideredCloseLoop) { - InitLoopMassMatrix(jointInfoArray); - } -} - -void dgSkeletonContainer::CalculateJointForce(dgJointInfo* const jointInfoArray, const dgBodyInfo* const bodyArray, dgJacobian* const internalForces) -{ - D_TRACKTIME(); - dgForcePair* const force = dgAlloca(dgForcePair, m_nodeCount); - dgForcePair* const accel = dgAlloca(dgForcePair, m_nodeCount); - - CalculateJointAccel(jointInfoArray, internalForces, accel); - CalculateForce(force, accel); - if (m_auxiliaryRowCount && m_consideredCloseLoop) { - SolveAuxiliary (jointInfoArray, internalForces, accel, force); - } else { - UpdateForces(jointInfoArray, internalForces, force); - } -} - diff --git a/thirdparty/src/newton/dgPhysics/dgSkeletonContainer.h b/thirdparty/src/newton/dgPhysics/dgSkeletonContainer.h deleted file mode 100644 index 5d59d1768..000000000 --- a/thirdparty/src/newton/dgPhysics/dgSkeletonContainer.h +++ /dev/null @@ -1,119 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_SKELETON_CONTAINER_H__ -#define _DG_SKELETON_CONTAINER_H__ - -#include "dgConstraint.h" -#include "dgContact.h" -#include "dgBilateralConstraint.h" - -class dgDynamicBody; - -class dgSkeletonContainer -{ - public: - class dgNode; - class dgNodePair; - class dgForcePair; - class dgMatriData; - class dgBodyJointMatrixDataPair; - - DG_CLASS_ALLOCATOR(allocator) - dgSkeletonContainer(dgWorld* const world, dgDynamicBody* const rootBody); - virtual ~dgSkeletonContainer(); - - dgWorld* GetWorld() const; - dgInt32 GetJointCount () const {return m_nodeCount - 1;} - dgNode* AddChild (dgBilateralConstraint* const joint, dgNode* const parent); - void RemoveLoopJoint(dgBilateralConstraint* const joint); - void Finalize (dgInt32 loopJoints, dgBilateralConstraint** const loopJointArray); - - dgNode* GetRoot () const; - dgDynamicBody* GetBody(dgNode* const node) const; - dgBilateralConstraint* GetJoint(dgNode* const node) const; - dgNode* GetParent (dgNode* const node) const; - dgNode* GetFirstChild (dgNode* const parent) const; - dgNode* GetNextSiblingChild (dgNode* const sibling) const; - - void ClearSelfCollision(); - void AddSelfCollisionJoint(dgConstraint* const joint); - - dgInt32 GetLru() const { return m_lru; } - void SetLru(dgInt32 lru) { m_lru = lru; } - - virtual void CalculateJointForce (dgJointInfo* const jointInfoArray, const dgBodyInfo* const bodyArray, dgJacobian* const internalForces); - virtual void InitMassMatrix (const dgJointInfo* const jointInfoArray, const dgLeftHandSide* const matrixRow, dgRightHandSide* const rightHandSide, bool m_consideredCloseLoop = true); - - private: - bool SanityCheck(const dgForcePair* const force, const dgForcePair* const accel) const; - void ConditionMassMatrix() const; - void RebuildMassMatrix(const dgFloat32* const diagDamp) const; - void CalculateLoopMassMatrixCoefficients(dgFloat32* const diagDamp); - - DG_INLINE void CalculateForce(dgForcePair* const force, const dgForcePair* const accel) const; - DG_INLINE void SolveBackward(dgForcePair* const force) const; - DG_INLINE void SolveForward(dgForcePair* const force, const dgForcePair* const accel, dgInt32 startNode = 0) const; - DG_INLINE void UpdateForces(dgJointInfo* const jointInfoArray, dgJacobian* const internalForces, const dgForcePair* const force) const; - DG_INLINE void CalculateJointAccel (dgJointInfo* const jointInfoArray, const dgJacobian* const internalForces, dgForcePair* const accel) const; - - dgNode* FindNode(dgDynamicBody* const node) const; - void SortGraph(dgNode* const root, dgInt32& index); - - void InitLoopMassMatrix (const dgJointInfo* const jointInfoArray); - dgInt8* CalculateBufferSizeInBytes (const dgJointInfo* const jointInfoArray); - void SolveAuxiliary (const dgJointInfo* const jointInfoArray, dgJacobian* const internalForces, const dgForcePair* const accel, dgForcePair* const force) const; - void SolveLcp(dgInt32 stride, dgInt32 size, const dgFloat32* const matrix, const dgFloat32* const x0, dgFloat32* const x, const dgFloat32* const b, const dgFloat32* const low, const dgFloat32* const high, const dgInt32* const normalIndex) const; - void SolveBlockLcp(dgInt32 size, dgInt32 blockSize, const dgFloat32* const x0, dgFloat32* const x, dgFloat32* const b, const dgFloat32* const low, const dgFloat32* const high, const dgInt32* const normalIndex) const; - void FactorizeMatrix(dgInt32 size, dgInt32 stride, dgFloat32* const matrix, dgFloat32* const diagDamp) const; - - dgWorld* m_world; - dgNode* m_skeleton; - dgNode** m_nodesOrder; - dgNodePair* m_pairs; - dgFloat32* m_deltaForce; - dgFloat32* m_massMatrix11; - dgFloat32* m_massMatrix10; - - dgRightHandSide* m_rightHandSide; - const dgLeftHandSide* m_leftHandSide; - dgInt32* m_frictionIndex; - dgInt32* m_matrixRowsIndex; - dgSkeletonList::dgListNode* m_listNode; - dgArray<dgConstraint*> m_loopingJoints; - dgArray<dgInt8> m_auxiliaryMemoryBuffer; - dgInt32 m_lru; - dgInt32 m_blockSize; - dgInt16 m_nodeCount; - dgInt16 m_loopCount; - dgInt16 m_dynamicsLoopCount; - dgInt16 m_rowCount; - dgInt16 m_loopRowCount; - dgInt16 m_auxiliaryRowCount; - dgInt16 m_consideredCloseLoop; - - friend class dgWorld; - friend class dgParallelBodySolver; - friend class dgWorldDynamicUpdate; -}; - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgSlidingConstraint.cpp b/thirdparty/src/newton/dgPhysics/dgSlidingConstraint.cpp deleted file mode 100644 index 5ca6e510a..000000000 --- a/thirdparty/src/newton/dgPhysics/dgSlidingConstraint.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgSlidingConstraint.h" - - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -dgSlidingConstraint::dgSlidingConstraint () - :dgBilateralConstraint() -{ - dgAssert ((((dgUnsigned64) &m_localMatrix0) & 15) == 0); - - m_localMatrix0 = dgGetIdentityMatrix(); - m_localMatrix1 = dgGetIdentityMatrix(); - - m_maxDOF = 6; - m_constId = m_sliderConstraint; - m_posit = dgFloat32 (0.0f); - m_jointAccelFnt = NULL; -} - -dgSlidingConstraint::~dgSlidingConstraint () -{ -} - -/* -dgSlidingConstraint* dgSlidingConstraint::Create(dgWorld* world) -{ - dgSlidingConstraint* constraint; - - dgSlidingConstraintArray& array = *world; -// constraint = dgSlidingConstraintArray::GetPool().GetElement(); - constraint = array.GetElement(); - - dgAssert ((((dgUnsigned64) &constraint->m_localMatrix0) & 15) == 0); - - constraint->Init (); - constraint->m_maxDOF = 6; - constraint->m_constId = dgSliderConstraintId; - constraint->m_posit = dgFloat32 (0.0f); - constraint->m_jointAccelFnt = NULL; - return constraint; -} - -void dgSlidingConstraint::Remove(dgWorld* world) -{ - dgSlidingConstraintArray& array = *world; - dgBilateralConstraint::Remove (world); -// dgSlidingConstraintArray::GetPool().RemoveElement (this); - array.RemoveElement (this); -} -*/ - -void dgSlidingConstraint::SetJointParameterCallback (dgSlidingJointAcceleration callback) -{ - m_jointAccelFnt = callback; -} - -dgFloat32 dgSlidingConstraint::GetJointPosit () const -{ - return m_posit; -} - -dgFloat32 dgSlidingConstraint::GetJointVeloc () const -{ - dgAssert (m_body0); - dgAssert (m_body1); - dgVector dir (m_body0->GetMatrix().RotateVector (m_localMatrix0[0])); - const dgVector& veloc0 = m_body0->GetVelocity(); - const dgVector& veloc1 = m_body1->GetVelocity(); - return dir.DotProduct(veloc0 - veloc1).GetScalar(); -} - -dgFloat32 dgSlidingConstraint::CalculateStopAccel (dgFloat32 distance, const dgJointCallbackParam* param) const -{ - dgFloat32 accel; - dgFloat32 speed; - dgFloat32 penetrationErr; - - accel = dgFloat32 (0.0f); - if (m_posit > distance) { - speed = GetJointVeloc (); - if (speed < dgFloat32 (0.0f)) { - speed = dgFloat32 (0.0f); - } - penetrationErr = (distance - m_posit); - accel = dgFloat32 (100.0f) * penetrationErr - speed * dgFloat32 (1.01f) / param->m_timestep; - - } else if (m_posit < distance) { - speed = GetJointVeloc (); - if (speed > dgFloat32 (0.0f)) { - speed = dgFloat32 (0.0f); - } - penetrationErr = distance - m_posit; - dgAssert (penetrationErr >= dgFloat32 (0.0f)); - accel = dgFloat32 (100.0f) * penetrationErr - speed * dgFloat32 (1.01f) / param->m_timestep; - } - return accel; -} - -dgVector dgSlidingConstraint::GetJointForce () const -{ - dgMatrix matrix0; - dgMatrix matrix1; - - CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1); - return dgVector (matrix0.m_up.Scale (m_jointForce[0].m_force) + - matrix0.m_right.Scale (m_jointForce[1].m_force) + - matrix0.m_up.Scale (m_jointForce[2].m_force) + - matrix0.m_right.Scale (m_jointForce[3].m_force) + - matrix0.m_right.Scale (m_jointForce[4].m_force)); -} - - -dgUnsigned32 dgSlidingConstraint::JacobianDerivative (dgContraintDescritor& params) -{ - dgMatrix matrix0; - dgMatrix matrix1; - - //dgVector angle (CalculateGlobalMatrixAndAngle (matrix0, matrix1)); - CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1); - m_posit = matrix0.m_front.DotProduct(matrix0.m_posit - matrix1.m_posit).GetScalar(); - matrix1.m_posit += matrix1.m_front.Scale (m_posit); - - dgAssert (dgAbs (dgFloat32 (1.0f) - matrix0.m_front.DotProduct(matrix0.m_front).GetScalar()) < dgFloat32 (1.0e-5f)); - dgAssert (dgAbs (dgFloat32 (1.0f) - matrix0.m_up.DotProduct(matrix0.m_up).GetScalar()) < dgFloat32 (1.0e-5f)); - dgAssert (dgAbs (dgFloat32 (1.0f) - matrix0.m_right.DotProduct(matrix0.m_right).GetScalar()) < dgFloat32 (1.0e-5f)); - - const dgVector& dir1 = matrix0.m_up; - const dgVector& dir2 = matrix0.m_right; - - dgVector p0 (matrix0.m_posit); - dgVector p1 (matrix1.m_posit + matrix1.m_front.Scale (matrix1.m_front.DotProduct(p0 - matrix1.m_posit).GetScalar())); - - dgVector q0 (p0 + matrix0.m_front.Scale(MIN_JOINT_PIN_LENGTH)); - dgVector q1 (p1 + matrix1.m_front.Scale(MIN_JOINT_PIN_LENGTH)); - - dgVector r0 (p0 + matrix0.m_up.Scale(MIN_JOINT_PIN_LENGTH)); - dgVector r1 (p1 + matrix1.m_up.Scale(MIN_JOINT_PIN_LENGTH)); - - dgPointParam pointDataP; - dgPointParam pointDataQ; - dgPointParam pointDataR; - InitPointParam (pointDataP, m_defualtDiagonalRegularizer, p0, p1); - InitPointParam (pointDataQ, m_defualtDiagonalRegularizer, q0, q1); - InitPointParam (pointDataR, m_defualtDiagonalRegularizer, r0, r1); - - CalculatePointDerivative (0, params, dir1, pointDataP, &m_jointForce[0]); - CalculatePointDerivative (1, params, dir2, pointDataP, &m_jointForce[1]); - CalculatePointDerivative (2, params, dir1, pointDataQ, &m_jointForce[2]); - CalculatePointDerivative (3, params, dir2, pointDataQ, &m_jointForce[3]); - CalculatePointDerivative (4, params, dir2, pointDataR, &m_jointForce[4]); - - dgInt32 ret = 5; - if (m_jointAccelFnt) { - dgJointCallbackParam axisParam; - axisParam.m_accel = dgFloat32 (0.0f); - axisParam.m_timestep = params.m_timestep; - axisParam.m_minFriction = DG_MIN_BOUND; - axisParam.m_maxFriction = DG_MAX_BOUND; - - if (m_jointAccelFnt (*this, &axisParam)) { - if ((axisParam.m_minFriction > DG_MIN_BOUND) || (axisParam.m_maxFriction < DG_MAX_BOUND)) { - params.m_forceBounds[5].m_low = axisParam.m_minFriction; - params.m_forceBounds[5].m_upper = axisParam.m_maxFriction; - params.m_forceBounds[5].m_normalIndex = DG_INDEPENDENT_ROW; - } - - CalculatePointDerivative (5, params, matrix0.m_front, pointDataP, &m_jointForce[5]); - SetMotorAcceleration (5, axisParam.m_accel, params); - ret = 6; - } - } - - return dgUnsigned32 (ret); -} - - - diff --git a/thirdparty/src/newton/dgPhysics/dgSlidingConstraint.h b/thirdparty/src/newton/dgPhysics/dgSlidingConstraint.h deleted file mode 100644 index 4e41c455c..000000000 --- a/thirdparty/src/newton/dgPhysics/dgSlidingConstraint.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -#if !defined(AFX_DGSLIDINGCONSTRAINT_H__3FF7D7AA_90CC_4BA5_B2A4_D3BA51AD2FFD_H) -#define AFX_DGSLIDINGCONSTRAINT_H__3FF7D7AA_90CC_4BA5_B2A4_D3BA51AD2FFD_H -#include "dgBilateralConstraint.h" - -//template<class T> class dgPool; - -class dgSlidingConstraint; -typedef dgUnsigned32 (dgApi *dgSlidingJointAcceleration) (const dgSlidingConstraint& hinge, dgJointCallbackParam* param); - -class dgSlidingConstraint: public dgBilateralConstraint -{ - public: - dgFloat32 GetJointPosit () const; - dgFloat32 GetJointVeloc () const; - dgVector GetJointForce () const; - dgFloat32 CalculateStopAccel (dgFloat32 distance, const dgJointCallbackParam* param) const; - void SetJointParameterCallback (dgSlidingJointAcceleration callback); - - private: - dgSlidingConstraint(); - virtual ~dgSlidingConstraint(); - - virtual dgUnsigned32 JacobianDerivative (dgContraintDescritor& params); - virtual void Serialize (dgSerialize serializeCallback, void* const userData) {dgAssert (0);} - - dgMatrix m_localMatrix0; - dgMatrix m_localMatrix1; - - dgFloat32 m_posit; - dgSlidingJointAcceleration m_jointAccelFnt; - -//#ifdef _NEWTON_USE_DOUBLE -// dgUnsigned32 m_reserve[1]; -//#else -// dgUnsigned32 m_reserve[2]; -//#endif - - friend class dgWorld; -// friend class dgPool<dgSlidingConstraint>; -}; - -/* -class dgSlidingConstraintArray: public dgPoolContainer<dgSlidingConstraint> -{ -}; -*/ - -#endif // !defined(AFX_DGSLIDINGCONSTRAINT_H__3FF7D7AA_90CC_4BA5_B2A4_D3BA51AD2FFD_H) - diff --git a/thirdparty/src/newton/dgPhysics/dgUniversalConstraint.cpp b/thirdparty/src/newton/dgPhysics/dgUniversalConstraint.cpp deleted file mode 100644 index 467c4e482..000000000 --- a/thirdparty/src/newton/dgPhysics/dgUniversalConstraint.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgUniversalConstraint.h" - - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -dgUniversalConstraint::dgUniversalConstraint () - :dgBilateralConstraint() -{ - dgAssert ((((dgUnsigned64) &m_localMatrix0) & 15) == 0); - - m_localMatrix0 = dgGetIdentityMatrix(); - m_localMatrix1 = dgGetIdentityMatrix(); - - m_maxDOF = 6; - m_constId = m_universalConstraint; - - m_angle0 = dgFloat32 (0.0f); - m_angle1 = dgFloat32 (0.0f); - m_jointAccelFnt = NULL; -} - -dgUniversalConstraint::~dgUniversalConstraint () -{ -} - -/* -dgUniversalConstraint* dgUniversalConstraint::Create(dgWorld* world) -{ - dgUniversalConstraint* constraint; - -// constraint = dgUniversalConstraintArray::GetPool().GetElement(); - - dgUniversalConstraintArray& array = * world; - constraint = array.GetElement(); - - dgAssert ((((dgUnsigned64) &constraint->m_localMatrix0) & 15) == 0); - constraint->Init (); - constraint->m_maxDOF = 6; - constraint->m_constId = dgUniversalConstraintId; - - constraint->m_angle0 = dgFloat32 (0.0f); - constraint->m_angle1 = dgFloat32 (0.0f); - constraint->m_jointAccelFnt = NULL; - return constraint; -} - -void dgUniversalConstraint::Remove(dgWorld* world) -{ - dgUniversalConstraintArray& array = * world; - - dgBilateralConstraint::Remove (world); -// dgUniversalConstraintArray::GetPool().RemoveElement (this); - array.RemoveElement (this); -} -*/ - -void dgUniversalConstraint::SetJointParameterCallback (dgUniversalJointAcceleration callback) -{ - m_jointAccelFnt = callback; -} - - -dgFloat32 dgUniversalConstraint::GetJointAngle0 () const -{ - return m_angle0; -} - -dgFloat32 dgUniversalConstraint::GetJointAngle1 () const -{ - return m_angle1; -} - - -dgFloat32 dgUniversalConstraint::GetJointOmega0 () const -{ - dgAssert (m_body0); - dgAssert (m_body1); - - dgVector dir (m_body0->GetMatrix().RotateVector (m_localMatrix0[0])); - const dgVector& omega0 = m_body0->GetOmega(); - const dgVector& omega1 = m_body1->GetOmega(); - -// dgVector omega1 (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f)); -// if (m_body1) { -// omega1 = m_body1->GetOmega(); -// } - return dir.DotProduct(omega0 - omega1).GetScalar(); -} - -dgFloat32 dgUniversalConstraint::GetJointOmega1 () const -{ - dgAssert (m_body0); - dgAssert (m_body1); - - dgVector dir (m_body1->GetMatrix().RotateVector (m_localMatrix1[1])); - const dgVector& omega0 = m_body0->GetOmega(); - const dgVector& omega1 = m_body1->GetOmega(); - -// dgMatrix matrix (dgGetIdentityMatrix()); -// if (m_body1) { -// matrix = m_body1->GetMatrix(); -// omega1 = m_body1->GetOmega(); -// } -// dgVector dir (matrix.RotateVector (m_localMatrix1[1])); - - return dir.DotProduct(omega0 - omega1).GetScalar(); -} - -dgFloat32 dgUniversalConstraint::CalculateStopAlpha0 (dgFloat32 angle, const dgJointCallbackParam* param) const -{ - dgFloat32 alpha; - dgFloat32 omega; - dgFloat32 penetrationErr; - - alpha = dgFloat32 (0.0f); - if (m_angle0 > angle) { - omega = GetJointOmega0 (); - if (omega < dgFloat32 (0.0f)) { - omega = dgFloat32 (0.0f); - } - penetrationErr = angle - m_angle0; - alpha = 100.0f * penetrationErr - omega * 1.01f / param->m_timestep; - - } else if (m_angle0 < angle) { - omega = GetJointOmega0 (); - if (omega > dgFloat32 (0.0f)) { - omega = dgFloat32 (0.0f); - } - - penetrationErr = angle - m_angle0; - alpha = 100.0f * penetrationErr - omega * 1.01f / param->m_timestep; - } - return alpha; - -} - -dgFloat32 dgUniversalConstraint::CalculateStopAlpha1 (dgFloat32 angle, const dgJointCallbackParam* param) const -{ - dgFloat32 alpha; - dgFloat32 omega; - dgFloat32 penetrationErr; - - alpha = dgFloat32 (0.0f); - if (m_angle1 > angle) { - omega = GetJointOmega1 (); - if (omega > dgFloat32 (0.0f)) { - omega = dgFloat32 (0.0f); - } - penetrationErr = m_angle1 - angle; -// alpha = (penetrationErr + omega * 1.01f) / param->m_timestep; - alpha = penetrationErr * 100.0f - omega * 1.01f / param->m_timestep; - } else if (m_angle1 < angle) { - omega = GetJointOmega1 (); - if (omega < dgFloat32 (0.0f)) { - omega = dgFloat32 (0.0f); - } - - penetrationErr = m_angle1 - angle; -// alpha = (penetrationErr + omega * 1.01f) / param->m_timestep; - alpha = penetrationErr * 100.0f - omega * 1.01f / param->m_timestep; - } - return alpha; -} - - -dgVector dgUniversalConstraint::GetJointForce () const -{ - dgMatrix matrix0; - dgMatrix matrix1; - - CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1); - - return dgVector (matrix0.m_up.Scale (m_jointForce[0].m_force) + - matrix0.m_right.Scale (m_jointForce[1].m_force) + - matrix0.m_up.Scale (m_jointForce[2].m_force) + - matrix0.m_right.Scale (m_jointForce[3].m_force)); -} - -dgUnsigned32 dgUniversalConstraint::JacobianDerivative (dgContraintDescritor& params) -{ - dgMatrix matrix0; - dgMatrix matrix1; - dgFloat32 sinAngle; - dgFloat32 cosAngle; - dgInt32 ret; - - CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1); - - const dgVector& dir0 = matrix0.m_front; - const dgVector& dir1 = matrix1.m_up; - dgVector dir2 (dir0.CrossProduct(dir1)); - - dgVector dir3 (dir2.CrossProduct(dir0)); - dir3 = dir3.Normalize(); - - const dgVector& p0 = matrix0.m_posit; - const dgVector& p1 = matrix1.m_posit; - - dgVector q0 (p0 + dir3.Scale(MIN_JOINT_PIN_LENGTH)); - dgVector q1 (p1 + dir1.Scale(MIN_JOINT_PIN_LENGTH)); - - dgPointParam pointDataP; - dgPointParam pointDataQ; - InitPointParam (pointDataP, m_defualtDiagonalRegularizer, p0, p1); - InitPointParam (pointDataQ, m_defualtDiagonalRegularizer, q0, q1); - - CalculatePointDerivative (0, params, dir0, pointDataP, &m_jointForce[0]); - CalculatePointDerivative (1, params, dir1, pointDataP, &m_jointForce[1]); - CalculatePointDerivative (2, params, dir2, pointDataP, &m_jointForce[2]); - CalculatePointDerivative (3, params, dir0, pointDataQ, &m_jointForce[3]); - ret = 4; - - -// dgVector sinAngle0 (matrix1.m_up * matrix0.m_up); -// m_angle0 = dgAsin (ClampValue (sinAngle0 % dir0, -0.9999999f, 0.9999999f)); -// if ((matrix0.m_up % matrix1.m_up) < dgFloat32 (0.0f)) { -// m_angle0 = (m_angle0 >= dgFloat32 (0.0f)) ? dgPI - m_angle0 : dgPI + m_angle0; -// } - - sinAngle = matrix0.m_front.DotProduct(matrix1.m_up.CrossProduct(matrix0.m_up)).GetScalar(); - cosAngle = matrix0.m_up.DotProduct(matrix1.m_up).GetScalar(); -// dgAssert (dgAbs (m_angle0 - dgAtan2 (sinAngle, cosAngle)) < 1.0e-1f); - m_angle0 = dgAtan2 (sinAngle, cosAngle); - -// dgVector sinAngle1 (matrix0.m_front * matrix1.m_front); -// m_angle1 = dgAsin (ClampValue (sinAngle1 % dir1, -0.9999999f, 0.9999999f)); -// if ((matrix0.m_front % matrix1.m_front) < dgFloat32 (0.0f)) { -// m_angle1 = (m_angle1 >= dgFloat32 (0.0f)) ? dgPI - m_angle1 : dgPI + m_angle1; -// } - - sinAngle = matrix1.m_up.DotProduct(matrix0.m_front.CrossProduct(matrix1.m_front)).GetScalar(); - cosAngle = matrix0.m_front.DotProduct(matrix1.m_front).GetScalar(); -// dgAssert (dgAbs (m_angle1 - dgAtan2 (sinAngle, cosAngle)) < 1.0e-1f); - m_angle1 = dgAtan2 (sinAngle, cosAngle); - - if (m_jointAccelFnt) { - dgUnsigned32 code; - dgJointCallbackParam axisParam[2]; - - // linear acceleration - axisParam[0].m_accel = dgFloat32 (0.0f); - axisParam[0].m_timestep = params.m_timestep; - axisParam[0].m_minFriction = DG_MIN_BOUND; - axisParam[0].m_maxFriction = DG_MAX_BOUND; - - // angular acceleration - axisParam[1].m_accel = dgFloat32 (0.0f); - axisParam[1].m_timestep = params.m_timestep; - axisParam[1].m_minFriction = DG_MIN_BOUND; - axisParam[1].m_maxFriction = DG_MAX_BOUND; - - code = m_jointAccelFnt (*this, axisParam); - if (code & 1) { - if ((axisParam[0].m_minFriction > DG_MIN_BOUND) || (axisParam[0].m_maxFriction < DG_MAX_BOUND)) { - params.m_forceBounds[ret].m_low = axisParam[0].m_minFriction; - params.m_forceBounds[ret].m_upper = axisParam[0].m_maxFriction; - params.m_forceBounds[ret].m_normalIndex = DG_INDEPENDENT_ROW; - } - -// CalculatePointDerivative (ret, params, dir0, pointDataP, &m_jointForce[ret]); - CalculateAngularDerivative (ret, params, dir0, m_defualtDiagonalRegularizer, dgFloat32 (0.0f), &m_jointForce[ret]); - SetMotorAcceleration (ret, axisParam[0].m_accel, params); - ret ++; - } - - if (code & 2) { - if ((axisParam[1].m_minFriction > DG_MIN_BOUND) || (axisParam[1].m_maxFriction < DG_MAX_BOUND)) { - params.m_forceBounds[ret].m_low = axisParam[1].m_minFriction; - params.m_forceBounds[ret].m_upper = axisParam[1].m_maxFriction; - params.m_forceBounds[ret].m_normalIndex = DG_INDEPENDENT_ROW; - } - CalculateAngularDerivative (ret, params, dir1, m_defualtDiagonalRegularizer, dgFloat32 (0.0f), &m_jointForce[ret]); - SetMotorAcceleration (ret, axisParam[1].m_accel, params); - ret ++; - - } - } - return dgUnsigned32 (ret); -} - - - diff --git a/thirdparty/src/newton/dgPhysics/dgUniversalConstraint.h b/thirdparty/src/newton/dgPhysics/dgUniversalConstraint.h deleted file mode 100644 index 96437aba6..000000000 --- a/thirdparty/src/newton/dgPhysics/dgUniversalConstraint.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -#if !defined(AFX_DGUNIVERSALCONSTRAINT_H__3FA456TR_INCLUDED) -#define AFX_DGUNIVERSALCONSTRAINT_H__3FA456TR_INCLUDED -#include "dgBilateralConstraint.h" - -//template<class T> class dgPool; - -class dgUniversalConstraint; - - -typedef dgUnsigned32 (dgApi *dgUniversalJointAcceleration) (const dgUniversalConstraint& hinge, dgJointCallbackParam* param); - -class dgUniversalConstraint: public dgBilateralConstraint -{ - public: - dgFloat32 GetJointAngle0 () const; - dgFloat32 GetJointAngle1 () const; - dgFloat32 GetJointOmega0 () const; - dgFloat32 GetJointOmega1 () const; - - dgVector GetJointForce () const; - dgFloat32 CalculateStopAlpha0 (dgFloat32 angle, const dgJointCallbackParam* param) const; - dgFloat32 CalculateStopAlpha1 (dgFloat32 angle, const dgJointCallbackParam* param) const; - void SetJointParameterCallback (dgUniversalJointAcceleration callback); - - private: - virtual dgUnsigned32 JacobianDerivative (dgContraintDescritor& params); - virtual void Serialize (dgSerialize serializeCallback, void* const userData) {dgAssert (0);} - - dgUniversalConstraint(); - virtual ~dgUniversalConstraint(); - - dgMatrix m_localMatrix0; - dgMatrix m_localMatrix1; - - dgFloat32 m_angle0; - dgFloat32 m_angle1; - dgUniversalJointAcceleration m_jointAccelFnt; - -//#ifdef _NEWTON_USE_DOUBLE -// dgUnsigned32 m_reserve[3]; -//#else -// dgUnsigned32 m_reserve[1]; -//#endif - - - friend class dgWorld; -// friend class dgPool<dgUniversalConstraint>; -}; - -//class dgUniversalConstraintArray: public dgPoolContainer<dgUniversalConstraint> -//{ -//}; - -#endif // !defined(AFX_DGUNIVERSALCONSTRAINT_H__3FA456TR_INCLUDED) - diff --git a/thirdparty/src/newton/dgPhysics/dgUpVectorConstraint.cpp b/thirdparty/src/newton/dgPhysics/dgUpVectorConstraint.cpp deleted file mode 100644 index b0f6f4bf6..000000000 --- a/thirdparty/src/newton/dgPhysics/dgUpVectorConstraint.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgUpVectorConstraint.h" - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -dgUpVectorConstraint::dgUpVectorConstraint () - :dgBilateralConstraint() -{ - dgAssert ( dgInt32 (sizeof (dgUpVectorConstraint) & 15) == 0); - dgAssert ((((dgUnsigned64) &m_localMatrix0) & 15) == 0); - - m_localMatrix0 = dgGetIdentityMatrix(); - m_localMatrix1 = dgGetIdentityMatrix(); - - SetStiffness (dgFloat32 (0.0f)); - m_maxDOF = 2; - m_constId = m_upVectorConstraint; - m_callBack = NULL; -} - -dgUpVectorConstraint::~dgUpVectorConstraint () -{ -} - -void dgUpVectorConstraint::InitPinDir (const dgVector& pin) -{ - - const dgMatrix& matrix = m_body0->GetMatrix(); - - dgVector pivot (matrix.m_posit); - SetPivotAndPinDir (pivot, pin, m_localMatrix0, m_localMatrix1); - -} - -void dgUpVectorConstraint::SetPinDir (const dgVector& pin) -{ - m_localMatrix1 = dgMatrix (pin); -} - -dgVector dgUpVectorConstraint::GetPinDir () const -{ - return m_localMatrix1.m_front; -} - - -void dgUpVectorConstraint::SetJointParameterCallback (dgUpVectorJointCallback callback) -{ - m_callBack = callback; -} - - -dgUnsigned32 dgUpVectorConstraint::JacobianDerivative (dgContraintDescritor& params) -{ - dgMatrix matrix0; - dgMatrix matrix1; - CalculateGlobalMatrixAndAngle (m_localMatrix0, m_localMatrix1, matrix0, matrix1); - - dgVector lateralDir (matrix0.m_front.CrossProduct(matrix1.m_front)); - - dgInt32 ret = 0; - dgFloat32 mag = lateralDir.DotProduct(lateralDir).GetScalar(); - if (mag > dgFloat32 (1.0e-6f)) { - mag = dgSqrt (mag); - lateralDir = lateralDir.Scale (dgFloat32 (1.0f) / mag); - dgFloat32 angle = dgAsin (mag); - CalculateAngularDerivative (0, params, lateralDir, m_defualtDiagonalRegularizer, angle, &m_jointForce[0]); - - dgVector frontDir (lateralDir.CrossProduct(matrix1.m_front)); - CalculateAngularDerivative (1, params, frontDir, m_defualtDiagonalRegularizer, dgFloat32 (0.0f), &m_jointForce[1]); - ret = 2; - } else { - CalculateAngularDerivative (0, params, matrix0.m_up, m_defualtDiagonalRegularizer, 0.0, &m_jointForce[0]); - CalculateAngularDerivative (1, params, matrix0.m_right, m_defualtDiagonalRegularizer, dgFloat32 (0.0f), &m_jointForce[1]); - ret = 2; - } - return dgUnsigned32 (ret); -} - - - diff --git a/thirdparty/src/newton/dgPhysics/dgUpVectorConstraint.h b/thirdparty/src/newton/dgPhysics/dgUpVectorConstraint.h deleted file mode 100644 index cc2923d81..000000000 --- a/thirdparty/src/newton/dgPhysics/dgUpVectorConstraint.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 __DGUPVECTORCONSTRAINT__ -#define __DGUPVECTORCONSTRAINT__ -#include "dgBilateralConstraint.h" - -//template<class T> class dgPool; - -class dgUpVectorConstraint; - -typedef dgUnsigned32 (dgApi *dgUpVectorJointCallback) (const dgUpVectorConstraint& upVector); - -class dgUpVectorConstraint: public dgBilateralConstraint -{ - public: - void SetJointParameterCallback (dgUpVectorJointCallback callback); - void InitPinDir (const dgVector& pin); - - dgVector GetPinDir () const; - void SetPinDir (const dgVector& pin); - - private: - dgUpVectorConstraint(); - virtual ~dgUpVectorConstraint(); - - virtual dgUnsigned32 JacobianDerivative (dgContraintDescritor& params); - virtual void Serialize (dgSerialize serializeCallback, void* const userData) {dgAssert (0);} - - dgUpVectorJointCallback m_callBack; - - dgMatrix m_localMatrix0; - dgMatrix m_localMatrix1; -// dgUnsigned32 m_reserve[3]; - - friend class dgWorld; -// friend class dgPool<dgUpVectorConstraint>; -}; - -/* -class dgUpVectorConstraintArray: public dgPoolContainer<dgUpVectorConstraint> -{ -}; -*/ - -#endif // !defined(__DGUPVECTORCONSTRAINT_563GFT35684GT_H) - diff --git a/thirdparty/src/newton/dgPhysics/dgUserConstraint.cpp b/thirdparty/src/newton/dgPhysics/dgUserConstraint.cpp deleted file mode 100644 index 4c8d6a079..000000000 --- a/thirdparty/src/newton/dgPhysics/dgUserConstraint.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgWorld.h" -#include "dgUserConstraint.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -dgUserConstraint::dgUserConstraint(dgWorld* const world, dgBody* const body0, dgBody* const body1, dgInt32 constraintID) - :dgBilateralConstraint() -{ - m_maxDOF = 6; - m_enableCollision = false; - m_constId = dgUnsigned32 (m_unknownConstraint + constraintID); - m_body0 = body0; - m_body1 = body1; - m_userData = NULL; - m_destructor = NULL; - if (world) { - world->AttachConstraint(this, body0, body1); - } -} - -dgUserConstraint::~dgUserConstraint() -{ -} - -void dgUserConstraint::GetInfo (dgConstraintInfo* const info) const -{ - InitInfo (info); -} - - diff --git a/thirdparty/src/newton/dgPhysics/dgUserConstraint.h b/thirdparty/src/newton/dgPhysics/dgUserConstraint.h deleted file mode 100644 index d1b516628..000000000 --- a/thirdparty/src/newton/dgPhysics/dgUserConstraint.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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. -*/ - -#if !defined(AFX_DGUSERCONSTRAINT_H__97A0E0E3_C511_4761_9346_BAEC6E6322BA_H) -#define AFX_DGUSERCONSTRAINT_H__97A0E0E3_C511_4761_9346_BAEC6E6322BA_H - - -#include "dgBilateralConstraint.h" - -//class dgWorld; - -class dgUserConstraint: public dgBilateralConstraint -{ - public: - - protected: - virtual dgUnsigned32 JacobianDerivative (dgContraintDescritor& params) = 0; - virtual void Serialize (dgSerialize serializeCallback, void* const userData) = 0; - dgUserConstraint (dgWorld* const manager, dgBody* const dyn0, dgBody* const dyn1, dgInt32 constraintID); - - virtual void GetInfo (dgConstraintInfo* const info) const; - - virtual ~dgUserConstraint(); -}; - -#endif // !defined(AFX_DGUSERCONSTRAINT_H__97A0E0E3_C511_4761_9346_BAEC6E6322BA_H) - diff --git a/thirdparty/src/newton/dgPhysics/dgWorld.cpp b/thirdparty/src/newton/dgPhysics/dgWorld.cpp deleted file mode 100644 index 9074b2aa3..000000000 --- a/thirdparty/src/newton/dgPhysics/dgWorld.cpp +++ /dev/null @@ -1,1859 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgWorld.h" - -#include "dgDynamicBody.h" -#include "dgKinematicBody.h" -#include "dgCollisionBox.h" -#include "dgKinematicBody.h" -#include "dgCollisionNull.h" -#include "dgCollisionCone.h" -#include "dgCollisionScene.h" -#include "dgCollisionSphere.h" -#include "dgBroadPhaseMixed.h" -#include "dgCollisionCapsule.h" -#include "dgCollisionInstance.h" -#include "dgCollisionCompound.h" -#include "dgWorldDynamicUpdate.h" -#include "dgCollisionConvexHull.h" -#include "dgBroadPhaseSegregated.h" -#include "dgCollisionChamferCylinder.h" - -#include "dgUserConstraint.h" -#include "dgBallConstraint.h" -#include "dgHingeConstraint.h" -#include "dgSkeletonContainer.h" -#include "dgSlidingConstraint.h" -#include "dgUpVectorConstraint.h" -#include "dgUniversalConstraint.h" -#include "dgCorkscrewConstraint.h" - -#define DG_DEFAULT_SOLVER_ITERATION_COUNT 4 -#define DG_SYNC_THREAD 1 -#define DG_ASYNC_THREAD 2 - -/* -static dgInt32 TestSort(const dgInt32* const A, const dgInt32* const B, void* const) -{ - if (*A < *B) { - return -1; - } else if (*A > *B) { - return 1; - } - return 0; -} - -static void TestSort() -{ - int array[] = { 10, 10, 10, 10, 10, 5, 10, 10, 10, 10, 10, 10 }; - dgSort(array, sizeof(array) / sizeof(array[0]), TestSort); -} - - -static char *xxx[10] = {"bbbbbbbbbb", - "baaaaaaaab", - "babbbbbaab", - "babaaabaab", - "baaababaab", - "bbbaaabaab", - "bbbbaabaab", - "babbbbbaab", - "baaaaaaaab", - "bbbbbbbbbb"}; - -struct myPath: public dgPathFinder<dgInt32, float> -{ - dgInt32 goalx; - dgInt32 goaly; - myPath () - :dgPathFinder<dgInt32, float>(1024, 10) - { - for (int i = 0; i < 10; i ++) { - strcpy (&m_map[i][0], xxx[i]); - } - } - - const dgPathNode<dgInt32, float>* CalCulatePath (dgInt32 source, dgInt32 goal) - { - goalx = goal % 10; - goaly = goal / 10; - return dgPathFinder<dgInt32, float>::CalCulatePath (source, goal) ; - } - - - float GetCostFromParent(const dgPathNode<dgInt32, float>& node) const - { - dgInt32 x; - dgInt32 y; - dgInt32 x0; - dgInt32 y0; - dgInt32 x1; - dgInt32 y1; - dgInt32 id; - - id = node.GetId(); - x = id % 10; - y = id / 10; - - const dgPathNode<dgInt32, float>* parent = node.GetParent(); - id = parent->GetId(); - x0 = id % 10; - y0 = id / 10; - - const dgPathNode<dgInt32, float>* grandParent = parent->GetParent(); - x1 = 2 * x0 - x; - y1 = 2 * y0 - y; - if (grandParent) { - id = grandParent->GetId(); - x1 = id % 10; - y1 = id / 10; - } - - dgInt32 dx0; - dgInt32 dy0; - dgInt32 dx1; - dgInt32 dy1; - float penalty; - - dx0 = x0 - x; - dy0 = y0 - y; - dx1 = x1 - x0; - dy1 = y1 - y0; - penalty = 0.0f; - if (dx1 * dy0 - dx0 * dy1) { - penalty = dgFloat32(1.0f); - } - - static dgInt32 xxxx; - if (!xxxx){ - xxxx = 1; - penalty = 9.1f; - } - - return (xxx[y][x] == 'a') ? (dgFloat32(1.0f) + penalty): 50.0f; - } - - float GetEstimatedCostToGoal(dgInt32 id) const - { - dgInt32 x; - dgInt32 y; - - x = id % 10 - goalx; - y = id / 10 - goaly; - return dgSqrt ((float)(x * x + y * y)); - } - - dgInt32 EnumerateChildren(dgInt32 parent, dgInt32 array[]) const - { - dgInt32 x; - dgInt32 y; - - x = parent % 10; - y = parent / 10; - - array[0] = (y - 1) * 10 + x; - array[1] = (y - 0) * 10 + x - 1; - array[2] = (y + 1) * 10 + x; - array[3] = (y + 0) * 10 + x + 1; - return 4; - } - - char m_map[20][20]; -}; - - -static void TestAStart() -{ - myPath path; - const dgPathNode<dgInt32, float>* firtNode; - for (firtNode = path.CalCulatePath (5 * 10 + 3, 4 * 10 + 8); firtNode; firtNode= firtNode->GetNext()) { - dgInt32 id; - dgInt32 x; - dgInt32 y; - - id = firtNode->GetId(); - x = id % 10; - y = id / 10; - path.m_map[y][x] = '_'; - } -} - - -class TestGradient: public dgSymmetricConjugateGradientSolver<dgFloat32> -{ - public: - TestGradient() - :dgSymmetricConjugateGradientSolver() - { - dgFloat32 xxx[4]; - dgFloat32 b[4]; - xxx[0] = 1.0f; xxx[1] = 2.0f; xxx[2] = 3.0f;; xxx[3] = 4.0f; - dgCovarianceMatrix(4, &A[0][0], xxx, xxx); - A[0][0] = 10.0f; A[1][1] = 10.0f; A[2][2] = 10.0f; - dgAssert(dgTestPSDmatrix(4, 4, &A[0][0])); - dgMatrixTimeVector(4, &A[0][0], xxx, b); - - dgFloat32 x[4]; - x[0] = 0.0f; x[1] = 0.0f; x[2] = 0.0f;; x[3] = 0.0f; - Solve(4, 1.0e-6f, x, b); - } - - virtual void MatrixTimeVector(dgFloat32* const out, const dgFloat32* const v) const - { - dgMatrixTimeVector(4, &A[0][0], v, out); - } - - virtual void InversePrecoditionerTimeVector(dgFloat32* const out, const dgFloat32* const v) const - { - for (int i = 0; i < 4; i++) { - out[i] = v[i] / A[i][i]; - } - } - - - dgFloat32 A[4][4]; -}; -*/ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -dgWorld::dgWorld(dgMemoryAllocator* const allocator) - :dgBodyMasterList(allocator) - ,dgBodyMaterialList(allocator) - ,dgBodyCollisionList(allocator) - ,dgSkeletonList(allocator) - ,dgContactList(allocator) - ,dgBilateralConstraintList(allocator) - ,dgWorldDynamicUpdate(allocator) - ,dgMutexThread("newtonMainThread", DG_SYNC_THREAD) - ,dgAsyncThread("newtonAsyncThread", DG_ASYNC_THREAD) - ,dgWorldThreadPool(allocator) - ,dgDeadBodies(allocator) - ,dgDeadJoints(allocator) - ,dgWorldPluginList(allocator) - ,m_broadPhase(NULL) - ,m_sentinelBody(NULL) - ,m_pointCollision(NULL) - ,m_userData(NULL) - ,m_allocator (allocator) - ,m_onPostUpdateCallback(NULL) - ,m_listeners(allocator) - ,m_perInstanceData(allocator) - ,m_bodiesMemory (allocator, 64) - ,m_jointsMemory (allocator, 64) - ,m_clusterMemory (allocator, 64) - ,m_solverJacobiansMemory (allocator, 64) - ,m_solverRightHandSideMemory (allocator, 64) - ,m_solverForceAccumulatorMemory (allocator, 64) -{ - //TestAStart(); - //TestSort(); - //TestGradient(); - - dgMutexThread* const myThread = this; - SetParentThread (myThread); - - // avoid small memory fragmentations on initialization - m_bodiesMemory.Resize(1024); - m_clusterMemory.Resize(1024); - m_jointsMemory.Resize(1024 * 2); - m_solverJacobiansMemory.Resize(1024 * 64); - m_solverRightHandSideMemory.Resize(1024 * 64); - m_solverForceAccumulatorMemory.Resize(1024 * 32); - - m_savetimestep = dgFloat32 (0.0f); - m_allocator = allocator; - - m_onCollisionInstanceDestruction = NULL; - m_onCollisionInstanceCopyConstrutor = NULL; - - m_onSerializeJointCallback = NULL; - m_onDeserializeJointCallback = NULL; - - m_inUpdate = 0; - m_clusterLRU = 0; - m_bodyGroupID = 0; - m_frameNumber = 0; - m_dynamicsLru = 0; - m_genericLRUMark = 0; - m_bodiesUniqueID = 0; - m_numberOfSubsteps = 1; - m_useParallelSolver = 1; - m_lastExecutionTime = 0; - m_defualtBodyGroupID = CreateBodyGroupID(); - m_solverIterations = DG_DEFAULT_SOLVER_ITERATION_COUNT; - - m_frictiomTheshold = dgFloat32 (0.25f); - - m_userData = NULL; - m_onClusterUpdate = NULL; - m_onCreateContact = NULL; - m_onDestroyContact = NULL; - - - m_freezeAccel2 = DG_FREEZE_ACCEL2; - m_freezeAlpha2 = DG_FREEZE_ACCEL2; - m_freezeSpeed2 = DG_FREEZE_SPEED2; - m_freezeOmega2 = DG_FREEZE_SPEED2; - - m_contactTolerance = DG_PRUNE_CONTACT_TOLERANCE; - - dgInt32 steps = 1; - dgFloat32 freezeAccel2 = m_freezeAccel2; - dgFloat32 freezeAlpha2 = m_freezeAlpha2; - dgFloat32 freezeSpeed2 = m_freezeSpeed2; - dgFloat32 freezeOmega2 = m_freezeOmega2; - for (dgInt32 i = 0; i < DG_SLEEP_ENTRIES; i ++) { - m_sleepTable[i].m_maxAccel = freezeAccel2; - m_sleepTable[i].m_maxAlpha = freezeAlpha2; - m_sleepTable[i].m_maxVeloc = freezeSpeed2; - m_sleepTable[i].m_maxOmega = freezeOmega2; - m_sleepTable[i].m_steps = steps; - steps += 7; - freezeAccel2 *= dgFloat32 (1.5f); - freezeAlpha2 *= dgFloat32 (1.5f); - freezeSpeed2 *= dgFloat32 (1.5f); - freezeOmega2 *= dgFloat32 (1.5f); - } - - m_sleepTable[0].m_maxAccel *= dgFloat32(0.009f); - m_sleepTable[0].m_maxAlpha *= dgFloat32(0.009f); - - steps += 300; - m_sleepTable[DG_SLEEP_ENTRIES - 1].m_maxAccel *= dgFloat32 (100.0f); - m_sleepTable[DG_SLEEP_ENTRIES - 1].m_maxAlpha *= dgFloat32 (100.0f); - m_sleepTable[DG_SLEEP_ENTRIES - 1].m_maxVeloc = 0.25f; - m_sleepTable[DG_SLEEP_ENTRIES - 1].m_maxOmega = 0.1f; - m_sleepTable[DG_SLEEP_ENTRIES - 1].m_steps = steps; - - SetThreadsCount (0); - - m_broadPhase = new (allocator) dgBroadPhaseMixed(this); - //m_broadPhase = new (allocator) dgBroadPhaseSegregated (this); - - //m_pointCollision = new (m_allocator) dgCollisionPoint(m_allocator); - dgCollision* const pointCollison = new (m_allocator) dgCollisionPoint(m_allocator); - m_pointCollision = CreateInstance(pointCollison, 0, dgGetIdentityMatrix()); - pointCollison->Release(); - - AddSentinelBody(); -} - -dgWorld::~dgWorld() -{ - Sync(); - dgAsyncThread::Terminate(); - dgMutexThread::Terminate(); - - UnloadPlugins(); - m_listeners.RemoveAll(); - - DestroyAllBodies(); - RemoveAllGroupID(); - m_pointCollision->Release(); - DestroyBody (m_sentinelBody); - - dgDeadBodies& bodyList = *this; - dgDeadJoints& jointList = *this; - - jointList.DestroyJoints(*this); - bodyList.DestroyBodies(*this); - - delete m_broadPhase; -} - -void dgWorld::DestroyAllBodies() -{ - dgBodyMasterList& me = *this; - - Sync(); - - dgSkeletonList& skelList = *this; - dgSkeletonList::Iterator iter(skelList); - for (iter.Begin(); iter; iter++) { - dgSkeletonContainer* const skeleton = iter.GetNode()->GetInfo(); - delete skeleton; - } - skelList.RemoveAll(); - - while (m_disableBodies.GetRoot()) { - dgBody* const body = m_disableBodies.GetRoot()->GetKey(); - BodyEnableSimulation(body); - } - - dgAssert(dgBodyMasterList::GetFirst()->GetInfo().GetBody() == m_sentinelBody); - for (dgBodyMasterList::dgListNode* node = me.GetFirst()->GetNext(); node;) { - dgBody* const body = node->GetInfo().GetBody(); - node = node->GetNext(); - DestroyBody(body); - } - - dgDeadBodies& bodyList = *this; - dgDeadJoints& jointList = *this; - - jointList.DestroyJoints(*this); - bodyList.DestroyBodies(*this); - - dgAssert(me.GetFirst()->GetInfo().GetCount() == 0); - dgAssert(dgBodyCollisionList::GetCount() == 0); -} - -void dgWorld::SetThreadsCount (dgInt32 count) -{ - dgThreadHive::SetThreadsCount(count); -} - -dgUnsigned32 dgWorld::GetPerformanceCount () -{ - return 0; -} - -void dgWorld::AddSentinelBody() -{ - dgCollision* const collision = new (m_allocator) dgCollisionNull (m_allocator, 0x4352fe67); - dgCollisionInstance* const instance = CreateInstance(collision, 0, dgGetIdentityMatrix()); - collision->Release(); - m_sentinelBody = CreateDynamicBody(instance, dgGetIdentityMatrix()); - instance->Release(); -} - -dgDynamicBody* dgWorld::GetSentinelBody() const -{ - return m_sentinelBody; -} - - -dgFloat32 dgWorld::GetContactMergeTolerance() const -{ - return m_contactTolerance; -} - -void dgWorld::SetContactMergeTolerance(dgFloat32 tolerenace) -{ - m_contactTolerance = dgMax (tolerenace, dgFloat32 (1.e-3f)); -} - -void dgWorld::EnableParallelSolverOnLargeIsland(dgInt32 mode) -{ - m_useParallelSolver = mode ? 1 : 0; -} - -dgInt32 dgWorld::GetParallelSolverOnLargeIsland() const -{ - return m_useParallelSolver ? 1 : 0; -} - - -void dgWorld::SetFrictionThreshold (dgFloat32 acceleration) -{ - m_frictiomTheshold = dgMax (dgFloat32(1.0e-2f), acceleration); -} - - -void dgWorld::RemoveAllGroupID() -{ - while (dgBodyMaterialList::GetCount()) { - dgBodyMaterialList::Remove (dgBodyMaterialList::GetRoot()); - } - m_bodyGroupID = 0; - m_defualtBodyGroupID = CreateBodyGroupID(); -} - -void dgWorld::InitBody (dgBody* const body, dgCollisionInstance* const collision, const dgMatrix& matrix) -{ - dgAssert (collision); - - m_bodiesUniqueID ++; - body->m_world = this; - - body->m_spawnnedFromCallback = dgUnsigned32 (m_inUpdate ? true : false); - body->m_uniqueID = dgInt32 (m_bodiesUniqueID); - - dgBodyMasterList::AddBody(body); - - body->SetLinearDamping(dgFloat32(0.1045f)); - body->SetCentreOfMass (dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (1.0f))); - body->SetAngularDamping (dgVector (dgFloat32 (0.1045f), dgFloat32 (0.1045f), dgFloat32 (0.1045f), dgFloat32 (0.0f))); - body->AttachCollision(collision); - body->m_bodyGroupId = dgInt32 (m_defualtBodyGroupID); - - dgMatrix inertia(dgGetIdentityMatrix()); - if (!body->GetCollision()->IsType(dgCollision::dgCollisionLumpedMass_RTTI)) { - inertia[0][0] = DG_INFINITE_MASS; - inertia[1][1] = DG_INFINITE_MASS; - inertia[2][2] = DG_INFINITE_MASS; - body->SetMassMatrix(DG_INFINITE_MASS * dgFloat32(2.0f), inertia); - } else { - dgBodyMasterList::RemoveBody(body); - body->UpdateLumpedMatrix(); - dgBodyMasterList::AddBody(body); - inertia[0][0] = body->m_mass.m_x; - inertia[1][1] = body->m_mass.m_y; - inertia[2][2] = body->m_mass.m_z; - body->SetMassMatrix(body->m_mass.m_w, inertia); - } - body->SetMatrix(matrix); - if (!body->GetCollision()->IsType (dgCollision::dgCollisionNull_RTTI)) { - m_broadPhase->Add (body); - } -} - -void dgWorld::BodyEnableSimulation (dgBody* const body) -{ - if (!body->m_masterNode) { - m_disableBodies.Remove(body); - dgBodyMasterList::AddBody(body); - body->SetMassMatrix(body->m_mass.m_w, body->CalculateLocalInertiaMatrix()); - m_broadPhase->Add (body); - dgAssert (body->m_masterNode); - } -} - -void dgWorld::BodyDisableSimulation(dgBody* const body) -{ - if (body->m_masterNode) { - m_broadPhase->Remove(body); - dgBodyMasterList::RemoveBody(body); - m_disableBodies.Insert(0, body); - dgAssert (!body->m_masterNode); - } -} - -bool dgWorld::GetBodyEnableDisableSimulationState (dgBody* const body) const -{ - return body->m_masterNode ? true : false; -} - -dgDynamicBody* dgWorld::CreateDynamicBody(dgCollisionInstance* const collision, const dgMatrix& matrix) -{ - dgDynamicBody* const body = new (m_allocator) dgDynamicBody(); - dgAssert (dgInt32 (sizeof (dgBody) & 0xf) == 0); - dgAssert ((dgUnsigned64 (body) & 0xf) == 0); - - InitBody (body, collision, matrix); - return body; -} - -dgDynamicBody* dgWorld::CreateDynamicBodyAsymetric(dgCollisionInstance* const collision, const dgMatrix& matrix) -{ - dgDynamicBody* const body = new (m_allocator) dgDynamicBodyAsymetric(); - dgAssert(dgInt32(sizeof(dgBody) & 0xf) == 0); - dgAssert((dgUnsigned64(body) & 0xf) == 0); - - InitBody(body, collision, matrix); - return body; -} - -dgKinematicBody* dgWorld::CreateKinematicBody (dgCollisionInstance* const collision, const dgMatrix& matrix) -{ - dgKinematicBody* const body = new (m_allocator) dgKinematicBody(); - dgAssert (dgInt32 (sizeof (dgBody) & 0xf) == 0); - dgAssert ((dgUnsigned64 (body) & 0xf) == 0); - - InitBody (body, collision, matrix); - return body; -} - - -void dgWorld::DestroyBody(dgBody* const body) -{ - for (dgListenerList::dgListNode* node = m_listeners.GetLast(); node; node = node->GetPrev()) { - dgListener& listener = node->GetInfo(); - if (listener.m_onBodyDestroy) { - listener.m_onBodyDestroy(this, node, body); - } - } - - dgDeadBodies& deadBodyList = *this; - deadBodyList.DestroyBody(body); -} - -void dgWorld::DestroyConstraint(dgConstraint* const constraint) -{ - RemoveConstraint (constraint); - delete constraint; -} - -void dgWorld::ExecuteUserJob (dgWorkerThreadTaskCallback userJobKernel, void* const userJobKernelContext, const char* const functionName) -{ - QueueJob (userJobKernel, this, userJobKernelContext, functionName); -} - -void dgWorld::SetUserData (void* const userData) -{ - m_userData = userData; -} - -void* dgWorld::GetUserData() const -{ - return m_userData; -} - -void dgWorld::SetIslandUpdateCallback (OnClusterUpdate callback) -{ - m_onClusterUpdate = callback; -} - -void dgWorld::SetCreateDestroyContactCallback(OnCreateContact createContactCallback, OnDestroyContact destroyContactCallback) -{ - m_onCreateContact = createContactCallback; - m_onDestroyContact = destroyContactCallback; -} - -void* dgWorld::AddListener (const char* const nameid, void* const userData) -{ - dgListenerList::dgListNode* const node = m_listeners.Append(); - dgListener& listener = node->GetInfo(); - strncpy (listener.m_name, nameid, sizeof (listener.m_name)); - listener.m_world = this; - listener.m_userData = userData; - return node; -} - -void dgWorld::ListenerSetDestroyCallback(void* const listenerNode, OnListenerDestroyCallback destroyCallback) -{ - dgListener& listener = ((dgListenerList::dgListNode*) listenerNode)->GetInfo(); - listener.m_onListenerDestroy = destroyCallback; -} - -void dgWorld::ListenerSetPreUpdate(void* const listenerNode, OnListenerUpdateCallback updateCallback) -{ - dgListener& listener = ((dgListenerList::dgListNode*) listenerNode)->GetInfo(); - listener.m_onPreUpdate = updateCallback; -} - -void dgWorld::ListenerSetPostUpdate(void* const listenerNode, OnListenerUpdateCallback updateCallback) -{ - dgListener& listener = ((dgListenerList::dgListNode*) listenerNode)->GetInfo(); - listener.m_onPostUpdate = updateCallback; -} - -void dgWorld::ListenerSetPostStep(void* const listenerNode, OnListenerUpdateCallback updateCallback) -{ - dgListener& listener = ((dgListenerList::dgListNode*) listenerNode)->GetInfo(); - listener.m_onPostStep = updateCallback; -} - -void* dgWorld::GetListenerUserData (void* const listenerNode) const -{ - dgListener& listener = ((dgListenerList::dgListNode*) listenerNode)->GetInfo(); - return listener.m_userData; -} - -void dgWorld::SetListenerBodyDestroyCallback (void* const listenerNode, OnListenerBodyDestroyCallback callback) -{ - dgListener& listener = ((dgListenerList::dgListNode*) listenerNode)->GetInfo(); - listener.m_onBodyDestroy = callback; -} - -void dgWorld::SetListenerBodyDebugCallback (void* const listenerNode, OnListenerDebugCallback callback) -{ - dgListener& listener = ((dgListenerList::dgListNode*) listenerNode)->GetInfo(); - listener.m_onDebugCallback = callback; -} - -dgWorld::OnListenerBodyDestroyCallback dgWorld::GetListenerBodyDestroyCallback (void* const listenerNode) const -{ - dgListener& listener = ((dgListenerList::dgListNode*) listenerNode)->GetInfo(); - return listener.m_onBodyDestroy; -} - -void dgWorld::ListenersDebug(void* const debugContext) -{ - for (dgListenerList::dgListNode* node = m_listeners.GetFirst(); node; node = node->GetNext()) { - dgListener& listener = node->GetInfo(); - if (listener.m_onDebugCallback) { - listener.m_onDebugCallback (this, listener.m_userData, debugContext); - } - } -} - -void* dgWorld::FindListener (const char* const nameid) const -{ - for (dgListenerList::dgListNode* node = m_listeners.GetFirst(); node; node = node->GetNext()) { - dgListener& listener = node->GetInfo(); - if (!strcmp (nameid, listener.m_name)) { - return node; - } - } - return NULL; -} - - -dgBallConstraint* dgWorld::CreateBallConstraint ( - const dgVector& pivot, - dgBody* const body0, - dgBody* const body1) -{ - - dgAssert (body0); - dgAssert (body0 != body1); - dgBallConstraint* const constraint = new (m_allocator) dgBallConstraint; - - AttachConstraint (constraint, body0, body1); - constraint->SetPivotPoint (pivot); - return constraint; -} - - -dgHingeConstraint* dgWorld::CreateHingeConstraint ( - const dgVector& pivot, - const dgVector& pinDir, - dgBody* const body0, - dgBody* const body1) -{ - dgAssert (body0); - dgAssert (body0 != body1); - dgHingeConstraint* const constraint = new (m_allocator) dgHingeConstraint; - - AttachConstraint (constraint, body0, body1); - constraint->SetPivotAndPinDir (pivot, pinDir, constraint->m_localMatrix0, constraint->m_localMatrix1); - return constraint; -} - - -dgUpVectorConstraint* dgWorld::CreateUpVectorConstraint (const dgVector& pin, dgBody *body) -{ - dgAssert (body); - dgUpVectorConstraint* const constraint = new (m_allocator) dgUpVectorConstraint; - - AttachConstraint (constraint, body, NULL); - constraint->InitPinDir (pin); - return constraint; -} - - - -dgSlidingConstraint* dgWorld::CreateSlidingConstraint ( - const dgVector& pivot, - const dgVector& pinDir, - dgBody* const body0, - dgBody* const body1) -{ - dgAssert (body0); - dgAssert (body0 != body1); - dgSlidingConstraint* const constraint = new (m_allocator) dgSlidingConstraint; - - AttachConstraint (constraint, body0, body1); - constraint->SetPivotAndPinDir (pivot, pinDir, constraint->m_localMatrix0, constraint->m_localMatrix1); - return constraint; -} - - -dgCorkscrewConstraint* dgWorld::CreateCorkscrewConstraint ( - const dgVector& pivot, - const dgVector& pinDir, - dgBody* const body0, - dgBody* const body1) -{ - dgAssert (body0); - dgAssert (body0 != body1); - dgCorkscrewConstraint* const constraint = new (m_allocator) dgCorkscrewConstraint; - - AttachConstraint (constraint, body0, body1); - constraint->SetPivotAndPinDir (pivot, pinDir, constraint->m_localMatrix0, constraint->m_localMatrix1); - return constraint; -} - - -dgUniversalConstraint* dgWorld::CreateUniversalConstraint ( - const dgVector& pivot, - const dgVector& pin0, - const dgVector& pin1, - dgBody* const body0, - dgBody* const body1) -{ - dgAssert (body0); - dgAssert (body0 != body1); - dgUniversalConstraint* const constraint = new (m_allocator) dgUniversalConstraint; - - AttachConstraint (constraint, body0, body1); - constraint->SetPivotAndPinDir(pivot, pin0, pin1, constraint->m_localMatrix0, constraint->m_localMatrix1); - return constraint; -} - -dgInt32 dgWorld::GetBodiesCount() const -{ - const dgBodyMasterList& list = *this; - return list.GetCount() - 1; -} - -dgInt32 dgWorld::GetConstraintsCount() const -{ - const dgBodyMasterList& list = *this; - return dgInt32 (list.m_constraintCount); -} - - -void dgWorld::BodySetMatrix (dgBody* const body, const dgMatrix& matrix) -{ - #define DG_RECURSIVE_SIZE 1024 - - dgBody* queue[DG_RECURSIVE_SIZE]; - - dgInt32 index = 1; - queue[0] = body; - m_genericLRUMark ++; - body->m_genericLRUMark = m_genericLRUMark; - dgMatrix relMatrix (body->GetMatrix().Inverse() * matrix); - while (index) { - index --; - dgBody* body1 = queue[index]; - dgAssert (body1 != m_sentinelBody); - - // why should I do this? I do no remember the reason - //m_broadPhase->Remove (body); - //m_broadPhase->Add (body); - - dgMatrix matrix1 (body1->GetMatrix() * relMatrix); - //body1->SetOmega (dgVector (dgFloat32 (0.0f))); - //body1->SetVelocity (dgVector (dgFloat32 (0.0f))); - body1->SetOmega (matrix1.RotateVector (body1->GetOmega())); - body1->SetVelocity (matrix1.RotateVector (body1->GetVelocity())); - - body1->SetMatrix (matrix1); - body1->UpdateCollisionMatrix (dgFloat32 (0.0f), 0); - body1->SetSleepState(false); - - for (dgBodyMasterListRow::dgListNode* jointNode = body1->m_masterNode->GetInfo().GetFirst(); jointNode; jointNode = jointNode->GetNext()) { - dgBodyMasterListCell& cell = jointNode->GetInfo(); - body1 = cell.m_bodyNode; - if (body1 != m_sentinelBody) { - if (body1->m_genericLRUMark != m_genericLRUMark) { - dgConstraint* constraint; - constraint = cell.m_joint; - if (constraint->GetId() != dgConstraint::m_contactConstraint) { - body1->m_genericLRUMark = m_genericLRUMark; - queue[index] = body1; - index ++; - dgAssert (index < DG_RECURSIVE_SIZE); - } - } - } - } - } -} - - -bool dgWorld::AreBodyConnectedByJoints (dgBody* const originSrc, dgBody* const targetSrc) -{ - #define DG_QEUEU_SIZE 1024 - dgBody* queue[DG_QEUEU_SIZE]; - - m_genericLRUMark ++; - - dgBody* origin1 = originSrc; - dgBody* target1 = targetSrc; - if (origin1->GetInvMass().m_w == dgFloat32 (0.0f)) { - dgSwap (origin1, target1); - } - - dgAssert (origin1->GetInvMass().m_w != dgFloat32 (0.0f)); - dgBody* const origin = origin1; - dgBody* const target = target1; - - dgInt32 end = 1; - dgInt32 start = 0; - queue[0] = origin; - origin->m_genericLRUMark = m_genericLRUMark; - - while (start != end) { - dgBody* const originVar = queue[start]; - start ++; - start &= (DG_QEUEU_SIZE - 1); - - for (dgBodyMasterListRow::dgListNode* jointNode = originVar->m_masterNode->GetInfo().GetFirst(); jointNode; jointNode = jointNode->GetNext()) { - dgBodyMasterListCell& cell = jointNode->GetInfo(); - - dgBody* const body = cell.m_bodyNode; - if (body->m_genericLRUMark != m_genericLRUMark) { - dgConstraint* const constraint = cell.m_joint; - if (constraint->GetId() != dgConstraint::m_contactConstraint) { - if (body == target) { - return true; - } - body->m_genericLRUMark = m_genericLRUMark; - queue[end] = body; - end ++; - end &= (DG_QEUEU_SIZE - 1); - } - } - } - } - return false; -} - -void dgWorld::FlushCache() -{ - // delete all contacts - dgContactList& contactList = *this; - for (dgInt32 i = contactList.m_contactCount - 1; i >= 0; i--) { - dgContact* const contact = contactList[i]; - contact->m_killContact = 1; - } - m_broadPhase->DeleteDeadContact(0.0f); - - // clean up memory in bradPhase - m_broadPhase->InvalidateCache (); - - // sort body list - SortMasterList(); -} - -void dgWorld::StepDynamics (dgFloat32 timestep) -{ - //SerializeToFile ("xxx.bin"); - - dgAssert (m_inUpdate == 0); - dgAssert (GetThreadCount() >= 1); - - m_inUpdate ++; - m_frameNumber ++; - - D_TRACKTIME(); - UpdateSkeletons(); - UpdateBroadphase(timestep); - UpdateDynamics (timestep); - - if (m_listeners.GetCount()) { - for (dgListenerList::dgListNode* node = m_listeners.GetFirst(); node; node = node->GetNext()) { - dgListener& listener = node->GetInfo(); - if (listener.m_onPostUpdate) { - listener.m_onPostUpdate(this, listener.m_userData, timestep); - } - } - } - - m_inUpdate --; -} - -void dgWorldThreadPool::OnBeginWorkerThread (dgInt32 threadId) -{ -} - -void dgWorldThreadPool::OnEndWorkerThread (dgInt32 threadId) -{ -} - -void dgWorld::Execute (dgInt32 threadID) -{ - dgMutexThread::Execute (threadID); -} - -void dgWorld::UpdateTransforms(dgBodyMasterList::dgListNode* node, dgInt32 threadID) -{ - const dgInt32 threadsCount = GetThreadCount(); - while (node) { - dgBody* const body = node->GetInfo().GetBody(); - if (body->m_transformIsDirty && body->m_matrixUpdate) { - body->m_matrixUpdate (*body, body->m_matrix, threadID); - } - body->m_transformIsDirty = false; - - for (dgInt32 i = 0; i < threadsCount; i++) { - node = node ? node->GetNext() : NULL; - } - } -} - -void dgWorld::UpdateTransforms(void* const context, void* const nodePtr, dgInt32 threadID) -{ - dgWorld* const world = (dgWorld*)context; - dgBodyMasterList::dgListNode* node = (dgBodyMasterList::dgListNode*) nodePtr; - world->UpdateTransforms(node, threadID); -} - -void dgWorld::RunStep () -{ - D_TRACKTIME(); - - BeginSection(); - dgUnsigned64 timeAcc = dgGetTimeInMicrosenconds(); - - dgFloat32 step = m_savetimestep / m_numberOfSubsteps; - for (dgUnsigned32 i = 0; i < m_numberOfSubsteps; i ++) { - StepDynamics (step); - - dgDeadBodies& bodyList = *this; - dgDeadJoints& jointList = *this; - - jointList.DestroyJoints (*this); - bodyList.DestroyBodies (*this); - } - - const dgBodyMasterList* const masterList = this; - dgBodyMasterList::dgListNode* threadNode = masterList->GetFirst(); - const dgInt32 threadsCount = GetThreadCount(); - for (dgInt32 i = 0; i < threadsCount; i++) { - QueueJob(UpdateTransforms, this, threadNode, "dgWorld::UpdateTransforms"); - threadNode = threadNode ? threadNode->GetNext() : NULL; - } - SynchronizationBarrier(); - - if (m_listeners.GetCount()) { - for (dgListenerList::dgListNode* node = m_listeners.GetFirst(); node; node = node->GetNext()) { - dgListener& listener = node->GetInfo(); - if (listener.m_onPostStep) { - listener.m_onPostStep(this, listener.m_userData, m_savetimestep); - } - } - } - - if (m_onPostUpdateCallback) { - m_onPostUpdateCallback (this, m_savetimestep); - } - - m_lastExecutionTime = (dgGetTimeInMicrosenconds() - timeAcc) * dgFloat32 (1.0e-6f); - EndSection(); -} - -void dgWorld::TickCallback(dgInt32 threadID) -{ - RunStep(); -} - -void dgWorld::Update (dgFloat32 timestep) -{ - m_savetimestep = timestep; - #ifdef DG_USE_THREAD_EMULATION - dgFloatExceptions exception; - dgSetPrecisionDouble precision; - RunStep (); - #else - // runs the update in a separate thread and wait until the update is completed before it returns. - // this will run well on single core systems, since the two thread are mutually exclusive - dgMutexThread::Tick(); - #endif -} - -void dgWorld::UpdateAsync (dgFloat32 timestep) -{ - - #ifdef DG_USE_THREAD_EMULATION - Update(timestep); - #else - m_savetimestep = timestep; - dgAsyncThread::Tick(); - //Update(timestep); - #endif -} - -void dgWorld::SetCollisionInstanceConstructorDestructor (OnCollisionInstanceDuplicate constructor, OnCollisionInstanceDestroy destructor) -{ - m_onCollisionInstanceDestruction = destructor; - m_onCollisionInstanceCopyConstrutor = constructor; -} - -dgInt32 dgWorld::GetBroadPhaseType() const -{ - return dgInt32 (m_broadPhase->GetType()); -} - -void dgWorld::SetBroadPhaseType(dgInt32 type) -{ - if (type != GetBroadPhaseType()) { - dgBroadPhase* newBroadPhase = NULL; - - switch (type) - { - case m_broadphaseSegregated: - newBroadPhase = new (m_allocator) dgBroadPhaseSegregated (this); - break; - - case m_broadphaseMixed: - default: - newBroadPhase = new (m_allocator) dgBroadPhaseMixed(this); - break; - } - - m_broadPhase->MoveNodes(newBroadPhase); - delete m_broadPhase; - m_broadPhase = newBroadPhase; - } -} - -void dgWorld::ResetBroadPhase() -{ - dgBroadPhase* newBroadPhase = NULL; - - switch (GetBroadPhaseType()) - { - case m_broadphaseSegregated: - newBroadPhase = new (m_allocator) dgBroadPhaseSegregated (this); - break; - - case m_broadphaseMixed: - default: - newBroadPhase = new (m_allocator) dgBroadPhaseMixed(this); - break; - } - - m_broadPhase->MoveNodes(newBroadPhase); - delete m_broadPhase; - m_broadPhase = newBroadPhase; -} - -dgContact* dgWorld::FindContactJoint (const dgBody* body0, const dgBody* body1) const -{ - dgAssert (m_broadPhase); - return m_broadPhase->m_contactCache.FindContactJoint(body0, body1); -} - -dgSkeletonContainer* dgWorld::CreateNewtonSkeletonContainer (dgBody* const rootBone) -{ - dgAssert (rootBone); - dgSkeletonList* const list = this; - dgAssert (rootBone->GetType() == dgBody::m_dynamicBody); - dgSkeletonContainer* const container = new (m_allocator) dgSkeletonContainer(this, (dgDynamicBody*)rootBone); - - container->m_listNode = list->Append(container); - return container; -} - -void dgWorld::DestroySkeletonContainer (dgSkeletonContainer* const container) -{ - dgSkeletonList* const list = this; - dgAssert(container->m_listNode); - list->Remove(container->m_listNode); - delete container; -} - -dgBroadPhaseAggregate* dgWorld::CreateAggreGate() const -{ - return m_broadPhase->CreateAggregate(); -} - -void dgWorld::DestroyAggregate(dgBroadPhaseAggregate* const aggregate) const -{ - m_broadPhase->DestroyAggregate((dgBroadPhaseAggregate*) aggregate); -} - -dgDeadJoints::dgDeadJoints(dgMemoryAllocator* const allocator) - :dgTree<dgConstraint*, void* >(allocator) - ,m_lock(0) -{ -} - -void dgDeadJoints::DestroyJoint(dgConstraint* const joint) -{ - dgScopeSpinLock lock(&m_lock); - dgWorld& me = *((dgWorld*)this); - me.DestroyConstraint(joint); -} - -void dgDeadJoints::DestroyJoints(dgWorld& world) -{ - dgScopeSpinLock lock(&m_lock); - Iterator iter (*this); - for (iter.Begin(); iter; iter++) { - dgTreeNode* const node = iter.GetNode(); - dgConstraint* const joint = node->GetInfo(); - world.DestroyConstraint (joint); - } - RemoveAll (); -} - -dgDeadBodies::dgDeadBodies(dgMemoryAllocator* const allocator) - :dgTree<dgBody*, void*>(allocator) - ,m_lock(0) -{ -} - -void dgDeadBodies::DestroyBody(dgBody* const body) -{ - if (body->m_destructor) { - body->m_destructor(*body); - } - body->m_isdead = 1; - body->SetDestructorCallback (NULL); - body->SetMatrixUpdateCallback (NULL); - body->SetExtForceAndTorqueCallback (NULL); - - for (dgBodyMasterListRow::dgListNode* node = body->GetMasterList()->GetInfo().GetLast(); node; node = node->GetPrev()) { - dgConstraint* const joint = node->GetInfo().m_joint; - if (joint && (joint->GetId() == dgConstraint::m_contactConstraint)) { - dgContact* const contactJoint = (dgContact*)joint; - contactJoint->m_killContact = 1; - } - } - - dgScopeSpinLock lock(&m_lock); - Insert (body, body); -} - -void dgDeadBodies::DestroyBodies(dgWorld& world) -{ -// dgScopeSpinLock lock(&m_lock); - if (GetCount()) { - world.m_broadPhase->DeleteDeadContact(0.0f); - Iterator iter(*this); - for (iter.Begin(); iter; iter++) { - dgTreeNode* const bodyNode = iter.GetNode(); - dgBody* const body = bodyNode->GetInfo(); - - if (world.m_disableBodies.Find(body)) { - world.m_disableBodies.Remove(body); - } else { - world.m_broadPhase->Remove(body); - world.dgBodyMasterList::RemoveBody(body); - } - - dgAssert(body->m_collision); - body->m_collision->Release(); - delete body; - } - RemoveAll(); - } -} - -void dgWorld::UpdateBroadphase(dgFloat32 timestep) -{ - m_broadPhase->UpdateContacts (timestep); -} - -#if 1 -dgInt32 dgWorld::CompareJointByInvMass(const dgBilateralConstraint* const jointA, const dgBilateralConstraint* const jointB, void* notUsed) -{ - dgInt32 modeA = jointA->m_solverModel; - dgInt32 modeB = jointB->m_solverModel; - - if (modeA < modeB) { - return -1; - } else if (modeA > modeB) { - return 1; - } else { - dgFloat32 invMassA = dgMin(jointA->GetBody0()->m_invMass.m_w, jointA->GetBody1()->m_invMass.m_w); - dgFloat32 invMassB = dgMin(jointB->GetBody0()->m_invMass.m_w, jointB->GetBody1()->m_invMass.m_w); - if (invMassA < invMassB) { - return -1; - } else if (invMassA > invMassB) { - return 1; - } - } - return 0; -} - -void dgWorld::UpdateSkeletons() -{ - D_TRACKTIME(); - dgSkeletonList& skelManager = *this; - - if (skelManager.m_skelListIsDirty) { - skelManager.m_skelListIsDirty = false; - dgSkeletonList::Iterator iter(skelManager); - for (iter.Begin(); iter; iter++) { - dgSkeletonContainer* const skeleton = iter.GetNode()->GetInfo(); - delete skeleton; - } - skelManager.RemoveAll(); - - m_dynamicsLru = m_dynamicsLru + 1; - dgUnsigned32 lru = m_dynamicsLru; - - dgBodyMasterList& masterList = *this; - m_solverJacobiansMemory.ResizeIfNecessary((2 * (masterList.m_constraintCount + 1024)) * sizeof (dgBilateralConstraint*)); - dgBilateralConstraint** const jointList = (dgBilateralConstraint**)&m_solverJacobiansMemory[0]; - - dgInt32 jointCount = 0; - for (dgBodyMasterList::dgListNode* node = masterList.GetFirst(); node; node = node->GetNext()) { - const dgBodyMasterListRow& graphNode = node->GetInfo(); - dgBody* const srcBody = graphNode.GetBody(); - - for (dgBodyMasterListRow::dgListNode* jointNode = srcBody->m_masterNode->GetInfo().GetLast(); jointNode; jointNode = jointNode->GetPrev()) { - dgBodyMasterListCell* const cell = &jointNode->GetInfo(); - dgConstraint* const constraint = cell->m_joint; - dgAssert(constraint); - dgAssert((constraint->m_body0 == srcBody) || (constraint->m_body1 == srcBody)); - dgAssert((constraint->m_body0 == cell->m_bodyNode) || (constraint->m_body1 == cell->m_bodyNode)); - bool test = constraint->IsBilateral(); - test = test && (constraint->m_solverModel < 2); - test = test && (constraint->m_dynamicsLru != lru); - test = test && (constraint->GetMassScaleBody0() == dgFloat32 (1.0f)); - test = test && (constraint->GetMassScaleBody1() == dgFloat32 (1.0f)); - //if (constraint->IsBilateral() && (constraint->m_solverModel < 2) && (constraint->m_dynamicsLru != lru)) { - if (test) { - constraint->m_dynamicsLru = lru; - jointList[jointCount] = (dgBilateralConstraint*)constraint; - jointCount++; - } - } - } - - dgSortIndirect(jointList, jointCount, CompareJointByInvMass); - - const dgInt32 poolSize = 1024 * 4; - dgBilateralConstraint* loopJoints[64]; - dgSkeletonContainer::dgNode* queuePool[poolSize]; - - m_dynamicsLru = m_dynamicsLru + 1; - lru = m_dynamicsLru; - for (dgInt32 i = 0; i < jointCount; i++) { - dgBilateralConstraint* const constraint = jointList[i]; - if (constraint->m_dynamicsLru != lru) { - dgQueue<dgSkeletonContainer::dgNode*> queue(queuePool, poolSize); - - dgInt32 loopCount = 0; - dgDynamicBody* const rootBody = (dgDynamicBody*)((constraint->GetBody0()->GetInvMass().m_w < constraint->GetBody1()->GetInvMass().m_w) ? constraint->GetBody0() : constraint->GetBody1()); - dgSkeletonContainer* const skeleton = CreateNewtonSkeletonContainer(rootBody); - dgSkeletonContainer::dgNode* const rootNode = skeleton->GetRoot(); - if (rootBody->GetInvMass().m_w == dgFloat32 (0.0f)) { - if (constraint->IsBilateral() && (constraint->m_dynamicsLru != lru)) { - constraint->m_dynamicsLru = lru; - dgDynamicBody* const childBody = (dgDynamicBody*)((constraint->GetBody0() == rootBody) ? constraint->GetBody1() : constraint->GetBody0()); - if (!constraint->m_solverModel) { - if ((childBody->m_dynamicsLru != lru) && (childBody->GetInvMass().m_w != dgFloat32(0.0f))) { - childBody->m_dynamicsLru = lru; - dgSkeletonContainer::dgNode* const node = skeleton->AddChild((dgBilateralConstraint*)constraint, rootNode); - queue.Insert(node); - } - } - } - } else { - queue.Insert(rootNode); - rootBody->m_dynamicsLru = lru; - } - - while (!queue.IsEmpty()) { - dgInt32 count = queue.m_firstIndex - queue.m_lastIndex; - if (count < 0) { - count += queue.m_mod; - } - - dgInt32 index = queue.m_lastIndex; - queue.Reset(); - - for (dgInt32 j = 0; j < count; j++) { - dgSkeletonContainer::dgNode* const parentNode = queue.m_pool[index]; - dgDynamicBody* const parentBody = skeleton->GetBody(parentNode); - - for (dgBodyMasterListRow::dgListNode* jointNode1 = parentBody->m_masterNode->GetInfo().GetFirst(); jointNode1; jointNode1 = jointNode1->GetNext()) { - dgBodyMasterListCell* const cell1 = &jointNode1->GetInfo(); - dgConstraint* const constraint1 = cell1->m_joint; - if (constraint1->IsBilateral() && (constraint1->m_dynamicsLru != lru)) { - constraint1->m_dynamicsLru = lru; - - dgDynamicBody* const childBody = (dgDynamicBody*)((constraint1->GetBody0() == parentBody) ? constraint1->GetBody1() : constraint1->GetBody0()); - if (!constraint1->m_solverModel) { - if ((childBody->m_dynamicsLru != lru) && (childBody->GetInvMass().m_w != dgFloat32(0.0f))) { - childBody->m_dynamicsLru = lru; - dgSkeletonContainer::dgNode* const childNode = skeleton->AddChild((dgBilateralConstraint*)constraint1, parentNode); - queue.Insert(childNode); - } else if (loopCount < (sizeof (loopJoints) / sizeof(loopJoints[0]))) { - loopJoints[loopCount] = (dgBilateralConstraint*)constraint1; - loopCount++; - } - - //} else if ((constraint1->m_solverModel != 2) && loopCount < (sizeof (loopJoints) / sizeof(loopJoints[0]))) { - } else if ((constraint1->m_solverModel == 1) && (loopCount < (sizeof (loopJoints) / sizeof(loopJoints[0])))) { - dgAssert (constraint1->m_solverModel != 0); - loopJoints[loopCount] = (dgBilateralConstraint*)constraint1; - loopCount++; - } - } - } - index++; - if (index >= queue.m_mod) { - index = 0; - } - } - } - - skeleton->Finalize(loopCount, loopJoints); - } - } - } - - dgSkeletonList::Iterator iter(skelManager); - for (iter.Begin(); iter; iter++) { - dgSkeletonContainer* const skeleton = iter.GetNode()->GetInfo(); - skeleton->ClearSelfCollision(); - } -} - -#else - -dgInt32 dgWorld::CompareJointByInvMass(const dgBilateralConstraint* const jointA, const dgBilateralConstraint* const jointB, void* notUsed) -{ - dgAssert (jointA->m_solverModel < 2); - dgAssert (jointB->m_solverModel < 2); - - dgWorld* const world = jointA->GetBody0()->GetWorld(); - dgBody* const rootA = world->FindRoot (jointA->GetBody0()); - dgBody* const rootB = world->FindRoot (jointB->GetBody0()); - - if (rootA->m_uniqueID < rootB->m_uniqueID) { - return -1; - } else if (rootA->m_uniqueID > rootB->m_uniqueID) { - return 1; - } - - dgFloat32 invMassA[2]; - dgFloat32 invMassB[2]; - invMassA[0] = jointA->GetBody0()->m_invMass.m_w; - invMassA[1] = jointA->GetBody1()->m_invMass.m_w; - - invMassB[0] = jointB->GetBody0()->m_invMass.m_w; - invMassB[1] = jointB->GetBody1()->m_invMass.m_w; - - if (invMassA[0] < invMassA[1]) { - dgSwap(invMassA[0], invMassA[1]); - } - if (invMassB[0] < invMassB[1]) { - dgSwap(invMassA[0], invMassA[1]); - } - - if (invMassA[1] < invMassB[1]) { - return -1; - } else if (invMassA[1] > invMassB[1]) { - return 1; - } - - if (invMassA[0] < invMassB[0]) { - return -1; - } else if (invMassA[0] > invMassB[0]) { - return 1; - } - - return 0; -} - -void dgWorld::UpdateSkeletons() -{ - D_TRACKTIME(); - dgSkeletonList& skelManager = *this; -skelManager.m_skelListIsDirty = true; - - if (skelManager.m_skelListIsDirty) { - skelManager.m_skelListIsDirty = false; - dgSkeletonList::Iterator iter(skelManager); - for (iter.Begin(); iter; iter++) { - dgSkeletonContainer* const skeleton = iter.GetNode()->GetInfo(); - delete skeleton; - } - skelManager.RemoveAll(); - - const dgBilateralConstraintList& jointList = *this; - m_solverJacobiansMemory.ResizeIfNecessary((jointList.GetCount() + 1024) * sizeof (dgBilateralConstraint*)); - dgBilateralConstraint** const jointArray = (dgBilateralConstraint**)&m_solverJacobiansMemory[0]; - - dgInt32 jointCount = 0; - for (dgBilateralConstraintList::dgListNode* node = jointList.GetFirst(); node; node = node->GetNext()) { - dgBilateralConstraint* const joint = node->GetInfo(); - if (joint->m_solverModel < 2) { - joint->m_body0->InitJointSet(); - joint->m_body1->InitJointSet(); - jointArray[jointCount] = joint; - jointCount++; - } - } - - for (dgInt32 i = 0; i < jointCount; i++) { - dgBilateralConstraint* const joint = jointArray[i]; - dgAssert(joint->GetBody0()->m_invMass.m_w > dgFloat32(0.0f)); - if (joint->GetBody1()->m_invMass.m_w > dgFloat32(0.0f)) { - UnionSet(joint); - } else { - dgBody* const root = FindRootAndSplit(joint->GetBody0()); - root->m_disjointInfo.m_jointCount += 1; - } - } - - dgSortIndirect(jointArray, jointCount, CompareJointByInvMass); - - for (dgInt32 i = 0; i < jointCount; i++) { - dgBilateralConstraint* const joint = jointArray[i]; - dgBody* const root = FindRoot (joint->GetBody0()); - root->m_disjointInfo.m_rank = -1; - } - - int skelCount = 0; - for (dgInt32 i = 0; i < jointCount; i++) { - dgBilateralConstraint* const joint = jointArray[i]; - dgBody* const root = FindRoot(joint->GetBody0()); - if (root->m_disjointInfo.m_rank == -1) { - root->m_disjointInfo.m_rank = skelCount; - skelCount ++; - } - } - - dgInt32* batchStart = dgAlloca (dgInt32, skelCount + 1); - memset (batchStart, 0, sizeof (dgInt32) *(skelCount + 1)); - for (dgInt32 i = 0; i < jointCount; i++) { - dgBilateralConstraint* const joint = jointArray[i]; - dgBody* const root = FindRoot(joint->GetBody0()); - batchStart[root->m_disjointInfo.m_rank] += 1; - } - - dgInt32 acc = 0; - for (dgInt32 i = 0; i <= skelCount ; i++) { - dgInt32 count = batchStart[i]; - batchStart[i] = acc; - acc += count; - } - - for (dgInt32 i = 0; i < skelCount ; i++) { - dgInt32 index = batchStart[i]; - dgInt32 count = batchStart[i + 1] - i; - dgBilateralConstraint** const constraint = &jointArray[index]; - - for (dgInt32 j = 0; j < count; j ++) { - dgBilateralConstraint* const joint = constraint[j]; - joint->m_body0->InitJointSet(); - joint->m_body1->InitJointSet(); - } - - dgInt32 loopCount = 0; - dgInt32 spanningCount = 0; - dgBilateralConstraint** const loopJoints = dgAlloca (dgBilateralConstraint*, count); - dgBilateralConstraint** const spanningTree = dgAlloca (dgBilateralConstraint*, count); - for (dgInt32 j = 0; j < count; j ++) { - dgBilateralConstraint* const joint = constraint[j]; - dgBody* const root0 = FindRoot(joint->GetBody0()); - dgBody* const root1 = FindRoot(joint->GetBody1()); - if (root0 != root1) { - UnionSet(joint); - spanningTree[spanningCount] = joint; - spanningCount ++; - } else { - loopJoints[loopCount] = joint; - loopCount ++; - } - } - //skeleton->Finalize(loopCount, loopJoints); - - } - } - - dgSkeletonList::Iterator iter(skelManager); - for (iter.Begin(); iter; iter++) { - dgSkeletonContainer* const skeleton = iter.GetNode()->GetInfo(); - skeleton->ClearSelfCollision(); - } -} -#endif - -void dgWorld::OnSerializeToFile(void* const fileHandle, const void* const buffer, dgInt32 size) -{ - dgAssert((size & 0x03) == 0); - size_t bytes = fwrite(buffer, size, 1, (FILE*)fileHandle); - bytes=0; -} - -void dgWorld::OnDeserializeFromFile(void* const fileHandle, void* const buffer, dgInt32 size) -{ - dgAssert((size & 0x03) == 0); - FILE* const file = (FILE*)fileHandle; - size_t bytes = fread(buffer, size, 1, file); - bytes=0; -} - -void dgWorld::OnBodySerializeToFile(dgBody& body, void* const userData, dgSerialize serializeCallback, void* const serializeHandle) -{ - const char* const bodyIndentification = "NewtonGravityBody\0\0\0\0"; - int size = (dgInt32(strlen(bodyIndentification)) + 3) & -4; - serializeCallback(serializeHandle, &size, sizeof (size)); - serializeCallback(serializeHandle, bodyIndentification, size); -} - -void dgWorld::SetJointSerializationCallbacks(OnJointSerializationCallback serializeJoint, OnJointDeserializationCallback deserializeJoint) -{ - m_onSerializeJointCallback = serializeJoint; - m_onDeserializeJointCallback = deserializeJoint; -} - -void dgWorld::GetJointSerializationCallbacks(OnJointSerializationCallback* const serializeJoint, OnJointDeserializationCallback* const deserializeJoint) const -{ - *serializeJoint = m_onSerializeJointCallback; - *deserializeJoint = m_onDeserializeJointCallback; -} - -dgBody* dgWorld::FindBodyFromSerializedID(dgInt32 serializedID) const -{ - const dgBodyMasterList& me = *this; - for (dgBodyMasterList::dgListNode* node = me.GetFirst()->GetNext(); node; node = node->GetNext()) { - const dgBodyMasterListRow& graphNode = node->GetInfo(); - if (graphNode.GetBody()->m_serializedEnum == serializedID) { - return graphNode.GetBody(); - } - } - return NULL; -} - -dgInt32 dgWorld::SerializeToFileSort(const dgBody* const body0, const dgBody* const body1, void* const context) -{ - if (body0->m_uniqueID < body1->m_uniqueID) { - return -1; - } else if (body0->m_uniqueID > body1->m_uniqueID) { - return 1; - } - return 0; -} - -void dgWorld::SerializeScene(void* const userData, OnBodySerialize bodyCallback, dgSerialize serializeCallback, void* const serializeHandle) const -{ - dgBody** const array = new dgBody*[GetBodiesCount()]; - - dgInt32 count = 0; - const dgBodyMasterList& me = *this; - for (dgBodyMasterList::dgListNode* node = me.GetFirst()->GetNext(); node; node = node->GetNext()) { - const dgBodyMasterListRow& graphNode = node->GetInfo(); - array[count] = graphNode.GetBody(); - array[count]->m_serializedEnum = count; - count++; - dgAssert(count <= GetBodiesCount()); - } - - dgSortIndirect(array, count, SerializeToFileSort); - SerializeBodyArray(userData, bodyCallback ? bodyCallback : OnBodySerializeToFile, array, count, serializeCallback, serializeHandle); - SerializeJointArray(count, OnSerializeToFile, serializeHandle); - - for (dgBodyMasterList::dgListNode* node = me.GetFirst()->GetNext(); node; node = node->GetNext()) { - const dgBodyMasterListRow& graphNode = node->GetInfo(); - graphNode.GetBody()->m_serializedEnum = -1; - } - - delete[] array; -} - -void dgWorld::DeserializeScene(void* const userData, OnBodyDeserialize bodyCallback, dgDeserialize deserializeCallback, void* const serializeHandle) -{ - dgTree<dgBody*, dgInt32> bodyMap(GetAllocator()); - DeserializeBodyArray(userData, bodyCallback ? bodyCallback : OnBodyDeserializeFromFile, bodyMap, deserializeCallback, serializeHandle); - DeserializeJointArray(bodyMap, deserializeCallback, serializeHandle); - - const dgBodyMasterList& me = *this; - for (dgBodyMasterList::dgListNode* node = me.GetFirst()->GetNext(); node; node = node->GetNext()) { - const dgBodyMasterListRow& graphNode = node->GetInfo(); - graphNode.GetBody()->m_serializedEnum = -1; - } -} - -void dgWorld::OnBodyDeserializeFromFile(dgBody& body, void* const userData, dgDeserialize deserializeCallback, void* const fileHandle) -{ -} - -void dgWorld::DeserializeBodyArray (void* const userData, OnBodyDeserialize bodyCallback, dgTree<dgBody*, dgInt32>&bodyMap, dgDeserialize deserializeCallback, void* const serializeHandle) -{ - dgInt32 revision = dgDeserializeMarker(deserializeCallback, serializeHandle); - - dgTree<const dgCollision*, dgInt32> shapeMap(GetAllocator()); - - dgInt32 uniqueShapes; - deserializeCallback(serializeHandle, &uniqueShapes, sizeof (uniqueShapes)); - for (dgInt32 i = 0; i < uniqueShapes; i++) { - dgInt32 id; - - deserializeCallback(serializeHandle, &id, sizeof (id)); - dgCollisionInstance instance(this, deserializeCallback, serializeHandle, revision); - dgDeserializeMarker(deserializeCallback, serializeHandle); - - const dgCollision* const shape = instance.GetChildShape(); - shapeMap.Insert(shape, id); - shape->AddRef(); - } - - dgInt32 bodyCount; - deserializeCallback(serializeHandle, &bodyCount, sizeof (bodyCount)); - for (dgInt32 i = 0; i < bodyCount; i++) { - dgInt32 bodyType; - deserializeCallback(serializeHandle, &bodyType, sizeof (bodyType)); - dgBody* body = NULL; - - switch (bodyType) - { - case dgBody::m_dynamicBody: - { - body = new (m_allocator)dgDynamicBody(this, &shapeMap, deserializeCallback, serializeHandle, revision); - break; - } - case dgBody::m_kinematicBody: - { - body = new (m_allocator)dgKinematicBody(this, &shapeMap, deserializeCallback, serializeHandle, revision); - break; - } - - case dgBody::m_dynamicBodyAsymatric: - { - body = new (m_allocator)dgDynamicBodyAsymetric(this, &shapeMap, deserializeCallback, serializeHandle, revision); - break; - } - - } - - dgAssert(body); - m_bodiesUniqueID++; - body->m_freeze = false; - body->m_sleeping = false; - body->m_equilibrium = false; - body->m_spawnnedFromCallback = false; - body->m_uniqueID = dgInt32(m_bodiesUniqueID); - - dgBodyMasterList::AddBody(body); - body->SetMatrix(body->GetMatrix()); - m_broadPhase->Add(body); - if (body->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - dgDynamicBody* const dynBody = (dgDynamicBody*)body; - dynBody->SetMassMatrix(dynBody->m_mass.m_w, dynBody->CalculateLocalInertiaMatrix()); - } - - // load user related data - bodyCallback(*body, userData, deserializeCallback, serializeHandle); - - bodyMap.Insert(body, body->m_serializedEnum); - - // sync to next body - dgDeserializeMarker(deserializeCallback, serializeHandle); - } - - dgTree<const dgCollision*, dgInt32>::Iterator iter(shapeMap); - for (iter.Begin(); iter; iter++) { - const dgCollision* const collision = iter.GetNode()->GetInfo(); - collision->Release(); - } -} - -void dgWorld::DeserializeJointArray (const dgTree<dgBody*, dgInt32>&bodyMap, dgDeserialize serializeCallback, void* const userData) -{ - dgInt32 count = 0; - - dgDeserializeMarker (serializeCallback, userData); - serializeCallback(userData, &count, sizeof (count)); - - for (dgInt32 i = 0; i < count; i ++) { - if (m_onDeserializeJointCallback) { - dgInt32 bodyIndex0; - dgInt32 bodyIndex1; - - serializeCallback(userData, &bodyIndex0, sizeof (bodyIndex0)); - serializeCallback(userData, &bodyIndex1, sizeof (bodyIndex1)); - - dgBody* const body0 = (bodyIndex0 != -1) ? bodyMap.Find (bodyIndex0)->GetInfo() : NULL; - dgBody* const body1 = (bodyIndex1 != -1) ? bodyMap.Find (bodyIndex1)->GetInfo() : NULL; - m_onDeserializeJointCallback (body0, body1, serializeCallback, userData); - } - dgDeserializeMarker(serializeCallback, userData); - } - - dgDeserializeMarker(serializeCallback, userData); -} - -void dgWorld::SerializeBodyArray(void* const userData, OnBodySerialize bodyCallback, dgBody** const array, dgInt32 count, dgSerialize serializeCallback, void* const fileHandle) const -{ - dgSerializeMarker(serializeCallback, fileHandle); - - // serialize all collisions - dgInt32 uniqueShapes = 0; - dgTree<dgInt32, const dgCollision*> shapeMap(GetAllocator()); - for (dgInt32 i = 0; i < count; i++) { - dgBody* const body = array[i]; - dgAssert(body->m_world == this); - dgCollisionInstance* const instance = body->GetCollision(); - const dgCollision* const collision = instance->GetChildShape(); - dgTree<dgInt32, const dgCollision*>::dgTreeNode* const shapeNode = shapeMap.Insert(uniqueShapes, collision); - if (shapeNode) { - uniqueShapes++; - } - } - - serializeCallback(fileHandle, &uniqueShapes, sizeof (uniqueShapes)); - dgTree<dgInt32, const dgCollision*>::Iterator iter(shapeMap); - for (iter.Begin(); iter; iter++) { - dgInt32 id = iter.GetNode()->GetInfo(); - const dgCollision* const collision = iter.GetKey(); - dgCollisionInstance instance(this, collision, 0, dgMatrix(dgGetIdentityMatrix())); - serializeCallback(fileHandle, &id, sizeof (id)); - instance.Serialize(serializeCallback, fileHandle); - dgSerializeMarker(serializeCallback, fileHandle); - } - - serializeCallback(fileHandle, &count, sizeof (count)); - for (dgInt32 i = 0; i < count; i++) { - dgBody* const body = array[i]; - - dgInt32 bodyType = body->GetType(); - serializeCallback(fileHandle, &bodyType, sizeof (bodyType)); - - // serialize the body - body->Serialize(shapeMap, serializeCallback, fileHandle); - - // serialize body custom data - bodyCallback(*body, userData, serializeCallback, fileHandle); - - dgSerializeMarker(serializeCallback, fileHandle); - } -} - -void dgWorld::SerializeJointArray(dgInt32 bodyCount, dgSerialize serializeCallback, void* const userData) const -{ - dgInt32 count = 0; - const dgBodyMasterList* me = this; - for (dgBodyMasterList::dgListNode* node = me->GetFirst(); node; node = node->GetNext()) { - const dgBodyMasterListRow& info = node->GetInfo(); - for (dgBodyMasterListRow::dgListNode *jointNode = info.GetFirst(); jointNode; jointNode = jointNode->GetNext()) { - const dgBodyMasterListCell& cell = jointNode->GetInfo(); - - dgConstraint* const joint = cell.m_joint; - count += joint->IsBilateral() ? 1 : 0; - } - } - - // dgTree<int, dgBody*> bodyMap (GetAllocator()); - // for (dgInt32 i = 0; i < bodyCount; i ++) { - // bodyMap.Insert (i, bodyArray[i]); - // } - - count /= 2; - dgSerializeMarker(serializeCallback, userData); - serializeCallback(userData, &count, sizeof (count)); - - dgTree<int, dgConstraint*> map(GetAllocator()); - for (dgBodyMasterList::dgListNode* node = me->GetFirst(); node; node = node->GetNext()) { - dgBodyMasterListRow& info = node->GetInfo(); - for (dgBodyMasterListRow::dgListNode *jointNode = info.GetFirst(); jointNode; jointNode = jointNode->GetNext()) { - const dgBodyMasterListCell& cell = jointNode->GetInfo(); - dgConstraint* const joint = cell.m_joint; - if (joint->IsBilateral()) { - if (!map.Find(joint)) { - map.Insert(0, joint); - dgAssert(joint->GetBody0()); - dgAssert(joint->GetBody1()); - const dgInt32 body0 = (joint->GetBody0() != m_sentinelBody) ? joint->GetBody0()->m_serializedEnum : -1; - const dgInt32 body1 = (joint->GetBody1() != m_sentinelBody) ? joint->GetBody1()->m_serializedEnum : -1; - - serializeCallback(userData, &body0, sizeof (dgInt32)); - serializeCallback(userData, &body1, sizeof (dgInt32)); - - dgBilateralConstraint* const bilateralJoint = (dgBilateralConstraint*)joint; - bilateralJoint->Serialize(serializeCallback, userData); - - dgSerializeMarker(serializeCallback, userData); - } - } - } - } - - dgSerializeMarker(serializeCallback, userData); -} - diff --git a/thirdparty/src/newton/dgPhysics/dgWorld.h b/thirdparty/src/newton/dgPhysics/dgWorld.h deleted file mode 100644 index 692c29db9..000000000 --- a/thirdparty/src/newton/dgPhysics/dgWorld.h +++ /dev/null @@ -1,654 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_WORLD_H_ -#define _DG_WORLD_H_ - -#include "dgBody.h" -#include "dgContact.h" -#include "dgCollision.h" -#include "dgBroadPhase.h" -#include "dgWorldPlugins.h" -#include "dgCollisionScene.h" -#include "dgBodyMasterList.h" -#include "dgWorldDynamicUpdate.h" -#include "dgBilateralConstraint.h" -//#include "dgDeformableBodiesUpdate.h" -#include "dgCollisionCompoundFractured.h" - -#define DG_REDUCE_CONTACT_TOLERANCE dgFloat32 (5.0e-2f) -#define DG_PRUNE_CONTACT_TOLERANCE dgFloat32 (5.0e-2f) - -#define DG_SLEEP_ENTRIES 8 -#define DG_MAX_DESTROYED_BODIES_BY_FORCE 8 - -class dgBody; -class dgDynamicBody; -class dgKinematicBody; -class dgCollisionPoint; -class dgUserConstraint; -class dgBallConstraint; -class dgHingeConstraint; -class dgUserMeshCreation; -class dgSlidingConstraint; -class dgCollisionInstance; -class dgSkeletonContainer; -class dgUpVectorConstraint; -class dgUniversalConstraint; -class dgCorkscrewConstraint; -class dgCollisionDeformableMesh; - - -class dgBodyCollisionList: public dgTree<const dgCollision*, dgUnsigned32> -{ - public: - dgBodyCollisionList (dgMemoryAllocator* const allocator) - :dgTree<const dgCollision*, dgUnsigned32>(allocator) - { - } -}; - -class dgBodyMaterialList: public dgTree<dgContactMaterial, dgUnsigned32> -{ - public: - dgBodyMaterialList (dgMemoryAllocator* const allocator) - :dgTree<dgContactMaterial, dgUnsigned32>(allocator) - { - } -}; - -class dgSkeletonList: public dgList<dgSkeletonContainer*> -{ - public: - dgSkeletonList(dgMemoryAllocator* const allocator) - :dgList<dgSkeletonContainer*>(allocator) - ,m_lruMarker(1) - ,m_skelListIsDirty(true) - { - } - - dgInt32 m_lruMarker; - bool m_skelListIsDirty; -}; - -class dgWorld; -class dgCollisionInstance; -class dgCollisionParamProxy; - -class dgSolverProgressiveSleepEntry -{ - public: - dgFloat32 m_maxAccel; - dgFloat32 m_maxAlpha; - dgFloat32 m_maxVeloc; - dgFloat32 m_maxOmega; - dgInt32 m_steps; -}; - -class dgWorldThreadPool: public dgThreadHive -{ - public: - dgWorldThreadPool(dgMemoryAllocator* const allocator) - :dgThreadHive(allocator) - { - } - - virtual void OnBeginWorkerThread (dgInt32 threadId); - virtual void OnEndWorkerThread (dgInt32 threadId); -}; - -class dgDeadJoints: public dgTree<dgConstraint*, void* > -{ - public: - dgDeadJoints(dgMemoryAllocator* const allocator); - void DestroyJoints(dgWorld& world); - void DestroyJoint(dgConstraint* const joint); - private: - dgInt32 m_lock; -}; - -class dgDeadBodies: public dgTree<dgBody*, void* > -{ - public: - dgDeadBodies(dgMemoryAllocator* const allocator); - void DestroyBody(dgBody* const body); - void DestroyBodies(dgWorld& world); - - private: - dgInt32 m_lock; -}; - -typedef void (*OnPostUpdateCallback) (const dgWorld* const world, dgFloat32 timestep); - -DG_MSC_VECTOR_ALIGNMENT -class dgWorld - :public dgBodyMasterList - ,public dgBodyMaterialList - ,public dgBodyCollisionList - ,public dgSkeletonList - ,public dgContactList - ,public dgBilateralConstraintList - ,public dgWorldDynamicUpdate - ,public dgMutexThread - ,public dgAsyncThread - ,public dgWorldThreadPool - ,public dgDeadBodies - ,public dgDeadJoints - ,public dgWorldPluginList -{ - public: - typedef void (dgApi *OnCreateContact) (const dgWorld* const world, const dgContact* const contact); - typedef void (dgApi *OnDestroyContact) (const dgWorld* const world, const dgContact* const contact); - typedef dgUnsigned32 (dgApi *OnClusterUpdate) (const dgWorld* const world, void* island, dgInt32 bodyCount); - typedef void (dgApi *OnListenerBodyDestroyCallback) (const dgWorld* const world, void* const listener, dgBody* const body); - typedef void (dgApi *OnListenerUpdateCallback) (const dgWorld* const world, void* const listener, dgFloat32 timestep); - typedef void (dgApi *OnListenerDestroyCallback) (const dgWorld* const world, void* const listener); - typedef void (dgApi *OnListenerDebugCallback) (const dgWorld* const world, void* const listener, void* const debugContext); - typedef void (dgApi *OnBodySerialize) (dgBody& me, void* const userData, dgSerialize funt, void* const serilalizeObject); - typedef void (dgApi *OnBodyDeserialize) (dgBody& me, void* const userData, dgDeserialize funt, void* const serilalizeObject); - typedef void (dgApi *OnCollisionInstanceDestroy) (const dgWorld* const world, const dgCollisionInstance* const collision); - typedef void (dgApi *OnCollisionInstanceDuplicate) (const dgWorld* const world, dgCollisionInstance* const collision, const dgCollisionInstance* const sourceCollision); - - typedef void (dgApi *OnJointSerializationCallback) (const dgUserConstraint* const joint, dgSerialize funt, void* const serilalizeObject); - typedef void (dgApi *OnJointDeserializationCallback) (const dgBody* const body0, const dgBody* const body1, dgDeserialize funt, void* const serilalizeObject); - - enum dgBroadPhaseType - { - m_broadphaseMixed, - m_broadphaseSegregated, - }; - - class dgListener - { - public: - dgListener() - :m_world(NULL) - ,m_userData(NULL) - ,m_onPostStep(NULL) - ,m_onPreUpdate(NULL) - ,m_onPostUpdate(NULL) - ,m_onDebugCallback(NULL) - ,m_onListenerDestroy(NULL) - ,m_onBodyDestroy(NULL) - { - } - - ~dgListener() - { - if (m_onListenerDestroy) { - m_onListenerDestroy(m_world, m_userData); - } - } - - char m_name[32]; - dgWorld* m_world; - void* m_userData; - OnListenerUpdateCallback m_onPostStep; - OnListenerUpdateCallback m_onPreUpdate; - OnListenerUpdateCallback m_onPostUpdate; - OnListenerDebugCallback m_onDebugCallback; - OnListenerDestroyCallback m_onListenerDestroy; - OnListenerBodyDestroyCallback m_onBodyDestroy; - }; - - class dgListenerList: public dgList <dgListener> - { - public: - dgListenerList (dgMemoryAllocator* const allocator) - :dgList <dgListener>(allocator) - { - } - - ~dgListenerList() - { - } - }; - - DG_CLASS_ALLOCATOR(allocator) - - dgWorld(dgMemoryAllocator* const allocator); - ~dgWorld(); - - dgFloat32 GetUpdateTime() const; - dgBroadPhase* GetBroadPhase() const; - - dgInt32 GetSolverIterations() const; - void SetSolverIterations (dgInt32 mode); - - OnPostUpdateCallback GetPostUpdateCallback() const; - void SetPostUpdateCallback (OnPostUpdateCallback callback); - - void EnableParallelSolverOnLargeIsland(dgInt32 mode); - dgInt32 GetParallelSolverOnLargeIsland() const; - - void FlushCache(); - - virtual dgUnsigned64 GetTimeInMicrosenconds() const; - - void* GetUserData() const; - void SetUserData (void* const userData); - - void Update (dgFloat32 timestep); - void UpdateAsync (dgFloat32 timestep); - void StepDynamics (dgFloat32 timestep); - - dgInt32 Collide (const dgCollisionInstance* const collisionA, const dgMatrix& matrixA, - const dgCollisionInstance* const collisionB, const dgMatrix& matrixB, - dgTriplex* const points, dgTriplex* const normals, dgFloat32* const penetration, - dgInt64* const attibuteA, dgInt64* const attibuteB, dgInt32 maxContacts, dgInt32 threadIndex); - - dgInt32 CollideContinue (const dgCollisionInstance* const collisionA, const dgMatrix& matrixA, const dgVector& velocA, const dgVector& omegaA, - const dgCollisionInstance* const collisionB, const dgMatrix& matrixB, const dgVector& velocB, const dgVector& omegaB, - dgFloat32& timeStep, dgTriplex* const points, dgTriplex* const normals, dgFloat32* const penetration, - dgInt64* const attibuteA, dgInt64* const attibuteB, dgInt32 maxContacts, dgInt32 threadIndex); - - bool IntersectionTest (const dgCollisionInstance* const collisionA, const dgMatrix& matrixA, - const dgCollisionInstance* const collisionB, const dgMatrix& matrixB, - dgInt32 threadIndex); - - dgInt32 ClosestPoint (dgTriplex& point, const dgCollisionInstance* const collision, const dgMatrix& matrix, dgTriplex& contact, dgTriplex& normal, dgInt32 threadIndex); - dgInt32 ClosestPoint (const dgCollisionInstance* const collisionA, const dgMatrix& matrixA, - const dgCollisionInstance* const collisionB, const dgMatrix& matrixB, - dgTriplex& contactA, dgTriplex& contactB, dgTriplex& normalAB, dgInt32 threadIndex); - - void SetFrictionThreshold (dgFloat32 acceletion); - - void ListenersDebug(void* const debugContext); - void* GetListenerUserData (void* const listener) const; - void* FindListener (const char* const nameid) const; - - void* AddListener (const char* const nameid, void* const userData); - void ListenerSetPostStep (void* const listener, OnListenerUpdateCallback updateCallback); - void ListenerSetPostUpdate (void* const listener, OnListenerUpdateCallback updateCallback); - void ListenerSetPreUpdate (void* const listener, OnListenerUpdateCallback updateCallback); - void ListenerSetDestroyCallback (void* const listener, OnListenerDestroyCallback destroyCallback); - - void SetListenerBodyDebugCallback (void* const listener, OnListenerDebugCallback callback); - void SetListenerBodyDestroyCallback (void* const listener, OnListenerBodyDestroyCallback callback); - OnListenerBodyDestroyCallback GetListenerBodyDestroyCallback (void* const listener) const; - - void SetIslandUpdateCallback (OnClusterUpdate callback); - void SetCreateDestroyContactCallback(OnCreateContact createContactCallback, OnDestroyContact destroyContactCallback); - - void InitBody (dgBody* const body, dgCollisionInstance* const collision, const dgMatrix& matrix); - dgDynamicBody* CreateDynamicBody (dgCollisionInstance* const collision, const dgMatrix& matrix); - dgKinematicBody* CreateKinematicBody (dgCollisionInstance* const collision, const dgMatrix& matrix); - dgDynamicBody* CreateDynamicBodyAsymetric(dgCollisionInstance* const collision, const dgMatrix& matrix); - void DestroyBody(dgBody* const body); - void DestroyAllBodies (); - - // apply the transform matrix to the body and recurse trough all bodies attached to this body with a - // bilateral joint contact joint are ignored. - void BodySetMatrix (dgBody* const body, const dgMatrix& matrix); - - dgInt32 GetBodiesCount() const; - dgInt32 GetConstraintsCount() const; - dgUnsigned32 GetFrameNumber() const; - - dgCollisionInstance* CreateInstance (const dgCollision* const child, dgInt32 shapeID, const dgMatrix& offsetMatrix); - - dgCollisionInstance* CreateNull (); - dgCollisionInstance* CreateSphere (dgFloat32 radiusdg, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix()); - dgCollisionInstance* CreateCone (dgFloat32 radius, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix()); - dgCollisionInstance* CreateCapsule (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix()); - dgCollisionInstance* CreateCylinder (dgFloat32 radio0, dgFloat32 radio1, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix()); - dgCollisionInstance* CreateBox (dgFloat32 dx, dgFloat32 dy, dgFloat32 dz, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix()); - dgCollisionInstance* CreateConvexHull (dgInt32 count, const dgFloat32* const points, dgInt32 strideInBytes, dgFloat32 thickness, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix()); - dgCollisionInstance* CreateChamferCylinder (dgFloat32 radius, dgFloat32 height, dgInt32 shapeID, const dgMatrix& offsetMatrix = dgGetIdentityMatrix()); - dgCollisionInstance* CreateCompound (); - dgCollisionInstance* CreateFracturedCompound (dgMeshEffect* const solidMesh, int shapeID, int fracturePhysicsMaterialID, int pointcloudCount, const dgFloat32* const vertexCloud, int strideInBytes, int materialID, const dgMatrix& textureMatrix, - dgCollisionCompoundFractured::OnEmitFractureChunkCallBack emitFrafuredChunk, dgCollisionCompoundFractured::OnEmitNewCompundFractureCallBack emitFracturedCompound, dgCollisionCompoundFractured::OnReconstructFractureMainMeshCallBack reconstructMainMesh); - - dgCollisionInstance* CreateDeformableSolid (dgMeshEffect* const mesh, dgInt32 shapeID); - dgCollisionInstance* CreateMassSpringDamperSystem (dgInt32 shapeID, dgInt32 pointCount, const dgFloat32* const points, dgInt32 srideInBytes, const dgFloat32* const pointsMass, dgInt32 linksCount, const dgInt32* const links, const dgFloat32* const linksSpring, const dgFloat32* const LinksDamper); - - dgCollisionInstance* CreateBVH (); - dgCollisionInstance* CreateStaticUserMesh (const dgVector& boxP0, const dgVector& boxP1, const dgUserMeshCreation& data); - dgCollisionInstance* CreateHeightField (dgInt32 width, dgInt32 height, dgInt32 contructionMode, dgInt32 elevationDataType, const void* const elevationMap, const dgInt8* const atributeMap, dgFloat32 verticalScale, dgFloat32 horizontalScale_x, dgFloat32 horizontalScale_z); - dgCollisionInstance* CreateScene (); - - dgBroadPhaseAggregate* CreateAggreGate() const; - void DestroyAggregate(dgBroadPhaseAggregate* const aggregate) const; - - void SetCollisionInstanceConstructorDestructor (OnCollisionInstanceDuplicate constructor, OnCollisionInstanceDestroy destructor); - - static void OnDeserializeFromFile(void* const userData, void* const buffer, dgInt32 size); - static void OnSerializeToFile(void* const userData, const void* const buffer, dgInt32 size); - static dgInt32 SerializeToFileSort (const dgBody* const body0, const dgBody* const body1, void* const context); - static void OnBodySerializeToFile (dgBody& body, void* const userData, dgSerialize serializeCallback, void* const serializeHandle); - static void OnBodyDeserializeFromFile (dgBody& body, void* const userData, dgDeserialize deserializeCallback, void* const serializeHandle); - - dgBody* FindBodyFromSerializedID(dgInt32 serializedID) const; - void SetJointSerializationCallbacks(OnJointSerializationCallback serializeJointCallback, OnJointDeserializationCallback deserializeJointCallback); - void GetJointSerializationCallbacks(OnJointSerializationCallback* const serializeJointCallback, OnJointDeserializationCallback* const deserializeJointCallback) const; - - void SerializeScene(void* const userData, OnBodySerialize bodyCallback, dgSerialize serializeCallback, void* const serializeHandle) const; - void DeserializeScene(void* const userData, OnBodyDeserialize bodyCallback, dgDeserialize deserializeCallback, void* const serializeHandle); - - void SerializeBodyArray (void* const userData, OnBodySerialize bodyCallback, dgBody** const array, dgInt32 count, dgSerialize serializeCallback, void* const serializeHandle) const; - void DeserializeBodyArray (void* const userData, OnBodyDeserialize bodyCallback, dgTree<dgBody*, dgInt32>&bodyMap, dgDeserialize deserializeCallback, void* const serializeHandle); - - void SerializeJointArray (dgInt32 count, dgSerialize serializeCallback, void* const serializeHandle) const; - void DeserializeJointArray (const dgTree<dgBody*, dgInt32>&bodyMap, dgDeserialize serializeCallback, void* const serializeHandle); - - void SerializeCollision (dgCollisionInstance* const shape, dgSerialize deserialization, void* const userData) const; - dgCollisionInstance* CreateCollisionFromSerialization (dgDeserialize deserialization, void* const userData); - void ReleaseCollision(const dgCollision* const collision); - - dgUpVectorConstraint* CreateUpVectorConstraint (const dgVector& pin, dgBody *body); - - dgBallConstraint* CreateBallConstraint (const dgVector& pivot, dgBody* const body0, dgBody *refBody = NULL); - dgHingeConstraint* CreateHingeConstraint (const dgVector& pivot, const dgVector& pin, dgBody* const body0, dgBody *refBody = NULL); - dgSlidingConstraint* CreateSlidingConstraint (const dgVector& pivot, const dgVector& pin, dgBody* const body0, dgBody *refBody = NULL); - dgCorkscrewConstraint* CreateCorkscrewConstraint (const dgVector& pivot, const dgVector& pin, dgBody* const body0, dgBody *refBody = NULL); - dgUniversalConstraint* CreateUniversalConstraint (const dgVector& pivot, const dgVector& pin0, const dgVector& pin1, dgBody* const body0, dgBody *body1 = NULL); - - void DestroyConstraint (dgConstraint* constraint); - - dgSkeletonContainer* CreateNewtonSkeletonContainer (dgBody* const rootBone); - void DestroySkeletonContainer (dgSkeletonContainer* const container); - - dgUnsigned32 CreateBodyGroupID(); - void RemoveAllGroupID(); - - dgUnsigned32 GetDefualtBodyGroupID() const; - dgContactMaterial* GetMaterial (dgUnsigned32 bodyGroupId0, dgUnsigned32 bodyGroupId1) const; - - dgContactMaterial* GetFirstMaterial () const; - dgContactMaterial* GetNextMaterial (dgContactMaterial* material) const; - dgContact* FindContactJoint (const dgBody* body0, const dgBody* body1) const; - - void SetThreadsCount (dgInt32 count); - - //Parallel Job dispatcher for user related stuff - void ExecuteUserJob (dgWorkerThreadTaskCallback userJobKernel, void* const userJobKernelContext, const char* const functionName); - - void BodyEnableSimulation (dgBody* const body); - void BodyDisableSimulation (dgBody* const body); - bool GetBodyEnableDisableSimulationState (dgBody* const body) const; - - dgDynamicBody* GetSentinelBody() const; - dgMemoryAllocator* GetAllocator() const; - - dgInt32 GetBroadPhaseType() const; - void SetBroadPhaseType (dgInt32 type); - void ResetBroadPhase(); - - dgFloat32 GetContactMergeTolerance() const; - void SetContactMergeTolerance(dgFloat32 tolerenace); - - void SetSubsteps (dgInt32 subSteps); - dgInt32 GetSubsteps () const; - void FlushRegisters() const; - - private: - class dgAdressDistPair - { - public: - dgInt32 m_adress; - dgFloat32 m_dist; - }; - - void RunStep (); - void CalculateContacts (dgBroadPhase::dgPair* const pair, dgInt32 threadIndex, bool ccdMode, bool intersectionTestOnly); - - dgInt32 PruneContacts (dgInt32 count, dgContactPoint* const contact, dgFloat32 distTolerenace, dgInt32 maxCount = (DG_CONSTRAINT_MAX_ROWS / 3)) const; - dgInt32 CalculateConvexPolygonToHullContactsDescrete (dgCollisionParamProxy& proxy) const; - dgInt32 CalculatePolySoupToHullContactsDescrete (dgCollisionParamProxy& proxy) const; - dgInt32 CalculateConvexToNonConvexContactsContinue (dgCollisionParamProxy& proxy) const; - dgInt32 CalculateUserContacts (dgCollisionParamProxy& proxy) const; - dgInt32 CalculateConvexToNonConvexContacts (dgCollisionParamProxy& proxy) const; - dgInt32 CalculateConvexToConvexContacts (dgCollisionParamProxy& proxy) const; - dgInt32 PruneContactsByRank(dgInt32 count, dgCollisionParamProxy& proxy, dgInt32 maxCount) const; - - void PopulateContacts (dgBroadPhase::dgPair* const pair, dgInt32 threadIndex); - void ProcessContacts (dgBroadPhase::dgPair* const pair, dgInt32 threadIndex); - - void ConvexContacts (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - void CompoundContacts (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - - void SceneContacts (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - void SceneChildContacts (dgBroadPhase::dgPair* const pair, dgCollisionParamProxy& proxy) const; - - dgFloat32 CalculateTimeToImpact (dgContact* const contactJoint, dgFloat32 timestep, dgInt32 threadIndex, dgVector& p, dgVector& q, dgVector& normal, dgFloat32 dist) const; - dgInt32 ClosestPoint (dgCollisionParamProxy& proxy) const; - //dgInt32 ClosestCompoundPoint (dgBody* const compoundConvexA, dgBody* const collisionB, dgTriplex& contactA, dgTriplex& contactB, dgTriplex& normalAB, dgInt32 threadIndex) const; - dgInt32 ClosestCompoundPoint (dgCollisionParamProxy& proxy) const; - - bool AreBodyConnectedByJoints (dgBody* const origin, dgBody* const target); - - void UpdateSkeletons(); - void UpdateBroadphase(dgFloat32 timestep); - - void AddSentinelBody(); - void InitConvexCollision (); - - dgInt32 Prune3dContacts(const dgMatrix& matrix, dgInt32 count, dgContactPoint* const contact, int maxCount, dgFloat32 distTol) const; - dgInt32 Prune2dContacts(const dgMatrix& matrix, dgInt32 count, dgContactPoint* const contact, int maxCount, dgFloat32 distTol) const; - DG_INLINE dgInt32 PruneSupport(dgInt32 count, const dgVector& dir, const dgVector* points) const; - - DG_INLINE dgBody* FindRoot(dgBody* const body) const; - DG_INLINE dgBody* FindRootAndSplit(dgBody* const body) const; - DG_INLINE void UnionSet(const dgConstraint* const joint) const; - - virtual void Execute (dgInt32 threadID); - virtual void TickCallback (dgInt32 threadID); - void UpdateTransforms(dgBodyMasterList::dgListNode* node, dgInt32 threadID); - - static dgUnsigned32 dgApi GetPerformanceCount (); - static void UpdateTransforms(void* const context, void* const node, dgInt32 threadID); - static dgInt32 SortFaces (const dgAdressDistPair* const A, const dgAdressDistPair* const B, void* const context); - static dgInt32 CompareJointByInvMass (const dgBilateralConstraint* const jointA, const dgBilateralConstraint* const jointB, void* notUsed); - - dgUnsigned32 m_numberOfSubsteps; - dgUnsigned32 m_frameNumber; - dgUnsigned32 m_dynamicsLru; - dgUnsigned32 m_inUpdate; - dgUnsigned32 m_solverIterations; - dgUnsigned32 m_bodyGroupID; - dgUnsigned32 m_defualtBodyGroupID; - dgUnsigned32 m_bodiesUniqueID; - dgUnsigned32 m_useParallelSolver; - dgUnsigned32 m_genericLRUMark; - dgInt32 m_clusterLRU; - - dgFloat32 m_freezeAccel2; - dgFloat32 m_freezeAlpha2; - dgFloat32 m_freezeSpeed2; - dgFloat32 m_freezeOmega2; - dgFloat32 m_frictiomTheshold; - dgFloat32 m_savetimestep; - dgFloat32 m_contactTolerance; - dgFloat32 m_lastExecutionTime; - - dgSolverProgressiveSleepEntry m_sleepTable[DG_SLEEP_ENTRIES]; - - dgBroadPhase* m_broadPhase; - dgDynamicBody* m_sentinelBody; - dgCollisionInstance* m_pointCollision; - - void* m_userData; - dgMemoryAllocator* m_allocator; - - OnClusterUpdate m_onClusterUpdate; - OnCreateContact m_onCreateContact; - OnDestroyContact m_onDestroyContact; - OnCollisionInstanceDestroy m_onCollisionInstanceDestruction; - OnCollisionInstanceDuplicate m_onCollisionInstanceCopyConstrutor; - OnJointSerializationCallback m_onSerializeJointCallback; - OnJointDeserializationCallback m_onDeserializeJointCallback; - OnPostUpdateCallback m_onPostUpdateCallback; - - dgListenerList m_listeners; - dgTree<void*, unsigned> m_perInstanceData; - dgArray<dgBodyInfo> m_bodiesMemory; - dgArray<dgJointInfo> m_jointsMemory; - dgArray<dgBodyCluster> m_clusterMemory; - dgArray<dgUnsigned8> m_solverJacobiansMemory; - dgArray<dgUnsigned8> m_solverRightHandSideMemory; - dgArray<dgUnsigned8> m_solverForceAccumulatorMemory; - - friend class dgBody; - friend class dgSolver; - friend class dgContact; - friend class dgBroadPhase; - friend class dgDeadBodies; - friend class dgDeadJoints; - friend class dgWorldPlugin; - friend class dgContactList; - friend class dgUserConstraint; - friend class dgBodyMasterList; - friend class dgJacobianMemory; - friend class dgCollisionScene; - friend class dgCollisionConvex; - friend class dgBroadPhaseMixed; - friend class dgCollisionInstance; - friend class dgCollisionCompound; - friend class dgParallelBodySolver; - friend class dgWorldDynamicUpdate; - friend class dgParallelSolverClear; - friend class dgParallelSolverSolve; - friend class dgCollisionHeightField; - friend class dgSolverWorlkerThreads; - friend class dgBroadPhaseSegregated; - friend class dgCollisionConvexPolygon; - friend class dgCollidingPairCollector; - friend class dgCollisionDeformableMesh; - friend class dgParallelSolverUpdateForce; - friend class dgParallelSolverUpdateVeloc; - friend class dgParallelSolverBodyInertia; - friend class dgCollisionDeformableSolidMesh; - friend class dgBroadPhaseApplyExternalForce; - friend class dgParallelSolverCalculateForces; - friend class dgCollisionMassSpringDamperSystem; - friend class dgParallelSolverJointAcceleration; - friend class dgParallelSolverBuildJacobianRows; - friend class dgParallelSolverInitFeedbackUpdate; - friend class dgParallelSolverInitInternalForces; - friend class dgParallelSolverBuildJacobianMatrix; - - friend class dgBroadPhaseMaterialCallbackWorkerThread; - friend class dgBroadPhaseCalculateContactsWorkerThread; -} DG_GCC_VECTOR_ALIGNMENT; - - -inline dgMemoryAllocator* dgWorld::GetAllocator() const -{ - return m_allocator; -} - -inline dgBroadPhase* dgWorld::GetBroadPhase() const -{ - return m_broadPhase; -} - -inline void dgWorld::SetSubsteps (dgInt32 subSteps) -{ - m_numberOfSubsteps = dgClamp(subSteps, 1, 8); -} - -inline dgInt32 dgWorld::GetSubsteps () const -{ - return m_numberOfSubsteps; -} - -inline dgFloat32 dgWorld::GetUpdateTime() const -{ - return m_lastExecutionTime; -} - -inline OnPostUpdateCallback dgWorld::GetPostUpdateCallback() const -{ - return m_onPostUpdateCallback; -} - -inline void dgWorld::SetPostUpdateCallback(OnPostUpdateCallback callback) -{ - m_onPostUpdateCallback = callback; -} - -inline dgUnsigned64 dgWorld::GetTimeInMicrosenconds() const -{ - return dgGetTimeInMicrosenconds(); -} - -inline void dgWorld::SetSolverIterations(dgInt32 mode) -{ - m_solverIterations = dgUnsigned32(dgMax(1, mode)); -} - -inline dgInt32 dgWorld::GetSolverIterations() const -{ - return m_solverIterations; -} - -DG_INLINE dgBody* dgWorld::FindRoot(dgBody* const body) const -{ - dgBody* node = body; - for (; node->m_disjointInfo.m_parent != node; node = node->m_disjointInfo.m_parent); - return node; -} - -DG_INLINE dgBody* dgWorld::FindRootAndSplit(dgBody* const body) const -{ - dgBody* node = body; - while (node->m_disjointInfo.m_parent != node) { - dgBody* const prev = node; - node = node->m_disjointInfo.m_parent; - prev->m_disjointInfo.m_parent = node->m_disjointInfo.m_parent; - } - return node; -} - -DG_INLINE void dgWorld::UnionSet(const dgConstraint* const joint) const -{ - dgBody* const body0 = joint->GetBody0(); - dgBody* const body1 = joint->GetBody1(); - dgBody* root0 = FindRootAndSplit(body0); - dgBody* root1 = FindRootAndSplit(body1); - if (root0 != root1) { - if (root0->m_disjointInfo.m_rank < root1->m_disjointInfo.m_rank) { - dgSwap(root0, root1); - } - root1->m_disjointInfo.m_parent = root0; - if (root0->m_disjointInfo.m_rank == root1->m_disjointInfo.m_rank) { - root0->m_disjointInfo.m_rank += 1; - dgAssert(root0->m_disjointInfo.m_rank <= 6); - } - root0->m_disjointInfo.m_rowCount += root1->m_disjointInfo.m_rowCount; - root0->m_disjointInfo.m_bodyCount += root1->m_disjointInfo.m_bodyCount; - root0->m_disjointInfo.m_jointCount += root1->m_disjointInfo.m_jointCount; - } - root0->m_disjointInfo.m_jointCount++; - root0->m_disjointInfo.m_rowCount += joint->m_maxDOF; -} - -DG_INLINE dgUnsigned32 dgWorld::GetFrameNumber() const -{ - return m_frameNumber; -} - -DG_INLINE void dgWorld::FlushRegisters() const -{ - dgWorldPluginList::FlushRegisters(); -} - -#endif diff --git a/thirdparty/src/newton/dgPhysics/dgWorldDynamicUpdate.cpp b/thirdparty/src/newton/dgPhysics/dgWorldDynamicUpdate.cpp deleted file mode 100644 index ad0767bbc..000000000 --- a/thirdparty/src/newton/dgPhysics/dgWorldDynamicUpdate.cpp +++ /dev/null @@ -1,687 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" - -#include "dgBody.h" -#include "dgWorld.h" -#include "dgBroadPhase.h" -#include "dgConstraint.h" -#include "dgDynamicBody.h" -#include "dgCollisionInstance.h" -#include "dgSkeletonContainer.h" -#include "dgWorldDynamicUpdate.h" -#include "dgBilateralConstraint.h" -#include "dgCollisionDeformableMesh.h" - - -dgVector dgWorldDynamicUpdate::m_velocTol (dgFloat32 (1.0e-8f)); - -class dgWorldDynamicUpdateSyncDescriptor -{ - public: - dgWorldDynamicUpdateSyncDescriptor() - { - memset (this, 0, sizeof (dgWorldDynamicUpdateSyncDescriptor)); - } - - dgFloat32 m_timestep; - dgInt32 m_atomicCounter; - - dgInt32 m_clusterCount; - dgInt32 m_firstCluster; -}; - - -void dgJacobianMemory::Init(dgWorld* const world, dgInt32 rowsCount, dgInt32 bodyCount) -{ - world->m_solverJacobiansMemory.ResizeIfNecessary((rowsCount + 1) * sizeof(dgLeftHandSide)); - m_leftHandSizeBuffer = (dgLeftHandSide*)&world->m_solverJacobiansMemory[0]; - - world->m_solverRightHandSideMemory.ResizeIfNecessary((rowsCount + 1) * sizeof(dgRightHandSide)); - m_righHandSizeBuffer = (dgRightHandSide*)&world->m_solverRightHandSideMemory[0]; - - world->m_solverForceAccumulatorMemory.ResizeIfNecessary((bodyCount + 8) * sizeof(dgJacobian)); - m_internalForcesBuffer = (dgJacobian*)&world->m_solverForceAccumulatorMemory[0]; - dgAssert(bodyCount <= (((world->m_solverForceAccumulatorMemory.GetBytesCapacity() - 16) / dgInt32(sizeof(dgJacobian))) & (-8))); - - dgAssert((dgUnsigned64(m_leftHandSizeBuffer) & 0x01f) == 0); - dgAssert((dgUnsigned64(m_internalForcesBuffer) & 0x01f) == 0); -} - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -dgWorldDynamicUpdate::dgWorldDynamicUpdate(dgMemoryAllocator* const allocator) - :m_solverMemory() - ,m_parallelSolver(allocator) - ,m_clusterData(NULL) - ,m_bodies(0) - ,m_joints(0) - ,m_clusters(0) - ,m_markLru(0) - ,m_softBodiesCount(0) - ,m_impulseLru(0) - ,m_softBodyCriticalSectionLock(0) -{ - m_parallelSolver.m_world = (dgWorld*) this; -} - -void dgWorldDynamicUpdate::UpdateDynamics(dgFloat32 timestep) -{ - D_TRACKTIME(); - - m_bodies = 0; - m_joints = 0; - m_clusters = 0; - m_softBodiesCount = 0; - dgWorld* const world = (dgWorld*) this; - world->m_dynamicsLru = world->m_dynamicsLru + DG_BODY_LRU_STEP; - m_markLru = world->m_dynamicsLru; - - dgDynamicBody* const sentinelBody = world->m_sentinelBody; - sentinelBody->m_index = 0; - sentinelBody->m_resting = 1; - sentinelBody->m_sleeping = 1; - sentinelBody->m_autoSleep = 1; - sentinelBody->m_equilibrium = 1; - sentinelBody->m_dynamicsLru = m_markLru; - - BuildClusters(timestep); - const dgInt32 threadCount = world->GetThreadCount(); - - dgWorldDynamicUpdateSyncDescriptor descriptor; - descriptor.m_timestep = timestep; - - dgInt32 index = m_softBodiesCount; - descriptor.m_atomicCounter = 0; - descriptor.m_firstCluster = index; - descriptor.m_clusterCount = m_clusters - index; - - dgInt32 useParallelSolver = world->m_useParallelSolver; -//useParallelSolver = 0; - if (useParallelSolver) { - dgInt32 count = 0; - for (dgInt32 i = 0; (i < m_clusters) && (m_clusterData[index + i].m_jointCount >= DG_PARALLEL_JOINT_COUNT_CUT_OFF); i++) { - count++; - } - if (count) { - CalculateReactionForcesParallel(&m_clusterData[index], count, timestep); - index += count; - } - } - - if (index < m_clusters) { - descriptor.m_atomicCounter = 0; - descriptor.m_firstCluster = index; - descriptor.m_clusterCount = m_clusters - index; - for (dgInt32 i = 0; i < threadCount; i ++) { - world->QueueJob (CalculateClusterReactionForcesKernel, &descriptor, world, "dgWorldDynamicUpdate::CalculateClusterReactionForces"); - } - world->SynchronizationBarrier(); - } - - dgBodyInfo* const bodyArrayPtr = &world->m_bodiesMemory[0]; - for (dgInt32 i = 0; i < m_softBodiesCount; i++) { - dgBodyCluster* const cluster = &m_clusterData[i]; -// IntegrateExternalForce(cluster, timestep, 0); - dgBodyInfo* const bodyArray = &bodyArrayPtr[cluster->m_bodyStart]; - dgAssert (cluster->m_bodyCount == 2); - dgDynamicBody* const body = (dgDynamicBody*)bodyArray[1].m_body; - dgAssert (body->m_collision->IsType(dgCollision::dgCollisionLumpedMass_RTTI)); - body->IntegrateOpenLoopExternalForce(timestep); - IntegrateVelocity(cluster, DG_SOLVER_MAX_ERROR, timestep, 0); - } - - m_clusterData = NULL; -} - -dgInt32 dgWorldDynamicUpdate::CompareKey(dgInt32 highA, dgInt32 lowA, dgInt32 highB, dgInt32 lowB) -{ - if (highA < highB) { - return 1; - } else if (highA > highB) { - return -1; - } - if (lowA < lowB) { - return 1; - } else if (lowA > lowB) { - return -1; - } - return 0; -} - -dgInt32 dgWorldDynamicUpdate::CompareJointInfos(const dgJointInfo* const infoA, const dgJointInfo* const infoB, void*) -{ - return CompareKey(infoA->m_jointCount, infoA->m_setId, infoB->m_jointCount, infoB->m_setId); -} - -dgInt32 dgWorldDynamicUpdate::CompareClusterInfos(const dgBodyCluster* const clusterA, const dgBodyCluster* const clusterB, void* notUsed) -{ - return CompareKey(clusterA->m_jointCount, clusterA->m_bodyStart, clusterB->m_jointCount, clusterB->m_bodyStart); -} - -void dgWorldDynamicUpdate::BuildClusters(dgFloat32 timestep) -{ - D_TRACKTIME(); - dgWorld* const world = (dgWorld*) this; - dgContactList& contactList = *world; - dgBodyMasterList& masterList = *world; - const dgBilateralConstraintList& jointList = *world; - dgInt32 jointCount = contactList.m_activeContactCount; - - dgArray<dgJointInfo>& jointArray = world->m_jointsMemory; - jointArray.ResizeIfNecessary(jointCount + jointList.GetCount()); - dgJointInfo* const baseJointArray = &jointArray[0]; - -#ifdef _DEBUG - for (dgBodyMasterList::dgListNode* node = masterList.GetLast(); node; node = node->GetPrev()) { - const dgBodyMasterListRow& graphNode = node->GetInfo(); - dgBody* const body = graphNode.GetBody(); - if (body->GetInvMass().m_w == dgFloat32(0.0f)) { - for (; node; node = node->GetPrev()) { - dgAssert(node->GetInfo().GetBody()->GetInvMass().m_w == dgFloat32(0.0f)); - } - break; - } - } -#endif - - // add bilateral joints to the joint array - for (dgBilateralConstraintList::dgListNode* node = jointList.GetFirst(); node; node = node->GetNext()) { - dgConstraint* const joint = node->GetInfo(); - if (joint->GetBody0()->m_invMass.m_w || joint->GetBody1()->m_invMass.m_w) { - baseJointArray[jointCount].m_joint = joint; - jointCount++; - } - } - - // form all disjoints sets - for (dgInt32 i = 0; i < jointCount; i ++) { - const dgConstraint* const joint = baseJointArray[i].m_joint; - dgBody* const body0 = joint->GetBody0(); - dgBody* const body1 = joint->GetBody1(); - const dgFloat32 invMass0 = body0->m_invMass.m_w; - const dgFloat32 invMass1 = body1->m_invMass.m_w; - - dgInt32 resting = body0->m_equilibrium & body1->m_equilibrium; - body0->m_resting = resting | (invMass0 == dgFloat32(0.0f)); - body1->m_resting = resting | (invMass1 == dgFloat32(0.0f)); - - if ((invMass0 > dgFloat32 (0.0f)) && (invMass1 > dgFloat32 (0.0f))) { - world->UnionSet(joint); - } else if (invMass1 == dgFloat32 (0.0f)) { - dgBody* const root = world->FindRootAndSplit(body0); - root->m_disjointInfo.m_jointCount += 1; - root->m_disjointInfo.m_rowCount += joint->m_maxDOF; - } else { - dgBody* const root = world->FindRootAndSplit(body1); - root->m_disjointInfo.m_jointCount += 1; - root->m_disjointInfo.m_rowCount += joint->m_maxDOF; - } - } - - // find and tag all sleeping disjoint sets, - // and add single bodies as a set of zero joints and one body - dgInt32 bodyInfoCount = 0; - dgInt32 clustersCount = 0; - dgInt32 augmentedJointCount = jointCount; - - dgArray<dgBodyCluster>& clusterMemory = world->m_clusterMemory; - for (dgBodyMasterList::dgListNode* node = masterList.GetLast(); node && (node->GetInfo().GetBody()->GetInvMass().m_w != dgFloat32(0.0f)); node = node->GetPrev()) { - dgBody* const body = node->GetInfo().GetBody(); - if (body->IsRTTIType(dgBody::m_dynamicBodyRTTI | dgBody::m_dynamicBodyAsymatric)) { - dgBody* root = body; - dgInt32 state = 1; - do { - state &= (root->m_equilibrium & root->m_autoSleep); - root = root->m_disjointInfo.m_parent; - } while (root->m_disjointInfo.m_parent != root); - root->m_jointSet &= state; - - if (!root->m_jointSet && !root->m_disjointInfo.m_jointCount) { - dgJointInfo& jointInfo = jointArray[augmentedJointCount]; - - dgAssert (root == body); - dgAssert (root->m_index == -1); - dgAssert (root->m_disjointInfo.m_bodyCount == 1); - - root->m_index = clustersCount; - jointInfo.m_body = body; - jointInfo.m_jointCount = 0; - jointInfo.m_setId = root->m_index; - jointInfo.m_bodyCount = root->m_disjointInfo.m_bodyCount; - jointInfo.m_pairCount = 0; - - dgBodyCluster& cluster = clusterMemory[clustersCount]; - cluster.m_bodyCount = 2; - cluster.m_jointCount = 0; - cluster.m_rowCount = 0; - cluster.m_hasSoftBodies = 0; - cluster.m_isContinueCollision = 0; - cluster.m_bodyStart = root->m_index; - - clustersCount ++; - bodyInfoCount += 2; - augmentedJointCount ++; - } - } - } - - // remove all sleeping joints sets - dgJointInfo* const augmentedJointArray = &jointArray[0]; - for (dgInt32 i = jointCount - 1; i >= 0; i --) { - dgJointInfo* const jointInfo = &augmentedJointArray[i]; - dgConstraint* const constraint = jointInfo->m_joint; - dgBody* const body = (constraint->GetBody0()->GetInvMass().m_w != dgFloat32 (0.0f)) ? constraint->GetBody0() : constraint->GetBody1(); - dgAssert (body->GetInvMass().m_w); - dgBody* const root = world->FindRoot (body); - if (root->m_jointSet) { - augmentedJointCount --; - augmentedJointArray[i] = augmentedJointArray[augmentedJointCount]; - } else { - if (root->m_index == -1) { - root->m_index = clustersCount; - - dgBodyCluster& cluster = clusterMemory[clustersCount]; - cluster.m_bodyCount = root->m_disjointInfo.m_bodyCount + 1; - cluster.m_jointCount = root->m_disjointInfo.m_jointCount; - cluster.m_rowCount = root->m_disjointInfo.m_rowCount; - cluster.m_hasSoftBodies = 0; - cluster.m_bodyStart = root->m_index; - cluster.m_isContinueCollision = 0; - - clustersCount++; - bodyInfoCount += root->m_disjointInfo.m_bodyCount + 1; - } - jointInfo->m_setId = root->m_index; - jointInfo->m_pairCount = constraint->m_maxDOF; - jointInfo->m_bodyCount = root->m_disjointInfo.m_bodyCount; - jointInfo->m_jointCount = root->m_disjointInfo.m_jointCount; - } - } - - m_clusterData = &world->m_clusterMemory[0]; -// dgSort(augmentedJointArray, augmentedJointCount, CompareJointInfos); -// dgSort(m_clusterData, clustersCount, CompareClusterInfos); - dgParallelSort(*world, augmentedJointArray, augmentedJointCount, CompareJointInfos); - dgParallelSort(*world, m_clusterData, clustersCount, CompareClusterInfos); - - dgInt32 bodyStart = 0; - dgInt32 jointStart = 0; - dgInt32 softBodiesCount = 0; - for (dgInt32 i = 0; i < clustersCount; i++) { - dgBodyCluster& cluster = m_clusterData[i]; - cluster.m_bodyStart = bodyStart; - cluster.m_jointStart = jointStart; - - bodyStart += cluster.m_bodyCount; - softBodiesCount += cluster.m_hasSoftBodies; - jointStart += cluster.m_jointCount ? cluster.m_jointCount : 1; - } - world->m_bodiesMemory.ResizeIfNecessary(bodyStart); - - dgInt32 rowStart = 0; - - for (dgInt32 i = 0; i < clustersCount; i++) { - dgBodyCluster& cluster = m_clusterData[i]; - dgBodyInfo* const bodyArray = &world->m_bodiesMemory[cluster.m_bodyStart]; - dgJointInfo* const jointSetArray = &augmentedJointArray[cluster.m_jointStart]; - bodyArray[0].m_body = world->GetSentinelBody(); - - cluster.m_rowStart = rowStart; - bool clusterIsContinueCollision = false; - if (cluster.m_jointCount) { - dgInt32 bodyIndex = 1; - for (dgInt32 j = 0; j < cluster.m_jointCount; j++) { - dgJointInfo* const jointInfo = &jointSetArray[j]; - dgConstraint* const joint = jointInfo->m_joint; - dgBody* const body0 = joint->m_body0; - dgBody* const body1 = joint->m_body1; - - dgInt32 m0 = 0; - if (body0->GetInvMass().m_w != dgFloat32(0.0f)) { - if (body0->m_disjointInfo.m_rank >= 0) { - body0->m_disjointInfo.m_rank = -1; - body0->m_index = bodyIndex; - bodyArray[bodyIndex].m_body = body0; - bodyIndex++; - dgAssert(bodyIndex <= cluster.m_bodyCount); - } - m0 = body0->m_index; - } - - dgInt32 m1 = 0; - if (body1->GetInvMass().m_w != dgFloat32(0.0f)) { - if (body1->m_disjointInfo.m_rank >= 0) { - body1->m_disjointInfo.m_rank = -1; - body1->m_index = bodyIndex; - bodyArray[bodyIndex].m_body = body1; - bodyIndex++; - dgAssert(bodyIndex <= cluster.m_bodyCount); - } - m1 = body1->m_index; - } - - if (joint->GetId() == dgConstraint::m_contactConstraint) { - // check for CCD mode - if (body0->m_continueCollisionMode | body1->m_continueCollisionMode) { - const dgContact* const contact = (dgContact*) joint; - clusterIsContinueCollision |= contact->EstimateCCD (timestep); - } - } - - jointInfo->m_m0 = m0; - jointInfo->m_m1 = m1; - jointInfo->m_pairStart = rowStart; - rowStart += jointInfo->m_pairCount; - } - - cluster.m_isContinueCollision = clusterIsContinueCollision; - if (cluster.m_isContinueCollision) { - cluster.m_rowCount += DG_CCD_EXTRA_CONTACT_COUNT * cluster.m_jointCount / 2; - if (cluster.m_rowCount < DG_CONSTRAINT_MAX_ROWS) { - cluster.m_rowCount = DG_CONSTRAINT_MAX_ROWS; - } - } - - } else { - dgAssert(cluster.m_bodyCount == 2); - bodyArray[1].m_body = jointSetArray[0].m_body; - } - } - - m_solverMemory.Init(world, rowStart, bodyStart); - - m_bodies = bodyStart; - m_joints = jointStart; - m_clusters = clustersCount; - m_softBodiesCount = softBodiesCount; -} - -dgInt32 dgWorldDynamicUpdate::CompareBodyJacobianPair(const dgBodyJacobianPair* const infoA, const dgBodyJacobianPair* const infoB, void* notUsed) -{ - if (infoA->m_bodyIndex < infoB->m_bodyIndex) { - return -1; - } else if (infoA->m_bodyIndex > infoB->m_bodyIndex) { - return 1; - } - return 0; -} - -dgBody* dgWorldDynamicUpdate::GetClusterBody(const void* const clusterPtr, dgInt32 index) const -{ - const dgClusterCallbackStruct* const cluster = (dgClusterCallbackStruct*)clusterPtr; - - char* const ptr = &((char*)cluster->m_bodyArray)[cluster->m_strideInByte * index]; - dgBody** const bodyPtr = (dgBody**)ptr; - return (index < cluster->m_count) ? ((index >= 0) ? *bodyPtr : NULL) : NULL; -} - -void dgWorldDynamicUpdate::CalculateClusterReactionForcesKernel (void* const context, void* const worldContext, dgInt32 threadID) -{ - D_TRACKTIME(); - dgWorldDynamicUpdateSyncDescriptor* const descriptor = (dgWorldDynamicUpdateSyncDescriptor*) context; - - dgFloat32 timestep = descriptor->m_timestep; - dgWorld* const world = (dgWorld*) worldContext; - dgInt32 count = descriptor->m_clusterCount; - dgBodyCluster* const clusters = &world->m_clusterData[descriptor->m_firstCluster]; - -//static int xxx; -//xxx++; -//if (xxx >= 59) -//xxx *=1; -//dgTrace(("\nframe %d\n", xxx)); - - for (dgInt32 i = dgAtomicExchangeAndAdd(&descriptor->m_atomicCounter, 1); i < count; i = dgAtomicExchangeAndAdd(&descriptor->m_atomicCounter, 1)) { - dgBodyCluster* const cluster = &clusters[i]; - world->ResolveClusterForces (cluster, threadID, timestep); - } -} - -dgInt32 dgWorldDynamicUpdate::GetJacobianDerivatives(dgContraintDescritor& constraintParam, dgJointInfo* const jointInfo, dgConstraint* const constraint, dgLeftHandSide* const leftHandSide, dgRightHandSide* const rightHandSide, dgInt32 rowCount) const -{ - dgInt32 dof = dgInt32(constraint->m_maxDOF); - dgAssert(dof <= DG_CONSTRAINT_MAX_ROWS); - for (dgInt32 i = 0; i < dof; i++) { - constraintParam.m_forceBounds[i].m_low = DG_MIN_BOUND; - constraintParam.m_forceBounds[i].m_upper = DG_MAX_BOUND; - constraintParam.m_forceBounds[i].m_jointForce = NULL; - constraintParam.m_forceBounds[i].m_normalIndex = DG_INDEPENDENT_ROW; - } - - dgAssert(constraint->m_body0); - dgAssert(constraint->m_body1); - - dgBody* const body0 = constraint->m_body0; - dgBody* const body1 = constraint->m_body1; - - dgAssert(body0->IsRTTIType(dgBody::m_dynamicBodyRTTI) || body0->IsRTTIType(dgBody::m_kinematicBodyRTTI)); - dgAssert(body1->IsRTTIType(dgBody::m_dynamicBodyRTTI) || body1->IsRTTIType(dgBody::m_kinematicBodyRTTI)); - - body0->m_inCallback = true; - body1->m_inCallback = true; - dof = constraint->JacobianDerivative(constraintParam); - body0->m_inCallback = false; - body1->m_inCallback = false; - - if (constraint->GetId() == dgConstraint::m_contactConstraint) { - dgContact* const contactJoint = (dgContact*)constraint; - contactJoint->m_isInSkeletonLoop = false; - dgSkeletonContainer* const skeleton0 = body0->GetSkeleton(); - dgSkeletonContainer* const skeleton1 = body1->GetSkeleton(); - if (skeleton0 && (skeleton0 == skeleton1)) { - if (contactJoint->IsSkeletonSelftCollision()) { - contactJoint->m_isInSkeletonLoop = true; - skeleton0->AddSelfCollisionJoint(contactJoint); - } - } else if (contactJoint->IsSkeletonIntraCollision()) { - if (skeleton0 && !skeleton1) { - contactJoint->m_isInSkeletonLoop = true; - skeleton0->AddSelfCollisionJoint(contactJoint); - } else if (skeleton1 && !skeleton0) { - contactJoint->m_isInSkeletonLoop = true; - skeleton1->AddSelfCollisionJoint(contactJoint); - } - } - } else if (constraint->IsBilateral() && !constraint->m_isInSkeleton && (constraint->m_solverModel == 3)) { - dgSkeletonContainer* const skeleton0 = body0->GetSkeleton(); - dgSkeletonContainer* const skeleton1 = body1->GetSkeleton(); - if (skeleton0 || skeleton1) { - if (skeleton0 && !skeleton1) { - constraint->m_isInSkeletonLoop = true; - skeleton0->AddSelfCollisionJoint(constraint); - } else if (skeleton1 && !skeleton0) { - constraint->m_isInSkeletonLoop = true; - skeleton1->AddSelfCollisionJoint(constraint); - } - } - } - - jointInfo->m_pairCount = dof; - jointInfo->m_pairStart = rowCount; - - for (dgInt32 i = 0; i < dof; i++) { - dgAssert(constraintParam.m_forceBounds[i].m_jointForce); - - dgLeftHandSide* const row = &leftHandSide[rowCount]; - dgRightHandSide* const rhs = &rightHandSide[rowCount]; - - row->m_Jt = constraintParam.m_jacobian[i]; - rhs->m_diagDamp = dgFloat32(0.0f); - rhs->m_diagonalRegularizer = dgClamp (constraintParam.m_diagonalRegularizer[i], dgFloat32(1.0e-5f), dgFloat32(1.0f)); - rhs->m_coordenateAccel = constraintParam.m_jointAccel[i]; - rhs->m_restitution = constraintParam.m_restitution[i]; - rhs->m_penetration = constraintParam.m_penetration[i]; - rhs->m_penetrationStiffness = constraintParam.m_penetrationStiffness[i]; - rhs->m_lowerBoundFrictionCoefficent = constraintParam.m_forceBounds[i].m_low; - rhs->m_upperBoundFrictionCoefficent = constraintParam.m_forceBounds[i].m_upper; - rhs->m_jointFeebackForce = constraintParam.m_forceBounds[i].m_jointForce; - - dgAssert (constraintParam.m_forceBounds[i].m_normalIndex >= -1); - rhs->m_normalForceIndex = constraintParam.m_forceBounds[i].m_normalIndex; - rowCount++; - } - - return rowCount; -} - -void dgWorldDynamicUpdate::IntegrateVelocity(const dgBodyCluster* const cluster, dgFloat32 accelTolerance, dgFloat32 timestep, dgInt32 threadID) const -{ - D_TRACKTIME(); - dgWorld* const world = (dgWorld*) this; - dgFloat32 velocityDragCoeff = DG_FREEZZING_VELOCITY_DRAG; - dgBodyInfo* const bodyArray = &world->m_bodiesMemory[cluster->m_bodyStart + 1]; - - dgInt32 count = cluster->m_bodyCount - 1; - if (count <= DG_SMALL_ISLAND_COUNT) { - velocityDragCoeff = dgFloat32(0.9999f); - } - - dgFloat32 maxAccel = dgFloat32(0.0f); - dgFloat32 maxAlpha = dgFloat32(0.0f); - dgFloat32 maxSpeed = dgFloat32(0.0f); - dgFloat32 maxOmega = dgFloat32(0.0f); - - const dgFloat32 speedFreeze = world->m_freezeSpeed2; - const dgFloat32 accelFreeze = world->m_freezeAccel2 * ((count <= DG_SMALL_ISLAND_COUNT) ? dgFloat32(0.01f) : dgFloat32(1.0f)); - //const dgFloat32 accelFreeze = world->m_freezeAccel2 * ((count <= DG_SMALL_ISLAND_COUNT) ? dgFloat32(0.0025f) : dgFloat32(1.0f)); - dgVector velocDragVect(velocityDragCoeff, velocityDragCoeff, velocityDragCoeff, dgFloat32(0.0f)); - - bool stackSleeping = true; - dgInt32 sleepCounter = 10000; - for (dgInt32 i = 0; i < count; i++) { - dgBody* const body = bodyArray[i].m_body; - dgAssert(body->IsRTTIType(dgBody::m_dynamicBodyRTTI) || body->IsRTTIType(dgBody::m_kinematicBody)); - - body->m_equilibrium = 1; - dgVector isMovingMask(body->m_veloc + body->m_omega + body->m_accel + body->m_alpha); - if ((isMovingMask.TestZero().GetSignMask() & 7) != 7) { - dgAssert(body->m_invMass.m_w); - if (body->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - body->IntegrateVelocity(timestep); - } - - dgAssert(body->m_accel.m_w == dgFloat32(0.0f)); - dgAssert(body->m_alpha.m_w == dgFloat32(0.0f)); - dgAssert(body->m_veloc.m_w == dgFloat32(0.0f)); - dgAssert(body->m_omega.m_w == dgFloat32(0.0f)); - dgFloat32 accel2 = body->m_accel.DotProduct(body->m_accel).GetScalar(); - dgFloat32 alpha2 = body->m_alpha.DotProduct(body->m_alpha).GetScalar(); - dgFloat32 speed2 = body->m_veloc.DotProduct(body->m_veloc).GetScalar(); - dgFloat32 omega2 = body->m_omega.DotProduct(body->m_omega).GetScalar(); - - maxAccel = dgMax(maxAccel, accel2); - maxAlpha = dgMax(maxAlpha, alpha2); - maxSpeed = dgMax(maxSpeed, speed2); - maxOmega = dgMax(maxOmega, omega2); - bool equilibrium = (accel2 < accelFreeze) && (alpha2 < accelFreeze) && (speed2 < speedFreeze) && (omega2 < speedFreeze); - if (equilibrium) { - dgVector veloc(body->m_veloc * velocDragVect); - dgVector omega(body->m_omega * velocDragVect); - body->m_veloc = (veloc.DotProduct(veloc) > m_velocTol) & veloc; - body->m_omega = (omega.DotProduct(omega) > m_velocTol) & omega; - } - - body->m_equilibrium = equilibrium ? 1 : 0; - stackSleeping &= equilibrium; - if (body->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - dgDynamicBody* const dynBody = (dgDynamicBody*)body; - sleepCounter = dgMin(sleepCounter, dynBody->m_sleepingCounter); - dynBody->m_sleepingCounter++; - } - - body->UpdateCollisionMatrix(timestep, threadID); - } - } - - if (cluster->m_jointCount) { - if (stackSleeping) { - for (dgInt32 i = 0; i < count; i++) { - dgBody* const body = bodyArray[i].m_body; - dgAssert(body->IsRTTIType(dgBody::m_dynamicBodyRTTI) || body->IsRTTIType(dgBody::m_kinematicBodyRTTI)); - body->m_accel = dgVector::m_zero; - body->m_alpha = dgVector::m_zero; - body->m_veloc = dgVector::m_zero; - body->m_omega = dgVector::m_zero; - body->m_sleeping = body->m_autoSleep; - // force entire island to equilibrium - body->m_equilibrium = 1; - } - } else { - bool state = (maxAccel > world->m_sleepTable[DG_SLEEP_ENTRIES - 1].m_maxAccel) || - (maxAlpha > world->m_sleepTable[DG_SLEEP_ENTRIES - 1].m_maxAlpha) || - (maxSpeed > world->m_sleepTable[DG_SLEEP_ENTRIES - 1].m_maxVeloc) || - (maxOmega > world->m_sleepTable[DG_SLEEP_ENTRIES - 1].m_maxOmega); - if (state) { - for (dgInt32 i = 0; i < count; i++) { - dgBody* const body = bodyArray[i].m_body; - if (body->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - dgDynamicBody* const dynBody = (dgDynamicBody*)body; - dynBody->m_sleepingCounter = 0; - } - } - } else { - if (count < DG_SMALL_ISLAND_COUNT) { - // delay small islands for about 10 seconds - sleepCounter >>= 8; - for (dgInt32 i = 0; i < count; i++) { - dgBody* const body = bodyArray[i].m_body; - body->m_equilibrium = 0; - } - } - dgInt32 timeScaleSleepCount = dgInt32(dgFloat32(60.0f) * sleepCounter * timestep); - - dgInt32 index = DG_SLEEP_ENTRIES; - for (dgInt32 i = 1; i < DG_SLEEP_ENTRIES; i ++) { - if (world->m_sleepTable[i].m_steps > timeScaleSleepCount) { - index = i; - break; - } - } - index --; - - bool state1 = (maxAccel < world->m_sleepTable[index].m_maxAccel) && - (maxAlpha < world->m_sleepTable[index].m_maxAlpha) && - (maxSpeed < world->m_sleepTable[index].m_maxVeloc) && - (maxOmega < world->m_sleepTable[index].m_maxOmega); - if (state1) { - for (dgInt32 i = 0; i < count; i++) { - dgBody* const body = bodyArray[i].m_body; - body->m_accel = dgVector::m_zero; - body->m_alpha = dgVector::m_zero; - body->m_veloc = dgVector::m_zero; - body->m_omega = dgVector::m_zero; - body->m_sleeping = body->m_autoSleep; - // force entire island to equilibrium - body->m_equilibrium = 1; - if (body->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - dgDynamicBody* const dynBody = (dgDynamicBody*)body; - dynBody->m_sleepingCounter = 0; - } - } - } - } - } - } -} diff --git a/thirdparty/src/newton/dgPhysics/dgWorldDynamicUpdate.h b/thirdparty/src/newton/dgPhysics/dgWorldDynamicUpdate.h deleted file mode 100644 index 6e98b76f4..000000000 --- a/thirdparty/src/newton/dgPhysics/dgWorldDynamicUpdate.h +++ /dev/null @@ -1,297 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_WORLD_DYNAMICS_H_ -#define _DG_WORLD_DYNAMICS_H_ - - -#include "dgPhysicsStdafx.h" -#include "dgWorldDynamicsParallelSolver.h" - - -#define DG_BODY_LRU_STEP 2 -#define DG_MAX_SKELETON_JOINT_COUNT 256 -#define DG_MAX_CONTINUE_COLLISON_STEPS 8 -#define DG_SMALL_ISLAND_COUNT 32 - -#define DG_FREEZZING_VELOCITY_DRAG dgFloat32 (0.9f) -#define DG_SOLVER_MAX_ERROR (DG_FREEZE_MAG * dgFloat32 (0.5f)) - -#define DG_CCD_EXTRA_CONTACT_COUNT (8 * 3) -#define DG_PARALLEL_JOINT_COUNT_CUT_OFF (64) -//#define DG_PARALLEL_JOINT_COUNT_CUT_OFF (2) - - -// the solver is a RK order 4, but instead of weighting the intermediate derivative by the usual 1/6, 1/3, 1/3, 1/6 coefficients -// I am using 1/4, 1/4, 1/4, 1/4. -// This is correct.The weighting coefficients of any RK method comes from an arbitrary criteria -// solving for a set of linear equation on the coefficients. -// The standard coefficients just happen to lead to an accurate result because they are optimal -// with respect to a second order solution.For differential equations of higher order, then is not -// clear if the traditional weigh factors are any better than any other set of weighting factors. -// A different set of coefficient generates results that are not much different than the optimal set, -// but it allows for simpler calculation of the intermediate derivatives and also for less intermediate memory. -// For more detail on the derivation of the Runge Kutta coefficients you can go to: -// http://pathfinder.scar.utoronto.ca/~dyer/csca57/book_P/node51.html - -class dgBody; -class dgDynamicBody; -class dgWorldDynamicUpdateSyncDescriptor; - -class dgClusterCallbackStruct -{ - public: - dgWorld* m_world; - dgInt32 m_count; - dgInt32 m_strideInByte; - void* m_bodyArray; -}; - -class dgBodyInfo -{ - public: - dgBody* m_body; -}; - -class dgJointInfo -{ - public: - union - { - struct - { - dgBody* m_body; - dgInt32 m_bodyCount; - dgInt32 m_jointCount; - dgInt32 m_setId; - dgInt32 m_unUsed; - }; - struct - { - dgConstraint* m_joint; - dgInt32 m_m0; - dgInt32 m_m1; - dgInt32 m_pairStart; - dgInt32 m_pairCount; - }; - }; - dgFloat32 m_preconditioner0; - dgFloat32 m_preconditioner1; -}; - -class dgBodyJacobianPair -{ - public: - dgInt32 m_bodyIndex; - dgInt32 m_JointIndex; -}; - -class dgBodyCluster -{ - public: - dgInt32 m_bodyCount; - dgInt32 m_jointCount; - dgInt32 m_rowCount; - dgInt32 m_bodyStart; - dgInt32 m_jointStart; - dgInt32 m_rowStart; - dgInt16 m_hasSoftBodies; - dgInt16 m_isContinueCollision; -}; - -class dgJointImpulseInfo -{ - public: - dgContact* m_joint; - dgInt32 m_m0; - dgInt32 m_m1; - dgInt32 m_pairStart; - dgInt32 m_pairCount; - dgInt32 m_rhsStart; -}; - - -template<class T> -class dgQueue -{ - public: - dgQueue (T* const pool, dgInt32 size) - :m_pool (pool) - { - m_mod = size; - m_lastIndex = 0; - m_firstIndex = 0; - } - - void Insert (T info) - { - m_pool[m_firstIndex] = info; - m_firstIndex ++; - if (m_firstIndex >= m_mod) { - m_firstIndex = 0; - } - dgAssert (m_firstIndex != m_lastIndex); - } - - T Remove () - { - dgAssert (m_firstIndex != m_lastIndex); - - T element = m_pool[m_lastIndex]; - m_lastIndex ++; - if (m_lastIndex >= m_mod) { - m_lastIndex = 0; - } - - return element; - } - - void Reset () - { - m_lastIndex = m_firstIndex; - } - - bool IsEmpty () const - { - return (m_firstIndex == m_lastIndex); - } - - dgInt32 m_mod; - dgInt32 m_firstIndex; - dgInt32 m_lastIndex; - T* m_pool; -}; - -DG_MSC_VECTOR_ALIGNMENT -class dgLeftHandSide -{ - public: - dgJacobianPair m_Jt; - dgJacobianPair m_JMinv; -} DG_GCC_VECTOR_ALIGNMENT; - - -DG_MSC_VECTOR_ALIGNMENT -class dgRightHandSide -{ - public: - dgFloat32 m_force; - dgFloat32 m_diagDamp; - dgFloat32 m_invJinvMJt; - dgFloat32 m_coordenateAccel; - - dgFloat32 m_lowerBoundFrictionCoefficent; - dgFloat32 m_upperBoundFrictionCoefficent; - dgFloat32 m_deltaAccel; - dgFloat32 m_restitution; - - dgFloat32 m_maxImpact; - dgFloat32 m_penetration; - dgFloat32 m_diagonalRegularizer; - dgFloat32 m_penetrationStiffness; - - dgForceImpactPair* m_jointFeebackForce; - dgInt32 m_normalForceIndex; -} DG_GCC_VECTOR_ALIGNMENT; - -class dgJacobianMemory -{ - public: - dgJacobianMemory() {} - void Init (dgWorld* const world, dgInt32 rowsCount, dgInt32 bodyCount); - - dgJacobian* m_internalForcesBuffer; - dgLeftHandSide* m_leftHandSizeBuffer; - dgRightHandSide* m_righHandSizeBuffer; -}; - -class dgWorldDynamicUpdate -{ - public: - class dgParallelClusterArray; - - dgWorldDynamicUpdate(dgMemoryAllocator* const allocator); - ~dgWorldDynamicUpdate() {} - void UpdateDynamics (dgFloat32 timestep); - dgBody* GetClusterBody (const void* const cluster, dgInt32 index) const; - - dgJacobianMemory& GetSolverMemory() { return m_solverMemory; } - virtual dgInt32 GetJacobianDerivatives (dgContraintDescritor& constraintParamOut, dgJointInfo* const jointInfo, dgConstraint* const constraint, dgLeftHandSide* const matrixRow, dgRightHandSide* const rightHandSide, dgInt32 rowCount) const; - virtual void CalculateNetAcceleration (dgBody* const body, const dgVector& invTimeStep, const dgVector& accNorm) const; - - private: - static DG_INLINE dgInt32 CompareKey(dgInt32 highA, dgInt32 lowA, dgInt32 highB, dgInt32 lowB); - static dgInt32 CompareJointInfos(const dgJointInfo* const infoA, const dgJointInfo* const infoB, void* notUsed); - static dgInt32 CompareClusterInfos (const dgBodyCluster* const clusterA, const dgBodyCluster* const clusterB, void* notUsed); - - void BuildClusters(dgFloat32 timestep); - - dgBodyCluster MergeClusters(const dgBodyCluster* const clusterArray, dgInt32 clustersCount) const; - dgInt32 SortClusters(const dgBodyCluster* const cluster, dgFloat32 timestep, dgInt32 threadID) const; - - static dgInt32 CompareBodyJacobianPair(const dgBodyJacobianPair* const infoA, const dgBodyJacobianPair* const infoB, void* notUsed); - static void IntegrateClustersParallelKernel (void* const context, void* const worldContext, dgInt32 threadID); - static void CalculateClusterReactionForcesKernel (void* const context, void* const worldContext, dgInt32 threadID); - - void BuildJacobianMatrix (dgBodyCluster* const cluster, dgInt32 threadID, dgFloat32 timestep) const; - void ResolveClusterForces (dgBodyCluster* const cluster, dgInt32 threadID, dgFloat32 timestep) const; - void IntegrateReactionsForces(const dgBodyCluster* const cluster, dgInt32 threadID, dgFloat32 timestep) const; - void BuildJacobianMatrix (const dgBodyInfo* const bodyInfo, dgJointInfo* const jointInfo, dgJacobian* const internalForces, dgLeftHandSide* const matrixRow, dgRightHandSide* const rightHandSide, dgFloat32 forceImpulseScale) const; - void CalculateClusterReactionForces(const dgBodyCluster* const cluster, dgInt32 threadID, dgFloat32 timestep) const; - - void IntegrateInslandParallel(dgParallelClusterArray* const clusters, dgInt32 threadID); - void CalculateReactionForcesParallel(const dgBodyCluster* const clusters, dgInt32 clustersCount, dgFloat32 timestep); - - dgFloat32 CalculateJointForce(const dgJointInfo* const jointInfo, const dgBodyInfo* const bodyArray, dgJacobian* const internalForces, const dgLeftHandSide* const matrixRow, dgRightHandSide* const rightHandSide) const; - dgFloat32 CalculateJointForce_3_13(const dgJointInfo* const jointInfo, const dgBodyInfo* const bodyArray, dgJacobian* const internalForces, const dgLeftHandSide* const matrixRow, dgRightHandSide* const rightHandSide) const; - dgJacobian IntegrateForceAndToque(dgDynamicBody* const body, const dgVector& force, const dgVector& torque, const dgVector& timestep) const ; - - void IntegrateExternalForce(const dgBodyCluster* const cluster, dgFloat32 timestep, dgInt32 threadID) const; - void IntegrateVelocity (const dgBodyCluster* const cluster, dgFloat32 accelTolerance, dgFloat32 timestep, dgInt32 threadID) const; - void CalculateClusterContacts (dgBodyCluster* const cluster, dgFloat32 timestep, dgInt32 currLru, dgInt32 threadID) const; - - void CalculateImpulseVeloc(dgJointImpulseInfo* const jointInfo, const dgLeftHandSide* const leftHandSide, const dgRightHandSide* const rightHandSide, dgFloat32* const contactVeloc) const; - void ResolveImpulse(const dgJointInfo* const constraintArray, const dgLeftHandSide* const leftHandSide, dgRightHandSide* const rightHandSide, dgDownHeap<dgContact*, dgFloat32>& impactJoints) const; - dgFloat32 CalculateJointImpulse(const dgJointImpulseInfo* const jointInfo, const dgBodyInfo* const bodyArray, dgJacobian* const internalForces, const dgLeftHandSide* const matrixRow, const dgRightHandSide* const rightHandSide, dgFloat32* const relVel, dgFloat32* const outImpulse) const; - - dgJacobianMemory m_solverMemory; - dgParallelBodySolver m_parallelSolver; - dgBodyCluster* m_clusterData; - - dgInt32 m_bodies; - dgInt32 m_joints; - dgInt32 m_clusters; - dgInt32 m_markLru; - dgInt32 m_softBodiesCount; - mutable dgInt32 m_impulseLru; - mutable dgInt32 m_softBodyCriticalSectionLock; - - static dgVector m_velocTol; - - friend class dgWorld; - friend class dgJacobianMemory; - friend class dgSkeletonContainer; - friend class dgParallelBodySolver; - friend class dgSolverWorlkerThreads; -}; - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgWorldDynamicsParallelSolver.cpp b/thirdparty/src/newton/dgPhysics/dgWorldDynamicsParallelSolver.cpp deleted file mode 100644 index 120b6170e..000000000 --- a/thirdparty/src/newton/dgPhysics/dgWorldDynamicsParallelSolver.cpp +++ /dev/null @@ -1,1416 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" - -#include "dgBody.h" -#include "dgWorld.h" -#include "dgConstraint.h" -#include "dgDynamicBody.h" -#include "dgSkeletonContainer.h" -#include "dgWorldDynamicUpdate.h" -#include "dgWorldDynamicsParallelSolver.h" - -#define D_USE_SOA_SOLVER - - -class dgWorldDynamicUpdate::dgParallelClusterArray -{ - public: - dgParallelClusterArray(const dgBodyCluster* const clusterArray, dgInt32 clustersCount, dgFloat32 timestep) - :m_clusterArray(clusterArray) - ,m_clustersCount(clustersCount) - ,m_timestep(timestep) - ,m_atomicIndex(0) - { - } - - const dgBodyCluster* m_clusterArray; - dgInt32 m_clustersCount; - dgFloat32 m_timestep; - dgInt32 m_atomicIndex; -}; - -void dgWorldDynamicUpdate::CalculateReactionForcesParallel(const dgBodyCluster* const clusterArray, dgInt32 clustersCount, dgFloat32 timestep) -{ - DG_TRACKTIME(); - dgWorld* const world = (dgWorld*) this; - - dgBodyCluster cluster(MergeClusters(clusterArray, clustersCount)); - dgBodyInfo* const bodyArray = &world->m_bodiesMemory[m_bodies]; - dgJointInfo* const jointArray = &world->m_jointsMemory[m_joints]; - - if (world->GetCurrentPlugin()) { - dgWorldPlugin* const plugin = world->GetCurrentPlugin()->GetInfo().m_plugin; - plugin->CalculateJointForces(cluster, bodyArray, jointArray, timestep); - } else { - m_parallelSolver.CalculateJointForces(cluster, bodyArray, jointArray, timestep); - } - - dgParallelClusterArray integrateCluster(clusterArray, clustersCount, timestep); - const dgInt32 threadCounts = world->GetThreadCount(); - for (dgInt32 i = 0; i < threadCounts; i++) { - world->QueueJob(IntegrateClustersParallelKernel, &integrateCluster, world, "dgWorldDynamicUpdate::IntegrateClustersParallelKernel"); - } - world->SynchronizationBarrier(); -} - -void dgWorldDynamicUpdate::IntegrateClustersParallelKernel(void* const context, void* const worldPtr, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgWorld* const world = (dgWorld*)worldPtr; - dgParallelClusterArray* const clusterArray = (dgParallelClusterArray*)context; - world->IntegrateInslandParallel(clusterArray, threadID); -} - -void dgWorldDynamicUpdate::IntegrateInslandParallel(dgParallelClusterArray* const clusterArray, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgWorld* const world = (dgWorld*) this; - dgFloat32 timestep = clusterArray->m_timestep; - const dgInt32 clustersCount = clusterArray->m_clustersCount; - for (dgInt32 i = dgAtomicExchangeAndAdd(&clusterArray->m_atomicIndex, 1); i < clustersCount; i = dgAtomicExchangeAndAdd(&clusterArray->m_atomicIndex, 1)) { - world->IntegrateVelocity(&clusterArray->m_clusterArray[i], DG_SOLVER_MAX_ERROR, timestep, 0); - } -} - -dgBodyCluster dgWorldDynamicUpdate::MergeClusters(const dgBodyCluster* const clusterArray, dgInt32 clustersCount) const -{ - DG_TRACKTIME(); - dgBodyCluster cluster; - dgWorld* const world = (dgWorld*) this; - dgInt32 bodyCount = 0; - dgInt32 jointsCount = 0; - dgInt32 rowCount = 0; - for (dgInt32 i = 0; i < clustersCount; i++) { - const dgBodyCluster* const srcCluster = &clusterArray[i]; - bodyCount += srcCluster->m_bodyCount - 1; - jointsCount += srcCluster->m_jointCount; - rowCount += srcCluster->m_rowCount; - } - - world->m_solverMemory.Init(world, rowCount, 2 * bodyCount); - world->m_bodiesMemory.ResizeIfNecessary((m_bodies + bodyCount + 1) * sizeof(dgBodyInfo)); - world->m_jointsMemory.ResizeIfNecessary(m_joints + jointsCount + 32); - - dgBodyInfo* const bodyPtr = &world->m_bodiesMemory[0]; - dgJointInfo* const constraintPtr = &world->m_jointsMemory[0]; - - dgBodyInfo* const bodyArray = &bodyPtr[m_bodies]; - dgJointInfo* const jointArray = &constraintPtr[m_joints]; - - bodyArray[0].m_body = world->m_sentinelBody; - dgAssert(world->m_sentinelBody->m_index == 0); - - dgInt32 rowsCount = 0; - dgInt32 bodyIndex = 1; - dgInt32 jointIndex = 0; - for (dgInt32 i = 0; i < clustersCount; i++) { - const dgBodyCluster* const srcCluster = &clusterArray[i]; - rowsCount += srcCluster->m_rowCount; - - dgBodyInfo* const srcBodyArray = &bodyPtr[srcCluster->m_bodyStart]; - const dgInt32 count = srcCluster->m_bodyCount; - for (dgInt32 j = 1; j < count; j++) { - dgBody* const body = srcBodyArray[j].m_body; - bodyArray[bodyIndex].m_body = body; - body->m_index = bodyIndex; - bodyIndex++; - } - - dgJointInfo* const clusterJointArray = &constraintPtr[srcCluster->m_jointStart]; - const dgInt32 joints = srcCluster->m_jointCount; - for (dgInt32 j = 0; j < joints; j++) { - jointArray[jointIndex] = clusterJointArray[j]; - dgJointInfo* const jointInfo = &jointArray[jointIndex]; - - dgConstraint* const constraint = jointInfo->m_joint; - constraint->m_index = jointIndex; - const dgBody* const body0 = constraint->GetBody0(); - const dgBody* const body1 = constraint->GetBody1(); - - dgInt32 m0 = (body0->GetInvMass().m_w != dgFloat32(0.0f)) ? body0->m_index : 0; - dgInt32 m1 = (body1->GetInvMass().m_w != dgFloat32(0.0f)) ? body1->m_index : 0; - jointInfo->m_m0 = m0; - jointInfo->m_m1 = m1; - jointIndex++; - } - } - - cluster.m_bodyStart = 0; - cluster.m_jointStart = 0; - cluster.m_bodyCount = bodyIndex; - cluster.m_jointCount = jointsCount; - cluster.m_rowCount = rowsCount; - - cluster.m_rowStart = 0; - cluster.m_isContinueCollision = 0; - cluster.m_hasSoftBodies = 0; - - return cluster; -} - -void dgParallelBodySolver::InitWeights() -{ - DG_TRACKTIME(); - const dgJointInfo* const jointArray = m_jointArray; - const dgInt32 jointCount = m_cluster->m_jointCount; - dgBodyProxy* const weight = m_bodyProxyArray; - memset(m_bodyProxyArray, 0, m_cluster->m_bodyCount * sizeof(dgBodyProxy)); - for (dgInt32 i = 0; i < jointCount; i++) { - const dgJointInfo* const jointInfo = &jointArray[i]; - const dgInt32 m0 = jointInfo->m_m0; - const dgInt32 m1 = jointInfo->m_m1; - weight[m0].m_weight += dgFloat32(1.0f); - weight[m1].m_weight += dgFloat32(1.0f); - } - m_bodyProxyArray[0].m_weight = dgFloat32(1.0f); - - dgFloat32 extraPasses = dgFloat32(0.0f); - const dgInt32 bodyCount = m_cluster->m_bodyCount; - - dgSkeletonList& skeletonList = *m_world; - const dgInt32 lru = skeletonList.m_lruMarker; - skeletonList.m_lruMarker += 1; - - m_skeletonCount = 0; - for (dgInt32 i = 1; i < bodyCount; i++) { - extraPasses = dgMax(weight[i].m_weight, extraPasses); - - dgDynamicBody* const body = (dgDynamicBody*)m_bodyArray[i].m_body; - dgSkeletonContainer* const container = body->GetSkeleton(); - if (container && (container->m_lru != lru)) { - container->m_lru = lru; - m_skeletonArray[m_skeletonCount] = container; - m_skeletonCount ++; - } - } - const dgInt32 conectivity = 7; - m_solverPasses += 2 * dgInt32(extraPasses) / conectivity + 1; -} - -void dgParallelBodySolver::InitBodyArray() -{ - for (dgInt32 i = 0; i < m_threadCounts; i++) { - m_world->QueueJob(InitBodyArrayKernel, this, NULL, "dgParallelBodySolver::InitBodyArray"); - } - m_world->SynchronizationBarrier(); - m_bodyProxyArray->m_invWeight = dgFloat32(1.0f); -} - -void dgParallelBodySolver::InitBodyArrayKernel(void* const context, void* const, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgParallelBodySolver* const me = (dgParallelBodySolver*)context; - me->InitBodyArray(threadID); -} - -void dgParallelBodySolver::InitJacobianMatrixKernel(void* const context, void* const, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgParallelBodySolver* const me = (dgParallelBodySolver*)context; - me->InitJacobianMatrix(threadID); -} - -void dgParallelBodySolver::CalculateJointsForceKernel(void* const context, void* const, dgInt32 threadID) -{ - dgParallelBodySolver* const me = (dgParallelBodySolver*)context; - me->CalculateJointsForce(threadID); -} - -void dgParallelBodySolver::CalculateJointsAccelerationKernel(void* const context, void* const, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgParallelBodySolver* const me = (dgParallelBodySolver*)context; - me->CalculateJointsAcceleration(threadID); -} - -void dgParallelBodySolver::IntegrateBodiesVelocityKernel(void* const context, void* const worldContext, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgParallelBodySolver* const me = (dgParallelBodySolver*)context; - me->IntegrateBodiesVelocity(threadID); -} - -void dgParallelBodySolver::CalculateBodiesAccelerationKernel(void* const context, void* const, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgParallelBodySolver* const me = (dgParallelBodySolver*)context; - me->CalculateBodiesAcceleration(threadID); -} - -void dgParallelBodySolver::UpdateForceFeedbackKernel(void* const context, void* const, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgParallelBodySolver* const me = (dgParallelBodySolver*)context; - me->UpdateForceFeedback(threadID); -} - -void dgParallelBodySolver::UpdateKinematicFeedbackKernel(void* const context, void* const, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgParallelBodySolver* const me = (dgParallelBodySolver*)context; - me->UpdateKinematicFeedback(threadID); -} - -void dgParallelBodySolver::TransposeMassMatrixKernel(void* const context, void* const, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgParallelBodySolver* const me = (dgParallelBodySolver*)context; - me->TransposeMassMatrix(threadID); -} - -void dgParallelBodySolver::UpdateRowAccelerationKernel(void* const context, void* const, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgParallelBodySolver* const me = (dgParallelBodySolver*)context; - me->UpdateRowAcceleration(threadID); -} - -DG_INLINE void dgParallelBodySolver::TransposeRow(dgSolverSoaElement* const row, const dgJointInfo* const jointInfoArray, dgInt32 index) -{ - const dgLeftHandSide* const leftHandSide = &m_world->m_solverMemory.m_leftHandSizeBuffer[0]; - const dgRightHandSide* const rightHandSide = &m_world->m_solverMemory.m_righHandSizeBuffer[0]; - dgInt32* const normalIndex = (dgInt32*) &row->m_normalForceIndex[0]; - if (jointInfoArray[0].m_pairCount == jointInfoArray[DG_WORK_GROUP_SIZE - 1].m_pairCount) { - for (dgInt32 i = 0; i < DG_WORK_GROUP_SIZE; i++) { - const dgJointInfo* const jointInfo = &jointInfoArray[i]; - const dgLeftHandSide* const lhs = &leftHandSide[jointInfo->m_pairStart + index]; - const dgRightHandSide* const rhs = &rightHandSide[jointInfo->m_pairStart + index]; - - row->m_Jt.m_jacobianM0.m_linear.m_x[i] = lhs->m_Jt.m_jacobianM0.m_linear.m_x; - row->m_Jt.m_jacobianM0.m_linear.m_y[i] = lhs->m_Jt.m_jacobianM0.m_linear.m_y; - row->m_Jt.m_jacobianM0.m_linear.m_z[i] = lhs->m_Jt.m_jacobianM0.m_linear.m_z; - row->m_Jt.m_jacobianM0.m_angular.m_x[i] = lhs->m_Jt.m_jacobianM0.m_angular.m_x; - row->m_Jt.m_jacobianM0.m_angular.m_y[i] = lhs->m_Jt.m_jacobianM0.m_angular.m_y; - row->m_Jt.m_jacobianM0.m_angular.m_z[i] = lhs->m_Jt.m_jacobianM0.m_angular.m_z; - row->m_Jt.m_jacobianM1.m_linear.m_x[i] = lhs->m_Jt.m_jacobianM1.m_linear.m_x; - row->m_Jt.m_jacobianM1.m_linear.m_y[i] = lhs->m_Jt.m_jacobianM1.m_linear.m_y; - row->m_Jt.m_jacobianM1.m_linear.m_z[i] = lhs->m_Jt.m_jacobianM1.m_linear.m_z; - row->m_Jt.m_jacobianM1.m_angular.m_x[i] = lhs->m_Jt.m_jacobianM1.m_angular.m_x; - row->m_Jt.m_jacobianM1.m_angular.m_y[i] = lhs->m_Jt.m_jacobianM1.m_angular.m_y; - row->m_Jt.m_jacobianM1.m_angular.m_z[i] = lhs->m_Jt.m_jacobianM1.m_angular.m_z; - - row->m_JMinv.m_jacobianM0.m_linear.m_x[i] = lhs->m_JMinv.m_jacobianM0.m_linear.m_x; - row->m_JMinv.m_jacobianM0.m_linear.m_y[i] = lhs->m_JMinv.m_jacobianM0.m_linear.m_y; - row->m_JMinv.m_jacobianM0.m_linear.m_z[i] = lhs->m_JMinv.m_jacobianM0.m_linear.m_z; - row->m_JMinv.m_jacobianM0.m_angular.m_x[i] = lhs->m_JMinv.m_jacobianM0.m_angular.m_x; - row->m_JMinv.m_jacobianM0.m_angular.m_y[i] = lhs->m_JMinv.m_jacobianM0.m_angular.m_y; - row->m_JMinv.m_jacobianM0.m_angular.m_z[i] = lhs->m_JMinv.m_jacobianM0.m_angular.m_z; - row->m_JMinv.m_jacobianM1.m_linear.m_x[i] = lhs->m_JMinv.m_jacobianM1.m_linear.m_x; - row->m_JMinv.m_jacobianM1.m_linear.m_y[i] = lhs->m_JMinv.m_jacobianM1.m_linear.m_y; - row->m_JMinv.m_jacobianM1.m_linear.m_z[i] = lhs->m_JMinv.m_jacobianM1.m_linear.m_z; - row->m_JMinv.m_jacobianM1.m_angular.m_x[i] = lhs->m_JMinv.m_jacobianM1.m_angular.m_x; - row->m_JMinv.m_jacobianM1.m_angular.m_y[i] = lhs->m_JMinv.m_jacobianM1.m_angular.m_y; - row->m_JMinv.m_jacobianM1.m_angular.m_z[i] = lhs->m_JMinv.m_jacobianM1.m_angular.m_z; - - row->m_force[i] = rhs->m_force; - row->m_diagDamp[i] = rhs->m_diagDamp; - row->m_invJinvMJt[i] = rhs->m_invJinvMJt; - row->m_coordenateAccel[i] = rhs->m_coordenateAccel; - row->m_lowerBoundFrictionCoefficent[i] = rhs->m_lowerBoundFrictionCoefficent; - row->m_upperBoundFrictionCoefficent[i] = rhs->m_upperBoundFrictionCoefficent; - //row->m_normalForceIndex.m_i[i] = (rhs->m_normalForceIndex + 1) * DG_WORK_GROUP_SIZE + i; - normalIndex[i] = (rhs->m_normalForceIndex + 1) * DG_WORK_GROUP_SIZE + i; - } - } else { - memset(row, 0, sizeof (dgSolverSoaElement)); - for (dgInt32 i = 0; i < DG_WORK_GROUP_SIZE; i++) { - if (index < jointInfoArray[i].m_pairCount) { - const dgJointInfo* const jointInfo = &jointInfoArray[i]; - const dgLeftHandSide* const lhs = &leftHandSide[jointInfo->m_pairStart + index]; - const dgRightHandSide* const rhs = &rightHandSide[jointInfo->m_pairStart + index]; - - row->m_Jt.m_jacobianM0.m_linear.m_x[i] = lhs->m_Jt.m_jacobianM0.m_linear.m_x; - row->m_Jt.m_jacobianM0.m_linear.m_y[i] = lhs->m_Jt.m_jacobianM0.m_linear.m_y; - row->m_Jt.m_jacobianM0.m_linear.m_z[i] = lhs->m_Jt.m_jacobianM0.m_linear.m_z; - row->m_Jt.m_jacobianM0.m_angular.m_x[i] = lhs->m_Jt.m_jacobianM0.m_angular.m_x; - row->m_Jt.m_jacobianM0.m_angular.m_y[i] = lhs->m_Jt.m_jacobianM0.m_angular.m_y; - row->m_Jt.m_jacobianM0.m_angular.m_z[i] = lhs->m_Jt.m_jacobianM0.m_angular.m_z; - row->m_Jt.m_jacobianM1.m_linear.m_x[i] = lhs->m_Jt.m_jacobianM1.m_linear.m_x; - row->m_Jt.m_jacobianM1.m_linear.m_y[i] = lhs->m_Jt.m_jacobianM1.m_linear.m_y; - row->m_Jt.m_jacobianM1.m_linear.m_z[i] = lhs->m_Jt.m_jacobianM1.m_linear.m_z; - row->m_Jt.m_jacobianM1.m_angular.m_x[i] = lhs->m_Jt.m_jacobianM1.m_angular.m_x; - row->m_Jt.m_jacobianM1.m_angular.m_y[i] = lhs->m_Jt.m_jacobianM1.m_angular.m_y; - row->m_Jt.m_jacobianM1.m_angular.m_z[i] = lhs->m_Jt.m_jacobianM1.m_angular.m_z; - - row->m_JMinv.m_jacobianM0.m_linear.m_x[i] = lhs->m_JMinv.m_jacobianM0.m_linear.m_x; - row->m_JMinv.m_jacobianM0.m_linear.m_y[i] = lhs->m_JMinv.m_jacobianM0.m_linear.m_y; - row->m_JMinv.m_jacobianM0.m_linear.m_z[i] = lhs->m_JMinv.m_jacobianM0.m_linear.m_z; - row->m_JMinv.m_jacobianM0.m_angular.m_x[i] = lhs->m_JMinv.m_jacobianM0.m_angular.m_x; - row->m_JMinv.m_jacobianM0.m_angular.m_y[i] = lhs->m_JMinv.m_jacobianM0.m_angular.m_y; - row->m_JMinv.m_jacobianM0.m_angular.m_z[i] = lhs->m_JMinv.m_jacobianM0.m_angular.m_z; - row->m_JMinv.m_jacobianM1.m_linear.m_x[i] = lhs->m_JMinv.m_jacobianM1.m_linear.m_x; - row->m_JMinv.m_jacobianM1.m_linear.m_y[i] = lhs->m_JMinv.m_jacobianM1.m_linear.m_y; - row->m_JMinv.m_jacobianM1.m_linear.m_z[i] = lhs->m_JMinv.m_jacobianM1.m_linear.m_z; - row->m_JMinv.m_jacobianM1.m_angular.m_x[i] = lhs->m_JMinv.m_jacobianM1.m_angular.m_x; - row->m_JMinv.m_jacobianM1.m_angular.m_y[i] = lhs->m_JMinv.m_jacobianM1.m_angular.m_y; - row->m_JMinv.m_jacobianM1.m_angular.m_z[i] = lhs->m_JMinv.m_jacobianM1.m_angular.m_z; - - row->m_force[i] = rhs->m_force; - row->m_diagDamp[i] = rhs->m_diagDamp; - row->m_invJinvMJt[i] = rhs->m_invJinvMJt; - row->m_coordenateAccel[i] = rhs->m_coordenateAccel; - row->m_lowerBoundFrictionCoefficent[i] = rhs->m_lowerBoundFrictionCoefficent; - row->m_upperBoundFrictionCoefficent[i] = rhs->m_upperBoundFrictionCoefficent; - //row->m_normalForceIndex.m_i[i] = (rhs->m_normalForceIndex + 1) * DG_WORK_GROUP_SIZE + i; - normalIndex[i] = (rhs->m_normalForceIndex + 1) * DG_WORK_GROUP_SIZE + i; - } else { - //row->m_normalForceIndex.m_i[i] = i; - normalIndex[i] = i; - } - } - } -} - -void dgParallelBodySolver::TransposeMassMatrix(dgInt32 threadID) -{ - const dgJointInfo* const jointInfoArray = m_jointArray; - dgSolverSoaElement* const massMatrixArray = &m_massMatrix[0]; - - const dgInt32 step = m_threadCounts; - const dgInt32 jointCount = m_jointCount; - for (dgInt32 i = threadID; i < jointCount; i += step) { - const dgInt32 index = i * DG_WORK_GROUP_SIZE; - const dgInt32 rowCount = jointInfoArray[index].m_pairCount; - const dgInt32 rowSoaStart = dgAtomicExchangeAndAdd(&m_soaRowsCount, rowCount); - m_soaRowStart[i] = rowSoaStart; - for (dgInt32 j = 0; j < rowCount; j++) { - dgSolverSoaElement* const row = &massMatrixArray[rowSoaStart + j]; - TransposeRow(row, &jointInfoArray[index], j); - } - } -} - -DG_INLINE void dgParallelBodySolver::BuildJacobianMatrix(dgJointInfo* const jointInfo, dgLeftHandSide* const leftHandSide, dgRightHandSide* const rightHandSide, dgJacobian* const internalForces) -{ - const dgInt32 m0 = jointInfo->m_m0; - const dgInt32 m1 = jointInfo->m_m1; - const dgInt32 index = jointInfo->m_pairStart; - const dgInt32 count = jointInfo->m_pairCount; - const dgDynamicBody* const body0 = (dgDynamicBody*)m_bodyArray[m0].m_body; - const dgDynamicBody* const body1 = (dgDynamicBody*)m_bodyArray[m1].m_body; - const bool isBilateral = jointInfo->m_joint->IsBilateral(); - - const dgMatrix invInertia0 = body0->m_invWorldInertiaMatrix; - const dgMatrix invInertia1 = body1->m_invWorldInertiaMatrix; - const dgVector invMass0(body0->m_invMass[3]); - const dgVector invMass1(body1->m_invMass[3]); - - dgWorkGroupFloat force0(dgVector::m_zero); - if (body0->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - force0 = dgWorkGroupFloat(body0->m_externalForce, body0->m_externalTorque); - } - - dgWorkGroupFloat force1(dgVector::m_zero); - if (body1->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - force1 = dgWorkGroupFloat(body1->m_externalForce, body1->m_externalTorque); - } - - jointInfo->m_preconditioner0 = dgFloat32(1.0f); - jointInfo->m_preconditioner1 = dgFloat32(1.0f); - if ((invMass0.GetScalar() > dgFloat32(0.0f)) && (invMass1.GetScalar() > dgFloat32(0.0f)) && !(body0->GetSkeleton() && body1->GetSkeleton())) { - const dgFloat32 mass0 = body0->GetMass().m_w; - const dgFloat32 mass1 = body1->GetMass().m_w; - if (mass0 > (DG_DIAGONAL_PRECONDITIONER * mass1)) { - jointInfo->m_preconditioner0 = mass0 / (mass1 * DG_DIAGONAL_PRECONDITIONER); - } else if (mass1 > (DG_DIAGONAL_PRECONDITIONER * mass0)) { - jointInfo->m_preconditioner1 = mass1 / (mass0 * DG_DIAGONAL_PRECONDITIONER); - } - } - - dgWorkGroupFloat forceAcc0(dgVector::m_zero); - dgWorkGroupFloat forceAcc1(dgVector::m_zero); - - const dgWorkGroupFloat weight0(m_bodyProxyArray[m0].m_weight * jointInfo->m_preconditioner0); - const dgWorkGroupFloat weight1(m_bodyProxyArray[m1].m_weight * jointInfo->m_preconditioner0); - - const dgFloat32 forceImpulseScale = dgFloat32(1.0f); - const dgFloat32 preconditioner0 = jointInfo->m_preconditioner0; - const dgFloat32 preconditioner1 = jointInfo->m_preconditioner1; - - for (dgInt32 i = 0; i < count; i++) { - dgLeftHandSide* const lhs = &leftHandSide[index + i]; - dgRightHandSide* const rhs = &rightHandSide[index + i]; - - lhs->m_JMinv.m_jacobianM0.m_linear = lhs->m_Jt.m_jacobianM0.m_linear * invMass0; - lhs->m_JMinv.m_jacobianM0.m_angular = invInertia0.RotateVector(lhs->m_Jt.m_jacobianM0.m_angular); - lhs->m_JMinv.m_jacobianM1.m_linear = lhs->m_Jt.m_jacobianM1.m_linear * invMass1; - lhs->m_JMinv.m_jacobianM1.m_angular = invInertia1.RotateVector(lhs->m_Jt.m_jacobianM1.m_angular); - - const dgWorkGroupFloat& JMinvM0 = (dgWorkGroupFloat&)lhs->m_JMinv.m_jacobianM0; - const dgWorkGroupFloat& JMinvM1 = (dgWorkGroupFloat&)lhs->m_JMinv.m_jacobianM1; - dgWorkGroupFloat tmpAccel((JMinvM0 * force0).MulAdd(JMinvM1, force1)); - - dgFloat32 extenalAcceleration = -tmpAccel.AddHorizontal(); - rhs->m_deltaAccel = extenalAcceleration * forceImpulseScale; - rhs->m_coordenateAccel += extenalAcceleration * forceImpulseScale; - dgAssert(rhs->m_jointFeebackForce); - const dgFloat32 force = rhs->m_jointFeebackForce->GetInitiailGuess() * forceImpulseScale; - //const dgFloat32 force = rhs->m_jointFeebackForce->m_force * forceImpulseScale; - - rhs->m_force = isBilateral ? dgClamp(force, rhs->m_lowerBoundFrictionCoefficent, rhs->m_upperBoundFrictionCoefficent) : force; - rhs->m_maxImpact = dgFloat32(0.0f); - - const dgWorkGroupFloat& JtM0 = (dgWorkGroupFloat&)lhs->m_Jt.m_jacobianM0; - const dgWorkGroupFloat& JtM1 = (dgWorkGroupFloat&)lhs->m_Jt.m_jacobianM1; - - dgWorkGroupFloat tmpDiag((weight0 * JMinvM0 * JtM0).MulAdd(weight1, JMinvM1 * JtM1)); - dgFloat32 diag = tmpDiag.AddHorizontal(); - dgAssert(diag > dgFloat32(0.0f)); - rhs->m_diagDamp = diag * rhs->m_diagonalRegularizer; - diag *= (dgFloat32(1.0f) + rhs->m_diagonalRegularizer); - rhs->m_invJinvMJt = dgFloat32(1.0f) / diag; - - dgWorkGroupFloat f0(rhs->m_force * preconditioner0); - dgWorkGroupFloat f1(rhs->m_force * preconditioner1); - forceAcc0 = forceAcc0.MulAdd(JtM0, f0); - forceAcc1 = forceAcc1.MulAdd(JtM1, f1); - } - - if (m0) { - dgWorkGroupFloat& out = (dgWorkGroupFloat&)internalForces[m0]; - dgScopeSpinPause lock(&m_bodyProxyArray[m0].m_lock); - out = out + forceAcc0; - } - if (m1) { - dgWorkGroupFloat& out = (dgWorkGroupFloat&)internalForces[m1]; - dgScopeSpinPause lock(&m_bodyProxyArray[m1].m_lock); - out = out + forceAcc1; - } -} - -DG_INLINE void dgParallelBodySolver::SortWorkGroup(dgInt32 base) const -{ - dgJointInfo* const jointArray = m_jointArray; - for (dgInt32 i = 1; i < DG_WORK_GROUP_SIZE; i++) { - dgInt32 index = base + i; - const dgJointInfo tmp(jointArray[index]); - for (; (index > base) && (jointArray[index - 1].m_pairCount < tmp.m_pairCount); index--) { - jointArray[index] = jointArray[index - 1]; - } - jointArray[index] = tmp; - } -} - -void dgParallelBodySolver::CalculateBodiesAcceleration() -{ - for (dgInt32 i = 0; i < m_threadCounts; i++) { - m_world->QueueJob(CalculateBodiesAccelerationKernel, this, NULL, "dgParallelBodySolver::CalculateBodiesAcceleration"); - } - m_world->SynchronizationBarrier(); -} - -void dgParallelBodySolver::UpdateForceFeedback() -{ - for (dgInt32 i = 0; i < m_threadCounts; i++) { - m_world->QueueJob(UpdateForceFeedbackKernel, this, NULL, "dgParallelBodySolver::UpdateForceFeedback"); - } - m_world->SynchronizationBarrier(); -} - -void dgParallelBodySolver::UpdateKinematicFeedback() -{ - for (dgInt32 i = 0; i < m_threadCounts; i++) { - m_world->QueueJob(UpdateKinematicFeedbackKernel, this, NULL, "dgParallelBodySolver::UpdateKinematicFeedback"); - } - m_world->SynchronizationBarrier(); -} - -void dgParallelBodySolver::InitJacobianMatrix(dgInt32 threadID) -{ - dgLeftHandSide* const leftHandSide = &m_world->m_solverMemory.m_leftHandSizeBuffer[0]; - dgRightHandSide* const rightHandSide = &m_world->m_solverMemory.m_righHandSizeBuffer[0]; - dgJacobian* const internalForces = &m_world->m_solverMemory.m_internalForcesBuffer[0]; - - dgContraintDescritor constraintParams; - constraintParams.m_world = m_world; - constraintParams.m_threadIndex = threadID; - constraintParams.m_timestep = m_timestep; - constraintParams.m_invTimestep = m_invTimestep; - - const dgInt32 step = m_threadCounts; - const dgInt32 jointCount = m_cluster->m_jointCount; - for (dgInt32 i = threadID; i < jointCount; i += step) { - dgJointInfo* const jointInfo = &m_jointArray[i]; - dgConstraint* const constraint = jointInfo->m_joint; - dgAssert(jointInfo->m_m0 >= 0); - dgAssert(jointInfo->m_m1 >= 0); - dgAssert(jointInfo->m_m0 != jointInfo->m_m1); - const dgInt32 rowBase = dgAtomicExchangeAndAdd(&m_jacobianMatrixRowAtomicIndex, jointInfo->m_pairCount); - m_world->GetJacobianDerivatives(constraintParams, jointInfo, constraint, leftHandSide, rightHandSide, rowBase); - BuildJacobianMatrix(jointInfo, leftHandSide, rightHandSide, internalForces); - } -} - -dgInt32 dgParallelBodySolver::CompareJointInfos(const dgJointInfo* const infoA, const dgJointInfo* const infoB, void* notUsed) -{ - const dgInt32 restingA = (infoA->m_joint->m_body0->m_resting & infoA->m_joint->m_body1->m_resting) ? 1 : 0; - const dgInt32 restingB = (infoB->m_joint->m_body0->m_resting & infoB->m_joint->m_body1->m_resting) ? 1 : 0; - - const dgInt32 countA = (restingA << 24) + infoA->m_pairCount; - const dgInt32 countB = (restingB << 24) + infoB->m_pairCount; - - if (countA < countB) { - return 1; - } - if (countA > countB) { - return -1; - } - return 0; -} - -void dgParallelBodySolver::InitJacobianMatrix() -{ - m_jacobianMatrixRowAtomicIndex = 0; - dgJacobian* const internalForces = &m_world->m_solverMemory.m_internalForcesBuffer[0]; - memset(internalForces, 0, m_cluster->m_bodyCount * sizeof (dgJacobian)); - - for (dgInt32 i = 0; i < m_threadCounts; i++) { - m_world->QueueJob(InitJacobianMatrixKernel, this, NULL, "dgParallelBodySolver::InitJacobianMatrix"); - } - m_world->SynchronizationBarrier(); - -#ifdef D_USE_SOA_SOLVER - dgJointInfo* const jointArray = m_jointArray; -// dgSort(jointArray, m_cluster->m_jointCount, CompareJointInfos); - dgParallelSort(*m_world, jointArray, m_cluster->m_jointCount, CompareJointInfos); - - const dgInt32 jointCount = m_jointCount * DG_WORK_GROUP_SIZE; - for (dgInt32 i = m_cluster->m_jointCount; i < jointCount; i++) { - memset(&jointArray[i], 0, sizeof(dgJointInfo)); - } - - dgInt32 size = 0; - for (dgInt32 i = 0; i < jointCount; i += DG_WORK_GROUP_SIZE) { - const dgConstraint* const joint1 = jointArray[i + DG_WORK_GROUP_SIZE - 1].m_joint; - if (joint1) { - if (!(joint1->m_body0->m_resting & joint1->m_body1->m_resting)) { - const dgConstraint* const joint0 = jointArray[i].m_joint; - if (joint0->m_body0->m_resting & joint0->m_body1->m_resting) { - SortWorkGroup(i); - } - } - for (dgInt32 j = 0; j < DG_WORK_GROUP_SIZE; j++) { - dgConstraint* const joint = jointArray[i + j].m_joint; - joint->m_index = i + j; - } - } else { - SortWorkGroup(i); - for (dgInt32 j = 0; j < DG_WORK_GROUP_SIZE; j ++) { - dgConstraint* const joint = jointArray[i + j].m_joint; - if (joint) { - joint->m_index = i + j; - } - } - } - size += jointArray[i].m_pairCount; - } - m_massMatrix.ResizeIfNecessary(size); - - m_soaRowsCount = 0; - for (dgInt32 i = 0; i < m_threadCounts; i++) { - m_world->QueueJob(TransposeMassMatrixKernel, this, NULL, "dgParallelBodySolver::TransposeMassMatrix"); - } - m_world->SynchronizationBarrier(); -#endif -} - -void dgParallelBodySolver::InitBodyArray(dgInt32 threadID) -{ - const dgBodyInfo* const bodyArray = m_bodyArray; - dgBodyProxy* const bodyProxyArray = m_bodyProxyArray; - - const dgInt32 step = m_threadCounts;; - const dgInt32 bodyCount = m_cluster->m_bodyCount; - for (dgInt32 i = threadID; i < bodyCount; i += step) { - const dgBodyInfo* const bodyInfo = &bodyArray[i]; - dgBody* const body = (dgDynamicBody*)bodyInfo->m_body; - body->AddDampingAcceleration(m_timestep); - body->CalcInvInertiaMatrix(); - - body->m_accel = body->m_veloc; - body->m_alpha = body->m_omega; - - const dgFloat32 w = bodyProxyArray[i].m_weight ? bodyProxyArray[i].m_weight : dgFloat32(1.0f); - bodyProxyArray[i].m_weight = w; - bodyProxyArray[i].m_invWeight = dgFloat32(1.0f) / w; - } -} - -void dgParallelBodySolver::CalculateJointsAcceleration(dgInt32 threadID) -{ - dgJointAccelerationDecriptor joindDesc; - joindDesc.m_timeStep = m_timestepRK; - joindDesc.m_invTimeStep = m_invTimestepRK; - joindDesc.m_firstPassCoefFlag = m_firstPassCoef; - dgRightHandSide* const rightHandSide = &m_world->m_solverMemory.m_righHandSizeBuffer[0]; - const dgLeftHandSide* const leftHandSide = &m_world->m_solverMemory.m_leftHandSizeBuffer[0]; - - const dgInt32 step = m_threadCounts; - const dgInt32 jointCount = m_cluster->m_jointCount; - for (dgInt32 i = threadID; i < jointCount; i += step) { - dgJointInfo* const jointInfo = &m_jointArray[i]; - dgConstraint* const constraint = jointInfo->m_joint; - const dgInt32 pairStart = jointInfo->m_pairStart; - joindDesc.m_rowsCount = jointInfo->m_pairCount; - joindDesc.m_leftHandSide = &leftHandSide[pairStart]; - joindDesc.m_rightHandSide = &rightHandSide[pairStart]; - - constraint->JointAccelerations(&joindDesc); - } -} - -void dgParallelBodySolver::CalculateBodiesAcceleration(dgInt32 threadID) -{ - dgVector invTime(m_invTimestep); - dgFloat32 maxAccNorm2 = DG_SOLVER_MAX_ERROR * DG_SOLVER_MAX_ERROR; - - const dgInt32 step = m_threadCounts; - const dgInt32 bodyCount = m_cluster->m_bodyCount; - for (dgInt32 i = threadID; i < bodyCount; i += step) { - dgDynamicBody* const body = (dgDynamicBody*)m_bodyArray[i].m_body; - m_world->CalculateNetAcceleration(body, invTime, maxAccNorm2); - } -} - -void dgParallelBodySolver::UpdateKinematicFeedback(dgInt32 threadID) -{ - const dgInt32 step = m_threadCounts; - const dgInt32 jointCount = m_cluster->m_jointCount; - for (dgInt32 i = threadID; i < jointCount; i += step) { - dgJointInfo* const jointInfo = &m_jointArray[i]; - if (jointInfo->m_joint->m_updaFeedbackCallback) { - jointInfo->m_joint->m_updaFeedbackCallback(*jointInfo->m_joint, m_timestep, threadID); - } - } -} - -void dgParallelBodySolver::UpdateRowAcceleration(dgInt32 threadID) -{ - dgSolverSoaElement* const massMatrix = &m_massMatrix[0]; - const dgRightHandSide* const rightHandSide = &m_world->m_solverMemory.m_righHandSizeBuffer[0]; - - const dgInt32* const soaRowStart = m_soaRowStart; - const dgJointInfo* const jointInfoArray = m_jointArray; - - const dgInt32 step = m_threadCounts; - const dgInt32 jointCount = m_jointCount; - for (dgInt32 i = threadID; i < jointCount; i += step) { - const dgInt32 rowStart = soaRowStart[i]; - const dgJointInfo* const jointInfoBase = &jointInfoArray[i * DG_WORK_GROUP_SIZE]; - - for (dgInt32 j = 0; j < DG_WORK_GROUP_SIZE; j++) { - const dgJointInfo* const jointInfo = &jointInfoBase[j]; - if (jointInfo->m_joint) { - dgInt32 const rowCount = jointInfo->m_pairCount; - dgInt32 const rowStartBase = jointInfo->m_pairStart; - for (dgInt32 k = 0; k < rowCount; k++) { - dgSolverSoaElement* const row = &massMatrix[rowStart + k]; - row->m_coordenateAccel[j] = rightHandSide[k + rowStartBase].m_coordenateAccel; - } - } - } - } -} - -void dgParallelBodySolver::UpdateForceFeedback(dgInt32 threadID) -{ - const dgRightHandSide* const rightHandSide = &m_world->m_solverMemory.m_righHandSizeBuffer[0]; - dgInt32 hasJointFeeback = 0; - - const dgInt32 step = m_threadCounts; - const dgInt32 jointCount = m_cluster->m_jointCount; - for (dgInt32 i = threadID; i < jointCount; i += step) { - dgJointInfo* const jointInfo = &m_jointArray[i]; - dgConstraint* const constraint = jointInfo->m_joint; - const dgInt32 first = jointInfo->m_pairStart; - const dgInt32 count = jointInfo->m_pairCount; - - for (dgInt32 j = 0; j < count; j++) { - const dgRightHandSide* const rhs = &rightHandSide[j + first]; - dgAssert(dgCheckFloat(rhs->m_force)); - rhs->m_jointFeebackForce->Push(rhs->m_force); - rhs->m_jointFeebackForce->m_force = rhs->m_force; - rhs->m_jointFeebackForce->m_impact = rhs->m_maxImpact * m_timestepRK; - } - hasJointFeeback |= (constraint->m_updaFeedbackCallback ? 1 : 0); - } - m_hasJointFeeback[threadID] = hasJointFeeback; -} - -void dgParallelBodySolver::IntegrateBodiesVelocity(dgInt32 threadID) -{ - dgVector speedFreeze2(m_world->m_freezeSpeed2 * dgFloat32(0.1f)); - dgVector freezeOmega2(m_world->m_freezeOmega2 * dgFloat32(0.1f)); - - dgVector timestep4(m_timestepRK); - dgJacobian* const internalForces = &m_world->m_solverMemory.m_internalForcesBuffer[0]; - - const dgInt32 step = m_threadCounts; - const dgInt32 bodyCount = m_cluster->m_bodyCount - 1; - for (dgInt32 j = threadID; j < bodyCount; j += step) { - const dgInt32 i = j + 1; - dgDynamicBody* const body = (dgDynamicBody*)m_bodyArray[i].m_body; - dgAssert(body->m_index == i); - - if (body->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - const dgJacobian& forceAndTorque = internalForces[i]; - const dgVector force(body->m_externalForce + forceAndTorque.m_linear); - const dgVector torque(body->m_externalTorque + forceAndTorque.m_angular); - - //const dgVector velocStep((force.Scale(body->m_invMass.m_w)) * timestep4); - //const dgVector omegaStep((body->m_invWorldInertiaMatrix.RotateVector(torque)) * timestep4); - const dgJacobian velocStep(body->IntegrateForceAndToque(force, torque, timestep4)); - - if (!body->m_resting) { - //body->m_veloc += velocStep; - //body->m_omega += omegaStep; - body->m_veloc += velocStep.m_linear; - body->m_omega += velocStep.m_angular; - } else { - //const dgVector velocStep2(velocStep.DotProduct(velocStep)); - //const dgVector omegaStep2(omegaStep.DotProduct(omegaStep)); - const dgVector velocStep2(velocStep.m_linear.DotProduct(velocStep.m_linear)); - const dgVector omegaStep2(velocStep.m_angular.DotProduct(velocStep.m_angular)); - const dgVector test(((velocStep2 > speedFreeze2) | (omegaStep2 > speedFreeze2)) & dgVector::m_negOne); - const dgInt32 equilibrium = test.GetSignMask() ? 0 : 1; - body->m_resting &= equilibrium; - } - dgAssert(body->m_veloc.m_w == dgFloat32(0.0f)); - dgAssert(body->m_omega.m_w == dgFloat32(0.0f)); - } - } -} - -void dgParallelBodySolver::IntegrateBodiesVelocity() -{ - DG_TRACKTIME(); - for (dgInt32 i = 0; i < m_threadCounts; i++) { - m_world->QueueJob(IntegrateBodiesVelocityKernel, this, NULL, "dgParallelBodySolver::IntegrateBodiesVelocity"); - } - m_world->SynchronizationBarrier(); -} - -void dgParallelBodySolver::CalculateJointsForce() -{ - DG_TRACKTIME(); - const dgInt32 bodyCount = m_cluster->m_bodyCount; - dgJacobian* const internalForces = &m_world->GetSolverMemory().m_internalForcesBuffer[0]; - dgJacobian* const tempInternalForces = &m_world->GetSolverMemory().m_internalForcesBuffer[bodyCount]; - const dgInt32 passes = m_solverPasses; - const dgInt32 threadCounts = m_world->GetThreadCount(); - - dgFloat32 accNorm = DG_SOLVER_MAX_ERROR * dgFloat32(2.0f); - for (dgInt32 k = 0; (k < passes) && (accNorm > DG_SOLVER_MAX_ERROR); k++) { - memset(tempInternalForces, 0, bodyCount * sizeof(dgJacobian)); - for (dgInt32 i = 0; i < threadCounts; i++) { - m_world->QueueJob(CalculateJointsForceKernel, this, NULL, "dgSolver::CalculateJointsForce"); - } - m_world->SynchronizationBarrier(); - memcpy(internalForces, tempInternalForces, bodyCount * sizeof(dgJacobian)); - for (dgInt32 i = 0; i < threadCounts; i++) { - accNorm = dgMax(accNorm, m_accelNorm[i]); - } - } -} - -void dgParallelBodySolver::CalculateJointsAccel() -{ - DG_TRACKTIME(); - for (dgInt32 i = 0; i < m_threadCounts; i++) { - m_world->QueueJob(CalculateJointsAccelerationKernel, this, NULL, "dgParallelBodySolver::CalculateJointsAcceleration"); - } - m_world->SynchronizationBarrier(); - m_firstPassCoef = dgFloat32(1.0f); - -#ifdef D_USE_SOA_SOLVER - for (dgInt32 i = 0; i < m_threadCounts; i++) { - m_world->QueueJob(UpdateRowAccelerationKernel, this, NULL, "dgParallelBodySolver::UpdateRowAcceleration"); - } - m_world->SynchronizationBarrier(); -#endif -} - -void dgParallelBodySolver::InitSkeletons(dgInt32 threadID) -{ - dgRightHandSide* const rightHandSide = &m_world->m_solverMemory.m_righHandSizeBuffer[0]; - const dgLeftHandSide* const leftHandSide = &m_world->m_solverMemory.m_leftHandSizeBuffer[0]; - - const dgInt32 count = m_skeletonCount; - const dgInt32 threadCounts = m_world->GetThreadCount(); - dgSkeletonContainer** const skeletonArray = &m_skeletonArray[0]; - - for (dgInt32 i = threadID; i < count; i += threadCounts) { - dgSkeletonContainer* const skeleton = skeletonArray[i]; - skeleton->InitMassMatrix(m_jointArray, leftHandSide, rightHandSide); - } -} - -void dgParallelBodySolver::UpdateSkeletons(dgInt32 threadID) -{ - const dgInt32 count = m_skeletonCount; - const dgInt32 threadCounts = m_world->GetThreadCount(); - dgSkeletonContainer** const skeletonArray = &m_skeletonArray[0]; - dgJacobian* const internalForces = &m_world->m_solverMemory.m_internalForcesBuffer[0]; - - for (dgInt32 i = threadID; i < count; i += threadCounts) { - dgSkeletonContainer* const skeleton = skeletonArray[i]; - skeleton->CalculateJointForce(m_jointArray, m_bodyArray, internalForces); - } -} - -void dgParallelBodySolver::InitSkeletonsKernel(void* const context, void* const, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgParallelBodySolver* const me = (dgParallelBodySolver*)context; - me->InitSkeletons(threadID); -} - -void dgParallelBodySolver::UpdateSkeletonsKernel(void* const context, void* const, dgInt32 threadID) -{ - DG_TRACKTIME(); - dgParallelBodySolver* const me = (dgParallelBodySolver*)context; - me->UpdateSkeletons(threadID); -} - -void dgParallelBodySolver::InitSkeletons() -{ - DG_TRACKTIME(); - const dgInt32 threadCounts = m_world->GetThreadCount(); - for (dgInt32 i = 0; i < threadCounts; i++) { - m_world->QueueJob(InitSkeletonsKernel, this, NULL, "dgSolver::InitSkeletonsKernel"); - } - m_world->SynchronizationBarrier(); -} - -void dgParallelBodySolver::UpdateSkeletons() -{ - DG_TRACKTIME(); - const dgInt32 threadCounts = m_world->GetThreadCount(); - for (dgInt32 i = 0; i < threadCounts; i++) { - m_world->QueueJob(UpdateSkeletonsKernel, this, NULL, "dgParallelBodySolver::UpdateSkeletons"); - } - m_world->SynchronizationBarrier(); -} - - -#ifdef D_USE_SOA_SOLVER - -dgFloat32 dgParallelBodySolver::CalculateJointForce(const dgJointInfo* const jointInfo, dgSolverSoaElement* const massMatrix, const dgJacobian* const internalForcesPtr) const -{ - dgWorkGroupVector6 forceM0; - dgWorkGroupVector6 forceM1; - dgWorkGroupFloat weight0; - dgWorkGroupFloat weight1; - dgWorkGroupFloat preconditioner0; - dgWorkGroupFloat preconditioner1; - dgWorkGroupFloat accNorm(m_zero); - dgWorkGroupFloat normalForce[DG_CONSTRAINT_MAX_ROWS + 1]; - const dgBodyProxy* const bodyProxyArray = m_bodyProxyArray; - const dgWorkGroupFloat* const internalForces = (dgWorkGroupFloat*)internalForcesPtr; - - for (dgInt32 i = 0; i < DG_WORK_GROUP_SIZE; i++) { - const dgInt32 m0 = jointInfo[i].m_m0; - const dgInt32 m1 = jointInfo[i].m_m1; - - forceM0.m_linear.m_x[i] = internalForces[m0][0]; - forceM0.m_linear.m_y[i] = internalForces[m0][1]; - forceM0.m_linear.m_z[i] = internalForces[m0][2]; - forceM0.m_angular.m_x[i] = internalForces[m0][4]; - forceM0.m_angular.m_y[i] = internalForces[m0][5]; - forceM0.m_angular.m_z[i] = internalForces[m0][6]; - - forceM1.m_linear.m_x[i] = internalForces[m1][0]; - forceM1.m_linear.m_y[i] = internalForces[m1][1]; - forceM1.m_linear.m_z[i] = internalForces[m1][2]; - forceM1.m_angular.m_x[i] = internalForces[m1][4]; - forceM1.m_angular.m_y[i] = internalForces[m1][5]; - forceM1.m_angular.m_z[i] = internalForces[m1][6]; - - weight0[i] = bodyProxyArray[m0].m_weight; - weight1[i] = bodyProxyArray[m1].m_weight; - - preconditioner0[i] = jointInfo[i].m_preconditioner0; - preconditioner1[i] = jointInfo[i].m_preconditioner1; - } - - forceM0.m_linear.m_x = forceM0.m_linear.m_x * preconditioner0; - forceM0.m_linear.m_y = forceM0.m_linear.m_y * preconditioner0; - forceM0.m_linear.m_z = forceM0.m_linear.m_z * preconditioner0; - forceM0.m_angular.m_x = forceM0.m_angular.m_x * preconditioner0; - forceM0.m_angular.m_y = forceM0.m_angular.m_y * preconditioner0; - forceM0.m_angular.m_z = forceM0.m_angular.m_z * preconditioner0; - - forceM1.m_linear.m_x = forceM1.m_linear.m_x * preconditioner1; - forceM1.m_linear.m_y = forceM1.m_linear.m_y * preconditioner1; - forceM1.m_linear.m_z = forceM1.m_linear.m_z * preconditioner1; - forceM1.m_angular.m_x = forceM1.m_angular.m_x * preconditioner1; - forceM1.m_angular.m_y = forceM1.m_angular.m_y * preconditioner1; - forceM1.m_angular.m_z = forceM1.m_angular.m_z * preconditioner1; - - preconditioner0 = preconditioner0 * weight0; - preconditioner1 = preconditioner1 * weight1; - - const dgInt32 rowsCount = jointInfo->m_pairCount; - normalForce[0] = m_one; - for (dgInt32 i = 0; i < rowsCount; i++) { - dgSolverSoaElement* const row = &massMatrix[i]; - - dgWorkGroupFloat a; - a = row->m_coordenateAccel.MulSub(row->m_JMinv.m_jacobianM0.m_linear.m_x, forceM0.m_linear.m_x); - a = a.MulSub(row->m_JMinv.m_jacobianM0.m_linear.m_y, forceM0.m_linear.m_y); - a = a.MulSub(row->m_JMinv.m_jacobianM0.m_linear.m_z, forceM0.m_linear.m_z); - a = a.MulSub(row->m_JMinv.m_jacobianM0.m_angular.m_x, forceM0.m_angular.m_x); - a = a.MulSub(row->m_JMinv.m_jacobianM0.m_angular.m_y, forceM0.m_angular.m_y); - a = a.MulSub(row->m_JMinv.m_jacobianM0.m_angular.m_z, forceM0.m_angular.m_z); - - a = a.MulSub(row->m_JMinv.m_jacobianM1.m_linear.m_x, forceM1.m_linear.m_x); - a = a.MulSub(row->m_JMinv.m_jacobianM1.m_linear.m_y, forceM1.m_linear.m_y); - a = a.MulSub(row->m_JMinv.m_jacobianM1.m_linear.m_z, forceM1.m_linear.m_z); - a = a.MulSub(row->m_JMinv.m_jacobianM1.m_angular.m_x, forceM1.m_angular.m_x); - a = a.MulSub(row->m_JMinv.m_jacobianM1.m_angular.m_y, forceM1.m_angular.m_y); - a = a.MulSub(row->m_JMinv.m_jacobianM1.m_angular.m_z, forceM1.m_angular.m_z); - a = a.MulSub(row->m_force, row->m_diagDamp); - - dgWorkGroupFloat f(row->m_force.MulAdd(row->m_invJinvMJt, a)); - dgWorkGroupFloat frictionNormal(normalForce, row->m_normalForceIndex); - - dgWorkGroupFloat lowerFrictionForce(frictionNormal * row->m_lowerBoundFrictionCoefficent); - dgWorkGroupFloat upperFrictionForce(frictionNormal * row->m_upperBoundFrictionCoefficent); - - a = a & (f < upperFrictionForce) & (f > lowerFrictionForce); - f = f.GetMax(lowerFrictionForce).GetMin(upperFrictionForce); - accNorm = accNorm.MulAdd(a, a); - - dgWorkGroupFloat deltaForce(f - row->m_force); - - row->m_force = f; - normalForce[i + 1] = f; - - dgWorkGroupFloat deltaForce0(deltaForce * preconditioner0); - dgWorkGroupFloat deltaForce1(deltaForce * preconditioner1); - - forceM0.m_linear.m_x = forceM0.m_linear.m_x.MulAdd(row->m_Jt.m_jacobianM0.m_linear.m_x, deltaForce0); - forceM0.m_linear.m_y = forceM0.m_linear.m_y.MulAdd(row->m_Jt.m_jacobianM0.m_linear.m_y, deltaForce0); - forceM0.m_linear.m_z = forceM0.m_linear.m_z.MulAdd(row->m_Jt.m_jacobianM0.m_linear.m_z, deltaForce0); - forceM0.m_angular.m_x = forceM0.m_angular.m_x.MulAdd(row->m_Jt.m_jacobianM0.m_angular.m_x, deltaForce0); - forceM0.m_angular.m_y = forceM0.m_angular.m_y.MulAdd(row->m_Jt.m_jacobianM0.m_angular.m_y, deltaForce0); - forceM0.m_angular.m_z = forceM0.m_angular.m_z.MulAdd(row->m_Jt.m_jacobianM0.m_angular.m_z, deltaForce0); - - forceM1.m_linear.m_x = forceM1.m_linear.m_x.MulAdd(row->m_Jt.m_jacobianM1.m_linear.m_x, deltaForce1); - forceM1.m_linear.m_y = forceM1.m_linear.m_y.MulAdd(row->m_Jt.m_jacobianM1.m_linear.m_y, deltaForce1); - forceM1.m_linear.m_z = forceM1.m_linear.m_z.MulAdd(row->m_Jt.m_jacobianM1.m_linear.m_z, deltaForce1); - forceM1.m_angular.m_x = forceM1.m_angular.m_x.MulAdd(row->m_Jt.m_jacobianM1.m_angular.m_x, deltaForce1); - forceM1.m_angular.m_y = forceM1.m_angular.m_y.MulAdd(row->m_Jt.m_jacobianM1.m_angular.m_y, deltaForce1); - forceM1.m_angular.m_z = forceM1.m_angular.m_z.MulAdd(row->m_Jt.m_jacobianM1.m_angular.m_z, deltaForce1); - } - - const dgFloat32 tol = dgFloat32(0.5f); - const dgFloat32 tol2 = tol * tol; - dgWorkGroupFloat maxAccel(accNorm); - for (dgInt32 i = 0; (i < 4) && (maxAccel.AddHorizontal() > tol2); i++) { - maxAccel = m_zero; - for (dgInt32 j = 0; j < rowsCount; j++) { - dgSolverSoaElement* const row = &massMatrix[j]; - - dgWorkGroupFloat a; - a = row->m_coordenateAccel.MulSub(row->m_JMinv.m_jacobianM0.m_linear.m_x, forceM0.m_linear.m_x); - a = a.MulSub(row->m_JMinv.m_jacobianM0.m_linear.m_y, forceM0.m_linear.m_y); - a = a.MulSub(row->m_JMinv.m_jacobianM0.m_linear.m_z, forceM0.m_linear.m_z); - a = a.MulSub(row->m_JMinv.m_jacobianM0.m_angular.m_x, forceM0.m_angular.m_x); - a = a.MulSub(row->m_JMinv.m_jacobianM0.m_angular.m_y, forceM0.m_angular.m_y); - a = a.MulSub(row->m_JMinv.m_jacobianM0.m_angular.m_z, forceM0.m_angular.m_z); - - a = a.MulSub(row->m_JMinv.m_jacobianM1.m_linear.m_x, forceM1.m_linear.m_x); - a = a.MulSub(row->m_JMinv.m_jacobianM1.m_linear.m_y, forceM1.m_linear.m_y); - a = a.MulSub(row->m_JMinv.m_jacobianM1.m_linear.m_z, forceM1.m_linear.m_z); - a = a.MulSub(row->m_JMinv.m_jacobianM1.m_angular.m_x, forceM1.m_angular.m_x); - a = a.MulSub(row->m_JMinv.m_jacobianM1.m_angular.m_y, forceM1.m_angular.m_y); - a = a.MulSub(row->m_JMinv.m_jacobianM1.m_angular.m_z, forceM1.m_angular.m_z); - a = a.MulSub(row->m_force, row->m_diagDamp); - - dgWorkGroupFloat f(row->m_force.MulAdd(row->m_invJinvMJt, a)); - dgWorkGroupFloat frictionNormal(normalForce, row->m_normalForceIndex); - - dgWorkGroupFloat lowerFrictionForce(frictionNormal * row->m_lowerBoundFrictionCoefficent); - dgWorkGroupFloat upperFrictionForce(frictionNormal * row->m_upperBoundFrictionCoefficent); - - a = a & (f < upperFrictionForce) & (f > lowerFrictionForce); - f = f.GetMax(lowerFrictionForce).GetMin(upperFrictionForce); - maxAccel = maxAccel.MulAdd(a, a); - - dgWorkGroupFloat deltaForce(f - row->m_force); - - row->m_force = f; - normalForce[j + 1] = f; - - dgWorkGroupFloat deltaForce0(deltaForce * preconditioner0); - dgWorkGroupFloat deltaForce1(deltaForce * preconditioner1); - - forceM0.m_linear.m_x = forceM0.m_linear.m_x.MulAdd(row->m_Jt.m_jacobianM0.m_linear.m_x, deltaForce0); - forceM0.m_linear.m_y = forceM0.m_linear.m_y.MulAdd(row->m_Jt.m_jacobianM0.m_linear.m_y, deltaForce0); - forceM0.m_linear.m_z = forceM0.m_linear.m_z.MulAdd(row->m_Jt.m_jacobianM0.m_linear.m_z, deltaForce0); - forceM0.m_angular.m_x = forceM0.m_angular.m_x.MulAdd(row->m_Jt.m_jacobianM0.m_angular.m_x, deltaForce0); - forceM0.m_angular.m_y = forceM0.m_angular.m_y.MulAdd(row->m_Jt.m_jacobianM0.m_angular.m_y, deltaForce0); - forceM0.m_angular.m_z = forceM0.m_angular.m_z.MulAdd(row->m_Jt.m_jacobianM0.m_angular.m_z, deltaForce0); - - forceM1.m_linear.m_x = forceM1.m_linear.m_x.MulAdd(row->m_Jt.m_jacobianM1.m_linear.m_x, deltaForce1); - forceM1.m_linear.m_y = forceM1.m_linear.m_y.MulAdd(row->m_Jt.m_jacobianM1.m_linear.m_y, deltaForce1); - forceM1.m_linear.m_z = forceM1.m_linear.m_z.MulAdd(row->m_Jt.m_jacobianM1.m_linear.m_z, deltaForce1); - forceM1.m_angular.m_x = forceM1.m_angular.m_x.MulAdd(row->m_Jt.m_jacobianM1.m_angular.m_x, deltaForce1); - forceM1.m_angular.m_y = forceM1.m_angular.m_y.MulAdd(row->m_Jt.m_jacobianM1.m_angular.m_y, deltaForce1); - forceM1.m_angular.m_z = forceM1.m_angular.m_z.MulAdd(row->m_Jt.m_jacobianM1.m_angular.m_z, deltaForce1); - } - } - - return accNorm.AddHorizontal(); -} - -void dgParallelBodySolver::CalculateJointsForce(dgInt32 threadID) -{ - const dgInt32* const soaRowStart = m_soaRowStart; - const dgBodyInfo* const bodyArray = m_bodyArray; - dgJacobian* const internalForces = &m_world->m_solverMemory.m_internalForcesBuffer[0]; - dgRightHandSide* const rightHandSide = &m_world->m_solverMemory.m_righHandSizeBuffer[0]; - dgSolverSoaElement* const massMatrix = &m_massMatrix[0]; - dgFloat32 accNorm = dgFloat32(0.0f); - - const dgInt32 step = m_threadCounts; - const dgInt32 jointCount = m_jointCount; - for (dgInt32 i = threadID; i < jointCount; i += step) { - const dgInt32 rowStart = soaRowStart[i]; - dgJointInfo* const jointInfo = &m_jointArray[i * DG_WORK_GROUP_SIZE]; - - bool isSleeping = true; - dgFloat32 accel2 = dgFloat32 (0.0f); - for (dgInt32 j = 0; (j < DG_WORK_GROUP_SIZE) && isSleeping; j++) { - const dgInt32 m0 = jointInfo[j].m_m0; - const dgInt32 m1 = jointInfo[j].m_m1; - const dgBody* const body0 = bodyArray[m0].m_body; - const dgBody* const body1 = bodyArray[m1].m_body; - isSleeping &= body0->m_resting; - isSleeping &= body1->m_resting; - } - if (!isSleeping) { - accel2 = CalculateJointForce(jointInfo, &massMatrix[rowStart], internalForces); - for (dgInt32 j = 0; j < DG_WORK_GROUP_SIZE; j++) { - const dgJointInfo* const joint = &jointInfo[j]; - if (joint->m_joint) { - dgInt32 const rowCount = joint->m_pairCount; - dgInt32 const rowStartBase = joint->m_pairStart; - for (dgInt32 k = 0; k < rowCount; k++) { - const dgSolverSoaElement* const row = &massMatrix[rowStart + k]; - rightHandSide[k + rowStartBase].m_force = row->m_force[j]; - rightHandSide[k + rowStartBase].m_maxImpact = dgMax(dgAbs(row->m_force[j]), rightHandSide[k + rowStartBase].m_maxImpact); - } - } - } - } - - dgWorkGroupVector6 forceM0; - dgWorkGroupVector6 forceM1; - - forceM0.m_linear.m_x = m_zero; - forceM0.m_linear.m_y = m_zero; - forceM0.m_linear.m_z = m_zero; - forceM0.m_angular.m_x = m_zero; - forceM0.m_angular.m_y = m_zero; - forceM0.m_angular.m_z = m_zero; - - forceM1.m_linear.m_x = m_zero; - forceM1.m_linear.m_y = m_zero; - forceM1.m_linear.m_z = m_zero; - forceM1.m_angular.m_x = m_zero; - forceM1.m_angular.m_y = m_zero; - forceM1.m_angular.m_z = m_zero; - - const dgInt32 rowsCount = jointInfo->m_pairCount; - - for (dgInt32 j = 0; j < rowsCount; j++) { - dgSolverSoaElement* const row = &massMatrix[rowStart + j]; - - dgWorkGroupFloat f(row->m_force); - forceM0.m_linear.m_x = forceM0.m_linear.m_x.MulAdd(row->m_Jt.m_jacobianM0.m_linear.m_x, f); - forceM0.m_linear.m_y = forceM0.m_linear.m_y.MulAdd(row->m_Jt.m_jacobianM0.m_linear.m_y, f); - forceM0.m_linear.m_z = forceM0.m_linear.m_z.MulAdd(row->m_Jt.m_jacobianM0.m_linear.m_z, f); - forceM0.m_angular.m_x = forceM0.m_angular.m_x.MulAdd(row->m_Jt.m_jacobianM0.m_angular.m_x, f); - forceM0.m_angular.m_y = forceM0.m_angular.m_y.MulAdd(row->m_Jt.m_jacobianM0.m_angular.m_y, f); - forceM0.m_angular.m_z = forceM0.m_angular.m_z.MulAdd(row->m_Jt.m_jacobianM0.m_angular.m_z, f); - - forceM1.m_linear.m_x = forceM1.m_linear.m_x.MulAdd(row->m_Jt.m_jacobianM1.m_linear.m_x, f); - forceM1.m_linear.m_y = forceM1.m_linear.m_y.MulAdd(row->m_Jt.m_jacobianM1.m_linear.m_y, f); - forceM1.m_linear.m_z = forceM1.m_linear.m_z.MulAdd(row->m_Jt.m_jacobianM1.m_linear.m_z, f); - forceM1.m_angular.m_x = forceM1.m_angular.m_x.MulAdd(row->m_Jt.m_jacobianM1.m_angular.m_x, f); - forceM1.m_angular.m_y = forceM1.m_angular.m_y.MulAdd(row->m_Jt.m_jacobianM1.m_angular.m_y, f); - forceM1.m_angular.m_z = forceM1.m_angular.m_z.MulAdd(row->m_Jt.m_jacobianM1.m_angular.m_z, f); - } - - dgBodyProxy* const bodyProxyArray = m_bodyProxyArray; - dgJacobian* const tempInternalForces = &m_world->m_solverMemory.m_internalForcesBuffer[m_cluster->m_bodyCount]; - for (dgInt32 j = 0; j < DG_WORK_GROUP_SIZE; j++) { - const dgJointInfo* const joint = &jointInfo[j]; - if (joint->m_joint) { - dgJacobian m_body0Force; - dgJacobian m_body1Force; - - m_body0Force.m_linear = dgVector (forceM0.m_linear.m_x[j], forceM0.m_linear.m_y[j], forceM0.m_linear.m_z[j], dgFloat32 (0.0f)); - m_body0Force.m_angular = dgVector (forceM0.m_angular.m_x[j], forceM0.m_angular.m_y[j], forceM0.m_angular.m_z[j], dgFloat32 (0.0f)); - - m_body1Force.m_linear = dgVector(forceM1.m_linear.m_x[j], forceM1.m_linear.m_y[j], forceM1.m_linear.m_z[j], dgFloat32(0.0f)); - m_body1Force.m_angular = dgVector(forceM1.m_angular.m_x[j], forceM1.m_angular.m_y[j], forceM1.m_angular.m_z[j], dgFloat32(0.0f)); - - const dgInt32 m0 = jointInfo[j].m_m0; - const dgInt32 m1 = jointInfo[j].m_m1; - - if (m0) { - dgScopeSpinPause lock(&bodyProxyArray[m0].m_lock); - tempInternalForces[m0].m_linear += m_body0Force.m_linear; - tempInternalForces[m0].m_angular += m_body0Force.m_angular; - } - if (m1) { - dgScopeSpinPause lock(&bodyProxyArray[m1].m_lock); - tempInternalForces[m1].m_linear += m_body1Force.m_linear; - tempInternalForces[m1].m_angular += m_body1Force.m_angular; - } - } - } - accNorm += accel2; - } - m_accelNorm[threadID] = accNorm; -} - -#else - -void dgParallelBodySolver::CalculateJointsForce(dgInt32 threadID) -{ - dgVector accNorm(dgVector::m_zero); - const dgBodyInfo* const bodyArray = m_bodyArray; - dgBodyProxy* const bodyProxyArray = m_bodyProxyArray; - dgJacobian* const internalForces = &m_world->m_solverMemory.m_internalForcesBuffer[0]; - dgJacobian* const tempInternalForces = &m_world->m_solverMemory.m_internalForcesBuffer[m_cluster->m_bodyCount]; - - dgRightHandSide* const rightHandSide = &m_world->m_solverMemory.m_righHandSizeBuffer[0]; - const dgLeftHandSide* const leftHandSide = &m_world->m_solverMemory.m_leftHandSizeBuffer[0]; - - const dgInt32 step = m_threadCounts; - const dgInt32 jointCount = m_cluster->m_jointCount; - dgFloat32 normalForce[DG_CONSTRAINT_MAX_ROWS + 1]; - - for (dgInt32 i = threadID; i < jointCount; i += step) { - dgJointInfo* const jointInfo = &m_jointArray[i]; - dgFloat32 accel2 = dgFloat32(0.0f); - - const dgInt32 m0 = jointInfo->m_m0; - const dgInt32 m1 = jointInfo->m_m1; - const dgBody* const body0 = bodyArray[m0].m_body; - const dgBody* const body1 = bodyArray[m1].m_body; - dgInt32 isSleeping = body0->m_resting & body1->m_resting; - if (!isSleeping) { - - dgVector preconditioner0 (jointInfo->m_preconditioner0); - dgVector preconditioner1 (jointInfo->m_preconditioner1); - - dgVector forceM0 (internalForces[m0].m_linear * preconditioner0); - dgVector torqueM0 (internalForces[m0].m_angular * preconditioner0); - dgVector forceM1 (internalForces[m1].m_linear * preconditioner1); - dgVector torqueM1 (internalForces[m1].m_angular * preconditioner1); - - preconditioner0 = preconditioner0.Scale (bodyProxyArray[m0].m_weight); - preconditioner1 = preconditioner1.Scale (bodyProxyArray[m1].m_weight); - - normalForce[0] = dgFloat32 (1.0f); - const dgInt32 rowsCount = jointInfo->m_pairCount; - const dgInt32 rowStart = jointInfo->m_pairStart; - for (dgInt32 j = 0; j < rowsCount; j++) { - dgRightHandSide* const rhs = &rightHandSide[rowStart + j]; - const dgLeftHandSide* const lhs = &leftHandSide[rowStart + j]; - dgVector a(lhs->m_JMinv.m_jacobianM0.m_linear * forceM0); - a = a.MulAdd(lhs->m_JMinv.m_jacobianM0.m_angular, torqueM0); - a = a.MulAdd(lhs->m_JMinv.m_jacobianM1.m_linear, forceM1); - a = a.MulAdd(lhs->m_JMinv.m_jacobianM1.m_angular, torqueM1); - //a = dgVector(rhs->m_coordenateAccel + rhs->m_gyroAccel - rhs->m_force * rhs->m_diagDamp) - a.AddHorizontal(); - a = dgVector(rhs->m_coordenateAccel - rhs->m_force * rhs->m_diagDamp) - a.AddHorizontal(); - dgVector f(rhs->m_force + rhs->m_invJinvMJt * a.GetScalar()); - - dgAssert(rhs->m_normalForceIndex >= -1); - dgAssert(rhs->m_normalForceIndex <= rowsCount); - - const dgInt32 frictionIndex = rhs->m_normalForceIndex + 1; - const dgFloat32 frictionNormal = normalForce[frictionIndex]; - const dgVector lowerFrictionForce(frictionNormal * rhs->m_lowerBoundFrictionCoefficent); - const dgVector upperFrictionForce(frictionNormal * rhs->m_upperBoundFrictionCoefficent); - - a = a & (f < upperFrictionForce) & (f > lowerFrictionForce); - f = f.GetMax(lowerFrictionForce).GetMin(upperFrictionForce); - accNorm = accNorm.MulAdd(a, a); - - dgVector deltaForce(f - dgVector(rhs->m_force)); - - rhs->m_force = f.GetScalar(); - normalForce[j + 1] = f.GetScalar(); - - dgVector deltaForce0(deltaForce * preconditioner0); - dgVector deltaForce1(deltaForce * preconditioner1); - - forceM0 = forceM0.MulAdd(lhs->m_Jt.m_jacobianM0.m_linear, deltaForce0); - torqueM0 = torqueM0.MulAdd(lhs->m_Jt.m_jacobianM0.m_angular, deltaForce0); - forceM1 = forceM1.MulAdd(lhs->m_Jt.m_jacobianM1.m_linear, deltaForce1); - torqueM1 = torqueM1.MulAdd(lhs->m_Jt.m_jacobianM1.m_angular, deltaForce1); - } - - const dgFloat32 tol = dgFloat32(0.5f); - const dgFloat32 tol2 = tol * tol; - dgVector maxAccel(accNorm); - - for (dgInt32 k = 0; (k < 4) && (maxAccel.GetScalar() > tol2); k++) { - maxAccel = dgVector::m_zero; - for (dgInt32 j = 0; j < rowsCount; j++) { - dgRightHandSide* const rhs = &rightHandSide[rowStart + j]; - const dgLeftHandSide* const lhs = &leftHandSide[rowStart + j]; - - dgVector a(lhs->m_JMinv.m_jacobianM0.m_linear * forceM0); - a = a.MulAdd(lhs->m_JMinv.m_jacobianM0.m_angular, torqueM0); - a = a.MulAdd(lhs->m_JMinv.m_jacobianM1.m_linear, forceM1); - a = a.MulAdd(lhs->m_JMinv.m_jacobianM1.m_angular, torqueM1); - //a = dgVector(rhs->m_coordenateAccel + rhs->m_gyroAccel - rhs->m_force * rhs->m_diagDamp) - a.AddHorizontal(); - a = dgVector(rhs->m_coordenateAccel - rhs->m_force * rhs->m_diagDamp) - a.AddHorizontal(); - dgVector f(rhs->m_force + rhs->m_invJinvMJt * a.GetScalar()); - - dgAssert(rhs->m_normalForceIndex >= -1); - dgAssert(rhs->m_normalForceIndex <= rowsCount); - - const dgInt32 frictionIndex = rhs->m_normalForceIndex + 1; - const dgFloat32 frictionNormal = normalForce[frictionIndex]; - const dgVector lowerFrictionForce(frictionNormal * rhs->m_lowerBoundFrictionCoefficent); - const dgVector upperFrictionForce(frictionNormal * rhs->m_upperBoundFrictionCoefficent); - - a = a & (f < upperFrictionForce) & (f > lowerFrictionForce); - f = f.GetMax(lowerFrictionForce).GetMin(upperFrictionForce); - maxAccel = maxAccel.MulAdd(a, a); - - dgVector deltaForce(f - rhs->m_force); - - rhs->m_force = f.GetScalar(); - normalForce[j + 1] = f.GetScalar(); - - dgVector deltaForce0(deltaForce * preconditioner0); - dgVector deltaForce1(deltaForce * preconditioner1); - forceM0 = forceM0.MulAdd(lhs->m_Jt.m_jacobianM0.m_linear, deltaForce0); - torqueM0 = torqueM0.MulAdd(lhs->m_Jt.m_jacobianM0.m_angular, deltaForce0); - forceM1 = forceM1.MulAdd(lhs->m_Jt.m_jacobianM1.m_linear, deltaForce1); - torqueM1 = torqueM1.MulAdd(lhs->m_Jt.m_jacobianM1.m_angular, deltaForce1); - } - } - - } - - dgVector forceM0(dgVector::m_zero); - dgVector torqueM0(dgVector::m_zero); - dgVector forceM1(dgVector::m_zero); - dgVector torqueM1(dgVector::m_zero); - - const dgInt32 rowsCount = jointInfo->m_pairCount; - const dgInt32 rowStart = jointInfo->m_pairStart; - - for (dgInt32 j = 0; j < rowsCount; j++) { - const dgRightHandSide* const rhs = &rightHandSide[rowStart + j]; - const dgLeftHandSide* const lhs = &leftHandSide[rowStart + j]; - - dgVector f (rhs->m_force); - forceM0 = forceM0.MulAdd(lhs->m_Jt.m_jacobianM0.m_linear, f); - torqueM0 = torqueM0.MulAdd(lhs->m_Jt.m_jacobianM0.m_angular, f); - forceM1 = forceM1.MulAdd(lhs->m_Jt.m_jacobianM1.m_linear, f); - torqueM1 = torqueM1.MulAdd(lhs->m_Jt.m_jacobianM1.m_angular, f); - } - - if (m0) { - dgScopeSpinPause lock(&bodyProxyArray[m0].m_lock); - tempInternalForces[m0].m_linear += forceM0; - tempInternalForces[m0].m_angular += torqueM0; - } - if (m1) { - dgScopeSpinPause lock(&bodyProxyArray[m1].m_lock); - tempInternalForces[m1].m_linear += forceM1; - tempInternalForces[m1].m_angular += torqueM1; - } - - accNorm += accel2; - } - m_accelNorm[threadID] = accNorm.GetScalar(); -} -#endif - - -void dgParallelBodySolver::CalculateForces() -{ - m_firstPassCoef = dgFloat32(0.0f); - if (m_skeletonCount) { - InitSkeletons(); - } - for (dgInt32 step = 0; step < 4; step++) { - CalculateJointsAccel(); - CalculateJointsForce(); - if (m_skeletonCount) { - UpdateSkeletons(); - } - IntegrateBodiesVelocity(); - } - - UpdateForceFeedback(); - - dgInt32 hasJointFeeback = 0; - for (dgInt32 i = 0; i < DG_MAX_THREADS_HIVE_COUNT; i++) { - hasJointFeeback |= m_hasJointFeeback[i]; - } - CalculateBodiesAcceleration(); - - if (hasJointFeeback) { - UpdateKinematicFeedback(); - } -} - -void dgParallelBodySolver::CalculateJointForces(const dgBodyCluster& cluster, dgBodyInfo* const bodyArray, dgJointInfo* const jointArray, dgFloat32 timestep) -{ - DG_TRACKTIME(); - m_cluster = &cluster; - m_bodyArray = bodyArray; - m_jointArray = jointArray; - m_timestep = timestep; - m_invTimestep = (timestep > dgFloat32(0.0f)) ? dgFloat32(1.0f) / timestep : dgFloat32(0.0f); - - m_invStepRK = dgFloat32(0.25f); - m_timestepRK = m_timestep * m_invStepRK; - m_invTimestepRK = m_invTimestep * dgFloat32(4.0f); - - m_solverPasses = m_world->GetSolverIterations(); - m_threadCounts = m_world->GetThreadCount(); - m_jointCount = ((m_cluster->m_jointCount + DG_WORK_GROUP_SIZE - 1) & -dgInt32(DG_WORK_GROUP_SIZE - 1)) / DG_WORK_GROUP_SIZE; - - m_soaRowStart = dgAlloca(dgInt32, m_jointCount); - m_bodyProxyArray = dgAlloca(dgBodyProxy, cluster.m_bodyCount); - - InitWeights(); - InitBodyArray(); - InitJacobianMatrix(); - CalculateForces(); -} - diff --git a/thirdparty/src/newton/dgPhysics/dgWorldDynamicsParallelSolver.h b/thirdparty/src/newton/dgPhysics/dgWorldDynamicsParallelSolver.h deleted file mode 100644 index 74be108ac..000000000 --- a/thirdparty/src/newton/dgPhysics/dgWorldDynamicsParallelSolver.h +++ /dev/null @@ -1,322 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_PARALLEL_SOLVER_H_ -#define _DG_PARALLEL_SOLVER_H_ - -#include "dgPhysicsStdafx.h" - -class dgBodyInfo; -class dgJointInfo; -class dgBodyCluster; -class dgSkeletonContainer; - -#define DG_WORK_GROUP_SIZE 8 - -DG_MSC_VECTOR_ALIGNMENT -class dgWorkGroupFloat -{ - public: - DG_INLINE dgWorkGroupFloat() - { - } - - DG_INLINE dgWorkGroupFloat(const dgWorkGroupFloat& me) - :m_low(me.m_low) - ,m_high(me.m_high) - { - } - - DG_INLINE dgWorkGroupFloat(const dgVector& v) - :m_low(v) - ,m_high(v) - { - } - - DG_INLINE dgWorkGroupFloat(const dgVector& low, const dgVector& high) - :m_low(low) - ,m_high(high) - { - } - - DG_INLINE dgWorkGroupFloat(const dgWorkGroupFloat* const baseAddr, const dgWorkGroupFloat& index) - { - const dgInt32* const indirectIndex = (dgInt32*) &index[0]; - const dgFloat32* const src = &(*baseAddr)[0]; - dgFloat32* const dst = &(*this)[0]; - for (dgInt32 i = 0; i < DG_WORK_GROUP_SIZE; i++) { - dst[i] = src[indirectIndex[i]]; - } - } - - DG_INLINE dgFloat32& operator[] (dgInt32 i) - { - dgAssert(i >= 0); - dgAssert(i < DG_WORK_GROUP_SIZE); - dgFloat32* const ptr = &m_low[0]; - return ptr[i]; - } - - DG_INLINE const dgFloat32& operator[] (dgInt32 i) const - { - dgAssert(i >= 0); - dgAssert(i < DG_WORK_GROUP_SIZE); - const dgFloat32* const ptr = &m_low[0]; - return ptr[i]; - } - - DG_INLINE dgWorkGroupFloat operator+ (const dgWorkGroupFloat& A) const - { - return dgWorkGroupFloat(m_low + A.m_low, m_high + A.m_high); - } - - DG_INLINE dgWorkGroupFloat operator- (const dgWorkGroupFloat& A) const - { - return dgWorkGroupFloat(m_low - A.m_low, m_high - A.m_high); - } - - DG_INLINE dgWorkGroupFloat operator* (const dgWorkGroupFloat& A) const - { - return dgWorkGroupFloat(m_low * A.m_low, m_high * A.m_high); - } - - DG_INLINE dgWorkGroupFloat MulAdd(const dgWorkGroupFloat& A, const dgWorkGroupFloat& B) const - { - return dgWorkGroupFloat(m_low.MulAdd(A.m_low, B.m_low), m_high.MulAdd(A.m_high, B.m_high)); - } - - DG_INLINE dgWorkGroupFloat MulSub(const dgWorkGroupFloat& A, const dgWorkGroupFloat& B) const - { - return dgWorkGroupFloat(m_low.MulSub(A.m_low, B.m_low), m_high.MulSub(A.m_high, B.m_high)); - } - - DG_INLINE dgWorkGroupFloat operator> (const dgWorkGroupFloat& A) const - { - return dgWorkGroupFloat(m_low > A.m_low, m_high > A.m_high); - } - - DG_INLINE dgWorkGroupFloat operator< (const dgWorkGroupFloat& A) const - { - return dgWorkGroupFloat(m_low < A.m_low, m_high < A.m_high); - } - - DG_INLINE dgWorkGroupFloat operator| (const dgWorkGroupFloat& A) const - { - return dgWorkGroupFloat(m_low | A.m_low, m_high | A.m_high); - } - - DG_INLINE dgWorkGroupFloat operator& (const dgWorkGroupFloat& A) const - { - return dgWorkGroupFloat(m_low & A.m_low, m_high & A.m_high); - } - - DG_INLINE dgWorkGroupFloat GetMin(const dgWorkGroupFloat& A) const - { - return dgWorkGroupFloat(m_low.GetMin(A.m_low), m_high.GetMin(A.m_high)); - } - - DG_INLINE dgWorkGroupFloat GetMax(const dgWorkGroupFloat& A) const - { - return dgWorkGroupFloat(m_low.GetMax(A.m_low), m_high.GetMax(A.m_high)); - } - - DG_INLINE dgFloat32 AddHorizontal() const - { - return (m_low + m_high).AddHorizontal().GetScalar(); - } - - DG_INLINE dgFloat32 GetMax() const - { - return (m_low.GetMax(m_high)).GetMax(); - } - - dgVector m_low; - dgVector m_high; -} DG_GCC_VECTOR_ALIGNMENT; - -DG_MSC_VECTOR_ALIGNMENT -class dgWorkGroupVector3 -{ - public: - dgWorkGroupFloat m_x; - dgWorkGroupFloat m_y; - dgWorkGroupFloat m_z; -} DG_GCC_VECTOR_ALIGNMENT; - - -DG_MSC_VECTOR_ALIGNMENT -class dgWorkGroupVector6 -{ - public: - dgWorkGroupVector3 m_linear; - dgWorkGroupVector3 m_angular; -} DG_GCC_AVX_ALIGNMENT; - -DG_MSC_VECTOR_ALIGNMENT -class dgSolverSoaJacobianPair -{ - public: - dgWorkGroupVector6 m_jacobianM0; - dgWorkGroupVector6 m_jacobianM1; -} DG_GCC_VECTOR_ALIGNMENT; - -DG_MSC_VECTOR_ALIGNMENT -class dgSolverSoaElement -{ - public: - dgSolverSoaJacobianPair m_Jt; - dgSolverSoaJacobianPair m_JMinv; - - dgWorkGroupFloat m_force; - dgWorkGroupFloat m_diagDamp; - dgWorkGroupFloat m_invJinvMJt; - dgWorkGroupFloat m_coordenateAccel; - dgWorkGroupFloat m_normalForceIndex; - dgWorkGroupFloat m_lowerBoundFrictionCoefficent; - dgWorkGroupFloat m_upperBoundFrictionCoefficent; -} DG_GCC_VECTOR_ALIGNMENT; - -class dgParallelBodySolver -{ - public: - class dgBodyProxy - { - public: - dgFloat32 m_weight; - dgFloat32 m_invWeight; - dgInt32 m_lock; - }; - - ~dgParallelBodySolver() {} - dgParallelBodySolver(dgMemoryAllocator* const allocator); - - void CalculateJointForces(const dgBodyCluster& cluster, dgBodyInfo* const bodyArray, dgJointInfo* const jointArray, dgFloat32 timestep); - - private: - void InitWeights(); - void InitBodyArray(); - void InitSkeletons(); - void CalculateForces(); - void UpdateSkeletons(); - void InitJacobianMatrix(); - void UpdateForceFeedback(); - void CalculateJointsForce(); - void CalculateJointsAccel(); - void IntegrateBodiesVelocity(); - void UpdateKinematicFeedback(); - void CalculateBodiesAcceleration(); - - void InitBodyArray(dgInt32 threadID); - void InitSkeletons(dgInt32 threadID); - void UpdateSkeletons(dgInt32 threadID); - void InitJacobianMatrix(dgInt32 threadID); - void UpdateForceFeedback(dgInt32 threadID); - void TransposeMassMatrix(dgInt32 threadID); - void CalculateJointsForce(dgInt32 threadID); - void UpdateRowAcceleration(dgInt32 threadID); - void IntegrateBodiesVelocity(dgInt32 threadID); - void UpdateKinematicFeedback(dgInt32 threadID); - void CalculateJointsAcceleration(dgInt32 threadID); - void CalculateBodiesAcceleration(dgInt32 threadID); - - static void InitSkeletonsKernel(void* const context, void* const, dgInt32 threadID); - static void InitBodyArrayKernel(void* const context, void* const, dgInt32 threadID); - static void UpdateSkeletonsKernel(void* const context, void* const, dgInt32 threadID); - static void InitJacobianMatrixKernel(void* const context, void* const, dgInt32 threadID); - static void UpdateForceFeedbackKernel(void* const context, void* const, dgInt32 threadID); - static void TransposeMassMatrixKernel(void* const context, void* const, dgInt32 threadID); - static void CalculateJointsForceKernel(void* const context, void* const, dgInt32 threadID); - static void UpdateRowAccelerationKernel(void* const context, void* const, dgInt32 threadID); - static void IntegrateBodiesVelocityKernel(void* const context, void* const, dgInt32 threadID); - static void UpdateKinematicFeedbackKernel(void* const context, void* const, dgInt32 threadID); - static void CalculateBodiesAccelerationKernel(void* const context, void* const, dgInt32 threadID); - static void CalculateJointsAccelerationKernel(void* const context, void* const, dgInt32 threadID); - - static dgInt32 CompareJointInfos(const dgJointInfo* const infoA, const dgJointInfo* const infoB, void* notUsed); - - dgFloat32 CalculateJointForce(const dgJointInfo* const jointInfo, dgSolverSoaElement* const massMatrix, const dgJacobian* const internalForces) const; - DG_INLINE void SortWorkGroup (dgInt32 base) const; - DG_INLINE void TransposeRow (dgSolverSoaElement* const row, const dgJointInfo* const jointInfoArray, dgInt32 index); - DG_INLINE void BuildJacobianMatrix(dgJointInfo* const jointInfo, dgLeftHandSide* const leftHandSide, dgRightHandSide* const righHandSide, dgJacobian* const internalForces); - - protected: - dgWorld* m_world; - const dgBodyCluster* m_cluster; - dgBodyInfo* m_bodyArray; - dgJointInfo* m_jointArray; - dgBodyProxy* m_bodyProxyArray; - dgFloat32 m_timestep; - dgFloat32 m_invTimestep; - dgFloat32 m_invStepRK; - dgFloat32 m_timestepRK; - dgFloat32 m_invTimestepRK; - dgFloat32 m_firstPassCoef; - dgFloat32 m_accelNorm[DG_MAX_THREADS_HIVE_COUNT]; - dgInt32 m_hasJointFeeback[DG_MAX_THREADS_HIVE_COUNT]; - dgArray<dgSkeletonContainer*> m_skeletonArray; - - dgInt32 m_jointCount; - dgInt32 m_solverPasses; - dgInt32 m_threadCounts; - dgInt32 m_soaRowsCount; - dgInt32 m_skeletonCount; - dgInt32 m_jacobianMatrixRowAtomicIndex; - dgInt32* m_soaRowStart; - dgInt32* m_bodyRowStart; - - private: - dgWorkGroupFloat m_one; - dgWorkGroupFloat m_zero; - - dgArray<dgSolverSoaElement> m_massMatrix; - friend class dgWorldDynamicUpdate; -}; - -DG_INLINE dgParallelBodySolver::dgParallelBodySolver(dgMemoryAllocator* const allocator) - :m_world(NULL) - ,m_cluster(NULL) - ,m_bodyArray(NULL) - ,m_jointArray(NULL) - ,m_bodyProxyArray(NULL) - ,m_timestep(dgFloat32(0.0f)) - ,m_invTimestep(dgFloat32(0.0f)) - ,m_invStepRK(dgFloat32(0.0f)) - ,m_timestepRK(dgFloat32(0.0f)) - ,m_invTimestepRK(dgFloat32(0.0f)) - ,m_firstPassCoef(dgFloat32(0.0f)) - ,m_skeletonArray(allocator) - ,m_jointCount(0) - ,m_solverPasses(0) - ,m_threadCounts(0) - ,m_soaRowsCount(0) - ,m_skeletonCount(0) - ,m_jacobianMatrixRowAtomicIndex(0) - ,m_soaRowStart(NULL) - ,m_bodyRowStart(NULL) - ,m_massMatrix(allocator) - ,m_one(dgFloat32 (1.0f)) - ,m_zero(dgFloat32 (0.0f)) -{ - m_skeletonArray[32] = NULL; -} - -#endif - diff --git a/thirdparty/src/newton/dgPhysics/dgWorldDynamicsSimpleSolver.cpp b/thirdparty/src/newton/dgPhysics/dgWorldDynamicsSimpleSolver.cpp deleted file mode 100644 index 1ffd2edb6..000000000 --- a/thirdparty/src/newton/dgPhysics/dgWorldDynamicsSimpleSolver.cpp +++ /dev/null @@ -1,1417 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgBody.h" -#include "dgWorld.h" -#include "dgConstraint.h" -#include "dgDynamicBody.h" -#include "dgDynamicBody.h" -#include "dgSkeletonContainer.h" -#include "dgCollisionInstance.h" -#include "dgWorldDynamicUpdate.h" -#include "dgBilateralConstraint.h" - -#define DG_IMPULSE_COUNT (DG_PARALLEL_JOINT_COUNT_CUT_OFF + 32) -#define DG_IMPULSE_CONTACT_SPEED dgFloat32(0.8f) - -void dgWorldDynamicUpdate::BuildJacobianMatrix(const dgBodyInfo* const bodyInfoArray, dgJointInfo* const jointInfo, dgJacobian* const internalForces, dgLeftHandSide* const leftHandSide, dgRightHandSide* const rightHandSide, dgFloat32 forceImpulseScale) const -{ - const dgInt32 index = jointInfo->m_pairStart; - const dgInt32 count = jointInfo->m_pairCount; - const dgInt32 m0 = jointInfo->m_m0; - const dgInt32 m1 = jointInfo->m_m1; - - const dgConstraint* const joint = jointInfo->m_joint; - const dgBody* const body0 = bodyInfoArray[m0].m_body; - const dgBody* const body1 = bodyInfoArray[m1].m_body; - const bool isBilateral = joint->IsBilateral(); - - const dgVector invMass0(body0->m_invMass[3]); - const dgMatrix& invInertia0 = body0->m_invWorldInertiaMatrix; - const dgVector invMass1(body1->m_invMass[3]); - const dgMatrix& invInertia1 = body1->m_invWorldInertiaMatrix; - - dgVector force0(dgVector::m_zero); - dgVector torque0(dgVector::m_zero); - if (body0->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - force0 = ((dgDynamicBody*)body0)->m_externalForce; - torque0 = ((dgDynamicBody*)body0)->m_externalTorque; - } - - dgVector force1(dgVector::m_zero); - dgVector torque1(dgVector::m_zero); - if (body1->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - force1 = ((dgDynamicBody*)body1)->m_externalForce; - torque1 = ((dgDynamicBody*)body1)->m_externalTorque; - } - - jointInfo->m_preconditioner0 = dgFloat32(1.0f); - jointInfo->m_preconditioner1 = dgFloat32(1.0f); - - if ((invMass0.GetScalar() > dgFloat32(0.0f)) && (invMass1.GetScalar() > dgFloat32(0.0f))) { - const dgFloat32 mass0 = body0->GetMass().m_w; - const dgFloat32 mass1 = body1->GetMass().m_w; - if (mass0 > (DG_DIAGONAL_PRECONDITIONER * mass1)) { - jointInfo->m_preconditioner0 = mass0 / (mass1 * DG_DIAGONAL_PRECONDITIONER); - } else if (mass1 > (DG_DIAGONAL_PRECONDITIONER * mass0)) { - jointInfo->m_preconditioner1 = mass1 / (mass0 * DG_DIAGONAL_PRECONDITIONER); - } - } - - if (joint->IsSkeletonLoop() || joint->IsSkeleton() || (body0->GetSkeleton() && body1->GetSkeleton())) { - jointInfo->m_preconditioner0 = dgFloat32(1.0f); - jointInfo->m_preconditioner1 = dgFloat32(1.0f); - } else { - const dgFloat32 scale0 = joint->GetMassScaleBody0(); - const dgFloat32 scale1 = joint->GetMassScaleBody1(); - if ((scale0 != dgFloat32 (1.0f)) || (scale1 != dgFloat32 (1.0f))) { - jointInfo->m_preconditioner0 = scale0; - jointInfo->m_preconditioner1 = scale1; - } - } - - dgJacobian forceAcc0; - dgJacobian forceAcc1; - const dgVector preconditioner0(jointInfo->m_preconditioner0); - const dgVector preconditioner1(jointInfo->m_preconditioner1); - forceAcc0.m_linear = dgVector::m_zero; - forceAcc0.m_angular = dgVector::m_zero; - forceAcc1.m_linear = dgVector::m_zero; - forceAcc1.m_angular = dgVector::m_zero; - - for (dgInt32 i = 0; i < count; i++) { - dgLeftHandSide* const row = &leftHandSide[index + i]; - dgRightHandSide* const rhs = &rightHandSide[index + i]; - - row->m_JMinv.m_jacobianM0.m_linear = row->m_Jt.m_jacobianM0.m_linear * invMass0; - row->m_JMinv.m_jacobianM0.m_angular = invInertia0.RotateVector(row->m_Jt.m_jacobianM0.m_angular); - row->m_JMinv.m_jacobianM1.m_linear = row->m_Jt.m_jacobianM1.m_linear * invMass1; - row->m_JMinv.m_jacobianM1.m_angular = invInertia1.RotateVector(row->m_Jt.m_jacobianM1.m_angular); - - dgVector tmpAccel(row->m_JMinv.m_jacobianM0.m_linear * force0 + row->m_JMinv.m_jacobianM0.m_angular * torque0 + - row->m_JMinv.m_jacobianM1.m_linear * force1 + row->m_JMinv.m_jacobianM1.m_angular * torque1); - - dgAssert(tmpAccel.m_w == dgFloat32(0.0f)); - dgFloat32 extenalAcceleration = -(tmpAccel.AddHorizontal()).GetScalar(); - rhs->m_deltaAccel = extenalAcceleration * forceImpulseScale; - rhs->m_coordenateAccel += extenalAcceleration * forceImpulseScale; - dgAssert(rhs->m_jointFeebackForce); - - const dgFloat32 force = rhs->m_jointFeebackForce->GetInitiailGuess() * forceImpulseScale; - //const dgFloat32 force = rhs->m_jointFeebackForce->m_force * forceImpulseScale; - - rhs->m_force = isBilateral ? dgClamp(force, rhs->m_lowerBoundFrictionCoefficent, rhs->m_upperBoundFrictionCoefficent) : force; - rhs->m_maxImpact = dgFloat32(0.0f); - - dgVector jMinvM0linear(preconditioner0 * row->m_JMinv.m_jacobianM0.m_linear); - dgVector jMinvM0angular(preconditioner0 * row->m_JMinv.m_jacobianM0.m_angular); - dgVector jMinvM1linear(preconditioner1 * row->m_JMinv.m_jacobianM1.m_linear); - dgVector jMinvM1angular(preconditioner1 * row->m_JMinv.m_jacobianM1.m_angular); - - dgVector tmpDiag(jMinvM0linear * row->m_Jt.m_jacobianM0.m_linear + jMinvM0angular * row->m_Jt.m_jacobianM0.m_angular + - jMinvM1linear * row->m_Jt.m_jacobianM1.m_linear + jMinvM1angular * row->m_Jt.m_jacobianM1.m_angular); - - dgAssert(tmpDiag.m_w == dgFloat32(0.0f)); - dgFloat32 diag = (tmpDiag.AddHorizontal()).GetScalar(); - dgAssert(diag > dgFloat32(0.0f)); - rhs->m_diagDamp = diag * rhs->m_diagonalRegularizer; - diag *= (dgFloat32(1.0f) + rhs->m_diagonalRegularizer); - rhs->m_invJinvMJt = dgFloat32(1.0f) / diag; - - dgAssert(dgCheckFloat(rhs->m_force)); - dgVector val(rhs->m_force); - forceAcc0.m_linear += row->m_Jt.m_jacobianM0.m_linear * val; - forceAcc0.m_angular += row->m_Jt.m_jacobianM0.m_angular * val; - forceAcc1.m_linear += row->m_Jt.m_jacobianM1.m_linear * val; - forceAcc1.m_angular += row->m_Jt.m_jacobianM1.m_angular * val; - } - - forceAcc0.m_linear = forceAcc0.m_linear * preconditioner0; - forceAcc0.m_angular = forceAcc0.m_angular * preconditioner0; - forceAcc1.m_linear = forceAcc1.m_linear * preconditioner1; - forceAcc1.m_angular = forceAcc1.m_angular * preconditioner1; - - internalForces[m0].m_linear += forceAcc0.m_linear; - internalForces[m0].m_angular += forceAcc0.m_angular; - internalForces[m1].m_linear += forceAcc1.m_linear; - internalForces[m1].m_angular += forceAcc1.m_angular; -} - -void dgWorldDynamicUpdate::BuildJacobianMatrix(dgBodyCluster* const cluster, dgInt32 threadID, dgFloat32 timestep) const -{ - D_TRACKTIME(); - dgAssert(cluster->m_bodyCount >= 2); - - dgWorld* const world = (dgWorld*) this; - const dgInt32 bodyCount = cluster->m_bodyCount; - - dgBodyInfo* const bodyArray = &world->m_bodiesMemory[cluster->m_bodyStart]; - dgJacobian* const internalForces = &m_solverMemory.m_internalForcesBuffer[cluster->m_bodyStart]; - - dgAssert(((dgDynamicBody*)bodyArray[0].m_body)->IsRTTIType(dgBody::m_dynamicBodyRTTI)); - dgAssert((((dgDynamicBody*)bodyArray[0].m_body)->m_accel.DotProduct(((dgDynamicBody*)bodyArray[0].m_body)->m_accel)).GetScalar() == dgFloat32(0.0f)); - dgAssert((((dgDynamicBody*)bodyArray[0].m_body)->m_alpha.DotProduct(((dgDynamicBody*)bodyArray[0].m_body)->m_alpha)).GetScalar() == dgFloat32(0.0f)); - dgAssert((((dgDynamicBody*)bodyArray[0].m_body)->m_externalForce.DotProduct(((dgDynamicBody*)bodyArray[0].m_body)->m_externalForce)).GetScalar() == dgFloat32(0.0f)); - dgAssert((((dgDynamicBody*)bodyArray[0].m_body)->m_externalTorque.DotProduct(((dgDynamicBody*)bodyArray[0].m_body)->m_externalTorque)).GetScalar() == dgFloat32(0.0f)); - - internalForces[0].m_linear = dgVector::m_zero; - internalForces[0].m_angular = dgVector::m_zero; - - if (timestep != dgFloat32(0.0f)) { - for (dgInt32 i = 1; i < bodyCount; i++) { - dgBody* const body = (dgDynamicBody*)bodyArray[i].m_body; - dgAssert(body->IsRTTIType(dgBody::m_dynamicBodyRTTI) || body->IsRTTIType(dgBody::m_kinematicBodyRTTI)); - if (!body->m_equilibrium) { - dgAssert(body->m_invMass.m_w > dgFloat32(0.0f)); - body->AddDampingAcceleration(timestep); - body->CalcInvInertiaMatrix(); - } - - // re use these variables for temp storage - body->m_accel = body->m_veloc; - body->m_alpha = body->m_omega; - - internalForces[i].m_linear = dgVector::m_zero; - internalForces[i].m_angular = dgVector::m_zero; - } - } else { - for (dgInt32 i = 1; i < bodyCount; i++) { - dgBody* const body = bodyArray[i].m_body; - dgAssert(body->IsRTTIType(dgBody::m_dynamicBodyRTTI) || body->IsRTTIType(dgBody::m_kinematicBodyRTTI)); - if (!body->m_equilibrium) { - dgAssert(body->m_invMass.m_w > dgFloat32(0.0f)); - body->CalcInvInertiaMatrix(); - } - - // re use these variables for temp storage - body->m_accel = body->m_veloc; - body->m_alpha = body->m_omega; - - internalForces[i].m_linear = dgVector::m_zero; - internalForces[i].m_angular = dgVector::m_zero; - } - } - - dgContraintDescritor constraintParams; - - constraintParams.m_world = world; - constraintParams.m_threadIndex = threadID; - constraintParams.m_timestep = timestep; - constraintParams.m_invTimestep = (timestep > dgFloat32(1.0e-5f)) ? dgFloat32(1.0f / timestep) : dgFloat32(0.0f); - const dgFloat32 forceOrImpulseScale = (timestep > dgFloat32(0.0f)) ? dgFloat32(1.0f) : dgFloat32(0.0f); - - dgJointInfo* const constraintArray = &world->m_jointsMemory[cluster->m_jointStart]; - dgLeftHandSide* const leftHandSide = &m_solverMemory.m_leftHandSizeBuffer[cluster->m_rowStart]; - dgRightHandSide* const rightHandSide = &m_solverMemory.m_righHandSizeBuffer[cluster->m_rowStart]; - - dgInt32 rowCount = 0; - const dgInt32 jointCount = cluster->m_jointCount; - - dgUnsigned8 impactBuffer[256 * (sizeof(dgContact*) + sizeof(dgFloat32))]; - dgDownHeap<dgContact*, dgFloat32> impactJoints(impactBuffer, sizeof(impactBuffer)); - - for (dgInt32 i = 0; i < jointCount; i++) { - dgJointInfo* const jointInfo = &constraintArray[i]; - dgConstraint* const constraint = jointInfo->m_joint; - - dgAssert(dgInt32(constraint->m_index) == i); - dgAssert(jointInfo->m_m0 < cluster->m_bodyCount); - dgAssert(jointInfo->m_m1 < cluster->m_bodyCount); - - rowCount = GetJacobianDerivatives(constraintParams, jointInfo, constraint, leftHandSide, rightHandSide, rowCount); - dgAssert(rowCount <= cluster->m_rowCount); - - dgAssert(jointInfo->m_m0 >= 0); - dgAssert(jointInfo->m_m0 < bodyCount); - dgAssert(jointInfo->m_m1 >= 0); - dgAssert(jointInfo->m_m1 < bodyCount); - BuildJacobianMatrix(bodyArray, jointInfo, internalForces, leftHandSide, rightHandSide, forceOrImpulseScale); - - dgFloat32 impulseSpeed = constraint->GetImpulseContactSpeed(); - if (impulseSpeed > DG_IMPULSE_CONTACT_SPEED) { - dgContact* contact = (dgContact*)constraint; - impactJoints.Push(contact, impulseSpeed); - } - } - - if (impactJoints.GetCount()) { -// ResolveImpulse(constraintArray, leftHandSide, rightHandSide, impactJoints); - } -} - -void dgWorldDynamicUpdate::ResolveImpulse(const dgJointInfo* const constraintArray, const dgLeftHandSide* const leftHandSide, dgRightHandSide* const rightHandSide, dgDownHeap<dgContact*, dgFloat32>& impactJoints) const -{ - dgJacobian impulse[DG_IMPULSE_COUNT]; - dgBodyInfo bodyArray[DG_IMPULSE_COUNT]; - dgJointImpulseInfo contactArray[DG_IMPULSE_COUNT]; - dgFloat32 relVeloc[DG_IMPULSE_COUNT]; - dgFloat32 outImpulse[DG_IMPULSE_COUNT]; - - dgAtomicExchangeAndAdd(&m_impulseLru, 1); - while (impactJoints.GetCount()) { - dgContact* const contact = impactJoints[0]; - impactJoints.Pop(); - if (contact->GetImpulseContactSpeed() > DG_IMPULSE_CONTACT_SPEED) { - dgBody* body = contact->GetBody0(); - dgBody* const otherBody = contact->GetBody1(); - bool test = otherBody->GetInvMass().m_w > dgFloat32(0.0f); - test = test && (otherBody->m_veloc.DotProduct(otherBody->m_veloc).GetScalar() > body->m_veloc.DotProduct(body->m_veloc).GetScalar()); - if (test) { - body = otherBody; - } - - dgInt32 bodyCount = 1; - dgInt32 rowsCount = 0; - dgInt32 contactCount = 0; - - bodyArray[0].m_body = body; - impulse[0].m_linear = dgVector::m_zero; - impulse[0].m_angular = dgVector::m_zero; - for (dgBodyMasterListRow::dgListNode* jointNode = body->m_masterNode->GetInfo().GetFirst(); jointNode; jointNode = jointNode->GetNext()) { - dgBodyMasterListCell* const cell = &jointNode->GetInfo(); - dgConstraint* const constraint = cell->m_joint; - - if (constraint->IsActive() && (constraint->GetId() == dgConstraint::m_contactConstraint)) { - dgContact* const contactJoint = (dgContact*)constraint; - if (contactJoint->GetImpulseContactSpeed() > DG_IMPULSE_CONTACT_SPEED) { - dgBody* const body0 = contactJoint->GetBody0(); - dgBody* const body1 = contactJoint->GetBody1(); - dgAssert ((body0 == body) || (body1 == body)); - - const dgJointInfo& jointInfo = constraintArray[contactJoint->m_index]; - dgJointImpulseInfo& contactInfo = contactArray[contactCount]; - contactInfo.m_joint = contactJoint; - dgAssert(jointInfo.m_joint == contactJoint); - - contactInfo.m_pairStart = jointInfo.m_pairStart; - contactInfo.m_pairCount = jointInfo.m_pairCount; - contactInfo.m_rhsStart = rowsCount; - - bodyArray[bodyCount].m_body = (body1 != body) ? body1 : body0; - contactArray[contactCount].m_m0 = (body1 != body) ? 0 : bodyCount; - contactArray[contactCount].m_m1 = (body1 != body) ? bodyCount : 0; - - impulse[bodyCount].m_linear = dgVector::m_zero; - impulse[bodyCount].m_angular = dgVector::m_zero; - - dgAssert (bodyArray[contactArray[contactCount].m_m0].m_body == contactJoint->GetBody0()); - dgAssert (bodyArray[contactArray[contactCount].m_m1].m_body == contactJoint->GetBody1()); - - bodyCount++; - contactCount++; - rowsCount += contactInfo.m_pairCount; - dgAssert(bodyCount < sizeof(bodyArray) / sizeof(bodyArray[0])); - } - } - } - - dgInt32 lru = dgAtomicExchangeAndAdd(&m_impulseLru, 1); - memset(outImpulse, 0, rowsCount * sizeof(dgFloat32)); - for (dgInt32 i = 0; i < contactCount; i++) { - dgJointImpulseInfo* const jointInfo = &contactArray[i]; - jointInfo->m_joint->m_impulseLru = lru; - jointInfo->m_joint->SetImpulseContactSpeed(dgFloat32 (0.0f)); - const dgInt32 index = jointInfo->m_pairStart; - CalculateImpulseVeloc(jointInfo, &leftHandSide[index], &rightHandSide[index], &relVeloc[jointInfo->m_rhsStart]); - } - - dgFloat32 impulseNorm = dgFloat32 (10.0f); - dgFloat32 maxImpulseNorm = DG_IMPULSE_CONTACT_SPEED; - for (dgInt32 j = 0; (j < 4) && (impulseNorm > maxImpulseNorm); j++) { - impulseNorm = dgFloat32 (0.0f); - for (dgInt32 i = 0; i < contactCount; i++) { - dgJointImpulseInfo* const jointInfo = &contactArray[i]; - const dgInt32 index = jointInfo->m_pairStart; - dgFloat32 impulse2 = CalculateJointImpulse(jointInfo, bodyArray, impulse, &leftHandSide[index], &rightHandSide[index], &relVeloc[jointInfo->m_rhsStart], &outImpulse[i]); - impulseNorm += impulse2; - } - } - - for (dgInt32 i = 0; i < bodyCount; i++) { - dgDynamicBody* const impulseBody = (dgDynamicBody*)bodyArray[i].m_body; - const dgVector velocStep(impulse[i].m_linear.Scale(impulseBody->m_invMass.m_w)); - const dgVector omegaStep(impulseBody->m_invWorldInertiaMatrix.RotateVector(impulse[i].m_angular)); - impulseBody->m_veloc += velocStep; - impulseBody->m_omega += omegaStep; - } - - for (dgInt32 i = 0; i < bodyCount; i ++) { - dgBody* const fanBody = bodyArray[i].m_body; - if (fanBody->GetInvMass().m_w > dgFloat32 (0.0f)) { - for (dgBodyMasterListRow::dgListNode* jointNode = fanBody->m_masterNode->GetInfo().GetFirst(); jointNode; jointNode = jointNode->GetNext()) { - dgBodyMasterListCell* const cell = &jointNode->GetInfo(); - dgConstraint* const constraint = cell->m_joint; - - if ((dgInt32 (constraint->m_index) != lru) && constraint->IsActive() && (constraint->GetId() == dgConstraint::m_contactConstraint)) { - dgAssert (0); - } - } - } - } - } - } -} - -dgFloat32 dgWorldDynamicUpdate::CalculateJointImpulse(const dgJointImpulseInfo* const jointInfo, const dgBodyInfo* const bodyArray, dgJacobian* const internalForces, const dgLeftHandSide* const matrixRow, const dgRightHandSide* const rightHandSide, dgFloat32* const relVel, dgFloat32* const out) const -{ - dgVector accNorm(dgVector::m_zero); - - dgFloat32 normalForce[DG_CONSTRAINT_MAX_ROWS + 4]; - - const dgInt32 m0 = jointInfo->m_m0; - const dgInt32 m1 = jointInfo->m_m1; - dgInt32 rowsCount = jointInfo->m_pairCount; - - dgVector linearM0(internalForces[m0].m_linear); - dgVector angularM0(internalForces[m0].m_angular); - dgVector linearM1(internalForces[m1].m_linear); - dgVector angularM1(internalForces[m1].m_angular); - - normalForce[0] = dgFloat32(1.0f); -// const dgInt32 rowStart = jointInfo->m_pairStart; - - for (dgInt32 j = 0; j < rowsCount; j++) { - const dgLeftHandSide* const row = &matrixRow[j]; - const dgRightHandSide* const rhs____ = &rightHandSide[j]; - dgVector a(row->m_JMinv.m_jacobianM0.m_linear * linearM0); - a = a.MulAdd(row->m_JMinv.m_jacobianM0.m_angular, angularM0); - a = a.MulAdd(row->m_JMinv.m_jacobianM1.m_linear, linearM1); - a = a.MulAdd(row->m_JMinv.m_jacobianM1.m_angular, angularM1); - //a = dgVector(rhs->m_coordenateAccel - rhs->m_force * rhs->m_diagDamp) - a.AddHorizontal(); - a = dgVector(relVel[j] - out[j] * rhs____->m_diagDamp) - a.AddHorizontal(); - - //dgVector f(rhs->m_force + rhs->m_invJinvMJt * a.GetScalar()); - dgVector f(out[j] + rhs____->m_invJinvMJt * a.GetScalar()); - dgAssert(rhs____->m_normalForceIndex >= -1); - dgAssert(rhs____->m_normalForceIndex <= rowsCount); - - dgInt32 frictionIndex = rhs____->m_normalForceIndex + 1; - dgFloat32 frictionNormal = normalForce[frictionIndex]; - dgVector lowerFrictionForce(frictionNormal * rhs____->m_lowerBoundFrictionCoefficent); - dgVector upperFrictionForce(frictionNormal * rhs____->m_upperBoundFrictionCoefficent); - - a = a & (f < upperFrictionForce) & (f > lowerFrictionForce); - f = f.GetMax(lowerFrictionForce).GetMin(upperFrictionForce); - accNorm = accNorm.MulAdd(a, a); - - //dgVector deltaForce(f - dgVector(rhs->m_force)); - dgVector deltaForce(f - dgVector(out[j])); - - //rhs->m_force = f.GetScalar(); - out[j] = f.GetScalar(); - normalForce[j + 1] = f.GetScalar(); - - linearM0 = linearM0.MulAdd(row->m_Jt.m_jacobianM0.m_linear, deltaForce); - angularM0 = angularM0.MulAdd(row->m_Jt.m_jacobianM0.m_angular, deltaForce); - linearM1 = linearM1.MulAdd(row->m_Jt.m_jacobianM1.m_linear, deltaForce); - angularM1 = angularM1.MulAdd(row->m_Jt.m_jacobianM1.m_angular, deltaForce); - } - - - dgVector maxAccel(accNorm); - const dgFloat32 tol = dgFloat32(0.5f); - const dgFloat32 tol2 = tol * tol; - for (dgInt32 i = 0; (i < 4) && (maxAccel.GetScalar() > tol2); i++) { - maxAccel = dgVector::m_zero; - for (dgInt32 j = 0; j < rowsCount; j++) { - const dgLeftHandSide* const row = &matrixRow[j]; - const dgRightHandSide* const rhs____ = &rightHandSide[j]; - dgVector a(row->m_JMinv.m_jacobianM0.m_linear * linearM0); - a = a.MulAdd(row->m_JMinv.m_jacobianM0.m_angular, angularM0); - a = a.MulAdd(row->m_JMinv.m_jacobianM1.m_linear, linearM1); - a = a.MulAdd(row->m_JMinv.m_jacobianM1.m_angular, angularM1); - //a = dgVector(rhs->m_coordenateAccel - rhs->m_force * rhs->m_diagDamp) - a.AddHorizontal(); - a = dgVector(relVel[j] - out[j] * rhs____->m_diagDamp) - a.AddHorizontal(); - - //dgVector f(rhs->m_force + rhs->m_invJinvMJt * a.GetScalar()); - dgVector f(out[j] + rhs____->m_invJinvMJt * a.GetScalar()); - dgAssert(rhs____->m_normalForceIndex >= -1); - dgAssert(rhs____->m_normalForceIndex <= rowsCount); - - dgInt32 frictionIndex = rhs____->m_normalForceIndex + 1; - dgFloat32 frictionNormal = normalForce[frictionIndex]; - dgVector lowerFrictionForce(frictionNormal * rhs____->m_lowerBoundFrictionCoefficent); - dgVector upperFrictionForce(frictionNormal * rhs____->m_upperBoundFrictionCoefficent); - - a = a & (f < upperFrictionForce) & (f > lowerFrictionForce); - f = f.GetMax(lowerFrictionForce).GetMin(upperFrictionForce); - maxAccel = maxAccel.MulAdd(a, a); - - //dgVector deltaForce(f - dgVector(rhs->m_force)); - dgVector deltaForce(f - dgVector(out[j])); - - //rhs->m_force = f.GetScalar(); - out[j] = f.GetScalar(); - normalForce[j + 1] = f.GetScalar(); - - linearM0 = linearM0.MulAdd(row->m_Jt.m_jacobianM0.m_linear, deltaForce); - angularM0 = angularM0.MulAdd(row->m_Jt.m_jacobianM0.m_angular, deltaForce); - linearM1 = linearM1.MulAdd(row->m_Jt.m_jacobianM1.m_linear, deltaForce); - angularM1 = angularM1.MulAdd(row->m_Jt.m_jacobianM1.m_angular, deltaForce); - } - } - - - internalForces[m0].m_linear = linearM0; - internalForces[m0].m_angular = angularM0; - internalForces[m1].m_linear = linearM1; - internalForces[m1].m_angular = angularM1; - - return accNorm.GetScalar(); -} - - -void dgWorldDynamicUpdate::CalculateImpulseVeloc(dgJointImpulseInfo* const jointInfo, const dgLeftHandSide* const leftHandSide, const dgRightHandSide* const rightHandSide, dgFloat32* const contactVeloc) const -{ - dgContact* const contact = (dgContact*)jointInfo->m_joint; - const dgVector& bodyVeloc0 = contact->GetBody0()->m_veloc; - const dgVector& bodyOmega0 = contact->GetBody0()->m_omega; - const dgVector& bodyVeloc1 = contact->GetBody1()->m_veloc; - const dgVector& bodyOmega1 = contact->GetBody1()->m_omega; - - const dgInt32 count = jointInfo->m_pairCount; - for (dgInt32 k = 0; k < count; k++) { - const dgRightHandSide* const rhs = &rightHandSide[k]; - const dgLeftHandSide* const row = &leftHandSide[k]; - const dgJacobian &jacobian0 = row->m_Jt.m_jacobianM0; - const dgJacobian &jacobian1 = row->m_Jt.m_jacobianM1; - - dgVector relVeloc(jacobian0.m_linear * bodyVeloc0 + jacobian0.m_angular * bodyOmega0 + jacobian1.m_linear * bodyVeloc1 + jacobian1.m_angular * bodyOmega1); - dgFloat32 vRel = relVeloc.AddHorizontal().GetScalar(); - if (rhs->m_normalForceIndex == DG_INDEPENDENT_ROW) { - dgAssert(rhs->m_restitution >= 0.0f); - dgAssert(rhs->m_restitution <= 2.0f); - dgFloat32 restitution = (vRel <= dgFloat32(0.0f)) ? (dgFloat32(1.0f) + rhs->m_restitution) : dgFloat32(1.0f); - vRel = vRel * restitution; - } - contactVeloc[k] = - vRel; - } -} - -dgInt32 dgWorldDynamicUpdate::SortClusters(const dgBodyCluster* const cluster, dgFloat32 timestep, dgInt32 threadID) const -{ - DG_TRACKTIME(); - dgWorld* const world = (dgWorld*) this; - dgBodyInfo* const bodyArray = &world->m_bodiesMemory[cluster->m_bodyStart]; - dgJointInfo* const constraintArray = &world->m_jointsMemory[cluster->m_jointStart]; - - const dgInt32 bodyCount = cluster->m_bodyCount; - const dgInt32 jointCount = cluster->m_jointCount; - - dgJointInfo* const tmpInfoList = dgAlloca(dgJointInfo, cluster->m_jointCount); - dgJointInfo** queueBuffer = dgAlloca(dgJointInfo*, cluster->m_jointCount * 2 + 1024 * 8); - dgBodyJacobianPair* const bodyJoint = dgAlloca(dgBodyJacobianPair, cluster->m_jointCount * 2); - dgInt32* const bodyJointList = dgAlloca(dgInt32, bodyCount + 1); - - dgQueue<dgJointInfo*> queue(queueBuffer, cluster->m_jointCount * 2 + 1024 * 8); - dgFloat32 heaviestMass = dgFloat32(1.0e20f); - dgInt32 infoIndex = 0; - dgInt32 activeJoints = 0; - dgJointInfo* heaviestBody = NULL; - - for (dgInt32 i = 0; i < jointCount; i++) { - dgJointInfo& jointInfo = constraintArray[i]; - tmpInfoList[i] = jointInfo; - tmpInfoList[i].m_preconditioner0 = dgFloat32(0.0f); - - jointInfo.m_joint->m_graphTagged = 0; - const dgInt32 m0 = jointInfo.m_m0; - const dgInt32 m1 = jointInfo.m_m1; - dgBody* const body0 = bodyArray[m0].m_body; - dgBody* const body1 = bodyArray[m1].m_body; - - const dgFloat32 invMass0 = body0->GetInvMass().m_w; - const dgFloat32 invMass1 = body1->GetInvMass().m_w; - - if ((invMass0 == dgFloat32(0.0f)) || (invMass1 == dgFloat32(0.0f))) { - queue.Insert(&tmpInfoList[i]); - tmpInfoList[i].m_preconditioner0 = dgFloat32(1.0f); - } else if (invMass0 && (heaviestMass > invMass0)) { - heaviestMass = invMass0; - heaviestBody = &tmpInfoList[i]; - } else if (invMass1 && (heaviestMass > invMass1)) { - heaviestMass = invMass1; - heaviestBody = &tmpInfoList[i]; - } - - bodyJoint[i * 2 + 0].m_bodyIndex = m0; - bodyJoint[i * 2 + 0].m_JointIndex = i; - bodyJoint[i * 2 + 1].m_bodyIndex = m1; - bodyJoint[i * 2 + 1].m_JointIndex = i; - } - - if (queue.IsEmpty()) { - dgAssert(heaviestBody); - queue.Insert(heaviestBody); - heaviestBody->m_preconditioner0 = dgFloat32(1.0f); - } - - dgSort(bodyJoint, jointCount * 2, CompareBodyJacobianPair); - memset(bodyJointList, 0, sizeof(dgInt32) * (cluster->m_bodyCount + 1)); - for (dgInt32 i = 0; i < jointCount * 2; i++) { - dgInt32 index = bodyJoint[i].m_bodyIndex; - bodyJointList[index] ++; - } - - dgInt32 startIndex = 0; - for (dgInt32 i = 0; i <= bodyCount; i++) { - dgInt32 count = bodyJointList[i]; - bodyJointList[i] = startIndex; - startIndex += count; - } - - while (!queue.IsEmpty()) { - dgInt32 count = queue.m_firstIndex - queue.m_lastIndex; - if (count < 0) { - count += queue.m_mod; - } - - dgInt32 index = queue.m_lastIndex; - queue.Reset(); - - for (dgInt32 i = 0; i < count; i++) { - dgJointInfo* const jointInfo = queue.m_pool[index]; - dgConstraint* const constraint = jointInfo->m_joint; - if (!constraint->m_graphTagged) { - constraint->m_index = infoIndex; - constraintArray[infoIndex] = *jointInfo; - constraint->m_graphTagged = 1; - infoIndex++; - dgAssert(infoIndex <= cluster->m_jointCount); - - const dgInt32 m0 = jointInfo->m_m0; - const dgInt32 m1 = jointInfo->m_m1; - const dgBody* const body0 = bodyArray[m0].m_body; - const dgBody* const body1 = bodyArray[m1].m_body; - - activeJoints += !(body0->m_resting & body1->m_resting); - - if (body0->GetInvMass().m_w > dgFloat32(0.0f)) { - const dgInt32 endJoint = bodyJointList[m0 + 1]; - for (dgInt32 j = bodyJointList[m0]; j < endJoint; j++) { - dgJointInfo* const info = &tmpInfoList[bodyJoint[j].m_JointIndex]; - dgConstraint* const nextConstraint = info->m_joint; - if (!nextConstraint->m_graphTagged) { - if (!info->m_preconditioner0) { - queue.Insert(info); - info->m_preconditioner0 = dgFloat32(1.0f); - } - } - } - } - - if (body1->GetInvMass().m_w > dgFloat32(0.0f)) { - const dgInt32 endJoint = bodyJointList[m1 + 1]; - for (dgInt32 j = bodyJointList[m1]; j < endJoint; j++) { - dgJointInfo* const info = &tmpInfoList[bodyJoint[j].m_JointIndex]; - dgConstraint* const nextConstraint = info->m_joint; - if (!nextConstraint->m_graphTagged) { - if (!info->m_preconditioner0) { - queue.Insert(info); - info->m_preconditioner0 = dgFloat32(1.0f); - } - } - } - } - - if (infoIndex == cluster->m_jointCount) { - queue.Reset(); - break; - } - } - index++; - if (index >= queue.m_mod) { - index = 0; - } - } - } - - dgAssert(infoIndex == cluster->m_jointCount); - return activeJoints; -} - -void dgWorldDynamicUpdate::ResolveClusterForces(dgBodyCluster* const cluster, dgInt32 threadID, dgFloat32 timestep) const -{ - dgInt32 activeJoint = cluster->m_jointCount; - if (activeJoint > 0) { - activeJoint = SortClusters(cluster, timestep, threadID); - } - - dgWorld* const world = (dgWorld*) this; - dgJointInfo* const constraintArray = &world->m_jointsMemory[cluster->m_jointStart]; - - if (!cluster->m_isContinueCollision) { - if (activeJoint >= 1) { - BuildJacobianMatrix(cluster, threadID, timestep); - CalculateClusterReactionForces(cluster, threadID, timestep); - } else if (cluster->m_jointCount == 0) { - IntegrateExternalForce(cluster, timestep, threadID); - } else { - dgAssert((activeJoint == 0) && cluster->m_jointCount); - dgBodyInfo* const bodyArray = &world->m_bodiesMemory[cluster->m_bodyStart]; - dgVector zero(dgVector::m_zero); - for (dgInt32 i = 1; i < cluster->m_bodyCount; i++) { - dgDynamicBody* const body = (dgDynamicBody*)bodyArray[i].m_body; - body->m_accel = zero; - body->m_alpha = zero; - } - } - - IntegrateVelocity (cluster, DG_SOLVER_MAX_ERROR, timestep, threadID); - } else { - // calculate reaction forces and new velocities - BuildJacobianMatrix (cluster, threadID, timestep); - IntegrateReactionsForces (cluster, threadID, timestep); - - // see if the cluster goes to sleep - bool isAutoSleep = true; - bool stackSleeping = true; - dgInt32 sleepCounter = 10000; - - const dgInt32 bodyCount = cluster->m_bodyCount; - dgBodyInfo* const bodyArray = &world->m_bodiesMemory[cluster->m_bodyStart]; - - const dgFloat32 forceDamp = DG_FREEZZING_VELOCITY_DRAG; - dgFloat32 maxAccel = dgFloat32 (0.0f); - dgFloat32 maxAlpha = dgFloat32 (0.0f); - dgFloat32 maxSpeed = dgFloat32 (0.0f); - dgFloat32 maxOmega = dgFloat32 (0.0f); - - const dgFloat32 speedFreeze = world->m_freezeSpeed2; - const dgFloat32 accelFreeze = world->m_freezeAccel2; - const dgVector forceDampVect (forceDamp, forceDamp, forceDamp, dgFloat32 (0.0f)); - for (dgInt32 i = 1; i < bodyCount; i ++) { - dgDynamicBody* const body = (dgDynamicBody*) bodyArray[i].m_body; - if (body->IsRTTIType (dgBody::m_dynamicBodyRTTI)) { - dgAssert (body->m_invMass.m_w); - - const dgFloat32 accel2 = body->m_accel.DotProduct(body->m_accel).GetScalar(); - const dgFloat32 alpha2 = body->m_alpha.DotProduct(body->m_alpha).GetScalar(); - const dgFloat32 speed2 = body->m_veloc.DotProduct(body->m_veloc).GetScalar(); - const dgFloat32 omega2 = body->m_omega.DotProduct(body->m_omega).GetScalar(); - - maxAccel = dgMax (maxAccel, accel2); - maxAlpha = dgMax (maxAlpha, alpha2); - maxSpeed = dgMax (maxSpeed, speed2); - maxOmega = dgMax (maxOmega, omega2); - - bool equilibrium = (accel2 < accelFreeze) && (alpha2 < accelFreeze) && (speed2 < speedFreeze) && (omega2 < speedFreeze); - if (equilibrium) { - dgVector veloc (body->m_veloc * forceDampVect); - dgVector omega = body->m_omega * forceDampVect; - body->m_veloc = (veloc.DotProduct(veloc) > m_velocTol) & veloc; - body->m_omega = (omega.DotProduct(omega) > m_velocTol) & omega; - - } - body->m_equilibrium = equilibrium ? 1 : 0; - stackSleeping &= equilibrium; - isAutoSleep &= body->m_autoSleep; - - sleepCounter = dgMin (sleepCounter, body->m_sleepingCounter); - } - // clear accel and angular acceleration - body->m_accel = dgVector::m_zero; - body->m_alpha = dgVector::m_zero; - } - - if (isAutoSleep) { - if (stackSleeping) { - // the cluster went to sleep mode, - for (dgInt32 i = 1; i < bodyCount; i ++) { - dgBody* const body = bodyArray[i].m_body; - dgAssert (body->IsRTTIType (dgBody::m_dynamicBodyRTTI) || body->IsRTTIType (dgBody::m_kinematicBodyRTTI)); - body->m_accel = dgVector::m_zero; - body->m_alpha = dgVector::m_zero; - body->m_veloc = dgVector::m_zero; - body->m_omega = dgVector::m_zero; - } - } else { - // cluster is not sleeping but may be resting with small residual velocity for a long time - // see if we can force to go to sleep - if ((maxAccel > world->m_sleepTable[DG_SLEEP_ENTRIES - 1].m_maxAccel) || - (maxAlpha > world->m_sleepTable[DG_SLEEP_ENTRIES - 1].m_maxAlpha) || - (maxSpeed > world->m_sleepTable[DG_SLEEP_ENTRIES - 1].m_maxVeloc) || - (maxOmega > world->m_sleepTable[DG_SLEEP_ENTRIES - 1].m_maxOmega)) { - for (dgInt32 i = 1; i < bodyCount; i ++) { - dgDynamicBody* const body = (dgDynamicBody*) bodyArray[i].m_body; - if (body->IsRTTIType (dgBody::m_dynamicBodyRTTI)) { - body->m_sleepingCounter = 0; - } - } - } else { - dgInt32 index = 0; - for (dgInt32 i = 0; i < DG_SLEEP_ENTRIES; i ++) { - if ((maxAccel <= world->m_sleepTable[i].m_maxAccel) && - (maxAlpha <= world->m_sleepTable[i].m_maxAlpha) && - (maxSpeed <= world->m_sleepTable[i].m_maxVeloc) && - (maxOmega <= world->m_sleepTable[i].m_maxOmega)) { - index = i; - break; - } - } - - dgInt32 timeScaleSleepCount = dgInt32 (dgFloat32 (60.0f) * sleepCounter * timestep); - if (timeScaleSleepCount > world->m_sleepTable[index].m_steps) { - // force cluster to sleep - stackSleeping = true; - for (dgInt32 i = 1; i < bodyCount; i ++) { - dgBody* const body = bodyArray[i].m_body; - dgAssert (body->IsRTTIType (dgBody::m_dynamicBodyRTTI) || body->IsRTTIType (dgBody::m_kinematicBodyRTTI)); - body->m_accel = dgVector::m_zero; - body->m_alpha = dgVector::m_zero; - body->m_veloc = dgVector::m_zero; - body->m_omega = dgVector::m_zero; - body->m_equilibrium = 1; - } - } else { - sleepCounter ++; - for (dgInt32 i = 1; i < bodyCount; i ++) { - dgDynamicBody* const body = (dgDynamicBody*) bodyArray[i].m_body; - if (body->IsRTTIType (dgBody::m_dynamicBodyRTTI)) { - body->m_sleepingCounter = sleepCounter; - } - } - } - } - } - } - - if (!(isAutoSleep & stackSleeping)) { - // cluster is not sleeping, need to integrate cluster velocity - const dgUnsigned32 lru = world->GetBroadPhase()->m_lru; - const dgInt32 jointCount = cluster->m_jointCount; - - dgFloat32 timeRemaining = timestep; - const dgFloat32 timeTol = dgFloat32 (0.01f) * timestep; - for (dgInt32 i = 0; (i < DG_MAX_CONTINUE_COLLISON_STEPS) && (timeRemaining > timeTol); i ++) { - // calculate the closest time to impact - dgFloat32 timeToImpact = timeRemaining; - for (dgInt32 j = 0; (j < jointCount) && (timeToImpact > timeTol); j ++) { - dgContact* const contact = (dgContact*) constraintArray[j].m_joint; - if (contact->GetId() == dgConstraint::m_contactConstraint) { - dgDynamicBody* const body0 = (dgDynamicBody*)contact->m_body0; - dgDynamicBody* const body1 = (dgDynamicBody*)contact->m_body1; - if (body0->m_continueCollisionMode | body1->m_continueCollisionMode) { - dgVector p; - dgVector q; - dgVector normal; - dgVector vrel(body0->m_veloc - body1->m_veloc); - dgFloat32 speed2 = vrel.DotProduct(vrel).GetScalar(); - if (speed2 < dgFloat32(1.0e-2f)) { - timeToImpact = dgFloat32(0.0f); - } else { - timeToImpact = dgMin(timeToImpact, world->CalculateTimeToImpact(contact, timeToImpact, threadID, p, q, normal, dgFloat32(-1.0f / 256.0f))); - } - } - } - } - - if (timeToImpact > timeTol) { - timeRemaining -= timeToImpact; - for (dgInt32 j = 1; j < bodyCount; j ++) { - dgDynamicBody* const body = (dgDynamicBody*) bodyArray[j].m_body; - if (body->IsRTTIType (dgBody::m_dynamicBodyRTTI)) { - body->IntegrateVelocity(timeToImpact); - body->UpdateWorlCollisionMatrix(); - } - } - } else { - if (timeToImpact >= dgFloat32 (-1.0e-5f)) { - for (dgInt32 j = 1; j < bodyCount; j++) { - dgDynamicBody* const body = (dgDynamicBody*)bodyArray[j].m_body; - if (body->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - body->IntegrateVelocity(timeToImpact); - body->UpdateWorlCollisionMatrix(); - } - } - } - - CalculateClusterContacts (cluster, timeRemaining, lru, threadID); - BuildJacobianMatrix (cluster, threadID, 0.0f); - IntegrateReactionsForces (cluster, threadID, 0.0f); - - bool clusterReceding = true; - const dgFloat32 step = timestep * dgFloat32 (1.0f / DG_MAX_CONTINUE_COLLISON_STEPS); - for (dgInt32 k = 0; (k < DG_MAX_CONTINUE_COLLISON_STEPS) && clusterReceding; k ++) { - dgFloat32 smallTimeStep = dgMin (step, timeRemaining); - timeRemaining -= smallTimeStep; - for (dgInt32 j = 1; j < bodyCount; j ++) { - dgDynamicBody* const body = (dgDynamicBody*) bodyArray[j].m_body; - if (body->IsRTTIType (dgBody::m_dynamicBodyRTTI)) { - body->IntegrateVelocity (smallTimeStep); - body->UpdateWorlCollisionMatrix(); - } - } - - clusterReceding = false; - if (timeRemaining > timeTol) { - CalculateClusterContacts (cluster, timeRemaining, lru, threadID); - - bool isColliding = false; - for (dgInt32 j = 0; (j < jointCount) && !isColliding; j ++) { - dgContact* const contact = (dgContact*) constraintArray[j].m_joint; - if (contact->GetId() == dgConstraint::m_contactConstraint) { - - const dgBody* const body0 = contact->m_body0; - const dgBody* const body1 = contact->m_body1; - - const dgVector& veloc0 = body0->m_veloc; - const dgVector& veloc1 = body1->m_veloc; - - const dgVector& omega0 = body0->m_omega; - const dgVector& omega1 = body1->m_omega; - - const dgVector& com0 = body0->m_globalCentreOfMass; - const dgVector& com1 = body1->m_globalCentreOfMass; - - for (dgList<dgContactMaterial>::dgListNode* node = contact->GetFirst(); node; node = node->GetNext()) { - const dgContactMaterial* const contactMaterial = &node->GetInfo(); - dgVector vel0 (veloc0 + omega0.CrossProduct(contactMaterial->m_point - com0)); - dgVector vel1 (veloc1 + omega1.CrossProduct(contactMaterial->m_point - com1)); - dgVector vRel (vel0 - vel1); - dgAssert (contactMaterial->m_normal.m_w == dgFloat32 (0.0f)); - dgFloat32 speed = vRel.DotProduct(contactMaterial->m_normal).m_w; - isColliding |= (speed < dgFloat32 (0.0f)); - } - } - } - clusterReceding = !isColliding; - } - } - } - } - - if (timeRemaining > dgFloat32 (0.0)) { - for (dgInt32 j = 1; j < bodyCount; j ++) { - dgDynamicBody* const body = (dgDynamicBody*) bodyArray[j].m_body; - if (body->IsRTTIType (dgBody::m_dynamicBodyRTTI)) { - body->IntegrateVelocity(timeRemaining); - body->UpdateCollisionMatrix (timeRemaining, threadID); - } - } - } else { - for (dgInt32 j = 1; j < bodyCount; j ++) { - dgDynamicBody* const body = (dgDynamicBody*) bodyArray[j].m_body; - if (body->IsRTTIType (dgBody::m_dynamicBodyRTTI)) { - body->UpdateCollisionMatrix (timestep, threadID); - } - } - } - } - } -} - -void dgWorldDynamicUpdate::CalculateClusterContacts(dgBodyCluster* const cluster, dgFloat32 timestep, dgInt32 currLru, dgInt32 threadID) const -{ - dgWorld* const world = (dgWorld*) this; - dgInt32 jointCount = cluster->m_jointCount; - dgJointInfo* const constraintArrayPtr = &world->m_jointsMemory[0]; - dgJointInfo* const constraintArray = &constraintArrayPtr[cluster->m_jointStart]; - - dgBroadPhase::dgPair pair; - dgContactPoint contactArray[DG_MAX_CONTATCS]; - for (dgInt32 j = 0; (j < jointCount); j ++) { - dgContact* const contact = (dgContact*) constraintArray[j].m_joint; - if (contact->GetId() == dgConstraint::m_contactConstraint) { - const dgContactMaterial* const material = contact->m_material; - if (material->m_flags & dgContactMaterial::m_collisionEnable) { - dgInt32 processContacts = 1; - if (material->m_aabbOverlap) { - //processContacts = material->m_aabbOverlap (*material, *contact->GetBody0(), *contact->GetBody1(), threadID); - processContacts = material->m_aabbOverlap(*contact, timestep, threadID); - } - - if (processContacts) { - contact->m_maxDOF = 0; - contact->m_broadphaseLru = currLru; - pair.m_contact = contact; - pair.m_cacheIsValid = false; - pair.m_timestep = timestep; - pair.m_contactBuffer = contactArray; - world->CalculateContacts (&pair, threadID, false, false); - if (pair.m_contactCount) { - dgAssert (pair.m_contactCount <= (DG_CONSTRAINT_MAX_ROWS / 3)); - world->ProcessContacts (&pair, threadID); - } - } - } - } - } -} - -void dgWorldDynamicUpdate::IntegrateExternalForce(const dgBodyCluster* const cluster, dgFloat32 timestep, dgInt32 threadID) const -{ - D_TRACKTIME(); - dgWorld* const world = (dgWorld*) this; - dgBodyInfo* const bodyArray = &world->m_bodiesMemory[cluster->m_bodyStart]; - - dgAssert (timestep > dgFloat32 (0.0f)); - const dgInt32 bodyCount = cluster->m_bodyCount; - for (dgInt32 i = 1; i < bodyCount; i ++) { - dgDynamicBody* const body = (dgDynamicBody*) bodyArray[i].m_body; - body->UpdateGyroData(); - body->AddDampingAcceleration(timestep); - body->IntegrateOpenLoopExternalForce(timestep); - } -} - -void dgWorldDynamicUpdate::CalculateNetAcceleration(dgBody* const body, const dgVector& invTimeStep, const dgVector& maxAccNorm2) const -{ - dgAssert(body->IsRTTIType(dgBody::m_dynamicBodyRTTI) || body->IsRTTIType(dgBody::m_kinematicBodyRTTI)); - // the initial velocity and angular velocity were stored in m_accel and body->m_alpha for memory saving - dgVector accel (invTimeStep * (body->m_veloc - body->m_accel)); - dgVector alpha (invTimeStep * (body->m_omega - body->m_alpha)); - dgVector accelTest((accel.DotProduct(accel) > maxAccNorm2) | (alpha.DotProduct(alpha) > maxAccNorm2)); - accel = accel & accelTest; - alpha = alpha & accelTest; - - body->m_accel = accel; - body->m_alpha = alpha; -} - - -void dgWorldDynamicUpdate::IntegrateReactionsForces(const dgBodyCluster* const cluster, dgInt32 threadID, dgFloat32 timestep) const -{ - if (cluster->m_jointCount == 0) { - IntegrateExternalForce(cluster, timestep, threadID); - } else { - CalculateClusterReactionForces(cluster, threadID, timestep); - } -} - -dgFloat32 dgWorldDynamicUpdate::CalculateJointForce_3_13(const dgJointInfo* const jointInfo, const dgBodyInfo* const bodyArray, dgJacobian* const internalForces, const dgLeftHandSide* const matrixRow, dgRightHandSide* const rightHandSide) const -{ - dgVector accNorm(dgVector::m_zero); - const dgInt32 m0 = jointInfo->m_m0; - const dgInt32 m1 = jointInfo->m_m1; - const dgBody* const body0 = bodyArray[m0].m_body; - const dgBody* const body1 = bodyArray[m1].m_body; - - if (!(body0->m_resting & body1->m_resting)) { - dgFloat32 normalForce[DG_CONSTRAINT_MAX_ROWS + 1]; - dgVector linearM0(internalForces[m0].m_linear); - dgVector angularM0(internalForces[m0].m_angular); - dgVector linearM1(internalForces[m1].m_linear); - dgVector angularM1(internalForces[m1].m_angular); - - const dgVector preconditioner0(jointInfo->m_preconditioner0); - const dgVector preconditioner1(jointInfo->m_preconditioner1); - - const dgInt32 index = jointInfo->m_pairStart; - const dgInt32 rowsCount = jointInfo->m_pairCount; - - normalForce[0] = dgFloat32 (1.0f); - dgVector firstPass(dgVector::m_one); - dgVector maxAccel(dgVector::m_three); - const dgFloat32 restAcceleration = DG_SOLVER_MAX_ERROR * DG_SOLVER_MAX_ERROR * dgFloat32(4.0f); - for (dgInt32 i = 0; (i < 4) && (maxAccel.GetScalar() > restAcceleration); i++) { - maxAccel = dgFloat32(0.0f); - for (dgInt32 j = 0; j < rowsCount; j++) { - dgRightHandSide* const rhs = &rightHandSide[index + j]; - const dgLeftHandSide* const row = &matrixRow[index + j]; - - dgAssert(row->m_Jt.m_jacobianM0.m_linear.m_w == dgFloat32(0.0f)); - dgAssert(row->m_Jt.m_jacobianM0.m_angular.m_w == dgFloat32(0.0f)); - dgAssert(row->m_Jt.m_jacobianM1.m_linear.m_w == dgFloat32(0.0f)); - dgAssert(row->m_Jt.m_jacobianM1.m_angular.m_w == dgFloat32(0.0f)); - - dgVector diag(row->m_JMinv.m_jacobianM0.m_linear * linearM0 + row->m_JMinv.m_jacobianM0.m_angular * angularM0 + - row->m_JMinv.m_jacobianM1.m_linear * linearM1 + row->m_JMinv.m_jacobianM1.m_angular * angularM1); - - dgVector accel(rhs->m_coordenateAccel - rhs->m_force * rhs->m_diagDamp - (diag.AddHorizontal()).GetScalar()); - dgVector force(rhs->m_force + rhs->m_invJinvMJt * accel.GetScalar()); - - dgAssert (rhs->m_normalForceIndex >= -1); - dgAssert (rhs->m_normalForceIndex <= rowsCount); - dgInt32 frictionIndex = rhs->m_normalForceIndex + 1; - - dgFloat32 frictionNormal = normalForce[frictionIndex]; - dgVector lowerFrictionForce(frictionNormal * rhs->m_lowerBoundFrictionCoefficent); - dgVector upperFrictionForce(frictionNormal * rhs->m_upperBoundFrictionCoefficent); - - accel = accel & (force < upperFrictionForce) & (force > lowerFrictionForce); - force = force.GetMax(lowerFrictionForce).GetMin(upperFrictionForce); - maxAccel = maxAccel.GetMax(accel.Abs()); - - dgAssert(maxAccel.m_x >= dgAbs(accel.m_x)); - - accNorm = accNorm.GetMax(maxAccel * firstPass); - - dgVector deltaForce(force - dgVector(rhs->m_force)); - rhs->m_force = force.GetScalar(); - normalForce[j + 1] = force.GetScalar(); - - dgVector deltaforce0(preconditioner0 * deltaForce); - dgVector deltaforce1(preconditioner1 * deltaForce); - - linearM0 += row->m_Jt.m_jacobianM0.m_linear * deltaforce0; - angularM0 += row->m_Jt.m_jacobianM0.m_angular * deltaforce0; - linearM1 += row->m_Jt.m_jacobianM1.m_linear * deltaforce1; - angularM1 += row->m_Jt.m_jacobianM1.m_angular * deltaforce1; - } - firstPass = dgVector::m_zero; - } - - for (dgInt32 i = 0; i < rowsCount; i++) { - //dgLeftHandSide* const row = &matrixRow[index + i]; - dgRightHandSide* const rhs = &rightHandSide[index + i]; - rhs->m_maxImpact = dgMax(dgAbs(rhs->m_force), rhs->m_maxImpact); - } - - internalForces[m0].m_linear = linearM0; - internalForces[m0].m_angular = angularM0; - internalForces[m1].m_linear = linearM1; - internalForces[m1].m_angular = angularM1; - } - - return accNorm.GetScalar() * accNorm.GetScalar(); -} - -dgFloat32 dgWorldDynamicUpdate::CalculateJointForce(const dgJointInfo* const jointInfo, const dgBodyInfo* const bodyArray, dgJacobian* const internalForces, const dgLeftHandSide* const matrixRow, dgRightHandSide* const rightHandSide) const -{ - dgVector accNorm(dgVector::m_zero); - dgFloat32 normalForce[DG_CONSTRAINT_MAX_ROWS + 4]; - - const dgInt32 m0 = jointInfo->m_m0; - const dgInt32 m1 = jointInfo->m_m1; - const dgBody* const body0 = bodyArray[m0].m_body; - const dgBody* const body1 = bodyArray[m1].m_body; - - if (!(body0->m_resting & body1->m_resting)) { - dgInt32 rowsCount = jointInfo->m_pairCount; - - dgVector linearM0(internalForces[m0].m_linear); - dgVector angularM0(internalForces[m0].m_angular); - dgVector linearM1(internalForces[m1].m_linear); - dgVector angularM1(internalForces[m1].m_angular); - - const dgVector preconditioner0(jointInfo->m_preconditioner0); - const dgVector preconditioner1(jointInfo->m_preconditioner1); - - normalForce[0] = dgFloat32(1.0f); - const dgInt32 rowStart = jointInfo->m_pairStart; - for (dgInt32 j = 0; j < rowsCount; j++) { - dgRightHandSide* const rhs = &rightHandSide[rowStart + j]; - const dgLeftHandSide* const row = &matrixRow[rowStart + j]; - dgVector a (row->m_JMinv.m_jacobianM0.m_linear * linearM0); - a = a.MulAdd(row->m_JMinv.m_jacobianM0.m_angular, angularM0); - a = a.MulAdd(row->m_JMinv.m_jacobianM1.m_linear, linearM1); - a = a.MulAdd(row->m_JMinv.m_jacobianM1.m_angular, angularM1); - a = dgVector(rhs->m_coordenateAccel - rhs->m_force * rhs->m_diagDamp) - a.AddHorizontal(); - - dgVector f(rhs->m_force + rhs->m_invJinvMJt * a.GetScalar()); - dgAssert(rhs->m_normalForceIndex >= -1); - dgAssert(rhs->m_normalForceIndex <= rowsCount); - dgInt32 frictionIndex = rhs->m_normalForceIndex + 1; - - dgFloat32 frictionNormal = normalForce[frictionIndex]; - dgVector lowerFrictionForce(frictionNormal * rhs->m_lowerBoundFrictionCoefficent); - dgVector upperFrictionForce(frictionNormal * rhs->m_upperBoundFrictionCoefficent); - - a = a & (f < upperFrictionForce) & (f > lowerFrictionForce); - f = f.GetMax(lowerFrictionForce).GetMin(upperFrictionForce); - accNorm = accNorm.MulAdd(a, a); - - dgVector deltaForce(f - dgVector(rhs->m_force)); - - rhs->m_force = f.GetScalar(); - normalForce[j + 1] = f.GetScalar(); - - dgVector deltaforce0(preconditioner0 * deltaForce); - dgVector deltaforce1(preconditioner1 * deltaForce); - linearM0 = linearM0.MulAdd(row->m_Jt.m_jacobianM0.m_linear, deltaforce0); - angularM0 = angularM0.MulAdd(row->m_Jt.m_jacobianM0.m_angular, deltaforce0); - linearM1 = linearM1.MulAdd(row->m_Jt.m_jacobianM1.m_linear, deltaforce1); - angularM1 = angularM1.MulAdd(row->m_Jt.m_jacobianM1.m_angular, deltaforce1); - } - - dgVector maxAccel(accNorm); - const dgFloat32 tol = dgFloat32(0.5f); - const dgFloat32 tol2 = tol * tol; - for (dgInt32 i = 0; (i < 4) && (maxAccel.GetScalar() > tol2); i++) { - maxAccel = dgVector::m_zero; - for (dgInt32 j = 0; j < rowsCount; j++) { - dgRightHandSide* const rhs = &rightHandSide[rowStart + j]; - const dgLeftHandSide* const row = &matrixRow[rowStart + j]; - dgVector a(row->m_JMinv.m_jacobianM0.m_linear * linearM0); - a = a.MulAdd(row->m_JMinv.m_jacobianM0.m_angular, angularM0); - a = a.MulAdd(row->m_JMinv.m_jacobianM1.m_linear, linearM1); - a = a.MulAdd(row->m_JMinv.m_jacobianM1.m_angular, angularM1); - a = dgVector(rhs->m_coordenateAccel - rhs->m_force * rhs->m_diagDamp) - a.AddHorizontal(); - - dgVector f(rhs->m_force + rhs->m_invJinvMJt * a.GetScalar()); - dgAssert(rhs->m_normalForceIndex >= -1); - dgAssert(rhs->m_normalForceIndex <= rowsCount); - dgInt32 frictionIndex = rhs->m_normalForceIndex + 1; - - dgFloat32 frictionNormal = normalForce[frictionIndex]; - dgVector lowerFrictionForce(frictionNormal * rhs->m_lowerBoundFrictionCoefficent); - dgVector upperFrictionForce(frictionNormal * rhs->m_upperBoundFrictionCoefficent); - - a = a & (f < upperFrictionForce) & (f > lowerFrictionForce); - f = f.GetMax(lowerFrictionForce).GetMin(upperFrictionForce); - maxAccel = maxAccel.MulAdd (a, a); - - dgVector deltaForce(f - dgVector(rhs->m_force)); - - rhs->m_force = f.GetScalar(); - normalForce[j + 1] = f.GetScalar(); - - dgVector deltaforce0(preconditioner0 * deltaForce); - dgVector deltaforce1(preconditioner1 * deltaForce); - linearM0 = linearM0.MulAdd(row->m_Jt.m_jacobianM0.m_linear, deltaforce0); - angularM0 = angularM0.MulAdd(row->m_Jt.m_jacobianM0.m_angular, deltaforce0); - linearM1 = linearM1.MulAdd(row->m_Jt.m_jacobianM1.m_linear, deltaforce1); - angularM1 = angularM1.MulAdd(row->m_Jt.m_jacobianM1.m_angular, deltaforce1); - } - } - - for (dgInt32 i = 0; i < rowsCount; i++) { - dgRightHandSide* const rhs = &rightHandSide[rowStart + i]; - rhs->m_maxImpact = dgMax(dgAbs(rhs->m_force), rhs->m_maxImpact); - } - - internalForces[m0].m_linear = linearM0; - internalForces[m0].m_angular = angularM0; - internalForces[m1].m_linear = linearM1; - internalForces[m1].m_angular = angularM1; - } - return accNorm.GetScalar(); -} - - -dgJacobian dgWorldDynamicUpdate::IntegrateForceAndToque(dgDynamicBody* const body, const dgVector& force, const dgVector& torque, const dgVector& timestep) const -{ - dgJacobian velocStep; - if (body->m_gyroTorqueOn) { - dgVector dtHalf(timestep * dgVector::m_half); - dgMatrix matrix(body->m_gyroRotation, dgVector::m_wOne); - - dgVector localOmega(matrix.UnrotateVector(body->m_omega)); - dgVector localTorque(matrix.UnrotateVector(torque)); - - // derivative at half time step. (similar to midpoint Euler so that it does not loses too much energy) - dgVector dw(localOmega * dtHalf); - dgVector inertia(body->m_mass); - - dgMatrix jacobianMatrix( - dgVector(inertia[0], (inertia[2] - inertia[1]) * dw[2], (inertia[2] - inertia[1]) * dw[1], dgFloat32(0.0f)), - dgVector((inertia[0] - inertia[2]) * dw[2], inertia[1], (inertia[0] - inertia[2]) * dw[0], dgFloat32(1.0f)), - dgVector((inertia[1] - inertia[0]) * dw[1], (inertia[1] - inertia[0]) * dw[0], inertia[2], dgFloat32(1.0f)), - dgVector::m_wOne); - - // and solving for alpha we get the angular acceleration at t + dt - // calculate gradient at a full time step - //dgVector gradientStep(localTorque * timestep); - dgVector gradientStep (jacobianMatrix.SolveByGaussianElimination(localTorque * timestep)); - - dgVector omega(matrix.RotateVector(localOmega + gradientStep)); - dgAssert(omega.m_w == dgFloat32(0.0f)); - - // integrate rotation here - dgFloat32 omegaMag2 = omega.DotProduct(omega).GetScalar() + dgFloat32(1.0e-12f); - dgFloat32 invOmegaMag = dgRsqrt(omegaMag2); - dgVector omegaAxis(omega.Scale(invOmegaMag)); - dgFloat32 omegaAngle = invOmegaMag * omegaMag2 * timestep.GetScalar(); - dgQuaternion deltaRotation(omegaAxis, omegaAngle); - body->m_gyroRotation = body->m_gyroRotation * deltaRotation; - dgAssert((body->m_gyroRotation.DotProduct(body->m_gyroRotation) - dgFloat32(1.0f)) < dgFloat32(1.0e-5f)); - - matrix = dgMatrix(body->m_gyroRotation, dgVector::m_wOne); - localOmega = matrix.UnrotateVector(omega); - //dgVector angularMomentum(inertia * localOmega); - //body->m_gyroTorque = matrix.RotateVector(localOmega.CrossProduct(angularMomentum)); - //body->m_gyroAlpha = body->m_invWorldInertiaMatrix.RotateVector(body->m_gyroTorque); - dgVector localGyroTorque(localOmega.CrossProduct(inertia * localOmega)); - body->m_gyroTorque = matrix.RotateVector(localGyroTorque); - body->m_gyroAlpha = matrix.RotateVector(localGyroTorque * body->m_invMass); - - velocStep.m_angular = matrix.RotateVector(gradientStep); - } else { - velocStep.m_angular = body->m_invWorldInertiaMatrix.RotateVector(torque - body->m_gyroTorque) * timestep; -// velocStep.m_angular = velocStep.m_angular * dgVector::m_half; - } - - velocStep.m_linear = force.Scale(body->m_invMass.m_w) * timestep; - return velocStep; -} - - -void dgWorldDynamicUpdate::CalculateClusterReactionForces(const dgBodyCluster* const cluster, dgInt32 threadID, dgFloat32 timestep) const -{ - D_TRACKTIME(); - dgWorld* const world = (dgWorld*) this; - const dgInt32 bodyCount = cluster->m_bodyCount; - const dgInt32 jointCount = cluster->m_jointCount; - - dgJacobian* const internalForces = &m_solverMemory.m_internalForcesBuffer[cluster->m_bodyStart]; - dgBodyInfo* const bodyArray = &world->m_bodiesMemory[cluster->m_bodyStart]; - dgJointInfo* const constraintArray = &world->m_jointsMemory[cluster->m_jointStart]; - - dgRightHandSide* const rightHandSide = &m_solverMemory.m_righHandSizeBuffer[cluster->m_rowStart]; - const dgLeftHandSide* const leftHandSide = &m_solverMemory.m_leftHandSizeBuffer[cluster->m_rowStart]; - - const dgInt32 derivativesEvaluationsRK4 = 4; - dgFloat32 invTimestep = (timestep > dgFloat32(0.0f)) ? dgFloat32(1.0f) / timestep : dgFloat32(0.0f); - dgFloat32 invStepRK = (dgFloat32(1.0f) / dgFloat32(derivativesEvaluationsRK4)); - dgFloat32 timestepRK = timestep * invStepRK; - dgFloat32 invTimestepRK = invTimestep * dgFloat32(derivativesEvaluationsRK4); - dgAssert(bodyArray[0].m_body == world->m_sentinelBody); - - dgVector speedFreeze2(world->m_freezeSpeed2 * dgFloat32(0.1f)); - dgVector freezeOmega2(world->m_freezeOmega2 * dgFloat32(0.1f)); - - dgJointAccelerationDecriptor joindDesc; - joindDesc.m_timeStep = timestepRK; - joindDesc.m_invTimeStep = invTimestepRK; - joindDesc.m_firstPassCoefFlag = dgFloat32(0.0f); - - dgInt32 skeletonCount = 0; - dgSkeletonList& skeletonList = *world; - dgSkeletonContainer* skeletonArray[DG_MAX_SKELETON_JOINT_COUNT]; - dgInt32 lru = dgAtomicExchangeAndAdd(&skeletonList.m_lruMarker, 1); - for (dgInt32 i = 1; i < bodyCount; i++) { - dgDynamicBody* const body = (dgDynamicBody*)bodyArray[i].m_body; - dgSkeletonContainer* const container = body->GetSkeleton(); - if (container && (container->m_lru != lru)) { - container->m_lru = lru; - skeletonArray[skeletonCount] = container; - container->InitMassMatrix(constraintArray, leftHandSide, rightHandSide); - skeletonCount++; - dgAssert(skeletonCount < dgInt32(sizeof(skeletonArray) / sizeof(skeletonArray[0]))); - } - } - - const dgInt32 passes = world->m_solverIterations; - const dgFloat32 maxAccNorm = DG_SOLVER_MAX_ERROR * DG_SOLVER_MAX_ERROR; - for (dgInt32 step = 0; step < derivativesEvaluationsRK4; step++) { - - for (dgInt32 i = 0; i < jointCount; i++) { - dgJointInfo* const jointInfo = &constraintArray[i]; - dgConstraint* const constraint = jointInfo->m_joint; - const dgInt32 pairStart = jointInfo->m_pairStart; - - joindDesc.m_rowsCount = jointInfo->m_pairCount; - joindDesc.m_leftHandSide = &leftHandSide[pairStart]; - joindDesc.m_rightHandSide = &rightHandSide[pairStart]; - constraint->JointAccelerations(&joindDesc); - } - joindDesc.m_firstPassCoefFlag = dgFloat32(1.0f); - - dgFloat32 accNorm = maxAccNorm * dgFloat32(2.0f); - for (dgInt32 i = 0; (i < passes) && (accNorm > maxAccNorm); i++) { - accNorm = dgFloat32(0.0f); - for (dgInt32 j = 0; j < jointCount; j++) { - dgJointInfo* const jointInfo = &constraintArray[j]; - //dgFloat32 accel2 = CalculateJointForce_3_13(jointInfo, bodyArray, internalForces, leftHandSide); - dgFloat32 accel2 = CalculateJointForce(jointInfo, bodyArray, internalForces, leftHandSide, rightHandSide); - accNorm += accel2; - } - } - for (dgInt32 j = 0; j < skeletonCount; j++) { - skeletonArray[j]->CalculateJointForce(constraintArray, bodyArray, internalForces); - } - - if (timestepRK != dgFloat32(0.0f)) { - dgVector timestep4(timestepRK); - for (dgInt32 i = 1; i < bodyCount; i++) { - dgDynamicBody* const body = (dgDynamicBody*)bodyArray[i].m_body; - dgAssert(body->m_index == i); - if (body->IsRTTIType(dgBody::m_dynamicBodyRTTI)) { - const dgJacobian& forceAndTorque = internalForces[i]; - const dgVector force(body->m_externalForce + forceAndTorque.m_linear); - const dgVector torque(body->m_externalTorque + forceAndTorque.m_angular); - - dgJacobian velocStep(body->IntegrateForceAndToque(force, torque, timestep4)); - if (!body->m_resting) { - body->m_veloc += velocStep.m_linear; - body->m_omega += velocStep.m_angular; - } else { - const dgVector velocStep2(velocStep.m_linear.DotProduct(velocStep.m_linear)); - const dgVector omegaStep2(velocStep.m_angular.DotProduct(velocStep.m_angular)); - const dgVector test(((velocStep2 > speedFreeze2) | (omegaStep2 > speedFreeze2)) & dgVector::m_negOne); - const dgInt32 equilibrium = test.GetSignMask() ? 0 : 1; - body->m_resting &= equilibrium; - } - - dgAssert(body->m_veloc.m_w == dgFloat32(0.0f)); - dgAssert(body->m_omega.m_w == dgFloat32(0.0f)); - } - } - } else { - for (dgInt32 i = 1; i < bodyCount; i++) { - dgDynamicBody* const body = (dgDynamicBody*)bodyArray[i].m_body; - const dgVector& linearMomentum = internalForces[i].m_linear; - const dgVector& angularMomentum = internalForces[i].m_angular; - - body->m_veloc += linearMomentum.Scale(body->m_invMass.m_w); - body->m_omega += body->m_invWorldInertiaMatrix.RotateVector(angularMomentum); - } - } - } - - dgInt32 hasJointFeeback = 0; - if (timestepRK != dgFloat32(0.0f)) { - for (dgInt32 i = 0; i < jointCount; i++) { - dgJointInfo* const jointInfo = &constraintArray[i]; - dgConstraint* const constraint = jointInfo->m_joint; - - const dgInt32 first = jointInfo->m_pairStart; - const dgInt32 count = jointInfo->m_pairCount; - - for (dgInt32 j = 0; j < count; j++) { - dgRightHandSide* const rhs = &rightHandSide[j + first]; - dgAssert(dgCheckFloat(rhs->m_force)); - rhs->m_jointFeebackForce->Push(rhs->m_force); - rhs->m_jointFeebackForce->m_force = rhs->m_force; - rhs->m_jointFeebackForce->m_impact = rhs->m_maxImpact * timestepRK; - } - hasJointFeeback |= (constraint->m_updaFeedbackCallback ? 1 : 0); - } - - //const dgFloat32 zeroAceel = (jointCount >= 16) ? DG_SOLVER_MAX_ERROR : DG_SOLVER_MAX_ERROR * dgFloat32 (0.25f); - const dgFloat32 zeroAceel = (bodyCount >= DG_SMALL_ISLAND_COUNT) ? DG_SOLVER_MAX_ERROR : DG_SOLVER_MAX_ERROR * dgFloat32 (0.125f); - const dgVector invTime(invTimestep); - const dgVector maxAccNorm2(zeroAceel * zeroAceel); - - for (dgInt32 i = 1; i < bodyCount; i++) { - dgBody* const body = bodyArray[i].m_body; - CalculateNetAcceleration(body, invTime, maxAccNorm2); - } - - if (hasJointFeeback) { - for (dgInt32 i = 0; i < jointCount; i++) { - if (constraintArray[i].m_joint->m_updaFeedbackCallback) { - constraintArray[i].m_joint->m_updaFeedbackCallback(*constraintArray[i].m_joint, timestep, threadID); - } - } - } - } else { - for (dgInt32 i = 1; i < bodyCount; i++) { - dgBody* const body = bodyArray[i].m_body; - dgAssert(body->IsRTTIType(dgBody::m_dynamicBodyRTTI) || body->IsRTTIType(dgBody::m_kinematicBodyRTTI)); - body->m_accel = dgVector::m_zero; - body->m_alpha = dgVector::m_zero; - } - } -} - diff --git a/thirdparty/src/newton/dgPhysics/dgWorldPlugins.cpp b/thirdparty/src/newton/dgPhysics/dgWorldPlugins.cpp deleted file mode 100644 index e6a4d65ad..000000000 --- a/thirdparty/src/newton/dgPhysics/dgWorldPlugins.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 "dgPhysicsStdafx.h" -#include "dgWorld.h" -#include "dgWorldPlugins.h" - - -#if __linux__ -#include <dlfcn.h> -#include <dirent.h> -#endif - - -dgWorldPluginList::dgWorldPluginList(dgMemoryAllocator* const allocator) - :dgList<dgWorldPluginModulePair>(allocator) - ,m_currentPlugin(NULL) - ,m_preferedPlugin(NULL) -{ -} - -dgWorldPluginList::~dgWorldPluginList() -{ -} - - -void dgWorldPluginList::LoadVisualStudioPlugins(const char* const plugInPath) -{ -#if defined(DG_USE_PLUGINS) && defined(_MSC_VER) - char rootPathInPath[2048]; - sprintf(rootPathInPath, "%s/*.dll", plugInPath); - - dgInt32 score = 0; - dgWorld* const world = (dgWorld*) this; - - // scan for all plugins in this folder - _finddata_t data; - intptr_t handle = _findfirst(rootPathInPath, &data); - if (handle != -1) { - do { - sprintf(rootPathInPath, "%s/%s", plugInPath, data.name); - HMODULE module = LoadLibrary(rootPathInPath); - - if (module) { - // get the interface function pointer to the Plug in classes - InitPlugin initModule = (InitPlugin)GetProcAddress(module, "GetPlugin"); - if (initModule) { - dgWorldPlugin* const plugin = initModule(world, GetAllocator ()); - if (plugin) { - dgWorldPluginModulePair entry(plugin, module); - dgListNode* const node = Append(entry); - dgInt32 pluginValue = plugin->GetScore(); - bool wasMoved = false; - for (dgListNode* ptr = GetLast()->GetPrev(); ptr; ptr = ptr->GetPrev()) { - dgInt32 value = ptr->GetInfo().m_plugin->GetScore(); - if (value > pluginValue) { - InsertAfter (ptr, node); - wasMoved = true; - break; - } - } - if (!wasMoved) { - InsertBefore (GetFirst(), node); - } - - if (pluginValue > score) { - score = pluginValue; - m_preferedPlugin = node; - } - } else { - FreeLibrary(module); - } - } else { - FreeLibrary(module); - } - } - - } while (_findnext(handle, &data) == 0); - - _findclose(handle); - } -#endif -} - -void dgWorldPluginList::LoadLinuxPlugins(const char* const plugInPath) -{ -#if defined(DG_USE_PLUGINS) && defined(__linux__) - char rootPathInPath[2048]; - DIR* directory; - dirent* dirEntry; - directory = opendir(plugInPath); - - dgInt32 score = 0; - dgWorld* const world = (dgWorld*) this; - - if(directory != NULL) { - while((dirEntry = readdir(directory)) != NULL) { - const char* const ext = strrchr(dirEntry->d_name, '.'); - if(!strcmp(ext, ".so")) { - sprintf(rootPathInPath, "%s/%s", plugInPath, dirEntry->d_name); - void* module = dlopen(rootPathInPath, RTLD_LAZY); - auto err = dlerror(); - if(module) { - InitPlugin initModule = (InitPlugin)dlsym(module, "GetPlugin"); - if(initModule) { - dgWorldPlugin* const plugin = initModule(world, GetAllocator ()); - if (plugin) { - dgWorldPluginModulePair entry(plugin, module); - dgListNode* const node = Append(entry); - dgInt32 pluginValue = plugin->GetScore(); - if (pluginValue > score) { - score = pluginValue; - m_preferedPlugin = node; - } - } else { - dlclose(module); - } - } - } - } - } - closedir(directory); - } -#endif -} - -void dgWorldPluginList::LoadPlugins(const char* const path) -{ - UnloadPlugins(); - #ifdef _MSC_VER - LoadVisualStudioPlugins(path); - #elif __linux__ - LoadLinuxPlugins(path); - #endif -} - -void dgWorldPluginList::UnloadPlugins() -{ -#if defined(DG_USE_PLUGINS) - #ifdef _MSC_VER - dgWorldPluginList& pluginsList = *this; - for (dgWorldPluginList::dgListNode* node = pluginsList.GetFirst(); node; node = node->GetNext()) { - HMODULE module = (HMODULE)node->GetInfo().m_module; - FreeLibrary(module); - } - #elif __linux__ - dgWorldPluginList& pluginsList = *this; - for (dgWorldPluginList::dgListNode* node = pluginsList.GetFirst(); node; node = node->GetNext()) { - void* module = node->GetInfo().m_module; - dlclose(module); - } - #endif -#endif - m_currentPlugin = NULL; - m_preferedPlugin = NULL; -} - -dgWorldPluginList::dgListNode* dgWorldPluginList::GetCurrentPlugin() -{ - return m_currentPlugin; -} - -dgWorldPluginList::dgListNode* dgWorldPluginList::GetpreferedPlugin() -{ - return m_preferedPlugin; -} - -dgWorldPluginList::dgListNode* dgWorldPluginList::GetFirstPlugin() -{ - dgWorldPluginList& list = *this; - return list.GetFirst(); -} - -dgWorldPluginList::dgListNode* dgWorldPluginList::GetNextPlugin(dgListNode* const plugin) -{ - return plugin->GetNext(); -} - -const char* dgWorldPluginList::GetPluginId(dgListNode* const pluginNode) -{ - dgWorldPluginModulePair entry(pluginNode->GetInfo()); - dgWorldPlugin* const plugin = entry.m_plugin; - return plugin->GetId(); -} - -void dgWorldPluginList::SelectPlugin(dgListNode* const plugin) -{ - m_currentPlugin = plugin; -} diff --git a/thirdparty/src/newton/dgPhysics/dgWorldPlugins.h b/thirdparty/src/newton/dgPhysics/dgWorldPlugins.h deleted file mode 100644 index 3ea4f8711..000000000 --- a/thirdparty/src/newton/dgPhysics/dgWorldPlugins.h +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics> -* -* 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 _DG_WORLD_PLUGINS_H_ -#define _DG_WORLD_PLUGINS_H_ - -class dgWorld; -class dgBodyInfo; -class dgJointInfo; -class dgBodyCluster; - - -class dgWorldPlugin -{ - public: - dgWorldPlugin(dgWorld* const world, dgMemoryAllocator* const allocator) - :m_world(world) - ,m_allocator(allocator) - { - } - - virtual ~dgWorldPlugin() - { - } - - virtual const char* GetId() const = 0; - virtual dgInt32 GetScore() const = 0; - virtual void FlushRegisters() const = 0; - virtual void CalculateJointForces(const dgBodyCluster& cluster, dgBodyInfo* const bodyArray, dgJointInfo* const jointArray, dgFloat32 timestep) = 0; - virtual void SolveDenseLcp(dgInt32 stride, dgInt32 size, const dgFloat32* const matrix, const dgFloat32* const x0, dgFloat32* const x, const dgFloat32* const b, const dgFloat32* const low, const dgFloat32* const high, const dgInt32* const normalIndex) const = 0; - - protected: - dgWorld* m_world; - dgMemoryAllocator* m_allocator; - friend class dgWorld; -}; - -#ifdef __cplusplus -extern "C" -{ - typedef dgWorldPlugin* (*InitPlugin)(dgWorld* const world, dgMemoryAllocator* const allocator); -} -#endif - - -class dgWorldPluginModulePair -{ - public: - dgWorldPluginModulePair (dgWorldPlugin* const plugin, void* module) - :m_plugin(plugin) - ,m_module(module) - { - } - dgWorldPlugin* m_plugin; - void* m_module; -}; - -class dgWorldPluginList: public dgList<dgWorldPluginModulePair> -{ - public: - dgWorldPluginList(dgMemoryAllocator* const allocator); - ~dgWorldPluginList(); - - void LoadPlugins(const char* const path); - void UnloadPlugins(); - - dgListNode* GetFirstPlugin(); - dgListNode* GetCurrentPlugin(); - dgListNode* GetpreferedPlugin(); - dgListNode* GetNextPlugin(dgListNode* const plugin); - const char* GetPluginId(dgListNode* const plugin); - void SelectPlugin(dgListNode* const plugin); - - void FlushRegisters() const - { - if (m_currentPlugin) { - dgWorldPlugin* const plugin = m_currentPlugin->GetInfo().m_plugin; - plugin->FlushRegisters(); - } - } - - private: - void LoadVisualStudioPlugins(const char* const path); - void LoadLinuxPlugins(const char* const path); - - dgListNode* m_currentPlugin; - dgListNode* m_preferedPlugin; -}; - - - - -#endif diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 000000000..3fbbfbcb5 --- /dev/null +++ b/xmake.lua @@ -0,0 +1,185 @@ +local modules = { + Audio = { + Deps = {"NazaraCore"}, + Packages = {"libsndfile"} + }, + Core = {}, + Graphics = { + Deps = {"NazaraRenderer"} + }, + Network = { + Deps = {"NazaraCore"}, + Custom = function() + if is_plat("windows") then + add_syslinks("ws2_32") + end + end + }, + OpenGLRenderer = { + Deps = {"NazaraRenderer"}, + Custom = function() + if is_plat("windows") then + add_syslinks("gdi32", "user32") + else + del_files("src/Nazara/OpenGLRenderer/Wrapper/Win32/**.cpp") + del_files("src/Nazara/OpenGLRenderer/Wrapper/WGL/**.cpp") + end + + if not is_plat("linux") then + del_files("src/Nazara/OpenGLRenderer/Wrapper/Linux/**.cpp") + end + end + }, + Physics2D = { + Deps = {"NazaraUtility"}, + Packages = {"chipmunk2d"} + }, + Physics3D = { + Deps = {"NazaraUtility"}, + Packages = {"newtondynamics"} + }, + Platform = { + Deps = {"NazaraUtility"}, + Packages = {"libsdl"}, + Custom = function() + if is_plat("windows") then + add_defines("SDL_VIDEO_DRIVER_WINDOWS=1") + elseif is_plat("linux") then + add_defines("SDL_VIDEO_DRIVER_X11=1") + add_defines("SDL_VIDEO_DRIVER_WAYLAND=1") + elseif is_plat("macosx") then + add_defines("SDL_VIDEO_DRIVER_COCOA=1") + end + end + }, + Renderer = { + Deps = {"NazaraPlatform", "NazaraShader"} + }, + Shader = { + Deps = {"NazaraUtility"} + }, + Utility = { + Deps = {"stb_image", "NazaraCore"}, + Packages = {"freetype"} + }, + VulkanRenderer = { + Deps = {"NazaraRenderer"}, + Custom = function() + add_defines("VK_NO_PROTOTYPES") + if is_plat("windows") then + add_defines("VK_USE_PLATFORM_WIN32_KHR") + add_syslinks("user32") + elseif is_plat("linux") then + add_defines("VK_USE_PLATFORM_XLIB_KHR") + add_defines("VK_USE_PLATFORM_WAYLAND_KHR") + elseif is_plat("macosx") then + add_defines("VK_USE_PLATFORM_MACOS_MVK") + end + end + } +} + +add_requires("assimp", "chipmunk2d", "libsndfile") +add_requires("freetype", "libsdl", { configs = { shared = true }}) +add_requires("newtondynamics", { debug = is_mode("debug") }) + +set_project("NazaraEngine") + +add_rules("mode.debug", "mode.releasedbg") +add_rules("plugin.vsxmake.autoupdate") + +if is_mode("debug") then + add_rules("debug_suffix") +end + +add_includedirs("include") +add_sysincludedirs("thirdparty/include") + +set_languages("c89", "cxx17") +set_rundir("./bin/$(os)_$(arch)_$(mode)") +set_runtimes(is_mode("debug") and "MDd" or "MD") +set_symbols("debug", "hidden") +set_targetdir("./bin/$(os)_$(arch)_$(mode)") +set_warnings("allextra") + +if is_mode("releasedbg") then + set_fpmodels("fast") + add_vectorexts("sse", "sse2", "sse3", "ssse3") +end + +if is_plat("windows") then + add_defines("_CRT_SECURE_NO_WARNINGS") + add_cxxflags("/bigobj", "/permissive-", "/Zc:__cplusplus", "/Zc:referenceBinding", "/Zc:throwingNew") + add_cxxflags("/FC") + add_cxflags("/w44062") -- Enable warning: switch case not handled + add_cxflags("/wd4251") -- Disable warning: class needs to have dll-interface to be used by clients of class blah blah blah +end + +target("stb_image") + set_kind("static") + set_group("Thirdparties") + add_files("thirdparty/src/stb/*.cpp") + +for name, module in pairs(modules) do + target("Nazara" .. name) + set_kind("shared") + set_group("Modules") + + if module.Deps then + add_deps(module.Deps) + end + + if module.Packages then + add_packages(module.Packages) + end + + add_defines("NAZARA_BUILD") + add_defines("NAZARA_" .. name:upper() .. "_BUILD") + + if is_mode("debug") then + add_defines("NAZARA_DEBUG") + add_defines("NAZARA_" .. name:upper() .. "_BUILD") + end + + add_headerfiles("include/Nazara/" .. name .. "/**.hpp") + add_headerfiles("include/Nazara/" .. name .. "/**.inl") + add_files("src/Nazara/" .. name .. "/**.cpp") + add_includedirs("src") + + if is_plat("windows") then + del_files("src/Nazara/" .. name .. "/Posix/**.cpp") + else + del_files("src/Nazara/" .. name .. "/Win32/**.cpp") + end + + if not is_plat("linux") then + del_files("src/Nazara/" .. name .. "/Linux/**.cpp") + end + + if module.Custom then + module.Custom() + end +end + +target("PluginAssimp") + set_kind("shared") + set_group("Plugins") + + add_deps("NazaraUtility") + add_packages("assimp") + + add_headerfiles("plugins/Assimp/**.hpp") + add_headerfiles("plugins/Assimp/**.inl") + add_includedirs("plugins/Assimp") + add_files("plugins/Assimp/**.cpp") + +target_end() + +includes("examples/*/xmake.lua") + +rule("debug_suffix") + on_load(function (target) + if target:kind() ~= "binary" then + target:set("basename", target:basename() .. "-d") + end + end)